electron/patches/common/chromium/isolate_holder.patch
2018-12-03 20:07:37 +05:30

50 lines
2.1 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.
diff --git a/gin/isolate_holder.cc b/gin/isolate_holder.cc
index 8ec7775b78b3645dbac5ee518404ca9a70122153..c82ca4d00398cb01ffea20b8d8d937329e764e45 100644
--- a/gin/isolate_holder.cc
+++ b/gin/isolate_holder.cc
@@ -52,7 +52,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());
@@ -60,7 +61,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_.reset(
new 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 535b0caa02f89f8a0fde841057d35e3834ea087f..c68d45722b50654fb92efeea28f5a0d4c9018b49 100644
--- a/gin/public/isolate_holder.h
+++ b/gin/public/isolate_holder.h
@@ -80,7 +80,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();
// Should be invoked once before creating IsolateHolder instances to