2023-08-31 00:38:07 +00:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Samuel Attard <marshallofsound@electronjs.org>
|
|
|
|
Date: Wed, 8 Mar 2023 13:04:21 -0800
|
|
|
|
Subject: refactor: expose HostImportModuleDynamically and
|
|
|
|
HostGetImportMetaProperties to embedders
|
|
|
|
|
|
|
|
This is so that Electron can blend Blink's and Node's implementations of these isolate handlers.
|
|
|
|
|
|
|
|
diff --git a/third_party/blink/renderer/bindings/core/v8/v8_initializer.cc b/third_party/blink/renderer/bindings/core/v8/v8_initializer.cc
|
2023-10-02 22:01:07 +00:00
|
|
|
index 9af71550493e372f3be34d0e8ad03ab2ae0413f0..f5fe8904e052289dfa7f83e4de3b053ec8b69f83 100644
|
2023-08-31 00:38:07 +00:00
|
|
|
--- a/third_party/blink/renderer/bindings/core/v8/v8_initializer.cc
|
|
|
|
+++ b/third_party/blink/renderer/bindings/core/v8/v8_initializer.cc
|
2023-10-02 22:01:07 +00:00
|
|
|
@@ -598,7 +598,9 @@ bool JavaScriptCompileHintsMagicEnabledCallback(
|
2023-08-31 00:38:07 +00:00
|
|
|
execution_context);
|
|
|
|
}
|
|
|
|
|
|
|
|
-v8::MaybeLocal<v8::Promise> HostImportModuleDynamically(
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+v8::MaybeLocal<v8::Promise> V8Initializer::HostImportModuleDynamically(
|
|
|
|
v8::Local<v8::Context> context,
|
|
|
|
v8::Local<v8::Data> v8_host_defined_options,
|
|
|
|
v8::Local<v8::Value> v8_referrer_resource_url,
|
2023-10-02 22:01:07 +00:00
|
|
|
@@ -674,7 +676,7 @@ v8::MaybeLocal<v8::Promise> HostImportModuleDynamically(
|
2023-08-31 00:38:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// https://html.spec.whatwg.org/C/#hostgetimportmetaproperties
|
|
|
|
-void HostGetImportMetaProperties(v8::Local<v8::Context> context,
|
|
|
|
+void V8Initializer::HostGetImportMetaProperties(v8::Local<v8::Context> context,
|
|
|
|
v8::Local<v8::Module> module,
|
|
|
|
v8::Local<v8::Object> meta) {
|
|
|
|
ScriptState* script_state = ScriptState::From(context);
|
2023-10-02 22:01:07 +00:00
|
|
|
@@ -701,6 +703,8 @@ void HostGetImportMetaProperties(v8::Local<v8::Context> context,
|
2023-08-31 00:38:07 +00:00
|
|
|
meta->CreateDataProperty(context, resolve_key, resolve_value).ToChecked();
|
|
|
|
}
|
|
|
|
|
|
|
|
+namespace {
|
|
|
|
+
|
|
|
|
void InitializeV8Common(v8::Isolate* isolate) {
|
|
|
|
// Set up garbage collection before setting up anything else as V8 may trigger
|
|
|
|
// GCs during Blink setup.
|
2023-10-02 22:01:07 +00:00
|
|
|
@@ -722,9 +726,9 @@ void InitializeV8Common(v8::Isolate* isolate) {
|
2023-08-31 00:38:07 +00:00
|
|
|
SharedArrayBufferConstructorEnabledCallback);
|
|
|
|
isolate->SetJavaScriptCompileHintsMagicEnabledCallback(
|
|
|
|
JavaScriptCompileHintsMagicEnabledCallback);
|
|
|
|
- isolate->SetHostImportModuleDynamicallyCallback(HostImportModuleDynamically);
|
|
|
|
+ isolate->SetHostImportModuleDynamicallyCallback(V8Initializer::HostImportModuleDynamically);
|
|
|
|
isolate->SetHostInitializeImportMetaObjectCallback(
|
|
|
|
- HostGetImportMetaProperties);
|
|
|
|
+ V8Initializer::HostGetImportMetaProperties);
|
|
|
|
isolate->SetMetricsRecorder(std::make_shared<V8MetricsRecorder>(isolate));
|
|
|
|
|
2023-09-18 20:44:09 +00:00
|
|
|
#if BUILDFLAG(IS_WIN)
|
2023-08-31 00:38:07 +00:00
|
|
|
diff --git a/third_party/blink/renderer/bindings/core/v8/v8_initializer.h b/third_party/blink/renderer/bindings/core/v8/v8_initializer.h
|
2023-09-01 08:28:01 +00:00
|
|
|
index 9e628b96a845322d407f9da30a63c04ef5de9c24..8f5e4602f5e3f6787a9e54d510b39519074d51e6 100644
|
2023-08-31 00:38:07 +00:00
|
|
|
--- a/third_party/blink/renderer/bindings/core/v8/v8_initializer.h
|
|
|
|
+++ b/third_party/blink/renderer/bindings/core/v8/v8_initializer.h
|
2023-09-01 08:28:01 +00:00
|
|
|
@@ -76,6 +76,17 @@ class CORE_EXPORT V8Initializer {
|
2023-08-31 00:38:07 +00:00
|
|
|
v8::Local<v8::Context> context,
|
|
|
|
v8::Local<v8::String> source);
|
|
|
|
|
|
|
|
+ static v8::MaybeLocal<v8::Promise> HostImportModuleDynamically(
|
|
|
|
+ v8::Local<v8::Context> context,
|
|
|
|
+ v8::Local<v8::Data> v8_host_defined_options,
|
|
|
|
+ v8::Local<v8::Value> v8_referrer_resource_url,
|
|
|
|
+ v8::Local<v8::String> v8_specifier,
|
|
|
|
+ v8::Local<v8::FixedArray> v8_import_assertions);
|
|
|
|
+
|
|
|
|
+ static void HostGetImportMetaProperties(v8::Local<v8::Context> context,
|
|
|
|
+ v8::Local<v8::Module> module,
|
|
|
|
+ v8::Local<v8::Object> meta);
|
|
|
|
+
|
|
|
|
static void WasmAsyncResolvePromiseCallback(
|
|
|
|
v8::Isolate* isolate,
|
|
|
|
v8::Local<v8::Context> context,
|