2018-10-24 18:24:11 +00:00
|
|
|
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.
|
|
|
|
|
2021-05-18 22:44:57 +00:00
|
|
|
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.
|
|
|
|
|
2018-10-03 07:06:40 +00:00
|
|
|
diff --git a/gin/isolate_holder.cc b/gin/isolate_holder.cc
|
2023-08-04 08:47:29 +00:00
|
|
|
index 1c3536a183aad1965e834b1681e36a3fc46ae419..1923f18cf2d4fff5094e6fe60bbef06b3e2cb06b 100644
|
2018-10-03 07:06:40 +00:00
|
|
|
--- a/gin/isolate_holder.cc
|
|
|
|
+++ b/gin/isolate_holder.cc
|
2023-08-04 08:47:29 +00:00
|
|
|
@@ -73,7 +73,8 @@ IsolateHolder::IsolateHolder(
|
2022-04-22 22:36:22 +00:00
|
|
|
IsolateCreationMode isolate_creation_mode,
|
2021-11-24 08:45:59 +00:00
|
|
|
v8::CreateHistogramCallback create_histogram_callback,
|
2023-08-04 08:47:29 +00:00
|
|
|
v8::AddHistogramSampleCallback add_histogram_sample_callback,
|
|
|
|
- scoped_refptr<base::SingleThreadTaskRunner> low_priority_task_runner)
|
|
|
|
+ scoped_refptr<base::SingleThreadTaskRunner> low_priority_task_runner,
|
2022-08-17 18:35:53 +00:00
|
|
|
+ v8::Isolate* isolate)
|
2023-08-04 08:47:29 +00:00
|
|
|
: IsolateHolder(std::move(task_runner),
|
2022-08-17 18:35:53 +00:00
|
|
|
access_mode,
|
|
|
|
isolate_type,
|
2023-08-04 08:47:29 +00:00
|
|
|
@@ -82,7 +83,8 @@ IsolateHolder::IsolateHolder(
|
2022-08-17 18:35:53 +00:00
|
|
|
create_histogram_callback,
|
|
|
|
add_histogram_sample_callback),
|
2023-08-04 08:47:29 +00:00
|
|
|
isolate_creation_mode,
|
|
|
|
- std::move(low_priority_task_runner)) {}
|
|
|
|
+ std::move(low_priority_task_runner),
|
2022-08-17 18:35:53 +00:00
|
|
|
+ isolate) {}
|
|
|
|
|
|
|
|
IsolateHolder::IsolateHolder(
|
|
|
|
scoped_refptr<base::SingleThreadTaskRunner> task_runner,
|
2023-08-04 08:47:29 +00:00
|
|
|
@@ -90,7 +92,8 @@ IsolateHolder::IsolateHolder(
|
2022-08-17 18:35:53 +00:00
|
|
|
IsolateType isolate_type,
|
|
|
|
std::unique_ptr<v8::Isolate::CreateParams> params,
|
2023-08-04 08:47:29 +00:00
|
|
|
IsolateCreationMode isolate_creation_mode,
|
|
|
|
- scoped_refptr<base::SingleThreadTaskRunner> low_priority_task_runner)
|
|
|
|
+ scoped_refptr<base::SingleThreadTaskRunner> low_priority_task_runner,
|
2018-10-05 18:40:17 +00:00
|
|
|
+ v8::Isolate* isolate)
|
2018-10-24 23:25:48 +00:00
|
|
|
: access_mode_(access_mode), isolate_type_(isolate_type) {
|
2021-07-26 16:02:16 +00:00
|
|
|
CHECK(Initialized())
|
|
|
|
<< "You need to invoke gin::IsolateHolder::Initialize first";
|
2023-08-04 08:47:29 +00:00
|
|
|
@@ -101,7 +104,7 @@ IsolateHolder::IsolateHolder(
|
2022-08-17 18:35:53 +00:00
|
|
|
v8::ArrayBuffer::Allocator* allocator = params->array_buffer_allocator;
|
2021-07-26 16:02:16 +00:00
|
|
|
DCHECK(allocator);
|
2018-10-03 07:06:40 +00:00
|
|
|
|
|
|
|
- isolate_ = v8::Isolate::Allocate();
|
2022-02-25 18:17:35 +00:00
|
|
|
+ isolate_ = isolate ? isolate : v8::Isolate::Allocate();
|
2023-08-04 08:47:29 +00:00
|
|
|
isolate_data_ = std::make_unique<PerIsolateData>(
|
|
|
|
isolate_, allocator, access_mode_, task_runner,
|
|
|
|
std::move(low_priority_task_runner));
|
2018-10-03 07:06:40 +00:00
|
|
|
diff --git a/gin/public/isolate_holder.h b/gin/public/isolate_holder.h
|
2023-08-04 08:47:29 +00:00
|
|
|
index a5db8841773618814ac90f740201d4d7e9057b3c..1368ab8bfbf9e69437b394a8376bf7c956ca13ce 100644
|
2018-10-03 07:06:40 +00:00
|
|
|
--- a/gin/public/isolate_holder.h
|
|
|
|
+++ b/gin/public/isolate_holder.h
|
2023-08-04 08:47:29 +00:00
|
|
|
@@ -85,7 +85,8 @@ class GIN_EXPORT IsolateHolder {
|
2021-11-24 08:45:59 +00:00
|
|
|
v8::CreateHistogramCallback create_histogram_callback = nullptr,
|
2023-08-04 08:47:29 +00:00
|
|
|
v8::AddHistogramSampleCallback add_histogram_sample_callback = nullptr,
|
|
|
|
scoped_refptr<base::SingleThreadTaskRunner> low_priority_task_runner =
|
|
|
|
- nullptr);
|
|
|
|
+ nullptr,
|
2022-08-17 18:35:53 +00:00
|
|
|
+ v8::Isolate* isolate = nullptr);
|
|
|
|
IsolateHolder(
|
|
|
|
scoped_refptr<base::SingleThreadTaskRunner> task_runner,
|
|
|
|
AccessMode access_mode,
|
2023-08-04 08:47:29 +00:00
|
|
|
@@ -93,7 +94,8 @@ class GIN_EXPORT IsolateHolder {
|
2022-08-17 18:35:53 +00:00
|
|
|
std::unique_ptr<v8::Isolate::CreateParams> params,
|
2023-08-04 08:47:29 +00:00
|
|
|
IsolateCreationMode isolate_creation_mode = IsolateCreationMode::kNormal,
|
|
|
|
scoped_refptr<base::SingleThreadTaskRunner> low_priority_task_runner =
|
|
|
|
- nullptr);
|
|
|
|
+ nullptr,
|
2018-10-05 18:40:17 +00:00
|
|
|
+ v8::Isolate* isolate = nullptr);
|
2021-04-27 21:27:34 +00:00
|
|
|
IsolateHolder(const IsolateHolder&) = delete;
|
|
|
|
IsolateHolder& operator=(const IsolateHolder&) = delete;
|
2018-10-03 07:06:40 +00:00
|
|
|
~IsolateHolder();
|