Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 45 #include "core/frame/ConsoleTypes.h" | 45 #include "core/frame/ConsoleTypes.h" |
| 46 #include "core/frame/LocalDOMWindow.h" | 46 #include "core/frame/LocalDOMWindow.h" |
| 47 #include "core/frame/LocalFrame.h" | 47 #include "core/frame/LocalFrame.h" |
| 48 #include "core/frame/csp/ContentSecurityPolicy.h" | 48 #include "core/frame/csp/ContentSecurityPolicy.h" |
| 49 #include "core/inspector/ConsoleMessage.h" | 49 #include "core/inspector/ConsoleMessage.h" |
| 50 #include "core/inspector/ScriptArguments.h" | 50 #include "core/inspector/ScriptArguments.h" |
| 51 #include "core/inspector/ScriptCallStack.h" | 51 #include "core/inspector/ScriptCallStack.h" |
| 52 #include "platform/EventDispatchForbiddenScope.h" | 52 #include "platform/EventDispatchForbiddenScope.h" |
| 53 #include "platform/RuntimeEnabledFeatures.h" | 53 #include "platform/RuntimeEnabledFeatures.h" |
| 54 #include "platform/TraceEvent.h" | 54 #include "platform/TraceEvent.h" |
| 55 #include "platform/scheduler/Scheduler.h" | |
| 56 #include "public/platform/Platform.h" | 55 #include "public/platform/Platform.h" |
| 56 #include "public/platform/WebScheduler.h" | |
| 57 #include "public/platform/WebTraceLocation.h" | |
| 57 #include "wtf/RefPtr.h" | 58 #include "wtf/RefPtr.h" |
| 58 #include "wtf/text/WTFString.h" | 59 #include "wtf/text/WTFString.h" |
| 59 #include <v8-debug.h> | 60 #include <v8-debug.h> |
| 60 | 61 |
| 61 namespace blink { | 62 namespace blink { |
| 62 | 63 |
| 63 static LocalFrame* findFrame(v8::Local<v8::Object> host, v8::Local<v8::Value> da ta, v8::Isolate* isolate) | 64 static LocalFrame* findFrame(v8::Local<v8::Object> host, v8::Local<v8::Value> da ta, v8::Isolate* isolate) |
| 64 { | 65 { |
| 65 const WrapperTypeInfo* type = WrapperTypeInfo::unwrap(data); | 66 const WrapperTypeInfo* type = WrapperTypeInfo::unwrap(data); |
| 66 | 67 |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 287 | 288 |
| 288 static bool codeGenerationCheckCallbackInMainThread(v8::Local<v8::Context> conte xt) | 289 static bool codeGenerationCheckCallbackInMainThread(v8::Local<v8::Context> conte xt) |
| 289 { | 290 { |
| 290 if (ExecutionContext* executionContext = toExecutionContext(context)) { | 291 if (ExecutionContext* executionContext = toExecutionContext(context)) { |
| 291 if (ContentSecurityPolicy* policy = toDocument(executionContext)->conten tSecurityPolicy()) | 292 if (ContentSecurityPolicy* policy = toDocument(executionContext)->conten tSecurityPolicy()) |
| 292 return policy->allowEval(ScriptState::from(context)); | 293 return policy->allowEval(ScriptState::from(context)); |
| 293 } | 294 } |
| 294 return false; | 295 return false; |
| 295 } | 296 } |
| 296 | 297 |
| 297 static void idleGCTaskInMainThread(double deadlineSeconds); | 298 static void postIdleGCTaskMainThread(); |
| 299 | |
| 300 class IdleGCTaskInMainThread : public WebScheduler::IdleTask { | |
| 301 public: | |
| 302 virtual void run(double deadlineSeconds) override | |
| 303 { | |
| 304 ASSERT(isMainThread()); | |
| 305 ASSERT(RuntimeEnabledFeatures::v8IdleTasksEnabled()); | |
| 306 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | |
| 307 // FIXME: Change V8's API to take a deadline - http://crbug.com/417668 | |
| 308 double idleTimeInSeconds = deadlineSeconds - Platform::current()->monoto nicallyIncreasingTime(); | |
| 309 int idleTimeInMillis = static_cast<int>(idleTimeInSeconds * 1000); | |
| 310 if (idleTimeInMillis > 0) | |
| 311 isolate->IdleNotification(idleTimeInMillis); | |
| 312 // FIXME: only repost if there is more work to do. | |
| 313 postIdleGCTaskMainThread(); | |
|
eseidel
2014/10/21 16:11:02
So we'll always have a GC task in the run loop? W
Sami
2014/10/21 18:49:34
The idle queue is disabled while the compositor is
| |
| 314 } | |
| 315 }; | |
| 298 | 316 |
| 299 static void postIdleGCTaskMainThread() | 317 static void postIdleGCTaskMainThread() |
| 300 { | 318 { |
| 301 if (RuntimeEnabledFeatures::v8IdleTasksEnabled()) { | 319 if (!RuntimeEnabledFeatures::v8IdleTasksEnabled()) |
|
eseidel
2014/10/21 16:11:02
Previously this was an assert?
Sami
2014/10/21 18:49:34
Sorry, the diff is a little confusing since I move
| |
| 302 Scheduler* scheduler = Scheduler::shared(); | 320 return; |
| 303 if (scheduler) | 321 if (WebScheduler* scheduler = Platform::current()->scheduler()) |
|
eseidel
2014/10/21 16:11:02
When do we ever have a platform but not have a sch
Sami
2014/10/21 18:49:34
Initially I thought we would need this for the boo
| |
| 304 scheduler->postIdleTask(FROM_HERE, WTF::bind<double>(idleGCTaskInMai nThread)); | 322 scheduler->postIdleTask(FROM_HERE.toWebTraceLocation(), new IdleGCTaskIn MainThread()); |
|
eseidel
2014/10/21 16:11:02
We don't just have a shared task which we reuse?
Sami
2014/10/21 18:49:34
Yes, that's the best we can do with the current mo
| |
| 305 } | |
| 306 } | |
| 307 | |
| 308 static void idleGCTaskInMainThread(double deadlineSeconds) | |
| 309 { | |
| 310 ASSERT(isMainThread()); | |
| 311 ASSERT(RuntimeEnabledFeatures::v8IdleTasksEnabled()); | |
| 312 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | |
| 313 // FIXME: Change V8's API to take a deadline - http://crbug.com/417668 | |
| 314 double idleTimeInSeconds = deadlineSeconds - Platform::current()->monotonica llyIncreasingTime(); | |
| 315 int idleTimeInMillis = static_cast<int>(idleTimeInSeconds * 1000); | |
| 316 if (idleTimeInMillis > 0) | |
| 317 isolate->IdleNotification(idleTimeInMillis); | |
| 318 // FIXME: only repost if there is more work to do. | |
| 319 postIdleGCTaskMainThread(); | |
| 320 } | 323 } |
| 321 | 324 |
| 322 static void timerTraceProfilerInMainThread(const char* name, int status) | 325 static void timerTraceProfilerInMainThread(const char* name, int status) |
| 323 { | 326 { |
| 324 if (!status) { | 327 if (!status) { |
| 325 TRACE_EVENT_BEGIN0("v8", name); | 328 TRACE_EVENT_BEGIN0("v8", name); |
| 326 } else { | 329 } else { |
| 327 TRACE_EVENT_END0("v8", name); | 330 TRACE_EVENT_END0("v8", name); |
| 328 } | 331 } |
| 329 } | 332 } |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 410 initializeV8Common(isolate); | 413 initializeV8Common(isolate); |
| 411 | 414 |
| 412 v8::V8::AddMessageListener(messageHandlerInWorker); | 415 v8::V8::AddMessageListener(messageHandlerInWorker); |
| 413 v8::V8::SetFatalErrorHandler(reportFatalErrorInWorker); | 416 v8::V8::SetFatalErrorHandler(reportFatalErrorInWorker); |
| 414 | 417 |
| 415 uint32_t here; | 418 uint32_t here; |
| 416 isolate->SetStackLimit(reinterpret_cast<uintptr_t>(&here - kWorkerMaxStackSi ze / sizeof(uint32_t*))); | 419 isolate->SetStackLimit(reinterpret_cast<uintptr_t>(&here - kWorkerMaxStackSi ze / sizeof(uint32_t*))); |
| 417 } | 420 } |
| 418 | 421 |
| 419 } // namespace blink | 422 } // namespace blink |
| OLD | NEW |