Index: Source/bindings/core/v8/V8Initializer.cpp |
diff --git a/Source/bindings/core/v8/V8Initializer.cpp b/Source/bindings/core/v8/V8Initializer.cpp |
index 00bfc941a52ca6137a5a9ea499feab51478dfff2..4d16f8c387bb7bed4fbbc17bc501023d96e58470 100644 |
--- a/Source/bindings/core/v8/V8Initializer.cpp |
+++ b/Source/bindings/core/v8/V8Initializer.cpp |
@@ -330,6 +330,23 @@ |
return false; |
} |
+static void idleGCTaskInMainThread(double deadlineSeconds) |
+{ |
+ ASSERT(isMainThread()); |
+ ASSERT(RuntimeEnabledFeatures::v8IdleTasksEnabled()); |
+ bool gcFinished = false; |
+ v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
+ |
+ Platform* platform = Platform::current(); |
+ if (deadlineSeconds > platform->monotonicallyIncreasingTime()) |
+ gcFinished = isolate->IdleNotificationDeadline(deadlineSeconds); |
+ |
+ if (gcFinished) |
+ platform->currentThread()->scheduler()->postIdleTaskAfterWakeup(FROM_HERE, WTF::bind<double>(idleGCTaskInMainThread)); |
+ else |
+ platform->currentThread()->scheduler()->postIdleTask(FROM_HERE, WTF::bind<double>(idleGCTaskInMainThread)); |
+} |
+ |
static void timerTraceProfilerInMainThread(const char* name, int status) |
{ |
if (!status) { |
@@ -398,6 +415,8 @@ |
if (RuntimeEnabledFeatures::v8IdleTasksEnabled()) { |
WebScheduler* scheduler = Platform::current()->currentThread()->scheduler(); |
V8PerIsolateData::enableIdleTasks(isolate, adoptPtr(new V8IdleTaskRunner(scheduler))); |
+ // FIXME: Remove idleGCTaskInMainThread once V8 starts posting idle task explicity. |
+ scheduler->postIdleTask(FROM_HERE, WTF::bind<double>(idleGCTaskInMainThread)); |
} |
isolate->SetEventLogger(timerTraceProfilerInMainThread); |