| Index: third_party/WebKit/Source/bindings/core/v8/V8Initializer.cpp
|
| diff --git a/third_party/WebKit/Source/bindings/core/v8/V8Initializer.cpp b/third_party/WebKit/Source/bindings/core/v8/V8Initializer.cpp
|
| index b9517bb7b0b0b823b2d98ea918473074ead2017a..378571aa2bd183eb80204ae0814645cfa246d7b1 100644
|
| --- a/third_party/WebKit/Source/bindings/core/v8/V8Initializer.cpp
|
| +++ b/third_party/WebKit/Source/bindings/core/v8/V8Initializer.cpp
|
| @@ -40,6 +40,7 @@
|
| #include "bindings/core/v8/V8ErrorHandler.h"
|
| #include "bindings/core/v8/V8GCController.h"
|
| #include "bindings/core/v8/V8IdleTaskRunner.h"
|
| +#include "bindings/core/v8/V8SnapshotCreator.h"
|
| #include "bindings/core/v8/WorkerOrWorkletScriptController.h"
|
| #include "core/dom/Document.h"
|
| #include "core/dom/ExecutionContext.h"
|
| @@ -380,6 +381,9 @@ static void InitializeV8Common(v8::Isolate* isolate) {
|
| isolate->SetUseCounterCallback(&UseCounterCallback);
|
| isolate->SetWasmModuleCallback(WasmModuleOverride);
|
| isolate->SetWasmInstanceCallback(WasmInstanceOverride);
|
| +
|
| + v8::HandleScope handle_scope(isolate);
|
| + V8SnapshotCreator::EnsureInterfaceTemplates(isolate);
|
| }
|
|
|
| namespace {
|
| @@ -421,7 +425,7 @@ static void AdjustAmountOfExternalAllocatedMemory(int64_t diff) {
|
| v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(diff);
|
| }
|
|
|
| -void V8Initializer::InitializeMainThread() {
|
| +void V8Initializer::InitializeMainThread(bool take_snapshot) {
|
| DCHECK(IsMainThread());
|
|
|
| WTF::ArrayBufferContents::Initialize(AdjustAmountOfExternalAllocatedMemory);
|
| @@ -434,14 +438,19 @@ void V8Initializer::InitializeMainThread() {
|
| v8_extras_mode, &array_buffer_allocator);
|
|
|
| // NOTE: Some threads (namely utility threads) don't have a scheduler.
|
| - WebScheduler* scheduler = Platform::Current()->CurrentThread()->Scheduler();
|
| + WebThread* thread = Platform::Current()->CurrentThread();
|
| + WebScheduler* scheduler = thread ? thread->Scheduler() : nullptr;
|
| +
|
| // When timer task runner is used for PerIsolateData, GC tasks are getting
|
| // throttled and memory usage goes up. For now we're using loading task queue
|
| // to prevent this.
|
| // TODO(altimin): Consider switching to timerTaskRunner here.
|
| v8::Isolate* isolate = V8PerIsolateData::Initialize(
|
| scheduler ? scheduler->LoadingTaskRunner()
|
| - : Platform::Current()->CurrentThread()->GetWebTaskRunner());
|
| + : thread ? thread->GetWebTaskRunner() : nullptr,
|
| + V8SnapshotCreator::GetReferenceTable(),
|
| + take_snapshot ? V8PerIsolateData::V8ContextMode::kTakeSnapshot
|
| + : V8PerIsolateData::V8ContextMode::kUseSnapshot);
|
|
|
| InitializeV8Common(isolate);
|
|
|
|
|