From 5245f5defd9c4f4f05323c38ad5a097c87d48346 Mon Sep 17 00:00:00 2001 From: Divy Srivastava Date: Sat, 6 Apr 2024 21:17:42 +0530 Subject: [PATCH] Use `const fn` for op declaration (#685) Switch op declaration from a `impl #name` to a `const fn #name`. This form for declaration can be used inside `impl` blocks. ```rust struct Foo {} impl Foo { #[op2(fast)] pub fn bar(#[state] state: &mut OpState) {} } // const DECL: OpDecl = Foo::bar(); ``` Based on Matt's suggestion in https://github.com/denoland/deno_core/pull/682 [Playground link](https://play.rust-lang.org/?version=stable&mode=release&edition=2021&gist=2d7152d548b4a466779c401551b21b05) This patch wraps `const` around the existing `impl` codegen to unblock work on op2++ --- core/examples/hello_world.rs | 3 +- core/extensions.rs | 11 +- core/ops_builtin.rs | 3 +- core/runtime/tests/ops.rs | 3 +- core/runtime/tests/snapshot.rs | 9 +- ops/op2/dispatch_fast.rs | 4 +- ops/op2/mod.rs | 70 +- ops/op2/test_cases/async/async_arg_return.out | 200 +-- .../async/async_arg_return_result.out | 224 +-- ops/op2/test_cases/async/async_deferred.out | 288 ++-- ops/op2/test_cases/async/async_jsbuffer.out | 241 ++-- ops/op2/test_cases/async/async_lazy.out | 288 ++-- .../test_cases/async/async_op_metadata.out | 344 ++--- ops/op2/test_cases/async/async_opstate.out | 206 +-- ops/op2/test_cases/async/async_result.out | 198 +-- .../test_cases/async/async_result_impl.out | 236 ++-- ops/op2/test_cases/async/async_result_smi.out | 258 ++-- ops/op2/test_cases/async/async_v8_global.out | 202 +-- ops/op2/test_cases/async/async_void.out | 164 +-- ops/op2/test_cases/sync/add.out | 306 +++-- ops/op2/test_cases/sync/add_options.out | 188 +-- ops/op2/test_cases/sync/bigint.out | 226 +-- ops/op2/test_cases/sync/bool.out | 250 ++-- ops/op2/test_cases/sync/bool_result.out | 326 ++--- ops/op2/test_cases/sync/buffers.out | 1214 +++++++++-------- ops/op2/test_cases/sync/buffers_copy.out | 782 +++++------ ops/op2/test_cases/sync/buffers_out.out | 585 ++++---- ops/op2/test_cases/sync/cfg.out | 456 ++++--- ops/op2/test_cases/sync/clippy_allow.out | 452 +++--- ops/op2/test_cases/sync/cppgc_resource.out | 614 +++++---- ops/op2/test_cases/sync/doc_comment.out | 224 +-- ops/op2/test_cases/sync/fast_alternative.out | 1004 +++++++------- ops/op2/test_cases/sync/generics.out | 666 ++++----- ops/op2/test_cases/sync/nofast.out | 196 +-- ops/op2/test_cases/sync/op_state_attr.out | 278 ++-- ops/op2/test_cases/sync/op_state_rc.out | 266 ++-- ops/op2/test_cases/sync/op_state_ref.out | 1028 +++++++------- ops/op2/test_cases/sync/result_external.out | 312 ++--- ops/op2/test_cases/sync/result_primitive.out | 310 ++--- ops/op2/test_cases/sync/result_scope.out | 178 +-- ops/op2/test_cases/sync/result_void.out | 310 ++--- ops/op2/test_cases/sync/serde_v8.out | 190 +-- ops/op2/test_cases/sync/smi.out | 964 ++++++------- ops/op2/test_cases/sync/string_cow.out | 276 ++-- ops/op2/test_cases/sync/string_onebyte.out | 288 ++-- .../test_cases/sync/string_option_return.out | 178 +-- ops/op2/test_cases/sync/string_owned.out | 260 ++-- ops/op2/test_cases/sync/string_ref.out | 276 ++-- ops/op2/test_cases/sync/string_return.out | 468 +++---- ops/op2/test_cases/sync/v8_global.out | 174 +-- ops/op2/test_cases/sync/v8_handlescope.out | 180 +-- ops/op2/test_cases/sync/v8_lifetime.out | 172 +-- ops/op2/test_cases/sync/v8_ref_option.out | 372 ++--- ops/op2/test_cases/sync/v8_string.out | 210 +-- 54 files changed, 8757 insertions(+), 8374 deletions(-) diff --git a/core/examples/hello_world.rs b/core/examples/hello_world.rs index 080b632a9..6e99349a7 100644 --- a/core/examples/hello_world.rs +++ b/core/examples/hello_world.rs @@ -16,9 +16,10 @@ fn op_sum(#[serde] nums: Vec) -> Result { fn main() { // Build a deno_core::Extension providing custom ops + const DECL: OpDecl = op_sum(); let ext = Extension { name: "my_ext", - ops: std::borrow::Cow::Borrowed(&[op_sum::DECL]), + ops: std::borrow::Cow::Borrowed(&[DECL]), ..Default::default() }; diff --git a/core/extensions.rs b/core/extensions.rs index 390d7566a..308eeb658 100644 --- a/core/extensions.rs +++ b/core/extensions.rs @@ -322,7 +322,7 @@ macro_rules! ops { vec![ $( $( #[ $m ] )* - $( $op )::+ :: decl $( :: <$op_param> )? () , + $( $op )+ $( :: <$op_param> )? () , )+ ] } @@ -331,7 +331,7 @@ macro_rules! ops { pub(crate) fn $name() -> ::std::Vec<$crate::OpDecl> { use $crate::Op; vec![ - $( $( #[ $m ] )* $( $op )::+ :: DECL, )+ + $( $( #[ $m ] )* $( $op )+() , )+ ] } } @@ -450,10 +450,11 @@ macro_rules! extension { const V: ::std::option::Option<&'static ::std::primitive::str> = $crate::or!($(::std::option::Option::Some($esm_entry_point))?, ::std::option::Option::None); V }, - ops: ::std::borrow::Cow::Borrowed(&[$($( + ops: ::std::borrow::Cow::Borrowed(&[$($({ $( #[ $m ] )* - $( $op )::+ $( :: < $($op_param),* > )? :: DECL - ),+)?]), + const DECL: $crate::OpDecl = $( $op )::+ $( :: < $($op_param),* > )? (); + DECL + }),+)?]), external_references: ::std::borrow::Cow::Borrowed(&[ $( $external_reference ),* ]), global_template_middleware: ::std::option::Option::None, global_object_middleware: ::std::option::Option::None, diff --git a/core/ops_builtin.rs b/core/ops_builtin.rs index abee5cc28..fab1796cd 100644 --- a/core/ops_builtin.rs +++ b/core/ops_builtin.rs @@ -10,7 +10,6 @@ use crate::ops_builtin_types; use crate::ops_builtin_v8; use crate::CancelHandle; use crate::JsBuffer; -use crate::Op; use crate::OpDecl; use crate::OpState; use crate::Resource; @@ -26,7 +25,7 @@ use std::rc::Rc; macro_rules! builtin_ops { ( $($op:ident $(:: $sub:ident)*),* ) => { pub const BUILTIN_OPS: &'static [OpDecl] = &[ - $( $op $(:: $sub)*::DECL, )* + $( $op $(:: $sub) * () ),* ]; } } diff --git a/core/runtime/tests/ops.rs b/core/runtime/tests/ops.rs index e46765ec5..994e35c89 100644 --- a/core/runtime/tests/ops.rs +++ b/core/runtime/tests/ops.rs @@ -1,6 +1,5 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. use crate::error::AnyError; -use crate::extensions::Op; use crate::extensions::OpDecl; use crate::modules::StaticModuleLoader; use crate::runtime::tests::setup; @@ -196,7 +195,7 @@ fn test_op_disabled() { } fn ops() -> Vec { - vec![op_foo::DECL.disable()] + vec![op_foo().disable()] } deno_core::extension!(test_ext, ops_fn = ops); diff --git a/core/runtime/tests/snapshot.rs b/core/runtime/tests/snapshot.rs index 64959c341..8359a78ef 100644 --- a/core/runtime/tests/snapshot.rs +++ b/core/runtime/tests/snapshot.rs @@ -1,5 +1,4 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. -use crate::extensions::Op; use crate::modules::ModuleInfo; use crate::modules::RequestedModuleType; use crate::runtime::NO_OF_BUILTIN_MODULES; @@ -236,11 +235,10 @@ fn es_snapshot() { fn op_test() -> Result { Ok(String::from("test")) } - let mut runtime = JsRuntimeForSnapshot::new(RuntimeOptions { extensions: vec![Extension { name: "test_ext", - ops: Cow::Borrowed(&[op_test::DECL]), + ops: Cow::Borrowed(&[DECL]), ..Default::default() }], ..Default::default() @@ -278,7 +276,7 @@ fn es_snapshot() { startup_snapshot: Some(snapshot), extensions: vec![Extension { name: "test_ext", - ops: Cow::Borrowed(&[op_test::DECL]), + ops: Cow::Borrowed(&[DECL]), ..Default::default() }], ..Default::default() @@ -294,11 +292,12 @@ fn es_snapshot() { let snapshot2 = runtime2.snapshot(); let snapshot2 = Box::leak(snapshot2); + const DECL: OpDecl = op_test(); let mut runtime3 = JsRuntime::new(RuntimeOptions { startup_snapshot: Some(snapshot2), extensions: vec![Extension { name: "test_ext", - ops: Cow::Borrowed(&[op_test::DECL]), + ops: Cow::Borrowed(&[DECL]), ..Default::default() }], ..Default::default() diff --git a/ops/op2/dispatch_fast.rs b/ops/op2/dispatch_fast.rs index 226aead7c..8c4bdb26c 100644 --- a/ops/op2/dispatch_fast.rs +++ b/ops/op2/dispatch_fast.rs @@ -375,8 +375,8 @@ pub(crate) fn generate_dispatch_fast( let alternative = syn::parse_str::(alternative).expect("Failed to reparse type"); return Ok(Some(( - quote!(#alternative::DECL.fast_fn()), - quote!(#alternative::DECL.fast_fn_with_metrics()), + quote!(#alternative().fast_fn()), + quote!(#alternative().fast_fn_with_metrics()), quote!(), ))); } diff --git a/ops/op2/mod.rs b/ops/op2/mod.rs index 5119b513e..c5560fe3b 100644 --- a/ops/op2/mod.rs +++ b/ops/op2/mod.rs @@ -244,46 +244,46 @@ fn generate_op2( Ok(quote! { #[allow(non_camel_case_types)] - #(#attrs)* - #vis struct #name <#(#generic),*> { - // We need to mark these type parameters as used, so we use a PhantomData - _unconstructable: ::std::marker::PhantomData<(#(#generic),*)> - } - - impl <#(#generic : #bound),*> ::deno_core::_ops::Op for #name <#(#generic),*> { - const NAME: &'static str = stringify!(#name); - const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( - /*name*/ ::deno_core::__op_name_fast!(#name), - /*is_async*/ #is_async, - /*is_reentrant*/ #is_reentrant, - /*arg_count*/ #arg_count as u8, - /*slow_fn*/ Self::#slow_function as _, - /*slow_fn_metrics*/ Self::#slow_function_metrics as _, - /*fast_fn*/ #fast_definition, - /*fast_fn_metrics*/ #fast_definition_metrics, - /*metadata*/ ::deno_core::OpMetadata { - #(#meta_key: Some(#meta_value),)* - ..::deno_core::OpMetadata::default() - }, - ); - } - - impl <#(#generic : #bound),*> #name <#(#generic),*> { - pub const fn name() -> &'static str { - stringify!(#name) + #vis const fn #name <#(#generic : #bound),*> () -> ::deno_core::_ops::OpDecl { + #[allow(non_camel_case_types)] + #(#attrs)* + #vis struct #name <#(#generic),*> { + // We need to mark these type parameters as used, so we use a PhantomData + _unconstructable: ::std::marker::PhantomData<(#(#generic),*)> } - #[deprecated(note = "Use the const op::DECL instead")] - pub const fn decl() -> deno_core::_ops::OpDecl { - ::DECL + impl <#(#generic : #bound),*> ::deno_core::_ops::Op for #name <#(#generic),*> { + const NAME: &'static str = stringify!(#name); + const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( + /*name*/ ::deno_core::__op_name_fast!(#name), + /*is_async*/ #is_async, + /*is_reentrant*/ #is_reentrant, + /*arg_count*/ #arg_count as u8, + /*slow_fn*/ Self::#slow_function as _, + /*slow_fn_metrics*/ Self::#slow_function_metrics as _, + /*fast_fn*/ #fast_definition, + /*fast_fn_metrics*/ #fast_definition_metrics, + /*metadata*/ ::deno_core::OpMetadata { + #(#meta_key: Some(#meta_value),)* + ..::deno_core::OpMetadata::default() + }, + ); } - #fast_fn - #slow_fn + impl <#(#generic : #bound),*> #name <#(#generic),*> { + pub const fn name() -> &'static str { + stringify!(#name) + } - #[inline(always)] - #(#attrs)* - #op_fn + #fast_fn + #slow_fn + + #[inline(always)] + #(#attrs)* + #op_fn + } + + <#name <#(#generic),*> as ::deno_core::_ops::Op>::DECL } }) } diff --git a/ops/op2/test_cases/async/async_arg_return.out b/ops/op2/test_cases/async/async_arg_return.out index d28f85097..1255c037f 100644 --- a/ops/op2/test_cases/async/async_arg_return.out +++ b/ops/op2/test_cases/async/async_arg_return.out @@ -1,109 +1,113 @@ #[allow(non_camel_case_types)] -pub struct op_async { - _unconstructable: ::std::marker::PhantomData<()>, -} -impl ::deno_core::_ops::Op for op_async { - const NAME: &'static str = stringify!(op_async); - const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( - ::deno_core::__op_name_fast!(op_async), - true, - false, - 2usize as u8, - Self::v8_fn_ptr as _, - Self::v8_fn_ptr_metrics as _, - None, - None, - ::deno_core::OpMetadata { - ..::deno_core::OpMetadata::default() - }, - ); -} -impl op_async { - pub const fn name() -> &'static str { - stringify!(op_async) - } - #[deprecated(note = "Use the const op::DECL instead")] - pub const fn decl() -> deno_core::_ops::OpDecl { - ::DECL +pub const fn op_async() -> ::deno_core::_ops::OpDecl { + #[allow(non_camel_case_types)] + pub struct op_async { + _unconstructable: ::std::marker::PhantomData<()>, } - #[inline(always)] - fn slow_function_impl(info: *const deno_core::v8::FunctionCallbackInfo) -> usize { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, - ); - let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { - &*info - }); - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - let result = { - let arg0 = args.get(1usize as i32); - let Some(arg0) = deno_core::_ops::to_i32_option(&arg0) else { - let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; - let msg = deno_core::v8::String::new_from_one_byte( - &mut scope, - "expected i32".as_bytes(), - deno_core::v8::NewStringType::Normal, - ) - .unwrap(); - let exc = deno_core::v8::Exception::type_error(&mut scope, msg); - scope.throw_exception(exc); - return 1; - }; - let arg0 = arg0 as _; - Self::call(arg0) - }; - let promise_id = deno_core::_ops::to_i32_option(&args.get(0)) - .unwrap_or_default(); - if let Some(result) = deno_core::_ops::map_async_op_infallible( - opctx, - false, + impl ::deno_core::_ops::Op for op_async { + const NAME: &'static str = stringify!(op_async); + const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( + ::deno_core::__op_name_fast!(op_async), + true, false, - promise_id, - result, - |scope, result| { Ok(deno_core::_ops::RustToV8::to_v8(result, scope)) }, - ) { - deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv); - return 0; - } - return 2; - } - extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { - Self::slow_function_impl(info); - } - extern "C" fn v8_fn_ptr_metrics(info: *const deno_core::v8::FunctionCallbackInfo) { - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_async( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, + 2usize as u8, + Self::v8_fn_ptr as _, + Self::v8_fn_ptr_metrics as _, + None, + None, + ::deno_core::OpMetadata { + ..::deno_core::OpMetadata::default() + }, ); - let res = Self::slow_function_impl(info); - if res == 0 { - deno_core::_ops::dispatch_metrics_async( - &opctx, - deno_core::_ops::OpMetricsEvent::Completed, + } + impl op_async { + pub const fn name() -> &'static str { + stringify!(op_async) + } + #[inline(always)] + fn slow_function_impl( + info: *const deno_core::v8::FunctionCallbackInfo, + ) -> usize { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, ); - } else if res == 1 { + let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { + &*info + }); + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; + let result = { + let arg0 = args.get(1usize as i32); + let Some(arg0) = deno_core::_ops::to_i32_option(&arg0) else { + let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; + let msg = deno_core::v8::String::new_from_one_byte( + &mut scope, + "expected i32".as_bytes(), + deno_core::v8::NewStringType::Normal, + ) + .unwrap(); + let exc = deno_core::v8::Exception::type_error(&mut scope, msg); + scope.throw_exception(exc); + return 1; + }; + let arg0 = arg0 as _; + Self::call(arg0) + }; + let promise_id = deno_core::_ops::to_i32_option(&args.get(0)) + .unwrap_or_default(); + if let Some(result) = deno_core::_ops::map_async_op_infallible( + opctx, + false, + false, + promise_id, + result, + |scope, result| { Ok(deno_core::_ops::RustToV8::to_v8(result, scope)) }, + ) { + deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv); + return 0; + } + return 2; + } + extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { + Self::slow_function_impl(info); + } + extern "C" fn v8_fn_ptr_metrics( + info: *const deno_core::v8::FunctionCallbackInfo, + ) { + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; deno_core::_ops::dispatch_metrics_async( &opctx, - deno_core::_ops::OpMetricsEvent::Error, + deno_core::_ops::OpMetricsEvent::Dispatched, ); + let res = Self::slow_function_impl(info); + if res == 0 { + deno_core::_ops::dispatch_metrics_async( + &opctx, + deno_core::_ops::OpMetricsEvent::Completed, + ); + } else if res == 1 { + deno_core::_ops::dispatch_metrics_async( + &opctx, + deno_core::_ops::OpMetricsEvent::Error, + ); + } + } + #[inline(always)] + pub async fn call(x: i32) -> i32 { + x } } - #[inline(always)] - pub async fn call(x: i32) -> i32 { - x - } + ::DECL } diff --git a/ops/op2/test_cases/async/async_arg_return_result.out b/ops/op2/test_cases/async/async_arg_return_result.out index 28a509cac..928cb9bdc 100644 --- a/ops/op2/test_cases/async/async_arg_return_result.out +++ b/ops/op2/test_cases/async/async_arg_return_result.out @@ -1,122 +1,130 @@ #[allow(non_camel_case_types)] -pub struct op_async { - _unconstructable: ::std::marker::PhantomData<()>, -} -impl ::deno_core::_ops::Op for op_async { - const NAME: &'static str = stringify!(op_async); - const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( - ::deno_core::__op_name_fast!(op_async), - true, - false, - 2usize as u8, - Self::v8_fn_ptr as _, - Self::v8_fn_ptr_metrics as _, - None, - None, - ::deno_core::OpMetadata { - ..::deno_core::OpMetadata::default() - }, - ); -} -impl op_async { - pub const fn name() -> &'static str { - stringify!(op_async) - } - #[deprecated(note = "Use the const op::DECL instead")] - pub const fn decl() -> deno_core::_ops::OpDecl { - ::DECL +pub const fn op_async() -> ::deno_core::_ops::OpDecl { + #[allow(non_camel_case_types)] + pub struct op_async { + _unconstructable: ::std::marker::PhantomData<()>, } - #[inline(always)] - fn slow_function_impl(info: *const deno_core::v8::FunctionCallbackInfo) -> usize { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, + impl ::deno_core::_ops::Op for op_async { + const NAME: &'static str = stringify!(op_async); + const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( + ::deno_core::__op_name_fast!(op_async), + true, + false, + 2usize as u8, + Self::v8_fn_ptr as _, + Self::v8_fn_ptr_metrics as _, + None, + None, + ::deno_core::OpMetadata { + ..::deno_core::OpMetadata::default() + }, ); - let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { - &*info - }); - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - let result = { - let arg0 = args.get(1usize as i32); - let Some(arg0) = deno_core::_ops::to_i32_option(&arg0) else { - let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; - let msg = deno_core::v8::String::new_from_one_byte( - &mut scope, - "expected i32".as_bytes(), - deno_core::v8::NewStringType::Normal, - ) - .unwrap(); - let exc = deno_core::v8::Exception::type_error(&mut scope, msg); - scope.throw_exception(exc); - return 1; + } + impl op_async { + pub const fn name() -> &'static str { + stringify!(op_async) + } + #[inline(always)] + fn slow_function_impl( + info: *const deno_core::v8::FunctionCallbackInfo, + ) -> usize { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, + ); + let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { + &*info + }); + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) }; - let arg0 = arg0 as _; - Self::call(arg0) - }; - let promise_id = deno_core::_ops::to_i32_option(&args.get(0)) - .unwrap_or_default(); - if let Some(result) = deno_core::_ops::map_async_op_fallible( - opctx, - false, - false, - promise_id, - result, - |scope, result| { Ok(deno_core::_ops::RustToV8::to_v8(result, scope)) }, - ) { - match result { - Ok(result) => deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv), - Err(err) => { + let result = { + let arg0 = args.get(1usize as i32); + let Some(arg0) = deno_core::_ops::to_i32_option(&arg0) else { let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; - let err = err.into(); - let exception = deno_core::error::to_v8_error( - &mut scope, - opctx.get_error_class_fn, - &err, - ); - scope.throw_exception(exception); + let msg = deno_core::v8::String::new_from_one_byte( + &mut scope, + "expected i32".as_bytes(), + deno_core::v8::NewStringType::Normal, + ) + .unwrap(); + let exc = deno_core::v8::Exception::type_error(&mut scope, msg); + scope.throw_exception(exc); return 1; - } + }; + let arg0 = arg0 as _; + Self::call(arg0) }; - return 0; + let promise_id = deno_core::_ops::to_i32_option(&args.get(0)) + .unwrap_or_default(); + if let Some(result) = deno_core::_ops::map_async_op_fallible( + opctx, + false, + false, + promise_id, + result, + |scope, result| { Ok(deno_core::_ops::RustToV8::to_v8(result, scope)) }, + ) { + match result { + Ok(result) => { + deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv) + } + Err(err) => { + let mut scope = unsafe { + deno_core::v8::CallbackScope::new(&*info) + }; + let err = err.into(); + let exception = deno_core::error::to_v8_error( + &mut scope, + opctx.get_error_class_fn, + &err, + ); + scope.throw_exception(exception); + return 1; + } + }; + return 0; + } + return 2; } - return 2; - } - extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { - Self::slow_function_impl(info); - } - extern "C" fn v8_fn_ptr_metrics(info: *const deno_core::v8::FunctionCallbackInfo) { - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_async( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, - ); - let res = Self::slow_function_impl(info); - if res == 0 { - deno_core::_ops::dispatch_metrics_async( - &opctx, - deno_core::_ops::OpMetricsEvent::Completed, - ); - } else if res == 1 { + extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { + Self::slow_function_impl(info); + } + extern "C" fn v8_fn_ptr_metrics( + info: *const deno_core::v8::FunctionCallbackInfo, + ) { + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; deno_core::_ops::dispatch_metrics_async( &opctx, - deno_core::_ops::OpMetricsEvent::Error, + deno_core::_ops::OpMetricsEvent::Dispatched, ); + let res = Self::slow_function_impl(info); + if res == 0 { + deno_core::_ops::dispatch_metrics_async( + &opctx, + deno_core::_ops::OpMetricsEvent::Completed, + ); + } else if res == 1 { + deno_core::_ops::dispatch_metrics_async( + &opctx, + deno_core::_ops::OpMetricsEvent::Error, + ); + } + } + #[inline(always)] + pub async fn call(x: i32) -> std::io::Result { + Ok(x) } } - #[inline(always)] - pub async fn call(x: i32) -> std::io::Result { - Ok(x) - } + ::DECL } diff --git a/ops/op2/test_cases/async/async_deferred.out b/ops/op2/test_cases/async/async_deferred.out index 8e135995f..fb31f5072 100644 --- a/ops/op2/test_cases/async/async_deferred.out +++ b/ops/op2/test_cases/async/async_deferred.out @@ -1,157 +1,161 @@ #[allow(non_camel_case_types)] -pub struct op_async_deferred { - _unconstructable: ::std::marker::PhantomData<()>, -} -impl ::deno_core::_ops::Op for op_async_deferred { - const NAME: &'static str = stringify!(op_async_deferred); - const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( - ::deno_core::__op_name_fast!(op_async_deferred), - true, - false, - 1usize as u8, - Self::v8_fn_ptr as _, - Self::v8_fn_ptr_metrics as _, - Some({ - use deno_core::v8::fast_api::Type; - use deno_core::v8::fast_api::CType; - deno_core::v8::fast_api::FastFunction::new_with_bigint( - &[Type::V8Value, Type::Int32, Type::CallbackOptions], - CType::Void, - Self::v8_fn_ptr_fast as *const ::std::ffi::c_void, - ) - }), - Some({ - use deno_core::v8::fast_api::Type; - use deno_core::v8::fast_api::CType; - deno_core::v8::fast_api::FastFunction::new_with_bigint( - &[Type::V8Value, Type::Int32, Type::CallbackOptions], - CType::Void, - Self::v8_fn_ptr_fast_metrics as *const ::std::ffi::c_void, - ) - }), - ::deno_core::OpMetadata { - ..::deno_core::OpMetadata::default() - }, - ); -} -impl op_async_deferred { - pub const fn name() -> &'static str { - stringify!(op_async_deferred) +pub const fn op_async_deferred() -> ::deno_core::_ops::OpDecl { + #[allow(non_camel_case_types)] + pub struct op_async_deferred { + _unconstructable: ::std::marker::PhantomData<()>, } - #[deprecated(note = "Use the const op::DECL instead")] - pub const fn decl() -> deno_core::_ops::OpDecl { - ::DECL - } - #[allow(clippy::too_many_arguments)] - extern "C" fn v8_fn_ptr_fast_metrics( - this: deno_core::v8::Local, - promise_id: i32, - fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, - ) -> () { - let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; - let opctx = unsafe { - &*(deno_core::v8::Local::< - deno_core::v8::External, - >::cast(unsafe { fast_api_callback_options.data.data }) - .value() as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_fast( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, - ); - let res = Self::v8_fn_ptr_fast(this, promise_id, fast_api_callback_options); - deno_core::_ops::dispatch_metrics_fast( - &opctx, - deno_core::_ops::OpMetricsEvent::Completed, - ); - res - } - #[allow(clippy::too_many_arguments)] - extern "C" fn v8_fn_ptr_fast( - _: deno_core::v8::Local, - promise_id: i32, - fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, - ) -> () { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, - ); - let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; - let opctx = unsafe { - &*(deno_core::v8::Local::< - deno_core::v8::External, - >::cast(unsafe { fast_api_callback_options.data.data }) - .value() as *const deno_core::_ops::OpCtx) - }; - let result = { Self::call() }; - deno_core::_ops::map_async_op_fallible( - opctx, - false, + impl ::deno_core::_ops::Op for op_async_deferred { + const NAME: &'static str = stringify!(op_async_deferred); + const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( + ::deno_core::__op_name_fast!(op_async_deferred), true, - promise_id, - result, - |scope, result| { Ok(deno_core::_ops::RustToV8::to_v8(result, scope)) }, - ); - } - #[inline(always)] - fn slow_function_impl(info: *const deno_core::v8::FunctionCallbackInfo) -> usize { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, - ); - let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { - &*info - }); - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - let result = { Self::call() }; - let promise_id = deno_core::_ops::to_i32_option(&args.get(0)) - .unwrap_or_default(); - deno_core::_ops::map_async_op_fallible( - opctx, false, - true, - promise_id, - result, - |scope, result| { Ok(deno_core::_ops::RustToV8::to_v8(result, scope)) }, + 1usize as u8, + Self::v8_fn_ptr as _, + Self::v8_fn_ptr_metrics as _, + Some({ + use deno_core::v8::fast_api::Type; + use deno_core::v8::fast_api::CType; + deno_core::v8::fast_api::FastFunction::new_with_bigint( + &[Type::V8Value, Type::Int32, Type::CallbackOptions], + CType::Void, + Self::v8_fn_ptr_fast as *const ::std::ffi::c_void, + ) + }), + Some({ + use deno_core::v8::fast_api::Type; + use deno_core::v8::fast_api::CType; + deno_core::v8::fast_api::FastFunction::new_with_bigint( + &[Type::V8Value, Type::Int32, Type::CallbackOptions], + CType::Void, + Self::v8_fn_ptr_fast_metrics as *const ::std::ffi::c_void, + ) + }), + ::deno_core::OpMetadata { + ..::deno_core::OpMetadata::default() + }, ); - return 2; - } - extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { - Self::slow_function_impl(info); } - extern "C" fn v8_fn_ptr_metrics(info: *const deno_core::v8::FunctionCallbackInfo) { - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_async( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, - ); - let res = Self::slow_function_impl(info); - if res == 0 { - deno_core::_ops::dispatch_metrics_async( + impl op_async_deferred { + pub const fn name() -> &'static str { + stringify!(op_async_deferred) + } + #[allow(clippy::too_many_arguments)] + extern "C" fn v8_fn_ptr_fast_metrics( + this: deno_core::v8::Local, + promise_id: i32, + fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, + ) -> () { + let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; + let opctx = unsafe { + &*(deno_core::v8::Local::< + deno_core::v8::External, + >::cast(unsafe { fast_api_callback_options.data.data }) + .value() as *const deno_core::_ops::OpCtx) + }; + deno_core::_ops::dispatch_metrics_fast( + &opctx, + deno_core::_ops::OpMetricsEvent::Dispatched, + ); + let res = Self::v8_fn_ptr_fast(this, promise_id, fast_api_callback_options); + deno_core::_ops::dispatch_metrics_fast( &opctx, deno_core::_ops::OpMetricsEvent::Completed, ); - } else if res == 1 { + res + } + #[allow(clippy::too_many_arguments)] + extern "C" fn v8_fn_ptr_fast( + _: deno_core::v8::Local, + promise_id: i32, + fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, + ) -> () { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, + ); + let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; + let opctx = unsafe { + &*(deno_core::v8::Local::< + deno_core::v8::External, + >::cast(unsafe { fast_api_callback_options.data.data }) + .value() as *const deno_core::_ops::OpCtx) + }; + let result = { Self::call() }; + deno_core::_ops::map_async_op_fallible( + opctx, + false, + true, + promise_id, + result, + |scope, result| { Ok(deno_core::_ops::RustToV8::to_v8(result, scope)) }, + ); + } + #[inline(always)] + fn slow_function_impl( + info: *const deno_core::v8::FunctionCallbackInfo, + ) -> usize { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, + ); + let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { + &*info + }); + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; + let result = { Self::call() }; + let promise_id = deno_core::_ops::to_i32_option(&args.get(0)) + .unwrap_or_default(); + deno_core::_ops::map_async_op_fallible( + opctx, + false, + true, + promise_id, + result, + |scope, result| { Ok(deno_core::_ops::RustToV8::to_v8(result, scope)) }, + ); + return 2; + } + extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { + Self::slow_function_impl(info); + } + extern "C" fn v8_fn_ptr_metrics( + info: *const deno_core::v8::FunctionCallbackInfo, + ) { + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; deno_core::_ops::dispatch_metrics_async( &opctx, - deno_core::_ops::OpMetricsEvent::Error, + deno_core::_ops::OpMetricsEvent::Dispatched, ); + let res = Self::slow_function_impl(info); + if res == 0 { + deno_core::_ops::dispatch_metrics_async( + &opctx, + deno_core::_ops::OpMetricsEvent::Completed, + ); + } else if res == 1 { + deno_core::_ops::dispatch_metrics_async( + &opctx, + deno_core::_ops::OpMetricsEvent::Error, + ); + } + } + #[inline(always)] + pub async fn call() -> std::io::Result { + Ok(0) } } - #[inline(always)] - pub async fn call() -> std::io::Result { - Ok(0) - } + ::DECL } diff --git a/ops/op2/test_cases/async/async_jsbuffer.out b/ops/op2/test_cases/async/async_jsbuffer.out index 0fd85dc9d..1f5a6ac27 100644 --- a/ops/op2/test_cases/async/async_jsbuffer.out +++ b/ops/op2/test_cases/async/async_jsbuffer.out @@ -1,128 +1,137 @@ #[allow(non_camel_case_types)] -pub struct op_async_v8_buffer { - _unconstructable: ::std::marker::PhantomData<()>, -} -impl ::deno_core::_ops::Op for op_async_v8_buffer { - const NAME: &'static str = stringify!(op_async_v8_buffer); - const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( - ::deno_core::__op_name_fast!(op_async_v8_buffer), - true, - false, - 2usize as u8, - Self::v8_fn_ptr as _, - Self::v8_fn_ptr_metrics as _, - None, - None, - ::deno_core::OpMetadata { - ..::deno_core::OpMetadata::default() - }, - ); -} -impl op_async_v8_buffer { - pub const fn name() -> &'static str { - stringify!(op_async_v8_buffer) - } - #[deprecated(note = "Use the const op::DECL instead")] - pub const fn decl() -> deno_core::_ops::OpDecl { - ::DECL +pub const fn op_async_v8_buffer() -> ::deno_core::_ops::OpDecl { + #[allow(non_camel_case_types)] + pub struct op_async_v8_buffer { + _unconstructable: ::std::marker::PhantomData<()>, } - #[inline(always)] - fn slow_function_impl(info: *const deno_core::v8::FunctionCallbackInfo) -> usize { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, - ); - let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; - let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { - &*info - }); - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - let result = { - let arg0 = args.get(1usize as i32); - let mut arg0_temp; - arg0_temp = match unsafe { deno_core::_ops::to_v8_slice::(arg0) } { - Ok(arg0) => arg0, - Err(arg0_err) => { - let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; - let msg = deno_core::v8::String::new_from_one_byte( - &mut scope, - arg0_err.as_bytes(), - deno_core::v8::NewStringType::Normal, - ) - .unwrap(); - let exc = deno_core::v8::Exception::type_error(&mut scope, msg); - scope.throw_exception(exc); - return 1; - } - }; - let arg0 = deno_core::serde_v8::JsBuffer::from_parts(arg0_temp); - Self::call(arg0) - }; - let promise_id = deno_core::_ops::to_i32_option(&args.get(0)) - .unwrap_or_default(); - if let Some(result) = deno_core::_ops::map_async_op_infallible( - opctx, - false, + impl ::deno_core::_ops::Op for op_async_v8_buffer { + const NAME: &'static str = stringify!(op_async_v8_buffer); + const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( + ::deno_core::__op_name_fast!(op_async_v8_buffer), + true, false, - promise_id, - result, - |scope, result| { - deno_core::_ops::RustToV8Fallible::to_v8_fallible(result, scope) + 2usize as u8, + Self::v8_fn_ptr as _, + Self::v8_fn_ptr_metrics as _, + None, + None, + ::deno_core::OpMetadata { + ..::deno_core::OpMetadata::default() }, - ) { - match deno_core::_ops::RustToV8Fallible::to_v8_fallible(result, &mut scope) { - Ok(v) => rv.set(v), - Err(rv_err) => { - let msg = deno_core::v8::String::new( - &mut scope, - &format!("{}", deno_core::anyhow::Error::from(rv_err)), - ) - .unwrap(); - let exc = deno_core::v8::Exception::type_error(&mut scope, msg); - scope.throw_exception(exc); - return 1; - } - }; - return 0; - } - return 2; - } - extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { - Self::slow_function_impl(info); - } - extern "C" fn v8_fn_ptr_metrics(info: *const deno_core::v8::FunctionCallbackInfo) { - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_async( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, ); - let res = Self::slow_function_impl(info); - if res == 0 { - deno_core::_ops::dispatch_metrics_async( - &opctx, - deno_core::_ops::OpMetricsEvent::Completed, + } + impl op_async_v8_buffer { + pub const fn name() -> &'static str { + stringify!(op_async_v8_buffer) + } + #[inline(always)] + fn slow_function_impl( + info: *const deno_core::v8::FunctionCallbackInfo, + ) -> usize { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, ); - } else if res == 1 { + let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; + let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { + &*info + }); + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; + let result = { + let arg0 = args.get(1usize as i32); + let mut arg0_temp; + arg0_temp = match unsafe { deno_core::_ops::to_v8_slice::(arg0) } { + Ok(arg0) => arg0, + Err(arg0_err) => { + let mut scope = unsafe { + deno_core::v8::CallbackScope::new(&*info) + }; + let msg = deno_core::v8::String::new_from_one_byte( + &mut scope, + arg0_err.as_bytes(), + deno_core::v8::NewStringType::Normal, + ) + .unwrap(); + let exc = deno_core::v8::Exception::type_error(&mut scope, msg); + scope.throw_exception(exc); + return 1; + } + }; + let arg0 = deno_core::serde_v8::JsBuffer::from_parts(arg0_temp); + Self::call(arg0) + }; + let promise_id = deno_core::_ops::to_i32_option(&args.get(0)) + .unwrap_or_default(); + if let Some(result) = deno_core::_ops::map_async_op_infallible( + opctx, + false, + false, + promise_id, + result, + |scope, result| { + deno_core::_ops::RustToV8Fallible::to_v8_fallible(result, scope) + }, + ) { + match deno_core::_ops::RustToV8Fallible::to_v8_fallible( + result, + &mut scope, + ) { + Ok(v) => rv.set(v), + Err(rv_err) => { + let msg = deno_core::v8::String::new( + &mut scope, + &format!("{}", deno_core::anyhow::Error::from(rv_err)), + ) + .unwrap(); + let exc = deno_core::v8::Exception::type_error(&mut scope, msg); + scope.throw_exception(exc); + return 1; + } + }; + return 0; + } + return 2; + } + extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { + Self::slow_function_impl(info); + } + extern "C" fn v8_fn_ptr_metrics( + info: *const deno_core::v8::FunctionCallbackInfo, + ) { + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; deno_core::_ops::dispatch_metrics_async( &opctx, - deno_core::_ops::OpMetricsEvent::Error, + deno_core::_ops::OpMetricsEvent::Dispatched, ); + let res = Self::slow_function_impl(info); + if res == 0 { + deno_core::_ops::dispatch_metrics_async( + &opctx, + deno_core::_ops::OpMetricsEvent::Completed, + ); + } else if res == 1 { + deno_core::_ops::dispatch_metrics_async( + &opctx, + deno_core::_ops::OpMetricsEvent::Error, + ); + } + } + #[inline(always)] + pub async fn call(buf: JsBuffer) -> JsBuffer { + buf } } - #[inline(always)] - pub async fn call(buf: JsBuffer) -> JsBuffer { - buf - } + ::DECL } diff --git a/ops/op2/test_cases/async/async_lazy.out b/ops/op2/test_cases/async/async_lazy.out index f1312d91c..e45930600 100644 --- a/ops/op2/test_cases/async/async_lazy.out +++ b/ops/op2/test_cases/async/async_lazy.out @@ -1,157 +1,161 @@ #[allow(non_camel_case_types)] -pub struct op_async_lazy { - _unconstructable: ::std::marker::PhantomData<()>, -} -impl ::deno_core::_ops::Op for op_async_lazy { - const NAME: &'static str = stringify!(op_async_lazy); - const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( - ::deno_core::__op_name_fast!(op_async_lazy), - true, - false, - 1usize as u8, - Self::v8_fn_ptr as _, - Self::v8_fn_ptr_metrics as _, - Some({ - use deno_core::v8::fast_api::Type; - use deno_core::v8::fast_api::CType; - deno_core::v8::fast_api::FastFunction::new_with_bigint( - &[Type::V8Value, Type::Int32, Type::CallbackOptions], - CType::Void, - Self::v8_fn_ptr_fast as *const ::std::ffi::c_void, - ) - }), - Some({ - use deno_core::v8::fast_api::Type; - use deno_core::v8::fast_api::CType; - deno_core::v8::fast_api::FastFunction::new_with_bigint( - &[Type::V8Value, Type::Int32, Type::CallbackOptions], - CType::Void, - Self::v8_fn_ptr_fast_metrics as *const ::std::ffi::c_void, - ) - }), - ::deno_core::OpMetadata { - ..::deno_core::OpMetadata::default() - }, - ); -} -impl op_async_lazy { - pub const fn name() -> &'static str { - stringify!(op_async_lazy) - } - #[deprecated(note = "Use the const op::DECL instead")] - pub const fn decl() -> deno_core::_ops::OpDecl { - ::DECL - } - #[allow(clippy::too_many_arguments)] - extern "C" fn v8_fn_ptr_fast_metrics( - this: deno_core::v8::Local, - promise_id: i32, - fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, - ) -> () { - let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; - let opctx = unsafe { - &*(deno_core::v8::Local::< - deno_core::v8::External, - >::cast(unsafe { fast_api_callback_options.data.data }) - .value() as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_fast( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, - ); - let res = Self::v8_fn_ptr_fast(this, promise_id, fast_api_callback_options); - deno_core::_ops::dispatch_metrics_fast( - &opctx, - deno_core::_ops::OpMetricsEvent::Completed, - ); - res - } - #[allow(clippy::too_many_arguments)] - extern "C" fn v8_fn_ptr_fast( - _: deno_core::v8::Local, - promise_id: i32, - fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, - ) -> () { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, - ); - let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; - let opctx = unsafe { - &*(deno_core::v8::Local::< - deno_core::v8::External, - >::cast(unsafe { fast_api_callback_options.data.data }) - .value() as *const deno_core::_ops::OpCtx) - }; - let result = { Self::call() }; - deno_core::_ops::map_async_op_fallible( - opctx, - true, - false, - promise_id, - result, - |scope, result| { Ok(deno_core::_ops::RustToV8::to_v8(result, scope)) }, - ); +pub const fn op_async_lazy() -> ::deno_core::_ops::OpDecl { + #[allow(non_camel_case_types)] + pub struct op_async_lazy { + _unconstructable: ::std::marker::PhantomData<()>, } - #[inline(always)] - fn slow_function_impl(info: *const deno_core::v8::FunctionCallbackInfo) -> usize { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, - ); - let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { - &*info - }); - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - let result = { Self::call() }; - let promise_id = deno_core::_ops::to_i32_option(&args.get(0)) - .unwrap_or_default(); - deno_core::_ops::map_async_op_fallible( - opctx, + impl ::deno_core::_ops::Op for op_async_lazy { + const NAME: &'static str = stringify!(op_async_lazy); + const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( + ::deno_core::__op_name_fast!(op_async_lazy), true, false, - promise_id, - result, - |scope, result| { Ok(deno_core::_ops::RustToV8::to_v8(result, scope)) }, + 1usize as u8, + Self::v8_fn_ptr as _, + Self::v8_fn_ptr_metrics as _, + Some({ + use deno_core::v8::fast_api::Type; + use deno_core::v8::fast_api::CType; + deno_core::v8::fast_api::FastFunction::new_with_bigint( + &[Type::V8Value, Type::Int32, Type::CallbackOptions], + CType::Void, + Self::v8_fn_ptr_fast as *const ::std::ffi::c_void, + ) + }), + Some({ + use deno_core::v8::fast_api::Type; + use deno_core::v8::fast_api::CType; + deno_core::v8::fast_api::FastFunction::new_with_bigint( + &[Type::V8Value, Type::Int32, Type::CallbackOptions], + CType::Void, + Self::v8_fn_ptr_fast_metrics as *const ::std::ffi::c_void, + ) + }), + ::deno_core::OpMetadata { + ..::deno_core::OpMetadata::default() + }, ); - return 2; - } - extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { - Self::slow_function_impl(info); } - extern "C" fn v8_fn_ptr_metrics(info: *const deno_core::v8::FunctionCallbackInfo) { - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_async( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, - ); - let res = Self::slow_function_impl(info); - if res == 0 { - deno_core::_ops::dispatch_metrics_async( + impl op_async_lazy { + pub const fn name() -> &'static str { + stringify!(op_async_lazy) + } + #[allow(clippy::too_many_arguments)] + extern "C" fn v8_fn_ptr_fast_metrics( + this: deno_core::v8::Local, + promise_id: i32, + fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, + ) -> () { + let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; + let opctx = unsafe { + &*(deno_core::v8::Local::< + deno_core::v8::External, + >::cast(unsafe { fast_api_callback_options.data.data }) + .value() as *const deno_core::_ops::OpCtx) + }; + deno_core::_ops::dispatch_metrics_fast( + &opctx, + deno_core::_ops::OpMetricsEvent::Dispatched, + ); + let res = Self::v8_fn_ptr_fast(this, promise_id, fast_api_callback_options); + deno_core::_ops::dispatch_metrics_fast( &opctx, deno_core::_ops::OpMetricsEvent::Completed, ); - } else if res == 1 { + res + } + #[allow(clippy::too_many_arguments)] + extern "C" fn v8_fn_ptr_fast( + _: deno_core::v8::Local, + promise_id: i32, + fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, + ) -> () { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, + ); + let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; + let opctx = unsafe { + &*(deno_core::v8::Local::< + deno_core::v8::External, + >::cast(unsafe { fast_api_callback_options.data.data }) + .value() as *const deno_core::_ops::OpCtx) + }; + let result = { Self::call() }; + deno_core::_ops::map_async_op_fallible( + opctx, + true, + false, + promise_id, + result, + |scope, result| { Ok(deno_core::_ops::RustToV8::to_v8(result, scope)) }, + ); + } + #[inline(always)] + fn slow_function_impl( + info: *const deno_core::v8::FunctionCallbackInfo, + ) -> usize { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, + ); + let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { + &*info + }); + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; + let result = { Self::call() }; + let promise_id = deno_core::_ops::to_i32_option(&args.get(0)) + .unwrap_or_default(); + deno_core::_ops::map_async_op_fallible( + opctx, + true, + false, + promise_id, + result, + |scope, result| { Ok(deno_core::_ops::RustToV8::to_v8(result, scope)) }, + ); + return 2; + } + extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { + Self::slow_function_impl(info); + } + extern "C" fn v8_fn_ptr_metrics( + info: *const deno_core::v8::FunctionCallbackInfo, + ) { + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; deno_core::_ops::dispatch_metrics_async( &opctx, - deno_core::_ops::OpMetricsEvent::Error, + deno_core::_ops::OpMetricsEvent::Dispatched, ); + let res = Self::slow_function_impl(info); + if res == 0 { + deno_core::_ops::dispatch_metrics_async( + &opctx, + deno_core::_ops::OpMetricsEvent::Completed, + ); + } else if res == 1 { + deno_core::_ops::dispatch_metrics_async( + &opctx, + deno_core::_ops::OpMetricsEvent::Error, + ); + } + } + #[inline(always)] + pub async fn call() -> std::io::Result { + Ok(0) } } - #[inline(always)] - pub async fn call() -> std::io::Result { - Ok(0) - } + ::DECL } diff --git a/ops/op2/test_cases/async/async_op_metadata.out b/ops/op2/test_cases/async/async_op_metadata.out index c4bd1cad3..d15522144 100644 --- a/ops/op2/test_cases/async/async_op_metadata.out +++ b/ops/op2/test_cases/async/async_op_metadata.out @@ -1,191 +1,199 @@ #[allow(non_camel_case_types)] -struct op_blob_read_part { - _unconstructable: ::std::marker::PhantomData<()>, -} -impl ::deno_core::_ops::Op for op_blob_read_part { - const NAME: &'static str = stringify!(op_blob_read_part); - const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( - ::deno_core::__op_name_fast!(op_blob_read_part), - true, - false, - 1usize as u8, - Self::v8_fn_ptr as _, - Self::v8_fn_ptr_metrics as _, - None, - None, - ::deno_core::OpMetadata { - sanitizer_details: Some("read from a Blob or File"), - sanitizer_fix: Some("awaiting the result of a Blob or File read"), - ..::deno_core::OpMetadata::default() - }, - ); -} -impl op_blob_read_part { - pub const fn name() -> &'static str { - stringify!(op_blob_read_part) - } - #[deprecated(note = "Use the const op::DECL instead")] - pub const fn decl() -> deno_core::_ops::OpDecl { - ::DECL +const fn op_blob_read_part() -> ::deno_core::_ops::OpDecl { + #[allow(non_camel_case_types)] + struct op_blob_read_part { + _unconstructable: ::std::marker::PhantomData<()>, } - #[inline(always)] - fn slow_function_impl(info: *const deno_core::v8::FunctionCallbackInfo) -> usize { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, - ); - let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { - &*info - }); - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - let result = { Self::call() }; - let promise_id = deno_core::_ops::to_i32_option(&args.get(0)) - .unwrap_or_default(); - if let Some(result) = deno_core::_ops::map_async_op_infallible( - opctx, - false, + impl ::deno_core::_ops::Op for op_blob_read_part { + const NAME: &'static str = stringify!(op_blob_read_part); + const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( + ::deno_core::__op_name_fast!(op_blob_read_part), + true, false, - promise_id, - result, - |scope, result| { Ok(deno_core::_ops::RustToV8::to_v8(result, scope)) }, - ) { - deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv); - return 0; - } - return 2; - } - extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { - Self::slow_function_impl(info); - } - extern "C" fn v8_fn_ptr_metrics(info: *const deno_core::v8::FunctionCallbackInfo) { - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_async( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, + 1usize as u8, + Self::v8_fn_ptr as _, + Self::v8_fn_ptr_metrics as _, + None, + None, + ::deno_core::OpMetadata { + sanitizer_details: Some("read from a Blob or File"), + sanitizer_fix: Some("awaiting the result of a Blob or File read"), + ..::deno_core::OpMetadata::default() + }, ); - let res = Self::slow_function_impl(info); - if res == 0 { - deno_core::_ops::dispatch_metrics_async( - &opctx, - deno_core::_ops::OpMetricsEvent::Completed, + } + impl op_blob_read_part { + pub const fn name() -> &'static str { + stringify!(op_blob_read_part) + } + #[inline(always)] + fn slow_function_impl( + info: *const deno_core::v8::FunctionCallbackInfo, + ) -> usize { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, ); - } else if res == 1 { + let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { + &*info + }); + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; + let result = { Self::call() }; + let promise_id = deno_core::_ops::to_i32_option(&args.get(0)) + .unwrap_or_default(); + if let Some(result) = deno_core::_ops::map_async_op_infallible( + opctx, + false, + false, + promise_id, + result, + |scope, result| { Ok(deno_core::_ops::RustToV8::to_v8(result, scope)) }, + ) { + deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv); + return 0; + } + return 2; + } + extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { + Self::slow_function_impl(info); + } + extern "C" fn v8_fn_ptr_metrics( + info: *const deno_core::v8::FunctionCallbackInfo, + ) { + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; deno_core::_ops::dispatch_metrics_async( &opctx, - deno_core::_ops::OpMetricsEvent::Error, + deno_core::_ops::OpMetricsEvent::Dispatched, ); + let res = Self::slow_function_impl(info); + if res == 0 { + deno_core::_ops::dispatch_metrics_async( + &opctx, + deno_core::_ops::OpMetricsEvent::Completed, + ); + } else if res == 1 { + deno_core::_ops::dispatch_metrics_async( + &opctx, + deno_core::_ops::OpMetricsEvent::Error, + ); + } + } + #[inline(always)] + async fn call() { + return; } } - #[inline(always)] - async fn call() { - return; - } + ::DECL } #[allow(non_camel_case_types)] -struct op_broadcast_recv { - _unconstructable: ::std::marker::PhantomData<()>, -} -impl ::deno_core::_ops::Op for op_broadcast_recv { - const NAME: &'static str = stringify!(op_broadcast_recv); - const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( - ::deno_core::__op_name_fast!(op_broadcast_recv), - true, - false, - 1usize as u8, - Self::v8_fn_ptr as _, - Self::v8_fn_ptr_metrics as _, - None, - None, - ::deno_core::OpMetadata { - sanitizer_details: Some("receive a message from a BroadcastChannel"), - sanitizer_fix: Some("closing the BroadcastChannel"), - ..::deno_core::OpMetadata::default() - }, - ); -} -impl op_broadcast_recv { - pub const fn name() -> &'static str { - stringify!(op_broadcast_recv) - } - #[deprecated(note = "Use the const op::DECL instead")] - pub const fn decl() -> deno_core::_ops::OpDecl { - ::DECL +const fn op_broadcast_recv() -> ::deno_core::_ops::OpDecl { + #[allow(non_camel_case_types)] + struct op_broadcast_recv { + _unconstructable: ::std::marker::PhantomData<()>, } - #[inline(always)] - fn slow_function_impl(info: *const deno_core::v8::FunctionCallbackInfo) -> usize { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, - ); - let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { - &*info - }); - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - let result = { Self::call() }; - let promise_id = deno_core::_ops::to_i32_option(&args.get(0)) - .unwrap_or_default(); - if let Some(result) = deno_core::_ops::map_async_op_infallible( - opctx, - false, + impl ::deno_core::_ops::Op for op_broadcast_recv { + const NAME: &'static str = stringify!(op_broadcast_recv); + const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( + ::deno_core::__op_name_fast!(op_broadcast_recv), + true, false, - promise_id, - result, - |scope, result| { Ok(deno_core::_ops::RustToV8::to_v8(result, scope)) }, - ) { - deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv); - return 0; - } - return 2; - } - extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { - Self::slow_function_impl(info); - } - extern "C" fn v8_fn_ptr_metrics(info: *const deno_core::v8::FunctionCallbackInfo) { - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_async( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, + 1usize as u8, + Self::v8_fn_ptr as _, + Self::v8_fn_ptr_metrics as _, + None, + None, + ::deno_core::OpMetadata { + sanitizer_details: Some("receive a message from a BroadcastChannel"), + sanitizer_fix: Some("closing the BroadcastChannel"), + ..::deno_core::OpMetadata::default() + }, ); - let res = Self::slow_function_impl(info); - if res == 0 { - deno_core::_ops::dispatch_metrics_async( - &opctx, - deno_core::_ops::OpMetricsEvent::Completed, + } + impl op_broadcast_recv { + pub const fn name() -> &'static str { + stringify!(op_broadcast_recv) + } + #[inline(always)] + fn slow_function_impl( + info: *const deno_core::v8::FunctionCallbackInfo, + ) -> usize { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, ); - } else if res == 1 { + let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { + &*info + }); + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; + let result = { Self::call() }; + let promise_id = deno_core::_ops::to_i32_option(&args.get(0)) + .unwrap_or_default(); + if let Some(result) = deno_core::_ops::map_async_op_infallible( + opctx, + false, + false, + promise_id, + result, + |scope, result| { Ok(deno_core::_ops::RustToV8::to_v8(result, scope)) }, + ) { + deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv); + return 0; + } + return 2; + } + extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { + Self::slow_function_impl(info); + } + extern "C" fn v8_fn_ptr_metrics( + info: *const deno_core::v8::FunctionCallbackInfo, + ) { + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; deno_core::_ops::dispatch_metrics_async( &opctx, - deno_core::_ops::OpMetricsEvent::Error, + deno_core::_ops::OpMetricsEvent::Dispatched, ); + let res = Self::slow_function_impl(info); + if res == 0 { + deno_core::_ops::dispatch_metrics_async( + &opctx, + deno_core::_ops::OpMetricsEvent::Completed, + ); + } else if res == 1 { + deno_core::_ops::dispatch_metrics_async( + &opctx, + deno_core::_ops::OpMetricsEvent::Error, + ); + } + } + #[inline(always)] + async fn call() { + return; } } - #[inline(always)] - async fn call() { - return; - } + ::DECL } diff --git a/ops/op2/test_cases/async/async_opstate.out b/ops/op2/test_cases/async/async_opstate.out index 73dd417b7..ce23f2ffe 100644 --- a/ops/op2/test_cases/async/async_opstate.out +++ b/ops/op2/test_cases/async/async_opstate.out @@ -1,110 +1,118 @@ #[allow(non_camel_case_types)] -pub struct op_async_opstate { - _unconstructable: ::std::marker::PhantomData<()>, -} -impl ::deno_core::_ops::Op for op_async_opstate { - const NAME: &'static str = stringify!(op_async_opstate); - const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( - ::deno_core::__op_name_fast!(op_async_opstate), - true, - false, - 2usize as u8, - Self::v8_fn_ptr as _, - Self::v8_fn_ptr_metrics as _, - None, - None, - ::deno_core::OpMetadata { - ..::deno_core::OpMetadata::default() - }, - ); -} -impl op_async_opstate { - pub const fn name() -> &'static str { - stringify!(op_async_opstate) - } - #[deprecated(note = "Use the const op::DECL instead")] - pub const fn decl() -> deno_core::_ops::OpDecl { - ::DECL +pub const fn op_async_opstate() -> ::deno_core::_ops::OpDecl { + #[allow(non_camel_case_types)] + pub struct op_async_opstate { + _unconstructable: ::std::marker::PhantomData<()>, } - #[inline(always)] - fn slow_function_impl(info: *const deno_core::v8::FunctionCallbackInfo) -> usize { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, - ); - let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { - &*info - }); - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - let opstate = &opctx.state; - let result = { - let arg0 = opstate.clone(); - Self::call(arg0) - }; - let promise_id = deno_core::_ops::to_i32_option(&args.get(0)) - .unwrap_or_default(); - if let Some(result) = deno_core::_ops::map_async_op_fallible( - opctx, - false, + impl ::deno_core::_ops::Op for op_async_opstate { + const NAME: &'static str = stringify!(op_async_opstate); + const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( + ::deno_core::__op_name_fast!(op_async_opstate), + true, false, - promise_id, - result, - |scope, result| { Ok(deno_core::_ops::RustToV8::to_v8(result, scope)) }, - ) { - match result { - Ok(result) => deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv), - Err(err) => { - let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; - let err = err.into(); - let exception = deno_core::error::to_v8_error( - &mut scope, - opctx.get_error_class_fn, - &err, - ); - scope.throw_exception(exception); - return 1; - } - }; - return 0; - } - return 2; - } - extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { - Self::slow_function_impl(info); - } - extern "C" fn v8_fn_ptr_metrics(info: *const deno_core::v8::FunctionCallbackInfo) { - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_async( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, + 2usize as u8, + Self::v8_fn_ptr as _, + Self::v8_fn_ptr_metrics as _, + None, + None, + ::deno_core::OpMetadata { + ..::deno_core::OpMetadata::default() + }, ); - let res = Self::slow_function_impl(info); - if res == 0 { - deno_core::_ops::dispatch_metrics_async( - &opctx, - deno_core::_ops::OpMetricsEvent::Completed, + } + impl op_async_opstate { + pub const fn name() -> &'static str { + stringify!(op_async_opstate) + } + #[inline(always)] + fn slow_function_impl( + info: *const deno_core::v8::FunctionCallbackInfo, + ) -> usize { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, ); - } else if res == 1 { + let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { + &*info + }); + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; + let opstate = &opctx.state; + let result = { + let arg0 = opstate.clone(); + Self::call(arg0) + }; + let promise_id = deno_core::_ops::to_i32_option(&args.get(0)) + .unwrap_or_default(); + if let Some(result) = deno_core::_ops::map_async_op_fallible( + opctx, + false, + false, + promise_id, + result, + |scope, result| { Ok(deno_core::_ops::RustToV8::to_v8(result, scope)) }, + ) { + match result { + Ok(result) => { + deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv) + } + Err(err) => { + let mut scope = unsafe { + deno_core::v8::CallbackScope::new(&*info) + }; + let err = err.into(); + let exception = deno_core::error::to_v8_error( + &mut scope, + opctx.get_error_class_fn, + &err, + ); + scope.throw_exception(exception); + return 1; + } + }; + return 0; + } + return 2; + } + extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { + Self::slow_function_impl(info); + } + extern "C" fn v8_fn_ptr_metrics( + info: *const deno_core::v8::FunctionCallbackInfo, + ) { + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; deno_core::_ops::dispatch_metrics_async( &opctx, - deno_core::_ops::OpMetricsEvent::Error, + deno_core::_ops::OpMetricsEvent::Dispatched, ); + let res = Self::slow_function_impl(info); + if res == 0 { + deno_core::_ops::dispatch_metrics_async( + &opctx, + deno_core::_ops::OpMetricsEvent::Completed, + ); + } else if res == 1 { + deno_core::_ops::dispatch_metrics_async( + &opctx, + deno_core::_ops::OpMetricsEvent::Error, + ); + } + } + #[inline(always)] + pub async fn call(state: Rc>) -> std::io::Result { + Ok(*state.borrow().borrow::()) } } - #[inline(always)] - pub async fn call(state: Rc>) -> std::io::Result { - Ok(*state.borrow().borrow::()) - } + ::DECL } diff --git a/ops/op2/test_cases/async/async_result.out b/ops/op2/test_cases/async/async_result.out index 547e720df..68fb97f47 100644 --- a/ops/op2/test_cases/async/async_result.out +++ b/ops/op2/test_cases/async/async_result.out @@ -1,106 +1,114 @@ #[allow(non_camel_case_types)] -pub struct op_async { - _unconstructable: ::std::marker::PhantomData<()>, -} -impl ::deno_core::_ops::Op for op_async { - const NAME: &'static str = stringify!(op_async); - const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( - ::deno_core::__op_name_fast!(op_async), - true, - false, - 1usize as u8, - Self::v8_fn_ptr as _, - Self::v8_fn_ptr_metrics as _, - None, - None, - ::deno_core::OpMetadata { - ..::deno_core::OpMetadata::default() - }, - ); -} -impl op_async { - pub const fn name() -> &'static str { - stringify!(op_async) - } - #[deprecated(note = "Use the const op::DECL instead")] - pub const fn decl() -> deno_core::_ops::OpDecl { - ::DECL +pub const fn op_async() -> ::deno_core::_ops::OpDecl { + #[allow(non_camel_case_types)] + pub struct op_async { + _unconstructable: ::std::marker::PhantomData<()>, } - #[inline(always)] - fn slow_function_impl(info: *const deno_core::v8::FunctionCallbackInfo) -> usize { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, - ); - let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { - &*info - }); - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - let result = { Self::call() }; - let promise_id = deno_core::_ops::to_i32_option(&args.get(0)) - .unwrap_or_default(); - if let Some(result) = deno_core::_ops::map_async_op_fallible( - opctx, - false, + impl ::deno_core::_ops::Op for op_async { + const NAME: &'static str = stringify!(op_async); + const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( + ::deno_core::__op_name_fast!(op_async), + true, false, - promise_id, - result, - |scope, result| { Ok(deno_core::_ops::RustToV8::to_v8(result, scope)) }, - ) { - match result { - Ok(result) => deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv), - Err(err) => { - let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; - let err = err.into(); - let exception = deno_core::error::to_v8_error( - &mut scope, - opctx.get_error_class_fn, - &err, - ); - scope.throw_exception(exception); - return 1; - } - }; - return 0; - } - return 2; - } - extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { - Self::slow_function_impl(info); - } - extern "C" fn v8_fn_ptr_metrics(info: *const deno_core::v8::FunctionCallbackInfo) { - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_async( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, + 1usize as u8, + Self::v8_fn_ptr as _, + Self::v8_fn_ptr_metrics as _, + None, + None, + ::deno_core::OpMetadata { + ..::deno_core::OpMetadata::default() + }, ); - let res = Self::slow_function_impl(info); - if res == 0 { - deno_core::_ops::dispatch_metrics_async( - &opctx, - deno_core::_ops::OpMetricsEvent::Completed, + } + impl op_async { + pub const fn name() -> &'static str { + stringify!(op_async) + } + #[inline(always)] + fn slow_function_impl( + info: *const deno_core::v8::FunctionCallbackInfo, + ) -> usize { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, ); - } else if res == 1 { + let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { + &*info + }); + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; + let result = { Self::call() }; + let promise_id = deno_core::_ops::to_i32_option(&args.get(0)) + .unwrap_or_default(); + if let Some(result) = deno_core::_ops::map_async_op_fallible( + opctx, + false, + false, + promise_id, + result, + |scope, result| { Ok(deno_core::_ops::RustToV8::to_v8(result, scope)) }, + ) { + match result { + Ok(result) => { + deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv) + } + Err(err) => { + let mut scope = unsafe { + deno_core::v8::CallbackScope::new(&*info) + }; + let err = err.into(); + let exception = deno_core::error::to_v8_error( + &mut scope, + opctx.get_error_class_fn, + &err, + ); + scope.throw_exception(exception); + return 1; + } + }; + return 0; + } + return 2; + } + extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { + Self::slow_function_impl(info); + } + extern "C" fn v8_fn_ptr_metrics( + info: *const deno_core::v8::FunctionCallbackInfo, + ) { + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; deno_core::_ops::dispatch_metrics_async( &opctx, - deno_core::_ops::OpMetricsEvent::Error, + deno_core::_ops::OpMetricsEvent::Dispatched, ); + let res = Self::slow_function_impl(info); + if res == 0 { + deno_core::_ops::dispatch_metrics_async( + &opctx, + deno_core::_ops::OpMetricsEvent::Completed, + ); + } else if res == 1 { + deno_core::_ops::dispatch_metrics_async( + &opctx, + deno_core::_ops::OpMetricsEvent::Error, + ); + } + } + #[inline(always)] + pub async fn call() -> std::io::Result { + Ok(0) } } - #[inline(always)] - pub async fn call() -> std::io::Result { - Ok(0) - } + ::DECL } diff --git a/ops/op2/test_cases/async/async_result_impl.out b/ops/op2/test_cases/async/async_result_impl.out index f1d9b02fa..b6bc5fd86 100644 --- a/ops/op2/test_cases/async/async_result_impl.out +++ b/ops/op2/test_cases/async/async_result_impl.out @@ -1,90 +1,66 @@ #[allow(non_camel_case_types)] -pub struct op_async_result_impl { - _unconstructable: ::std::marker::PhantomData<()>, -} -impl ::deno_core::_ops::Op for op_async_result_impl { - const NAME: &'static str = stringify!(op_async_result_impl); - const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( - ::deno_core::__op_name_fast!(op_async_result_impl), - true, - false, - 2usize as u8, - Self::v8_fn_ptr as _, - Self::v8_fn_ptr_metrics as _, - None, - None, - ::deno_core::OpMetadata { - ..::deno_core::OpMetadata::default() - }, - ); -} -impl op_async_result_impl { - pub const fn name() -> &'static str { - stringify!(op_async_result_impl) +pub const fn op_async_result_impl() -> ::deno_core::_ops::OpDecl { + #[allow(non_camel_case_types)] + pub struct op_async_result_impl { + _unconstructable: ::std::marker::PhantomData<()>, } - #[deprecated(note = "Use the const op::DECL instead")] - pub const fn decl() -> deno_core::_ops::OpDecl { - ::DECL - } - #[inline(always)] - fn slow_function_impl(info: *const deno_core::v8::FunctionCallbackInfo) -> usize { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, + impl ::deno_core::_ops::Op for op_async_result_impl { + const NAME: &'static str = stringify!(op_async_result_impl); + const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( + ::deno_core::__op_name_fast!(op_async_result_impl), + true, + false, + 2usize as u8, + Self::v8_fn_ptr as _, + Self::v8_fn_ptr_metrics as _, + None, + None, + ::deno_core::OpMetadata { + ..::deno_core::OpMetadata::default() + }, ); - let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { - &*info - }); - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - let result = { - let arg0 = args.get(1usize as i32); - let Some(arg0) = deno_core::_ops::to_i32_option(&arg0) else { - let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; - let msg = deno_core::v8::String::new_from_one_byte( - &mut scope, - "expected i32".as_bytes(), - deno_core::v8::NewStringType::Normal, - ) - .unwrap(); - let exc = deno_core::v8::Exception::type_error(&mut scope, msg); - scope.throw_exception(exc); - return 1; + } + impl op_async_result_impl { + pub const fn name() -> &'static str { + stringify!(op_async_result_impl) + } + #[inline(always)] + fn slow_function_impl( + info: *const deno_core::v8::FunctionCallbackInfo, + ) -> usize { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, + ); + let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { + &*info + }); + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) }; - let arg0 = arg0 as _; - Self::call(arg0) - }; - let result = match result { - Ok(result) => result, - Err(err) => { - let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; - let err = err.into(); - let exception = deno_core::error::to_v8_error( - &mut scope, - opctx.get_error_class_fn, - &err, - ); - scope.throw_exception(exception); - return 1; - } - }; - let promise_id = deno_core::_ops::to_i32_option(&args.get(0)) - .unwrap_or_default(); - if let Some(result) = deno_core::_ops::map_async_op_fallible( - opctx, - false, - false, - promise_id, - result, - |scope, result| { Ok(deno_core::_ops::RustToV8::to_v8(result, scope)) }, - ) { - match result { - Ok(result) => deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv), + let result = { + let arg0 = args.get(1usize as i32); + let Some(arg0) = deno_core::_ops::to_i32_option(&arg0) else { + let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; + let msg = deno_core::v8::String::new_from_one_byte( + &mut scope, + "expected i32".as_bytes(), + deno_core::v8::NewStringType::Normal, + ) + .unwrap(); + let exc = deno_core::v8::Exception::type_error(&mut scope, msg); + scope.throw_exception(exc); + return 1; + }; + let arg0 = arg0 as _; + Self::call(arg0) + }; + let result = match result { + Ok(result) => result, Err(err) => { let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; let err = err.into(); @@ -97,40 +73,74 @@ impl op_async_result_impl { return 1; } }; - return 0; + let promise_id = deno_core::_ops::to_i32_option(&args.get(0)) + .unwrap_or_default(); + if let Some(result) = deno_core::_ops::map_async_op_fallible( + opctx, + false, + false, + promise_id, + result, + |scope, result| { Ok(deno_core::_ops::RustToV8::to_v8(result, scope)) }, + ) { + match result { + Ok(result) => { + deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv) + } + Err(err) => { + let mut scope = unsafe { + deno_core::v8::CallbackScope::new(&*info) + }; + let err = err.into(); + let exception = deno_core::error::to_v8_error( + &mut scope, + opctx.get_error_class_fn, + &err, + ); + scope.throw_exception(exception); + return 1; + } + }; + return 0; + } + return 2; } - return 2; - } - extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { - Self::slow_function_impl(info); - } - extern "C" fn v8_fn_ptr_metrics(info: *const deno_core::v8::FunctionCallbackInfo) { - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_async( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, - ); - let res = Self::slow_function_impl(info); - if res == 0 { - deno_core::_ops::dispatch_metrics_async( - &opctx, - deno_core::_ops::OpMetricsEvent::Completed, - ); - } else if res == 1 { + extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { + Self::slow_function_impl(info); + } + extern "C" fn v8_fn_ptr_metrics( + info: *const deno_core::v8::FunctionCallbackInfo, + ) { + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; deno_core::_ops::dispatch_metrics_async( &opctx, - deno_core::_ops::OpMetricsEvent::Error, + deno_core::_ops::OpMetricsEvent::Dispatched, ); + let res = Self::slow_function_impl(info); + if res == 0 { + deno_core::_ops::dispatch_metrics_async( + &opctx, + deno_core::_ops::OpMetricsEvent::Completed, + ); + } else if res == 1 { + deno_core::_ops::dispatch_metrics_async( + &opctx, + deno_core::_ops::OpMetricsEvent::Error, + ); + } + } + #[inline(always)] + pub fn call( + x: i32, + ) -> Result>, AnyError> { + Ok(async move { Ok(x) }) } } - #[inline(always)] - pub fn call(x: i32) -> Result>, AnyError> { - Ok(async move { Ok(x) }) - } + ::DECL } diff --git a/ops/op2/test_cases/async/async_result_smi.out b/ops/op2/test_cases/async/async_result_smi.out index 7f136f4ec..dd237e67e 100644 --- a/ops/op2/test_cases/async/async_result_smi.out +++ b/ops/op2/test_cases/async/async_result_smi.out @@ -1,140 +1,146 @@ #[allow(non_camel_case_types)] -pub struct op_async { - _unconstructable: ::std::marker::PhantomData<()>, -} -impl ::deno_core::_ops::Op for op_async { - const NAME: &'static str = stringify!(op_async); - const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( - ::deno_core::__op_name_fast!(op_async), - true, - false, - 2usize as u8, - Self::v8_fn_ptr as _, - Self::v8_fn_ptr_metrics as _, - None, - None, - ::deno_core::OpMetadata { - ..::deno_core::OpMetadata::default() - }, - ); -} -impl op_async { - pub const fn name() -> &'static str { - stringify!(op_async) +pub const fn op_async() -> ::deno_core::_ops::OpDecl { + #[allow(non_camel_case_types)] + pub struct op_async { + _unconstructable: ::std::marker::PhantomData<()>, } - #[deprecated(note = "Use the const op::DECL instead")] - pub const fn decl() -> deno_core::_ops::OpDecl { - ::DECL - } - #[inline(always)] - fn slow_function_impl(info: *const deno_core::v8::FunctionCallbackInfo) -> usize { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, - ); - let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { - &*info - }); - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - let result = { - let arg0 = args.get(1usize as i32); - let Some(arg0) = deno_core::_ops::to_i32_option(&arg0) else { - let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; - let msg = deno_core::v8::String::new_from_one_byte( - &mut scope, - "expected i32".as_bytes(), - deno_core::v8::NewStringType::Normal, - ) - .unwrap(); - let exc = deno_core::v8::Exception::type_error(&mut scope, msg); - scope.throw_exception(exc); - return 1; - }; - let arg0 = arg0 as _; - Self::call(arg0) - }; - let promise_id = deno_core::_ops::to_i32_option(&args.get(0)) - .unwrap_or_default(); - if let Some(result) = deno_core::_ops::map_async_op_fallible( - opctx, - false, + impl ::deno_core::_ops::Op for op_async { + const NAME: &'static str = stringify!(op_async); + const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( + ::deno_core::__op_name_fast!(op_async), + true, false, - promise_id, - result, - |scope, result| { - Ok( - deno_core::_ops::RustToV8::to_v8( - deno_core::_ops::RustToV8Marker::< - deno_core::_ops::SmiMarker, - _, - >::from(result), - scope, - ), - ) + 2usize as u8, + Self::v8_fn_ptr as _, + Self::v8_fn_ptr_metrics as _, + None, + None, + ::deno_core::OpMetadata { + ..::deno_core::OpMetadata::default() }, - ) { - match result { - Ok(result) => { - deno_core::_ops::RustToV8RetVal::to_v8_rv( - deno_core::_ops::RustToV8Marker::< - deno_core::_ops::SmiMarker, - _, - >::from(result), - &mut rv, - ) - } - Err(err) => { + ); + } + impl op_async { + pub const fn name() -> &'static str { + stringify!(op_async) + } + #[inline(always)] + fn slow_function_impl( + info: *const deno_core::v8::FunctionCallbackInfo, + ) -> usize { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, + ); + let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { + &*info + }); + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; + let result = { + let arg0 = args.get(1usize as i32); + let Some(arg0) = deno_core::_ops::to_i32_option(&arg0) else { let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; - let err = err.into(); - let exception = deno_core::error::to_v8_error( - &mut scope, - opctx.get_error_class_fn, - &err, - ); - scope.throw_exception(exception); + let msg = deno_core::v8::String::new_from_one_byte( + &mut scope, + "expected i32".as_bytes(), + deno_core::v8::NewStringType::Normal, + ) + .unwrap(); + let exc = deno_core::v8::Exception::type_error(&mut scope, msg); + scope.throw_exception(exc); return 1; - } + }; + let arg0 = arg0 as _; + Self::call(arg0) }; - return 0; + let promise_id = deno_core::_ops::to_i32_option(&args.get(0)) + .unwrap_or_default(); + if let Some(result) = deno_core::_ops::map_async_op_fallible( + opctx, + false, + false, + promise_id, + result, + |scope, result| { + Ok( + deno_core::_ops::RustToV8::to_v8( + deno_core::_ops::RustToV8Marker::< + deno_core::_ops::SmiMarker, + _, + >::from(result), + scope, + ), + ) + }, + ) { + match result { + Ok(result) => { + deno_core::_ops::RustToV8RetVal::to_v8_rv( + deno_core::_ops::RustToV8Marker::< + deno_core::_ops::SmiMarker, + _, + >::from(result), + &mut rv, + ) + } + Err(err) => { + let mut scope = unsafe { + deno_core::v8::CallbackScope::new(&*info) + }; + let err = err.into(); + let exception = deno_core::error::to_v8_error( + &mut scope, + opctx.get_error_class_fn, + &err, + ); + scope.throw_exception(exception); + return 1; + } + }; + return 0; + } + return 2; } - return 2; - } - extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { - Self::slow_function_impl(info); - } - extern "C" fn v8_fn_ptr_metrics(info: *const deno_core::v8::FunctionCallbackInfo) { - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_async( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, - ); - let res = Self::slow_function_impl(info); - if res == 0 { - deno_core::_ops::dispatch_metrics_async( - &opctx, - deno_core::_ops::OpMetricsEvent::Completed, - ); - } else if res == 1 { + extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { + Self::slow_function_impl(info); + } + extern "C" fn v8_fn_ptr_metrics( + info: *const deno_core::v8::FunctionCallbackInfo, + ) { + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; deno_core::_ops::dispatch_metrics_async( &opctx, - deno_core::_ops::OpMetricsEvent::Error, + deno_core::_ops::OpMetricsEvent::Dispatched, ); + let res = Self::slow_function_impl(info); + if res == 0 { + deno_core::_ops::dispatch_metrics_async( + &opctx, + deno_core::_ops::OpMetricsEvent::Completed, + ); + } else if res == 1 { + deno_core::_ops::dispatch_metrics_async( + &opctx, + deno_core::_ops::OpMetricsEvent::Error, + ); + } + } + #[inline(always)] + pub async fn call(rid: ResourceId) -> std::io::Result { + Ok(rid as _) } } - #[inline(always)] - pub async fn call(rid: ResourceId) -> std::io::Result { - Ok(rid as _) - } + ::DECL } diff --git a/ops/op2/test_cases/async/async_v8_global.out b/ops/op2/test_cases/async/async_v8_global.out index b66b37d57..f35b4a5fa 100644 --- a/ops/op2/test_cases/async/async_v8_global.out +++ b/ops/op2/test_cases/async/async_v8_global.out @@ -1,110 +1,114 @@ #[allow(non_camel_case_types)] -pub struct op_async_v8_global { - _unconstructable: ::std::marker::PhantomData<()>, -} -impl ::deno_core::_ops::Op for op_async_v8_global { - const NAME: &'static str = stringify!(op_async_v8_global); - const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( - ::deno_core::__op_name_fast!(op_async_v8_global), - true, - false, - 2usize as u8, - Self::v8_fn_ptr as _, - Self::v8_fn_ptr_metrics as _, - None, - None, - ::deno_core::OpMetadata { - ..::deno_core::OpMetadata::default() - }, - ); -} -impl op_async_v8_global { - pub const fn name() -> &'static str { - stringify!(op_async_v8_global) - } - #[deprecated(note = "Use the const op::DECL instead")] - pub const fn decl() -> deno_core::_ops::OpDecl { - ::DECL +pub const fn op_async_v8_global() -> ::deno_core::_ops::OpDecl { + #[allow(non_camel_case_types)] + pub struct op_async_v8_global { + _unconstructable: ::std::marker::PhantomData<()>, } - #[inline(always)] - fn slow_function_impl(info: *const deno_core::v8::FunctionCallbackInfo) -> usize { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, - ); - let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; - let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { - &*info - }); - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - let result = { - let arg0 = args.get(1usize as i32); - let Ok(mut arg0) = deno_core::_ops::v8_try_convert::< - deno_core::v8::String, - >(arg0) else { - let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; - let msg = deno_core::v8::String::new_from_one_byte( - &mut scope, - "expected String".as_bytes(), - deno_core::v8::NewStringType::Normal, - ) - .unwrap(); - let exc = deno_core::v8::Exception::type_error(&mut scope, msg); - scope.throw_exception(exc); - return 1; - }; - let arg0 = deno_core::v8::Global::new(&mut scope, arg0); - Self::call(arg0) - }; - let promise_id = deno_core::_ops::to_i32_option(&args.get(0)) - .unwrap_or_default(); - if let Some(result) = deno_core::_ops::map_async_op_infallible( - opctx, + impl ::deno_core::_ops::Op for op_async_v8_global { + const NAME: &'static str = stringify!(op_async_v8_global); + const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( + ::deno_core::__op_name_fast!(op_async_v8_global), + true, false, - false, - promise_id, - result, - |scope, result| { Ok(deno_core::_ops::RustToV8::to_v8(result, scope)) }, - ) { - deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv); - return 0; - } - return 2; - } - extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { - Self::slow_function_impl(info); - } - extern "C" fn v8_fn_ptr_metrics(info: *const deno_core::v8::FunctionCallbackInfo) { - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_async( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, + 2usize as u8, + Self::v8_fn_ptr as _, + Self::v8_fn_ptr_metrics as _, + None, + None, + ::deno_core::OpMetadata { + ..::deno_core::OpMetadata::default() + }, ); - let res = Self::slow_function_impl(info); - if res == 0 { - deno_core::_ops::dispatch_metrics_async( - &opctx, - deno_core::_ops::OpMetricsEvent::Completed, + } + impl op_async_v8_global { + pub const fn name() -> &'static str { + stringify!(op_async_v8_global) + } + #[inline(always)] + fn slow_function_impl( + info: *const deno_core::v8::FunctionCallbackInfo, + ) -> usize { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, ); - } else if res == 1 { + let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; + let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { + &*info + }); + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; + let result = { + let arg0 = args.get(1usize as i32); + let Ok(mut arg0) = deno_core::_ops::v8_try_convert::< + deno_core::v8::String, + >(arg0) else { + let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; + let msg = deno_core::v8::String::new_from_one_byte( + &mut scope, + "expected String".as_bytes(), + deno_core::v8::NewStringType::Normal, + ) + .unwrap(); + let exc = deno_core::v8::Exception::type_error(&mut scope, msg); + scope.throw_exception(exc); + return 1; + }; + let arg0 = deno_core::v8::Global::new(&mut scope, arg0); + Self::call(arg0) + }; + let promise_id = deno_core::_ops::to_i32_option(&args.get(0)) + .unwrap_or_default(); + if let Some(result) = deno_core::_ops::map_async_op_infallible( + opctx, + false, + false, + promise_id, + result, + |scope, result| { Ok(deno_core::_ops::RustToV8::to_v8(result, scope)) }, + ) { + deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv); + return 0; + } + return 2; + } + extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { + Self::slow_function_impl(info); + } + extern "C" fn v8_fn_ptr_metrics( + info: *const deno_core::v8::FunctionCallbackInfo, + ) { + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; deno_core::_ops::dispatch_metrics_async( &opctx, - deno_core::_ops::OpMetricsEvent::Error, + deno_core::_ops::OpMetricsEvent::Dispatched, ); + let res = Self::slow_function_impl(info); + if res == 0 { + deno_core::_ops::dispatch_metrics_async( + &opctx, + deno_core::_ops::OpMetricsEvent::Completed, + ); + } else if res == 1 { + deno_core::_ops::dispatch_metrics_async( + &opctx, + deno_core::_ops::OpMetricsEvent::Error, + ); + } } + #[inline(always)] + pub async fn call(_s: v8::Global) {} } - #[inline(always)] - pub async fn call(_s: v8::Global) {} + ::DECL } diff --git a/ops/op2/test_cases/async/async_void.out b/ops/op2/test_cases/async/async_void.out index 68133421b..9454d7a9f 100644 --- a/ops/op2/test_cases/async/async_void.out +++ b/ops/op2/test_cases/async/async_void.out @@ -1,91 +1,95 @@ #[allow(non_camel_case_types)] -pub struct op_async { - _unconstructable: ::std::marker::PhantomData<()>, -} -impl ::deno_core::_ops::Op for op_async { - const NAME: &'static str = stringify!(op_async); - const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( - ::deno_core::__op_name_fast!(op_async), - true, - false, - 1usize as u8, - Self::v8_fn_ptr as _, - Self::v8_fn_ptr_metrics as _, - None, - None, - ::deno_core::OpMetadata { - ..::deno_core::OpMetadata::default() - }, - ); -} -impl op_async { - pub const fn name() -> &'static str { - stringify!(op_async) +pub const fn op_async() -> ::deno_core::_ops::OpDecl { + #[allow(non_camel_case_types)] + pub struct op_async { + _unconstructable: ::std::marker::PhantomData<()>, } - #[deprecated(note = "Use the const op::DECL instead")] - pub const fn decl() -> deno_core::_ops::OpDecl { - ::DECL - } - #[inline(always)] - fn slow_function_impl(info: *const deno_core::v8::FunctionCallbackInfo) -> usize { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, - ); - let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { - &*info - }); - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - let result = { Self::call() }; - let promise_id = deno_core::_ops::to_i32_option(&args.get(0)) - .unwrap_or_default(); - if let Some(result) = deno_core::_ops::map_async_op_infallible( - opctx, + impl ::deno_core::_ops::Op for op_async { + const NAME: &'static str = stringify!(op_async); + const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( + ::deno_core::__op_name_fast!(op_async), + true, false, - false, - promise_id, - result, - |scope, result| { Ok(deno_core::_ops::RustToV8::to_v8(result, scope)) }, - ) { - deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv); - return 0; - } - return 2; - } - extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { - Self::slow_function_impl(info); - } - extern "C" fn v8_fn_ptr_metrics(info: *const deno_core::v8::FunctionCallbackInfo) { - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_async( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, + 1usize as u8, + Self::v8_fn_ptr as _, + Self::v8_fn_ptr_metrics as _, + None, + None, + ::deno_core::OpMetadata { + ..::deno_core::OpMetadata::default() + }, ); - let res = Self::slow_function_impl(info); - if res == 0 { - deno_core::_ops::dispatch_metrics_async( - &opctx, - deno_core::_ops::OpMetricsEvent::Completed, + } + impl op_async { + pub const fn name() -> &'static str { + stringify!(op_async) + } + #[inline(always)] + fn slow_function_impl( + info: *const deno_core::v8::FunctionCallbackInfo, + ) -> usize { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, ); - } else if res == 1 { + let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { + &*info + }); + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; + let result = { Self::call() }; + let promise_id = deno_core::_ops::to_i32_option(&args.get(0)) + .unwrap_or_default(); + if let Some(result) = deno_core::_ops::map_async_op_infallible( + opctx, + false, + false, + promise_id, + result, + |scope, result| { Ok(deno_core::_ops::RustToV8::to_v8(result, scope)) }, + ) { + deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv); + return 0; + } + return 2; + } + extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { + Self::slow_function_impl(info); + } + extern "C" fn v8_fn_ptr_metrics( + info: *const deno_core::v8::FunctionCallbackInfo, + ) { + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; deno_core::_ops::dispatch_metrics_async( &opctx, - deno_core::_ops::OpMetricsEvent::Error, + deno_core::_ops::OpMetricsEvent::Dispatched, ); + let res = Self::slow_function_impl(info); + if res == 0 { + deno_core::_ops::dispatch_metrics_async( + &opctx, + deno_core::_ops::OpMetricsEvent::Completed, + ); + } else if res == 1 { + deno_core::_ops::dispatch_metrics_async( + &opctx, + deno_core::_ops::OpMetricsEvent::Error, + ); + } } + #[inline(always)] + pub async fn call() {} } - #[inline(always)] - pub async fn call() {} + ::DECL } diff --git a/ops/op2/test_cases/sync/add.out b/ops/op2/test_cases/sync/add.out index 3bba11d25..6d2096417 100644 --- a/ops/op2/test_cases/sync/add.out +++ b/ops/op2/test_cases/sync/add.out @@ -1,165 +1,169 @@ #[allow(non_camel_case_types)] -struct op_add { - _unconstructable: ::std::marker::PhantomData<()>, -} -impl ::deno_core::_ops::Op for op_add { - const NAME: &'static str = stringify!(op_add); - const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( - ::deno_core::__op_name_fast!(op_add), - false, - false, - 2usize as u8, - Self::v8_fn_ptr as _, - Self::v8_fn_ptr_metrics as _, - Some({ - use deno_core::v8::fast_api::Type; - use deno_core::v8::fast_api::CType; - deno_core::v8::fast_api::FastFunction::new_with_bigint( - &[Type::V8Value, Type::Uint32, Type::Uint32], - CType::Uint32, - Self::v8_fn_ptr_fast as *const ::std::ffi::c_void, - ) - }), - Some({ - use deno_core::v8::fast_api::Type; - use deno_core::v8::fast_api::CType; - deno_core::v8::fast_api::FastFunction::new_with_bigint( - &[Type::V8Value, Type::Uint32, Type::Uint32, Type::CallbackOptions], - CType::Uint32, - Self::v8_fn_ptr_fast_metrics as *const ::std::ffi::c_void, - ) - }), - ::deno_core::OpMetadata { - ..::deno_core::OpMetadata::default() - }, - ); -} -impl op_add { - pub const fn name() -> &'static str { - stringify!(op_add) +const fn op_add() -> ::deno_core::_ops::OpDecl { + #[allow(non_camel_case_types)] + struct op_add { + _unconstructable: ::std::marker::PhantomData<()>, } - #[deprecated(note = "Use the const op::DECL instead")] - pub const fn decl() -> deno_core::_ops::OpDecl { - ::DECL - } - #[allow(clippy::too_many_arguments)] - extern "C" fn v8_fn_ptr_fast_metrics( - this: deno_core::v8::Local, - arg0: u32, - arg1: u32, - fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, - ) -> u32 { - let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; - let opctx = unsafe { - &*(deno_core::v8::Local::< - deno_core::v8::External, - >::cast(unsafe { fast_api_callback_options.data.data }) - .value() as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_fast( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, - ); - let res = Self::v8_fn_ptr_fast(this, arg0, arg1); - deno_core::_ops::dispatch_metrics_fast( - &opctx, - deno_core::_ops::OpMetricsEvent::Completed, + impl ::deno_core::_ops::Op for op_add { + const NAME: &'static str = stringify!(op_add); + const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( + ::deno_core::__op_name_fast!(op_add), + false, + false, + 2usize as u8, + Self::v8_fn_ptr as _, + Self::v8_fn_ptr_metrics as _, + Some({ + use deno_core::v8::fast_api::Type; + use deno_core::v8::fast_api::CType; + deno_core::v8::fast_api::FastFunction::new_with_bigint( + &[Type::V8Value, Type::Uint32, Type::Uint32], + CType::Uint32, + Self::v8_fn_ptr_fast as *const ::std::ffi::c_void, + ) + }), + Some({ + use deno_core::v8::fast_api::Type; + use deno_core::v8::fast_api::CType; + deno_core::v8::fast_api::FastFunction::new_with_bigint( + &[Type::V8Value, Type::Uint32, Type::Uint32, Type::CallbackOptions], + CType::Uint32, + Self::v8_fn_ptr_fast_metrics as *const ::std::ffi::c_void, + ) + }), + ::deno_core::OpMetadata { + ..::deno_core::OpMetadata::default() + }, ); - res } - #[allow(clippy::too_many_arguments)] - extern "C" fn v8_fn_ptr_fast( - _: deno_core::v8::Local, - arg0: u32, - arg1: u32, - ) -> u32 { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, - ); - let result = { - let arg0 = arg0 as _; - let arg1 = arg1 as _; - Self::call(arg0, arg1) - }; - result as _ - } - #[inline(always)] - fn slow_function_impl(info: *const deno_core::v8::FunctionCallbackInfo) -> usize { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, - ); - let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { - &*info - }); - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let result = { - let arg0 = args.get(0usize as i32); - let Some(arg0) = deno_core::_ops::to_u32_option(&arg0) else { - let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; - let msg = deno_core::v8::String::new_from_one_byte( - &mut scope, - "expected u32".as_bytes(), - deno_core::v8::NewStringType::Normal, - ) - .unwrap(); - let exc = deno_core::v8::Exception::type_error(&mut scope, msg); - scope.throw_exception(exc); - return 1; - }; - let arg0 = arg0 as _; - let arg1 = args.get(1usize as i32); - let Some(arg1) = deno_core::_ops::to_u32_option(&arg1) else { - let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; - let msg = deno_core::v8::String::new_from_one_byte( - &mut scope, - "expected u32".as_bytes(), - deno_core::v8::NewStringType::Normal, - ) - .unwrap(); - let exc = deno_core::v8::Exception::type_error(&mut scope, msg); - scope.throw_exception(exc); - return 1; + impl op_add { + pub const fn name() -> &'static str { + stringify!(op_add) + } + #[allow(clippy::too_many_arguments)] + extern "C" fn v8_fn_ptr_fast_metrics( + this: deno_core::v8::Local, + arg0: u32, + arg1: u32, + fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, + ) -> u32 { + let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; + let opctx = unsafe { + &*(deno_core::v8::Local::< + deno_core::v8::External, + >::cast(unsafe { fast_api_callback_options.data.data }) + .value() as *const deno_core::_ops::OpCtx) }; - let arg1 = arg1 as _; - Self::call(arg0, arg1) - }; - deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv); - return 0; - } - extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { - Self::slow_function_impl(info); - } - extern "C" fn v8_fn_ptr_metrics(info: *const deno_core::v8::FunctionCallbackInfo) { - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_slow( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, - ); - let res = Self::slow_function_impl(info); - if res == 0 { - deno_core::_ops::dispatch_metrics_slow( + deno_core::_ops::dispatch_metrics_fast( + &opctx, + deno_core::_ops::OpMetricsEvent::Dispatched, + ); + let res = Self::v8_fn_ptr_fast(this, arg0, arg1); + deno_core::_ops::dispatch_metrics_fast( &opctx, deno_core::_ops::OpMetricsEvent::Completed, ); - } else { + res + } + #[allow(clippy::too_many_arguments)] + extern "C" fn v8_fn_ptr_fast( + _: deno_core::v8::Local, + arg0: u32, + arg1: u32, + ) -> u32 { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, + ); + let result = { + let arg0 = arg0 as _; + let arg1 = arg1 as _; + Self::call(arg0, arg1) + }; + result as _ + } + #[inline(always)] + fn slow_function_impl( + info: *const deno_core::v8::FunctionCallbackInfo, + ) -> usize { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, + ); + let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { + &*info + }); + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let result = { + let arg0 = args.get(0usize as i32); + let Some(arg0) = deno_core::_ops::to_u32_option(&arg0) else { + let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; + let msg = deno_core::v8::String::new_from_one_byte( + &mut scope, + "expected u32".as_bytes(), + deno_core::v8::NewStringType::Normal, + ) + .unwrap(); + let exc = deno_core::v8::Exception::type_error(&mut scope, msg); + scope.throw_exception(exc); + return 1; + }; + let arg0 = arg0 as _; + let arg1 = args.get(1usize as i32); + let Some(arg1) = deno_core::_ops::to_u32_option(&arg1) else { + let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; + let msg = deno_core::v8::String::new_from_one_byte( + &mut scope, + "expected u32".as_bytes(), + deno_core::v8::NewStringType::Normal, + ) + .unwrap(); + let exc = deno_core::v8::Exception::type_error(&mut scope, msg); + scope.throw_exception(exc); + return 1; + }; + let arg1 = arg1 as _; + Self::call(arg0, arg1) + }; + deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv); + return 0; + } + extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { + Self::slow_function_impl(info); + } + extern "C" fn v8_fn_ptr_metrics( + info: *const deno_core::v8::FunctionCallbackInfo, + ) { + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; deno_core::_ops::dispatch_metrics_slow( &opctx, - deno_core::_ops::OpMetricsEvent::Error, + deno_core::_ops::OpMetricsEvent::Dispatched, ); + let res = Self::slow_function_impl(info); + if res == 0 { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Completed, + ); + } else { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Error, + ); + } + } + #[inline(always)] + fn call(a: u32, b: u32) -> u32 { + a + b } } - #[inline(always)] - fn call(a: u32, b: u32) -> u32 { - a + b - } + ::DECL } diff --git a/ops/op2/test_cases/sync/add_options.out b/ops/op2/test_cases/sync/add_options.out index 5c79f4dab..0999106e1 100644 --- a/ops/op2/test_cases/sync/add_options.out +++ b/ops/op2/test_cases/sync/add_options.out @@ -1,63 +1,46 @@ #[allow(non_camel_case_types)] -pub struct op_test_add_option { - _unconstructable: ::std::marker::PhantomData<()>, -} -impl ::deno_core::_ops::Op for op_test_add_option { - const NAME: &'static str = stringify!(op_test_add_option); - const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( - ::deno_core::__op_name_fast!(op_test_add_option), - false, - false, - 2usize as u8, - Self::v8_fn_ptr as _, - Self::v8_fn_ptr_metrics as _, - None, - None, - ::deno_core::OpMetadata { - ..::deno_core::OpMetadata::default() - }, - ); -} -impl op_test_add_option { - pub const fn name() -> &'static str { - stringify!(op_test_add_option) - } - #[deprecated(note = "Use the const op::DECL instead")] - pub const fn decl() -> deno_core::_ops::OpDecl { - ::DECL +pub const fn op_test_add_option() -> ::deno_core::_ops::OpDecl { + #[allow(non_camel_case_types)] + pub struct op_test_add_option { + _unconstructable: ::std::marker::PhantomData<()>, } - #[inline(always)] - fn slow_function_impl(info: *const deno_core::v8::FunctionCallbackInfo) -> usize { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, + impl ::deno_core::_ops::Op for op_test_add_option { + const NAME: &'static str = stringify!(op_test_add_option); + const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( + ::deno_core::__op_name_fast!(op_test_add_option), + false, + false, + 2usize as u8, + Self::v8_fn_ptr as _, + Self::v8_fn_ptr_metrics as _, + None, + None, + ::deno_core::OpMetadata { + ..::deno_core::OpMetadata::default() + }, ); - let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { - &*info - }); - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let result = { - let arg0 = args.get(0usize as i32); - let Some(arg0) = deno_core::_ops::to_u32_option(&arg0) else { - let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; - let msg = deno_core::v8::String::new_from_one_byte( - &mut scope, - "expected u32".as_bytes(), - deno_core::v8::NewStringType::Normal, - ) - .unwrap(); - let exc = deno_core::v8::Exception::type_error(&mut scope, msg); - scope.throw_exception(exc); - return 1; - }; - let arg0 = arg0 as _; - let arg1 = args.get(1usize as i32); - let arg1 = if arg1.is_null_or_undefined() { - None - } else { - let Some(arg1) = deno_core::_ops::to_u32_option(&arg1) else { + } + impl op_test_add_option { + pub const fn name() -> &'static str { + stringify!(op_test_add_option) + } + #[inline(always)] + fn slow_function_impl( + info: *const deno_core::v8::FunctionCallbackInfo, + ) -> usize { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, + ); + let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { + &*info + }); + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let result = { + let arg0 = args.get(0usize as i32); + let Some(arg0) = deno_core::_ops::to_u32_option(&arg0) else { let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; let msg = deno_core::v8::String::new_from_one_byte( &mut scope, @@ -69,44 +52,67 @@ impl op_test_add_option { scope.throw_exception(exc); return 1; }; - let arg1 = arg1 as _; - Some(arg1) + let arg0 = arg0 as _; + let arg1 = args.get(1usize as i32); + let arg1 = if arg1.is_null_or_undefined() { + None + } else { + let Some(arg1) = deno_core::_ops::to_u32_option(&arg1) else { + let mut scope = unsafe { + deno_core::v8::CallbackScope::new(&*info) + }; + let msg = deno_core::v8::String::new_from_one_byte( + &mut scope, + "expected u32".as_bytes(), + deno_core::v8::NewStringType::Normal, + ) + .unwrap(); + let exc = deno_core::v8::Exception::type_error(&mut scope, msg); + scope.throw_exception(exc); + return 1; + }; + let arg1 = arg1 as _; + Some(arg1) + }; + Self::call(arg0, arg1) + }; + deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv); + return 0; + } + extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { + Self::slow_function_impl(info); + } + extern "C" fn v8_fn_ptr_metrics( + info: *const deno_core::v8::FunctionCallbackInfo, + ) { + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) }; - Self::call(arg0, arg1) - }; - deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv); - return 0; - } - extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { - Self::slow_function_impl(info); - } - extern "C" fn v8_fn_ptr_metrics(info: *const deno_core::v8::FunctionCallbackInfo) { - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_slow( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, - ); - let res = Self::slow_function_impl(info); - if res == 0 { - deno_core::_ops::dispatch_metrics_slow( - &opctx, - deno_core::_ops::OpMetricsEvent::Completed, - ); - } else { deno_core::_ops::dispatch_metrics_slow( &opctx, - deno_core::_ops::OpMetricsEvent::Error, + deno_core::_ops::OpMetricsEvent::Dispatched, ); + let res = Self::slow_function_impl(info); + if res == 0 { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Completed, + ); + } else { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Error, + ); + } + } + #[inline(always)] + pub fn call(a: u32, b: Option) -> u32 { + a + b.unwrap_or(100) } } - #[inline(always)] - pub fn call(a: u32, b: Option) -> u32 { - a + b.unwrap_or(100) - } + ::DECL } diff --git a/ops/op2/test_cases/sync/bigint.out b/ops/op2/test_cases/sync/bigint.out index 8a597afde..861a1039e 100644 --- a/ops/op2/test_cases/sync/bigint.out +++ b/ops/op2/test_cases/sync/bigint.out @@ -1,123 +1,129 @@ #[allow(non_camel_case_types)] -pub struct op_bigint { - _unconstructable: ::std::marker::PhantomData<()>, -} -impl ::deno_core::_ops::Op for op_bigint { - const NAME: &'static str = stringify!(op_bigint); - const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( - ::deno_core::__op_name_fast!(op_bigint), - false, - false, - 0usize as u8, - Self::v8_fn_ptr as _, - Self::v8_fn_ptr_metrics as _, - Some({ - use deno_core::v8::fast_api::Type; - use deno_core::v8::fast_api::CType; - deno_core::v8::fast_api::FastFunction::new_with_bigint( - &[Type::V8Value], - CType::Uint64, - Self::v8_fn_ptr_fast as *const ::std::ffi::c_void, - ) - }), - Some({ - use deno_core::v8::fast_api::Type; - use deno_core::v8::fast_api::CType; - deno_core::v8::fast_api::FastFunction::new_with_bigint( - &[Type::V8Value, Type::CallbackOptions], - CType::Uint64, - Self::v8_fn_ptr_fast_metrics as *const ::std::ffi::c_void, - ) - }), - ::deno_core::OpMetadata { - ..::deno_core::OpMetadata::default() - }, - ); -} -impl op_bigint { - pub const fn name() -> &'static str { - stringify!(op_bigint) - } - #[deprecated(note = "Use the const op::DECL instead")] - pub const fn decl() -> deno_core::_ops::OpDecl { - ::DECL - } - #[allow(clippy::too_many_arguments)] - extern "C" fn v8_fn_ptr_fast_metrics( - this: deno_core::v8::Local, - fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, - ) -> u64 { - let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; - let opctx = unsafe { - &*(deno_core::v8::Local::< - deno_core::v8::External, - >::cast(unsafe { fast_api_callback_options.data.data }) - .value() as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_fast( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, - ); - let res = Self::v8_fn_ptr_fast(this); - deno_core::_ops::dispatch_metrics_fast( - &opctx, - deno_core::_ops::OpMetricsEvent::Completed, - ); - res +pub const fn op_bigint() -> ::deno_core::_ops::OpDecl { + #[allow(non_camel_case_types)] + pub struct op_bigint { + _unconstructable: ::std::marker::PhantomData<()>, } - #[allow(clippy::too_many_arguments)] - extern "C" fn v8_fn_ptr_fast(_: deno_core::v8::Local) -> u64 { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, + impl ::deno_core::_ops::Op for op_bigint { + const NAME: &'static str = stringify!(op_bigint); + const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( + ::deno_core::__op_name_fast!(op_bigint), + false, + false, + 0usize as u8, + Self::v8_fn_ptr as _, + Self::v8_fn_ptr_metrics as _, + Some({ + use deno_core::v8::fast_api::Type; + use deno_core::v8::fast_api::CType; + deno_core::v8::fast_api::FastFunction::new_with_bigint( + &[Type::V8Value], + CType::Uint64, + Self::v8_fn_ptr_fast as *const ::std::ffi::c_void, + ) + }), + Some({ + use deno_core::v8::fast_api::Type; + use deno_core::v8::fast_api::CType; + deno_core::v8::fast_api::FastFunction::new_with_bigint( + &[Type::V8Value, Type::CallbackOptions], + CType::Uint64, + Self::v8_fn_ptr_fast_metrics as *const ::std::ffi::c_void, + ) + }), + ::deno_core::OpMetadata { + ..::deno_core::OpMetadata::default() + }, ); - let result = { Self::call() }; - result as _ } - #[inline(always)] - fn slow_function_impl(info: *const deno_core::v8::FunctionCallbackInfo) -> usize { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, - ); - let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; - let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { - &*info - }); - let result = { Self::call() }; - rv.set(deno_core::_ops::RustToV8::to_v8(result, &mut scope)); - return 0; - } - extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { - Self::slow_function_impl(info); - } - extern "C" fn v8_fn_ptr_metrics(info: *const deno_core::v8::FunctionCallbackInfo) { - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_slow( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, - ); - let res = Self::slow_function_impl(info); - if res == 0 { - deno_core::_ops::dispatch_metrics_slow( + impl op_bigint { + pub const fn name() -> &'static str { + stringify!(op_bigint) + } + #[allow(clippy::too_many_arguments)] + extern "C" fn v8_fn_ptr_fast_metrics( + this: deno_core::v8::Local, + fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, + ) -> u64 { + let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; + let opctx = unsafe { + &*(deno_core::v8::Local::< + deno_core::v8::External, + >::cast(unsafe { fast_api_callback_options.data.data }) + .value() as *const deno_core::_ops::OpCtx) + }; + deno_core::_ops::dispatch_metrics_fast( + &opctx, + deno_core::_ops::OpMetricsEvent::Dispatched, + ); + let res = Self::v8_fn_ptr_fast(this); + deno_core::_ops::dispatch_metrics_fast( &opctx, deno_core::_ops::OpMetricsEvent::Completed, ); - } else { + res + } + #[allow(clippy::too_many_arguments)] + extern "C" fn v8_fn_ptr_fast( + _: deno_core::v8::Local, + ) -> u64 { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, + ); + let result = { Self::call() }; + result as _ + } + #[inline(always)] + fn slow_function_impl( + info: *const deno_core::v8::FunctionCallbackInfo, + ) -> usize { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, + ); + let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; + let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { + &*info + }); + let result = { Self::call() }; + rv.set(deno_core::_ops::RustToV8::to_v8(result, &mut scope)); + return 0; + } + extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { + Self::slow_function_impl(info); + } + extern "C" fn v8_fn_ptr_metrics( + info: *const deno_core::v8::FunctionCallbackInfo, + ) { + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; deno_core::_ops::dispatch_metrics_slow( &opctx, - deno_core::_ops::OpMetricsEvent::Error, + deno_core::_ops::OpMetricsEvent::Dispatched, ); + let res = Self::slow_function_impl(info); + if res == 0 { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Completed, + ); + } else { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Error, + ); + } + } + #[inline(always)] + pub fn call() -> u64 { + 0 } } - #[inline(always)] - pub fn call() -> u64 { - 0 - } + ::DECL } diff --git a/ops/op2/test_cases/sync/bool.out b/ops/op2/test_cases/sync/bool.out index 188f2f1bb..ff05a04b7 100644 --- a/ops/op2/test_cases/sync/bool.out +++ b/ops/op2/test_cases/sync/bool.out @@ -1,136 +1,140 @@ #[allow(non_camel_case_types)] -pub struct op_bool { - _unconstructable: ::std::marker::PhantomData<()>, -} -impl ::deno_core::_ops::Op for op_bool { - const NAME: &'static str = stringify!(op_bool); - const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( - ::deno_core::__op_name_fast!(op_bool), - false, - false, - 1usize as u8, - Self::v8_fn_ptr as _, - Self::v8_fn_ptr_metrics as _, - Some({ - use deno_core::v8::fast_api::Type; - use deno_core::v8::fast_api::CType; - deno_core::v8::fast_api::FastFunction::new_with_bigint( - &[Type::V8Value, Type::Bool], - CType::Bool, - Self::v8_fn_ptr_fast as *const ::std::ffi::c_void, - ) - }), - Some({ - use deno_core::v8::fast_api::Type; - use deno_core::v8::fast_api::CType; - deno_core::v8::fast_api::FastFunction::new_with_bigint( - &[Type::V8Value, Type::Bool, Type::CallbackOptions], - CType::Bool, - Self::v8_fn_ptr_fast_metrics as *const ::std::ffi::c_void, - ) - }), - ::deno_core::OpMetadata { - ..::deno_core::OpMetadata::default() - }, - ); -} -impl op_bool { - pub const fn name() -> &'static str { - stringify!(op_bool) - } - #[deprecated(note = "Use the const op::DECL instead")] - pub const fn decl() -> deno_core::_ops::OpDecl { - ::DECL - } - #[allow(clippy::too_many_arguments)] - extern "C" fn v8_fn_ptr_fast_metrics( - this: deno_core::v8::Local, - arg0: bool, - fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, - ) -> bool { - let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; - let opctx = unsafe { - &*(deno_core::v8::Local::< - deno_core::v8::External, - >::cast(unsafe { fast_api_callback_options.data.data }) - .value() as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_fast( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, - ); - let res = Self::v8_fn_ptr_fast(this, arg0); - deno_core::_ops::dispatch_metrics_fast( - &opctx, - deno_core::_ops::OpMetricsEvent::Completed, - ); - res +pub const fn op_bool() -> ::deno_core::_ops::OpDecl { + #[allow(non_camel_case_types)] + pub struct op_bool { + _unconstructable: ::std::marker::PhantomData<()>, } - #[allow(clippy::too_many_arguments)] - extern "C" fn v8_fn_ptr_fast( - _: deno_core::v8::Local, - arg0: bool, - ) -> bool { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, + impl ::deno_core::_ops::Op for op_bool { + const NAME: &'static str = stringify!(op_bool); + const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( + ::deno_core::__op_name_fast!(op_bool), + false, + false, + 1usize as u8, + Self::v8_fn_ptr as _, + Self::v8_fn_ptr_metrics as _, + Some({ + use deno_core::v8::fast_api::Type; + use deno_core::v8::fast_api::CType; + deno_core::v8::fast_api::FastFunction::new_with_bigint( + &[Type::V8Value, Type::Bool], + CType::Bool, + Self::v8_fn_ptr_fast as *const ::std::ffi::c_void, + ) + }), + Some({ + use deno_core::v8::fast_api::Type; + use deno_core::v8::fast_api::CType; + deno_core::v8::fast_api::FastFunction::new_with_bigint( + &[Type::V8Value, Type::Bool, Type::CallbackOptions], + CType::Bool, + Self::v8_fn_ptr_fast_metrics as *const ::std::ffi::c_void, + ) + }), + ::deno_core::OpMetadata { + ..::deno_core::OpMetadata::default() + }, ); - let result = { - let arg0 = arg0 as _; - Self::call(arg0) - }; - result as _ } - #[inline(always)] - fn slow_function_impl(info: *const deno_core::v8::FunctionCallbackInfo) -> usize { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, - ); - let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { - &*info - }); - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let result = { - let arg0 = args.get(0usize as i32); - let arg0 = arg0.is_true(); - Self::call(arg0) - }; - deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv); - return 0; - } - extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { - Self::slow_function_impl(info); - } - extern "C" fn v8_fn_ptr_metrics(info: *const deno_core::v8::FunctionCallbackInfo) { - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_slow( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, - ); - let res = Self::slow_function_impl(info); - if res == 0 { - deno_core::_ops::dispatch_metrics_slow( + impl op_bool { + pub const fn name() -> &'static str { + stringify!(op_bool) + } + #[allow(clippy::too_many_arguments)] + extern "C" fn v8_fn_ptr_fast_metrics( + this: deno_core::v8::Local, + arg0: bool, + fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, + ) -> bool { + let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; + let opctx = unsafe { + &*(deno_core::v8::Local::< + deno_core::v8::External, + >::cast(unsafe { fast_api_callback_options.data.data }) + .value() as *const deno_core::_ops::OpCtx) + }; + deno_core::_ops::dispatch_metrics_fast( + &opctx, + deno_core::_ops::OpMetricsEvent::Dispatched, + ); + let res = Self::v8_fn_ptr_fast(this, arg0); + deno_core::_ops::dispatch_metrics_fast( &opctx, deno_core::_ops::OpMetricsEvent::Completed, ); - } else { + res + } + #[allow(clippy::too_many_arguments)] + extern "C" fn v8_fn_ptr_fast( + _: deno_core::v8::Local, + arg0: bool, + ) -> bool { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, + ); + let result = { + let arg0 = arg0 as _; + Self::call(arg0) + }; + result as _ + } + #[inline(always)] + fn slow_function_impl( + info: *const deno_core::v8::FunctionCallbackInfo, + ) -> usize { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, + ); + let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { + &*info + }); + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let result = { + let arg0 = args.get(0usize as i32); + let arg0 = arg0.is_true(); + Self::call(arg0) + }; + deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv); + return 0; + } + extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { + Self::slow_function_impl(info); + } + extern "C" fn v8_fn_ptr_metrics( + info: *const deno_core::v8::FunctionCallbackInfo, + ) { + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; deno_core::_ops::dispatch_metrics_slow( &opctx, - deno_core::_ops::OpMetricsEvent::Error, + deno_core::_ops::OpMetricsEvent::Dispatched, ); + let res = Self::slow_function_impl(info); + if res == 0 { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Completed, + ); + } else { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Error, + ); + } + } + #[inline(always)] + pub fn call(arg: bool) -> bool { + arg } } - #[inline(always)] - pub fn call(arg: bool) -> bool { - arg - } + ::DECL } diff --git a/ops/op2/test_cases/sync/bool_result.out b/ops/op2/test_cases/sync/bool_result.out index e131340f1..8d166638e 100644 --- a/ops/op2/test_cases/sync/bool_result.out +++ b/ops/op2/test_cases/sync/bool_result.out @@ -1,140 +1,122 @@ #[allow(non_camel_case_types)] -pub struct op_bool { - _unconstructable: ::std::marker::PhantomData<()>, -} -impl ::deno_core::_ops::Op for op_bool { - const NAME: &'static str = stringify!(op_bool); - const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( - ::deno_core::__op_name_fast!(op_bool), - false, - false, - 1usize as u8, - Self::v8_fn_ptr as _, - Self::v8_fn_ptr_metrics as _, - Some({ - use deno_core::v8::fast_api::Type; - use deno_core::v8::fast_api::CType; - deno_core::v8::fast_api::FastFunction::new_with_bigint( - &[Type::V8Value, Type::Bool, Type::CallbackOptions], - CType::Bool, - Self::v8_fn_ptr_fast as *const ::std::ffi::c_void, - ) - }), - Some({ - use deno_core::v8::fast_api::Type; - use deno_core::v8::fast_api::CType; - deno_core::v8::fast_api::FastFunction::new_with_bigint( - &[Type::V8Value, Type::Bool, Type::CallbackOptions], - CType::Bool, - Self::v8_fn_ptr_fast_metrics as *const ::std::ffi::c_void, - ) - }), - ::deno_core::OpMetadata { - ..::deno_core::OpMetadata::default() - }, - ); -} -impl op_bool { - pub const fn name() -> &'static str { - stringify!(op_bool) - } - #[deprecated(note = "Use the const op::DECL instead")] - pub const fn decl() -> deno_core::_ops::OpDecl { - ::DECL +pub const fn op_bool() -> ::deno_core::_ops::OpDecl { + #[allow(non_camel_case_types)] + pub struct op_bool { + _unconstructable: ::std::marker::PhantomData<()>, } - #[allow(clippy::too_many_arguments)] - extern "C" fn v8_fn_ptr_fast_metrics( - this: deno_core::v8::Local, - arg0: bool, - fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, - ) -> bool { - let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; - let opctx = unsafe { - &*(deno_core::v8::Local::< - deno_core::v8::External, - >::cast(unsafe { fast_api_callback_options.data.data }) - .value() as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_fast( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, + impl ::deno_core::_ops::Op for op_bool { + const NAME: &'static str = stringify!(op_bool); + const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( + ::deno_core::__op_name_fast!(op_bool), + false, + false, + 1usize as u8, + Self::v8_fn_ptr as _, + Self::v8_fn_ptr_metrics as _, + Some({ + use deno_core::v8::fast_api::Type; + use deno_core::v8::fast_api::CType; + deno_core::v8::fast_api::FastFunction::new_with_bigint( + &[Type::V8Value, Type::Bool, Type::CallbackOptions], + CType::Bool, + Self::v8_fn_ptr_fast as *const ::std::ffi::c_void, + ) + }), + Some({ + use deno_core::v8::fast_api::Type; + use deno_core::v8::fast_api::CType; + deno_core::v8::fast_api::FastFunction::new_with_bigint( + &[Type::V8Value, Type::Bool, Type::CallbackOptions], + CType::Bool, + Self::v8_fn_ptr_fast_metrics as *const ::std::ffi::c_void, + ) + }), + ::deno_core::OpMetadata { + ..::deno_core::OpMetadata::default() + }, ); - let res = Self::v8_fn_ptr_fast(this, arg0, fast_api_callback_options); - deno_core::_ops::dispatch_metrics_fast( - &opctx, - deno_core::_ops::OpMetricsEvent::Completed, - ); - res - } - #[allow(clippy::too_many_arguments)] - extern "C" fn v8_fn_ptr_fast( - _: deno_core::v8::Local, - arg0: bool, - fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, - ) -> bool { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, - ); - let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; - let opctx = unsafe { - &*(deno_core::v8::Local::< - deno_core::v8::External, - >::cast(unsafe { fast_api_callback_options.data.data }) - .value() as *const deno_core::_ops::OpCtx) - }; - let result = { - let arg0 = arg0 as _; - Self::call(arg0) - }; - let result = match result { - Ok(result) => result, - Err(err) => { - let err = err.into(); - unsafe { - opctx.unsafely_set_last_error_for_ops_only(err); - } - fast_api_callback_options.fallback = true; - return unsafe { std::mem::zeroed() }; - } - }; - result as _ } - #[inline(always)] - fn slow_function_impl(info: *const deno_core::v8::FunctionCallbackInfo) -> usize { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, - ); - let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { - &*info - }); - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - if let Some(err) = unsafe { opctx.unsafely_take_last_error_for_ops_only() } { - let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; - let err = err.into(); - let exception = deno_core::error::to_v8_error( - &mut scope, - opctx.get_error_class_fn, - &err, + impl op_bool { + pub const fn name() -> &'static str { + stringify!(op_bool) + } + #[allow(clippy::too_many_arguments)] + extern "C" fn v8_fn_ptr_fast_metrics( + this: deno_core::v8::Local, + arg0: bool, + fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, + ) -> bool { + let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; + let opctx = unsafe { + &*(deno_core::v8::Local::< + deno_core::v8::External, + >::cast(unsafe { fast_api_callback_options.data.data }) + .value() as *const deno_core::_ops::OpCtx) + }; + deno_core::_ops::dispatch_metrics_fast( + &opctx, + deno_core::_ops::OpMetricsEvent::Dispatched, + ); + let res = Self::v8_fn_ptr_fast(this, arg0, fast_api_callback_options); + deno_core::_ops::dispatch_metrics_fast( + &opctx, + deno_core::_ops::OpMetricsEvent::Completed, + ); + res + } + #[allow(clippy::too_many_arguments)] + extern "C" fn v8_fn_ptr_fast( + _: deno_core::v8::Local, + arg0: bool, + fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, + ) -> bool { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, ); - scope.throw_exception(exception); - return 1; + let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; + let opctx = unsafe { + &*(deno_core::v8::Local::< + deno_core::v8::External, + >::cast(unsafe { fast_api_callback_options.data.data }) + .value() as *const deno_core::_ops::OpCtx) + }; + let result = { + let arg0 = arg0 as _; + Self::call(arg0) + }; + let result = match result { + Ok(result) => result, + Err(err) => { + let err = err.into(); + unsafe { + opctx.unsafely_set_last_error_for_ops_only(err); + } + fast_api_callback_options.fallback = true; + return unsafe { std::mem::zeroed() }; + } + }; + result as _ } - let result = { - let arg0 = args.get(0usize as i32); - let arg0 = arg0.is_true(); - Self::call(arg0) - }; - match result { - Ok(result) => deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv), - Err(err) => { + #[inline(always)] + fn slow_function_impl( + info: *const deno_core::v8::FunctionCallbackInfo, + ) -> usize { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, + ); + let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { + &*info + }); + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; + if let Some(err) = unsafe { opctx.unsafely_take_last_error_for_ops_only() } { let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; let err = err.into(); let exception = deno_core::error::to_v8_error( @@ -145,39 +127,61 @@ impl op_bool { scope.throw_exception(exception); return 1; } - }; - return 0; - } - extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { - Self::slow_function_impl(info); - } - extern "C" fn v8_fn_ptr_metrics(info: *const deno_core::v8::FunctionCallbackInfo) { - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_slow( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, - ); - let res = Self::slow_function_impl(info); - if res == 0 { - deno_core::_ops::dispatch_metrics_slow( - &opctx, - deno_core::_ops::OpMetricsEvent::Completed, - ); - } else { + let result = { + let arg0 = args.get(0usize as i32); + let arg0 = arg0.is_true(); + Self::call(arg0) + }; + match result { + Ok(result) => deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv), + Err(err) => { + let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; + let err = err.into(); + let exception = deno_core::error::to_v8_error( + &mut scope, + opctx.get_error_class_fn, + &err, + ); + scope.throw_exception(exception); + return 1; + } + }; + return 0; + } + extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { + Self::slow_function_impl(info); + } + extern "C" fn v8_fn_ptr_metrics( + info: *const deno_core::v8::FunctionCallbackInfo, + ) { + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; deno_core::_ops::dispatch_metrics_slow( &opctx, - deno_core::_ops::OpMetricsEvent::Error, + deno_core::_ops::OpMetricsEvent::Dispatched, ); + let res = Self::slow_function_impl(info); + if res == 0 { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Completed, + ); + } else { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Error, + ); + } + } + #[inline(always)] + pub fn call(arg: bool) -> Result { + Ok(arg) } } - #[inline(always)] - pub fn call(arg: bool) -> Result { - Ok(arg) - } + ::DECL } diff --git a/ops/op2/test_cases/sync/buffers.out b/ops/op2/test_cases/sync/buffers.out index 52e33fdad..398314bfe 100644 --- a/ops/op2/test_cases/sync/buffers.out +++ b/ops/op2/test_cases/sync/buffers.out @@ -1,584 +1,435 @@ #[allow(non_camel_case_types)] -struct op_buffers { - _unconstructable: ::std::marker::PhantomData<()>, -} -impl ::deno_core::_ops::Op for op_buffers { - const NAME: &'static str = stringify!(op_buffers); - const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( - ::deno_core::__op_name_fast!(op_buffers), - false, - false, - 4usize as u8, - Self::v8_fn_ptr as _, - Self::v8_fn_ptr_metrics as _, - Some({ - use deno_core::v8::fast_api::Type; - use deno_core::v8::fast_api::CType; - deno_core::v8::fast_api::FastFunction::new_with_bigint( - &[ - Type::V8Value, - Type::TypedArray(CType::Uint8), - Type::TypedArray(CType::Uint8), - Type::TypedArray(CType::Uint8), - Type::TypedArray(CType::Uint8), - ], - CType::Void, - Self::v8_fn_ptr_fast as *const ::std::ffi::c_void, - ) - }), - Some({ - use deno_core::v8::fast_api::Type; - use deno_core::v8::fast_api::CType; - deno_core::v8::fast_api::FastFunction::new_with_bigint( - &[ - Type::V8Value, - Type::TypedArray(CType::Uint8), - Type::TypedArray(CType::Uint8), - Type::TypedArray(CType::Uint8), - Type::TypedArray(CType::Uint8), - Type::CallbackOptions, - ], - CType::Void, - Self::v8_fn_ptr_fast_metrics as *const ::std::ffi::c_void, - ) - }), - ::deno_core::OpMetadata { - ..::deno_core::OpMetadata::default() - }, - ); -} -impl op_buffers { - pub const fn name() -> &'static str { - stringify!(op_buffers) - } - #[deprecated(note = "Use the const op::DECL instead")] - pub const fn decl() -> deno_core::_ops::OpDecl { - ::DECL - } - #[allow(clippy::too_many_arguments)] - extern "C" fn v8_fn_ptr_fast_metrics( - this: deno_core::v8::Local, - arg0: *mut deno_core::v8::fast_api::FastApiTypedArray, - arg1: *mut deno_core::v8::fast_api::FastApiTypedArray, - arg2: *mut deno_core::v8::fast_api::FastApiTypedArray, - arg3: *mut deno_core::v8::fast_api::FastApiTypedArray, - fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, - ) -> () { - let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; - let opctx = unsafe { - &*(deno_core::v8::Local::< - deno_core::v8::External, - >::cast(unsafe { fast_api_callback_options.data.data }) - .value() as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_fast( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, - ); - let res = Self::v8_fn_ptr_fast(this, arg0, arg1, arg2, arg3); - deno_core::_ops::dispatch_metrics_fast( - &opctx, - deno_core::_ops::OpMetricsEvent::Completed, - ); - res +const fn op_buffers() -> ::deno_core::_ops::OpDecl { + #[allow(non_camel_case_types)] + struct op_buffers { + _unconstructable: ::std::marker::PhantomData<()>, } - #[allow(clippy::too_many_arguments)] - extern "C" fn v8_fn_ptr_fast( - _: deno_core::v8::Local, - arg0: *mut deno_core::v8::fast_api::FastApiTypedArray, - arg1: *mut deno_core::v8::fast_api::FastApiTypedArray, - arg2: *mut deno_core::v8::fast_api::FastApiTypedArray, - arg3: *mut deno_core::v8::fast_api::FastApiTypedArray, - ) -> () { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, - ); - let result = { - let arg0 = unsafe { - deno_core::v8::fast_api::FastApiTypedArray::get_storage_from_pointer_if_aligned( - arg0, + impl ::deno_core::_ops::Op for op_buffers { + const NAME: &'static str = stringify!(op_buffers); + const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( + ::deno_core::__op_name_fast!(op_buffers), + false, + false, + 4usize as u8, + Self::v8_fn_ptr as _, + Self::v8_fn_ptr_metrics as _, + Some({ + use deno_core::v8::fast_api::Type; + use deno_core::v8::fast_api::CType; + deno_core::v8::fast_api::FastFunction::new_with_bigint( + &[ + Type::V8Value, + Type::TypedArray(CType::Uint8), + Type::TypedArray(CType::Uint8), + Type::TypedArray(CType::Uint8), + Type::TypedArray(CType::Uint8), + ], + CType::Void, + Self::v8_fn_ptr_fast as *const ::std::ffi::c_void, ) - } - .expect("Invalid buffer"); - let arg0 = arg0; - let arg1 = unsafe { - deno_core::v8::fast_api::FastApiTypedArray::get_storage_from_pointer_if_aligned( - arg1, + }), + Some({ + use deno_core::v8::fast_api::Type; + use deno_core::v8::fast_api::CType; + deno_core::v8::fast_api::FastFunction::new_with_bigint( + &[ + Type::V8Value, + Type::TypedArray(CType::Uint8), + Type::TypedArray(CType::Uint8), + Type::TypedArray(CType::Uint8), + Type::TypedArray(CType::Uint8), + Type::CallbackOptions, + ], + CType::Void, + Self::v8_fn_ptr_fast_metrics as *const ::std::ffi::c_void, ) - } - .expect("Invalid buffer"); - let arg1 = arg1; - let arg2 = unsafe { - deno_core::v8::fast_api::FastApiTypedArray::get_storage_from_pointer_if_aligned( - arg2, - ) - } - .expect("Invalid buffer"); - let arg2 = if arg2.len() == 0 { - ::std::ptr::null_mut() - } else { - arg2.as_mut_ptr() as _ - }; - let arg3 = unsafe { - deno_core::v8::fast_api::FastApiTypedArray::get_storage_from_pointer_if_aligned( - arg3, - ) - } - .expect("Invalid buffer"); - let arg3 = if arg3.len() == 0 { - ::std::ptr::null_mut() - } else { - arg3.as_mut_ptr() as _ - }; - Self::call(arg0, arg1, arg2, arg3) - }; - result as _ - } - #[inline(always)] - fn slow_function_impl(info: *const deno_core::v8::FunctionCallbackInfo) -> usize { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, + }), + ::deno_core::OpMetadata { + ..::deno_core::OpMetadata::default() + }, ); - let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { - &*info - }); - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let result = { - let arg0 = args.get(0usize as i32); - let mut arg0_temp; - arg0_temp = match unsafe { deno_core::_ops::to_v8_slice::(arg0) } { - Ok(arg0) => arg0, - Err(arg0_err) => { - let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; - let msg = deno_core::v8::String::new_from_one_byte( - &mut scope, - arg0_err.as_bytes(), - deno_core::v8::NewStringType::Normal, - ) - .unwrap(); - let exc = deno_core::v8::Exception::type_error(&mut scope, msg); - scope.throw_exception(exc); - return 1; - } + } + impl op_buffers { + pub const fn name() -> &'static str { + stringify!(op_buffers) + } + #[allow(clippy::too_many_arguments)] + extern "C" fn v8_fn_ptr_fast_metrics( + this: deno_core::v8::Local, + arg0: *mut deno_core::v8::fast_api::FastApiTypedArray, + arg1: *mut deno_core::v8::fast_api::FastApiTypedArray, + arg2: *mut deno_core::v8::fast_api::FastApiTypedArray, + arg3: *mut deno_core::v8::fast_api::FastApiTypedArray, + fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, + ) -> () { + let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; + let opctx = unsafe { + &*(deno_core::v8::Local::< + deno_core::v8::External, + >::cast(unsafe { fast_api_callback_options.data.data }) + .value() as *const deno_core::_ops::OpCtx) }; - let arg0 = arg0_temp.as_ref(); - let arg1 = args.get(1usize as i32); - let mut arg1_temp; - arg1_temp = match unsafe { deno_core::_ops::to_v8_slice::(arg1) } { - Ok(arg1) => arg1, - Err(arg1_err) => { - let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; - let msg = deno_core::v8::String::new_from_one_byte( - &mut scope, - arg1_err.as_bytes(), - deno_core::v8::NewStringType::Normal, - ) - .unwrap(); - let exc = deno_core::v8::Exception::type_error(&mut scope, msg); - scope.throw_exception(exc); - return 1; + deno_core::_ops::dispatch_metrics_fast( + &opctx, + deno_core::_ops::OpMetricsEvent::Dispatched, + ); + let res = Self::v8_fn_ptr_fast(this, arg0, arg1, arg2, arg3); + deno_core::_ops::dispatch_metrics_fast( + &opctx, + deno_core::_ops::OpMetricsEvent::Completed, + ); + res + } + #[allow(clippy::too_many_arguments)] + extern "C" fn v8_fn_ptr_fast( + _: deno_core::v8::Local, + arg0: *mut deno_core::v8::fast_api::FastApiTypedArray, + arg1: *mut deno_core::v8::fast_api::FastApiTypedArray, + arg2: *mut deno_core::v8::fast_api::FastApiTypedArray, + arg3: *mut deno_core::v8::fast_api::FastApiTypedArray, + ) -> () { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, + ); + let result = { + let arg0 = unsafe { + deno_core::v8::fast_api::FastApiTypedArray::get_storage_from_pointer_if_aligned( + arg0, + ) } - }; - let arg1 = arg1_temp.as_mut(); - let arg2 = args.get(2usize as i32); - let mut arg2_temp; - arg2_temp = match unsafe { deno_core::_ops::to_v8_slice::(arg2) } { - Ok(arg2) => arg2, - Err(arg2_err) => { - let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; - let msg = deno_core::v8::String::new_from_one_byte( - &mut scope, - arg2_err.as_bytes(), - deno_core::v8::NewStringType::Normal, - ) - .unwrap(); - let exc = deno_core::v8::Exception::type_error(&mut scope, msg); - scope.throw_exception(exc); - return 1; + .expect("Invalid buffer"); + let arg0 = arg0; + let arg1 = unsafe { + deno_core::v8::fast_api::FastApiTypedArray::get_storage_from_pointer_if_aligned( + arg1, + ) } - }; - let arg2 = if arg2_temp.len() == 0 { - std::ptr::null() - } else { - arg2_temp.as_ref().as_ptr() - }; - let arg3 = args.get(3usize as i32); - let mut arg3_temp; - arg3_temp = match unsafe { deno_core::_ops::to_v8_slice::(arg3) } { - Ok(arg3) => arg3, - Err(arg3_err) => { - let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; - let msg = deno_core::v8::String::new_from_one_byte( - &mut scope, - arg3_err.as_bytes(), - deno_core::v8::NewStringType::Normal, - ) - .unwrap(); - let exc = deno_core::v8::Exception::type_error(&mut scope, msg); - scope.throw_exception(exc); - return 1; + .expect("Invalid buffer"); + let arg1 = arg1; + let arg2 = unsafe { + deno_core::v8::fast_api::FastApiTypedArray::get_storage_from_pointer_if_aligned( + arg2, + ) } + .expect("Invalid buffer"); + let arg2 = if arg2.len() == 0 { + ::std::ptr::null_mut() + } else { + arg2.as_mut_ptr() as _ + }; + let arg3 = unsafe { + deno_core::v8::fast_api::FastApiTypedArray::get_storage_from_pointer_if_aligned( + arg3, + ) + } + .expect("Invalid buffer"); + let arg3 = if arg3.len() == 0 { + ::std::ptr::null_mut() + } else { + arg3.as_mut_ptr() as _ + }; + Self::call(arg0, arg1, arg2, arg3) }; - let arg3 = if arg3_temp.len() == 0 { - std::ptr::null_mut() - } else { - arg3_temp.as_mut().as_mut_ptr() - }; - Self::call(arg0, arg1, arg2, arg3) - }; - deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv); - return 0; - } - extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { - Self::slow_function_impl(info); - } - extern "C" fn v8_fn_ptr_metrics(info: *const deno_core::v8::FunctionCallbackInfo) { - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_slow( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, - ); - let res = Self::slow_function_impl(info); - if res == 0 { - deno_core::_ops::dispatch_metrics_slow( - &opctx, - deno_core::_ops::OpMetricsEvent::Completed, + result as _ + } + #[inline(always)] + fn slow_function_impl( + info: *const deno_core::v8::FunctionCallbackInfo, + ) -> usize { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, ); - } else { + let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { + &*info + }); + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let result = { + let arg0 = args.get(0usize as i32); + let mut arg0_temp; + arg0_temp = match unsafe { deno_core::_ops::to_v8_slice::(arg0) } { + Ok(arg0) => arg0, + Err(arg0_err) => { + let mut scope = unsafe { + deno_core::v8::CallbackScope::new(&*info) + }; + let msg = deno_core::v8::String::new_from_one_byte( + &mut scope, + arg0_err.as_bytes(), + deno_core::v8::NewStringType::Normal, + ) + .unwrap(); + let exc = deno_core::v8::Exception::type_error(&mut scope, msg); + scope.throw_exception(exc); + return 1; + } + }; + let arg0 = arg0_temp.as_ref(); + let arg1 = args.get(1usize as i32); + let mut arg1_temp; + arg1_temp = match unsafe { deno_core::_ops::to_v8_slice::(arg1) } { + Ok(arg1) => arg1, + Err(arg1_err) => { + let mut scope = unsafe { + deno_core::v8::CallbackScope::new(&*info) + }; + let msg = deno_core::v8::String::new_from_one_byte( + &mut scope, + arg1_err.as_bytes(), + deno_core::v8::NewStringType::Normal, + ) + .unwrap(); + let exc = deno_core::v8::Exception::type_error(&mut scope, msg); + scope.throw_exception(exc); + return 1; + } + }; + let arg1 = arg1_temp.as_mut(); + let arg2 = args.get(2usize as i32); + let mut arg2_temp; + arg2_temp = match unsafe { deno_core::_ops::to_v8_slice::(arg2) } { + Ok(arg2) => arg2, + Err(arg2_err) => { + let mut scope = unsafe { + deno_core::v8::CallbackScope::new(&*info) + }; + let msg = deno_core::v8::String::new_from_one_byte( + &mut scope, + arg2_err.as_bytes(), + deno_core::v8::NewStringType::Normal, + ) + .unwrap(); + let exc = deno_core::v8::Exception::type_error(&mut scope, msg); + scope.throw_exception(exc); + return 1; + } + }; + let arg2 = if arg2_temp.len() == 0 { + std::ptr::null() + } else { + arg2_temp.as_ref().as_ptr() + }; + let arg3 = args.get(3usize as i32); + let mut arg3_temp; + arg3_temp = match unsafe { deno_core::_ops::to_v8_slice::(arg3) } { + Ok(arg3) => arg3, + Err(arg3_err) => { + let mut scope = unsafe { + deno_core::v8::CallbackScope::new(&*info) + }; + let msg = deno_core::v8::String::new_from_one_byte( + &mut scope, + arg3_err.as_bytes(), + deno_core::v8::NewStringType::Normal, + ) + .unwrap(); + let exc = deno_core::v8::Exception::type_error(&mut scope, msg); + scope.throw_exception(exc); + return 1; + } + }; + let arg3 = if arg3_temp.len() == 0 { + std::ptr::null_mut() + } else { + arg3_temp.as_mut().as_mut_ptr() + }; + Self::call(arg0, arg1, arg2, arg3) + }; + deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv); + return 0; + } + extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { + Self::slow_function_impl(info); + } + extern "C" fn v8_fn_ptr_metrics( + info: *const deno_core::v8::FunctionCallbackInfo, + ) { + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; deno_core::_ops::dispatch_metrics_slow( &opctx, - deno_core::_ops::OpMetricsEvent::Error, + deno_core::_ops::OpMetricsEvent::Dispatched, ); + let res = Self::slow_function_impl(info); + if res == 0 { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Completed, + ); + } else { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Error, + ); + } } + #[inline(always)] + fn call(_a: &[u8], _b: &mut [u8], _c: *const u8, _d: *mut u8) {} } - #[inline(always)] - fn call(_a: &[u8], _b: &mut [u8], _c: *const u8, _d: *mut u8) {} + ::DECL } #[allow(non_camel_case_types)] -struct op_buffers_32 { - _unconstructable: ::std::marker::PhantomData<()>, -} -impl ::deno_core::_ops::Op for op_buffers_32 { - const NAME: &'static str = stringify!(op_buffers_32); - const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( - ::deno_core::__op_name_fast!(op_buffers_32), - false, - false, - 4usize as u8, - Self::v8_fn_ptr as _, - Self::v8_fn_ptr_metrics as _, - Some({ - use deno_core::v8::fast_api::Type; - use deno_core::v8::fast_api::CType; - deno_core::v8::fast_api::FastFunction::new_with_bigint( - &[ - Type::V8Value, - Type::TypedArray(CType::Uint32), - Type::TypedArray(CType::Uint32), - Type::TypedArray(CType::Uint32), - Type::TypedArray(CType::Uint32), - ], - CType::Void, - Self::v8_fn_ptr_fast as *const ::std::ffi::c_void, - ) - }), - Some({ - use deno_core::v8::fast_api::Type; - use deno_core::v8::fast_api::CType; - deno_core::v8::fast_api::FastFunction::new_with_bigint( - &[ - Type::V8Value, - Type::TypedArray(CType::Uint32), - Type::TypedArray(CType::Uint32), - Type::TypedArray(CType::Uint32), - Type::TypedArray(CType::Uint32), - Type::CallbackOptions, - ], - CType::Void, - Self::v8_fn_ptr_fast_metrics as *const ::std::ffi::c_void, - ) - }), - ::deno_core::OpMetadata { - ..::deno_core::OpMetadata::default() - }, - ); -} -impl op_buffers_32 { - pub const fn name() -> &'static str { - stringify!(op_buffers_32) +const fn op_buffers_32() -> ::deno_core::_ops::OpDecl { + #[allow(non_camel_case_types)] + struct op_buffers_32 { + _unconstructable: ::std::marker::PhantomData<()>, } - #[deprecated(note = "Use the const op::DECL instead")] - pub const fn decl() -> deno_core::_ops::OpDecl { - ::DECL - } - #[allow(clippy::too_many_arguments)] - extern "C" fn v8_fn_ptr_fast_metrics( - this: deno_core::v8::Local, - arg0: *mut deno_core::v8::fast_api::FastApiTypedArray, - arg1: *mut deno_core::v8::fast_api::FastApiTypedArray, - arg2: *mut deno_core::v8::fast_api::FastApiTypedArray, - arg3: *mut deno_core::v8::fast_api::FastApiTypedArray, - fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, - ) -> () { - let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; - let opctx = unsafe { - &*(deno_core::v8::Local::< - deno_core::v8::External, - >::cast(unsafe { fast_api_callback_options.data.data }) - .value() as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_fast( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, - ); - let res = Self::v8_fn_ptr_fast(this, arg0, arg1, arg2, arg3); - deno_core::_ops::dispatch_metrics_fast( - &opctx, - deno_core::_ops::OpMetricsEvent::Completed, - ); - res - } - #[allow(clippy::too_many_arguments)] - extern "C" fn v8_fn_ptr_fast( - _: deno_core::v8::Local, - arg0: *mut deno_core::v8::fast_api::FastApiTypedArray, - arg1: *mut deno_core::v8::fast_api::FastApiTypedArray, - arg2: *mut deno_core::v8::fast_api::FastApiTypedArray, - arg3: *mut deno_core::v8::fast_api::FastApiTypedArray, - ) -> () { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, - ); - let result = { - let arg0 = unsafe { - deno_core::v8::fast_api::FastApiTypedArray::get_storage_from_pointer_if_aligned( - arg0, - ) - } - .expect("Invalid buffer"); - let arg0 = arg0; - let arg1 = unsafe { - deno_core::v8::fast_api::FastApiTypedArray::get_storage_from_pointer_if_aligned( - arg1, + impl ::deno_core::_ops::Op for op_buffers_32 { + const NAME: &'static str = stringify!(op_buffers_32); + const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( + ::deno_core::__op_name_fast!(op_buffers_32), + false, + false, + 4usize as u8, + Self::v8_fn_ptr as _, + Self::v8_fn_ptr_metrics as _, + Some({ + use deno_core::v8::fast_api::Type; + use deno_core::v8::fast_api::CType; + deno_core::v8::fast_api::FastFunction::new_with_bigint( + &[ + Type::V8Value, + Type::TypedArray(CType::Uint32), + Type::TypedArray(CType::Uint32), + Type::TypedArray(CType::Uint32), + Type::TypedArray(CType::Uint32), + ], + CType::Void, + Self::v8_fn_ptr_fast as *const ::std::ffi::c_void, ) - } - .expect("Invalid buffer"); - let arg1 = arg1; - let arg2 = unsafe { - deno_core::v8::fast_api::FastApiTypedArray::get_storage_from_pointer_if_aligned( - arg2, + }), + Some({ + use deno_core::v8::fast_api::Type; + use deno_core::v8::fast_api::CType; + deno_core::v8::fast_api::FastFunction::new_with_bigint( + &[ + Type::V8Value, + Type::TypedArray(CType::Uint32), + Type::TypedArray(CType::Uint32), + Type::TypedArray(CType::Uint32), + Type::TypedArray(CType::Uint32), + Type::CallbackOptions, + ], + CType::Void, + Self::v8_fn_ptr_fast_metrics as *const ::std::ffi::c_void, ) - } - .expect("Invalid buffer"); - let arg2 = if arg2.len() == 0 { - ::std::ptr::null_mut() - } else { - arg2.as_mut_ptr() as _ - }; - let arg3 = unsafe { - deno_core::v8::fast_api::FastApiTypedArray::get_storage_from_pointer_if_aligned( - arg3, - ) - } - .expect("Invalid buffer"); - let arg3 = if arg3.len() == 0 { - ::std::ptr::null_mut() - } else { - arg3.as_mut_ptr() as _ - }; - Self::call(arg0, arg1, arg2, arg3) - }; - result as _ - } - #[inline(always)] - fn slow_function_impl(info: *const deno_core::v8::FunctionCallbackInfo) -> usize { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, + }), + ::deno_core::OpMetadata { + ..::deno_core::OpMetadata::default() + }, ); - let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { - &*info - }); - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let result = { - let arg0 = args.get(0usize as i32); - let mut arg0_temp; - arg0_temp = match unsafe { deno_core::_ops::to_v8_slice::(arg0) } { - Ok(arg0) => arg0, - Err(arg0_err) => { - let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; - let msg = deno_core::v8::String::new_from_one_byte( - &mut scope, - arg0_err.as_bytes(), - deno_core::v8::NewStringType::Normal, - ) - .unwrap(); - let exc = deno_core::v8::Exception::type_error(&mut scope, msg); - scope.throw_exception(exc); - return 1; - } - }; - let arg0 = arg0_temp.as_ref(); - let arg1 = args.get(1usize as i32); - let mut arg1_temp; - arg1_temp = match unsafe { deno_core::_ops::to_v8_slice::(arg1) } { - Ok(arg1) => arg1, - Err(arg1_err) => { - let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; - let msg = deno_core::v8::String::new_from_one_byte( - &mut scope, - arg1_err.as_bytes(), - deno_core::v8::NewStringType::Normal, - ) - .unwrap(); - let exc = deno_core::v8::Exception::type_error(&mut scope, msg); - scope.throw_exception(exc); - return 1; - } - }; - let arg1 = arg1_temp.as_mut(); - let arg2 = args.get(2usize as i32); - let mut arg2_temp; - arg2_temp = match unsafe { deno_core::_ops::to_v8_slice::(arg2) } { - Ok(arg2) => arg2, - Err(arg2_err) => { - let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; - let msg = deno_core::v8::String::new_from_one_byte( - &mut scope, - arg2_err.as_bytes(), - deno_core::v8::NewStringType::Normal, - ) - .unwrap(); - let exc = deno_core::v8::Exception::type_error(&mut scope, msg); - scope.throw_exception(exc); - return 1; - } - }; - let arg2 = if arg2_temp.len() == 0 { - std::ptr::null() - } else { - arg2_temp.as_ref().as_ptr() - }; - let arg3 = args.get(3usize as i32); - let mut arg3_temp; - arg3_temp = match unsafe { deno_core::_ops::to_v8_slice::(arg3) } { - Ok(arg3) => arg3, - Err(arg3_err) => { - let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; - let msg = deno_core::v8::String::new_from_one_byte( - &mut scope, - arg3_err.as_bytes(), - deno_core::v8::NewStringType::Normal, - ) - .unwrap(); - let exc = deno_core::v8::Exception::type_error(&mut scope, msg); - scope.throw_exception(exc); - return 1; - } - }; - let arg3 = if arg3_temp.len() == 0 { - std::ptr::null_mut() - } else { - arg3_temp.as_mut().as_mut_ptr() - }; - Self::call(arg0, arg1, arg2, arg3) - }; - deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv); - return 0; - } - extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { - Self::slow_function_impl(info); } - extern "C" fn v8_fn_ptr_metrics(info: *const deno_core::v8::FunctionCallbackInfo) { - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_slow( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, - ); - let res = Self::slow_function_impl(info); - if res == 0 { - deno_core::_ops::dispatch_metrics_slow( + impl op_buffers_32 { + pub const fn name() -> &'static str { + stringify!(op_buffers_32) + } + #[allow(clippy::too_many_arguments)] + extern "C" fn v8_fn_ptr_fast_metrics( + this: deno_core::v8::Local, + arg0: *mut deno_core::v8::fast_api::FastApiTypedArray, + arg1: *mut deno_core::v8::fast_api::FastApiTypedArray, + arg2: *mut deno_core::v8::fast_api::FastApiTypedArray, + arg3: *mut deno_core::v8::fast_api::FastApiTypedArray, + fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, + ) -> () { + let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; + let opctx = unsafe { + &*(deno_core::v8::Local::< + deno_core::v8::External, + >::cast(unsafe { fast_api_callback_options.data.data }) + .value() as *const deno_core::_ops::OpCtx) + }; + deno_core::_ops::dispatch_metrics_fast( &opctx, - deno_core::_ops::OpMetricsEvent::Completed, + deno_core::_ops::OpMetricsEvent::Dispatched, ); - } else { - deno_core::_ops::dispatch_metrics_slow( + let res = Self::v8_fn_ptr_fast(this, arg0, arg1, arg2, arg3); + deno_core::_ops::dispatch_metrics_fast( &opctx, - deno_core::_ops::OpMetricsEvent::Error, + deno_core::_ops::OpMetricsEvent::Completed, ); + res } - } - #[inline(always)] - fn call(_a: &[u32], _b: &mut [u32], _c: *const u32, _d: *mut u32) {} -} - -#[allow(non_camel_case_types)] -struct op_buffers_option { - _unconstructable: ::std::marker::PhantomData<()>, -} -impl ::deno_core::_ops::Op for op_buffers_option { - const NAME: &'static str = stringify!(op_buffers_option); - const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( - ::deno_core::__op_name_fast!(op_buffers_option), - false, - false, - 2usize as u8, - Self::v8_fn_ptr as _, - Self::v8_fn_ptr_metrics as _, - None, - None, - ::deno_core::OpMetadata { - ..::deno_core::OpMetadata::default() - }, - ); -} -impl op_buffers_option { - pub const fn name() -> &'static str { - stringify!(op_buffers_option) - } - #[deprecated(note = "Use the const op::DECL instead")] - pub const fn decl() -> deno_core::_ops::OpDecl { - ::DECL - } - #[inline(always)] - fn slow_function_impl(info: *const deno_core::v8::FunctionCallbackInfo) -> usize { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, - ); - let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { - &*info - }); - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let result = { - let arg0 = args.get(0usize as i32); - let mut arg0_temp; - let arg0 = if arg0.is_null_or_undefined() { - None - } else { - arg0_temp = match unsafe { deno_core::_ops::to_v8_slice::(arg0) } { + #[allow(clippy::too_many_arguments)] + extern "C" fn v8_fn_ptr_fast( + _: deno_core::v8::Local, + arg0: *mut deno_core::v8::fast_api::FastApiTypedArray, + arg1: *mut deno_core::v8::fast_api::FastApiTypedArray, + arg2: *mut deno_core::v8::fast_api::FastApiTypedArray, + arg3: *mut deno_core::v8::fast_api::FastApiTypedArray, + ) -> () { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, + ); + let result = { + let arg0 = unsafe { + deno_core::v8::fast_api::FastApiTypedArray::get_storage_from_pointer_if_aligned( + arg0, + ) + } + .expect("Invalid buffer"); + let arg0 = arg0; + let arg1 = unsafe { + deno_core::v8::fast_api::FastApiTypedArray::get_storage_from_pointer_if_aligned( + arg1, + ) + } + .expect("Invalid buffer"); + let arg1 = arg1; + let arg2 = unsafe { + deno_core::v8::fast_api::FastApiTypedArray::get_storage_from_pointer_if_aligned( + arg2, + ) + } + .expect("Invalid buffer"); + let arg2 = if arg2.len() == 0 { + ::std::ptr::null_mut() + } else { + arg2.as_mut_ptr() as _ + }; + let arg3 = unsafe { + deno_core::v8::fast_api::FastApiTypedArray::get_storage_from_pointer_if_aligned( + arg3, + ) + } + .expect("Invalid buffer"); + let arg3 = if arg3.len() == 0 { + ::std::ptr::null_mut() + } else { + arg3.as_mut_ptr() as _ + }; + Self::call(arg0, arg1, arg2, arg3) + }; + result as _ + } + #[inline(always)] + fn slow_function_impl( + info: *const deno_core::v8::FunctionCallbackInfo, + ) -> usize { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, + ); + let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { + &*info + }); + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let result = { + let arg0 = args.get(0usize as i32); + let mut arg0_temp; + arg0_temp = match unsafe { deno_core::_ops::to_v8_slice::(arg0) } { Ok(arg0) => arg0, Err(arg0_err) => { let mut scope = unsafe { @@ -596,14 +447,9 @@ impl op_buffers_option { } }; let arg0 = arg0_temp.as_ref(); - Some(arg0) - }; - let arg1 = args.get(1usize as i32); - let mut arg1_temp; - let arg1 = if arg1.is_null_or_undefined() { - None - } else { - arg1_temp = match unsafe { deno_core::_ops::to_v8_slice::(arg1) } { + let arg1 = args.get(1usize as i32); + let mut arg1_temp; + arg1_temp = match unsafe { deno_core::_ops::to_v8_slice::(arg1) } { Ok(arg1) => arg1, Err(arg1_err) => { let mut scope = unsafe { @@ -620,42 +466,234 @@ impl op_buffers_option { return 1; } }; - let arg1 = deno_core::serde_v8::JsBuffer::from_parts(arg1_temp); - Some(arg1) + let arg1 = arg1_temp.as_mut(); + let arg2 = args.get(2usize as i32); + let mut arg2_temp; + arg2_temp = match unsafe { deno_core::_ops::to_v8_slice::(arg2) } { + Ok(arg2) => arg2, + Err(arg2_err) => { + let mut scope = unsafe { + deno_core::v8::CallbackScope::new(&*info) + }; + let msg = deno_core::v8::String::new_from_one_byte( + &mut scope, + arg2_err.as_bytes(), + deno_core::v8::NewStringType::Normal, + ) + .unwrap(); + let exc = deno_core::v8::Exception::type_error(&mut scope, msg); + scope.throw_exception(exc); + return 1; + } + }; + let arg2 = if arg2_temp.len() == 0 { + std::ptr::null() + } else { + arg2_temp.as_ref().as_ptr() + }; + let arg3 = args.get(3usize as i32); + let mut arg3_temp; + arg3_temp = match unsafe { deno_core::_ops::to_v8_slice::(arg3) } { + Ok(arg3) => arg3, + Err(arg3_err) => { + let mut scope = unsafe { + deno_core::v8::CallbackScope::new(&*info) + }; + let msg = deno_core::v8::String::new_from_one_byte( + &mut scope, + arg3_err.as_bytes(), + deno_core::v8::NewStringType::Normal, + ) + .unwrap(); + let exc = deno_core::v8::Exception::type_error(&mut scope, msg); + scope.throw_exception(exc); + return 1; + } + }; + let arg3 = if arg3_temp.len() == 0 { + std::ptr::null_mut() + } else { + arg3_temp.as_mut().as_mut_ptr() + }; + Self::call(arg0, arg1, arg2, arg3) + }; + deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv); + return 0; + } + extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { + Self::slow_function_impl(info); + } + extern "C" fn v8_fn_ptr_metrics( + info: *const deno_core::v8::FunctionCallbackInfo, + ) { + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) }; - Self::call(arg0, arg1) - }; - deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv); - return 0; + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Dispatched, + ); + let res = Self::slow_function_impl(info); + if res == 0 { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Completed, + ); + } else { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Error, + ); + } + } + #[inline(always)] + fn call(_a: &[u32], _b: &mut [u32], _c: *const u32, _d: *mut u32) {} } - extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { - Self::slow_function_impl(info); + ::DECL +} + +#[allow(non_camel_case_types)] +const fn op_buffers_option() -> ::deno_core::_ops::OpDecl { + #[allow(non_camel_case_types)] + struct op_buffers_option { + _unconstructable: ::std::marker::PhantomData<()>, } - extern "C" fn v8_fn_ptr_metrics(info: *const deno_core::v8::FunctionCallbackInfo) { - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_slow( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, + impl ::deno_core::_ops::Op for op_buffers_option { + const NAME: &'static str = stringify!(op_buffers_option); + const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( + ::deno_core::__op_name_fast!(op_buffers_option), + false, + false, + 2usize as u8, + Self::v8_fn_ptr as _, + Self::v8_fn_ptr_metrics as _, + None, + None, + ::deno_core::OpMetadata { + ..::deno_core::OpMetadata::default() + }, ); - let res = Self::slow_function_impl(info); - if res == 0 { - deno_core::_ops::dispatch_metrics_slow( - &opctx, - deno_core::_ops::OpMetricsEvent::Completed, + } + impl op_buffers_option { + pub const fn name() -> &'static str { + stringify!(op_buffers_option) + } + #[inline(always)] + fn slow_function_impl( + info: *const deno_core::v8::FunctionCallbackInfo, + ) -> usize { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, ); - } else { + let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { + &*info + }); + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let result = { + let arg0 = args.get(0usize as i32); + let mut arg0_temp; + let arg0 = if arg0.is_null_or_undefined() { + None + } else { + arg0_temp = match unsafe { + deno_core::_ops::to_v8_slice::(arg0) + } { + Ok(arg0) => arg0, + Err(arg0_err) => { + let mut scope = unsafe { + deno_core::v8::CallbackScope::new(&*info) + }; + let msg = deno_core::v8::String::new_from_one_byte( + &mut scope, + arg0_err.as_bytes(), + deno_core::v8::NewStringType::Normal, + ) + .unwrap(); + let exc = deno_core::v8::Exception::type_error( + &mut scope, + msg, + ); + scope.throw_exception(exc); + return 1; + } + }; + let arg0 = arg0_temp.as_ref(); + Some(arg0) + }; + let arg1 = args.get(1usize as i32); + let mut arg1_temp; + let arg1 = if arg1.is_null_or_undefined() { + None + } else { + arg1_temp = match unsafe { + deno_core::_ops::to_v8_slice::(arg1) + } { + Ok(arg1) => arg1, + Err(arg1_err) => { + let mut scope = unsafe { + deno_core::v8::CallbackScope::new(&*info) + }; + let msg = deno_core::v8::String::new_from_one_byte( + &mut scope, + arg1_err.as_bytes(), + deno_core::v8::NewStringType::Normal, + ) + .unwrap(); + let exc = deno_core::v8::Exception::type_error( + &mut scope, + msg, + ); + scope.throw_exception(exc); + return 1; + } + }; + let arg1 = deno_core::serde_v8::JsBuffer::from_parts(arg1_temp); + Some(arg1) + }; + Self::call(arg0, arg1) + }; + deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv); + return 0; + } + extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { + Self::slow_function_impl(info); + } + extern "C" fn v8_fn_ptr_metrics( + info: *const deno_core::v8::FunctionCallbackInfo, + ) { + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; deno_core::_ops::dispatch_metrics_slow( &opctx, - deno_core::_ops::OpMetricsEvent::Error, + deno_core::_ops::OpMetricsEvent::Dispatched, ); + let res = Self::slow_function_impl(info); + if res == 0 { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Completed, + ); + } else { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Error, + ); + } } + #[inline(always)] + fn call(_a: Option<&[u8]>, _b: Option) {} } - #[inline(always)] - fn call(_a: Option<&[u8]>, _b: Option) {} + ::DECL } diff --git a/ops/op2/test_cases/sync/buffers_copy.out b/ops/op2/test_cases/sync/buffers_copy.out index 42f9dfa27..6ed0d3738 100644 --- a/ops/op2/test_cases/sync/buffers_copy.out +++ b/ops/op2/test_cases/sync/buffers_copy.out @@ -1,414 +1,432 @@ #[allow(non_camel_case_types)] -struct op_buffers { - _unconstructable: ::std::marker::PhantomData<()>, -} -impl ::deno_core::_ops::Op for op_buffers { - const NAME: &'static str = stringify!(op_buffers); - const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( - ::deno_core::__op_name_fast!(op_buffers), - false, - false, - 3usize as u8, - Self::v8_fn_ptr as _, - Self::v8_fn_ptr_metrics as _, - Some({ - use deno_core::v8::fast_api::Type; - use deno_core::v8::fast_api::CType; - deno_core::v8::fast_api::FastFunction::new_with_bigint( - &[ - Type::V8Value, - Type::TypedArray(CType::Uint8), - Type::TypedArray(CType::Uint8), - Type::TypedArray(CType::Uint8), - ], - CType::Void, - Self::v8_fn_ptr_fast as *const ::std::ffi::c_void, - ) - }), - Some({ - use deno_core::v8::fast_api::Type; - use deno_core::v8::fast_api::CType; - deno_core::v8::fast_api::FastFunction::new_with_bigint( - &[ - Type::V8Value, - Type::TypedArray(CType::Uint8), - Type::TypedArray(CType::Uint8), - Type::TypedArray(CType::Uint8), - Type::CallbackOptions, - ], - CType::Void, - Self::v8_fn_ptr_fast_metrics as *const ::std::ffi::c_void, - ) - }), - ::deno_core::OpMetadata { - ..::deno_core::OpMetadata::default() - }, - ); -} -impl op_buffers { - pub const fn name() -> &'static str { - stringify!(op_buffers) - } - #[deprecated(note = "Use the const op::DECL instead")] - pub const fn decl() -> deno_core::_ops::OpDecl { - ::DECL +const fn op_buffers() -> ::deno_core::_ops::OpDecl { + #[allow(non_camel_case_types)] + struct op_buffers { + _unconstructable: ::std::marker::PhantomData<()>, } - #[allow(clippy::too_many_arguments)] - extern "C" fn v8_fn_ptr_fast_metrics( - this: deno_core::v8::Local, - arg0: *mut deno_core::v8::fast_api::FastApiTypedArray, - arg1: *mut deno_core::v8::fast_api::FastApiTypedArray, - arg2: *mut deno_core::v8::fast_api::FastApiTypedArray, - fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, - ) -> () { - let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; - let opctx = unsafe { - &*(deno_core::v8::Local::< - deno_core::v8::External, - >::cast(unsafe { fast_api_callback_options.data.data }) - .value() as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_fast( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, - ); - let res = Self::v8_fn_ptr_fast(this, arg0, arg1, arg2); - deno_core::_ops::dispatch_metrics_fast( - &opctx, - deno_core::_ops::OpMetricsEvent::Completed, - ); - res - } - #[allow(clippy::too_many_arguments)] - extern "C" fn v8_fn_ptr_fast( - _: deno_core::v8::Local, - arg0: *mut deno_core::v8::fast_api::FastApiTypedArray, - arg1: *mut deno_core::v8::fast_api::FastApiTypedArray, - arg2: *mut deno_core::v8::fast_api::FastApiTypedArray, - ) -> () { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, - ); - let result = { - let arg0 = unsafe { - deno_core::v8::fast_api::FastApiTypedArray::get_storage_from_pointer_if_aligned( - arg0, - ) - } - .expect("Invalid buffer"); - let arg0 = arg0.to_vec(); - let arg1 = unsafe { - deno_core::v8::fast_api::FastApiTypedArray::get_storage_from_pointer_if_aligned( - arg1, + impl ::deno_core::_ops::Op for op_buffers { + const NAME: &'static str = stringify!(op_buffers); + const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( + ::deno_core::__op_name_fast!(op_buffers), + false, + false, + 3usize as u8, + Self::v8_fn_ptr as _, + Self::v8_fn_ptr_metrics as _, + Some({ + use deno_core::v8::fast_api::Type; + use deno_core::v8::fast_api::CType; + deno_core::v8::fast_api::FastFunction::new_with_bigint( + &[ + Type::V8Value, + Type::TypedArray(CType::Uint8), + Type::TypedArray(CType::Uint8), + Type::TypedArray(CType::Uint8), + ], + CType::Void, + Self::v8_fn_ptr_fast as *const ::std::ffi::c_void, ) - } - .expect("Invalid buffer"); - let arg1 = arg1.to_vec().into_boxed_slice(); - let arg2 = unsafe { - deno_core::v8::fast_api::FastApiTypedArray::get_storage_from_pointer_if_aligned( - arg2, + }), + Some({ + use deno_core::v8::fast_api::Type; + use deno_core::v8::fast_api::CType; + deno_core::v8::fast_api::FastFunction::new_with_bigint( + &[ + Type::V8Value, + Type::TypedArray(CType::Uint8), + Type::TypedArray(CType::Uint8), + Type::TypedArray(CType::Uint8), + Type::CallbackOptions, + ], + CType::Void, + Self::v8_fn_ptr_fast_metrics as *const ::std::ffi::c_void, ) - } - .expect("Invalid buffer"); - let arg2 = arg2.to_vec().into(); - Self::call(arg0, arg1, arg2) - }; - result as _ - } - #[inline(always)] - fn slow_function_impl(info: *const deno_core::v8::FunctionCallbackInfo) -> usize { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, + }), + ::deno_core::OpMetadata { + ..::deno_core::OpMetadata::default() + }, ); - let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { - &*info - }); - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let result = { - let arg0 = args.get(0usize as i32); - let mut arg0_temp; - arg0_temp = match unsafe { deno_core::_ops::to_v8_slice::(arg0) } { - Ok(arg0) => arg0, - Err(arg0_err) => { - let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; - let msg = deno_core::v8::String::new_from_one_byte( - &mut scope, - arg0_err.as_bytes(), - deno_core::v8::NewStringType::Normal, - ) - .unwrap(); - let exc = deno_core::v8::Exception::type_error(&mut scope, msg); - scope.throw_exception(exc); - return 1; - } + } + impl op_buffers { + pub const fn name() -> &'static str { + stringify!(op_buffers) + } + #[allow(clippy::too_many_arguments)] + extern "C" fn v8_fn_ptr_fast_metrics( + this: deno_core::v8::Local, + arg0: *mut deno_core::v8::fast_api::FastApiTypedArray, + arg1: *mut deno_core::v8::fast_api::FastApiTypedArray, + arg2: *mut deno_core::v8::fast_api::FastApiTypedArray, + fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, + ) -> () { + let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; + let opctx = unsafe { + &*(deno_core::v8::Local::< + deno_core::v8::External, + >::cast(unsafe { fast_api_callback_options.data.data }) + .value() as *const deno_core::_ops::OpCtx) }; - let arg0 = arg0_temp.to_vec(); - let arg1 = args.get(1usize as i32); - let mut arg1_temp; - arg1_temp = match unsafe { deno_core::_ops::to_v8_slice::(arg1) } { - Ok(arg1) => arg1, - Err(arg1_err) => { - let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; - let msg = deno_core::v8::String::new_from_one_byte( - &mut scope, - arg1_err.as_bytes(), - deno_core::v8::NewStringType::Normal, - ) - .unwrap(); - let exc = deno_core::v8::Exception::type_error(&mut scope, msg); - scope.throw_exception(exc); - return 1; + deno_core::_ops::dispatch_metrics_fast( + &opctx, + deno_core::_ops::OpMetricsEvent::Dispatched, + ); + let res = Self::v8_fn_ptr_fast(this, arg0, arg1, arg2); + deno_core::_ops::dispatch_metrics_fast( + &opctx, + deno_core::_ops::OpMetricsEvent::Completed, + ); + res + } + #[allow(clippy::too_many_arguments)] + extern "C" fn v8_fn_ptr_fast( + _: deno_core::v8::Local, + arg0: *mut deno_core::v8::fast_api::FastApiTypedArray, + arg1: *mut deno_core::v8::fast_api::FastApiTypedArray, + arg2: *mut deno_core::v8::fast_api::FastApiTypedArray, + ) -> () { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, + ); + let result = { + let arg0 = unsafe { + deno_core::v8::fast_api::FastApiTypedArray::get_storage_from_pointer_if_aligned( + arg0, + ) } - }; - let arg1 = arg1_temp.to_boxed_slice(); - let arg2 = args.get(2usize as i32); - let mut arg2_temp; - arg2_temp = match unsafe { deno_core::_ops::to_v8_slice::(arg2) } { - Ok(arg2) => arg2, - Err(arg2_err) => { - let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; - let msg = deno_core::v8::String::new_from_one_byte( - &mut scope, - arg2_err.as_bytes(), - deno_core::v8::NewStringType::Normal, - ) - .unwrap(); - let exc = deno_core::v8::Exception::type_error(&mut scope, msg); - scope.throw_exception(exc); - return 1; + .expect("Invalid buffer"); + let arg0 = arg0.to_vec(); + let arg1 = unsafe { + deno_core::v8::fast_api::FastApiTypedArray::get_storage_from_pointer_if_aligned( + arg1, + ) } + .expect("Invalid buffer"); + let arg1 = arg1.to_vec().into_boxed_slice(); + let arg2 = unsafe { + deno_core::v8::fast_api::FastApiTypedArray::get_storage_from_pointer_if_aligned( + arg2, + ) + } + .expect("Invalid buffer"); + let arg2 = arg2.to_vec().into(); + Self::call(arg0, arg1, arg2) }; - let arg2 = arg2_temp.to_vec().into(); - Self::call(arg0, arg1, arg2) - }; - deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv); - return 0; - } - extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { - Self::slow_function_impl(info); - } - extern "C" fn v8_fn_ptr_metrics(info: *const deno_core::v8::FunctionCallbackInfo) { - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_slow( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, - ); - let res = Self::slow_function_impl(info); - if res == 0 { - deno_core::_ops::dispatch_metrics_slow( - &opctx, - deno_core::_ops::OpMetricsEvent::Completed, + result as _ + } + #[inline(always)] + fn slow_function_impl( + info: *const deno_core::v8::FunctionCallbackInfo, + ) -> usize { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, ); - } else { + let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { + &*info + }); + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let result = { + let arg0 = args.get(0usize as i32); + let mut arg0_temp; + arg0_temp = match unsafe { deno_core::_ops::to_v8_slice::(arg0) } { + Ok(arg0) => arg0, + Err(arg0_err) => { + let mut scope = unsafe { + deno_core::v8::CallbackScope::new(&*info) + }; + let msg = deno_core::v8::String::new_from_one_byte( + &mut scope, + arg0_err.as_bytes(), + deno_core::v8::NewStringType::Normal, + ) + .unwrap(); + let exc = deno_core::v8::Exception::type_error(&mut scope, msg); + scope.throw_exception(exc); + return 1; + } + }; + let arg0 = arg0_temp.to_vec(); + let arg1 = args.get(1usize as i32); + let mut arg1_temp; + arg1_temp = match unsafe { deno_core::_ops::to_v8_slice::(arg1) } { + Ok(arg1) => arg1, + Err(arg1_err) => { + let mut scope = unsafe { + deno_core::v8::CallbackScope::new(&*info) + }; + let msg = deno_core::v8::String::new_from_one_byte( + &mut scope, + arg1_err.as_bytes(), + deno_core::v8::NewStringType::Normal, + ) + .unwrap(); + let exc = deno_core::v8::Exception::type_error(&mut scope, msg); + scope.throw_exception(exc); + return 1; + } + }; + let arg1 = arg1_temp.to_boxed_slice(); + let arg2 = args.get(2usize as i32); + let mut arg2_temp; + arg2_temp = match unsafe { deno_core::_ops::to_v8_slice::(arg2) } { + Ok(arg2) => arg2, + Err(arg2_err) => { + let mut scope = unsafe { + deno_core::v8::CallbackScope::new(&*info) + }; + let msg = deno_core::v8::String::new_from_one_byte( + &mut scope, + arg2_err.as_bytes(), + deno_core::v8::NewStringType::Normal, + ) + .unwrap(); + let exc = deno_core::v8::Exception::type_error(&mut scope, msg); + scope.throw_exception(exc); + return 1; + } + }; + let arg2 = arg2_temp.to_vec().into(); + Self::call(arg0, arg1, arg2) + }; + deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv); + return 0; + } + extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { + Self::slow_function_impl(info); + } + extern "C" fn v8_fn_ptr_metrics( + info: *const deno_core::v8::FunctionCallbackInfo, + ) { + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; deno_core::_ops::dispatch_metrics_slow( &opctx, - deno_core::_ops::OpMetricsEvent::Error, + deno_core::_ops::OpMetricsEvent::Dispatched, ); + let res = Self::slow_function_impl(info); + if res == 0 { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Completed, + ); + } else { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Error, + ); + } } + #[inline(always)] + fn call(_a: Vec, _b: Box<[u8]>, _c: bytes::Bytes) {} } - #[inline(always)] - fn call(_a: Vec, _b: Box<[u8]>, _c: bytes::Bytes) {} + ::DECL } #[allow(non_camel_case_types)] -struct op_buffers_32 { - _unconstructable: ::std::marker::PhantomData<()>, -} -impl ::deno_core::_ops::Op for op_buffers_32 { - const NAME: &'static str = stringify!(op_buffers_32); - const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( - ::deno_core::__op_name_fast!(op_buffers_32), - false, - false, - 2usize as u8, - Self::v8_fn_ptr as _, - Self::v8_fn_ptr_metrics as _, - Some({ - use deno_core::v8::fast_api::Type; - use deno_core::v8::fast_api::CType; - deno_core::v8::fast_api::FastFunction::new_with_bigint( - &[ - Type::V8Value, - Type::TypedArray(CType::Uint32), - Type::TypedArray(CType::Uint32), - ], - CType::Void, - Self::v8_fn_ptr_fast as *const ::std::ffi::c_void, - ) - }), - Some({ - use deno_core::v8::fast_api::Type; - use deno_core::v8::fast_api::CType; - deno_core::v8::fast_api::FastFunction::new_with_bigint( - &[ - Type::V8Value, - Type::TypedArray(CType::Uint32), - Type::TypedArray(CType::Uint32), - Type::CallbackOptions, - ], - CType::Void, - Self::v8_fn_ptr_fast_metrics as *const ::std::ffi::c_void, - ) - }), - ::deno_core::OpMetadata { - ..::deno_core::OpMetadata::default() - }, - ); -} -impl op_buffers_32 { - pub const fn name() -> &'static str { - stringify!(op_buffers_32) +const fn op_buffers_32() -> ::deno_core::_ops::OpDecl { + #[allow(non_camel_case_types)] + struct op_buffers_32 { + _unconstructable: ::std::marker::PhantomData<()>, } - #[deprecated(note = "Use the const op::DECL instead")] - pub const fn decl() -> deno_core::_ops::OpDecl { - ::DECL - } - #[allow(clippy::too_many_arguments)] - extern "C" fn v8_fn_ptr_fast_metrics( - this: deno_core::v8::Local, - arg0: *mut deno_core::v8::fast_api::FastApiTypedArray, - arg1: *mut deno_core::v8::fast_api::FastApiTypedArray, - fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, - ) -> () { - let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; - let opctx = unsafe { - &*(deno_core::v8::Local::< - deno_core::v8::External, - >::cast(unsafe { fast_api_callback_options.data.data }) - .value() as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_fast( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, - ); - let res = Self::v8_fn_ptr_fast(this, arg0, arg1); - deno_core::_ops::dispatch_metrics_fast( - &opctx, - deno_core::_ops::OpMetricsEvent::Completed, - ); - res - } - #[allow(clippy::too_many_arguments)] - extern "C" fn v8_fn_ptr_fast( - _: deno_core::v8::Local, - arg0: *mut deno_core::v8::fast_api::FastApiTypedArray, - arg1: *mut deno_core::v8::fast_api::FastApiTypedArray, - ) -> () { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, - ); - let result = { - let arg0 = unsafe { - deno_core::v8::fast_api::FastApiTypedArray::get_storage_from_pointer_if_aligned( - arg0, + impl ::deno_core::_ops::Op for op_buffers_32 { + const NAME: &'static str = stringify!(op_buffers_32); + const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( + ::deno_core::__op_name_fast!(op_buffers_32), + false, + false, + 2usize as u8, + Self::v8_fn_ptr as _, + Self::v8_fn_ptr_metrics as _, + Some({ + use deno_core::v8::fast_api::Type; + use deno_core::v8::fast_api::CType; + deno_core::v8::fast_api::FastFunction::new_with_bigint( + &[ + Type::V8Value, + Type::TypedArray(CType::Uint32), + Type::TypedArray(CType::Uint32), + ], + CType::Void, + Self::v8_fn_ptr_fast as *const ::std::ffi::c_void, ) - } - .expect("Invalid buffer"); - let arg0 = arg0.to_vec(); - let arg1 = unsafe { - deno_core::v8::fast_api::FastApiTypedArray::get_storage_from_pointer_if_aligned( - arg1, + }), + Some({ + use deno_core::v8::fast_api::Type; + use deno_core::v8::fast_api::CType; + deno_core::v8::fast_api::FastFunction::new_with_bigint( + &[ + Type::V8Value, + Type::TypedArray(CType::Uint32), + Type::TypedArray(CType::Uint32), + Type::CallbackOptions, + ], + CType::Void, + Self::v8_fn_ptr_fast_metrics as *const ::std::ffi::c_void, ) - } - .expect("Invalid buffer"); - let arg1 = arg1.to_vec().into_boxed_slice(); - Self::call(arg0, arg1) - }; - result as _ - } - #[inline(always)] - fn slow_function_impl(info: *const deno_core::v8::FunctionCallbackInfo) -> usize { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, + }), + ::deno_core::OpMetadata { + ..::deno_core::OpMetadata::default() + }, ); - let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { - &*info - }); - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let result = { - let arg0 = args.get(0usize as i32); - let mut arg0_temp; - arg0_temp = match unsafe { deno_core::_ops::to_v8_slice::(arg0) } { - Ok(arg0) => arg0, - Err(arg0_err) => { - let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; - let msg = deno_core::v8::String::new_from_one_byte( - &mut scope, - arg0_err.as_bytes(), - deno_core::v8::NewStringType::Normal, - ) - .unwrap(); - let exc = deno_core::v8::Exception::type_error(&mut scope, msg); - scope.throw_exception(exc); - return 1; - } - }; - let arg0 = arg0_temp.to_vec(); - let arg1 = args.get(1usize as i32); - let mut arg1_temp; - arg1_temp = match unsafe { deno_core::_ops::to_v8_slice::(arg1) } { - Ok(arg1) => arg1, - Err(arg1_err) => { - let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; - let msg = deno_core::v8::String::new_from_one_byte( - &mut scope, - arg1_err.as_bytes(), - deno_core::v8::NewStringType::Normal, - ) - .unwrap(); - let exc = deno_core::v8::Exception::type_error(&mut scope, msg); - scope.throw_exception(exc); - return 1; - } - }; - let arg1 = arg1_temp.to_boxed_slice(); - Self::call(arg0, arg1) - }; - deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv); - return 0; } - extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { - Self::slow_function_impl(info); - } - extern "C" fn v8_fn_ptr_metrics(info: *const deno_core::v8::FunctionCallbackInfo) { - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_slow( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, - ); - let res = Self::slow_function_impl(info); - if res == 0 { - deno_core::_ops::dispatch_metrics_slow( + impl op_buffers_32 { + pub const fn name() -> &'static str { + stringify!(op_buffers_32) + } + #[allow(clippy::too_many_arguments)] + extern "C" fn v8_fn_ptr_fast_metrics( + this: deno_core::v8::Local, + arg0: *mut deno_core::v8::fast_api::FastApiTypedArray, + arg1: *mut deno_core::v8::fast_api::FastApiTypedArray, + fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, + ) -> () { + let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; + let opctx = unsafe { + &*(deno_core::v8::Local::< + deno_core::v8::External, + >::cast(unsafe { fast_api_callback_options.data.data }) + .value() as *const deno_core::_ops::OpCtx) + }; + deno_core::_ops::dispatch_metrics_fast( + &opctx, + deno_core::_ops::OpMetricsEvent::Dispatched, + ); + let res = Self::v8_fn_ptr_fast(this, arg0, arg1); + deno_core::_ops::dispatch_metrics_fast( &opctx, deno_core::_ops::OpMetricsEvent::Completed, ); - } else { + res + } + #[allow(clippy::too_many_arguments)] + extern "C" fn v8_fn_ptr_fast( + _: deno_core::v8::Local, + arg0: *mut deno_core::v8::fast_api::FastApiTypedArray, + arg1: *mut deno_core::v8::fast_api::FastApiTypedArray, + ) -> () { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, + ); + let result = { + let arg0 = unsafe { + deno_core::v8::fast_api::FastApiTypedArray::get_storage_from_pointer_if_aligned( + arg0, + ) + } + .expect("Invalid buffer"); + let arg0 = arg0.to_vec(); + let arg1 = unsafe { + deno_core::v8::fast_api::FastApiTypedArray::get_storage_from_pointer_if_aligned( + arg1, + ) + } + .expect("Invalid buffer"); + let arg1 = arg1.to_vec().into_boxed_slice(); + Self::call(arg0, arg1) + }; + result as _ + } + #[inline(always)] + fn slow_function_impl( + info: *const deno_core::v8::FunctionCallbackInfo, + ) -> usize { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, + ); + let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { + &*info + }); + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let result = { + let arg0 = args.get(0usize as i32); + let mut arg0_temp; + arg0_temp = match unsafe { deno_core::_ops::to_v8_slice::(arg0) } { + Ok(arg0) => arg0, + Err(arg0_err) => { + let mut scope = unsafe { + deno_core::v8::CallbackScope::new(&*info) + }; + let msg = deno_core::v8::String::new_from_one_byte( + &mut scope, + arg0_err.as_bytes(), + deno_core::v8::NewStringType::Normal, + ) + .unwrap(); + let exc = deno_core::v8::Exception::type_error(&mut scope, msg); + scope.throw_exception(exc); + return 1; + } + }; + let arg0 = arg0_temp.to_vec(); + let arg1 = args.get(1usize as i32); + let mut arg1_temp; + arg1_temp = match unsafe { deno_core::_ops::to_v8_slice::(arg1) } { + Ok(arg1) => arg1, + Err(arg1_err) => { + let mut scope = unsafe { + deno_core::v8::CallbackScope::new(&*info) + }; + let msg = deno_core::v8::String::new_from_one_byte( + &mut scope, + arg1_err.as_bytes(), + deno_core::v8::NewStringType::Normal, + ) + .unwrap(); + let exc = deno_core::v8::Exception::type_error(&mut scope, msg); + scope.throw_exception(exc); + return 1; + } + }; + let arg1 = arg1_temp.to_boxed_slice(); + Self::call(arg0, arg1) + }; + deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv); + return 0; + } + extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { + Self::slow_function_impl(info); + } + extern "C" fn v8_fn_ptr_metrics( + info: *const deno_core::v8::FunctionCallbackInfo, + ) { + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; deno_core::_ops::dispatch_metrics_slow( &opctx, - deno_core::_ops::OpMetricsEvent::Error, + deno_core::_ops::OpMetricsEvent::Dispatched, ); + let res = Self::slow_function_impl(info); + if res == 0 { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Completed, + ); + } else { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Error, + ); + } } + #[inline(always)] + fn call(_a: Vec, _b: Box<[u32]>) {} } - #[inline(always)] - fn call(_a: Vec, _b: Box<[u32]>) {} + ::DECL } diff --git a/ops/op2/test_cases/sync/buffers_out.out b/ops/op2/test_cases/sync/buffers_out.out index 52e1ee3d1..a8c9eb3ec 100644 --- a/ops/op2/test_cases/sync/buffers_out.out +++ b/ops/op2/test_cases/sync/buffers_out.out @@ -1,55 +1,73 @@ #[allow(non_camel_case_types)] -struct op_buffers { - _unconstructable: ::std::marker::PhantomData<()>, -} -impl ::deno_core::_ops::Op for op_buffers { - const NAME: &'static str = stringify!(op_buffers); - const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( - ::deno_core::__op_name_fast!(op_buffers), - false, - false, - 1usize as u8, - Self::v8_fn_ptr as _, - Self::v8_fn_ptr_metrics as _, - None, - None, - ::deno_core::OpMetadata { - ..::deno_core::OpMetadata::default() - }, - ); -} -impl op_buffers { - pub const fn name() -> &'static str { - stringify!(op_buffers) +const fn op_buffers() -> ::deno_core::_ops::OpDecl { + #[allow(non_camel_case_types)] + struct op_buffers { + _unconstructable: ::std::marker::PhantomData<()>, } - #[deprecated(note = "Use the const op::DECL instead")] - pub const fn decl() -> deno_core::_ops::OpDecl { - ::DECL - } - #[inline(always)] - fn slow_function_impl(info: *const deno_core::v8::FunctionCallbackInfo) -> usize { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, + impl ::deno_core::_ops::Op for op_buffers { + const NAME: &'static str = stringify!(op_buffers); + const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( + ::deno_core::__op_name_fast!(op_buffers), + false, + false, + 1usize as u8, + Self::v8_fn_ptr as _, + Self::v8_fn_ptr_metrics as _, + None, + None, + ::deno_core::OpMetadata { + ..::deno_core::OpMetadata::default() + }, ); - let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; - let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { - &*info - }); - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let result = { - let arg0 = args.get(0usize as i32); - let mut arg0_temp; - arg0_temp = match unsafe { deno_core::_ops::to_v8_slice::(arg0) } { - Ok(arg0) => arg0, - Err(arg0_err) => { - let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; - let msg = deno_core::v8::String::new_from_one_byte( + } + impl op_buffers { + pub const fn name() -> &'static str { + stringify!(op_buffers) + } + #[inline(always)] + fn slow_function_impl( + info: *const deno_core::v8::FunctionCallbackInfo, + ) -> usize { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, + ); + let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; + let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { + &*info + }); + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let result = { + let arg0 = args.get(0usize as i32); + let mut arg0_temp; + arg0_temp = match unsafe { deno_core::_ops::to_v8_slice::(arg0) } { + Ok(arg0) => arg0, + Err(arg0_err) => { + let mut scope = unsafe { + deno_core::v8::CallbackScope::new(&*info) + }; + let msg = deno_core::v8::String::new_from_one_byte( + &mut scope, + arg0_err.as_bytes(), + deno_core::v8::NewStringType::Normal, + ) + .unwrap(); + let exc = deno_core::v8::Exception::type_error(&mut scope, msg); + scope.throw_exception(exc); + return 1; + } + }; + let arg0 = deno_core::serde_v8::JsBuffer::from_parts(arg0_temp); + Self::call(arg0) + }; + match deno_core::_ops::RustToV8Fallible::to_v8_fallible(result, &mut scope) { + Ok(v) => rv.set(v), + Err(rv_err) => { + let msg = deno_core::v8::String::new( &mut scope, - arg0_err.as_bytes(), - deno_core::v8::NewStringType::Normal, + &format!("{}", deno_core::anyhow::Error::from(rv_err)), ) .unwrap(); let exc = deno_core::v8::Exception::type_error(&mut scope, msg); @@ -57,106 +75,218 @@ impl op_buffers { return 1; } }; - let arg0 = deno_core::serde_v8::JsBuffer::from_parts(arg0_temp); - Self::call(arg0) - }; - match deno_core::_ops::RustToV8Fallible::to_v8_fallible(result, &mut scope) { - Ok(v) => rv.set(v), - Err(rv_err) => { - let msg = deno_core::v8::String::new( - &mut scope, - &format!("{}", deno_core::anyhow::Error::from(rv_err)), - ) - .unwrap(); - let exc = deno_core::v8::Exception::type_error(&mut scope, msg); - scope.throw_exception(exc); - return 1; + return 0; + } + extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { + Self::slow_function_impl(info); + } + extern "C" fn v8_fn_ptr_metrics( + info: *const deno_core::v8::FunctionCallbackInfo, + ) { + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Dispatched, + ); + let res = Self::slow_function_impl(info); + if res == 0 { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Completed, + ); + } else { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Error, + ); } - }; - return 0; + } + #[inline(always)] + fn call(buffer: JsBuffer) -> JsBuffer { + buffer + } } - extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { - Self::slow_function_impl(info); + ::DECL +} + +#[allow(non_camel_case_types)] +const fn op_buffers_option() -> ::deno_core::_ops::OpDecl { + #[allow(non_camel_case_types)] + struct op_buffers_option { + _unconstructable: ::std::marker::PhantomData<()>, } - extern "C" fn v8_fn_ptr_metrics(info: *const deno_core::v8::FunctionCallbackInfo) { - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_slow( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, + impl ::deno_core::_ops::Op for op_buffers_option { + const NAME: &'static str = stringify!(op_buffers_option); + const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( + ::deno_core::__op_name_fast!(op_buffers_option), + false, + false, + 1usize as u8, + Self::v8_fn_ptr as _, + Self::v8_fn_ptr_metrics as _, + None, + None, + ::deno_core::OpMetadata { + ..::deno_core::OpMetadata::default() + }, ); - let res = Self::slow_function_impl(info); - if res == 0 { - deno_core::_ops::dispatch_metrics_slow( - &opctx, - deno_core::_ops::OpMetricsEvent::Completed, + } + impl op_buffers_option { + pub const fn name() -> &'static str { + stringify!(op_buffers_option) + } + #[inline(always)] + fn slow_function_impl( + info: *const deno_core::v8::FunctionCallbackInfo, + ) -> usize { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, ); - } else { + let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; + let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { + &*info + }); + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let result = { + let arg0 = args.get(0usize as i32); + let mut arg0_temp; + let arg0 = if arg0.is_null_or_undefined() { + None + } else { + arg0_temp = match unsafe { + deno_core::_ops::to_v8_slice::(arg0) + } { + Ok(arg0) => arg0, + Err(arg0_err) => { + let mut scope = unsafe { + deno_core::v8::CallbackScope::new(&*info) + }; + let msg = deno_core::v8::String::new_from_one_byte( + &mut scope, + arg0_err.as_bytes(), + deno_core::v8::NewStringType::Normal, + ) + .unwrap(); + let exc = deno_core::v8::Exception::type_error( + &mut scope, + msg, + ); + scope.throw_exception(exc); + return 1; + } + }; + let arg0 = deno_core::serde_v8::JsBuffer::from_parts(arg0_temp); + Some(arg0) + }; + Self::call(arg0) + }; + match deno_core::_ops::RustToV8Fallible::to_v8_fallible(result, &mut scope) { + Ok(v) => rv.set(v), + Err(rv_err) => { + let msg = deno_core::v8::String::new( + &mut scope, + &format!("{}", deno_core::anyhow::Error::from(rv_err)), + ) + .unwrap(); + let exc = deno_core::v8::Exception::type_error(&mut scope, msg); + scope.throw_exception(exc); + return 1; + } + }; + return 0; + } + extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { + Self::slow_function_impl(info); + } + extern "C" fn v8_fn_ptr_metrics( + info: *const deno_core::v8::FunctionCallbackInfo, + ) { + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; deno_core::_ops::dispatch_metrics_slow( &opctx, - deno_core::_ops::OpMetricsEvent::Error, + deno_core::_ops::OpMetricsEvent::Dispatched, ); + let res = Self::slow_function_impl(info); + if res == 0 { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Completed, + ); + } else { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Error, + ); + } + } + #[inline(always)] + fn call(buffer: Option) -> Option { + buffer } } - #[inline(always)] - fn call(buffer: JsBuffer) -> JsBuffer { - buffer - } + ::DECL } #[allow(non_camel_case_types)] -struct op_buffers_option { - _unconstructable: ::std::marker::PhantomData<()>, -} -impl ::deno_core::_ops::Op for op_buffers_option { - const NAME: &'static str = stringify!(op_buffers_option); - const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( - ::deno_core::__op_name_fast!(op_buffers_option), - false, - false, - 1usize as u8, - Self::v8_fn_ptr as _, - Self::v8_fn_ptr_metrics as _, - None, - None, - ::deno_core::OpMetadata { - ..::deno_core::OpMetadata::default() - }, - ); -} -impl op_buffers_option { - pub const fn name() -> &'static str { - stringify!(op_buffers_option) - } - #[deprecated(note = "Use the const op::DECL instead")] - pub const fn decl() -> deno_core::_ops::OpDecl { - ::DECL +const fn op_arraybuffers() -> ::deno_core::_ops::OpDecl { + #[allow(non_camel_case_types)] + struct op_arraybuffers { + _unconstructable: ::std::marker::PhantomData<()>, } - #[inline(always)] - fn slow_function_impl(info: *const deno_core::v8::FunctionCallbackInfo) -> usize { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, + impl ::deno_core::_ops::Op for op_arraybuffers { + const NAME: &'static str = stringify!(op_arraybuffers); + const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( + ::deno_core::__op_name_fast!(op_arraybuffers), + false, + false, + 1usize as u8, + Self::v8_fn_ptr as _, + Self::v8_fn_ptr_metrics as _, + None, + None, + ::deno_core::OpMetadata { + ..::deno_core::OpMetadata::default() + }, ); - let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; - let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { - &*info - }); - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let result = { - let arg0 = args.get(0usize as i32); - let mut arg0_temp; - let arg0 = if arg0.is_null_or_undefined() { - None - } else { - arg0_temp = match unsafe { deno_core::_ops::to_v8_slice::(arg0) } { + } + impl op_arraybuffers { + pub const fn name() -> &'static str { + stringify!(op_arraybuffers) + } + #[inline(always)] + fn slow_function_impl( + info: *const deno_core::v8::FunctionCallbackInfo, + ) -> usize { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, + ); + let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; + let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { + &*info + }); + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let result = { + let arg0 = args.get(0usize as i32); + let mut arg0_temp; + arg0_temp = match unsafe { deno_core::_ops::to_v8_slice_buffer(arg0) } { Ok(arg0) => arg0, Err(arg0_err) => { let mut scope = unsafe { @@ -174,162 +304,53 @@ impl op_buffers_option { } }; let arg0 = deno_core::serde_v8::JsBuffer::from_parts(arg0_temp); - Some(arg0) + Self::call(arg0) }; - Self::call(arg0) - }; - match deno_core::_ops::RustToV8Fallible::to_v8_fallible(result, &mut scope) { - Ok(v) => rv.set(v), - Err(rv_err) => { - let msg = deno_core::v8::String::new( - &mut scope, - &format!("{}", deno_core::anyhow::Error::from(rv_err)), - ) - .unwrap(); - let exc = deno_core::v8::Exception::type_error(&mut scope, msg); - scope.throw_exception(exc); - return 1; - } - }; - return 0; - } - extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { - Self::slow_function_impl(info); - } - extern "C" fn v8_fn_ptr_metrics(info: *const deno_core::v8::FunctionCallbackInfo) { - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_slow( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, - ); - let res = Self::slow_function_impl(info); - if res == 0 { - deno_core::_ops::dispatch_metrics_slow( - &opctx, - deno_core::_ops::OpMetricsEvent::Completed, - ); - } else { - deno_core::_ops::dispatch_metrics_slow( - &opctx, - deno_core::_ops::OpMetricsEvent::Error, + rv.set( + deno_core::_ops::RustToV8::to_v8( + deno_core::_ops::RustToV8Marker::< + deno_core::_ops::ArrayBufferMarker, + _, + >::from(result), + &mut scope, + ), ); + return 0; } - } - #[inline(always)] - fn call(buffer: Option) -> Option { - buffer - } -} - -#[allow(non_camel_case_types)] -struct op_arraybuffers { - _unconstructable: ::std::marker::PhantomData<()>, -} -impl ::deno_core::_ops::Op for op_arraybuffers { - const NAME: &'static str = stringify!(op_arraybuffers); - const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( - ::deno_core::__op_name_fast!(op_arraybuffers), - false, - false, - 1usize as u8, - Self::v8_fn_ptr as _, - Self::v8_fn_ptr_metrics as _, - None, - None, - ::deno_core::OpMetadata { - ..::deno_core::OpMetadata::default() - }, - ); -} -impl op_arraybuffers { - pub const fn name() -> &'static str { - stringify!(op_arraybuffers) - } - #[deprecated(note = "Use the const op::DECL instead")] - pub const fn decl() -> deno_core::_ops::OpDecl { - ::DECL - } - #[inline(always)] - fn slow_function_impl(info: *const deno_core::v8::FunctionCallbackInfo) -> usize { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, - ); - let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; - let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { - &*info - }); - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let result = { - let arg0 = args.get(0usize as i32); - let mut arg0_temp; - arg0_temp = match unsafe { deno_core::_ops::to_v8_slice_buffer(arg0) } { - Ok(arg0) => arg0, - Err(arg0_err) => { - let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; - let msg = deno_core::v8::String::new_from_one_byte( - &mut scope, - arg0_err.as_bytes(), - deno_core::v8::NewStringType::Normal, - ) - .unwrap(); - let exc = deno_core::v8::Exception::type_error(&mut scope, msg); - scope.throw_exception(exc); - return 1; - } + extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { + Self::slow_function_impl(info); + } + extern "C" fn v8_fn_ptr_metrics( + info: *const deno_core::v8::FunctionCallbackInfo, + ) { + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) }; - let arg0 = deno_core::serde_v8::JsBuffer::from_parts(arg0_temp); - Self::call(arg0) - }; - rv.set( - deno_core::_ops::RustToV8::to_v8( - deno_core::_ops::RustToV8Marker::< - deno_core::_ops::ArrayBufferMarker, - _, - >::from(result), - &mut scope, - ), - ); - return 0; - } - extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { - Self::slow_function_impl(info); - } - extern "C" fn v8_fn_ptr_metrics(info: *const deno_core::v8::FunctionCallbackInfo) { - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_slow( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, - ); - let res = Self::slow_function_impl(info); - if res == 0 { deno_core::_ops::dispatch_metrics_slow( &opctx, - deno_core::_ops::OpMetricsEvent::Completed, - ); - } else { - deno_core::_ops::dispatch_metrics_slow( - &opctx, - deno_core::_ops::OpMetricsEvent::Error, + deno_core::_ops::OpMetricsEvent::Dispatched, ); + let res = Self::slow_function_impl(info); + if res == 0 { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Completed, + ); + } else { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Error, + ); + } + } + #[inline(always)] + fn call(buffer: JsBuffer) -> JsBuffer { + buffer } } - #[inline(always)] - fn call(buffer: JsBuffer) -> JsBuffer { - buffer - } + ::DECL } diff --git a/ops/op2/test_cases/sync/cfg.out b/ops/op2/test_cases/sync/cfg.out index 006a549cf..e6cc7702d 100644 --- a/ops/op2/test_cases/sync/cfg.out +++ b/ops/op2/test_cases/sync/cfg.out @@ -1,249 +1,261 @@ #[allow(non_camel_case_types)] -/// This is a doc comment. -#[cfg(windows)] -pub struct op_maybe_windows { - _unconstructable: ::std::marker::PhantomData<()>, -} -impl ::deno_core::_ops::Op for op_maybe_windows { - const NAME: &'static str = stringify!(op_maybe_windows); - const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( - ::deno_core::__op_name_fast!(op_maybe_windows), - false, - false, - 0usize as u8, - Self::v8_fn_ptr as _, - Self::v8_fn_ptr_metrics as _, - Some({ - use deno_core::v8::fast_api::Type; - use deno_core::v8::fast_api::CType; - deno_core::v8::fast_api::FastFunction::new_with_bigint( - &[Type::V8Value], - CType::Void, - Self::v8_fn_ptr_fast as *const ::std::ffi::c_void, - ) - }), - Some({ - use deno_core::v8::fast_api::Type; - use deno_core::v8::fast_api::CType; - deno_core::v8::fast_api::FastFunction::new_with_bigint( - &[Type::V8Value, Type::CallbackOptions], - CType::Void, - Self::v8_fn_ptr_fast_metrics as *const ::std::ffi::c_void, - ) - }), - ::deno_core::OpMetadata { - ..::deno_core::OpMetadata::default() - }, - ); -} -impl op_maybe_windows { - pub const fn name() -> &'static str { - stringify!(op_maybe_windows) - } - #[deprecated(note = "Use the const op::DECL instead")] - pub const fn decl() -> deno_core::_ops::OpDecl { - ::DECL - } - #[allow(clippy::too_many_arguments)] - extern "C" fn v8_fn_ptr_fast_metrics( - this: deno_core::v8::Local, - fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, - ) -> () { - let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; - let opctx = unsafe { - &*(deno_core::v8::Local::< - deno_core::v8::External, - >::cast(unsafe { fast_api_callback_options.data.data }) - .value() as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_fast( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, - ); - let res = Self::v8_fn_ptr_fast(this); - deno_core::_ops::dispatch_metrics_fast( - &opctx, - deno_core::_ops::OpMetricsEvent::Completed, - ); - res - } - #[allow(clippy::too_many_arguments)] - extern "C" fn v8_fn_ptr_fast(_: deno_core::v8::Local) -> () { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, - ); - let result = { Self::call() }; - result as _ +pub const fn op_maybe_windows() -> ::deno_core::_ops::OpDecl { + #[allow(non_camel_case_types)] + /// This is a doc comment. + #[cfg(windows)] + pub struct op_maybe_windows { + _unconstructable: ::std::marker::PhantomData<()>, } - #[inline(always)] - fn slow_function_impl(info: *const deno_core::v8::FunctionCallbackInfo) -> usize { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, + impl ::deno_core::_ops::Op for op_maybe_windows { + const NAME: &'static str = stringify!(op_maybe_windows); + const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( + ::deno_core::__op_name_fast!(op_maybe_windows), + false, + false, + 0usize as u8, + Self::v8_fn_ptr as _, + Self::v8_fn_ptr_metrics as _, + Some({ + use deno_core::v8::fast_api::Type; + use deno_core::v8::fast_api::CType; + deno_core::v8::fast_api::FastFunction::new_with_bigint( + &[Type::V8Value], + CType::Void, + Self::v8_fn_ptr_fast as *const ::std::ffi::c_void, + ) + }), + Some({ + use deno_core::v8::fast_api::Type; + use deno_core::v8::fast_api::CType; + deno_core::v8::fast_api::FastFunction::new_with_bigint( + &[Type::V8Value, Type::CallbackOptions], + CType::Void, + Self::v8_fn_ptr_fast_metrics as *const ::std::ffi::c_void, + ) + }), + ::deno_core::OpMetadata { + ..::deno_core::OpMetadata::default() + }, ); - let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { - &*info - }); - let result = { Self::call() }; - deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv); - return 0; - } - extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { - Self::slow_function_impl(info); } - extern "C" fn v8_fn_ptr_metrics(info: *const deno_core::v8::FunctionCallbackInfo) { - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_slow( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, - ); - let res = Self::slow_function_impl(info); - if res == 0 { - deno_core::_ops::dispatch_metrics_slow( + impl op_maybe_windows { + pub const fn name() -> &'static str { + stringify!(op_maybe_windows) + } + #[allow(clippy::too_many_arguments)] + extern "C" fn v8_fn_ptr_fast_metrics( + this: deno_core::v8::Local, + fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, + ) -> () { + let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; + let opctx = unsafe { + &*(deno_core::v8::Local::< + deno_core::v8::External, + >::cast(unsafe { fast_api_callback_options.data.data }) + .value() as *const deno_core::_ops::OpCtx) + }; + deno_core::_ops::dispatch_metrics_fast( + &opctx, + deno_core::_ops::OpMetricsEvent::Dispatched, + ); + let res = Self::v8_fn_ptr_fast(this); + deno_core::_ops::dispatch_metrics_fast( &opctx, deno_core::_ops::OpMetricsEvent::Completed, ); - } else { + res + } + #[allow(clippy::too_many_arguments)] + extern "C" fn v8_fn_ptr_fast( + _: deno_core::v8::Local, + ) -> () { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, + ); + let result = { Self::call() }; + result as _ + } + #[inline(always)] + fn slow_function_impl( + info: *const deno_core::v8::FunctionCallbackInfo, + ) -> usize { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, + ); + let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { + &*info + }); + let result = { Self::call() }; + deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv); + return 0; + } + extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { + Self::slow_function_impl(info); + } + extern "C" fn v8_fn_ptr_metrics( + info: *const deno_core::v8::FunctionCallbackInfo, + ) { + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; deno_core::_ops::dispatch_metrics_slow( &opctx, - deno_core::_ops::OpMetricsEvent::Error, + deno_core::_ops::OpMetricsEvent::Dispatched, ); + let res = Self::slow_function_impl(info); + if res == 0 { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Completed, + ); + } else { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Error, + ); + } } + #[inline(always)] + /// This is a doc comment. + #[cfg(windows)] + pub fn call() -> () {} } - #[inline(always)] - /// This is a doc comment. - #[cfg(windows)] - pub fn call() -> () {} + ::DECL } #[allow(non_camel_case_types)] -/// This is a doc comment. -#[cfg(not(windows))] -pub struct op_maybe_windows { - _unconstructable: ::std::marker::PhantomData<()>, -} -impl ::deno_core::_ops::Op for op_maybe_windows { - const NAME: &'static str = stringify!(op_maybe_windows); - const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( - ::deno_core::__op_name_fast!(op_maybe_windows), - false, - false, - 0usize as u8, - Self::v8_fn_ptr as _, - Self::v8_fn_ptr_metrics as _, - Some({ - use deno_core::v8::fast_api::Type; - use deno_core::v8::fast_api::CType; - deno_core::v8::fast_api::FastFunction::new_with_bigint( - &[Type::V8Value], - CType::Void, - Self::v8_fn_ptr_fast as *const ::std::ffi::c_void, - ) - }), - Some({ - use deno_core::v8::fast_api::Type; - use deno_core::v8::fast_api::CType; - deno_core::v8::fast_api::FastFunction::new_with_bigint( - &[Type::V8Value, Type::CallbackOptions], - CType::Void, - Self::v8_fn_ptr_fast_metrics as *const ::std::ffi::c_void, - ) - }), - ::deno_core::OpMetadata { - ..::deno_core::OpMetadata::default() - }, - ); -} -impl op_maybe_windows { - pub const fn name() -> &'static str { - stringify!(op_maybe_windows) - } - #[deprecated(note = "Use the const op::DECL instead")] - pub const fn decl() -> deno_core::_ops::OpDecl { - ::DECL - } - #[allow(clippy::too_many_arguments)] - extern "C" fn v8_fn_ptr_fast_metrics( - this: deno_core::v8::Local, - fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, - ) -> () { - let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; - let opctx = unsafe { - &*(deno_core::v8::Local::< - deno_core::v8::External, - >::cast(unsafe { fast_api_callback_options.data.data }) - .value() as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_fast( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, - ); - let res = Self::v8_fn_ptr_fast(this); - deno_core::_ops::dispatch_metrics_fast( - &opctx, - deno_core::_ops::OpMetricsEvent::Completed, - ); - res - } - #[allow(clippy::too_many_arguments)] - extern "C" fn v8_fn_ptr_fast(_: deno_core::v8::Local) -> () { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, - ); - let result = { Self::call() }; - result as _ +pub const fn op_maybe_windows() -> ::deno_core::_ops::OpDecl { + #[allow(non_camel_case_types)] + /// This is a doc comment. + #[cfg(not(windows))] + pub struct op_maybe_windows { + _unconstructable: ::std::marker::PhantomData<()>, } - #[inline(always)] - fn slow_function_impl(info: *const deno_core::v8::FunctionCallbackInfo) -> usize { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, + impl ::deno_core::_ops::Op for op_maybe_windows { + const NAME: &'static str = stringify!(op_maybe_windows); + const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( + ::deno_core::__op_name_fast!(op_maybe_windows), + false, + false, + 0usize as u8, + Self::v8_fn_ptr as _, + Self::v8_fn_ptr_metrics as _, + Some({ + use deno_core::v8::fast_api::Type; + use deno_core::v8::fast_api::CType; + deno_core::v8::fast_api::FastFunction::new_with_bigint( + &[Type::V8Value], + CType::Void, + Self::v8_fn_ptr_fast as *const ::std::ffi::c_void, + ) + }), + Some({ + use deno_core::v8::fast_api::Type; + use deno_core::v8::fast_api::CType; + deno_core::v8::fast_api::FastFunction::new_with_bigint( + &[Type::V8Value, Type::CallbackOptions], + CType::Void, + Self::v8_fn_ptr_fast_metrics as *const ::std::ffi::c_void, + ) + }), + ::deno_core::OpMetadata { + ..::deno_core::OpMetadata::default() + }, ); - let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { - &*info - }); - let result = { Self::call() }; - deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv); - return 0; - } - extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { - Self::slow_function_impl(info); } - extern "C" fn v8_fn_ptr_metrics(info: *const deno_core::v8::FunctionCallbackInfo) { - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_slow( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, - ); - let res = Self::slow_function_impl(info); - if res == 0 { - deno_core::_ops::dispatch_metrics_slow( + impl op_maybe_windows { + pub const fn name() -> &'static str { + stringify!(op_maybe_windows) + } + #[allow(clippy::too_many_arguments)] + extern "C" fn v8_fn_ptr_fast_metrics( + this: deno_core::v8::Local, + fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, + ) -> () { + let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; + let opctx = unsafe { + &*(deno_core::v8::Local::< + deno_core::v8::External, + >::cast(unsafe { fast_api_callback_options.data.data }) + .value() as *const deno_core::_ops::OpCtx) + }; + deno_core::_ops::dispatch_metrics_fast( + &opctx, + deno_core::_ops::OpMetricsEvent::Dispatched, + ); + let res = Self::v8_fn_ptr_fast(this); + deno_core::_ops::dispatch_metrics_fast( &opctx, deno_core::_ops::OpMetricsEvent::Completed, ); - } else { + res + } + #[allow(clippy::too_many_arguments)] + extern "C" fn v8_fn_ptr_fast( + _: deno_core::v8::Local, + ) -> () { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, + ); + let result = { Self::call() }; + result as _ + } + #[inline(always)] + fn slow_function_impl( + info: *const deno_core::v8::FunctionCallbackInfo, + ) -> usize { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, + ); + let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { + &*info + }); + let result = { Self::call() }; + deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv); + return 0; + } + extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { + Self::slow_function_impl(info); + } + extern "C" fn v8_fn_ptr_metrics( + info: *const deno_core::v8::FunctionCallbackInfo, + ) { + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; deno_core::_ops::dispatch_metrics_slow( &opctx, - deno_core::_ops::OpMetricsEvent::Error, + deno_core::_ops::OpMetricsEvent::Dispatched, ); + let res = Self::slow_function_impl(info); + if res == 0 { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Completed, + ); + } else { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Error, + ); + } } + #[inline(always)] + /// This is a doc comment. + #[cfg(not(windows))] + pub fn call() -> () {} } - #[inline(always)] - /// This is a doc comment. - #[cfg(not(windows))] - pub fn call() -> () {} + ::DECL } diff --git a/ops/op2/test_cases/sync/clippy_allow.out b/ops/op2/test_cases/sync/clippy_allow.out index a9c89a83b..1b62b8fd9 100644 --- a/ops/op2/test_cases/sync/clippy_allow.out +++ b/ops/op2/test_cases/sync/clippy_allow.out @@ -1,247 +1,259 @@ #[allow(non_camel_case_types)] -/// This is a doc comment. -#[allow(clippy::some_annotation)] -pub struct op_extra_annotation { - _unconstructable: ::std::marker::PhantomData<()>, -} -impl ::deno_core::_ops::Op for op_extra_annotation { - const NAME: &'static str = stringify!(op_extra_annotation); - const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( - ::deno_core::__op_name_fast!(op_extra_annotation), - false, - false, - 0usize as u8, - Self::v8_fn_ptr as _, - Self::v8_fn_ptr_metrics as _, - Some({ - use deno_core::v8::fast_api::Type; - use deno_core::v8::fast_api::CType; - deno_core::v8::fast_api::FastFunction::new_with_bigint( - &[Type::V8Value], - CType::Void, - Self::v8_fn_ptr_fast as *const ::std::ffi::c_void, - ) - }), - Some({ - use deno_core::v8::fast_api::Type; - use deno_core::v8::fast_api::CType; - deno_core::v8::fast_api::FastFunction::new_with_bigint( - &[Type::V8Value, Type::CallbackOptions], - CType::Void, - Self::v8_fn_ptr_fast_metrics as *const ::std::ffi::c_void, - ) - }), - ::deno_core::OpMetadata { - ..::deno_core::OpMetadata::default() - }, - ); -} -impl op_extra_annotation { - pub const fn name() -> &'static str { - stringify!(op_extra_annotation) - } - #[deprecated(note = "Use the const op::DECL instead")] - pub const fn decl() -> deno_core::_ops::OpDecl { - ::DECL - } - #[allow(clippy::too_many_arguments)] - extern "C" fn v8_fn_ptr_fast_metrics( - this: deno_core::v8::Local, - fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, - ) -> () { - let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; - let opctx = unsafe { - &*(deno_core::v8::Local::< - deno_core::v8::External, - >::cast(unsafe { fast_api_callback_options.data.data }) - .value() as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_fast( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, - ); - let res = Self::v8_fn_ptr_fast(this); - deno_core::_ops::dispatch_metrics_fast( - &opctx, - deno_core::_ops::OpMetricsEvent::Completed, - ); - res - } - #[allow(clippy::too_many_arguments)] - extern "C" fn v8_fn_ptr_fast(_: deno_core::v8::Local) -> () { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, - ); - let result = { Self::call() }; - result as _ +pub const fn op_extra_annotation() -> ::deno_core::_ops::OpDecl { + #[allow(non_camel_case_types)] + /// This is a doc comment. + #[allow(clippy::some_annotation)] + pub struct op_extra_annotation { + _unconstructable: ::std::marker::PhantomData<()>, } - #[inline(always)] - fn slow_function_impl(info: *const deno_core::v8::FunctionCallbackInfo) -> usize { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, + impl ::deno_core::_ops::Op for op_extra_annotation { + const NAME: &'static str = stringify!(op_extra_annotation); + const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( + ::deno_core::__op_name_fast!(op_extra_annotation), + false, + false, + 0usize as u8, + Self::v8_fn_ptr as _, + Self::v8_fn_ptr_metrics as _, + Some({ + use deno_core::v8::fast_api::Type; + use deno_core::v8::fast_api::CType; + deno_core::v8::fast_api::FastFunction::new_with_bigint( + &[Type::V8Value], + CType::Void, + Self::v8_fn_ptr_fast as *const ::std::ffi::c_void, + ) + }), + Some({ + use deno_core::v8::fast_api::Type; + use deno_core::v8::fast_api::CType; + deno_core::v8::fast_api::FastFunction::new_with_bigint( + &[Type::V8Value, Type::CallbackOptions], + CType::Void, + Self::v8_fn_ptr_fast_metrics as *const ::std::ffi::c_void, + ) + }), + ::deno_core::OpMetadata { + ..::deno_core::OpMetadata::default() + }, ); - let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { - &*info - }); - let result = { Self::call() }; - deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv); - return 0; - } - extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { - Self::slow_function_impl(info); } - extern "C" fn v8_fn_ptr_metrics(info: *const deno_core::v8::FunctionCallbackInfo) { - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_slow( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, - ); - let res = Self::slow_function_impl(info); - if res == 0 { - deno_core::_ops::dispatch_metrics_slow( + impl op_extra_annotation { + pub const fn name() -> &'static str { + stringify!(op_extra_annotation) + } + #[allow(clippy::too_many_arguments)] + extern "C" fn v8_fn_ptr_fast_metrics( + this: deno_core::v8::Local, + fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, + ) -> () { + let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; + let opctx = unsafe { + &*(deno_core::v8::Local::< + deno_core::v8::External, + >::cast(unsafe { fast_api_callback_options.data.data }) + .value() as *const deno_core::_ops::OpCtx) + }; + deno_core::_ops::dispatch_metrics_fast( + &opctx, + deno_core::_ops::OpMetricsEvent::Dispatched, + ); + let res = Self::v8_fn_ptr_fast(this); + deno_core::_ops::dispatch_metrics_fast( &opctx, deno_core::_ops::OpMetricsEvent::Completed, ); - } else { + res + } + #[allow(clippy::too_many_arguments)] + extern "C" fn v8_fn_ptr_fast( + _: deno_core::v8::Local, + ) -> () { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, + ); + let result = { Self::call() }; + result as _ + } + #[inline(always)] + fn slow_function_impl( + info: *const deno_core::v8::FunctionCallbackInfo, + ) -> usize { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, + ); + let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { + &*info + }); + let result = { Self::call() }; + deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv); + return 0; + } + extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { + Self::slow_function_impl(info); + } + extern "C" fn v8_fn_ptr_metrics( + info: *const deno_core::v8::FunctionCallbackInfo, + ) { + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; deno_core::_ops::dispatch_metrics_slow( &opctx, - deno_core::_ops::OpMetricsEvent::Error, + deno_core::_ops::OpMetricsEvent::Dispatched, ); + let res = Self::slow_function_impl(info); + if res == 0 { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Completed, + ); + } else { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Error, + ); + } } + #[inline(always)] + /// This is a doc comment. + #[allow(clippy::some_annotation)] + pub fn call() -> () {} } - #[inline(always)] - /// This is a doc comment. - #[allow(clippy::some_annotation)] - pub fn call() -> () {} + ::DECL } #[allow(non_camel_case_types)] -pub struct op_clippy_internal { - _unconstructable: ::std::marker::PhantomData<()>, -} -impl ::deno_core::_ops::Op for op_clippy_internal { - const NAME: &'static str = stringify!(op_clippy_internal); - const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( - ::deno_core::__op_name_fast!(op_clippy_internal), - false, - false, - 0usize as u8, - Self::v8_fn_ptr as _, - Self::v8_fn_ptr_metrics as _, - Some({ - use deno_core::v8::fast_api::Type; - use deno_core::v8::fast_api::CType; - deno_core::v8::fast_api::FastFunction::new_with_bigint( - &[Type::V8Value], - CType::Void, - Self::v8_fn_ptr_fast as *const ::std::ffi::c_void, - ) - }), - Some({ - use deno_core::v8::fast_api::Type; - use deno_core::v8::fast_api::CType; - deno_core::v8::fast_api::FastFunction::new_with_bigint( - &[Type::V8Value, Type::CallbackOptions], - CType::Void, - Self::v8_fn_ptr_fast_metrics as *const ::std::ffi::c_void, - ) - }), - ::deno_core::OpMetadata { - ..::deno_core::OpMetadata::default() - }, - ); -} -impl op_clippy_internal { - pub const fn name() -> &'static str { - stringify!(op_clippy_internal) - } - #[deprecated(note = "Use the const op::DECL instead")] - pub const fn decl() -> deno_core::_ops::OpDecl { - ::DECL - } - #[allow(clippy::too_many_arguments)] - extern "C" fn v8_fn_ptr_fast_metrics( - this: deno_core::v8::Local, - fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, - ) -> () { - let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; - let opctx = unsafe { - &*(deno_core::v8::Local::< - deno_core::v8::External, - >::cast(unsafe { fast_api_callback_options.data.data }) - .value() as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_fast( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, - ); - let res = Self::v8_fn_ptr_fast(this); - deno_core::_ops::dispatch_metrics_fast( - &opctx, - deno_core::_ops::OpMetricsEvent::Completed, - ); - res - } - #[allow(clippy::too_many_arguments)] - extern "C" fn v8_fn_ptr_fast(_: deno_core::v8::Local) -> () { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, - ); - let result = { Self::call() }; - result as _ +pub const fn op_clippy_internal() -> ::deno_core::_ops::OpDecl { + #[allow(non_camel_case_types)] + pub struct op_clippy_internal { + _unconstructable: ::std::marker::PhantomData<()>, } - #[inline(always)] - fn slow_function_impl(info: *const deno_core::v8::FunctionCallbackInfo) -> usize { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, + impl ::deno_core::_ops::Op for op_clippy_internal { + const NAME: &'static str = stringify!(op_clippy_internal); + const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( + ::deno_core::__op_name_fast!(op_clippy_internal), + false, + false, + 0usize as u8, + Self::v8_fn_ptr as _, + Self::v8_fn_ptr_metrics as _, + Some({ + use deno_core::v8::fast_api::Type; + use deno_core::v8::fast_api::CType; + deno_core::v8::fast_api::FastFunction::new_with_bigint( + &[Type::V8Value], + CType::Void, + Self::v8_fn_ptr_fast as *const ::std::ffi::c_void, + ) + }), + Some({ + use deno_core::v8::fast_api::Type; + use deno_core::v8::fast_api::CType; + deno_core::v8::fast_api::FastFunction::new_with_bigint( + &[Type::V8Value, Type::CallbackOptions], + CType::Void, + Self::v8_fn_ptr_fast_metrics as *const ::std::ffi::c_void, + ) + }), + ::deno_core::OpMetadata { + ..::deno_core::OpMetadata::default() + }, ); - let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { - &*info - }); - let result = { Self::call() }; - deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv); - return 0; } - extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { - Self::slow_function_impl(info); - } - extern "C" fn v8_fn_ptr_metrics(info: *const deno_core::v8::FunctionCallbackInfo) { - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_slow( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, - ); - let res = Self::slow_function_impl(info); - if res == 0 { - deno_core::_ops::dispatch_metrics_slow( + impl op_clippy_internal { + pub const fn name() -> &'static str { + stringify!(op_clippy_internal) + } + #[allow(clippy::too_many_arguments)] + extern "C" fn v8_fn_ptr_fast_metrics( + this: deno_core::v8::Local, + fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, + ) -> () { + let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; + let opctx = unsafe { + &*(deno_core::v8::Local::< + deno_core::v8::External, + >::cast(unsafe { fast_api_callback_options.data.data }) + .value() as *const deno_core::_ops::OpCtx) + }; + deno_core::_ops::dispatch_metrics_fast( + &opctx, + deno_core::_ops::OpMetricsEvent::Dispatched, + ); + let res = Self::v8_fn_ptr_fast(this); + deno_core::_ops::dispatch_metrics_fast( &opctx, deno_core::_ops::OpMetricsEvent::Completed, ); - } else { + res + } + #[allow(clippy::too_many_arguments)] + extern "C" fn v8_fn_ptr_fast( + _: deno_core::v8::Local, + ) -> () { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, + ); + let result = { Self::call() }; + result as _ + } + #[inline(always)] + fn slow_function_impl( + info: *const deno_core::v8::FunctionCallbackInfo, + ) -> usize { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, + ); + let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { + &*info + }); + let result = { Self::call() }; + deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv); + return 0; + } + extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { + Self::slow_function_impl(info); + } + extern "C" fn v8_fn_ptr_metrics( + info: *const deno_core::v8::FunctionCallbackInfo, + ) { + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; deno_core::_ops::dispatch_metrics_slow( &opctx, - deno_core::_ops::OpMetricsEvent::Error, + deno_core::_ops::OpMetricsEvent::Dispatched, ); + let res = Self::slow_function_impl(info); + if res == 0 { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Completed, + ); + } else { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Error, + ); + } + } + #[inline(always)] + pub fn call() -> () { + { #![allow(clippy::await_holding_refcell_ref)] } } } - #[inline(always)] - pub fn call() -> () { - { #![allow(clippy::await_holding_refcell_ref)] } - } + ::DECL } diff --git a/ops/op2/test_cases/sync/cppgc_resource.out b/ops/op2/test_cases/sync/cppgc_resource.out index dea8d635d..e505b9bf3 100644 --- a/ops/op2/test_cases/sync/cppgc_resource.out +++ b/ops/op2/test_cases/sync/cppgc_resource.out @@ -1,302 +1,201 @@ #[allow(non_camel_case_types)] -struct op_file { - _unconstructable: ::std::marker::PhantomData<()>, -} -impl ::deno_core::_ops::Op for op_file { - const NAME: &'static str = stringify!(op_file); - const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( - ::deno_core::__op_name_fast!(op_file), - false, - false, - 1usize as u8, - Self::v8_fn_ptr as _, - Self::v8_fn_ptr_metrics as _, - Some({ - use deno_core::v8::fast_api::Type; - use deno_core::v8::fast_api::CType; - deno_core::v8::fast_api::FastFunction::new_with_bigint( - &[Type::V8Value, Type::V8Value, Type::CallbackOptions], - CType::Void, - Self::v8_fn_ptr_fast as *const ::std::ffi::c_void, - ) - }), - Some({ - use deno_core::v8::fast_api::Type; - use deno_core::v8::fast_api::CType; - deno_core::v8::fast_api::FastFunction::new_with_bigint( - &[Type::V8Value, Type::V8Value, Type::CallbackOptions], - CType::Void, - Self::v8_fn_ptr_fast_metrics as *const ::std::ffi::c_void, - ) - }), - ::deno_core::OpMetadata { - ..::deno_core::OpMetadata::default() - }, - ); -} -impl op_file { - pub const fn name() -> &'static str { - stringify!(op_file) - } - #[deprecated(note = "Use the const op::DECL instead")] - pub const fn decl() -> deno_core::_ops::OpDecl { - ::DECL - } - #[allow(clippy::too_many_arguments)] - extern "C" fn v8_fn_ptr_fast_metrics( - this: deno_core::v8::Local, - arg0: deno_core::v8::Local, - fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, - ) -> () { - let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; - let opctx = unsafe { - &*(deno_core::v8::Local::< - deno_core::v8::External, - >::cast(unsafe { fast_api_callback_options.data.data }) - .value() as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_fast( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, - ); - let res = Self::v8_fn_ptr_fast(this, arg0, fast_api_callback_options); - deno_core::_ops::dispatch_metrics_fast( - &opctx, - deno_core::_ops::OpMetricsEvent::Completed, - ); - res +const fn op_file() -> ::deno_core::_ops::OpDecl { + #[allow(non_camel_case_types)] + struct op_file { + _unconstructable: ::std::marker::PhantomData<()>, } - #[allow(clippy::too_many_arguments)] - extern "C" fn v8_fn_ptr_fast( - _: deno_core::v8::Local, - arg0: deno_core::v8::Local, - fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, - ) -> () { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, + impl ::deno_core::_ops::Op for op_file { + const NAME: &'static str = stringify!(op_file); + const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( + ::deno_core::__op_name_fast!(op_file), + false, + false, + 1usize as u8, + Self::v8_fn_ptr as _, + Self::v8_fn_ptr_metrics as _, + Some({ + use deno_core::v8::fast_api::Type; + use deno_core::v8::fast_api::CType; + deno_core::v8::fast_api::FastFunction::new_with_bigint( + &[Type::V8Value, Type::V8Value, Type::CallbackOptions], + CType::Void, + Self::v8_fn_ptr_fast as *const ::std::ffi::c_void, + ) + }), + Some({ + use deno_core::v8::fast_api::Type; + use deno_core::v8::fast_api::CType; + deno_core::v8::fast_api::FastFunction::new_with_bigint( + &[Type::V8Value, Type::V8Value, Type::CallbackOptions], + CType::Void, + Self::v8_fn_ptr_fast_metrics as *const ::std::ffi::c_void, + ) + }), + ::deno_core::OpMetadata { + ..::deno_core::OpMetadata::default() + }, ); - let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; - let result = { - let Some(arg0) = deno_core::cppgc::try_unwrap_cppgc_object::< - std::fs::File, - >(arg0) else { - fast_api_callback_options.fallback = true; - return unsafe { std::mem::zeroed() }; - }; - Self::call(arg0) - }; - result as _ } - #[inline(always)] - fn slow_function_impl(info: *const deno_core::v8::FunctionCallbackInfo) -> usize { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, - ); - let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { - &*info - }); - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let result = { - let arg0 = args.get(0usize as i32); - let Some(arg0) = deno_core::cppgc::try_unwrap_cppgc_object::< - std::fs::File, - >(arg0) else { - let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; - let msg = deno_core::v8::String::new_from_one_byte( - &mut scope, - "expected std::fs::File".as_bytes(), - deno_core::v8::NewStringType::Normal, - ) - .unwrap(); - let exc = deno_core::v8::Exception::type_error(&mut scope, msg); - scope.throw_exception(exc); - return 1; + impl op_file { + pub const fn name() -> &'static str { + stringify!(op_file) + } + #[allow(clippy::too_many_arguments)] + extern "C" fn v8_fn_ptr_fast_metrics( + this: deno_core::v8::Local, + arg0: deno_core::v8::Local, + fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, + ) -> () { + let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; + let opctx = unsafe { + &*(deno_core::v8::Local::< + deno_core::v8::External, + >::cast(unsafe { fast_api_callback_options.data.data }) + .value() as *const deno_core::_ops::OpCtx) }; - Self::call(arg0) - }; - deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv); - return 0; - } - extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { - Self::slow_function_impl(info); - } - extern "C" fn v8_fn_ptr_metrics(info: *const deno_core::v8::FunctionCallbackInfo) { - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_slow( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, - ); - let res = Self::slow_function_impl(info); - if res == 0 { - deno_core::_ops::dispatch_metrics_slow( + deno_core::_ops::dispatch_metrics_fast( &opctx, - deno_core::_ops::OpMetricsEvent::Completed, + deno_core::_ops::OpMetricsEvent::Dispatched, ); - } else { - deno_core::_ops::dispatch_metrics_slow( + let res = Self::v8_fn_ptr_fast(this, arg0, fast_api_callback_options); + deno_core::_ops::dispatch_metrics_fast( &opctx, - deno_core::_ops::OpMetricsEvent::Error, + deno_core::_ops::OpMetricsEvent::Completed, ); + res } - } - #[inline(always)] - fn call(_file: &std::fs::File) {} -} - -#[allow(non_camel_case_types)] -struct op_make_cppgc_object { - _unconstructable: ::std::marker::PhantomData<()>, -} -impl ::deno_core::_ops::Op for op_make_cppgc_object { - const NAME: &'static str = stringify!(op_make_cppgc_object); - const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( - ::deno_core::__op_name_fast!(op_make_cppgc_object), - false, - false, - 0usize as u8, - Self::v8_fn_ptr as _, - Self::v8_fn_ptr_metrics as _, - None, - None, - ::deno_core::OpMetadata { - ..::deno_core::OpMetadata::default() - }, - ); -} -impl op_make_cppgc_object { - pub const fn name() -> &'static str { - stringify!(op_make_cppgc_object) - } - #[deprecated(note = "Use the const op::DECL instead")] - pub const fn decl() -> deno_core::_ops::OpDecl { - ::DECL - } - #[inline(always)] - fn slow_function_impl(info: *const deno_core::v8::FunctionCallbackInfo) -> usize { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, - ); - let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; - let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { - &*info - }); - let result = { Self::call() }; - rv.set( - deno_core::_ops::RustToV8NoScope::to_v8( - deno_core::v8::Local::< - deno_core::v8::Value, - >::from(deno_core::cppgc::make_cppgc_object(&mut scope, result)), - ), - ); - return 0; - } - extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { - Self::slow_function_impl(info); - } - extern "C" fn v8_fn_ptr_metrics(info: *const deno_core::v8::FunctionCallbackInfo) { - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_slow( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, - ); - let res = Self::slow_function_impl(info); - if res == 0 { - deno_core::_ops::dispatch_metrics_slow( - &opctx, - deno_core::_ops::OpMetricsEvent::Completed, + #[allow(clippy::too_many_arguments)] + extern "C" fn v8_fn_ptr_fast( + _: deno_core::v8::Local, + arg0: deno_core::v8::Local, + fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, + ) -> () { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, ); - } else { + let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; + let result = { + let Some(arg0) = deno_core::cppgc::try_unwrap_cppgc_object::< + std::fs::File, + >(arg0) else { + fast_api_callback_options.fallback = true; + return unsafe { std::mem::zeroed() }; + }; + Self::call(arg0) + }; + result as _ + } + #[inline(always)] + fn slow_function_impl( + info: *const deno_core::v8::FunctionCallbackInfo, + ) -> usize { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, + ); + let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { + &*info + }); + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let result = { + let arg0 = args.get(0usize as i32); + let Some(arg0) = deno_core::cppgc::try_unwrap_cppgc_object::< + std::fs::File, + >(arg0) else { + let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; + let msg = deno_core::v8::String::new_from_one_byte( + &mut scope, + "expected std::fs::File".as_bytes(), + deno_core::v8::NewStringType::Normal, + ) + .unwrap(); + let exc = deno_core::v8::Exception::type_error(&mut scope, msg); + scope.throw_exception(exc); + return 1; + }; + Self::call(arg0) + }; + deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv); + return 0; + } + extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { + Self::slow_function_impl(info); + } + extern "C" fn v8_fn_ptr_metrics( + info: *const deno_core::v8::FunctionCallbackInfo, + ) { + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; deno_core::_ops::dispatch_metrics_slow( &opctx, - deno_core::_ops::OpMetricsEvent::Error, + deno_core::_ops::OpMetricsEvent::Dispatched, ); + let res = Self::slow_function_impl(info); + if res == 0 { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Completed, + ); + } else { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Error, + ); + } } + #[inline(always)] + fn call(_file: &std::fs::File) {} } - #[inline(always)] - fn call() -> Wrap { - Wrap - } + ::DECL } #[allow(non_camel_case_types)] -struct op_make_cppgc_object_async { - _unconstructable: ::std::marker::PhantomData<()>, -} -impl ::deno_core::_ops::Op for op_make_cppgc_object_async { - const NAME: &'static str = stringify!(op_make_cppgc_object_async); - const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( - ::deno_core::__op_name_fast!(op_make_cppgc_object_async), - true, - false, - 1usize as u8, - Self::v8_fn_ptr as _, - Self::v8_fn_ptr_metrics as _, - None, - None, - ::deno_core::OpMetadata { - ..::deno_core::OpMetadata::default() - }, - ); -} -impl op_make_cppgc_object_async { - pub const fn name() -> &'static str { - stringify!(op_make_cppgc_object_async) +const fn op_make_cppgc_object() -> ::deno_core::_ops::OpDecl { + #[allow(non_camel_case_types)] + struct op_make_cppgc_object { + _unconstructable: ::std::marker::PhantomData<()>, } - #[deprecated(note = "Use the const op::DECL instead")] - pub const fn decl() -> deno_core::_ops::OpDecl { - ::DECL - } - #[inline(always)] - fn slow_function_impl(info: *const deno_core::v8::FunctionCallbackInfo) -> usize { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, - ); - let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; - let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { - &*info - }); - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - let result = { Self::call() }; - let promise_id = deno_core::_ops::to_i32_option(&args.get(0)) - .unwrap_or_default(); - if let Some(result) = deno_core::_ops::map_async_op_infallible( - opctx, + impl ::deno_core::_ops::Op for op_make_cppgc_object { + const NAME: &'static str = stringify!(op_make_cppgc_object); + const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( + ::deno_core::__op_name_fast!(op_make_cppgc_object), false, false, - promise_id, - result, - |scope, result| { - Ok( - deno_core::_ops::RustToV8NoScope::to_v8( - deno_core::cppgc::make_cppgc_object(scope, result), - ), - ) + 0usize as u8, + Self::v8_fn_ptr as _, + Self::v8_fn_ptr_metrics as _, + None, + None, + ::deno_core::OpMetadata { + ..::deno_core::OpMetadata::default() }, - ) { + ); + } + impl op_make_cppgc_object { + pub const fn name() -> &'static str { + stringify!(op_make_cppgc_object) + } + #[inline(always)] + fn slow_function_impl( + info: *const deno_core::v8::FunctionCallbackInfo, + ) -> usize { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, + ); + let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; + let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { + &*info + }); + let result = { Self::call() }; rv.set( deno_core::_ops::RustToV8NoScope::to_v8( deno_core::v8::Local::< @@ -306,38 +205,151 @@ impl op_make_cppgc_object_async { ); return 0; } - return 2; + extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { + Self::slow_function_impl(info); + } + extern "C" fn v8_fn_ptr_metrics( + info: *const deno_core::v8::FunctionCallbackInfo, + ) { + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Dispatched, + ); + let res = Self::slow_function_impl(info); + if res == 0 { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Completed, + ); + } else { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Error, + ); + } + } + #[inline(always)] + fn call() -> Wrap { + Wrap + } } - extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { - Self::slow_function_impl(info); + ::DECL +} + +#[allow(non_camel_case_types)] +const fn op_make_cppgc_object_async() -> ::deno_core::_ops::OpDecl { + #[allow(non_camel_case_types)] + struct op_make_cppgc_object_async { + _unconstructable: ::std::marker::PhantomData<()>, } - extern "C" fn v8_fn_ptr_metrics(info: *const deno_core::v8::FunctionCallbackInfo) { - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_async( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, + impl ::deno_core::_ops::Op for op_make_cppgc_object_async { + const NAME: &'static str = stringify!(op_make_cppgc_object_async); + const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( + ::deno_core::__op_name_fast!(op_make_cppgc_object_async), + true, + false, + 1usize as u8, + Self::v8_fn_ptr as _, + Self::v8_fn_ptr_metrics as _, + None, + None, + ::deno_core::OpMetadata { + ..::deno_core::OpMetadata::default() + }, ); - let res = Self::slow_function_impl(info); - if res == 0 { - deno_core::_ops::dispatch_metrics_async( - &opctx, - deno_core::_ops::OpMetricsEvent::Completed, + } + impl op_make_cppgc_object_async { + pub const fn name() -> &'static str { + stringify!(op_make_cppgc_object_async) + } + #[inline(always)] + fn slow_function_impl( + info: *const deno_core::v8::FunctionCallbackInfo, + ) -> usize { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, ); - } else if res == 1 { + let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; + let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { + &*info + }); + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; + let result = { Self::call() }; + let promise_id = deno_core::_ops::to_i32_option(&args.get(0)) + .unwrap_or_default(); + if let Some(result) = deno_core::_ops::map_async_op_infallible( + opctx, + false, + false, + promise_id, + result, + |scope, result| { + Ok( + deno_core::_ops::RustToV8NoScope::to_v8( + deno_core::cppgc::make_cppgc_object(scope, result), + ), + ) + }, + ) { + rv.set( + deno_core::_ops::RustToV8NoScope::to_v8( + deno_core::v8::Local::< + deno_core::v8::Value, + >::from(deno_core::cppgc::make_cppgc_object(&mut scope, result)), + ), + ); + return 0; + } + return 2; + } + extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { + Self::slow_function_impl(info); + } + extern "C" fn v8_fn_ptr_metrics( + info: *const deno_core::v8::FunctionCallbackInfo, + ) { + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; deno_core::_ops::dispatch_metrics_async( &opctx, - deno_core::_ops::OpMetricsEvent::Error, + deno_core::_ops::OpMetricsEvent::Dispatched, ); + let res = Self::slow_function_impl(info); + if res == 0 { + deno_core::_ops::dispatch_metrics_async( + &opctx, + deno_core::_ops::OpMetricsEvent::Completed, + ); + } else if res == 1 { + deno_core::_ops::dispatch_metrics_async( + &opctx, + deno_core::_ops::OpMetricsEvent::Error, + ); + } + } + #[inline(always)] + async fn call() -> Wrap { + Wrap } } - #[inline(always)] - async fn call() -> Wrap { - Wrap - } + ::DECL } diff --git a/ops/op2/test_cases/sync/doc_comment.out b/ops/op2/test_cases/sync/doc_comment.out index a25f3afe3..b61c53c7e 100644 --- a/ops/op2/test_cases/sync/doc_comment.out +++ b/ops/op2/test_cases/sync/doc_comment.out @@ -1,122 +1,128 @@ #[allow(non_camel_case_types)] -/// This is a doc comment. -pub struct op_has_doc_comment { - _unconstructable: ::std::marker::PhantomData<()>, -} -impl ::deno_core::_ops::Op for op_has_doc_comment { - const NAME: &'static str = stringify!(op_has_doc_comment); - const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( - ::deno_core::__op_name_fast!(op_has_doc_comment), - false, - false, - 0usize as u8, - Self::v8_fn_ptr as _, - Self::v8_fn_ptr_metrics as _, - Some({ - use deno_core::v8::fast_api::Type; - use deno_core::v8::fast_api::CType; - deno_core::v8::fast_api::FastFunction::new_with_bigint( - &[Type::V8Value], - CType::Void, - Self::v8_fn_ptr_fast as *const ::std::ffi::c_void, - ) - }), - Some({ - use deno_core::v8::fast_api::Type; - use deno_core::v8::fast_api::CType; - deno_core::v8::fast_api::FastFunction::new_with_bigint( - &[Type::V8Value, Type::CallbackOptions], - CType::Void, - Self::v8_fn_ptr_fast_metrics as *const ::std::ffi::c_void, - ) - }), - ::deno_core::OpMetadata { - ..::deno_core::OpMetadata::default() - }, - ); -} -impl op_has_doc_comment { - pub const fn name() -> &'static str { - stringify!(op_has_doc_comment) - } - #[deprecated(note = "Use the const op::DECL instead")] - pub const fn decl() -> deno_core::_ops::OpDecl { - ::DECL - } - #[allow(clippy::too_many_arguments)] - extern "C" fn v8_fn_ptr_fast_metrics( - this: deno_core::v8::Local, - fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, - ) -> () { - let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; - let opctx = unsafe { - &*(deno_core::v8::Local::< - deno_core::v8::External, - >::cast(unsafe { fast_api_callback_options.data.data }) - .value() as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_fast( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, - ); - let res = Self::v8_fn_ptr_fast(this); - deno_core::_ops::dispatch_metrics_fast( - &opctx, - deno_core::_ops::OpMetricsEvent::Completed, - ); - res - } - #[allow(clippy::too_many_arguments)] - extern "C" fn v8_fn_ptr_fast(_: deno_core::v8::Local) -> () { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, - ); - let result = { Self::call() }; - result as _ +pub const fn op_has_doc_comment() -> ::deno_core::_ops::OpDecl { + #[allow(non_camel_case_types)] + /// This is a doc comment. + pub struct op_has_doc_comment { + _unconstructable: ::std::marker::PhantomData<()>, } - #[inline(always)] - fn slow_function_impl(info: *const deno_core::v8::FunctionCallbackInfo) -> usize { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, + impl ::deno_core::_ops::Op for op_has_doc_comment { + const NAME: &'static str = stringify!(op_has_doc_comment); + const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( + ::deno_core::__op_name_fast!(op_has_doc_comment), + false, + false, + 0usize as u8, + Self::v8_fn_ptr as _, + Self::v8_fn_ptr_metrics as _, + Some({ + use deno_core::v8::fast_api::Type; + use deno_core::v8::fast_api::CType; + deno_core::v8::fast_api::FastFunction::new_with_bigint( + &[Type::V8Value], + CType::Void, + Self::v8_fn_ptr_fast as *const ::std::ffi::c_void, + ) + }), + Some({ + use deno_core::v8::fast_api::Type; + use deno_core::v8::fast_api::CType; + deno_core::v8::fast_api::FastFunction::new_with_bigint( + &[Type::V8Value, Type::CallbackOptions], + CType::Void, + Self::v8_fn_ptr_fast_metrics as *const ::std::ffi::c_void, + ) + }), + ::deno_core::OpMetadata { + ..::deno_core::OpMetadata::default() + }, ); - let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { - &*info - }); - let result = { Self::call() }; - deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv); - return 0; } - extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { - Self::slow_function_impl(info); - } - extern "C" fn v8_fn_ptr_metrics(info: *const deno_core::v8::FunctionCallbackInfo) { - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_slow( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, - ); - let res = Self::slow_function_impl(info); - if res == 0 { - deno_core::_ops::dispatch_metrics_slow( + impl op_has_doc_comment { + pub const fn name() -> &'static str { + stringify!(op_has_doc_comment) + } + #[allow(clippy::too_many_arguments)] + extern "C" fn v8_fn_ptr_fast_metrics( + this: deno_core::v8::Local, + fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, + ) -> () { + let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; + let opctx = unsafe { + &*(deno_core::v8::Local::< + deno_core::v8::External, + >::cast(unsafe { fast_api_callback_options.data.data }) + .value() as *const deno_core::_ops::OpCtx) + }; + deno_core::_ops::dispatch_metrics_fast( + &opctx, + deno_core::_ops::OpMetricsEvent::Dispatched, + ); + let res = Self::v8_fn_ptr_fast(this); + deno_core::_ops::dispatch_metrics_fast( &opctx, deno_core::_ops::OpMetricsEvent::Completed, ); - } else { + res + } + #[allow(clippy::too_many_arguments)] + extern "C" fn v8_fn_ptr_fast( + _: deno_core::v8::Local, + ) -> () { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, + ); + let result = { Self::call() }; + result as _ + } + #[inline(always)] + fn slow_function_impl( + info: *const deno_core::v8::FunctionCallbackInfo, + ) -> usize { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, + ); + let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { + &*info + }); + let result = { Self::call() }; + deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv); + return 0; + } + extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { + Self::slow_function_impl(info); + } + extern "C" fn v8_fn_ptr_metrics( + info: *const deno_core::v8::FunctionCallbackInfo, + ) { + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; deno_core::_ops::dispatch_metrics_slow( &opctx, - deno_core::_ops::OpMetricsEvent::Error, + deno_core::_ops::OpMetricsEvent::Dispatched, ); + let res = Self::slow_function_impl(info); + if res == 0 { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Completed, + ); + } else { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Error, + ); + } } + #[inline(always)] + /// This is a doc comment. + pub fn call() -> () {} } - #[inline(always)] - /// This is a doc comment. - pub fn call() -> () {} + ::DECL } diff --git a/ops/op2/test_cases/sync/fast_alternative.out b/ops/op2/test_cases/sync/fast_alternative.out index f84ce51db..e1b29eeb4 100644 --- a/ops/op2/test_cases/sync/fast_alternative.out +++ b/ops/op2/test_cases/sync/fast_alternative.out @@ -1,547 +1,563 @@ #[allow(non_camel_case_types)] -struct op_slow { - _unconstructable: ::std::marker::PhantomData<()>, -} -impl ::deno_core::_ops::Op for op_slow { - const NAME: &'static str = stringify!(op_slow); - const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( - ::deno_core::__op_name_fast!(op_slow), - false, - false, - 3usize as u8, - Self::v8_fn_ptr as _, - Self::v8_fn_ptr_metrics as _, - Some({ op_fast::DECL.fast_fn() }), - Some({ op_fast::DECL.fast_fn_with_metrics() }), - ::deno_core::OpMetadata { - ..::deno_core::OpMetadata::default() - }, - ); -} -impl op_slow { - pub const fn name() -> &'static str { - stringify!(op_slow) - } - #[deprecated(note = "Use the const op::DECL instead")] - pub const fn decl() -> deno_core::_ops::OpDecl { - ::DECL +const fn op_slow() -> ::deno_core::_ops::OpDecl { + #[allow(non_camel_case_types)] + struct op_slow { + _unconstructable: ::std::marker::PhantomData<()>, } - #[inline(always)] - fn slow_function_impl(info: *const deno_core::v8::FunctionCallbackInfo) -> usize { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, + impl ::deno_core::_ops::Op for op_slow { + const NAME: &'static str = stringify!(op_slow); + const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( + ::deno_core::__op_name_fast!(op_slow), + false, + false, + 3usize as u8, + Self::v8_fn_ptr as _, + Self::v8_fn_ptr_metrics as _, + Some({ op_fast().fast_fn() }), + Some({ op_fast().fast_fn_with_metrics() }), + ::deno_core::OpMetadata { + ..::deno_core::OpMetadata::default() + }, ); - let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; - let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { - &*info - }); - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let result = { - let arg1 = args.get(0usize as i32); - let Some(arg1) = deno_core::_ops::to_u32_option(&arg1) else { - let msg = deno_core::v8::String::new_from_one_byte( - &mut scope, - "expected u32".as_bytes(), - deno_core::v8::NewStringType::Normal, - ) - .unwrap(); - let exc = deno_core::v8::Exception::type_error(&mut scope, msg); - scope.throw_exception(exc); - return 1; - }; - let arg1 = arg1 as _; - let arg2 = args.get(1usize as i32); - let Some(arg2) = deno_core::_ops::to_u32_option(&arg2) else { - let msg = deno_core::v8::String::new_from_one_byte( - &mut scope, - "expected u32".as_bytes(), - deno_core::v8::NewStringType::Normal, - ) - .unwrap(); - let exc = deno_core::v8::Exception::type_error(&mut scope, msg); - scope.throw_exception(exc); - return 1; - }; - let arg2 = arg2 as _; - let arg0 = &mut scope; - Self::call(arg0, arg1, arg2) - }; - deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv); - return 0; - } - extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { - Self::slow_function_impl(info); } - extern "C" fn v8_fn_ptr_metrics(info: *const deno_core::v8::FunctionCallbackInfo) { - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_slow( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, - ); - let res = Self::slow_function_impl(info); - if res == 0 { - deno_core::_ops::dispatch_metrics_slow( - &opctx, - deno_core::_ops::OpMetricsEvent::Completed, + impl op_slow { + pub const fn name() -> &'static str { + stringify!(op_slow) + } + #[inline(always)] + fn slow_function_impl( + info: *const deno_core::v8::FunctionCallbackInfo, + ) -> usize { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, ); - } else { + let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; + let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { + &*info + }); + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let result = { + let arg1 = args.get(0usize as i32); + let Some(arg1) = deno_core::_ops::to_u32_option(&arg1) else { + let msg = deno_core::v8::String::new_from_one_byte( + &mut scope, + "expected u32".as_bytes(), + deno_core::v8::NewStringType::Normal, + ) + .unwrap(); + let exc = deno_core::v8::Exception::type_error(&mut scope, msg); + scope.throw_exception(exc); + return 1; + }; + let arg1 = arg1 as _; + let arg2 = args.get(1usize as i32); + let Some(arg2) = deno_core::_ops::to_u32_option(&arg2) else { + let msg = deno_core::v8::String::new_from_one_byte( + &mut scope, + "expected u32".as_bytes(), + deno_core::v8::NewStringType::Normal, + ) + .unwrap(); + let exc = deno_core::v8::Exception::type_error(&mut scope, msg); + scope.throw_exception(exc); + return 1; + }; + let arg2 = arg2 as _; + let arg0 = &mut scope; + Self::call(arg0, arg1, arg2) + }; + deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv); + return 0; + } + extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { + Self::slow_function_impl(info); + } + extern "C" fn v8_fn_ptr_metrics( + info: *const deno_core::v8::FunctionCallbackInfo, + ) { + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; deno_core::_ops::dispatch_metrics_slow( &opctx, - deno_core::_ops::OpMetricsEvent::Error, + deno_core::_ops::OpMetricsEvent::Dispatched, ); + let res = Self::slow_function_impl(info); + if res == 0 { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Completed, + ); + } else { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Error, + ); + } + } + #[inline(always)] + fn call(_scope: &v8::HandleScope, a: u32, b: u32) -> u32 { + a + b } } - #[inline(always)] - fn call(_scope: &v8::HandleScope, a: u32, b: u32) -> u32 { - a + b - } + ::DECL } #[allow(non_camel_case_types)] -struct op_fast { - _unconstructable: ::std::marker::PhantomData<()>, -} -impl ::deno_core::_ops::Op for op_fast { - const NAME: &'static str = stringify!(op_fast); - const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( - ::deno_core::__op_name_fast!(op_fast), - false, - false, - 2usize as u8, - Self::v8_fn_ptr as _, - Self::v8_fn_ptr_metrics as _, - Some({ - use deno_core::v8::fast_api::Type; - use deno_core::v8::fast_api::CType; - deno_core::v8::fast_api::FastFunction::new_with_bigint( - &[Type::V8Value, Type::Uint32, Type::Uint32], - CType::Uint32, - Self::v8_fn_ptr_fast as *const ::std::ffi::c_void, - ) - }), - Some({ - use deno_core::v8::fast_api::Type; - use deno_core::v8::fast_api::CType; - deno_core::v8::fast_api::FastFunction::new_with_bigint( - &[Type::V8Value, Type::Uint32, Type::Uint32, Type::CallbackOptions], - CType::Uint32, - Self::v8_fn_ptr_fast_metrics as *const ::std::ffi::c_void, - ) - }), - ::deno_core::OpMetadata { - ..::deno_core::OpMetadata::default() - }, - ); -} -impl op_fast { - pub const fn name() -> &'static str { - stringify!(op_fast) - } - #[deprecated(note = "Use the const op::DECL instead")] - pub const fn decl() -> deno_core::_ops::OpDecl { - ::DECL +const fn op_fast() -> ::deno_core::_ops::OpDecl { + #[allow(non_camel_case_types)] + struct op_fast { + _unconstructable: ::std::marker::PhantomData<()>, } - #[allow(clippy::too_many_arguments)] - extern "C" fn v8_fn_ptr_fast_metrics( - this: deno_core::v8::Local, - arg0: u32, - arg1: u32, - fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, - ) -> u32 { - let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; - let opctx = unsafe { - &*(deno_core::v8::Local::< - deno_core::v8::External, - >::cast(unsafe { fast_api_callback_options.data.data }) - .value() as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_fast( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, + impl ::deno_core::_ops::Op for op_fast { + const NAME: &'static str = stringify!(op_fast); + const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( + ::deno_core::__op_name_fast!(op_fast), + false, + false, + 2usize as u8, + Self::v8_fn_ptr as _, + Self::v8_fn_ptr_metrics as _, + Some({ + use deno_core::v8::fast_api::Type; + use deno_core::v8::fast_api::CType; + deno_core::v8::fast_api::FastFunction::new_with_bigint( + &[Type::V8Value, Type::Uint32, Type::Uint32], + CType::Uint32, + Self::v8_fn_ptr_fast as *const ::std::ffi::c_void, + ) + }), + Some({ + use deno_core::v8::fast_api::Type; + use deno_core::v8::fast_api::CType; + deno_core::v8::fast_api::FastFunction::new_with_bigint( + &[Type::V8Value, Type::Uint32, Type::Uint32, Type::CallbackOptions], + CType::Uint32, + Self::v8_fn_ptr_fast_metrics as *const ::std::ffi::c_void, + ) + }), + ::deno_core::OpMetadata { + ..::deno_core::OpMetadata::default() + }, ); - let res = Self::v8_fn_ptr_fast(this, arg0, arg1); - deno_core::_ops::dispatch_metrics_fast( - &opctx, - deno_core::_ops::OpMetricsEvent::Completed, - ); - res } - #[allow(clippy::too_many_arguments)] - extern "C" fn v8_fn_ptr_fast( - _: deno_core::v8::Local, - arg0: u32, - arg1: u32, - ) -> u32 { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, - ); - let result = { - let arg0 = arg0 as _; - let arg1 = arg1 as _; - Self::call(arg0, arg1) - }; - result as _ - } - #[inline(always)] - fn slow_function_impl(info: *const deno_core::v8::FunctionCallbackInfo) -> usize { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, - ); - let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { - &*info - }); - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let result = { - let arg0 = args.get(0usize as i32); - let Some(arg0) = deno_core::_ops::to_u32_option(&arg0) else { - let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; - let msg = deno_core::v8::String::new_from_one_byte( - &mut scope, - "expected u32".as_bytes(), - deno_core::v8::NewStringType::Normal, - ) - .unwrap(); - let exc = deno_core::v8::Exception::type_error(&mut scope, msg); - scope.throw_exception(exc); - return 1; - }; - let arg0 = arg0 as _; - let arg1 = args.get(1usize as i32); - let Some(arg1) = deno_core::_ops::to_u32_option(&arg1) else { - let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; - let msg = deno_core::v8::String::new_from_one_byte( - &mut scope, - "expected u32".as_bytes(), - deno_core::v8::NewStringType::Normal, - ) - .unwrap(); - let exc = deno_core::v8::Exception::type_error(&mut scope, msg); - scope.throw_exception(exc); - return 1; + impl op_fast { + pub const fn name() -> &'static str { + stringify!(op_fast) + } + #[allow(clippy::too_many_arguments)] + extern "C" fn v8_fn_ptr_fast_metrics( + this: deno_core::v8::Local, + arg0: u32, + arg1: u32, + fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, + ) -> u32 { + let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; + let opctx = unsafe { + &*(deno_core::v8::Local::< + deno_core::v8::External, + >::cast(unsafe { fast_api_callback_options.data.data }) + .value() as *const deno_core::_ops::OpCtx) }; - let arg1 = arg1 as _; - Self::call(arg0, arg1) - }; - deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv); - return 0; - } - extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { - Self::slow_function_impl(info); - } - extern "C" fn v8_fn_ptr_metrics(info: *const deno_core::v8::FunctionCallbackInfo) { - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_slow( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, - ); - let res = Self::slow_function_impl(info); - if res == 0 { - deno_core::_ops::dispatch_metrics_slow( + deno_core::_ops::dispatch_metrics_fast( + &opctx, + deno_core::_ops::OpMetricsEvent::Dispatched, + ); + let res = Self::v8_fn_ptr_fast(this, arg0, arg1); + deno_core::_ops::dispatch_metrics_fast( &opctx, deno_core::_ops::OpMetricsEvent::Completed, ); - } else { + res + } + #[allow(clippy::too_many_arguments)] + extern "C" fn v8_fn_ptr_fast( + _: deno_core::v8::Local, + arg0: u32, + arg1: u32, + ) -> u32 { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, + ); + let result = { + let arg0 = arg0 as _; + let arg1 = arg1 as _; + Self::call(arg0, arg1) + }; + result as _ + } + #[inline(always)] + fn slow_function_impl( + info: *const deno_core::v8::FunctionCallbackInfo, + ) -> usize { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, + ); + let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { + &*info + }); + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let result = { + let arg0 = args.get(0usize as i32); + let Some(arg0) = deno_core::_ops::to_u32_option(&arg0) else { + let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; + let msg = deno_core::v8::String::new_from_one_byte( + &mut scope, + "expected u32".as_bytes(), + deno_core::v8::NewStringType::Normal, + ) + .unwrap(); + let exc = deno_core::v8::Exception::type_error(&mut scope, msg); + scope.throw_exception(exc); + return 1; + }; + let arg0 = arg0 as _; + let arg1 = args.get(1usize as i32); + let Some(arg1) = deno_core::_ops::to_u32_option(&arg1) else { + let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; + let msg = deno_core::v8::String::new_from_one_byte( + &mut scope, + "expected u32".as_bytes(), + deno_core::v8::NewStringType::Normal, + ) + .unwrap(); + let exc = deno_core::v8::Exception::type_error(&mut scope, msg); + scope.throw_exception(exc); + return 1; + }; + let arg1 = arg1 as _; + Self::call(arg0, arg1) + }; + deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv); + return 0; + } + extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { + Self::slow_function_impl(info); + } + extern "C" fn v8_fn_ptr_metrics( + info: *const deno_core::v8::FunctionCallbackInfo, + ) { + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; deno_core::_ops::dispatch_metrics_slow( &opctx, - deno_core::_ops::OpMetricsEvent::Error, + deno_core::_ops::OpMetricsEvent::Dispatched, ); + let res = Self::slow_function_impl(info); + if res == 0 { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Completed, + ); + } else { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Error, + ); + } + } + #[inline(always)] + fn call(a: u32, b: u32) -> u32 { + a + b } } - #[inline(always)] - fn call(a: u32, b: u32) -> u32 { - a + b - } + ::DECL } #[allow(non_camel_case_types)] -struct op_slow_generic { - _unconstructable: ::std::marker::PhantomData<(T)>, -} -impl ::deno_core::_ops::Op for op_slow_generic { - const NAME: &'static str = stringify!(op_slow_generic); - const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( - ::deno_core::__op_name_fast!(op_slow_generic), - false, - false, - 3usize as u8, - Self::v8_fn_ptr as _, - Self::v8_fn_ptr_metrics as _, - Some({ op_fast_generic::::DECL.fast_fn() }), - Some({ op_fast_generic::::DECL.fast_fn_with_metrics() }), - ::deno_core::OpMetadata { - ..::deno_core::OpMetadata::default() - }, - ); -} -impl op_slow_generic { - pub const fn name() -> &'static str { - stringify!(op_slow_generic) - } - #[deprecated(note = "Use the const op::DECL instead")] - pub const fn decl() -> deno_core::_ops::OpDecl { - ::DECL +const fn op_slow_generic() -> ::deno_core::_ops::OpDecl { + #[allow(non_camel_case_types)] + struct op_slow_generic { + _unconstructable: ::std::marker::PhantomData<(T)>, } - #[inline(always)] - fn slow_function_impl(info: *const deno_core::v8::FunctionCallbackInfo) -> usize { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, + impl ::deno_core::_ops::Op for op_slow_generic { + const NAME: &'static str = stringify!(op_slow_generic); + const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( + ::deno_core::__op_name_fast!(op_slow_generic), + false, + false, + 3usize as u8, + Self::v8_fn_ptr as _, + Self::v8_fn_ptr_metrics as _, + Some({ op_fast_generic::().fast_fn() }), + Some({ op_fast_generic::().fast_fn_with_metrics() }), + ::deno_core::OpMetadata { + ..::deno_core::OpMetadata::default() + }, ); - let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; - let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { - &*info - }); - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let result = { - let arg1 = args.get(0usize as i32); - let Some(arg1) = deno_core::_ops::to_u32_option(&arg1) else { - let msg = deno_core::v8::String::new_from_one_byte( - &mut scope, - "expected u32".as_bytes(), - deno_core::v8::NewStringType::Normal, - ) - .unwrap(); - let exc = deno_core::v8::Exception::type_error(&mut scope, msg); - scope.throw_exception(exc); - return 1; - }; - let arg1 = arg1 as _; - let arg2 = args.get(1usize as i32); - let Some(arg2) = deno_core::_ops::to_u32_option(&arg2) else { - let msg = deno_core::v8::String::new_from_one_byte( - &mut scope, - "expected u32".as_bytes(), - deno_core::v8::NewStringType::Normal, - ) - .unwrap(); - let exc = deno_core::v8::Exception::type_error(&mut scope, msg); - scope.throw_exception(exc); - return 1; - }; - let arg2 = arg2 as _; - let arg0 = &mut scope; - Self::call(arg0, arg1, arg2) - }; - deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv); - return 0; - } - extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { - Self::slow_function_impl(info); } - extern "C" fn v8_fn_ptr_metrics(info: *const deno_core::v8::FunctionCallbackInfo) { - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_slow( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, - ); - let res = Self::slow_function_impl(info); - if res == 0 { - deno_core::_ops::dispatch_metrics_slow( - &opctx, - deno_core::_ops::OpMetricsEvent::Completed, + impl op_slow_generic { + pub const fn name() -> &'static str { + stringify!(op_slow_generic) + } + #[inline(always)] + fn slow_function_impl( + info: *const deno_core::v8::FunctionCallbackInfo, + ) -> usize { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, ); - } else { + let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; + let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { + &*info + }); + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let result = { + let arg1 = args.get(0usize as i32); + let Some(arg1) = deno_core::_ops::to_u32_option(&arg1) else { + let msg = deno_core::v8::String::new_from_one_byte( + &mut scope, + "expected u32".as_bytes(), + deno_core::v8::NewStringType::Normal, + ) + .unwrap(); + let exc = deno_core::v8::Exception::type_error(&mut scope, msg); + scope.throw_exception(exc); + return 1; + }; + let arg1 = arg1 as _; + let arg2 = args.get(1usize as i32); + let Some(arg2) = deno_core::_ops::to_u32_option(&arg2) else { + let msg = deno_core::v8::String::new_from_one_byte( + &mut scope, + "expected u32".as_bytes(), + deno_core::v8::NewStringType::Normal, + ) + .unwrap(); + let exc = deno_core::v8::Exception::type_error(&mut scope, msg); + scope.throw_exception(exc); + return 1; + }; + let arg2 = arg2 as _; + let arg0 = &mut scope; + Self::call(arg0, arg1, arg2) + }; + deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv); + return 0; + } + extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { + Self::slow_function_impl(info); + } + extern "C" fn v8_fn_ptr_metrics( + info: *const deno_core::v8::FunctionCallbackInfo, + ) { + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; deno_core::_ops::dispatch_metrics_slow( &opctx, - deno_core::_ops::OpMetricsEvent::Error, + deno_core::_ops::OpMetricsEvent::Dispatched, ); + let res = Self::slow_function_impl(info); + if res == 0 { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Completed, + ); + } else { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Error, + ); + } + } + #[inline(always)] + fn call(_scope: &v8::HandleScope, a: u32, b: u32) -> u32 { + a + b } } - #[inline(always)] - fn call(_scope: &v8::HandleScope, a: u32, b: u32) -> u32 { - a + b - } + as ::deno_core::_ops::Op>::DECL } #[allow(non_camel_case_types)] -struct op_fast_generic { - _unconstructable: ::std::marker::PhantomData<(T)>, -} -impl ::deno_core::_ops::Op for op_fast_generic { - const NAME: &'static str = stringify!(op_fast_generic); - const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( - ::deno_core::__op_name_fast!(op_fast_generic), - false, - false, - 2usize as u8, - Self::v8_fn_ptr as _, - Self::v8_fn_ptr_metrics as _, - Some({ - use deno_core::v8::fast_api::Type; - use deno_core::v8::fast_api::CType; - deno_core::v8::fast_api::FastFunction::new_with_bigint( - &[Type::V8Value, Type::Uint32, Type::Uint32], - CType::Uint32, - Self::v8_fn_ptr_fast as *const ::std::ffi::c_void, - ) - }), - Some({ - use deno_core::v8::fast_api::Type; - use deno_core::v8::fast_api::CType; - deno_core::v8::fast_api::FastFunction::new_with_bigint( - &[Type::V8Value, Type::Uint32, Type::Uint32, Type::CallbackOptions], - CType::Uint32, - Self::v8_fn_ptr_fast_metrics as *const ::std::ffi::c_void, - ) - }), - ::deno_core::OpMetadata { - ..::deno_core::OpMetadata::default() - }, - ); -} -impl op_fast_generic { - pub const fn name() -> &'static str { - stringify!(op_fast_generic) - } - #[deprecated(note = "Use the const op::DECL instead")] - pub const fn decl() -> deno_core::_ops::OpDecl { - ::DECL +const fn op_fast_generic() -> ::deno_core::_ops::OpDecl { + #[allow(non_camel_case_types)] + struct op_fast_generic { + _unconstructable: ::std::marker::PhantomData<(T)>, } - #[allow(clippy::too_many_arguments)] - extern "C" fn v8_fn_ptr_fast_metrics( - this: deno_core::v8::Local, - arg0: u32, - arg1: u32, - fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, - ) -> u32 { - let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; - let opctx = unsafe { - &*(deno_core::v8::Local::< - deno_core::v8::External, - >::cast(unsafe { fast_api_callback_options.data.data }) - .value() as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_fast( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, + impl ::deno_core::_ops::Op for op_fast_generic { + const NAME: &'static str = stringify!(op_fast_generic); + const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( + ::deno_core::__op_name_fast!(op_fast_generic), + false, + false, + 2usize as u8, + Self::v8_fn_ptr as _, + Self::v8_fn_ptr_metrics as _, + Some({ + use deno_core::v8::fast_api::Type; + use deno_core::v8::fast_api::CType; + deno_core::v8::fast_api::FastFunction::new_with_bigint( + &[Type::V8Value, Type::Uint32, Type::Uint32], + CType::Uint32, + Self::v8_fn_ptr_fast as *const ::std::ffi::c_void, + ) + }), + Some({ + use deno_core::v8::fast_api::Type; + use deno_core::v8::fast_api::CType; + deno_core::v8::fast_api::FastFunction::new_with_bigint( + &[Type::V8Value, Type::Uint32, Type::Uint32, Type::CallbackOptions], + CType::Uint32, + Self::v8_fn_ptr_fast_metrics as *const ::std::ffi::c_void, + ) + }), + ::deno_core::OpMetadata { + ..::deno_core::OpMetadata::default() + }, ); - let res = Self::v8_fn_ptr_fast(this, arg0, arg1); - deno_core::_ops::dispatch_metrics_fast( - &opctx, - deno_core::_ops::OpMetricsEvent::Completed, - ); - res } - #[allow(clippy::too_many_arguments)] - extern "C" fn v8_fn_ptr_fast( - _: deno_core::v8::Local, - arg0: u32, - arg1: u32, - ) -> u32 { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, - ); - let result = { - let arg0 = arg0 as _; - let arg1 = arg1 as _; - Self::call(arg0, arg1) - }; - result as _ - } - #[inline(always)] - fn slow_function_impl(info: *const deno_core::v8::FunctionCallbackInfo) -> usize { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, - ); - let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { - &*info - }); - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let result = { - let arg0 = args.get(0usize as i32); - let Some(arg0) = deno_core::_ops::to_u32_option(&arg0) else { - let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; - let msg = deno_core::v8::String::new_from_one_byte( - &mut scope, - "expected u32".as_bytes(), - deno_core::v8::NewStringType::Normal, - ) - .unwrap(); - let exc = deno_core::v8::Exception::type_error(&mut scope, msg); - scope.throw_exception(exc); - return 1; - }; - let arg0 = arg0 as _; - let arg1 = args.get(1usize as i32); - let Some(arg1) = deno_core::_ops::to_u32_option(&arg1) else { - let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; - let msg = deno_core::v8::String::new_from_one_byte( - &mut scope, - "expected u32".as_bytes(), - deno_core::v8::NewStringType::Normal, - ) - .unwrap(); - let exc = deno_core::v8::Exception::type_error(&mut scope, msg); - scope.throw_exception(exc); - return 1; + impl op_fast_generic { + pub const fn name() -> &'static str { + stringify!(op_fast_generic) + } + #[allow(clippy::too_many_arguments)] + extern "C" fn v8_fn_ptr_fast_metrics( + this: deno_core::v8::Local, + arg0: u32, + arg1: u32, + fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, + ) -> u32 { + let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; + let opctx = unsafe { + &*(deno_core::v8::Local::< + deno_core::v8::External, + >::cast(unsafe { fast_api_callback_options.data.data }) + .value() as *const deno_core::_ops::OpCtx) }; - let arg1 = arg1 as _; - Self::call(arg0, arg1) - }; - deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv); - return 0; - } - extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { - Self::slow_function_impl(info); - } - extern "C" fn v8_fn_ptr_metrics(info: *const deno_core::v8::FunctionCallbackInfo) { - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_slow( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, - ); - let res = Self::slow_function_impl(info); - if res == 0 { - deno_core::_ops::dispatch_metrics_slow( + deno_core::_ops::dispatch_metrics_fast( + &opctx, + deno_core::_ops::OpMetricsEvent::Dispatched, + ); + let res = Self::v8_fn_ptr_fast(this, arg0, arg1); + deno_core::_ops::dispatch_metrics_fast( &opctx, deno_core::_ops::OpMetricsEvent::Completed, ); - } else { + res + } + #[allow(clippy::too_many_arguments)] + extern "C" fn v8_fn_ptr_fast( + _: deno_core::v8::Local, + arg0: u32, + arg1: u32, + ) -> u32 { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, + ); + let result = { + let arg0 = arg0 as _; + let arg1 = arg1 as _; + Self::call(arg0, arg1) + }; + result as _ + } + #[inline(always)] + fn slow_function_impl( + info: *const deno_core::v8::FunctionCallbackInfo, + ) -> usize { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, + ); + let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { + &*info + }); + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let result = { + let arg0 = args.get(0usize as i32); + let Some(arg0) = deno_core::_ops::to_u32_option(&arg0) else { + let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; + let msg = deno_core::v8::String::new_from_one_byte( + &mut scope, + "expected u32".as_bytes(), + deno_core::v8::NewStringType::Normal, + ) + .unwrap(); + let exc = deno_core::v8::Exception::type_error(&mut scope, msg); + scope.throw_exception(exc); + return 1; + }; + let arg0 = arg0 as _; + let arg1 = args.get(1usize as i32); + let Some(arg1) = deno_core::_ops::to_u32_option(&arg1) else { + let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; + let msg = deno_core::v8::String::new_from_one_byte( + &mut scope, + "expected u32".as_bytes(), + deno_core::v8::NewStringType::Normal, + ) + .unwrap(); + let exc = deno_core::v8::Exception::type_error(&mut scope, msg); + scope.throw_exception(exc); + return 1; + }; + let arg1 = arg1 as _; + Self::call(arg0, arg1) + }; + deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv); + return 0; + } + extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { + Self::slow_function_impl(info); + } + extern "C" fn v8_fn_ptr_metrics( + info: *const deno_core::v8::FunctionCallbackInfo, + ) { + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; deno_core::_ops::dispatch_metrics_slow( &opctx, - deno_core::_ops::OpMetricsEvent::Error, + deno_core::_ops::OpMetricsEvent::Dispatched, ); + let res = Self::slow_function_impl(info); + if res == 0 { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Completed, + ); + } else { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Error, + ); + } + } + #[inline(always)] + fn call(a: u32, b: u32) -> u32 { + a + b } } - #[inline(always)] - fn call(a: u32, b: u32) -> u32 { - a + b - } + as ::deno_core::_ops::Op>::DECL } diff --git a/ops/op2/test_cases/sync/generics.out b/ops/op2/test_cases/sync/generics.out index f9da0101e..5190d966e 100644 --- a/ops/op2/test_cases/sync/generics.out +++ b/ops/op2/test_cases/sync/generics.out @@ -1,365 +1,383 @@ #[allow(non_camel_case_types)] -pub struct op_generics { - _unconstructable: ::std::marker::PhantomData<(T)>, -} -impl ::deno_core::_ops::Op for op_generics { - const NAME: &'static str = stringify!(op_generics); - const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( - ::deno_core::__op_name_fast!(op_generics), - false, - false, - 0usize as u8, - Self::v8_fn_ptr as _, - Self::v8_fn_ptr_metrics as _, - Some({ - use deno_core::v8::fast_api::Type; - use deno_core::v8::fast_api::CType; - deno_core::v8::fast_api::FastFunction::new_with_bigint( - &[Type::V8Value], - CType::Void, - Self::v8_fn_ptr_fast as *const ::std::ffi::c_void, - ) - }), - Some({ - use deno_core::v8::fast_api::Type; - use deno_core::v8::fast_api::CType; - deno_core::v8::fast_api::FastFunction::new_with_bigint( - &[Type::V8Value, Type::CallbackOptions], - CType::Void, - Self::v8_fn_ptr_fast_metrics as *const ::std::ffi::c_void, - ) - }), - ::deno_core::OpMetadata { - ..::deno_core::OpMetadata::default() - }, - ); -} -impl op_generics { - pub const fn name() -> &'static str { - stringify!(op_generics) - } - #[deprecated(note = "Use the const op::DECL instead")] - pub const fn decl() -> deno_core::_ops::OpDecl { - ::DECL - } - #[allow(clippy::too_many_arguments)] - extern "C" fn v8_fn_ptr_fast_metrics( - this: deno_core::v8::Local, - fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, - ) -> () { - let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; - let opctx = unsafe { - &*(deno_core::v8::Local::< - deno_core::v8::External, - >::cast(unsafe { fast_api_callback_options.data.data }) - .value() as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_fast( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, - ); - let res = Self::v8_fn_ptr_fast(this); - deno_core::_ops::dispatch_metrics_fast( - &opctx, - deno_core::_ops::OpMetricsEvent::Completed, - ); - res - } - #[allow(clippy::too_many_arguments)] - extern "C" fn v8_fn_ptr_fast(_: deno_core::v8::Local) -> () { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, - ); - let result = { Self::call() }; - result as _ +pub const fn op_generics() -> ::deno_core::_ops::OpDecl { + #[allow(non_camel_case_types)] + pub struct op_generics { + _unconstructable: ::std::marker::PhantomData<(T)>, } - #[inline(always)] - fn slow_function_impl(info: *const deno_core::v8::FunctionCallbackInfo) -> usize { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, + impl ::deno_core::_ops::Op for op_generics { + const NAME: &'static str = stringify!(op_generics); + const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( + ::deno_core::__op_name_fast!(op_generics), + false, + false, + 0usize as u8, + Self::v8_fn_ptr as _, + Self::v8_fn_ptr_metrics as _, + Some({ + use deno_core::v8::fast_api::Type; + use deno_core::v8::fast_api::CType; + deno_core::v8::fast_api::FastFunction::new_with_bigint( + &[Type::V8Value], + CType::Void, + Self::v8_fn_ptr_fast as *const ::std::ffi::c_void, + ) + }), + Some({ + use deno_core::v8::fast_api::Type; + use deno_core::v8::fast_api::CType; + deno_core::v8::fast_api::FastFunction::new_with_bigint( + &[Type::V8Value, Type::CallbackOptions], + CType::Void, + Self::v8_fn_ptr_fast_metrics as *const ::std::ffi::c_void, + ) + }), + ::deno_core::OpMetadata { + ..::deno_core::OpMetadata::default() + }, ); - let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { - &*info - }); - let result = { Self::call() }; - deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv); - return 0; } - extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { - Self::slow_function_impl(info); - } - extern "C" fn v8_fn_ptr_metrics(info: *const deno_core::v8::FunctionCallbackInfo) { - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_slow( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, - ); - let res = Self::slow_function_impl(info); - if res == 0 { - deno_core::_ops::dispatch_metrics_slow( + impl op_generics { + pub const fn name() -> &'static str { + stringify!(op_generics) + } + #[allow(clippy::too_many_arguments)] + extern "C" fn v8_fn_ptr_fast_metrics( + this: deno_core::v8::Local, + fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, + ) -> () { + let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; + let opctx = unsafe { + &*(deno_core::v8::Local::< + deno_core::v8::External, + >::cast(unsafe { fast_api_callback_options.data.data }) + .value() as *const deno_core::_ops::OpCtx) + }; + deno_core::_ops::dispatch_metrics_fast( + &opctx, + deno_core::_ops::OpMetricsEvent::Dispatched, + ); + let res = Self::v8_fn_ptr_fast(this); + deno_core::_ops::dispatch_metrics_fast( &opctx, deno_core::_ops::OpMetricsEvent::Completed, ); - } else { + res + } + #[allow(clippy::too_many_arguments)] + extern "C" fn v8_fn_ptr_fast( + _: deno_core::v8::Local, + ) -> () { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, + ); + let result = { Self::call() }; + result as _ + } + #[inline(always)] + fn slow_function_impl( + info: *const deno_core::v8::FunctionCallbackInfo, + ) -> usize { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, + ); + let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { + &*info + }); + let result = { Self::call() }; + deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv); + return 0; + } + extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { + Self::slow_function_impl(info); + } + extern "C" fn v8_fn_ptr_metrics( + info: *const deno_core::v8::FunctionCallbackInfo, + ) { + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; deno_core::_ops::dispatch_metrics_slow( &opctx, - deno_core::_ops::OpMetricsEvent::Error, + deno_core::_ops::OpMetricsEvent::Dispatched, ); + let res = Self::slow_function_impl(info); + if res == 0 { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Completed, + ); + } else { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Error, + ); + } } + #[inline(always)] + pub fn call() {} } - #[inline(always)] - pub fn call() {} + as ::deno_core::_ops::Op>::DECL } #[allow(non_camel_case_types)] -pub struct op_generics_static { - _unconstructable: ::std::marker::PhantomData<(T)>, -} -impl ::deno_core::_ops::Op for op_generics_static { - const NAME: &'static str = stringify!(op_generics_static); - const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( - ::deno_core::__op_name_fast!(op_generics_static), - false, - false, - 0usize as u8, - Self::v8_fn_ptr as _, - Self::v8_fn_ptr_metrics as _, - Some({ - use deno_core::v8::fast_api::Type; - use deno_core::v8::fast_api::CType; - deno_core::v8::fast_api::FastFunction::new_with_bigint( - &[Type::V8Value], - CType::Void, - Self::v8_fn_ptr_fast as *const ::std::ffi::c_void, - ) - }), - Some({ - use deno_core::v8::fast_api::Type; - use deno_core::v8::fast_api::CType; - deno_core::v8::fast_api::FastFunction::new_with_bigint( - &[Type::V8Value, Type::CallbackOptions], - CType::Void, - Self::v8_fn_ptr_fast_metrics as *const ::std::ffi::c_void, - ) - }), - ::deno_core::OpMetadata { - ..::deno_core::OpMetadata::default() - }, - ); -} -impl op_generics_static { - pub const fn name() -> &'static str { - stringify!(op_generics_static) - } - #[deprecated(note = "Use the const op::DECL instead")] - pub const fn decl() -> deno_core::_ops::OpDecl { - ::DECL +pub const fn op_generics_static() -> ::deno_core::_ops::OpDecl { + #[allow(non_camel_case_types)] + pub struct op_generics_static { + _unconstructable: ::std::marker::PhantomData<(T)>, } - #[allow(clippy::too_many_arguments)] - extern "C" fn v8_fn_ptr_fast_metrics( - this: deno_core::v8::Local, - fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, - ) -> () { - let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; - let opctx = unsafe { - &*(deno_core::v8::Local::< - deno_core::v8::External, - >::cast(unsafe { fast_api_callback_options.data.data }) - .value() as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_fast( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, + impl ::deno_core::_ops::Op for op_generics_static { + const NAME: &'static str = stringify!(op_generics_static); + const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( + ::deno_core::__op_name_fast!(op_generics_static), + false, + false, + 0usize as u8, + Self::v8_fn_ptr as _, + Self::v8_fn_ptr_metrics as _, + Some({ + use deno_core::v8::fast_api::Type; + use deno_core::v8::fast_api::CType; + deno_core::v8::fast_api::FastFunction::new_with_bigint( + &[Type::V8Value], + CType::Void, + Self::v8_fn_ptr_fast as *const ::std::ffi::c_void, + ) + }), + Some({ + use deno_core::v8::fast_api::Type; + use deno_core::v8::fast_api::CType; + deno_core::v8::fast_api::FastFunction::new_with_bigint( + &[Type::V8Value, Type::CallbackOptions], + CType::Void, + Self::v8_fn_ptr_fast_metrics as *const ::std::ffi::c_void, + ) + }), + ::deno_core::OpMetadata { + ..::deno_core::OpMetadata::default() + }, ); - let res = Self::v8_fn_ptr_fast(this); - deno_core::_ops::dispatch_metrics_fast( - &opctx, - deno_core::_ops::OpMetricsEvent::Completed, - ); - res - } - #[allow(clippy::too_many_arguments)] - extern "C" fn v8_fn_ptr_fast(_: deno_core::v8::Local) -> () { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, - ); - let result = { Self::call() }; - result as _ } - #[inline(always)] - fn slow_function_impl(info: *const deno_core::v8::FunctionCallbackInfo) -> usize { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, - ); - let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { - &*info - }); - let result = { Self::call() }; - deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv); - return 0; - } - extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { - Self::slow_function_impl(info); - } - extern "C" fn v8_fn_ptr_metrics(info: *const deno_core::v8::FunctionCallbackInfo) { - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_slow( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, - ); - let res = Self::slow_function_impl(info); - if res == 0 { - deno_core::_ops::dispatch_metrics_slow( + impl op_generics_static { + pub const fn name() -> &'static str { + stringify!(op_generics_static) + } + #[allow(clippy::too_many_arguments)] + extern "C" fn v8_fn_ptr_fast_metrics( + this: deno_core::v8::Local, + fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, + ) -> () { + let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; + let opctx = unsafe { + &*(deno_core::v8::Local::< + deno_core::v8::External, + >::cast(unsafe { fast_api_callback_options.data.data }) + .value() as *const deno_core::_ops::OpCtx) + }; + deno_core::_ops::dispatch_metrics_fast( + &opctx, + deno_core::_ops::OpMetricsEvent::Dispatched, + ); + let res = Self::v8_fn_ptr_fast(this); + deno_core::_ops::dispatch_metrics_fast( &opctx, deno_core::_ops::OpMetricsEvent::Completed, ); - } else { + res + } + #[allow(clippy::too_many_arguments)] + extern "C" fn v8_fn_ptr_fast( + _: deno_core::v8::Local, + ) -> () { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, + ); + let result = { Self::call() }; + result as _ + } + #[inline(always)] + fn slow_function_impl( + info: *const deno_core::v8::FunctionCallbackInfo, + ) -> usize { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, + ); + let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { + &*info + }); + let result = { Self::call() }; + deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv); + return 0; + } + extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { + Self::slow_function_impl(info); + } + extern "C" fn v8_fn_ptr_metrics( + info: *const deno_core::v8::FunctionCallbackInfo, + ) { + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; deno_core::_ops::dispatch_metrics_slow( &opctx, - deno_core::_ops::OpMetricsEvent::Error, + deno_core::_ops::OpMetricsEvent::Dispatched, ); + let res = Self::slow_function_impl(info); + if res == 0 { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Completed, + ); + } else { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Error, + ); + } } + #[inline(always)] + pub fn call() {} } - #[inline(always)] - pub fn call() {} + as ::deno_core::_ops::Op>::DECL } #[allow(non_camel_case_types)] -pub struct op_generics_static_where { - _unconstructable: ::std::marker::PhantomData<(T)>, -} -impl ::deno_core::_ops::Op for op_generics_static_where { - const NAME: &'static str = stringify!(op_generics_static_where); - const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( - ::deno_core::__op_name_fast!(op_generics_static_where), - false, - false, - 0usize as u8, - Self::v8_fn_ptr as _, - Self::v8_fn_ptr_metrics as _, - Some({ - use deno_core::v8::fast_api::Type; - use deno_core::v8::fast_api::CType; - deno_core::v8::fast_api::FastFunction::new_with_bigint( - &[Type::V8Value], - CType::Void, - Self::v8_fn_ptr_fast as *const ::std::ffi::c_void, - ) - }), - Some({ - use deno_core::v8::fast_api::Type; - use deno_core::v8::fast_api::CType; - deno_core::v8::fast_api::FastFunction::new_with_bigint( - &[Type::V8Value, Type::CallbackOptions], - CType::Void, - Self::v8_fn_ptr_fast_metrics as *const ::std::ffi::c_void, - ) - }), - ::deno_core::OpMetadata { - ..::deno_core::OpMetadata::default() - }, - ); -} -impl op_generics_static_where { - pub const fn name() -> &'static str { - stringify!(op_generics_static_where) - } - #[deprecated(note = "Use the const op::DECL instead")] - pub const fn decl() -> deno_core::_ops::OpDecl { - ::DECL - } - #[allow(clippy::too_many_arguments)] - extern "C" fn v8_fn_ptr_fast_metrics( - this: deno_core::v8::Local, - fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, - ) -> () { - let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; - let opctx = unsafe { - &*(deno_core::v8::Local::< - deno_core::v8::External, - >::cast(unsafe { fast_api_callback_options.data.data }) - .value() as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_fast( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, - ); - let res = Self::v8_fn_ptr_fast(this); - deno_core::_ops::dispatch_metrics_fast( - &opctx, - deno_core::_ops::OpMetricsEvent::Completed, - ); - res - } - #[allow(clippy::too_many_arguments)] - extern "C" fn v8_fn_ptr_fast(_: deno_core::v8::Local) -> () { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, - ); - let result = { Self::call() }; - result as _ +pub const fn op_generics_static_where() -> ::deno_core::_ops::OpDecl { + #[allow(non_camel_case_types)] + pub struct op_generics_static_where { + _unconstructable: ::std::marker::PhantomData<(T)>, } - #[inline(always)] - fn slow_function_impl(info: *const deno_core::v8::FunctionCallbackInfo) -> usize { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, + impl ::deno_core::_ops::Op for op_generics_static_where { + const NAME: &'static str = stringify!(op_generics_static_where); + const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( + ::deno_core::__op_name_fast!(op_generics_static_where), + false, + false, + 0usize as u8, + Self::v8_fn_ptr as _, + Self::v8_fn_ptr_metrics as _, + Some({ + use deno_core::v8::fast_api::Type; + use deno_core::v8::fast_api::CType; + deno_core::v8::fast_api::FastFunction::new_with_bigint( + &[Type::V8Value], + CType::Void, + Self::v8_fn_ptr_fast as *const ::std::ffi::c_void, + ) + }), + Some({ + use deno_core::v8::fast_api::Type; + use deno_core::v8::fast_api::CType; + deno_core::v8::fast_api::FastFunction::new_with_bigint( + &[Type::V8Value, Type::CallbackOptions], + CType::Void, + Self::v8_fn_ptr_fast_metrics as *const ::std::ffi::c_void, + ) + }), + ::deno_core::OpMetadata { + ..::deno_core::OpMetadata::default() + }, ); - let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { - &*info - }); - let result = { Self::call() }; - deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv); - return 0; - } - extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { - Self::slow_function_impl(info); } - extern "C" fn v8_fn_ptr_metrics(info: *const deno_core::v8::FunctionCallbackInfo) { - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_slow( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, - ); - let res = Self::slow_function_impl(info); - if res == 0 { - deno_core::_ops::dispatch_metrics_slow( + impl op_generics_static_where { + pub const fn name() -> &'static str { + stringify!(op_generics_static_where) + } + #[allow(clippy::too_many_arguments)] + extern "C" fn v8_fn_ptr_fast_metrics( + this: deno_core::v8::Local, + fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, + ) -> () { + let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; + let opctx = unsafe { + &*(deno_core::v8::Local::< + deno_core::v8::External, + >::cast(unsafe { fast_api_callback_options.data.data }) + .value() as *const deno_core::_ops::OpCtx) + }; + deno_core::_ops::dispatch_metrics_fast( + &opctx, + deno_core::_ops::OpMetricsEvent::Dispatched, + ); + let res = Self::v8_fn_ptr_fast(this); + deno_core::_ops::dispatch_metrics_fast( &opctx, deno_core::_ops::OpMetricsEvent::Completed, ); - } else { + res + } + #[allow(clippy::too_many_arguments)] + extern "C" fn v8_fn_ptr_fast( + _: deno_core::v8::Local, + ) -> () { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, + ); + let result = { Self::call() }; + result as _ + } + #[inline(always)] + fn slow_function_impl( + info: *const deno_core::v8::FunctionCallbackInfo, + ) -> usize { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, + ); + let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { + &*info + }); + let result = { Self::call() }; + deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv); + return 0; + } + extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { + Self::slow_function_impl(info); + } + extern "C" fn v8_fn_ptr_metrics( + info: *const deno_core::v8::FunctionCallbackInfo, + ) { + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; deno_core::_ops::dispatch_metrics_slow( &opctx, - deno_core::_ops::OpMetricsEvent::Error, + deno_core::_ops::OpMetricsEvent::Dispatched, ); + let res = Self::slow_function_impl(info); + if res == 0 { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Completed, + ); + } else { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Error, + ); + } } + #[inline(always)] + pub fn call() + where + T: Trait + 'static, + {} } - #[inline(always)] - pub fn call() - where - T: Trait + 'static, - {} + as ::deno_core::_ops::Op>::DECL } diff --git a/ops/op2/test_cases/sync/nofast.out b/ops/op2/test_cases/sync/nofast.out index 316672f59..92753e18e 100644 --- a/ops/op2/test_cases/sync/nofast.out +++ b/ops/op2/test_cases/sync/nofast.out @@ -1,107 +1,111 @@ #[allow(non_camel_case_types)] -struct op_nofast { - _unconstructable: ::std::marker::PhantomData<()>, -} -impl ::deno_core::_ops::Op for op_nofast { - const NAME: &'static str = stringify!(op_nofast); - const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( - ::deno_core::__op_name_fast!(op_nofast), - false, - false, - 2usize as u8, - Self::v8_fn_ptr as _, - Self::v8_fn_ptr_metrics as _, - None, - None, - ::deno_core::OpMetadata { - ..::deno_core::OpMetadata::default() - }, - ); -} -impl op_nofast { - pub const fn name() -> &'static str { - stringify!(op_nofast) +const fn op_nofast() -> ::deno_core::_ops::OpDecl { + #[allow(non_camel_case_types)] + struct op_nofast { + _unconstructable: ::std::marker::PhantomData<()>, } - #[deprecated(note = "Use the const op::DECL instead")] - pub const fn decl() -> deno_core::_ops::OpDecl { - ::DECL - } - #[inline(always)] - fn slow_function_impl(info: *const deno_core::v8::FunctionCallbackInfo) -> usize { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, + impl ::deno_core::_ops::Op for op_nofast { + const NAME: &'static str = stringify!(op_nofast); + const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( + ::deno_core::__op_name_fast!(op_nofast), + false, + false, + 2usize as u8, + Self::v8_fn_ptr as _, + Self::v8_fn_ptr_metrics as _, + None, + None, + ::deno_core::OpMetadata { + ..::deno_core::OpMetadata::default() + }, ); - let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { - &*info - }); - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let result = { - let arg0 = args.get(0usize as i32); - let Some(arg0) = deno_core::_ops::to_u32_option(&arg0) else { - let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; - let msg = deno_core::v8::String::new_from_one_byte( - &mut scope, - "expected u32".as_bytes(), - deno_core::v8::NewStringType::Normal, - ) - .unwrap(); - let exc = deno_core::v8::Exception::type_error(&mut scope, msg); - scope.throw_exception(exc); - return 1; - }; - let arg0 = arg0 as _; - let arg1 = args.get(1usize as i32); - let Some(arg1) = deno_core::_ops::to_u32_option(&arg1) else { - let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; - let msg = deno_core::v8::String::new_from_one_byte( - &mut scope, - "expected u32".as_bytes(), - deno_core::v8::NewStringType::Normal, - ) - .unwrap(); - let exc = deno_core::v8::Exception::type_error(&mut scope, msg); - scope.throw_exception(exc); - return 1; - }; - let arg1 = arg1 as _; - Self::call(arg0, arg1) - }; - deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv); - return 0; - } - extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { - Self::slow_function_impl(info); } - extern "C" fn v8_fn_ptr_metrics(info: *const deno_core::v8::FunctionCallbackInfo) { - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_slow( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, - ); - let res = Self::slow_function_impl(info); - if res == 0 { - deno_core::_ops::dispatch_metrics_slow( - &opctx, - deno_core::_ops::OpMetricsEvent::Completed, + impl op_nofast { + pub const fn name() -> &'static str { + stringify!(op_nofast) + } + #[inline(always)] + fn slow_function_impl( + info: *const deno_core::v8::FunctionCallbackInfo, + ) -> usize { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, ); - } else { + let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { + &*info + }); + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let result = { + let arg0 = args.get(0usize as i32); + let Some(arg0) = deno_core::_ops::to_u32_option(&arg0) else { + let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; + let msg = deno_core::v8::String::new_from_one_byte( + &mut scope, + "expected u32".as_bytes(), + deno_core::v8::NewStringType::Normal, + ) + .unwrap(); + let exc = deno_core::v8::Exception::type_error(&mut scope, msg); + scope.throw_exception(exc); + return 1; + }; + let arg0 = arg0 as _; + let arg1 = args.get(1usize as i32); + let Some(arg1) = deno_core::_ops::to_u32_option(&arg1) else { + let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; + let msg = deno_core::v8::String::new_from_one_byte( + &mut scope, + "expected u32".as_bytes(), + deno_core::v8::NewStringType::Normal, + ) + .unwrap(); + let exc = deno_core::v8::Exception::type_error(&mut scope, msg); + scope.throw_exception(exc); + return 1; + }; + let arg1 = arg1 as _; + Self::call(arg0, arg1) + }; + deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv); + return 0; + } + extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { + Self::slow_function_impl(info); + } + extern "C" fn v8_fn_ptr_metrics( + info: *const deno_core::v8::FunctionCallbackInfo, + ) { + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; deno_core::_ops::dispatch_metrics_slow( &opctx, - deno_core::_ops::OpMetricsEvent::Error, + deno_core::_ops::OpMetricsEvent::Dispatched, ); + let res = Self::slow_function_impl(info); + if res == 0 { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Completed, + ); + } else { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Error, + ); + } + } + #[inline(always)] + fn call(a: u32, b: u32) -> u32 { + a + b } } - #[inline(always)] - fn call(a: u32, b: u32) -> u32 { - a + b - } + ::DECL } diff --git a/ops/op2/test_cases/sync/op_state_attr.out b/ops/op2/test_cases/sync/op_state_attr.out index 4e6cd73bc..ed6c15aa9 100644 --- a/ops/op2/test_cases/sync/op_state_attr.out +++ b/ops/op2/test_cases/sync/op_state_attr.out @@ -1,150 +1,154 @@ #[allow(non_camel_case_types)] -struct op_state_rc { - _unconstructable: ::std::marker::PhantomData<()>, -} -impl ::deno_core::_ops::Op for op_state_rc { - const NAME: &'static str = stringify!(op_state_rc); - const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( - ::deno_core::__op_name_fast!(op_state_rc), - false, - false, - 2usize as u8, - Self::v8_fn_ptr as _, - Self::v8_fn_ptr_metrics as _, - Some({ - use deno_core::v8::fast_api::Type; - use deno_core::v8::fast_api::CType; - deno_core::v8::fast_api::FastFunction::new_with_bigint( - &[Type::V8Value, Type::CallbackOptions], - CType::Void, - Self::v8_fn_ptr_fast as *const ::std::ffi::c_void, - ) - }), - Some({ - use deno_core::v8::fast_api::Type; - use deno_core::v8::fast_api::CType; - deno_core::v8::fast_api::FastFunction::new_with_bigint( - &[Type::V8Value, Type::CallbackOptions], - CType::Void, - Self::v8_fn_ptr_fast_metrics as *const ::std::ffi::c_void, - ) - }), - ::deno_core::OpMetadata { - ..::deno_core::OpMetadata::default() - }, - ); -} -impl op_state_rc { - pub const fn name() -> &'static str { - stringify!(op_state_rc) - } - #[deprecated(note = "Use the const op::DECL instead")] - pub const fn decl() -> deno_core::_ops::OpDecl { - ::DECL - } - #[allow(clippy::too_many_arguments)] - extern "C" fn v8_fn_ptr_fast_metrics( - this: deno_core::v8::Local, - fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, - ) -> () { - let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; - let opctx = unsafe { - &*(deno_core::v8::Local::< - deno_core::v8::External, - >::cast(unsafe { fast_api_callback_options.data.data }) - .value() as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_fast( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, - ); - let res = Self::v8_fn_ptr_fast(this, fast_api_callback_options); - deno_core::_ops::dispatch_metrics_fast( - &opctx, - deno_core::_ops::OpMetricsEvent::Completed, - ); - res - } - #[allow(clippy::too_many_arguments)] - extern "C" fn v8_fn_ptr_fast( - _: deno_core::v8::Local, - fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, - ) -> () { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, - ); - let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; - let opctx = unsafe { - &*(deno_core::v8::Local::< - deno_core::v8::External, - >::cast(unsafe { fast_api_callback_options.data.data }) - .value() as *const deno_core::_ops::OpCtx) - }; - let result = { - let arg0 = ::std::cell::RefCell::borrow(&opctx.state); - let arg0 = deno_core::_ops::opstate_borrow::(&arg0); - let arg1 = &::std::cell::RefCell::borrow(&opctx.state); - let arg1 = arg1.try_borrow::(); - Self::call(arg0, arg1) - }; - result as _ +const fn op_state_rc() -> ::deno_core::_ops::OpDecl { + #[allow(non_camel_case_types)] + struct op_state_rc { + _unconstructable: ::std::marker::PhantomData<()>, } - #[inline(always)] - fn slow_function_impl(info: *const deno_core::v8::FunctionCallbackInfo) -> usize { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, + impl ::deno_core::_ops::Op for op_state_rc { + const NAME: &'static str = stringify!(op_state_rc); + const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( + ::deno_core::__op_name_fast!(op_state_rc), + false, + false, + 2usize as u8, + Self::v8_fn_ptr as _, + Self::v8_fn_ptr_metrics as _, + Some({ + use deno_core::v8::fast_api::Type; + use deno_core::v8::fast_api::CType; + deno_core::v8::fast_api::FastFunction::new_with_bigint( + &[Type::V8Value, Type::CallbackOptions], + CType::Void, + Self::v8_fn_ptr_fast as *const ::std::ffi::c_void, + ) + }), + Some({ + use deno_core::v8::fast_api::Type; + use deno_core::v8::fast_api::CType; + deno_core::v8::fast_api::FastFunction::new_with_bigint( + &[Type::V8Value, Type::CallbackOptions], + CType::Void, + Self::v8_fn_ptr_fast_metrics as *const ::std::ffi::c_void, + ) + }), + ::deno_core::OpMetadata { + ..::deno_core::OpMetadata::default() + }, ); - let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { - &*info - }); - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - let opstate = &opctx.state; - let result = { - let arg0 = ::std::cell::RefCell::borrow(&opstate); - let arg0 = deno_core::_ops::opstate_borrow::(&arg0); - let arg1 = &::std::cell::RefCell::borrow(&opstate); - let arg1 = arg1.try_borrow::(); - Self::call(arg0, arg1) - }; - deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv); - return 0; } - extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { - Self::slow_function_impl(info); - } - extern "C" fn v8_fn_ptr_metrics(info: *const deno_core::v8::FunctionCallbackInfo) { - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_slow( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, - ); - let res = Self::slow_function_impl(info); - if res == 0 { - deno_core::_ops::dispatch_metrics_slow( + impl op_state_rc { + pub const fn name() -> &'static str { + stringify!(op_state_rc) + } + #[allow(clippy::too_many_arguments)] + extern "C" fn v8_fn_ptr_fast_metrics( + this: deno_core::v8::Local, + fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, + ) -> () { + let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; + let opctx = unsafe { + &*(deno_core::v8::Local::< + deno_core::v8::External, + >::cast(unsafe { fast_api_callback_options.data.data }) + .value() as *const deno_core::_ops::OpCtx) + }; + deno_core::_ops::dispatch_metrics_fast( + &opctx, + deno_core::_ops::OpMetricsEvent::Dispatched, + ); + let res = Self::v8_fn_ptr_fast(this, fast_api_callback_options); + deno_core::_ops::dispatch_metrics_fast( &opctx, deno_core::_ops::OpMetricsEvent::Completed, ); - } else { + res + } + #[allow(clippy::too_many_arguments)] + extern "C" fn v8_fn_ptr_fast( + _: deno_core::v8::Local, + fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, + ) -> () { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, + ); + let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; + let opctx = unsafe { + &*(deno_core::v8::Local::< + deno_core::v8::External, + >::cast(unsafe { fast_api_callback_options.data.data }) + .value() as *const deno_core::_ops::OpCtx) + }; + let result = { + let arg0 = ::std::cell::RefCell::borrow(&opctx.state); + let arg0 = deno_core::_ops::opstate_borrow::(&arg0); + let arg1 = &::std::cell::RefCell::borrow(&opctx.state); + let arg1 = arg1.try_borrow::(); + Self::call(arg0, arg1) + }; + result as _ + } + #[inline(always)] + fn slow_function_impl( + info: *const deno_core::v8::FunctionCallbackInfo, + ) -> usize { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, + ); + let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { + &*info + }); + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; + let opstate = &opctx.state; + let result = { + let arg0 = ::std::cell::RefCell::borrow(&opstate); + let arg0 = deno_core::_ops::opstate_borrow::(&arg0); + let arg1 = &::std::cell::RefCell::borrow(&opstate); + let arg1 = arg1.try_borrow::(); + Self::call(arg0, arg1) + }; + deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv); + return 0; + } + extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { + Self::slow_function_impl(info); + } + extern "C" fn v8_fn_ptr_metrics( + info: *const deno_core::v8::FunctionCallbackInfo, + ) { + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; deno_core::_ops::dispatch_metrics_slow( &opctx, - deno_core::_ops::OpMetricsEvent::Error, + deno_core::_ops::OpMetricsEvent::Dispatched, ); + let res = Self::slow_function_impl(info); + if res == 0 { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Completed, + ); + } else { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Error, + ); + } } + #[inline(always)] + fn call(_arg: &Something, _arg_opt: Option<&Something>) {} } - #[inline(always)] - fn call(_arg: &Something, _arg_opt: Option<&Something>) {} + ::DECL } diff --git a/ops/op2/test_cases/sync/op_state_rc.out b/ops/op2/test_cases/sync/op_state_rc.out index 64651898d..98825d589 100644 --- a/ops/op2/test_cases/sync/op_state_rc.out +++ b/ops/op2/test_cases/sync/op_state_rc.out @@ -1,144 +1,148 @@ #[allow(non_camel_case_types)] -struct op_state_rc { - _unconstructable: ::std::marker::PhantomData<()>, -} -impl ::deno_core::_ops::Op for op_state_rc { - const NAME: &'static str = stringify!(op_state_rc); - const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( - ::deno_core::__op_name_fast!(op_state_rc), - false, - false, - 1usize as u8, - Self::v8_fn_ptr as _, - Self::v8_fn_ptr_metrics as _, - Some({ - use deno_core::v8::fast_api::Type; - use deno_core::v8::fast_api::CType; - deno_core::v8::fast_api::FastFunction::new_with_bigint( - &[Type::V8Value, Type::CallbackOptions], - CType::Void, - Self::v8_fn_ptr_fast as *const ::std::ffi::c_void, - ) - }), - Some({ - use deno_core::v8::fast_api::Type; - use deno_core::v8::fast_api::CType; - deno_core::v8::fast_api::FastFunction::new_with_bigint( - &[Type::V8Value, Type::CallbackOptions], - CType::Void, - Self::v8_fn_ptr_fast_metrics as *const ::std::ffi::c_void, - ) - }), - ::deno_core::OpMetadata { - ..::deno_core::OpMetadata::default() - }, - ); -} -impl op_state_rc { - pub const fn name() -> &'static str { - stringify!(op_state_rc) - } - #[deprecated(note = "Use the const op::DECL instead")] - pub const fn decl() -> deno_core::_ops::OpDecl { - ::DECL - } - #[allow(clippy::too_many_arguments)] - extern "C" fn v8_fn_ptr_fast_metrics( - this: deno_core::v8::Local, - fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, - ) -> () { - let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; - let opctx = unsafe { - &*(deno_core::v8::Local::< - deno_core::v8::External, - >::cast(unsafe { fast_api_callback_options.data.data }) - .value() as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_fast( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, - ); - let res = Self::v8_fn_ptr_fast(this, fast_api_callback_options); - deno_core::_ops::dispatch_metrics_fast( - &opctx, - deno_core::_ops::OpMetricsEvent::Completed, - ); - res - } - #[allow(clippy::too_many_arguments)] - extern "C" fn v8_fn_ptr_fast( - _: deno_core::v8::Local, - fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, - ) -> () { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, - ); - let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; - let opctx = unsafe { - &*(deno_core::v8::Local::< - deno_core::v8::External, - >::cast(unsafe { fast_api_callback_options.data.data }) - .value() as *const deno_core::_ops::OpCtx) - }; - let result = { - let arg0 = opctx.state.clone(); - Self::call(arg0) - }; - result as _ +const fn op_state_rc() -> ::deno_core::_ops::OpDecl { + #[allow(non_camel_case_types)] + struct op_state_rc { + _unconstructable: ::std::marker::PhantomData<()>, } - #[inline(always)] - fn slow_function_impl(info: *const deno_core::v8::FunctionCallbackInfo) -> usize { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, + impl ::deno_core::_ops::Op for op_state_rc { + const NAME: &'static str = stringify!(op_state_rc); + const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( + ::deno_core::__op_name_fast!(op_state_rc), + false, + false, + 1usize as u8, + Self::v8_fn_ptr as _, + Self::v8_fn_ptr_metrics as _, + Some({ + use deno_core::v8::fast_api::Type; + use deno_core::v8::fast_api::CType; + deno_core::v8::fast_api::FastFunction::new_with_bigint( + &[Type::V8Value, Type::CallbackOptions], + CType::Void, + Self::v8_fn_ptr_fast as *const ::std::ffi::c_void, + ) + }), + Some({ + use deno_core::v8::fast_api::Type; + use deno_core::v8::fast_api::CType; + deno_core::v8::fast_api::FastFunction::new_with_bigint( + &[Type::V8Value, Type::CallbackOptions], + CType::Void, + Self::v8_fn_ptr_fast_metrics as *const ::std::ffi::c_void, + ) + }), + ::deno_core::OpMetadata { + ..::deno_core::OpMetadata::default() + }, ); - let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { - &*info - }); - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - let opstate = &opctx.state; - let result = { - let arg0 = opstate.clone(); - Self::call(arg0) - }; - deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv); - return 0; } - extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { - Self::slow_function_impl(info); - } - extern "C" fn v8_fn_ptr_metrics(info: *const deno_core::v8::FunctionCallbackInfo) { - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_slow( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, - ); - let res = Self::slow_function_impl(info); - if res == 0 { - deno_core::_ops::dispatch_metrics_slow( + impl op_state_rc { + pub const fn name() -> &'static str { + stringify!(op_state_rc) + } + #[allow(clippy::too_many_arguments)] + extern "C" fn v8_fn_ptr_fast_metrics( + this: deno_core::v8::Local, + fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, + ) -> () { + let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; + let opctx = unsafe { + &*(deno_core::v8::Local::< + deno_core::v8::External, + >::cast(unsafe { fast_api_callback_options.data.data }) + .value() as *const deno_core::_ops::OpCtx) + }; + deno_core::_ops::dispatch_metrics_fast( + &opctx, + deno_core::_ops::OpMetricsEvent::Dispatched, + ); + let res = Self::v8_fn_ptr_fast(this, fast_api_callback_options); + deno_core::_ops::dispatch_metrics_fast( &opctx, deno_core::_ops::OpMetricsEvent::Completed, ); - } else { + res + } + #[allow(clippy::too_many_arguments)] + extern "C" fn v8_fn_ptr_fast( + _: deno_core::v8::Local, + fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, + ) -> () { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, + ); + let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; + let opctx = unsafe { + &*(deno_core::v8::Local::< + deno_core::v8::External, + >::cast(unsafe { fast_api_callback_options.data.data }) + .value() as *const deno_core::_ops::OpCtx) + }; + let result = { + let arg0 = opctx.state.clone(); + Self::call(arg0) + }; + result as _ + } + #[inline(always)] + fn slow_function_impl( + info: *const deno_core::v8::FunctionCallbackInfo, + ) -> usize { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, + ); + let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { + &*info + }); + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; + let opstate = &opctx.state; + let result = { + let arg0 = opstate.clone(); + Self::call(arg0) + }; + deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv); + return 0; + } + extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { + Self::slow_function_impl(info); + } + extern "C" fn v8_fn_ptr_metrics( + info: *const deno_core::v8::FunctionCallbackInfo, + ) { + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; deno_core::_ops::dispatch_metrics_slow( &opctx, - deno_core::_ops::OpMetricsEvent::Error, + deno_core::_ops::OpMetricsEvent::Dispatched, ); + let res = Self::slow_function_impl(info); + if res == 0 { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Completed, + ); + } else { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Error, + ); + } } + #[inline(always)] + fn call(_state: Rc>) {} } - #[inline(always)] - fn call(_state: Rc>) {} + ::DECL } diff --git a/ops/op2/test_cases/sync/op_state_ref.out b/ops/op2/test_cases/sync/op_state_ref.out index a914a5758..63ecf4842 100644 --- a/ops/op2/test_cases/sync/op_state_ref.out +++ b/ops/op2/test_cases/sync/op_state_ref.out @@ -1,560 +1,576 @@ #[allow(non_camel_case_types)] -struct op_state_ref { - _unconstructable: ::std::marker::PhantomData<()>, -} -impl ::deno_core::_ops::Op for op_state_ref { - const NAME: &'static str = stringify!(op_state_ref); - const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( - ::deno_core::__op_name_fast!(op_state_ref), - false, - false, - 1usize as u8, - Self::v8_fn_ptr as _, - Self::v8_fn_ptr_metrics as _, - Some({ - use deno_core::v8::fast_api::Type; - use deno_core::v8::fast_api::CType; - deno_core::v8::fast_api::FastFunction::new_with_bigint( - &[Type::V8Value, Type::CallbackOptions], - CType::Void, - Self::v8_fn_ptr_fast as *const ::std::ffi::c_void, - ) - }), - Some({ - use deno_core::v8::fast_api::Type; - use deno_core::v8::fast_api::CType; - deno_core::v8::fast_api::FastFunction::new_with_bigint( - &[Type::V8Value, Type::CallbackOptions], - CType::Void, - Self::v8_fn_ptr_fast_metrics as *const ::std::ffi::c_void, - ) - }), - ::deno_core::OpMetadata { - ..::deno_core::OpMetadata::default() - }, - ); -} -impl op_state_ref { - pub const fn name() -> &'static str { - stringify!(op_state_ref) - } - #[deprecated(note = "Use the const op::DECL instead")] - pub const fn decl() -> deno_core::_ops::OpDecl { - ::DECL - } - #[allow(clippy::too_many_arguments)] - extern "C" fn v8_fn_ptr_fast_metrics( - this: deno_core::v8::Local, - fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, - ) -> () { - let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; - let opctx = unsafe { - &*(deno_core::v8::Local::< - deno_core::v8::External, - >::cast(unsafe { fast_api_callback_options.data.data }) - .value() as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_fast( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, - ); - let res = Self::v8_fn_ptr_fast(this, fast_api_callback_options); - deno_core::_ops::dispatch_metrics_fast( - &opctx, - deno_core::_ops::OpMetricsEvent::Completed, - ); - res +const fn op_state_ref() -> ::deno_core::_ops::OpDecl { + #[allow(non_camel_case_types)] + struct op_state_ref { + _unconstructable: ::std::marker::PhantomData<()>, } - #[allow(clippy::too_many_arguments)] - extern "C" fn v8_fn_ptr_fast( - _: deno_core::v8::Local, - fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, - ) -> () { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, + impl ::deno_core::_ops::Op for op_state_ref { + const NAME: &'static str = stringify!(op_state_ref); + const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( + ::deno_core::__op_name_fast!(op_state_ref), + false, + false, + 1usize as u8, + Self::v8_fn_ptr as _, + Self::v8_fn_ptr_metrics as _, + Some({ + use deno_core::v8::fast_api::Type; + use deno_core::v8::fast_api::CType; + deno_core::v8::fast_api::FastFunction::new_with_bigint( + &[Type::V8Value, Type::CallbackOptions], + CType::Void, + Self::v8_fn_ptr_fast as *const ::std::ffi::c_void, + ) + }), + Some({ + use deno_core::v8::fast_api::Type; + use deno_core::v8::fast_api::CType; + deno_core::v8::fast_api::FastFunction::new_with_bigint( + &[Type::V8Value, Type::CallbackOptions], + CType::Void, + Self::v8_fn_ptr_fast_metrics as *const ::std::ffi::c_void, + ) + }), + ::deno_core::OpMetadata { + ..::deno_core::OpMetadata::default() + }, ); - let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; - let opctx = unsafe { - &*(deno_core::v8::Local::< - deno_core::v8::External, - >::cast(unsafe { fast_api_callback_options.data.data }) - .value() as *const deno_core::_ops::OpCtx) - }; - let result = { - let arg0 = &::std::cell::RefCell::borrow(&opctx.state); - Self::call(arg0) - }; - result as _ } - #[inline(always)] - fn slow_function_impl(info: *const deno_core::v8::FunctionCallbackInfo) -> usize { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, - ); - let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { - &*info - }); - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - let opstate = &opctx.state; - let result = { - let arg0 = &::std::cell::RefCell::borrow(&opstate); - Self::call(arg0) - }; - deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv); - return 0; - } - extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { - Self::slow_function_impl(info); - } - extern "C" fn v8_fn_ptr_metrics(info: *const deno_core::v8::FunctionCallbackInfo) { - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_slow( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, - ); - let res = Self::slow_function_impl(info); - if res == 0 { - deno_core::_ops::dispatch_metrics_slow( + impl op_state_ref { + pub const fn name() -> &'static str { + stringify!(op_state_ref) + } + #[allow(clippy::too_many_arguments)] + extern "C" fn v8_fn_ptr_fast_metrics( + this: deno_core::v8::Local, + fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, + ) -> () { + let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; + let opctx = unsafe { + &*(deno_core::v8::Local::< + deno_core::v8::External, + >::cast(unsafe { fast_api_callback_options.data.data }) + .value() as *const deno_core::_ops::OpCtx) + }; + deno_core::_ops::dispatch_metrics_fast( + &opctx, + deno_core::_ops::OpMetricsEvent::Dispatched, + ); + let res = Self::v8_fn_ptr_fast(this, fast_api_callback_options); + deno_core::_ops::dispatch_metrics_fast( &opctx, deno_core::_ops::OpMetricsEvent::Completed, ); - } else { + res + } + #[allow(clippy::too_many_arguments)] + extern "C" fn v8_fn_ptr_fast( + _: deno_core::v8::Local, + fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, + ) -> () { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, + ); + let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; + let opctx = unsafe { + &*(deno_core::v8::Local::< + deno_core::v8::External, + >::cast(unsafe { fast_api_callback_options.data.data }) + .value() as *const deno_core::_ops::OpCtx) + }; + let result = { + let arg0 = &::std::cell::RefCell::borrow(&opctx.state); + Self::call(arg0) + }; + result as _ + } + #[inline(always)] + fn slow_function_impl( + info: *const deno_core::v8::FunctionCallbackInfo, + ) -> usize { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, + ); + let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { + &*info + }); + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; + let opstate = &opctx.state; + let result = { + let arg0 = &::std::cell::RefCell::borrow(&opstate); + Self::call(arg0) + }; + deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv); + return 0; + } + extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { + Self::slow_function_impl(info); + } + extern "C" fn v8_fn_ptr_metrics( + info: *const deno_core::v8::FunctionCallbackInfo, + ) { + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; deno_core::_ops::dispatch_metrics_slow( &opctx, - deno_core::_ops::OpMetricsEvent::Error, + deno_core::_ops::OpMetricsEvent::Dispatched, ); + let res = Self::slow_function_impl(info); + if res == 0 { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Completed, + ); + } else { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Error, + ); + } } + #[inline(always)] + fn call(_state: &OpState) {} } - #[inline(always)] - fn call(_state: &OpState) {} + ::DECL } #[allow(non_camel_case_types)] -struct op_state_mut { - _unconstructable: ::std::marker::PhantomData<()>, -} -impl ::deno_core::_ops::Op for op_state_mut { - const NAME: &'static str = stringify!(op_state_mut); - const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( - ::deno_core::__op_name_fast!(op_state_mut), - false, - false, - 1usize as u8, - Self::v8_fn_ptr as _, - Self::v8_fn_ptr_metrics as _, - Some({ - use deno_core::v8::fast_api::Type; - use deno_core::v8::fast_api::CType; - deno_core::v8::fast_api::FastFunction::new_with_bigint( - &[Type::V8Value, Type::CallbackOptions], - CType::Void, - Self::v8_fn_ptr_fast as *const ::std::ffi::c_void, - ) - }), - Some({ - use deno_core::v8::fast_api::Type; - use deno_core::v8::fast_api::CType; - deno_core::v8::fast_api::FastFunction::new_with_bigint( - &[Type::V8Value, Type::CallbackOptions], - CType::Void, - Self::v8_fn_ptr_fast_metrics as *const ::std::ffi::c_void, - ) - }), - ::deno_core::OpMetadata { - ..::deno_core::OpMetadata::default() - }, - ); -} -impl op_state_mut { - pub const fn name() -> &'static str { - stringify!(op_state_mut) - } - #[deprecated(note = "Use the const op::DECL instead")] - pub const fn decl() -> deno_core::_ops::OpDecl { - ::DECL - } - #[allow(clippy::too_many_arguments)] - extern "C" fn v8_fn_ptr_fast_metrics( - this: deno_core::v8::Local, - fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, - ) -> () { - let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; - let opctx = unsafe { - &*(deno_core::v8::Local::< - deno_core::v8::External, - >::cast(unsafe { fast_api_callback_options.data.data }) - .value() as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_fast( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, - ); - let res = Self::v8_fn_ptr_fast(this, fast_api_callback_options); - deno_core::_ops::dispatch_metrics_fast( - &opctx, - deno_core::_ops::OpMetricsEvent::Completed, - ); - res - } - #[allow(clippy::too_many_arguments)] - extern "C" fn v8_fn_ptr_fast( - _: deno_core::v8::Local, - fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, - ) -> () { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, - ); - let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; - let opctx = unsafe { - &*(deno_core::v8::Local::< - deno_core::v8::External, - >::cast(unsafe { fast_api_callback_options.data.data }) - .value() as *const deno_core::_ops::OpCtx) - }; - let result = { - let arg0 = &mut ::std::cell::RefCell::borrow_mut(&opctx.state); - Self::call(arg0) - }; - result as _ +const fn op_state_mut() -> ::deno_core::_ops::OpDecl { + #[allow(non_camel_case_types)] + struct op_state_mut { + _unconstructable: ::std::marker::PhantomData<()>, } - #[inline(always)] - fn slow_function_impl(info: *const deno_core::v8::FunctionCallbackInfo) -> usize { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, + impl ::deno_core::_ops::Op for op_state_mut { + const NAME: &'static str = stringify!(op_state_mut); + const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( + ::deno_core::__op_name_fast!(op_state_mut), + false, + false, + 1usize as u8, + Self::v8_fn_ptr as _, + Self::v8_fn_ptr_metrics as _, + Some({ + use deno_core::v8::fast_api::Type; + use deno_core::v8::fast_api::CType; + deno_core::v8::fast_api::FastFunction::new_with_bigint( + &[Type::V8Value, Type::CallbackOptions], + CType::Void, + Self::v8_fn_ptr_fast as *const ::std::ffi::c_void, + ) + }), + Some({ + use deno_core::v8::fast_api::Type; + use deno_core::v8::fast_api::CType; + deno_core::v8::fast_api::FastFunction::new_with_bigint( + &[Type::V8Value, Type::CallbackOptions], + CType::Void, + Self::v8_fn_ptr_fast_metrics as *const ::std::ffi::c_void, + ) + }), + ::deno_core::OpMetadata { + ..::deno_core::OpMetadata::default() + }, ); - let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { - &*info - }); - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - let opstate = &opctx.state; - let result = { - let arg0 = &mut ::std::cell::RefCell::borrow_mut(&opstate); - Self::call(arg0) - }; - deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv); - return 0; - } - extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { - Self::slow_function_impl(info); } - extern "C" fn v8_fn_ptr_metrics(info: *const deno_core::v8::FunctionCallbackInfo) { - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_slow( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, - ); - let res = Self::slow_function_impl(info); - if res == 0 { - deno_core::_ops::dispatch_metrics_slow( + impl op_state_mut { + pub const fn name() -> &'static str { + stringify!(op_state_mut) + } + #[allow(clippy::too_many_arguments)] + extern "C" fn v8_fn_ptr_fast_metrics( + this: deno_core::v8::Local, + fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, + ) -> () { + let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; + let opctx = unsafe { + &*(deno_core::v8::Local::< + deno_core::v8::External, + >::cast(unsafe { fast_api_callback_options.data.data }) + .value() as *const deno_core::_ops::OpCtx) + }; + deno_core::_ops::dispatch_metrics_fast( + &opctx, + deno_core::_ops::OpMetricsEvent::Dispatched, + ); + let res = Self::v8_fn_ptr_fast(this, fast_api_callback_options); + deno_core::_ops::dispatch_metrics_fast( &opctx, deno_core::_ops::OpMetricsEvent::Completed, ); - } else { + res + } + #[allow(clippy::too_many_arguments)] + extern "C" fn v8_fn_ptr_fast( + _: deno_core::v8::Local, + fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, + ) -> () { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, + ); + let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; + let opctx = unsafe { + &*(deno_core::v8::Local::< + deno_core::v8::External, + >::cast(unsafe { fast_api_callback_options.data.data }) + .value() as *const deno_core::_ops::OpCtx) + }; + let result = { + let arg0 = &mut ::std::cell::RefCell::borrow_mut(&opctx.state); + Self::call(arg0) + }; + result as _ + } + #[inline(always)] + fn slow_function_impl( + info: *const deno_core::v8::FunctionCallbackInfo, + ) -> usize { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, + ); + let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { + &*info + }); + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; + let opstate = &opctx.state; + let result = { + let arg0 = &mut ::std::cell::RefCell::borrow_mut(&opstate); + Self::call(arg0) + }; + deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv); + return 0; + } + extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { + Self::slow_function_impl(info); + } + extern "C" fn v8_fn_ptr_metrics( + info: *const deno_core::v8::FunctionCallbackInfo, + ) { + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; deno_core::_ops::dispatch_metrics_slow( &opctx, - deno_core::_ops::OpMetricsEvent::Error, + deno_core::_ops::OpMetricsEvent::Dispatched, ); + let res = Self::slow_function_impl(info); + if res == 0 { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Completed, + ); + } else { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Error, + ); + } } + #[inline(always)] + fn call(_state: &mut OpState) {} } - #[inline(always)] - fn call(_state: &mut OpState) {} + ::DECL } #[allow(non_camel_case_types)] -struct op_state_and_v8 { - _unconstructable: ::std::marker::PhantomData<()>, -} -impl ::deno_core::_ops::Op for op_state_and_v8 { - const NAME: &'static str = stringify!(op_state_and_v8); - const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( - ::deno_core::__op_name_fast!(op_state_and_v8), - false, - false, - 2usize as u8, - Self::v8_fn_ptr as _, - Self::v8_fn_ptr_metrics as _, - None, - None, - ::deno_core::OpMetadata { - ..::deno_core::OpMetadata::default() - }, - ); -} -impl op_state_and_v8 { - pub const fn name() -> &'static str { - stringify!(op_state_and_v8) - } - #[deprecated(note = "Use the const op::DECL instead")] - pub const fn decl() -> deno_core::_ops::OpDecl { - ::DECL +const fn op_state_and_v8() -> ::deno_core::_ops::OpDecl { + #[allow(non_camel_case_types)] + struct op_state_and_v8 { + _unconstructable: ::std::marker::PhantomData<()>, } - #[inline(always)] - fn slow_function_impl(info: *const deno_core::v8::FunctionCallbackInfo) -> usize { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, + impl ::deno_core::_ops::Op for op_state_and_v8 { + const NAME: &'static str = stringify!(op_state_and_v8); + const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( + ::deno_core::__op_name_fast!(op_state_and_v8), + false, + false, + 2usize as u8, + Self::v8_fn_ptr as _, + Self::v8_fn_ptr_metrics as _, + None, + None, + ::deno_core::OpMetadata { + ..::deno_core::OpMetadata::default() + }, ); - let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { - &*info - }); - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - let mut scope = unsafe { &mut *opctx.isolate }; - let opstate = &opctx.state; - let result = { - let arg1 = args.get(0usize as i32); - let Ok(mut arg1) = deno_core::_ops::v8_try_convert::< - deno_core::v8::Function, - >(arg1) else { - let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; - let msg = deno_core::v8::String::new_from_one_byte( - &mut scope, - "expected Function".as_bytes(), - deno_core::v8::NewStringType::Normal, - ) - .unwrap(); - let exc = deno_core::v8::Exception::type_error(&mut scope, msg); - scope.throw_exception(exc); - return 1; - }; - let arg1 = deno_core::v8::Global::new(&mut scope, arg1); - let arg0 = &mut ::std::cell::RefCell::borrow_mut(&opstate); - Self::call(arg0, arg1) - }; - deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv); - return 0; } - extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { - Self::slow_function_impl(info); - } - extern "C" fn v8_fn_ptr_metrics(info: *const deno_core::v8::FunctionCallbackInfo) { - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_slow( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, - ); - let res = Self::slow_function_impl(info); - if res == 0 { - deno_core::_ops::dispatch_metrics_slow( - &opctx, - deno_core::_ops::OpMetricsEvent::Completed, + impl op_state_and_v8 { + pub const fn name() -> &'static str { + stringify!(op_state_and_v8) + } + #[inline(always)] + fn slow_function_impl( + info: *const deno_core::v8::FunctionCallbackInfo, + ) -> usize { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, ); - } else { + let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { + &*info + }); + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; + let mut scope = unsafe { &mut *opctx.isolate }; + let opstate = &opctx.state; + let result = { + let arg1 = args.get(0usize as i32); + let Ok(mut arg1) = deno_core::_ops::v8_try_convert::< + deno_core::v8::Function, + >(arg1) else { + let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; + let msg = deno_core::v8::String::new_from_one_byte( + &mut scope, + "expected Function".as_bytes(), + deno_core::v8::NewStringType::Normal, + ) + .unwrap(); + let exc = deno_core::v8::Exception::type_error(&mut scope, msg); + scope.throw_exception(exc); + return 1; + }; + let arg1 = deno_core::v8::Global::new(&mut scope, arg1); + let arg0 = &mut ::std::cell::RefCell::borrow_mut(&opstate); + Self::call(arg0, arg1) + }; + deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv); + return 0; + } + extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { + Self::slow_function_impl(info); + } + extern "C" fn v8_fn_ptr_metrics( + info: *const deno_core::v8::FunctionCallbackInfo, + ) { + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; deno_core::_ops::dispatch_metrics_slow( &opctx, - deno_core::_ops::OpMetricsEvent::Error, + deno_core::_ops::OpMetricsEvent::Dispatched, ); + let res = Self::slow_function_impl(info); + if res == 0 { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Completed, + ); + } else { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Error, + ); + } } + #[inline(always)] + fn call(_state: &mut OpState, _callback: v8::Global) {} } - #[inline(always)] - fn call(_state: &mut OpState, _callback: v8::Global) {} + ::DECL } #[allow(non_camel_case_types)] -struct op_state_and_v8_local { - _unconstructable: ::std::marker::PhantomData<()>, -} -impl ::deno_core::_ops::Op for op_state_and_v8_local { - const NAME: &'static str = stringify!(op_state_and_v8_local); - const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( - ::deno_core::__op_name_fast!(op_state_and_v8_local), - false, - false, - 2usize as u8, - Self::v8_fn_ptr as _, - Self::v8_fn_ptr_metrics as _, - Some({ - use deno_core::v8::fast_api::Type; - use deno_core::v8::fast_api::CType; - deno_core::v8::fast_api::FastFunction::new_with_bigint( - &[Type::V8Value, Type::V8Value, Type::CallbackOptions], - CType::Void, - Self::v8_fn_ptr_fast as *const ::std::ffi::c_void, - ) - }), - Some({ - use deno_core::v8::fast_api::Type; - use deno_core::v8::fast_api::CType; - deno_core::v8::fast_api::FastFunction::new_with_bigint( - &[Type::V8Value, Type::V8Value, Type::CallbackOptions], - CType::Void, - Self::v8_fn_ptr_fast_metrics as *const ::std::ffi::c_void, - ) - }), - ::deno_core::OpMetadata { - ..::deno_core::OpMetadata::default() - }, - ); -} -impl op_state_and_v8_local { - pub const fn name() -> &'static str { - stringify!(op_state_and_v8_local) - } - #[deprecated(note = "Use the const op::DECL instead")] - pub const fn decl() -> deno_core::_ops::OpDecl { - ::DECL +const fn op_state_and_v8_local() -> ::deno_core::_ops::OpDecl { + #[allow(non_camel_case_types)] + struct op_state_and_v8_local { + _unconstructable: ::std::marker::PhantomData<()>, } - #[allow(clippy::too_many_arguments)] - extern "C" fn v8_fn_ptr_fast_metrics( - this: deno_core::v8::Local, - arg1: deno_core::v8::Local, - fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, - ) -> () { - let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; - let opctx = unsafe { - &*(deno_core::v8::Local::< - deno_core::v8::External, - >::cast(unsafe { fast_api_callback_options.data.data }) - .value() as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_fast( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, + impl ::deno_core::_ops::Op for op_state_and_v8_local { + const NAME: &'static str = stringify!(op_state_and_v8_local); + const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( + ::deno_core::__op_name_fast!(op_state_and_v8_local), + false, + false, + 2usize as u8, + Self::v8_fn_ptr as _, + Self::v8_fn_ptr_metrics as _, + Some({ + use deno_core::v8::fast_api::Type; + use deno_core::v8::fast_api::CType; + deno_core::v8::fast_api::FastFunction::new_with_bigint( + &[Type::V8Value, Type::V8Value, Type::CallbackOptions], + CType::Void, + Self::v8_fn_ptr_fast as *const ::std::ffi::c_void, + ) + }), + Some({ + use deno_core::v8::fast_api::Type; + use deno_core::v8::fast_api::CType; + deno_core::v8::fast_api::FastFunction::new_with_bigint( + &[Type::V8Value, Type::V8Value, Type::CallbackOptions], + CType::Void, + Self::v8_fn_ptr_fast_metrics as *const ::std::ffi::c_void, + ) + }), + ::deno_core::OpMetadata { + ..::deno_core::OpMetadata::default() + }, ); - let res = Self::v8_fn_ptr_fast(this, arg1, fast_api_callback_options); - deno_core::_ops::dispatch_metrics_fast( - &opctx, - deno_core::_ops::OpMetricsEvent::Completed, - ); - res - } - #[allow(clippy::too_many_arguments)] - extern "C" fn v8_fn_ptr_fast( - _: deno_core::v8::Local, - arg1: deno_core::v8::Local, - fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, - ) -> () { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, - ); - let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; - let opctx = unsafe { - &*(deno_core::v8::Local::< - deno_core::v8::External, - >::cast(unsafe { fast_api_callback_options.data.data }) - .value() as *const deno_core::_ops::OpCtx) - }; - let result = { - let arg0 = &mut ::std::cell::RefCell::borrow_mut(&opctx.state); - let Ok(mut arg1) = deno_core::_ops::v8_try_convert::< - deno_core::v8::Function, - >(arg1) else { - fast_api_callback_options.fallback = true; - return unsafe { std::mem::zeroed() }; - }; - let arg1 = arg1; - Self::call(arg0, arg1) - }; - result as _ } - #[inline(always)] - fn slow_function_impl(info: *const deno_core::v8::FunctionCallbackInfo) -> usize { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, - ); - let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { - &*info - }); - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - let opstate = &opctx.state; - let result = { - let arg1 = args.get(0usize as i32); - let Ok(mut arg1) = deno_core::_ops::v8_try_convert::< - deno_core::v8::Function, - >(arg1) else { - let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; - let msg = deno_core::v8::String::new_from_one_byte( - &mut scope, - "expected Function".as_bytes(), - deno_core::v8::NewStringType::Normal, - ) - .unwrap(); - let exc = deno_core::v8::Exception::type_error(&mut scope, msg); - scope.throw_exception(exc); - return 1; + impl op_state_and_v8_local { + pub const fn name() -> &'static str { + stringify!(op_state_and_v8_local) + } + #[allow(clippy::too_many_arguments)] + extern "C" fn v8_fn_ptr_fast_metrics( + this: deno_core::v8::Local, + arg1: deno_core::v8::Local, + fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, + ) -> () { + let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; + let opctx = unsafe { + &*(deno_core::v8::Local::< + deno_core::v8::External, + >::cast(unsafe { fast_api_callback_options.data.data }) + .value() as *const deno_core::_ops::OpCtx) }; - let arg1 = arg1; - let arg0 = &mut ::std::cell::RefCell::borrow_mut(&opstate); - Self::call(arg0, arg1) - }; - deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv); - return 0; - } - extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { - Self::slow_function_impl(info); - } - extern "C" fn v8_fn_ptr_metrics(info: *const deno_core::v8::FunctionCallbackInfo) { - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_slow( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, - ); - let res = Self::slow_function_impl(info); - if res == 0 { - deno_core::_ops::dispatch_metrics_slow( + deno_core::_ops::dispatch_metrics_fast( + &opctx, + deno_core::_ops::OpMetricsEvent::Dispatched, + ); + let res = Self::v8_fn_ptr_fast(this, arg1, fast_api_callback_options); + deno_core::_ops::dispatch_metrics_fast( &opctx, deno_core::_ops::OpMetricsEvent::Completed, ); - } else { + res + } + #[allow(clippy::too_many_arguments)] + extern "C" fn v8_fn_ptr_fast( + _: deno_core::v8::Local, + arg1: deno_core::v8::Local, + fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, + ) -> () { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, + ); + let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; + let opctx = unsafe { + &*(deno_core::v8::Local::< + deno_core::v8::External, + >::cast(unsafe { fast_api_callback_options.data.data }) + .value() as *const deno_core::_ops::OpCtx) + }; + let result = { + let arg0 = &mut ::std::cell::RefCell::borrow_mut(&opctx.state); + let Ok(mut arg1) = deno_core::_ops::v8_try_convert::< + deno_core::v8::Function, + >(arg1) else { + fast_api_callback_options.fallback = true; + return unsafe { std::mem::zeroed() }; + }; + let arg1 = arg1; + Self::call(arg0, arg1) + }; + result as _ + } + #[inline(always)] + fn slow_function_impl( + info: *const deno_core::v8::FunctionCallbackInfo, + ) -> usize { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, + ); + let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { + &*info + }); + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; + let opstate = &opctx.state; + let result = { + let arg1 = args.get(0usize as i32); + let Ok(mut arg1) = deno_core::_ops::v8_try_convert::< + deno_core::v8::Function, + >(arg1) else { + let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; + let msg = deno_core::v8::String::new_from_one_byte( + &mut scope, + "expected Function".as_bytes(), + deno_core::v8::NewStringType::Normal, + ) + .unwrap(); + let exc = deno_core::v8::Exception::type_error(&mut scope, msg); + scope.throw_exception(exc); + return 1; + }; + let arg1 = arg1; + let arg0 = &mut ::std::cell::RefCell::borrow_mut(&opstate); + Self::call(arg0, arg1) + }; + deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv); + return 0; + } + extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { + Self::slow_function_impl(info); + } + extern "C" fn v8_fn_ptr_metrics( + info: *const deno_core::v8::FunctionCallbackInfo, + ) { + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; deno_core::_ops::dispatch_metrics_slow( &opctx, - deno_core::_ops::OpMetricsEvent::Error, + deno_core::_ops::OpMetricsEvent::Dispatched, ); + let res = Self::slow_function_impl(info); + if res == 0 { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Completed, + ); + } else { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Error, + ); + } } + #[inline(always)] + fn call(_state: &mut OpState, _callback: v8::Local) {} } - #[inline(always)] - fn call(_state: &mut OpState, _callback: v8::Local) {} + ::DECL } diff --git a/ops/op2/test_cases/sync/result_external.out b/ops/op2/test_cases/sync/result_external.out index 38ab70ddc..182eb9b60 100644 --- a/ops/op2/test_cases/sync/result_external.out +++ b/ops/op2/test_cases/sync/result_external.out @@ -1,135 +1,119 @@ #[allow(non_camel_case_types)] -pub struct op_external_with_result { - _unconstructable: ::std::marker::PhantomData<()>, -} -impl ::deno_core::_ops::Op for op_external_with_result { - const NAME: &'static str = stringify!(op_external_with_result); - const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( - ::deno_core::__op_name_fast!(op_external_with_result), - false, - false, - 0usize as u8, - Self::v8_fn_ptr as _, - Self::v8_fn_ptr_metrics as _, - Some({ - use deno_core::v8::fast_api::Type; - use deno_core::v8::fast_api::CType; - deno_core::v8::fast_api::FastFunction::new_with_bigint( - &[Type::V8Value, Type::CallbackOptions], - CType::Pointer, - Self::v8_fn_ptr_fast as *const ::std::ffi::c_void, - ) - }), - Some({ - use deno_core::v8::fast_api::Type; - use deno_core::v8::fast_api::CType; - deno_core::v8::fast_api::FastFunction::new_with_bigint( - &[Type::V8Value, Type::CallbackOptions], - CType::Pointer, - Self::v8_fn_ptr_fast_metrics as *const ::std::ffi::c_void, - ) - }), - ::deno_core::OpMetadata { - ..::deno_core::OpMetadata::default() - }, - ); -} -impl op_external_with_result { - pub const fn name() -> &'static str { - stringify!(op_external_with_result) - } - #[deprecated(note = "Use the const op::DECL instead")] - pub const fn decl() -> deno_core::_ops::OpDecl { - ::DECL +pub const fn op_external_with_result() -> ::deno_core::_ops::OpDecl { + #[allow(non_camel_case_types)] + pub struct op_external_with_result { + _unconstructable: ::std::marker::PhantomData<()>, } - #[allow(clippy::too_many_arguments)] - extern "C" fn v8_fn_ptr_fast_metrics( - this: deno_core::v8::Local, - fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, - ) -> *mut ::std::ffi::c_void { - let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; - let opctx = unsafe { - &*(deno_core::v8::Local::< - deno_core::v8::External, - >::cast(unsafe { fast_api_callback_options.data.data }) - .value() as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_fast( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, + impl ::deno_core::_ops::Op for op_external_with_result { + const NAME: &'static str = stringify!(op_external_with_result); + const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( + ::deno_core::__op_name_fast!(op_external_with_result), + false, + false, + 0usize as u8, + Self::v8_fn_ptr as _, + Self::v8_fn_ptr_metrics as _, + Some({ + use deno_core::v8::fast_api::Type; + use deno_core::v8::fast_api::CType; + deno_core::v8::fast_api::FastFunction::new_with_bigint( + &[Type::V8Value, Type::CallbackOptions], + CType::Pointer, + Self::v8_fn_ptr_fast as *const ::std::ffi::c_void, + ) + }), + Some({ + use deno_core::v8::fast_api::Type; + use deno_core::v8::fast_api::CType; + deno_core::v8::fast_api::FastFunction::new_with_bigint( + &[Type::V8Value, Type::CallbackOptions], + CType::Pointer, + Self::v8_fn_ptr_fast_metrics as *const ::std::ffi::c_void, + ) + }), + ::deno_core::OpMetadata { + ..::deno_core::OpMetadata::default() + }, ); - let res = Self::v8_fn_ptr_fast(this, fast_api_callback_options); - deno_core::_ops::dispatch_metrics_fast( - &opctx, - deno_core::_ops::OpMetricsEvent::Completed, - ); - res } - #[allow(clippy::too_many_arguments)] - extern "C" fn v8_fn_ptr_fast( - _: deno_core::v8::Local, - fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, - ) -> *mut ::std::ffi::c_void { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, - ); - let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; - let opctx = unsafe { - &*(deno_core::v8::Local::< - deno_core::v8::External, - >::cast(unsafe { fast_api_callback_options.data.data }) - .value() as *const deno_core::_ops::OpCtx) - }; - let result = { Self::call() }; - let result = match result { - Ok(result) => result, - Err(err) => { - let err = err.into(); - unsafe { - opctx.unsafely_set_last_error_for_ops_only(err); + impl op_external_with_result { + pub const fn name() -> &'static str { + stringify!(op_external_with_result) + } + #[allow(clippy::too_many_arguments)] + extern "C" fn v8_fn_ptr_fast_metrics( + this: deno_core::v8::Local, + fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, + ) -> *mut ::std::ffi::c_void { + let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; + let opctx = unsafe { + &*(deno_core::v8::Local::< + deno_core::v8::External, + >::cast(unsafe { fast_api_callback_options.data.data }) + .value() as *const deno_core::_ops::OpCtx) + }; + deno_core::_ops::dispatch_metrics_fast( + &opctx, + deno_core::_ops::OpMetricsEvent::Dispatched, + ); + let res = Self::v8_fn_ptr_fast(this, fast_api_callback_options); + deno_core::_ops::dispatch_metrics_fast( + &opctx, + deno_core::_ops::OpMetricsEvent::Completed, + ); + res + } + #[allow(clippy::too_many_arguments)] + extern "C" fn v8_fn_ptr_fast( + _: deno_core::v8::Local, + fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, + ) -> *mut ::std::ffi::c_void { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, + ); + let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; + let opctx = unsafe { + &*(deno_core::v8::Local::< + deno_core::v8::External, + >::cast(unsafe { fast_api_callback_options.data.data }) + .value() as *const deno_core::_ops::OpCtx) + }; + let result = { Self::call() }; + let result = match result { + Ok(result) => result, + Err(err) => { + let err = err.into(); + unsafe { + opctx.unsafely_set_last_error_for_ops_only(err); + } + fast_api_callback_options.fallback = true; + return unsafe { std::mem::zeroed() }; } - fast_api_callback_options.fallback = true; - return unsafe { std::mem::zeroed() }; - } - }; - result as _ - } - #[inline(always)] - fn slow_function_impl(info: *const deno_core::v8::FunctionCallbackInfo) -> usize { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, - ); - let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; - let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { - &*info - }); - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - if let Some(err) = unsafe { opctx.unsafely_take_last_error_for_ops_only() } { + }; + result as _ + } + #[inline(always)] + fn slow_function_impl( + info: *const deno_core::v8::FunctionCallbackInfo, + ) -> usize { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, + ); let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; + let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { + &*info + }); let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { &*info }); - let err = err.into(); - let exception = deno_core::error::to_v8_error( - &mut scope, - opctx.get_error_class_fn, - &err, - ); - scope.throw_exception(exception); - return 1; - } - let result = { Self::call() }; - match result { - Ok(result) => rv.set(deno_core::_ops::RustToV8::to_v8(result, &mut scope)), - Err(err) => { + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; + if let Some(err) = unsafe { opctx.unsafely_take_last_error_for_ops_only() } { + let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { &*info }); @@ -142,39 +126,61 @@ impl op_external_with_result { scope.throw_exception(exception); return 1; } - }; - return 0; - } - extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { - Self::slow_function_impl(info); - } - extern "C" fn v8_fn_ptr_metrics(info: *const deno_core::v8::FunctionCallbackInfo) { - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_slow( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, - ); - let res = Self::slow_function_impl(info); - if res == 0 { - deno_core::_ops::dispatch_metrics_slow( - &opctx, - deno_core::_ops::OpMetricsEvent::Completed, - ); - } else { + let result = { Self::call() }; + match result { + Ok(result) => { + rv.set(deno_core::_ops::RustToV8::to_v8(result, &mut scope)) + } + Err(err) => { + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let err = err.into(); + let exception = deno_core::error::to_v8_error( + &mut scope, + opctx.get_error_class_fn, + &err, + ); + scope.throw_exception(exception); + return 1; + } + }; + return 0; + } + extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { + Self::slow_function_impl(info); + } + extern "C" fn v8_fn_ptr_metrics( + info: *const deno_core::v8::FunctionCallbackInfo, + ) { + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; deno_core::_ops::dispatch_metrics_slow( &opctx, - deno_core::_ops::OpMetricsEvent::Error, + deno_core::_ops::OpMetricsEvent::Dispatched, ); + let res = Self::slow_function_impl(info); + if res == 0 { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Completed, + ); + } else { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Error, + ); + } + } + #[inline(always)] + pub fn call() -> Result<*mut std::ffi::c_void, AnyError> { + Ok(0 as _) } } - #[inline(always)] - pub fn call() -> Result<*mut std::ffi::c_void, AnyError> { - Ok(0 as _) - } + ::DECL } diff --git a/ops/op2/test_cases/sync/result_primitive.out b/ops/op2/test_cases/sync/result_primitive.out index 42138b8f3..01d633ece 100644 --- a/ops/op2/test_cases/sync/result_primitive.out +++ b/ops/op2/test_cases/sync/result_primitive.out @@ -1,134 +1,117 @@ #[allow(non_camel_case_types)] -pub struct op_u32_with_result { - _unconstructable: ::std::marker::PhantomData<()>, -} -impl ::deno_core::_ops::Op for op_u32_with_result { - const NAME: &'static str = stringify!(op_u32_with_result); - const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( - ::deno_core::__op_name_fast!(op_u32_with_result), - false, - false, - 0usize as u8, - Self::v8_fn_ptr as _, - Self::v8_fn_ptr_metrics as _, - Some({ - use deno_core::v8::fast_api::Type; - use deno_core::v8::fast_api::CType; - deno_core::v8::fast_api::FastFunction::new_with_bigint( - &[Type::V8Value, Type::CallbackOptions], - CType::Uint32, - Self::v8_fn_ptr_fast as *const ::std::ffi::c_void, - ) - }), - Some({ - use deno_core::v8::fast_api::Type; - use deno_core::v8::fast_api::CType; - deno_core::v8::fast_api::FastFunction::new_with_bigint( - &[Type::V8Value, Type::CallbackOptions], - CType::Uint32, - Self::v8_fn_ptr_fast_metrics as *const ::std::ffi::c_void, - ) - }), - ::deno_core::OpMetadata { - ..::deno_core::OpMetadata::default() - }, - ); -} -impl op_u32_with_result { - pub const fn name() -> &'static str { - stringify!(op_u32_with_result) - } - #[deprecated(note = "Use the const op::DECL instead")] - pub const fn decl() -> deno_core::_ops::OpDecl { - ::DECL +pub const fn op_u32_with_result() -> ::deno_core::_ops::OpDecl { + #[allow(non_camel_case_types)] + pub struct op_u32_with_result { + _unconstructable: ::std::marker::PhantomData<()>, } - #[allow(clippy::too_many_arguments)] - extern "C" fn v8_fn_ptr_fast_metrics( - this: deno_core::v8::Local, - fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, - ) -> u32 { - let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; - let opctx = unsafe { - &*(deno_core::v8::Local::< - deno_core::v8::External, - >::cast(unsafe { fast_api_callback_options.data.data }) - .value() as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_fast( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, + impl ::deno_core::_ops::Op for op_u32_with_result { + const NAME: &'static str = stringify!(op_u32_with_result); + const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( + ::deno_core::__op_name_fast!(op_u32_with_result), + false, + false, + 0usize as u8, + Self::v8_fn_ptr as _, + Self::v8_fn_ptr_metrics as _, + Some({ + use deno_core::v8::fast_api::Type; + use deno_core::v8::fast_api::CType; + deno_core::v8::fast_api::FastFunction::new_with_bigint( + &[Type::V8Value, Type::CallbackOptions], + CType::Uint32, + Self::v8_fn_ptr_fast as *const ::std::ffi::c_void, + ) + }), + Some({ + use deno_core::v8::fast_api::Type; + use deno_core::v8::fast_api::CType; + deno_core::v8::fast_api::FastFunction::new_with_bigint( + &[Type::V8Value, Type::CallbackOptions], + CType::Uint32, + Self::v8_fn_ptr_fast_metrics as *const ::std::ffi::c_void, + ) + }), + ::deno_core::OpMetadata { + ..::deno_core::OpMetadata::default() + }, ); - let res = Self::v8_fn_ptr_fast(this, fast_api_callback_options); - deno_core::_ops::dispatch_metrics_fast( - &opctx, - deno_core::_ops::OpMetricsEvent::Completed, - ); - res } - #[allow(clippy::too_many_arguments)] - extern "C" fn v8_fn_ptr_fast( - _: deno_core::v8::Local, - fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, - ) -> u32 { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, - ); - let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; - let opctx = unsafe { - &*(deno_core::v8::Local::< - deno_core::v8::External, - >::cast(unsafe { fast_api_callback_options.data.data }) - .value() as *const deno_core::_ops::OpCtx) - }; - let result = { Self::call() }; - let result = match result { - Ok(result) => result, - Err(err) => { - let err = err.into(); - unsafe { - opctx.unsafely_set_last_error_for_ops_only(err); + impl op_u32_with_result { + pub const fn name() -> &'static str { + stringify!(op_u32_with_result) + } + #[allow(clippy::too_many_arguments)] + extern "C" fn v8_fn_ptr_fast_metrics( + this: deno_core::v8::Local, + fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, + ) -> u32 { + let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; + let opctx = unsafe { + &*(deno_core::v8::Local::< + deno_core::v8::External, + >::cast(unsafe { fast_api_callback_options.data.data }) + .value() as *const deno_core::_ops::OpCtx) + }; + deno_core::_ops::dispatch_metrics_fast( + &opctx, + deno_core::_ops::OpMetricsEvent::Dispatched, + ); + let res = Self::v8_fn_ptr_fast(this, fast_api_callback_options); + deno_core::_ops::dispatch_metrics_fast( + &opctx, + deno_core::_ops::OpMetricsEvent::Completed, + ); + res + } + #[allow(clippy::too_many_arguments)] + extern "C" fn v8_fn_ptr_fast( + _: deno_core::v8::Local, + fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, + ) -> u32 { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, + ); + let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; + let opctx = unsafe { + &*(deno_core::v8::Local::< + deno_core::v8::External, + >::cast(unsafe { fast_api_callback_options.data.data }) + .value() as *const deno_core::_ops::OpCtx) + }; + let result = { Self::call() }; + let result = match result { + Ok(result) => result, + Err(err) => { + let err = err.into(); + unsafe { + opctx.unsafely_set_last_error_for_ops_only(err); + } + fast_api_callback_options.fallback = true; + return unsafe { std::mem::zeroed() }; } - fast_api_callback_options.fallback = true; - return unsafe { std::mem::zeroed() }; - } - }; - result as _ - } - #[inline(always)] - fn slow_function_impl(info: *const deno_core::v8::FunctionCallbackInfo) -> usize { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, - ); - let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { - &*info - }); - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - if let Some(err) = unsafe { opctx.unsafely_take_last_error_for_ops_only() } { - let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; + }; + result as _ + } + #[inline(always)] + fn slow_function_impl( + info: *const deno_core::v8::FunctionCallbackInfo, + ) -> usize { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, + ); + let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { + &*info + }); let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { &*info }); - let err = err.into(); - let exception = deno_core::error::to_v8_error( - &mut scope, - opctx.get_error_class_fn, - &err, - ); - scope.throw_exception(exception); - return 1; - } - let result = { Self::call() }; - match result { - Ok(result) => deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv), - Err(err) => { + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; + if let Some(err) = unsafe { opctx.unsafely_take_last_error_for_ops_only() } { let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { &*info @@ -142,39 +125,60 @@ impl op_u32_with_result { scope.throw_exception(exception); return 1; } - }; - return 0; - } - extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { - Self::slow_function_impl(info); - } - extern "C" fn v8_fn_ptr_metrics(info: *const deno_core::v8::FunctionCallbackInfo) { - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_slow( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, - ); - let res = Self::slow_function_impl(info); - if res == 0 { - deno_core::_ops::dispatch_metrics_slow( - &opctx, - deno_core::_ops::OpMetricsEvent::Completed, - ); - } else { + let result = { Self::call() }; + match result { + Ok(result) => deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv), + Err(err) => { + let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let err = err.into(); + let exception = deno_core::error::to_v8_error( + &mut scope, + opctx.get_error_class_fn, + &err, + ); + scope.throw_exception(exception); + return 1; + } + }; + return 0; + } + extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { + Self::slow_function_impl(info); + } + extern "C" fn v8_fn_ptr_metrics( + info: *const deno_core::v8::FunctionCallbackInfo, + ) { + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; deno_core::_ops::dispatch_metrics_slow( &opctx, - deno_core::_ops::OpMetricsEvent::Error, + deno_core::_ops::OpMetricsEvent::Dispatched, ); + let res = Self::slow_function_impl(info); + if res == 0 { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Completed, + ); + } else { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Error, + ); + } + } + #[inline(always)] + pub fn call() -> Result { + Ok(0) } } - #[inline(always)] - pub fn call() -> Result { - Ok(0) - } + ::DECL } diff --git a/ops/op2/test_cases/sync/result_scope.out b/ops/op2/test_cases/sync/result_scope.out index 33248c719..40fa65482 100644 --- a/ops/op2/test_cases/sync/result_scope.out +++ b/ops/op2/test_cases/sync/result_scope.out @@ -1,97 +1,103 @@ #[allow(non_camel_case_types)] -pub struct op_void_with_result { - _unconstructable: ::std::marker::PhantomData<()>, -} -impl ::deno_core::_ops::Op for op_void_with_result { - const NAME: &'static str = stringify!(op_void_with_result); - const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( - ::deno_core::__op_name_fast!(op_void_with_result), - false, - false, - 1usize as u8, - Self::v8_fn_ptr as _, - Self::v8_fn_ptr_metrics as _, - None, - None, - ::deno_core::OpMetadata { - ..::deno_core::OpMetadata::default() - }, - ); -} -impl op_void_with_result { - pub const fn name() -> &'static str { - stringify!(op_void_with_result) - } - #[deprecated(note = "Use the const op::DECL instead")] - pub const fn decl() -> deno_core::_ops::OpDecl { - ::DECL +pub const fn op_void_with_result() -> ::deno_core::_ops::OpDecl { + #[allow(non_camel_case_types)] + pub struct op_void_with_result { + _unconstructable: ::std::marker::PhantomData<()>, } - #[inline(always)] - fn slow_function_impl(info: *const deno_core::v8::FunctionCallbackInfo) -> usize { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, + impl ::deno_core::_ops::Op for op_void_with_result { + const NAME: &'static str = stringify!(op_void_with_result); + const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( + ::deno_core::__op_name_fast!(op_void_with_result), + false, + false, + 1usize as u8, + Self::v8_fn_ptr as _, + Self::v8_fn_ptr_metrics as _, + None, + None, + ::deno_core::OpMetadata { + ..::deno_core::OpMetadata::default() + }, ); - let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; - let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { - &*info - }); - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let result = { - let arg0 = &mut scope; - Self::call(arg0) - }; - match result { - Ok(result) => deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv), - Err(err) => { - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()) - .value() as *const deno_core::_ops::OpCtx) - }; - let err = err.into(); - let exception = deno_core::error::to_v8_error( - &mut scope, - opctx.get_error_class_fn, - &err, - ); - scope.throw_exception(exception); - return 1; - } - }; - return 0; } - extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { - Self::slow_function_impl(info); - } - extern "C" fn v8_fn_ptr_metrics(info: *const deno_core::v8::FunctionCallbackInfo) { - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_slow( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, - ); - let res = Self::slow_function_impl(info); - if res == 0 { - deno_core::_ops::dispatch_metrics_slow( - &opctx, - deno_core::_ops::OpMetricsEvent::Completed, + impl op_void_with_result { + pub const fn name() -> &'static str { + stringify!(op_void_with_result) + } + #[inline(always)] + fn slow_function_impl( + info: *const deno_core::v8::FunctionCallbackInfo, + ) -> usize { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, ); - } else { + let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; + let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { + &*info + }); + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let result = { + let arg0 = &mut scope; + Self::call(arg0) + }; + match result { + Ok(result) => deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv), + Err(err) => { + let opctx = unsafe { + &*(deno_core::v8::Local::< + deno_core::v8::External, + >::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; + let err = err.into(); + let exception = deno_core::error::to_v8_error( + &mut scope, + opctx.get_error_class_fn, + &err, + ); + scope.throw_exception(exception); + return 1; + } + }; + return 0; + } + extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { + Self::slow_function_impl(info); + } + extern "C" fn v8_fn_ptr_metrics( + info: *const deno_core::v8::FunctionCallbackInfo, + ) { + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; deno_core::_ops::dispatch_metrics_slow( &opctx, - deno_core::_ops::OpMetricsEvent::Error, + deno_core::_ops::OpMetricsEvent::Dispatched, ); + let res = Self::slow_function_impl(info); + if res == 0 { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Completed, + ); + } else { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Error, + ); + } + } + #[inline(always)] + pub fn call(_scope: &mut v8::HandleScope) -> Result<(), AnyError> { + Ok(()) } } - #[inline(always)] - pub fn call(_scope: &mut v8::HandleScope) -> Result<(), AnyError> { - Ok(()) - } + ::DECL } diff --git a/ops/op2/test_cases/sync/result_void.out b/ops/op2/test_cases/sync/result_void.out index 03593384e..b09419eae 100644 --- a/ops/op2/test_cases/sync/result_void.out +++ b/ops/op2/test_cases/sync/result_void.out @@ -1,134 +1,117 @@ #[allow(non_camel_case_types)] -pub struct op_void_with_result { - _unconstructable: ::std::marker::PhantomData<()>, -} -impl ::deno_core::_ops::Op for op_void_with_result { - const NAME: &'static str = stringify!(op_void_with_result); - const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( - ::deno_core::__op_name_fast!(op_void_with_result), - false, - false, - 0usize as u8, - Self::v8_fn_ptr as _, - Self::v8_fn_ptr_metrics as _, - Some({ - use deno_core::v8::fast_api::Type; - use deno_core::v8::fast_api::CType; - deno_core::v8::fast_api::FastFunction::new_with_bigint( - &[Type::V8Value, Type::CallbackOptions], - CType::Void, - Self::v8_fn_ptr_fast as *const ::std::ffi::c_void, - ) - }), - Some({ - use deno_core::v8::fast_api::Type; - use deno_core::v8::fast_api::CType; - deno_core::v8::fast_api::FastFunction::new_with_bigint( - &[Type::V8Value, Type::CallbackOptions], - CType::Void, - Self::v8_fn_ptr_fast_metrics as *const ::std::ffi::c_void, - ) - }), - ::deno_core::OpMetadata { - ..::deno_core::OpMetadata::default() - }, - ); -} -impl op_void_with_result { - pub const fn name() -> &'static str { - stringify!(op_void_with_result) - } - #[deprecated(note = "Use the const op::DECL instead")] - pub const fn decl() -> deno_core::_ops::OpDecl { - ::DECL +pub const fn op_void_with_result() -> ::deno_core::_ops::OpDecl { + #[allow(non_camel_case_types)] + pub struct op_void_with_result { + _unconstructable: ::std::marker::PhantomData<()>, } - #[allow(clippy::too_many_arguments)] - extern "C" fn v8_fn_ptr_fast_metrics( - this: deno_core::v8::Local, - fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, - ) -> () { - let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; - let opctx = unsafe { - &*(deno_core::v8::Local::< - deno_core::v8::External, - >::cast(unsafe { fast_api_callback_options.data.data }) - .value() as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_fast( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, + impl ::deno_core::_ops::Op for op_void_with_result { + const NAME: &'static str = stringify!(op_void_with_result); + const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( + ::deno_core::__op_name_fast!(op_void_with_result), + false, + false, + 0usize as u8, + Self::v8_fn_ptr as _, + Self::v8_fn_ptr_metrics as _, + Some({ + use deno_core::v8::fast_api::Type; + use deno_core::v8::fast_api::CType; + deno_core::v8::fast_api::FastFunction::new_with_bigint( + &[Type::V8Value, Type::CallbackOptions], + CType::Void, + Self::v8_fn_ptr_fast as *const ::std::ffi::c_void, + ) + }), + Some({ + use deno_core::v8::fast_api::Type; + use deno_core::v8::fast_api::CType; + deno_core::v8::fast_api::FastFunction::new_with_bigint( + &[Type::V8Value, Type::CallbackOptions], + CType::Void, + Self::v8_fn_ptr_fast_metrics as *const ::std::ffi::c_void, + ) + }), + ::deno_core::OpMetadata { + ..::deno_core::OpMetadata::default() + }, ); - let res = Self::v8_fn_ptr_fast(this, fast_api_callback_options); - deno_core::_ops::dispatch_metrics_fast( - &opctx, - deno_core::_ops::OpMetricsEvent::Completed, - ); - res } - #[allow(clippy::too_many_arguments)] - extern "C" fn v8_fn_ptr_fast( - _: deno_core::v8::Local, - fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, - ) -> () { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, - ); - let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; - let opctx = unsafe { - &*(deno_core::v8::Local::< - deno_core::v8::External, - >::cast(unsafe { fast_api_callback_options.data.data }) - .value() as *const deno_core::_ops::OpCtx) - }; - let result = { Self::call() }; - let result = match result { - Ok(result) => result, - Err(err) => { - let err = err.into(); - unsafe { - opctx.unsafely_set_last_error_for_ops_only(err); + impl op_void_with_result { + pub const fn name() -> &'static str { + stringify!(op_void_with_result) + } + #[allow(clippy::too_many_arguments)] + extern "C" fn v8_fn_ptr_fast_metrics( + this: deno_core::v8::Local, + fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, + ) -> () { + let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; + let opctx = unsafe { + &*(deno_core::v8::Local::< + deno_core::v8::External, + >::cast(unsafe { fast_api_callback_options.data.data }) + .value() as *const deno_core::_ops::OpCtx) + }; + deno_core::_ops::dispatch_metrics_fast( + &opctx, + deno_core::_ops::OpMetricsEvent::Dispatched, + ); + let res = Self::v8_fn_ptr_fast(this, fast_api_callback_options); + deno_core::_ops::dispatch_metrics_fast( + &opctx, + deno_core::_ops::OpMetricsEvent::Completed, + ); + res + } + #[allow(clippy::too_many_arguments)] + extern "C" fn v8_fn_ptr_fast( + _: deno_core::v8::Local, + fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, + ) -> () { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, + ); + let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; + let opctx = unsafe { + &*(deno_core::v8::Local::< + deno_core::v8::External, + >::cast(unsafe { fast_api_callback_options.data.data }) + .value() as *const deno_core::_ops::OpCtx) + }; + let result = { Self::call() }; + let result = match result { + Ok(result) => result, + Err(err) => { + let err = err.into(); + unsafe { + opctx.unsafely_set_last_error_for_ops_only(err); + } + fast_api_callback_options.fallback = true; + return unsafe { std::mem::zeroed() }; } - fast_api_callback_options.fallback = true; - return unsafe { std::mem::zeroed() }; - } - }; - result as _ - } - #[inline(always)] - fn slow_function_impl(info: *const deno_core::v8::FunctionCallbackInfo) -> usize { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, - ); - let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { - &*info - }); - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - if let Some(err) = unsafe { opctx.unsafely_take_last_error_for_ops_only() } { - let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; + }; + result as _ + } + #[inline(always)] + fn slow_function_impl( + info: *const deno_core::v8::FunctionCallbackInfo, + ) -> usize { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, + ); + let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { + &*info + }); let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { &*info }); - let err = err.into(); - let exception = deno_core::error::to_v8_error( - &mut scope, - opctx.get_error_class_fn, - &err, - ); - scope.throw_exception(exception); - return 1; - } - let result = { Self::call() }; - match result { - Ok(result) => deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv), - Err(err) => { + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; + if let Some(err) = unsafe { opctx.unsafely_take_last_error_for_ops_only() } { let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { &*info @@ -142,39 +125,60 @@ impl op_void_with_result { scope.throw_exception(exception); return 1; } - }; - return 0; - } - extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { - Self::slow_function_impl(info); - } - extern "C" fn v8_fn_ptr_metrics(info: *const deno_core::v8::FunctionCallbackInfo) { - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_slow( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, - ); - let res = Self::slow_function_impl(info); - if res == 0 { - deno_core::_ops::dispatch_metrics_slow( - &opctx, - deno_core::_ops::OpMetricsEvent::Completed, - ); - } else { + let result = { Self::call() }; + match result { + Ok(result) => deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv), + Err(err) => { + let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let err = err.into(); + let exception = deno_core::error::to_v8_error( + &mut scope, + opctx.get_error_class_fn, + &err, + ); + scope.throw_exception(exception); + return 1; + } + }; + return 0; + } + extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { + Self::slow_function_impl(info); + } + extern "C" fn v8_fn_ptr_metrics( + info: *const deno_core::v8::FunctionCallbackInfo, + ) { + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; deno_core::_ops::dispatch_metrics_slow( &opctx, - deno_core::_ops::OpMetricsEvent::Error, + deno_core::_ops::OpMetricsEvent::Dispatched, ); + let res = Self::slow_function_impl(info); + if res == 0 { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Completed, + ); + } else { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Error, + ); + } + } + #[inline(always)] + pub fn call() -> std::io::Result<()> { + Ok(()) } } - #[inline(always)] - pub fn call() -> std::io::Result<()> { - Ok(()) - } + ::DECL } diff --git a/ops/op2/test_cases/sync/serde_v8.out b/ops/op2/test_cases/sync/serde_v8.out index 95075c284..3c6c69d9a 100644 --- a/ops/op2/test_cases/sync/serde_v8.out +++ b/ops/op2/test_cases/sync/serde_v8.out @@ -1,52 +1,73 @@ #[allow(non_camel_case_types)] -pub struct op_serde_v8 { - _unconstructable: ::std::marker::PhantomData<()>, -} -impl ::deno_core::_ops::Op for op_serde_v8 { - const NAME: &'static str = stringify!(op_serde_v8); - const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( - ::deno_core::__op_name_fast!(op_serde_v8), - false, - false, - 1usize as u8, - Self::v8_fn_ptr as _, - Self::v8_fn_ptr_metrics as _, - None, - None, - ::deno_core::OpMetadata { - ..::deno_core::OpMetadata::default() - }, - ); -} -impl op_serde_v8 { - pub const fn name() -> &'static str { - stringify!(op_serde_v8) - } - #[deprecated(note = "Use the const op::DECL instead")] - pub const fn decl() -> deno_core::_ops::OpDecl { - ::DECL +pub const fn op_serde_v8() -> ::deno_core::_ops::OpDecl { + #[allow(non_camel_case_types)] + pub struct op_serde_v8 { + _unconstructable: ::std::marker::PhantomData<()>, } - #[inline(always)] - fn slow_function_impl(info: *const deno_core::v8::FunctionCallbackInfo) -> usize { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, + impl ::deno_core::_ops::Op for op_serde_v8 { + const NAME: &'static str = stringify!(op_serde_v8); + const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( + ::deno_core::__op_name_fast!(op_serde_v8), + false, + false, + 1usize as u8, + Self::v8_fn_ptr as _, + Self::v8_fn_ptr_metrics as _, + None, + None, + ::deno_core::OpMetadata { + ..::deno_core::OpMetadata::default() + }, ); - let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; - let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { - &*info - }); - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let result = { - let arg0 = args.get(0usize as i32); - let arg0 = match deno_core::_ops::serde_v8_to_rust(&mut scope, arg0) { - Ok(t) => t, - Err(arg0_err) => { + } + impl op_serde_v8 { + pub const fn name() -> &'static str { + stringify!(op_serde_v8) + } + #[inline(always)] + fn slow_function_impl( + info: *const deno_core::v8::FunctionCallbackInfo, + ) -> usize { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, + ); + let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; + let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { + &*info + }); + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let result = { + let arg0 = args.get(0usize as i32); + let arg0 = match deno_core::_ops::serde_v8_to_rust(&mut scope, arg0) { + Ok(t) => t, + Err(arg0_err) => { + let msg = deno_core::v8::String::new( + &mut scope, + &format!("{}", deno_core::anyhow::Error::from(arg0_err)), + ) + .unwrap(); + let exc = deno_core::v8::Exception::type_error(&mut scope, msg); + scope.throw_exception(exc); + return 1; + } + }; + Self::call(arg0) + }; + match deno_core::_ops::RustToV8Fallible::to_v8_fallible( + deno_core::_ops::RustToV8Marker::< + deno_core::_ops::SerdeMarker, + _, + >::from(result), + &mut scope, + ) { + Ok(v) => rv.set(v), + Err(rv_err) => { let msg = deno_core::v8::String::new( &mut scope, - &format!("{}", deno_core::anyhow::Error::from(arg0_err)), + &format!("{}", deno_core::anyhow::Error::from(rv_err)), ) .unwrap(); let exc = deno_core::v8::Exception::type_error(&mut scope, msg); @@ -54,59 +75,42 @@ impl op_serde_v8 { return 1; } }; - Self::call(arg0) - }; - match deno_core::_ops::RustToV8Fallible::to_v8_fallible( - deno_core::_ops::RustToV8Marker::< - deno_core::_ops::SerdeMarker, - _, - >::from(result), - &mut scope, + return 0; + } + extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { + Self::slow_function_impl(info); + } + extern "C" fn v8_fn_ptr_metrics( + info: *const deno_core::v8::FunctionCallbackInfo, ) { - Ok(v) => rv.set(v), - Err(rv_err) => { - let msg = deno_core::v8::String::new( - &mut scope, - &format!("{}", deno_core::anyhow::Error::from(rv_err)), - ) - .unwrap(); - let exc = deno_core::v8::Exception::type_error(&mut scope, msg); - scope.throw_exception(exc); - return 1; - } - }; - return 0; - } - extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { - Self::slow_function_impl(info); - } - extern "C" fn v8_fn_ptr_metrics(info: *const deno_core::v8::FunctionCallbackInfo) { - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_slow( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, - ); - let res = Self::slow_function_impl(info); - if res == 0 { - deno_core::_ops::dispatch_metrics_slow( - &opctx, - deno_core::_ops::OpMetricsEvent::Completed, - ); - } else { + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; deno_core::_ops::dispatch_metrics_slow( &opctx, - deno_core::_ops::OpMetricsEvent::Error, + deno_core::_ops::OpMetricsEvent::Dispatched, ); + let res = Self::slow_function_impl(info); + if res == 0 { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Completed, + ); + } else { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Error, + ); + } + } + #[inline(always)] + pub fn call(_input: Input) -> Output { + Output {} } } - #[inline(always)] - pub fn call(_input: Input) -> Output { - Output {} - } + ::DECL } diff --git a/ops/op2/test_cases/sync/smi.out b/ops/op2/test_cases/sync/smi.out index c7e5180ab..af8f4643a 100644 --- a/ops/op2/test_cases/sync/smi.out +++ b/ops/op2/test_cases/sync/smi.out @@ -1,474 +1,333 @@ #[allow(non_camel_case_types)] -struct op_smi_unsigned_return { - _unconstructable: ::std::marker::PhantomData<()>, -} -impl ::deno_core::_ops::Op for op_smi_unsigned_return { - const NAME: &'static str = stringify!(op_smi_unsigned_return); - const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( - ::deno_core::__op_name_fast!(op_smi_unsigned_return), - false, - false, - 4usize as u8, - Self::v8_fn_ptr as _, - Self::v8_fn_ptr_metrics as _, - Some({ - use deno_core::v8::fast_api::Type; - use deno_core::v8::fast_api::CType; - deno_core::v8::fast_api::FastFunction::new_with_bigint( - &[Type::V8Value, Type::Int32, Type::Int32, Type::Int32, Type::Int32], - CType::Int32, - Self::v8_fn_ptr_fast as *const ::std::ffi::c_void, - ) - }), - Some({ - use deno_core::v8::fast_api::Type; - use deno_core::v8::fast_api::CType; - deno_core::v8::fast_api::FastFunction::new_with_bigint( - &[ - Type::V8Value, - Type::Int32, - Type::Int32, - Type::Int32, - Type::Int32, - Type::CallbackOptions, - ], - CType::Int32, - Self::v8_fn_ptr_fast_metrics as *const ::std::ffi::c_void, - ) - }), - ::deno_core::OpMetadata { - ..::deno_core::OpMetadata::default() - }, - ); -} -impl op_smi_unsigned_return { - pub const fn name() -> &'static str { - stringify!(op_smi_unsigned_return) - } - #[deprecated(note = "Use the const op::DECL instead")] - pub const fn decl() -> deno_core::_ops::OpDecl { - ::DECL - } - #[allow(clippy::too_many_arguments)] - extern "C" fn v8_fn_ptr_fast_metrics( - this: deno_core::v8::Local, - arg0: i32, - arg1: i32, - arg2: i32, - arg3: i32, - fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, - ) -> i32 { - let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; - let opctx = unsafe { - &*(deno_core::v8::Local::< - deno_core::v8::External, - >::cast(unsafe { fast_api_callback_options.data.data }) - .value() as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_fast( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, - ); - let res = Self::v8_fn_ptr_fast(this, arg0, arg1, arg2, arg3); - deno_core::_ops::dispatch_metrics_fast( - &opctx, - deno_core::_ops::OpMetricsEvent::Completed, - ); - res +const fn op_smi_unsigned_return() -> ::deno_core::_ops::OpDecl { + #[allow(non_camel_case_types)] + struct op_smi_unsigned_return { + _unconstructable: ::std::marker::PhantomData<()>, } - #[allow(clippy::too_many_arguments)] - extern "C" fn v8_fn_ptr_fast( - _: deno_core::v8::Local, - arg0: i32, - arg1: i32, - arg2: i32, - arg3: i32, - ) -> i32 { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, + impl ::deno_core::_ops::Op for op_smi_unsigned_return { + const NAME: &'static str = stringify!(op_smi_unsigned_return); + const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( + ::deno_core::__op_name_fast!(op_smi_unsigned_return), + false, + false, + 4usize as u8, + Self::v8_fn_ptr as _, + Self::v8_fn_ptr_metrics as _, + Some({ + use deno_core::v8::fast_api::Type; + use deno_core::v8::fast_api::CType; + deno_core::v8::fast_api::FastFunction::new_with_bigint( + &[Type::V8Value, Type::Int32, Type::Int32, Type::Int32, Type::Int32], + CType::Int32, + Self::v8_fn_ptr_fast as *const ::std::ffi::c_void, + ) + }), + Some({ + use deno_core::v8::fast_api::Type; + use deno_core::v8::fast_api::CType; + deno_core::v8::fast_api::FastFunction::new_with_bigint( + &[ + Type::V8Value, + Type::Int32, + Type::Int32, + Type::Int32, + Type::Int32, + Type::CallbackOptions, + ], + CType::Int32, + Self::v8_fn_ptr_fast_metrics as *const ::std::ffi::c_void, + ) + }), + ::deno_core::OpMetadata { + ..::deno_core::OpMetadata::default() + }, ); - let result = { - let arg0 = arg0 as _; - let arg1 = arg1 as _; - let arg2 = arg2 as _; - let arg3 = arg3 as _; - Self::call(arg0, arg1, arg2, arg3) - }; - result as _ } - #[inline(always)] - fn slow_function_impl(info: *const deno_core::v8::FunctionCallbackInfo) -> usize { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, - ); - let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { - &*info - }); - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let result = { - let arg0 = args.get(0usize as i32); - let Some(arg0) = deno_core::_ops::to_i32_option(&arg0) else { - let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; - let msg = deno_core::v8::String::new_from_one_byte( - &mut scope, - "expected i32".as_bytes(), - deno_core::v8::NewStringType::Normal, - ) - .unwrap(); - let exc = deno_core::v8::Exception::type_error(&mut scope, msg); - scope.throw_exception(exc); - return 1; - }; - let arg0 = arg0 as _; - let arg1 = args.get(1usize as i32); - let Some(arg1) = deno_core::_ops::to_i32_option(&arg1) else { - let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; - let msg = deno_core::v8::String::new_from_one_byte( - &mut scope, - "expected i32".as_bytes(), - deno_core::v8::NewStringType::Normal, - ) - .unwrap(); - let exc = deno_core::v8::Exception::type_error(&mut scope, msg); - scope.throw_exception(exc); - return 1; - }; - let arg1 = arg1 as _; - let arg2 = args.get(2usize as i32); - let Some(arg2) = deno_core::_ops::to_i32_option(&arg2) else { - let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; - let msg = deno_core::v8::String::new_from_one_byte( - &mut scope, - "expected i32".as_bytes(), - deno_core::v8::NewStringType::Normal, - ) - .unwrap(); - let exc = deno_core::v8::Exception::type_error(&mut scope, msg); - scope.throw_exception(exc); - return 1; - }; - let arg2 = arg2 as _; - let arg3 = args.get(3usize as i32); - let Some(arg3) = deno_core::_ops::to_i32_option(&arg3) else { - let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; - let msg = deno_core::v8::String::new_from_one_byte( - &mut scope, - "expected i32".as_bytes(), - deno_core::v8::NewStringType::Normal, - ) - .unwrap(); - let exc = deno_core::v8::Exception::type_error(&mut scope, msg); - scope.throw_exception(exc); - return 1; + impl op_smi_unsigned_return { + pub const fn name() -> &'static str { + stringify!(op_smi_unsigned_return) + } + #[allow(clippy::too_many_arguments)] + extern "C" fn v8_fn_ptr_fast_metrics( + this: deno_core::v8::Local, + arg0: i32, + arg1: i32, + arg2: i32, + arg3: i32, + fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, + ) -> i32 { + let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; + let opctx = unsafe { + &*(deno_core::v8::Local::< + deno_core::v8::External, + >::cast(unsafe { fast_api_callback_options.data.data }) + .value() as *const deno_core::_ops::OpCtx) }; - let arg3 = arg3 as _; - Self::call(arg0, arg1, arg2, arg3) - }; - deno_core::_ops::RustToV8RetVal::to_v8_rv( - deno_core::_ops::RustToV8Marker::< - deno_core::_ops::SmiMarker, - _, - >::from(result), - &mut rv, - ); - return 0; - } - extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { - Self::slow_function_impl(info); - } - extern "C" fn v8_fn_ptr_metrics(info: *const deno_core::v8::FunctionCallbackInfo) { - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_slow( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, - ); - let res = Self::slow_function_impl(info); - if res == 0 { - deno_core::_ops::dispatch_metrics_slow( + deno_core::_ops::dispatch_metrics_fast( + &opctx, + deno_core::_ops::OpMetricsEvent::Dispatched, + ); + let res = Self::v8_fn_ptr_fast(this, arg0, arg1, arg2, arg3); + deno_core::_ops::dispatch_metrics_fast( &opctx, deno_core::_ops::OpMetricsEvent::Completed, ); - } else { + res + } + #[allow(clippy::too_many_arguments)] + extern "C" fn v8_fn_ptr_fast( + _: deno_core::v8::Local, + arg0: i32, + arg1: i32, + arg2: i32, + arg3: i32, + ) -> i32 { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, + ); + let result = { + let arg0 = arg0 as _; + let arg1 = arg1 as _; + let arg2 = arg2 as _; + let arg3 = arg3 as _; + Self::call(arg0, arg1, arg2, arg3) + }; + result as _ + } + #[inline(always)] + fn slow_function_impl( + info: *const deno_core::v8::FunctionCallbackInfo, + ) -> usize { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, + ); + let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { + &*info + }); + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let result = { + let arg0 = args.get(0usize as i32); + let Some(arg0) = deno_core::_ops::to_i32_option(&arg0) else { + let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; + let msg = deno_core::v8::String::new_from_one_byte( + &mut scope, + "expected i32".as_bytes(), + deno_core::v8::NewStringType::Normal, + ) + .unwrap(); + let exc = deno_core::v8::Exception::type_error(&mut scope, msg); + scope.throw_exception(exc); + return 1; + }; + let arg0 = arg0 as _; + let arg1 = args.get(1usize as i32); + let Some(arg1) = deno_core::_ops::to_i32_option(&arg1) else { + let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; + let msg = deno_core::v8::String::new_from_one_byte( + &mut scope, + "expected i32".as_bytes(), + deno_core::v8::NewStringType::Normal, + ) + .unwrap(); + let exc = deno_core::v8::Exception::type_error(&mut scope, msg); + scope.throw_exception(exc); + return 1; + }; + let arg1 = arg1 as _; + let arg2 = args.get(2usize as i32); + let Some(arg2) = deno_core::_ops::to_i32_option(&arg2) else { + let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; + let msg = deno_core::v8::String::new_from_one_byte( + &mut scope, + "expected i32".as_bytes(), + deno_core::v8::NewStringType::Normal, + ) + .unwrap(); + let exc = deno_core::v8::Exception::type_error(&mut scope, msg); + scope.throw_exception(exc); + return 1; + }; + let arg2 = arg2 as _; + let arg3 = args.get(3usize as i32); + let Some(arg3) = deno_core::_ops::to_i32_option(&arg3) else { + let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; + let msg = deno_core::v8::String::new_from_one_byte( + &mut scope, + "expected i32".as_bytes(), + deno_core::v8::NewStringType::Normal, + ) + .unwrap(); + let exc = deno_core::v8::Exception::type_error(&mut scope, msg); + scope.throw_exception(exc); + return 1; + }; + let arg3 = arg3 as _; + Self::call(arg0, arg1, arg2, arg3) + }; + deno_core::_ops::RustToV8RetVal::to_v8_rv( + deno_core::_ops::RustToV8Marker::< + deno_core::_ops::SmiMarker, + _, + >::from(result), + &mut rv, + ); + return 0; + } + extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { + Self::slow_function_impl(info); + } + extern "C" fn v8_fn_ptr_metrics( + info: *const deno_core::v8::FunctionCallbackInfo, + ) { + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; deno_core::_ops::dispatch_metrics_slow( &opctx, - deno_core::_ops::OpMetricsEvent::Error, + deno_core::_ops::OpMetricsEvent::Dispatched, ); + let res = Self::slow_function_impl(info); + if res == 0 { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Completed, + ); + } else { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Error, + ); + } + } + #[inline(always)] + fn call(a: Int16, b: Int32, c: Uint16, d: Uint32) -> Uint32 { + a as Uint32 + b as Uint32 + c as Uint32 + d as Uint32 } } - #[inline(always)] - fn call(a: Int16, b: Int32, c: Uint16, d: Uint32) -> Uint32 { - a as Uint32 + b as Uint32 + c as Uint32 + d as Uint32 - } + ::DECL } #[allow(non_camel_case_types)] -struct op_smi_signed_return { - _unconstructable: ::std::marker::PhantomData<()>, -} -impl ::deno_core::_ops::Op for op_smi_signed_return { - const NAME: &'static str = stringify!(op_smi_signed_return); - const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( - ::deno_core::__op_name_fast!(op_smi_signed_return), - false, - false, - 4usize as u8, - Self::v8_fn_ptr as _, - Self::v8_fn_ptr_metrics as _, - Some({ - use deno_core::v8::fast_api::Type; - use deno_core::v8::fast_api::CType; - deno_core::v8::fast_api::FastFunction::new_with_bigint( - &[Type::V8Value, Type::Int32, Type::Int32, Type::Int32, Type::Int32], - CType::Int32, - Self::v8_fn_ptr_fast as *const ::std::ffi::c_void, - ) - }), - Some({ - use deno_core::v8::fast_api::Type; - use deno_core::v8::fast_api::CType; - deno_core::v8::fast_api::FastFunction::new_with_bigint( - &[ - Type::V8Value, - Type::Int32, - Type::Int32, - Type::Int32, - Type::Int32, - Type::CallbackOptions, - ], - CType::Int32, - Self::v8_fn_ptr_fast_metrics as *const ::std::ffi::c_void, - ) - }), - ::deno_core::OpMetadata { - ..::deno_core::OpMetadata::default() - }, - ); -} -impl op_smi_signed_return { - pub const fn name() -> &'static str { - stringify!(op_smi_signed_return) - } - #[deprecated(note = "Use the const op::DECL instead")] - pub const fn decl() -> deno_core::_ops::OpDecl { - ::DECL +const fn op_smi_signed_return() -> ::deno_core::_ops::OpDecl { + #[allow(non_camel_case_types)] + struct op_smi_signed_return { + _unconstructable: ::std::marker::PhantomData<()>, } - #[allow(clippy::too_many_arguments)] - extern "C" fn v8_fn_ptr_fast_metrics( - this: deno_core::v8::Local, - arg0: i32, - arg1: i32, - arg2: i32, - arg3: i32, - fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, - ) -> i32 { - let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; - let opctx = unsafe { - &*(deno_core::v8::Local::< - deno_core::v8::External, - >::cast(unsafe { fast_api_callback_options.data.data }) - .value() as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_fast( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, + impl ::deno_core::_ops::Op for op_smi_signed_return { + const NAME: &'static str = stringify!(op_smi_signed_return); + const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( + ::deno_core::__op_name_fast!(op_smi_signed_return), + false, + false, + 4usize as u8, + Self::v8_fn_ptr as _, + Self::v8_fn_ptr_metrics as _, + Some({ + use deno_core::v8::fast_api::Type; + use deno_core::v8::fast_api::CType; + deno_core::v8::fast_api::FastFunction::new_with_bigint( + &[Type::V8Value, Type::Int32, Type::Int32, Type::Int32, Type::Int32], + CType::Int32, + Self::v8_fn_ptr_fast as *const ::std::ffi::c_void, + ) + }), + Some({ + use deno_core::v8::fast_api::Type; + use deno_core::v8::fast_api::CType; + deno_core::v8::fast_api::FastFunction::new_with_bigint( + &[ + Type::V8Value, + Type::Int32, + Type::Int32, + Type::Int32, + Type::Int32, + Type::CallbackOptions, + ], + CType::Int32, + Self::v8_fn_ptr_fast_metrics as *const ::std::ffi::c_void, + ) + }), + ::deno_core::OpMetadata { + ..::deno_core::OpMetadata::default() + }, ); - let res = Self::v8_fn_ptr_fast(this, arg0, arg1, arg2, arg3); - deno_core::_ops::dispatch_metrics_fast( - &opctx, - deno_core::_ops::OpMetricsEvent::Completed, - ); - res - } - #[allow(clippy::too_many_arguments)] - extern "C" fn v8_fn_ptr_fast( - _: deno_core::v8::Local, - arg0: i32, - arg1: i32, - arg2: i32, - arg3: i32, - ) -> i32 { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, - ); - let result = { - let arg0 = arg0 as _; - let arg1 = arg1 as _; - let arg2 = arg2 as _; - let arg3 = arg3 as _; - Self::call(arg0, arg1, arg2, arg3) - }; - result as _ } - #[inline(always)] - fn slow_function_impl(info: *const deno_core::v8::FunctionCallbackInfo) -> usize { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, - ); - let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { - &*info - }); - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let result = { - let arg0 = args.get(0usize as i32); - let Some(arg0) = deno_core::_ops::to_i32_option(&arg0) else { - let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; - let msg = deno_core::v8::String::new_from_one_byte( - &mut scope, - "expected i32".as_bytes(), - deno_core::v8::NewStringType::Normal, - ) - .unwrap(); - let exc = deno_core::v8::Exception::type_error(&mut scope, msg); - scope.throw_exception(exc); - return 1; - }; - let arg0 = arg0 as _; - let arg1 = args.get(1usize as i32); - let Some(arg1) = deno_core::_ops::to_i32_option(&arg1) else { - let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; - let msg = deno_core::v8::String::new_from_one_byte( - &mut scope, - "expected i32".as_bytes(), - deno_core::v8::NewStringType::Normal, - ) - .unwrap(); - let exc = deno_core::v8::Exception::type_error(&mut scope, msg); - scope.throw_exception(exc); - return 1; - }; - let arg1 = arg1 as _; - let arg2 = args.get(2usize as i32); - let Some(arg2) = deno_core::_ops::to_i32_option(&arg2) else { - let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; - let msg = deno_core::v8::String::new_from_one_byte( - &mut scope, - "expected i32".as_bytes(), - deno_core::v8::NewStringType::Normal, - ) - .unwrap(); - let exc = deno_core::v8::Exception::type_error(&mut scope, msg); - scope.throw_exception(exc); - return 1; - }; - let arg2 = arg2 as _; - let arg3 = args.get(3usize as i32); - let Some(arg3) = deno_core::_ops::to_i32_option(&arg3) else { - let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; - let msg = deno_core::v8::String::new_from_one_byte( - &mut scope, - "expected i32".as_bytes(), - deno_core::v8::NewStringType::Normal, - ) - .unwrap(); - let exc = deno_core::v8::Exception::type_error(&mut scope, msg); - scope.throw_exception(exc); - return 1; + impl op_smi_signed_return { + pub const fn name() -> &'static str { + stringify!(op_smi_signed_return) + } + #[allow(clippy::too_many_arguments)] + extern "C" fn v8_fn_ptr_fast_metrics( + this: deno_core::v8::Local, + arg0: i32, + arg1: i32, + arg2: i32, + arg3: i32, + fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, + ) -> i32 { + let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; + let opctx = unsafe { + &*(deno_core::v8::Local::< + deno_core::v8::External, + >::cast(unsafe { fast_api_callback_options.data.data }) + .value() as *const deno_core::_ops::OpCtx) }; - let arg3 = arg3 as _; - Self::call(arg0, arg1, arg2, arg3) - }; - deno_core::_ops::RustToV8RetVal::to_v8_rv( - deno_core::_ops::RustToV8Marker::< - deno_core::_ops::SmiMarker, - _, - >::from(result), - &mut rv, - ); - return 0; - } - extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { - Self::slow_function_impl(info); - } - extern "C" fn v8_fn_ptr_metrics(info: *const deno_core::v8::FunctionCallbackInfo) { - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_slow( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, - ); - let res = Self::slow_function_impl(info); - if res == 0 { - deno_core::_ops::dispatch_metrics_slow( + deno_core::_ops::dispatch_metrics_fast( &opctx, - deno_core::_ops::OpMetricsEvent::Completed, + deno_core::_ops::OpMetricsEvent::Dispatched, ); - } else { - deno_core::_ops::dispatch_metrics_slow( + let res = Self::v8_fn_ptr_fast(this, arg0, arg1, arg2, arg3); + deno_core::_ops::dispatch_metrics_fast( &opctx, - deno_core::_ops::OpMetricsEvent::Error, + deno_core::_ops::OpMetricsEvent::Completed, ); + res } - } - #[inline(always)] - fn call(a: Int16, b: Int32, c: Uint16, d: Uint32) -> Int32 { - a as Int32 + b as Int32 + c as Int32 + d as Int32 - } -} - -#[allow(non_camel_case_types)] -struct op_smi_option { - _unconstructable: ::std::marker::PhantomData<()>, -} -impl ::deno_core::_ops::Op for op_smi_option { - const NAME: &'static str = stringify!(op_smi_option); - const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( - ::deno_core::__op_name_fast!(op_smi_option), - false, - false, - 1usize as u8, - Self::v8_fn_ptr as _, - Self::v8_fn_ptr_metrics as _, - None, - None, - ::deno_core::OpMetadata { - ..::deno_core::OpMetadata::default() - }, - ); -} -impl op_smi_option { - pub const fn name() -> &'static str { - stringify!(op_smi_option) - } - #[deprecated(note = "Use the const op::DECL instead")] - pub const fn decl() -> deno_core::_ops::OpDecl { - ::DECL - } - #[inline(always)] - fn slow_function_impl(info: *const deno_core::v8::FunctionCallbackInfo) -> usize { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, - ); - let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { - &*info - }); - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let result = { - let arg0 = args.get(0usize as i32); - let arg0 = if arg0.is_null_or_undefined() { - None - } else { + #[allow(clippy::too_many_arguments)] + extern "C" fn v8_fn_ptr_fast( + _: deno_core::v8::Local, + arg0: i32, + arg1: i32, + arg2: i32, + arg3: i32, + ) -> i32 { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, + ); + let result = { + let arg0 = arg0 as _; + let arg1 = arg1 as _; + let arg2 = arg2 as _; + let arg3 = arg3 as _; + Self::call(arg0, arg1, arg2, arg3) + }; + result as _ + } + #[inline(always)] + fn slow_function_impl( + info: *const deno_core::v8::FunctionCallbackInfo, + ) -> usize { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, + ); + let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { + &*info + }); + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let result = { + let arg0 = args.get(0usize as i32); let Some(arg0) = deno_core::_ops::to_i32_option(&arg0) else { let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; let msg = deno_core::v8::String::new_from_one_byte( @@ -482,43 +341,198 @@ impl op_smi_option { return 1; }; let arg0 = arg0 as _; - Some(arg0) + let arg1 = args.get(1usize as i32); + let Some(arg1) = deno_core::_ops::to_i32_option(&arg1) else { + let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; + let msg = deno_core::v8::String::new_from_one_byte( + &mut scope, + "expected i32".as_bytes(), + deno_core::v8::NewStringType::Normal, + ) + .unwrap(); + let exc = deno_core::v8::Exception::type_error(&mut scope, msg); + scope.throw_exception(exc); + return 1; + }; + let arg1 = arg1 as _; + let arg2 = args.get(2usize as i32); + let Some(arg2) = deno_core::_ops::to_i32_option(&arg2) else { + let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; + let msg = deno_core::v8::String::new_from_one_byte( + &mut scope, + "expected i32".as_bytes(), + deno_core::v8::NewStringType::Normal, + ) + .unwrap(); + let exc = deno_core::v8::Exception::type_error(&mut scope, msg); + scope.throw_exception(exc); + return 1; + }; + let arg2 = arg2 as _; + let arg3 = args.get(3usize as i32); + let Some(arg3) = deno_core::_ops::to_i32_option(&arg3) else { + let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; + let msg = deno_core::v8::String::new_from_one_byte( + &mut scope, + "expected i32".as_bytes(), + deno_core::v8::NewStringType::Normal, + ) + .unwrap(); + let exc = deno_core::v8::Exception::type_error(&mut scope, msg); + scope.throw_exception(exc); + return 1; + }; + let arg3 = arg3 as _; + Self::call(arg0, arg1, arg2, arg3) }; - Self::call(arg0) - }; - deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv); - return 0; + deno_core::_ops::RustToV8RetVal::to_v8_rv( + deno_core::_ops::RustToV8Marker::< + deno_core::_ops::SmiMarker, + _, + >::from(result), + &mut rv, + ); + return 0; + } + extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { + Self::slow_function_impl(info); + } + extern "C" fn v8_fn_ptr_metrics( + info: *const deno_core::v8::FunctionCallbackInfo, + ) { + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Dispatched, + ); + let res = Self::slow_function_impl(info); + if res == 0 { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Completed, + ); + } else { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Error, + ); + } + } + #[inline(always)] + fn call(a: Int16, b: Int32, c: Uint16, d: Uint32) -> Int32 { + a as Int32 + b as Int32 + c as Int32 + d as Int32 + } } - extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { - Self::slow_function_impl(info); + ::DECL +} + +#[allow(non_camel_case_types)] +const fn op_smi_option() -> ::deno_core::_ops::OpDecl { + #[allow(non_camel_case_types)] + struct op_smi_option { + _unconstructable: ::std::marker::PhantomData<()>, } - extern "C" fn v8_fn_ptr_metrics(info: *const deno_core::v8::FunctionCallbackInfo) { - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_slow( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, + impl ::deno_core::_ops::Op for op_smi_option { + const NAME: &'static str = stringify!(op_smi_option); + const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( + ::deno_core::__op_name_fast!(op_smi_option), + false, + false, + 1usize as u8, + Self::v8_fn_ptr as _, + Self::v8_fn_ptr_metrics as _, + None, + None, + ::deno_core::OpMetadata { + ..::deno_core::OpMetadata::default() + }, ); - let res = Self::slow_function_impl(info); - if res == 0 { - deno_core::_ops::dispatch_metrics_slow( - &opctx, - deno_core::_ops::OpMetricsEvent::Completed, + } + impl op_smi_option { + pub const fn name() -> &'static str { + stringify!(op_smi_option) + } + #[inline(always)] + fn slow_function_impl( + info: *const deno_core::v8::FunctionCallbackInfo, + ) -> usize { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, ); - } else { + let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { + &*info + }); + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let result = { + let arg0 = args.get(0usize as i32); + let arg0 = if arg0.is_null_or_undefined() { + None + } else { + let Some(arg0) = deno_core::_ops::to_i32_option(&arg0) else { + let mut scope = unsafe { + deno_core::v8::CallbackScope::new(&*info) + }; + let msg = deno_core::v8::String::new_from_one_byte( + &mut scope, + "expected i32".as_bytes(), + deno_core::v8::NewStringType::Normal, + ) + .unwrap(); + let exc = deno_core::v8::Exception::type_error(&mut scope, msg); + scope.throw_exception(exc); + return 1; + }; + let arg0 = arg0 as _; + Some(arg0) + }; + Self::call(arg0) + }; + deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv); + return 0; + } + extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { + Self::slow_function_impl(info); + } + extern "C" fn v8_fn_ptr_metrics( + info: *const deno_core::v8::FunctionCallbackInfo, + ) { + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; deno_core::_ops::dispatch_metrics_slow( &opctx, - deno_core::_ops::OpMetricsEvent::Error, + deno_core::_ops::OpMetricsEvent::Dispatched, ); + let res = Self::slow_function_impl(info); + if res == 0 { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Completed, + ); + } else { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Error, + ); + } + } + #[inline(always)] + fn call(a: Option) -> Option { + a } } - #[inline(always)] - fn call(a: Option) -> Option { - a - } + ::DECL } diff --git a/ops/op2/test_cases/sync/string_cow.out b/ops/op2/test_cases/sync/string_cow.out index ab08e70fd..b6a7fa4ff 100644 --- a/ops/op2/test_cases/sync/string_cow.out +++ b/ops/op2/test_cases/sync/string_cow.out @@ -1,150 +1,154 @@ #[allow(non_camel_case_types)] -struct op_string_cow { - _unconstructable: ::std::marker::PhantomData<()>, -} -impl ::deno_core::_ops::Op for op_string_cow { - const NAME: &'static str = stringify!(op_string_cow); - const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( - ::deno_core::__op_name_fast!(op_string_cow), - false, - false, - 1usize as u8, - Self::v8_fn_ptr as _, - Self::v8_fn_ptr_metrics as _, - Some({ - use deno_core::v8::fast_api::Type; - use deno_core::v8::fast_api::CType; - deno_core::v8::fast_api::FastFunction::new_with_bigint( - &[Type::V8Value, Type::SeqOneByteString], - CType::Uint32, - Self::v8_fn_ptr_fast as *const ::std::ffi::c_void, - ) - }), - Some({ - use deno_core::v8::fast_api::Type; - use deno_core::v8::fast_api::CType; - deno_core::v8::fast_api::FastFunction::new_with_bigint( - &[Type::V8Value, Type::SeqOneByteString, Type::CallbackOptions], - CType::Uint32, - Self::v8_fn_ptr_fast_metrics as *const ::std::ffi::c_void, - ) - }), - ::deno_core::OpMetadata { - ..::deno_core::OpMetadata::default() - }, - ); -} -impl op_string_cow { - pub const fn name() -> &'static str { - stringify!(op_string_cow) - } - #[deprecated(note = "Use the const op::DECL instead")] - pub const fn decl() -> deno_core::_ops::OpDecl { - ::DECL +const fn op_string_cow() -> ::deno_core::_ops::OpDecl { + #[allow(non_camel_case_types)] + struct op_string_cow { + _unconstructable: ::std::marker::PhantomData<()>, } - #[allow(clippy::too_many_arguments)] - extern "C" fn v8_fn_ptr_fast_metrics( - this: deno_core::v8::Local, - arg0: *mut deno_core::v8::fast_api::FastApiOneByteString, - fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, - ) -> u32 { - let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; - let opctx = unsafe { - &*(deno_core::v8::Local::< - deno_core::v8::External, - >::cast(unsafe { fast_api_callback_options.data.data }) - .value() as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_fast( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, + impl ::deno_core::_ops::Op for op_string_cow { + const NAME: &'static str = stringify!(op_string_cow); + const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( + ::deno_core::__op_name_fast!(op_string_cow), + false, + false, + 1usize as u8, + Self::v8_fn_ptr as _, + Self::v8_fn_ptr_metrics as _, + Some({ + use deno_core::v8::fast_api::Type; + use deno_core::v8::fast_api::CType; + deno_core::v8::fast_api::FastFunction::new_with_bigint( + &[Type::V8Value, Type::SeqOneByteString], + CType::Uint32, + Self::v8_fn_ptr_fast as *const ::std::ffi::c_void, + ) + }), + Some({ + use deno_core::v8::fast_api::Type; + use deno_core::v8::fast_api::CType; + deno_core::v8::fast_api::FastFunction::new_with_bigint( + &[Type::V8Value, Type::SeqOneByteString, Type::CallbackOptions], + CType::Uint32, + Self::v8_fn_ptr_fast_metrics as *const ::std::ffi::c_void, + ) + }), + ::deno_core::OpMetadata { + ..::deno_core::OpMetadata::default() + }, ); - let res = Self::v8_fn_ptr_fast(this, arg0); - deno_core::_ops::dispatch_metrics_fast( - &opctx, - deno_core::_ops::OpMetricsEvent::Completed, - ); - res } - #[allow(clippy::too_many_arguments)] - extern "C" fn v8_fn_ptr_fast( - _: deno_core::v8::Local, - arg0: *mut deno_core::v8::fast_api::FastApiOneByteString, - ) -> u32 { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, - ); - let result = { - let mut arg0_temp: [::std::mem::MaybeUninit< - u8, - >; deno_core::_ops::STRING_STACK_BUFFER_SIZE] = [::std::mem::MaybeUninit::uninit(); deno_core::_ops::STRING_STACK_BUFFER_SIZE]; - let arg0 = deno_core::_ops::to_str_ptr( - unsafe { &mut *arg0 }, - &mut arg0_temp, + impl op_string_cow { + pub const fn name() -> &'static str { + stringify!(op_string_cow) + } + #[allow(clippy::too_many_arguments)] + extern "C" fn v8_fn_ptr_fast_metrics( + this: deno_core::v8::Local, + arg0: *mut deno_core::v8::fast_api::FastApiOneByteString, + fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, + ) -> u32 { + let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; + let opctx = unsafe { + &*(deno_core::v8::Local::< + deno_core::v8::External, + >::cast(unsafe { fast_api_callback_options.data.data }) + .value() as *const deno_core::_ops::OpCtx) + }; + deno_core::_ops::dispatch_metrics_fast( + &opctx, + deno_core::_ops::OpMetricsEvent::Dispatched, ); - Self::call(arg0) - }; - result as _ - } - #[inline(always)] - fn slow_function_impl(info: *const deno_core::v8::FunctionCallbackInfo) -> usize { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, - ); - let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { - &*info - }); - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - let mut scope = unsafe { &mut *opctx.isolate }; - let result = { - let arg0 = args.get(0usize as i32); - let mut arg0_temp: [::std::mem::MaybeUninit< - u8, - >; deno_core::_ops::STRING_STACK_BUFFER_SIZE] = [::std::mem::MaybeUninit::uninit(); deno_core::_ops::STRING_STACK_BUFFER_SIZE]; - let arg0 = deno_core::_ops::to_str(&mut scope, &arg0, &mut arg0_temp); - Self::call(arg0) - }; - deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv); - return 0; - } - extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { - Self::slow_function_impl(info); - } - extern "C" fn v8_fn_ptr_metrics(info: *const deno_core::v8::FunctionCallbackInfo) { - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_slow( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, - ); - let res = Self::slow_function_impl(info); - if res == 0 { - deno_core::_ops::dispatch_metrics_slow( + let res = Self::v8_fn_ptr_fast(this, arg0); + deno_core::_ops::dispatch_metrics_fast( &opctx, deno_core::_ops::OpMetricsEvent::Completed, ); - } else { + res + } + #[allow(clippy::too_many_arguments)] + extern "C" fn v8_fn_ptr_fast( + _: deno_core::v8::Local, + arg0: *mut deno_core::v8::fast_api::FastApiOneByteString, + ) -> u32 { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, + ); + let result = { + let mut arg0_temp: [::std::mem::MaybeUninit< + u8, + >; deno_core::_ops::STRING_STACK_BUFFER_SIZE] = [::std::mem::MaybeUninit::uninit(); deno_core::_ops::STRING_STACK_BUFFER_SIZE]; + let arg0 = deno_core::_ops::to_str_ptr( + unsafe { &mut *arg0 }, + &mut arg0_temp, + ); + Self::call(arg0) + }; + result as _ + } + #[inline(always)] + fn slow_function_impl( + info: *const deno_core::v8::FunctionCallbackInfo, + ) -> usize { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, + ); + let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { + &*info + }); + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; + let mut scope = unsafe { &mut *opctx.isolate }; + let result = { + let arg0 = args.get(0usize as i32); + let mut arg0_temp: [::std::mem::MaybeUninit< + u8, + >; deno_core::_ops::STRING_STACK_BUFFER_SIZE] = [::std::mem::MaybeUninit::uninit(); deno_core::_ops::STRING_STACK_BUFFER_SIZE]; + let arg0 = deno_core::_ops::to_str(&mut scope, &arg0, &mut arg0_temp); + Self::call(arg0) + }; + deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv); + return 0; + } + extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { + Self::slow_function_impl(info); + } + extern "C" fn v8_fn_ptr_metrics( + info: *const deno_core::v8::FunctionCallbackInfo, + ) { + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; deno_core::_ops::dispatch_metrics_slow( &opctx, - deno_core::_ops::OpMetricsEvent::Error, + deno_core::_ops::OpMetricsEvent::Dispatched, ); + let res = Self::slow_function_impl(info); + if res == 0 { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Completed, + ); + } else { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Error, + ); + } + } + #[inline(always)] + fn call(s: Cow) -> u32 { + s.len() as _ } } - #[inline(always)] - fn call(s: Cow) -> u32 { - s.len() as _ - } + ::DECL } diff --git a/ops/op2/test_cases/sync/string_onebyte.out b/ops/op2/test_cases/sync/string_onebyte.out index bf690df9d..70b3fcdb8 100644 --- a/ops/op2/test_cases/sync/string_onebyte.out +++ b/ops/op2/test_cases/sync/string_onebyte.out @@ -1,155 +1,161 @@ #[allow(non_camel_case_types)] -struct op_string_onebyte { - _unconstructable: ::std::marker::PhantomData<()>, -} -impl ::deno_core::_ops::Op for op_string_onebyte { - const NAME: &'static str = stringify!(op_string_onebyte); - const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( - ::deno_core::__op_name_fast!(op_string_onebyte), - false, - false, - 1usize as u8, - Self::v8_fn_ptr as _, - Self::v8_fn_ptr_metrics as _, - Some({ - use deno_core::v8::fast_api::Type; - use deno_core::v8::fast_api::CType; - deno_core::v8::fast_api::FastFunction::new_with_bigint( - &[Type::V8Value, Type::SeqOneByteString], - CType::Uint32, - Self::v8_fn_ptr_fast as *const ::std::ffi::c_void, - ) - }), - Some({ - use deno_core::v8::fast_api::Type; - use deno_core::v8::fast_api::CType; - deno_core::v8::fast_api::FastFunction::new_with_bigint( - &[Type::V8Value, Type::SeqOneByteString, Type::CallbackOptions], - CType::Uint32, - Self::v8_fn_ptr_fast_metrics as *const ::std::ffi::c_void, - ) - }), - ::deno_core::OpMetadata { - ..::deno_core::OpMetadata::default() - }, - ); -} -impl op_string_onebyte { - pub const fn name() -> &'static str { - stringify!(op_string_onebyte) +const fn op_string_onebyte() -> ::deno_core::_ops::OpDecl { + #[allow(non_camel_case_types)] + struct op_string_onebyte { + _unconstructable: ::std::marker::PhantomData<()>, } - #[deprecated(note = "Use the const op::DECL instead")] - pub const fn decl() -> deno_core::_ops::OpDecl { - ::DECL - } - #[allow(clippy::too_many_arguments)] - extern "C" fn v8_fn_ptr_fast_metrics( - this: deno_core::v8::Local, - arg0: *mut deno_core::v8::fast_api::FastApiOneByteString, - fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, - ) -> u32 { - let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; - let opctx = unsafe { - &*(deno_core::v8::Local::< - deno_core::v8::External, - >::cast(unsafe { fast_api_callback_options.data.data }) - .value() as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_fast( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, - ); - let res = Self::v8_fn_ptr_fast(this, arg0); - deno_core::_ops::dispatch_metrics_fast( - &opctx, - deno_core::_ops::OpMetricsEvent::Completed, + impl ::deno_core::_ops::Op for op_string_onebyte { + const NAME: &'static str = stringify!(op_string_onebyte); + const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( + ::deno_core::__op_name_fast!(op_string_onebyte), + false, + false, + 1usize as u8, + Self::v8_fn_ptr as _, + Self::v8_fn_ptr_metrics as _, + Some({ + use deno_core::v8::fast_api::Type; + use deno_core::v8::fast_api::CType; + deno_core::v8::fast_api::FastFunction::new_with_bigint( + &[Type::V8Value, Type::SeqOneByteString], + CType::Uint32, + Self::v8_fn_ptr_fast as *const ::std::ffi::c_void, + ) + }), + Some({ + use deno_core::v8::fast_api::Type; + use deno_core::v8::fast_api::CType; + deno_core::v8::fast_api::FastFunction::new_with_bigint( + &[Type::V8Value, Type::SeqOneByteString, Type::CallbackOptions], + CType::Uint32, + Self::v8_fn_ptr_fast_metrics as *const ::std::ffi::c_void, + ) + }), + ::deno_core::OpMetadata { + ..::deno_core::OpMetadata::default() + }, ); - res } - #[allow(clippy::too_many_arguments)] - extern "C" fn v8_fn_ptr_fast( - _: deno_core::v8::Local, - arg0: *mut deno_core::v8::fast_api::FastApiOneByteString, - ) -> u32 { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, - ); - let result = { - let arg0 = deno_core::_ops::to_cow_byte_ptr(unsafe { &mut *arg0 }); - Self::call(arg0) - }; - result as _ - } - #[inline(always)] - fn slow_function_impl(info: *const deno_core::v8::FunctionCallbackInfo) -> usize { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, - ); - let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { - &*info - }); - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - let mut scope = unsafe { &mut *opctx.isolate }; - let result = { - let arg0 = args.get(0usize as i32); - let arg0 = match deno_core::_ops::to_cow_one_byte(&mut scope, &arg0) { - Ok(arg0) => arg0, - Err(arg0) => { - let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; - let msg = deno_core::v8::String::new_from_one_byte( - &mut scope, - arg0.as_bytes(), - deno_core::v8::NewStringType::Normal, - ) - .unwrap(); - let exc = deno_core::v8::Exception::type_error(&mut scope, msg); - scope.throw_exception(exc); - return 1; - } + impl op_string_onebyte { + pub const fn name() -> &'static str { + stringify!(op_string_onebyte) + } + #[allow(clippy::too_many_arguments)] + extern "C" fn v8_fn_ptr_fast_metrics( + this: deno_core::v8::Local, + arg0: *mut deno_core::v8::fast_api::FastApiOneByteString, + fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, + ) -> u32 { + let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; + let opctx = unsafe { + &*(deno_core::v8::Local::< + deno_core::v8::External, + >::cast(unsafe { fast_api_callback_options.data.data }) + .value() as *const deno_core::_ops::OpCtx) }; - Self::call(arg0) - }; - deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv); - return 0; - } - extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { - Self::slow_function_impl(info); - } - extern "C" fn v8_fn_ptr_metrics(info: *const deno_core::v8::FunctionCallbackInfo) { - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_slow( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, - ); - let res = Self::slow_function_impl(info); - if res == 0 { - deno_core::_ops::dispatch_metrics_slow( + deno_core::_ops::dispatch_metrics_fast( + &opctx, + deno_core::_ops::OpMetricsEvent::Dispatched, + ); + let res = Self::v8_fn_ptr_fast(this, arg0); + deno_core::_ops::dispatch_metrics_fast( &opctx, deno_core::_ops::OpMetricsEvent::Completed, ); - } else { + res + } + #[allow(clippy::too_many_arguments)] + extern "C" fn v8_fn_ptr_fast( + _: deno_core::v8::Local, + arg0: *mut deno_core::v8::fast_api::FastApiOneByteString, + ) -> u32 { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, + ); + let result = { + let arg0 = deno_core::_ops::to_cow_byte_ptr(unsafe { &mut *arg0 }); + Self::call(arg0) + }; + result as _ + } + #[inline(always)] + fn slow_function_impl( + info: *const deno_core::v8::FunctionCallbackInfo, + ) -> usize { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, + ); + let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { + &*info + }); + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; + let mut scope = unsafe { &mut *opctx.isolate }; + let result = { + let arg0 = args.get(0usize as i32); + let arg0 = match deno_core::_ops::to_cow_one_byte(&mut scope, &arg0) { + Ok(arg0) => arg0, + Err(arg0) => { + let mut scope = unsafe { + deno_core::v8::CallbackScope::new(&*info) + }; + let msg = deno_core::v8::String::new_from_one_byte( + &mut scope, + arg0.as_bytes(), + deno_core::v8::NewStringType::Normal, + ) + .unwrap(); + let exc = deno_core::v8::Exception::type_error(&mut scope, msg); + scope.throw_exception(exc); + return 1; + } + }; + Self::call(arg0) + }; + deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv); + return 0; + } + extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { + Self::slow_function_impl(info); + } + extern "C" fn v8_fn_ptr_metrics( + info: *const deno_core::v8::FunctionCallbackInfo, + ) { + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; deno_core::_ops::dispatch_metrics_slow( &opctx, - deno_core::_ops::OpMetricsEvent::Error, + deno_core::_ops::OpMetricsEvent::Dispatched, ); + let res = Self::slow_function_impl(info); + if res == 0 { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Completed, + ); + } else { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Error, + ); + } + } + #[inline(always)] + fn call(s: Cow<[u8]>) -> u32 { + s.len() as _ } } - #[inline(always)] - fn call(s: Cow<[u8]>) -> u32 { - s.len() as _ - } + ::DECL } diff --git a/ops/op2/test_cases/sync/string_option_return.out b/ops/op2/test_cases/sync/string_option_return.out index ad39c53bd..48cee1f35 100644 --- a/ops/op2/test_cases/sync/string_option_return.out +++ b/ops/op2/test_cases/sync/string_option_return.out @@ -1,98 +1,102 @@ #[allow(non_camel_case_types)] -pub struct op_string_return { - _unconstructable: ::std::marker::PhantomData<()>, -} -impl ::deno_core::_ops::Op for op_string_return { - const NAME: &'static str = stringify!(op_string_return); - const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( - ::deno_core::__op_name_fast!(op_string_return), - false, - false, - 1usize as u8, - Self::v8_fn_ptr as _, - Self::v8_fn_ptr_metrics as _, - None, - None, - ::deno_core::OpMetadata { - ..::deno_core::OpMetadata::default() - }, - ); -} -impl op_string_return { - pub const fn name() -> &'static str { - stringify!(op_string_return) - } - #[deprecated(note = "Use the const op::DECL instead")] - pub const fn decl() -> deno_core::_ops::OpDecl { - ::DECL +pub const fn op_string_return() -> ::deno_core::_ops::OpDecl { + #[allow(non_camel_case_types)] + pub struct op_string_return { + _unconstructable: ::std::marker::PhantomData<()>, } - #[inline(always)] - fn slow_function_impl(info: *const deno_core::v8::FunctionCallbackInfo) -> usize { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, + impl ::deno_core::_ops::Op for op_string_return { + const NAME: &'static str = stringify!(op_string_return); + const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( + ::deno_core::__op_name_fast!(op_string_return), + false, + false, + 1usize as u8, + Self::v8_fn_ptr as _, + Self::v8_fn_ptr_metrics as _, + None, + None, + ::deno_core::OpMetadata { + ..::deno_core::OpMetadata::default() + }, ); - let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; - let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { - &*info - }); - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let result = { - let arg0 = args.get(0usize as i32); - let arg0 = if arg0.is_null_or_undefined() { - None - } else { - Some(deno_core::_ops::to_string(&mut scope, &arg0)) - }; - Self::call(arg0) - }; - match deno_core::_ops::RustToV8Fallible::to_v8_fallible(result, &mut scope) { - Ok(v) => rv.set(v), - Err(rv_err) => { - let msg = deno_core::v8::String::new( - &mut scope, - &format!("{}", deno_core::anyhow::Error::from(rv_err)), - ) - .unwrap(); - let exc = deno_core::v8::Exception::type_error(&mut scope, msg); - scope.throw_exception(exc); - return 1; - } - }; - return 0; - } - extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { - Self::slow_function_impl(info); } - extern "C" fn v8_fn_ptr_metrics(info: *const deno_core::v8::FunctionCallbackInfo) { - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_slow( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, - ); - let res = Self::slow_function_impl(info); - if res == 0 { - deno_core::_ops::dispatch_metrics_slow( - &opctx, - deno_core::_ops::OpMetricsEvent::Completed, + impl op_string_return { + pub const fn name() -> &'static str { + stringify!(op_string_return) + } + #[inline(always)] + fn slow_function_impl( + info: *const deno_core::v8::FunctionCallbackInfo, + ) -> usize { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, ); - } else { + let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; + let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { + &*info + }); + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let result = { + let arg0 = args.get(0usize as i32); + let arg0 = if arg0.is_null_or_undefined() { + None + } else { + Some(deno_core::_ops::to_string(&mut scope, &arg0)) + }; + Self::call(arg0) + }; + match deno_core::_ops::RustToV8Fallible::to_v8_fallible(result, &mut scope) { + Ok(v) => rv.set(v), + Err(rv_err) => { + let msg = deno_core::v8::String::new( + &mut scope, + &format!("{}", deno_core::anyhow::Error::from(rv_err)), + ) + .unwrap(); + let exc = deno_core::v8::Exception::type_error(&mut scope, msg); + scope.throw_exception(exc); + return 1; + } + }; + return 0; + } + extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { + Self::slow_function_impl(info); + } + extern "C" fn v8_fn_ptr_metrics( + info: *const deno_core::v8::FunctionCallbackInfo, + ) { + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; deno_core::_ops::dispatch_metrics_slow( &opctx, - deno_core::_ops::OpMetricsEvent::Error, + deno_core::_ops::OpMetricsEvent::Dispatched, ); + let res = Self::slow_function_impl(info); + if res == 0 { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Completed, + ); + } else { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Error, + ); + } + } + #[inline(always)] + pub fn call(s: Option) -> Option { + s } } - #[inline(always)] - pub fn call(s: Option) -> Option { - s - } + ::DECL } diff --git a/ops/op2/test_cases/sync/string_owned.out b/ops/op2/test_cases/sync/string_owned.out index 52e67ed9c..8467ab08a 100644 --- a/ops/op2/test_cases/sync/string_owned.out +++ b/ops/op2/test_cases/sync/string_owned.out @@ -1,141 +1,145 @@ #[allow(non_camel_case_types)] -struct op_string_owned { - _unconstructable: ::std::marker::PhantomData<()>, -} -impl ::deno_core::_ops::Op for op_string_owned { - const NAME: &'static str = stringify!(op_string_owned); - const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( - ::deno_core::__op_name_fast!(op_string_owned), - false, - false, - 1usize as u8, - Self::v8_fn_ptr as _, - Self::v8_fn_ptr_metrics as _, - Some({ - use deno_core::v8::fast_api::Type; - use deno_core::v8::fast_api::CType; - deno_core::v8::fast_api::FastFunction::new_with_bigint( - &[Type::V8Value, Type::SeqOneByteString], - CType::Uint32, - Self::v8_fn_ptr_fast as *const ::std::ffi::c_void, - ) - }), - Some({ - use deno_core::v8::fast_api::Type; - use deno_core::v8::fast_api::CType; - deno_core::v8::fast_api::FastFunction::new_with_bigint( - &[Type::V8Value, Type::SeqOneByteString, Type::CallbackOptions], - CType::Uint32, - Self::v8_fn_ptr_fast_metrics as *const ::std::ffi::c_void, - ) - }), - ::deno_core::OpMetadata { - ..::deno_core::OpMetadata::default() - }, - ); -} -impl op_string_owned { - pub const fn name() -> &'static str { - stringify!(op_string_owned) - } - #[deprecated(note = "Use the const op::DECL instead")] - pub const fn decl() -> deno_core::_ops::OpDecl { - ::DECL - } - #[allow(clippy::too_many_arguments)] - extern "C" fn v8_fn_ptr_fast_metrics( - this: deno_core::v8::Local, - arg0: *mut deno_core::v8::fast_api::FastApiOneByteString, - fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, - ) -> u32 { - let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; - let opctx = unsafe { - &*(deno_core::v8::Local::< - deno_core::v8::External, - >::cast(unsafe { fast_api_callback_options.data.data }) - .value() as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_fast( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, - ); - let res = Self::v8_fn_ptr_fast(this, arg0); - deno_core::_ops::dispatch_metrics_fast( - &opctx, - deno_core::_ops::OpMetricsEvent::Completed, - ); - res +const fn op_string_owned() -> ::deno_core::_ops::OpDecl { + #[allow(non_camel_case_types)] + struct op_string_owned { + _unconstructable: ::std::marker::PhantomData<()>, } - #[allow(clippy::too_many_arguments)] - extern "C" fn v8_fn_ptr_fast( - _: deno_core::v8::Local, - arg0: *mut deno_core::v8::fast_api::FastApiOneByteString, - ) -> u32 { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, + impl ::deno_core::_ops::Op for op_string_owned { + const NAME: &'static str = stringify!(op_string_owned); + const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( + ::deno_core::__op_name_fast!(op_string_owned), + false, + false, + 1usize as u8, + Self::v8_fn_ptr as _, + Self::v8_fn_ptr_metrics as _, + Some({ + use deno_core::v8::fast_api::Type; + use deno_core::v8::fast_api::CType; + deno_core::v8::fast_api::FastFunction::new_with_bigint( + &[Type::V8Value, Type::SeqOneByteString], + CType::Uint32, + Self::v8_fn_ptr_fast as *const ::std::ffi::c_void, + ) + }), + Some({ + use deno_core::v8::fast_api::Type; + use deno_core::v8::fast_api::CType; + deno_core::v8::fast_api::FastFunction::new_with_bigint( + &[Type::V8Value, Type::SeqOneByteString, Type::CallbackOptions], + CType::Uint32, + Self::v8_fn_ptr_fast_metrics as *const ::std::ffi::c_void, + ) + }), + ::deno_core::OpMetadata { + ..::deno_core::OpMetadata::default() + }, ); - let result = { - let arg0 = deno_core::_ops::to_string_ptr(unsafe { &mut *arg0 }); - Self::call(arg0) - }; - result as _ } - #[inline(always)] - fn slow_function_impl(info: *const deno_core::v8::FunctionCallbackInfo) -> usize { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, - ); - let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { - &*info - }); - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - let mut scope = unsafe { &mut *opctx.isolate }; - let result = { - let arg0 = args.get(0usize as i32); - let arg0 = deno_core::_ops::to_string(&mut scope, &arg0); - Self::call(arg0) - }; - deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv); - return 0; - } - extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { - Self::slow_function_impl(info); - } - extern "C" fn v8_fn_ptr_metrics(info: *const deno_core::v8::FunctionCallbackInfo) { - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_slow( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, - ); - let res = Self::slow_function_impl(info); - if res == 0 { - deno_core::_ops::dispatch_metrics_slow( + impl op_string_owned { + pub const fn name() -> &'static str { + stringify!(op_string_owned) + } + #[allow(clippy::too_many_arguments)] + extern "C" fn v8_fn_ptr_fast_metrics( + this: deno_core::v8::Local, + arg0: *mut deno_core::v8::fast_api::FastApiOneByteString, + fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, + ) -> u32 { + let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; + let opctx = unsafe { + &*(deno_core::v8::Local::< + deno_core::v8::External, + >::cast(unsafe { fast_api_callback_options.data.data }) + .value() as *const deno_core::_ops::OpCtx) + }; + deno_core::_ops::dispatch_metrics_fast( + &opctx, + deno_core::_ops::OpMetricsEvent::Dispatched, + ); + let res = Self::v8_fn_ptr_fast(this, arg0); + deno_core::_ops::dispatch_metrics_fast( &opctx, deno_core::_ops::OpMetricsEvent::Completed, ); - } else { + res + } + #[allow(clippy::too_many_arguments)] + extern "C" fn v8_fn_ptr_fast( + _: deno_core::v8::Local, + arg0: *mut deno_core::v8::fast_api::FastApiOneByteString, + ) -> u32 { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, + ); + let result = { + let arg0 = deno_core::_ops::to_string_ptr(unsafe { &mut *arg0 }); + Self::call(arg0) + }; + result as _ + } + #[inline(always)] + fn slow_function_impl( + info: *const deno_core::v8::FunctionCallbackInfo, + ) -> usize { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, + ); + let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { + &*info + }); + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; + let mut scope = unsafe { &mut *opctx.isolate }; + let result = { + let arg0 = args.get(0usize as i32); + let arg0 = deno_core::_ops::to_string(&mut scope, &arg0); + Self::call(arg0) + }; + deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv); + return 0; + } + extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { + Self::slow_function_impl(info); + } + extern "C" fn v8_fn_ptr_metrics( + info: *const deno_core::v8::FunctionCallbackInfo, + ) { + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; deno_core::_ops::dispatch_metrics_slow( &opctx, - deno_core::_ops::OpMetricsEvent::Error, + deno_core::_ops::OpMetricsEvent::Dispatched, ); + let res = Self::slow_function_impl(info); + if res == 0 { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Completed, + ); + } else { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Error, + ); + } + } + #[inline(always)] + fn call(s: String) -> u32 { + s.len() as _ } } - #[inline(always)] - fn call(s: String) -> u32 { - s.len() as _ - } + ::DECL } diff --git a/ops/op2/test_cases/sync/string_ref.out b/ops/op2/test_cases/sync/string_ref.out index c4badc64a..3685a8e26 100644 --- a/ops/op2/test_cases/sync/string_ref.out +++ b/ops/op2/test_cases/sync/string_ref.out @@ -1,150 +1,154 @@ #[allow(non_camel_case_types)] -struct op_string_owned { - _unconstructable: ::std::marker::PhantomData<()>, -} -impl ::deno_core::_ops::Op for op_string_owned { - const NAME: &'static str = stringify!(op_string_owned); - const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( - ::deno_core::__op_name_fast!(op_string_owned), - false, - false, - 1usize as u8, - Self::v8_fn_ptr as _, - Self::v8_fn_ptr_metrics as _, - Some({ - use deno_core::v8::fast_api::Type; - use deno_core::v8::fast_api::CType; - deno_core::v8::fast_api::FastFunction::new_with_bigint( - &[Type::V8Value, Type::SeqOneByteString], - CType::Uint32, - Self::v8_fn_ptr_fast as *const ::std::ffi::c_void, - ) - }), - Some({ - use deno_core::v8::fast_api::Type; - use deno_core::v8::fast_api::CType; - deno_core::v8::fast_api::FastFunction::new_with_bigint( - &[Type::V8Value, Type::SeqOneByteString, Type::CallbackOptions], - CType::Uint32, - Self::v8_fn_ptr_fast_metrics as *const ::std::ffi::c_void, - ) - }), - ::deno_core::OpMetadata { - ..::deno_core::OpMetadata::default() - }, - ); -} -impl op_string_owned { - pub const fn name() -> &'static str { - stringify!(op_string_owned) - } - #[deprecated(note = "Use the const op::DECL instead")] - pub const fn decl() -> deno_core::_ops::OpDecl { - ::DECL +const fn op_string_owned() -> ::deno_core::_ops::OpDecl { + #[allow(non_camel_case_types)] + struct op_string_owned { + _unconstructable: ::std::marker::PhantomData<()>, } - #[allow(clippy::too_many_arguments)] - extern "C" fn v8_fn_ptr_fast_metrics( - this: deno_core::v8::Local, - arg0: *mut deno_core::v8::fast_api::FastApiOneByteString, - fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, - ) -> u32 { - let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; - let opctx = unsafe { - &*(deno_core::v8::Local::< - deno_core::v8::External, - >::cast(unsafe { fast_api_callback_options.data.data }) - .value() as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_fast( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, + impl ::deno_core::_ops::Op for op_string_owned { + const NAME: &'static str = stringify!(op_string_owned); + const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( + ::deno_core::__op_name_fast!(op_string_owned), + false, + false, + 1usize as u8, + Self::v8_fn_ptr as _, + Self::v8_fn_ptr_metrics as _, + Some({ + use deno_core::v8::fast_api::Type; + use deno_core::v8::fast_api::CType; + deno_core::v8::fast_api::FastFunction::new_with_bigint( + &[Type::V8Value, Type::SeqOneByteString], + CType::Uint32, + Self::v8_fn_ptr_fast as *const ::std::ffi::c_void, + ) + }), + Some({ + use deno_core::v8::fast_api::Type; + use deno_core::v8::fast_api::CType; + deno_core::v8::fast_api::FastFunction::new_with_bigint( + &[Type::V8Value, Type::SeqOneByteString, Type::CallbackOptions], + CType::Uint32, + Self::v8_fn_ptr_fast_metrics as *const ::std::ffi::c_void, + ) + }), + ::deno_core::OpMetadata { + ..::deno_core::OpMetadata::default() + }, ); - let res = Self::v8_fn_ptr_fast(this, arg0); - deno_core::_ops::dispatch_metrics_fast( - &opctx, - deno_core::_ops::OpMetricsEvent::Completed, - ); - res } - #[allow(clippy::too_many_arguments)] - extern "C" fn v8_fn_ptr_fast( - _: deno_core::v8::Local, - arg0: *mut deno_core::v8::fast_api::FastApiOneByteString, - ) -> u32 { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, - ); - let result = { - let mut arg0_temp: [::std::mem::MaybeUninit< - u8, - >; deno_core::_ops::STRING_STACK_BUFFER_SIZE] = [::std::mem::MaybeUninit::uninit(); deno_core::_ops::STRING_STACK_BUFFER_SIZE]; - let arg0 = &deno_core::_ops::to_str_ptr( - unsafe { &mut *arg0 }, - &mut arg0_temp, + impl op_string_owned { + pub const fn name() -> &'static str { + stringify!(op_string_owned) + } + #[allow(clippy::too_many_arguments)] + extern "C" fn v8_fn_ptr_fast_metrics( + this: deno_core::v8::Local, + arg0: *mut deno_core::v8::fast_api::FastApiOneByteString, + fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, + ) -> u32 { + let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; + let opctx = unsafe { + &*(deno_core::v8::Local::< + deno_core::v8::External, + >::cast(unsafe { fast_api_callback_options.data.data }) + .value() as *const deno_core::_ops::OpCtx) + }; + deno_core::_ops::dispatch_metrics_fast( + &opctx, + deno_core::_ops::OpMetricsEvent::Dispatched, ); - Self::call(arg0) - }; - result as _ - } - #[inline(always)] - fn slow_function_impl(info: *const deno_core::v8::FunctionCallbackInfo) -> usize { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, - ); - let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { - &*info - }); - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - let mut scope = unsafe { &mut *opctx.isolate }; - let result = { - let arg0 = args.get(0usize as i32); - let mut arg0_temp: [::std::mem::MaybeUninit< - u8, - >; deno_core::_ops::STRING_STACK_BUFFER_SIZE] = [::std::mem::MaybeUninit::uninit(); deno_core::_ops::STRING_STACK_BUFFER_SIZE]; - let arg0 = &deno_core::_ops::to_str(&mut scope, &arg0, &mut arg0_temp); - Self::call(arg0) - }; - deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv); - return 0; - } - extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { - Self::slow_function_impl(info); - } - extern "C" fn v8_fn_ptr_metrics(info: *const deno_core::v8::FunctionCallbackInfo) { - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_slow( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, - ); - let res = Self::slow_function_impl(info); - if res == 0 { - deno_core::_ops::dispatch_metrics_slow( + let res = Self::v8_fn_ptr_fast(this, arg0); + deno_core::_ops::dispatch_metrics_fast( &opctx, deno_core::_ops::OpMetricsEvent::Completed, ); - } else { + res + } + #[allow(clippy::too_many_arguments)] + extern "C" fn v8_fn_ptr_fast( + _: deno_core::v8::Local, + arg0: *mut deno_core::v8::fast_api::FastApiOneByteString, + ) -> u32 { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, + ); + let result = { + let mut arg0_temp: [::std::mem::MaybeUninit< + u8, + >; deno_core::_ops::STRING_STACK_BUFFER_SIZE] = [::std::mem::MaybeUninit::uninit(); deno_core::_ops::STRING_STACK_BUFFER_SIZE]; + let arg0 = &deno_core::_ops::to_str_ptr( + unsafe { &mut *arg0 }, + &mut arg0_temp, + ); + Self::call(arg0) + }; + result as _ + } + #[inline(always)] + fn slow_function_impl( + info: *const deno_core::v8::FunctionCallbackInfo, + ) -> usize { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, + ); + let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { + &*info + }); + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; + let mut scope = unsafe { &mut *opctx.isolate }; + let result = { + let arg0 = args.get(0usize as i32); + let mut arg0_temp: [::std::mem::MaybeUninit< + u8, + >; deno_core::_ops::STRING_STACK_BUFFER_SIZE] = [::std::mem::MaybeUninit::uninit(); deno_core::_ops::STRING_STACK_BUFFER_SIZE]; + let arg0 = &deno_core::_ops::to_str(&mut scope, &arg0, &mut arg0_temp); + Self::call(arg0) + }; + deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv); + return 0; + } + extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { + Self::slow_function_impl(info); + } + extern "C" fn v8_fn_ptr_metrics( + info: *const deno_core::v8::FunctionCallbackInfo, + ) { + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; deno_core::_ops::dispatch_metrics_slow( &opctx, - deno_core::_ops::OpMetricsEvent::Error, + deno_core::_ops::OpMetricsEvent::Dispatched, ); + let res = Self::slow_function_impl(info); + if res == 0 { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Completed, + ); + } else { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Error, + ); + } + } + #[inline(always)] + fn call(s: &str) -> u32 { + s.len() as _ } } - #[inline(always)] - fn call(s: &str) -> u32 { - s.len() as _ - } + ::DECL } diff --git a/ops/op2/test_cases/sync/string_return.out b/ops/op2/test_cases/sync/string_return.out index 2c7d94a88..15f416d60 100644 --- a/ops/op2/test_cases/sync/string_return.out +++ b/ops/op2/test_cases/sync/string_return.out @@ -1,263 +1,275 @@ #[allow(non_camel_case_types)] -pub struct op_string_return { - _unconstructable: ::std::marker::PhantomData<()>, -} -impl ::deno_core::_ops::Op for op_string_return { - const NAME: &'static str = stringify!(op_string_return); - const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( - ::deno_core::__op_name_fast!(op_string_return), - false, - false, - 0usize as u8, - Self::v8_fn_ptr as _, - Self::v8_fn_ptr_metrics as _, - None, - None, - ::deno_core::OpMetadata { - ..::deno_core::OpMetadata::default() - }, - ); -} -impl op_string_return { - pub const fn name() -> &'static str { - stringify!(op_string_return) - } - #[deprecated(note = "Use the const op::DECL instead")] - pub const fn decl() -> deno_core::_ops::OpDecl { - ::DECL +pub const fn op_string_return() -> ::deno_core::_ops::OpDecl { + #[allow(non_camel_case_types)] + pub struct op_string_return { + _unconstructable: ::std::marker::PhantomData<()>, } - #[inline(always)] - fn slow_function_impl(info: *const deno_core::v8::FunctionCallbackInfo) -> usize { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, + impl ::deno_core::_ops::Op for op_string_return { + const NAME: &'static str = stringify!(op_string_return); + const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( + ::deno_core::__op_name_fast!(op_string_return), + false, + false, + 0usize as u8, + Self::v8_fn_ptr as _, + Self::v8_fn_ptr_metrics as _, + None, + None, + ::deno_core::OpMetadata { + ..::deno_core::OpMetadata::default() + }, ); - let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; - let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { - &*info - }); - let result = { Self::call() }; - match deno_core::_ops::RustToV8Fallible::to_v8_fallible(result, &mut scope) { - Ok(v) => rv.set(v), - Err(rv_err) => { - let msg = deno_core::v8::String::new( - &mut scope, - &format!("{}", deno_core::anyhow::Error::from(rv_err)), - ) - .unwrap(); - let exc = deno_core::v8::Exception::type_error(&mut scope, msg); - scope.throw_exception(exc); - return 1; - } - }; - return 0; - } - extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { - Self::slow_function_impl(info); } - extern "C" fn v8_fn_ptr_metrics(info: *const deno_core::v8::FunctionCallbackInfo) { - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_slow( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, - ); - let res = Self::slow_function_impl(info); - if res == 0 { - deno_core::_ops::dispatch_metrics_slow( - &opctx, - deno_core::_ops::OpMetricsEvent::Completed, + impl op_string_return { + pub const fn name() -> &'static str { + stringify!(op_string_return) + } + #[inline(always)] + fn slow_function_impl( + info: *const deno_core::v8::FunctionCallbackInfo, + ) -> usize { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, ); - } else { + let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; + let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { + &*info + }); + let result = { Self::call() }; + match deno_core::_ops::RustToV8Fallible::to_v8_fallible(result, &mut scope) { + Ok(v) => rv.set(v), + Err(rv_err) => { + let msg = deno_core::v8::String::new( + &mut scope, + &format!("{}", deno_core::anyhow::Error::from(rv_err)), + ) + .unwrap(); + let exc = deno_core::v8::Exception::type_error(&mut scope, msg); + scope.throw_exception(exc); + return 1; + } + }; + return 0; + } + extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { + Self::slow_function_impl(info); + } + extern "C" fn v8_fn_ptr_metrics( + info: *const deno_core::v8::FunctionCallbackInfo, + ) { + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; deno_core::_ops::dispatch_metrics_slow( &opctx, - deno_core::_ops::OpMetricsEvent::Error, + deno_core::_ops::OpMetricsEvent::Dispatched, ); + let res = Self::slow_function_impl(info); + if res == 0 { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Completed, + ); + } else { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Error, + ); + } + } + #[inline(always)] + pub fn call() -> String { + "".into() } } - #[inline(always)] - pub fn call() -> String { - "".into() - } + ::DECL } #[allow(non_camel_case_types)] -pub struct op_string_return_ref { - _unconstructable: ::std::marker::PhantomData<()>, -} -impl ::deno_core::_ops::Op for op_string_return_ref { - const NAME: &'static str = stringify!(op_string_return_ref); - const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( - ::deno_core::__op_name_fast!(op_string_return_ref), - false, - false, - 0usize as u8, - Self::v8_fn_ptr as _, - Self::v8_fn_ptr_metrics as _, - None, - None, - ::deno_core::OpMetadata { - ..::deno_core::OpMetadata::default() - }, - ); -} -impl op_string_return_ref { - pub const fn name() -> &'static str { - stringify!(op_string_return_ref) +pub const fn op_string_return_ref() -> ::deno_core::_ops::OpDecl { + #[allow(non_camel_case_types)] + pub struct op_string_return_ref { + _unconstructable: ::std::marker::PhantomData<()>, } - #[deprecated(note = "Use the const op::DECL instead")] - pub const fn decl() -> deno_core::_ops::OpDecl { - ::DECL - } - #[inline(always)] - fn slow_function_impl(info: *const deno_core::v8::FunctionCallbackInfo) -> usize { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, + impl ::deno_core::_ops::Op for op_string_return_ref { + const NAME: &'static str = stringify!(op_string_return_ref); + const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( + ::deno_core::__op_name_fast!(op_string_return_ref), + false, + false, + 0usize as u8, + Self::v8_fn_ptr as _, + Self::v8_fn_ptr_metrics as _, + None, + None, + ::deno_core::OpMetadata { + ..::deno_core::OpMetadata::default() + }, ); - let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; - let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { - &*info - }); - let result = { Self::call() }; - match deno_core::_ops::RustToV8Fallible::to_v8_fallible(result, &mut scope) { - Ok(v) => rv.set(v), - Err(rv_err) => { - let msg = deno_core::v8::String::new( - &mut scope, - &format!("{}", deno_core::anyhow::Error::from(rv_err)), - ) - .unwrap(); - let exc = deno_core::v8::Exception::type_error(&mut scope, msg); - scope.throw_exception(exc); - return 1; - } - }; - return 0; - } - extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { - Self::slow_function_impl(info); } - extern "C" fn v8_fn_ptr_metrics(info: *const deno_core::v8::FunctionCallbackInfo) { - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_slow( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, - ); - let res = Self::slow_function_impl(info); - if res == 0 { - deno_core::_ops::dispatch_metrics_slow( - &opctx, - deno_core::_ops::OpMetricsEvent::Completed, + impl op_string_return_ref { + pub const fn name() -> &'static str { + stringify!(op_string_return_ref) + } + #[inline(always)] + fn slow_function_impl( + info: *const deno_core::v8::FunctionCallbackInfo, + ) -> usize { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, ); - } else { + let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; + let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { + &*info + }); + let result = { Self::call() }; + match deno_core::_ops::RustToV8Fallible::to_v8_fallible(result, &mut scope) { + Ok(v) => rv.set(v), + Err(rv_err) => { + let msg = deno_core::v8::String::new( + &mut scope, + &format!("{}", deno_core::anyhow::Error::from(rv_err)), + ) + .unwrap(); + let exc = deno_core::v8::Exception::type_error(&mut scope, msg); + scope.throw_exception(exc); + return 1; + } + }; + return 0; + } + extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { + Self::slow_function_impl(info); + } + extern "C" fn v8_fn_ptr_metrics( + info: *const deno_core::v8::FunctionCallbackInfo, + ) { + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; deno_core::_ops::dispatch_metrics_slow( &opctx, - deno_core::_ops::OpMetricsEvent::Error, + deno_core::_ops::OpMetricsEvent::Dispatched, ); + let res = Self::slow_function_impl(info); + if res == 0 { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Completed, + ); + } else { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Error, + ); + } + } + #[inline(always)] + pub fn call() -> &'static str { + "" } } - #[inline(always)] - pub fn call() -> &'static str { - "" - } + ::DECL } #[allow(non_camel_case_types)] -pub struct op_string_return_cow { - _unconstructable: ::std::marker::PhantomData<()>, -} -impl ::deno_core::_ops::Op for op_string_return_cow { - const NAME: &'static str = stringify!(op_string_return_cow); - const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( - ::deno_core::__op_name_fast!(op_string_return_cow), - false, - false, - 0usize as u8, - Self::v8_fn_ptr as _, - Self::v8_fn_ptr_metrics as _, - None, - None, - ::deno_core::OpMetadata { - ..::deno_core::OpMetadata::default() - }, - ); -} -impl op_string_return_cow { - pub const fn name() -> &'static str { - stringify!(op_string_return_cow) +pub const fn op_string_return_cow() -> ::deno_core::_ops::OpDecl { + #[allow(non_camel_case_types)] + pub struct op_string_return_cow { + _unconstructable: ::std::marker::PhantomData<()>, } - #[deprecated(note = "Use the const op::DECL instead")] - pub const fn decl() -> deno_core::_ops::OpDecl { - ::DECL - } - #[inline(always)] - fn slow_function_impl(info: *const deno_core::v8::FunctionCallbackInfo) -> usize { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, + impl ::deno_core::_ops::Op for op_string_return_cow { + const NAME: &'static str = stringify!(op_string_return_cow); + const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( + ::deno_core::__op_name_fast!(op_string_return_cow), + false, + false, + 0usize as u8, + Self::v8_fn_ptr as _, + Self::v8_fn_ptr_metrics as _, + None, + None, + ::deno_core::OpMetadata { + ..::deno_core::OpMetadata::default() + }, ); - let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; - let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { - &*info - }); - let result = { Self::call() }; - match deno_core::_ops::RustToV8Fallible::to_v8_fallible(result, &mut scope) { - Ok(v) => rv.set(v), - Err(rv_err) => { - let msg = deno_core::v8::String::new( - &mut scope, - &format!("{}", deno_core::anyhow::Error::from(rv_err)), - ) - .unwrap(); - let exc = deno_core::v8::Exception::type_error(&mut scope, msg); - scope.throw_exception(exc); - return 1; - } - }; - return 0; } - extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { - Self::slow_function_impl(info); - } - extern "C" fn v8_fn_ptr_metrics(info: *const deno_core::v8::FunctionCallbackInfo) { - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_slow( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, - ); - let res = Self::slow_function_impl(info); - if res == 0 { - deno_core::_ops::dispatch_metrics_slow( - &opctx, - deno_core::_ops::OpMetricsEvent::Completed, + impl op_string_return_cow { + pub const fn name() -> &'static str { + stringify!(op_string_return_cow) + } + #[inline(always)] + fn slow_function_impl( + info: *const deno_core::v8::FunctionCallbackInfo, + ) -> usize { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, ); - } else { + let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; + let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { + &*info + }); + let result = { Self::call() }; + match deno_core::_ops::RustToV8Fallible::to_v8_fallible(result, &mut scope) { + Ok(v) => rv.set(v), + Err(rv_err) => { + let msg = deno_core::v8::String::new( + &mut scope, + &format!("{}", deno_core::anyhow::Error::from(rv_err)), + ) + .unwrap(); + let exc = deno_core::v8::Exception::type_error(&mut scope, msg); + scope.throw_exception(exc); + return 1; + } + }; + return 0; + } + extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { + Self::slow_function_impl(info); + } + extern "C" fn v8_fn_ptr_metrics( + info: *const deno_core::v8::FunctionCallbackInfo, + ) { + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; deno_core::_ops::dispatch_metrics_slow( &opctx, - deno_core::_ops::OpMetricsEvent::Error, + deno_core::_ops::OpMetricsEvent::Dispatched, ); + let res = Self::slow_function_impl(info); + if res == 0 { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Completed, + ); + } else { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Error, + ); + } + } + #[inline(always)] + pub fn call<'a>() -> Cow<'a, str> { + "".into() } } - #[inline(always)] - pub fn call<'a>() -> Cow<'a, str> { - "".into() - } + ::DECL } diff --git a/ops/op2/test_cases/sync/v8_global.out b/ops/op2/test_cases/sync/v8_global.out index b50e56225..4f6406fb0 100644 --- a/ops/op2/test_cases/sync/v8_global.out +++ b/ops/op2/test_cases/sync/v8_global.out @@ -1,96 +1,100 @@ #[allow(non_camel_case_types)] -pub struct op_global { - _unconstructable: ::std::marker::PhantomData<()>, -} -impl ::deno_core::_ops::Op for op_global { - const NAME: &'static str = stringify!(op_global); - const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( - ::deno_core::__op_name_fast!(op_global), - false, - false, - 1usize as u8, - Self::v8_fn_ptr as _, - Self::v8_fn_ptr_metrics as _, - None, - None, - ::deno_core::OpMetadata { - ..::deno_core::OpMetadata::default() - }, - ); -} -impl op_global { - pub const fn name() -> &'static str { - stringify!(op_global) +pub const fn op_global() -> ::deno_core::_ops::OpDecl { + #[allow(non_camel_case_types)] + pub struct op_global { + _unconstructable: ::std::marker::PhantomData<()>, } - #[deprecated(note = "Use the const op::DECL instead")] - pub const fn decl() -> deno_core::_ops::OpDecl { - ::DECL - } - #[inline(always)] - fn slow_function_impl(info: *const deno_core::v8::FunctionCallbackInfo) -> usize { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, + impl ::deno_core::_ops::Op for op_global { + const NAME: &'static str = stringify!(op_global); + const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( + ::deno_core::__op_name_fast!(op_global), + false, + false, + 1usize as u8, + Self::v8_fn_ptr as _, + Self::v8_fn_ptr_metrics as _, + None, + None, + ::deno_core::OpMetadata { + ..::deno_core::OpMetadata::default() + }, ); - let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; - let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { - &*info - }); - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let result = { - let arg0 = args.get(0usize as i32); - let Ok(mut arg0) = deno_core::_ops::v8_try_convert::< - deno_core::v8::String, - >(arg0) else { - let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; - let msg = deno_core::v8::String::new_from_one_byte( - &mut scope, - "expected String".as_bytes(), - deno_core::v8::NewStringType::Normal, - ) - .unwrap(); - let exc = deno_core::v8::Exception::type_error(&mut scope, msg); - scope.throw_exception(exc); - return 1; - }; - let arg0 = deno_core::v8::Global::new(&mut scope, arg0); - Self::call(arg0) - }; - rv.set(deno_core::_ops::RustToV8::to_v8(result, &mut scope)); - return 0; } - extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { - Self::slow_function_impl(info); - } - extern "C" fn v8_fn_ptr_metrics(info: *const deno_core::v8::FunctionCallbackInfo) { - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_slow( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, - ); - let res = Self::slow_function_impl(info); - if res == 0 { - deno_core::_ops::dispatch_metrics_slow( - &opctx, - deno_core::_ops::OpMetricsEvent::Completed, + impl op_global { + pub const fn name() -> &'static str { + stringify!(op_global) + } + #[inline(always)] + fn slow_function_impl( + info: *const deno_core::v8::FunctionCallbackInfo, + ) -> usize { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, ); - } else { + let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; + let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { + &*info + }); + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let result = { + let arg0 = args.get(0usize as i32); + let Ok(mut arg0) = deno_core::_ops::v8_try_convert::< + deno_core::v8::String, + >(arg0) else { + let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; + let msg = deno_core::v8::String::new_from_one_byte( + &mut scope, + "expected String".as_bytes(), + deno_core::v8::NewStringType::Normal, + ) + .unwrap(); + let exc = deno_core::v8::Exception::type_error(&mut scope, msg); + scope.throw_exception(exc); + return 1; + }; + let arg0 = deno_core::v8::Global::new(&mut scope, arg0); + Self::call(arg0) + }; + rv.set(deno_core::_ops::RustToV8::to_v8(result, &mut scope)); + return 0; + } + extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { + Self::slow_function_impl(info); + } + extern "C" fn v8_fn_ptr_metrics( + info: *const deno_core::v8::FunctionCallbackInfo, + ) { + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; deno_core::_ops::dispatch_metrics_slow( &opctx, - deno_core::_ops::OpMetricsEvent::Error, + deno_core::_ops::OpMetricsEvent::Dispatched, ); + let res = Self::slow_function_impl(info); + if res == 0 { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Completed, + ); + } else { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Error, + ); + } + } + #[inline(always)] + pub fn call(g: v8::Global) -> v8::Global { + g } } - #[inline(always)] - pub fn call(g: v8::Global) -> v8::Global { - g - } + ::DECL } diff --git a/ops/op2/test_cases/sync/v8_handlescope.out b/ops/op2/test_cases/sync/v8_handlescope.out index e65462f0a..01fe092b4 100644 --- a/ops/op2/test_cases/sync/v8_handlescope.out +++ b/ops/op2/test_cases/sync/v8_handlescope.out @@ -1,99 +1,103 @@ #[allow(non_camel_case_types)] -struct op_handlescope { - _unconstructable: ::std::marker::PhantomData<()>, -} -impl ::deno_core::_ops::Op for op_handlescope { - const NAME: &'static str = stringify!(op_handlescope); - const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( - ::deno_core::__op_name_fast!(op_handlescope), - false, - false, - 2usize as u8, - Self::v8_fn_ptr as _, - Self::v8_fn_ptr_metrics as _, - None, - None, - ::deno_core::OpMetadata { - ..::deno_core::OpMetadata::default() - }, - ); -} -impl op_handlescope { - pub const fn name() -> &'static str { - stringify!(op_handlescope) +const fn op_handlescope() -> ::deno_core::_ops::OpDecl { + #[allow(non_camel_case_types)] + struct op_handlescope { + _unconstructable: ::std::marker::PhantomData<()>, } - #[deprecated(note = "Use the const op::DECL instead")] - pub const fn decl() -> deno_core::_ops::OpDecl { - ::DECL - } - #[inline(always)] - fn slow_function_impl(info: *const deno_core::v8::FunctionCallbackInfo) -> usize { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, + impl ::deno_core::_ops::Op for op_handlescope { + const NAME: &'static str = stringify!(op_handlescope); + const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( + ::deno_core::__op_name_fast!(op_handlescope), + false, + false, + 2usize as u8, + Self::v8_fn_ptr as _, + Self::v8_fn_ptr_metrics as _, + None, + None, + ::deno_core::OpMetadata { + ..::deno_core::OpMetadata::default() + }, ); - let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; - let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { - &*info - }); - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let result = { - let arg1 = args.get(0usize as i32); - let Ok(mut arg1) = deno_core::_ops::v8_try_convert::< - deno_core::v8::String, - >(arg1) else { - let msg = deno_core::v8::String::new_from_one_byte( - &mut scope, - "expected String".as_bytes(), - deno_core::v8::NewStringType::Normal, - ) - .unwrap(); - let exc = deno_core::v8::Exception::type_error(&mut scope, msg); - scope.throw_exception(exc); - return 1; - }; - let arg1 = arg1; - let arg0 = &mut scope; - Self::call(arg0, arg1) - }; - rv.set(deno_core::_ops::RustToV8NoScope::to_v8(result)); - return 0; } - extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { - Self::slow_function_impl(info); - } - extern "C" fn v8_fn_ptr_metrics(info: *const deno_core::v8::FunctionCallbackInfo) { - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_slow( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, - ); - let res = Self::slow_function_impl(info); - if res == 0 { - deno_core::_ops::dispatch_metrics_slow( - &opctx, - deno_core::_ops::OpMetricsEvent::Completed, + impl op_handlescope { + pub const fn name() -> &'static str { + stringify!(op_handlescope) + } + #[inline(always)] + fn slow_function_impl( + info: *const deno_core::v8::FunctionCallbackInfo, + ) -> usize { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, ); - } else { + let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; + let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { + &*info + }); + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let result = { + let arg1 = args.get(0usize as i32); + let Ok(mut arg1) = deno_core::_ops::v8_try_convert::< + deno_core::v8::String, + >(arg1) else { + let msg = deno_core::v8::String::new_from_one_byte( + &mut scope, + "expected String".as_bytes(), + deno_core::v8::NewStringType::Normal, + ) + .unwrap(); + let exc = deno_core::v8::Exception::type_error(&mut scope, msg); + scope.throw_exception(exc); + return 1; + }; + let arg1 = arg1; + let arg0 = &mut scope; + Self::call(arg0, arg1) + }; + rv.set(deno_core::_ops::RustToV8NoScope::to_v8(result)); + return 0; + } + extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { + Self::slow_function_impl(info); + } + extern "C" fn v8_fn_ptr_metrics( + info: *const deno_core::v8::FunctionCallbackInfo, + ) { + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; deno_core::_ops::dispatch_metrics_slow( &opctx, - deno_core::_ops::OpMetricsEvent::Error, + deno_core::_ops::OpMetricsEvent::Dispatched, ); + let res = Self::slow_function_impl(info); + if res == 0 { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Completed, + ); + } else { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Error, + ); + } + } + #[inline(always)] + fn call<'a>( + _scope: &v8::HandleScope<'a>, + _str2: v8::Local, + ) -> v8::Local<'a, v8::String> { + unimplemented!() } } - #[inline(always)] - fn call<'a>( - _scope: &v8::HandleScope<'a>, - _str2: v8::Local, - ) -> v8::Local<'a, v8::String> { - unimplemented!() - } + ::DECL } diff --git a/ops/op2/test_cases/sync/v8_lifetime.out b/ops/op2/test_cases/sync/v8_lifetime.out index 841facfd1..f2d8a23b6 100644 --- a/ops/op2/test_cases/sync/v8_lifetime.out +++ b/ops/op2/test_cases/sync/v8_lifetime.out @@ -1,95 +1,99 @@ #[allow(non_camel_case_types)] -pub struct op_v8_lifetime { - _unconstructable: ::std::marker::PhantomData<()>, -} -impl ::deno_core::_ops::Op for op_v8_lifetime { - const NAME: &'static str = stringify!(op_v8_lifetime); - const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( - ::deno_core::__op_name_fast!(op_v8_lifetime), - false, - false, - 1usize as u8, - Self::v8_fn_ptr as _, - Self::v8_fn_ptr_metrics as _, - None, - None, - ::deno_core::OpMetadata { - ..::deno_core::OpMetadata::default() - }, - ); -} -impl op_v8_lifetime { - pub const fn name() -> &'static str { - stringify!(op_v8_lifetime) +pub const fn op_v8_lifetime() -> ::deno_core::_ops::OpDecl { + #[allow(non_camel_case_types)] + pub struct op_v8_lifetime { + _unconstructable: ::std::marker::PhantomData<()>, } - #[deprecated(note = "Use the const op::DECL instead")] - pub const fn decl() -> deno_core::_ops::OpDecl { - ::DECL - } - #[inline(always)] - fn slow_function_impl(info: *const deno_core::v8::FunctionCallbackInfo) -> usize { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, + impl ::deno_core::_ops::Op for op_v8_lifetime { + const NAME: &'static str = stringify!(op_v8_lifetime); + const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( + ::deno_core::__op_name_fast!(op_v8_lifetime), + false, + false, + 1usize as u8, + Self::v8_fn_ptr as _, + Self::v8_fn_ptr_metrics as _, + None, + None, + ::deno_core::OpMetadata { + ..::deno_core::OpMetadata::default() + }, ); - let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { - &*info - }); - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let result = { - let arg0 = args.get(0usize as i32); - let Ok(mut arg0) = deno_core::_ops::v8_try_convert::< - deno_core::v8::String, - >(arg0) else { - let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; - let msg = deno_core::v8::String::new_from_one_byte( - &mut scope, - "expected String".as_bytes(), - deno_core::v8::NewStringType::Normal, - ) - .unwrap(); - let exc = deno_core::v8::Exception::type_error(&mut scope, msg); - scope.throw_exception(exc); - return 1; - }; - let arg0 = arg0; - Self::call(arg0) - }; - rv.set(deno_core::_ops::RustToV8NoScope::to_v8(result)); - return 0; } - extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { - Self::slow_function_impl(info); - } - extern "C" fn v8_fn_ptr_metrics(info: *const deno_core::v8::FunctionCallbackInfo) { - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_slow( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, - ); - let res = Self::slow_function_impl(info); - if res == 0 { - deno_core::_ops::dispatch_metrics_slow( - &opctx, - deno_core::_ops::OpMetricsEvent::Completed, + impl op_v8_lifetime { + pub const fn name() -> &'static str { + stringify!(op_v8_lifetime) + } + #[inline(always)] + fn slow_function_impl( + info: *const deno_core::v8::FunctionCallbackInfo, + ) -> usize { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, ); - } else { + let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { + &*info + }); + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let result = { + let arg0 = args.get(0usize as i32); + let Ok(mut arg0) = deno_core::_ops::v8_try_convert::< + deno_core::v8::String, + >(arg0) else { + let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; + let msg = deno_core::v8::String::new_from_one_byte( + &mut scope, + "expected String".as_bytes(), + deno_core::v8::NewStringType::Normal, + ) + .unwrap(); + let exc = deno_core::v8::Exception::type_error(&mut scope, msg); + scope.throw_exception(exc); + return 1; + }; + let arg0 = arg0; + Self::call(arg0) + }; + rv.set(deno_core::_ops::RustToV8NoScope::to_v8(result)); + return 0; + } + extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { + Self::slow_function_impl(info); + } + extern "C" fn v8_fn_ptr_metrics( + info: *const deno_core::v8::FunctionCallbackInfo, + ) { + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; deno_core::_ops::dispatch_metrics_slow( &opctx, - deno_core::_ops::OpMetricsEvent::Error, + deno_core::_ops::OpMetricsEvent::Dispatched, ); + let res = Self::slow_function_impl(info); + if res == 0 { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Completed, + ); + } else { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Error, + ); + } + } + #[inline(always)] + pub fn call<'s>(_s: v8::Local<'s, v8::String>) -> v8::Local<'s, v8::String> { + unimplemented!() } } - #[inline(always)] - pub fn call<'s>(_s: v8::Local<'s, v8::String>) -> v8::Local<'s, v8::String> { - unimplemented!() - } + ::DECL } diff --git a/ops/op2/test_cases/sync/v8_ref_option.out b/ops/op2/test_cases/sync/v8_ref_option.out index a00419034..4ad4682f1 100644 --- a/ops/op2/test_cases/sync/v8_ref_option.out +++ b/ops/op2/test_cases/sync/v8_ref_option.out @@ -1,193 +1,207 @@ #[allow(non_camel_case_types)] -pub struct op_v8_lifetime { - _unconstructable: ::std::marker::PhantomData<()>, -} -impl ::deno_core::_ops::Op for op_v8_lifetime { - const NAME: &'static str = stringify!(op_v8_lifetime); - const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( - ::deno_core::__op_name_fast!(op_v8_lifetime), - false, - false, - 2usize as u8, - Self::v8_fn_ptr as _, - Self::v8_fn_ptr_metrics as _, - Some({ - use deno_core::v8::fast_api::Type; - use deno_core::v8::fast_api::CType; - deno_core::v8::fast_api::FastFunction::new_with_bigint( - &[Type::V8Value, Type::V8Value, Type::V8Value, Type::CallbackOptions], - CType::Void, - Self::v8_fn_ptr_fast as *const ::std::ffi::c_void, - ) - }), - Some({ - use deno_core::v8::fast_api::Type; - use deno_core::v8::fast_api::CType; - deno_core::v8::fast_api::FastFunction::new_with_bigint( - &[Type::V8Value, Type::V8Value, Type::V8Value, Type::CallbackOptions], - CType::Void, - Self::v8_fn_ptr_fast_metrics as *const ::std::ffi::c_void, - ) - }), - ::deno_core::OpMetadata { - ..::deno_core::OpMetadata::default() - }, - ); -} -impl op_v8_lifetime { - pub const fn name() -> &'static str { - stringify!(op_v8_lifetime) +pub const fn op_v8_lifetime() -> ::deno_core::_ops::OpDecl { + #[allow(non_camel_case_types)] + pub struct op_v8_lifetime { + _unconstructable: ::std::marker::PhantomData<()>, } - #[deprecated(note = "Use the const op::DECL instead")] - pub const fn decl() -> deno_core::_ops::OpDecl { - ::DECL - } - #[allow(clippy::too_many_arguments)] - extern "C" fn v8_fn_ptr_fast_metrics( - this: deno_core::v8::Local, - arg0: deno_core::v8::Local, - arg1: deno_core::v8::Local, - fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, - ) -> () { - let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; - let opctx = unsafe { - &*(deno_core::v8::Local::< - deno_core::v8::External, - >::cast(unsafe { fast_api_callback_options.data.data }) - .value() as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_fast( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, - ); - let res = Self::v8_fn_ptr_fast(this, arg0, arg1, fast_api_callback_options); - deno_core::_ops::dispatch_metrics_fast( - &opctx, - deno_core::_ops::OpMetricsEvent::Completed, + impl ::deno_core::_ops::Op for op_v8_lifetime { + const NAME: &'static str = stringify!(op_v8_lifetime); + const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( + ::deno_core::__op_name_fast!(op_v8_lifetime), + false, + false, + 2usize as u8, + Self::v8_fn_ptr as _, + Self::v8_fn_ptr_metrics as _, + Some({ + use deno_core::v8::fast_api::Type; + use deno_core::v8::fast_api::CType; + deno_core::v8::fast_api::FastFunction::new_with_bigint( + &[ + Type::V8Value, + Type::V8Value, + Type::V8Value, + Type::CallbackOptions, + ], + CType::Void, + Self::v8_fn_ptr_fast as *const ::std::ffi::c_void, + ) + }), + Some({ + use deno_core::v8::fast_api::Type; + use deno_core::v8::fast_api::CType; + deno_core::v8::fast_api::FastFunction::new_with_bigint( + &[ + Type::V8Value, + Type::V8Value, + Type::V8Value, + Type::CallbackOptions, + ], + CType::Void, + Self::v8_fn_ptr_fast_metrics as *const ::std::ffi::c_void, + ) + }), + ::deno_core::OpMetadata { + ..::deno_core::OpMetadata::default() + }, ); - res } - #[allow(clippy::too_many_arguments)] - extern "C" fn v8_fn_ptr_fast( - _: deno_core::v8::Local, - arg0: deno_core::v8::Local, - arg1: deno_core::v8::Local, - fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, - ) -> () { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, - ); - let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; - let result = { - let Ok(mut arg0) = deno_core::_ops::v8_try_convert_option::< - deno_core::v8::String, - >(arg0) else { - fast_api_callback_options.fallback = true; - return unsafe { std::mem::zeroed() }; - }; - let arg0 = match &arg0 { - None => None, - Some(v) => Some(::std::ops::Deref::deref(v)), - }; - let Ok(mut arg1) = deno_core::_ops::v8_try_convert_option::< - deno_core::v8::String, - >(arg1) else { - fast_api_callback_options.fallback = true; - return unsafe { std::mem::zeroed() }; - }; - let arg1 = match &arg1 { - None => None, - Some(v) => Some(::std::ops::Deref::deref(v)), - }; - Self::call(arg0, arg1) - }; - result as _ - } - #[inline(always)] - fn slow_function_impl(info: *const deno_core::v8::FunctionCallbackInfo) -> usize { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, - ); - let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { - &*info - }); - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let result = { - let arg0 = args.get(0usize as i32); - let Ok(mut arg0) = deno_core::_ops::v8_try_convert_option::< - deno_core::v8::String, - >(arg0) else { - let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; - let msg = deno_core::v8::String::new_from_one_byte( - &mut scope, - "expected String".as_bytes(), - deno_core::v8::NewStringType::Normal, - ) - .unwrap(); - let exc = deno_core::v8::Exception::type_error(&mut scope, msg); - scope.throw_exception(exc); - return 1; - }; - let arg0 = match &arg0 { - None => None, - Some(v) => Some(::std::ops::Deref::deref(v)), - }; - let arg1 = args.get(1usize as i32); - let Ok(mut arg1) = deno_core::_ops::v8_try_convert_option::< - deno_core::v8::String, - >(arg1) else { - let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; - let msg = deno_core::v8::String::new_from_one_byte( - &mut scope, - "expected String".as_bytes(), - deno_core::v8::NewStringType::Normal, - ) - .unwrap(); - let exc = deno_core::v8::Exception::type_error(&mut scope, msg); - scope.throw_exception(exc); - return 1; - }; - let arg1 = match &arg1 { - None => None, - Some(v) => Some(::std::ops::Deref::deref(v)), + impl op_v8_lifetime { + pub const fn name() -> &'static str { + stringify!(op_v8_lifetime) + } + #[allow(clippy::too_many_arguments)] + extern "C" fn v8_fn_ptr_fast_metrics( + this: deno_core::v8::Local, + arg0: deno_core::v8::Local, + arg1: deno_core::v8::Local, + fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, + ) -> () { + let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; + let opctx = unsafe { + &*(deno_core::v8::Local::< + deno_core::v8::External, + >::cast(unsafe { fast_api_callback_options.data.data }) + .value() as *const deno_core::_ops::OpCtx) }; - Self::call(arg0, arg1) - }; - deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv); - return 0; - } - extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { - Self::slow_function_impl(info); - } - extern "C" fn v8_fn_ptr_metrics(info: *const deno_core::v8::FunctionCallbackInfo) { - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_slow( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, - ); - let res = Self::slow_function_impl(info); - if res == 0 { - deno_core::_ops::dispatch_metrics_slow( + deno_core::_ops::dispatch_metrics_fast( + &opctx, + deno_core::_ops::OpMetricsEvent::Dispatched, + ); + let res = Self::v8_fn_ptr_fast(this, arg0, arg1, fast_api_callback_options); + deno_core::_ops::dispatch_metrics_fast( &opctx, deno_core::_ops::OpMetricsEvent::Completed, ); - } else { + res + } + #[allow(clippy::too_many_arguments)] + extern "C" fn v8_fn_ptr_fast( + _: deno_core::v8::Local, + arg0: deno_core::v8::Local, + arg1: deno_core::v8::Local, + fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, + ) -> () { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, + ); + let fast_api_callback_options = unsafe { &mut *fast_api_callback_options }; + let result = { + let Ok(mut arg0) = deno_core::_ops::v8_try_convert_option::< + deno_core::v8::String, + >(arg0) else { + fast_api_callback_options.fallback = true; + return unsafe { std::mem::zeroed() }; + }; + let arg0 = match &arg0 { + None => None, + Some(v) => Some(::std::ops::Deref::deref(v)), + }; + let Ok(mut arg1) = deno_core::_ops::v8_try_convert_option::< + deno_core::v8::String, + >(arg1) else { + fast_api_callback_options.fallback = true; + return unsafe { std::mem::zeroed() }; + }; + let arg1 = match &arg1 { + None => None, + Some(v) => Some(::std::ops::Deref::deref(v)), + }; + Self::call(arg0, arg1) + }; + result as _ + } + #[inline(always)] + fn slow_function_impl( + info: *const deno_core::v8::FunctionCallbackInfo, + ) -> usize { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, + ); + let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { + &*info + }); + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let result = { + let arg0 = args.get(0usize as i32); + let Ok(mut arg0) = deno_core::_ops::v8_try_convert_option::< + deno_core::v8::String, + >(arg0) else { + let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; + let msg = deno_core::v8::String::new_from_one_byte( + &mut scope, + "expected String".as_bytes(), + deno_core::v8::NewStringType::Normal, + ) + .unwrap(); + let exc = deno_core::v8::Exception::type_error(&mut scope, msg); + scope.throw_exception(exc); + return 1; + }; + let arg0 = match &arg0 { + None => None, + Some(v) => Some(::std::ops::Deref::deref(v)), + }; + let arg1 = args.get(1usize as i32); + let Ok(mut arg1) = deno_core::_ops::v8_try_convert_option::< + deno_core::v8::String, + >(arg1) else { + let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; + let msg = deno_core::v8::String::new_from_one_byte( + &mut scope, + "expected String".as_bytes(), + deno_core::v8::NewStringType::Normal, + ) + .unwrap(); + let exc = deno_core::v8::Exception::type_error(&mut scope, msg); + scope.throw_exception(exc); + return 1; + }; + let arg1 = match &arg1 { + None => None, + Some(v) => Some(::std::ops::Deref::deref(v)), + }; + Self::call(arg0, arg1) + }; + deno_core::_ops::RustToV8RetVal::to_v8_rv(result, &mut rv); + return 0; + } + extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { + Self::slow_function_impl(info); + } + extern "C" fn v8_fn_ptr_metrics( + info: *const deno_core::v8::FunctionCallbackInfo, + ) { + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; deno_core::_ops::dispatch_metrics_slow( &opctx, - deno_core::_ops::OpMetricsEvent::Error, + deno_core::_ops::OpMetricsEvent::Dispatched, ); + let res = Self::slow_function_impl(info); + if res == 0 { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Completed, + ); + } else { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Error, + ); + } } + #[inline(always)] + pub fn call<'s>(_s: Option<&v8::String>, _s2: Option<&v8::String>) {} } - #[inline(always)] - pub fn call<'s>(_s: Option<&v8::String>, _s2: Option<&v8::String>) {} + ::DECL } diff --git a/ops/op2/test_cases/sync/v8_string.out b/ops/op2/test_cases/sync/v8_string.out index 121ea746b..deefbd4f8 100644 --- a/ops/op2/test_cases/sync/v8_string.out +++ b/ops/op2/test_cases/sync/v8_string.out @@ -1,114 +1,118 @@ #[allow(non_camel_case_types)] -struct op_v8_string { - _unconstructable: ::std::marker::PhantomData<()>, -} -impl ::deno_core::_ops::Op for op_v8_string { - const NAME: &'static str = stringify!(op_v8_string); - const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( - ::deno_core::__op_name_fast!(op_v8_string), - false, - false, - 2usize as u8, - Self::v8_fn_ptr as _, - Self::v8_fn_ptr_metrics as _, - None, - None, - ::deno_core::OpMetadata { - ..::deno_core::OpMetadata::default() - }, - ); -} -impl op_v8_string { - pub const fn name() -> &'static str { - stringify!(op_v8_string) +const fn op_v8_string() -> ::deno_core::_ops::OpDecl { + #[allow(non_camel_case_types)] + struct op_v8_string { + _unconstructable: ::std::marker::PhantomData<()>, } - #[deprecated(note = "Use the const op::DECL instead")] - pub const fn decl() -> deno_core::_ops::OpDecl { - ::DECL - } - #[inline(always)] - fn slow_function_impl(info: *const deno_core::v8::FunctionCallbackInfo) -> usize { - #[cfg(debug_assertions)] - let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( - &::DECL, + impl ::deno_core::_ops::Op for op_v8_string { + const NAME: &'static str = stringify!(op_v8_string); + const DECL: ::deno_core::_ops::OpDecl = ::deno_core::_ops::OpDecl::new_internal_op2( + ::deno_core::__op_name_fast!(op_v8_string), + false, + false, + 2usize as u8, + Self::v8_fn_ptr as _, + Self::v8_fn_ptr_metrics as _, + None, + None, + ::deno_core::OpMetadata { + ..::deno_core::OpMetadata::default() + }, ); - let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { - &*info - }); - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let result = { - let arg0 = args.get(0usize as i32); - let Ok(mut arg0) = deno_core::_ops::v8_try_convert::< - deno_core::v8::String, - >(arg0) else { - let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; - let msg = deno_core::v8::String::new_from_one_byte( - &mut scope, - "expected String".as_bytes(), - deno_core::v8::NewStringType::Normal, - ) - .unwrap(); - let exc = deno_core::v8::Exception::type_error(&mut scope, msg); - scope.throw_exception(exc); - return 1; - }; - let arg0 = &arg0; - let arg1 = args.get(1usize as i32); - let Ok(mut arg1) = deno_core::_ops::v8_try_convert::< - deno_core::v8::String, - >(arg1) else { - let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; - let msg = deno_core::v8::String::new_from_one_byte( - &mut scope, - "expected String".as_bytes(), - deno_core::v8::NewStringType::Normal, - ) - .unwrap(); - let exc = deno_core::v8::Exception::type_error(&mut scope, msg); - scope.throw_exception(exc); - return 1; - }; - let arg1 = arg1; - Self::call(arg0, arg1) - }; - rv.set(deno_core::_ops::RustToV8NoScope::to_v8(result)); - return 0; - } - extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { - Self::slow_function_impl(info); } - extern "C" fn v8_fn_ptr_metrics(info: *const deno_core::v8::FunctionCallbackInfo) { - let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { - &*info - }); - let opctx = unsafe { - &*(deno_core::v8::Local::::cast(args.data()).value() - as *const deno_core::_ops::OpCtx) - }; - deno_core::_ops::dispatch_metrics_slow( - &opctx, - deno_core::_ops::OpMetricsEvent::Dispatched, - ); - let res = Self::slow_function_impl(info); - if res == 0 { - deno_core::_ops::dispatch_metrics_slow( - &opctx, - deno_core::_ops::OpMetricsEvent::Completed, + impl op_v8_string { + pub const fn name() -> &'static str { + stringify!(op_v8_string) + } + #[inline(always)] + fn slow_function_impl( + info: *const deno_core::v8::FunctionCallbackInfo, + ) -> usize { + #[cfg(debug_assertions)] + let _reentrancy_check_guard = deno_core::_ops::reentrancy_check( + &::DECL, ); - } else { + let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { + &*info + }); + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let result = { + let arg0 = args.get(0usize as i32); + let Ok(mut arg0) = deno_core::_ops::v8_try_convert::< + deno_core::v8::String, + >(arg0) else { + let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; + let msg = deno_core::v8::String::new_from_one_byte( + &mut scope, + "expected String".as_bytes(), + deno_core::v8::NewStringType::Normal, + ) + .unwrap(); + let exc = deno_core::v8::Exception::type_error(&mut scope, msg); + scope.throw_exception(exc); + return 1; + }; + let arg0 = &arg0; + let arg1 = args.get(1usize as i32); + let Ok(mut arg1) = deno_core::_ops::v8_try_convert::< + deno_core::v8::String, + >(arg1) else { + let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) }; + let msg = deno_core::v8::String::new_from_one_byte( + &mut scope, + "expected String".as_bytes(), + deno_core::v8::NewStringType::Normal, + ) + .unwrap(); + let exc = deno_core::v8::Exception::type_error(&mut scope, msg); + scope.throw_exception(exc); + return 1; + }; + let arg1 = arg1; + Self::call(arg0, arg1) + }; + rv.set(deno_core::_ops::RustToV8NoScope::to_v8(result)); + return 0; + } + extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { + Self::slow_function_impl(info); + } + extern "C" fn v8_fn_ptr_metrics( + info: *const deno_core::v8::FunctionCallbackInfo, + ) { + let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { + &*info + }); + let opctx = unsafe { + &*(deno_core::v8::Local::::cast(args.data()) + .value() as *const deno_core::_ops::OpCtx) + }; deno_core::_ops::dispatch_metrics_slow( &opctx, - deno_core::_ops::OpMetricsEvent::Error, + deno_core::_ops::OpMetricsEvent::Dispatched, ); + let res = Self::slow_function_impl(info); + if res == 0 { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Completed, + ); + } else { + deno_core::_ops::dispatch_metrics_slow( + &opctx, + deno_core::_ops::OpMetricsEvent::Error, + ); + } + } + #[inline(always)] + fn call<'a>( + _str1: &v8::String, + _str2: v8::Local, + ) -> v8::Local<'a, v8::String> { + unimplemented!() } } - #[inline(always)] - fn call<'a>( - _str1: &v8::String, - _str2: v8::Local, - ) -> v8::Local<'a, v8::String> { - unimplemented!() - } + ::DECL }