Bytes_moved accounting fix and accounting cleanup
Bytes_moved should be incremented by the correct number of bytes needed
for the space the object is allocated in, not the number of bytes it
would take in region space.
Various minor cleanups for code that I found hard to read while
attempting to track this down.
Remove a CHECK that held only because of the incorrect accounting.
It now results in TreeHugger test failures.
Bug: 79921586
Test: Build and boot AOSP.
Change-Id: Iab75d271eb5b9812a127e708cf6b567d0c4c16f1
diff --git a/runtime/gc/heap.cc b/runtime/gc/heap.cc
index 532b3ef..59d7953 100644
--- a/runtime/gc/heap.cc
+++ b/runtime/gc/heap.cc
@@ -1613,8 +1613,8 @@
void Heap::RecordFree(uint64_t freed_objects, int64_t freed_bytes) {
// Use signed comparison since freed bytes can be negative when background compaction foreground
- // transitions occurs. This is caused by the moving objects from a bump pointer space to a
- // free list backed space typically increasing memory footprint due to padding and binning.
+ // transitions occurs. This is typically due to objects moving from a bump pointer space to a
+ // free list backed space, which may increase memory footprint due to padding and binning.
RACING_DCHECK_LE(freed_bytes,
static_cast<int64_t>(num_bytes_allocated_.load(std::memory_order_relaxed)));
// Note: This relies on 2s complement for handling negative freed_bytes.