diff options
Diffstat (limited to 'ops/optimizer_tests')
31 files changed, 1391 insertions, 689 deletions
diff --git a/ops/optimizer_tests/async_nop.out b/ops/optimizer_tests/async_nop.out index d59967a45..85c55f2f4 100644 --- a/ops/optimizer_tests/async_nop.out +++ b/ops/optimizer_tests/async_nop.out @@ -3,16 +3,39 @@ /// ///Use `op_void_async::decl()` to get an op-declaration ///you can include in a `deno_core::Extension`. -pub struct op_void_async; +pub struct op_void_async { + _phantom_data: ::std::marker::PhantomData<()>, +} +impl deno_core::_ops::Op for op_void_async { + const NAME: &'static str = stringify!(op_void_async); + const DECL: deno_core::OpDecl = deno_core::OpDecl { + name: Self::name(), + v8_fn_ptr: Self::v8_fn_ptr as _, + enabled: true, + fast_fn: { + use deno_core::v8::fast_api::CType; + use deno_core::v8::fast_api::Type::*; + Some( + deno_core::v8::fast_api::FastFunction::new( + &[V8Value, Int32, CallbackOptions], + CType::Void, + Self::op_void_async_fast_fn as *const ::std::ffi::c_void, + ), + ) + }, + is_async: true, + is_unstable: false, + is_v8: false, + arg_count: 0, + }; +} #[doc(hidden)] impl op_void_async { pub const fn name() -> &'static str { stringify!(op_void_async) } #[allow(clippy::not_unsafe_ptr_arg_deref)] - pub extern "C" fn v8_fn_ptr<'scope>( - info: *const deno_core::v8::FunctionCallbackInfo, - ) { + pub extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { let info = unsafe { &*info }; let scope = &mut unsafe { deno_core::v8::CallbackScope::new(info) }; let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info( @@ -21,19 +44,19 @@ impl op_void_async { let rv = deno_core::v8::ReturnValue::from_function_callback_info(info); Self::v8_func(scope, args, rv); } - pub const fn decl<'scope>() -> deno_core::OpDecl { + pub const fn decl() -> deno_core::OpDecl { deno_core::OpDecl { name: Self::name(), v8_fn_ptr: Self::v8_fn_ptr as _, enabled: true, fast_fn: { - use deno_core::v8::fast_api::Type::*; use deno_core::v8::fast_api::CType; + use deno_core::v8::fast_api::Type::*; Some( deno_core::v8::fast_api::FastFunction::new( &[V8Value, Int32, CallbackOptions], CType::Void, - op_void_async_fast_fn as *const ::std::ffi::c_void, + Self::op_void_async_fast_fn as *const ::std::ffi::c_void, ), ) }, @@ -45,7 +68,8 @@ impl op_void_async { } #[inline] #[allow(clippy::too_many_arguments)] - async fn call() {} + #[allow(clippy::extra_unused_lifetimes)] + async fn call<'scope>() {} pub fn v8_func<'scope>( scope: &mut deno_core::v8::HandleScope<'scope>, args: deno_core::v8::FunctionCallbackArguments, @@ -85,27 +109,29 @@ impl op_void_async { } } } -#[allow(clippy::too_many_arguments)] -fn op_void_async_fast_fn<'scope>( - _: deno_core::v8::Local<deno_core::v8::Object>, - __promise_id: i32, - fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, -) -> () { - use deno_core::v8; - use deno_core::_ops; - let __opts: &mut v8::fast_api::FastApiCallbackOptions = unsafe { - &mut *fast_api_callback_options - }; - let __ctx = unsafe { - &*(v8::Local::<v8::External>::cast(unsafe { __opts.data.data }).value() - as *const _ops::OpCtx) - }; - let op_state = __ctx.state.clone(); - let result = op_void_async::call(); - let result = _ops::queue_fast_async_op( - __ctx, - __promise_id, - async move { Ok(result.await) }, - ); - result +impl op_void_async { + #[allow(clippy::too_many_arguments)] + fn op_void_async_fast_fn( + _: deno_core::v8::Local<deno_core::v8::Object>, + __promise_id: i32, + fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, + ) -> () { + use deno_core::v8; + use deno_core::_ops; + let __opts: &mut v8::fast_api::FastApiCallbackOptions = unsafe { + &mut *fast_api_callback_options + }; + let __ctx = unsafe { + &*(v8::Local::<v8::External>::cast(unsafe { __opts.data.data }).value() + as *const _ops::OpCtx) + }; + let op_state = __ctx.state.clone(); + let result = Self::call(); + let result = _ops::queue_fast_async_op( + __ctx, + __promise_id, + async move { Ok(result.await) }, + ); + result + } } diff --git a/ops/optimizer_tests/async_result.out b/ops/optimizer_tests/async_result.out index 6f61a9697..91117e4a1 100644 --- a/ops/optimizer_tests/async_result.out +++ b/ops/optimizer_tests/async_result.out @@ -3,16 +3,39 @@ /// ///Use `op_async_result::decl()` to get an op-declaration ///you can include in a `deno_core::Extension`. -pub struct op_async_result; +pub struct op_async_result { + _phantom_data: ::std::marker::PhantomData<()>, +} +impl deno_core::_ops::Op for op_async_result { + const NAME: &'static str = stringify!(op_async_result); + const DECL: deno_core::OpDecl = deno_core::OpDecl { + name: Self::name(), + v8_fn_ptr: Self::v8_fn_ptr as _, + enabled: true, + fast_fn: { + use deno_core::v8::fast_api::CType; + use deno_core::v8::fast_api::Type::*; + Some( + deno_core::v8::fast_api::FastFunction::new( + &[V8Value, Int32, Uint32, CallbackOptions], + CType::Void, + Self::op_async_result_fast_fn as *const ::std::ffi::c_void, + ), + ) + }, + is_async: true, + is_unstable: false, + is_v8: false, + arg_count: 0, + }; +} #[doc(hidden)] impl op_async_result { pub const fn name() -> &'static str { stringify!(op_async_result) } #[allow(clippy::not_unsafe_ptr_arg_deref)] - pub extern "C" fn v8_fn_ptr<'scope>( - info: *const deno_core::v8::FunctionCallbackInfo, - ) { + pub extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { let info = unsafe { &*info }; let scope = &mut unsafe { deno_core::v8::CallbackScope::new(info) }; let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info( @@ -21,19 +44,19 @@ impl op_async_result { let rv = deno_core::v8::ReturnValue::from_function_callback_info(info); Self::v8_func(scope, args, rv); } - pub const fn decl<'scope>() -> deno_core::OpDecl { + pub const fn decl() -> deno_core::OpDecl { deno_core::OpDecl { name: Self::name(), v8_fn_ptr: Self::v8_fn_ptr as _, enabled: true, fast_fn: { - use deno_core::v8::fast_api::Type::*; use deno_core::v8::fast_api::CType; + use deno_core::v8::fast_api::Type::*; Some( deno_core::v8::fast_api::FastFunction::new( &[V8Value, Int32, Uint32, CallbackOptions], CType::Void, - op_async_result_fast_fn as *const ::std::ffi::c_void, + Self::op_async_result_fast_fn as *const ::std::ffi::c_void, ), ) }, @@ -45,7 +68,11 @@ impl op_async_result { } #[inline] #[allow(clippy::too_many_arguments)] - async fn call(state: Rc<RefCell<OpState>>, rid: ResourceId) -> Result<u32, Error> {} + #[allow(clippy::extra_unused_lifetimes)] + async fn call<'scope>( + state: Rc<RefCell<OpState>>, + rid: ResourceId, + ) -> Result<u32, Error> {} pub fn v8_func<'scope>( scope: &mut deno_core::v8::HandleScope<'scope>, args: deno_core::v8::FunctionCallbackArguments, @@ -99,23 +126,25 @@ impl op_async_result { } } } -#[allow(clippy::too_many_arguments)] -fn op_async_result_fast_fn<'scope>( - _: deno_core::v8::Local<deno_core::v8::Object>, - __promise_id: i32, - rid: ResourceId, - fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, -) -> () { - use deno_core::v8; - use deno_core::_ops; - let __opts: &mut v8::fast_api::FastApiCallbackOptions = unsafe { - &mut *fast_api_callback_options - }; - let __ctx = unsafe { - &*(v8::Local::<v8::External>::cast(unsafe { __opts.data.data }).value() - as *const _ops::OpCtx) - }; - let state = __ctx.state.clone(); - let result = op_async_result::call(state, rid); - let result = _ops::queue_fast_async_op(__ctx, __promise_id, result); +impl op_async_result { + #[allow(clippy::too_many_arguments)] + fn op_async_result_fast_fn( + _: deno_core::v8::Local<deno_core::v8::Object>, + __promise_id: i32, + rid: ResourceId, + fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, + ) -> () { + use deno_core::v8; + use deno_core::_ops; + let __opts: &mut v8::fast_api::FastApiCallbackOptions = unsafe { + &mut *fast_api_callback_options + }; + let __ctx = unsafe { + &*(v8::Local::<v8::External>::cast(unsafe { __opts.data.data }).value() + as *const _ops::OpCtx) + }; + let state = __ctx.state.clone(); + let result = Self::call(state, rid); + let result = _ops::queue_fast_async_op(__ctx, __promise_id, result); + } } diff --git a/ops/optimizer_tests/callback_options.out b/ops/optimizer_tests/callback_options.out index d46d46765..a868d6393 100644 --- a/ops/optimizer_tests/callback_options.out +++ b/ops/optimizer_tests/callback_options.out @@ -3,16 +3,39 @@ /// ///Use `op_fallback::decl()` to get an op-declaration ///you can include in a `deno_core::Extension`. -pub struct op_fallback; +pub struct op_fallback { + _phantom_data: ::std::marker::PhantomData<()>, +} +impl deno_core::_ops::Op for op_fallback { + const NAME: &'static str = stringify!(op_fallback); + const DECL: deno_core::OpDecl = deno_core::OpDecl { + name: Self::name(), + v8_fn_ptr: Self::v8_fn_ptr as _, + enabled: true, + fast_fn: { + use deno_core::v8::fast_api::CType; + use deno_core::v8::fast_api::Type::*; + Some( + deno_core::v8::fast_api::FastFunction::new( + &[V8Value, CallbackOptions], + CType::Void, + Self::op_fallback_fast_fn as *const ::std::ffi::c_void, + ), + ) + }, + is_async: false, + is_unstable: false, + is_v8: false, + arg_count: 0, + }; +} #[doc(hidden)] impl op_fallback { pub const fn name() -> &'static str { stringify!(op_fallback) } #[allow(clippy::not_unsafe_ptr_arg_deref)] - pub extern "C" fn v8_fn_ptr<'scope>( - info: *const deno_core::v8::FunctionCallbackInfo, - ) { + pub extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { let info = unsafe { &*info }; let scope = &mut unsafe { deno_core::v8::CallbackScope::new(info) }; let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info( @@ -21,19 +44,19 @@ impl op_fallback { let rv = deno_core::v8::ReturnValue::from_function_callback_info(info); Self::v8_func(scope, args, rv); } - pub const fn decl<'scope>() -> deno_core::OpDecl { + pub const fn decl() -> deno_core::OpDecl { deno_core::OpDecl { name: Self::name(), v8_fn_ptr: Self::v8_fn_ptr as _, enabled: true, fast_fn: { - use deno_core::v8::fast_api::Type::*; use deno_core::v8::fast_api::CType; + use deno_core::v8::fast_api::Type::*; Some( deno_core::v8::fast_api::FastFunction::new( &[V8Value, CallbackOptions], CType::Void, - op_fallback_fast_fn as *const ::std::ffi::c_void, + Self::op_fallback_fast_fn as *const ::std::ffi::c_void, ), ) }, @@ -45,7 +68,8 @@ impl op_fallback { } #[inline] #[allow(clippy::too_many_arguments)] - fn call(options: Option<&mut FastApiCallbackOptions>) { + #[allow(clippy::extra_unused_lifetimes)] + fn call<'scope>(options: Option<&mut FastApiCallbackOptions>) { if let Some(options) = options { options.fallback = true; } @@ -65,16 +89,18 @@ impl op_fallback { op_state.tracker.track_sync(ctx.id); } } -#[allow(clippy::too_many_arguments)] -fn op_fallback_fast_fn<'scope>( - _: deno_core::v8::Local<deno_core::v8::Object>, - fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, -) -> () { - use deno_core::v8; - use deno_core::_ops; - let __opts: &mut v8::fast_api::FastApiCallbackOptions = unsafe { - &mut *fast_api_callback_options - }; - let result = op_fallback::call(options); - result +impl op_fallback { + #[allow(clippy::too_many_arguments)] + fn op_fallback_fast_fn( + _: deno_core::v8::Local<deno_core::v8::Object>, + fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, + ) -> () { + use deno_core::v8; + use deno_core::_ops; + let __opts: &mut v8::fast_api::FastApiCallbackOptions = unsafe { + &mut *fast_api_callback_options + }; + let result = Self::call(options); + result + } } diff --git a/ops/optimizer_tests/cow_str.out b/ops/optimizer_tests/cow_str.out index d52df86ee..15c92f346 100644 --- a/ops/optimizer_tests/cow_str.out +++ b/ops/optimizer_tests/cow_str.out @@ -3,16 +3,39 @@ /// ///Use `op_cow_str::decl()` to get an op-declaration ///you can include in a `deno_core::Extension`. -pub struct op_cow_str; +pub struct op_cow_str { + _phantom_data: ::std::marker::PhantomData<()>, +} +impl deno_core::_ops::Op for op_cow_str { + const NAME: &'static str = stringify!(op_cow_str); + const DECL: deno_core::OpDecl = deno_core::OpDecl { + name: Self::name(), + v8_fn_ptr: Self::v8_fn_ptr as _, + enabled: true, + fast_fn: { + use deno_core::v8::fast_api::CType; + use deno_core::v8::fast_api::Type::*; + Some( + deno_core::v8::fast_api::FastFunction::new( + &[V8Value, SeqOneByteString, CallbackOptions], + CType::Void, + Self::op_cow_str_fast_fn as *const ::std::ffi::c_void, + ), + ) + }, + is_async: false, + is_unstable: false, + is_v8: false, + arg_count: 0, + }; +} #[doc(hidden)] impl op_cow_str { pub const fn name() -> &'static str { stringify!(op_cow_str) } #[allow(clippy::not_unsafe_ptr_arg_deref)] - pub extern "C" fn v8_fn_ptr<'scope>( - info: *const deno_core::v8::FunctionCallbackInfo, - ) { + pub extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { let info = unsafe { &*info }; let scope = &mut unsafe { deno_core::v8::CallbackScope::new(info) }; let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info( @@ -21,19 +44,19 @@ impl op_cow_str { let rv = deno_core::v8::ReturnValue::from_function_callback_info(info); Self::v8_func(scope, args, rv); } - pub const fn decl<'scope>() -> deno_core::OpDecl { + pub const fn decl() -> deno_core::OpDecl { deno_core::OpDecl { name: Self::name(), v8_fn_ptr: Self::v8_fn_ptr as _, enabled: true, fast_fn: { - use deno_core::v8::fast_api::Type::*; use deno_core::v8::fast_api::CType; + use deno_core::v8::fast_api::Type::*; Some( deno_core::v8::fast_api::FastFunction::new( &[V8Value, SeqOneByteString, CallbackOptions], CType::Void, - op_cow_str_fast_fn as *const ::std::ffi::c_void, + Self::op_cow_str_fast_fn as *const ::std::ffi::c_void, ), ) }, @@ -45,7 +68,8 @@ impl op_cow_str { } #[inline] #[allow(clippy::too_many_arguments)] - fn call(c: Cow<'_, str>) {} + #[allow(clippy::extra_unused_lifetimes)] + fn call<'scope>(c: Cow<'_, str>) {} pub fn v8_func<'scope>( scope: &mut deno_core::v8::HandleScope<'scope>, args: deno_core::v8::FunctionCallbackArguments, @@ -73,23 +97,25 @@ impl op_cow_str { op_state.tracker.track_sync(ctx.id); } } -#[allow(clippy::too_many_arguments)] -fn op_cow_str_fast_fn<'scope>( - _: deno_core::v8::Local<deno_core::v8::Object>, - c: *const deno_core::v8::fast_api::FastApiOneByteString, - fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, -) -> () { - use deno_core::v8; - use deno_core::_ops; - let c = ::std::borrow::Cow::Borrowed( - match ::std::str::from_utf8(unsafe { &*c }.as_bytes()) { - Ok(v) => v, - Err(_) => { - unsafe { &mut *fast_api_callback_options }.fallback = true; - return Default::default(); - } - }, - ); - let result = op_cow_str::call(c); - result +impl op_cow_str { + #[allow(clippy::too_many_arguments)] + fn op_cow_str_fast_fn( + _: deno_core::v8::Local<deno_core::v8::Object>, + c: *const deno_core::v8::fast_api::FastApiOneByteString, + fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, + ) -> () { + use deno_core::v8; + use deno_core::_ops; + let c = ::std::borrow::Cow::Borrowed( + match ::std::str::from_utf8(unsafe { &*c }.as_bytes()) { + Ok(v) => v, + Err(_) => { + unsafe { &mut *fast_api_callback_options }.fallback = true; + return Default::default(); + } + }, + ); + let result = Self::call(c); + result + } } diff --git a/ops/optimizer_tests/f64_slice.out b/ops/optimizer_tests/f64_slice.out index 403ec8fa3..183677731 100644 --- a/ops/optimizer_tests/f64_slice.out +++ b/ops/optimizer_tests/f64_slice.out @@ -3,16 +3,39 @@ /// ///Use `op_f64_buf::decl()` to get an op-declaration ///you can include in a `deno_core::Extension`. -pub struct op_f64_buf; +pub struct op_f64_buf { + _phantom_data: ::std::marker::PhantomData<()>, +} +impl deno_core::_ops::Op for op_f64_buf { + const NAME: &'static str = stringify!(op_f64_buf); + const DECL: deno_core::OpDecl = deno_core::OpDecl { + name: Self::name(), + v8_fn_ptr: Self::v8_fn_ptr as _, + enabled: true, + fast_fn: { + use deno_core::v8::fast_api::CType; + use deno_core::v8::fast_api::Type::*; + Some( + deno_core::v8::fast_api::FastFunction::new( + &[V8Value, TypedArray(CType::Float64), CallbackOptions], + CType::Void, + Self::op_f64_buf_fast_fn as *const ::std::ffi::c_void, + ), + ) + }, + is_async: false, + is_unstable: false, + is_v8: false, + arg_count: 0, + }; +} #[doc(hidden)] impl op_f64_buf { pub const fn name() -> &'static str { stringify!(op_f64_buf) } #[allow(clippy::not_unsafe_ptr_arg_deref)] - pub extern "C" fn v8_fn_ptr<'scope>( - info: *const deno_core::v8::FunctionCallbackInfo, - ) { + pub extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { let info = unsafe { &*info }; let scope = &mut unsafe { deno_core::v8::CallbackScope::new(info) }; let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info( @@ -21,19 +44,19 @@ impl op_f64_buf { let rv = deno_core::v8::ReturnValue::from_function_callback_info(info); Self::v8_func(scope, args, rv); } - pub const fn decl<'scope>() -> deno_core::OpDecl { + pub const fn decl() -> deno_core::OpDecl { deno_core::OpDecl { name: Self::name(), v8_fn_ptr: Self::v8_fn_ptr as _, enabled: true, fast_fn: { - use deno_core::v8::fast_api::Type::*; use deno_core::v8::fast_api::CType; + use deno_core::v8::fast_api::Type::*; Some( deno_core::v8::fast_api::FastFunction::new( &[V8Value, TypedArray(CType::Float64), CallbackOptions], CType::Void, - op_f64_buf_fast_fn as *const ::std::ffi::c_void, + Self::op_f64_buf_fast_fn as *const ::std::ffi::c_void, ), ) }, @@ -45,7 +68,8 @@ impl op_f64_buf { } #[inline] #[allow(clippy::too_many_arguments)] - fn call(buffer: &mut [f64]) {} + #[allow(clippy::extra_unused_lifetimes)] + fn call<'scope>(buffer: &mut [f64]) {} pub fn v8_func<'scope>( scope: &mut deno_core::v8::HandleScope<'scope>, args: deno_core::v8::FunctionCallbackArguments, @@ -91,21 +115,23 @@ impl op_f64_buf { op_state.tracker.track_sync(ctx.id); } } -#[allow(clippy::too_many_arguments)] -fn op_f64_buf_fast_fn<'scope>( - _: deno_core::v8::Local<deno_core::v8::Object>, - buffer: *const deno_core::v8::fast_api::FastApiTypedArray<f64>, - fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, -) -> () { - use deno_core::v8; - use deno_core::_ops; - let buffer = match unsafe { &*buffer }.get_storage_if_aligned() { - Some(v) => v, - None => { - unsafe { &mut *fast_api_callback_options }.fallback = true; - return Default::default(); - } - }; - let result = op_f64_buf::call(buffer); - result +impl op_f64_buf { + #[allow(clippy::too_many_arguments)] + fn op_f64_buf_fast_fn( + _: deno_core::v8::Local<deno_core::v8::Object>, + buffer: *const deno_core::v8::fast_api::FastApiTypedArray<f64>, + fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, + ) -> () { + use deno_core::v8; + use deno_core::_ops; + let buffer = match unsafe { &*buffer }.get_storage_if_aligned() { + Some(v) => v, + None => { + unsafe { &mut *fast_api_callback_options }.fallback = true; + return Default::default(); + } + }; + let result = Self::call(buffer); + result + } } diff --git a/ops/optimizer_tests/incompatible_1.out b/ops/optimizer_tests/incompatible_1.out index 0e8c98fd0..d51a1eda8 100644 --- a/ops/optimizer_tests/incompatible_1.out +++ b/ops/optimizer_tests/incompatible_1.out @@ -3,16 +3,29 @@ /// ///Use `op_sync_serialize_object_with_numbers_as_keys::decl()` to get an op-declaration ///you can include in a `deno_core::Extension`. -pub struct op_sync_serialize_object_with_numbers_as_keys; +pub struct op_sync_serialize_object_with_numbers_as_keys { + _phantom_data: ::std::marker::PhantomData<()>, +} +impl deno_core::_ops::Op for op_sync_serialize_object_with_numbers_as_keys { + const NAME: &'static str = stringify!(op_sync_serialize_object_with_numbers_as_keys); + const DECL: deno_core::OpDecl = deno_core::OpDecl { + name: Self::name(), + v8_fn_ptr: Self::v8_fn_ptr as _, + enabled: true, + fast_fn: None, + is_async: false, + is_unstable: false, + is_v8: false, + arg_count: 0, + }; +} #[doc(hidden)] impl op_sync_serialize_object_with_numbers_as_keys { pub const fn name() -> &'static str { stringify!(op_sync_serialize_object_with_numbers_as_keys) } #[allow(clippy::not_unsafe_ptr_arg_deref)] - pub extern "C" fn v8_fn_ptr<'scope>( - info: *const deno_core::v8::FunctionCallbackInfo, - ) { + pub extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { let info = unsafe { &*info }; let scope = &mut unsafe { deno_core::v8::CallbackScope::new(info) }; let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info( @@ -21,7 +34,7 @@ impl op_sync_serialize_object_with_numbers_as_keys { let rv = deno_core::v8::ReturnValue::from_function_callback_info(info); Self::v8_func(scope, args, rv); } - pub const fn decl<'scope>() -> deno_core::OpDecl { + pub const fn decl() -> deno_core::OpDecl { deno_core::OpDecl { name: Self::name(), v8_fn_ptr: Self::v8_fn_ptr as _, @@ -35,7 +48,8 @@ impl op_sync_serialize_object_with_numbers_as_keys { } #[inline] #[allow(clippy::too_many_arguments)] - fn call(value: serde_json::Value) -> Result<(), Error> { + #[allow(clippy::extra_unused_lifetimes)] + fn call<'scope>(value: serde_json::Value) -> Result<(), Error> { assert_eq!( value.to_string(), r#"{"lines":{"100":{"unit":"m"},"200":{"unit":"cm"}}}"# ); diff --git a/ops/optimizer_tests/issue16934.out b/ops/optimizer_tests/issue16934.out index 355add5e0..0f85b1157 100644 --- a/ops/optimizer_tests/issue16934.out +++ b/ops/optimizer_tests/issue16934.out @@ -3,16 +3,29 @@ /// ///Use `send_stdin::decl()` to get an op-declaration ///you can include in a `deno_core::Extension`. -pub struct send_stdin; +pub struct send_stdin { + _phantom_data: ::std::marker::PhantomData<()>, +} +impl deno_core::_ops::Op for send_stdin { + const NAME: &'static str = stringify!(send_stdin); + const DECL: deno_core::OpDecl = deno_core::OpDecl { + name: Self::name(), + v8_fn_ptr: Self::v8_fn_ptr as _, + enabled: true, + fast_fn: None, + is_async: true, + is_unstable: false, + is_v8: false, + arg_count: 0, + }; +} #[doc(hidden)] impl send_stdin { pub const fn name() -> &'static str { stringify!(send_stdin) } #[allow(clippy::not_unsafe_ptr_arg_deref)] - pub extern "C" fn v8_fn_ptr<'scope>( - info: *const deno_core::v8::FunctionCallbackInfo, - ) { + pub extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { let info = unsafe { &*info }; let scope = &mut unsafe { deno_core::v8::CallbackScope::new(info) }; let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info( @@ -21,7 +34,7 @@ impl send_stdin { let rv = deno_core::v8::ReturnValue::from_function_callback_info(info); Self::v8_func(scope, args, rv); } - pub const fn decl<'scope>() -> deno_core::OpDecl { + pub const fn decl() -> deno_core::OpDecl { deno_core::OpDecl { name: Self::name(), v8_fn_ptr: Self::v8_fn_ptr as _, @@ -35,7 +48,11 @@ impl send_stdin { } #[inline] #[allow(clippy::too_many_arguments)] - async fn call(state: &mut OpState, cmd: String) -> Result<(), anyhow::Error> { + #[allow(clippy::extra_unused_lifetimes)] + async fn call<'scope>( + state: &mut OpState, + cmd: String, + ) -> Result<(), anyhow::Error> { let instance = state.borrow::<MinecraftInstance>().clone(); instance.send_command(&cmd, CausedBy::Unknown).await?; Ok(()) diff --git a/ops/optimizer_tests/issue16934_fast.out b/ops/optimizer_tests/issue16934_fast.out index b6e80b574..2bbbc02bb 100644 --- a/ops/optimizer_tests/issue16934_fast.out +++ b/ops/optimizer_tests/issue16934_fast.out @@ -3,16 +3,29 @@ /// ///Use `send_stdin::decl()` to get an op-declaration ///you can include in a `deno_core::Extension`. -pub struct send_stdin; +pub struct send_stdin { + _phantom_data: ::std::marker::PhantomData<()>, +} +impl deno_core::_ops::Op for send_stdin { + const NAME: &'static str = stringify!(send_stdin); + const DECL: deno_core::OpDecl = deno_core::OpDecl { + name: Self::name(), + v8_fn_ptr: Self::v8_fn_ptr as _, + enabled: true, + fast_fn: None, + is_async: true, + is_unstable: false, + is_v8: false, + arg_count: 0, + }; +} #[doc(hidden)] impl send_stdin { pub const fn name() -> &'static str { stringify!(send_stdin) } #[allow(clippy::not_unsafe_ptr_arg_deref)] - pub extern "C" fn v8_fn_ptr<'scope>( - info: *const deno_core::v8::FunctionCallbackInfo, - ) { + pub extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { let info = unsafe { &*info }; let scope = &mut unsafe { deno_core::v8::CallbackScope::new(info) }; let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info( @@ -21,7 +34,7 @@ impl send_stdin { let rv = deno_core::v8::ReturnValue::from_function_callback_info(info); Self::v8_func(scope, args, rv); } - pub const fn decl<'scope>() -> deno_core::OpDecl { + pub const fn decl() -> deno_core::OpDecl { deno_core::OpDecl { name: Self::name(), v8_fn_ptr: Self::v8_fn_ptr as _, @@ -35,7 +48,8 @@ impl send_stdin { } #[inline] #[allow(clippy::too_many_arguments)] - async fn call(state: &mut OpState, v: i32) -> Result<(), anyhow::Error> { + #[allow(clippy::extra_unused_lifetimes)] + async fn call<'scope>(state: &mut OpState, v: i32) -> Result<(), anyhow::Error> { Ok(()) } pub fn v8_func<'scope>( diff --git a/ops/optimizer_tests/op_blob_revoke_object_url.out b/ops/optimizer_tests/op_blob_revoke_object_url.out index 3165430df..72af25cc9 100644 --- a/ops/optimizer_tests/op_blob_revoke_object_url.out +++ b/ops/optimizer_tests/op_blob_revoke_object_url.out @@ -3,16 +3,29 @@ /// ///Use `op_blob_revoke_object_url::decl()` to get an op-declaration ///you can include in a `deno_core::Extension`. -pub struct op_blob_revoke_object_url; +pub struct op_blob_revoke_object_url { + _phantom_data: ::std::marker::PhantomData<()>, +} +impl deno_core::_ops::Op for op_blob_revoke_object_url { + const NAME: &'static str = stringify!(op_blob_revoke_object_url); + const DECL: deno_core::OpDecl = deno_core::OpDecl { + name: Self::name(), + v8_fn_ptr: Self::v8_fn_ptr as _, + enabled: true, + fast_fn: None, + is_async: false, + is_unstable: false, + is_v8: false, + arg_count: 0, + }; +} #[doc(hidden)] impl op_blob_revoke_object_url { pub const fn name() -> &'static str { stringify!(op_blob_revoke_object_url) } #[allow(clippy::not_unsafe_ptr_arg_deref)] - pub extern "C" fn v8_fn_ptr<'scope>( - info: *const deno_core::v8::FunctionCallbackInfo, - ) { + pub extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { let info = unsafe { &*info }; let scope = &mut unsafe { deno_core::v8::CallbackScope::new(info) }; let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info( @@ -21,7 +34,7 @@ impl op_blob_revoke_object_url { let rv = deno_core::v8::ReturnValue::from_function_callback_info(info); Self::v8_func(scope, args, rv); } - pub const fn decl<'scope>() -> deno_core::OpDecl { + pub const fn decl() -> deno_core::OpDecl { deno_core::OpDecl { name: Self::name(), v8_fn_ptr: Self::v8_fn_ptr as _, @@ -35,7 +48,8 @@ impl op_blob_revoke_object_url { } #[inline] #[allow(clippy::too_many_arguments)] - pub fn call(state: &mut OpState, url: String) -> Result<(), AnyError> { + #[allow(clippy::extra_unused_lifetimes)] + pub fn call<'scope>(state: &mut OpState, url: String) -> Result<(), AnyError> { let url = Url::parse(&url)?; let blob_store = state.borrow::<BlobStore>(); blob_store.remove_object_url(&url); diff --git a/ops/optimizer_tests/op_ffi_ptr_value.out b/ops/optimizer_tests/op_ffi_ptr_value.out index 3e4b2571d..8fcce53c6 100644 --- a/ops/optimizer_tests/op_ffi_ptr_value.out +++ b/ops/optimizer_tests/op_ffi_ptr_value.out @@ -3,16 +3,39 @@ /// ///Use `op_ffi_ptr_value::decl()` to get an op-declaration ///you can include in a `deno_core::Extension`. -pub struct op_ffi_ptr_value; +pub struct op_ffi_ptr_value { + _phantom_data: ::std::marker::PhantomData<()>, +} +impl deno_core::_ops::Op for op_ffi_ptr_value { + const NAME: &'static str = stringify!(op_ffi_ptr_value); + const DECL: deno_core::OpDecl = deno_core::OpDecl { + name: Self::name(), + v8_fn_ptr: Self::v8_fn_ptr as _, + enabled: true, + fast_fn: { + use deno_core::v8::fast_api::CType; + use deno_core::v8::fast_api::Type::*; + Some( + deno_core::v8::fast_api::FastFunction::new( + &[V8Value, Pointer, TypedArray(CType::Uint32), CallbackOptions], + CType::Void, + Self::op_ffi_ptr_value_fast_fn as *const ::std::ffi::c_void, + ), + ) + }, + is_async: false, + is_unstable: false, + is_v8: false, + arg_count: 0, + }; +} #[doc(hidden)] impl op_ffi_ptr_value { pub const fn name() -> &'static str { stringify!(op_ffi_ptr_value) } #[allow(clippy::not_unsafe_ptr_arg_deref)] - pub extern "C" fn v8_fn_ptr<'scope>( - info: *const deno_core::v8::FunctionCallbackInfo, - ) { + pub extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { let info = unsafe { &*info }; let scope = &mut unsafe { deno_core::v8::CallbackScope::new(info) }; let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info( @@ -21,19 +44,19 @@ impl op_ffi_ptr_value { let rv = deno_core::v8::ReturnValue::from_function_callback_info(info); Self::v8_func(scope, args, rv); } - pub const fn decl<'scope>() -> deno_core::OpDecl { + pub const fn decl() -> deno_core::OpDecl { deno_core::OpDecl { name: Self::name(), v8_fn_ptr: Self::v8_fn_ptr as _, enabled: true, fast_fn: { - use deno_core::v8::fast_api::Type::*; use deno_core::v8::fast_api::CType; + use deno_core::v8::fast_api::Type::*; Some( deno_core::v8::fast_api::FastFunction::new( &[V8Value, Pointer, TypedArray(CType::Uint32), CallbackOptions], CType::Void, - op_ffi_ptr_value_fast_fn as *const ::std::ffi::c_void, + Self::op_ffi_ptr_value_fast_fn as *const ::std::ffi::c_void, ), ) }, @@ -45,7 +68,8 @@ impl op_ffi_ptr_value { } #[inline] #[allow(clippy::too_many_arguments)] - pub fn call(ptr: *mut c_void, out: &mut [u32]) {} + #[allow(clippy::extra_unused_lifetimes)] + pub fn call<'scope>(ptr: *mut c_void, out: &mut [u32]) {} pub fn v8_func<'scope>( scope: &mut deno_core::v8::HandleScope<'scope>, args: deno_core::v8::FunctionCallbackArguments, @@ -105,22 +129,24 @@ impl op_ffi_ptr_value { op_state.tracker.track_sync(ctx.id); } } -#[allow(clippy::too_many_arguments)] -fn op_ffi_ptr_value_fast_fn<'scope>( - _: deno_core::v8::Local<deno_core::v8::Object>, - ptr: *mut ::std::ffi::c_void, - out: *const deno_core::v8::fast_api::FastApiTypedArray<u32>, - fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, -) -> () { - use deno_core::v8; - use deno_core::_ops; - let out = match unsafe { &*out }.get_storage_if_aligned() { - Some(v) => v, - None => { - unsafe { &mut *fast_api_callback_options }.fallback = true; - return Default::default(); - } - }; - let result = op_ffi_ptr_value::call(ptr, out); - result +impl op_ffi_ptr_value { + #[allow(clippy::too_many_arguments)] + fn op_ffi_ptr_value_fast_fn( + _: deno_core::v8::Local<deno_core::v8::Object>, + ptr: *mut ::std::ffi::c_void, + out: *const deno_core::v8::fast_api::FastApiTypedArray<u32>, + fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, + ) -> () { + use deno_core::v8; + use deno_core::_ops; + let out = match unsafe { &*out }.get_storage_if_aligned() { + Some(v) => v, + None => { + unsafe { &mut *fast_api_callback_options }.fallback = true; + return Default::default(); + } + }; + let result = Self::call(ptr, out); + result + } } diff --git a/ops/optimizer_tests/op_print.out b/ops/optimizer_tests/op_print.out index d79cdfd62..5023a6b03 100644 --- a/ops/optimizer_tests/op_print.out +++ b/ops/optimizer_tests/op_print.out @@ -3,16 +3,29 @@ /// ///Use `op_print::decl()` to get an op-declaration ///you can include in a `deno_core::Extension`. -pub struct op_print; +pub struct op_print { + _phantom_data: ::std::marker::PhantomData<()>, +} +impl deno_core::_ops::Op for op_print { + const NAME: &'static str = stringify!(op_print); + const DECL: deno_core::OpDecl = deno_core::OpDecl { + name: Self::name(), + v8_fn_ptr: Self::v8_fn_ptr as _, + enabled: true, + fast_fn: None, + is_async: false, + is_unstable: false, + is_v8: false, + arg_count: 0, + }; +} #[doc(hidden)] impl op_print { pub const fn name() -> &'static str { stringify!(op_print) } #[allow(clippy::not_unsafe_ptr_arg_deref)] - pub extern "C" fn v8_fn_ptr<'scope>( - info: *const deno_core::v8::FunctionCallbackInfo, - ) { + pub extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { let info = unsafe { &*info }; let scope = &mut unsafe { deno_core::v8::CallbackScope::new(info) }; let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info( @@ -21,7 +34,7 @@ impl op_print { let rv = deno_core::v8::ReturnValue::from_function_callback_info(info); Self::v8_func(scope, args, rv); } - pub const fn decl<'scope>() -> deno_core::OpDecl { + pub const fn decl() -> deno_core::OpDecl { deno_core::OpDecl { name: Self::name(), v8_fn_ptr: Self::v8_fn_ptr as _, @@ -35,7 +48,12 @@ impl op_print { } #[inline] #[allow(clippy::too_many_arguments)] - fn call(state: &mut OpState, msg: &str, is_err: bool) -> Result<(), AnyError> {} + #[allow(clippy::extra_unused_lifetimes)] + fn call<'scope>( + state: &mut OpState, + msg: &str, + is_err: bool, + ) -> Result<(), AnyError> {} pub fn v8_func<'scope>( scope: &mut deno_core::v8::HandleScope<'scope>, args: deno_core::v8::FunctionCallbackArguments, diff --git a/ops/optimizer_tests/op_state.out b/ops/optimizer_tests/op_state.out index 1d83ae431..1b6d86b06 100644 --- a/ops/optimizer_tests/op_state.out +++ b/ops/optimizer_tests/op_state.out @@ -3,16 +3,39 @@ /// ///Use `op_set_exit_code::decl()` to get an op-declaration ///you can include in a `deno_core::Extension`. -pub struct op_set_exit_code; +pub struct op_set_exit_code { + _phantom_data: ::std::marker::PhantomData<()>, +} +impl deno_core::_ops::Op for op_set_exit_code { + const NAME: &'static str = stringify!(op_set_exit_code); + const DECL: deno_core::OpDecl = deno_core::OpDecl { + name: Self::name(), + v8_fn_ptr: Self::v8_fn_ptr as _, + enabled: true, + fast_fn: { + use deno_core::v8::fast_api::CType; + use deno_core::v8::fast_api::Type::*; + Some( + deno_core::v8::fast_api::FastFunction::new( + &[V8Value, Int32, CallbackOptions], + CType::Void, + Self::op_set_exit_code_fast_fn as *const ::std::ffi::c_void, + ), + ) + }, + is_async: false, + is_unstable: false, + is_v8: false, + arg_count: 0, + }; +} #[doc(hidden)] impl op_set_exit_code { pub const fn name() -> &'static str { stringify!(op_set_exit_code) } #[allow(clippy::not_unsafe_ptr_arg_deref)] - pub extern "C" fn v8_fn_ptr<'scope>( - info: *const deno_core::v8::FunctionCallbackInfo, - ) { + pub extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { let info = unsafe { &*info }; let scope = &mut unsafe { deno_core::v8::CallbackScope::new(info) }; let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info( @@ -21,19 +44,19 @@ impl op_set_exit_code { let rv = deno_core::v8::ReturnValue::from_function_callback_info(info); Self::v8_func(scope, args, rv); } - pub const fn decl<'scope>() -> deno_core::OpDecl { + pub const fn decl() -> deno_core::OpDecl { deno_core::OpDecl { name: Self::name(), v8_fn_ptr: Self::v8_fn_ptr as _, enabled: true, fast_fn: { - use deno_core::v8::fast_api::Type::*; use deno_core::v8::fast_api::CType; + use deno_core::v8::fast_api::Type::*; Some( deno_core::v8::fast_api::FastFunction::new( &[V8Value, Int32, CallbackOptions], CType::Void, - op_set_exit_code_fast_fn as *const ::std::ffi::c_void, + Self::op_set_exit_code_fast_fn as *const ::std::ffi::c_void, ), ) }, @@ -45,7 +68,8 @@ impl op_set_exit_code { } #[inline] #[allow(clippy::too_many_arguments)] - fn call(state: &mut OpState, code: i32) { + #[allow(clippy::extra_unused_lifetimes)] + fn call<'scope>(state: &mut OpState, code: i32) { state.borrow_mut::<ExitCode>().set(code); } pub fn v8_func<'scope>( @@ -73,22 +97,24 @@ impl op_set_exit_code { op_state.tracker.track_sync(ctx.id); } } -#[allow(clippy::too_many_arguments)] -fn op_set_exit_code_fast_fn<'scope>( - _: deno_core::v8::Local<deno_core::v8::Object>, - code: i32, - fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, -) -> () { - use deno_core::v8; - use deno_core::_ops; - let __opts: &mut v8::fast_api::FastApiCallbackOptions = unsafe { - &mut *fast_api_callback_options - }; - let __ctx = unsafe { - &*(v8::Local::<v8::External>::cast(unsafe { __opts.data.data }).value() - as *const _ops::OpCtx) - }; - let state = &mut ::std::cell::RefCell::borrow_mut(&__ctx.state); - let result = op_set_exit_code::call(state, code); - result +impl op_set_exit_code { + #[allow(clippy::too_many_arguments)] + fn op_set_exit_code_fast_fn( + _: deno_core::v8::Local<deno_core::v8::Object>, + code: i32, + fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, + ) -> () { + use deno_core::v8; + use deno_core::_ops; + let __opts: &mut v8::fast_api::FastApiCallbackOptions = unsafe { + &mut *fast_api_callback_options + }; + let __ctx = unsafe { + &*(v8::Local::<v8::External>::cast(unsafe { __opts.data.data }).value() + as *const _ops::OpCtx) + }; + let state = &mut ::std::cell::RefCell::borrow_mut(&__ctx.state); + let result = Self::call(state, code); + result + } } diff --git a/ops/optimizer_tests/op_state_basic1.out b/ops/optimizer_tests/op_state_basic1.out index c1ea447c5..284232a3a 100644 --- a/ops/optimizer_tests/op_state_basic1.out +++ b/ops/optimizer_tests/op_state_basic1.out @@ -3,16 +3,39 @@ /// ///Use `foo::decl()` to get an op-declaration ///you can include in a `deno_core::Extension`. -pub struct foo; +pub struct foo { + _phantom_data: ::std::marker::PhantomData<()>, +} +impl deno_core::_ops::Op for foo { + const NAME: &'static str = stringify!(foo); + const DECL: deno_core::OpDecl = deno_core::OpDecl { + name: Self::name(), + v8_fn_ptr: Self::v8_fn_ptr as _, + enabled: true, + fast_fn: { + use deno_core::v8::fast_api::CType; + use deno_core::v8::fast_api::Type::*; + Some( + deno_core::v8::fast_api::FastFunction::new( + &[V8Value, Uint32, Uint32, CallbackOptions], + CType::Uint32, + Self::foo_fast_fn as *const ::std::ffi::c_void, + ), + ) + }, + is_async: false, + is_unstable: false, + is_v8: false, + arg_count: 0, + }; +} #[doc(hidden)] impl foo { pub const fn name() -> &'static str { stringify!(foo) } #[allow(clippy::not_unsafe_ptr_arg_deref)] - pub extern "C" fn v8_fn_ptr<'scope>( - info: *const deno_core::v8::FunctionCallbackInfo, - ) { + pub extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { let info = unsafe { &*info }; let scope = &mut unsafe { deno_core::v8::CallbackScope::new(info) }; let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info( @@ -21,19 +44,19 @@ impl foo { let rv = deno_core::v8::ReturnValue::from_function_callback_info(info); Self::v8_func(scope, args, rv); } - pub const fn decl<'scope>() -> deno_core::OpDecl { + pub const fn decl() -> deno_core::OpDecl { deno_core::OpDecl { name: Self::name(), v8_fn_ptr: Self::v8_fn_ptr as _, enabled: true, fast_fn: { - use deno_core::v8::fast_api::Type::*; use deno_core::v8::fast_api::CType; + use deno_core::v8::fast_api::Type::*; Some( deno_core::v8::fast_api::FastFunction::new( &[V8Value, Uint32, Uint32, CallbackOptions], CType::Uint32, - foo_fast_fn as *const ::std::ffi::c_void, + Self::foo_fast_fn as *const ::std::ffi::c_void, ), ) }, @@ -45,7 +68,8 @@ impl foo { } #[inline] #[allow(clippy::too_many_arguments)] - fn call(state: &mut OpState, a: u32, b: u32) -> u32 { + #[allow(clippy::extra_unused_lifetimes)] + fn call<'scope>(state: &mut OpState, a: u32, b: u32) -> u32 { a + b } pub fn v8_func<'scope>( @@ -100,23 +124,25 @@ impl foo { }; } } -#[allow(clippy::too_many_arguments)] -fn foo_fast_fn<'scope>( - _: deno_core::v8::Local<deno_core::v8::Object>, - a: u32, - b: u32, - fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, -) -> u32 { - use deno_core::v8; - use deno_core::_ops; - let __opts: &mut v8::fast_api::FastApiCallbackOptions = unsafe { - &mut *fast_api_callback_options - }; - let __ctx = unsafe { - &*(v8::Local::<v8::External>::cast(unsafe { __opts.data.data }).value() - as *const _ops::OpCtx) - }; - let state = &mut ::std::cell::RefCell::borrow_mut(&__ctx.state); - let result = foo::call(state, a, b); - result +impl foo { + #[allow(clippy::too_many_arguments)] + fn foo_fast_fn( + _: deno_core::v8::Local<deno_core::v8::Object>, + a: u32, + b: u32, + fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, + ) -> u32 { + use deno_core::v8; + use deno_core::_ops; + let __opts: &mut v8::fast_api::FastApiCallbackOptions = unsafe { + &mut *fast_api_callback_options + }; + let __ctx = unsafe { + &*(v8::Local::<v8::External>::cast(unsafe { __opts.data.data }).value() + as *const _ops::OpCtx) + }; + let state = &mut ::std::cell::RefCell::borrow_mut(&__ctx.state); + let result = Self::call(state, a, b); + result + } } diff --git a/ops/optimizer_tests/op_state_generics.out b/ops/optimizer_tests/op_state_generics.out index 24596256a..a3e476d9e 100644 --- a/ops/optimizer_tests/op_state_generics.out +++ b/ops/optimizer_tests/op_state_generics.out @@ -3,43 +3,66 @@ /// ///Use `op_foo::decl()` to get an op-declaration ///you can include in a `deno_core::Extension`. -pub struct op_foo; +pub struct op_foo<SP> { + _phantom_data: ::std::marker::PhantomData<(SP)>, +} +impl<SP> deno_core::_ops::Op for op_foo<SP> +where + SP: SomePermission + 'static, +{ + const NAME: &'static str = stringify!(op_foo); + const DECL: deno_core::OpDecl = deno_core::OpDecl { + name: Self::name(), + v8_fn_ptr: Self::v8_fn_ptr as _, + enabled: true, + fast_fn: { + use deno_core::v8::fast_api::CType; + use deno_core::v8::fast_api::Type::*; + Some( + deno_core::v8::fast_api::FastFunction::new( + &[V8Value, CallbackOptions], + CType::Void, + Self::op_foo_fast_fn as *const ::std::ffi::c_void, + ), + ) + }, + is_async: false, + is_unstable: false, + is_v8: false, + arg_count: 0, + }; +} #[doc(hidden)] -impl op_foo { +impl<SP> op_foo<SP> +where + SP: SomePermission + 'static, +{ pub const fn name() -> &'static str { stringify!(op_foo) } #[allow(clippy::not_unsafe_ptr_arg_deref)] - pub extern "C" fn v8_fn_ptr<'scope, SP>( - info: *const deno_core::v8::FunctionCallbackInfo, - ) - where - SP: SomePermission + 'static, - { + pub extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { let info = unsafe { &*info }; let scope = &mut unsafe { deno_core::v8::CallbackScope::new(info) }; let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info( info, ); let rv = deno_core::v8::ReturnValue::from_function_callback_info(info); - Self::v8_func::<SP>(scope, args, rv); + Self::v8_func(scope, args, rv); } - pub const fn decl<'scope, SP>() -> deno_core::OpDecl - where - SP: SomePermission + 'static, - { + pub const fn decl() -> deno_core::OpDecl { deno_core::OpDecl { name: Self::name(), - v8_fn_ptr: Self::v8_fn_ptr::<SP> as _, + v8_fn_ptr: Self::v8_fn_ptr as _, enabled: true, fast_fn: { - use deno_core::v8::fast_api::Type::*; use deno_core::v8::fast_api::CType; + use deno_core::v8::fast_api::Type::*; Some( deno_core::v8::fast_api::FastFunction::new( &[V8Value, CallbackOptions], CType::Void, - op_foo_fast_fn::<SP> as *const ::std::ffi::c_void, + Self::op_foo_fast_fn as *const ::std::ffi::c_void, ), ) }, @@ -51,45 +74,42 @@ impl op_foo { } #[inline] #[allow(clippy::too_many_arguments)] - pub fn call<SP>(state: &mut OpState) - where - SP: SomePermission + 'static, - {} - pub fn v8_func<'scope, SP>( + #[allow(clippy::extra_unused_lifetimes)] + pub fn call<'scope>(state: &mut OpState) {} + pub fn v8_func<'scope>( scope: &mut deno_core::v8::HandleScope<'scope>, args: deno_core::v8::FunctionCallbackArguments, mut rv: deno_core::v8::ReturnValue, - ) - where - SP: SomePermission + 'static, - { + ) { let ctx = unsafe { &*(deno_core::v8::Local::<deno_core::v8::External>::cast(args.data()).value() as *const deno_core::_ops::OpCtx) }; - let result = Self::call::<SP>(&mut std::cell::RefCell::borrow_mut(&ctx.state)); + let result = Self::call(&mut std::cell::RefCell::borrow_mut(&ctx.state)); let op_state = ::std::cell::RefCell::borrow(&*ctx.state); op_state.tracker.track_sync(ctx.id); } } -#[allow(clippy::too_many_arguments)] -fn op_foo_fast_fn<'scope, SP>( - _: deno_core::v8::Local<deno_core::v8::Object>, - fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, -) -> () +impl<SP> op_foo<SP> where SP: SomePermission + 'static, { - use deno_core::v8; - use deno_core::_ops; - let __opts: &mut v8::fast_api::FastApiCallbackOptions = unsafe { - &mut *fast_api_callback_options - }; - let __ctx = unsafe { - &*(v8::Local::<v8::External>::cast(unsafe { __opts.data.data }).value() - as *const _ops::OpCtx) - }; - let state = &mut ::std::cell::RefCell::borrow_mut(&__ctx.state); - let result = op_foo::call::<SP>(state); - result + #[allow(clippy::too_many_arguments)] + fn op_foo_fast_fn( + _: deno_core::v8::Local<deno_core::v8::Object>, + fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, + ) -> () { + use deno_core::v8; + use deno_core::_ops; + let __opts: &mut v8::fast_api::FastApiCallbackOptions = unsafe { + &mut *fast_api_callback_options + }; + let __ctx = unsafe { + &*(v8::Local::<v8::External>::cast(unsafe { __opts.data.data }).value() + as *const _ops::OpCtx) + }; + let state = &mut ::std::cell::RefCell::borrow_mut(&__ctx.state); + let result = Self::call(state); + result + } } diff --git a/ops/optimizer_tests/op_state_result.out b/ops/optimizer_tests/op_state_result.out index 4c58de8d6..67793d93a 100644 --- a/ops/optimizer_tests/op_state_result.out +++ b/ops/optimizer_tests/op_state_result.out @@ -3,16 +3,39 @@ /// ///Use `foo::decl()` to get an op-declaration ///you can include in a `deno_core::Extension`. -pub struct foo; +pub struct foo { + _phantom_data: ::std::marker::PhantomData<()>, +} +impl deno_core::_ops::Op for foo { + const NAME: &'static str = stringify!(foo); + const DECL: deno_core::OpDecl = deno_core::OpDecl { + name: Self::name(), + v8_fn_ptr: Self::v8_fn_ptr as _, + enabled: true, + fast_fn: { + use deno_core::v8::fast_api::CType; + use deno_core::v8::fast_api::Type::*; + Some( + deno_core::v8::fast_api::FastFunction::new( + &[V8Value, Uint32, Uint32, CallbackOptions], + CType::Uint32, + Self::foo_fast_fn as *const ::std::ffi::c_void, + ), + ) + }, + is_async: false, + is_unstable: false, + is_v8: false, + arg_count: 0, + }; +} #[doc(hidden)] impl foo { pub const fn name() -> &'static str { stringify!(foo) } #[allow(clippy::not_unsafe_ptr_arg_deref)] - pub extern "C" fn v8_fn_ptr<'scope>( - info: *const deno_core::v8::FunctionCallbackInfo, - ) { + pub extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { let info = unsafe { &*info }; let scope = &mut unsafe { deno_core::v8::CallbackScope::new(info) }; let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info( @@ -21,19 +44,19 @@ impl foo { let rv = deno_core::v8::ReturnValue::from_function_callback_info(info); Self::v8_func(scope, args, rv); } - pub const fn decl<'scope>() -> deno_core::OpDecl { + pub const fn decl() -> deno_core::OpDecl { deno_core::OpDecl { name: Self::name(), v8_fn_ptr: Self::v8_fn_ptr as _, enabled: true, fast_fn: { - use deno_core::v8::fast_api::Type::*; use deno_core::v8::fast_api::CType; + use deno_core::v8::fast_api::Type::*; Some( deno_core::v8::fast_api::FastFunction::new( &[V8Value, Uint32, Uint32, CallbackOptions], CType::Uint32, - foo_fast_fn as *const ::std::ffi::c_void, + Self::foo_fast_fn as *const ::std::ffi::c_void, ), ) }, @@ -45,7 +68,8 @@ impl foo { } #[inline] #[allow(clippy::too_many_arguments)] - fn call(state: &mut OpState, a: u32, b: u32) -> Result<u32, AnyError> { + #[allow(clippy::extra_unused_lifetimes)] + fn call<'scope>(state: &mut OpState, a: u32, b: u32) -> Result<u32, AnyError> { Ok(a + b) } pub fn v8_func<'scope>( @@ -113,30 +137,32 @@ impl foo { }; } } -#[allow(clippy::too_many_arguments)] -fn foo_fast_fn<'scope>( - _: deno_core::v8::Local<deno_core::v8::Object>, - a: u32, - b: u32, - fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, -) -> u32 { - use deno_core::v8; - use deno_core::_ops; - let __opts: &mut v8::fast_api::FastApiCallbackOptions = unsafe { - &mut *fast_api_callback_options - }; - let __ctx = unsafe { - &*(v8::Local::<v8::External>::cast(unsafe { __opts.data.data }).value() - as *const _ops::OpCtx) - }; - let state = &mut ::std::cell::RefCell::borrow_mut(&__ctx.state); - let result = foo::call(state, a, b); - match result { - Ok(result) => result, - Err(err) => { - state.last_fast_op_error.replace(err); - __opts.fallback = true; - Default::default() +impl foo { + #[allow(clippy::too_many_arguments)] + fn foo_fast_fn( + _: deno_core::v8::Local<deno_core::v8::Object>, + a: u32, + b: u32, + fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, + ) -> u32 { + use deno_core::v8; + use deno_core::_ops; + let __opts: &mut v8::fast_api::FastApiCallbackOptions = unsafe { + &mut *fast_api_callback_options + }; + let __ctx = unsafe { + &*(v8::Local::<v8::External>::cast(unsafe { __opts.data.data }).value() + as *const _ops::OpCtx) + }; + let state = &mut ::std::cell::RefCell::borrow_mut(&__ctx.state); + let result = Self::call(state, a, b); + match result { + Ok(result) => result, + Err(err) => { + state.last_fast_op_error.replace(err); + __opts.fallback = true; + Default::default() + } } } } diff --git a/ops/optimizer_tests/op_state_warning.out b/ops/optimizer_tests/op_state_warning.out index 97d76aa97..51947f90a 100644 --- a/ops/optimizer_tests/op_state_warning.out +++ b/ops/optimizer_tests/op_state_warning.out @@ -3,16 +3,39 @@ /// ///Use `op_listen::decl()` to get an op-declaration ///you can include in a `deno_core::Extension`. -pub struct op_listen; +pub struct op_listen { + _phantom_data: ::std::marker::PhantomData<()>, +} +impl deno_core::_ops::Op for op_listen { + const NAME: &'static str = stringify!(op_listen); + const DECL: deno_core::OpDecl = deno_core::OpDecl { + name: Self::name(), + v8_fn_ptr: Self::v8_fn_ptr as _, + enabled: true, + fast_fn: { + use deno_core::v8::fast_api::CType; + use deno_core::v8::fast_api::Type::*; + Some( + deno_core::v8::fast_api::FastFunction::new( + &[V8Value, CallbackOptions], + CType::Uint32, + Self::op_listen_fast_fn as *const ::std::ffi::c_void, + ), + ) + }, + is_async: false, + is_unstable: false, + is_v8: false, + arg_count: 0, + }; +} #[doc(hidden)] impl op_listen { pub const fn name() -> &'static str { stringify!(op_listen) } #[allow(clippy::not_unsafe_ptr_arg_deref)] - pub extern "C" fn v8_fn_ptr<'scope>( - info: *const deno_core::v8::FunctionCallbackInfo, - ) { + pub extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { let info = unsafe { &*info }; let scope = &mut unsafe { deno_core::v8::CallbackScope::new(info) }; let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info( @@ -21,19 +44,19 @@ impl op_listen { let rv = deno_core::v8::ReturnValue::from_function_callback_info(info); Self::v8_func(scope, args, rv); } - pub const fn decl<'scope>() -> deno_core::OpDecl { + pub const fn decl() -> deno_core::OpDecl { deno_core::OpDecl { name: Self::name(), v8_fn_ptr: Self::v8_fn_ptr as _, enabled: true, fast_fn: { - use deno_core::v8::fast_api::Type::*; use deno_core::v8::fast_api::CType; + use deno_core::v8::fast_api::Type::*; Some( deno_core::v8::fast_api::FastFunction::new( &[V8Value, CallbackOptions], CType::Uint32, - op_listen_fast_fn as *const ::std::ffi::c_void, + Self::op_listen_fast_fn as *const ::std::ffi::c_void, ), ) }, @@ -45,7 +68,8 @@ impl op_listen { } #[inline] #[allow(clippy::too_many_arguments)] - fn call(state: &mut OpState) -> Result<ResourceId, Error> { + #[allow(clippy::extra_unused_lifetimes)] + fn call<'scope>(state: &mut OpState) -> Result<ResourceId, Error> { log::debug!("listen"); let addr = "127.0.0.1:4570".parse::<SocketAddr>().unwrap(); let std_listener = std::net::TcpListener::bind(&addr)?; @@ -104,28 +128,30 @@ impl op_listen { }; } } -#[allow(clippy::too_many_arguments)] -fn op_listen_fast_fn<'scope>( - _: deno_core::v8::Local<deno_core::v8::Object>, - fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, -) -> u32 { - use deno_core::v8; - use deno_core::_ops; - let __opts: &mut v8::fast_api::FastApiCallbackOptions = unsafe { - &mut *fast_api_callback_options - }; - let __ctx = unsafe { - &*(v8::Local::<v8::External>::cast(unsafe { __opts.data.data }).value() - as *const _ops::OpCtx) - }; - let state = &mut ::std::cell::RefCell::borrow_mut(&__ctx.state); - let result = op_listen::call(state); - match result { - Ok(result) => result, - Err(err) => { - state.last_fast_op_error.replace(err); - __opts.fallback = true; - Default::default() +impl op_listen { + #[allow(clippy::too_many_arguments)] + fn op_listen_fast_fn( + _: deno_core::v8::Local<deno_core::v8::Object>, + fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, + ) -> u32 { + use deno_core::v8; + use deno_core::_ops; + let __opts: &mut v8::fast_api::FastApiCallbackOptions = unsafe { + &mut *fast_api_callback_options + }; + let __ctx = unsafe { + &*(v8::Local::<v8::External>::cast(unsafe { __opts.data.data }).value() + as *const _ops::OpCtx) + }; + let state = &mut ::std::cell::RefCell::borrow_mut(&__ctx.state); + let result = Self::call(state); + match result { + Ok(result) => result, + Err(err) => { + state.last_fast_op_error.replace(err); + __opts.fallback = true; + Default::default() + } } } } diff --git a/ops/optimizer_tests/op_state_with_transforms.out b/ops/optimizer_tests/op_state_with_transforms.out index 3bbb7289f..09303e269 100644 --- a/ops/optimizer_tests/op_state_with_transforms.out +++ b/ops/optimizer_tests/op_state_with_transforms.out @@ -3,43 +3,66 @@ /// ///Use `op_now::decl()` to get an op-declaration ///you can include in a `deno_core::Extension`. -pub struct op_now; +pub struct op_now<TP> { + _phantom_data: ::std::marker::PhantomData<(TP)>, +} +impl<TP> deno_core::_ops::Op for op_now<TP> +where + TP: TimersPermission + 'static, +{ + const NAME: &'static str = stringify!(op_now); + const DECL: deno_core::OpDecl = deno_core::OpDecl { + name: Self::name(), + v8_fn_ptr: Self::v8_fn_ptr as _, + enabled: true, + fast_fn: { + use deno_core::v8::fast_api::CType; + use deno_core::v8::fast_api::Type::*; + Some( + deno_core::v8::fast_api::FastFunction::new( + &[V8Value, TypedArray(CType::Uint8), CallbackOptions], + CType::Void, + Self::op_now_fast_fn as *const ::std::ffi::c_void, + ), + ) + }, + is_async: false, + is_unstable: false, + is_v8: false, + arg_count: 0, + }; +} #[doc(hidden)] -impl op_now { +impl<TP> op_now<TP> +where + TP: TimersPermission + 'static, +{ pub const fn name() -> &'static str { stringify!(op_now) } #[allow(clippy::not_unsafe_ptr_arg_deref)] - pub extern "C" fn v8_fn_ptr<'scope, TP>( - info: *const deno_core::v8::FunctionCallbackInfo, - ) - where - TP: TimersPermission + 'static, - { + pub extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { let info = unsafe { &*info }; let scope = &mut unsafe { deno_core::v8::CallbackScope::new(info) }; let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info( info, ); let rv = deno_core::v8::ReturnValue::from_function_callback_info(info); - Self::v8_func::<TP>(scope, args, rv); + Self::v8_func(scope, args, rv); } - pub const fn decl<'scope, TP>() -> deno_core::OpDecl - where - TP: TimersPermission + 'static, - { + pub const fn decl() -> deno_core::OpDecl { deno_core::OpDecl { name: Self::name(), - v8_fn_ptr: Self::v8_fn_ptr::<TP> as _, + v8_fn_ptr: Self::v8_fn_ptr as _, enabled: true, fast_fn: { - use deno_core::v8::fast_api::Type::*; use deno_core::v8::fast_api::CType; + use deno_core::v8::fast_api::Type::*; Some( deno_core::v8::fast_api::FastFunction::new( &[V8Value, TypedArray(CType::Uint8), CallbackOptions], CType::Void, - op_now_fast_fn::<TP> as *const ::std::ffi::c_void, + Self::op_now_fast_fn as *const ::std::ffi::c_void, ), ) }, @@ -51,18 +74,13 @@ impl op_now { } #[inline] #[allow(clippy::too_many_arguments)] - pub fn call<TP>(state: &mut OpState, buf: &mut [u8]) - where - TP: TimersPermission + 'static, - {} - pub fn v8_func<'scope, TP>( + #[allow(clippy::extra_unused_lifetimes)] + pub fn call<'scope>(state: &mut OpState, buf: &mut [u8]) {} + pub fn v8_func<'scope>( scope: &mut deno_core::v8::HandleScope<'scope>, args: deno_core::v8::FunctionCallbackArguments, mut rv: deno_core::v8::ReturnValue, - ) - where - TP: TimersPermission + 'static, - { + ) { let ctx = unsafe { &*(deno_core::v8::Local::<deno_core::v8::External>::cast(args.data()).value() as *const deno_core::_ops::OpCtx) @@ -112,33 +130,33 @@ impl op_now { } } }; - let result = Self::call::< - TP, - >(&mut std::cell::RefCell::borrow_mut(&ctx.state), arg_0); + let result = Self::call(&mut std::cell::RefCell::borrow_mut(&ctx.state), arg_0); let op_state = ::std::cell::RefCell::borrow(&*ctx.state); op_state.tracker.track_sync(ctx.id); } } -#[allow(clippy::too_many_arguments)] -fn op_now_fast_fn<'scope, TP>( - _: deno_core::v8::Local<deno_core::v8::Object>, - buf: *const deno_core::v8::fast_api::FastApiTypedArray<u8>, - fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, -) -> () +impl<TP> op_now<TP> where TP: TimersPermission + 'static, { - use deno_core::v8; - use deno_core::_ops; - let __opts: &mut v8::fast_api::FastApiCallbackOptions = unsafe { - &mut *fast_api_callback_options - }; - let __ctx = unsafe { - &*(v8::Local::<v8::External>::cast(unsafe { __opts.data.data }).value() - as *const _ops::OpCtx) - }; - let state = &mut ::std::cell::RefCell::borrow_mut(&__ctx.state); - let buf = unsafe { (&*buf).get_storage_if_aligned().unwrap_unchecked() }; - let result = op_now::call::<TP>(state, buf); - result + #[allow(clippy::too_many_arguments)] + fn op_now_fast_fn( + _: deno_core::v8::Local<deno_core::v8::Object>, + buf: *const deno_core::v8::fast_api::FastApiTypedArray<u8>, + fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, + ) -> () { + use deno_core::v8; + use deno_core::_ops; + let __opts: &mut v8::fast_api::FastApiCallbackOptions = unsafe { + &mut *fast_api_callback_options + }; + let __ctx = unsafe { + &*(v8::Local::<v8::External>::cast(unsafe { __opts.data.data }).value() + as *const _ops::OpCtx) + }; + let state = &mut ::std::cell::RefCell::borrow_mut(&__ctx.state); + let buf = unsafe { (&*buf).get_storage_if_aligned().unwrap_unchecked() }; + let result = Self::call(state, buf); + result + } } diff --git a/ops/optimizer_tests/opstate_with_arity.out b/ops/optimizer_tests/opstate_with_arity.out index 88651ce76..d7e85328a 100644 --- a/ops/optimizer_tests/opstate_with_arity.out +++ b/ops/optimizer_tests/opstate_with_arity.out @@ -3,16 +3,39 @@ /// ///Use `op_add_4::decl()` to get an op-declaration ///you can include in a `deno_core::Extension`. -pub struct op_add_4; +pub struct op_add_4 { + _phantom_data: ::std::marker::PhantomData<()>, +} +impl deno_core::_ops::Op for op_add_4 { + const NAME: &'static str = stringify!(op_add_4); + const DECL: deno_core::OpDecl = deno_core::OpDecl { + name: Self::name(), + v8_fn_ptr: Self::v8_fn_ptr as _, + enabled: true, + fast_fn: { + use deno_core::v8::fast_api::CType; + use deno_core::v8::fast_api::Type::*; + Some( + deno_core::v8::fast_api::FastFunction::new( + &[V8Value, Uint32, Uint32, Uint32, Uint32, CallbackOptions], + CType::Uint32, + Self::op_add_4_fast_fn as *const ::std::ffi::c_void, + ), + ) + }, + is_async: false, + is_unstable: false, + is_v8: false, + arg_count: 0, + }; +} #[doc(hidden)] impl op_add_4 { pub const fn name() -> &'static str { stringify!(op_add_4) } #[allow(clippy::not_unsafe_ptr_arg_deref)] - pub extern "C" fn v8_fn_ptr<'scope>( - info: *const deno_core::v8::FunctionCallbackInfo, - ) { + pub extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { let info = unsafe { &*info }; let scope = &mut unsafe { deno_core::v8::CallbackScope::new(info) }; let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info( @@ -21,19 +44,19 @@ impl op_add_4 { let rv = deno_core::v8::ReturnValue::from_function_callback_info(info); Self::v8_func(scope, args, rv); } - pub const fn decl<'scope>() -> deno_core::OpDecl { + pub const fn decl() -> deno_core::OpDecl { deno_core::OpDecl { name: Self::name(), v8_fn_ptr: Self::v8_fn_ptr as _, enabled: true, fast_fn: { - use deno_core::v8::fast_api::Type::*; use deno_core::v8::fast_api::CType; + use deno_core::v8::fast_api::Type::*; Some( deno_core::v8::fast_api::FastFunction::new( &[V8Value, Uint32, Uint32, Uint32, Uint32, CallbackOptions], CType::Uint32, - op_add_4_fast_fn as *const ::std::ffi::c_void, + Self::op_add_4_fast_fn as *const ::std::ffi::c_void, ), ) }, @@ -45,7 +68,8 @@ impl op_add_4 { } #[inline] #[allow(clippy::too_many_arguments)] - fn call(x1: u32, x2: u32, x3: u32, x4: u32) -> Result<u32, anyhow::Error> { + #[allow(clippy::extra_unused_lifetimes)] + fn call<'scope>(x1: u32, x2: u32, x3: u32, x4: u32) -> Result<u32, anyhow::Error> { Ok(x1 + x2 + x3 + x4) } pub fn v8_func<'scope>( @@ -131,32 +155,34 @@ impl op_add_4 { }; } } -#[allow(clippy::too_many_arguments)] -fn op_add_4_fast_fn<'scope>( - _: deno_core::v8::Local<deno_core::v8::Object>, - x1: u32, - x2: u32, - x3: u32, - x4: u32, - fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, -) -> u32 { - use deno_core::v8; - use deno_core::_ops; - let __opts: &mut v8::fast_api::FastApiCallbackOptions = unsafe { - &mut *fast_api_callback_options - }; - let __ctx = unsafe { - &*(v8::Local::<v8::External>::cast(unsafe { __opts.data.data }).value() - as *const _ops::OpCtx) - }; - let op_state = &mut ::std::cell::RefCell::borrow_mut(&__ctx.state); - let result = op_add_4::call(x1, x2, x3, x4); - match result { - Ok(result) => result, - Err(err) => { - op_state.last_fast_op_error.replace(err); - __opts.fallback = true; - Default::default() +impl op_add_4 { + #[allow(clippy::too_many_arguments)] + fn op_add_4_fast_fn( + _: deno_core::v8::Local<deno_core::v8::Object>, + x1: u32, + x2: u32, + x3: u32, + x4: u32, + fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, + ) -> u32 { + use deno_core::v8; + use deno_core::_ops; + let __opts: &mut v8::fast_api::FastApiCallbackOptions = unsafe { + &mut *fast_api_callback_options + }; + let __ctx = unsafe { + &*(v8::Local::<v8::External>::cast(unsafe { __opts.data.data }).value() + as *const _ops::OpCtx) + }; + let op_state = &mut ::std::cell::RefCell::borrow_mut(&__ctx.state); + let result = Self::call(x1, x2, x3, x4); + match result { + Ok(result) => result, + Err(err) => { + op_state.last_fast_op_error.replace(err); + __opts.fallback = true; + Default::default() + } } } } diff --git a/ops/optimizer_tests/option_arg.out b/ops/optimizer_tests/option_arg.out index f00937a74..5880ec88e 100644 --- a/ops/optimizer_tests/option_arg.out +++ b/ops/optimizer_tests/option_arg.out @@ -3,16 +3,29 @@ /// ///Use `op_try_close::decl()` to get an op-declaration ///you can include in a `deno_core::Extension`. -pub struct op_try_close; +pub struct op_try_close { + _phantom_data: ::std::marker::PhantomData<()>, +} +impl deno_core::_ops::Op for op_try_close { + const NAME: &'static str = stringify!(op_try_close); + const DECL: deno_core::OpDecl = deno_core::OpDecl { + name: Self::name(), + v8_fn_ptr: Self::v8_fn_ptr as _, + enabled: true, + fast_fn: None, + is_async: false, + is_unstable: false, + is_v8: false, + arg_count: 0, + }; +} #[doc(hidden)] impl op_try_close { pub const fn name() -> &'static str { stringify!(op_try_close) } #[allow(clippy::not_unsafe_ptr_arg_deref)] - pub extern "C" fn v8_fn_ptr<'scope>( - info: *const deno_core::v8::FunctionCallbackInfo, - ) { + pub extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { let info = unsafe { &*info }; let scope = &mut unsafe { deno_core::v8::CallbackScope::new(info) }; let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info( @@ -21,7 +34,7 @@ impl op_try_close { let rv = deno_core::v8::ReturnValue::from_function_callback_info(info); Self::v8_func(scope, args, rv); } - pub const fn decl<'scope>() -> deno_core::OpDecl { + pub const fn decl() -> deno_core::OpDecl { deno_core::OpDecl { name: Self::name(), v8_fn_ptr: Self::v8_fn_ptr as _, @@ -35,7 +48,11 @@ impl op_try_close { } #[inline] #[allow(clippy::too_many_arguments)] - pub fn call(state: &mut OpState, rid: Option<ResourceId>) -> Result<(), Error> {} + #[allow(clippy::extra_unused_lifetimes)] + pub fn call<'scope>( + state: &mut OpState, + rid: Option<ResourceId>, + ) -> Result<(), Error> {} pub fn v8_func<'scope>( scope: &mut deno_core::v8::HandleScope<'scope>, args: deno_core::v8::FunctionCallbackArguments, diff --git a/ops/optimizer_tests/owned_string.out b/ops/optimizer_tests/owned_string.out index d186e5108..58c7f72ae 100644 --- a/ops/optimizer_tests/owned_string.out +++ b/ops/optimizer_tests/owned_string.out @@ -3,16 +3,39 @@ /// ///Use `op_string_length::decl()` to get an op-declaration ///you can include in a `deno_core::Extension`. -pub struct op_string_length; +pub struct op_string_length { + _phantom_data: ::std::marker::PhantomData<()>, +} +impl deno_core::_ops::Op for op_string_length { + const NAME: &'static str = stringify!(op_string_length); + const DECL: deno_core::OpDecl = deno_core::OpDecl { + name: Self::name(), + v8_fn_ptr: Self::v8_fn_ptr as _, + enabled: true, + fast_fn: { + use deno_core::v8::fast_api::CType; + use deno_core::v8::fast_api::Type::*; + Some( + deno_core::v8::fast_api::FastFunction::new( + &[V8Value, SeqOneByteString, CallbackOptions], + CType::Uint32, + Self::op_string_length_fast_fn as *const ::std::ffi::c_void, + ), + ) + }, + is_async: false, + is_unstable: false, + is_v8: false, + arg_count: 0, + }; +} #[doc(hidden)] impl op_string_length { pub const fn name() -> &'static str { stringify!(op_string_length) } #[allow(clippy::not_unsafe_ptr_arg_deref)] - pub extern "C" fn v8_fn_ptr<'scope>( - info: *const deno_core::v8::FunctionCallbackInfo, - ) { + pub extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { let info = unsafe { &*info }; let scope = &mut unsafe { deno_core::v8::CallbackScope::new(info) }; let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info( @@ -21,19 +44,19 @@ impl op_string_length { let rv = deno_core::v8::ReturnValue::from_function_callback_info(info); Self::v8_func(scope, args, rv); } - pub const fn decl<'scope>() -> deno_core::OpDecl { + pub const fn decl() -> deno_core::OpDecl { deno_core::OpDecl { name: Self::name(), v8_fn_ptr: Self::v8_fn_ptr as _, enabled: true, fast_fn: { - use deno_core::v8::fast_api::Type::*; use deno_core::v8::fast_api::CType; + use deno_core::v8::fast_api::Type::*; Some( deno_core::v8::fast_api::FastFunction::new( &[V8Value, SeqOneByteString, CallbackOptions], CType::Uint32, - op_string_length_fast_fn as *const ::std::ffi::c_void, + Self::op_string_length_fast_fn as *const ::std::ffi::c_void, ), ) }, @@ -45,7 +68,8 @@ impl op_string_length { } #[inline] #[allow(clippy::too_many_arguments)] - fn call(string: String) -> u32 { + #[allow(clippy::extra_unused_lifetimes)] + fn call<'scope>(string: String) -> u32 { string.len() as u32 } pub fn v8_func<'scope>( @@ -85,21 +109,23 @@ impl op_string_length { }; } } -#[allow(clippy::too_many_arguments)] -fn op_string_length_fast_fn<'scope>( - _: deno_core::v8::Local<deno_core::v8::Object>, - string: *const deno_core::v8::fast_api::FastApiOneByteString, - fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, -) -> u32 { - use deno_core::v8; - use deno_core::_ops; - let string = match ::std::str::from_utf8(unsafe { &*string }.as_bytes()) { - Ok(v) => v.to_owned(), - Err(_) => { - unsafe { &mut *fast_api_callback_options }.fallback = true; - return Default::default(); - } - }; - let result = op_string_length::call(string); - result +impl op_string_length { + #[allow(clippy::too_many_arguments)] + fn op_string_length_fast_fn( + _: deno_core::v8::Local<deno_core::v8::Object>, + string: *const deno_core::v8::fast_api::FastApiOneByteString, + fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, + ) -> u32 { + use deno_core::v8; + use deno_core::_ops; + let string = match ::std::str::from_utf8(unsafe { &*string }.as_bytes()) { + Ok(v) => v.to_owned(), + Err(_) => { + unsafe { &mut *fast_api_callback_options }.fallback = true; + return Default::default(); + } + }; + let result = Self::call(string); + result + } } diff --git a/ops/optimizer_tests/param_mut_binding_warning.out b/ops/optimizer_tests/param_mut_binding_warning.out index 5435b21db..43a33d6e3 100644 --- a/ops/optimizer_tests/param_mut_binding_warning.out +++ b/ops/optimizer_tests/param_mut_binding_warning.out @@ -3,16 +3,29 @@ /// ///Use `op_read_sync::decl()` to get an op-declaration ///you can include in a `deno_core::Extension`. -pub struct op_read_sync; +pub struct op_read_sync { + _phantom_data: ::std::marker::PhantomData<()>, +} +impl deno_core::_ops::Op for op_read_sync { + const NAME: &'static str = stringify!(op_read_sync); + const DECL: deno_core::OpDecl = deno_core::OpDecl { + name: Self::name(), + v8_fn_ptr: Self::v8_fn_ptr as _, + enabled: true, + fast_fn: None, + is_async: false, + is_unstable: false, + is_v8: false, + arg_count: 0, + }; +} #[doc(hidden)] impl op_read_sync { pub const fn name() -> &'static str { stringify!(op_read_sync) } #[allow(clippy::not_unsafe_ptr_arg_deref)] - pub extern "C" fn v8_fn_ptr<'scope>( - info: *const deno_core::v8::FunctionCallbackInfo, - ) { + pub extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { let info = unsafe { &*info }; let scope = &mut unsafe { deno_core::v8::CallbackScope::new(info) }; let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info( @@ -21,7 +34,7 @@ impl op_read_sync { let rv = deno_core::v8::ReturnValue::from_function_callback_info(info); Self::v8_func(scope, args, rv); } - pub const fn decl<'scope>() -> deno_core::OpDecl { + pub const fn decl() -> deno_core::OpDecl { deno_core::OpDecl { name: Self::name(), v8_fn_ptr: Self::v8_fn_ptr as _, @@ -35,7 +48,8 @@ impl op_read_sync { } #[inline] #[allow(clippy::too_many_arguments)] - fn call( + #[allow(clippy::extra_unused_lifetimes)] + fn call<'scope>( state: &mut OpState, rid: ResourceId, mut buf: ZeroCopyBuf, diff --git a/ops/optimizer_tests/raw_ptr.out b/ops/optimizer_tests/raw_ptr.out index a1bacbfc8..18d2aaa4a 100644 --- a/ops/optimizer_tests/raw_ptr.out +++ b/ops/optimizer_tests/raw_ptr.out @@ -3,38 +3,66 @@ /// ///Use `op_ffi_ptr_of::decl()` to get an op-declaration ///you can include in a `deno_core::Extension`. -pub struct op_ffi_ptr_of; +pub struct op_ffi_ptr_of<FP> { + _phantom_data: ::std::marker::PhantomData<(FP)>, +} +impl<FP> deno_core::_ops::Op for op_ffi_ptr_of<FP> +where + FP: FfiPermissions + 'static, +{ + const NAME: &'static str = stringify!(op_ffi_ptr_of); + const DECL: deno_core::OpDecl = deno_core::OpDecl { + name: Self::name(), + v8_fn_ptr: Self::v8_fn_ptr as _, + enabled: true, + fast_fn: { + use deno_core::v8::fast_api::CType; + use deno_core::v8::fast_api::Type::*; + Some( + deno_core::v8::fast_api::FastFunction::new( + &[ + V8Value, + TypedArray(CType::Uint8), + TypedArray(CType::Uint32), + CallbackOptions, + ], + CType::Void, + Self::op_ffi_ptr_of_fast_fn as *const ::std::ffi::c_void, + ), + ) + }, + is_async: false, + is_unstable: false, + is_v8: false, + arg_count: 0, + }; +} #[doc(hidden)] -impl op_ffi_ptr_of { +impl<FP> op_ffi_ptr_of<FP> +where + FP: FfiPermissions + 'static, +{ pub const fn name() -> &'static str { stringify!(op_ffi_ptr_of) } #[allow(clippy::not_unsafe_ptr_arg_deref)] - pub extern "C" fn v8_fn_ptr<'scope, FP>( - info: *const deno_core::v8::FunctionCallbackInfo, - ) - where - FP: FfiPermissions + 'static, - { + pub extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { let info = unsafe { &*info }; let scope = &mut unsafe { deno_core::v8::CallbackScope::new(info) }; let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info( info, ); let rv = deno_core::v8::ReturnValue::from_function_callback_info(info); - Self::v8_func::<FP>(scope, args, rv); + Self::v8_func(scope, args, rv); } - pub const fn decl<'scope, FP>() -> deno_core::OpDecl - where - FP: FfiPermissions + 'static, - { + pub const fn decl() -> deno_core::OpDecl { deno_core::OpDecl { name: Self::name(), - v8_fn_ptr: Self::v8_fn_ptr::<FP> as _, + v8_fn_ptr: Self::v8_fn_ptr as _, enabled: true, fast_fn: { - use deno_core::v8::fast_api::Type::*; use deno_core::v8::fast_api::CType; + use deno_core::v8::fast_api::Type::*; Some( deno_core::v8::fast_api::FastFunction::new( &[ @@ -44,7 +72,7 @@ impl op_ffi_ptr_of { CallbackOptions, ], CType::Void, - op_ffi_ptr_of_fast_fn::<FP> as *const ::std::ffi::c_void, + Self::op_ffi_ptr_of_fast_fn as *const ::std::ffi::c_void, ), ) }, @@ -56,18 +84,13 @@ impl op_ffi_ptr_of { } #[inline] #[allow(clippy::too_many_arguments)] - fn call<FP>(state: &mut OpState, buf: *const u8, out: &mut [u32]) - where - FP: FfiPermissions + 'static, - {} - pub fn v8_func<'scope, FP>( + #[allow(clippy::extra_unused_lifetimes)] + fn call<'scope>(state: &mut OpState, buf: *const u8, out: &mut [u32]) {} + pub fn v8_func<'scope>( scope: &mut deno_core::v8::HandleScope<'scope>, args: deno_core::v8::FunctionCallbackArguments, mut rv: deno_core::v8::ReturnValue, - ) - where - FP: FfiPermissions + 'static, - { + ) { let ctx = unsafe { &*(deno_core::v8::Local::<deno_core::v8::External>::cast(args.data()).value() as *const deno_core::_ops::OpCtx) @@ -143,41 +166,46 @@ impl op_ffi_ptr_of { format!("Expected Uint32Array at position {}", 1usize), ); }; - let result = Self::call::< - FP, - >(&mut std::cell::RefCell::borrow_mut(&ctx.state), arg_0, arg_1); + let result = Self::call( + &mut std::cell::RefCell::borrow_mut(&ctx.state), + arg_0, + arg_1, + ); let op_state = ::std::cell::RefCell::borrow(&*ctx.state); op_state.tracker.track_sync(ctx.id); } } -#[allow(clippy::too_many_arguments)] -fn op_ffi_ptr_of_fast_fn<'scope, FP>( - _: deno_core::v8::Local<deno_core::v8::Object>, - buf: *const deno_core::v8::fast_api::FastApiTypedArray<u8>, - out: *const deno_core::v8::fast_api::FastApiTypedArray<u32>, - fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, -) -> () +impl<FP> op_ffi_ptr_of<FP> where FP: FfiPermissions + 'static, { - use deno_core::v8; - use deno_core::_ops; - let __opts: &mut v8::fast_api::FastApiCallbackOptions = unsafe { - &mut *fast_api_callback_options - }; - let __ctx = unsafe { - &*(v8::Local::<v8::External>::cast(unsafe { __opts.data.data }).value() - as *const _ops::OpCtx) - }; - let state = &mut ::std::cell::RefCell::borrow_mut(&__ctx.state); - let buf = unsafe { (&*buf).get_storage_if_aligned().unwrap_unchecked() }.as_ptr(); - let out = match unsafe { &*out }.get_storage_if_aligned() { - Some(v) => v, - None => { - unsafe { &mut *fast_api_callback_options }.fallback = true; - return Default::default(); - } - }; - let result = op_ffi_ptr_of::call::<FP>(state, buf, out); - result + #[allow(clippy::too_many_arguments)] + fn op_ffi_ptr_of_fast_fn( + _: deno_core::v8::Local<deno_core::v8::Object>, + buf: *const deno_core::v8::fast_api::FastApiTypedArray<u8>, + out: *const deno_core::v8::fast_api::FastApiTypedArray<u32>, + fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, + ) -> () { + use deno_core::v8; + use deno_core::_ops; + let __opts: &mut v8::fast_api::FastApiCallbackOptions = unsafe { + &mut *fast_api_callback_options + }; + let __ctx = unsafe { + &*(v8::Local::<v8::External>::cast(unsafe { __opts.data.data }).value() + as *const _ops::OpCtx) + }; + let state = &mut ::std::cell::RefCell::borrow_mut(&__ctx.state); + let buf = unsafe { (&*buf).get_storage_if_aligned().unwrap_unchecked() } + .as_ptr(); + let out = match unsafe { &*out }.get_storage_if_aligned() { + Some(v) => v, + None => { + unsafe { &mut *fast_api_callback_options }.fallback = true; + return Default::default(); + } + }; + let result = Self::call(state, buf, out); + result + } } diff --git a/ops/optimizer_tests/serde_v8_value.out b/ops/optimizer_tests/serde_v8_value.out index 034caec50..20cc97584 100644 --- a/ops/optimizer_tests/serde_v8_value.out +++ b/ops/optimizer_tests/serde_v8_value.out @@ -3,16 +3,39 @@ /// ///Use `op_is_proxy::decl()` to get an op-declaration ///you can include in a `deno_core::Extension`. -pub struct op_is_proxy; +pub struct op_is_proxy { + _phantom_data: ::std::marker::PhantomData<()>, +} +impl deno_core::_ops::Op for op_is_proxy { + const NAME: &'static str = stringify!(op_is_proxy); + const DECL: deno_core::OpDecl = deno_core::OpDecl { + name: Self::name(), + v8_fn_ptr: Self::v8_fn_ptr as _, + enabled: true, + fast_fn: { + use deno_core::v8::fast_api::CType; + use deno_core::v8::fast_api::Type::*; + Some( + deno_core::v8::fast_api::FastFunction::new( + &[V8Value, V8Value], + CType::Bool, + Self::op_is_proxy_fast_fn as *const ::std::ffi::c_void, + ), + ) + }, + is_async: false, + is_unstable: false, + is_v8: false, + arg_count: 0, + }; +} #[doc(hidden)] impl op_is_proxy { pub const fn name() -> &'static str { stringify!(op_is_proxy) } #[allow(clippy::not_unsafe_ptr_arg_deref)] - pub extern "C" fn v8_fn_ptr<'scope>( - info: *const deno_core::v8::FunctionCallbackInfo, - ) { + pub extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { let info = unsafe { &*info }; let scope = &mut unsafe { deno_core::v8::CallbackScope::new(info) }; let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info( @@ -21,19 +44,19 @@ impl op_is_proxy { let rv = deno_core::v8::ReturnValue::from_function_callback_info(info); Self::v8_func(scope, args, rv); } - pub const fn decl<'scope>() -> deno_core::OpDecl { + pub const fn decl() -> deno_core::OpDecl { deno_core::OpDecl { name: Self::name(), v8_fn_ptr: Self::v8_fn_ptr as _, enabled: true, fast_fn: { - use deno_core::v8::fast_api::Type::*; use deno_core::v8::fast_api::CType; + use deno_core::v8::fast_api::Type::*; Some( deno_core::v8::fast_api::FastFunction::new( &[V8Value, V8Value], CType::Bool, - op_is_proxy_fast_fn as *const ::std::ffi::c_void, + Self::op_is_proxy_fast_fn as *const ::std::ffi::c_void, ), ) }, @@ -45,7 +68,8 @@ impl op_is_proxy { } #[inline] #[allow(clippy::too_many_arguments)] - fn call(value: serde_v8::Value) -> bool { + #[allow(clippy::extra_unused_lifetimes)] + fn call<'scope>(value: serde_v8::Value) -> bool { value.v8_value.is_proxy() } pub fn v8_func<'scope>( @@ -85,14 +109,16 @@ impl op_is_proxy { }; } } -#[allow(clippy::too_many_arguments)] -fn op_is_proxy_fast_fn<'scope>( - _: deno_core::v8::Local<deno_core::v8::Object>, - value: deno_core::v8::Local<deno_core::v8::Value>, -) -> bool { - use deno_core::v8; - use deno_core::_ops; - let value = serde_v8::Value { v8_value: value }; - let result = op_is_proxy::call(value); - result +impl op_is_proxy { + #[allow(clippy::too_many_arguments)] + fn op_is_proxy_fast_fn( + _: deno_core::v8::Local<deno_core::v8::Object>, + value: deno_core::v8::Local<deno_core::v8::Value>, + ) -> bool { + use deno_core::v8; + use deno_core::_ops; + let value = serde_v8::Value { v8_value: value }; + let result = Self::call(value); + result + } } diff --git a/ops/optimizer_tests/strings.out b/ops/optimizer_tests/strings.out index a1e684caf..c59214f6a 100644 --- a/ops/optimizer_tests/strings.out +++ b/ops/optimizer_tests/strings.out @@ -3,16 +3,39 @@ /// ///Use `op_string_length::decl()` to get an op-declaration ///you can include in a `deno_core::Extension`. -pub struct op_string_length; +pub struct op_string_length { + _phantom_data: ::std::marker::PhantomData<()>, +} +impl deno_core::_ops::Op for op_string_length { + const NAME: &'static str = stringify!(op_string_length); + const DECL: deno_core::OpDecl = deno_core::OpDecl { + name: Self::name(), + v8_fn_ptr: Self::v8_fn_ptr as _, + enabled: true, + fast_fn: { + use deno_core::v8::fast_api::CType; + use deno_core::v8::fast_api::Type::*; + Some( + deno_core::v8::fast_api::FastFunction::new( + &[V8Value, SeqOneByteString, CallbackOptions], + CType::Uint32, + Self::op_string_length_fast_fn as *const ::std::ffi::c_void, + ), + ) + }, + is_async: false, + is_unstable: false, + is_v8: false, + arg_count: 0, + }; +} #[doc(hidden)] impl op_string_length { pub const fn name() -> &'static str { stringify!(op_string_length) } #[allow(clippy::not_unsafe_ptr_arg_deref)] - pub extern "C" fn v8_fn_ptr<'scope>( - info: *const deno_core::v8::FunctionCallbackInfo, - ) { + pub extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { let info = unsafe { &*info }; let scope = &mut unsafe { deno_core::v8::CallbackScope::new(info) }; let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info( @@ -21,19 +44,19 @@ impl op_string_length { let rv = deno_core::v8::ReturnValue::from_function_callback_info(info); Self::v8_func(scope, args, rv); } - pub const fn decl<'scope>() -> deno_core::OpDecl { + pub const fn decl() -> deno_core::OpDecl { deno_core::OpDecl { name: Self::name(), v8_fn_ptr: Self::v8_fn_ptr as _, enabled: true, fast_fn: { - use deno_core::v8::fast_api::Type::*; use deno_core::v8::fast_api::CType; + use deno_core::v8::fast_api::Type::*; Some( deno_core::v8::fast_api::FastFunction::new( &[V8Value, SeqOneByteString, CallbackOptions], CType::Uint32, - op_string_length_fast_fn as *const ::std::ffi::c_void, + Self::op_string_length_fast_fn as *const ::std::ffi::c_void, ), ) }, @@ -45,7 +68,8 @@ impl op_string_length { } #[inline] #[allow(clippy::too_many_arguments)] - fn call(string: &str) -> u32 { + #[allow(clippy::extra_unused_lifetimes)] + fn call<'scope>(string: &str) -> u32 { string.len() as u32 } pub fn v8_func<'scope>( @@ -86,21 +110,23 @@ impl op_string_length { }; } } -#[allow(clippy::too_many_arguments)] -fn op_string_length_fast_fn<'scope>( - _: deno_core::v8::Local<deno_core::v8::Object>, - string: *const deno_core::v8::fast_api::FastApiOneByteString, - fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, -) -> u32 { - use deno_core::v8; - use deno_core::_ops; - let string = match ::std::str::from_utf8(unsafe { &*string }.as_bytes()) { - Ok(v) => v, - Err(_) => { - unsafe { &mut *fast_api_callback_options }.fallback = true; - return Default::default(); - } - }; - let result = op_string_length::call(string); - result +impl op_string_length { + #[allow(clippy::too_many_arguments)] + fn op_string_length_fast_fn( + _: deno_core::v8::Local<deno_core::v8::Object>, + string: *const deno_core::v8::fast_api::FastApiOneByteString, + fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, + ) -> u32 { + use deno_core::v8; + use deno_core::_ops; + let string = match ::std::str::from_utf8(unsafe { &*string }.as_bytes()) { + Ok(v) => v, + Err(_) => { + unsafe { &mut *fast_api_callback_options }.fallback = true; + return Default::default(); + } + }; + let result = Self::call(string); + result + } } diff --git a/ops/optimizer_tests/strings_result.out b/ops/optimizer_tests/strings_result.out index 46e27e762..45ca1fac7 100644 --- a/ops/optimizer_tests/strings_result.out +++ b/ops/optimizer_tests/strings_result.out @@ -3,16 +3,29 @@ /// ///Use `op_string_length::decl()` to get an op-declaration ///you can include in a `deno_core::Extension`. -pub struct op_string_length; +pub struct op_string_length { + _phantom_data: ::std::marker::PhantomData<()>, +} +impl deno_core::_ops::Op for op_string_length { + const NAME: &'static str = stringify!(op_string_length); + const DECL: deno_core::OpDecl = deno_core::OpDecl { + name: Self::name(), + v8_fn_ptr: Self::v8_fn_ptr as _, + enabled: true, + fast_fn: None, + is_async: false, + is_unstable: false, + is_v8: false, + arg_count: 0, + }; +} #[doc(hidden)] impl op_string_length { pub const fn name() -> &'static str { stringify!(op_string_length) } #[allow(clippy::not_unsafe_ptr_arg_deref)] - pub extern "C" fn v8_fn_ptr<'scope>( - info: *const deno_core::v8::FunctionCallbackInfo, - ) { + pub extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { let info = unsafe { &*info }; let scope = &mut unsafe { deno_core::v8::CallbackScope::new(info) }; let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info( @@ -21,7 +34,7 @@ impl op_string_length { let rv = deno_core::v8::ReturnValue::from_function_callback_info(info); Self::v8_func(scope, args, rv); } - pub const fn decl<'scope>() -> deno_core::OpDecl { + pub const fn decl() -> deno_core::OpDecl { deno_core::OpDecl { name: Self::name(), v8_fn_ptr: Self::v8_fn_ptr as _, @@ -35,7 +48,8 @@ impl op_string_length { } #[inline] #[allow(clippy::too_many_arguments)] - fn call(string: &str) -> Result<u32, AnyError> { + #[allow(clippy::extra_unused_lifetimes)] + fn call<'scope>(string: &str) -> Result<u32, AnyError> { Ok(string.len() as u32) } pub fn v8_func<'scope>( diff --git a/ops/optimizer_tests/u64_result.out b/ops/optimizer_tests/u64_result.out index 46ccd53e1..5a4df68b1 100644 --- a/ops/optimizer_tests/u64_result.out +++ b/ops/optimizer_tests/u64_result.out @@ -3,16 +3,29 @@ /// ///Use `op_bench_now::decl()` to get an op-declaration ///you can include in a `deno_core::Extension`. -pub struct op_bench_now; +pub struct op_bench_now { + _phantom_data: ::std::marker::PhantomData<()>, +} +impl deno_core::_ops::Op for op_bench_now { + const NAME: &'static str = stringify!(op_bench_now); + const DECL: deno_core::OpDecl = deno_core::OpDecl { + name: Self::name(), + v8_fn_ptr: Self::v8_fn_ptr as _, + enabled: true, + fast_fn: None, + is_async: false, + is_unstable: false, + is_v8: false, + arg_count: 0, + }; +} #[doc(hidden)] impl op_bench_now { pub const fn name() -> &'static str { stringify!(op_bench_now) } #[allow(clippy::not_unsafe_ptr_arg_deref)] - pub extern "C" fn v8_fn_ptr<'scope>( - info: *const deno_core::v8::FunctionCallbackInfo, - ) { + pub extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { let info = unsafe { &*info }; let scope = &mut unsafe { deno_core::v8::CallbackScope::new(info) }; let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info( @@ -21,7 +34,7 @@ impl op_bench_now { let rv = deno_core::v8::ReturnValue::from_function_callback_info(info); Self::v8_func(scope, args, rv); } - pub const fn decl<'scope>() -> deno_core::OpDecl { + pub const fn decl() -> deno_core::OpDecl { deno_core::OpDecl { name: Self::name(), v8_fn_ptr: Self::v8_fn_ptr as _, @@ -35,7 +48,8 @@ impl op_bench_now { } #[inline] #[allow(clippy::too_many_arguments)] - fn call(state: &mut OpState) -> Result<u64, AnyError> { + #[allow(clippy::extra_unused_lifetimes)] + fn call<'scope>(state: &mut OpState) -> Result<u64, AnyError> { let ns = state.borrow::<time::Instant>().elapsed().as_nanos(); let ns_u64 = u64::try_from(ns)?; Ok(ns_u64) diff --git a/ops/optimizer_tests/uint8array.out b/ops/optimizer_tests/uint8array.out index 31915d2fe..335bf42f6 100644 --- a/ops/optimizer_tests/uint8array.out +++ b/ops/optimizer_tests/uint8array.out @@ -3,16 +3,39 @@ /// ///Use `op_import_spki_x25519::decl()` to get an op-declaration ///you can include in a `deno_core::Extension`. -pub struct op_import_spki_x25519; +pub struct op_import_spki_x25519 { + _phantom_data: ::std::marker::PhantomData<()>, +} +impl deno_core::_ops::Op for op_import_spki_x25519 { + const NAME: &'static str = stringify!(op_import_spki_x25519); + const DECL: deno_core::OpDecl = deno_core::OpDecl { + name: Self::name(), + v8_fn_ptr: Self::v8_fn_ptr as _, + enabled: true, + fast_fn: { + use deno_core::v8::fast_api::CType; + use deno_core::v8::fast_api::Type::*; + Some( + deno_core::v8::fast_api::FastFunction::new( + &[V8Value, TypedArray(CType::Uint8), TypedArray(CType::Uint8)], + CType::Bool, + Self::op_import_spki_x25519_fast_fn as *const ::std::ffi::c_void, + ), + ) + }, + is_async: false, + is_unstable: false, + is_v8: false, + arg_count: 0, + }; +} #[doc(hidden)] impl op_import_spki_x25519 { pub const fn name() -> &'static str { stringify!(op_import_spki_x25519) } #[allow(clippy::not_unsafe_ptr_arg_deref)] - pub extern "C" fn v8_fn_ptr<'scope>( - info: *const deno_core::v8::FunctionCallbackInfo, - ) { + pub extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { let info = unsafe { &*info }; let scope = &mut unsafe { deno_core::v8::CallbackScope::new(info) }; let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info( @@ -21,19 +44,19 @@ impl op_import_spki_x25519 { let rv = deno_core::v8::ReturnValue::from_function_callback_info(info); Self::v8_func(scope, args, rv); } - pub const fn decl<'scope>() -> deno_core::OpDecl { + pub const fn decl() -> deno_core::OpDecl { deno_core::OpDecl { name: Self::name(), v8_fn_ptr: Self::v8_fn_ptr as _, enabled: true, fast_fn: { - use deno_core::v8::fast_api::Type::*; use deno_core::v8::fast_api::CType; + use deno_core::v8::fast_api::Type::*; Some( deno_core::v8::fast_api::FastFunction::new( &[V8Value, TypedArray(CType::Uint8), TypedArray(CType::Uint8)], CType::Bool, - op_import_spki_x25519_fast_fn as *const ::std::ffi::c_void, + Self::op_import_spki_x25519_fast_fn as *const ::std::ffi::c_void, ), ) }, @@ -45,7 +68,8 @@ impl op_import_spki_x25519 { } #[inline] #[allow(clippy::too_many_arguments)] - pub fn call(key_data: &[u8], out: &mut [u8]) -> bool {} + #[allow(clippy::extra_unused_lifetimes)] + pub fn call<'scope>(key_data: &[u8], out: &mut [u8]) -> bool {} pub fn v8_func<'scope>( scope: &mut deno_core::v8::HandleScope<'scope>, args: deno_core::v8::FunctionCallbackArguments, @@ -162,16 +186,20 @@ impl op_import_spki_x25519 { }; } } -#[allow(clippy::too_many_arguments)] -fn op_import_spki_x25519_fast_fn<'scope>( - _: deno_core::v8::Local<deno_core::v8::Object>, - key_data: *const deno_core::v8::fast_api::FastApiTypedArray<u8>, - out: *const deno_core::v8::fast_api::FastApiTypedArray<u8>, -) -> bool { - use deno_core::v8; - use deno_core::_ops; - let key_data = unsafe { (&*key_data).get_storage_if_aligned().unwrap_unchecked() }; - let out = unsafe { (&*out).get_storage_if_aligned().unwrap_unchecked() }; - let result = op_import_spki_x25519::call(key_data, out); - result +impl op_import_spki_x25519 { + #[allow(clippy::too_many_arguments)] + fn op_import_spki_x25519_fast_fn( + _: deno_core::v8::Local<deno_core::v8::Object>, + key_data: *const deno_core::v8::fast_api::FastApiTypedArray<u8>, + out: *const deno_core::v8::fast_api::FastApiTypedArray<u8>, + ) -> bool { + use deno_core::v8; + use deno_core::_ops; + let key_data = unsafe { + (&*key_data).get_storage_if_aligned().unwrap_unchecked() + }; + let out = unsafe { (&*out).get_storage_if_aligned().unwrap_unchecked() }; + let result = Self::call(key_data, out); + result + } } diff --git a/ops/optimizer_tests/unit_result.out b/ops/optimizer_tests/unit_result.out index cab67c0ea..894297255 100644 --- a/ops/optimizer_tests/unit_result.out +++ b/ops/optimizer_tests/unit_result.out @@ -3,16 +3,39 @@ /// ///Use `op_unit_result::decl()` to get an op-declaration ///you can include in a `deno_core::Extension`. -pub struct op_unit_result; +pub struct op_unit_result { + _phantom_data: ::std::marker::PhantomData<()>, +} +impl deno_core::_ops::Op for op_unit_result { + const NAME: &'static str = stringify!(op_unit_result); + const DECL: deno_core::OpDecl = deno_core::OpDecl { + name: Self::name(), + v8_fn_ptr: Self::v8_fn_ptr as _, + enabled: true, + fast_fn: { + use deno_core::v8::fast_api::CType; + use deno_core::v8::fast_api::Type::*; + Some( + deno_core::v8::fast_api::FastFunction::new( + &[V8Value, CallbackOptions], + CType::Void, + Self::op_unit_result_fast_fn as *const ::std::ffi::c_void, + ), + ) + }, + is_async: false, + is_unstable: false, + is_v8: false, + arg_count: 0, + }; +} #[doc(hidden)] impl op_unit_result { pub const fn name() -> &'static str { stringify!(op_unit_result) } #[allow(clippy::not_unsafe_ptr_arg_deref)] - pub extern "C" fn v8_fn_ptr<'scope>( - info: *const deno_core::v8::FunctionCallbackInfo, - ) { + pub extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { let info = unsafe { &*info }; let scope = &mut unsafe { deno_core::v8::CallbackScope::new(info) }; let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info( @@ -21,19 +44,19 @@ impl op_unit_result { let rv = deno_core::v8::ReturnValue::from_function_callback_info(info); Self::v8_func(scope, args, rv); } - pub const fn decl<'scope>() -> deno_core::OpDecl { + pub const fn decl() -> deno_core::OpDecl { deno_core::OpDecl { name: Self::name(), v8_fn_ptr: Self::v8_fn_ptr as _, enabled: true, fast_fn: { - use deno_core::v8::fast_api::Type::*; use deno_core::v8::fast_api::CType; + use deno_core::v8::fast_api::Type::*; Some( deno_core::v8::fast_api::FastFunction::new( &[V8Value, CallbackOptions], CType::Void, - op_unit_result_fast_fn as *const ::std::ffi::c_void, + Self::op_unit_result_fast_fn as *const ::std::ffi::c_void, ), ) }, @@ -45,7 +68,8 @@ impl op_unit_result { } #[inline] #[allow(clippy::too_many_arguments)] - fn call() -> Result<(), AnyError> { + #[allow(clippy::extra_unused_lifetimes)] + fn call<'scope>() -> Result<(), AnyError> { Ok(()) } pub fn v8_func<'scope>( @@ -85,27 +109,29 @@ impl op_unit_result { }; } } -#[allow(clippy::too_many_arguments)] -fn op_unit_result_fast_fn<'scope>( - _: deno_core::v8::Local<deno_core::v8::Object>, - fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, -) -> () { - use deno_core::v8; - use deno_core::_ops; - let __opts: &mut v8::fast_api::FastApiCallbackOptions = unsafe { - &mut *fast_api_callback_options - }; - let __ctx = unsafe { - &*(v8::Local::<v8::External>::cast(unsafe { __opts.data.data }).value() - as *const _ops::OpCtx) - }; - let op_state = &mut ::std::cell::RefCell::borrow_mut(&__ctx.state); - let result = op_unit_result::call(); - match result { - Ok(result) => result, - Err(err) => { - op_state.last_fast_op_error.replace(err); - __opts.fallback = true; +impl op_unit_result { + #[allow(clippy::too_many_arguments)] + fn op_unit_result_fast_fn( + _: deno_core::v8::Local<deno_core::v8::Object>, + fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, + ) -> () { + use deno_core::v8; + use deno_core::_ops; + let __opts: &mut v8::fast_api::FastApiCallbackOptions = unsafe { + &mut *fast_api_callback_options + }; + let __ctx = unsafe { + &*(v8::Local::<v8::External>::cast(unsafe { __opts.data.data }).value() + as *const _ops::OpCtx) + }; + let op_state = &mut ::std::cell::RefCell::borrow_mut(&__ctx.state); + let result = Self::call(); + match result { + Ok(result) => result, + Err(err) => { + op_state.last_fast_op_error.replace(err); + __opts.fallback = true; + } } } } diff --git a/ops/optimizer_tests/unit_result2.out b/ops/optimizer_tests/unit_result2.out index 3d8479791..d091b91cd 100644 --- a/ops/optimizer_tests/unit_result2.out +++ b/ops/optimizer_tests/unit_result2.out @@ -3,16 +3,39 @@ /// ///Use `op_set_nodelay::decl()` to get an op-declaration ///you can include in a `deno_core::Extension`. -pub struct op_set_nodelay; +pub struct op_set_nodelay { + _phantom_data: ::std::marker::PhantomData<()>, +} +impl deno_core::_ops::Op for op_set_nodelay { + const NAME: &'static str = stringify!(op_set_nodelay); + const DECL: deno_core::OpDecl = deno_core::OpDecl { + name: Self::name(), + v8_fn_ptr: Self::v8_fn_ptr as _, + enabled: true, + fast_fn: { + use deno_core::v8::fast_api::CType; + use deno_core::v8::fast_api::Type::*; + Some( + deno_core::v8::fast_api::FastFunction::new( + &[V8Value, Uint32, Bool, CallbackOptions], + CType::Void, + Self::op_set_nodelay_fast_fn as *const ::std::ffi::c_void, + ), + ) + }, + is_async: false, + is_unstable: false, + is_v8: false, + arg_count: 0, + }; +} #[doc(hidden)] impl op_set_nodelay { pub const fn name() -> &'static str { stringify!(op_set_nodelay) } #[allow(clippy::not_unsafe_ptr_arg_deref)] - pub extern "C" fn v8_fn_ptr<'scope>( - info: *const deno_core::v8::FunctionCallbackInfo, - ) { + pub extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { let info = unsafe { &*info }; let scope = &mut unsafe { deno_core::v8::CallbackScope::new(info) }; let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info( @@ -21,19 +44,19 @@ impl op_set_nodelay { let rv = deno_core::v8::ReturnValue::from_function_callback_info(info); Self::v8_func(scope, args, rv); } - pub const fn decl<'scope>() -> deno_core::OpDecl { + pub const fn decl() -> deno_core::OpDecl { deno_core::OpDecl { name: Self::name(), v8_fn_ptr: Self::v8_fn_ptr as _, enabled: true, fast_fn: { - use deno_core::v8::fast_api::Type::*; use deno_core::v8::fast_api::CType; + use deno_core::v8::fast_api::Type::*; Some( deno_core::v8::fast_api::FastFunction::new( &[V8Value, Uint32, Bool, CallbackOptions], CType::Void, - op_set_nodelay_fast_fn as *const ::std::ffi::c_void, + Self::op_set_nodelay_fast_fn as *const ::std::ffi::c_void, ), ) }, @@ -45,7 +68,8 @@ impl op_set_nodelay { } #[inline] #[allow(clippy::too_many_arguments)] - pub fn call( + #[allow(clippy::extra_unused_lifetimes)] + pub fn call<'scope>( state: &mut OpState, rid: ResourceId, nodelay: bool, @@ -118,29 +142,31 @@ impl op_set_nodelay { }; } } -#[allow(clippy::too_many_arguments)] -fn op_set_nodelay_fast_fn<'scope>( - _: deno_core::v8::Local<deno_core::v8::Object>, - rid: ResourceId, - nodelay: bool, - fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, -) -> () { - use deno_core::v8; - use deno_core::_ops; - let __opts: &mut v8::fast_api::FastApiCallbackOptions = unsafe { - &mut *fast_api_callback_options - }; - let __ctx = unsafe { - &*(v8::Local::<v8::External>::cast(unsafe { __opts.data.data }).value() - as *const _ops::OpCtx) - }; - let state = &mut ::std::cell::RefCell::borrow_mut(&__ctx.state); - let result = op_set_nodelay::call(state, rid, nodelay); - match result { - Ok(result) => result, - Err(err) => { - state.last_fast_op_error.replace(err); - __opts.fallback = true; +impl op_set_nodelay { + #[allow(clippy::too_many_arguments)] + fn op_set_nodelay_fast_fn( + _: deno_core::v8::Local<deno_core::v8::Object>, + rid: ResourceId, + nodelay: bool, + fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, + ) -> () { + use deno_core::v8; + use deno_core::_ops; + let __opts: &mut v8::fast_api::FastApiCallbackOptions = unsafe { + &mut *fast_api_callback_options + }; + let __ctx = unsafe { + &*(v8::Local::<v8::External>::cast(unsafe { __opts.data.data }).value() + as *const _ops::OpCtx) + }; + let state = &mut ::std::cell::RefCell::borrow_mut(&__ctx.state); + let result = Self::call(state, rid, nodelay); + match result { + Ok(result) => result, + Err(err) => { + state.last_fast_op_error.replace(err); + __opts.fallback = true; + } } } } diff --git a/ops/optimizer_tests/unit_ret.out b/ops/optimizer_tests/unit_ret.out index 523ae6504..1a721c407 100644 --- a/ops/optimizer_tests/unit_ret.out +++ b/ops/optimizer_tests/unit_ret.out @@ -3,16 +3,39 @@ /// ///Use `op_unit::decl()` to get an op-declaration ///you can include in a `deno_core::Extension`. -pub struct op_unit; +pub struct op_unit { + _phantom_data: ::std::marker::PhantomData<()>, +} +impl deno_core::_ops::Op for op_unit { + const NAME: &'static str = stringify!(op_unit); + const DECL: deno_core::OpDecl = deno_core::OpDecl { + name: Self::name(), + v8_fn_ptr: Self::v8_fn_ptr as _, + enabled: true, + fast_fn: { + use deno_core::v8::fast_api::CType; + use deno_core::v8::fast_api::Type::*; + Some( + deno_core::v8::fast_api::FastFunction::new( + &[V8Value], + CType::Void, + Self::op_unit_fast_fn as *const ::std::ffi::c_void, + ), + ) + }, + is_async: false, + is_unstable: false, + is_v8: false, + arg_count: 0, + }; +} #[doc(hidden)] impl op_unit { pub const fn name() -> &'static str { stringify!(op_unit) } #[allow(clippy::not_unsafe_ptr_arg_deref)] - pub extern "C" fn v8_fn_ptr<'scope>( - info: *const deno_core::v8::FunctionCallbackInfo, - ) { + pub extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { let info = unsafe { &*info }; let scope = &mut unsafe { deno_core::v8::CallbackScope::new(info) }; let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info( @@ -21,19 +44,19 @@ impl op_unit { let rv = deno_core::v8::ReturnValue::from_function_callback_info(info); Self::v8_func(scope, args, rv); } - pub const fn decl<'scope>() -> deno_core::OpDecl { + pub const fn decl() -> deno_core::OpDecl { deno_core::OpDecl { name: Self::name(), v8_fn_ptr: Self::v8_fn_ptr as _, enabled: true, fast_fn: { - use deno_core::v8::fast_api::Type::*; use deno_core::v8::fast_api::CType; + use deno_core::v8::fast_api::Type::*; Some( deno_core::v8::fast_api::FastFunction::new( &[V8Value], CType::Void, - op_unit_fast_fn as *const ::std::ffi::c_void, + Self::op_unit_fast_fn as *const ::std::ffi::c_void, ), ) }, @@ -45,7 +68,8 @@ impl op_unit { } #[inline] #[allow(clippy::too_many_arguments)] - fn call() -> () { + #[allow(clippy::extra_unused_lifetimes)] + fn call<'scope>() -> () { () } pub fn v8_func<'scope>( @@ -74,10 +98,12 @@ impl op_unit { }; } } -#[allow(clippy::too_many_arguments)] -fn op_unit_fast_fn<'scope>(_: deno_core::v8::Local<deno_core::v8::Object>) -> () { - use deno_core::v8; - use deno_core::_ops; - let result = op_unit::call(); - result +impl op_unit { + #[allow(clippy::too_many_arguments)] + fn op_unit_fast_fn(_: deno_core::v8::Local<deno_core::v8::Object>) -> () { + use deno_core::v8; + use deno_core::_ops; + let result = Self::call(); + result + } } diff --git a/ops/optimizer_tests/wasm_op.out b/ops/optimizer_tests/wasm_op.out index 5a8996cd0..023506fc2 100644 --- a/ops/optimizer_tests/wasm_op.out +++ b/ops/optimizer_tests/wasm_op.out @@ -3,16 +3,39 @@ /// ///Use `op_wasm::decl()` to get an op-declaration ///you can include in a `deno_core::Extension`. -pub struct op_wasm; +pub struct op_wasm { + _phantom_data: ::std::marker::PhantomData<()>, +} +impl deno_core::_ops::Op for op_wasm { + const NAME: &'static str = stringify!(op_wasm); + const DECL: deno_core::OpDecl = deno_core::OpDecl { + name: Self::name(), + v8_fn_ptr: Self::v8_fn_ptr as _, + enabled: true, + fast_fn: { + use deno_core::v8::fast_api::CType; + use deno_core::v8::fast_api::Type::*; + Some( + deno_core::v8::fast_api::FastFunction::new( + &[V8Value, CallbackOptions], + CType::Void, + Self::op_wasm_fast_fn as *const ::std::ffi::c_void, + ), + ) + }, + is_async: false, + is_unstable: false, + is_v8: false, + arg_count: 0, + }; +} #[doc(hidden)] impl op_wasm { pub const fn name() -> &'static str { stringify!(op_wasm) } #[allow(clippy::not_unsafe_ptr_arg_deref)] - pub extern "C" fn v8_fn_ptr<'scope>( - info: *const deno_core::v8::FunctionCallbackInfo, - ) { + pub extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) { let info = unsafe { &*info }; let scope = &mut unsafe { deno_core::v8::CallbackScope::new(info) }; let args = deno_core::v8::FunctionCallbackArguments::from_function_callback_info( @@ -21,19 +44,19 @@ impl op_wasm { let rv = deno_core::v8::ReturnValue::from_function_callback_info(info); Self::v8_func(scope, args, rv); } - pub const fn decl<'scope>() -> deno_core::OpDecl { + pub const fn decl() -> deno_core::OpDecl { deno_core::OpDecl { name: Self::name(), v8_fn_ptr: Self::v8_fn_ptr as _, enabled: true, fast_fn: { - use deno_core::v8::fast_api::Type::*; use deno_core::v8::fast_api::CType; + use deno_core::v8::fast_api::Type::*; Some( deno_core::v8::fast_api::FastFunction::new( &[V8Value, CallbackOptions], CType::Void, - op_wasm_fast_fn as *const ::std::ffi::c_void, + Self::op_wasm_fast_fn as *const ::std::ffi::c_void, ), ) }, @@ -45,7 +68,8 @@ impl op_wasm { } #[inline] #[allow(clippy::too_many_arguments)] - fn call(memory: Option<&mut [u8]>) {} + #[allow(clippy::extra_unused_lifetimes)] + fn call<'scope>(memory: Option<&mut [u8]>) {} pub fn v8_func<'scope>( scope: &mut deno_core::v8::HandleScope<'scope>, args: deno_core::v8::FunctionCallbackArguments, @@ -61,20 +85,23 @@ impl op_wasm { op_state.tracker.track_sync(ctx.id); } } -#[allow(clippy::too_many_arguments)] -fn op_wasm_fast_fn<'scope>( - _: deno_core::v8::Local<deno_core::v8::Object>, - fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, -) -> () { - use deno_core::v8; - use deno_core::_ops; - let __opts: &mut v8::fast_api::FastApiCallbackOptions = unsafe { - &mut *fast_api_callback_options - }; - let memory = unsafe { - &*(__opts.wasm_memory as *const deno_core::v8::fast_api::FastApiTypedArray<u8>) +impl op_wasm { + #[allow(clippy::too_many_arguments)] + fn op_wasm_fast_fn( + _: deno_core::v8::Local<deno_core::v8::Object>, + fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, + ) -> () { + use deno_core::v8; + use deno_core::_ops; + let __opts: &mut v8::fast_api::FastApiCallbackOptions = unsafe { + &mut *fast_api_callback_options + }; + let memory = unsafe { + &*(__opts.wasm_memory + as *const deno_core::v8::fast_api::FastApiTypedArray<u8>) + } + .get_storage_if_aligned(); + let result = Self::call(memory); + result } - .get_storage_if_aligned(); - let result = op_wasm::call(memory); - result } |