Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(311)

Unified Diff: Source/bindings/core/v8/V8Initializer.cpp

Issue 639773007: Enable V8 idle tasks. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Source/platform/RuntimeEnabledFeatures.in » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/core/v8/V8Initializer.cpp
diff --git a/Source/bindings/core/v8/V8Initializer.cpp b/Source/bindings/core/v8/V8Initializer.cpp
index 3e3157b30eea1a0a7b7052b561545c2c3e07bf16..f8441c25f57e8cfa6a7c3a786e907f28afed8460 100644
--- a/Source/bindings/core/v8/V8Initializer.cpp
+++ b/Source/bindings/core/v8/V8Initializer.cpp
@@ -50,7 +50,9 @@
#include "core/inspector/ScriptArguments.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"
@@ -253,6 +255,31 @@ 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();
+ // FIXME: Change V8's API to take a deadline - http://crbug.com/417668
+ double idleTimeInSeconds = deadlineSeconds - Platform::current()->monotonicallyIncreasingTime();
+ int idleTimeInMillis = static_cast<int>(idleTimeInSeconds * 1000);
+ if (idleTimeInMillis > 0)
+ isolate->IdleNotification(idleTimeInMillis);
+ // FIXME: only repost if there is more work to do.
+ postIdleGCTaskMainThread();
+}
+
static void timerTraceProfilerInMainThread(const char* name, int status)
{
if (!status) {
@@ -292,6 +319,8 @@ void V8Initializer::initializeMainThreadIfNeeded()
v8::V8::SetFailedAccessCheckCallbackFunction(failedAccessCheckCallbackInMainThread);
v8::V8::SetAllowCodeGenerationFromStringsCallback(codeGenerationCheckCallbackInMainThread);
+ postIdleGCTaskMainThread();
+
isolate->SetEventLogger(timerTraceProfilerInMainThread);
isolate->SetPromiseRejectCallback(promiseRejectHandlerInMainThread);
« no previous file with comments | « no previous file | Source/platform/RuntimeEnabledFeatures.in » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698