Chromium Code Reviews| Index: src/heap/mark-compact.cc |
| diff --git a/src/heap/mark-compact.cc b/src/heap/mark-compact.cc |
| index 49bf1040b0bbc8270470717cb2ed9878042a6e07..d84c20e94e482c6e70562ca9766e56abbf6f9418 100644 |
| --- a/src/heap/mark-compact.cc |
| +++ b/src/heap/mark-compact.cc |
| @@ -290,17 +290,67 @@ void MarkCompactCollector::ClearInvalidStoreAndSlotsBufferEntries() { |
| int number_of_pages = evacuation_candidates_.length(); |
| for (int i = 0; i < number_of_pages; i++) { |
| Page* p = evacuation_candidates_[i]; |
| - SlotsBuffer::RemoveInvalidSlots(heap_, p->slots_buffer()); |
| + ClearInvalidSlotsBufferEntries(p->slots_buffer()); |
| + } |
| +} |
| + |
| + |
| +void MarkCompactCollector::ClearInvalidSlotsBufferEntries(SlotsBuffer* buffer) { |
| + // Remove entries by replacing them with an old-space slot containing a smi |
| + // that is located in an unmovable page. |
| + const SlotsBuffer::ObjectSlot kRemovedEntry = HeapObject::RawField( |
| + heap_->empty_fixed_array(), FixedArrayBase::kLengthOffset); |
| + DCHECK(Page::FromAddress(reinterpret_cast<Address>(kRemovedEntry)) |
| + ->NeverEvacuate()); |
| + |
| + while (buffer != NULL) { |
| + for (int slot_idx = 0; slot_idx < buffer->Size(); ++slot_idx) { |
| + SlotsBuffer::ObjectSlot slot = buffer->Get(slot_idx); |
| + if (!SlotsBuffer::IsTypedSlot(slot)) { |
| + Object* object = *slot; |
| + if ((object->IsHeapObject() && heap_->InNewSpace(object)) || |
| + !heap_->mark_compact_collector()->IsSlotInLiveObject( |
| + reinterpret_cast<Address>(slot))) { |
| + buffer->Set(slot_idx, kRemovedEntry); |
| + } |
| + } else { |
| + ++slot_idx; |
| + DCHECK(slot_idx < buffer->Size()); |
| + } |
| + } |
| + buffer = buffer->next(); |
| } |
| } |
| #ifdef VERIFY_HEAP |
| +void VerifySlots(Heap* heap, SlotsBuffer* buffer) { |
| + while (buffer != NULL) { |
| + for (int slot_idx = 0; slot_idx < buffer->Size(); ++slot_idx) { |
| + SlotsBuffer::ObjectSlot slot = buffer->Get(slot_idx); |
| + if (!SlotsBuffer::IsTypedSlot(slot)) { |
| + Object* object = *slot; |
| + if (object->IsHeapObject()) { |
| + HeapObject* heap_object = HeapObject::cast(object); |
| + CHECK(!heap->InNewSpace(object)); |
| + heap->mark_compact_collector()->VerifyIsSlotInLiveObject( |
| + reinterpret_cast<Address>(slot), heap_object); |
| + } |
| + } else { |
| + ++slot_idx; |
| + DCHECK(slot_idx < buffer->Size()); |
| + } |
| + } |
| + buffer = buffer->next(); |
| + } |
| +} |
| + |
| + |
| static void VerifyValidSlotsBufferEntries(Heap* heap, PagedSpace* space) { |
| PageIterator it(space); |
| while (it.has_next()) { |
| Page* p = it.next(); |
| - SlotsBuffer::VerifySlots(heap, p->slots_buffer()); |
| + VerifySlots(heap, p->slots_buffer()); |
| } |
| } |
| @@ -311,12 +361,6 @@ static void VerifyValidStoreAndSlotsBufferEntries(Heap* heap) { |
| VerifyValidSlotsBufferEntries(heap, heap->old_space()); |
| VerifyValidSlotsBufferEntries(heap, heap->code_space()); |
| VerifyValidSlotsBufferEntries(heap, heap->map_space()); |
| - |
| - LargeObjectIterator it(heap->lo_space()); |
|
Michael Lippautz
2015/08/18 09:22:05
\o/
|
| - for (HeapObject* object = it.Next(); object != NULL; object = it.Next()) { |
| - MemoryChunk* chunk = MemoryChunk::FromAddress(object->address()); |
| - SlotsBuffer::VerifySlots(heap, chunk->slots_buffer()); |
| - } |
| } |
| #endif |
| @@ -4468,37 +4512,6 @@ bool SlotsBuffer::AddTo(SlotsBufferAllocator* allocator, |
| } |
| -void SlotsBuffer::RemoveInvalidSlots(Heap* heap, SlotsBuffer* buffer) { |
| - // Remove entries by replacing them with an old-space slot containing a smi |
| - // that is located in an unmovable page. |
| - const ObjectSlot kRemovedEntry = HeapObject::RawField( |
| - heap->empty_fixed_array(), FixedArrayBase::kLengthOffset); |
| - DCHECK(Page::FromAddress(reinterpret_cast<Address>(kRemovedEntry)) |
| - ->NeverEvacuate()); |
| - |
| - while (buffer != NULL) { |
| - SlotsBuffer::ObjectSlot* slots = buffer->slots_; |
| - intptr_t slots_count = buffer->idx_; |
| - |
| - for (int slot_idx = 0; slot_idx < slots_count; ++slot_idx) { |
| - ObjectSlot slot = slots[slot_idx]; |
| - if (!IsTypedSlot(slot)) { |
| - Object* object = *slot; |
| - if ((object->IsHeapObject() && heap->InNewSpace(object)) || |
| - !heap->mark_compact_collector()->IsSlotInLiveObject( |
| - reinterpret_cast<Address>(slot))) { |
| - slots[slot_idx] = kRemovedEntry; |
| - } |
| - } else { |
| - ++slot_idx; |
| - DCHECK(slot_idx < slots_count); |
| - } |
| - } |
| - buffer = buffer->next(); |
| - } |
| -} |
| - |
| - |
| void SlotsBuffer::RemoveObjectSlots(Heap* heap, SlotsBuffer* buffer, |
| Address start_slot, Address end_slot) { |
| // Remove entries by replacing them with an old-space slot containing a smi |
| @@ -4534,31 +4547,6 @@ void SlotsBuffer::RemoveObjectSlots(Heap* heap, SlotsBuffer* buffer, |
| } |
| -void SlotsBuffer::VerifySlots(Heap* heap, SlotsBuffer* buffer) { |
| - while (buffer != NULL) { |
| - SlotsBuffer::ObjectSlot* slots = buffer->slots_; |
| - intptr_t slots_count = buffer->idx_; |
| - |
| - for (int slot_idx = 0; slot_idx < slots_count; ++slot_idx) { |
| - ObjectSlot slot = slots[slot_idx]; |
| - if (!IsTypedSlot(slot)) { |
| - Object* object = *slot; |
| - if (object->IsHeapObject()) { |
| - HeapObject* heap_object = HeapObject::cast(object); |
| - CHECK(!heap->InNewSpace(object)); |
| - heap->mark_compact_collector()->VerifyIsSlotInLiveObject( |
| - reinterpret_cast<Address>(slot), heap_object); |
| - } |
| - } else { |
| - ++slot_idx; |
| - DCHECK(slot_idx < slots_count); |
| - } |
| - } |
| - buffer = buffer->next(); |
| - } |
| -} |
| - |
| - |
| static inline SlotsBuffer::SlotType SlotTypeForRMode(RelocInfo::Mode rmode) { |
| if (RelocInfo::IsCodeTarget(rmode)) { |
| return SlotsBuffer::CODE_TARGET_SLOT; |