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

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 ebdfabeafd5697c4653865246d80c37b948394c0..de08e8c2b1cc629e6b9e97f6dd1c174a57297ae2 100644
--- a/Source/platform/heap/Heap.cpp
+++ b/Source/platform/heap/Heap.cpp
@@ -609,31 +609,51 @@ 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();
+ // 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.
+ if (pageCount % 10 == 0) {
+ if (deadlineSeconds <= Platform::current()->monotonicallyIncreasingTime()) {
rmcilroy 2015/03/31 13:01:30 Could we add some slack here (e.g., deadlineSecond
haraken 2015/03/31 13:07:45 That is a hard question to answer since the time t
rmcilroy 2015/03/31 13:19:26 Right I thought this might be the case.
+ return false;
+ }
}
+ pageCount++;
}
+ return true;
+}
- if (threadState()->isMainThread())
- ScriptForbiddenScope::exit();
+void BaseHeap::completeSweep()
+{
+ RELEASE_ASSERT(threadState()->isSweepingInProgress());
+ ASSERT(threadState()->sweepForbidden());
+
+ 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