summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNayeem Rahman <nayeemrmn99@gmail.com>2023-06-03 21:22:32 +0100
committerGitHub <noreply@github.com>2023-06-03 14:22:32 -0600
commit34dac6c6efa75f38c29031a65db1ee3332a67259 (patch)
tree5facbc9c0631feebc23ed2f2d9ea37643d0e7086
parent7d0853d15863b2fb61bcf5927139cfdd3d869d73 (diff)
refactor(core): remove force_op_registration and cleanup JsRuntimeForSnapshot (#19353)
Addresses https://github.com/denoland/deno/pull/19308#discussion_r1212248194. Removes force_op_registration as it is no longer necessary.
-rw-r--r--cli/lsp/tsc.rs3
-rw-r--r--cli/ops/bench.rs3
-rw-r--r--cli/ops/mod.rs3
-rw-r--r--cli/ops/testing.rs3
-rw-r--r--cli/tsc/mod.rs11
-rw-r--r--core/bindings.rs23
-rw-r--r--core/extensions.rs15
-rw-r--r--core/runtime.rs390
-rw-r--r--core/snapshot_util.rs38
-rw-r--r--ops/lib.rs2
-rw-r--r--ops/optimizer_tests/async_nop.out1
-rw-r--r--ops/optimizer_tests/async_result.out1
-rw-r--r--ops/optimizer_tests/callback_options.out1
-rw-r--r--ops/optimizer_tests/cow_str.out1
-rw-r--r--ops/optimizer_tests/f64_slice.out1
-rw-r--r--ops/optimizer_tests/incompatible_1.out1
-rw-r--r--ops/optimizer_tests/issue16934.out1
-rw-r--r--ops/optimizer_tests/issue16934_fast.out1
-rw-r--r--ops/optimizer_tests/op_blob_revoke_object_url.out1
-rw-r--r--ops/optimizer_tests/op_ffi_ptr_value.out1
-rw-r--r--ops/optimizer_tests/op_print.out1
-rw-r--r--ops/optimizer_tests/op_state.out1
-rw-r--r--ops/optimizer_tests/op_state_basic1.out1
-rw-r--r--ops/optimizer_tests/op_state_generics.out1
-rw-r--r--ops/optimizer_tests/op_state_result.out1
-rw-r--r--ops/optimizer_tests/op_state_warning.out1
-rw-r--r--ops/optimizer_tests/op_state_with_transforms.out1
-rw-r--r--ops/optimizer_tests/opstate_with_arity.out1
-rw-r--r--ops/optimizer_tests/option_arg.out1
-rw-r--r--ops/optimizer_tests/owned_string.out1
-rw-r--r--ops/optimizer_tests/param_mut_binding_warning.out1
-rw-r--r--ops/optimizer_tests/raw_ptr.out1
-rw-r--r--ops/optimizer_tests/serde_v8_value.out1
-rw-r--r--ops/optimizer_tests/strings.out1
-rw-r--r--ops/optimizer_tests/strings_result.out1
-rw-r--r--ops/optimizer_tests/u64_result.out1
-rw-r--r--ops/optimizer_tests/uint8array.out1
-rw-r--r--ops/optimizer_tests/unit_result.out1
-rw-r--r--ops/optimizer_tests/unit_result2.out1
-rw-r--r--ops/optimizer_tests/unit_ret.out1
-rw-r--r--ops/optimizer_tests/wasm_op.out1
-rw-r--r--runtime/examples/extension_with_ops/main.rs8
-rw-r--r--runtime/ops/fs_events.rs3
-rw-r--r--runtime/ops/http.rs3
-rw-r--r--runtime/ops/os/mod.rs6
-rw-r--r--runtime/ops/permissions.rs3
-rw-r--r--runtime/ops/process.rs3
-rw-r--r--runtime/ops/runtime.rs3
-rw-r--r--runtime/ops/signal.rs3
-rw-r--r--runtime/ops/tty.rs3
-rw-r--r--runtime/ops/web_worker.rs3
-rw-r--r--runtime/ops/worker_host.rs3
52 files changed, 161 insertions, 402 deletions
diff --git a/cli/lsp/tsc.rs b/cli/lsp/tsc.rs
index bfbb5cf9a..0e52f8d87 100644
--- a/cli/lsp/tsc.rs
+++ b/cli/lsp/tsc.rs
@@ -3261,9 +3261,6 @@ deno_core::extension!(deno_tsc,
options.performance,
));
},
- customizer = |ext: &mut deno_core::ExtensionBuilder| {
- ext.force_op_registration();
- },
);
/// Instruct a language server runtime to start the language server and provide
diff --git a/cli/ops/bench.rs b/cli/ops/bench.rs
index da0f3d959..f569a8cbb 100644
--- a/cli/ops/bench.rs
+++ b/cli/ops/bench.rs
@@ -42,9 +42,6 @@ deno_core::extension!(deno_bench,
state.put(options.sender);
state.put(BenchContainer::default());
},
- customizer = |ext: &mut deno_core::ExtensionBuilder| {
- ext.force_op_registration();
- },
);
#[derive(Clone)]
diff --git a/cli/ops/mod.rs b/cli/ops/mod.rs
index d39f19270..5066c44b9 100644
--- a/cli/ops/mod.rs
+++ b/cli/ops/mod.rs
@@ -23,9 +23,6 @@ deno_core::extension!(deno_cli,
state = |state, options| {
state.put(options.npm_resolver);
},
- customizer = |ext: &mut deno_core::ExtensionBuilder| {
- ext.force_op_registration();
- },
);
#[op]
diff --git a/cli/ops/testing.rs b/cli/ops/testing.rs
index 3f9ade7c9..b4d9b451a 100644
--- a/cli/ops/testing.rs
+++ b/cli/ops/testing.rs
@@ -43,9 +43,6 @@ deno_core::extension!(deno_test,
state.put(options.sender);
state.put(TestContainer::default());
},
- customizer = |ext: &mut deno_core::ExtensionBuilder| {
- ext.force_op_registration();
- },
);
#[derive(Clone)]
diff --git a/cli/tsc/mod.rs b/cli/tsc/mod.rs
index 2b8a210ab..d9f9b8b53 100644
--- a/cli/tsc/mod.rs
+++ b/cli/tsc/mod.rs
@@ -117,13 +117,7 @@ pub fn get_types_declaration_file_text(unstable: bool) -> String {
}
fn get_asset_texts_from_new_runtime() -> Result<Vec<AssetText>, AnyError> {
- deno_core::extension!(
- deno_cli_tsc,
- ops_fn = deno_ops,
- customizer = |ext: &mut deno_core::ExtensionBuilder| {
- ext.force_op_registration();
- },
- );
+ deno_core::extension!(deno_cli_tsc, ops_fn = deno_ops);
// the assets are stored within the typescript isolate, so take them out of there
let mut runtime = JsRuntime::new(RuntimeOptions {
@@ -780,9 +774,6 @@ pub fn exec(request: Request) -> Result<Response, AnyError> {
.unwrap(),
));
},
- customizer = |ext: &mut deno_core::ExtensionBuilder| {
- ext.force_op_registration();
- },
);
let startup_source = ascii_str!("globalThis.startup({ legacyFlag: false })");
diff --git a/core/bindings.rs b/core/bindings.rs
index d91e4c309..2be9b35b6 100644
--- a/core/bindings.rs
+++ b/core/bindings.rs
@@ -15,19 +15,10 @@ use crate::modules::ImportAssertionsKind;
use crate::modules::ModuleMap;
use crate::modules::ResolutionKind;
use crate::ops::OpCtx;
+use crate::runtime::InitMode;
use crate::JsRealm;
use crate::JsRuntime;
-#[derive(Copy, Clone, Eq, PartialEq)]
-pub(crate) enum BindingsMode {
- /// We have no snapshot -- this is a pristine context.
- New,
- /// We have initialized before, are reloading a snapshot, and will snapshot.
- Loaded,
- /// We have initialized before, are reloading a snapshot, and will not snapshot again.
- LoadedFinal,
-}
-
pub(crate) fn external_references(ops: &[OpCtx]) -> v8::ExternalReferences {
// Overallocate a bit, it's better than having to resize the vector.
let mut references = Vec::with_capacity(4 + ops.len() * 4);
@@ -127,7 +118,7 @@ pub(crate) fn initialize_context<'s>(
scope: &mut v8::HandleScope<'s>,
context: v8::Local<'s, v8::Context>,
op_ctxs: &[OpCtx],
- bindings_mode: BindingsMode,
+ init_mode: InitMode,
) -> v8::Local<'s, v8::Context> {
let global = context.global(scope);
@@ -137,17 +128,11 @@ pub(crate) fn initialize_context<'s>(
codegen,
"Deno.__op__ = function(opFns, callConsole, console) {{"
);
- if bindings_mode == BindingsMode::New {
+ if init_mode == InitMode::New {
_ = writeln!(codegen, "Deno.__op__console(callConsole, console);");
}
for op_ctx in op_ctxs {
if op_ctx.decl.enabled {
- // If we're loading from a snapshot, we can skip registration for most ops
- if bindings_mode == BindingsMode::LoadedFinal
- && !op_ctx.decl.force_registration
- {
- continue;
- }
_ = writeln!(
codegen,
"Deno.__op__registerOp({}, opFns[{}], \"{}\");",
@@ -182,7 +167,7 @@ pub(crate) fn initialize_context<'s>(
let op_fn = op_ctx_function(scope, op_ctx);
op_fns.set_index(scope, op_ctx.id as u32, op_fn.into());
}
- if bindings_mode != BindingsMode::New {
+ if init_mode == InitMode::FromSnapshot {
op_fn.call(scope, recv.into(), &[op_fns.into()]);
} else {
// Bind functions to Deno.core.*
diff --git a/core/extensions.rs b/core/extensions.rs
index ff86fec64..fa6d7851e 100644
--- a/core/extensions.rs
+++ b/core/extensions.rs
@@ -72,7 +72,6 @@ pub struct OpDecl {
pub is_async: bool,
pub is_unstable: bool,
pub is_v8: bool,
- pub force_registration: bool,
pub arg_count: u8,
pub fast_fn: Option<FastFunction>,
}
@@ -360,7 +359,6 @@ pub struct Extension {
initialized: bool,
enabled: bool,
deps: Option<&'static [&'static str]>,
- force_op_registration: bool,
pub(crate) is_core: bool,
}
@@ -431,7 +429,6 @@ impl Extension {
let mut ops = self.ops.take()?;
for op in ops.iter_mut() {
op.enabled = self.enabled && op.enabled;
- op.force_registration = self.force_op_registration;
}
Some(ops)
}
@@ -485,7 +482,6 @@ pub struct ExtensionBuilder {
event_loop_middleware: Option<Box<OpEventLoopFn>>,
name: &'static str,
deps: &'static [&'static str],
- force_op_registration: bool,
is_core: bool,
}
@@ -534,15 +530,6 @@ impl ExtensionBuilder {
self
}
- /// Mark that ops from this extension should be added to `Deno.core.ops`
- /// unconditionally. This is useful is some ops are not available
- /// during snapshotting, as ops are not registered by default when a
- /// `JsRuntime` is created with an existing snapshot.
- pub fn force_op_registration(&mut self) -> &mut Self {
- self.force_op_registration = true;
- self
- }
-
/// Consume the [`ExtensionBuilder`] and return an [`Extension`].
pub fn take(self) -> Extension {
let js_files = Some(self.js);
@@ -560,7 +547,6 @@ impl ExtensionBuilder {
initialized: false,
enabled: true,
name: self.name,
- force_op_registration: self.force_op_registration,
deps,
is_core: self.is_core,
}
@@ -583,7 +569,6 @@ impl ExtensionBuilder {
enabled: true,
name: self.name,
deps,
- force_op_registration: self.force_op_registration,
is_core: self.is_core,
}
}
diff --git a/core/runtime.rs b/core/runtime.rs
index f95c4a8ef..fdcb81e9e 100644
--- a/core/runtime.rs
+++ b/core/runtime.rs
@@ -1,7 +1,6 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
use crate::bindings;
-use crate::bindings::BindingsMode;
use crate::error::generic_error;
use crate::error::to_v8_type_error;
use crate::error::JsError;
@@ -24,8 +23,6 @@ use crate::realm::ContextState;
use crate::realm::JsRealm;
use crate::realm::JsRealmInner;
use crate::snapshot_util;
-use crate::snapshot_util::SnapshotOptions;
-use crate::snapshot_util::SnapshottedData;
use crate::source_map::SourceMapCache;
use crate::source_map::SourceMapGetter;
use crate::Extension;
@@ -63,7 +60,6 @@ use std::sync::Mutex;
use std::sync::Once;
use std::task::Context;
use std::task::Poll;
-use v8::CreateParams;
const STATE_DATA_OFFSET: u32 = 0;
const MODULE_MAP_DATA_OFFSET: u32 = 1;
@@ -121,7 +117,7 @@ impl<T> DerefMut for ManuallyDropRc<T> {
/// This inner struct allows us to let the outer JsRuntime drop normally without a Drop impl, while we
/// control dropping more closely here using ManuallyDrop.
struct InnerIsolateState {
- snapshotting: bool,
+ will_snapshot: bool,
state: ManuallyDropRc<RefCell<JsRuntimeState>>,
v8_isolate: ManuallyDrop<v8::OwnedIsolate>,
}
@@ -182,7 +178,7 @@ impl Drop for InnerIsolateState {
// SAFETY: We gotta drop these
unsafe {
ManuallyDrop::drop(&mut self.state.0);
- if self.snapshotting {
+ if self.will_snapshot {
// Create the snapshot and just drop it.
eprintln!("WARNING: v8::OwnedIsolate for snapshot was leaked");
} else {
@@ -192,47 +188,46 @@ impl Drop for InnerIsolateState {
}
}
+#[derive(Copy, Clone, Debug, Eq, PartialEq)]
+pub(crate) enum InitMode {
+ /// We have no snapshot -- this is a pristine context.
+ New,
+ /// We are using a snapshot, thus certain initialization steps are skipped.
+ FromSnapshot,
+}
+
+impl InitMode {
+ fn from_options(options: &RuntimeOptions) -> Self {
+ match options.startup_snapshot {
+ None => Self::New,
+ Some(_) => Self::FromSnapshot,
+ }
+ }
+}
+
/// A single execution context of JavaScript. Corresponds roughly to the "Web
/// Worker" concept in the DOM.
////
-/// The JsRuntimeImpl future completes when there is an error or when all
+/// The JsRuntime future completes when there is an error or when all
/// pending ops have completed.
///
-/// API consumers will want to use either the [`JsRuntime`] or [`JsRuntimeForSnapshot`]
-/// type aliases.
-pub struct JsRuntimeImpl<const FOR_SNAPSHOT: bool = false> {
+/// Use [`JsRuntimeForSnapshot`] to be able to create a snapshot.
+pub struct JsRuntime {
inner: InnerIsolateState,
module_map: Rc<RefCell<ModuleMap>>,
allocations: IsolateAllocations,
extensions: Vec<Extension>,
event_loop_middlewares: Vec<Box<OpEventLoopFn>>,
- bindings_mode: BindingsMode,
+ init_mode: InitMode,
// Marks if this is considered the top-level runtime. Used only be inspector.
is_main: bool,
}
-/// The runtime type that most users will use when not creating a snapshot.
-pub struct JsRuntime(JsRuntimeImpl<false>);
-
-impl Deref for JsRuntime {
- type Target = JsRuntimeImpl<false>;
-
- fn deref(&self) -> &Self::Target {
- &self.0
- }
-}
-
-impl DerefMut for JsRuntime {
- fn deref_mut(&mut self) -> &mut Self::Target {
- &mut self.0
- }
-}
-
/// The runtime type used for snapshot creation.
-pub struct JsRuntimeForSnapshot(JsRuntimeImpl<true>);
+pub struct JsRuntimeForSnapshot(JsRuntime);
impl Deref for JsRuntimeForSnapshot {
- type Target = JsRuntimeImpl<true>;
+ type Target = JsRuntime;
fn deref(&self) -> &Self::Target {
&self.0
@@ -301,7 +296,7 @@ pub type SharedArrayBufferStore =
pub type CompiledWasmModuleStore = CrossIsolateStore<v8::CompiledWasmModule>;
-/// Internal state for JsRuntimeImpl which is stored in one of v8::Isolate's
+/// Internal state for JsRuntime which is stored in one of v8::Isolate's
/// embedder slots.
pub struct JsRuntimeState {
global_realm: Option<JsRealm>,
@@ -398,7 +393,7 @@ pub struct RuntimeOptions {
/// executed tries to load modules.
pub module_loader: Option<Rc<dyn ModuleLoader>>,
- /// JsRuntimeImpl extensions, not to be confused with ES modules.
+ /// JsRuntime extensions, not to be confused with ES modules.
/// Only ops registered by extensions will be initialized. If you need
/// to execute JS code from extensions, pass source files in `js` or `esm`
/// option on `ExtensionBuilder`.
@@ -448,21 +443,60 @@ pub struct RuntimeSnapshotOptions {
pub snapshot_module_load_cb: Option<ExtModuleLoaderCb>,
}
-trait JsRuntimeInternalTrait {
- fn create_raw_isolate(
- refs: &'static v8::ExternalReferences,
- params: Option<CreateParams>,
- snapshot: SnapshotOptions,
- ) -> v8::OwnedIsolate;
-}
+impl JsRuntime {
+ /// Only constructor, configuration is done through `options`.
+ pub fn new(mut options: RuntimeOptions) -> JsRuntime {
+ JsRuntime::init_v8(options.v8_platform.take(), cfg!(test));
+ JsRuntime::new_inner(options, false, None)
+ }
+
+ pub(crate) fn state_from(
+ isolate: &v8::Isolate,
+ ) -> Rc<RefCell<JsRuntimeState>> {
+ let state_ptr = isolate.get_data(STATE_DATA_OFFSET);
+ let state_rc =
+ // SAFETY: We are sure that it's a valid pointer for whole lifetime of
+ // the runtime.
+ unsafe { Rc::from_raw(state_ptr as *const RefCell<JsRuntimeState>) };
+ let state = state_rc.clone();
+ std::mem::forget(state_rc);
+ state
+ }
-impl<const FOR_SNAPSHOT: bool> JsRuntimeImpl<FOR_SNAPSHOT> {
- fn init_v8(v8_platform: Option<v8::SharedRef<v8::Platform>>) {
+ pub(crate) fn module_map_from(
+ isolate: &v8::Isolate,
+ ) -> Rc<RefCell<ModuleMap>> {
+ let module_map_ptr = isolate.get_data(MODULE_MAP_DATA_OFFSET);
+ let module_map_rc =
+ // SAFETY: We are sure that it's a valid pointer for whole lifetime of
+ // the runtime.
+ unsafe { Rc::from_raw(module_map_ptr as *const RefCell<ModuleMap>) };
+ let module_map = module_map_rc.clone();
+ std::mem::forget(module_map_rc);
+ module_map
+ }
+
+ pub(crate) fn event_loop_pending_state_from_scope(
+ scope: &mut v8::HandleScope,
+ ) -> EventLoopPendingState {
+ let state = JsRuntime::state_from(scope);
+ let module_map = JsRuntime::module_map_from(scope);
+ let state = EventLoopPendingState::new(
+ scope,
+ &mut state.borrow_mut(),
+ &module_map.borrow(),
+ );
+ state
+ }
+
+ fn init_v8(
+ v8_platform: Option<v8::SharedRef<v8::Platform>>,
+ predictable: bool,
+ ) {
static DENO_INIT: Once = Once::new();
static DENO_PREDICTABLE: AtomicBool = AtomicBool::new(false);
static DENO_PREDICTABLE_SET: AtomicBool = AtomicBool::new(false);
- let predictable = FOR_SNAPSHOT || cfg!(test);
if DENO_PREDICTABLE_SET.load(Ordering::SeqCst) {
let current = DENO_PREDICTABLE.load(Ordering::SeqCst);
assert_eq!(current, predictable, "V8 may only be initialized once in either snapshotting or non-snapshotting mode. Either snapshotting or non-snapshotting mode may be used in a single process, not both.");
@@ -473,15 +507,13 @@ impl<const FOR_SNAPSHOT: bool> JsRuntimeImpl<FOR_SNAPSHOT> {
DENO_INIT.call_once(move || v8_init(v8_platform, predictable));
}
- fn new_runtime(
+ fn new_inner(
mut options: RuntimeOptions,
- snapshot_options: SnapshotOptions,
+ will_snapshot: bool,
maybe_load_callback: Option<ExtModuleLoaderCb>,
- ) -> JsRuntimeImpl<FOR_SNAPSHOT>
- where
- JsRuntimeImpl<FOR_SNAPSHOT>: JsRuntimeInternalTrait,
- {
- let (op_state, ops) = Self::create_opstate(&mut options, &snapshot_options);
+ ) -> JsRuntime {
+ let init_mode = InitMode::from_options(&options);
+ let (op_state, ops) = Self::create_opstate(&mut options, init_mode);
let op_state = Rc::new(RefCell::new(op_state));
// Collect event-loop middleware
@@ -546,19 +578,56 @@ impl<const FOR_SNAPSHOT: bool> JsRuntimeImpl<FOR_SNAPSHOT> {
// V8 takes ownership of external_references.
let refs: &'static v8::ExternalReferences = Box::leak(Box::new(refs));
- let bindings_mode = match snapshot_options {
- SnapshotOptions::None => bindings::BindingsMode::New,
- SnapshotOptions::Create => bindings::BindingsMode::New,
- SnapshotOptions::Load(_) => bindings::BindingsMode::LoadedFinal,
- SnapshotOptions::CreateFromExisting(_) => bindings::BindingsMode::Loaded,
+ let mut isolate = if will_snapshot {
+ snapshot_util::create_snapshot_creator(
+ refs,
+ options.startup_snapshot.take(),
+ )
+ } else {
+ let mut params = options
+ .create_params
+ .take()
+ .unwrap_or_default()
+ .embedder_wrapper_type_info_offsets(
+ V8_WRAPPER_TYPE_INDEX,
+ V8_WRAPPER_OBJECT_INDEX,
+ )
+ .external_references(&**refs);
+ if let Some(snapshot) = options.startup_snapshot.take() {
+ params = match snapshot {
+ Snapshot::Static(data) => params.snapshot_blob(data),
+ Snapshot::JustCreated(data) => params.snapshot_blob(data),
+ Snapshot::Boxed(data) => params.snapshot_blob(data),
+ };
+ }
+ v8::Isolate::new(params)
};
- let snapshotting = snapshot_options.will_snapshot();
-
- let (mut isolate, global_context, snapshotted_data) = Self::create_isolate(
- refs,
- options.create_params.take(),
- snapshot_options,
+ isolate.set_capture_stack_trace_for_uncaught_exceptions(true, 10);
+ isolate.set_promise_reject_callback(bindings::promise_reject_callback);
+ isolate.set_host_initialize_import_meta_object_callback(
+ bindings::host_initialize_import_meta_object_callback,
);
+ isolate.set_host_import_module_dynamically_callback(
+ bindings::host_import_module_dynamically_callback,
+ );
+ isolate.set_wasm_async_resolve_promise_callback(
+ bindings::wasm_async_resolve_promise_callback,
+ );
+
+ let (global_context, snapshotted_data) = {
+ let scope = &mut v8::HandleScope::new(&mut isolate);
+ let context = v8::Context::new(scope);
+
+ // Get module map data from the snapshot
+ let snapshotted_data = if init_mode == InitMode::FromSnapshot {
+ Some(snapshot_util::get_snapshotted_data(scope, context))
+ } else {
+ None
+ };
+
+ (v8::Global::new(scope, context), snapshotted_data)
+ };
+
// SAFETY: this is first use of `isolate_ptr` so we are sure we're
// not overwriting an existing pointer.
isolate = unsafe {
@@ -575,7 +644,7 @@ impl<const FOR_SNAPSHOT: bool> JsRuntimeImpl<FOR_SNAPSHOT> {
scope,
context,
&context_state.borrow().op_ctxs,
- bindings_mode,
+ init_mode,
);
context.set_slot(scope, context_state.clone());
@@ -619,13 +688,13 @@ impl<const FOR_SNAPSHOT: bool> JsRuntimeImpl<FOR_SNAPSHOT> {
drop(context_scope);
- let mut js_runtime = JsRuntimeImpl {
+ let mut js_runtime = JsRuntime {
inner: InnerIsolateState {
- snapshotting,
+ will_snapshot,
state: ManuallyDropRc(ManuallyDrop::new(state_rc)),
v8_isolate: ManuallyDrop::new(isolate),
},
- bindings_mode,
+ init_mode,
allocations: IsolateAllocations::default(),
event_loop_middlewares,
extensions: options.extensions,
@@ -641,51 +710,6 @@ impl<const FOR_SNAPSHOT: bool> JsRuntimeImpl<FOR_SNAPSHOT> {
js_runtime
}
- /// Create a new [`v8::OwnedIsolate`] and its global [`v8::Context`] from optional parameters and snapshot.
- fn create_isolate(
- refs: &'static v8::ExternalReferences,
- params: Option<CreateParams>,
- snapshot: SnapshotOptions,
- ) -> (
- v8::OwnedIsolate,
- v8::Global<v8::Context>,
- Option<SnapshottedData>,
- )
- where
- JsRuntimeImpl<FOR_SNAPSHOT>: JsRuntimeInternalTrait,
- {
- let has_snapshot = snapshot.loaded();
- let mut isolate = Self::create_raw_isolate(refs, params, snapshot);
-
- isolate.set_capture_stack_trace_for_uncaught_exceptions(true, 10);
- isolate.set_promise_reject_callback(bindings::promise_reject_callback);
- isolate.set_host_initialize_import_meta_object_callback(
- bindings::host_initialize_import_meta_object_callback,
- );
- isolate.set_host_import_module_dynamically_callback(
- bindings::host_import_module_dynamically_callback,
- );
- isolate.set_wasm_async_resolve_promise_callback(
- bindings::wasm_async_resolve_promise_callback,
- );
-
- let (context, snapshotted_data) = {
- let scope = &mut v8::HandleScope::new(&mut isolate);
- let context = v8::Context::new(scope);
-
- // Get module map data from the snapshot
- let snapshotted_data = if has_snapshot {
- Some(snapshot_util::get_snapshotted_data(scope, context))
- } else {
- None
- };
-
- (v8::Global::new(scope, context), snapshotted_data)
- };
-
- (isolate, context, snapshotted_data)
- }
-
#[cfg(test)]
#[inline]
pub(crate) fn module_map(&self) -> &Rc<RefCell<ModuleMap>> {
@@ -728,7 +752,7 @@ impl<const FOR_SNAPSHOT: bool> JsRuntimeImpl<FOR_SNAPSHOT> {
/// Creates a new realm (V8 context) in this JS execution context,
/// pre-initialized with all of the extensions that were passed in
- /// [`RuntimeOptions::extensions`] when the [`JsRuntimeImpl`] was
+ /// [`RuntimeOptions::extensions`] when the [`JsRuntime`] was
/// constructed.
pub fn create_realm(&mut self) -> Result<JsRealm, Error> {
let realm = {
@@ -768,7 +792,7 @@ impl<const FOR_SNAPSHOT: bool> JsRuntimeImpl<FOR_SNAPSHOT> {
scope,
context,
&context_state.borrow().op_ctxs,
- self.bindings_mode,
+ self.init_mode,
);
context.set_slot(scope, context_state.clone());
let realm = JsRealmInner::new(
@@ -946,10 +970,10 @@ impl<const FOR_SNAPSHOT: bool> JsRuntimeImpl<FOR_SNAPSHOT> {
/// Initializes ops of provided Extensions
fn create_opstate(
options: &mut RuntimeOptions,
- snapshot_options: &SnapshotOptions,
+ init_mode: InitMode,
) -> (OpState, Vec<OpDecl>) {
// Add built-in extension
- if snapshot_options.loaded() {
+ if init_mode == InitMode::FromSnapshot {
options
.extensions
.insert(0, crate::ops_builtin::core::init_ops());
@@ -1470,78 +1494,15 @@ impl<const FOR_SNAPSHOT: bool> JsRuntimeImpl<FOR_SNAPSHOT> {
}
}
-impl JsRuntime {
- /// Only constructor, configuration is done through `options`.
- pub fn new(mut options: RuntimeOptions) -> JsRuntime {
- JsRuntimeImpl::<false>::init_v8(options.v8_platform.take());
-
- let snapshot_options = snapshot_util::SnapshotOptions::new_from(
- options.startup_snapshot.take(),
- false,
- );
-
- JsRuntime(JsRuntimeImpl::<false>::new_runtime(
- options,
- snapshot_options,
- None,
- ))
- }
-
- pub(crate) fn state_from(
- isolate: &v8::Isolate,
- ) -> Rc<RefCell<JsRuntimeState>> {
- let state_ptr = isolate.get_data(STATE_DATA_OFFSET);
- let state_rc =
- // SAFETY: We are sure that it's a valid pointer for whole lifetime of
- // the runtime.
- unsafe { Rc::from_raw(state_ptr as *const RefCell<JsRuntimeState>) };
- let state = state_rc.clone();
- std::mem::forget(state_rc);
- state
- }
-
- pub(crate) fn module_map_from(
- isolate: &v8::Isolate,
- ) -> Rc<RefCell<ModuleMap>> {
- let module_map_ptr = isolate.get_data(MODULE_MAP_DATA_OFFSET);
- let module_map_rc =
- // SAFETY: We are sure that it's a valid pointer for whole lifetime of
- // the runtime.
- unsafe { Rc::from_raw(module_map_ptr as *const RefCell<ModuleMap>) };
- let module_map = module_map_rc.clone();
- std::mem::forget(module_map_rc);
- module_map
- }
-
- pub(crate) fn event_loop_pending_state_from_scope(
- scope: &mut v8::HandleScope,
- ) -> EventLoopPendingState {
- let state = JsRuntime::state_from(scope);
- let module_map = JsRuntime::module_map_from(scope);
- let state = EventLoopPendingState::new(
- scope,
- &mut state.borrow_mut(),
- &module_map.borrow(),
- );
- state
- }
-}
-
impl JsRuntimeForSnapshot {
pub fn new(
mut options: RuntimeOptions,
runtime_snapshot_options: RuntimeSnapshotOptions,
) -> JsRuntimeForSnapshot {
- JsRuntimeImpl::<true>::init_v8(options.v8_platform.take());
-
- let snapshot_options = snapshot_util::SnapshotOptions::new_from(
- options.startup_snapshot.take(),
- true,
- );
-
- JsRuntimeForSnapshot(JsRuntimeImpl::<true>::new_runtime(
+ JsRuntime::init_v8(options.v8_platform.take(), true);
+ JsRuntimeForSnapshot(JsRuntime::new_inner(
options,
- snapshot_options,
+ true,
runtime_snapshot_options.snapshot_module_load_cb,
))
}
@@ -1590,42 +1551,6 @@ impl JsRuntimeForSnapshot {
}
}
-impl JsRuntimeInternalTrait for JsRuntimeImpl<true> {
- fn create_raw_isolate(
- refs: &'static v8::ExternalReferences,
- _params: Option<CreateParams>,
- snapshot: SnapshotOptions,
- ) -> v8::OwnedIsolate {
- snapshot_util::create_snapshot_creator(refs, snapshot)
- }
-}
-
-impl JsRuntimeInternalTrait for JsRuntimeImpl<false> {
- fn create_raw_isolate(
- refs: &'static v8::ExternalReferences,
- params: Option<CreateParams>,
- snapshot: SnapshotOptions,
- ) -> v8::OwnedIsolate {
- let mut params = params
- .unwrap_or_default()
- .embedder_wrapper_type_info_offsets(
- V8_WRAPPER_TYPE_INDEX,
- V8_WRAPPER_OBJECT_INDEX,
- )
- .external_references(&**refs);
-
- if let Some(snapshot) = snapshot.snapshot() {
- params = match snapshot {
- Snapshot::Static(data) => params.snapshot_blob(data),
- Snapshot::JustCreated(data) => params.snapshot_blob(data),
- Snapshot::Boxed(data) => params.snapshot_blob(data),
- };
- }
-
- v8::Isolate::new(params)
- }
-}
-
fn get_stalled_top_level_await_message_for_module(
scope: &mut v8::HandleScope,
module_id: ModuleId,
@@ -1731,7 +1656,7 @@ where
F: FnMut(usize, usize) -> usize,
{
// SAFETY: The data is a pointer to the Rust callback function. It is stored
- // in `JsRuntimeImpl::allocations` and thus is guaranteed to outlive the isolate.
+ // in `JsRuntime::allocations` and thus is guaranteed to outlive the isolate.
let callback = unsafe { &mut *(data as *mut F) };
callback(current_heap_limit, initial_heap_limit)
}
@@ -1800,7 +1725,7 @@ pub(crate) fn exception_to_err_result<T>(
}
// Related to module loading
-impl<const FOR_SNAPSHOT: bool> JsRuntimeImpl<FOR_SNAPSHOT> {
+impl JsRuntime {
pub(crate) fn instantiate_module(
&mut self,
id: ModuleId,
@@ -1916,11 +1841,11 @@ impl<const FOR_SNAPSHOT: bool> JsRuntimeImpl<FOR_SNAPSHOT> {
/// Evaluates an already instantiated ES module.
///
/// Returns a receiver handle that resolves when module promise resolves.
- /// Implementors must manually call [`JsRuntimeImpl::run_event_loop`] to drive
+ /// Implementors must manually call [`JsRuntime::run_event_loop`] to drive
/// module evaluation future.
///
/// `Error` can usually be downcast to `JsError` and should be awaited and
- /// checked after [`JsRuntimeImpl::run_event_loop`] completion.
+ /// checked after [`JsRuntime::run_event_loop`] completion.
///
/// This function panics if module has not been instantiated.
pub fn mod_evaluate(
@@ -1953,7 +1878,7 @@ impl<const FOR_SNAPSHOT: bool> JsRuntimeImpl<FOR_SNAPSHOT> {
// Because that promise is created internally by V8, when error occurs during
// module evaluation the promise is rejected, and since the promise has no rejection
// handler it will result in call to `bindings::promise_reject_callback` adding
- // the promise to pending promise rejection table - meaning JsRuntimeImpl will return
+ // the promise to pending promise rejection table - meaning JsRuntime will return
// error on next poll().
//
// This situation is not desirable as we want to manually return error at the
@@ -2362,7 +2287,7 @@ impl<const FOR_SNAPSHOT: bool> JsRuntimeImpl<FOR_SNAPSHOT> {
/// The module will be marked as "main", and because of that
/// "import.meta.main" will return true when checked inside that module.
///
- /// User must call [`JsRuntimeImpl::mod_evaluate`] with returned `ModuleId`
+ /// User must call [`JsRuntime::mod_evaluate`] with returned `ModuleId`
/// manually after load is finished.
pub async fn load_main_module(
&mut self,
@@ -2417,7 +2342,7 @@ impl<const FOR_SNAPSHOT: bool> JsRuntimeImpl<FOR_SNAPSHOT> {
/// This method is meant to be used when loading some utility code that
/// might be later imported by the main module (ie. an entry point module).
///
- /// User must call [`JsRuntimeImpl::mod_evaluate`] with returned `ModuleId`
+ /// User must call [`JsRuntime::mod_evaluate`] with returned `ModuleId`
/// manually after load is finished.
pub async fn load_side_module(
&mut self,
@@ -2563,7 +2488,7 @@ pub fn queue_fast_async_op<R: serde::Serialize + 'static>(
) {
let runtime_state = match ctx.runtime_state.upgrade() {
Some(rc_state) => rc_state,
- // at least 1 Rc is held by the JsRuntimeImpl.
+ // at least 1 Rc is held by the JsRuntime.
None => unreachable!(),
};
let get_class = {
@@ -2661,7 +2586,7 @@ pub fn queue_async_op<'s>(
) -> Option<v8::Local<'s, v8::Value>> {
let runtime_state = match ctx.runtime_state.upgrade() {
Some(rc_state) => rc_state,
- // at least 1 Rc is held by the JsRuntimeImpl.
+ // at least 1 Rc is held by the JsRuntime.
None => unreachable!(),
};
@@ -3559,8 +3484,8 @@ pub mod tests {
}
}
- fn create_module<const FOR_SNAPSHOT: bool>(
- runtime: &mut JsRuntimeImpl<FOR_SNAPSHOT>,
+ fn create_module(
+ runtime: &mut JsRuntime,
i: usize,
main: bool,
) -> ModuleInfo {
@@ -3603,10 +3528,7 @@ pub mod tests {
}
}
- fn assert_module_map<const FOR_SNAPSHOT: bool>(
- runtime: &mut JsRuntimeImpl<FOR_SNAPSHOT>,
- modules: &Vec<ModuleInfo>,
- ) {
+ fn assert_module_map(runtime: &mut JsRuntime, modules: &Vec<ModuleInfo>) {
let module_map = runtime.module_map.borrow();
assert_eq!(module_map.handles.len(), modules.len());
assert_eq!(module_map.info.len(), modules.len());
@@ -4679,13 +4601,7 @@ Deno.core.opAsync("op_async_serialize_object_with_numbers_as_keys", {
Ok(String::from("Test"))
}
- deno_core::extension!(
- test_ext,
- ops = [op_test],
- customizer = |ext: &mut deno_core::ExtensionBuilder| {
- ext.force_op_registration();
- },
- );
+ 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()],
diff --git a/core/snapshot_util.rs b/core/snapshot_util.rs
index 05a196f50..88c273147 100644
--- a/core/snapshot_util.rs
+++ b/core/snapshot_util.rs
@@ -153,40 +153,6 @@ fn data_error_to_panic(err: v8::DataError) -> ! {
}
}
-pub(crate) enum SnapshotOptions {
- Load(Snapshot),
- CreateFromExisting(Snapshot),
- Create,
- None,
-}
-
-impl SnapshotOptions {
- pub fn new_from(snapshot: Option<Snapshot>, will_snapshot: bool) -> Self {
- match (snapshot, will_snapshot) {
- (Some(snapshot), true) => Self::CreateFromExisting(snapshot),
- (None, true) => Self::Create,
- (Some(snapshot), false) => Self::Load(snapshot),
- (None, false) => Self::None,
- }
- }
-
- pub fn loaded(&self) -> bool {
- matches!(self, Self::Load(_) | Self::CreateFromExisting(_))
- }
-
- pub fn will_snapshot(&self) -> bool {
- matches!(self, Self::Create | Self::CreateFromExisting(_))
- }
-
- pub fn snapshot(self) -> Option<Snapshot> {
- match self {
- Self::CreateFromExisting(snapshot) => Some(snapshot),
- Self::Load(snapshot) => Some(snapshot),
- _ => None,
- }
- }
-}
-
pub(crate) struct SnapshottedData {
pub module_map_data: v8::Global<v8::Array>,
pub module_handles: Vec<v8::Global<v8::Module>>,
@@ -257,9 +223,9 @@ pub(crate) fn set_snapshotted_data(
/// Returns an isolate set up for snapshotting.
pub(crate) fn create_snapshot_creator(
external_refs: &'static v8::ExternalReferences,
- maybe_startup_snapshot: SnapshotOptions,
+ maybe_startup_snapshot: Option<Snapshot>,
) -> v8::OwnedIsolate {
- if let Some(snapshot) = maybe_startup_snapshot.snapshot() {
+ if let Some(snapshot) = maybe_startup_snapshot {
match snapshot {
Snapshot::Static(data) => {
v8::Isolate::snapshot_creator_from_existing_snapshot(
diff --git a/ops/lib.rs b/ops/lib.rs
index d4fa0bb82..d7c8b0640 100644
--- a/ops/lib.rs
+++ b/ops/lib.rs
@@ -143,7 +143,6 @@ impl Op {
is_async: #is_async,
is_unstable: #is_unstable,
is_v8: #is_v8,
- force_registration: false,
// TODO(mmastrac)
arg_count: 0,
}
@@ -206,7 +205,6 @@ impl Op {
is_async: #is_async,
is_unstable: #is_unstable,
is_v8: #is_v8,
- force_registration: false,
arg_count: #arg_count as u8,
}
}
diff --git a/ops/optimizer_tests/async_nop.out b/ops/optimizer_tests/async_nop.out
index 3765e611a..d59967a45 100644
--- a/ops/optimizer_tests/async_nop.out
+++ b/ops/optimizer_tests/async_nop.out
@@ -40,7 +40,6 @@ impl op_void_async {
is_async: true,
is_unstable: false,
is_v8: false,
- force_registration: false,
arg_count: 1usize as u8,
}
}
diff --git a/ops/optimizer_tests/async_result.out b/ops/optimizer_tests/async_result.out
index ca6d13c2e..6f61a9697 100644
--- a/ops/optimizer_tests/async_result.out
+++ b/ops/optimizer_tests/async_result.out
@@ -40,7 +40,6 @@ impl op_async_result {
is_async: true,
is_unstable: false,
is_v8: false,
- force_registration: false,
arg_count: 2usize as u8,
}
}
diff --git a/ops/optimizer_tests/callback_options.out b/ops/optimizer_tests/callback_options.out
index 656124a80..d46d46765 100644
--- a/ops/optimizer_tests/callback_options.out
+++ b/ops/optimizer_tests/callback_options.out
@@ -40,7 +40,6 @@ impl op_fallback {
is_async: false,
is_unstable: false,
is_v8: false,
- force_registration: false,
arg_count: 1usize as u8,
}
}
diff --git a/ops/optimizer_tests/cow_str.out b/ops/optimizer_tests/cow_str.out
index ebb2108a2..d52df86ee 100644
--- a/ops/optimizer_tests/cow_str.out
+++ b/ops/optimizer_tests/cow_str.out
@@ -40,7 +40,6 @@ impl op_cow_str {
is_async: false,
is_unstable: false,
is_v8: false,
- force_registration: false,
arg_count: 1usize as u8,
}
}
diff --git a/ops/optimizer_tests/f64_slice.out b/ops/optimizer_tests/f64_slice.out
index 811aee288..403ec8fa3 100644
--- a/ops/optimizer_tests/f64_slice.out
+++ b/ops/optimizer_tests/f64_slice.out
@@ -40,7 +40,6 @@ impl op_f64_buf {
is_async: false,
is_unstable: false,
is_v8: false,
- force_registration: false,
arg_count: 1usize as u8,
}
}
diff --git a/ops/optimizer_tests/incompatible_1.out b/ops/optimizer_tests/incompatible_1.out
index 59eb600bc..0e8c98fd0 100644
--- a/ops/optimizer_tests/incompatible_1.out
+++ b/ops/optimizer_tests/incompatible_1.out
@@ -30,7 +30,6 @@ impl op_sync_serialize_object_with_numbers_as_keys {
is_async: false,
is_unstable: false,
is_v8: false,
- force_registration: false,
arg_count: 1usize as u8,
}
}
diff --git a/ops/optimizer_tests/issue16934.out b/ops/optimizer_tests/issue16934.out
index 35bd38339..355add5e0 100644
--- a/ops/optimizer_tests/issue16934.out
+++ b/ops/optimizer_tests/issue16934.out
@@ -30,7 +30,6 @@ impl send_stdin {
is_async: true,
is_unstable: false,
is_v8: false,
- force_registration: false,
arg_count: 2usize as u8,
}
}
diff --git a/ops/optimizer_tests/issue16934_fast.out b/ops/optimizer_tests/issue16934_fast.out
index 1291f9cab..b6e80b574 100644
--- a/ops/optimizer_tests/issue16934_fast.out
+++ b/ops/optimizer_tests/issue16934_fast.out
@@ -30,7 +30,6 @@ impl send_stdin {
is_async: true,
is_unstable: false,
is_v8: false,
- force_registration: false,
arg_count: 2usize as u8,
}
}
diff --git a/ops/optimizer_tests/op_blob_revoke_object_url.out b/ops/optimizer_tests/op_blob_revoke_object_url.out
index 1a10a2b0a..3165430df 100644
--- a/ops/optimizer_tests/op_blob_revoke_object_url.out
+++ b/ops/optimizer_tests/op_blob_revoke_object_url.out
@@ -30,7 +30,6 @@ impl op_blob_revoke_object_url {
is_async: false,
is_unstable: false,
is_v8: false,
- force_registration: false,
arg_count: 1usize as u8,
}
}
diff --git a/ops/optimizer_tests/op_ffi_ptr_value.out b/ops/optimizer_tests/op_ffi_ptr_value.out
index f3da0dfce..3e4b2571d 100644
--- a/ops/optimizer_tests/op_ffi_ptr_value.out
+++ b/ops/optimizer_tests/op_ffi_ptr_value.out
@@ -40,7 +40,6 @@ impl op_ffi_ptr_value {
is_async: false,
is_unstable: false,
is_v8: false,
- force_registration: false,
arg_count: 2usize as u8,
}
}
diff --git a/ops/optimizer_tests/op_print.out b/ops/optimizer_tests/op_print.out
index e0fecd6b2..d79cdfd62 100644
--- a/ops/optimizer_tests/op_print.out
+++ b/ops/optimizer_tests/op_print.out
@@ -30,7 +30,6 @@ impl op_print {
is_async: false,
is_unstable: false,
is_v8: false,
- force_registration: false,
arg_count: 2usize as u8,
}
}
diff --git a/ops/optimizer_tests/op_state.out b/ops/optimizer_tests/op_state.out
index 300dd6fc2..1d83ae431 100644
--- a/ops/optimizer_tests/op_state.out
+++ b/ops/optimizer_tests/op_state.out
@@ -40,7 +40,6 @@ impl op_set_exit_code {
is_async: false,
is_unstable: false,
is_v8: false,
- force_registration: false,
arg_count: 1usize as u8,
}
}
diff --git a/ops/optimizer_tests/op_state_basic1.out b/ops/optimizer_tests/op_state_basic1.out
index 2452e886c..c1ea447c5 100644
--- a/ops/optimizer_tests/op_state_basic1.out
+++ b/ops/optimizer_tests/op_state_basic1.out
@@ -40,7 +40,6 @@ impl foo {
is_async: false,
is_unstable: false,
is_v8: false,
- force_registration: false,
arg_count: 2usize as u8,
}
}
diff --git a/ops/optimizer_tests/op_state_generics.out b/ops/optimizer_tests/op_state_generics.out
index 3faaa4bf1..24596256a 100644
--- a/ops/optimizer_tests/op_state_generics.out
+++ b/ops/optimizer_tests/op_state_generics.out
@@ -46,7 +46,6 @@ impl op_foo {
is_async: false,
is_unstable: false,
is_v8: false,
- force_registration: false,
arg_count: 0usize as u8,
}
}
diff --git a/ops/optimizer_tests/op_state_result.out b/ops/optimizer_tests/op_state_result.out
index 137eeeac0..4c58de8d6 100644
--- a/ops/optimizer_tests/op_state_result.out
+++ b/ops/optimizer_tests/op_state_result.out
@@ -40,7 +40,6 @@ impl foo {
is_async: false,
is_unstable: false,
is_v8: false,
- force_registration: false,
arg_count: 2usize as u8,
}
}
diff --git a/ops/optimizer_tests/op_state_warning.out b/ops/optimizer_tests/op_state_warning.out
index ce677f0fa..97d76aa97 100644
--- a/ops/optimizer_tests/op_state_warning.out
+++ b/ops/optimizer_tests/op_state_warning.out
@@ -40,7 +40,6 @@ impl op_listen {
is_async: false,
is_unstable: false,
is_v8: false,
- force_registration: false,
arg_count: 0usize as u8,
}
}
diff --git a/ops/optimizer_tests/op_state_with_transforms.out b/ops/optimizer_tests/op_state_with_transforms.out
index 4347f63e4..3bbb7289f 100644
--- a/ops/optimizer_tests/op_state_with_transforms.out
+++ b/ops/optimizer_tests/op_state_with_transforms.out
@@ -46,7 +46,6 @@ impl op_now {
is_async: false,
is_unstable: false,
is_v8: false,
- force_registration: false,
arg_count: 1usize as u8,
}
}
diff --git a/ops/optimizer_tests/opstate_with_arity.out b/ops/optimizer_tests/opstate_with_arity.out
index a1ae08127..88651ce76 100644
--- a/ops/optimizer_tests/opstate_with_arity.out
+++ b/ops/optimizer_tests/opstate_with_arity.out
@@ -40,7 +40,6 @@ impl op_add_4 {
is_async: false,
is_unstable: false,
is_v8: false,
- force_registration: false,
arg_count: 4usize as u8,
}
}
diff --git a/ops/optimizer_tests/option_arg.out b/ops/optimizer_tests/option_arg.out
index adfc8da19..f00937a74 100644
--- a/ops/optimizer_tests/option_arg.out
+++ b/ops/optimizer_tests/option_arg.out
@@ -30,7 +30,6 @@ impl op_try_close {
is_async: false,
is_unstable: false,
is_v8: false,
- force_registration: false,
arg_count: 1usize as u8,
}
}
diff --git a/ops/optimizer_tests/owned_string.out b/ops/optimizer_tests/owned_string.out
index d8c0842ac..d186e5108 100644
--- a/ops/optimizer_tests/owned_string.out
+++ b/ops/optimizer_tests/owned_string.out
@@ -40,7 +40,6 @@ impl op_string_length {
is_async: false,
is_unstable: false,
is_v8: false,
- force_registration: false,
arg_count: 1usize as u8,
}
}
diff --git a/ops/optimizer_tests/param_mut_binding_warning.out b/ops/optimizer_tests/param_mut_binding_warning.out
index e99606b37..5435b21db 100644
--- a/ops/optimizer_tests/param_mut_binding_warning.out
+++ b/ops/optimizer_tests/param_mut_binding_warning.out
@@ -30,7 +30,6 @@ impl op_read_sync {
is_async: false,
is_unstable: false,
is_v8: false,
- force_registration: false,
arg_count: 2usize as u8,
}
}
diff --git a/ops/optimizer_tests/raw_ptr.out b/ops/optimizer_tests/raw_ptr.out
index 3eefb5e7f..a1bacbfc8 100644
--- a/ops/optimizer_tests/raw_ptr.out
+++ b/ops/optimizer_tests/raw_ptr.out
@@ -51,7 +51,6 @@ impl op_ffi_ptr_of {
is_async: false,
is_unstable: false,
is_v8: false,
- force_registration: false,
arg_count: 2usize as u8,
}
}
diff --git a/ops/optimizer_tests/serde_v8_value.out b/ops/optimizer_tests/serde_v8_value.out
index 867d89e43..1a3d1ed31 100644
--- a/ops/optimizer_tests/serde_v8_value.out
+++ b/ops/optimizer_tests/serde_v8_value.out
@@ -40,7 +40,6 @@ impl op_is_proxy {
is_async: false,
is_unstable: false,
is_v8: false,
- force_registration: false,
arg_count: 1usize as u8,
}
}
diff --git a/ops/optimizer_tests/strings.out b/ops/optimizer_tests/strings.out
index 523736d70..a1e684caf 100644
--- a/ops/optimizer_tests/strings.out
+++ b/ops/optimizer_tests/strings.out
@@ -40,7 +40,6 @@ impl op_string_length {
is_async: false,
is_unstable: false,
is_v8: false,
- force_registration: false,
arg_count: 1usize as u8,
}
}
diff --git a/ops/optimizer_tests/strings_result.out b/ops/optimizer_tests/strings_result.out
index aae8b356b..46e27e762 100644
--- a/ops/optimizer_tests/strings_result.out
+++ b/ops/optimizer_tests/strings_result.out
@@ -30,7 +30,6 @@ impl op_string_length {
is_async: false,
is_unstable: false,
is_v8: false,
- force_registration: false,
arg_count: 1usize as u8,
}
}
diff --git a/ops/optimizer_tests/u64_result.out b/ops/optimizer_tests/u64_result.out
index a0d746512..46ccd53e1 100644
--- a/ops/optimizer_tests/u64_result.out
+++ b/ops/optimizer_tests/u64_result.out
@@ -30,7 +30,6 @@ impl op_bench_now {
is_async: false,
is_unstable: false,
is_v8: false,
- force_registration: false,
arg_count: 0usize as u8,
}
}
diff --git a/ops/optimizer_tests/uint8array.out b/ops/optimizer_tests/uint8array.out
index 124f2ac57..31915d2fe 100644
--- a/ops/optimizer_tests/uint8array.out
+++ b/ops/optimizer_tests/uint8array.out
@@ -40,7 +40,6 @@ impl op_import_spki_x25519 {
is_async: false,
is_unstable: false,
is_v8: false,
- force_registration: false,
arg_count: 2usize as u8,
}
}
diff --git a/ops/optimizer_tests/unit_result.out b/ops/optimizer_tests/unit_result.out
index 9a46ee087..cab67c0ea 100644
--- a/ops/optimizer_tests/unit_result.out
+++ b/ops/optimizer_tests/unit_result.out
@@ -40,7 +40,6 @@ impl op_unit_result {
is_async: false,
is_unstable: false,
is_v8: false,
- force_registration: false,
arg_count: 0usize as u8,
}
}
diff --git a/ops/optimizer_tests/unit_result2.out b/ops/optimizer_tests/unit_result2.out
index c2e6708a0..3d8479791 100644
--- a/ops/optimizer_tests/unit_result2.out
+++ b/ops/optimizer_tests/unit_result2.out
@@ -40,7 +40,6 @@ impl op_set_nodelay {
is_async: false,
is_unstable: false,
is_v8: false,
- force_registration: false,
arg_count: 2usize as u8,
}
}
diff --git a/ops/optimizer_tests/unit_ret.out b/ops/optimizer_tests/unit_ret.out
index 538674068..523ae6504 100644
--- a/ops/optimizer_tests/unit_ret.out
+++ b/ops/optimizer_tests/unit_ret.out
@@ -40,7 +40,6 @@ impl op_unit {
is_async: false,
is_unstable: false,
is_v8: false,
- force_registration: false,
arg_count: 0usize as u8,
}
}
diff --git a/ops/optimizer_tests/wasm_op.out b/ops/optimizer_tests/wasm_op.out
index cc8e3b847..5a8996cd0 100644
--- a/ops/optimizer_tests/wasm_op.out
+++ b/ops/optimizer_tests/wasm_op.out
@@ -40,7 +40,6 @@ impl op_wasm {
is_async: false,
is_unstable: false,
is_v8: false,
- force_registration: false,
arg_count: 1usize as u8,
}
}
diff --git a/runtime/examples/extension_with_ops/main.rs b/runtime/examples/extension_with_ops/main.rs
index 47feaeaeb..1feb4ba27 100644
--- a/runtime/examples/extension_with_ops/main.rs
+++ b/runtime/examples/extension_with_ops/main.rs
@@ -11,13 +11,7 @@ use deno_runtime::permissions::PermissionsContainer;
use deno_runtime::worker::MainWorker;
use deno_runtime::worker::WorkerOptions;
-deno_core::extension!(
- hello_runtime,
- ops = [op_hello],
- customizer = |ext: &mut deno_core::ExtensionBuilder| {
- ext.force_op_registration();
- },
-);
+deno_core::extension!(hello_runtime, ops = [op_hello]);
#[op]
fn op_hello(text: &str) {
diff --git a/runtime/ops/fs_events.rs b/runtime/ops/fs_events.rs
index 27e76b3d3..2668431eb 100644
--- a/runtime/ops/fs_events.rs
+++ b/runtime/ops/fs_events.rs
@@ -31,9 +31,6 @@ use tokio::sync::mpsc;
deno_core::extension!(
deno_fs_events,
ops = [op_fs_events_open, op_fs_events_poll],
- customizer = |ext: &mut deno_core::ExtensionBuilder| {
- ext.force_op_registration();
- },
);
struct FsEventsResource {
diff --git a/runtime/ops/http.rs b/runtime/ops/http.rs
index 767fc3ae0..eb2711257 100644
--- a/runtime/ops/http.rs
+++ b/runtime/ops/http.rs
@@ -30,9 +30,6 @@ use tokio::net::UnixStream;
deno_core::extension!(
deno_http_runtime,
ops = [op_http_start, op_http_upgrade],
- customizer = |ext: &mut deno_core::ExtensionBuilder| {
- ext.force_op_registration();
- },
);
#[op]
diff --git a/runtime/ops/os/mod.rs b/runtime/ops/os/mod.rs
index b997a89d9..043dec700 100644
--- a/runtime/ops/os/mod.rs
+++ b/runtime/ops/os/mod.rs
@@ -48,9 +48,6 @@ deno_core::extension!(
state = |state, options| {
state.put::<ExitCode>(options.exit_code);
},
- customizer = |ext: &mut deno_core::ExtensionBuilder| {
- ext.force_op_registration();
- }
);
deno_core::extension!(
@@ -63,9 +60,6 @@ deno_core::extension!(
},
_ => op,
},
- customizer = |ext: &mut deno_core::ExtensionBuilder| {
- ext.force_op_registration();
- }
);
#[op]
diff --git a/runtime/ops/permissions.rs b/runtime/ops/permissions.rs
index 6f7b98a30..663b1d240 100644
--- a/runtime/ops/permissions.rs
+++ b/runtime/ops/permissions.rs
@@ -18,9 +18,6 @@ deno_core::extension!(
op_revoke_permission,
op_request_permission,
],
- customizer = |ext: &mut deno_core::ExtensionBuilder| {
- ext.force_op_registration();
- },
);
#[derive(Deserialize)]
diff --git a/runtime/ops/process.rs b/runtime/ops/process.rs
index a2eace8b6..44429fdab 100644
--- a/runtime/ops/process.rs
+++ b/runtime/ops/process.rs
@@ -112,9 +112,6 @@ deno_core::extension!(
deprecated::op_run_status,
deprecated::op_kill,
],
- customizer = |ext: &mut deno_core::ExtensionBuilder| {
- ext.force_op_registration();
- },
);
/// Second member stores the pid separately from the RefCell. It's needed for
diff --git a/runtime/ops/runtime.rs b/runtime/ops/runtime.rs
index 9f2e48d7a..3f60c7437 100644
--- a/runtime/ops/runtime.rs
+++ b/runtime/ops/runtime.rs
@@ -13,9 +13,6 @@ deno_core::extension!(
state = |state, options| {
state.put::<ModuleSpecifier>(options.main_module);
},
- customizer = |ext: &mut deno_core::ExtensionBuilder| {
- ext.force_op_registration();
- },
);
#[op]
diff --git a/runtime/ops/signal.rs b/runtime/ops/signal.rs
index ba9a2a178..934192c77 100644
--- a/runtime/ops/signal.rs
+++ b/runtime/ops/signal.rs
@@ -32,9 +32,6 @@ use tokio::signal::windows::CtrlC;
deno_core::extension!(
deno_signal,
ops = [op_signal_bind, op_signal_unbind, op_signal_poll],
- customizer = |ext: &mut deno_core::ExtensionBuilder| {
- ext.force_op_registration();
- },
);
#[cfg(unix)]
diff --git a/runtime/ops/tty.rs b/runtime/ops/tty.rs
index 7f24daec4..b4e4d7340 100644
--- a/runtime/ops/tty.rs
+++ b/runtime/ops/tty.rs
@@ -79,9 +79,6 @@ deno_core::extension!(
#[cfg(unix)]
state.put(TtyModeStore::default());
},
- customizer = |ext: &mut deno_core::ExtensionBuilder| {
- ext.force_op_registration();
- },
);
// ref: <https://learn.microsoft.com/en-us/windows/console/setconsolemode>
diff --git a/runtime/ops/web_worker.rs b/runtime/ops/web_worker.rs
index 7952a03f2..e62642fdd 100644
--- a/runtime/ops/web_worker.rs
+++ b/runtime/ops/web_worker.rs
@@ -25,9 +25,6 @@ deno_core::extension!(
op_worker_get_type,
op_worker_sync_fetch,
],
- customizer = |ext: &mut deno_core::ExtensionBuilder| {
- ext.force_op_registration();
- },
);
#[op]
diff --git a/runtime/ops/worker_host.rs b/runtime/ops/worker_host.rs
index d5285ec89..f96ae38e8 100644
--- a/runtime/ops/worker_host.rs
+++ b/runtime/ops/worker_host.rs
@@ -119,9 +119,6 @@ deno_core::extension!(
FormatJsErrorFnHolder(options.format_js_error_fn);
state.put::<FormatJsErrorFnHolder>(format_js_error_fn_holder);
},
- customizer = |ext: &mut deno_core::ExtensionBuilder| {
- ext.force_op_registration();
- },
);
#[derive(Deserialize)]