Chromium Code Reviews| Index: src/mark-compact-inl.h |
| diff --git a/src/mark-compact-inl.h b/src/mark-compact-inl.h |
| index a42e0f7f12eed9e1ba4caae546f0c5a9ea35ae3b..1777097251a984bd5adf1949d09b305279bbf82f 100644 |
| --- a/src/mark-compact-inl.h |
| +++ b/src/mark-compact-inl.h |
| @@ -86,7 +86,8 @@ void MarkCompactCollector::RecordSlot(Object** anchor_slot, |
| Page* object_page = Page::FromAddress(reinterpret_cast<Address>(object)); |
| if (object_page->IsEvacuationCandidate() && |
| !ShouldSkipEvacuationSlotRecording(anchor_slot)) { |
| - if (!SlotsBuffer::AddTo(&slots_buffer_allocator_, |
| + if (!SlotsBuffer::AddTo(heap_, |
| + &slots_buffer_allocator_, |
| object_page->slots_buffer_address(), |
| slot, |
| mode)) { |
| @@ -96,6 +97,55 @@ void MarkCompactCollector::RecordSlot(Object** anchor_slot, |
| } |
| +bool SlotsBuffer::AddTo(Heap* heap, |
| + SlotsBufferAllocator* allocator, |
| + SlotsBuffer** buffer_address, |
| + ObjectSlot slot, |
| + AdditionMode mode) { |
| + ASSERT(!heap->mark_compact_collector()->IsInsideEvacuationScope() || |
| + mode == IGNORE_OVERFLOW); |
| + ASSERT(heap->mark_compact_collector()->IsInsideEvacuationScope() || |
| + mode == FAIL_ON_OVERFLOW); |
|
Michael Starzinger
2014/03/06 10:47:25
This invariant can be expressed in one expression
|
| + SlotsBuffer* buffer = *buffer_address; |
| + if (buffer == NULL || buffer->IsFull()) { |
| + if (mode == FAIL_ON_OVERFLOW && ChainLengthThresholdReached(buffer)) { |
| + allocator->DeallocateChain(buffer_address); |
| + return false; |
| + } |
| + buffer = allocator->AllocateBuffer(heap, buffer); |
| + *buffer_address = buffer; |
| + } |
| + buffer->Add(slot); |
| + return true; |
| +} |
| + |
| + |
| +bool SlotsBuffer::AddTo(Heap* heap, |
| + SlotsBufferAllocator* allocator, |
| + SlotsBuffer** buffer_address, |
| + SlotType type, |
| + Address addr, |
| + AdditionMode mode) { |
| + ASSERT(!heap->mark_compact_collector()->IsInsideEvacuationScope() || |
| + mode == IGNORE_OVERFLOW); |
| + ASSERT(heap->mark_compact_collector()->IsInsideEvacuationScope() || |
| + mode == FAIL_ON_OVERFLOW); |
|
Michael Starzinger
2014/03/06 10:47:25
Likewise.
|
| + SlotsBuffer* buffer = *buffer_address; |
| + if (buffer == NULL || !buffer->HasSpaceForTypedSlot()) { |
| + if (mode == FAIL_ON_OVERFLOW && ChainLengthThresholdReached(buffer)) { |
| + allocator->DeallocateChain(buffer_address); |
| + return false; |
| + } |
| + buffer = allocator->AllocateBuffer(heap, buffer); |
| + *buffer_address = buffer; |
| + } |
| + ASSERT(buffer->HasSpaceForTypedSlot()); |
| + buffer->Add(reinterpret_cast<ObjectSlot>(type)); |
| + buffer->Add(reinterpret_cast<ObjectSlot>(addr)); |
| + return true; |
| +} |
| + |
| + |
| } } // namespace v8::internal |
| #endif // V8_MARK_COMPACT_INL_H_ |