From 8fe9b8a4cc381f9b94ce2caf10c61ddff864bdb4 Mon Sep 17 00:00:00 2001 From: Matt Mastracci Date: Sun, 25 Jun 2023 16:36:09 +0200 Subject: refactor(ops): ops2 supports result in fast path (#19603) Implements `Result` in fast-calls. Note that the approach here is slightly different. Rather than store the last result in the `OpState`, we put it into the `OpCtx` which saves us a lookup and lock in the error case. We do not have to lock this field as it's guaranteed only one runtime and thread can ever access it. The fastcall path for many ops can avoid doing a great deal of work, even for `Result` return values. In the previous iteration of `ops`, all `Result`-returning functions would fetch and lock the `OpState`, regardless of whether it was used or not. --- ops/op2/test_cases/sync/doc_comment.out | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'ops/op2/test_cases/sync/doc_comment.out') diff --git a/ops/op2/test_cases/sync/doc_comment.out b/ops/op2/test_cases/sync/doc_comment.out index bd0d0b21f..e9f063102 100644 --- a/ops/op2/test_cases/sync/doc_comment.out +++ b/ops/op2/test_cases/sync/doc_comment.out @@ -13,7 +13,7 @@ impl op_has_doc_comment { use deno_core::v8::fast_api::Type; use deno_core::v8::fast_api::CType; deno_core::v8::fast_api::FastFunction::new( - &[], + &[Type::V8Value], CType::Void, Self::fast_function as *const ::std::ffi::c_void, ) @@ -28,7 +28,8 @@ impl op_has_doc_comment { let result = Self::call(); } fn fast_function(_: deno_core::v8::Local) -> () { - Self::call() + let result = Self::call(); + result } #[inline(always)] pub fn call() -> () {} -- cgit v1.2.3