Shared single GC iteration accounting for all GCs.
Previously, each garbage collector had data that was only used
during collection. Since only one collector can be running at any
given time, we can make this data be shared between all collectors.
This reduces memory usage since we don't need to have redundant
information for each GC types. Also reduced how much code is required
to sweep spaces.
Bug: 9969166
Change-Id: I31caf0ee4d572f75e0c66863fe7db12c08ae08e7
diff --git a/runtime/gc/space/large_object_space.cc b/runtime/gc/space/large_object_space.cc
index 54a63f0..abae8ff 100644
--- a/runtime/gc/space/large_object_space.cc
+++ b/runtime/gc/space/large_object_space.cc
@@ -411,28 +411,24 @@
bitmap->Clear(ptrs[i]);
}
}
- context->freed_objects += num_ptrs;
- context->freed_bytes += space->FreeList(self, num_ptrs, ptrs);
+ context->freed.objects += num_ptrs;
+ context->freed.bytes += space->FreeList(self, num_ptrs, ptrs);
}
-void LargeObjectSpace::Sweep(bool swap_bitmaps, size_t* out_freed_objects,
- size_t* out_freed_bytes) {
+collector::ObjectBytePair LargeObjectSpace::Sweep(bool swap_bitmaps) {
if (Begin() >= End()) {
- return;
+ return collector::ObjectBytePair(0, 0);
}
accounting::LargeObjectBitmap* live_bitmap = GetLiveBitmap();
accounting::LargeObjectBitmap* mark_bitmap = GetMarkBitmap();
if (swap_bitmaps) {
std::swap(live_bitmap, mark_bitmap);
}
- DCHECK(out_freed_objects != nullptr);
- DCHECK(out_freed_bytes != nullptr);
- SweepCallbackContext scc(swap_bitmaps, this);
+ AllocSpace::SweepCallbackContext scc(swap_bitmaps, this);
accounting::LargeObjectBitmap::SweepWalk(*live_bitmap, *mark_bitmap,
reinterpret_cast<uintptr_t>(Begin()),
reinterpret_cast<uintptr_t>(End()), SweepCallback, &scc);
- *out_freed_objects += scc.freed_objects;
- *out_freed_bytes += scc.freed_bytes;
+ return scc.freed;
}
} // namespace space