Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(222)

Unified Diff: Source/platform/heap/Heap.cpp

Issue 1046123002: Oilpan: Split completeSweep() in idle tasks into chunks (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/platform/heap/Heap.h ('k') | Source/platform/heap/ThreadState.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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)
« no previous file with comments | « Source/platform/heap/Heap.h ('k') | Source/platform/heap/ThreadState.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698