electron/patches/chromium/isolate_holder.patch

57 lines
2.6 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Samuel Attard <samuel.r.attard@gmail.com>
Date: Thu, 18 Oct 2018 17:07:27 -0700
Subject: isolate_holder.patch
Pass pre allocated isolate for initialization, node platform
needs to register on an isolate so that it can be used later
down in the initialization process of an isolate.
Specifically, v8::Isolate::Initialize ends up calling
NodePlatform::GetForegroundTaskRunner, which requires that the
isolate has previously been registered with NodePlatform::RegisterIsolate.
However, if we let gin allocate the isolate, there's no opportunity
for us to register the isolate in between Isolate::Allocate and
Isolate::Initialize.
diff --git a/gin/isolate_holder.cc b/gin/isolate_holder.cc
index 9fd05f22c4f6d484c5cedfa1f38a147158726d42..2897c065246d5336d209d4e5a856fb984d06063f 100644
--- a/gin/isolate_holder.cc
+++ b/gin/isolate_holder.cc
@@ -53,7 +53,8 @@ IsolateHolder::IsolateHolder(
AccessMode access_mode,
AllowAtomicsWaitMode atomics_wait_mode,
IsolateType isolate_type,
- IsolateCreationMode isolate_creation_mode)
+ IsolateCreationMode isolate_creation_mode,
+ v8::Isolate* isolate)
: access_mode_(access_mode), isolate_type_(isolate_type) {
DCHECK(task_runner);
DCHECK(task_runner->BelongsToCurrentThread());
@@ -61,7 +62,11 @@ IsolateHolder::IsolateHolder(
v8::ArrayBuffer::Allocator* allocator = g_array_buffer_allocator;
CHECK(allocator) << "You need to invoke gin::IsolateHolder::Initialize first";
- isolate_ = v8::Isolate::Allocate();
+ if (!isolate) {
+ isolate_ = v8::Isolate::Allocate();
+ } else {
+ isolate_ = isolate;
+ }
isolate_data_ = std::make_unique<PerIsolateData>(isolate_, allocator,
access_mode_, task_runner);
if (isolate_creation_mode == IsolateCreationMode::kCreateSnapshot) {
diff --git a/gin/public/isolate_holder.h b/gin/public/isolate_holder.h
index 6bd634c4a66999648c51b8867c0d9b0ccbda78f1..d596a0e73fe6cd270d43109b7c9e8cc7021d3d60 100644
--- a/gin/public/isolate_holder.h
+++ b/gin/public/isolate_holder.h
@@ -74,7 +74,8 @@ class GIN_EXPORT IsolateHolder {
AccessMode access_mode,
AllowAtomicsWaitMode atomics_wait_mode,
IsolateType isolate_type,
- IsolateCreationMode isolate_creation_mode = IsolateCreationMode::kNormal);
+ IsolateCreationMode isolate_creation_mode = IsolateCreationMode::kNormal,
+ v8::Isolate* isolate = nullptr);
IsolateHolder(const IsolateHolder&) = delete;
IsolateHolder& operator=(const IsolateHolder&) = delete;
~IsolateHolder();