summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorNayeem Rahman <nayeemrmn99@gmail.com>2023-06-13 16:45:06 +0100
committerGitHub <noreply@github.com>2023-06-13 09:45:06 -0600
commitceb03cfb037cf7024a5048b17b508ddda59cfa05 (patch)
tree0c2df444e00f17131f9e2af708f80cdc4b032ce8 /core
parent5348778666d2d8d7ce138bbdf75ac5aa9f7ed428 (diff)
refactor(core): cleanup feature flags for js source inclusion (#19463)
Remove `ExtensionFileSourceCode::LoadedFromFsDuringSnapshot` and feature `include_js_for_snapshotting` since they leak paths that are only applicable in this repo to embedders. Replace with feature `exclude_js_sources`. Additionally the feature `force_include_js_sources` allows negating it, if both features are set. We need both of these because features are additive and there must be a way of force including sources for snapshot creation while still having the `exclude_js_sources` feature. `force_include_js_sources` is only set for build deps, so sources are still excluded from the final binary. You can also specify `force_include_js_sources` on any extension to override the above features for that extension. Towards #19398. But there was still the snapshot-from-snapshot situation where code could be executed twice, I addressed that by making `mod_evaluate()` and scripts like `core/01_core.js` behave idempotently. This allowed unifying `ext::init_ops()` and `ext::init_ops_and_esm()` into `ext::init()`.
Diffstat (limited to 'core')
-rw-r--r--core/00_primordials.js3
-rw-r--r--core/01_core.js3
-rw-r--r--core/02_error.js3
-rw-r--r--core/Cargo.toml6
-rw-r--r--core/extensions.rs133
-rw-r--r--core/inspector.rs3
-rw-r--r--core/lib.rs1
-rw-r--r--core/modules.rs27
-rw-r--r--core/runtime.rs80
-rw-r--r--core/snapshot_util.rs30
10 files changed, 105 insertions, 184 deletions
diff --git a/core/00_primordials.js b/core/00_primordials.js
index 60474e649..b85aa6673 100644
--- a/core/00_primordials.js
+++ b/core/00_primordials.js
@@ -34,6 +34,9 @@
"use strict";
(() => {
+ if (globalThis.__bootstrap) {
+ return;
+ }
const primordials = {};
const {
diff --git a/core/01_core.js b/core/01_core.js
index 13aa17c7e..8b5a4ff66 100644
--- a/core/01_core.js
+++ b/core/01_core.js
@@ -2,6 +2,9 @@
"use strict";
((window) => {
+ if (globalThis.__bootstrap.core) {
+ return;
+ }
const {
Array,
ArrayPrototypeFill,
diff --git a/core/02_error.js b/core/02_error.js
index b29dc9b4e..ffca10a32 100644
--- a/core/02_error.js
+++ b/core/02_error.js
@@ -2,6 +2,9 @@
"use strict";
((window) => {
+ if (globalThis.__bootstrap.core.prepareStackTrace) {
+ return;
+ }
const core = Deno.core;
const ops = core.ops;
const {
diff --git a/core/Cargo.toml b/core/Cargo.toml
index b9cb265e8..251f15429 100644
--- a/core/Cargo.toml
+++ b/core/Cargo.toml
@@ -16,7 +16,10 @@ 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 JS sources from the binary (e.g. if they are already snapshotted).
+exclude_js_sources = []
+# Enable to override `exclude_js_sources` (e.g. for snapshot creation in `build.rs`).
+force_include_js_sources = ["exclude_js_sources"]
[dependencies]
anyhow.workspace = true
@@ -47,3 +50,4 @@ path = "examples/http_bench_json_ops/main.rs"
# These dependencies are only used for the 'http_bench_*_ops' examples.
[dev-dependencies]
deno_ast.workspace = true
+deno_core = { workspace = true, features = ["force_include_js_sources"] }
diff --git a/core/extensions.rs b/core/extensions.rs
index fa6d7851e..ab0578106 100644
--- a/core/extensions.rs
+++ b/core/extensions.rs
@@ -1,32 +1,15 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
use crate::modules::ModuleCode;
use crate::OpState;
-use anyhow::Context as _;
-use anyhow::Error;
use std::cell::RefCell;
-use std::path::PathBuf;
use std::rc::Rc;
use std::task::Context;
use v8::fast_api::FastFunction;
#[derive(Clone, Debug)]
-pub enum ExtensionFileSourceCode {
- /// Source code is included in the binary produced. Either by being defined
- /// inline, or included using `include_str!()`. If you are snapshotting, this
- /// will result in two copies of the source code being included - one in the
- /// 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),
-}
-
-#[derive(Clone, Debug)]
pub struct ExtensionFileSource {
pub specifier: &'static str,
- pub code: ExtensionFileSourceCode,
+ pub code: &'static str,
}
impl ExtensionFileSource {
@@ -34,29 +17,14 @@ impl ExtensionFileSource {
s.chars().filter(|c| !c.is_ascii()).collect::<String>()
}
- pub fn load(&self) -> Result<ModuleCode, Error> {
- match &self.code {
- ExtensionFileSourceCode::IncludedInBinary(code) => {
- debug_assert!(
- code.is_ascii(),
- "Extension code must be 7-bit ASCII: {} (found {})",
- self.specifier,
- Self::find_non_ascii(code)
- );
- Ok(ModuleCode::from_static(code))
- }
- ExtensionFileSourceCode::LoadedFromFsDuringSnapshot(path) => {
- let msg = || format!("Failed to read \"{}\"", path.display());
- let s = std::fs::read_to_string(path).with_context(msg)?;
- debug_assert!(
- s.is_ascii(),
- "Extension code must be 7-bit ASCII: {} (found {})",
- self.specifier,
- Self::find_non_ascii(&s)
- );
- Ok(s.into())
- }
- }
+ pub fn load(&self) -> ModuleCode {
+ debug_assert!(
+ self.code.is_ascii(),
+ "Extension code must be 7-bit ASCII: {} (found {})",
+ self.specifier,
+ Self::find_non_ascii(self.code)
+ );
+ ModuleCode::from_static(self.code)
}
}
@@ -187,6 +155,7 @@ macro_rules! extension {
$(, 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,9 +180,9 @@ 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(
+ $crate::include_js_files!( $name $( force_include_js_sources $($force_include_js_sources)?, )? $( $( dir $dir_esm , )? $( $esm , )* )? )
+ );
$(
ext.esm(vec![ExtensionFileSource {
specifier: "ext:setup",
@@ -223,9 +192,9 @@ macro_rules! extension {
$(
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 +254,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 $( < $( $param : $type + 'static ),+ > )? ( $( $( $options_id : $options_type ),* )? ) -> $crate::Extension
$( where $( $bound : $bound_type ),+ )?
{
let mut ext = Self::ext();
@@ -296,17 +265,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()
- }
}
};
@@ -608,54 +566,49 @@ 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(not(all(
+ feature = "exclude_js_sources",
+ not(feature = "force_include_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 $(force_include_js_sources $($dummy:block)?,)? $(dir $dir:literal,)? $($file:literal,)*) => {
+ $crate::force_include_js_files!($name $(dir $dir,)? $($file,)*)
};
+}
- ($name:ident $($file:literal,)+) => {
- vec![
- $($crate::ExtensionFileSource {
- specifier: concat!("ext:", stringify!($name), "/", $file),
- code: $crate::ExtensionFileSourceCode::IncludedInBinary(
- include_str!($file)
- ),
- },)+
- ]
+#[cfg(all(
+ feature = "exclude_js_sources",
+ not(feature = "force_include_js_sources")
+))]
+#[macro_export]
+macro_rules! include_js_files {
+ ($name:ident force_include_js_sources $($dummy:block)?, $(dir $dir:literal,)? $($file:literal,)*) => {
+ $crate::force_include_js_files!($name $(dir $dir,)? $($file,)*)
+ };
+
+ ($name:ident $(dir $dir:literal,)? $($file:literal,)*) => {
+ vec![]
};
}
-#[cfg(feature = "include_js_files_for_snapshotting")]
#[macro_export]
-macro_rules! include_js_files {
- ($name:ident dir $dir:literal, $($file:literal,)+) => {
+macro_rules! force_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)
- ),
- },)+
+ code: include_str!(concat!($dir, "/", $file)),
+ },)*
]
};
- ($name:ident $($file:literal,)+) => {
+ ($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)
- ),
- },)+
+ code: include_str!($file),
+ },)*
]
};
}
diff --git a/core/inspector.rs b/core/inspector.rs
index d7c84608f..d7592fbe4 100644
--- a/core/inspector.rs
+++ b/core/inspector.rs
@@ -365,6 +365,9 @@ impl JsRuntimeInspector {
w.poll_state = PollState::Parked;
w.parked_thread.replace(thread::current());
}
+ PollState::Parked => {
+ w.parked_thread.replace(thread::current());
+ }
_ => unreachable!(),
};
w.poll_state
diff --git a/core/lib.rs b/core/lib.rs
index 336d9c2b9..729182a4f 100644
--- a/core/lib.rs
+++ b/core/lib.rs
@@ -60,7 +60,6 @@ pub use crate::async_cell::RcRef;
pub use crate::extensions::Extension;
pub use crate::extensions::ExtensionBuilder;
pub use crate::extensions::ExtensionFileSource;
-pub use crate::extensions::ExtensionFileSourceCode;
pub use crate::extensions::OpDecl;
pub use crate::extensions::OpMiddlewareFn;
pub use crate::fast_string::FastString;
diff --git a/core/modules.rs b/core/modules.rs
index 4f1875ae5..5d9fe2fc4 100644
--- a/core/modules.rs
+++ b/core/modules.rs
@@ -438,7 +438,7 @@ impl ModuleLoader for ExtModuleLoader {
let result = if let Some(load_callback) = &self.maybe_load_callback {
load_callback(source)
} else {
- source.load()
+ Ok(source.load())
};
match result {
Ok(code) => {
@@ -459,29 +459,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
@@ -2044,7 +2021,7 @@ import "/a.js";
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()],
module_loader: Some(loader),
..Default::default()
});
diff --git a/core/runtime.rs b/core/runtime.rs
index ecfd0bd57..29064df63 100644
--- a/core/runtime.rs
+++ b/core/runtime.rs
@@ -510,7 +510,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
@@ -860,7 +860,7 @@ impl JsRuntime {
realm.execute_script(
self.v8_isolate(),
file_source.specifier,
- file_source.load()?,
+ file_source.load(),
)?;
}
}
@@ -963,20 +963,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());
let ops = Self::collect_ops(&mut options.extensions);
@@ -1858,6 +1849,19 @@ impl JsRuntime {
.map(|handle| v8::Local::new(tc_scope, handle))
.expect("ModuleInfo not found");
let mut status = module.get_status();
+ if status == v8::ModuleStatus::Evaluated {
+ let (sender, receiver) = oneshot::channel();
+ sender.send(Ok(())).unwrap();
+ return receiver;
+ }
+ if status == v8::ModuleStatus::Errored {
+ let (sender, receiver) = oneshot::channel();
+ let exception = module.get_exception();
+ sender
+ .send(exception_to_err_result(tc_scope, exception, false))
+ .unwrap();
+ return receiver;
+ }
assert_eq!(
status,
v8::ModuleStatus::Instantiated,
@@ -2703,7 +2707,7 @@ pub mod tests {
}
);
let mut runtime = JsRuntime::new(RuntimeOptions {
- extensions: vec![test_ext::init_ops(mode, dispatch_count.clone())],
+ extensions: vec![test_ext::init(mode, dispatch_count.clone())],
get_error_class_fn: Some(&|error| {
crate::error::get_custom_error_class(error).unwrap()
}),
@@ -3118,7 +3122,7 @@ pub mod tests {
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()],
get_error_class_fn: Some(&get_error_class_name),
..Default::default()
});
@@ -3724,7 +3728,7 @@ main();
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()],
..Default::default()
});
@@ -3886,7 +3890,7 @@ assertEquals(1, notify_return_value);
state = |state| state.put(InnerState(42))
);
let mut runtime = JsRuntime::new(RuntimeOptions {
- extensions: vec![test_ext::init_ops()],
+ extensions: vec![test_ext::init()],
..Default::default()
});
@@ -3917,7 +3921,7 @@ assertEquals(1, notify_return_value);
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()],
..Default::default()
});
@@ -3959,7 +3963,7 @@ Deno.core.ops.op_sync_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()],
..Default::default()
});
@@ -3995,7 +3999,7 @@ Deno.core.opAsync("op_async_serialize_object_with_numbers_as_keys", {
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()],
..Default::default()
});
@@ -4050,7 +4054,7 @@ Deno.core.opAsync("op_async_serialize_object_with_numbers_as_keys", {
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()],
..Default::default()
});
@@ -4191,7 +4195,7 @@ Deno.core.opAsync("op_async_serialize_object_with_numbers_as_keys", {
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()],
..Default::default()
});
@@ -4334,7 +4338,7 @@ Deno.core.opAsync("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()],
module_loader: Some(Rc::new(ModsLoader)),
..Default::default()
});
@@ -4359,7 +4363,7 @@ Deno.core.opAsync("op_async_serialize_object_with_numbers_as_keys", {
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()],
..Default::default()
});
assert!(runtime
@@ -4384,7 +4388,7 @@ Deno.core.opAsync("op_async_serialize_object_with_numbers_as_keys", {
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()],
..Default::default()
});
let r = runtime
@@ -4407,7 +4411,7 @@ Deno.core.opAsync("op_async_serialize_object_with_numbers_as_keys", {
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()],
..Default::default()
});
let err = runtime
@@ -4436,7 +4440,7 @@ Deno.core.opAsync("op_async_serialize_object_with_numbers_as_keys", {
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()],
..Default::default()
});
@@ -4505,7 +4509,7 @@ Deno.core.opAsync("op_async_serialize_object_with_numbers_as_keys", {
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()],
..Default::default()
});
runtime
@@ -4553,7 +4557,7 @@ Deno.core.opAsync("op_async_serialize_object_with_numbers_as_keys", {
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()],
..Default::default()
});
let realm = runtime.create_realm().unwrap();
@@ -4586,7 +4590,7 @@ Deno.core.opAsync("op_async_serialize_object_with_numbers_as_keys", {
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()],
..Default::default()
});
let realm = runtime.create_realm().unwrap();
@@ -4620,7 +4624,7 @@ Deno.core.opAsync("op_async_serialize_object_with_numbers_as_keys", {
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()],
get_error_class_fn: Some(&|error| {
crate::error::get_custom_error_class(error).unwrap()
}),
@@ -4668,7 +4672,7 @@ Deno.core.opAsync("op_async_serialize_object_with_numbers_as_keys", {
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()],
get_error_class_fn: Some(&|error| {
crate::error::get_custom_error_class(error).unwrap()
}),
@@ -4745,7 +4749,7 @@ Deno.core.opAsync("op_async_serialize_object_with_numbers_as_keys", {
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()],
..Default::default()
});
@@ -4792,7 +4796,7 @@ Deno.core.opAsync("op_async_serialize_object_with_numbers_as_keys", {
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()],
..Default::default()
});
@@ -4892,7 +4896,7 @@ Deno.core.opAsync("op_async_serialize_object_with_numbers_as_keys", {
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()],
..Default::default()
});
}
@@ -4911,7 +4915,7 @@ Deno.core.opAsync("op_async_serialize_object_with_numbers_as_keys", {
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()],
..Default::default()
});
diff --git a/core/snapshot_util.rs b/core/snapshot_util.rs
index 88c273147..200a81d15 100644
--- a/core/snapshot_util.rs
+++ b/core/snapshot_util.rs
@@ -22,16 +22,7 @@ pub struct CreateSnapshotOptions {
pub snapshot_module_load_cb: Option<ExtModuleLoaderCb>,
}
-pub struct CreateSnapshotOutput {
- /// Any files marked as LoadedFromFsDuringSnapshot are collected here and should be
- /// printed as 'cargo:rerun-if-changed' lines from your build script.
- pub files_loaded_during_snapshot: Vec<PathBuf>,
-}
-
-#[must_use = "The files listed by create_snapshot should be printed as 'cargo:rerun-if-changed' lines"]
-pub fn create_snapshot(
- create_snapshot_options: CreateSnapshotOptions,
-) -> CreateSnapshotOutput {
+pub fn create_snapshot(create_snapshot_options: CreateSnapshotOptions) {
let mut mark = Instant::now();
let js_runtime = JsRuntimeForSnapshot::new(
@@ -51,22 +42,6 @@ pub fn create_snapshot(
);
mark = Instant::now();
- let mut files_loaded_during_snapshot = vec![];
- for source in js_runtime
- .extensions()
- .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
- {
- files_loaded_during_snapshot.push(path.clone());
- }
- }
-
let snapshot = js_runtime.snapshot();
let snapshot_slice: &[u8] = &snapshot;
println!(
@@ -112,9 +87,6 @@ pub fn create_snapshot(
Instant::now().saturating_duration_since(mark),
create_snapshot_options.snapshot_path.display(),
);
- CreateSnapshotOutput {
- files_loaded_during_snapshot,
- }
}
pub type FilterFn = Box<dyn Fn(&PathBuf) -> bool>;