Fix GarbageCollector to work with VERIFY_OBJECT_ENABLED
There were two problems with the GC:
1.) roots were being missed for most of the C++ fields
2.) Heap::RecordFree(Object) was not being called, only Space::Free
To solve #1, added all C++ shadow fields to libcore.
This involed updating dalvik to cope with the new sizes and offsets.
This had the positive side effect of allowing a lot of special cases
in the object scanning and image writing.
To solve #2, added a call to the now public Heap::RecordFree from MarkSweep
Given the now better working GC:
- Reenabled HeapTest.GarbageCollectClassLinkerInit which is now passing.
- ImageWriter now GC's before writing an image to avoid garbage.
Change-Id: Ie7d1cc89e0bcf314cb37f0cabcb8593bf6e4d4be
diff --git a/src/heap.h b/src/heap.h
index 4922207..3dc612a 100644
--- a/src/heap.h
+++ b/src/heap.h
@@ -134,13 +134,14 @@
verify_object_disabled_ = true;
}
+ static void RecordFree(Space* space, const Object* object);
+
private:
// Allocates uninitialized storage.
static Object* Allocate(size_t num_bytes);
static Object* Allocate(Space* space, size_t num_bytes);
static void RecordAllocation(Space* space, const Object* object);
- static void RecordFree(Space* space, const Object* object);
static void RecordImageAllocations(Space* space);
static void CollectGarbageInternal();