summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/Cargo.toml2
-rw-r--r--core/bindings.rs16
-rw-r--r--core/runtime.rs13
3 files changed, 25 insertions, 6 deletions
diff --git a/core/Cargo.toml b/core/Cargo.toml
index 7f9b5072f..61c38521d 100644
--- a/core/Cargo.toml
+++ b/core/Cargo.toml
@@ -33,7 +33,7 @@ serde_json = { version = "1.0.79", features = ["preserve_order"] }
serde_v8 = { version = "0.58.0", path = "../serde_v8" }
sourcemap = "=6.0.1"
url = { version = "2.2.2", features = ["serde"] }
-v8 = { version = "0.47.1", default-features = false }
+v8 = { version = "0.48.1", default-features = false }
[[example]]
name = "http_bench_json_ops"
diff --git a/core/bindings.rs b/core/bindings.rs
index aef479472..f3c16acbf 100644
--- a/core/bindings.rs
+++ b/core/bindings.rs
@@ -140,6 +140,22 @@ pub fn set_func_raw(
obj.set(scope, key.into(), val.into());
}
+pub extern "C" fn wasm_async_resolve_promise_callback(
+ _isolate: *mut v8::Isolate,
+ context: v8::Local<v8::Context>,
+ resolver: v8::Local<v8::PromiseResolver>,
+ compilation_result: v8::Local<v8::Value>,
+ success: v8::WasmAsyncSuccess,
+) {
+ // SAFETY: `CallbackScope` can be safely constructed from `Local<Context>`
+ let scope = &mut unsafe { v8::CallbackScope::new(context) };
+ if success == v8::WasmAsyncSuccess::Success {
+ resolver.resolve(scope, compilation_result).unwrap();
+ } else {
+ resolver.reject(scope, compilation_result).unwrap();
+ }
+}
+
pub extern "C" fn host_import_module_dynamically_callback(
context: v8::Local<v8::Context>,
_host_defined_options: v8::Local<v8::Data>,
diff --git a/core/runtime.rs b/core/runtime.rs
index 541aa7c02..7f113223f 100644
--- a/core/runtime.rs
+++ b/core/runtime.rs
@@ -227,11 +227,6 @@ fn v8_init(
static ICU_DATA: IcuData = IcuData(*include_bytes!("icudtl.dat"));
v8::icu::set_common_data_71(&ICU_DATA.0).unwrap();
- let v8_platform = v8_platform
- .unwrap_or_else(|| v8::new_default_platform(0, false).make_shared());
- v8::V8::initialize_platform(v8_platform);
- v8::V8::initialize();
-
let flags = concat!(
" --experimental-wasm-threads",
" --wasm-test-streaming",
@@ -248,6 +243,11 @@ fn v8_init(
} else {
v8::V8::set_flags_from_string(flags);
}
+
+ let v8_platform = v8_platform
+ .unwrap_or_else(|| v8::new_default_platform(0, false).make_shared());
+ v8::V8::initialize_platform(v8_platform);
+ v8::V8::initialize();
}
#[derive(Default)]
@@ -516,6 +516,9 @@ impl JsRuntime {
isolate.set_host_import_module_dynamically_callback(
bindings::host_import_module_dynamically_callback,
);
+ isolate.set_wasm_async_resolve_promise_callback(
+ bindings::wasm_async_resolve_promise_callback,
+ );
isolate
}