From dcf8d7283bd51714f3faa55b631ae4103dc98b51 Mon Sep 17 00:00:00 2001 From: Mathieu Chartier Date: Thu, 2 Aug 2012 14:55:54 -0700 Subject: Fix zygote live/mark bitmap size. Fixed some errors with the sizes of mark/live bitmaps after zygote space creation. This was causing us to occasionally have overlapping mark/live bitmaps. Added a new verify objects mode called VERIFY_OBJECT_FAST which only checks objects and not their classes. Refactored/optimized some of the scanning code to use xor to clear bits instead of and+not. Change-Id: Iec87d9157f69e6a558e300950b51d8781679e3f7 --- src/space_bitmap.h | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'src/space_bitmap.h') diff --git a/src/space_bitmap.h b/src/space_bitmap.h index 1e8a9a776b..adf1996afe 100644 --- a/src/space_bitmap.h +++ b/src/space_bitmap.h @@ -60,7 +60,7 @@ class SpaceBitmap { // Pack the bits in backwards so they come out in address order when using CLZ. static word OffsetToMask(uintptr_t offset_) { - return 1 << (kBitsPerWord - 1 - (offset_ / kAlignment) % kBitsPerWord); + return static_cast(kWordHighBitMask) >> ((offset_ / kAlignment) % kBitsPerWord); } inline void Set(const Object* obj) { @@ -119,8 +119,7 @@ class SpaceBitmap { size_t word_start = bit_index_start / kBitsPerWord; size_t word_end = bit_index_end / kBitsPerWord; - - const size_t high_bit = 1 << (kBitsPerWord - 1); + DCHECK_LT(word_end * kWordSize, Size()); // Trim off left_bits of left bits. size_t edge_word = bitmap_begin_[word_start]; @@ -138,7 +137,7 @@ class SpaceBitmap { const size_t shift = CLZ(edge_word); Object* obj = reinterpret_cast(ptr_base + shift * kAlignment); visitor(obj); - edge_word &= ~(high_bit >> shift); + edge_word ^= static_cast(kWordHighBitMask) >> shift; } while (edge_word != 0); } word_start++; @@ -151,7 +150,7 @@ class SpaceBitmap { const size_t shift = CLZ(w); Object* obj = reinterpret_cast(ptr_base + shift * kAlignment); visitor(obj); - w &= ~(high_bit >> shift); + w ^= static_cast(kWordHighBitMask) >> shift; } while (w != 0); } } @@ -169,10 +168,10 @@ class SpaceBitmap { edge_word &= ~((1 << trim_bits) - 1); uintptr_t ptr_base = IndexToOffset(word_end) + heap_begin_; while (edge_word != 0) { - const int shift = CLZ(edge_word); + const size_t shift = CLZ(edge_word); Object* obj = reinterpret_cast(ptr_base + shift * kAlignment); visitor(obj); - edge_word &= ~(high_bit >> shift); + edge_word ^= static_cast(kWordHighBitMask) >> shift; } } @@ -202,11 +201,17 @@ class SpaceBitmap { return IndexToOffset(Size() / kWordSize); } - uintptr_t HeapBegin() { + uintptr_t HeapBegin() const { return heap_begin_; } - void Trim(size_t heap_capcity); + // The maximum address which the bitmap can span. (HeapBegin() <= object < HeapLimit()). + uintptr_t HeapLimit() const { + return HeapBegin() + static_cast(HeapSize()); + } + + // Set the max address which can covered by the bitmap. + void SetHeapLimit(uintptr_t new_end); private: // TODO: heap_end_ is initialized so that the heap bitmap is empty, this doesn't require the -1, -- cgit v1.2.3-59-g8ed1b