Index: Source/platform/heap/ThreadState.cpp |
diff --git a/Source/platform/heap/ThreadState.cpp b/Source/platform/heap/ThreadState.cpp |
index 0ae8284286368653772f4242475dd2bbe5d75e9d..ffb71e3ab4e6b7eb67266741eb072a4a9c02ebb4 100644 |
--- a/Source/platform/heap/ThreadState.cpp |
+++ b/Source/platform/heap/ThreadState.cpp |
@@ -669,6 +669,9 @@ bool ThreadState::shouldSchedulePreciseGC() |
// These heuristics affect performance significantly. |
bool ThreadState::shouldForceConservativeGC() |
{ |
+ if (Heap::isGCUrgentlyRequested()) |
+ return true; |
+ |
size_t newSize = Heap::allocatedObjectSize(); |
if (newSize >= 300 * 1024 * 1024) { |
// If we consume too much memory, trigger a conservative GC |
@@ -694,13 +697,22 @@ void ThreadState::scheduleGCIfNeeded() |
checkThread(); |
// Allocation is allowed during sweeping, but those allocations should not |
// trigger nested GCs |
- if (isSweepingInProgress()) |
- return; |
+ if (isSweepingInProgress()) { |
+ if (!Heap::isGCUrgentlyRequested() || !isSweepingScheduled()) |
haraken
2015/02/19 23:47:44
As commented earlier, I guess we should just call
sof
2015/02/20 09:33:49
This will already happen when the collectGarbage()
haraken
2015/02/23 08:42:27
Makes sense.
|
+ 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()) { |
haraken
2015/02/19 23:47:44
Slightly better:
if (Heap::isGCUrgentlyRequested(
sof
2015/02/20 09:33:49
See above; redundant.
|
+ // If GC is deemed urgent, eagerly sweep and finalize any external allocations right away. |
+ GCType gcType = Heap::isGCUrgentlyRequested() ? GCWithSweep : GCWithoutSweep; |
+ Heap::clearUrgentGC(); |
+ Heap::collectGarbage(HeapPointersOnStack, gcType); |
+ return; |
+ } |
+ if (shouldSchedulePreciseGC()) |
schedulePreciseGC(); |
else if (shouldScheduleIdleGC()) |
scheduleIdleGC(); |