From d90d9eeb8fdb75a0dffef5812955a80b937e266a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Wed, 31 Jan 2024 01:43:57 +0100 Subject: [PATCH 1/6] refactor: internal ops are under Deno.core.coreOps --- core/01_core.js | 23 +++++++++++++-- core/02_error.js | 7 ++--- core/runtime/bindings.rs | 52 ++++++++++++++++++++++++++++++++-- core/runtime/jsruntime.rs | 6 +++- core/runtime/tests/jsrealm.rs | 2 +- core/runtime/tests/misc.rs | 6 ++-- core/runtime/tests/ops.rs | 4 +-- core/runtime/tests/snapshot.rs | 2 +- 8 files changed, 85 insertions(+), 17 deletions(-) diff --git a/core/01_core.js b/core/01_core.js index 37d69d8e0..950d406ea 100644 --- a/core/01_core.js +++ b/core/01_core.js @@ -23,11 +23,17 @@ TypeError, } = window.__bootstrap.primordials; const { + coreOps, ops, getPromise, hasPromise, promiseIdSymbol, } = window.Deno.core; + // TODO(bartlomieju): because op bindings are generated on each startup + // we can't remove it right now. See https://github.com/denoland/deno_core/issues/521. + // Delete `Deno.core.coreOps` immediately. These bindings shouldn't be accessible + // outside deno_core. + // delete window.Deno.core.coreOps; let unhandledPromiseRejectionHandler = () => false; let timerDepth = 0; @@ -302,7 +308,7 @@ op_read_sync: readSync, op_write_sync: writeSync, op_shutdown: shutdown, - } = ensureFastOps(true); + } = coreOps; const callSiteRetBuf = new Uint32Array(2); const callSiteRetBufU8 = new Uint8Array(callSiteRetBuf.buffer); @@ -420,6 +426,12 @@ op_set_wasm_streaming_callback, op_str_byte_length, op_timer_cancel, + op_void_async, + op_void_async_deferred, + op_set_format_exception_callback, + op_format_file_name, + op_apply_source_map_filename, + op_apply_source_map, op_timer_queue, op_timer_ref, op_timer_unref, @@ -453,7 +465,7 @@ op_is_typed_array, op_is_weak_map, op_is_weak_set, - } = ensureFastOps(); + } = coreOps; // Extra Deno.core.* exports const core = ObjectAssign(globalThis.Deno.core, { @@ -538,7 +550,14 @@ destructureError: (error) => op_destructure_error(error), opNames: () => op_op_names(), eventLoopHasMoreWork: () => op_event_loop_has_more_work(), + setFormatExceptionCallback: (cb) => op_set_format_exception_callback(cb), + applySourceMapFilename: () => op_apply_source_map_filename(), + applySourceMap: (fileName, lineNumber, columnNumber, retBuf) => + op_apply_source_map(fileName, lineNumber, columnNumber, retBuf), + formatFileName: (fileName) => op_format_file_name(fileName), byteLength: (str) => op_str_byte_length(str), + opVoidAsync: () => op_void_async(), + opVoidAsyncDeferred: () => op_void_async_deferred(), setHandledPromiseRejectionHandler: (handler) => op_set_handled_promise_rejection_handler(handler), setUnhandledPromiseRejectionHandler: (handler) => diff --git a/core/02_error.js b/core/02_error.js index 4c297eae0..52c2c9c3e 100644 --- a/core/02_error.js +++ b/core/02_error.js @@ -3,7 +3,6 @@ ((window) => { const core = Deno.core; - const ops = core.ops; const { Error, ObjectDefineProperties, @@ -22,7 +21,7 @@ fileName.startsWith("data:") && fileName.length > DATA_URL_ABBREV_THRESHOLD ) { - return ops.op_format_file_name(fileName); + return core.formatFileName(fileName); } return fileName; } @@ -151,7 +150,7 @@ callSite.fileName !== null && callSite.lineNumber !== null && callSite.columnNumber !== null ) { - res = ops.op_apply_source_map( + res = core.applySourceMap( callSite.fileName, callSite.lineNumber, callSite.columnNumber, @@ -163,7 +162,7 @@ callSite.columnNumber = applySourceMapRetBuf[1]; } if (res >= 2) { - callSite.fileName = ops.op_apply_source_map_filename(); + callSite.fileName = core.applySourceMapFilename(); } ArrayPrototypePush(error.__callSiteEvals, callSite); stack += `\n at ${formatCallSiteEval(callSite)}`; diff --git a/core/runtime/bindings.rs b/core/runtime/bindings.rs index 8a7e860f0..6bf9c434f 100644 --- a/core/runtime/bindings.rs +++ b/core/runtime/bindings.rs @@ -127,12 +127,13 @@ where .get(scope, key.into()) .unwrap_or_else(|| panic!("{path} exists")) .try_into() - .unwrap_or_else(|_| panic!("unable to convert")) + .unwrap_or_else(|_| panic!("Unable to convert {path} to desired type")) } pub mod v8_static_strings { pub static DENO: &[u8] = b"Deno"; pub static CORE: &[u8] = b"core"; + pub static CORE_OPS: &[u8] = b"coreOps"; pub static OPS: &[u8] = b"ops"; pub static URL: &[u8] = b"url"; pub static MAIN: &[u8] = b"main"; @@ -192,6 +193,20 @@ pub(crate) fn initialize_deno_core_namespace<'s>( .set(scope, deno_core_ops_key.into(), deno_core_ops_obj.into()) .unwrap(); + // Set up `Deno.core.coreOps` object + let deno_core_core_ops_obj = v8::Object::new(scope); + let deno_core_core_ops_key = + v8::String::new_external_onebyte_static(scope, v8_static_strings::CORE_OPS) + .unwrap(); + + deno_core_obj + .set( + scope, + deno_core_core_ops_key.into(), + deno_core_core_ops_obj.into(), + ) + .unwrap(); + // If we're initializing fresh context set up the console if init_mode == InitMode::New { // Bind `call_console` to Deno.core.callConsole @@ -248,10 +263,12 @@ pub(crate) fn initialize_primordials_and_infra( } /// Set up JavaScript bindings for ops. -pub(crate) fn initialize_deno_core_ops_bindings<'s>( +pub(crate) fn initialize_ops_bindings<'s>( scope: &mut v8::HandleScope<'s>, context: v8::Local<'s, v8::Context>, op_ctxs: &[OpCtx], + // TODO(bartlomieju): this is really hacky solution + last_deno_core_op_id: usize, ) { let global = context.global(scope); @@ -262,6 +279,9 @@ pub(crate) fn initialize_deno_core_ops_bindings<'s>( let deno_core_obj = get(scope, deno_obj, b"core", "Deno.core"); let deno_core_ops_obj: v8::Local = get(scope, deno_core_obj, b"ops", "Deno.core.ops"); + let deno_core_core_ops_obj: v8::Local = + get(scope, deno_core_obj, b"coreOps", "Deno.core.coreOps"); + let set_up_async_stub_fn: v8::Local = get( scope, deno_core_obj, @@ -270,7 +290,33 @@ pub(crate) fn initialize_deno_core_ops_bindings<'s>( ); let undefined = v8::undefined(scope); - for op_ctx in op_ctxs { + + let deno_core_op_ctxs = &op_ctxs[..last_deno_core_op_id]; + let ext_op_ctxs = &op_ctxs[last_deno_core_op_id..]; + // TODO(bartlomieju): `deno_core_op_ctxs` should be initialized only once + // with `init_mode == InitMode::New`. + for op_ctx in deno_core_op_ctxs { + let mut op_fn = op_ctx_function(scope, op_ctx); + let key = v8::String::new_external_onebyte_static( + scope, + op_ctx.decl.name.as_bytes(), + ) + .unwrap(); + + // For async ops we need to set them up, by calling `Deno.core.setUpAsyncStub` - + // this call will generate an optimized function that binds to the provided + // op, while keeping track of promises and error remapping. + if op_ctx.decl.is_async { + let result = set_up_async_stub_fn + .call(scope, undefined.into(), &[key.into(), op_fn.into()]) + .unwrap(); + op_fn = result.try_into().unwrap() + } + + deno_core_core_ops_obj.set(scope, key.into(), op_fn.into()); + } + + for op_ctx in ext_op_ctxs { let mut op_fn = op_ctx_function(scope, op_ctx); let key = v8::String::new_external_onebyte_static( scope, diff --git a/core/runtime/jsruntime.rs b/core/runtime/jsruntime.rs index 9196b8ac3..a0a6c1e16 100644 --- a/core/runtime/jsruntime.rs +++ b/core/runtime/jsruntime.rs @@ -730,10 +730,14 @@ impl JsRuntime { // If we're creating a new runtime or there are new ops to register // set up JavaScript bindings for them. if init_mode.needs_ops_bindings() { - bindings::initialize_deno_core_ops_bindings( + // TODO(bartlomieju): this is a really hacky solution and relies + // implicitly on how `extension_set::create_op_ctxs` works. + let last_deno_core_op_id = crate::ops_builtin::BUILTIN_OPS.len() - 1; + bindings::initialize_ops_bindings( scope, context, &context_state.op_ctxs, + last_deno_core_op_id, ); } diff --git a/core/runtime/tests/jsrealm.rs b/core/runtime/tests/jsrealm.rs index 3df62a702..e8425acb4 100644 --- a/core/runtime/tests/jsrealm.rs +++ b/core/runtime/tests/jsrealm.rs @@ -29,7 +29,7 @@ fn test_set_format_exception_callback_realms() { "", format!( r#" - Deno.core.ops.op_set_format_exception_callback((error) => {{ + Deno.core.setFormatExceptionCallback((error) => {{ return `{realm_name} / ${{error}}`; }}); "# diff --git a/core/runtime/tests/misc.rs b/core/runtime/tests/misc.rs index 36e453d90..4caf2c4ec 100644 --- a/core/runtime/tests/misc.rs +++ b/core/runtime/tests/misc.rs @@ -826,7 +826,7 @@ async fn test_promise_rejection_handler_generic( function throwError() { throw new Error("boom"); } - const { op_void_async, op_void_async_deferred } = Deno.core.ensureFastOps(); + const { opVoidAsync, opVoidAsyncDeferred } = Deno.core; if (test != "no_handler") { Deno.core.setUnhandledPromiseRejectionHandler((promise, rejection) => { if (test.startsWith("exception_")) { @@ -841,9 +841,9 @@ async fn test_promise_rejection_handler_generic( } if (test != "no_reject") { if (test.startsWith("async_op_eager_")) { - op_void_async().then(() => { Deno.core.ops.op_breakpoint(); throw new Error("fail") }); + opVoidAsync().then(() => { Deno.core.ops.op_breakpoint(); throw new Error("fail") }); } else if (test.startsWith("async_op_deferred_")) { - op_void_async_deferred().then(() => { Deno.core.ops.op_breakpoint(); throw new Error("fail") }); + opVoidAsyncDeferred().then(() => { Deno.core.ops.op_breakpoint(); throw new Error("fail") }); } else if (test.startsWith("throw_")) { Deno.core.ops.op_breakpoint(); throw new Error("fail"); diff --git a/core/runtime/tests/ops.rs b/core/runtime/tests/ops.rs index ed52a6fb4..7c04f60c8 100644 --- a/core/runtime/tests/ops.rs +++ b/core/runtime/tests/ops.rs @@ -494,8 +494,8 @@ await import('./mod.js'); Url::parse("http://x/mod.js").unwrap(), ascii_str!( r#" -const { op_void_async_deferred } = Deno.core.ensureFastOps(); -await op_void_async_deferred(); +const { opVoidAsyncDeferred } = Deno.core; +await opVoidAsyncDeferred(); "# ), ), diff --git a/core/runtime/tests/snapshot.rs b/core/runtime/tests/snapshot.rs index 32676eb74..75b33983f 100644 --- a/core/runtime/tests/snapshot.rs +++ b/core/runtime/tests/snapshot.rs @@ -75,7 +75,7 @@ fn test_snapshot_callbacks() { Deno.core.setMacrotaskCallback(() => { return true; }); - Deno.core.ops.op_set_format_exception_callback(()=> { + Deno.core.setFormatExceptionCallback(()=> { return null; }) Deno.core.setUnhandledPromiseRejectionHandler(() => { From 082370a0e5956ec481d5e78e738cb1e8c7f7c7bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Thu, 1 Feb 2024 02:31:04 +0100 Subject: [PATCH 2/6] delete Deno.core.coreOps after all --- core/01_core.js | 6 ++++- core/runtime/bindings.rs | 51 ++++++++++++++++++++------------------ core/runtime/jsruntime.rs | 1 + core/runtime/tests/misc.rs | 4 +-- 4 files changed, 35 insertions(+), 27 deletions(-) diff --git a/core/01_core.js b/core/01_core.js index 601f152a6..eb3082620 100644 --- a/core/01_core.js +++ b/core/01_core.js @@ -33,7 +33,7 @@ // we can't remove it right now. See https://github.com/denoland/deno_core/issues/521. // Delete `Deno.core.coreOps` immediately. These bindings shouldn't be accessible // outside deno_core. - // delete window.Deno.core.coreOps; + delete window.Deno.core.coreOps; let unhandledPromiseRejectionHandler = () => false; let timerDepth = 0; @@ -432,6 +432,8 @@ op_set_format_exception_callback, op_format_file_name, op_apply_source_map_filename, + op_wasm_streaming_feed, + op_wasm_streaming_set_url, op_apply_source_map, op_timer_queue, op_timer_ref, @@ -629,6 +631,8 @@ isRegExp: (value) => op_is_reg_exp(value), isSet: (value) => op_is_set(value), isSetIterator: (value) => op_is_set_iterator(value), + wasmStreamingFeed: (rid, bytes) => op_wasm_streaming_feed(rid, bytes), + wasmStreamingSetUrl: (rid, url) => op_wasm_streaming_set_url(rid, url), isSharedArrayBuffer: (value) => op_is_shared_array_buffer(value), isStringObject: (value) => op_is_string_object(value), isSymbolObject: (value) => op_is_symbol_object(value), diff --git a/core/runtime/bindings.rs b/core/runtime/bindings.rs index 6c5150e7e..7121c16a2 100644 --- a/core/runtime/bindings.rs +++ b/core/runtime/bindings.rs @@ -260,6 +260,7 @@ pub(crate) fn initialize_ops_bindings<'s>( scope: &mut v8::HandleScope<'s>, context: v8::Local<'s, v8::Context>, op_ctxs: &[OpCtx], + init_mode: InitMode, // TODO(bartlomieju): this is really hacky solution last_deno_core_op_id: usize, ) { @@ -277,12 +278,6 @@ pub(crate) fn initialize_ops_bindings<'s>( v8_static_strings::OPS, "Deno.core.ops", ); - let deno_core_core_ops_obj: v8::Local = get( - scope, - deno_core_obj, - v8_static_strings::CORE_OPS, - "Deno.core.coreOps", - ); let set_up_async_stub_fn: v8::Local = get( scope, @@ -295,27 +290,35 @@ pub(crate) fn initialize_ops_bindings<'s>( let deno_core_op_ctxs = &op_ctxs[..last_deno_core_op_id]; let ext_op_ctxs = &op_ctxs[last_deno_core_op_id..]; - // TODO(bartlomieju): `deno_core_op_ctxs` should be initialized only once - // with `init_mode == InitMode::New`. - for op_ctx in deno_core_op_ctxs { - let mut op_fn = op_ctx_function(scope, op_ctx); - let key = v8::String::new_external_onebyte_static( + + // TODO(bartlomieju): hoist this to a separate function + if init_mode == InitMode::New { + let deno_core_core_ops_obj: v8::Local = get( scope, - op_ctx.decl.name.as_bytes(), - ) - .unwrap(); + deno_core_obj, + v8_static_strings::CORE_OPS, + "Deno.core.coreOps", + ); + for op_ctx in deno_core_op_ctxs { + let mut op_fn = op_ctx_function(scope, op_ctx); + let key = v8::String::new_external_onebyte_static( + scope, + op_ctx.decl.name.as_bytes(), + ) + .unwrap(); - // For async ops we need to set them up, by calling `Deno.core.setUpAsyncStub` - - // this call will generate an optimized function that binds to the provided - // op, while keeping track of promises and error remapping. - if op_ctx.decl.is_async { - let result = set_up_async_stub_fn - .call(scope, undefined.into(), &[key.into(), op_fn.into()]) - .unwrap(); - op_fn = result.try_into().unwrap() - } + // For async ops we need to set them up, by calling `Deno.core.setUpAsyncStub` - + // this call will generate an optimized function that binds to the provided + // op, while keeping track of promises and error remapping. + if op_ctx.decl.is_async { + let result = set_up_async_stub_fn + .call(scope, undefined.into(), &[key.into(), op_fn.into()]) + .unwrap(); + op_fn = result.try_into().unwrap() + } - deno_core_core_ops_obj.set(scope, key.into(), op_fn.into()); + deno_core_core_ops_obj.set(scope, key.into(), op_fn.into()); + } } for op_ctx in ext_op_ctxs { diff --git a/core/runtime/jsruntime.rs b/core/runtime/jsruntime.rs index 6b95934f9..9396aa1e7 100644 --- a/core/runtime/jsruntime.rs +++ b/core/runtime/jsruntime.rs @@ -737,6 +737,7 @@ impl JsRuntime { scope, context, &context_state.op_ctxs, + init_mode, last_deno_core_op_id, ); } diff --git a/core/runtime/tests/misc.rs b/core/runtime/tests/misc.rs index 4caf2c4ec..db2a8f8e9 100644 --- a/core/runtime/tests/misc.rs +++ b/core/runtime/tests/misc.rs @@ -376,8 +376,8 @@ async fn wasm_streaming_op_invocation_in_import() { runtime.execute_script_static("setup.js", r#" Deno.core.setWasmStreamingCallback((source, rid) => { - Deno.core.ops.op_wasm_streaming_set_url(rid, "file:///foo.wasm"); - Deno.core.ops.op_wasm_streaming_feed(rid, source); + Deno.core.wasmStreamingSetUrl(rid, "file:///foo.wasm"); + Deno.core.wasmStreamingFeed(rid, source); Deno.core.close(rid); }); "#).unwrap(); From 655e3626302486f2062d41a31d7d79713582cb01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Thu, 1 Feb 2024 03:52:42 +0100 Subject: [PATCH 3/6] virtual ops module doesn't generate bindings for core ops --- core/runtime/jsruntime.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core/runtime/jsruntime.rs b/core/runtime/jsruntime.rs index 9396aa1e7..cfd2ebbf1 100644 --- a/core/runtime/jsruntime.rs +++ b/core/runtime/jsruntime.rs @@ -949,8 +949,13 @@ impl JsRuntime { let context_local = v8::Local::new(scope, context_global); let context_state = JsRealm::state_from_scope(scope); let global = context_local.global(scope); + + // TODO(bartlomieju): this is a really hacky solution and relies + // implicitly on how `extension_set::create_op_ctxs` works. + let last_deno_core_op_id = crate::ops_builtin::BUILTIN_OPS.len() - 1; + let synthetic_module_exports = create_exports_for_ops_virtual_module( - &context_state.op_ctxs, + &context_state.op_ctxs[last_deno_core_op_id..], scope, global, ); From 0ce4e8b3bf8d1c4ad1184c9769e79cb208c4c8e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Thu, 1 Feb 2024 04:27:00 +0100 Subject: [PATCH 4/6] maybe fix deno? --- core/modules/loaders.rs | 6 +++++- core/runtime/bindings.rs | 23 +++++++++++++++++++++-- core/runtime/jsruntime.rs | 2 +- core/runtime/mod.rs | 1 + 4 files changed, 28 insertions(+), 4 deletions(-) diff --git a/core/modules/loaders.rs b/core/modules/loaders.rs index 6686fa3ac..825db0368 100644 --- a/core/modules/loaders.rs +++ b/core/modules/loaders.rs @@ -9,6 +9,7 @@ use crate::modules::ModuleType; use crate::modules::RequestedModuleType; use crate::modules::ResolutionKind; use crate::resolve_import; +use crate::runtime::VIRTUAL_OPS_MODULE_NAME; use crate::Extension; use crate::ModuleSourceCode; @@ -251,7 +252,10 @@ impl Drop for ExtModuleLoader { let used_specifiers = self.used_specifiers.get_mut(); let unused_modules: Vec<_> = sources .iter() - .filter(|(k, _)| !used_specifiers.contains(k.as_str())) + .filter(|(k, _)| { + k.as_str() == VIRTUAL_OPS_MODULE_NAME + || !used_specifiers.contains(k.as_str()) + }) .collect(); if !unused_modules.is_empty() { diff --git a/core/runtime/bindings.rs b/core/runtime/bindings.rs index 7121c16a2..a46eb7793 100644 --- a/core/runtime/bindings.rs +++ b/core/runtime/bindings.rs @@ -113,6 +113,24 @@ pub fn script_origin<'a>( ) } +macro_rules! get_todo { + ($type:ty, $scope: expr, $from:expr, $key:expr, $path:literal) => {{ + let temp = v8_static_strings::new($scope, $key).into(); + TryInto::<$type>::try_into( + $from + .get($scope, temp) + .unwrap_or_else(|| panic!("{} exists", $path)), + ) + .unwrap_or_else(|_| { + panic!( + "Unable to convert {} to desired {}", + $path, + stringify!($type) + ) + }) + }}; +} + pub(crate) fn get<'s, T>( scope: &mut v8::HandleScope<'s>, from: v8::Local, @@ -221,11 +239,12 @@ pub(crate) fn initialize_deno_core_namespace<'s>( // Bind v8 console object to Deno.core.console let extra_binding_obj = context.get_extras_binding_object(scope); - let console_obj: v8::Local = get( + let console_obj = get_todo!( + v8::Local, scope, extra_binding_obj, v8_static_strings::CONSOLE, - "ExtrasBindingObject.console", + "ExtrasBindingObject.console" ); let console_key = v8_static_strings::new(scope, v8_static_strings::CONSOLE); deno_core_obj.set(scope, console_key.into(), console_obj.into()); diff --git a/core/runtime/jsruntime.rs b/core/runtime/jsruntime.rs index cfd2ebbf1..84db0e9d0 100644 --- a/core/runtime/jsruntime.rs +++ b/core/runtime/jsruntime.rs @@ -264,7 +264,7 @@ impl Future for RcPromiseFuture { } } -const VIRTUAL_OPS_MODULE_NAME: &str = "ext:core/ops"; +pub(crate) const VIRTUAL_OPS_MODULE_NAME: &str = "ext:core/ops"; /// These files are executed just after a new context is created. They provided /// the necessary infrastructure to bind ops. diff --git a/core/runtime/mod.rs b/core/runtime/mod.rs index a86367935..1b187927e 100644 --- a/core/runtime/mod.rs +++ b/core/runtime/mod.rs @@ -33,6 +33,7 @@ pub use jsruntime::SharedArrayBufferStore; pub use jsruntime::Snapshot; #[cfg(test)] pub(crate) use jsruntime::NO_OF_BUILTIN_MODULES; +pub(crate) use jsruntime::VIRTUAL_OPS_MODULE_NAME; pub use snapshot_util::create_snapshot; pub use snapshot_util::get_js_files; pub use snapshot_util::CreateSnapshotOptions; From 46f072d1deebd3b975b88174911d4da7d9cac39c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Thu, 1 Feb 2024 17:19:13 +0100 Subject: [PATCH 5/6] expose more internal ops --- core/01_core.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/core/01_core.js b/core/01_core.js index eb3082620..cb5368863 100644 --- a/core/01_core.js +++ b/core/01_core.js @@ -439,6 +439,9 @@ op_timer_ref, op_timer_unref, op_unref_op, + op_arraybuffer_was_detached, + op_get_constructor_name, + op_get_non_index_property_names, op_is_any_array_buffer, op_is_arguments_object, @@ -649,6 +652,10 @@ opNames: () => op_op_names(), eventLoopHasMoreWork: () => op_event_loop_has_more_work(), setFormatExceptionCallback: (cb) => op_set_format_exception_callback(cb), + arrayBufferWasDetached: (buf) => op_arraybuffer_was_detached(buf), + getConstructorName: (obj) => op_get_constructor_name(obj), + getNonIndexPropertyNames: (obj, filter) => + op_get_non_index_property_names(obj, filter), applySourceMapFilename: () => op_apply_source_map_filename(), applySourceMap: (fileName, lineNumber, columnNumber, retBuf) => op_apply_source_map(fileName, lineNumber, columnNumber, retBuf), From f9b3db31701e52b5948a29298de13bfa6502253b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Thu, 1 Feb 2024 17:20:48 +0100 Subject: [PATCH 6/6] revert unrelated changes --- core/modules/loaders.rs | 6 +----- core/runtime/mod.rs | 1 - 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/core/modules/loaders.rs b/core/modules/loaders.rs index 825db0368..6686fa3ac 100644 --- a/core/modules/loaders.rs +++ b/core/modules/loaders.rs @@ -9,7 +9,6 @@ use crate::modules::ModuleType; use crate::modules::RequestedModuleType; use crate::modules::ResolutionKind; use crate::resolve_import; -use crate::runtime::VIRTUAL_OPS_MODULE_NAME; use crate::Extension; use crate::ModuleSourceCode; @@ -252,10 +251,7 @@ impl Drop for ExtModuleLoader { let used_specifiers = self.used_specifiers.get_mut(); let unused_modules: Vec<_> = sources .iter() - .filter(|(k, _)| { - k.as_str() == VIRTUAL_OPS_MODULE_NAME - || !used_specifiers.contains(k.as_str()) - }) + .filter(|(k, _)| !used_specifiers.contains(k.as_str())) .collect(); if !unused_modules.is_empty() { diff --git a/core/runtime/mod.rs b/core/runtime/mod.rs index 1b187927e..a86367935 100644 --- a/core/runtime/mod.rs +++ b/core/runtime/mod.rs @@ -33,7 +33,6 @@ pub use jsruntime::SharedArrayBufferStore; pub use jsruntime::Snapshot; #[cfg(test)] pub(crate) use jsruntime::NO_OF_BUILTIN_MODULES; -pub(crate) use jsruntime::VIRTUAL_OPS_MODULE_NAME; pub use snapshot_util::create_snapshot; pub use snapshot_util::get_js_files; pub use snapshot_util::CreateSnapshotOptions;