summaryrefslogtreecommitdiff
path: root/ops/optimizer_tests
diff options
context:
space:
mode:
Diffstat (limited to 'ops/optimizer_tests')
-rw-r--r--ops/optimizer_tests/async_nop.expected10
-rw-r--r--ops/optimizer_tests/async_nop.out44
-rw-r--r--ops/optimizer_tests/async_nop.rs3
-rw-r--r--ops/optimizer_tests/async_result.expected10
-rw-r--r--ops/optimizer_tests/async_result.out53
-rw-r--r--ops/optimizer_tests/async_result.rs7
-rw-r--r--ops/optimizer_tests/callback_options.expected2
-rw-r--r--ops/optimizer_tests/op_state.expected2
-rw-r--r--ops/optimizer_tests/op_state_basic1.expected2
-rw-r--r--ops/optimizer_tests/op_state_generics.expected2
-rw-r--r--ops/optimizer_tests/op_state_result.expected2
-rw-r--r--ops/optimizer_tests/op_state_warning.expected10
-rw-r--r--ops/optimizer_tests/op_state_warning.out40
-rw-r--r--ops/optimizer_tests/op_state_warning.rs9
-rw-r--r--ops/optimizer_tests/op_state_with_transforms.expected2
-rw-r--r--ops/optimizer_tests/opstate_with_arity.expected2
-rw-r--r--ops/optimizer_tests/serde_v8_value.expected2
17 files changed, 202 insertions, 0 deletions
diff --git a/ops/optimizer_tests/async_nop.expected b/ops/optimizer_tests/async_nop.expected
new file mode 100644
index 000000000..78c161e8c
--- /dev/null
+++ b/ops/optimizer_tests/async_nop.expected
@@ -0,0 +1,10 @@
+=== Optimizer Dump ===
+returns_result: false
+has_ref_opstate: false
+has_rc_opstate: false
+has_fast_callback_option: false
+fast_result: Some(Void)
+fast_parameters: [V8Value, I32]
+transforms: {}
+is_async: true
+fast_compatible: true
diff --git a/ops/optimizer_tests/async_nop.out b/ops/optimizer_tests/async_nop.out
new file mode 100644
index 000000000..901b8a225
--- /dev/null
+++ b/ops/optimizer_tests/async_nop.out
@@ -0,0 +1,44 @@
+struct op_void_async_fast {
+ _phantom: ::std::marker::PhantomData<()>,
+}
+impl<'scope> deno_core::v8::fast_api::FastFunction for op_void_async_fast {
+ fn function(&self) -> *const ::std::ffi::c_void {
+ op_void_async_fast_fn as *const ::std::ffi::c_void
+ }
+ fn args(&self) -> &'static [deno_core::v8::fast_api::Type] {
+ use deno_core::v8::fast_api::Type::*;
+ use deno_core::v8::fast_api::CType;
+ &[V8Value, Int32, CallbackOptions]
+ }
+ fn return_type(&self) -> deno_core::v8::fast_api::CType {
+ deno_core::v8::fast_api::CType::Void
+ }
+}
+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 __op_id = __ctx.id;
+ let __state = ::std::cell::RefCell::borrow(&__ctx.state);
+ __state.tracker.track_async(__op_id);
+ let result = _ops::queue_fast_async_op(
+ __ctx,
+ async move {
+ let result = result.await;
+ (__promise_id, __op_id, _ops::OpResult::Ok(result.into()))
+ },
+ );
+ result
+}
diff --git a/ops/optimizer_tests/async_nop.rs b/ops/optimizer_tests/async_nop.rs
new file mode 100644
index 000000000..95a1522f1
--- /dev/null
+++ b/ops/optimizer_tests/async_nop.rs
@@ -0,0 +1,3 @@
+async fn op_void_async() {
+ // @test-attr:fast
+}
diff --git a/ops/optimizer_tests/async_result.expected b/ops/optimizer_tests/async_result.expected
new file mode 100644
index 000000000..dcd9cd1e3
--- /dev/null
+++ b/ops/optimizer_tests/async_result.expected
@@ -0,0 +1,10 @@
+=== Optimizer Dump ===
+returns_result: true
+has_ref_opstate: false
+has_rc_opstate: true
+has_fast_callback_option: true
+fast_result: None
+fast_parameters: [V8Value, I32, U32, Uint8Array]
+transforms: {2: Transform { kind: SliceU8(true), index: 2 }}
+is_async: true
+fast_compatible: true
diff --git a/ops/optimizer_tests/async_result.out b/ops/optimizer_tests/async_result.out
new file mode 100644
index 000000000..d312fde73
--- /dev/null
+++ b/ops/optimizer_tests/async_result.out
@@ -0,0 +1,53 @@
+struct op_read_fast {
+ _phantom: ::std::marker::PhantomData<()>,
+}
+impl<'scope> deno_core::v8::fast_api::FastFunction for op_read_fast {
+ fn function(&self) -> *const ::std::ffi::c_void {
+ op_read_fast_fn as *const ::std::ffi::c_void
+ }
+ fn args(&self) -> &'static [deno_core::v8::fast_api::Type] {
+ use deno_core::v8::fast_api::Type::*;
+ use deno_core::v8::fast_api::CType;
+ &[V8Value, Int32, Uint32, TypedArray(CType::Uint8), CallbackOptions]
+ }
+ fn return_type(&self) -> deno_core::v8::fast_api::CType {
+ deno_core::v8::fast_api::CType::Void
+ }
+}
+fn op_read_fast_fn<'scope>(
+ _: deno_core::v8::Local<deno_core::v8::Object>,
+ __promise_id: i32,
+ rid: ResourceId,
+ 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 = __ctx.state.clone();
+ let buf = match unsafe { &*buf }.get_storage_if_aligned() {
+ Some(v) => v,
+ None => {
+ unsafe { &mut *fast_api_callback_options }.fallback = true;
+ return Default::default();
+ }
+ };
+ let result = op_read::call(state, rid, buf);
+ let __op_id = __ctx.id;
+ let __state = ::std::cell::RefCell::borrow(&__ctx.state);
+ __state.tracker.track_async(__op_id);
+ let __get_class = __state.get_error_class_fn;
+ let result = _ops::queue_fast_async_op(
+ __ctx,
+ async move {
+ let result = result.await;
+ (__promise_id, __op_id, _ops::to_op_result(__get_class, result))
+ },
+ );
+}
diff --git a/ops/optimizer_tests/async_result.rs b/ops/optimizer_tests/async_result.rs
new file mode 100644
index 000000000..c1602ec49
--- /dev/null
+++ b/ops/optimizer_tests/async_result.rs
@@ -0,0 +1,7 @@
+async fn op_read(
+ state: Rc<RefCell<OpState>>,
+ rid: ResourceId,
+ buf: &mut [u8],
+) -> Result<u32, Error> {
+ // @test-attr:fast
+}
diff --git a/ops/optimizer_tests/callback_options.expected b/ops/optimizer_tests/callback_options.expected
index 063032bb5..b309ab987 100644
--- a/ops/optimizer_tests/callback_options.expected
+++ b/ops/optimizer_tests/callback_options.expected
@@ -6,3 +6,5 @@ has_fast_callback_option: false
fast_result: Some(Void)
fast_parameters: [V8Value]
transforms: {}
+is_async: false
+fast_compatible: true
diff --git a/ops/optimizer_tests/op_state.expected b/ops/optimizer_tests/op_state.expected
index f23bf764a..d8d680455 100644
--- a/ops/optimizer_tests/op_state.expected
+++ b/ops/optimizer_tests/op_state.expected
@@ -6,3 +6,5 @@ has_fast_callback_option: false
fast_result: Some(Void)
fast_parameters: [V8Value, I32]
transforms: {}
+is_async: false
+fast_compatible: true
diff --git a/ops/optimizer_tests/op_state_basic1.expected b/ops/optimizer_tests/op_state_basic1.expected
index 3639959b8..6e7b15493 100644
--- a/ops/optimizer_tests/op_state_basic1.expected
+++ b/ops/optimizer_tests/op_state_basic1.expected
@@ -6,3 +6,5 @@ has_fast_callback_option: false
fast_result: Some(U32)
fast_parameters: [V8Value, U32, U32]
transforms: {}
+is_async: false
+fast_compatible: true
diff --git a/ops/optimizer_tests/op_state_generics.expected b/ops/optimizer_tests/op_state_generics.expected
index 83e938502..b78c81c5f 100644
--- a/ops/optimizer_tests/op_state_generics.expected
+++ b/ops/optimizer_tests/op_state_generics.expected
@@ -6,3 +6,5 @@ has_fast_callback_option: false
fast_result: Some(Void)
fast_parameters: [V8Value]
transforms: {}
+is_async: false
+fast_compatible: true
diff --git a/ops/optimizer_tests/op_state_result.expected b/ops/optimizer_tests/op_state_result.expected
index 16e71c38c..e13390052 100644
--- a/ops/optimizer_tests/op_state_result.expected
+++ b/ops/optimizer_tests/op_state_result.expected
@@ -6,3 +6,5 @@ has_fast_callback_option: false
fast_result: Some(U32)
fast_parameters: [V8Value, U32, U32]
transforms: {}
+is_async: false
+fast_compatible: true
diff --git a/ops/optimizer_tests/op_state_warning.expected b/ops/optimizer_tests/op_state_warning.expected
new file mode 100644
index 000000000..94580fd6d
--- /dev/null
+++ b/ops/optimizer_tests/op_state_warning.expected
@@ -0,0 +1,10 @@
+=== Optimizer Dump ===
+returns_result: true
+has_ref_opstate: true
+has_rc_opstate: false
+has_fast_callback_option: false
+fast_result: Some(U32)
+fast_parameters: [V8Value]
+transforms: {}
+is_async: false
+fast_compatible: true
diff --git a/ops/optimizer_tests/op_state_warning.out b/ops/optimizer_tests/op_state_warning.out
new file mode 100644
index 000000000..2c40b0f71
--- /dev/null
+++ b/ops/optimizer_tests/op_state_warning.out
@@ -0,0 +1,40 @@
+struct op_listen_fast {
+ _phantom: ::std::marker::PhantomData<()>,
+}
+impl<'scope> deno_core::v8::fast_api::FastFunction for op_listen_fast {
+ fn function(&self) -> *const ::std::ffi::c_void {
+ op_listen_fast_fn as *const ::std::ffi::c_void
+ }
+ fn args(&self) -> &'static [deno_core::v8::fast_api::Type] {
+ use deno_core::v8::fast_api::Type::*;
+ use deno_core::v8::fast_api::CType;
+ &[V8Value, CallbackOptions]
+ }
+ fn return_type(&self) -> deno_core::v8::fast_api::CType {
+ deno_core::v8::fast_api::CType::Uint32
+ }
+}
+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()
+ }
+ }
+}
diff --git a/ops/optimizer_tests/op_state_warning.rs b/ops/optimizer_tests/op_state_warning.rs
new file mode 100644
index 000000000..a725e6f7e
--- /dev/null
+++ b/ops/optimizer_tests/op_state_warning.rs
@@ -0,0 +1,9 @@
+fn op_listen(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)?;
+ std_listener.set_nonblocking(true)?;
+ let listener = TcpListener::try_from(std_listener)?;
+ let rid = state.resource_table.add(listener);
+ Ok(rid)
+}
diff --git a/ops/optimizer_tests/op_state_with_transforms.expected b/ops/optimizer_tests/op_state_with_transforms.expected
index 388d396f5..0fc9c9949 100644
--- a/ops/optimizer_tests/op_state_with_transforms.expected
+++ b/ops/optimizer_tests/op_state_with_transforms.expected
@@ -6,3 +6,5 @@ has_fast_callback_option: true
fast_result: Some(Void)
fast_parameters: [V8Value, Uint8Array]
transforms: {1: Transform { kind: SliceU8(true), index: 1 }}
+is_async: false
+fast_compatible: true
diff --git a/ops/optimizer_tests/opstate_with_arity.expected b/ops/optimizer_tests/opstate_with_arity.expected
index 6259f3e28..4be888c33 100644
--- a/ops/optimizer_tests/opstate_with_arity.expected
+++ b/ops/optimizer_tests/opstate_with_arity.expected
@@ -6,3 +6,5 @@ has_fast_callback_option: false
fast_result: Some(U32)
fast_parameters: [V8Value, U32, U32, U32, U32]
transforms: {}
+is_async: false
+fast_compatible: true
diff --git a/ops/optimizer_tests/serde_v8_value.expected b/ops/optimizer_tests/serde_v8_value.expected
index 5acd38655..058b17b1c 100644
--- a/ops/optimizer_tests/serde_v8_value.expected
+++ b/ops/optimizer_tests/serde_v8_value.expected
@@ -6,3 +6,5 @@ has_fast_callback_option: false
fast_result: Some(Bool)
fast_parameters: [V8Value, V8Value]
transforms: {0: Transform { kind: V8Value, index: 0 }}
+is_async: false
+fast_compatible: true