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

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: 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') | Source/platform/RuntimeEnabledFeatures.in » ('J')
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 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) {
« no previous file with comments | « no previous file | Source/platform/RuntimeEnabledFeatures.in » ('j') | Source/platform/RuntimeEnabledFeatures.in » ('J')

Powered by Google App Engine
This is Rietveld 408576698