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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 29 matching lines...) Expand all
40 #include "bindings/core/v8/V8PerContextData.h" 40 #include "bindings/core/v8/V8PerContextData.h"
41 #include "bindings/core/v8/V8Window.h" 41 #include "bindings/core/v8/V8Window.h"
42 #include "core/dom/Document.h" 42 #include "core/dom/Document.h"
43 #include "core/dom/ExceptionCode.h" 43 #include "core/dom/ExceptionCode.h"
44 #include "core/frame/ConsoleTypes.h" 44 #include "core/frame/ConsoleTypes.h"
45 #include "core/frame/LocalDOMWindow.h" 45 #include "core/frame/LocalDOMWindow.h"
46 #include "core/frame/LocalFrame.h" 46 #include "core/frame/LocalFrame.h"
47 #include "core/frame/csp/ContentSecurityPolicy.h" 47 #include "core/frame/csp/ContentSecurityPolicy.h"
48 #include "core/inspector/ScriptCallStack.h" 48 #include "core/inspector/ScriptCallStack.h"
49 #include "platform/EventDispatchForbiddenScope.h" 49 #include "platform/EventDispatchForbiddenScope.h"
50 #include "platform/RuntimeEnabledFeatures.h"
50 #include "platform/TraceEvent.h" 51 #include "platform/TraceEvent.h"
52 #include "platform/scheduler/Scheduler.h"
51 #include "public/platform/Platform.h" 53 #include "public/platform/Platform.h"
52 #include "wtf/RefPtr.h" 54 #include "wtf/RefPtr.h"
53 #include "wtf/text/WTFString.h" 55 #include "wtf/text/WTFString.h"
54 #include <v8-debug.h> 56 #include <v8-debug.h>
55 57
56 namespace blink { 58 namespace blink {
57 59
58 static LocalFrame* findFrame(v8::Local<v8::Object> host, v8::Local<v8::Value> da ta, v8::Isolate* isolate) 60 static LocalFrame* findFrame(v8::Local<v8::Object> host, v8::Local<v8::Value> da ta, v8::Isolate* isolate)
59 { 61 {
60 const WrapperTypeInfo* type = WrapperTypeInfo::unwrap(data); 62 const WrapperTypeInfo* type = WrapperTypeInfo::unwrap(data);
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 173
172 static bool codeGenerationCheckCallbackInMainThread(v8::Local<v8::Context> conte xt) 174 static bool codeGenerationCheckCallbackInMainThread(v8::Local<v8::Context> conte xt)
173 { 175 {
174 if (ExecutionContext* executionContext = toExecutionContext(context)) { 176 if (ExecutionContext* executionContext = toExecutionContext(context)) {
175 if (ContentSecurityPolicy* policy = toDocument(executionContext)->conten tSecurityPolicy()) 177 if (ContentSecurityPolicy* policy = toDocument(executionContext)->conten tSecurityPolicy())
176 return policy->allowEval(ScriptState::from(context)); 178 return policy->allowEval(ScriptState::from(context));
177 } 179 }
178 return false; 180 return false;
179 } 181 }
180 182
183 static void idleGCTaskInMainThread(double deadlineSeconds);
184
185 static void postIdleGCTaskMainThread()
186 {
187 if (RuntimeEnabledFeatures::v8IdleTasksEnabled()) {
188 Scheduler* scheduler = Scheduler::shared();
189 if (scheduler)
190 scheduler->postIdleTask(FROM_HERE, WTF::bind<double>(idleGCTaskInMai nThread));
191 }
192 }
193
194 static void idleGCTaskInMainThread(double deadlineSeconds)
195 {
196 ASSERT(isMainThread());
197 ASSERT(RuntimeEnabledFeatures::v8IdleTasksEnabled());
198 v8::Isolate* isolate = v8::Isolate::GetCurrent();
199 // 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.
200 double idleTimeInSeconds = deadlineSeconds - Platform::current()->monotonica llyIncreasingTime();
201 int idleTimeInMillis = static_cast<int>(idleTimeInSeconds * 1000);
202 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.
203 isolate->IdleNotification(idleTimeInMillis);
204 }
205 // TODO: only repost if there is more work to do.
206 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
207 }
208
181 static void timerTraceProfilerInMainThread(const char* name, int status) 209 static void timerTraceProfilerInMainThread(const char* name, int status)
182 { 210 {
183 if (!status) { 211 if (!status) {
184 TRACE_EVENT_BEGIN0("v8", name); 212 TRACE_EVENT_BEGIN0("v8", name);
185 } else { 213 } else {
186 TRACE_EVENT_END0("v8", name); 214 TRACE_EVENT_END0("v8", name);
187 } 215 }
188 } 216 }
189 217
190 static void initializeV8Common(v8::Isolate* isolate) 218 static void initializeV8Common(v8::Isolate* isolate)
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 initializeV8Common(isolate); 294 initializeV8Common(isolate);
267 295
268 v8::V8::AddMessageListener(messageHandlerInWorker); 296 v8::V8::AddMessageListener(messageHandlerInWorker);
269 v8::V8::SetFatalErrorHandler(reportFatalErrorInWorker); 297 v8::V8::SetFatalErrorHandler(reportFatalErrorInWorker);
270 298
271 uint32_t here; 299 uint32_t here;
272 isolate->SetStackLimit(reinterpret_cast<uintptr_t>(&here - kWorkerMaxStackSi ze / sizeof(uint32_t*))); 300 isolate->SetStackLimit(reinterpret_cast<uintptr_t>(&here - kWorkerMaxStackSi ze / sizeof(uint32_t*)));
273 } 301 }
274 302
275 } // namespace blink 303 } // namespace blink
OLDNEW
« 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