Commit 2b383e44 authored by haraken's avatar haraken Committed by Commit bot

V8GCController::gcEpilogue should not fire Oilpan's GC if GCs are forbidden

BUG=613678

Review-Url: https://codereview.chromium.org/2078353002
Cr-Commit-Position: refs/heads/master@{#400655}
parent 30f8b46a
...@@ -353,41 +353,41 @@ void V8GCController::gcEpilogue(v8::Isolate* isolate, v8::GCType type, v8::GCCal ...@@ -353,41 +353,41 @@ void V8GCController::gcEpilogue(v8::Isolate* isolate, v8::GCType type, v8::GCCal
if (BlameContext* blameContext = Platform::current()->topLevelBlameContext()) if (BlameContext* blameContext = Platform::current()->topLevelBlameContext())
blameContext->Leave(); blameContext->Leave();
// v8::kGCCallbackFlagForced forces a Blink heap garbage collection if (ThreadState::current() && !ThreadState::current()->isGCForbidden()) {
// when a garbage collection was forced from V8. This is either used // v8::kGCCallbackFlagForced forces a Blink heap garbage collection
// for tests that force GCs from JavaScript to verify that objects die // when a garbage collection was forced from V8. This is either used
// when expected. // for tests that force GCs from JavaScript to verify that objects die
if (flags & v8::kGCCallbackFlagForced) { // when expected.
// This single GC is not enough for two reasons: if (flags & v8::kGCCallbackFlagForced) {
// (1) The GC is not precise because the GC scans on-stack pointers conservatively. // This single GC is not enough for two reasons:
// (2) One GC is not enough to break a chain of persistent handles. It's possible that // (1) The GC is not precise because the GC scans on-stack pointers conservatively.
// some heap allocated objects own objects that contain persistent handles // (2) One GC is not enough to break a chain of persistent handles. It's possible that
// pointing to other heap allocated objects. To break the chain, we need multiple GCs. // some heap allocated objects own objects that contain persistent handles
// // pointing to other heap allocated objects. To break the chain, we need multiple GCs.
// Regarding (1), we force a precise GC at the end of the current event loop. So if you want //
// to collect all garbage, you need to wait until the next event loop. // Regarding (1), we force a precise GC at the end of the current event loop. So if you want
// Regarding (2), it would be OK in practice to trigger only one GC per gcEpilogue, because // to collect all garbage, you need to wait until the next event loop.
// GCController.collectAll() forces multiple V8's GC. // Regarding (2), it would be OK in practice to trigger only one GC per gcEpilogue, because
ThreadHeap::collectGarbage(BlinkGC::HeapPointersOnStack, BlinkGC::GCWithSweep, BlinkGC::ForcedGC); // GCController.collectAll() forces multiple V8's GC.
ThreadHeap::collectGarbage(BlinkGC::HeapPointersOnStack, BlinkGC::GCWithSweep, BlinkGC::ForcedGC);
// Forces a precise GC at the end of the current event loop.
if (ThreadState::current()) { // Forces a precise GC at the end of the current event loop.
RELEASE_ASSERT(!ThreadState::current()->isInGC()); RELEASE_ASSERT(!ThreadState::current()->isInGC());
ThreadState::current()->setGCState(ThreadState::FullGCScheduled); ThreadState::current()->setGCState(ThreadState::FullGCScheduled);
} }
}
// v8::kGCCallbackFlagCollectAllAvailableGarbage is used when V8 handles // v8::kGCCallbackFlagCollectAllAvailableGarbage is used when V8 handles
// low memory notifications. // low memory notifications.
if (flags & v8::kGCCallbackFlagCollectAllAvailableGarbage) { if (flags & v8::kGCCallbackFlagCollectAllAvailableGarbage) {
// This single GC is not enough. See the above comment. // This single GC is not enough. See the above comment.
ThreadHeap::collectGarbage(BlinkGC::HeapPointersOnStack, BlinkGC::GCWithSweep, BlinkGC::ForcedGC); ThreadHeap::collectGarbage(BlinkGC::HeapPointersOnStack, BlinkGC::GCWithSweep, BlinkGC::ForcedGC);
// Do not force a precise GC at the end of the current event loop. // Do not force a precise GC at the end of the current event loop.
// According to UMA stats, the collection rate of the precise GC // According to UMA stats, the collection rate of the precise GC
// scheduled at the end of the low memory handling is extremely low, // scheduled at the end of the low memory handling is extremely low,
// because the above conservative GC is sufficient for collecting // because the above conservative GC is sufficient for collecting
// most objects. So we intentionally don't schedule a precise GC here. // most objects. So we intentionally don't schedule a precise GC here.
}
} }
TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "UpdateCounters", TRACE_EVENT_SCOPE_THREAD, "data", InspectorUpdateCountersEvent::data()); TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "UpdateCounters", TRACE_EVENT_SCOPE_THREAD, "data", InspectorUpdateCountersEvent::data());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment