Refactor and optimize GC code.
Fixed the reference cache mod union table, and re-enabled it by
default. Added a boolean flag to count how many null objects,
immune, fast path, slow path objects we marked.
Slight speedup in mark stack processing, large speedup in image mod
union table scanning.
EvaluateAndApplyChanges Before:
Process mark stack time for full GC only:
12.464089s, 12.357870s, 12.538028s
Time spent marking mod image union table ~240ms.
After:
Process mark stack time: 12.299375s, 12.217142s, 12.187076s
Time spent marking mod image union table ~40ms.
TODO: Refactor reference visiting logic into mirror::Object.
Change-Id: I91889ded9d3f2bf127bc0051c1b1ff77e792e94f
diff --git a/runtime/gc/accounting/heap_bitmap.h b/runtime/gc/accounting/heap_bitmap.h
index 7cfeb63..b23b12e 100644
--- a/runtime/gc/accounting/heap_bitmap.h
+++ b/runtime/gc/accounting/heap_bitmap.h
@@ -31,12 +31,9 @@
class HeapBitmap {
public:
- typedef std::vector<SpaceBitmap*, GcAllocator<SpaceBitmap*> > SpaceBitmapVector;
- typedef std::vector<ObjectSet*, GcAllocator<ObjectSet*> > ObjectSetVector;
-
bool Test(const mirror::Object* obj) SHARED_LOCKS_REQUIRED(Locks::heap_bitmap_lock_) {
SpaceBitmap* bitmap = GetContinuousSpaceBitmap(obj);
- if (LIKELY(bitmap != NULL)) {
+ if (LIKELY(bitmap != nullptr)) {
return bitmap->Test(obj);
} else {
return GetDiscontinuousSpaceObjectSet(obj) != NULL;
@@ -71,7 +68,7 @@
return bitmap;
}
}
- return NULL;
+ return nullptr;
}
ObjectSet* GetDiscontinuousSpaceObjectSet(const mirror::Object* obj) {
@@ -80,7 +77,7 @@
return space_set;
}
}
- return NULL;
+ return nullptr;
}
void Walk(ObjectCallback* callback, void* arg)
@@ -110,10 +107,10 @@
void RemoveDiscontinuousObjectSet(ObjectSet* set);
// Bitmaps covering continuous spaces.
- SpaceBitmapVector continuous_space_bitmaps_;
+ std::vector<SpaceBitmap*, GcAllocator<SpaceBitmap*>> continuous_space_bitmaps_;
// Sets covering discontinuous spaces.
- ObjectSetVector discontinuous_space_sets_;
+ std::vector<ObjectSet*, GcAllocator<ObjectSet*>> discontinuous_space_sets_;
friend class art::gc::Heap;
};