electron/patches/chromium/gin_enable_disable_v8_platform.patch
2022-08-17 11:35:53 -07:00

77 lines
4 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Cheng Zhao <zcbenz@gmail.com>
Date: Thu, 20 Sep 2018 17:47:44 -0700
Subject: gin_enable_disable_v8_platform.patch
We don't use gin to create the V8 platform, because we need to inject Node
things.
diff --git a/gin/isolate_holder.cc b/gin/isolate_holder.cc
index 88f9e4dd05d8efdabbbdd044f5e09e844ced3d55..c254b045494936eca14ce947e1c2de3327820aa2 100644
--- a/gin/isolate_holder.cc
+++ b/gin/isolate_holder.cc
@@ -137,9 +137,10 @@ void IsolateHolder::Initialize(ScriptMode mode,
const intptr_t* reference_table,
const std::string js_command_line_flags,
v8::FatalErrorCallback fatal_error_callback,
- v8::OOMErrorCallback oom_error_callback) {
+ v8::OOMErrorCallback oom_error_callback,
+ bool create_v8_platform) {
CHECK(allocator);
- V8Initializer::Initialize(mode, js_command_line_flags, oom_error_callback);
+ V8Initializer::Initialize(mode, js_command_line_flags, oom_error_callback, create_v8_platform);
g_array_buffer_allocator = allocator;
g_reference_table = reference_table;
g_fatal_error_callback = fatal_error_callback;
diff --git a/gin/public/isolate_holder.h b/gin/public/isolate_holder.h
index d7739924bc3c3daec848db52730bd60c72ff2d8a..78af701cb06f6cb1bdd9829b2fcc46c8d63f5c4f 100644
--- a/gin/public/isolate_holder.h
+++ b/gin/public/isolate_holder.h
@@ -109,7 +109,8 @@ class GIN_EXPORT IsolateHolder {
const intptr_t* reference_table = nullptr,
const std::string js_command_line_flags = {},
v8::FatalErrorCallback fatal_error_callback = nullptr,
- v8::OOMErrorCallback oom_error_callback = nullptr);
+ v8::OOMErrorCallback oom_error_callback = nullptr,
+ bool create_v8_platform = true);
// Returns whether `Initialize` has already been invoked in the process.
// Initialization is a one-way operation (i.e., this method cannot return
diff --git a/gin/v8_initializer.cc b/gin/v8_initializer.cc
index ab2affbcab0ca7eea0b908fd1dd75f36ef095385..952b3ba6247935053d9a080bced30e3b3c640dd4 100644
--- a/gin/v8_initializer.cc
+++ b/gin/v8_initializer.cc
@@ -362,7 +362,8 @@ void SetFlags(IsolateHolder::ScriptMode mode,
// static
void V8Initializer::Initialize(IsolateHolder::ScriptMode mode,
const std::string js_command_line_flags,
- v8::OOMErrorCallback oom_error_callback) {
+ v8::OOMErrorCallback oom_error_callback,
+ bool create_v8_platform) {
static bool v8_is_initialized = false;
if (v8_is_initialized)
return;
@@ -372,7 +373,8 @@ void V8Initializer::Initialize(IsolateHolder::ScriptMode mode,
// See https://crbug.com/v8/11043
SetFlags(mode, js_command_line_flags);
- v8::V8::InitializePlatform(V8Platform::Get());
+ if (create_v8_platform)
+ v8::V8::InitializePlatform(V8Platform::Get());
// Set this as early as possible in order to ensure OOM errors are reported
// correctly.
diff --git a/gin/v8_initializer.h b/gin/v8_initializer.h
index da5b4017b4a8128bf620d4b43d4c2d183719265b..13a120c7fe8e69a44793473f3124c33d572a07a3 100644
--- a/gin/v8_initializer.h
+++ b/gin/v8_initializer.h
@@ -31,7 +31,8 @@ class GIN_EXPORT V8Initializer {
// This should be called by IsolateHolder::Initialize().
static void Initialize(IsolateHolder::ScriptMode mode,
const std::string js_command_line_flags = {},
- v8::OOMErrorCallback oom_error_callback = nullptr);
+ v8::OOMErrorCallback oom_error_callback = nullptr,
+ bool create_v8_platform = true);
// Get address and size information for currently loaded snapshot.
// If no snapshot is loaded, the return values are null for addresses