diff options
Diffstat (limited to 'ops/op2/test_cases')
-rw-r--r-- | ops/op2/test_cases/sync/add.out | 47 | ||||
-rw-r--r-- | ops/op2/test_cases/sync/add_options.out | 21 | ||||
-rw-r--r-- | ops/op2/test_cases/sync/doc_comment.out | 35 | ||||
-rw-r--r-- | ops/op2/test_cases/sync/generics.out | 59 | ||||
-rw-r--r-- | ops/op2/test_cases/sync/generics.rs | 4 | ||||
-rw-r--r-- | ops/op2/test_cases/sync/result_primitive.out | 79 | ||||
-rw-r--r-- | ops/op2/test_cases/sync/result_void.out | 79 | ||||
-rw-r--r-- | ops/op2/test_cases/sync/smi.out | 47 |
8 files changed, 282 insertions, 89 deletions
diff --git a/ops/op2/test_cases/sync/add.out b/ops/op2/test_cases/sync/add.out index 7d97a7161..c8f77ab92 100644 --- a/ops/op2/test_cases/sync/add.out +++ b/ops/op2/test_cases/sync/add.out @@ -1,5 +1,28 @@ #[allow(non_camel_case_types)] -struct op_add {} +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 { + name: stringify!(op_add), + v8_fn_ptr: Self::v8_fn_ptr as _, + enabled: true, + fast_fn: Some({ + use deno_core::v8::fast_api::Type; + use deno_core::v8::fast_api::CType; + deno_core::v8::fast_api::FastFunction::new( + &[Type::V8Value, Type::Uint32, Type::Uint32], + CType::Uint32, + Self::v8_fn_ptr_fast as *const ::std::ffi::c_void, + ) + }), + is_async: false, + is_unstable: false, + is_v8: false, + arg_count: 2usize as u8, + }; +} impl op_add { pub const fn name() -> &'static str { stringify!(op_add) @@ -7,7 +30,7 @@ impl op_add { pub const fn decl() -> deno_core::_ops::OpDecl { deno_core::_ops::OpDecl { name: stringify!(op_add), - v8_fn_ptr: Self::slow_function as _, + v8_fn_ptr: Self::v8_fn_ptr as _, enabled: true, fast_fn: Some({ use deno_core::v8::fast_api::Type; @@ -15,7 +38,7 @@ impl op_add { deno_core::v8::fast_api::FastFunction::new( &[Type::V8Value, Type::Uint32, Type::Uint32], CType::Uint32, - Self::fast_function as *const ::std::ffi::c_void, + Self::v8_fn_ptr_fast as *const ::std::ffi::c_void, ) }), is_async: false, @@ -24,7 +47,15 @@ impl op_add { arg_count: 2usize as u8, } } - pub extern "C" fn slow_function(info: *const deno_core::v8::FunctionCallbackInfo) { + fn v8_fn_ptr_fast( + _: deno_core::v8::Local<deno_core::v8::Object>, + arg0: u32, + arg1: u32, + ) -> u32 { + let result = Self::call(arg0 as _, arg1 as _); + result + } + extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { &*info }); @@ -38,14 +69,6 @@ impl op_add { let result = Self::call(arg0, arg1); rv.set_uint32(result as u32); } - fn fast_function( - _: deno_core::v8::Local<deno_core::v8::Object>, - arg0: u32, - arg1: u32, - ) -> u32 { - let result = Self::call(arg0 as _, arg1 as _); - result - } #[inline(always)] fn call(a: u32, b: u32) -> u32 { a + b diff --git a/ops/op2/test_cases/sync/add_options.out b/ops/op2/test_cases/sync/add_options.out index ca1da8fbe..9fada187f 100644 --- a/ops/op2/test_cases/sync/add_options.out +++ b/ops/op2/test_cases/sync/add_options.out @@ -1,5 +1,20 @@ #[allow(non_camel_case_types)] -pub struct op_test_add_option {} +pub struct op_test_add_option { + _unconstructable: ::std::marker::PhantomData<()>, +} +impl crate::_ops::Op for op_test_add_option { + const NAME: &'static str = stringify!(op_test_add_option); + const DECL: crate::_ops::OpDecl = crate::_ops::OpDecl { + name: stringify!(op_test_add_option), + v8_fn_ptr: Self::v8_fn_ptr as _, + enabled: true, + fast_fn: None, + is_async: false, + is_unstable: false, + is_v8: false, + arg_count: 2usize as u8, + }; +} impl op_test_add_option { pub const fn name() -> &'static str { stringify!(op_test_add_option) @@ -7,7 +22,7 @@ impl op_test_add_option { pub const fn decl() -> crate::_ops::OpDecl { crate::_ops::OpDecl { name: stringify!(op_test_add_option), - v8_fn_ptr: Self::slow_function as _, + v8_fn_ptr: Self::v8_fn_ptr as _, enabled: true, fast_fn: None, is_async: false, @@ -16,7 +31,7 @@ impl op_test_add_option { arg_count: 2usize as u8, } } - pub extern "C" fn slow_function(info: *const crate::v8::FunctionCallbackInfo) { + extern "C" fn v8_fn_ptr(info: *const crate::v8::FunctionCallbackInfo) { let mut rv = crate::v8::ReturnValue::from_function_callback_info(unsafe { &*info }); diff --git a/ops/op2/test_cases/sync/doc_comment.out b/ops/op2/test_cases/sync/doc_comment.out index e9f063102..d7e8005d9 100644 --- a/ops/op2/test_cases/sync/doc_comment.out +++ b/ops/op2/test_cases/sync/doc_comment.out @@ -1,5 +1,28 @@ #[allow(non_camel_case_types)] -pub struct op_has_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 { + name: stringify!(op_has_doc_comment), + v8_fn_ptr: Self::v8_fn_ptr as _, + enabled: true, + fast_fn: Some({ + use deno_core::v8::fast_api::Type; + use deno_core::v8::fast_api::CType; + deno_core::v8::fast_api::FastFunction::new( + &[Type::V8Value], + CType::Void, + Self::v8_fn_ptr_fast as *const ::std::ffi::c_void, + ) + }), + is_async: false, + is_unstable: false, + is_v8: false, + arg_count: 0usize as u8, + }; +} impl op_has_doc_comment { pub const fn name() -> &'static str { stringify!(op_has_doc_comment) @@ -7,7 +30,7 @@ impl op_has_doc_comment { pub const fn decl() -> deno_core::_ops::OpDecl { deno_core::_ops::OpDecl { name: stringify!(op_has_doc_comment), - v8_fn_ptr: Self::slow_function as _, + v8_fn_ptr: Self::v8_fn_ptr as _, enabled: true, fast_fn: Some({ use deno_core::v8::fast_api::Type; @@ -15,7 +38,7 @@ impl op_has_doc_comment { deno_core::v8::fast_api::FastFunction::new( &[Type::V8Value], CType::Void, - Self::fast_function as *const ::std::ffi::c_void, + Self::v8_fn_ptr_fast as *const ::std::ffi::c_void, ) }), is_async: false, @@ -24,12 +47,12 @@ impl op_has_doc_comment { arg_count: 0usize as u8, } } - pub extern "C" fn slow_function(info: *const deno_core::v8::FunctionCallbackInfo) { + fn v8_fn_ptr_fast(_: deno_core::v8::Local<deno_core::v8::Object>) -> () { let result = Self::call(); + result } - fn fast_function(_: deno_core::v8::Local<deno_core::v8::Object>) -> () { + extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { let result = Self::call(); - result } #[inline(always)] pub fn call() -> () {} diff --git a/ops/op2/test_cases/sync/generics.out b/ops/op2/test_cases/sync/generics.out new file mode 100644 index 000000000..26e3af9b7 --- /dev/null +++ b/ops/op2/test_cases/sync/generics.out @@ -0,0 +1,59 @@ +#[allow(non_camel_case_types)] +pub struct op_generics<T> { + _unconstructable: ::std::marker::PhantomData<(T)>, +} +impl<T: Trait> deno_core::_ops::Op for op_generics<T> { + const NAME: &'static str = stringify!(op_generics); + const DECL: deno_core::_ops::OpDecl = deno_core::_ops::OpDecl { + name: stringify!(op_generics), + v8_fn_ptr: Self::v8_fn_ptr as _, + enabled: true, + fast_fn: Some({ + use deno_core::v8::fast_api::Type; + use deno_core::v8::fast_api::CType; + deno_core::v8::fast_api::FastFunction::new( + &[Type::V8Value], + CType::Void, + Self::v8_fn_ptr_fast as *const ::std::ffi::c_void, + ) + }), + is_async: false, + is_unstable: false, + is_v8: false, + arg_count: 0usize as u8, + }; +} +impl<T: Trait> op_generics<T> { + pub const fn name() -> &'static str { + stringify!(op_generics) + } + pub const fn decl() -> deno_core::_ops::OpDecl { + deno_core::_ops::OpDecl { + name: stringify!(op_generics), + v8_fn_ptr: Self::v8_fn_ptr as _, + enabled: true, + fast_fn: Some({ + use deno_core::v8::fast_api::Type; + use deno_core::v8::fast_api::CType; + deno_core::v8::fast_api::FastFunction::new( + &[Type::V8Value], + CType::Void, + Self::v8_fn_ptr_fast as *const ::std::ffi::c_void, + ) + }), + is_async: false, + is_unstable: false, + is_v8: false, + arg_count: 0usize as u8, + } + } + fn v8_fn_ptr_fast(_: deno_core::v8::Local<deno_core::v8::Object>) -> () { + let result = Self::call(); + result + } + extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { + let result = Self::call(); + } + #[inline(always)] + pub fn call() {} +} diff --git a/ops/op2/test_cases/sync/generics.rs b/ops/op2/test_cases/sync/generics.rs new file mode 100644 index 000000000..b412a7f93 --- /dev/null +++ b/ops/op2/test_cases/sync/generics.rs @@ -0,0 +1,4 @@ +// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. + +#[op2(fast)] +pub fn op_generics<T: Trait>() {} diff --git a/ops/op2/test_cases/sync/result_primitive.out b/ops/op2/test_cases/sync/result_primitive.out index 151e8e730..4f296a893 100644 --- a/ops/op2/test_cases/sync/result_primitive.out +++ b/ops/op2/test_cases/sync/result_primitive.out @@ -1,5 +1,28 @@ #[allow(non_camel_case_types)] -pub struct op_u32_with_result {} +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 { + name: stringify!(op_u32_with_result), + v8_fn_ptr: Self::v8_fn_ptr as _, + enabled: true, + fast_fn: Some({ + use deno_core::v8::fast_api::Type; + use deno_core::v8::fast_api::CType; + deno_core::v8::fast_api::FastFunction::new( + &[Type::V8Value, Type::CallbackOptions], + CType::Uint32, + Self::v8_fn_ptr_fast as *const ::std::ffi::c_void, + ) + }), + is_async: false, + is_unstable: false, + is_v8: false, + arg_count: 0usize as u8, + }; +} impl op_u32_with_result { pub const fn name() -> &'static str { stringify!(op_u32_with_result) @@ -7,7 +30,7 @@ impl op_u32_with_result { pub const fn decl() -> deno_core::_ops::OpDecl { deno_core::_ops::OpDecl { name: stringify!(op_u32_with_result), - v8_fn_ptr: Self::slow_function as _, + v8_fn_ptr: Self::v8_fn_ptr as _, enabled: true, fast_fn: Some({ use deno_core::v8::fast_api::Type; @@ -15,7 +38,7 @@ impl op_u32_with_result { deno_core::v8::fast_api::FastFunction::new( &[Type::V8Value, Type::CallbackOptions], CType::Uint32, - Self::fast_function as *const ::std::ffi::c_void, + Self::v8_fn_ptr_fast as *const ::std::ffi::c_void, ) }), is_async: false, @@ -24,7 +47,31 @@ impl op_u32_with_result { arg_count: 0usize as u8, } } - pub extern "C" fn slow_function(info: *const deno_core::v8::FunctionCallbackInfo) { + fn v8_fn_ptr_fast( + _: deno_core::v8::Local<deno_core::v8::Object>, + 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::< + 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) => { + unsafe { + opctx.unsafely_set_last_error_for_ops_only(err); + } + fast_api_callback_options.fallback = true; + return ::std::default::Default::default(); + } + }; + result + } + extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { &*info }); @@ -70,30 +117,6 @@ impl op_u32_with_result { } }; } - fn fast_function( - _: deno_core::v8::Local<deno_core::v8::Object>, - 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::< - 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) => { - unsafe { - opctx.unsafely_set_last_error_for_ops_only(err); - } - fast_api_callback_options.fallback = true; - return ::std::default::Default::default(); - } - }; - result - } #[inline(always)] pub fn call() -> Result<u32, AnyError> {} } diff --git a/ops/op2/test_cases/sync/result_void.out b/ops/op2/test_cases/sync/result_void.out index afc10582b..74aa84a8d 100644 --- a/ops/op2/test_cases/sync/result_void.out +++ b/ops/op2/test_cases/sync/result_void.out @@ -1,5 +1,28 @@ #[allow(non_camel_case_types)] -pub struct op_void_with_result {} +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 { + name: stringify!(op_void_with_result), + v8_fn_ptr: Self::v8_fn_ptr as _, + enabled: true, + fast_fn: Some({ + use deno_core::v8::fast_api::Type; + use deno_core::v8::fast_api::CType; + deno_core::v8::fast_api::FastFunction::new( + &[Type::V8Value, Type::CallbackOptions], + CType::Void, + Self::v8_fn_ptr_fast as *const ::std::ffi::c_void, + ) + }), + is_async: false, + is_unstable: false, + is_v8: false, + arg_count: 0usize as u8, + }; +} impl op_void_with_result { pub const fn name() -> &'static str { stringify!(op_void_with_result) @@ -7,7 +30,7 @@ impl op_void_with_result { pub const fn decl() -> deno_core::_ops::OpDecl { deno_core::_ops::OpDecl { name: stringify!(op_void_with_result), - v8_fn_ptr: Self::slow_function as _, + v8_fn_ptr: Self::v8_fn_ptr as _, enabled: true, fast_fn: Some({ use deno_core::v8::fast_api::Type; @@ -15,7 +38,7 @@ impl op_void_with_result { deno_core::v8::fast_api::FastFunction::new( &[Type::V8Value, Type::CallbackOptions], CType::Void, - Self::fast_function as *const ::std::ffi::c_void, + Self::v8_fn_ptr_fast as *const ::std::ffi::c_void, ) }), is_async: false, @@ -24,7 +47,31 @@ impl op_void_with_result { arg_count: 0usize as u8, } } - pub extern "C" fn slow_function(info: *const deno_core::v8::FunctionCallbackInfo) { + fn v8_fn_ptr_fast( + _: deno_core::v8::Local<deno_core::v8::Object>, + 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::< + 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) => { + unsafe { + opctx.unsafely_set_last_error_for_ops_only(err); + } + fast_api_callback_options.fallback = true; + return ::std::default::Default::default(); + } + }; + result + } + extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info(unsafe { &*info }); @@ -65,30 +112,6 @@ impl op_void_with_result { } }; } - fn fast_function( - _: deno_core::v8::Local<deno_core::v8::Object>, - 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::< - 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) => { - unsafe { - opctx.unsafely_set_last_error_for_ops_only(err); - } - fast_api_callback_options.fallback = true; - return ::std::default::Default::default(); - } - }; - result - } #[inline(always)] pub fn call() -> Result<(), AnyError> {} } diff --git a/ops/op2/test_cases/sync/smi.out b/ops/op2/test_cases/sync/smi.out index 7210e0572..85db2576e 100644 --- a/ops/op2/test_cases/sync/smi.out +++ b/ops/op2/test_cases/sync/smi.out @@ -1,5 +1,28 @@ #[allow(non_camel_case_types)] -struct op_add {} +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 { + name: stringify!(op_add), + v8_fn_ptr: Self::v8_fn_ptr as _, + enabled: true, + fast_fn: Some({ + use deno_core::v8::fast_api::Type; + use deno_core::v8::fast_api::CType; + deno_core::v8::fast_api::FastFunction::new( + &[Type::V8Value, Type::Int32, Type::Uint32], + CType::Uint32, + Self::v8_fn_ptr_fast as *const ::std::ffi::c_void, + ) + }), + is_async: false, + is_unstable: false, + is_v8: false, + arg_count: 2usize as u8, + }; +} impl op_add { pub const fn name() -> &'static str { stringify!(op_add) @@ -7,7 +30,7 @@ impl op_add { pub const fn decl() -> deno_core::_ops::OpDecl { deno_core::_ops::OpDecl { name: stringify!(op_add), - v8_fn_ptr: Self::slow_function as _, + v8_fn_ptr: Self::v8_fn_ptr as _, enabled: true, fast_fn: Some({ use deno_core::v8::fast_api::Type; @@ -15,7 +38,7 @@ impl op_add { deno_core::v8::fast_api::FastFunction::new( &[Type::V8Value, Type::Int32, Type::Uint32], CType::Uint32, - Self::fast_function as *const ::std::ffi::c_void, + Self::v8_fn_ptr_fast as *const ::std::ffi::c_void, ) }), is_async: false, @@ -24,7 +47,15 @@ impl op_add { arg_count: 2usize as u8, } } - pub extern "C" fn slow_function(info: *const deno_core::v8::FunctionCallbackInfo) { + fn v8_fn_ptr_fast( + _: deno_core::v8::Local<deno_core::v8::Object>, + arg0: i32, + arg1: u32, + ) -> u32 { + let result = Self::call(arg0 as _, arg1 as _); + result + } + extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe { &*info }); @@ -38,14 +69,6 @@ impl op_add { let result = Self::call(arg0, arg1); rv.set_uint32(result as u32); } - fn fast_function( - _: deno_core::v8::Local<deno_core::v8::Object>, - arg0: i32, - arg1: u32, - ) -> u32 { - let result = Self::call(arg0 as _, arg1 as _); - result - } #[inline(always)] fn call(id: ResourceId, extra: u16) -> u32 {} } |