diff --git a/gin/isolate_holder.cc b/gin/isolate_holder.cc index d7619f995c991c..620e9c85491b53 100644 --- a/gin/isolate_holder.cc +++ b/gin/isolate_holder.cc @@ -75,10 +75,19 @@ IsolateHolder::IsolateHolder( IsolateHolder::IsolateHolder(const intptr_t* reference_table, v8::StartupData* existing_blob) - : snapshot_creator_( - new v8::SnapshotCreator(reference_table, existing_blob)), - isolate_(snapshot_creator_->GetIsolate()), - access_mode_(AccessMode::kSingleThread) { + : access_mode_(AccessMode::kSingleThread) { + CHECK(existing_blob); + + v8::StartupData unused_natives; + V8Initializer::GetV8ExternalSnapshotData(&unused_natives, existing_blob); + if (!existing_blob->data) { + existing_blob = nullptr; + } + + snapshot_creator_.reset( + new v8::SnapshotCreator(reference_table, existing_blob)); + isolate_ = snapshot_creator_->GetIsolate(); + SetUp(nullptr); } diff --git a/third_party/WebKit/Source/platform/bindings/V8PerIsolateData.cpp b/third_party/WebKit/Source/platform/bindings/V8PerIsolateData.cpp index e6ea7b17fc2781..990035a48ee5ee 100644 --- a/third_party/WebKit/Source/platform/bindings/V8PerIsolateData.cpp +++ b/third_party/WebKit/Source/platform/bindings/V8PerIsolateData.cpp @@ -39,6 +39,7 @@ #include "public/platform/Platform.h" #include "public/web/WebKit.h" #include "v8/include/v8-debug.h" +#include "v8/include/v8.h" namespace blink { @@ -97,7 +98,7 @@ V8PerIsolateData::V8PerIsolateData( // main thread. V8PerIsolateData::V8PerIsolateData(const intptr_t* reference_table) : v8_context_snapshot_mode_(V8ContextSnapshotMode::kTakeSnapshot), - isolate_holder_(reference_table, nullptr), + isolate_holder_(reference_table, &startup_data_), interface_template_map_for_v8_context_snapshot_(GetIsolate()), string_cache_(WTF::WrapUnique(new StringCache(GetIsolate()))), private_property_(V8PrivateProperty::Create()), diff --git a/third_party/WebKit/Source/platform/bindings/V8PerIsolateData.h b/third_party/WebKit/Source/platform/bindings/V8PerIsolateData.h index 10475068e067d3..7ee8909fafb34f 100644 --- a/third_party/WebKit/Source/platform/bindings/V8PerIsolateData.h +++ b/third_party/WebKit/Source/platform/bindings/V8PerIsolateData.h @@ -288,8 +288,7 @@ class PLATFORM_EXPORT V8PerIsolateData { HashMap>> eternal_name_cache_; // Members required for the V8 context snapshot. - // v8::Context is created from this blob data image. This needs to be - // instantiated before |isolate_holder_| gets instantiated. + // v8::Context is created from this blob data image. v8::StartupData startup_data_; // When taking a V8 context snapshot, we can't keep V8 objects with eternal // handles. So we use a special interface map that doesn't use eternal handles