Chromium Code Reviews| Index: third_party/WebKit/Source/platform/heap/HeapPage.cpp |
| diff --git a/third_party/WebKit/Source/platform/heap/HeapPage.cpp b/third_party/WebKit/Source/platform/heap/HeapPage.cpp |
| index 48fef56bb8d22195b33ce7ad3b0c8a15ffeb2b25..be9877f49a1ce33f4ab2d0a39df280d526dff7fc 100644 |
| --- a/third_party/WebKit/Source/platform/heap/HeapPage.cpp |
| +++ b/third_party/WebKit/Source/platform/heap/HeapPage.cpp |
| @@ -126,8 +126,8 @@ void BaseHeap::cleanupPages() |
| ASSERT(!m_firstUnsweptPage); |
| // Add the BaseHeap's pages to the orphanedPagePool. |
| for (BasePage* page = m_firstPage; page; page = page->next()) { |
| - Heap::decreaseAllocatedSpace(page->size()); |
| - Heap::orphanedPagePool()->addOrphanedPage(heapIndex(), page); |
| + threadState()->gcGroup()->heapStats().decreaseAllocatedSpace(page->size()); |
| + threadState()->gcGroup()->orphanedPagePool()->addOrphanedPage(heapIndex(), page); |
| } |
| m_firstPage = nullptr; |
| } |
| @@ -301,7 +301,7 @@ Address BaseHeap::lazySweep(size_t allocationSize, size_t gcInfoIndex) |
| ScriptForbiddenIfMainThreadScope scriptForbidden; |
| double startTime = WTF::currentTimeMS(); |
| - Address result = lazySweepPages(allocationSize, gcInfoIndex); |
| + Address result = lazySweepPages(allocationSize, gcInfoIndex, threadState()->gcGroup()); |
| threadState()->accumulateSweepingTime(WTF::currentTimeMS() - startTime); |
| Heap::reportMemoryUsageForTracing(); |
| @@ -419,7 +419,7 @@ void NormalPageHeap::takeFreelistSnapshot(const String& dumpName) |
| void NormalPageHeap::allocatePage() |
| { |
| threadState()->shouldFlushHeapDoesNotContainCache(); |
| - PageMemory* pageMemory = Heap::freePagePool()->takeFreePage(heapIndex()); |
| + PageMemory* pageMemory = threadState()->gcGroup()->freePagePool()->takeFreePage(heapIndex()); |
| if (!pageMemory) { |
| // Allocate a memory region for blinkPagesPerRegion pages that |
| @@ -427,7 +427,7 @@ void NormalPageHeap::allocatePage() |
| // |
| // [ guard os page | ... payload ... | guard os page ] |
| // ^---{ aligned to blink page size } |
| - PageMemoryRegion* region = PageMemoryRegion::allocateNormalPages(); |
| + PageMemoryRegion* region = PageMemoryRegion::allocateNormalPages(threadState()->gcGroup()); |
| // Setup the PageMemory object for each of the pages in the region. |
| for (size_t i = 0; i < blinkPagesPerRegion; ++i) { |
| @@ -442,7 +442,7 @@ void NormalPageHeap::allocatePage() |
| RELEASE_ASSERT(result); |
| pageMemory = memory; |
| } else { |
| - Heap::freePagePool()->addFreePage(heapIndex(), memory); |
| + threadState()->gcGroup()->freePagePool()->addFreePage(heapIndex(), memory); |
| } |
| } |
| } |
| @@ -450,7 +450,7 @@ void NormalPageHeap::allocatePage() |
| NormalPage* page = new (pageMemory->writableStart()) NormalPage(pageMemory, this); |
| page->link(&m_firstPage); |
| - Heap::increaseAllocatedSpace(page->size()); |
| + threadState()->gcGroup()->heapStats().increaseAllocatedSpace(page->size()); |
| #if ENABLE(ASSERT) || defined(LEAK_SANITIZER) || defined(ADDRESS_SANITIZER) |
| // Allow the following addToFreeList() to add the newly allocated memory |
| // to the free list. |
| @@ -465,7 +465,7 @@ void NormalPageHeap::allocatePage() |
| void NormalPageHeap::freePage(NormalPage* page) |
| { |
| - Heap::decreaseAllocatedSpace(page->size()); |
| + threadState()->gcGroup()->heapStats().decreaseAllocatedSpace(page->size()); |
| if (page->terminating()) { |
| // The thread is shutting down and this page is being removed as a part |
| @@ -476,11 +476,11 @@ void NormalPageHeap::freePage(NormalPage* page) |
| // ensures that tracing the dangling pointer in the next global GC just |
| // crashes instead of causing use-after-frees. After the next global |
| // GC, the orphaned pages are removed. |
| - Heap::orphanedPagePool()->addOrphanedPage(heapIndex(), page); |
| + threadState()->gcGroup()->orphanedPagePool()->addOrphanedPage(heapIndex(), page); |
| } else { |
| PageMemory* memory = page->storage(); |
| page->~NormalPage(); |
| - Heap::freePagePool()->addFreePage(heapIndex(), memory); |
| + threadState()->gcGroup()->freePagePool()->addFreePage(heapIndex(), memory); |
| } |
| } |
| @@ -545,7 +545,7 @@ bool NormalPageHeap::coalesce() |
| if (startOfGap != page->payloadEnd()) |
| addToFreeList(startOfGap, page->payloadEnd() - startOfGap); |
| } |
| - Heap::decreaseAllocatedObjectSize(freedSize); |
| + threadState()->gcGroup()->heapStats().decreaseAllocatedObjectSize(freedSize); |
| ASSERT(m_promptlyFreedSize == freedSize); |
| m_promptlyFreedSize = 0; |
| return true; |
| @@ -628,7 +628,7 @@ bool NormalPageHeap::shrinkObject(HeapObjectHeader* header, size_t newSize) |
| return false; |
| } |
| -Address NormalPageHeap::lazySweepPages(size_t allocationSize, size_t gcInfoIndex) |
| +Address NormalPageHeap::lazySweepPages(size_t allocationSize, size_t gcInfoIndex, GCGroup*) |
|
haraken
2016/01/28 15:52:49
The GCGroup parameter looks unnecessary.
keishi
2016/02/29 06:02:33
Done.
|
| { |
| ASSERT(!hasCurrentAllocationArea()); |
| Address result = nullptr; |
| @@ -663,16 +663,16 @@ void NormalPageHeap::setRemainingAllocationSize(size_t newRemainingAllocationSiz |
| // - if previous alloc checkpoint is larger, allocation size has increased. |
| // - if smaller, a net reduction in size since last call to updateRemainingAllocationSize(). |
| if (m_lastRemainingAllocationSize > m_remainingAllocationSize) |
| - Heap::increaseAllocatedObjectSize(m_lastRemainingAllocationSize - m_remainingAllocationSize); |
| + threadState()->gcGroup()->heapStats().increaseAllocatedObjectSize(m_lastRemainingAllocationSize - m_remainingAllocationSize); |
| else if (m_lastRemainingAllocationSize != m_remainingAllocationSize) |
| - Heap::decreaseAllocatedObjectSize(m_remainingAllocationSize - m_lastRemainingAllocationSize); |
| + threadState()->gcGroup()->heapStats().decreaseAllocatedObjectSize(m_remainingAllocationSize - m_lastRemainingAllocationSize); |
| m_lastRemainingAllocationSize = m_remainingAllocationSize; |
| } |
| void NormalPageHeap::updateRemainingAllocationSize() |
| { |
| if (m_lastRemainingAllocationSize > remainingAllocationSize()) { |
| - Heap::increaseAllocatedObjectSize(m_lastRemainingAllocationSize - remainingAllocationSize()); |
| + threadState()->gcGroup()->heapStats().increaseAllocatedObjectSize(m_lastRemainingAllocationSize - remainingAllocationSize()); |
| m_lastRemainingAllocationSize = remainingAllocationSize(); |
| } |
| ASSERT(m_lastRemainingAllocationSize == remainingAllocationSize()); |
| @@ -706,7 +706,7 @@ Address NormalPageHeap::outOfLineAllocate(size_t allocationSize, size_t gcInfoIn |
| // TODO(sof): support eagerly finalized large objects, if ever needed. |
| RELEASE_ASSERT(heapIndex() != BlinkGC::EagerSweepHeapIndex); |
| LargeObjectHeap* largeObjectHeap = static_cast<LargeObjectHeap*>(threadState()->heap(BlinkGC::LargeObjectHeapIndex)); |
| - Address largeObject = largeObjectHeap->allocateLargeObjectPage(allocationSize, gcInfoIndex); |
| + Address largeObject = largeObjectHeap->allocateLargeObjectPage(allocationSize, gcInfoIndex, threadState()->gcGroup()); |
| ASAN_MARK_LARGE_VECTOR_CONTAINER(this, largeObject); |
| return largeObject; |
| } |
| @@ -785,7 +785,7 @@ LargeObjectHeap::LargeObjectHeap(ThreadState* state, int index) |
| { |
| } |
| -Address LargeObjectHeap::allocateLargeObjectPage(size_t allocationSize, size_t gcInfoIndex) |
| +Address LargeObjectHeap::allocateLargeObjectPage(size_t allocationSize, size_t gcInfoIndex, GCGroup* gcGroup) |
|
haraken
2016/01/28 15:52:50
Remove the GCGroup parameter.
keishi
2016/02/29 06:02:33
Done.
|
| { |
| // Caller already added space for object header and rounded up to allocation |
| // alignment |
| @@ -804,10 +804,10 @@ Address LargeObjectHeap::allocateLargeObjectPage(size_t allocationSize, size_t g |
| // 3. Check if we should trigger a GC. |
| threadState()->scheduleGCIfNeeded(); |
| - return doAllocateLargeObjectPage(allocationSize, gcInfoIndex); |
| + return doAllocateLargeObjectPage(allocationSize, gcInfoIndex, gcGroup); |
| } |
| -Address LargeObjectHeap::doAllocateLargeObjectPage(size_t allocationSize, size_t gcInfoIndex) |
| +Address LargeObjectHeap::doAllocateLargeObjectPage(size_t allocationSize, size_t gcInfoIndex, GCGroup* gcGroup) |
|
haraken
2016/01/28 15:52:49
Remove the GCGroup parameter.
keishi
2016/02/29 06:02:33
Done.
|
| { |
| size_t largeObjectSize = LargeObjectPage::pageHeaderSize() + allocationSize; |
| // If ASan is supported we add allocationGranularity bytes to the allocated |
| @@ -817,7 +817,7 @@ Address LargeObjectHeap::doAllocateLargeObjectPage(size_t allocationSize, size_t |
| #endif |
| threadState()->shouldFlushHeapDoesNotContainCache(); |
| - PageMemory* pageMemory = PageMemory::allocate(largeObjectSize); |
| + PageMemory* pageMemory = PageMemory::allocate(largeObjectSize, gcGroup); |
|
haraken
2016/01/28 15:52:49
And use threadState()->gcGroup().
keishi
2016/02/29 06:02:33
Done.
|
| Address largeObjectAddress = pageMemory->writableStart(); |
| Address headerAddress = largeObjectAddress + LargeObjectPage::pageHeaderSize(); |
| #if ENABLE(ASSERT) |
| @@ -838,8 +838,8 @@ Address LargeObjectHeap::doAllocateLargeObjectPage(size_t allocationSize, size_t |
| largeObject->link(&m_firstPage); |
| - Heap::increaseAllocatedSpace(largeObject->size()); |
| - Heap::increaseAllocatedObjectSize(largeObject->size()); |
| + threadState()->gcGroup()->heapStats().increaseAllocatedSpace(largeObject->size()); |
| + threadState()->gcGroup()->heapStats().increaseAllocatedObjectSize(largeObject->size()); |
| return result; |
| } |
| @@ -847,7 +847,7 @@ void LargeObjectHeap::freeLargeObjectPage(LargeObjectPage* object) |
| { |
| ASAN_UNPOISON_MEMORY_REGION(object->payload(), object->payloadSize()); |
| object->heapObjectHeader()->finalize(object->payload(), object->payloadSize()); |
| - Heap::decreaseAllocatedSpace(object->size()); |
| + threadState()->gcGroup()->heapStats().decreaseAllocatedSpace(object->size()); |
| // Unpoison the object header and allocationGranularity bytes after the |
| // object before freeing. |
| @@ -864,7 +864,7 @@ void LargeObjectHeap::freeLargeObjectPage(LargeObjectPage* object) |
| // ensures that tracing the dangling pointer in the next global GC just |
| // crashes instead of causing use-after-frees. After the next global |
| // GC, the orphaned pages are removed. |
| - Heap::orphanedPagePool()->addOrphanedPage(heapIndex(), object); |
| + threadState()->gcGroup()->orphanedPagePool()->addOrphanedPage(heapIndex(), object); |
| } else { |
| ASSERT(!ThreadState::current()->isTerminating()); |
| PageMemory* memory = object->storage(); |
| @@ -873,7 +873,7 @@ void LargeObjectHeap::freeLargeObjectPage(LargeObjectPage* object) |
| } |
| } |
| -Address LargeObjectHeap::lazySweepPages(size_t allocationSize, size_t gcInfoIndex) |
| +Address LargeObjectHeap::lazySweepPages(size_t allocationSize, size_t gcInfoIndex, GCGroup* gcGroup) |
|
haraken
2016/01/28 15:52:49
Remove the GCGroup parameter.
keishi
2016/02/29 06:02:33
Done.
|
| { |
| Address result = nullptr; |
| size_t sweptSize = 0; |
| @@ -886,7 +886,7 @@ Address LargeObjectHeap::lazySweepPages(size_t allocationSize, size_t gcInfoInde |
| // For LargeObjectPage, stop lazy sweeping once we have swept |
| // more than allocationSize bytes. |
| if (sweptSize >= allocationSize) { |
| - result = doAllocateLargeObjectPage(allocationSize, gcInfoIndex); |
| + result = doAllocateLargeObjectPage(allocationSize, gcInfoIndex, gcGroup); |
| ASSERT(result); |
| break; |
| } |
| @@ -1157,7 +1157,7 @@ void NormalPage::sweep() |
| heapForNormalPage()->addToFreeList(startOfGap, payloadEnd() - startOfGap); |
| if (markedObjectSize) |
| - Heap::increaseMarkedObjectSize(markedObjectSize); |
| + ThreadState::current()->gcGroup()->heapStats().increaseMarkedObjectSize(markedObjectSize); |
|
haraken
2016/01/28 15:52:50
heap()->threadState()
keishi
2016/02/29 06:02:33
Done.
|
| } |
| void NormalPage::makeConsistentForGC() |
| @@ -1182,7 +1182,7 @@ void NormalPage::makeConsistentForGC() |
| headerAddress += header->size(); |
| } |
| if (markedObjectSize) |
| - Heap::increaseMarkedObjectSize(markedObjectSize); |
| + ThreadState::current()->gcGroup()->heapStats().increaseMarkedObjectSize(markedObjectSize); |
|
haraken
2016/01/28 15:52:49
heap()->threadState()
keishi
2016/02/29 06:02:33
Done.
|
| } |
| void NormalPage::makeConsistentForMutator() |
| @@ -1449,7 +1449,7 @@ void LargeObjectPage::removeFromHeap() |
| void LargeObjectPage::sweep() |
| { |
| heapObjectHeader()->unmark(); |
| - Heap::increaseMarkedObjectSize(size()); |
| + ThreadState::current()->gcGroup()->heapStats().increaseMarkedObjectSize(size()); |
|
haraken
2016/01/28 15:52:49
heap()->threadState()
keishi
2016/02/29 06:02:33
Done.
|
| } |
| void LargeObjectPage::makeConsistentForGC() |
| @@ -1457,7 +1457,7 @@ void LargeObjectPage::makeConsistentForGC() |
| HeapObjectHeader* header = heapObjectHeader(); |
| if (header->isMarked()) { |
| header->unmark(); |
| - Heap::increaseMarkedObjectSize(size()); |
| + ThreadState::current()->gcGroup()->heapStats().increaseMarkedObjectSize(size()); |
|
haraken
2016/01/28 15:52:49
heap()->threadState()
keishi
2016/02/29 06:02:33
Done.
|
| } else { |
| header->markDead(); |
| } |