From 61c9cb5ab3137bfd61d42bc6d38c2e3ba9110bd1 Mon Sep 17 00:00:00 2001 From: Mathieu Chartier Date: Tue, 3 Jul 2012 14:39:54 -0700 Subject: 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 --- src/heap_bitmap.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/heap_bitmap.cc') diff --git a/src/heap_bitmap.cc b/src/heap_bitmap.cc index 769ee9d602..fc722f5dd4 100644 --- a/src/heap_bitmap.cc +++ b/src/heap_bitmap.cc @@ -24,7 +24,8 @@ namespace art { HeapBitmap* HeapBitmap::Create(const char* name, byte* heap_begin, size_t heap_capacity) { CHECK(heap_begin != NULL); - size_t bitmap_size = HB_OFFSET_TO_INDEX(heap_capacity) * kWordSize; + // Round up since heap_capacity is not necessarily a multiple of kAlignment * kBitsPerWord. + size_t bitmap_size = HB_OFFSET_TO_INDEX(RoundUp(heap_capacity, kAlignment * kBitsPerWord)) * kWordSize; UniquePtr mem_map(MemMap::MapAnonymous(name, NULL, bitmap_size, PROT_READ | PROT_WRITE)); if (mem_map.get() == NULL) { LOG(ERROR) << "Failed to allocate bitmap " << name; -- cgit v1.2.3-59-g8ed1b