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

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 8d427e01653243a1ed74979eca0a426d27464632..7027df8157fdf6f9c0dfb096ea6ffc1ea7dad09f 100644
--- a/Source/platform/heap/Heap.cpp
+++ b/Source/platform/heap/Heap.cpp
@@ -609,31 +609,56 @@ 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)
+{
+ // It might be heavy to call Platform::current()->monotonicallyIncreasingTime()
+ // per page (i.e., 128 KB sweep or one LargeObject sweep), so we check
+ // the deadline per 10 pages.
+ static const int deadlineCheckInterval = 10;
+
RELEASE_ASSERT(threadState()->isSweepingInProgress());
ASSERT(threadState()->sweepForbidden());
+ ASSERT(!threadState()->isMainThread() || ScriptForbiddenScope::isScriptForbidden());
- 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();
+ if (pageCount % deadlineCheckInterval == 0) {
+ if (deadlineSeconds <= Platform::current()->monotonicallyIncreasingTime()) {
+ // Deadline has come.
+ return !m_firstUnsweptPage;
+ }
}
+ pageCount++;
}
+ return true;
+}
- if (threadState()->isMainThread())
- ScriptForbiddenScope::exit();
+void BaseHeap::completeSweep()
+{
+ RELEASE_ASSERT(threadState()->isSweepingInProgress());
+ ASSERT(threadState()->sweepForbidden());
+ ASSERT(!threadState()->isMainThread() || ScriptForbiddenScope::isScriptForbidden());
+
+ while (m_firstUnsweptPage) {
+ 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