Repository: denoland/deno_core
Pull request #254 (2023-10-03 18:50:38)

feat(ops): allow JsBuffer arguments to be fast
Only supported in sync ops for now. Reduces the need for scope creation for all JsBuffer usage (except in detaching mode).

mmastrac: I can definitely run a bench, but it should be 4-5x faster by my estimates. We save both the slowcall cost and scope cost which are both pretty heavy. 

Patch:
diff --git a/core/runtime/ops.rs b/core/runtime/ops.rs
index 22693ee..a201c14 100644
--- a/core/runtime/ops.rs
+++ b/core/runtime/ops.rs
@@ -569,7 +569,6 @@ pub fn serde_v8_to_rust<'a, T: Deserialize<'a>>(
 
 /// Retrieve a [`serde_v8::V8Slice`] from a typed array in an [`v8::ArrayBufferView`].
 pub fn to_v8_slice<'a, T>(
-  scope: &mut v8::HandleScope,
   input: v8::Local<'a, v8::Value>,
 ) -> Result<serde_v8::V8Slice<T>, &'static str>
 where
@@ -580,14 +579,10 @@ where
   let (store, offset, length) =
     if let Ok(buf) = v8::Local::<T::V8>::try_from(input) {
       let buf: v8::Local<v8::ArrayBufferView> = buf.into();
-      let Some(buffer) = buf.buffer(scope) else {
+      let Some(buffer) = buf.get_backing_store() else {
       return Err("buffer missing");
     };
-      (
-        buffer.get_backing_store(),
-        buf.byte_offset(),
-        buf.byte_length(),
-      )
+      (buffer, buf.byte_offset(), buf.byte_length())
     } else {
       return Err("expected typed ArrayBufferView");
     };
@@ -719,20 +714,16 @@ pub fn to_v8_slice_buffer_detachable(
 
 /// Retrieve a [`serde_v8::V8Slice`] from a [`v8::ArrayBuffer`].
 pub fn to_v8_slice_any(
-  scope: &mut v8::HandleScope,
   input: v8::Local<v8::Value>,
 ) -> Result<serde_v8::V8Slice<u8>, &'static str> {
   if let Ok(buf) = v8::Local::<v8::ArrayBufferView>::try_from(input) {
     let offset = buf.byte_offset();
     let len = buf.byte_length();
-    let Some(buf) = buf.buffer(scope) else {
+    let Some(buf) = buf.get_backing_store() else {
       return Err("buffer missing");
     };
     return Ok(unsafe {
-      serde_v8::V8Slice::<u8>::from_parts(
-        buf.get_backing_store(),
-        offset..offset + len,
-      )
+      serde_v8::V8Slice::<u8>::from_parts(buf, offset..offset + len)
     });
   }
   if let Ok(buf) = to_v8_slice_buffer(input) {
@@ -1795,7 +1786,7 @@ mod tests {
     Ok(())
   }
 
-  #[op2(core)]
+  #[op2(core, fast)]
   pub fn op_buffer_jsbuffer(
     #[buffer] input: JsBuffer,
     #[number] inlen: usize,
diff --git a/ops/op2/README.md b/ops/op2/README.md
index 0d0dd91..774981a 100644
--- a/ops/op2/README.md
+++ b/ops/op2/README.md
@@ -849,9 +849,9 @@ Safe, but forces a copy.
 ```
 
 </td><td>
-
+✅
 </td><td>
-ArrayBuffer, ArrayBufferView (resizable=false)
+ArrayBufferView (resizable=false)
 </td><td>
 ⚠️ JS may modify the contents of slices obtained from buffer.
 </td></tr>
@@ -865,7 +865,7 @@ ArrayBuffer, ArrayBufferView (resizable=false)
 </td><td>
 
 </td><td>
-ArrayBuffer, ArrayBufferView (resizable=true,false)
+ArrayBufferView (resizable=true,false)
 </td><td>
 Safe.
 </td></tr>
diff --git a/ops/op2/dispatch_fast.rs b/ops/op2/dispatch_fast.rs
index 84ad64d..484350c 100644
--- a/ops/op2/dispatch_fast.rs
+++ b/ops/op2/dispatch_fast.rs
@@ -400,6 +400,22 @@ fn map_v8_fastcall_arg_to_arg(
         #buf
       )
     }
+    Arg::Buffer(
+      buffer @ (BufferType::V8Slice(..) | BufferType::JsBuffer),
+      _,
+      BufferSource::TypedArray,
+    ) => {
+      *needs_fast_api_callback_options = true;
+      let buf = v8slice_to_buffer(deno_core, arg_ident, &arg_temp, *buffer)?;
+      quote!(
+        let Ok(mut #arg_temp) = #deno_core::_ops::to_v8_slice(#arg_ident.into()) else {
+          #fast_api_callback_options.fallback = true;
+          // SAFETY: All fast return types have zero as a valid value
+          return unsafe { std::mem::zeroed() };
+        };
+        #buf
+      )
+    }
     Arg::Buffer(buffer, _, BufferSource::ArrayBuffer) => {
       *needs_fast_api_callback_options = true;
       let buf = byte_slice_to_buffer(arg_ident, &arg_temp, *buffer)?;
@@ -549,7 +565,7 @@ fn map_arg_to_v8_fastcall_type(
       BufferType::JsBuffer | BufferType::V8Slice(..),
       _,
       BufferSource::TypedArray,
-    ) => return Ok(None),
+    ) => V8FastCallType::V8Value,
     Arg::Buffer(
       BufferType::Slice(.., NumericArg::u8)
       | BufferType::Ptr(.., NumericArg::u8),
diff --git a/ops/op2/dispatch_slow.rs b/ops/op2/dispatch_slow.rs
index 06cad07..6010558 100644
--- a/ops/op2/dispatch_slow.rs
+++ b/ops/op2/dispatch_slow.rs
@@ -561,22 +561,22 @@ pub fn from_arg_buffer(
   let throw_exception = throw_type_error_static_string(generator_state, &err)?;
 
   let array = buffer_type.element();
-  generator_state.needs_scope = true;
 
   let to_v8_slice = if matches!(buffer_mode, BufferMode::Detach) {
-    quote!(to_v8_slice_detachable)
+    generator_state.needs_scope = true;
+    gs_quote!(generator_state(deno_core, scope) => { #deno_core::_ops::to_v8_slice_detachable::<#array>(&mut #scope, #arg_ident) })
   } else {
-    quote!(to_v8_slice)
+    gs_quote!(generator_state(deno_core) => { #deno_core::_ops::to_v8_slice::<#array>(#arg_ident) })
   };
 
-  let make_v8slice = gs_quote!(generator_state(deno_core, scope) => {
-    #temp = match unsafe { #deno_core::_ops::#to_v8_slice::<#array>(&mut #scope, #arg_ident) } {
+  let make_v8slice = quote!(
+    #temp = match unsafe { #to_v8_slice } {
       Ok(#arg_ident) => #arg_ident,
       Err(#err) => {
         #throw_exception
       }
     };
-  });
+  );
 
   let make_arg = v8slice_to_buffer(
     &generator_state.deno_core,
@@ -645,11 +645,8 @@ pub fn from_arg_any_buffer(
     quote!(to_v8_slice_any)
   };
 
-  // TODO(mmastrac): upstream change required to avoid scope
-  generator_state.needs_scope = true;
-
-  let make_v8slice = gs_quote!(generator_state(deno_core, scope) => {
-    #temp = match unsafe { #deno_core::_ops::#to_v8_slice(&mut #scope, #arg_ident) } {
+  let make_v8slice = gs_quote!(generator_state(deno_core) => {
+    #temp = match unsafe { #deno_core::_ops::#to_v8_slice(#arg_ident) } {
       Ok(#arg_ident) => #arg_ident,
       Err(#err) => {
         #throw_exception
diff --git a/ops/op2/valid_args.md b/ops/op2/valid_args.md
index 21796b6..bd49ac3 100644
--- a/ops/op2/valid_args.md
+++ b/ops/op2/valid_args.md
@@ -48,13 +48,13 @@
 | X         | #[buffer] &[u32]                  | X        | UInt32Array (resizable=true,false)                  | ⚠️ JS may modify the contents of the slice if V8 is called re-entrantly.                                                                                                                                        |
 | X         | #[buffer(copy)] Vec<u32>          | X        | UInt32Array (resizable=true,false)                  | Safe, but forces a copy.                                                                                                                                                                                       |
 | X         | #[buffer(copy)] Box<[u32]>        | X        | UInt32Array (resizable=true,false)                  | Safe, but forces a copy.                                                                                                                                                                                       |
-|           | #[buffer] V8Slice                 | X        | ArrayBuffer, ArrayBufferView (resizable=false)      | ⚠️ JS may modify the contents of slices obtained from buffer.                                                                                                                                                   |
-|           | #[buffer(detach)] V8Slice         | X        | ArrayBuffer, ArrayBufferView (resizable=true,false) | Safe.                                                                                                                                                                                                          |
-|           | #[buffer] V8ResizableSlice        | X        | ArrayBuffer, ArrayBufferView (resizable=true)       | ⚠️ JS may modify the contents of slices obtained from buffer.                                                                                                                                                   |
-| X         | #[buffer] JsBuffer                |          | ArrayBuffer, ArrayBufferView (resizable=false)      | ⚠️ JS may modify the contents of slices obtained from buffer.                                                                                                                                                   |
-| X         | #[buffer(detach)] JsBuffer        |          | ArrayBuffer, ArrayBufferView (resizable=true,false) | Safe.                                                                                                                                                                                                          |
-|           | #[buffer(unsafe)] bytes::Bytes    | X        | ArrayBuffer, ArrayBufferView (resizable=false)      | ⚠️ JS may modify the contents of the buffer.                                                                                                                                                                    |
-|           | #[buffer(detach)] bytes::Bytes    | X        | ArrayBuffer, ArrayBufferView (resizable=true,false) | Safe.                                                                                                                                                                                                          |
+|           | #[buffer] V8Slice                 | X        | ArrayBufferView (resizable=false)                   | ⚠️ JS may modify the contents of slices obtained from buffer.                                                                                                                                                   |
+|           | #[buffer(detach)] V8Slice         | X        | ArrayBufferView (resizable=true,false)              | Safe.                                                                                                                                                                                                          |
+|           | #[buffer] V8ResizableSlice        | X        | ArrayBufferView (resizable=true)                    | ⚠️ JS may modify the contents of slices obtained from buffer.                                                                                                                                                   |
+| X         | #[buffer] JsBuffer                | X        | ArrayBufferView (resizable=false)                   | ⚠️ JS may modify the contents of slices obtained from buffer.                                                                                                                                                   |
+| X         | #[buffer(detach)] JsBuffer        |          | ArrayBufferView (resizable=true,false)              | Safe.                                                                                                                                                                                                          |
+|           | #[buffer(unsafe)] bytes::Bytes    | X        | ArrayBufferView (resizable=false)                   | ⚠️ JS may modify the contents of the buffer.                                                                                                                                                                    |
+|           | #[buffer(detach)] bytes::Bytes    | X        | ArrayBufferView (resizable=true,false)              | Safe.                                                                                                                                                                                                          |
 | X         | *const std::ffi::c_void           | X        | External                                            |                                                                                                                                                                                                                |
 | X         | *mut std::ffi::c_void             | X        | External                                            |                                                                                                                                                                                                                |
 | X         | &OpState                          | X        |                                                     |                                                                                                                                                                                                                |


Test patch:
diff --git a/ops/op2/test_cases/async/async_jsbuffer.out b/ops/op2/test_cases/async/async_jsbuffer.out
index 26ce082..ec5e32c 100644
--- a/ops/op2/test_cases/async/async_jsbuffer.out
+++ b/ops/op2/test_cases/async/async_jsbuffer.out
@@ -43,9 +43,7 @@ impl op_async_v8_buffer {
         let result = {
             let arg0 = args.get(1usize as i32);
             let mut arg0_temp;
-            arg0_temp = match unsafe {
-                deno_core::_ops::to_v8_slice::<u8>(&mut scope, arg0)
-            } {
+            arg0_temp = match unsafe { deno_core::_ops::to_v8_slice::<u8>(arg0) } {
                 Ok(arg0) => arg0,
                 Err(arg0_err) => {
                     let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) };
diff --git a/ops/op2/test_cases/sync/buffers.out b/ops/op2/test_cases/sync/buffers.out
index cae5419..97552f1 100644
--- a/ops/op2/test_cases/sync/buffers.out
+++ b/ops/op2/test_cases/sync/buffers.out
@@ -128,7 +128,6 @@ impl op_buffers {
         result as _
     }
     extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) {
-        let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) };
         let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe {
             &*info
         });
@@ -138,9 +137,7 @@ impl op_buffers {
         let result = {
             let arg0 = args.get(0usize as i32);
             let mut arg0_temp;
-            arg0_temp = match unsafe {
-                deno_core::_ops::to_v8_slice::<u8>(&mut scope, arg0)
-            } {
+            arg0_temp = match unsafe { deno_core::_ops::to_v8_slice::<u8>(arg0) } {
                 Ok(arg0) => arg0,
                 Err(arg0_err) => {
                     let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) };
@@ -158,11 +155,10 @@ impl op_buffers {
             let arg0 = arg0_temp.as_ref();
             let arg1 = args.get(1usize as i32);
             let mut arg1_temp;
-            arg1_temp = match unsafe {
-                deno_core::_ops::to_v8_slice::<u8>(&mut scope, arg1)
-            } {
+            arg1_temp = match unsafe { deno_core::_ops::to_v8_slice::<u8>(arg1) } {
                 Ok(arg1) => arg1,
                 Err(arg1_err) => {
+                    let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) };
                     let msg = deno_core::v8::String::new_from_one_byte(
                             &mut scope,
                             arg1_err.as_bytes(),
@@ -177,11 +173,10 @@ impl op_buffers {
             let arg1 = arg1_temp.as_mut();
             let arg2 = args.get(2usize as i32);
             let mut arg2_temp;
-            arg2_temp = match unsafe {
-                deno_core::_ops::to_v8_slice::<u8>(&mut scope, arg2)
-            } {
+            arg2_temp = match unsafe { deno_core::_ops::to_v8_slice::<u8>(arg2) } {
                 Ok(arg2) => arg2,
                 Err(arg2_err) => {
+                    let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) };
                     let msg = deno_core::v8::String::new_from_one_byte(
                             &mut scope,
                             arg2_err.as_bytes(),
@@ -200,11 +195,10 @@ impl op_buffers {
             };
             let arg3 = args.get(3usize as i32);
             let mut arg3_temp;
-            arg3_temp = match unsafe {
-                deno_core::_ops::to_v8_slice::<u8>(&mut scope, arg3)
-            } {
+            arg3_temp = match unsafe { deno_core::_ops::to_v8_slice::<u8>(arg3) } {
                 Ok(arg3) => arg3,
                 Err(arg3_err) => {
+                    let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) };
                     let msg = deno_core::v8::String::new_from_one_byte(
                             &mut scope,
                             arg3_err.as_bytes(),
@@ -377,7 +371,6 @@ impl op_buffers_32 {
         result as _
     }
     extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) {
-        let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) };
         let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe {
             &*info
         });
@@ -387,9 +380,7 @@ impl op_buffers_32 {
         let result = {
             let arg0 = args.get(0usize as i32);
             let mut arg0_temp;
-            arg0_temp = match unsafe {
-                deno_core::_ops::to_v8_slice::<u32>(&mut scope, arg0)
-            } {
+            arg0_temp = match unsafe { deno_core::_ops::to_v8_slice::<u32>(arg0) } {
                 Ok(arg0) => arg0,
                 Err(arg0_err) => {
                     let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) };
@@ -407,11 +398,10 @@ impl op_buffers_32 {
             let arg0 = arg0_temp.as_ref();
             let arg1 = args.get(1usize as i32);
             let mut arg1_temp;
-            arg1_temp = match unsafe {
-                deno_core::_ops::to_v8_slice::<u32>(&mut scope, arg1)
-            } {
+            arg1_temp = match unsafe { deno_core::_ops::to_v8_slice::<u32>(arg1) } {
                 Ok(arg1) => arg1,
                 Err(arg1_err) => {
+                    let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) };
                     let msg = deno_core::v8::String::new_from_one_byte(
                             &mut scope,
                             arg1_err.as_bytes(),
@@ -426,11 +416,10 @@ impl op_buffers_32 {
             let arg1 = arg1_temp.as_mut();
             let arg2 = args.get(2usize as i32);
             let mut arg2_temp;
-            arg2_temp = match unsafe {
-                deno_core::_ops::to_v8_slice::<u32>(&mut scope, arg2)
-            } {
+            arg2_temp = match unsafe { deno_core::_ops::to_v8_slice::<u32>(arg2) } {
                 Ok(arg2) => arg2,
                 Err(arg2_err) => {
+                    let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) };
                     let msg = deno_core::v8::String::new_from_one_byte(
                             &mut scope,
                             arg2_err.as_bytes(),
@@ -449,11 +438,10 @@ impl op_buffers_32 {
             };
             let arg3 = args.get(3usize as i32);
             let mut arg3_temp;
-            arg3_temp = match unsafe {
-                deno_core::_ops::to_v8_slice::<u32>(&mut scope, arg3)
-            } {
+            arg3_temp = match unsafe { deno_core::_ops::to_v8_slice::<u32>(arg3) } {
                 Ok(arg3) => arg3,
                 Err(arg3_err) => {
+                    let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) };
                     let msg = deno_core::v8::String::new_from_one_byte(
                             &mut scope,
                             arg3_err.as_bytes(),
@@ -521,7 +509,6 @@ impl op_buffers_option {
         <Self as deno_core::_ops::Op>::DECL
     }
     extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) {
-        let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) };
         let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe {
             &*info
         });
@@ -534,9 +521,7 @@ impl op_buffers_option {
             let arg0 = if arg0.is_null_or_undefined() {
                 None
             } else {
-                arg0_temp = match unsafe {
-                    deno_core::_ops::to_v8_slice::<u8>(&mut scope, arg0)
-                } {
+                arg0_temp = match unsafe { deno_core::_ops::to_v8_slice::<u8>(arg0) } {
                     Ok(arg0) => arg0,
                     Err(arg0_err) => {
                         let mut scope = unsafe {
@@ -561,11 +546,12 @@ impl op_buffers_option {
             let arg1 = if arg1.is_null_or_undefined() {
                 None
             } else {
-                arg1_temp = match unsafe {
-                    deno_core::_ops::to_v8_slice::<u8>(&mut scope, arg1)
-                } {
+                arg1_temp = match unsafe { deno_core::_ops::to_v8_slice::<u8>(arg1) } {
                     Ok(arg1) => arg1,
                     Err(arg1_err) => {
+                        let mut scope = unsafe {
+                            deno_core::v8::CallbackScope::new(&*info)
+                        };
                         let msg = deno_core::v8::String::new_from_one_byte(
                                 &mut scope,
                                 arg1_err.as_bytes(),
diff --git a/ops/op2/test_cases/sync/buffers_copy.out b/ops/op2/test_cases/sync/buffers_copy.out
index d6bec48..3de1b02 100644
--- a/ops/op2/test_cases/sync/buffers_copy.out
+++ b/ops/op2/test_cases/sync/buffers_copy.out
@@ -109,7 +109,6 @@ impl op_buffers {
         result as _
     }
     extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) {
-        let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) };
         let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe {
             &*info
         });
@@ -119,9 +118,7 @@ impl op_buffers {
         let result = {
             let arg0 = args.get(0usize as i32);
             let mut arg0_temp;
-            arg0_temp = match unsafe {
-                deno_core::_ops::to_v8_slice::<u8>(&mut scope, arg0)
-            } {
+            arg0_temp = match unsafe { deno_core::_ops::to_v8_slice::<u8>(arg0) } {
                 Ok(arg0) => arg0,
                 Err(arg0_err) => {
                     let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) };
@@ -139,11 +136,10 @@ impl op_buffers {
             let arg0 = arg0_temp.to_vec();
             let arg1 = args.get(1usize as i32);
             let mut arg1_temp;
-            arg1_temp = match unsafe {
-                deno_core::_ops::to_v8_slice::<u8>(&mut scope, arg1)
-            } {
+            arg1_temp = match unsafe { deno_core::_ops::to_v8_slice::<u8>(arg1) } {
                 Ok(arg1) => arg1,
                 Err(arg1_err) => {
+                    let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) };
                     let msg = deno_core::v8::String::new_from_one_byte(
                             &mut scope,
                             arg1_err.as_bytes(),
@@ -158,11 +154,10 @@ impl op_buffers {
             let arg1 = arg1_temp.to_boxed_slice();
             let arg2 = args.get(2usize as i32);
             let mut arg2_temp;
-            arg2_temp = match unsafe {
-                deno_core::_ops::to_v8_slice::<u8>(&mut scope, arg2)
-            } {
+            arg2_temp = match unsafe { deno_core::_ops::to_v8_slice::<u8>(arg2) } {
                 Ok(arg2) => arg2,
                 Err(arg2_err) => {
+                    let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) };
                     let msg = deno_core::v8::String::new_from_one_byte(
                             &mut scope,
                             arg2_err.as_bytes(),
@@ -301,7 +296,6 @@ impl op_buffers_32 {
         result as _
     }
     extern "C" fn v8_fn_ptr(info: *const deno_core::v8::FunctionCallbackInfo) {
-        let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) };
         let mut rv = deno_core::v8::ReturnValue::from_function_callback_info(unsafe {
             &*info
         });
@@ -311,9 +305,7 @@ impl op_buffers_32 {
         let result = {
             let arg0 = args.get(0usize as i32);
             let mut arg0_temp;
-            arg0_temp = match unsafe {
-                deno_core::_ops::to_v8_slice::<u32>(&mut scope, arg0)
-            } {
+            arg0_temp = match unsafe { deno_core::_ops::to_v8_slice::<u32>(arg0) } {
                 Ok(arg0) => arg0,
                 Err(arg0_err) => {
                     let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) };
@@ -331,11 +323,10 @@ impl op_buffers_32 {
             let arg0 = arg0_temp.to_vec();
             let arg1 = args.get(1usize as i32);
             let mut arg1_temp;
-            arg1_temp = match unsafe {
-                deno_core::_ops::to_v8_slice::<u32>(&mut scope, arg1)
-            } {
+            arg1_temp = match unsafe { deno_core::_ops::to_v8_slice::<u32>(arg1) } {
                 Ok(arg1) => arg1,
                 Err(arg1_err) => {
+                    let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) };
                     let msg = deno_core::v8::String::new_from_one_byte(
                             &mut scope,
                             arg1_err.as_bytes(),
diff --git a/ops/op2/test_cases/sync/buffers_out.out b/ops/op2/test_cases/sync/buffers_out.out
index 9c32a2e..6147fce 100644
--- a/ops/op2/test_cases/sync/buffers_out.out
+++ b/ops/op2/test_cases/sync/buffers_out.out
@@ -33,9 +33,7 @@ impl op_buffers {
         let result = {
             let arg0 = args.get(0usize as i32);
             let mut arg0_temp;
-            arg0_temp = match unsafe {
-                deno_core::_ops::to_v8_slice::<u8>(&mut scope, arg0)
-            } {
+            arg0_temp = match unsafe { deno_core::_ops::to_v8_slice::<u8>(arg0) } {
                 Ok(arg0) => arg0,
                 Err(arg0_err) => {
                     let mut scope = unsafe { deno_core::v8::CallbackScope::new(&*info) };
@@ -129,9 +127,7 @@ impl op_buffers_option {
             let arg0 = if arg0.is_null_or_undefined() {
                 None
             } else {
-                arg0_temp = match unsafe {
-                    deno_core::_ops::to_v8_slice::<u8>(&mut scope, arg0)
-                } {
+                arg0_temp = match unsafe { deno_core::_ops::to_v8_slice::<u8>(arg0) } {
                     Ok(arg0) => arg0,
                     Err(arg0_err) => {
                         let mut scope = unsafe {