Chromium Code Reviews| Index: Source/platform/heap/Heap.cpp |
| diff --git a/Source/platform/heap/Heap.cpp b/Source/platform/heap/Heap.cpp |
| index 82bf5004634adfe7d318875ee824dccbe5100611..b051ca244998aadabbf018e694f85a283825f8dc 100644 |
| --- a/Source/platform/heap/Heap.cpp |
| +++ b/Source/platform/heap/Heap.cpp |
| @@ -543,6 +543,7 @@ void LargeObject::markUnmarkedObjectsDead() |
| void LargeObject::removeFromHeap(ThreadHeap* heap) |
| { |
| + m_sweepStatus = 0; |
| heap->freeLargeObject(this); |
| } |
| @@ -747,11 +748,11 @@ Address ThreadHeap::lazySweepPages(size_t allocationSize, size_t gcInfoIndex) |
| page->sweep(); |
| page->unlink(&m_firstUnsweptPage); |
| page->link(&m_firstPage); |
| + page->markAsLazilySwept(); |
| result = allocateFromFreeList(allocationSize, gcInfoIndex); |
| - if (result) { |
| + if (result) |
| break; |
| - } |
| } |
| } |
| @@ -804,6 +805,7 @@ bool ThreadHeap::lazySweepLargeObjects(size_t allocationSize) |
| largeObject->sweep(); |
| largeObject->unlink(&m_firstUnsweptLargeObject); |
| largeObject->link(&m_firstLargeObject); |
| + largeObject->markAsLazilySwept(); |
| } |
| } |
| @@ -832,6 +834,7 @@ void ThreadHeap::completeSweep() |
| page->sweep(); |
| page->unlink(&m_firstUnsweptPage); |
| page->link(&m_firstPage); |
| + page->markAsLazilySwept(); |
| } |
| } |
| @@ -847,6 +850,7 @@ void ThreadHeap::completeSweep() |
| largeObject->sweep(); |
| largeObject->unlink(&m_firstUnsweptLargeObject); |
| largeObject->link(&m_firstLargeObject); |
| + largeObject->markAsLazilySwept(); |
| } |
| } |
| @@ -1238,6 +1242,30 @@ BaseHeapPage::BaseHeapPage(PageMemory* storage, ThreadHeap* heap) |
| ASSERT(isPageHeaderAddress(reinterpret_cast<Address>(this))); |
| } |
| +void BaseHeapPage::markAsLazilySwept() |
| +{ |
| + // To signal completion of a lazy sweep, update the |
| + // page's sweep status to match that of the ThreadState's |
| + // flip-flop sweep token. |
| + bool currentToken = heap()->threadState()->lazySweepToken(); |
| + m_sweepStatus = currentToken ? 2 : 1; |
| +} |
| + |
| +bool BaseHeapPage::hasBeenLazilySwept() const |
| +{ |
| + // Returns true if this page has been swept |
| + // by the ongoing lazy sweep operation. |
| + ASSERT(heap()->threadState()->isSweepingInProgress()); |
| + ASSERT(m_sweepStatus <= 2); |
| + |
| + // Page has been swept, freed. |
| + if (!m_sweepStatus) |
| + return false; |
| + |
| + bool currentToken = heap()->threadState()->lazySweepToken(); |
| + return currentToken == (m_sweepStatus == 2); |
|
haraken
2015/01/16 13:40:01
The token looks a bit tricky to me. Can we just de
sof
2015/01/16 13:43:10
I elected not to scan all pages (previously swept
haraken
2015/01/16 13:54:55
If you need to go with the flip bit, I guess you'l
|
| +} |
| + |
| void BaseHeapPage::markOrphaned() |
| { |
| m_heap = nullptr; |
| @@ -1618,6 +1646,7 @@ void HeapPage::markUnmarkedObjectsDead() |
| void HeapPage::removeFromHeap(ThreadHeap* heap) |
| { |
| + m_sweepStatus = 0; |
| heap->freePage(this); |
| } |