| Index: src/heap/spaces.cc
|
| diff --git a/src/heap/spaces.cc b/src/heap/spaces.cc
|
| index d322916a5dc0a9cbc2957f961f407f11976d32b2..85815a0e32577a0446a13b46bb40b37f9096e71d 100644
|
| --- a/src/heap/spaces.cc
|
| +++ b/src/heap/spaces.cc
|
| @@ -538,12 +538,13 @@ MemoryChunk* MemoryChunk::Initialize(Heap* heap, Address base, size_t size,
|
| chunk->mutex_ = new base::Mutex();
|
| chunk->available_in_free_list_ = 0;
|
| chunk->wasted_memory_ = 0;
|
| - chunk->ClearLiveness();
|
| chunk->young_generation_bitmap_ = nullptr;
|
| chunk->set_next_chunk(nullptr);
|
| chunk->set_prev_chunk(nullptr);
|
| chunk->local_tracker_ = nullptr;
|
|
|
| + MarkingState::Internal(chunk).ClearLiveness();
|
| +
|
| DCHECK(OFFSET_OF(MemoryChunk, flags_) == kFlagsOffset);
|
|
|
| if (executable == EXECUTABLE) {
|
| @@ -854,9 +855,10 @@ void Page::CreateBlackArea(Address start, Address end) {
|
| DCHECK_EQ(Page::FromAddress(start), this);
|
| DCHECK_NE(start, end);
|
| DCHECK_EQ(Page::FromAddress(end - 1), this);
|
| - markbits()->SetRange(AddressToMarkbitIndex(start),
|
| - AddressToMarkbitIndex(end));
|
| - IncrementLiveBytes(static_cast<int>(end - start));
|
| + MarkingState::Internal(this).bitmap()->SetRange(AddressToMarkbitIndex(start),
|
| + AddressToMarkbitIndex(end));
|
| + MarkingState::Internal(this).IncrementLiveBytes(
|
| + static_cast<int>(end - start));
|
| }
|
|
|
| void MemoryAllocator::PartialFreeMemory(MemoryChunk* chunk,
|
| @@ -1196,15 +1198,6 @@ void MemoryChunk::ReleaseYoungGenerationBitmap() {
|
| young_generation_bitmap_ = nullptr;
|
| }
|
|
|
| -template <MarkingMode mode>
|
| -void MemoryChunk::ClearLiveness() {
|
| - markbits<mode>()->Clear();
|
| - ResetLiveBytes<mode>();
|
| -}
|
| -
|
| -template void MemoryChunk::ClearLiveness<MarkingMode::FULL>();
|
| -template void MemoryChunk::ClearLiveness<MarkingMode::YOUNG_GENERATION>();
|
| -
|
| // -----------------------------------------------------------------------------
|
| // PagedSpace implementation
|
|
|
| @@ -1420,9 +1413,11 @@ void PagedSpace::EmptyAllocationInfo() {
|
|
|
| // Clear the bits in the unused black area.
|
| if (current_top != current_limit) {
|
| - page->markbits()->ClearRange(page->AddressToMarkbitIndex(current_top),
|
| - page->AddressToMarkbitIndex(current_limit));
|
| - page->IncrementLiveBytes(-static_cast<int>(current_limit - current_top));
|
| + MarkingState::Internal(page).bitmap()->ClearRange(
|
| + page->AddressToMarkbitIndex(current_top),
|
| + page->AddressToMarkbitIndex(current_limit));
|
| + MarkingState::Internal(page).IncrementLiveBytes(
|
| + -static_cast<int>(current_limit - current_top));
|
| }
|
| }
|
|
|
| @@ -1436,7 +1431,7 @@ void PagedSpace::IncreaseCapacity(size_t bytes) {
|
| }
|
|
|
| void PagedSpace::ReleasePage(Page* page) {
|
| - DCHECK_EQ(page->LiveBytes(), 0);
|
| + DCHECK_EQ(0, MarkingState::Internal(page).live_bytes());
|
| DCHECK_EQ(page->owner(), this);
|
|
|
| free_list_.EvictFreeListItems(page);
|
| @@ -1497,14 +1492,14 @@ void PagedSpace::Verify(ObjectVisitor* visitor) {
|
| // All the interior pointers should be contained in the heap.
|
| int size = object->Size();
|
| object->IterateBody(map->instance_type(), size, visitor);
|
| - if (ObjectMarking::IsBlack(object)) {
|
| + if (ObjectMarking::IsBlack(object, MarkingState::Internal(object))) {
|
| black_size += size;
|
| }
|
|
|
| CHECK(object->address() + size <= top);
|
| end_of_previous_object = object->address() + size;
|
| }
|
| - CHECK_LE(black_size, page->LiveBytes());
|
| + CHECK_LE(black_size, MarkingState::Internal(page).live_bytes());
|
| }
|
| CHECK(allocation_pointer_found_in_space);
|
| }
|
| @@ -1637,7 +1632,7 @@ bool SemiSpace::EnsureCurrentCapacity() {
|
| if (current_page == nullptr) return false;
|
| DCHECK_NOT_NULL(current_page);
|
| current_page->InsertAfter(anchor());
|
| - current_page->ClearLiveness();
|
| + MarkingState::Internal(current_page).ClearLiveness();
|
| current_page->SetFlags(anchor()->prev_page()->GetFlags(),
|
| static_cast<uintptr_t>(Page::kCopyAllFlags));
|
| heap()->CreateFillerObjectAt(current_page->area_start(),
|
| @@ -1709,7 +1704,7 @@ void NewSpace::ResetAllocationInfo() {
|
| UpdateAllocationInfo();
|
| // Clear all mark-bits in the to-space.
|
| for (Page* p : to_space_) {
|
| - p->ClearLiveness();
|
| + MarkingState::Internal(p).ClearLiveness();
|
| }
|
| InlineAllocationStep(old_top, allocation_info_.top(), nullptr, 0);
|
| }
|
| @@ -2010,7 +2005,7 @@ bool SemiSpace::GrowTo(size_t new_capacity) {
|
| return false;
|
| }
|
| new_page->InsertAfter(last_page);
|
| - new_page->ClearLiveness();
|
| + MarkingState::Internal(new_page).ClearLiveness();
|
| // Duplicate the flags that was set on the old page.
|
| new_page->SetFlags(last_page->GetFlags(), Page::kCopyOnFlipFlagsMask);
|
| last_page = new_page;
|
| @@ -2071,7 +2066,7 @@ void SemiSpace::FixPagesFlags(intptr_t flags, intptr_t mask) {
|
| page->ClearFlag(MemoryChunk::IN_FROM_SPACE);
|
| page->SetFlag(MemoryChunk::IN_TO_SPACE);
|
| page->ClearFlag(MemoryChunk::NEW_SPACE_BELOW_AGE_MARK);
|
| - page->ResetLiveBytes();
|
| + MarkingState::Internal(page).SetLiveBytes(0);
|
| } else {
|
| page->SetFlag(MemoryChunk::IN_FROM_SPACE);
|
| page->ClearFlag(MemoryChunk::IN_TO_SPACE);
|
| @@ -3044,7 +3039,7 @@ AllocationResult LargeObjectSpace::AllocateRaw(int object_size,
|
| ClearRecordedSlots::kNo);
|
|
|
| if (heap()->incremental_marking()->black_allocation()) {
|
| - ObjectMarking::WhiteToBlack(object);
|
| + ObjectMarking::WhiteToBlack(object, MarkingState::Internal(object));
|
| }
|
| return object;
|
| }
|
| @@ -3091,13 +3086,14 @@ LargePage* LargeObjectSpace::FindPage(Address a) {
|
| void LargeObjectSpace::ClearMarkingStateOfLiveObjects() {
|
| LargeObjectIterator it(this);
|
| for (HeapObject* obj = it.Next(); obj != NULL; obj = it.Next()) {
|
| - if (ObjectMarking::IsBlackOrGrey(obj)) {
|
| - Marking::MarkWhite(ObjectMarking::MarkBitFrom(obj));
|
| + if (ObjectMarking::IsBlackOrGrey(obj, MarkingState::Internal(obj))) {
|
| + Marking::MarkWhite(
|
| + ObjectMarking::MarkBitFrom(obj, MarkingState::Internal(obj)));
|
| MemoryChunk* chunk = MemoryChunk::FromAddress(obj->address());
|
| chunk->ResetProgressBar();
|
| - chunk->ResetLiveBytes();
|
| + MarkingState::Internal(chunk).SetLiveBytes(0);
|
| }
|
| - DCHECK(ObjectMarking::IsWhite(obj));
|
| + DCHECK(ObjectMarking::IsWhite(obj, MarkingState::Internal(obj)));
|
| }
|
| }
|
|
|
| @@ -3139,8 +3135,8 @@ void LargeObjectSpace::FreeUnmarkedObjects() {
|
| LargePage* current = first_page_;
|
| while (current != NULL) {
|
| HeapObject* object = current->GetObject();
|
| - DCHECK(!ObjectMarking::IsGrey(object));
|
| - if (ObjectMarking::IsBlack(object)) {
|
| + DCHECK(!ObjectMarking::IsGrey(object, MarkingState::Internal(object)));
|
| + if (ObjectMarking::IsBlack(object, MarkingState::Internal(object))) {
|
| Address free_start;
|
| if ((free_start = current->GetAddressToShrink()) != 0) {
|
| // TODO(hpayer): Perform partial free concurrently.
|
| @@ -3276,7 +3272,8 @@ void Page::Print() {
|
| unsigned mark_size = 0;
|
| for (HeapObject* object = objects.Next(); object != NULL;
|
| object = objects.Next()) {
|
| - bool is_marked = ObjectMarking::IsBlackOrGrey(object);
|
| + bool is_marked =
|
| + ObjectMarking::IsBlackOrGrey(object, MarkingState::Internal(object));
|
| PrintF(" %c ", (is_marked ? '!' : ' ')); // Indent a little.
|
| if (is_marked) {
|
| mark_size += object->Size();
|
| @@ -3285,7 +3282,8 @@ void Page::Print() {
|
| PrintF("\n");
|
| }
|
| printf(" --------------------------------------\n");
|
| - printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes());
|
| + printf(" Marked: %x, LiveCount: %" V8PRIdPTR "\n", mark_size,
|
| + MarkingState::Internal(this).live_bytes());
|
| }
|
|
|
| #endif // DEBUG
|
|
|