From ca66978a5aadddf7895b49b44076c574e7e6a0b0 Mon Sep 17 00:00:00 2001 From: Divy Srivastava Date: Sun, 27 Nov 2022 05:54:28 -0800 Subject: feat(ops): fast calls for Wasm (#16776) This PR introduces Wasm ops. These calls are optimized for entry from Wasm land. The `#[op(wasm)]` attribute is opt-in. Last parameter `Option<&mut [u8]>` is the memory slice of the Wasm module *when entered from a Fast API call*. Otherwise, the user is expected to implement logic to obtain the memory if `None` ```rust #[op(wasm)] pub fn op_args_get( offset: i32, buffer_offset: i32, memory: Option<&mut [u8]>, ) { // ... } ``` --- ops/fast_call.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'ops/fast_call.rs') diff --git a/ops/fast_call.rs b/ops/fast_call.rs index 07bf87026..f2ed8cb2d 100644 --- a/ops/fast_call.rs +++ b/ops/fast_call.rs @@ -139,6 +139,7 @@ pub(crate) fn generate( // Apply *hard* optimizer hints. if optimizer.has_fast_callback_option + || optimizer.has_wasm_memory || optimizer.needs_opstate() || optimizer.is_async || optimizer.needs_fast_callback_option @@ -147,7 +148,7 @@ pub(crate) fn generate( fast_api_callback_options: *mut #core::v8::fast_api::FastApiCallbackOptions }; - if optimizer.has_fast_callback_option { + if optimizer.has_fast_callback_option || optimizer.has_wasm_memory { // Replace last parameter. assert!(fast_fn_inputs.pop().is_some()); fast_fn_inputs.push(decl); @@ -174,6 +175,7 @@ pub(crate) fn generate( if optimizer.needs_opstate() || optimizer.is_async || optimizer.has_fast_callback_option + || optimizer.has_wasm_memory { // Dark arts 🪄 ✨ // -- cgit v1.2.3