Index: third_party/WebKit/Source/platform/heap/ThreadState.cpp |
diff --git a/third_party/WebKit/Source/platform/heap/ThreadState.cpp b/third_party/WebKit/Source/platform/heap/ThreadState.cpp |
index 4a1efe48e8904b9f5bcf581155bcf3d28980ee82..9222e8bb75494167a15e14433158469e96e62842 100644 |
--- a/third_party/WebKit/Source/platform/heap/ThreadState.cpp |
+++ b/third_party/WebKit/Source/platform/heap/ThreadState.cpp |
@@ -670,6 +670,18 @@ bool ThreadState::shouldForceConservativeGC() |
return judgeGCThreshold(32 * 1024 * 1024, 5.0); |
} |
+bool ThreadState::forceMemoryPressureGCIfNeeded() |
+{ |
+ if (!shouldForceMemoryPressureGC()) |
+ return false; |
+ completeSweep(); |
+ if (!shouldForceMemoryPressureGC()) |
+ return false; |
+ |
+ Heap::collectGarbage(HeapPointersOnStack, GCWithoutSweep, Heap::ConservativeGC); |
+ return true; |
+} |
+ |
void ThreadState::scheduleV8FollowupGCIfNeeded(V8GCType gcType) |
{ |
ASSERT(checkThread()); |
@@ -678,6 +690,11 @@ void ThreadState::scheduleV8FollowupGCIfNeeded(V8GCType gcType) |
if (isGCForbidden()) |
return; |
+ // If V8 has acted on a memory pressure signal and performed a major GC, |
+ // follow up, if needed. |
+ if (gcType == V8MajorGC && forceMemoryPressureGCIfNeeded()) |
+ return; |
+ |
if (isSweepingInProgress()) |
return; |
ASSERT(!sweepForbidden()); |