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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 #include "core/frame/LocalDOMWindow.h" | 49 #include "core/frame/LocalDOMWindow.h" |
50 #include "core/frame/LocalFrame.h" | 50 #include "core/frame/LocalFrame.h" |
51 #include "core/frame/csp/ContentSecurityPolicy.h" | 51 #include "core/frame/csp/ContentSecurityPolicy.h" |
52 #include "core/inspector/ScriptArguments.h" | 52 #include "core/inspector/ScriptArguments.h" |
53 #include "core/inspector/ScriptCallStack.h" | 53 #include "core/inspector/ScriptCallStack.h" |
54 #include "core/workers/WorkerGlobalScope.h" | 54 #include "core/workers/WorkerGlobalScope.h" |
55 #include "platform/EventDispatchForbiddenScope.h" | 55 #include "platform/EventDispatchForbiddenScope.h" |
56 #include "platform/RuntimeEnabledFeatures.h" | 56 #include "platform/RuntimeEnabledFeatures.h" |
57 #include "platform/TraceEvent.h" | 57 #include "platform/TraceEvent.h" |
58 #include "platform/heap/AddressSanitizer.h" | 58 #include "platform/heap/AddressSanitizer.h" |
59 #include "platform/scheduler/Scheduler.h" | |
60 #include "public/platform/Platform.h" | 59 #include "public/platform/Platform.h" |
| 60 #include "public/platform/WebScheduler.h" |
| 61 #include "public/platform/WebThread.h" |
61 #include "wtf/ArrayBufferContents.h" | 62 #include "wtf/ArrayBufferContents.h" |
62 #include "wtf/RefPtr.h" | 63 #include "wtf/RefPtr.h" |
63 #include "wtf/text/WTFString.h" | 64 #include "wtf/text/WTFString.h" |
64 #include <v8-debug.h> | 65 #include <v8-debug.h> |
65 | 66 |
66 namespace blink { | 67 namespace blink { |
67 | 68 |
68 static Frame* findFrame(v8::Local<v8::Object> host, v8::Local<v8::Value> data, v
8::Isolate* isolate) | 69 static Frame* findFrame(v8::Local<v8::Object> host, v8::Local<v8::Value> data, v
8::Isolate* isolate) |
69 { | 70 { |
70 const WrapperTypeInfo* type = WrapperTypeInfo::unwrap(data); | 71 const WrapperTypeInfo* type = WrapperTypeInfo::unwrap(data); |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 } | 314 } |
314 return false; | 315 return false; |
315 } | 316 } |
316 | 317 |
317 static void idleGCTaskInMainThread(double deadlineSeconds) | 318 static void idleGCTaskInMainThread(double deadlineSeconds) |
318 { | 319 { |
319 ASSERT(isMainThread()); | 320 ASSERT(isMainThread()); |
320 ASSERT(RuntimeEnabledFeatures::v8IdleTasksEnabled()); | 321 ASSERT(RuntimeEnabledFeatures::v8IdleTasksEnabled()); |
321 bool gcFinished = false; | 322 bool gcFinished = false; |
322 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 323 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
323 if (deadlineSeconds > Platform::current()->monotonicallyIncreasingTime()) | 324 |
| 325 Platform* platform = Platform::current(); |
| 326 if (deadlineSeconds > platform->monotonicallyIncreasingTime()) |
324 gcFinished = isolate->IdleNotificationDeadline(deadlineSeconds); | 327 gcFinished = isolate->IdleNotificationDeadline(deadlineSeconds); |
325 | 328 |
326 Scheduler* scheduler = Scheduler::shared(); | |
327 ASSERT(scheduler); | |
328 if (gcFinished) | 329 if (gcFinished) |
329 scheduler->postIdleTaskAfterWakeup(FROM_HERE, WTF::bind<double>(idleGCTa
skInMainThread)); | 330 platform->currentThread()->scheduler()->postIdleTaskAfterWakeup(FROM_HER
E, WTF::bind<double>(idleGCTaskInMainThread)); |
330 else | 331 else |
331 scheduler->postIdleTask(FROM_HERE, WTF::bind<double>(idleGCTaskInMainThr
ead)); | 332 platform->currentThread()->scheduler()->postIdleTask(FROM_HERE, WTF::bin
d<double>(idleGCTaskInMainThread)); |
332 } | 333 } |
333 | 334 |
334 static void timerTraceProfilerInMainThread(const char* name, int status) | 335 static void timerTraceProfilerInMainThread(const char* name, int status) |
335 { | 336 { |
336 if (!status) { | 337 if (!status) { |
337 TRACE_EVENT_BEGIN0("v8", name); | 338 TRACE_EVENT_BEGIN0("v8", name); |
338 } else { | 339 } else { |
339 TRACE_EVENT_END0("v8", name); | 340 TRACE_EVENT_END0("v8", name); |
340 } | 341 } |
341 } | 342 } |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 v8::Isolate* isolate = V8PerIsolateData::initialize(); | 391 v8::Isolate* isolate = V8PerIsolateData::initialize(); |
391 | 392 |
392 initializeV8Common(isolate); | 393 initializeV8Common(isolate); |
393 | 394 |
394 v8::V8::SetFatalErrorHandler(reportFatalErrorInMainThread); | 395 v8::V8::SetFatalErrorHandler(reportFatalErrorInMainThread); |
395 v8::V8::AddMessageListener(messageHandlerInMainThread); | 396 v8::V8::AddMessageListener(messageHandlerInMainThread); |
396 v8::V8::SetFailedAccessCheckCallbackFunction(failedAccessCheckCallbackInMain
Thread); | 397 v8::V8::SetFailedAccessCheckCallbackFunction(failedAccessCheckCallbackInMain
Thread); |
397 v8::V8::SetAllowCodeGenerationFromStringsCallback(codeGenerationCheckCallbac
kInMainThread); | 398 v8::V8::SetAllowCodeGenerationFromStringsCallback(codeGenerationCheckCallbac
kInMainThread); |
398 | 399 |
399 if (RuntimeEnabledFeatures::v8IdleTasksEnabled()) | 400 if (RuntimeEnabledFeatures::v8IdleTasksEnabled()) |
400 Scheduler::shared()->postIdleTask(FROM_HERE, WTF::bind<double>(idleGCTas
kInMainThread)); | 401 Platform::current()->currentThread()->scheduler()->postIdleTask(FROM_HER
E, WTF::bind<double>(idleGCTaskInMainThread)); |
401 | 402 |
402 isolate->SetEventLogger(timerTraceProfilerInMainThread); | 403 isolate->SetEventLogger(timerTraceProfilerInMainThread); |
403 isolate->SetPromiseRejectCallback(promiseRejectHandlerInMainThread); | 404 isolate->SetPromiseRejectCallback(promiseRejectHandlerInMainThread); |
404 | 405 |
405 ScriptProfiler::initialize(); | 406 ScriptProfiler::initialize(); |
406 } | 407 } |
407 | 408 |
408 static void reportFatalErrorInWorker(const char* location, const char* message) | 409 static void reportFatalErrorInWorker(const char* location, const char* message) |
409 { | 410 { |
410 // FIXME: We temporarily deal with V8 internal error situations such as out-
of-memory by crashing the worker. | 411 // FIXME: We temporarily deal with V8 internal error situations such as out-
of-memory by crashing the worker. |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 | 461 |
461 v8::V8::AddMessageListener(messageHandlerInWorker); | 462 v8::V8::AddMessageListener(messageHandlerInWorker); |
462 v8::V8::SetFatalErrorHandler(reportFatalErrorInWorker); | 463 v8::V8::SetFatalErrorHandler(reportFatalErrorInWorker); |
463 | 464 |
464 uint32_t here; | 465 uint32_t here; |
465 isolate->SetStackLimit(reinterpret_cast<uintptr_t>(&here - kWorkerMaxStackSi
ze / sizeof(uint32_t*))); | 466 isolate->SetStackLimit(reinterpret_cast<uintptr_t>(&here - kWorkerMaxStackSi
ze / sizeof(uint32_t*))); |
466 isolate->SetPromiseRejectCallback(promiseRejectHandlerInWorker); | 467 isolate->SetPromiseRejectCallback(promiseRejectHandlerInWorker); |
467 } | 468 } |
468 | 469 |
469 } // namespace blink | 470 } // namespace blink |
OLD | NEW |