Fix SweepSystemWeaks not checking the correct bitmaps due to bitmap swapping.
This error was causing GCs to occasionally free weak objects which were still in use (Monitors, etc..).
Change-Id: I2f4cfee1e76f2bb01d745ec8316774205f69c42f
diff --git a/src/mark_sweep.h b/src/mark_sweep.h
index 108da87..189462f 100644
--- a/src/mark_sweep.h
+++ b/src/mark_sweep.h
@@ -99,10 +99,14 @@
return heap_->GetMarkBitmap()->Test(object);
}
- static bool IsMarked(const Object* object, void* arg) {
+ static bool IsMarkedCallback(const Object* object, void* arg) {
return reinterpret_cast<MarkSweep*>(arg)->IsMarked(object);
}
+ static bool IsLiveCallback(const Object* object, void* arg) {
+ return reinterpret_cast<MarkSweep*>(arg)->GetHeap()->GetLiveBitmap()->Test(object);
+ }
+
static void MarkObjectVisitor(const Object* root, void* arg);
static void ReMarkObjectVisitor(const Object* root, void* arg);
@@ -250,8 +254,8 @@
Object** finalizer_references,
Object** phantom_references);
- void SweepSystemWeaks();
- void SweepJniWeakGlobals();
+ void SweepSystemWeaks(bool swap_bitmaps);
+ void SweepJniWeakGlobals(HeapBitmap* bitmap);
// Current space, we check this space first to avoid searching for the appropriate space for an object.
SpaceBitmap* current_mark_bitmap_;