Fix heap bitmap rounding down size error
Fixed an error where we rounded down heap bitmap sizes which resulted in occasional check failures when we modified/tested bits belonging to objects near the end of the heap.
Added a regression test for this fix.
Change-Id: If061a26436beacee235ef74f9b39d05e66204bde
diff --git a/src/heap_test.cc b/src/heap_test.cc
index 0077a77..d5c07da 100644
--- a/src/heap_test.cc
+++ b/src/heap_test.cc
@@ -45,4 +45,11 @@
Runtime::Current()->GetHeap()->CollectGarbage(false);
}
+TEST_F(HeapTest, HeapBitmapCapacityTest) {
+ byte* heap_begin = reinterpret_cast<byte*>(0x1000);
+ const size_t heap_capacity = HeapBitmap::kAlignment * (sizeof(intptr_t) * 8 + 1);
+ UniquePtr<HeapBitmap> bitmap(HeapBitmap::Create("test-bitmap", heap_begin, heap_capacity));
+ bitmap->Set(reinterpret_cast<const Object*>(&heap_begin[heap_capacity - HeapBitmap::kAlignment]));
+}
+
} // namespace art