diff options
Diffstat (limited to 'core/runtime.rs')
-rw-r--r-- | core/runtime.rs | 34 |
1 files changed, 14 insertions, 20 deletions
diff --git a/core/runtime.rs b/core/runtime.rs index 171abbb5e..547f6aa23 100644 --- a/core/runtime.rs +++ b/core/runtime.rs @@ -305,6 +305,11 @@ impl JsRuntime { waker: AtomicWaker::new(), }))); + // Add builtins extension + options + .extensions + .insert(0, crate::ops_builtin::init_builtins()); + let mut js_runtime = Self { v8_isolate: Some(isolate), snapshot_creator: maybe_snapshot_creator, @@ -316,7 +321,6 @@ impl JsRuntime { // 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 @@ -360,18 +364,6 @@ impl JsRuntime { s.clone() } - /// Executes a JavaScript code to provide Deno.core and error reporting. - /// - /// This function can be called during snapshotting. - fn js_init(&mut self) { - self - .execute("deno:core/core.js", include_str!("core.js")) - .unwrap(); - self - .execute("deno:core/error.js", include_str!("error.js")) - .unwrap(); - } - /// Initializes JS of provided Extensions fn init_extension_js(&mut self) -> Result<(), AnyError> { // Take extensions to avoid double-borrow @@ -1592,7 +1584,8 @@ pub mod tests { dispatch_count: dispatch_count.clone(), }); - runtime.register_op("test", dispatch); + runtime.register_op("op_test", dispatch); + runtime.sync_ops_cache(); runtime .execute( @@ -1618,9 +1611,9 @@ pub mod tests { "filename.js", r#" let control = 42; - Deno.core.opcall(1, null, control); + Deno.core.opAsync("op_test", control); async function main() { - Deno.core.opcall(1, null, control); + Deno.core.opAsync("op_test", control); } main(); "#, @@ -1636,7 +1629,7 @@ pub mod tests { .execute( "filename.js", r#" - Deno.core.opcall(1); + Deno.core.opAsync("op_test"); "#, ) .unwrap(); @@ -1651,7 +1644,7 @@ pub mod tests { "filename.js", r#" let zero_copy_a = new Uint8Array([0]); - Deno.core.opcall(1, null, null, zero_copy_a); + Deno.core.opAsync("op_test", null, zero_copy_a); "#, ) .unwrap(); @@ -1954,7 +1947,8 @@ pub mod tests { module_loader: Some(loader), ..Default::default() }); - runtime.register_op("test", dispatcher); + runtime.register_op("op_test", dispatcher); + runtime.sync_ops_cache(); runtime .execute( @@ -1980,7 +1974,7 @@ pub mod tests { import { b } from './b.js' if (b() != 'b') throw Error(); let control = 42; - Deno.core.opcall(1, null, control); + Deno.core.opAsync("op_test", control); "#, ) .unwrap(); |