summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/runtime.rs13
-rw-r--r--op_crates/url/benches/url_ops.rs3
-rw-r--r--runtime/build.rs2
-rw-r--r--runtime/web_worker.rs2
-rw-r--r--runtime/worker.rs2
5 files changed, 9 insertions, 13 deletions
diff --git a/core/runtime.rs b/core/runtime.rs
index 4cfcad0ba..7573dfb67 100644
--- a/core/runtime.rs
+++ b/core/runtime.rs
@@ -313,9 +313,16 @@ impl JsRuntime {
extensions: options.extensions,
};
+ // TODO(@AaronO): diff extensions inited in snapshot and those provided
+ // for now we assume that snapshot and extensions always match
if !has_startup_snapshot {
js_runtime.js_init();
+ js_runtime.init_extension_js().unwrap();
}
+ // Init extension ops
+ js_runtime.init_extension_ops().unwrap();
+ js_runtime.sync_ops_cache();
+ // Init async ops callback
js_runtime.init_recv_cb();
js_runtime
@@ -366,8 +373,7 @@ impl JsRuntime {
}
/// Initializes JS of provided Extensions
- // NOTE: this will probably change when streamlining snapshot flow
- pub fn init_extension_js(&mut self) -> Result<(), AnyError> {
+ fn init_extension_js(&mut self) -> Result<(), AnyError> {
// Take extensions to avoid double-borrow
let mut extensions: Vec<Extension> = std::mem::take(&mut self.extensions);
for m in extensions.iter_mut() {
@@ -384,8 +390,7 @@ impl JsRuntime {
}
/// Initializes ops of provided Extensions
- // NOTE: this will probably change when streamlining snapshot flow
- pub fn init_extension_ops(&mut self) -> Result<(), AnyError> {
+ fn init_extension_ops(&mut self) -> Result<(), AnyError> {
let op_state = self.op_state();
// Take extensions to avoid double-borrow
let mut extensions: Vec<Extension> = std::mem::take(&mut self.extensions);
diff --git a/op_crates/url/benches/url_ops.rs b/op_crates/url/benches/url_ops.rs
index 18b2f300e..8b3cf2705 100644
--- a/op_crates/url/benches/url_ops.rs
+++ b/op_crates/url/benches/url_ops.rs
@@ -10,9 +10,6 @@ fn create_js_runtime() -> JsRuntime {
..Default::default()
});
- runtime.init_extension_js().unwrap();
- runtime.init_extension_ops().unwrap();
-
runtime
.execute("setup", "const { URL } = globalThis.__bootstrap.url;")
.unwrap();
diff --git a/runtime/build.rs b/runtime/build.rs
index 591ebaab7..b6a9da582 100644
--- a/runtime/build.rs
+++ b/runtime/build.rs
@@ -14,8 +14,6 @@ fn create_snapshot(
snapshot_path: &Path,
files: Vec<PathBuf>,
) {
- js_runtime.init_extension_js().unwrap();
-
// TODO(nayeemrmn): https://github.com/rust-lang/cargo/issues/3946 to get the
// workspace root.
let display_root = Path::new(env!("CARGO_MANIFEST_DIR")).parent().unwrap();
diff --git a/runtime/web_worker.rs b/runtime/web_worker.rs
index 5feb0212c..7f0a4885f 100644
--- a/runtime/web_worker.rs
+++ b/runtime/web_worker.rs
@@ -253,8 +253,6 @@ impl WebWorker {
});
}
- js_runtime.init_extension_ops().unwrap();
-
ops::web_worker::init(js_runtime, sender.clone(), handle);
ops::runtime::init(js_runtime, main_module);
ops::worker_host::init(
diff --git a/runtime/worker.rs b/runtime/worker.rs
index fddaf1f01..c2e241169 100644
--- a/runtime/worker.rs
+++ b/runtime/worker.rs
@@ -140,8 +140,6 @@ impl MainWorker {
});
}
- js_runtime.init_extension_ops().unwrap();
-
ops::runtime::init(js_runtime, main_module);
ops::worker_host::init(
js_runtime,