| 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 22 matching lines...) Expand all Loading... |
| 33 #include "bindings/core/v8/ScriptController.h" | 33 #include "bindings/core/v8/ScriptController.h" |
| 34 #include "bindings/core/v8/ScriptValue.h" | 34 #include "bindings/core/v8/ScriptValue.h" |
| 35 #include "bindings/core/v8/SourceLocation.h" | 35 #include "bindings/core/v8/SourceLocation.h" |
| 36 #include "bindings/core/v8/UseCounterCallback.h" | 36 #include "bindings/core/v8/UseCounterCallback.h" |
| 37 #include "bindings/core/v8/V8BindingForCore.h" | 37 #include "bindings/core/v8/V8BindingForCore.h" |
| 38 #include "bindings/core/v8/V8DOMException.h" | 38 #include "bindings/core/v8/V8DOMException.h" |
| 39 #include "bindings/core/v8/V8ErrorEvent.h" | 39 #include "bindings/core/v8/V8ErrorEvent.h" |
| 40 #include "bindings/core/v8/V8ErrorHandler.h" | 40 #include "bindings/core/v8/V8ErrorHandler.h" |
| 41 #include "bindings/core/v8/V8GCController.h" | 41 #include "bindings/core/v8/V8GCController.h" |
| 42 #include "bindings/core/v8/V8IdleTaskRunner.h" | 42 #include "bindings/core/v8/V8IdleTaskRunner.h" |
| 43 #include "bindings/core/v8/V8SnapshotCreator.h" |
| 43 #include "bindings/core/v8/WorkerOrWorkletScriptController.h" | 44 #include "bindings/core/v8/WorkerOrWorkletScriptController.h" |
| 44 #include "core/dom/Document.h" | 45 #include "core/dom/Document.h" |
| 45 #include "core/dom/ExecutionContext.h" | 46 #include "core/dom/ExecutionContext.h" |
| 46 #include "core/frame/LocalDOMWindow.h" | 47 #include "core/frame/LocalDOMWindow.h" |
| 47 #include "core/frame/csp/ContentSecurityPolicy.h" | 48 #include "core/frame/csp/ContentSecurityPolicy.h" |
| 48 #include "core/inspector/ConsoleMessage.h" | 49 #include "core/inspector/ConsoleMessage.h" |
| 49 #include "core/inspector/MainThreadDebugger.h" | 50 #include "core/inspector/MainThreadDebugger.h" |
| 50 #include "core/workers/WorkerGlobalScope.h" | 51 #include "core/workers/WorkerGlobalScope.h" |
| 51 #include "platform/EventDispatchForbiddenScope.h" | 52 #include "platform/EventDispatchForbiddenScope.h" |
| 52 #include "platform/RuntimeEnabledFeatures.h" | 53 #include "platform/RuntimeEnabledFeatures.h" |
| (...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 WTF::ArrayBufferContents::Initialize(AdjustAmountOfExternalAllocatedMemory); | 428 WTF::ArrayBufferContents::Initialize(AdjustAmountOfExternalAllocatedMemory); |
| 428 | 429 |
| 429 DEFINE_STATIC_LOCAL(ArrayBufferAllocator, array_buffer_allocator, ()); | 430 DEFINE_STATIC_LOCAL(ArrayBufferAllocator, array_buffer_allocator, ()); |
| 430 auto v8_extras_mode = RuntimeEnabledFeatures::experimentalV8ExtrasEnabled() | 431 auto v8_extras_mode = RuntimeEnabledFeatures::experimentalV8ExtrasEnabled() |
| 431 ? gin::IsolateHolder::kStableAndExperimentalV8Extras | 432 ? gin::IsolateHolder::kStableAndExperimentalV8Extras |
| 432 : gin::IsolateHolder::kStableV8Extras; | 433 : gin::IsolateHolder::kStableV8Extras; |
| 433 gin::IsolateHolder::Initialize(gin::IsolateHolder::kNonStrictMode, | 434 gin::IsolateHolder::Initialize(gin::IsolateHolder::kNonStrictMode, |
| 434 v8_extras_mode, &array_buffer_allocator); | 435 v8_extras_mode, &array_buffer_allocator); |
| 435 | 436 |
| 436 // NOTE: Some threads (namely utility threads) don't have a scheduler. | 437 // NOTE: Some threads (namely utility threads) don't have a scheduler. |
| 437 WebScheduler* scheduler = Platform::Current()->CurrentThread()->Scheduler(); | 438 WebThread* thread = Platform::Current()->CurrentThread(); |
| 439 WebScheduler* scheduler = thread ? thread->Scheduler() : nullptr; |
| 440 |
| 438 // When timer task runner is used for PerIsolateData, GC tasks are getting | 441 // When timer task runner is used for PerIsolateData, GC tasks are getting |
| 439 // throttled and memory usage goes up. For now we're using loading task queue | 442 // throttled and memory usage goes up. For now we're using loading task queue |
| 440 // to prevent this. | 443 // to prevent this. |
| 441 // TODO(altimin): Consider switching to timerTaskRunner here. | 444 // TODO(altimin): Consider switching to timerTaskRunner here. |
| 442 v8::Isolate* isolate = V8PerIsolateData::Initialize( | 445 v8::Isolate* isolate = V8PerIsolateData::Initialize( |
| 443 scheduler ? scheduler->LoadingTaskRunner() | 446 scheduler ? scheduler->LoadingTaskRunner() |
| 444 : Platform::Current()->CurrentThread()->GetWebTaskRunner()); | 447 : thread ? thread->GetWebTaskRunner() : nullptr, |
| 448 V8SnapshotCreator::GetReferenceTable(), |
| 449 V8SnapshotCreator::TakingSnapshot() ? gin::IsolateHolder::kTakeSnapshot |
| 450 : gin::IsolateHolder::kUseSnapshot); |
| 445 | 451 |
| 446 InitializeV8Common(isolate); | 452 InitializeV8Common(isolate); |
| 447 | 453 |
| 448 isolate->SetOOMErrorHandler(ReportOOMErrorInMainThread); | 454 isolate->SetOOMErrorHandler(ReportOOMErrorInMainThread); |
| 449 isolate->SetFatalErrorHandler(ReportFatalErrorInMainThread); | 455 isolate->SetFatalErrorHandler(ReportFatalErrorInMainThread); |
| 450 isolate->AddMessageListenerWithErrorLevel( | 456 isolate->AddMessageListenerWithErrorLevel( |
| 451 MessageHandlerInMainThread, | 457 MessageHandlerInMainThread, |
| 452 v8::Isolate::kMessageError | v8::Isolate::kMessageWarning | | 458 v8::Isolate::kMessageError | v8::Isolate::kMessageWarning | |
| 453 v8::Isolate::kMessageInfo | v8::Isolate::kMessageDebug | | 459 v8::Isolate::kMessageInfo | v8::Isolate::kMessageDebug | |
| 454 v8::Isolate::kMessageLog); | 460 v8::Isolate::kMessageLog); |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 558 v8::Isolate::kMessageLog); | 564 v8::Isolate::kMessageLog); |
| 559 isolate->SetFatalErrorHandler(ReportFatalErrorInWorker); | 565 isolate->SetFatalErrorHandler(ReportFatalErrorInWorker); |
| 560 | 566 |
| 561 uint32_t here; | 567 uint32_t here; |
| 562 isolate->SetStackLimit(reinterpret_cast<uintptr_t>(&here) - | 568 isolate->SetStackLimit(reinterpret_cast<uintptr_t>(&here) - |
| 563 kWorkerMaxStackSize); | 569 kWorkerMaxStackSize); |
| 564 isolate->SetPromiseRejectCallback(PromiseRejectHandlerInWorker); | 570 isolate->SetPromiseRejectCallback(PromiseRejectHandlerInWorker); |
| 565 } | 571 } |
| 566 | 572 |
| 567 } // namespace blink | 573 } // namespace blink |
| OLD | NEW |