summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/00_primordials.js12
-rw-r--r--core/01_core.js7
-rw-r--r--core/02_error.js7
-rw-r--r--core/Cargo.toml11
-rw-r--r--core/extensions.rs148
-rw-r--r--core/modules/loaders.rs24
-rw-r--r--core/modules/tests.rs2
-rw-r--r--core/runtime/jsruntime.rs59
-rw-r--r--core/runtime/ops.rs2
-rw-r--r--core/runtime/snapshot_util.rs5
-rw-r--r--core/runtime/tests.rs46
11 files changed, 152 insertions, 171 deletions
diff --git a/core/00_primordials.js b/core/00_primordials.js
index 60474e649..998bfc7ab 100644
--- a/core/00_primordials.js
+++ b/core/00_primordials.js
@@ -34,6 +34,14 @@
"use strict";
(() => {
+ // Provide bootstrap namespace
+ globalThis.__bootstrap ??= {};
+ const key = Symbol.for("00_primordials.js");
+ if (globalThis.__bootstrap[key]) {
+ return;
+ }
+ globalThis.__bootstrap[key] = true;
+
const primordials = {};
const {
@@ -297,6 +305,7 @@
ArrayPrototypeJoin,
ArrayPrototypeMap,
FunctionPrototypeCall,
+ ObjectAssign,
ObjectDefineProperty,
ObjectFreeze,
ObjectPrototypeIsPrototypeOf,
@@ -610,6 +619,5 @@
ObjectSetPrototypeOf(primordials, null);
ObjectFreeze(primordials);
- // Provide bootstrap namespace
- globalThis.__bootstrap = { primordials };
+ ObjectAssign(globalThis.__bootstrap, { primordials });
})();
diff --git a/core/01_core.js b/core/01_core.js
index d4a6508cb..44da702ad 100644
--- a/core/01_core.js
+++ b/core/01_core.js
@@ -38,6 +38,13 @@
URIError,
setQueueMicrotask,
} = window.__bootstrap.primordials;
+
+ const key = SymbolFor("01_core.js");
+ if (globalThis.__bootstrap[key]) {
+ return;
+ }
+ globalThis.__bootstrap[key] = true;
+
const { ops, asyncOps } = window.Deno.core;
const build = {
diff --git a/core/02_error.js b/core/02_error.js
index b29dc9b4e..c082486f4 100644
--- a/core/02_error.js
+++ b/core/02_error.js
@@ -14,8 +14,15 @@
ArrayPrototypePush,
ArrayPrototypeMap,
ArrayPrototypeJoin,
+ SymbolFor,
} = window.__bootstrap.primordials;
+ const key = SymbolFor("02_error.js");
+ if (globalThis.__bootstrap[key]) {
+ return;
+ }
+ globalThis.__bootstrap[key] = true;
+
// Keep in sync with `cli/fmt_errors.rs`.
function formatLocation(cse) {
if (cse.isNative) {
diff --git a/core/Cargo.toml b/core/Cargo.toml
index 05da36f55..b89fe7585 100644
--- a/core/Cargo.toml
+++ b/core/Cargo.toml
@@ -16,7 +16,12 @@ path = "lib.rs"
[features]
default = ["v8_use_custom_libcxx"]
v8_use_custom_libcxx = ["v8/use_custom_libcxx"]
-include_js_files_for_snapshotting = []
+# Enable to exclude extension!() JS sources from the binary (e.g. if they are already snapshotted).
+exclude_js_sources = []
+# Read extension!() JS sources at 'runtime' instead of statically including them. They will be read
+# from their `CARGO_MANIFEST_DIR`-based paths, so it should only to be used in build and dev scripts
+# where these paths are available. Overrides `exclude_js_sources`.
+runtime_js_sources = ["exclude_js_sources"]
[dependencies]
anyhow.workspace = true
@@ -44,6 +49,8 @@ v8.workspace = true
name = "http_bench_json_ops"
path = "examples/http_bench_json_ops/main.rs"
-# These dependencies are only used for the 'http_bench_*_ops' examples.
[dev-dependencies]
+deno_core = { workspace = true, features = ["runtime_js_sources"] }
+
+# These dependencies are only used for the 'http_bench_*_ops' examples.
deno_ast.workspace = true
diff --git a/core/extensions.rs b/core/extensions.rs
index fa6d7851e..62390d054 100644
--- a/core/extensions.rs
+++ b/core/extensions.rs
@@ -17,10 +17,10 @@ pub enum ExtensionFileSourceCode {
/// snapshot, the other the static string in the `Extension`.
IncludedInBinary(&'static str),
- // Source code is loaded from a file on disk. It's meant to be used if the
- // embedder is creating snapshots. Files will be loaded from the filesystem
- // during the build time and they will only be present in the V8 snapshot.
- LoadedFromFsDuringSnapshot(PathBuf),
+ /// Source code is loaded from a file on disk at 'runtime'. It's meant to be
+ /// used in build and dev scripts using the `runtime_js_sources` feature,
+ /// likely to create snapshots.
+ LoadAtRuntime(PathBuf),
}
#[derive(Clone, Debug)]
@@ -45,7 +45,7 @@ impl ExtensionFileSource {
);
Ok(ModuleCode::from_static(code))
}
- ExtensionFileSourceCode::LoadedFromFsDuringSnapshot(path) => {
+ ExtensionFileSourceCode::LoadAtRuntime(path) => {
let msg = || format!("Failed to read \"{}\"", path.display());
let s = std::fs::read_to_string(path).with_context(msg)?;
debug_assert!(
@@ -168,7 +168,6 @@ macro_rules! ops {
/// * bounds: a comma-separated list of additional type bounds, eg: `bounds = [ P::MyAssociatedType: MyTrait ]`
/// * ops: a comma-separated list of [`OpDecl`]s to provide, eg: `ops = [ op_foo, op_bar ]`
/// * esm: a comma-separated list of ESM module filenames (see [`include_js_files`]), eg: `esm = [ dir "dir", "my_file.js" ]`
-/// * esm_setup_script: see [`ExtensionBuilder::esm_setup_script`]
/// * js: a comma-separated list of JS filenames (see [`include_js_files`]), eg: `js = [ dir "dir", "my_file.js" ]`
/// * config: a structure-like definition for configuration parameters which will be required when initializing this extension, eg: `config = { my_param: Option<usize> }`
/// * middleware: an [`OpDecl`] middleware function with the signature `fn (OpDecl) -> OpDecl`
@@ -185,8 +184,8 @@ macro_rules! extension {
$(, ops = [ $( $(#[$m:meta])* $( $op:ident )::+ $( < $( $op_param:ident ),* > )? ),+ $(,)? ] )?
$(, esm_entry_point = $esm_entry_point:literal )?
$(, esm = [ $( dir $dir_esm:literal , )? $( $esm:literal ),* $(,)? ] )?
- $(, esm_setup_script = $esm_setup_script:expr )?
$(, js = [ $( dir $dir_js:literal , )? $( $js:literal ),* $(,)? ] )?
+ $(, force_include_js_sources $($force_include_js_sources:block)? )? // dummy variable
$(, options = { $( $options_id:ident : $options_type:ty ),* $(,)? } )?
$(, middleware = $middleware_fn:expr )?
$(, state = $state_fn:expr )?
@@ -211,21 +210,15 @@ macro_rules! extension {
#[inline(always)]
#[allow(unused_variables)]
fn with_js(ext: &mut $crate::ExtensionBuilder) {
- $( ext.esm(
- $crate::include_js_files!( $name $( dir $dir_esm , )? $( $esm , )* )
- ); )?
- $(
- ext.esm(vec![ExtensionFileSource {
- specifier: "ext:setup",
- code: ExtensionFileSourceCode::IncludedInBinary($esm_setup_script),
- }]);
- )?
+ ext.esm(
+ $crate::include_js_files!( $name $( force_include_js_sources $($force_include_js_sources)?, )? $( $( dir $dir_esm , )? $( $esm , )* )? )
+ );
$(
ext.esm_entry_point($esm_entry_point);
)?
- $( ext.js(
- $crate::include_js_files!( $name $( dir $dir_js , )? $( $js , )* )
- ); )?
+ ext.js(
+ $crate::include_js_files!( $name $( force_include_js_sources $($force_include_js_sources)?, )? $( $( dir $dir_js , )? $( $js , )* )? )
+ );
}
// If ops were specified, add those ops to the extension.
@@ -285,7 +278,7 @@ macro_rules! extension {
}
#[allow(dead_code)]
- pub fn init_ops_and_esm $( < $( $param : $type + 'static ),+ > )? ( $( $( $options_id : $options_type ),* )? ) -> $crate::Extension
+ pub fn init_ext $( < $( $param : $type + 'static ),+ > )? ( $( $( $options_id : $options_type ),* )? ) -> $crate::Extension
$( where $( $bound : $bound_type ),+ )?
{
let mut ext = Self::ext();
@@ -296,17 +289,6 @@ macro_rules! extension {
Self::with_customizer(&mut ext);
ext.take()
}
-
- #[allow(dead_code)]
- pub fn init_ops $( < $( $param : $type + 'static ),+ > )? ( $( $( $options_id : $options_type ),* )? ) -> $crate::Extension
- $( where $( $bound : $bound_type ),+ )?
- {
- let mut ext = Self::ext();
- Self::with_ops $( ::< $( $param ),+ > )?(&mut ext);
- Self::with_state_and_middleware $( ::< $( $param ),+ > )?(&mut ext, $( $( $options_id , )* )? );
- Self::with_customizer(&mut ext);
- ext.take()
- }
}
};
@@ -349,8 +331,8 @@ macro_rules! extension {
#[derive(Default)]
pub struct Extension {
pub(crate) name: &'static str,
- js_files: Option<Vec<ExtensionFileSource>>,
- esm_files: Option<Vec<ExtensionFileSource>>,
+ js_files: Vec<ExtensionFileSource>,
+ esm_files: Vec<ExtensionFileSource>,
esm_entry_point: Option<&'static str>,
ops: Option<Vec<OpDecl>>,
opstate_fn: Option<Box<OpStateFn>>,
@@ -406,12 +388,12 @@ impl Extension {
/// returns JS source code to be loaded into the isolate (either at snapshotting,
/// or at startup). as a vector of a tuple of the file name, and the source code.
- pub fn get_js_sources(&self) -> Option<&Vec<ExtensionFileSource>> {
- self.js_files.as_ref()
+ pub fn get_js_sources(&self) -> &Vec<ExtensionFileSource> {
+ &self.js_files
}
- pub fn get_esm_sources(&self) -> Option<&Vec<ExtensionFileSource>> {
- self.esm_files.as_ref()
+ pub fn get_esm_sources(&self) -> &Vec<ExtensionFileSource> {
+ &self.esm_files
}
pub fn get_esm_entry_point(&self) -> Option<&'static str> {
@@ -532,13 +514,11 @@ impl ExtensionBuilder {
/// Consume the [`ExtensionBuilder`] and return an [`Extension`].
pub fn take(self) -> Extension {
- let js_files = Some(self.js);
- let esm_files = Some(self.esm);
let ops = Some(self.ops);
let deps = Some(self.deps);
Extension {
- js_files,
- esm_files,
+ js_files: self.js,
+ esm_files: self.esm,
esm_entry_point: self.esm_entry_point,
ops,
opstate_fn: self.state,
@@ -553,13 +533,11 @@ impl ExtensionBuilder {
}
pub fn build(&mut self) -> Extension {
- let js_files = Some(std::mem::take(&mut self.js));
- let esm_files = Some(std::mem::take(&mut self.esm));
let ops = Some(std::mem::take(&mut self.ops));
let deps = Some(std::mem::take(&mut self.deps));
Extension {
- js_files,
- esm_files,
+ js_files: std::mem::take(&mut self.js),
+ esm_files: std::mem::take(&mut self.esm),
esm_entry_point: self.esm_entry_point.take(),
ops,
opstate_fn: self.state.take(),
@@ -608,54 +586,58 @@ impl ExtensionBuilder {
/// - "ext:my_extension/js/01_hello.js"
/// - "ext:my_extension/js/02_goodbye.js"
/// ```
-#[cfg(not(feature = "include_js_files_for_snapshotting"))]
+#[cfg(all(
+ feature = "exclude_js_sources",
+ not(feature = "runtime_js_sources"),
+))]
#[macro_export]
macro_rules! include_js_files {
- ($name:ident dir $dir:literal, $($file:literal,)+) => {
- vec![
- $($crate::ExtensionFileSource {
- specifier: concat!("ext:", stringify!($name), "/", $file),
- code: $crate::ExtensionFileSourceCode::IncludedInBinary(
- include_str!(concat!($dir, "/", $file)
- )),
- },)+
- ]
+ ($name:ident $(dir $dir:literal,)? $($file:literal,)*) => {
+ vec![]
+ };
+
+ ($name:ident force_include_js_sources $($dummy:block)?, $($file:literal,)*) => {
+ vec![$($crate::include_js_file!($name $file)),*]
};
- ($name:ident $($file:literal,)+) => {
- vec![
- $($crate::ExtensionFileSource {
- specifier: concat!("ext:", stringify!($name), "/", $file),
- code: $crate::ExtensionFileSourceCode::IncludedInBinary(
- include_str!($file)
- ),
- },)+
- ]
+ ($name:ident force_include_js_sources $($dummy:block)?, dir $dir:literal, $($file:literal,)*) => {
+ vec![$($crate::include_js_file!($name dir $dir, $file)),*]
};
}
-#[cfg(feature = "include_js_files_for_snapshotting")]
+#[cfg(not(all(
+ feature = "exclude_js_sources",
+ not(feature = "runtime_js_sources"),
+)))]
#[macro_export]
macro_rules! include_js_files {
- ($name:ident dir $dir:literal, $($file:literal,)+) => {
- vec![
- $($crate::ExtensionFileSource {
- specifier: concat!("ext:", stringify!($name), "/", $file),
- code: $crate::ExtensionFileSourceCode::LoadedFromFsDuringSnapshot(
- std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")).join($dir).join($file)
- ),
- },)+
- ]
+ ($name:ident $(force_include_js_sources $($dummy:block)?,)? $($file:literal,)*) => {
+ vec![$($crate::include_js_file!($name $file)),*]
};
- ($name:ident $($file:literal,)+) => {
- vec![
- $($crate::ExtensionFileSource {
- specifier: concat!("ext:", stringify!($name), "/", $file),
- code: $crate::ExtensionFileSourceCode::LoadedFromFsDuringSnapshot(
- std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")).join($file)
- ),
- },)+
- ]
+ ($name:ident $(force_include_js_sources $($dummy:block)?,)? dir $dir:literal, $($file:literal,)*) => {
+ vec![$($crate::include_js_file!($name dir $dir, $file)),*]
+ };
+}
+
+#[cfg(not(feature = "runtime_js_sources"))]
+#[macro_export]
+macro_rules! include_js_file {
+ ($ext_name:ident $(dir $dir:literal,)? $file:literal) => {
+ $crate::ExtensionFileSource {
+ specifier: concat!("ext:", stringify!($ext_name), "/", $file),
+ code: $crate::ExtensionFileSourceCode::IncludedInBinary(include_str!(concat!($($dir, "/",)? $file))),
+ }
+ };
+}
+
+#[cfg(feature = "runtime_js_sources")]
+#[macro_export]
+macro_rules! include_js_file {
+ ($ext_name:ident $(dir $dir:literal,)? $file:literal) => {
+ $crate::ExtensionFileSource {
+ specifier: concat!("ext:", stringify!($ext_name), "/", $file),
+ code: $crate::ExtensionFileSourceCode::LoadAtRuntime(std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"))$(.join($dir))?.join($file)),
+ }
};
}
diff --git a/core/modules/loaders.rs b/core/modules/loaders.rs
index d4dbf1ec2..fc0ab2deb 100644
--- a/core/modules/loaders.rs
+++ b/core/modules/loaders.rs
@@ -119,7 +119,6 @@ impl ExtModuleLoader {
extensions
.iter()
.flat_map(|e| e.get_esm_sources())
- .flatten()
.map(|s| (s.specifier.to_string(), s.clone())),
);
ExtModuleLoader {
@@ -179,29 +178,6 @@ impl ModuleLoader for ExtModuleLoader {
}
}
-impl Drop for ExtModuleLoader {
- fn drop(&mut self) {
- let sources = self.sources.get_mut();
- let used_specifiers = self.used_specifiers.get_mut();
- let unused_modules: Vec<_> = sources
- .iter()
- .filter(|(k, _)| !used_specifiers.contains(k.as_str()))
- .collect();
-
- if !unused_modules.is_empty() {
- let mut msg =
- "Following modules were passed to ExtModuleLoader but never used:\n"
- .to_string();
- for m in unused_modules {
- msg.push_str(" - ");
- msg.push_str(m.0);
- msg.push('\n');
- }
- panic!("{}", msg);
- }
- }
-}
-
/// Basic file system module loader.
///
/// Note that this loader will **block** event loop
diff --git a/core/modules/tests.rs b/core/modules/tests.rs
index 0eb7ce514..103019412 100644
--- a/core/modules/tests.rs
+++ b/core/modules/tests.rs
@@ -342,7 +342,7 @@ fn test_mods() {
deno_core::extension!(test_ext, ops = [op_test]);
let mut runtime = JsRuntime::new(RuntimeOptions {
- extensions: vec![test_ext::init_ops()],
+ extensions: vec![test_ext::init_ext()],
module_loader: Some(loader),
..Default::default()
});
diff --git a/core/runtime/jsruntime.rs b/core/runtime/jsruntime.rs
index 2e473e7c9..e6b531d61 100644
--- a/core/runtime/jsruntime.rs
+++ b/core/runtime/jsruntime.rs
@@ -505,7 +505,7 @@ impl JsRuntime {
maybe_load_callback: Option<ExtModuleLoaderCb>,
) -> JsRuntime {
let init_mode = InitMode::from_options(&options);
- let (op_state, ops) = Self::create_opstate(&mut options, init_mode);
+ let (op_state, ops) = Self::create_opstate(&mut options);
let op_state = Rc::new(RefCell::new(op_state));
// Collect event-loop middleware
@@ -844,29 +844,25 @@ impl JsRuntime {
for extension in &extensions {
let maybe_esm_entry_point = extension.get_esm_entry_point();
- if let Some(esm_files) = extension.get_esm_sources() {
- for file_source in esm_files {
- self
- .load_side_module(
- &ModuleSpecifier::parse(file_source.specifier)?,
- None,
- )
- .await?;
- }
+ for file_source in extension.get_esm_sources() {
+ self
+ .load_side_module(
+ &ModuleSpecifier::parse(file_source.specifier)?,
+ None,
+ )
+ .await?;
}
if let Some(entry_point) = maybe_esm_entry_point {
esm_entrypoints.push(entry_point);
}
- if let Some(js_files) = extension.get_js_sources() {
- for file_source in js_files {
- realm.execute_script(
- self.v8_isolate(),
- file_source.specifier,
- file_source.load()?,
- )?;
- }
+ for file_source in extension.get_js_sources() {
+ realm.execute_script(
+ self.v8_isolate(),
+ file_source.specifier,
+ file_source.load()?,
+ )?;
}
if extension.is_core {
@@ -884,6 +880,16 @@ impl JsRuntime {
panic!("{} not present in the module map", specifier)
})
};
+ {
+ let module_map_rc = self.module_map.clone();
+ let module_map = module_map_rc.borrow();
+ let handle = module_map.handles.get(mod_id).unwrap().clone();
+ let mut scope = realm.handle_scope(self.v8_isolate());
+ let handle = v8::Local::new(&mut scope, handle);
+ if handle.get_status() == v8::ModuleStatus::Evaluated {
+ continue;
+ }
+ }
let receiver = self.mod_evaluate(mod_id);
self.run_event_loop(false).await?;
receiver
@@ -967,20 +973,11 @@ impl JsRuntime {
}
/// Initializes ops of provided Extensions
- fn create_opstate(
- options: &mut RuntimeOptions,
- init_mode: InitMode,
- ) -> (OpState, Vec<OpDecl>) {
+ fn create_opstate(options: &mut RuntimeOptions) -> (OpState, Vec<OpDecl>) {
// Add built-in extension
- if init_mode == InitMode::FromSnapshot {
- options
- .extensions
- .insert(0, crate::ops_builtin::core::init_ops());
- } else {
- options
- .extensions
- .insert(0, crate::ops_builtin::core::init_ops_and_esm());
- }
+ options
+ .extensions
+ .insert(0, crate::ops_builtin::core::init_ext());
let ops = Self::collect_ops(&mut options.extensions);
diff --git a/core/runtime/ops.rs b/core/runtime/ops.rs
index 85708b24b..76a29c5c3 100644
--- a/core/runtime/ops.rs
+++ b/core/runtime/ops.rs
@@ -235,7 +235,7 @@ mod tests {
f: impl FnOnce(Result<&v8::Value, anyhow::Error>, &mut v8::HandleScope),
) {
let mut runtime = JsRuntime::new(RuntimeOptions {
- extensions: vec![testing::init_ops_and_esm()],
+ extensions: vec![testing::init_ext()],
..Default::default()
});
let value: Result<v8::Global<v8::Value>, anyhow::Error> = runtime
diff --git a/core/runtime/snapshot_util.rs b/core/runtime/snapshot_util.rs
index 88c273147..dba1bc233 100644
--- a/core/runtime/snapshot_util.rs
+++ b/core/runtime/snapshot_util.rs
@@ -57,12 +57,9 @@ pub fn create_snapshot(
.iter()
.flat_map(|e| vec![e.get_esm_sources(), e.get_js_sources()])
.flatten()
- .flatten()
{
use crate::ExtensionFileSourceCode;
- if let ExtensionFileSourceCode::LoadedFromFsDuringSnapshot(path) =
- &source.code
- {
+ if let ExtensionFileSourceCode::LoadAtRuntime(path) = &source.code {
files_loaded_during_snapshot.push(path.clone());
}
}
diff --git a/core/runtime/tests.rs b/core/runtime/tests.rs
index 88c62e280..faabef0c4 100644
--- a/core/runtime/tests.rs
+++ b/core/runtime/tests.rs
@@ -100,7 +100,7 @@ fn setup(mode: Mode) -> (JsRuntime, Arc<AtomicUsize>) {
}
);
let mut runtime = JsRuntime::new(RuntimeOptions {
- extensions: vec![test_ext::init_ops(mode, dispatch_count.clone())],
+ extensions: vec![test_ext::init_ext(mode, dispatch_count.clone())],
get_error_class_fn: Some(&|error| {
crate::error::get_custom_error_class(error).unwrap()
}),
@@ -515,7 +515,7 @@ async fn test_error_builder() {
deno_core::extension!(test_ext, ops = [op_err]);
let mut runtime = JsRuntime::new(RuntimeOptions {
- extensions: vec![test_ext::init_ops()],
+ extensions: vec![test_ext::init_ext()],
get_error_class_fn: Some(&get_error_class_name),
..Default::default()
});
@@ -1114,7 +1114,7 @@ async fn test_error_context() {
deno_core::extension!(test_ext, ops = [op_err_sync, op_err_async]);
let mut runtime = JsRuntime::new(RuntimeOptions {
- extensions: vec![test_ext::init_ops()],
+ extensions: vec![test_ext::init_ext()],
..Default::default()
});
@@ -1274,7 +1274,7 @@ async fn test_async_opstate_borrow() {
state = |state| state.put(InnerState(42))
);
let mut runtime = JsRuntime::new(RuntimeOptions {
- extensions: vec![test_ext::init_ops()],
+ extensions: vec![test_ext::init_ext()],
..Default::default()
});
@@ -1305,7 +1305,7 @@ async fn test_sync_op_serialize_object_with_numbers_as_keys() {
ops = [op_sync_serialize_object_with_numbers_as_keys]
);
let mut runtime = JsRuntime::new(RuntimeOptions {
- extensions: vec![test_ext::init_ops()],
+ extensions: vec![test_ext::init_ext()],
..Default::default()
});
@@ -1347,7 +1347,7 @@ async fn test_async_op_serialize_object_with_numbers_as_keys() {
ops = [op_async_serialize_object_with_numbers_as_keys]
);
let mut runtime = JsRuntime::new(RuntimeOptions {
- extensions: vec![test_ext::init_ops()],
+ extensions: vec![test_ext::init_ext()],
..Default::default()
});
@@ -1383,7 +1383,7 @@ async fn test_set_macrotask_callback_set_next_tick_callback() {
deno_core::extension!(test_ext, ops = [op_async_sleep]);
let mut runtime = JsRuntime::new(RuntimeOptions {
- extensions: vec![test_ext::init_ops()],
+ extensions: vec![test_ext::init_ext()],
..Default::default()
});
@@ -1438,7 +1438,7 @@ fn test_has_tick_scheduled() {
deno_core::extension!(test_ext, ops = [op_macrotask, op_next_tick]);
let mut runtime = JsRuntime::new(RuntimeOptions {
- extensions: vec![test_ext::init_ops()],
+ extensions: vec![test_ext::init_ext()],
..Default::default()
});
@@ -1578,7 +1578,7 @@ async fn test_set_promise_reject_callback() {
deno_core::extension!(test_ext, ops = [op_promise_reject]);
let mut runtime = JsRuntime::new(RuntimeOptions {
- extensions: vec![test_ext::init_ops()],
+ extensions: vec![test_ext::init_ext()],
..Default::default()
});
@@ -1717,7 +1717,7 @@ async fn test_set_promise_reject_callback_top_level_await() {
}
let mut runtime = JsRuntime::new(RuntimeOptions {
- extensions: vec![test_ext::init_ops()],
+ extensions: vec![test_ext::init_ext()],
module_loader: Some(Rc::new(ModsLoader)),
..Default::default()
});
@@ -1742,7 +1742,7 @@ fn test_op_return_serde_v8_error() {
deno_core::extension!(test_ext, ops = [op_err]);
let mut runtime = JsRuntime::new(RuntimeOptions {
- extensions: vec![test_ext::init_ops()],
+ extensions: vec![test_ext::init_ext()],
..Default::default()
});
assert!(runtime
@@ -1767,7 +1767,7 @@ fn test_op_high_arity() {
deno_core::extension!(test_ext, ops = [op_add_4]);
let mut runtime = JsRuntime::new(RuntimeOptions {
- extensions: vec![test_ext::init_ops()],
+ extensions: vec![test_ext::init_ext()],
..Default::default()
});
let r = runtime
@@ -1790,7 +1790,7 @@ fn test_op_disabled() {
deno_core::extension!(test_ext, ops_fn = ops);
let mut runtime = JsRuntime::new(RuntimeOptions {
- extensions: vec![test_ext::init_ops()],
+ extensions: vec![test_ext::init_ext()],
..Default::default()
});
let err = runtime
@@ -1817,7 +1817,7 @@ fn test_op_detached_buffer() {
deno_core::extension!(test_ext, ops = [op_sum_take, op_boomerang]);
let mut runtime = JsRuntime::new(RuntimeOptions {
- extensions: vec![test_ext::init_ops()],
+ extensions: vec![test_ext::init_ext()],
..Default::default()
});
@@ -1886,7 +1886,7 @@ fn test_op_unstable_disabling() {
middleware = |op| if op.is_unstable { op.disable() } else { op }
);
let mut runtime = JsRuntime::new(RuntimeOptions {
- extensions: vec![test_ext::init_ops()],
+ extensions: vec![test_ext::init_ext()],
..Default::default()
});
runtime
@@ -1934,7 +1934,7 @@ fn js_realm_init() {
deno_core::extension!(test_ext, ops = [op_test]);
let mut runtime = JsRuntime::new(RuntimeOptions {
- extensions: vec![test_ext::init_ops()],
+ extensions: vec![test_ext::init_ext()],
..Default::default()
});
let realm = runtime.create_realm().unwrap();
@@ -1963,7 +1963,7 @@ fn js_realm_init_snapshot() {
deno_core::extension!(test_ext, ops = [op_test]);
let mut runtime = JsRuntime::new(RuntimeOptions {
startup_snapshot: Some(Snapshot::Boxed(snapshot)),
- extensions: vec![test_ext::init_ops()],
+ extensions: vec![test_ext::init_ext()],
..Default::default()
});
let realm = runtime.create_realm().unwrap();
@@ -1993,7 +1993,7 @@ fn js_realm_sync_ops() {
deno_core::extension!(test_ext, ops = [op_test]);
let mut runtime = JsRuntime::new(RuntimeOptions {
- extensions: vec![test_ext::init_ops()],
+ extensions: vec![test_ext::init_ext()],
get_error_class_fn: Some(&|error| {
crate::error::get_custom_error_class(error).unwrap()
}),
@@ -2041,7 +2041,7 @@ async fn js_realm_async_ops() {
deno_core::extension!(test_ext, ops = [op_test]);
let mut runtime = JsRuntime::new(RuntimeOptions {
- extensions: vec![test_ext::init_ops()],
+ extensions: vec![test_ext::init_ext()],
get_error_class_fn: Some(&|error| {
crate::error::get_custom_error_class(error).unwrap()
}),
@@ -2118,7 +2118,7 @@ async fn js_realm_gc() {
deno_core::extension!(test_ext, ops = [op_pending]);
let mut runtime = JsRuntime::new(RuntimeOptions {
- extensions: vec![test_ext::init_ops()],
+ extensions: vec![test_ext::init_ext()],
..Default::default()
});
@@ -2165,7 +2165,7 @@ async fn js_realm_ref_unref_ops() {
deno_core::extension!(test_ext, ops = [op_pending]);
let mut runtime = JsRuntime::new(RuntimeOptions {
- extensions: vec![test_ext::init_ops()],
+ extensions: vec![test_ext::init_ext()],
..Default::default()
});
@@ -2265,7 +2265,7 @@ fn duplicate_op_names() {
deno_core::extension!(test_ext, ops = [a::op_test, op_test]);
JsRuntime::new(RuntimeOptions {
- extensions: vec![test_ext::init_ops()],
+ extensions: vec![test_ext::init_ext()],
..Default::default()
});
}
@@ -2284,7 +2284,7 @@ fn ops_in_js_have_proper_names() {
deno_core::extension!(test_ext, ops = [op_test_sync, op_test_async]);
let mut runtime = JsRuntime::new(RuntimeOptions {
- extensions: vec![test_ext::init_ops()],
+ extensions: vec![test_ext::init_ext()],
..Default::default()
});