Index: Source/bindings/core/v8/V8Initializer.cpp |
diff --git a/Source/bindings/core/v8/V8Initializer.cpp b/Source/bindings/core/v8/V8Initializer.cpp |
index f73978540a245000a78a8a178ab3b90a6fb93a5a..14e6c037d5bf4069c88ee354e8b039435b041771 100644 |
--- a/Source/bindings/core/v8/V8Initializer.cpp |
+++ b/Source/bindings/core/v8/V8Initializer.cpp |
@@ -47,7 +47,9 @@ |
#include "core/frame/csp/ContentSecurityPolicy.h" |
#include "core/inspector/ScriptCallStack.h" |
#include "platform/EventDispatchForbiddenScope.h" |
+#include "platform/RuntimeEnabledFeatures.h" |
#include "platform/TraceEvent.h" |
+#include "platform/scheduler/Scheduler.h" |
#include "public/platform/Platform.h" |
#include "wtf/RefPtr.h" |
#include "wtf/text/WTFString.h" |
@@ -178,6 +180,32 @@ static bool codeGenerationCheckCallbackInMainThread(v8::Local<v8::Context> conte |
return false; |
} |
+static void idleGCTaskInMainThread(double deadlineSeconds); |
+ |
+static void postIdleGCTaskMainThread() |
+{ |
+ if (RuntimeEnabledFeatures::v8IdleTasksEnabled()) { |
+ Scheduler* scheduler = Scheduler::shared(); |
+ if (scheduler) |
+ scheduler->postIdleTask(FROM_HERE, WTF::bind<double>(idleGCTaskInMainThread)); |
+ } |
+} |
+ |
+static void idleGCTaskInMainThread(double deadlineSeconds) |
+{ |
+ ASSERT(isMainThread()); |
+ ASSERT(RuntimeEnabledFeatures::v8IdleTasksEnabled()); |
+ v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
+ // TODO: Change V8's API to take a deadline - http://crbug.com/417668 |
jochen (gone - plz use gerrit)
2014/10/13 08:06:20
blink has FIXME: instead of TODO
rmcilroy
2014/10/13 11:22:07
Done.
|
+ double idleTimeInSeconds = deadlineSeconds - Platform::current()->monotonicallyIncreasingTime(); |
+ int idleTimeInMillis = static_cast<int>(idleTimeInSeconds * 1000); |
+ if (idleTimeInMillis > 0) { |
jochen (gone - plz use gerrit)
2014/10/13 08:06:20
no { } required
jochen (gone - plz use gerrit)
2014/10/13 08:06:20
no { } required
rmcilroy
2014/10/13 11:22:08
Done.
|
+ isolate->IdleNotification(idleTimeInMillis); |
+ } |
+ // TODO: only repost if there is more work to do. |
+ postIdleGCTaskMainThread(); |
jochen (gone - plz use gerrit)
2014/10/13 08:06:20
how will you make sure that you don't end up squee
rmcilroy
2014/10/13 11:22:07
CL https://codereview.chromium.org/640053003/ deal
|
+} |
+ |
static void timerTraceProfilerInMainThread(const char* name, int status) |
{ |
if (!status) { |