summaryrefslogtreecommitdiff
path: root/ops/optimizer_tests/op_blob_revoke_object_url.out
diff options
context:
space:
mode:
authorDivy Srivastava <dj.srivastava23@gmail.com>2022-12-01 21:29:15 -0800
committerGitHub <noreply@github.com>2022-12-02 05:29:15 +0000
commit9b2b8df927ac23cfa99016a684179f2a3198ba2e (patch)
tree1d13b575bc7c4f7279b2ff3fdde175a7522d643a /ops/optimizer_tests/op_blob_revoke_object_url.out
parent075854e5162c3d9f4fd7061d19acbe2c5855536e (diff)
feat(ops): Fast zero copy string arguments (#16777)
Uses SeqOneByteString optimization to do zero-copy `&str` arguments in fast calls. - [x] Depends on https://github.com/denoland/rusty_v8/pull/1129 - [x] Depends on https://chromium-review.googlesource.com/c/v8/v8/+/4036884 - [x] Disable in async ops - [x] Make it work with owned `String` with an extra alloc in fast path. - [x] Support `Cow<'_, str>`. Owned for slow case, Borrowed for fast case ```rust #[op] fn op_string_len(s: &str) -> u32 { str.len() as u32 } ```
Diffstat (limited to 'ops/optimizer_tests/op_blob_revoke_object_url.out')
-rw-r--r--ops/optimizer_tests/op_blob_revoke_object_url.out62
1 files changed, 60 insertions, 2 deletions
diff --git a/ops/optimizer_tests/op_blob_revoke_object_url.out b/ops/optimizer_tests/op_blob_revoke_object_url.out
index 72bc75e05..28fe17acb 100644
--- a/ops/optimizer_tests/op_blob_revoke_object_url.out
+++ b/ops/optimizer_tests/op_blob_revoke_object_url.out
@@ -18,7 +18,11 @@ impl op_blob_revoke_object_url {
name: Self::name(),
v8_fn_ptr: Self::v8_fn_ptr(),
enabled: true,
- fast_fn: None,
+ fast_fn: Some(
+ Box::new(op_blob_revoke_object_url_fast {
+ _phantom: ::std::marker::PhantomData,
+ }),
+ ),
is_async: false,
is_unstable: false,
is_v8: false,
@@ -27,7 +31,7 @@ impl op_blob_revoke_object_url {
}
#[inline]
#[allow(clippy::too_many_arguments)]
- pub fn call(state: &mut deno_core::OpState, url: String) -> Result<(), AnyError> {
+ pub fn call(state: &mut OpState, url: String) -> Result<(), AnyError> {
let url = Url::parse(&url)?;
let blob_store = state.borrow::<BlobStore>();
blob_store.remove_object_url(&url);
@@ -42,6 +46,18 @@ impl op_blob_revoke_object_url {
&*(deno_core::v8::Local::<deno_core::v8::External>::cast(args.data()).value()
as *const deno_core::_ops::OpCtx)
};
+ {
+ let op_state = &mut std::cell::RefCell::borrow_mut(&ctx.state);
+ if let Some(err) = op_state.last_fast_op_error.take() {
+ let exception = deno_core::error::to_v8_error(
+ scope,
+ op_state.get_error_class_fn,
+ &err,
+ );
+ scope.throw_exception(exception);
+ return;
+ }
+ }
let arg_0 = match deno_core::v8::Local::<
deno_core::v8::String,
>::try_from(args.get(0usize as i32)) {
@@ -69,3 +85,45 @@ impl op_blob_revoke_object_url {
};
}
}
+struct op_blob_revoke_object_url_fast {
+ _phantom: ::std::marker::PhantomData<()>,
+}
+impl<'scope> deno_core::v8::fast_api::FastFunction for op_blob_revoke_object_url_fast {
+ fn function(&self) -> *const ::std::ffi::c_void {
+ op_blob_revoke_object_url_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, SeqOneByteString, CallbackOptions]
+ }
+ fn return_type(&self) -> deno_core::v8::fast_api::CType {
+ deno_core::v8::fast_api::CType::Void
+ }
+}
+fn op_blob_revoke_object_url_fast_fn<'scope>(
+ _: deno_core::v8::Local<deno_core::v8::Object>,
+ url: *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 __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 url = unsafe { &*url }.as_str().to_owned();
+ let result = op_blob_revoke_object_url::call(state, url);
+ match result {
+ Ok(result) => result,
+ Err(err) => {
+ state.last_fast_op_error.replace(err);
+ __opts.fallback = true;
+ Default::default()
+ }
+ }
+}