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

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

Issue 875503003: Allow Oilpan heap objects account for their external allocations. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: more minor stuff Created 5 years, 10 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.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/heap/ThreadState.cpp
diff --git a/Source/platform/heap/ThreadState.cpp b/Source/platform/heap/ThreadState.cpp
index 2be4900377a959a67d0a37c7ef6748bc9f184f78..08cae49ebe409d9424de89897115884a18a7c17b 100644
--- a/Source/platform/heap/ThreadState.cpp
+++ b/Source/platform/heap/ThreadState.cpp
@@ -673,6 +673,9 @@ bool ThreadState::shouldForceConservativeGC()
if (UNLIKELY(m_gcForbiddenCount))
return false;
+ if (Heap::isUrgentGCRequested())
+ return true;
+
size_t newSize = Heap::allocatedObjectSize();
if (newSize >= 300 * 1024 * 1024) {
// If we consume too much memory, trigger a conservative GC
@@ -697,14 +700,18 @@ void ThreadState::scheduleGCIfNeeded()
{
checkThread();
// Allocation is allowed during sweeping, but those allocations should not
- // trigger nested GCs
- if (isSweepingInProgress())
+ // trigger nested GCs. Does not apply if an urgent GC has been requested.
+ if (isSweepingInProgress() && UNLIKELY(!Heap::isUrgentGCRequested()))
return;
ASSERT(!sweepForbidden());
- if (shouldForceConservativeGC())
- Heap::collectGarbage(ThreadState::HeapPointersOnStack, ThreadState::GCWithoutSweep);
- else if (shouldSchedulePreciseGC())
+ if (shouldForceConservativeGC()) {
+ // If GC is deemed urgent, eagerly sweep and finalize any external allocations right away.
+ GCType gcType = Heap::isUrgentGCRequested() ? GCWithSweep : GCWithoutSweep;
+ Heap::collectGarbage(HeapPointersOnStack, gcType);
+ return;
+ }
+ if (shouldSchedulePreciseGC())
schedulePreciseGC();
else if (shouldScheduleIdleGC())
scheduleIdleGC();
« no previous file with comments | « Source/platform/heap/Heap.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698