Index: Source/platform/heap/ThreadState.cpp |
diff --git a/Source/platform/heap/ThreadState.cpp b/Source/platform/heap/ThreadState.cpp |
index 2be4900377a959a67d0a37c7ef6748bc9f184f78..7c9559e8d7fb5c76e5fbbcdc6d0dd88d3590a8a6 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 |
@@ -698,13 +701,21 @@ void ThreadState::scheduleGCIfNeeded() |
checkThread(); |
// Allocation is allowed during sweeping, but those allocations should not |
// trigger nested GCs |
- if (isSweepingInProgress()) |
- return; |
+ if (isSweepingInProgress()) { |
+ if (!Heap::isUrgentGCRequested() || !isSweepingScheduled()) |
haraken
2015/02/23 16:40:29
Sorry to bug you a lot of times on this... I recon
sof
2015/02/23 20:47:05
Yes, we don't want to make a distinction between t
|
+ return; |
+ // Urgent GC requested with only a GC scheduled; fall through |
+ // and have it be serviced by a conservative GC. |
+ } |
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(); |