Chromium Code Reviews| Index: Source/platform/heap/Heap.cpp |
| diff --git a/Source/platform/heap/Heap.cpp b/Source/platform/heap/Heap.cpp |
| index 88496aa7058904784e7c463207761b7c1c73e9d0..3ce579b39a7b66120abd3b81235ef8e3516cf6f9 100644 |
| --- a/Source/platform/heap/Heap.cpp |
| +++ b/Source/platform/heap/Heap.cpp |
| @@ -609,31 +609,49 @@ Address BaseHeap::lazySweep(size_t allocationSize, size_t gcInfoIndex) |
| return result; |
| } |
| -void BaseHeap::completeSweep() |
| +void BaseHeap::sweepUnsweptPage() |
| +{ |
| + BasePage* page = m_firstUnsweptPage; |
| + if (page->isEmpty()) { |
| + page->unlink(&m_firstUnsweptPage); |
| + page->removeFromHeap(); |
| + } else { |
| + // Sweep a page and move the page from m_firstUnsweptPages to |
| + // m_firstPages. |
| + page->sweep(); |
| + page->unlink(&m_firstUnsweptPage); |
| + page->link(&m_firstPage); |
| + page->markAsSwept(); |
| + } |
| +} |
| + |
| +bool BaseHeap::lazySweepWithDeadline(double deadlineSeconds) |
| { |
| RELEASE_ASSERT(threadState()->isSweepingInProgress()); |
| ASSERT(threadState()->sweepForbidden()); |
| - if (threadState()->isMainThread()) |
| - ScriptForbiddenScope::enter(); |
| - |
| + int pageCount = 1; |
| while (m_firstUnsweptPage) { |
| - BasePage* page = m_firstUnsweptPage; |
| - if (page->isEmpty()) { |
| - page->unlink(&m_firstUnsweptPage); |
| - page->removeFromHeap(); |
| - } else { |
| - // Sweep a page and move the page from m_firstUnsweptPages to |
| - // m_firstPages. |
| - page->sweep(); |
| - page->unlink(&m_firstUnsweptPage); |
| - page->link(&m_firstPage); |
| - page->markAsSwept(); |
| + sweepUnsweptPage(); |
| + // Check the deadline every time we sweep 10 page. |
| + if (pageCount % 10 == 0) { |
|
kouhei (in TOK)
2015/03/31 11:42:07
Why 10?
haraken
2015/03/31 12:46:58
I thought it might be heavy to call Platform::curr
Sami
2015/03/31 12:52:00
Might want to make this a named constant too. Also
rmcilroy
2015/03/31 13:01:30
+1
haraken
2015/03/31 13:07:45
Will fix.
|
| + if (deadlineSeconds <= Platform::current()->monotonicallyIncreasingTime()) { |
| + return false; |
| + } |
| } |
| + pageCount++; |
| } |
| + return true; |
| +} |
| - if (threadState()->isMainThread()) |
| - ScriptForbiddenScope::exit(); |
| +void BaseHeap::completeSweep() |
| +{ |
| + RELEASE_ASSERT(threadState()->isSweepingInProgress()); |
| + ASSERT(threadState()->sweepForbidden()); |
| + |
| + while (m_firstUnsweptPage) { |
|
kouhei (in TOK)
2015/03/31 11:42:07
Nit: Unneeded {}
haraken
2015/03/31 12:46:58
Nit: The coding style guide is updated and it's up
|
| + sweepUnsweptPage(); |
| + } |
| } |
| NormalPageHeap::NormalPageHeap(ThreadState* state, int index) |