summaryrefslogtreecommitdiff
path: root/ops/op2/test_cases/sync/add.out
diff options
context:
space:
mode:
authorMatt Mastracci <matthew@mastracci.com>2023-06-29 10:23:14 -0600
committerGitHub <noreply@github.com>2023-06-29 10:23:14 -0600
commitfbb69329343c9985c26181e6297e6556c46d381d (patch)
treeee428c94727bdfdf9040a4944bd66981b4cd07fb /ops/op2/test_cases/sync/add.out
parent98df69fd4cbe3687e2ff3519fbd6bff4e5f3101f (diff)
refactor(ops): op2 support for generics (#19636)
Implementation of generics for `#[op2]`, along with some refactoring to improve the ergonomics of ops with generics parameters: - The ops have generics on the struct rather than the associated methods, which allows us to trait-ify ops (impossible when they are on the methods) - The decl() method can become a trait-associated const field which unlocks future optimizations Callers of ops need to switch from: `op_net_connect_tcp::call::<TestPermission>(conn_state, ip_addr)` to `op_net_connect_tcp::<TestPermission>::call(conn_state, ip_addr)`.
Diffstat (limited to 'ops/op2/test_cases/sync/add.out')
-rw-r--r--ops/op2/test_cases/sync/add.out47
1 files changed, 35 insertions, 12 deletions
diff --git a/ops/op2/test_cases/sync/add.out b/ops/op2/test_cases/sync/add.out
index 7d97a7161..c8f77ab92 100644
--- a/ops/op2/test_cases/sync/add.out
+++ b/ops/op2/test_cases/sync/add.out
@@ -1,5 +1,28 @@
#[allow(non_camel_case_types)]
-struct op_add {}
+struct op_add {
+ _unconstructable: ::std::marker::PhantomData<()>,
+}
+impl deno_core::_ops::Op for op_add {
+ const NAME: &'static str = stringify!(op_add);
+ const DECL: deno_core::_ops::OpDecl = deno_core::_ops::OpDecl {
+ name: stringify!(op_add),
+ v8_fn_ptr: Self::v8_fn_ptr as _,
+ enabled: true,
+ fast_fn: Some({
+ use deno_core::v8::fast_api::Type;
+ use deno_core::v8::fast_api::CType;
+ deno_core::v8::fast_api::FastFunction::new(
+ &[Type::V8Value, Type::Uint32, Type::Uint32],
+ CType::Uint32,
+ Self::v8_fn_ptr_fast as *const ::std::ffi::c_void,
+ )
+ }),
+ is_async: false,
+ is_unstable: false,
+ is_v8: false,
+ arg_count: 2usize as u8,
+ };
+}
impl op_add {
pub const fn name() -> &'static str {
stringify!(op_add)
@@ -7,7 +30,7 @@ impl op_add {
pub const fn decl() -> deno_core::_ops::OpDecl {
deno_core::_ops::OpDecl {
name: stringify!(op_add),
- v8_fn_ptr: Self::slow_function as _,
+ v8_fn_ptr: Self::v8_fn_ptr as _,
enabled: true,
fast_fn: Some({
use deno_core::v8::fast_api::Type;
@@ -15,7 +38,7 @@ impl op_add {
deno_core::v8::fast_api::FastFunction::new(
&[Type::V8Value, Type::Uint32, Type::Uint32],
CType::Uint32,
- Self::fast_function as *const ::std::ffi::c_void,
+ Self::v8_fn_ptr_fast as *const ::std::ffi::c_void,
)
}),
is_async: false,
@@ -24,7 +47,15 @@ impl op_add {
arg_count: 2usize as u8,
}
}
- pub extern "C" fn slow_function(info: *const deno_core::v8::FunctionCallbackInfo) {
+ fn v8_fn_ptr_fast(
+ _: deno_core::v8::Local<deno_core::v8::Object>,
+ arg0: u32,
+ arg1: u32,
+ ) -> u32 {
+ let result = Self::call(arg0 as _, arg1 as _);
+ result
+ }
+ extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) {
let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe {
&*info
});
@@ -38,14 +69,6 @@ impl op_add {
let result = Self::call(arg0, arg1);
rv.set_uint32(result as u32);
}
- fn fast_function(
- _: deno_core::v8::Local<deno_core::v8::Object>,
- arg0: u32,
- arg1: u32,
- ) -> u32 {
- let result = Self::call(arg0 as _, arg1 as _);
- result
- }
#[inline(always)]
fn call(a: u32, b: u32) -> u32 {
a + b