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
|
2024-06-07 21:18:35 +00:00
|
|
|
index 61d35042fcd0aa7b632c34253bce42a00c8d732d..db074920753e6a7aec4ffad82f8f4296f6ab854b 100644
|
2018-10-03 07:06:40 +00:00
|
|
|
--- a/gin/isolate_holder.cc
|
|
|
|
+++ b/gin/isolate_holder.cc
|
2024-01-25 17:46:30 +00:00
|
|
|
@@ -75,7 +75,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,
|
2024-01-25 17:46:30 +00:00
|
|
|
@@ -84,7 +85,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,
|
2024-01-25 17:46:30 +00:00
|
|
|
@@ -92,7 +94,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";
|
2024-01-25 17:46:30 +00:00
|
|
|
@@ -103,7 +106,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();
|