From b96b9eba0ea19dab6b7d39e673b1ddd56705d194 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Mon, 2 Feb 2026 13:33:47 -0700 Subject: [PATCH 1/6] deprecate `[Typed]Func::post_return[_async]` and make them no-ops With the advent of the Component Model concurrency ABI and it's `task.return` intrinsic, post-return functions have been informally deprecated and are expected to be removed for WASI 1.0 and the corresponding stable edition of the Component Model. Consequently, it does not make sense anymore to require embedders to explicitly call the post-return function after using `[Typed]Func::call[_async]`. As of this commit, `[Typed]Func::post_return[_async]` are no-ops. Instead, the post-return function is called automatically as part of `[Typed]Func::call[_async]` if present, which is how `[Typed]Func::call_concurrent` has worked all along. In addition, this commit fixes and tests a couple of cases where the task and/or thread was being disposed of before the post-return function was called. --- benches/call.rs | 14 - crates/c-api/src/component/func.rs | 9 +- crates/fuzzing/src/oracles/component_api.rs | 5 +- .../tests/scenario/round_trip.rs | 1 - .../tests/scenario/round_trip_many.rs | 1 - crates/test-util/src/component.rs | 46 +-- .../src/runtime/component/concurrent.rs | 117 +----- crates/wasmtime/src/runtime/component/func.rs | 133 +++---- .../src/runtime/component/func/typed.rs | 30 +- crates/wast/src/wast.rs | 12 +- crates/wit-bindgen/src/lib.rs | 13 - crates/wizer/src/component/wasmtime.rs | 8 +- examples/wasip2/main.rs | 2 - src/commands/run.rs | 1 - tests/all/component_model.rs | 2 +- tests/all/component_model/async.rs | 6 +- tests/all/component_model/async_dynamic.rs | 12 - tests/all/component_model/call_hook.rs | 11 - tests/all/component_model/dynamic.rs | 67 ++-- tests/all/component_model/func.rs | 364 +++++++++++------- tests/all/component_model/macros.rs | 26 +- tests/all/component_model/missing_async.rs | 23 -- tests/all/component_model/post_return.rs | 95 +---- tests/all/component_model/resources.rs | 54 +-- tests/all/component_model/strings.rs | 1 - tests/all/pulley.rs | 21 - 26 files changed, 358 insertions(+), 716 deletions(-) diff --git a/benches/call.rs b/benches/call.rs index 59863d4763d5..7e35b7fe422d 100644 --- a/benches/call.rs +++ b/benches/call.rs @@ -642,11 +642,6 @@ mod component { typed.call(&mut *store, typed_params).unwrap() }; assert_eq!(results, typed_results); - if is_async.use_async() { - run_await(typed.post_return_async(&mut *store)).unwrap() - } else { - typed.post_return(&mut *store).unwrap() - } }) }); @@ -667,11 +662,6 @@ mod component { for (expected, actual) in expected_results.iter().zip(&results) { assert_eq!(expected, actual); } - if is_async.use_async() { - run_await(untyped.post_return_async(&mut *store)).unwrap() - } else { - untyped.post_return(&mut *store).unwrap() - } }) }, ); @@ -864,10 +854,8 @@ mod component { let start = Instant::now(); if is_async.use_async() { run_await(run.call_async(&mut *store, (iters,))).unwrap(); - run_await(run.post_return_async(&mut *store)).unwrap(); } else { run.call(&mut *store, (iters,)).unwrap(); - run.post_return(&mut *store).unwrap(); } start.elapsed() }) @@ -882,10 +870,8 @@ mod component { let start = Instant::now(); if is_async.use_async() { run_await(run.call_async(&mut *store, (iters,))).unwrap(); - run_await(run.post_return_async(&mut *store)).unwrap(); } else { run.call(&mut *store, (iters,)).unwrap(); - run.post_return(&mut *store).unwrap(); } start.elapsed() }) diff --git a/crates/c-api/src/component/func.rs b/crates/c-api/src/component/func.rs index 0c5fcdaae8e8..280693e15291 100644 --- a/crates/c-api/src/component/func.rs +++ b/crates/c-api/src/component/func.rs @@ -26,14 +26,13 @@ pub unsafe extern "C" fn wasmtime_component_func_call( }) } +#[deprecated(note = "no longer has any effect")] #[unsafe(no_mangle)] pub unsafe extern "C" fn wasmtime_component_func_post_return( - func: &Func, - mut context: WasmtimeStoreContextMut<'_>, + _func: &Func, + _context: WasmtimeStoreContextMut<'_>, ) -> Option> { - let result = func.post_return(&mut context); - - crate::handle_result(result, |_| {}) + crate::handle_result(Ok(()), |_| {}) } #[unsafe(no_mangle)] diff --git a/crates/fuzzing/src/oracles/component_api.rs b/crates/fuzzing/src/oracles/component_api.rs index 47f0faae57b3..131f92d6e704 100644 --- a/crates/fuzzing/src/oracles/component_api.rs +++ b/crates/fuzzing/src/oracles/component_api.rs @@ -278,9 +278,7 @@ where .await .unwrap() } else { - let result = func.call_async(&mut store, params).await.unwrap(); - func.post_return_async(&mut store).await.unwrap(); - result + func.call_async(&mut store, params).await.unwrap() }; log::trace!("got result {actual:?}"); assert_eq!(actual, result); @@ -382,7 +380,6 @@ pub fn dynamic_component_api_target(input: &mut arbitrary::Unstructured) -> arbi func.call_async(&mut store, ¶ms, &mut actual) .await .unwrap(); - func.post_return_async(&mut store).await.unwrap(); } log::trace!("received results {actual:?}"); assert_eq!(actual, results); diff --git a/crates/misc/component-async-tests/tests/scenario/round_trip.rs b/crates/misc/component-async-tests/tests/scenario/round_trip.rs index a1314e52bd81..21a52345b0d2 100644 --- a/crates/misc/component-async-tests/tests/scenario/round_trip.rs +++ b/crates/misc/component-async-tests/tests/scenario/round_trip.rs @@ -569,7 +569,6 @@ pub async fn test_round_trip( unreachable!() }; assert_eq!(*expected, actual); - foo_function.post_return_async(&mut store).await?; } store.assert_concurrent_state_empty(); diff --git a/crates/misc/component-async-tests/tests/scenario/round_trip_many.rs b/crates/misc/component-async-tests/tests/scenario/round_trip_many.rs index 980b46a92333..1cd0999374f0 100644 --- a/crates/misc/component-async-tests/tests/scenario/round_trip_many.rs +++ b/crates/misc/component-async-tests/tests/scenario/round_trip_many.rs @@ -425,7 +425,6 @@ async fn test_round_trip_many( unreachable!() }; assert_eq!(&make(expected), actual); - foo_function.post_return_async(&mut store).await?; } store.assert_concurrent_state_empty(); diff --git a/crates/test-util/src/component.rs b/crates/test-util/src/component.rs index c711ce908ef1..fb31b594a534 100644 --- a/crates/test-util/src/component.rs +++ b/crates/test-util/src/component.rs @@ -3,52 +3,10 @@ use std::mem::MaybeUninit; use wasmtime::component::__internal::{ CanonicalAbiInfo, InstanceType, InterfaceType, LiftContext, LowerContext, }; -use wasmtime::component::{ComponentNamedList, ComponentType, Func, Lift, Lower, TypedFunc, Val}; -use wasmtime::{AsContextMut, Config, Engine}; +use wasmtime::component::{ComponentType, Lift, Lower}; +use wasmtime::{Config, Engine}; use wasmtime_environ::prelude::*; -pub trait TypedFuncExt { - fn call_and_post_return(&self, store: impl AsContextMut, params: P) -> Result; -} - -impl TypedFuncExt for TypedFunc -where - P: ComponentNamedList + Lower, - R: ComponentNamedList + Lift + Send + Sync + 'static, -{ - fn call_and_post_return( - &self, - mut store: impl AsContextMut, - params: P, - ) -> Result { - let result = self.call(&mut store, params)?; - self.post_return(&mut store)?; - Ok(result) - } -} - -pub trait FuncExt { - fn call_and_post_return( - &self, - store: impl AsContextMut, - params: &[Val], - results: &mut [Val], - ) -> Result<()>; -} - -impl FuncExt for Func { - fn call_and_post_return( - &self, - mut store: impl AsContextMut, - params: &[Val], - results: &mut [Val], - ) -> Result<()> { - self.call(&mut store, params, results)?; - self.post_return(&mut store)?; - Ok(()) - } -} - pub fn config() -> Config { drop(env_logger::try_init()); diff --git a/crates/wasmtime/src/runtime/component/concurrent.rs b/crates/wasmtime/src/runtime/component/concurrent.rs index 113bdda0637d..3b272e95a750 100644 --- a/crates/wasmtime/src/runtime/component/concurrent.rs +++ b/crates/wasmtime/src/runtime/component/concurrent.rs @@ -50,7 +50,7 @@ //! store. This is equivalent to `StoreContextMut::spawn` but more convenient to use //! in host functions. -use crate::component::func::{self, Func}; +use crate::component::func::{self, Func, call_post_return}; use crate::component::{ HasData, HasSelf, Instance, Resource, ResourceTable, ResourceTableError, RuntimeInstance, }; @@ -81,7 +81,6 @@ use std::mem::{self, ManuallyDrop, MaybeUninit}; use std::ops::DerefMut; use std::pin::{Pin, pin}; use std::ptr::{self, NonNull}; -use std::slice; use std::sync::Arc; use std::task::{Context, Poll, Waker}; use std::vec::Vec; @@ -1444,7 +1443,6 @@ impl StoreOpaque { tx: None, exit_tx: Arc::new(oneshot::channel().0), host_future_present: false, - call_post_return_automatically: false, caller: state.guest_thread, } }, @@ -2225,7 +2223,7 @@ impl Instance { log::trace!( "sync/async-stackful call: replaced {old_thread:?} with {guest_thread:?} as current thread", ); - let mut flags = self.id().get(store).instance_flags(callee_instance.index); + let flags = self.id().get(store).instance_flags(callee_instance.index); store.maybe_push_call_context(guest_thread.task)?; @@ -2244,12 +2242,9 @@ impl Instance { // over must be valid. let storage = call(store)?; - // This is a callback-less call, so the implicit thread has now completed - self.cleanup_thread(store, guest_thread, callee_instance.index)?; - if async_ { let task = store.concurrent_state_mut().get_mut(guest_thread.task)?; - if task.threads.is_empty() && !task.returned_or_cancelled() { + if task.threads.len() == 1 && !task.returned_or_cancelled() { bail!(Trap::NoAsyncResult); } } else { @@ -2287,47 +2282,21 @@ impl Instance { _ => unreachable!(), }; - if store - .concurrent_state_mut() - .get_mut(guest_thread.task)? - .call_post_return_automatically() - { - unsafe { - flags.set_may_leave(false); - flags.set_needs_post_return(false); - } - - if let Some(func) = post_return { - let mut store = token.as_context_mut(store); - - // SAFETY: `func` is a valid `*mut VMFuncRef` from - // either `wasmtime-cranelift`-generated fused adapter - // code or `component::Options`. Per `wasmparser` - // post-return signature validation, we know it takes a - // single parameter. - unsafe { - crate::Func::call_unchecked_raw( - &mut store, - func.as_non_null(), - slice::from_ref(&post_return_arg).into(), - )?; - } - } - - unsafe { - flags.set_may_leave(true); - } + unsafe { + call_post_return( + token.as_context_mut(store), + post_return.map(|v| v.as_non_null()), + post_return_arg, + flags, + )?; } - self.task_complete( - store, - guest_thread.task, - result, - Status::Returned, - post_return_arg, - )?; + self.task_complete(store, guest_thread.task, result, Status::Returned)?; } + // This is a callback-less call, so the implicit thread has now completed + self.cleanup_thread(store, guest_thread, callee_instance.index)?; + store.set_thread(old_thread); store.maybe_pop_call_context(guest_thread.task)?; @@ -2975,13 +2944,7 @@ impl Instance { log::trace!("task.return for {guest_thread:?}"); let result = (lift.lift)(store, storage)?; - self.task_complete( - store, - guest_thread.task, - result, - Status::Returned, - ValRaw::i32(0), - ) + self.task_complete(store, guest_thread.task, result, Status::Returned) } /// Implements the `task.cancel` intrinsic. @@ -3011,7 +2974,6 @@ impl Instance { guest_thread.task, Box::new(DummyResult), Status::ReturnCancelled, - ValRaw::i32(0), ) } @@ -3026,35 +2988,14 @@ impl Instance { guest_task: TableId, result: Box, status: Status, - post_return_arg: ValRaw, ) -> Result<()> { - if store - .concurrent_state_mut() - .get_mut(guest_task)? - .call_post_return_automatically() - { - let (calls, host_table, _, instance) = - store.component_resource_state_with_instance(self); - ResourceTables { - calls, - host_table: Some(host_table), - guest: Some(instance.instance_states()), - } - .exit_call()?; - } else { - // As of this writing, the only scenario where `call_post_return_automatically` - // would be false for a `GuestTask` is for host-to-guest calls using - // `[Typed]Func::call_async`, in which case the `function_index` - // should be a non-`None` value. - let function_index = store - .concurrent_state_mut() - .get_mut(guest_task)? - .function_index - .unwrap(); - self.id() - .get_mut(store) - .post_return_arg_set(function_index, post_return_arg); + let (calls, host_table, _, instance) = store.component_resource_state_with_instance(self); + ResourceTables { + calls, + host_table: Some(host_table), + guest: Some(instance.instance_states()), } + .exit_call()?; let state = store.concurrent_state_mut(); let task = state.get_mut(guest_task)?; @@ -4321,8 +4262,6 @@ enum Caller { /// If true, there's a host future that must be dropped before the task /// can be deleted. host_future_present: bool, - /// If true, call `post-return` function (if any) automatically. - call_post_return_automatically: bool, /// If `Some`, represents the `QualifiedThreadId` caller of the host /// function which called back into a guest. Note that this thread /// could belong to an entirely unrelated top-level component instance @@ -4656,7 +4595,6 @@ impl GuestTask { // exited: exit_tx: exit_tx.clone(), host_future_present: false, - call_post_return_automatically: true, caller: *caller, }; } @@ -4672,17 +4610,6 @@ impl GuestTask { Ok(()) } - - fn call_post_return_automatically(&self) -> bool { - matches!( - self.caller, - Caller::Guest { .. } - | Caller::Host { - call_post_return_automatically: true, - .. - } - ) - } } impl TableDebug for GuestTask { @@ -5300,7 +5227,6 @@ pub(crate) fn prepare_call( handle: Func, param_count: usize, host_future_present: bool, - call_post_return_automatically: bool, lower_params: impl FnOnce(Func, StoreContextMut, &mut [MaybeUninit]) -> Result<()> + Send + Sync @@ -5348,7 +5274,6 @@ pub(crate) fn prepare_call( tx: Some(tx), exit_tx: Arc::new(exit_tx), host_future_present, - call_post_return_automatically, caller, }, callback.map(|callback| { diff --git a/crates/wasmtime/src/runtime/component/func.rs b/crates/wasmtime/src/runtime/component/func.rs index 0a8cbd9f49ad..c6acdac86675 100644 --- a/crates/wasmtime/src/runtime/component/func.rs +++ b/crates/wasmtime/src/runtime/component/func.rs @@ -237,7 +237,9 @@ impl Func { ) -> Result<()> { let mut store = store.as_context_mut(); store.0.validate_sync_call()?; - self.call_impl(&mut store.as_context_mut(), params, results) + self.call_impl(store.as_context_mut(), params, results)?; + self.post_return_impl(store)?; + Ok(()) } /// Exactly like [`Self::call`] except for use on async stores. @@ -261,7 +263,7 @@ impl Func { if store.0.concurrency_support() { return store .run_concurrent_trap_on_idle(async |store| { - self.call_concurrent_dynamic(store, params, results, false) + self.call_concurrent_dynamic(store, params, results) .await .map(drop) }) @@ -403,7 +405,7 @@ impl Func { params: &[Val], results: &mut [Val], ) -> Result { - self.call_concurrent_dynamic(accessor, params, results, true) + self.call_concurrent_dynamic(accessor, params, results) .await } @@ -414,15 +416,10 @@ impl Func { accessor: impl AsAccessor, params: &[Val], results: &mut [Val], - call_post_return_automatically: bool, ) -> Result { let result = accessor.as_accessor().with(|mut store| { self.check_params_results(store.as_context_mut(), params, results)?; - let prepared = self.prepare_call_dynamic( - store.as_context_mut(), - params.to_vec(), - call_post_return_automatically, - )?; + let prepared = self.prepare_call_dynamic(store.as_context_mut(), params.to_vec())?; concurrent::queue_call(store.as_context_mut(), prepared) })?; @@ -441,7 +438,6 @@ impl Func { self, mut store: StoreContextMut<'a, T>, params: Vec, - call_post_return_automatically: bool, ) -> Result>> { let store = store.as_context_mut(); @@ -450,9 +446,8 @@ impl Func { self, MAX_FLAT_PARAMS, false, - call_post_return_automatically, move |func, store, params_out| { - func.with_lower_context(store, call_post_return_automatically, |cx, ty| { + func.with_lower_context(store, true, |cx, ty| { Self::lower_args(cx, ¶ms, ty, params_out) }) }, @@ -701,51 +696,20 @@ impl Func { return Ok(val); } - /// Invokes the `post-return` canonical ABI option, if specified, after a - /// [`Func::call`] has finished. - /// - /// This function is a required method call after a [`Func::call`] completes - /// successfully. After the embedder has finished processing the return - /// value then this function must be invoked. - /// - /// # Errors - /// - /// This function will return an error in the case of a WebAssembly trap - /// happening during the execution of the `post-return` function, if - /// specified. - /// - /// # Panics - /// - /// This function will panic if it's not called under the correct - /// conditions. This can only be called after a previous invocation of - /// [`Func::call`] completes successfully, and this function can only - /// be called for the same [`Func`] that was `call`'d. - /// - /// If this function is called when [`Func::call`] was not previously - /// called, then it will panic. If a different [`Func`] for the same - /// component instance was invoked then this function will also panic - /// because the `post-return` needs to happen for the other function. - #[inline] - pub fn post_return(&self, mut store: impl AsContextMut) -> Result<()> { - let store = store.as_context_mut(); - store.0.validate_sync_call()?; - self.post_return_impl(store, false) + #[doc(hidden)] + #[deprecated(note = "no longer has any effect")] + pub fn post_return(&self, _store: impl AsContextMut) -> Result<()> { + Ok(()) } - /// Exactly like [`Self::post_return`] except for invoke WebAssembly - /// [asynchronously](crate#async). + #[doc(hidden)] + #[deprecated(note = "no longer has any effect")] #[cfg(feature = "async")] - pub async fn post_return_async(&self, mut store: impl AsContextMut) -> Result<()> { - let mut store = store.as_context_mut(); - // Future optimization opportunity: conditionally use a fiber here since - // some func's post_return will not need the async context (i.e. end up - // calling async host functionality) - store - .on_fiber(|store| self.post_return_impl(store, true)) - .await? + pub async fn post_return_async(&self, _store: impl AsContextMut) -> Result<()> { + Ok(()) } - fn post_return_impl(&self, mut store: impl AsContextMut, async_: bool) -> Result<()> { + pub(crate) fn post_return_impl(&self, mut store: impl AsContextMut) -> Result<()> { let mut store = store.as_context_mut(); let index = self.index; @@ -753,8 +717,7 @@ impl Func { let component = vminstance.component(); let (_ty, _def, options) = component.export_lifted_function(index); let post_return = self.post_return_core_func(store.0); - let mut flags = - vminstance.instance_flags(component.env_component().options[options].instance); + let flags = vminstance.instance_flags(component.env_component().options[options].instance); let mut instance = self.instance.id().get_mut(store.0); let post_return_arg = instance.as_mut().post_return_arg_take(index); @@ -781,30 +744,7 @@ impl Func { ); let post_return_arg = post_return_arg.expect("calling post_return on wrong function"); - // Unset the "needs post return" flag now that post-return is being - // processed. This will cause future invocations of this method to - // panic, even if the function call below traps. - flags.set_needs_post_return(false); - - // Post return functions are forbidden from calling imports or - // intrinsics. - flags.set_may_leave(false); - - // If the function actually had a `post-return` configured in its - // canonical options that's executed here. - if let Some(func) = post_return { - crate::Func::call_unchecked_raw( - &mut store, - func, - NonNull::new(core::ptr::slice_from_raw_parts(&post_return_arg, 1).cast_mut()) - .unwrap(), - )?; - } - - // And finally if everything completed successfully then the "may - // leave" flags is set to `true` again here which enables further - // use of the component. - flags.set_may_leave(true); + call_post_return(&mut store, post_return, post_return_arg, flags)?; let (calls, host_table, _, instance) = store .0 @@ -816,7 +756,7 @@ impl Func { } .exit_call()?; - if !async_ && store.0.concurrency_support() { + if store.0.concurrency_support() { store.0.exit_sync_call(false)?; } } @@ -1009,3 +949,38 @@ impl TaskExit { _ = self.0.await; } } + +pub(crate) unsafe fn call_post_return( + mut store: impl AsContextMut, + func: Option>, + arg: ValRaw, + mut flags: InstanceFlags, +) -> Result<()> { + unsafe { + // Unset the "needs post return" flag now that post-return is being + // processed. This will cause future invocations of this method to + // panic, even if the function call below traps. + flags.set_needs_post_return(false); + + // Post return functions are forbidden from calling imports or + // intrinsics. + flags.set_may_leave(false); + + // If the function actually had a `post-return` configured in its + // canonical options that's executed here. + if let Some(func) = func { + crate::Func::call_unchecked_raw( + &mut store.as_context_mut(), + func, + std::slice::from_ref(&arg).into(), + )?; + } + + // And finally if everything completed successfully then the "may + // leave" flags is set to `true` again here which enables further + // use of the component. + flags.set_may_leave(true); + } + + Ok(()) +} diff --git a/crates/wasmtime/src/runtime/component/func/typed.rs b/crates/wasmtime/src/runtime/component/func/typed.rs index c03d08a97b02..a26f2976bf1b 100644 --- a/crates/wasmtime/src/runtime/component/func/typed.rs +++ b/crates/wasmtime/src/runtime/component/func/typed.rs @@ -158,9 +158,11 @@ where /// /// Panics if `store` does not own this function. pub fn call(&self, mut store: impl AsContextMut, params: Params) -> Result { - let store = store.as_context_mut(); + let mut store = store.as_context_mut(); store.0.validate_sync_call()?; - self.call_impl(store, params) + let result = self.call_impl(store.as_context_mut(), params)?; + self.func.post_return_impl(store)?; + Ok(result) } /// Exactly like [`Self::call`], except for invoking WebAssembly @@ -188,7 +190,7 @@ where let ptr = SendSyncPtr::from(NonNull::from(¶ms).cast::()); let prepared = - self.prepare_call(store.as_context_mut(), true, false, move |cx, ty, dst| { + self.prepare_call(store.as_context_mut(), true, move |cx, ty, dst| { // SAFETY: The goal here is to get `Params`, a non-`'static` // value, to live long enough to the lowering of the // parameters. We're guaranteed that `Params` lives in the @@ -326,7 +328,7 @@ where ); let prepared = - self.prepare_call(store.as_context_mut(), false, true, move |cx, ty, dst| { + self.prepare_call(store.as_context_mut(), false, move |cx, ty, dst| { Self::lower_args(cx, ty, dst, ¶ms) })?; concurrent::queue_call(store, prepared) @@ -364,7 +366,6 @@ where self, store: StoreContextMut<'_, T>, host_future_present: bool, - call_post_return_automatically: bool, lower: impl FnOnce( &mut LowerContext, InterfaceType, @@ -395,11 +396,8 @@ where self.func, param_count, host_future_present, - call_post_return_automatically, move |func, store, params_out| { - func.with_lower_context(store, call_post_return_automatically, |cx, ty| { - lower(cx, ty, params_out) - }) + func.with_lower_context(store, true, |cx, ty| lower(cx, ty, params_out)) }, move |func, store, results| { let result = if Return::flatten_count() <= max_results { @@ -581,18 +579,20 @@ where Return::linear_lift_from_memory(cx, ty, bytes) } - /// See [`Func::post_return`] - pub fn post_return(&self, store: impl AsContextMut) -> Result<()> { - self.func.post_return(store) + #[doc(hidden)] + #[deprecated(note = "no longer has any effect")] + pub fn post_return(&self, _store: impl AsContextMut) -> Result<()> { + Ok(()) } - /// See [`Func::post_return_async`] + #[doc(hidden)] + #[deprecated(note = "no longer has any effect")] #[cfg(feature = "async")] pub async fn post_return_async( &self, - store: impl AsContextMut, + _store: impl AsContextMut, ) -> Result<()> { - self.func.post_return_async(store).await + Ok(()) } } diff --git a/crates/wast/src/wast.rs b/crates/wast/src/wast.rs index c37be5c67dad..48cec7a22586 100644 --- a/crates/wast/src/wast.rs +++ b/crates/wast/src/wast.rs @@ -310,17 +310,7 @@ impl WastContext { None => func.call(&mut *store, &values, &mut results), }; Ok(match result { - Ok(()) => { - let result = match &replace.rt { - Some(rt) => rt.block_on(func.post_return_async(&mut *store)), - None => func.post_return(&mut *store), - }; - - match result { - Ok(()) => Outcome::Ok(Results::Component(results)), - Err(e) => Outcome::Trap(e), - } - } + Ok(()) => Outcome::Ok(Results::Component(results)), Err(e) => Outcome::Trap(e), }) } diff --git a/crates/wit-bindgen/src/lib.rs b/crates/wit-bindgen/src/lib.rs index 88a614eff236..47550d804a77 100644 --- a/crates/wit-bindgen/src/lib.rs +++ b/crates/wit-bindgen/src/lib.rs @@ -2854,19 +2854,6 @@ impl<'a> InterfaceGenerator<'a> { }; uwriteln!(self.src, ")){instrument}{await_}?;"); - let instrument = if flags.contains(FunctionFlags::ASYNC | FunctionFlags::TRACING) { - ".instrument(span)" - } else { - "" - }; - - if !flags.contains(FunctionFlags::STORE) { - uwriteln!( - self.src, - "callee.post_return{async__}(store.as_context_mut()){instrument}{await_}?;" - ); - } - self.src.push_str("Ok("); if task_exit { self.src.push_str("("); diff --git a/crates/wizer/src/component/wasmtime.rs b/crates/wizer/src/component/wasmtime.rs index b5785b821c79..df337456ca40 100644 --- a/crates/wizer/src/component/wasmtime.rs +++ b/crates/wizer/src/component/wasmtime.rs @@ -70,10 +70,6 @@ impl Wizer { .call_async(&mut *store, ()) .await .with_context(|| format!("the initialization function trapped"))?; - init_func - .post_return_async(&mut *store) - .await - .context("failed to call post-return")?; Ok(()) } @@ -111,9 +107,7 @@ impl WasmtimeWizerComponent<'_, T> { .get_typed_func::<(), (R,)>(&mut *self.store, func_export) .unwrap(); let ret = func.call_async(&mut *self.store, ()).await.unwrap().0; - let ret = use_ret(&mut *self.store, ret); - func.post_return_async(&mut *self.store).await.unwrap(); - ret + use_ret(&mut *self.store, ret) } } diff --git a/examples/wasip2/main.rs b/examples/wasip2/main.rs index 878e31c8f7fb..22dfaae889ce 100644 --- a/examples/wasip2/main.rs +++ b/examples/wasip2/main.rs @@ -81,7 +81,5 @@ fn main() -> Result<()> { // * Documentation for [Func::typed](https://docs.rs/wasmtime/latest/wasmtime/component/struct.Func.html#method.typed) and [ComponentNamedList](https://docs.rs/wasmtime/latest/wasmtime/component/trait.ComponentNamedList.html) let typed = func.typed::<(), (Result<(), ()>,)>(&store)?; let (result,) = typed.call(&mut store, ())?; - // Required, see documentation of TypedFunc::call - typed.post_return(&mut store)?; result.map_err(|_| wasmtime::format_err!("error")) } diff --git a/src/commands/run.rs b/src/commands/run.rs index e3ce0e9a0abe..3b311864ef36 100644 --- a/src/commands/run.rs +++ b/src/commands/run.rs @@ -645,7 +645,6 @@ impl RunCommand { } func.call_async(&mut *store, ¶ms, results).await?; - func.post_return_async(&mut *store).await?; Ok(()) } diff --git a/tests/all/component_model.rs b/tests/all/component_model.rs index 4ad94b84eb6e..49248dc3c4ba 100644 --- a/tests/all/component_model.rs +++ b/tests/all/component_model.rs @@ -3,7 +3,7 @@ use std::iter; use wasmtime::Result; use wasmtime::component::Component; use wasmtime_component_util::REALLOC_AND_FREE; -use wasmtime_test_util::component::{TypedFuncExt, async_engine, config, engine}; +use wasmtime_test_util::component::{async_engine, config, engine}; mod aot; mod r#async; diff --git a/tests/all/component_model/async.rs b/tests/all/component_model/async.rs index 7e71ccd38eab..949639e1dd15 100644 --- a/tests/all/component_model/async.rs +++ b/tests/all/component_model/async.rs @@ -2,7 +2,7 @@ use crate::async_functions::{PollOnce, execute_across_threads}; use std::pin::Pin; use std::task::{Context, Poll}; use wasmtime::Result; -use wasmtime::{AsContextMut, Config, component::*}; +use wasmtime::{Config, component::*}; use wasmtime::{Engine, Store, StoreContextMut, Trap}; use wasmtime_component_util::REALLOC_AND_FREE; @@ -36,7 +36,6 @@ async fn smoke() -> Result<()> { let thunk = instance.get_typed_func::<(), ()>(&mut store, "thunk")?; thunk.call_async(&mut store, ()).await?; - thunk.post_return_async(&mut store).await?; let err = instance .get_typed_func::<(), ()>(&mut store, "thunk-trap")? @@ -88,7 +87,6 @@ async fn smoke_func_wrap() -> Result<()> { let thunk = instance.get_typed_func::<(), ()>(&mut store, "thunk")?; thunk.call_async(&mut store, ()).await?; - thunk.post_return_async(&mut store).await?; Ok(()) } @@ -305,7 +303,6 @@ async fn drop_resource_async() -> Result<()> { execute_across_threads(async move { let resource = Resource::new_own(100); f.call_async(&mut store, (resource,)).await?; - f.post_return_async(&mut store).await?; Ok::<_, wasmtime::Error>(()) }) .await?; @@ -664,7 +661,6 @@ async fn task_deletion() -> Result<()> { for func in funcs { let func = instance.get_typed_func::<(), (u32,)>(&mut store, func)?; assert_eq!(func.call_async(&mut store, ()).await?, (42,)); - func.post_return_async(store.as_context_mut()).await?; } Ok(()) diff --git a/tests/all/component_model/async_dynamic.rs b/tests/all/component_model/async_dynamic.rs index 860777d1e755..33740084f2d8 100644 --- a/tests/all/component_model/async_dynamic.rs +++ b/tests/all/component_model/async_dynamic.rs @@ -136,13 +136,9 @@ fn simple_type_assertions() -> Result<()> { let roundtrip = |store: &mut Store<()>, f: FutureReader| -> Result<()> { let (f,) = f_t_t.call(&mut *store, (f,))?; - f_t_t.post_return(&mut *store)?; let (f,) = f_t_a.call(&mut *store, (f,))?; - f_t_a.post_return(&mut *store)?; let (f,) = f_a_a.call(&mut *store, (f,))?; - f_a_a.post_return(&mut *store)?; let (mut f,) = f_a_t.call(&mut *store, (f,))?; - f_a_t.post_return(&mut *store)?; f.close(&mut *store); Ok(()) }; @@ -151,23 +147,17 @@ fn simple_type_assertions() -> Result<()> { roundtrip(&mut store, f)?; let (f,) = mk_f_t.call(&mut store, ())?; - mk_f_t.post_return(&mut store)?; roundtrip(&mut store, f)?; let (f,) = mk_f_a.call(&mut store, ())?; - mk_f_a.post_return(&mut store)?; let f = f.try_into_future_reader::()?; roundtrip(&mut store, f)?; let roundtrip = |store: &mut Store<()>, s: StreamReader| -> Result<()> { let (s,) = s_t_t.call(&mut *store, (s,))?; - s_t_t.post_return(&mut *store)?; let (s,) = s_t_a.call(&mut *store, (s,))?; - s_t_a.post_return(&mut *store)?; let (s,) = s_a_a.call(&mut *store, (s,))?; - s_a_a.post_return(&mut *store)?; let (mut s,) = s_a_t.call(&mut *store, (s,))?; - s_a_t.post_return(&mut *store)?; s.close(&mut *store); Ok(()) }; @@ -176,11 +166,9 @@ fn simple_type_assertions() -> Result<()> { roundtrip(&mut store, s)?; let (s,) = mk_s_t.call(&mut store, ())?; - mk_s_t.post_return(&mut store)?; roundtrip(&mut store, s)?; let (s,) = mk_s_a.call(&mut store, ())?; - mk_s_a.post_return(&mut store)?; let s = s.try_into_stream_reader::()?; roundtrip(&mut store, s)?; diff --git a/tests/all/component_model/call_hook.rs b/tests/all/component_model/call_hook.rs index 72602d2220de..4d5ca9d524cd 100644 --- a/tests/all/component_model/call_hook.rs +++ b/tests/all/component_model/call_hook.rs @@ -59,7 +59,6 @@ fn call_wrapped_func() -> Result<()> { .expect("looking up `export`"); export.call(&mut store, ())?; - export.post_return(&mut store)?; let s = store.into_data(); assert_eq!(s.calls_into_host, 1); @@ -126,8 +125,6 @@ fn call_func_with_realloc() -> Result<()> { let result = res.to_str(&store)?; assert_eq!(&message, &result); - export.post_return(&mut store)?; - // There are two wasm calls for the `list8-to-str` call and the guest realloc call for the list // argument. let s = store.into_data(); @@ -173,12 +170,6 @@ fn call_func_with_post_return() -> Result<()> { export.call(&mut store, ())?; - // Before post-return, there will only have been one call into wasm. - assert_eq!(store.data().calls_into_wasm, 1); - assert_eq!(store.data().returns_from_wasm, 1); - - export.post_return(&mut store)?; - // There are no host calls in this example, but the post-return does increment the count of // wasm calls by 1, putting the total number of wasm calls at 2. let s = store.into_data(); @@ -244,7 +235,6 @@ async fn call_wrapped_async_func() -> Result<()> { .expect("looking up `export`"); export.call_async(&mut store, ()).await?; - export.post_return_async(&mut store).await?; let s = store.into_data(); assert_eq!(s.calls_into_host, 1); @@ -330,7 +320,6 @@ fn trapping() -> Result<()> { let mut r = export.call(&mut store, (action,)); if r.is_ok() && again { - export.post_return(&mut store).unwrap(); r = export.call(&mut store, (action,)); } (store.into_data(), r.err()) diff --git a/tests/all/component_model/dynamic.rs b/tests/all/component_model/dynamic.rs index 17be5371f91e..0a67a320f82b 100644 --- a/tests/all/component_model/dynamic.rs +++ b/tests/all/component_model/dynamic.rs @@ -6,7 +6,6 @@ use wasmtime::component::types::{self, Case, ComponentItem, Field}; use wasmtime::component::{Component, Linker, ResourceType, Val}; use wasmtime::{Module, Store}; use wasmtime_component_util::REALLOC_AND_FREE; -use wasmtime_test_util::component::FuncExt; #[test] fn primitives() -> Result<()> { @@ -39,7 +38,7 @@ fn primitives() -> Result<()> { let component = Component::new(&engine, make_echo_component_with_params(ty, &[param]))?; let instance = Linker::new(&engine).instantiate(&mut store, &component)?; let func = instance.get_func(&mut store, "echo").unwrap(); - func.call_and_post_return(&mut store, &[input.clone()], &mut output)?; + func.call(&mut store, &[input.clone()], &mut output)?; assert_eq!(input, output[0]); } @@ -53,7 +52,7 @@ fn primitives() -> Result<()> { let instance = Linker::new(&engine).instantiate(&mut store, &component)?; let func = instance.get_func(&mut store, "echo").unwrap(); let err = func - .call_and_post_return(&mut store, &[Val::U64(42)], &mut output) + .call(&mut store, &[Val::U64(42)], &mut output) .unwrap_err(); assert!(err.to_string().contains("type mismatch"), "{err}"); @@ -61,7 +60,7 @@ fn primitives() -> Result<()> { // Sad path: arity mismatch (too many) let err = func - .call_and_post_return( + .call( &mut store, &[Val::Float64(3.14159265), Val::Float64(3.14159265)], &mut output, @@ -75,17 +74,13 @@ fn primitives() -> Result<()> { // Sad path: arity mismatch (too few) - let err = func - .call_and_post_return(&mut store, &[], &mut output) - .unwrap_err(); + let err = func.call(&mut store, &[], &mut output).unwrap_err(); assert!( err.to_string().contains("expected 1 argument(s), got 0"), "{err}" ); - let err = func - .call_and_post_return(&mut store, &output, &mut []) - .unwrap_err(); + let err = func.call(&mut store, &output, &mut []).unwrap_err(); assert!( err.to_string().contains("expected 1 result(s), got 0"), "{err}" @@ -104,7 +99,7 @@ fn strings() -> Result<()> { let func = instance.get_func(&mut store, "echo").unwrap(); let input = Val::String("hello, component!".into()); let mut output = [Val::Bool(false)]; - func.call_and_post_return(&mut store, &[input.clone()], &mut output)?; + func.call(&mut store, &[input.clone()], &mut output)?; assert_eq!(input, output[0]); Ok(()) @@ -124,7 +119,7 @@ fn lists() -> Result<()> { Val::U32(2084037802), ]); let mut output = [Val::Bool(false)]; - func.call_and_post_return(&mut store, &[input.clone()], &mut output)?; + func.call(&mut store, &[input.clone()], &mut output)?; assert_eq!(input, output[0]); @@ -135,9 +130,7 @@ fn lists() -> Result<()> { Val::U32(79023439), Val::Float32(3.14159265), ]); - let err = func - .call_and_post_return(&mut store, &[err], &mut output) - .unwrap_err(); + let err = func.call(&mut store, &[err], &mut output).unwrap_err(); assert!(err.to_string().contains("type mismatch"), "{err}"); Ok(()) @@ -185,7 +178,7 @@ fn records() -> Result<()> { ), ]); let mut output = [Val::Bool(false)]; - func.call_and_post_return(&mut store, &[input.clone()], &mut output)?; + func.call(&mut store, &[input.clone()], &mut output)?; assert_eq!(input, output[0]); @@ -204,9 +197,7 @@ fn records() -> Result<()> { ]); let instance = Linker::new(&engine).instantiate(&mut store, &component)?; let func = instance.get_func(&mut store, "echo").unwrap(); - let err = func - .call_and_post_return(&mut store, &[err], &mut output) - .unwrap_err(); + let err = func.call(&mut store, &[err], &mut output).unwrap_err(); assert!(err.to_string().contains("type mismatch"), "{err}"); // Sad path: too many fields @@ -225,9 +216,7 @@ fn records() -> Result<()> { ]); let instance = Linker::new(&engine).instantiate(&mut store, &component)?; let func = instance.get_func(&mut store, "echo").unwrap(); - let err = func - .call_and_post_return(&mut store, &[err], &mut output) - .unwrap_err(); + let err = func.call(&mut store, &[err], &mut output).unwrap_err(); assert!( err.to_string().contains("expected 3 fields, got 4"), "{err}" @@ -241,9 +230,7 @@ fn records() -> Result<()> { ]); let instance = Linker::new(&engine).instantiate(&mut store, &component)?; let func = instance.get_func(&mut store, "echo").unwrap(); - let err = func - .call_and_post_return(&mut store, &[err], &mut output) - .unwrap_err(); + let err = func.call(&mut store, &[err], &mut output).unwrap_err(); assert!( err.to_string().contains("expected 3 fields, got 2"), "{err}" @@ -282,7 +269,7 @@ fn variants() -> Result<()> { let func = instance.get_func(&mut store, "echo").unwrap(); let input = Val::Variant("B".into(), Some(Box::new(Val::Float64(3.14159265)))); let mut output = [Val::Bool(false)]; - func.call_and_post_return(&mut store, &[input.clone()], &mut output)?; + func.call(&mut store, &[input.clone()], &mut output)?; assert_eq!(input, output[0]); @@ -308,7 +295,7 @@ fn variants() -> Result<()> { ("E".into(), Val::U32(314159265)), ]))), ); - func.call_and_post_return(&mut store, &[input.clone()], &mut output)?; + func.call(&mut store, &[input.clone()], &mut output)?; assert_eq!(input, output[0]); @@ -317,17 +304,13 @@ fn variants() -> Result<()> { let instance = Linker::new(&engine).instantiate(&mut store, &component)?; let func = instance.get_func(&mut store, "echo").unwrap(); let err = Val::Variant("B".into(), Some(Box::new(Val::U64(314159265)))); - let err = func - .call_and_post_return(&mut store, &[err], &mut output) - .unwrap_err(); + let err = func.call(&mut store, &[err], &mut output).unwrap_err(); assert!(err.to_string().contains("type mismatch"), "{err}"); let instance = Linker::new(&engine).instantiate(&mut store, &component)?; let func = instance.get_func(&mut store, "echo").unwrap(); let err = Val::Variant("B".into(), None); - let err = func - .call_and_post_return(&mut store, &[err], &mut output) - .unwrap_err(); + let err = func.call(&mut store, &[err], &mut output).unwrap_err(); assert!( err.to_string().contains("expected a payload for case `B`"), "{err}" @@ -338,17 +321,13 @@ fn variants() -> Result<()> { let instance = Linker::new(&engine).instantiate(&mut store, &component)?; let func = instance.get_func(&mut store, "echo").unwrap(); let err = Val::Variant("D".into(), Some(Box::new(Val::U64(314159265)))); - let err = func - .call_and_post_return(&mut store, &[err], &mut output) - .unwrap_err(); + let err = func.call(&mut store, &[err], &mut output).unwrap_err(); assert!(err.to_string().contains("unknown variant case"), "{err}"); let instance = Linker::new(&engine).instantiate(&mut store, &component)?; let func = instance.get_func(&mut store, "echo").unwrap(); let err = Val::Variant("D".into(), None); - let err = func - .call_and_post_return(&mut store, &[err], &mut output) - .unwrap_err(); + let err = func.call(&mut store, &[err], &mut output).unwrap_err(); assert!(err.to_string().contains("unknown variant case"), "{err}"); // Make sure we lift variants which have cases of different sizes with the correct alignment @@ -387,7 +366,7 @@ fn variants() -> Result<()> { ), ("B".into(), Val::U32(628318530)), ]); - func.call_and_post_return(&mut store, &[input.clone()], &mut output)?; + func.call(&mut store, &[input.clone()], &mut output)?; assert_eq!(input, output[0]); @@ -410,16 +389,14 @@ fn flags() -> Result<()> { let func = instance.get_func(&mut store, "echo").unwrap(); let input = Val::Flags(vec!["B".into(), "D".into()]); let mut output = [Val::Bool(false)]; - func.call_and_post_return(&mut store, &[input.clone()], &mut output)?; + func.call(&mut store, &[input.clone()], &mut output)?; assert_eq!(input, output[0]); // Sad path: unknown flags let err = Val::Flags(vec!["B".into(), "D".into(), "F".into()]); - let err = func - .call_and_post_return(&mut store, &[err], &mut output) - .unwrap_err(); + let err = func.call(&mut store, &[err], &mut output).unwrap_err(); assert!(err.to_string().contains("unknown flag"), "{err}"); Ok(()) @@ -539,7 +516,7 @@ fn everything() -> Result<()> { ), ]); let mut output = [Val::Bool(false)]; - func.call_and_post_return(&mut store, &[input.clone()], &mut output)?; + func.call(&mut store, &[input.clone()], &mut output)?; assert_eq!(input, output[0]); diff --git a/tests/all/component_model/func.rs b/tests/all/component_model/func.rs index 2bc1d6ad02cc..ac891f316405 100644 --- a/tests/all/component_model/func.rs +++ b/tests/all/component_model/func.rs @@ -1,6 +1,6 @@ #![cfg(not(miri))] -use super::{REALLOC_AND_FREE, TypedFuncExt}; +use super::REALLOC_AND_FREE; use std::sync::Arc; use wasmtime::Result; use wasmtime::component::*; @@ -33,7 +33,7 @@ fn thunks() -> Result<()> { let instance = Linker::new(&engine).instantiate(&mut store, &component)?; instance .get_typed_func::<(), ()>(&mut store, "thunk")? - .call_and_post_return(&mut store, ())?; + .call(&mut store, ())?; let err = instance .get_typed_func::<(), ()>(&mut store, "thunk-trap")? .call(&mut store, ()) @@ -188,28 +188,28 @@ fn integers() -> Result<()> { // Passing in 100 is valid for all primitives instance .get_typed_func::<(u8,), ()>(&mut store, "take-u8")? - .call_and_post_return(&mut store, (100,))?; + .call(&mut store, (100,))?; instance .get_typed_func::<(i8,), ()>(&mut store, "take-s8")? - .call_and_post_return(&mut store, (100,))?; + .call(&mut store, (100,))?; instance .get_typed_func::<(u16,), ()>(&mut store, "take-u16")? - .call_and_post_return(&mut store, (100,))?; + .call(&mut store, (100,))?; instance .get_typed_func::<(i16,), ()>(&mut store, "take-s16")? - .call_and_post_return(&mut store, (100,))?; + .call(&mut store, (100,))?; instance .get_typed_func::<(u32,), ()>(&mut store, "take-u32")? - .call_and_post_return(&mut store, (100,))?; + .call(&mut store, (100,))?; instance .get_typed_func::<(i32,), ()>(&mut store, "take-s32")? - .call_and_post_return(&mut store, (100,))?; + .call(&mut store, (100,))?; instance .get_typed_func::<(u64,), ()>(&mut store, "take-u64")? - .call_and_post_return(&mut store, (100,))?; + .call(&mut store, (100,))?; instance .get_typed_func::<(i64,), ()>(&mut store, "take-s64")? - .call_and_post_return(&mut store, (100,))?; + .call(&mut store, (100,))?; // This specific wasm instance traps if any value other than 100 is passed with_new_instance(&engine, &component, |store, instance| { @@ -273,49 +273,49 @@ fn integers() -> Result<()> { assert_eq!( instance .get_typed_func::<(), (u8,)>(&mut store, "ret-u8")? - .call_and_post_return(&mut store, ())?, + .call(&mut store, ())?, (0,) ); assert_eq!( instance .get_typed_func::<(), (i8,)>(&mut store, "ret-s8")? - .call_and_post_return(&mut store, ())?, + .call(&mut store, ())?, (0,) ); assert_eq!( instance .get_typed_func::<(), (u16,)>(&mut store, "ret-u16")? - .call_and_post_return(&mut store, ())?, + .call(&mut store, ())?, (0,) ); assert_eq!( instance .get_typed_func::<(), (i16,)>(&mut store, "ret-s16")? - .call_and_post_return(&mut store, ())?, + .call(&mut store, ())?, (0,) ); assert_eq!( instance .get_typed_func::<(), (u32,)>(&mut store, "ret-u32")? - .call_and_post_return(&mut store, ())?, + .call(&mut store, ())?, (0,) ); assert_eq!( instance .get_typed_func::<(), (i32,)>(&mut store, "ret-s32")? - .call_and_post_return(&mut store, ())?, + .call(&mut store, ())?, (0,) ); assert_eq!( instance .get_typed_func::<(), (u64,)>(&mut store, "ret-u64")? - .call_and_post_return(&mut store, ())?, + .call(&mut store, ())?, (0,) ); assert_eq!( instance .get_typed_func::<(), (i64,)>(&mut store, "ret-s64")? - .call_and_post_return(&mut store, ())?, + .call(&mut store, ())?, (0,) ); @@ -323,49 +323,49 @@ fn integers() -> Result<()> { assert_eq!( instance .get_typed_func::<(), (u8,)>(&mut store, "retm1-u8")? - .call_and_post_return(&mut store, ())?, + .call(&mut store, ())?, (0xff,) ); assert_eq!( instance .get_typed_func::<(), (i8,)>(&mut store, "retm1-s8")? - .call_and_post_return(&mut store, ())?, + .call(&mut store, ())?, (-1,) ); assert_eq!( instance .get_typed_func::<(), (u16,)>(&mut store, "retm1-u16")? - .call_and_post_return(&mut store, ())?, + .call(&mut store, ())?, (0xffff,) ); assert_eq!( instance .get_typed_func::<(), (i16,)>(&mut store, "retm1-s16")? - .call_and_post_return(&mut store, ())?, + .call(&mut store, ())?, (-1,) ); assert_eq!( instance .get_typed_func::<(), (u32,)>(&mut store, "retm1-u32")? - .call_and_post_return(&mut store, ())?, + .call(&mut store, ())?, (0xffffffff,) ); assert_eq!( instance .get_typed_func::<(), (i32,)>(&mut store, "retm1-s32")? - .call_and_post_return(&mut store, ())?, + .call(&mut store, ())?, (-1,) ); assert_eq!( instance .get_typed_func::<(), (u64,)>(&mut store, "retm1-u64")? - .call_and_post_return(&mut store, ())?, + .call(&mut store, ())?, (0xffffffff_ffffffff,) ); assert_eq!( instance .get_typed_func::<(), (i64,)>(&mut store, "retm1-s64")? - .call_and_post_return(&mut store, ())?, + .call(&mut store, ())?, (-1,) ); @@ -374,37 +374,37 @@ fn integers() -> Result<()> { assert_eq!( instance .get_typed_func::<(), (u8,)>(&mut store, "retbig-u8")? - .call_and_post_return(&mut store, ())?, + .call(&mut store, ())?, (ret as u8,), ); assert_eq!( instance .get_typed_func::<(), (i8,)>(&mut store, "retbig-s8")? - .call_and_post_return(&mut store, ())?, + .call(&mut store, ())?, (ret as i8,), ); assert_eq!( instance .get_typed_func::<(), (u16,)>(&mut store, "retbig-u16")? - .call_and_post_return(&mut store, ())?, + .call(&mut store, ())?, (ret as u16,), ); assert_eq!( instance .get_typed_func::<(), (i16,)>(&mut store, "retbig-s16")? - .call_and_post_return(&mut store, ())?, + .call(&mut store, ())?, (ret as i16,), ); assert_eq!( instance .get_typed_func::<(), (u32,)>(&mut store, "retbig-u32")? - .call_and_post_return(&mut store, ())?, + .call(&mut store, ())?, (ret,), ); assert_eq!( instance .get_typed_func::<(), (i32,)>(&mut store, "retbig-s32")? - .call_and_post_return(&mut store, ())?, + .call(&mut store, ())?, (ret as i32,), ); @@ -436,16 +436,16 @@ fn type_layers() -> Result<()> { instance .get_typed_func::<(Box,), ()>(&mut store, "take-u32")? - .call_and_post_return(&mut store, (Box::new(2),))?; + .call(&mut store, (Box::new(2),))?; instance .get_typed_func::<(&u32,), ()>(&mut store, "take-u32")? - .call_and_post_return(&mut store, (&2,))?; + .call(&mut store, (&2,))?; instance .get_typed_func::<(Arc,), ()>(&mut store, "take-u32")? - .call_and_post_return(&mut store, (Arc::new(2),))?; + .call(&mut store, (Arc::new(2),))?; instance .get_typed_func::<(&Box>>,), ()>(&mut store, "take-u32")? - .call_and_post_return(&mut store, (&Box::new(Arc::new(Box::new(2))),))?; + .call(&mut store, (&Box::new(Arc::new(Box::new(2))),))?; Ok(()) } @@ -499,13 +499,9 @@ fn floats() -> Result<()> { let u64_to_f64 = instance.get_typed_func::<(u64,), (f64,)>(&mut store, "u64-to-f64")?; assert_eq!(f32_to_u32.call(&mut store, (1.0,))?, (1.0f32.to_bits(),)); - f32_to_u32.post_return(&mut store)?; assert_eq!(f64_to_u64.call(&mut store, (2.0,))?, (2.0f64.to_bits(),)); - f64_to_u64.post_return(&mut store)?; assert_eq!(u32_to_f32.call(&mut store, (3.0f32.to_bits(),))?, (3.0,)); - u32_to_f32.post_return(&mut store)?; assert_eq!(u64_to_f64.call(&mut store, (4.0f64.to_bits(),))?, (4.0,)); - u64_to_f64.post_return(&mut store)?; assert_eq!( u32_to_f32 @@ -514,7 +510,6 @@ fn floats() -> Result<()> { .to_bits(), CANON_32BIT_NAN | 1 ); - u32_to_f32.post_return(&mut store)?; assert_eq!( u64_to_f64 .call(&mut store, (CANON_64BIT_NAN | 1,))? @@ -522,18 +517,15 @@ fn floats() -> Result<()> { .to_bits(), CANON_64BIT_NAN | 1, ); - u64_to_f64.post_return(&mut store)?; assert_eq!( f32_to_u32.call(&mut store, (f32::from_bits(CANON_32BIT_NAN | 1),))?, (CANON_32BIT_NAN | 1,) ); - f32_to_u32.post_return(&mut store)?; assert_eq!( f64_to_u64.call(&mut store, (f64::from_bits(CANON_64BIT_NAN | 1),))?, (CANON_64BIT_NAN | 1,) ); - f64_to_u64.post_return(&mut store)?; Ok(()) } @@ -564,15 +556,10 @@ fn bools() -> Result<()> { let bool_to_u32 = instance.get_typed_func::<(bool,), (u32,)>(&mut store, "bool-to-u32")?; assert_eq!(bool_to_u32.call(&mut store, (false,))?, (0,)); - bool_to_u32.post_return(&mut store)?; assert_eq!(bool_to_u32.call(&mut store, (true,))?, (1,)); - bool_to_u32.post_return(&mut store)?; assert_eq!(u32_to_bool.call(&mut store, (0,))?, (false,)); - u32_to_bool.post_return(&mut store)?; assert_eq!(u32_to_bool.call(&mut store, (1,))?, (true,)); - u32_to_bool.post_return(&mut store)?; assert_eq!(u32_to_bool.call(&mut store, (2,))?, (true,)); - u32_to_bool.post_return(&mut store)?; Ok(()) } @@ -604,9 +591,7 @@ fn chars() -> Result<()> { let mut roundtrip = |x: char| -> Result<()> { assert_eq!(char_to_u32.call(&mut store, (x,))?, (x as u32,)); - char_to_u32.post_return(&mut store)?; assert_eq!(u32_to_char.call(&mut store, (x as u32,))?, (x,)); - u32_to_char.post_return(&mut store)?; Ok(()) }; @@ -682,7 +667,7 @@ fn tuple_result() -> Result<()> { let input = (-1, 100, 3.0, 100.0); let output = instance .get_typed_func::<(i8, u16, f32, f64), ((i8, u16, f32, f64),)>(&mut store, "tuple")? - .call_and_post_return(&mut store, input)?; + .call(&mut store, input)?; assert_eq!((input,), output); let invalid_func = @@ -773,23 +758,19 @@ fn strings() -> Result<()> { let mut roundtrip = |x: &str| -> Result<()> { let ret = list8_to_str.call(&mut store, (x.as_bytes(),))?.0; assert_eq!(ret.to_str(&store)?, x); - list8_to_str.post_return(&mut store)?; let utf16 = x.encode_utf16().collect::>(); let ret = list16_to_str.call(&mut store, (&utf16[..],))?.0; assert_eq!(ret.to_str(&store)?, x); - list16_to_str.post_return(&mut store)?; let ret = str_to_list8.call(&mut store, (x,))?.0; assert_eq!( ret.iter(&mut store).collect::>>()?, x.as_bytes() ); - str_to_list8.post_return(&mut store)?; let ret = str_to_list16.call(&mut store, (x,))?.0; assert_eq!(ret.iter(&mut store).collect::>>()?, utf16,); - str_to_list16.post_return(&mut store)?; Ok(()) }; @@ -803,29 +784,24 @@ fn strings() -> Result<()> { let ret = list8_to_str.call(&mut store, (b"\xff",))?.0; let err = ret.to_str(&store).unwrap_err(); assert!(err.to_string().contains("invalid utf-8"), "{}", err); - list8_to_str.post_return(&mut store)?; let ret = list8_to_str .call(&mut store, (b"hello there \xff invalid",))? .0; let err = ret.to_str(&store).unwrap_err(); assert!(err.to_string().contains("invalid utf-8"), "{}", err); - list8_to_str.post_return(&mut store)?; let ret = list16_to_str.call(&mut store, (&[0xd800],))?.0; let err = ret.to_str(&store).unwrap_err(); assert!(err.to_string().contains("unpaired surrogate"), "{}", err); - list16_to_str.post_return(&mut store)?; let ret = list16_to_str.call(&mut store, (&[0xdfff],))?.0; let err = ret.to_str(&store).unwrap_err(); assert!(err.to_string().contains("unpaired surrogate"), "{}", err); - list16_to_str.post_return(&mut store)?; let ret = list16_to_str.call(&mut store, (&[0xd800, 0xff00],))?.0; let err = ret.to_str(&store).unwrap_err(); assert!(err.to_string().contains("unpaired surrogate"), "{}", err); - list16_to_str.post_return(&mut store)?; Ok(()) } @@ -2096,12 +2072,12 @@ fn some_traps() -> Result<()> { with_new_instance(&engine, &component, |store, instance| { instance .get_typed_func::<(&[u8],), ()>(&mut *store, "take-list-end-oob")? - .call_and_post_return(store, (&[],)) + .call(store, (&[],)) })?; with_new_instance(&engine, &component, |store, instance| { instance .get_typed_func::<(&[u8],), ()>(&mut *store, "take-list-end-oob")? - .call_and_post_return(store, (&[1, 2, 3, 4],)) + .call(store, (&[1, 2, 3, 4],)) })?; let err = with_new_instance(&engine, &component, |store, instance| { instance @@ -2113,12 +2089,12 @@ fn some_traps() -> Result<()> { with_new_instance(&engine, &component, |store, instance| { instance .get_typed_func::<(&str,), ()>(&mut *store, "take-string-end-oob")? - .call_and_post_return(store, ("",)) + .call(store, ("",)) })?; with_new_instance(&engine, &component, |store, instance| { instance .get_typed_func::<(&str,), ()>(&mut *store, "take-string-end-oob")? - .call_and_post_return(store, ("abcd",)) + .call(store, ("abcd",)) })?; let err = with_new_instance(&engine, &component, |store, instance| { instance @@ -2214,15 +2190,12 @@ fn char_bool_memory() -> Result<()> { let (ret,) = func.call(&mut store, (0, 'a' as u32))?; assert_eq!(ret, (false, 'a')); - func.post_return(&mut store)?; let (ret,) = func.call(&mut store, (1, '🍰' as u32))?; assert_eq!(ret, (true, '🍰')); - func.post_return(&mut store)?; let (ret,) = func.call(&mut store, (2, 'a' as u32))?; assert_eq!(ret, (true, 'a')); - func.post_return(&mut store)?; assert!(func.call(&mut store, (0, 0xd800)).is_err()); @@ -2434,26 +2407,20 @@ fn option() -> Result<()> { let option_u8_to_tuple = instance .get_typed_func::<(Option,), ((u32, u32),)>(&mut store, "option-u8-to-tuple")?; assert_eq!(option_u8_to_tuple.call(&mut store, (None,))?, ((0, 0),)); - option_u8_to_tuple.post_return(&mut store)?; assert_eq!(option_u8_to_tuple.call(&mut store, (Some(0),))?, ((1, 0),)); - option_u8_to_tuple.post_return(&mut store)?; assert_eq!( option_u8_to_tuple.call(&mut store, (Some(100),))?, ((1, 100),) ); - option_u8_to_tuple.post_return(&mut store)?; let option_u32_to_tuple = instance .get_typed_func::<(Option,), ((u32, u32),)>(&mut store, "option-u32-to-tuple")?; assert_eq!(option_u32_to_tuple.call(&mut store, (None,))?, ((0, 0),)); - option_u32_to_tuple.post_return(&mut store)?; assert_eq!(option_u32_to_tuple.call(&mut store, (Some(0),))?, ((1, 0),)); - option_u32_to_tuple.post_return(&mut store)?; assert_eq!( option_u32_to_tuple.call(&mut store, (Some(100),))?, ((1, 100),) ); - option_u32_to_tuple.post_return(&mut store)?; let option_string_to_tuple = instance.get_typed_func::<(Option<&str>,), ((u32, WasmStr),)>( &mut store, @@ -2462,39 +2429,30 @@ fn option() -> Result<()> { let ((a, b),) = option_string_to_tuple.call(&mut store, (None,))?; assert_eq!(a, 0); assert_eq!(b.to_str(&store)?, ""); - option_string_to_tuple.post_return(&mut store)?; let ((a, b),) = option_string_to_tuple.call(&mut store, (Some(""),))?; assert_eq!(a, 1); assert_eq!(b.to_str(&store)?, ""); - option_string_to_tuple.post_return(&mut store)?; let ((a, b),) = option_string_to_tuple.call(&mut store, (Some("hello"),))?; assert_eq!(a, 1); assert_eq!(b.to_str(&store)?, "hello"); - option_string_to_tuple.post_return(&mut store)?; let instance = linker.instantiate(&mut store, &component)?; let to_option_u8 = instance.get_typed_func::<(u32, u32), (Option,)>(&mut store, "to-option-u8")?; assert_eq!(to_option_u8.call(&mut store, (0x00_00, 0))?, (None,)); - to_option_u8.post_return(&mut store)?; assert_eq!(to_option_u8.call(&mut store, (0x00_01, 0))?, (Some(0),)); - to_option_u8.post_return(&mut store)?; assert_eq!(to_option_u8.call(&mut store, (0xfd_01, 0))?, (Some(0xfd),)); - to_option_u8.post_return(&mut store)?; assert!(to_option_u8.call(&mut store, (0x00_02, 0)).is_err()); let instance = linker.instantiate(&mut store, &component)?; let to_option_u32 = instance.get_typed_func::<(u32, u32), (Option,)>(&mut store, "to-option-u32")?; assert_eq!(to_option_u32.call(&mut store, (0, 0))?, (None,)); - to_option_u32.post_return(&mut store)?; assert_eq!(to_option_u32.call(&mut store, (1, 0))?, (Some(0),)); - to_option_u32.post_return(&mut store)?; assert_eq!( to_option_u32.call(&mut store, (1, 0x1234fead))?, (Some(0x1234fead),) ); - to_option_u32.post_return(&mut store)?; assert!(to_option_u32.call(&mut store, (2, 0)).is_err()); let instance = linker.instantiate(&mut store, &component)?; @@ -2502,13 +2460,10 @@ fn option() -> Result<()> { .get_typed_func::<(u32, &str), (Option,)>(&mut store, "to-option-string")?; let ret = to_option_string.call(&mut store, (0, ""))?.0; assert!(ret.is_none()); - to_option_string.post_return(&mut store)?; let ret = to_option_string.call(&mut store, (1, ""))?.0; assert_eq!(ret.unwrap().to_str(&store)?, ""); - to_option_string.post_return(&mut store)?; let ret = to_option_string.call(&mut store, (1, "cheesecake"))?.0; assert_eq!(ret.unwrap().to_str(&store)?, "cheesecake"); - to_option_string.post_return(&mut store)?; assert!(to_option_string.call(&mut store, (2, "")).is_err()); Ok(()) @@ -2602,19 +2557,15 @@ fn expected() -> Result<()> { let take_expected_unit = instance.get_typed_func::<(Result<(), ()>,), (u32,)>(&mut store, "take-expected-unit")?; assert_eq!(take_expected_unit.call(&mut store, (Ok(()),))?, (0,)); - take_expected_unit.post_return(&mut store)?; assert_eq!(take_expected_unit.call(&mut store, (Err(()),))?, (1,)); - take_expected_unit.post_return(&mut store)?; let take_expected_u8_f32 = instance .get_typed_func::<(Result,), ((u32, u32),)>(&mut store, "take-expected-u8-f32")?; assert_eq!(take_expected_u8_f32.call(&mut store, (Ok(1),))?, ((0, 1),)); - take_expected_u8_f32.post_return(&mut store)?; assert_eq!( take_expected_u8_f32.call(&mut store, (Err(2.0),))?, ((1, 2.0f32.to_bits()),) ); - take_expected_u8_f32.post_return(&mut store)?; let take_expected_string = instance .get_typed_func::<(Result<&str, &[u8]>,), ((u32, WasmStr),)>( @@ -2624,19 +2575,15 @@ fn expected() -> Result<()> { let ((a, b),) = take_expected_string.call(&mut store, (Ok("hello"),))?; assert_eq!(a, 0); assert_eq!(b.to_str(&store)?, "hello"); - take_expected_string.post_return(&mut store)?; let ((a, b),) = take_expected_string.call(&mut store, (Err(b"goodbye"),))?; assert_eq!(a, 1); assert_eq!(b.to_str(&store)?, "goodbye"); - take_expected_string.post_return(&mut store)?; let instance = linker.instantiate(&mut store, &component)?; let to_expected_unit = instance.get_typed_func::<(u32,), (Result<(), ()>,)>(&mut store, "to-expected-unit")?; assert_eq!(to_expected_unit.call(&mut store, (0,))?, (Ok(()),)); - to_expected_unit.post_return(&mut store)?; assert_eq!(to_expected_unit.call(&mut store, (1,))?, (Err(()),)); - to_expected_unit.post_return(&mut store)?; let err = to_expected_unit.call(&mut store, (2,)).unwrap_err(); assert!(err.to_string().contains("invalid expected"), "{}", err); @@ -2644,19 +2591,15 @@ fn expected() -> Result<()> { let to_expected_s16_f32 = instance .get_typed_func::<(u32, u32), (Result,)>(&mut store, "to-expected-s16-f32")?; assert_eq!(to_expected_s16_f32.call(&mut store, (0, 0))?, (Ok(0),)); - to_expected_s16_f32.post_return(&mut store)?; assert_eq!(to_expected_s16_f32.call(&mut store, (0, 100))?, (Ok(100),)); - to_expected_s16_f32.post_return(&mut store)?; assert_eq!( to_expected_s16_f32.call(&mut store, (1, 1.0f32.to_bits()))?, (Err(1.0),) ); - to_expected_s16_f32.post_return(&mut store)?; let ret = to_expected_s16_f32 .call(&mut store, (1, CANON_32BIT_NAN | 1))? .0; assert_eq!(ret.unwrap_err().to_bits(), CANON_32BIT_NAN | 1); - to_expected_s16_f32.post_return(&mut store)?; assert!(to_expected_s16_f32.call(&mut store, (2, 0)).is_err()); Ok(()) @@ -3008,7 +2951,7 @@ fn raw_slice_of_various_types() -> Result<()> { let list = instance .get_typed_func::<(), (WasmList,)>(&mut store, "list-u8")? - .call_and_post_return(&mut store, ())? + .call(&mut store, ())? .0; assert_eq!( list.as_le_slice(&store), @@ -3019,7 +2962,7 @@ fn raw_slice_of_various_types() -> Result<()> { ); let list = instance .get_typed_func::<(), (WasmList,)>(&mut store, "list-i8")? - .call_and_post_return(&mut store, ())? + .call(&mut store, ())? .0; assert_eq!( list.as_le_slice(&store), @@ -3031,7 +2974,7 @@ fn raw_slice_of_various_types() -> Result<()> { let list = instance .get_typed_func::<(), (WasmList,)>(&mut store, "list-u16")? - .call_and_post_return(&mut store, ())? + .call(&mut store, ())? .0; assert_eq!( list.as_le_slice(&store), @@ -3048,7 +2991,7 @@ fn raw_slice_of_various_types() -> Result<()> { ); let list = instance .get_typed_func::<(), (WasmList,)>(&mut store, "list-i16")? - .call_and_post_return(&mut store, ())? + .call(&mut store, ())? .0; assert_eq!( list.as_le_slice(&store), @@ -3065,7 +3008,7 @@ fn raw_slice_of_various_types() -> Result<()> { ); let list = instance .get_typed_func::<(), (WasmList,)>(&mut store, "list-u32")? - .call_and_post_return(&mut store, ())? + .call(&mut store, ())? .0; assert_eq!( list.as_le_slice(&store), @@ -3078,7 +3021,7 @@ fn raw_slice_of_various_types() -> Result<()> { ); let list = instance .get_typed_func::<(), (WasmList,)>(&mut store, "list-i32")? - .call_and_post_return(&mut store, ())? + .call(&mut store, ())? .0; assert_eq!( list.as_le_slice(&store), @@ -3091,7 +3034,7 @@ fn raw_slice_of_various_types() -> Result<()> { ); let list = instance .get_typed_func::<(), (WasmList,)>(&mut store, "list-u64")? - .call_and_post_return(&mut store, ())? + .call(&mut store, ())? .0; assert_eq!( list.as_le_slice(&store), @@ -3102,7 +3045,7 @@ fn raw_slice_of_various_types() -> Result<()> { ); let list = instance .get_typed_func::<(), (WasmList,)>(&mut store, "list-i64")? - .call_and_post_return(&mut store, ())? + .call(&mut store, ())? .0; assert_eq!( list.as_le_slice(&store), @@ -3460,8 +3403,73 @@ fn test_recurse(kind: RecurseKind) -> Result<()> { Ok(()) } -#[test] -fn thread_index_during_init() -> Result<()> { +#[derive(Copy, Clone)] +enum ApiStyle { + Sync, + Async, + Concurrent, +} + +fn thread_config() -> Config { + let mut config = super::config(); + config.wasm_component_model_threading(true); + config +} + +async fn instantiate( + store: &mut Store, + linker: &Linker, + component: &Component, + style: ApiStyle, +) -> Result { + match style { + ApiStyle::Sync => linker.instantiate(store, &component), + ApiStyle::Async | ApiStyle::Concurrent => linker.instantiate_async(store, &component).await, + } +} + +async fn call< + P: ComponentNamedList + Lower + 'static, + R: ComponentNamedList + Lift + 'static, + T: Send, +>( + store: &mut Store, + func: TypedFunc, + params: P, + style: ApiStyle, +) -> Result { + match style { + ApiStyle::Sync => func.call(&mut *store, params), + ApiStyle::Async => func.call_async(&mut *store, params).await, + ApiStyle::Concurrent => Ok(store + .run_concurrent(async |access| func.call_concurrent(access, params).await) + .await?? + .0), + } +} + +async fn resource_drop( + store: &mut Store, + resource: ResourceAny, + style: ApiStyle, +) -> Result<()> { + match style { + ApiStyle::Sync => resource.resource_drop(store), + ApiStyle::Async | ApiStyle::Concurrent => resource.resource_drop_async(store).await, + } +} + +#[tokio::test] +async fn thread_index_via_instantiation_sync() -> Result<()> { + thread_index_via_instantiation(ApiStyle::Sync).await +} + +#[tokio::test] +async fn thread_index_via_instantiation_async() -> Result<()> { + thread_index_via_instantiation(ApiStyle::Async).await +} + +async fn thread_index_via_instantiation(style: ApiStyle) -> Result<()> { let component = r#" (component (core module $m @@ -3477,18 +3485,30 @@ fn thread_index_during_init() -> Result<()> { )))) ) "#; - let mut config = super::config(); - config.wasm_component_model_threading(true); - let engine = Engine::new(&config)?; + let engine = Engine::new(&thread_config())?; let component = Component::new(&engine, component)?; let mut store = Store::new(&engine, ()); let linker = Linker::new(&engine); - linker.instantiate(&mut store, &component)?; + instantiate(&mut store, &linker, &component, style).await?; Ok(()) } -#[test] -fn thread_index_via_sync_host_call() -> Result<()> { +#[tokio::test] +async fn thread_index_via_call_sync() -> Result<()> { + thread_index_via_call(ApiStyle::Sync).await +} + +#[tokio::test] +async fn thread_index_via_call_async() -> Result<()> { + thread_index_via_call(ApiStyle::Async).await +} + +#[tokio::test] +async fn thread_index_via_call_concurrent() -> Result<()> { + thread_index_via_call(ApiStyle::Concurrent).await +} + +async fn thread_index_via_call(style: ApiStyle) -> Result<()> { let component = r#" (component (core module $m @@ -3504,20 +3524,32 @@ fn thread_index_via_sync_host_call() -> Result<()> { (func (export "run") (canon lift (core func $m "run"))) ) "#; - let mut config = super::config(); - config.wasm_component_model_threading(true); - let engine = Engine::new(&config)?; + let engine = Engine::new(&thread_config())?; let component = Component::new(&engine, component)?; let mut store = Store::new(&engine, ()); let linker = Linker::new(&engine); - let instance = linker.instantiate(&mut store, &component)?; + let instance = instantiate(&mut store, &linker, &component, style).await?; let run = instance.get_typed_func::<(), ()>(&mut store, "run")?; - run.call_and_post_return(&mut store, ())?; + call(&mut store, run, (), style).await?; Ok(()) } -#[test] -fn thread_index_via_sync_host_call_post_return() -> Result<()> { +#[tokio::test] +async fn thread_index_via_post_return_sync() -> Result<()> { + thread_index_via_post_return(ApiStyle::Sync).await +} + +#[tokio::test] +async fn thread_index_via_post_return_async() -> Result<()> { + thread_index_via_post_return(ApiStyle::Async).await +} + +#[tokio::test] +async fn thread_index_via_post_return_concurrent() -> Result<()> { + thread_index_via_post_return(ApiStyle::Concurrent).await +} + +async fn thread_index_via_post_return(style: ApiStyle) -> Result<()> { let component = r#" (component (core module $m @@ -3541,20 +3573,32 @@ fn thread_index_via_sync_host_call_post_return() -> Result<()> { (func (export "run") (canon lift (core func $m "run") (post-return (func $m "run-post-return")))) ) "#; - let mut config = super::config(); - config.wasm_component_model_threading(true); - let engine = Engine::new(&config)?; + let engine = Engine::new(&thread_config())?; let component = Component::new(&engine, component)?; let mut store = Store::new(&engine, ()); let linker = Linker::new(&engine); - let instance = linker.instantiate(&mut store, &component)?; + let instance = instantiate(&mut store, &linker, &component, style).await?; let run = instance.get_typed_func::<(), ()>(&mut store, "run")?; - run.call_and_post_return(&mut store, ())?; + call(&mut store, run, (), style).await?; Ok(()) } -#[test] -fn thread_index_via_sync_host_call_cabi_realloc() -> Result<()> { +#[tokio::test] +async fn thread_index_via_cabi_realloc_sync() -> Result<()> { + thread_index_via_cabi_realloc(ApiStyle::Sync).await +} + +#[tokio::test] +async fn thread_index_via_cabi_realloc_async() -> Result<()> { + thread_index_via_cabi_realloc(ApiStyle::Async).await +} + +#[tokio::test] +async fn thread_index_via_cabi_realloc_concurrent() -> Result<()> { + thread_index_via_cabi_realloc(ApiStyle::Concurrent).await +} + +async fn thread_index_via_cabi_realloc(style: ApiStyle) -> Result<()> { let component = r#" (component (core module $m @@ -3584,20 +3628,32 @@ fn thread_index_via_sync_host_call_cabi_realloc() -> Result<()> { )) ) "#; - let mut config = super::config(); - config.wasm_component_model_threading(true); - let engine = Engine::new(&config)?; + let engine = Engine::new(&thread_config())?; let component = Component::new(&engine, component)?; let mut store = Store::new(&engine, ()); let linker = Linker::new(&engine); - let instance = linker.instantiate(&mut store, &component)?; - let run = instance.get_typed_func::<(&str,), ()>(&mut store, "run")?; - run.call_and_post_return(&mut store, ("hola",))?; + let instance = instantiate(&mut store, &linker, &component, style).await?; + let run = instance.get_typed_func::<(String,), ()>(&mut store, "run")?; + call(&mut store, run, ("hola".to_string(),), style).await?; Ok(()) } -#[test] -fn thread_index_via_resource_drop_from_host() -> Result<()> { +#[tokio::test] +async fn thread_index_via_resource_drop_sync() -> Result<()> { + thread_index_via_resource_drop(ApiStyle::Sync).await +} + +#[tokio::test] +async fn thread_index_via_resource_drop_async() -> Result<()> { + thread_index_via_resource_drop(ApiStyle::Async).await +} + +#[tokio::test] +async fn thread_index_via_resource_drop_concurrent() -> Result<()> { + thread_index_via_resource_drop(ApiStyle::Concurrent).await +} + +async fn thread_index_via_resource_drop(style: ApiStyle) -> Result<()> { let component = r#" (component (core module $m @@ -3635,25 +3691,37 @@ fn thread_index_via_resource_drop_from_host() -> Result<()> { (export "i" (instance $c)) ) "#; - let mut config = super::config(); - config.wasm_component_model_threading(true); - let engine = Engine::new(&config)?; + let engine = Engine::new(&thread_config())?; let component = Component::new(&engine, component)?; let mut store = Store::new(&engine, ()); let linker = Linker::new(&engine); - let instance = linker.instantiate(&mut store, &component)?; + let instance = instantiate(&mut store, &linker, &component, style).await?; let instance_index = instance.get_export_index(&mut store, None, "i").unwrap(); let func_index = instance .get_export_index(&mut store, Some(&instance_index), "new") .unwrap(); let run = instance.get_typed_func::<(), (ResourceAny,)>(&mut store, &func_index)?; - let (resource,) = run.call_and_post_return(&mut store, ())?; - resource.resource_drop(&mut store)?; + let (resource,) = call(&mut store, run, (), style).await?; + resource_drop(&mut store, resource, style).await?; Ok(()) } -#[test] -fn thread_index_via_sync_host_call_and_sync_guest_call() -> Result<()> { +#[tokio::test] +async fn thread_index_via_guest_call_sync() -> Result<()> { + thread_index_via_guest_call(ApiStyle::Sync).await +} + +#[tokio::test] +async fn thread_index_via_guest_call_async() -> Result<()> { + thread_index_via_guest_call(ApiStyle::Async).await +} + +#[tokio::test] +async fn thread_index_via_guest_call_concurrent() -> Result<()> { + thread_index_via_guest_call(ApiStyle::Concurrent).await +} + +async fn thread_index_via_guest_call(style: ApiStyle) -> Result<()> { let component = r#" (component (component $c @@ -3699,15 +3767,13 @@ fn thread_index_via_sync_host_call_and_sync_guest_call() -> Result<()> { (func (export "run") (alias export $d "run")) ) "#; - let mut config = super::config(); - config.wasm_component_model_threading(true); - let engine = Engine::new(&config)?; + let engine = Engine::new(&thread_config())?; let component = Component::new(&engine, component)?; let mut store = Store::new(&engine, ()); let linker = Linker::new(&engine); - let instance = linker.instantiate(&mut store, &component)?; + let instance = instantiate(&mut store, &linker, &component, style).await?; let run = instance.get_typed_func::<(), ()>(&mut store, "run")?; - run.call_and_post_return(&mut store, ())?; + call(&mut store, run, (), style).await?; Ok(()) } diff --git a/tests/all/component_model/macros.rs b/tests/all/component_model/macros.rs index c8d790c7ff2c..554a19aa6579 100644 --- a/tests/all/component_model/macros.rs +++ b/tests/all/component_model/macros.rs @@ -1,6 +1,6 @@ #![cfg(not(miri))] -use super::{TypedFuncExt, make_echo_component}; +use super::make_echo_component; use wasmtime::Result; use wasmtime::component::{Component, ComponentType, Lift, Linker, Lower}; use wasmtime::{Engine, Store}; @@ -30,7 +30,7 @@ fn record_derive() -> Result<()> { let input = Foo { a: -42, b: 73 }; let output = instance .get_typed_func::<(Foo,), (Foo,)>(&mut store, "echo")? - .call_and_post_return(&mut store, (input,))?; + .call(&mut store, (input,))?; assert_eq!((input,), output); @@ -116,7 +116,7 @@ fn record_derive() -> Result<()> { let output = instance .get_typed_func::<(Generic,), (Generic,)>(&mut store, "echo")? - .call_and_post_return(&mut store, (input,))?; + .call(&mut store, (input,))?; assert_eq!((input,), output); @@ -150,7 +150,7 @@ fn variant_derive() -> Result<()> { let func = instance.get_typed_func::<(Foo,), (Foo,)>(&mut store, "echo")?; for &input in &[Foo::A(-42), Foo::B(73), Foo::C] { - let output = func.call_and_post_return(&mut store, (input,))?; + let output = func.call(&mut store, (input,))?; assert_eq!((input,), output); } @@ -240,7 +240,7 @@ fn variant_derive() -> Result<()> { .get_typed_func::<(Generic,), (Generic,)>(&mut store, "echo")?; for &input in &[Generic::::A(-42), Generic::B(73), Generic::C] { - let output = func.call_and_post_return(&mut store, (input,))?; + let output = func.call(&mut store, (input,))?; assert_eq!((input,), output); } @@ -273,7 +273,7 @@ fn enum_derive() -> Result<()> { let func = instance.get_typed_func::<(Foo,), (Foo,)>(&mut store, "echo")?; for &input in &[Foo::A, Foo::B, Foo::C] { - let output = func.call_and_post_return(&mut store, (input,))?; + let output = func.call(&mut store, (input,))?; assert_eq!((input,), output); } @@ -342,7 +342,7 @@ fn enum_derive() -> Result<()> { let func = instance.get_typed_func::<(Many,), (Many,)>(&mut store, "echo")?; for &input in &[Many::V0, Many::V1, Many::V254, Many::V255, Many::V256] { - let output = func.call_and_post_return(&mut store, (input,))?; + let output = func.call(&mut store, (input,))?; assert_eq!((input,), output); } @@ -404,7 +404,7 @@ fn flags() -> Result<()> { input |= Foo::C; } - let output = func.call_and_post_return(&mut store, (input,))?; + let output = func.call(&mut store, (input,))?; assert_eq!((input,), output); } @@ -500,7 +500,7 @@ fn flags() -> Result<()> { Foo8Exact::F6, Foo8Exact::F7, ] { - let output = func.call_and_post_return(&mut store, (input,))?; + let output = func.call(&mut store, (input,))?; assert_eq!((input,), output); } @@ -543,7 +543,7 @@ fn flags() -> Result<()> { let func = instance.get_typed_func::<(Foo16,), (Foo16,)>(&mut store, "echo")?; for &input in &[Foo16::F0, Foo16::F1, Foo16::F6, Foo16::F7, Foo16::F8] { - let output = func.call_and_post_return(&mut store, (input,))?; + let output = func.call(&mut store, (input,))?; assert_eq!((input,), output); } @@ -597,7 +597,7 @@ fn flags() -> Result<()> { Foo16Exact::F14, Foo16Exact::F15, ] { - let output = func.call_and_post_return(&mut store, (input,))?; + let output = func.call(&mut store, (input,))?; assert_eq!((input,), output); } @@ -630,7 +630,7 @@ fn flags() -> Result<()> { let func = instance.get_typed_func::<(Foo32,), (Foo32,)>(&mut store, "echo")?; for &input in &[Foo32::F0, Foo32::F1, Foo32::F14, Foo32::F15, Foo32::F16] { - let output = func.call_and_post_return(&mut store, (input,))?; + let output = func.call(&mut store, (input,))?; assert_eq!((input,), output); } @@ -684,7 +684,7 @@ fn flags() -> Result<()> { Foo32Exact::F30, Foo32Exact::F31, ] { - let output = func.call_and_post_return(&mut store, (input,))?; + let output = func.call(&mut store, (input,))?; assert_eq!((input,), output); } diff --git a/tests/all/component_model/missing_async.rs b/tests/all/component_model/missing_async.rs index 56851aa4cbaf..ec4fdc935a37 100644 --- a/tests/all/component_model/missing_async.rs +++ b/tests/all/component_model/missing_async.rs @@ -44,17 +44,6 @@ async fn async_disallows_func_call() -> Result<()> { Ok(()) } -#[tokio::test] -async fn async_disallows_func_post_return() -> Result<()> { - let mut store = async_store(); - let func = func_in_store(&mut store).await?; - func.call_async(&mut store, &[], &mut []).await?; - - assert!(func.post_return(&mut store).is_err()); - func.post_return_async(&mut store).await?; - Ok(()) -} - #[tokio::test] async fn async_disallows_typed_func_call() -> Result<()> { let mut store = async_store(); @@ -65,17 +54,6 @@ async fn async_disallows_typed_func_call() -> Result<()> { Ok(()) } -#[tokio::test] -async fn async_disallows_typed_func_post_return() -> Result<()> { - let mut store = async_store(); - let func = func_in_store(&mut store).await?; - let func = func.typed::<(), ()>(&store)?; - func.call_async(&mut store, ()).await?; - assert!(func.post_return(&mut store).is_err()); - func.post_return_async(&mut store).await?; - Ok(()) -} - #[tokio::test] async fn async_disallows_instantiate() -> Result<()> { let mut store = async_store(); @@ -200,7 +178,6 @@ async fn async_disallows_resource_any_drop() -> Result<()> { .await?; let func = instance.get_typed_func::<(u32,), (ResourceAny,)>(&mut store, "mk")?; let (resource,) = func.call_async(&mut store, (42,)).await?; - func.post_return_async(&mut store).await?; assert!(resource.resource_drop(&mut store).is_err()); resource.resource_drop_async(&mut store).await?; diff --git a/tests/all/component_model/post_return.rs b/tests/all/component_model/post_return.rs index 9ae1d30a6312..5cf23edc7c85 100644 --- a/tests/all/component_model/post_return.rs +++ b/tests/all/component_model/post_return.rs @@ -4,86 +4,6 @@ use wasmtime::Result; use wasmtime::component::*; use wasmtime::{Store, StoreContextMut, Trap}; -#[test] -fn invalid_api() -> Result<()> { - let component = r#" - (component - (core module $m - (func (export "thunk1")) - (func (export "thunk2")) - ) - (core instance $i (instantiate $m)) - (func (export "thunk1") - (canon lift (core func $i "thunk1")) - ) - (func (export "thunk2") - (canon lift (core func $i "thunk2")) - ) - ) - "#; - - let engine = super::engine(); - let component = Component::new(&engine, component)?; - let mut store = Store::new(&engine, ()); - let instance = Linker::new(&engine).instantiate(&mut store, &component)?; - let thunk1 = instance.get_typed_func::<(), ()>(&mut store, "thunk1")?; - let thunk2 = instance.get_typed_func::<(), ()>(&mut store, "thunk2")?; - - // Ensure that we can't call `post_return` before doing anything - let msg = "post_return can only be called after a function has previously been called"; - assert_panics(|| drop(thunk1.post_return(&mut store)), msg); - assert_panics(|| drop(thunk2.post_return(&mut store)), msg); - - // Schedule a "needs post return" - thunk1.call(&mut store, ())?; - - // Ensure that we can't reenter the instance through either this function or - // another one. - let err = thunk1.call(&mut store, ()).unwrap_err(); - assert_eq!( - err.downcast_ref(), - Some(&Trap::CannotEnterComponent), - "{err}", - ); - let err = thunk2.call(&mut store, ()).unwrap_err(); - assert_eq!( - err.downcast_ref(), - Some(&Trap::CannotEnterComponent), - "{err}", - ); - - // Calling post-return on the wrong function should panic - assert_panics( - || drop(thunk2.post_return(&mut store)), - "calling post_return on wrong function", - ); - - // Actually execute the post-return - thunk1.post_return(&mut store)?; - - // And now post-return should be invalid again. - assert_panics(|| drop(thunk1.post_return(&mut store)), msg); - assert_panics(|| drop(thunk2.post_return(&mut store)), msg); - - Ok(()) -} - -#[track_caller] -fn assert_panics(f: impl FnOnce(), msg: &str) { - match std::panic::catch_unwind(std::panic::AssertUnwindSafe(f)) { - Ok(()) => panic!("expected closure to panic"), - Err(e) => match e.downcast::() { - Ok(s) => { - assert!(s.contains(msg), "bad panic: {s}"); - } - Err(e) => match e.downcast::<&'static str>() { - Ok(s) => assert!(s.contains(msg), "bad panic: {s}"), - Err(_) => panic!("bad panic"), - }, - }, - } -} - #[test] fn invoke_post_return() -> Result<()> { let component = r#" @@ -129,8 +49,7 @@ fn invoke_post_return() -> Result<()> { let instance = linker.instantiate(&mut store, &component)?; let thunk = instance.get_typed_func::<(), ()>(&mut store, "thunk")?; - thunk.call(&mut store, ())?; - let result = thunk.post_return(&mut store); + let result = thunk.call(&mut store, ()); assert!(matches!( result.unwrap_err().downcast::(), Ok(Trap::CannotLeaveComponent) @@ -200,16 +119,12 @@ fn post_return_all_types() -> Result<()> { let f64 = instance.get_typed_func::<(), (f64,)>(&mut store, "f64")?; assert_eq!(i32.call(&mut store, ())?, (1,)); - i32.post_return(&mut store)?; assert_eq!(i64.call(&mut store, ())?, (2,)); - i64.post_return(&mut store)?; assert_eq!(f32.call(&mut store, ())?, (3.,)); - f32.post_return(&mut store)?; assert_eq!(f64.call(&mut store, ())?, (4.,)); - f64.post_return(&mut store)?; Ok(()) } @@ -252,7 +167,6 @@ fn post_return_string() -> Result<()> { let get = instance.get_typed_func::<(), (WasmStr,)>(&mut store, "get")?; let s = get.call(&mut store, ())?.0; assert_eq!(s.to_str(&store)?, "hello world"); - get.post_return(&mut store)?; Ok(()) } @@ -280,8 +194,7 @@ fn trap_in_post_return_poisons_instance() -> Result<()> { let mut store = Store::new(&engine, ()); let instance = Linker::new(&engine).instantiate(&mut store, &component)?; let f = instance.get_typed_func::<(), ()>(&mut store, "f")?; - f.call(&mut store, ())?; - let trap = f.post_return(&mut store).unwrap_err().downcast::()?; + let trap = f.call(&mut store, ()).unwrap_err().downcast::()?; assert_eq!(trap, Trap::UnreachableCodeReached); let err = f.call(&mut store, ()).unwrap_err(); assert_eq!( @@ -289,10 +202,6 @@ fn trap_in_post_return_poisons_instance() -> Result<()> { Some(&Trap::CannotEnterComponent), "{err}", ); - assert_panics( - || drop(f.post_return(&mut store)), - "can only be called after", - ); Ok(()) } diff --git a/tests/all/component_model/resources.rs b/tests/all/component_model/resources.rs index f40ab07f2526..000ee2689c45 100644 --- a/tests/all/component_model/resources.rs +++ b/tests/all/component_model/resources.rs @@ -152,13 +152,9 @@ fn resource_any() -> Result<()> { let u_dtor = i.get_typed_func::<(ResourceAny,), ()>(&mut store, "drop-u")?; let (t1,) = t_ctor.call(&mut store, (100,))?; - t_ctor.post_return(&mut store)?; let (t2,) = t_ctor.call(&mut store, (200,))?; - t_ctor.post_return(&mut store)?; let (u1,) = u_ctor.call(&mut store, (300,))?; - u_ctor.post_return(&mut store)?; let (u2,) = u_ctor.call(&mut store, (400,))?; - u_ctor.post_return(&mut store)?; assert_eq!(t1.ty(), t); assert_eq!(t2.ty(), t); @@ -166,16 +162,12 @@ fn resource_any() -> Result<()> { assert_eq!(u2.ty(), u); u_dtor.call(&mut store, (u2,))?; - u_dtor.post_return(&mut store)?; u_dtor.call(&mut store, (u1,))?; - u_dtor.post_return(&mut store)?; t_dtor.call(&mut store, (t1,))?; - t_dtor.post_return(&mut store)?; t_dtor.call(&mut store, (t2,))?; - t_dtor.post_return(&mut store)?; } { @@ -187,13 +179,10 @@ fn resource_any() -> Result<()> { // `t` is placed at host index 0 let (t,) = t_ctor.call(&mut store, (100,))?; - t_ctor.post_return(&mut store)?; t_dtor.call(&mut store, (t,))?; - t_dtor.post_return(&mut store)?; // `u` is also placed at host index 0 since `t` was deallocated let (_u,) = u_ctor.call(&mut store, (100,))?; - u_ctor.post_return(&mut store)?; // reuse of `t` should fail, despite it pointing to a valid resource assert_eq!( @@ -270,7 +259,6 @@ fn mismatch_resource_types() -> Result<()> { let dtor = i.get_typed_func::<(ResourceAny,), ()>(&mut store, "dtor")?; let (t,) = ctor.call(&mut store, (100,))?; - ctor.post_return(&mut store)?; assert_eq!( dtor.call(&mut store, (t,)).unwrap_err().to_string(), "mismatched resource types" @@ -321,19 +309,13 @@ fn drop_in_different_places() -> Result<()> { let dtor3 = i.get_typed_func::<(ResourceAny,), ()>(&mut store, "dtor3")?; let (t,) = ctor.call(&mut store, (100,))?; - ctor.post_return(&mut store)?; dtor1.call(&mut store, (t,))?; - dtor1.post_return(&mut store)?; let (t,) = ctor.call(&mut store, (200,))?; - ctor.post_return(&mut store)?; dtor2.call(&mut store, (t,))?; - dtor2.post_return(&mut store)?; let (t,) = ctor.call(&mut store, (300,))?; - ctor.post_return(&mut store)?; dtor3.call(&mut store, (t,))?; - dtor3.post_return(&mut store)?; Ok(()) } @@ -366,9 +348,7 @@ fn drop_guest_twice() -> Result<()> { let dtor = i.get_typed_func::<(&ResourceAny,), ()>(&mut store, "dtor")?; let (t,) = ctor.call(&mut store, (100,))?; - ctor.post_return(&mut store)?; dtor.call(&mut store, (&t,))?; - dtor.post_return(&mut store)?; assert_eq!( dtor.call(&mut store, (&t,)).unwrap_err().to_string(), @@ -406,7 +386,6 @@ fn drop_host_twice() -> Result<()> { let t = Resource::new_own(100); dtor.call(&mut store, (&t,))?; - dtor.post_return(&mut store)?; assert_eq!( dtor.call(&mut store, (&t,)).unwrap_err().to_string(), @@ -481,7 +460,6 @@ fn manually_destroy() -> Result<()> { // Host resources can be destroyed through `resource_drop` let t1 = Resource::new_own(100); let (t1,) = t1_pass.call(&mut store, (t1,))?; - t1_pass.post_return(&mut store)?; assert_eq!(store.data().drops, 0); assert_eq!(store.data().last_drop, None); t1.resource_drop(&mut store)?; @@ -490,16 +468,11 @@ fn manually_destroy() -> Result<()> { // Guest resources can be destroyed through `resource_drop` let (t2,) = t2_ctor.call(&mut store, (200,))?; - t2_ctor.post_return(&mut store)?; assert_eq!(t2_drops.call(&mut store, ())?, (0,)); - t2_drops.post_return(&mut store)?; assert_eq!(t2_last_drop.call(&mut store, ())?, (0,)); - t2_last_drop.post_return(&mut store)?; t2.resource_drop(&mut store)?; assert_eq!(t2_drops.call(&mut store, ())?, (1,)); - t2_drops.post_return(&mut store)?; assert_eq!(t2_last_drop.call(&mut store, ())?, (200,)); - t2_last_drop.post_return(&mut store)?; // Wires weren't crossed to drop more resources assert_eq!(store.data().drops, 1); @@ -604,12 +577,10 @@ fn dynamic_val() -> Result<()> { let t1 = Resource::new_own(100); let (t1,) = a_typed.call(&mut store, (t1,))?; - a_typed.post_return(&mut store)?; assert_eq!(t1.ty(), ResourceType::host::()); let mut results = [Val::Bool(false)]; a.call(&mut store, &[Val::Resource(t1)], &mut results)?; - a.post_return(&mut store)?; match &results[0] { Val::Resource(resource) => { assert_eq!(resource.ty(), ResourceType::host::()); @@ -629,7 +600,6 @@ fn dynamic_val() -> Result<()> { let t1_any = Resource::::new_own(100).try_into_resource_any(&mut store)?; let mut results = [Val::Bool(false)]; a.call(&mut store, &[Val::Resource(t1_any)], &mut results)?; - a.post_return(&mut store)?; match &results[0] { Val::Resource(resource) => { assert_eq!(resource.ty(), ResourceType::host::()); @@ -650,7 +620,6 @@ fn dynamic_val() -> Result<()> { .try_into_resource_any(&mut store)? .try_into_resource(&mut store)?; let (t1,) = a_typed_result.call(&mut store, (t1,))?; - a_typed_result.post_return(&mut store)?; assert_eq!(t1.rep(), 100); assert!(t1.owned()); @@ -660,7 +629,6 @@ fn dynamic_val() -> Result<()> { .try_into_resource_any(&mut store)?; let mut results = [Val::Bool(false)]; a.call(&mut store, &[Val::Resource(t1_any)], &mut results)?; - a.post_return(&mut store)?; match &results[0] { Val::Resource(resource) => { assert_eq!(resource.ty(), ResourceType::host::()); @@ -740,7 +708,6 @@ fn cannot_reenter_during_import() -> Result<()> { let call = i.get_typed_func::<(), ()>(&mut store, "call")?; let (resource,) = ctor.call(&mut store, (100,))?; - ctor.post_return(&mut store)?; *store.data_mut() = Some(resource); call.call(&mut store, ())?; @@ -779,8 +746,7 @@ fn active_borrows_at_end_of_call() -> Result<()> { let f = i.get_typed_func::<(&Resource,), ()>(&mut store, "f")?; let resource = Resource::new_own(1); - f.call(&mut store, (&resource,))?; - let err = f.post_return(&mut store).unwrap_err(); + let err = f.call(&mut store, (&resource,)).unwrap_err(); assert_eq!( err.to_string(), "borrow handles still remain at the end of the call", @@ -844,7 +810,6 @@ fn thread_through_borrow() -> Result<()> { let resource = Resource::new_own(100); f.call(&mut store, (&resource,))?; - f.post_return(&mut store)?; Ok(()) } @@ -931,22 +896,18 @@ fn can_use_own_for_borrow() -> Result<()> { let resource = Resource::new_own(100); f_typed.call(&mut store, (&resource,))?; - f_typed.post_return(&mut store)?; let resource = Resource::new_borrow(200); f_typed.call(&mut store, (&resource,))?; - f_typed.post_return(&mut store)?; let resource = Resource::::new_own(300).try_into_resource_any(&mut store)?; f.call(&mut store, &[Val::Resource(resource)], &mut [])?; - f.post_return(&mut store)?; resource.resource_drop(&mut store)?; // TODO: Enable once https://github.com/bytecodealliance/wasmtime/issues/7793 is fixed //let resource = // Resource::::new_borrow(400).try_into_resource_any(&mut store, &i_pre, ty_idx)?; //f.call(&mut store, &[Val::Resource(resource)], &mut [])?; - //f.post_return(&mut store)?; //resource.resource_drop(&mut store)?; Ok(()) @@ -1124,7 +1085,6 @@ fn drop_no_dtor() -> Result<()> { let i = Linker::new(&engine).instantiate(&mut store, &c)?; let ctor = i.get_typed_func::<(u32,), (ResourceAny,)>(&mut store, "ctor")?; let (resource,) = ctor.call(&mut store, (100,))?; - ctor.post_return(&mut store)?; resource.resource_drop(&mut store)?; Ok(()) @@ -1141,16 +1101,20 @@ fn host_borrow_as_resource_any() -> Result<()> { (import "f" (func $f (param "f" (borrow $t)))) (core func $f (canon lower (func $f))) + (core func $drop (canon resource.drop $t)) (core module $m (import "" "f" (func $f (param i32))) + (import "" "drop" (func $drop (param i32))) (func (export "f2") (param i32) (call $f (local.get 0)) + (call $drop (local.get 0)) ) ) (core instance $i (instantiate $m (with "" (instance (export "f" (func $f)) + (export "drop" (func $drop)) )) )) @@ -1252,9 +1216,7 @@ fn pass_guest_back_as_borrow() -> Result<()> { let take = i.get_typed_func::<(&ResourceAny,), ()>(&mut store, "take")?; let (resource,) = mk.call(&mut store, ())?; - mk.post_return(&mut store)?; take.call(&mut store, (&resource,))?; - take.post_return(&mut store)?; resource.resource_drop(&mut store)?; @@ -1306,7 +1268,6 @@ fn pass_host_borrow_to_guest() -> Result<()> { let resource = Resource::new_borrow(100); take.call(&mut store, (&resource,))?; - take.post_return(&mut store)?; Ok(()) } @@ -1466,7 +1427,6 @@ fn guest_different_host_same() -> Result<()> { let resource = Resource::new_own(100); f.call(&mut store, (&resource, &resource))?; - f.post_return(&mut store)?; Ok(()) } @@ -1523,7 +1483,6 @@ fn resource_any_to_typed_handles_borrow() -> Result<()> { let resource = Resource::new_own(100); f.call(&mut store, (&resource,))?; - f.post_return(&mut store)?; Ok(()) } @@ -1576,10 +1535,8 @@ fn resource_dynamic() -> Result<()> { let drop_u = instance.get_typed_func::<(ResourceDynamic,), ()>(&mut store, "drop-u")?; drop_t.call(&mut store, (ResourceDynamic::new_own(1, 2),))?; - drop_t.post_return(&mut store)?; drop_u.call(&mut store, (ResourceDynamic::new_own(2, 3),))?; - drop_u.post_return(&mut store)?; assert!( drop_t @@ -1666,7 +1623,6 @@ fn intrinsic_trampolines() -> Result<()> { let rep = i.get_typed_func::<(ResourceAny,), (u32,)>(&mut store, "rep")?; let r = new.call(&mut store, (42,))?.0; - new.post_return(&mut store)?; assert!(rep.call(&mut store, (r,)).is_err()); Ok(()) } diff --git a/tests/all/component_model/strings.rs b/tests/all/component_model/strings.rs index ce60ea10fdb8..d341ef36a184 100644 --- a/tests/all/component_model/strings.rs +++ b/tests/all/component_model/strings.rs @@ -188,7 +188,6 @@ fn test_roundtrip(engine: &Engine, src: &str, dst: &str) -> Result<()> { *store.data_mut() = string.to_string(); let (ret,) = func.call(&mut store, (string.to_string(),))?; assert_eq!(ret, *string); - func.post_return(&mut store)?; } Ok(()) } diff --git a/tests/all/pulley.rs b/tests/all/pulley.rs index 50f4ffc53363..bd651cb850b5 100644 --- a/tests/all/pulley.rs +++ b/tests/all/pulley.rs @@ -272,43 +272,32 @@ fn pulley_provenance_test_components() -> Result<()> { instance.get_typed_func::<(&[&str],), (Vec,)>(&mut store, "guest-list")?; guest_empty.call(&mut store, ())?; - guest_empty.post_return(&mut store)?; let (result,) = guest_u32.call(&mut store, (42,))?; assert_eq!(result, 42); - guest_u32.post_return(&mut store)?; let (result,) = guest_enum.call(&mut store, (E::B,))?; assert_eq!(result, E::B); - guest_enum.post_return(&mut store)?; let (result,) = guest_option.call(&mut store, (None,))?; assert_eq!(result, None); - guest_option.post_return(&mut store)?; let (result,) = guest_option.call(&mut store, (Some(200),))?; assert_eq!(result, Some(200)); - guest_option.post_return(&mut store)?; let (result,) = guest_result.call(&mut store, (Ok(10),))?; assert_eq!(result, Ok(10)); - guest_result.post_return(&mut store)?; let (result,) = guest_result.call(&mut store, (Err(i64::MIN),))?; assert_eq!(result, Err(i64::MIN)); - guest_result.post_return(&mut store)?; let (result,) = guest_string.call(&mut store, ("",))?; assert_eq!(result, ""); - guest_string.post_return(&mut store)?; let (result,) = guest_string.call(&mut store, ("hello",))?; assert_eq!(result, "hello"); - guest_string.post_return(&mut store)?; let (result,) = guest_list.call(&mut store, (&[],))?; assert!(result.is_empty()); - guest_list.post_return(&mut store)?; let (result,) = guest_list.call(&mut store, (&["a", "", "b", "c"],))?; assert_eq!(result, ["a", "", "b", "c"]); - guest_list.post_return(&mut store)?; instance .get_typed_func::<(), ()>(&mut store, "resource-intrinsics")? @@ -363,27 +352,22 @@ fn pulley_provenance_test_components() -> Result<()> { let mut results = []; guest_empty.call(&mut store, &[], &mut results)?; - guest_empty.post_return(&mut store)?; let mut results = [Val::U32(0)]; guest_u32.call(&mut store, &[Val::U32(42)], &mut results)?; assert_eq!(results[0], Val::U32(42)); - guest_u32.post_return(&mut store)?; guest_enum.call(&mut store, &[Val::Enum("B".into())], &mut results)?; assert_eq!(results[0], Val::Enum("B".into())); - guest_enum.post_return(&mut store)?; guest_option.call(&mut store, &[Val::Option(None)], &mut results)?; assert_eq!(results[0], Val::Option(None)); - guest_option.post_return(&mut store)?; guest_option.call( &mut store, &[Val::Option(Some(Box::new(Val::U8(201))))], &mut results, )?; assert_eq!(results[0], Val::Option(Some(Box::new(Val::U8(201))))); - guest_option.post_return(&mut store)?; guest_result.call( &mut store, @@ -391,7 +375,6 @@ fn pulley_provenance_test_components() -> Result<()> { &mut results, )?; assert_eq!(results[0], Val::Result(Ok(Some(Box::new(Val::U16(20)))))); - guest_result.post_return(&mut store)?; guest_result.call( &mut store, &[Val::Result(Err(Some(Box::new(Val::S64(i64::MAX)))))], @@ -401,18 +384,14 @@ fn pulley_provenance_test_components() -> Result<()> { results[0], Val::Result(Err(Some(Box::new(Val::S64(i64::MAX))))) ); - guest_result.post_return(&mut store)?; guest_string.call(&mut store, &[Val::String("B".into())], &mut results)?; assert_eq!(results[0], Val::String("B".into())); - guest_string.post_return(&mut store)?; guest_string.call(&mut store, &[Val::String("".into())], &mut results)?; assert_eq!(results[0], Val::String("".into())); - guest_string.post_return(&mut store)?; guest_list.call(&mut store, &[Val::List(Vec::new())], &mut results)?; assert_eq!(results[0], Val::List(Vec::new())); - guest_list.post_return(&mut store)?; } Ok(()) From bef631cbcc46023156a91a05da028c2fdf5ef2b9 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Tue, 3 Feb 2026 09:51:10 -0700 Subject: [PATCH 2/6] address review feedback --- .../c-api/include/wasmtime/component/func.h | 11 ++--- crates/c-api/src/component/func.rs | 2 +- crates/wasmtime/src/runtime/component/func.rs | 22 ++++------ .../src/runtime/component/func/typed.rs | 43 +++++++------------ 4 files changed, 30 insertions(+), 48 deletions(-) diff --git a/crates/c-api/include/wasmtime/component/func.h b/crates/c-api/include/wasmtime/component/func.h index 7c871ba224fb..ebd4ad5309d4 100644 --- a/crates/c-api/include/wasmtime/component/func.h +++ b/crates/c-api/include/wasmtime/component/func.h @@ -58,13 +58,14 @@ WASM_API_EXTERN wasmtime_error_t *wasmtime_component_func_call( wasmtime_component_val_t *results, size_t results_size); /** - * \brief Invokes the `post-return` canonical ABI option, if specified, after a - * #wasmtime_component_func_call has finished. + * \brief No longer needs to be called; this function has no effect. * - * This function is a required method call after a #wasmtime_component_func_call - * completes successfully. After the embedder has finished processing the return - * value then this function must be invoked. + * Previously, this invoked the `post-return` canonical ABI option, if + * specified, after a #wasmtime_component_func_call had finished. Now that's + * taken care of automatically as part of #wasmtime_component_func_call, so this + * function is no longer needed. */ +__attribute__((__deprecated__)) WASM_API_EXTERN wasmtime_error_t * wasmtime_component_func_post_return(const wasmtime_component_func_t *func, wasmtime_context_t *context); diff --git a/crates/c-api/src/component/func.rs b/crates/c-api/src/component/func.rs index 280693e15291..a540b079a7d8 100644 --- a/crates/c-api/src/component/func.rs +++ b/crates/c-api/src/component/func.rs @@ -32,7 +32,7 @@ pub unsafe extern "C" fn wasmtime_component_func_post_return( _func: &Func, _context: WasmtimeStoreContextMut<'_>, ) -> Option> { - crate::handle_result(Ok(()), |_| {}) + None } #[unsafe(no_mangle)] diff --git a/crates/wasmtime/src/runtime/component/func.rs b/crates/wasmtime/src/runtime/component/func.rs index c6acdac86675..447d64617d04 100644 --- a/crates/wasmtime/src/runtime/component/func.rs +++ b/crates/wasmtime/src/runtime/component/func.rs @@ -204,10 +204,7 @@ impl Func { /// size of `results` exactly matches the number of results that this /// function produces. /// - /// Note that after a function is invoked the embedder needs to invoke - /// [`Func::post_return`] to execute any final cleanup required by the - /// guest. This function call is required to either call the function again - /// or to call another function. + /// This will also call the corresponding `post-return` function, if any. /// /// For more detailed information see the documentation of /// [`TypedFunc::call`]. @@ -238,15 +235,11 @@ impl Func { let mut store = store.as_context_mut(); store.0.validate_sync_call()?; self.call_impl(store.as_context_mut(), params, results)?; - self.post_return_impl(store)?; Ok(()) } /// Exactly like [`Self::call`] except for use on async stores. /// - /// Note that after this [`Func::post_return_async`] will be used instead of - /// the synchronous version at [`Func::post_return`]. - /// /// # Panics /// /// Panics if `store` does not own this function. @@ -311,8 +304,7 @@ impl Func { /// exclusive access to the store until the completion of the call), calls /// made using this method may run concurrently with other calls to the same /// instance. In addition, the runtime will call the `post-return` function - /// (if any) automatically when the guest task completes -- no need to - /// explicitly call `Func::post_return` afterward. + /// (if any) automatically when the guest task completes. /// /// This returns a [`TaskExit`] representing the completion of the guest /// task and any transitive subtasks it might create. @@ -500,7 +492,7 @@ impl Func { // function used here matching the actual lift. unsafe { self.call_raw( - store, + store.as_context_mut(), |cx, ty, dst: &mut MaybeUninit<[MaybeUninit; MAX_FLAT_PARAMS]>| { // SAFETY: it's safe to assume that // `MaybeUninit` is initialized because @@ -517,8 +509,10 @@ impl Func { } Ok(()) }, - ) + )? } + + self.post_return_impl(store) } pub(crate) fn lifted_core_func(&self, store: &mut StoreOpaque) -> NonNull { @@ -697,13 +691,13 @@ impl Func { } #[doc(hidden)] - #[deprecated(note = "no longer has any effect")] + #[deprecated(note = "no longer needs to be called; this function has no effect")] pub fn post_return(&self, _store: impl AsContextMut) -> Result<()> { Ok(()) } #[doc(hidden)] - #[deprecated(note = "no longer has any effect")] + #[deprecated(note = "no longer needs to be called; this function has no effect")] #[cfg(feature = "async")] pub async fn post_return_async(&self, _store: impl AsContextMut) -> Result<()> { Ok(()) diff --git a/crates/wasmtime/src/runtime/component/func/typed.rs b/crates/wasmtime/src/runtime/component/func/typed.rs index a26f2976bf1b..d0c9e7e362e9 100644 --- a/crates/wasmtime/src/runtime/component/func/typed.rs +++ b/crates/wasmtime/src/runtime/component/func/typed.rs @@ -112,20 +112,8 @@ where /// memory leaks in wasm itself. The `post-return` canonical abi option is /// used to configured this. /// - /// To accommodate this feature of the component model after invoking a - /// function via [`TypedFunc::call`] you must next invoke - /// [`TypedFunc::post_return`]. Note that the return value of the function - /// should be processed between these two function calls. The return value - /// continues to be usable from an embedder's perspective after - /// `post_return` is called, but after `post_return` is invoked it may no - /// longer retain the same value that the wasm module originally returned. - /// - /// Also note that [`TypedFunc::post_return`] must be invoked irrespective - /// of whether the canonical ABI option `post-return` was configured or not. - /// This means that embedders must unconditionally call - /// [`TypedFunc::post_return`] when a function returns. If this function - /// call returns an error, however, then [`TypedFunc::post_return`] is not - /// required. + /// If a post-return function is present, it will be called automatically by + /// this function. /// /// # Errors /// @@ -138,8 +126,6 @@ where /// * If the wasm returns a value which violates the canonical ABI. /// * If this function's instances cannot be entered, for example if the /// instance is currently calling a host function. - /// * If a previous function call occurred and the corresponding - /// `post_return` hasn't been invoked yet. /// * If `store` requires using [`Self::call_async`] instead, see /// [crate documentation](crate#async) for more info. /// @@ -160,9 +146,7 @@ where pub fn call(&self, mut store: impl AsContextMut, params: Params) -> Result { let mut store = store.as_context_mut(); store.0.validate_sync_call()?; - let result = self.call_impl(store.as_context_mut(), params)?; - self.func.post_return_impl(store)?; - Ok(result) + self.call_impl(store.as_context_mut(), params) } /// Exactly like [`Self::call`], except for invoking WebAssembly @@ -253,8 +237,7 @@ where /// exclusive access to the store until the completion of the call), calls /// made using this method may run concurrently with other calls to the same /// instance. In addition, the runtime will call the `post-return` function - /// (if any) automatically when the guest task completes -- no need to - /// explicitly call `Func::post_return` afterward. + /// (if any) automatically when the guest task completes. /// /// Besides the task's return value, this returns a [`TaskExit`] /// representing the completion of the guest task and any transitive @@ -433,7 +416,7 @@ where } fn call_impl(&self, mut store: impl AsContextMut, params: Params) -> Result { - let store = store.as_context_mut(); + let mut store = store.as_context_mut(); if self.func.abi_async(store.0) { bail!("must enable the `component-model-async` feature to call async-lifted exports") @@ -456,7 +439,7 @@ where // safety requirements of `Lift` and `Lower` on `Params` and `Return` in // combination with checking the various possible branches here and // dispatching to appropriately typed functions. - unsafe { + let result = unsafe { // This type is used as `LowerParams` for `call_raw` which is either // `Params::Lower` or `ValRaw` representing it's either on the stack // or it's on the heap. This allocates 1 extra `ValRaw` on the stack @@ -471,7 +454,7 @@ where if Return::flatten_count() <= MAX_FLAT_RESULTS { self.func.call_raw( - store, + store.as_context_mut(), |cx, ty, dst: &mut MaybeUninit>| { let dst = storage_as_slice_mut(dst); Self::lower_args(cx, ty, dst, ¶ms) @@ -480,7 +463,7 @@ where ) } else { self.func.call_raw( - store, + store.as_context_mut(), |cx, ty, dst: &mut MaybeUninit>| { let dst = storage_as_slice_mut(dst); Self::lower_args(cx, ty, dst, ¶ms) @@ -488,7 +471,11 @@ where Self::lift_heap_result, ) } - } + }?; + + self.func.post_return_impl(store)?; + + Ok(result) } /// Lower parameters directly onto the stack specified by the `dst` @@ -580,13 +567,13 @@ where } #[doc(hidden)] - #[deprecated(note = "no longer has any effect")] + #[deprecated(note = "no longer needs to be called; this function has no effect")] pub fn post_return(&self, _store: impl AsContextMut) -> Result<()> { Ok(()) } #[doc(hidden)] - #[deprecated(note = "no longer has any effect")] + #[deprecated(note = "no longer needs to be called; this function has no effect")] #[cfg(feature = "async")] pub async fn post_return_async( &self, From fbb4ce3cf6b15b2f00c97778f5cc8478b2c56245 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Tue, 3 Feb 2026 10:39:05 -0700 Subject: [PATCH 3/6] test post-return function in more scenarios Specifically, I've split the `invoke_post_return` test into multiple tests: - using `TypedFunc::call` - using `TypedFunc::call_async` with concurrency support enabled - using `TypedFunc::call_async` with concurrency support disabled - using `Func::call_async` with concurrency support disabled - using `TypedFunc::call_concurrent` --- .../c-api/include/wasmtime/component/func.h | 3 +- tests/all/component_model.rs | 78 ++++++++++++++- tests/all/component_model/func.rs | 94 ++++--------------- tests/all/component_model/post_return.rs | 42 +++++++-- 4 files changed, 132 insertions(+), 85 deletions(-) diff --git a/crates/c-api/include/wasmtime/component/func.h b/crates/c-api/include/wasmtime/component/func.h index ebd4ad5309d4..7da144a5d112 100644 --- a/crates/c-api/include/wasmtime/component/func.h +++ b/crates/c-api/include/wasmtime/component/func.h @@ -65,8 +65,7 @@ WASM_API_EXTERN wasmtime_error_t *wasmtime_component_func_call( * taken care of automatically as part of #wasmtime_component_func_call, so this * function is no longer needed. */ -__attribute__((__deprecated__)) -WASM_API_EXTERN wasmtime_error_t * +__attribute__((__deprecated__)) WASM_API_EXTERN wasmtime_error_t * wasmtime_component_func_post_return(const wasmtime_component_func_t *func, wasmtime_context_t *context); diff --git a/tests/all/component_model.rs b/tests/all/component_model.rs index 49248dc3c4ba..d2efd3e70412 100644 --- a/tests/all/component_model.rs +++ b/tests/all/component_model.rs @@ -1,7 +1,9 @@ use std::fmt::Write; use std::iter; -use wasmtime::Result; -use wasmtime::component::Component; +use wasmtime::component::{ + Component, ComponentNamedList, Instance, Lift, Linker, Lower, ResourceAny, TypedFunc, +}; +use wasmtime::{Config, Result, Store}; use wasmtime_component_util::REALLOC_AND_FREE; use wasmtime_test_util::component::{async_engine, config, engine}; @@ -22,6 +24,78 @@ mod post_return; mod resources; mod strings; +#[derive(Copy, Clone)] +enum ApiStyle { + Sync, + Async, + AsyncNotConcurrent, + Concurrent, +} + +impl ApiStyle { + fn config(self) -> Config { + let mut config = config(); + match self { + ApiStyle::AsyncNotConcurrent => { + config.concurrency_support(false); + } + ApiStyle::Sync | ApiStyle::Async | ApiStyle::Concurrent => { + config.wasm_component_model_threading(true); + } + } + config + } + + async fn instantiate( + self, + store: &mut Store, + linker: &Linker, + component: &Component, + ) -> Result { + match self { + ApiStyle::Sync => linker.instantiate(store, &component), + ApiStyle::Async | ApiStyle::AsyncNotConcurrent | ApiStyle::Concurrent => { + linker.instantiate_async(store, &component).await + } + } + } + + async fn call< + P: ComponentNamedList + Lower + 'static, + R: ComponentNamedList + Lift + 'static, + T: Send, + >( + self, + store: &mut Store, + func: TypedFunc, + params: P, + ) -> Result { + match self { + ApiStyle::Sync => func.call(&mut *store, params), + ApiStyle::Async | ApiStyle::AsyncNotConcurrent => { + func.call_async(&mut *store, params).await + } + ApiStyle::Concurrent => Ok(store + .run_concurrent(async |access| func.call_concurrent(access, params).await) + .await?? + .0), + } + } + + async fn resource_drop( + self, + store: &mut Store, + resource: ResourceAny, + ) -> Result<()> { + match self { + ApiStyle::Sync => resource.resource_drop(store), + ApiStyle::Async | ApiStyle::AsyncNotConcurrent | ApiStyle::Concurrent => { + resource.resource_drop_async(store).await + } + } + } +} + #[test] #[cfg_attr(miri, ignore)] fn components_importing_modules() -> Result<()> { diff --git a/tests/all/component_model/func.rs b/tests/all/component_model/func.rs index ac891f316405..fd13a8b2182d 100644 --- a/tests/all/component_model/func.rs +++ b/tests/all/component_model/func.rs @@ -1,6 +1,6 @@ #![cfg(not(miri))] -use super::REALLOC_AND_FREE; +use super::{ApiStyle, REALLOC_AND_FREE}; use std::sync::Arc; use wasmtime::Result; use wasmtime::component::*; @@ -3403,62 +3403,6 @@ fn test_recurse(kind: RecurseKind) -> Result<()> { Ok(()) } -#[derive(Copy, Clone)] -enum ApiStyle { - Sync, - Async, - Concurrent, -} - -fn thread_config() -> Config { - let mut config = super::config(); - config.wasm_component_model_threading(true); - config -} - -async fn instantiate( - store: &mut Store, - linker: &Linker, - component: &Component, - style: ApiStyle, -) -> Result { - match style { - ApiStyle::Sync => linker.instantiate(store, &component), - ApiStyle::Async | ApiStyle::Concurrent => linker.instantiate_async(store, &component).await, - } -} - -async fn call< - P: ComponentNamedList + Lower + 'static, - R: ComponentNamedList + Lift + 'static, - T: Send, ->( - store: &mut Store, - func: TypedFunc, - params: P, - style: ApiStyle, -) -> Result { - match style { - ApiStyle::Sync => func.call(&mut *store, params), - ApiStyle::Async => func.call_async(&mut *store, params).await, - ApiStyle::Concurrent => Ok(store - .run_concurrent(async |access| func.call_concurrent(access, params).await) - .await?? - .0), - } -} - -async fn resource_drop( - store: &mut Store, - resource: ResourceAny, - style: ApiStyle, -) -> Result<()> { - match style { - ApiStyle::Sync => resource.resource_drop(store), - ApiStyle::Async | ApiStyle::Concurrent => resource.resource_drop_async(store).await, - } -} - #[tokio::test] async fn thread_index_via_instantiation_sync() -> Result<()> { thread_index_via_instantiation(ApiStyle::Sync).await @@ -3485,11 +3429,11 @@ async fn thread_index_via_instantiation(style: ApiStyle) -> Result<()> { )))) ) "#; - let engine = Engine::new(&thread_config())?; + let engine = Engine::new(&style.config())?; let component = Component::new(&engine, component)?; let mut store = Store::new(&engine, ()); let linker = Linker::new(&engine); - instantiate(&mut store, &linker, &component, style).await?; + style.instantiate(&mut store, &linker, &component).await?; Ok(()) } @@ -3524,13 +3468,13 @@ async fn thread_index_via_call(style: ApiStyle) -> Result<()> { (func (export "run") (canon lift (core func $m "run"))) ) "#; - let engine = Engine::new(&thread_config())?; + let engine = Engine::new(&style.config())?; let component = Component::new(&engine, component)?; let mut store = Store::new(&engine, ()); let linker = Linker::new(&engine); - let instance = instantiate(&mut store, &linker, &component, style).await?; + let instance = style.instantiate(&mut store, &linker, &component).await?; let run = instance.get_typed_func::<(), ()>(&mut store, "run")?; - call(&mut store, run, (), style).await?; + style.call(&mut store, run, ()).await?; Ok(()) } @@ -3573,13 +3517,13 @@ async fn thread_index_via_post_return(style: ApiStyle) -> Result<()> { (func (export "run") (canon lift (core func $m "run") (post-return (func $m "run-post-return")))) ) "#; - let engine = Engine::new(&thread_config())?; + let engine = Engine::new(&style.config())?; let component = Component::new(&engine, component)?; let mut store = Store::new(&engine, ()); let linker = Linker::new(&engine); - let instance = instantiate(&mut store, &linker, &component, style).await?; + let instance = style.instantiate(&mut store, &linker, &component).await?; let run = instance.get_typed_func::<(), ()>(&mut store, "run")?; - call(&mut store, run, (), style).await?; + style.call(&mut store, run, ()).await?; Ok(()) } @@ -3628,13 +3572,13 @@ async fn thread_index_via_cabi_realloc(style: ApiStyle) -> Result<()> { )) ) "#; - let engine = Engine::new(&thread_config())?; + let engine = Engine::new(&style.config())?; let component = Component::new(&engine, component)?; let mut store = Store::new(&engine, ()); let linker = Linker::new(&engine); - let instance = instantiate(&mut store, &linker, &component, style).await?; + let instance = style.instantiate(&mut store, &linker, &component).await?; let run = instance.get_typed_func::<(String,), ()>(&mut store, "run")?; - call(&mut store, run, ("hola".to_string(),), style).await?; + style.call(&mut store, run, ("hola".to_string(),)).await?; Ok(()) } @@ -3691,18 +3635,18 @@ async fn thread_index_via_resource_drop(style: ApiStyle) -> Result<()> { (export "i" (instance $c)) ) "#; - let engine = Engine::new(&thread_config())?; + let engine = Engine::new(&style.config())?; let component = Component::new(&engine, component)?; let mut store = Store::new(&engine, ()); let linker = Linker::new(&engine); - let instance = instantiate(&mut store, &linker, &component, style).await?; + let instance = style.instantiate(&mut store, &linker, &component).await?; let instance_index = instance.get_export_index(&mut store, None, "i").unwrap(); let func_index = instance .get_export_index(&mut store, Some(&instance_index), "new") .unwrap(); let run = instance.get_typed_func::<(), (ResourceAny,)>(&mut store, &func_index)?; - let (resource,) = call(&mut store, run, (), style).await?; - resource_drop(&mut store, resource, style).await?; + let (resource,) = style.call(&mut store, run, ()).await?; + style.resource_drop(&mut store, resource).await?; Ok(()) } @@ -3767,13 +3711,13 @@ async fn thread_index_via_guest_call(style: ApiStyle) -> Result<()> { (func (export "run") (alias export $d "run")) ) "#; - let engine = Engine::new(&thread_config())?; + let engine = Engine::new(&style.config())?; let component = Component::new(&engine, component)?; let mut store = Store::new(&engine, ()); let linker = Linker::new(&engine); - let instance = instantiate(&mut store, &linker, &component, style).await?; + let instance = style.instantiate(&mut store, &linker, &component).await?; let run = instance.get_typed_func::<(), ()>(&mut store, "run")?; - call(&mut store, run, (), style).await?; + style.call(&mut store, run, ()).await?; Ok(()) } diff --git a/tests/all/component_model/post_return.rs b/tests/all/component_model/post_return.rs index 5cf23edc7c85..39ba3111b43d 100644 --- a/tests/all/component_model/post_return.rs +++ b/tests/all/component_model/post_return.rs @@ -1,11 +1,36 @@ #![cfg(not(miri))] -use wasmtime::Result; +use super::ApiStyle; use wasmtime::component::*; +use wasmtime::{Engine, Result}; use wasmtime::{Store, StoreContextMut, Trap}; -#[test] -fn invoke_post_return() -> Result<()> { +#[tokio::test] +async fn invoke_post_return_sync() -> Result<()> { + invoke_post_return(ApiStyle::Sync, true).await +} + +#[tokio::test] +async fn invoke_post_return_async() -> Result<()> { + invoke_post_return(ApiStyle::Async, true).await +} + +#[tokio::test] +async fn invoke_post_return_async_not_concurrent() -> Result<()> { + invoke_post_return(ApiStyle::AsyncNotConcurrent, true).await +} + +#[tokio::test] +async fn invoke_post_return_async_not_concurrent_dynamic() -> Result<()> { + invoke_post_return(ApiStyle::AsyncNotConcurrent, false).await +} + +#[tokio::test] +async fn invoke_post_return_concurrent() -> Result<()> { + invoke_post_return(ApiStyle::Concurrent, true).await +} + +async fn invoke_post_return(style: ApiStyle, typed: bool) -> Result<()> { let component = r#" (component (import "f" (func $f)) @@ -36,7 +61,7 @@ fn invoke_post_return() -> Result<()> { ) "#; - let engine = super::engine(); + let engine = Engine::new(&style.config())?; let component = Component::new(&engine, component)?; let mut store = Store::new(&engine, ()); let mut linker = Linker::new(&engine); @@ -46,10 +71,15 @@ fn invoke_post_return() -> Result<()> { unreachable!() })?; - let instance = linker.instantiate(&mut store, &component)?; + let instance = style.instantiate(&mut store, &linker, &component).await?; let thunk = instance.get_typed_func::<(), ()>(&mut store, "thunk")?; - let result = thunk.call(&mut store, ()); + let result = if typed { + style.call(&mut store, thunk, ()).await + } else { + assert!(matches!(style, ApiStyle::AsyncNotConcurrent)); + thunk.func().call_async(&mut store, &[], &mut []).await + }; assert!(matches!( result.unwrap_err().downcast::(), Ok(Trap::CannotLeaveComponent) From b8a4ca3b0406cabc0b77c7bf870fa9defe4a9b2f Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Tue, 3 Feb 2026 11:02:19 -0700 Subject: [PATCH 4/6] remove GCC/clang-specific deprecation attribute This broke the MSVC build. --- crates/c-api/include/wasmtime/component/func.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/c-api/include/wasmtime/component/func.h b/crates/c-api/include/wasmtime/component/func.h index 7da144a5d112..a0fd8e30ab9a 100644 --- a/crates/c-api/include/wasmtime/component/func.h +++ b/crates/c-api/include/wasmtime/component/func.h @@ -60,12 +60,12 @@ WASM_API_EXTERN wasmtime_error_t *wasmtime_component_func_call( /** * \brief No longer needs to be called; this function has no effect. * - * Previously, this invoked the `post-return` canonical ABI option, if - * specified, after a #wasmtime_component_func_call had finished. Now that's + * \deprecated Previously, this invoked the `post-return` canonical ABI option, + * if specified, after a #wasmtime_component_func_call had finished. Now that's * taken care of automatically as part of #wasmtime_component_func_call, so this - * function is no longer needed. + * function is no longer needed, and any calls to it may be removed. */ -__attribute__((__deprecated__)) WASM_API_EXTERN wasmtime_error_t * +WASM_API_EXTERN wasmtime_error_t * wasmtime_component_func_post_return(const wasmtime_component_func_t *func, wasmtime_context_t *context); From bd015ab37725134222160d500a44335bde350e2d Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Tue, 3 Feb 2026 11:14:09 -0700 Subject: [PATCH 5/6] bless bindgen output --- crates/component-macro/tests/expanded/char.rs | 2 - .../tests/expanded/char_async.rs | 2 - .../tests/expanded/char_tracing_async.rs | 8 -- .../tests/expanded/conventions.rs | 12 -- .../tests/expanded/conventions_async.rs | 12 -- .../expanded/conventions_tracing_async.rs | 48 -------- .../component-macro/tests/expanded/flags.rs | 7 -- .../tests/expanded/flags_async.rs | 7 -- .../tests/expanded/flags_tracing_async.rs | 28 ----- .../component-macro/tests/expanded/floats.rs | 4 - .../tests/expanded/floats_async.rs | 4 - .../tests/expanded/floats_tracing_async.rs | 16 --- .../tests/expanded/function-new.rs | 1 - .../tests/expanded/function-new_async.rs | 1 - .../expanded/function-new_tracing_async.rs | 1 - .../tests/expanded/integers.rs | 18 --- .../tests/expanded/integers_async.rs | 18 --- .../tests/expanded/integers_tracing_async.rs | 72 ----------- .../component-macro/tests/expanded/lists.rs | 29 ----- .../tests/expanded/lists_async.rs | 29 ----- .../tests/expanded/lists_tracing_async.rs | 116 ------------------ .../tests/expanded/many-arguments.rs | 2 - .../tests/expanded/many-arguments_async.rs | 2 - .../expanded/many-arguments_tracing_async.rs | 8 -- .../tests/expanded/multiversion.rs | 2 - .../tests/expanded/multiversion_async.rs | 2 - .../expanded/multiversion_tracing_async.rs | 8 -- .../component-macro/tests/expanded/records.rs | 11 -- .../tests/expanded/records_async.rs | 11 -- .../tests/expanded/records_tracing_async.rs | 44 ------- .../tests/expanded/resources-export.rs | 8 -- .../tests/expanded/resources-export_async.rs | 8 -- .../resources-export_tracing_async.rs | 32 ----- .../tests/expanded/resources-import.rs | 2 - .../tests/expanded/resources-import_async.rs | 2 - .../resources-import_tracing_async.rs | 5 - .../tests/expanded/share-types.rs | 1 - .../tests/expanded/share-types_async.rs | 1 - .../expanded/share-types_tracing_async.rs | 1 - .../tests/expanded/simple-functions.rs | 6 - .../tests/expanded/simple-functions_async.rs | 6 - .../simple-functions_tracing_async.rs | 24 ---- .../tests/expanded/simple-lists.rs | 4 - .../tests/expanded/simple-lists_async.rs | 4 - .../expanded/simple-lists_tracing_async.rs | 16 --- .../tests/expanded/small-anonymous.rs | 1 - .../tests/expanded/small-anonymous_async.rs | 1 - .../expanded/small-anonymous_tracing_async.rs | 4 - .../tests/expanded/smoke-default.rs | 1 - .../tests/expanded/smoke-default_async.rs | 1 - .../expanded/smoke-default_tracing_async.rs | 1 - .../tests/expanded/smoke-export.rs | 1 - .../tests/expanded/smoke-export_async.rs | 1 - .../expanded/smoke-export_tracing_async.rs | 1 - .../component-macro/tests/expanded/strings.rs | 3 - .../tests/expanded/strings_async.rs | 3 - .../tests/expanded/strings_tracing_async.rs | 12 -- .../tests/expanded/variants.rs | 20 --- .../tests/expanded/variants_async.rs | 20 --- .../tests/expanded/variants_tracing_async.rs | 80 ------------ .../tests/expanded/worlds-with-types.rs | 1 - .../tests/expanded/worlds-with-types_async.rs | 1 - .../worlds-with-types_tracing_async.rs | 1 - 63 files changed, 798 deletions(-) diff --git a/crates/component-macro/tests/expanded/char.rs b/crates/component-macro/tests/expanded/char.rs index 273780c38bac..a5b7d1bedba6 100644 --- a/crates/component-macro/tests/expanded/char.rs +++ b/crates/component-macro/tests/expanded/char.rs @@ -334,7 +334,6 @@ pub mod exports { >::new_unchecked(self.take_char) }; let () = callee.call(store.as_context_mut(), (arg0,))?; - callee.post_return(store.as_context_mut())?; Ok(()) } /// A function that returns a character @@ -349,7 +348,6 @@ pub mod exports { >::new_unchecked(self.return_char) }; let (ret0,) = callee.call(store.as_context_mut(), ())?; - callee.post_return(store.as_context_mut())?; Ok(ret0) } } diff --git a/crates/component-macro/tests/expanded/char_async.rs b/crates/component-macro/tests/expanded/char_async.rs index 4dd42e6782e7..8d454304c5fb 100644 --- a/crates/component-macro/tests/expanded/char_async.rs +++ b/crates/component-macro/tests/expanded/char_async.rs @@ -353,7 +353,6 @@ pub mod exports { let () = callee .call_async(store.as_context_mut(), (arg0,)) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(()) } /// A function that returns a character @@ -373,7 +372,6 @@ pub mod exports { let (ret0,) = callee .call_async(store.as_context_mut(), ()) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(ret0) } } diff --git a/crates/component-macro/tests/expanded/char_tracing_async.rs b/crates/component-macro/tests/expanded/char_tracing_async.rs index 19835e7fd944..6d69397a3b97 100644 --- a/crates/component-macro/tests/expanded/char_tracing_async.rs +++ b/crates/component-macro/tests/expanded/char_tracing_async.rs @@ -388,10 +388,6 @@ pub mod exports { .call_async(store.as_context_mut(), (arg0,)) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(()) } /// A function that returns a character @@ -417,10 +413,6 @@ pub mod exports { .call_async(store.as_context_mut(), ()) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(ret0) } } diff --git a/crates/component-macro/tests/expanded/conventions.rs b/crates/component-macro/tests/expanded/conventions.rs index a623593be463..4bc40a0e36ca 100644 --- a/crates/component-macro/tests/expanded/conventions.rs +++ b/crates/component-macro/tests/expanded/conventions.rs @@ -626,7 +626,6 @@ pub mod exports { >::new_unchecked(self.kebab_case) }; let () = callee.call(store.as_context_mut(), ())?; - callee.post_return(store.as_context_mut())?; Ok(()) } pub fn call_foo( @@ -641,7 +640,6 @@ pub mod exports { >::new_unchecked(self.foo) }; let () = callee.call(store.as_context_mut(), (arg0,))?; - callee.post_return(store.as_context_mut())?; Ok(()) } pub fn call_function_with_dashes( @@ -655,7 +653,6 @@ pub mod exports { >::new_unchecked(self.function_with_dashes) }; let () = callee.call(store.as_context_mut(), ())?; - callee.post_return(store.as_context_mut())?; Ok(()) } pub fn call_function_with_no_weird_characters< @@ -668,7 +665,6 @@ pub mod exports { >::new_unchecked(self.function_with_no_weird_characters) }; let () = callee.call(store.as_context_mut(), ())?; - callee.post_return(store.as_context_mut())?; Ok(()) } pub fn call_apple( @@ -682,7 +678,6 @@ pub mod exports { >::new_unchecked(self.apple) }; let () = callee.call(store.as_context_mut(), ())?; - callee.post_return(store.as_context_mut())?; Ok(()) } pub fn call_apple_pear( @@ -696,7 +691,6 @@ pub mod exports { >::new_unchecked(self.apple_pear) }; let () = callee.call(store.as_context_mut(), ())?; - callee.post_return(store.as_context_mut())?; Ok(()) } pub fn call_apple_pear_grape( @@ -710,7 +704,6 @@ pub mod exports { >::new_unchecked(self.apple_pear_grape) }; let () = callee.call(store.as_context_mut(), ())?; - callee.post_return(store.as_context_mut())?; Ok(()) } pub fn call_a0( @@ -724,7 +717,6 @@ pub mod exports { >::new_unchecked(self.a0) }; let () = callee.call(store.as_context_mut(), ())?; - callee.post_return(store.as_context_mut())?; Ok(()) } /// Comment out identifiers that collide when mapped to snake_case, for now; see @@ -743,7 +735,6 @@ pub mod exports { >::new_unchecked(self.is_xml) }; let () = callee.call(store.as_context_mut(), ())?; - callee.post_return(store.as_context_mut())?; Ok(()) } pub fn call_explicit( @@ -757,7 +748,6 @@ pub mod exports { >::new_unchecked(self.explicit) }; let () = callee.call(store.as_context_mut(), ())?; - callee.post_return(store.as_context_mut())?; Ok(()) } pub fn call_explicit_kebab( @@ -771,7 +761,6 @@ pub mod exports { >::new_unchecked(self.explicit_kebab) }; let () = callee.call(store.as_context_mut(), ())?; - callee.post_return(store.as_context_mut())?; Ok(()) } /// Identifiers with the same name as keywords are quoted. @@ -786,7 +775,6 @@ pub mod exports { >::new_unchecked(self.bool) }; let () = callee.call(store.as_context_mut(), ())?; - callee.post_return(store.as_context_mut())?; Ok(()) } } diff --git a/crates/component-macro/tests/expanded/conventions_async.rs b/crates/component-macro/tests/expanded/conventions_async.rs index cf55278a6921..1167d3575409 100644 --- a/crates/component-macro/tests/expanded/conventions_async.rs +++ b/crates/component-macro/tests/expanded/conventions_async.rs @@ -687,7 +687,6 @@ pub mod exports { >::new_unchecked(self.kebab_case) }; let () = callee.call_async(store.as_context_mut(), ()).await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(()) } pub async fn call_foo( @@ -707,7 +706,6 @@ pub mod exports { let () = callee .call_async(store.as_context_mut(), (arg0,)) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(()) } pub async fn call_function_with_dashes( @@ -724,7 +722,6 @@ pub mod exports { >::new_unchecked(self.function_with_dashes) }; let () = callee.call_async(store.as_context_mut(), ()).await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(()) } pub async fn call_function_with_no_weird_characters< @@ -740,7 +737,6 @@ pub mod exports { >::new_unchecked(self.function_with_no_weird_characters) }; let () = callee.call_async(store.as_context_mut(), ()).await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(()) } pub async fn call_apple( @@ -757,7 +753,6 @@ pub mod exports { >::new_unchecked(self.apple) }; let () = callee.call_async(store.as_context_mut(), ()).await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(()) } pub async fn call_apple_pear( @@ -774,7 +769,6 @@ pub mod exports { >::new_unchecked(self.apple_pear) }; let () = callee.call_async(store.as_context_mut(), ()).await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(()) } pub async fn call_apple_pear_grape( @@ -791,7 +785,6 @@ pub mod exports { >::new_unchecked(self.apple_pear_grape) }; let () = callee.call_async(store.as_context_mut(), ()).await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(()) } pub async fn call_a0( @@ -808,7 +801,6 @@ pub mod exports { >::new_unchecked(self.a0) }; let () = callee.call_async(store.as_context_mut(), ()).await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(()) } /// Comment out identifiers that collide when mapped to snake_case, for now; see @@ -830,7 +822,6 @@ pub mod exports { >::new_unchecked(self.is_xml) }; let () = callee.call_async(store.as_context_mut(), ()).await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(()) } pub async fn call_explicit( @@ -847,7 +838,6 @@ pub mod exports { >::new_unchecked(self.explicit) }; let () = callee.call_async(store.as_context_mut(), ()).await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(()) } pub async fn call_explicit_kebab( @@ -864,7 +854,6 @@ pub mod exports { >::new_unchecked(self.explicit_kebab) }; let () = callee.call_async(store.as_context_mut(), ()).await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(()) } /// Identifiers with the same name as keywords are quoted. @@ -882,7 +871,6 @@ pub mod exports { >::new_unchecked(self.bool) }; let () = callee.call_async(store.as_context_mut(), ()).await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(()) } } diff --git a/crates/component-macro/tests/expanded/conventions_tracing_async.rs b/crates/component-macro/tests/expanded/conventions_tracing_async.rs index 516a50f58e52..ad8d5d0083c9 100644 --- a/crates/component-macro/tests/expanded/conventions_tracing_async.rs +++ b/crates/component-macro/tests/expanded/conventions_tracing_async.rs @@ -855,10 +855,6 @@ pub mod exports { .call_async(store.as_context_mut(), ()) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(()) } pub async fn call_foo( @@ -884,10 +880,6 @@ pub mod exports { .call_async(store.as_context_mut(), (arg0,)) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(()) } pub async fn call_function_with_dashes( @@ -912,10 +904,6 @@ pub mod exports { .call_async(store.as_context_mut(), ()) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(()) } pub async fn call_function_with_no_weird_characters< @@ -940,10 +928,6 @@ pub mod exports { .call_async(store.as_context_mut(), ()) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(()) } pub async fn call_apple( @@ -968,10 +952,6 @@ pub mod exports { .call_async(store.as_context_mut(), ()) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(()) } pub async fn call_apple_pear( @@ -996,10 +976,6 @@ pub mod exports { .call_async(store.as_context_mut(), ()) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(()) } pub async fn call_apple_pear_grape( @@ -1024,10 +1000,6 @@ pub mod exports { .call_async(store.as_context_mut(), ()) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(()) } pub async fn call_a0( @@ -1052,10 +1024,6 @@ pub mod exports { .call_async(store.as_context_mut(), ()) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(()) } /// Comment out identifiers that collide when mapped to snake_case, for now; see @@ -1085,10 +1053,6 @@ pub mod exports { .call_async(store.as_context_mut(), ()) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(()) } pub async fn call_explicit( @@ -1113,10 +1077,6 @@ pub mod exports { .call_async(store.as_context_mut(), ()) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(()) } pub async fn call_explicit_kebab( @@ -1141,10 +1101,6 @@ pub mod exports { .call_async(store.as_context_mut(), ()) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(()) } /// Identifiers with the same name as keywords are quoted. @@ -1170,10 +1126,6 @@ pub mod exports { .call_async(store.as_context_mut(), ()) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(()) } } diff --git a/crates/component-macro/tests/expanded/flags.rs b/crates/component-macro/tests/expanded/flags.rs index 4b7150019c3c..83618cb4eaa8 100644 --- a/crates/component-macro/tests/expanded/flags.rs +++ b/crates/component-macro/tests/expanded/flags.rs @@ -731,7 +731,6 @@ pub mod exports { >::new_unchecked(self.roundtrip_flag1) }; let (ret0,) = callee.call(store.as_context_mut(), (arg0,))?; - callee.post_return(store.as_context_mut())?; Ok(ret0) } pub fn call_roundtrip_flag2( @@ -746,7 +745,6 @@ pub mod exports { >::new_unchecked(self.roundtrip_flag2) }; let (ret0,) = callee.call(store.as_context_mut(), (arg0,))?; - callee.post_return(store.as_context_mut())?; Ok(ret0) } pub fn call_roundtrip_flag4( @@ -761,7 +759,6 @@ pub mod exports { >::new_unchecked(self.roundtrip_flag4) }; let (ret0,) = callee.call(store.as_context_mut(), (arg0,))?; - callee.post_return(store.as_context_mut())?; Ok(ret0) } pub fn call_roundtrip_flag8( @@ -776,7 +773,6 @@ pub mod exports { >::new_unchecked(self.roundtrip_flag8) }; let (ret0,) = callee.call(store.as_context_mut(), (arg0,))?; - callee.post_return(store.as_context_mut())?; Ok(ret0) } pub fn call_roundtrip_flag16( @@ -791,7 +787,6 @@ pub mod exports { >::new_unchecked(self.roundtrip_flag16) }; let (ret0,) = callee.call(store.as_context_mut(), (arg0,))?; - callee.post_return(store.as_context_mut())?; Ok(ret0) } pub fn call_roundtrip_flag32( @@ -806,7 +801,6 @@ pub mod exports { >::new_unchecked(self.roundtrip_flag32) }; let (ret0,) = callee.call(store.as_context_mut(), (arg0,))?; - callee.post_return(store.as_context_mut())?; Ok(ret0) } pub fn call_roundtrip_flag64( @@ -821,7 +815,6 @@ pub mod exports { >::new_unchecked(self.roundtrip_flag64) }; let (ret0,) = callee.call(store.as_context_mut(), (arg0,))?; - callee.post_return(store.as_context_mut())?; Ok(ret0) } } diff --git a/crates/component-macro/tests/expanded/flags_async.rs b/crates/component-macro/tests/expanded/flags_async.rs index 8b263ef392fe..9d0e0fcb92fa 100644 --- a/crates/component-macro/tests/expanded/flags_async.rs +++ b/crates/component-macro/tests/expanded/flags_async.rs @@ -792,7 +792,6 @@ pub mod exports { let (ret0,) = callee .call_async(store.as_context_mut(), (arg0,)) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(ret0) } pub async fn call_roundtrip_flag2( @@ -812,7 +811,6 @@ pub mod exports { let (ret0,) = callee .call_async(store.as_context_mut(), (arg0,)) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(ret0) } pub async fn call_roundtrip_flag4( @@ -832,7 +830,6 @@ pub mod exports { let (ret0,) = callee .call_async(store.as_context_mut(), (arg0,)) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(ret0) } pub async fn call_roundtrip_flag8( @@ -852,7 +849,6 @@ pub mod exports { let (ret0,) = callee .call_async(store.as_context_mut(), (arg0,)) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(ret0) } pub async fn call_roundtrip_flag16( @@ -872,7 +868,6 @@ pub mod exports { let (ret0,) = callee .call_async(store.as_context_mut(), (arg0,)) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(ret0) } pub async fn call_roundtrip_flag32( @@ -892,7 +887,6 @@ pub mod exports { let (ret0,) = callee .call_async(store.as_context_mut(), (arg0,)) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(ret0) } pub async fn call_roundtrip_flag64( @@ -912,7 +906,6 @@ pub mod exports { let (ret0,) = callee .call_async(store.as_context_mut(), (arg0,)) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(ret0) } } diff --git a/crates/component-macro/tests/expanded/flags_tracing_async.rs b/crates/component-macro/tests/expanded/flags_tracing_async.rs index f5dc442560fe..adbd44dc046b 100644 --- a/crates/component-macro/tests/expanded/flags_tracing_async.rs +++ b/crates/component-macro/tests/expanded/flags_tracing_async.rs @@ -910,10 +910,6 @@ pub mod exports { .call_async(store.as_context_mut(), (arg0,)) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(ret0) } pub async fn call_roundtrip_flag2( @@ -939,10 +935,6 @@ pub mod exports { .call_async(store.as_context_mut(), (arg0,)) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(ret0) } pub async fn call_roundtrip_flag4( @@ -968,10 +960,6 @@ pub mod exports { .call_async(store.as_context_mut(), (arg0,)) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(ret0) } pub async fn call_roundtrip_flag8( @@ -997,10 +985,6 @@ pub mod exports { .call_async(store.as_context_mut(), (arg0,)) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(ret0) } pub async fn call_roundtrip_flag16( @@ -1026,10 +1010,6 @@ pub mod exports { .call_async(store.as_context_mut(), (arg0,)) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(ret0) } pub async fn call_roundtrip_flag32( @@ -1055,10 +1035,6 @@ pub mod exports { .call_async(store.as_context_mut(), (arg0,)) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(ret0) } pub async fn call_roundtrip_flag64( @@ -1084,10 +1060,6 @@ pub mod exports { .call_async(store.as_context_mut(), (arg0,)) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(ret0) } } diff --git a/crates/component-macro/tests/expanded/floats.rs b/crates/component-macro/tests/expanded/floats.rs index a41e1425d0e2..f1a8fa975d21 100644 --- a/crates/component-macro/tests/expanded/floats.rs +++ b/crates/component-macro/tests/expanded/floats.rs @@ -368,7 +368,6 @@ pub mod exports { >::new_unchecked(self.f32_param) }; let () = callee.call(store.as_context_mut(), (arg0,))?; - callee.post_return(store.as_context_mut())?; Ok(()) } pub fn call_f64_param( @@ -383,7 +382,6 @@ pub mod exports { >::new_unchecked(self.f64_param) }; let () = callee.call(store.as_context_mut(), (arg0,))?; - callee.post_return(store.as_context_mut())?; Ok(()) } pub fn call_f32_result( @@ -397,7 +395,6 @@ pub mod exports { >::new_unchecked(self.f32_result) }; let (ret0,) = callee.call(store.as_context_mut(), ())?; - callee.post_return(store.as_context_mut())?; Ok(ret0) } pub fn call_f64_result( @@ -411,7 +408,6 @@ pub mod exports { >::new_unchecked(self.f64_result) }; let (ret0,) = callee.call(store.as_context_mut(), ())?; - callee.post_return(store.as_context_mut())?; Ok(ret0) } } diff --git a/crates/component-macro/tests/expanded/floats_async.rs b/crates/component-macro/tests/expanded/floats_async.rs index f977c62c47d4..7eb526573480 100644 --- a/crates/component-macro/tests/expanded/floats_async.rs +++ b/crates/component-macro/tests/expanded/floats_async.rs @@ -401,7 +401,6 @@ pub mod exports { let () = callee .call_async(store.as_context_mut(), (arg0,)) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(()) } pub async fn call_f64_param( @@ -421,7 +420,6 @@ pub mod exports { let () = callee .call_async(store.as_context_mut(), (arg0,)) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(()) } pub async fn call_f32_result( @@ -440,7 +438,6 @@ pub mod exports { let (ret0,) = callee .call_async(store.as_context_mut(), ()) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(ret0) } pub async fn call_f64_result( @@ -459,7 +456,6 @@ pub mod exports { let (ret0,) = callee .call_async(store.as_context_mut(), ()) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(ret0) } } diff --git a/crates/component-macro/tests/expanded/floats_tracing_async.rs b/crates/component-macro/tests/expanded/floats_tracing_async.rs index 63c8ed1bb60c..685d2074d5f8 100644 --- a/crates/component-macro/tests/expanded/floats_tracing_async.rs +++ b/crates/component-macro/tests/expanded/floats_tracing_async.rs @@ -465,10 +465,6 @@ pub mod exports { .call_async(store.as_context_mut(), (arg0,)) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(()) } pub async fn call_f64_param( @@ -494,10 +490,6 @@ pub mod exports { .call_async(store.as_context_mut(), (arg0,)) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(()) } pub async fn call_f32_result( @@ -522,10 +514,6 @@ pub mod exports { .call_async(store.as_context_mut(), ()) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(ret0) } pub async fn call_f64_result( @@ -550,10 +538,6 @@ pub mod exports { .call_async(store.as_context_mut(), ()) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(ret0) } } diff --git a/crates/component-macro/tests/expanded/function-new.rs b/crates/component-macro/tests/expanded/function-new.rs index 8ccbaa041251..0072bef34519 100644 --- a/crates/component-macro/tests/expanded/function-new.rs +++ b/crates/component-macro/tests/expanded/function-new.rs @@ -188,7 +188,6 @@ const _: () = { wasmtime::component::TypedFunc::<(), ()>::new_unchecked(self.new) }; let () = callee.call(store.as_context_mut(), ())?; - callee.post_return(store.as_context_mut())?; Ok(()) } } diff --git a/crates/component-macro/tests/expanded/function-new_async.rs b/crates/component-macro/tests/expanded/function-new_async.rs index 3fe487f0703f..44af5dc74479 100644 --- a/crates/component-macro/tests/expanded/function-new_async.rs +++ b/crates/component-macro/tests/expanded/function-new_async.rs @@ -191,7 +191,6 @@ const _: () = { wasmtime::component::TypedFunc::<(), ()>::new_unchecked(self.new) }; let () = callee.call_async(store.as_context_mut(), ()).await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(()) } } diff --git a/crates/component-macro/tests/expanded/function-new_tracing_async.rs b/crates/component-macro/tests/expanded/function-new_tracing_async.rs index 46563e630879..5e30aca2a0fe 100644 --- a/crates/component-macro/tests/expanded/function-new_tracing_async.rs +++ b/crates/component-macro/tests/expanded/function-new_tracing_async.rs @@ -199,7 +199,6 @@ const _: () = { .call_async(store.as_context_mut(), ()) .instrument(span.clone()) .await?; - callee.post_return_async(store.as_context_mut()).instrument(span).await?; Ok(()) } } diff --git a/crates/component-macro/tests/expanded/integers.rs b/crates/component-macro/tests/expanded/integers.rs index 9498a81ccf5e..295860b8ef6d 100644 --- a/crates/component-macro/tests/expanded/integers.rs +++ b/crates/component-macro/tests/expanded/integers.rs @@ -696,7 +696,6 @@ pub mod exports { >::new_unchecked(self.a1) }; let () = callee.call(store.as_context_mut(), (arg0,))?; - callee.post_return(store.as_context_mut())?; Ok(()) } pub fn call_a2( @@ -711,7 +710,6 @@ pub mod exports { >::new_unchecked(self.a2) }; let () = callee.call(store.as_context_mut(), (arg0,))?; - callee.post_return(store.as_context_mut())?; Ok(()) } pub fn call_a3( @@ -726,7 +724,6 @@ pub mod exports { >::new_unchecked(self.a3) }; let () = callee.call(store.as_context_mut(), (arg0,))?; - callee.post_return(store.as_context_mut())?; Ok(()) } pub fn call_a4( @@ -741,7 +738,6 @@ pub mod exports { >::new_unchecked(self.a4) }; let () = callee.call(store.as_context_mut(), (arg0,))?; - callee.post_return(store.as_context_mut())?; Ok(()) } pub fn call_a5( @@ -756,7 +752,6 @@ pub mod exports { >::new_unchecked(self.a5) }; let () = callee.call(store.as_context_mut(), (arg0,))?; - callee.post_return(store.as_context_mut())?; Ok(()) } pub fn call_a6( @@ -771,7 +766,6 @@ pub mod exports { >::new_unchecked(self.a6) }; let () = callee.call(store.as_context_mut(), (arg0,))?; - callee.post_return(store.as_context_mut())?; Ok(()) } pub fn call_a7( @@ -786,7 +780,6 @@ pub mod exports { >::new_unchecked(self.a7) }; let () = callee.call(store.as_context_mut(), (arg0,))?; - callee.post_return(store.as_context_mut())?; Ok(()) } pub fn call_a8( @@ -801,7 +794,6 @@ pub mod exports { >::new_unchecked(self.a8) }; let () = callee.call(store.as_context_mut(), (arg0,))?; - callee.post_return(store.as_context_mut())?; Ok(()) } pub fn call_a9( @@ -827,7 +819,6 @@ pub mod exports { store.as_context_mut(), (arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7), )?; - callee.post_return(store.as_context_mut())?; Ok(()) } pub fn call_r1( @@ -841,7 +832,6 @@ pub mod exports { >::new_unchecked(self.r1) }; let (ret0,) = callee.call(store.as_context_mut(), ())?; - callee.post_return(store.as_context_mut())?; Ok(ret0) } pub fn call_r2( @@ -855,7 +845,6 @@ pub mod exports { >::new_unchecked(self.r2) }; let (ret0,) = callee.call(store.as_context_mut(), ())?; - callee.post_return(store.as_context_mut())?; Ok(ret0) } pub fn call_r3( @@ -869,7 +858,6 @@ pub mod exports { >::new_unchecked(self.r3) }; let (ret0,) = callee.call(store.as_context_mut(), ())?; - callee.post_return(store.as_context_mut())?; Ok(ret0) } pub fn call_r4( @@ -883,7 +871,6 @@ pub mod exports { >::new_unchecked(self.r4) }; let (ret0,) = callee.call(store.as_context_mut(), ())?; - callee.post_return(store.as_context_mut())?; Ok(ret0) } pub fn call_r5( @@ -897,7 +884,6 @@ pub mod exports { >::new_unchecked(self.r5) }; let (ret0,) = callee.call(store.as_context_mut(), ())?; - callee.post_return(store.as_context_mut())?; Ok(ret0) } pub fn call_r6( @@ -911,7 +897,6 @@ pub mod exports { >::new_unchecked(self.r6) }; let (ret0,) = callee.call(store.as_context_mut(), ())?; - callee.post_return(store.as_context_mut())?; Ok(ret0) } pub fn call_r7( @@ -925,7 +910,6 @@ pub mod exports { >::new_unchecked(self.r7) }; let (ret0,) = callee.call(store.as_context_mut(), ())?; - callee.post_return(store.as_context_mut())?; Ok(ret0) } pub fn call_r8( @@ -939,7 +923,6 @@ pub mod exports { >::new_unchecked(self.r8) }; let (ret0,) = callee.call(store.as_context_mut(), ())?; - callee.post_return(store.as_context_mut())?; Ok(ret0) } pub fn call_pair_ret( @@ -953,7 +936,6 @@ pub mod exports { >::new_unchecked(self.pair_ret) }; let (ret0,) = callee.call(store.as_context_mut(), ())?; - callee.post_return(store.as_context_mut())?; Ok(ret0) } } diff --git a/crates/component-macro/tests/expanded/integers_async.rs b/crates/component-macro/tests/expanded/integers_async.rs index 016aa0fc4077..db1617f4c4c1 100644 --- a/crates/component-macro/tests/expanded/integers_async.rs +++ b/crates/component-macro/tests/expanded/integers_async.rs @@ -790,7 +790,6 @@ pub mod exports { let () = callee .call_async(store.as_context_mut(), (arg0,)) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(()) } pub async fn call_a2( @@ -810,7 +809,6 @@ pub mod exports { let () = callee .call_async(store.as_context_mut(), (arg0,)) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(()) } pub async fn call_a3( @@ -830,7 +828,6 @@ pub mod exports { let () = callee .call_async(store.as_context_mut(), (arg0,)) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(()) } pub async fn call_a4( @@ -850,7 +847,6 @@ pub mod exports { let () = callee .call_async(store.as_context_mut(), (arg0,)) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(()) } pub async fn call_a5( @@ -870,7 +866,6 @@ pub mod exports { let () = callee .call_async(store.as_context_mut(), (arg0,)) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(()) } pub async fn call_a6( @@ -890,7 +885,6 @@ pub mod exports { let () = callee .call_async(store.as_context_mut(), (arg0,)) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(()) } pub async fn call_a7( @@ -910,7 +904,6 @@ pub mod exports { let () = callee .call_async(store.as_context_mut(), (arg0,)) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(()) } pub async fn call_a8( @@ -930,7 +923,6 @@ pub mod exports { let () = callee .call_async(store.as_context_mut(), (arg0,)) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(()) } pub async fn call_a9( @@ -960,7 +952,6 @@ pub mod exports { (arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7), ) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(()) } pub async fn call_r1( @@ -979,7 +970,6 @@ pub mod exports { let (ret0,) = callee .call_async(store.as_context_mut(), ()) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(ret0) } pub async fn call_r2( @@ -998,7 +988,6 @@ pub mod exports { let (ret0,) = callee .call_async(store.as_context_mut(), ()) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(ret0) } pub async fn call_r3( @@ -1017,7 +1006,6 @@ pub mod exports { let (ret0,) = callee .call_async(store.as_context_mut(), ()) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(ret0) } pub async fn call_r4( @@ -1036,7 +1024,6 @@ pub mod exports { let (ret0,) = callee .call_async(store.as_context_mut(), ()) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(ret0) } pub async fn call_r5( @@ -1055,7 +1042,6 @@ pub mod exports { let (ret0,) = callee .call_async(store.as_context_mut(), ()) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(ret0) } pub async fn call_r6( @@ -1074,7 +1060,6 @@ pub mod exports { let (ret0,) = callee .call_async(store.as_context_mut(), ()) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(ret0) } pub async fn call_r7( @@ -1093,7 +1078,6 @@ pub mod exports { let (ret0,) = callee .call_async(store.as_context_mut(), ()) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(ret0) } pub async fn call_r8( @@ -1112,7 +1096,6 @@ pub mod exports { let (ret0,) = callee .call_async(store.as_context_mut(), ()) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(ret0) } pub async fn call_pair_ret( @@ -1131,7 +1114,6 @@ pub mod exports { let (ret0,) = callee .call_async(store.as_context_mut(), ()) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(ret0) } } diff --git a/crates/component-macro/tests/expanded/integers_tracing_async.rs b/crates/component-macro/tests/expanded/integers_tracing_async.rs index 15093f08d7b3..bf7da5352009 100644 --- a/crates/component-macro/tests/expanded/integers_tracing_async.rs +++ b/crates/component-macro/tests/expanded/integers_tracing_async.rs @@ -1061,10 +1061,6 @@ pub mod exports { .call_async(store.as_context_mut(), (arg0,)) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(()) } pub async fn call_a2( @@ -1090,10 +1086,6 @@ pub mod exports { .call_async(store.as_context_mut(), (arg0,)) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(()) } pub async fn call_a3( @@ -1119,10 +1111,6 @@ pub mod exports { .call_async(store.as_context_mut(), (arg0,)) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(()) } pub async fn call_a4( @@ -1148,10 +1136,6 @@ pub mod exports { .call_async(store.as_context_mut(), (arg0,)) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(()) } pub async fn call_a5( @@ -1177,10 +1161,6 @@ pub mod exports { .call_async(store.as_context_mut(), (arg0,)) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(()) } pub async fn call_a6( @@ -1206,10 +1186,6 @@ pub mod exports { .call_async(store.as_context_mut(), (arg0,)) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(()) } pub async fn call_a7( @@ -1235,10 +1211,6 @@ pub mod exports { .call_async(store.as_context_mut(), (arg0,)) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(()) } pub async fn call_a8( @@ -1264,10 +1236,6 @@ pub mod exports { .call_async(store.as_context_mut(), (arg0,)) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(()) } pub async fn call_a9( @@ -1303,10 +1271,6 @@ pub mod exports { ) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(()) } pub async fn call_r1( @@ -1331,10 +1295,6 @@ pub mod exports { .call_async(store.as_context_mut(), ()) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(ret0) } pub async fn call_r2( @@ -1359,10 +1319,6 @@ pub mod exports { .call_async(store.as_context_mut(), ()) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(ret0) } pub async fn call_r3( @@ -1387,10 +1343,6 @@ pub mod exports { .call_async(store.as_context_mut(), ()) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(ret0) } pub async fn call_r4( @@ -1415,10 +1367,6 @@ pub mod exports { .call_async(store.as_context_mut(), ()) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(ret0) } pub async fn call_r5( @@ -1443,10 +1391,6 @@ pub mod exports { .call_async(store.as_context_mut(), ()) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(ret0) } pub async fn call_r6( @@ -1471,10 +1415,6 @@ pub mod exports { .call_async(store.as_context_mut(), ()) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(ret0) } pub async fn call_r7( @@ -1499,10 +1439,6 @@ pub mod exports { .call_async(store.as_context_mut(), ()) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(ret0) } pub async fn call_r8( @@ -1527,10 +1463,6 @@ pub mod exports { .call_async(store.as_context_mut(), ()) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(ret0) } pub async fn call_pair_ret( @@ -1555,10 +1487,6 @@ pub mod exports { .call_async(store.as_context_mut(), ()) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(ret0) } } diff --git a/crates/component-macro/tests/expanded/lists.rs b/crates/component-macro/tests/expanded/lists.rs index 51800bae0fdf..613735361d9d 100644 --- a/crates/component-macro/tests/expanded/lists.rs +++ b/crates/component-macro/tests/expanded/lists.rs @@ -1553,7 +1553,6 @@ pub mod exports { >::new_unchecked(self.list_u8_param) }; let () = callee.call(store.as_context_mut(), (arg0,))?; - callee.post_return(store.as_context_mut())?; Ok(()) } pub fn call_list_u16_param( @@ -1568,7 +1567,6 @@ pub mod exports { >::new_unchecked(self.list_u16_param) }; let () = callee.call(store.as_context_mut(), (arg0,))?; - callee.post_return(store.as_context_mut())?; Ok(()) } pub fn call_list_u32_param( @@ -1583,7 +1581,6 @@ pub mod exports { >::new_unchecked(self.list_u32_param) }; let () = callee.call(store.as_context_mut(), (arg0,))?; - callee.post_return(store.as_context_mut())?; Ok(()) } pub fn call_list_u64_param( @@ -1598,7 +1595,6 @@ pub mod exports { >::new_unchecked(self.list_u64_param) }; let () = callee.call(store.as_context_mut(), (arg0,))?; - callee.post_return(store.as_context_mut())?; Ok(()) } pub fn call_list_s8_param( @@ -1613,7 +1609,6 @@ pub mod exports { >::new_unchecked(self.list_s8_param) }; let () = callee.call(store.as_context_mut(), (arg0,))?; - callee.post_return(store.as_context_mut())?; Ok(()) } pub fn call_list_s16_param( @@ -1628,7 +1623,6 @@ pub mod exports { >::new_unchecked(self.list_s16_param) }; let () = callee.call(store.as_context_mut(), (arg0,))?; - callee.post_return(store.as_context_mut())?; Ok(()) } pub fn call_list_s32_param( @@ -1643,7 +1637,6 @@ pub mod exports { >::new_unchecked(self.list_s32_param) }; let () = callee.call(store.as_context_mut(), (arg0,))?; - callee.post_return(store.as_context_mut())?; Ok(()) } pub fn call_list_s64_param( @@ -1658,7 +1651,6 @@ pub mod exports { >::new_unchecked(self.list_s64_param) }; let () = callee.call(store.as_context_mut(), (arg0,))?; - callee.post_return(store.as_context_mut())?; Ok(()) } pub fn call_list_f32_param( @@ -1673,7 +1665,6 @@ pub mod exports { >::new_unchecked(self.list_f32_param) }; let () = callee.call(store.as_context_mut(), (arg0,))?; - callee.post_return(store.as_context_mut())?; Ok(()) } pub fn call_list_f64_param( @@ -1688,7 +1679,6 @@ pub mod exports { >::new_unchecked(self.list_f64_param) }; let () = callee.call(store.as_context_mut(), (arg0,))?; - callee.post_return(store.as_context_mut())?; Ok(()) } pub fn call_list_u8_ret( @@ -1702,7 +1692,6 @@ pub mod exports { >::new_unchecked(self.list_u8_ret) }; let (ret0,) = callee.call(store.as_context_mut(), ())?; - callee.post_return(store.as_context_mut())?; Ok(ret0) } pub fn call_list_u16_ret( @@ -1716,7 +1705,6 @@ pub mod exports { >::new_unchecked(self.list_u16_ret) }; let (ret0,) = callee.call(store.as_context_mut(), ())?; - callee.post_return(store.as_context_mut())?; Ok(ret0) } pub fn call_list_u32_ret( @@ -1730,7 +1718,6 @@ pub mod exports { >::new_unchecked(self.list_u32_ret) }; let (ret0,) = callee.call(store.as_context_mut(), ())?; - callee.post_return(store.as_context_mut())?; Ok(ret0) } pub fn call_list_u64_ret( @@ -1744,7 +1731,6 @@ pub mod exports { >::new_unchecked(self.list_u64_ret) }; let (ret0,) = callee.call(store.as_context_mut(), ())?; - callee.post_return(store.as_context_mut())?; Ok(ret0) } pub fn call_list_s8_ret( @@ -1758,7 +1744,6 @@ pub mod exports { >::new_unchecked(self.list_s8_ret) }; let (ret0,) = callee.call(store.as_context_mut(), ())?; - callee.post_return(store.as_context_mut())?; Ok(ret0) } pub fn call_list_s16_ret( @@ -1772,7 +1757,6 @@ pub mod exports { >::new_unchecked(self.list_s16_ret) }; let (ret0,) = callee.call(store.as_context_mut(), ())?; - callee.post_return(store.as_context_mut())?; Ok(ret0) } pub fn call_list_s32_ret( @@ -1786,7 +1770,6 @@ pub mod exports { >::new_unchecked(self.list_s32_ret) }; let (ret0,) = callee.call(store.as_context_mut(), ())?; - callee.post_return(store.as_context_mut())?; Ok(ret0) } pub fn call_list_s64_ret( @@ -1800,7 +1783,6 @@ pub mod exports { >::new_unchecked(self.list_s64_ret) }; let (ret0,) = callee.call(store.as_context_mut(), ())?; - callee.post_return(store.as_context_mut())?; Ok(ret0) } pub fn call_list_f32_ret( @@ -1814,7 +1796,6 @@ pub mod exports { >::new_unchecked(self.list_f32_ret) }; let (ret0,) = callee.call(store.as_context_mut(), ())?; - callee.post_return(store.as_context_mut())?; Ok(ret0) } pub fn call_list_f64_ret( @@ -1828,7 +1809,6 @@ pub mod exports { >::new_unchecked(self.list_f64_ret) }; let (ret0,) = callee.call(store.as_context_mut(), ())?; - callee.post_return(store.as_context_mut())?; Ok(ret0) } pub fn call_tuple_list( @@ -1845,7 +1825,6 @@ pub mod exports { >::new_unchecked(self.tuple_list) }; let (ret0,) = callee.call(store.as_context_mut(), (arg0,))?; - callee.post_return(store.as_context_mut())?; Ok(ret0) } pub fn call_string_list_arg( @@ -1860,7 +1839,6 @@ pub mod exports { >::new_unchecked(self.string_list_arg) }; let () = callee.call(store.as_context_mut(), (arg0,))?; - callee.post_return(store.as_context_mut())?; Ok(()) } pub fn call_string_list_ret( @@ -1882,7 +1860,6 @@ pub mod exports { >::new_unchecked(self.string_list_ret) }; let (ret0,) = callee.call(store.as_context_mut(), ())?; - callee.post_return(store.as_context_mut())?; Ok(ret0) } pub fn call_tuple_string_list( @@ -1905,7 +1882,6 @@ pub mod exports { >::new_unchecked(self.tuple_string_list) }; let (ret0,) = callee.call(store.as_context_mut(), (arg0,))?; - callee.post_return(store.as_context_mut())?; Ok(ret0) } pub fn call_string_list( @@ -1928,7 +1904,6 @@ pub mod exports { >::new_unchecked(self.string_list) }; let (ret0,) = callee.call(store.as_context_mut(), (arg0,))?; - callee.post_return(store.as_context_mut())?; Ok(ret0) } pub fn call_record_list( @@ -1945,7 +1920,6 @@ pub mod exports { >::new_unchecked(self.record_list) }; let (ret0,) = callee.call(store.as_context_mut(), (arg0,))?; - callee.post_return(store.as_context_mut())?; Ok(ret0) } pub fn call_record_list_reverse( @@ -1962,7 +1936,6 @@ pub mod exports { >::new_unchecked(self.record_list_reverse) }; let (ret0,) = callee.call(store.as_context_mut(), (arg0,))?; - callee.post_return(store.as_context_mut())?; Ok(ret0) } pub fn call_variant_list( @@ -1979,7 +1952,6 @@ pub mod exports { >::new_unchecked(self.variant_list) }; let (ret0,) = callee.call(store.as_context_mut(), (arg0,))?; - callee.post_return(store.as_context_mut())?; Ok(ret0) } pub fn call_load_store_everything( @@ -1994,7 +1966,6 @@ pub mod exports { >::new_unchecked(self.load_store_everything) }; let (ret0,) = callee.call(store.as_context_mut(), (arg0,))?; - callee.post_return(store.as_context_mut())?; Ok(ret0) } } diff --git a/crates/component-macro/tests/expanded/lists_async.rs b/crates/component-macro/tests/expanded/lists_async.rs index fdb896fdcdba..3f7866b3b7a3 100644 --- a/crates/component-macro/tests/expanded/lists_async.rs +++ b/crates/component-macro/tests/expanded/lists_async.rs @@ -1724,7 +1724,6 @@ pub mod exports { let () = callee .call_async(store.as_context_mut(), (arg0,)) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(()) } pub async fn call_list_u16_param( @@ -1744,7 +1743,6 @@ pub mod exports { let () = callee .call_async(store.as_context_mut(), (arg0,)) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(()) } pub async fn call_list_u32_param( @@ -1764,7 +1762,6 @@ pub mod exports { let () = callee .call_async(store.as_context_mut(), (arg0,)) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(()) } pub async fn call_list_u64_param( @@ -1784,7 +1781,6 @@ pub mod exports { let () = callee .call_async(store.as_context_mut(), (arg0,)) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(()) } pub async fn call_list_s8_param( @@ -1804,7 +1800,6 @@ pub mod exports { let () = callee .call_async(store.as_context_mut(), (arg0,)) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(()) } pub async fn call_list_s16_param( @@ -1824,7 +1819,6 @@ pub mod exports { let () = callee .call_async(store.as_context_mut(), (arg0,)) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(()) } pub async fn call_list_s32_param( @@ -1844,7 +1838,6 @@ pub mod exports { let () = callee .call_async(store.as_context_mut(), (arg0,)) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(()) } pub async fn call_list_s64_param( @@ -1864,7 +1857,6 @@ pub mod exports { let () = callee .call_async(store.as_context_mut(), (arg0,)) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(()) } pub async fn call_list_f32_param( @@ -1884,7 +1876,6 @@ pub mod exports { let () = callee .call_async(store.as_context_mut(), (arg0,)) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(()) } pub async fn call_list_f64_param( @@ -1904,7 +1895,6 @@ pub mod exports { let () = callee .call_async(store.as_context_mut(), (arg0,)) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(()) } pub async fn call_list_u8_ret( @@ -1923,7 +1913,6 @@ pub mod exports { let (ret0,) = callee .call_async(store.as_context_mut(), ()) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(ret0) } pub async fn call_list_u16_ret( @@ -1942,7 +1931,6 @@ pub mod exports { let (ret0,) = callee .call_async(store.as_context_mut(), ()) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(ret0) } pub async fn call_list_u32_ret( @@ -1961,7 +1949,6 @@ pub mod exports { let (ret0,) = callee .call_async(store.as_context_mut(), ()) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(ret0) } pub async fn call_list_u64_ret( @@ -1980,7 +1967,6 @@ pub mod exports { let (ret0,) = callee .call_async(store.as_context_mut(), ()) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(ret0) } pub async fn call_list_s8_ret( @@ -1999,7 +1985,6 @@ pub mod exports { let (ret0,) = callee .call_async(store.as_context_mut(), ()) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(ret0) } pub async fn call_list_s16_ret( @@ -2018,7 +2003,6 @@ pub mod exports { let (ret0,) = callee .call_async(store.as_context_mut(), ()) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(ret0) } pub async fn call_list_s32_ret( @@ -2037,7 +2021,6 @@ pub mod exports { let (ret0,) = callee .call_async(store.as_context_mut(), ()) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(ret0) } pub async fn call_list_s64_ret( @@ -2056,7 +2039,6 @@ pub mod exports { let (ret0,) = callee .call_async(store.as_context_mut(), ()) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(ret0) } pub async fn call_list_f32_ret( @@ -2075,7 +2057,6 @@ pub mod exports { let (ret0,) = callee .call_async(store.as_context_mut(), ()) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(ret0) } pub async fn call_list_f64_ret( @@ -2094,7 +2075,6 @@ pub mod exports { let (ret0,) = callee .call_async(store.as_context_mut(), ()) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(ret0) } pub async fn call_tuple_list( @@ -2116,7 +2096,6 @@ pub mod exports { let (ret0,) = callee .call_async(store.as_context_mut(), (arg0,)) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(ret0) } pub async fn call_string_list_arg( @@ -2136,7 +2115,6 @@ pub mod exports { let () = callee .call_async(store.as_context_mut(), (arg0,)) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(()) } pub async fn call_string_list_ret( @@ -2163,7 +2141,6 @@ pub mod exports { let (ret0,) = callee .call_async(store.as_context_mut(), ()) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(ret0) } pub async fn call_tuple_string_list( @@ -2191,7 +2168,6 @@ pub mod exports { let (ret0,) = callee .call_async(store.as_context_mut(), (arg0,)) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(ret0) } pub async fn call_string_list( @@ -2219,7 +2195,6 @@ pub mod exports { let (ret0,) = callee .call_async(store.as_context_mut(), (arg0,)) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(ret0) } pub async fn call_record_list( @@ -2241,7 +2216,6 @@ pub mod exports { let (ret0,) = callee .call_async(store.as_context_mut(), (arg0,)) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(ret0) } pub async fn call_record_list_reverse( @@ -2263,7 +2237,6 @@ pub mod exports { let (ret0,) = callee .call_async(store.as_context_mut(), (arg0,)) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(ret0) } pub async fn call_variant_list( @@ -2285,7 +2258,6 @@ pub mod exports { let (ret0,) = callee .call_async(store.as_context_mut(), (arg0,)) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(ret0) } pub async fn call_load_store_everything( @@ -2305,7 +2277,6 @@ pub mod exports { let (ret0,) = callee .call_async(store.as_context_mut(), (arg0,)) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(ret0) } } diff --git a/crates/component-macro/tests/expanded/lists_tracing_async.rs b/crates/component-macro/tests/expanded/lists_tracing_async.rs index 5dc0cfbd47a7..c2b5f0c04bf4 100644 --- a/crates/component-macro/tests/expanded/lists_tracing_async.rs +++ b/crates/component-macro/tests/expanded/lists_tracing_async.rs @@ -2161,10 +2161,6 @@ pub mod exports { .call_async(store.as_context_mut(), (arg0,)) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(()) } pub async fn call_list_u16_param( @@ -2190,10 +2186,6 @@ pub mod exports { .call_async(store.as_context_mut(), (arg0,)) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(()) } pub async fn call_list_u32_param( @@ -2219,10 +2211,6 @@ pub mod exports { .call_async(store.as_context_mut(), (arg0,)) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(()) } pub async fn call_list_u64_param( @@ -2248,10 +2236,6 @@ pub mod exports { .call_async(store.as_context_mut(), (arg0,)) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(()) } pub async fn call_list_s8_param( @@ -2277,10 +2261,6 @@ pub mod exports { .call_async(store.as_context_mut(), (arg0,)) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(()) } pub async fn call_list_s16_param( @@ -2306,10 +2286,6 @@ pub mod exports { .call_async(store.as_context_mut(), (arg0,)) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(()) } pub async fn call_list_s32_param( @@ -2335,10 +2311,6 @@ pub mod exports { .call_async(store.as_context_mut(), (arg0,)) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(()) } pub async fn call_list_s64_param( @@ -2364,10 +2336,6 @@ pub mod exports { .call_async(store.as_context_mut(), (arg0,)) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(()) } pub async fn call_list_f32_param( @@ -2393,10 +2361,6 @@ pub mod exports { .call_async(store.as_context_mut(), (arg0,)) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(()) } pub async fn call_list_f64_param( @@ -2422,10 +2386,6 @@ pub mod exports { .call_async(store.as_context_mut(), (arg0,)) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(()) } pub async fn call_list_u8_ret( @@ -2450,10 +2410,6 @@ pub mod exports { .call_async(store.as_context_mut(), ()) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(ret0) } pub async fn call_list_u16_ret( @@ -2478,10 +2434,6 @@ pub mod exports { .call_async(store.as_context_mut(), ()) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(ret0) } pub async fn call_list_u32_ret( @@ -2506,10 +2458,6 @@ pub mod exports { .call_async(store.as_context_mut(), ()) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(ret0) } pub async fn call_list_u64_ret( @@ -2534,10 +2482,6 @@ pub mod exports { .call_async(store.as_context_mut(), ()) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(ret0) } pub async fn call_list_s8_ret( @@ -2562,10 +2506,6 @@ pub mod exports { .call_async(store.as_context_mut(), ()) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(ret0) } pub async fn call_list_s16_ret( @@ -2590,10 +2530,6 @@ pub mod exports { .call_async(store.as_context_mut(), ()) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(ret0) } pub async fn call_list_s32_ret( @@ -2618,10 +2554,6 @@ pub mod exports { .call_async(store.as_context_mut(), ()) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(ret0) } pub async fn call_list_s64_ret( @@ -2646,10 +2578,6 @@ pub mod exports { .call_async(store.as_context_mut(), ()) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(ret0) } pub async fn call_list_f32_ret( @@ -2674,10 +2602,6 @@ pub mod exports { .call_async(store.as_context_mut(), ()) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(ret0) } pub async fn call_list_f64_ret( @@ -2702,10 +2626,6 @@ pub mod exports { .call_async(store.as_context_mut(), ()) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(ret0) } pub async fn call_tuple_list( @@ -2733,10 +2653,6 @@ pub mod exports { .call_async(store.as_context_mut(), (arg0,)) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(ret0) } pub async fn call_string_list_arg( @@ -2762,10 +2678,6 @@ pub mod exports { .call_async(store.as_context_mut(), (arg0,)) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(()) } pub async fn call_string_list_ret( @@ -2798,10 +2710,6 @@ pub mod exports { .call_async(store.as_context_mut(), ()) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(ret0) } pub async fn call_tuple_string_list( @@ -2835,10 +2743,6 @@ pub mod exports { .call_async(store.as_context_mut(), (arg0,)) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(ret0) } pub async fn call_string_list( @@ -2872,10 +2776,6 @@ pub mod exports { .call_async(store.as_context_mut(), (arg0,)) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(ret0) } pub async fn call_record_list( @@ -2903,10 +2803,6 @@ pub mod exports { .call_async(store.as_context_mut(), (arg0,)) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(ret0) } pub async fn call_record_list_reverse( @@ -2934,10 +2830,6 @@ pub mod exports { .call_async(store.as_context_mut(), (arg0,)) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(ret0) } pub async fn call_variant_list( @@ -2965,10 +2857,6 @@ pub mod exports { .call_async(store.as_context_mut(), (arg0,)) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(ret0) } pub async fn call_load_store_everything( @@ -2994,10 +2882,6 @@ pub mod exports { .call_async(store.as_context_mut(), (arg0,)) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(ret0) } } diff --git a/crates/component-macro/tests/expanded/many-arguments.rs b/crates/component-macro/tests/expanded/many-arguments.rs index 1c18b77b2599..69ee064a7973 100644 --- a/crates/component-macro/tests/expanded/many-arguments.rs +++ b/crates/component-macro/tests/expanded/many-arguments.rs @@ -679,7 +679,6 @@ pub mod exports { arg15, ), )?; - callee.post_return(store.as_context_mut())?; Ok(()) } pub fn call_big_argument( @@ -694,7 +693,6 @@ pub mod exports { >::new_unchecked(self.big_argument) }; let () = callee.call(store.as_context_mut(), (arg0,))?; - callee.post_return(store.as_context_mut())?; Ok(()) } } diff --git a/crates/component-macro/tests/expanded/many-arguments_async.rs b/crates/component-macro/tests/expanded/many-arguments_async.rs index 4d9700235c83..5657799da780 100644 --- a/crates/component-macro/tests/expanded/many-arguments_async.rs +++ b/crates/component-macro/tests/expanded/many-arguments_async.rs @@ -697,7 +697,6 @@ pub mod exports { ), ) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(()) } pub async fn call_big_argument( @@ -717,7 +716,6 @@ pub mod exports { let () = callee .call_async(store.as_context_mut(), (arg0,)) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(()) } } diff --git a/crates/component-macro/tests/expanded/many-arguments_tracing_async.rs b/crates/component-macro/tests/expanded/many-arguments_tracing_async.rs index 0e5049be7d3b..bae7812bc364 100644 --- a/crates/component-macro/tests/expanded/many-arguments_tracing_async.rs +++ b/crates/component-macro/tests/expanded/many-arguments_tracing_async.rs @@ -746,10 +746,6 @@ pub mod exports { ) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(()) } pub async fn call_big_argument( @@ -775,10 +771,6 @@ pub mod exports { .call_async(store.as_context_mut(), (arg0,)) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(()) } } diff --git a/crates/component-macro/tests/expanded/multiversion.rs b/crates/component-macro/tests/expanded/multiversion.rs index ab9291731c8f..3e60b5ebb487 100644 --- a/crates/component-macro/tests/expanded/multiversion.rs +++ b/crates/component-macro/tests/expanded/multiversion.rs @@ -352,7 +352,6 @@ pub mod exports { >::new_unchecked(self.x) }; let () = callee.call(store.as_context_mut(), ())?; - callee.post_return(store.as_context_mut())?; Ok(()) } } @@ -432,7 +431,6 @@ pub mod exports { >::new_unchecked(self.x) }; let () = callee.call(store.as_context_mut(), ())?; - callee.post_return(store.as_context_mut())?; Ok(()) } } diff --git a/crates/component-macro/tests/expanded/multiversion_async.rs b/crates/component-macro/tests/expanded/multiversion_async.rs index 7774844f2bcf..ead3b04e9615 100644 --- a/crates/component-macro/tests/expanded/multiversion_async.rs +++ b/crates/component-macro/tests/expanded/multiversion_async.rs @@ -359,7 +359,6 @@ pub mod exports { >::new_unchecked(self.x) }; let () = callee.call_async(store.as_context_mut(), ()).await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(()) } } @@ -442,7 +441,6 @@ pub mod exports { >::new_unchecked(self.x) }; let () = callee.call_async(store.as_context_mut(), ()).await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(()) } } diff --git a/crates/component-macro/tests/expanded/multiversion_tracing_async.rs b/crates/component-macro/tests/expanded/multiversion_tracing_async.rs index 3935f76f3cc1..f8c6d2557186 100644 --- a/crates/component-macro/tests/expanded/multiversion_tracing_async.rs +++ b/crates/component-macro/tests/expanded/multiversion_tracing_async.rs @@ -393,10 +393,6 @@ pub mod exports { .call_async(store.as_context_mut(), ()) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(()) } } @@ -487,10 +483,6 @@ pub mod exports { .call_async(store.as_context_mut(), ()) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(()) } } diff --git a/crates/component-macro/tests/expanded/records.rs b/crates/component-macro/tests/expanded/records.rs index 0ad1a56b866f..fe82efb4a2bf 100644 --- a/crates/component-macro/tests/expanded/records.rs +++ b/crates/component-macro/tests/expanded/records.rs @@ -895,7 +895,6 @@ pub mod exports { >::new_unchecked(self.tuple_arg) }; let () = callee.call(store.as_context_mut(), (arg0,))?; - callee.post_return(store.as_context_mut())?; Ok(()) } pub fn call_tuple_result( @@ -909,7 +908,6 @@ pub mod exports { >::new_unchecked(self.tuple_result) }; let (ret0,) = callee.call(store.as_context_mut(), ())?; - callee.post_return(store.as_context_mut())?; Ok(ret0) } pub fn call_empty_arg( @@ -924,7 +922,6 @@ pub mod exports { >::new_unchecked(self.empty_arg) }; let () = callee.call(store.as_context_mut(), (arg0,))?; - callee.post_return(store.as_context_mut())?; Ok(()) } pub fn call_empty_result( @@ -938,7 +935,6 @@ pub mod exports { >::new_unchecked(self.empty_result) }; let (ret0,) = callee.call(store.as_context_mut(), ())?; - callee.post_return(store.as_context_mut())?; Ok(ret0) } pub fn call_scalar_arg( @@ -953,7 +949,6 @@ pub mod exports { >::new_unchecked(self.scalar_arg) }; let () = callee.call(store.as_context_mut(), (arg0,))?; - callee.post_return(store.as_context_mut())?; Ok(()) } pub fn call_scalar_result( @@ -967,7 +962,6 @@ pub mod exports { >::new_unchecked(self.scalar_result) }; let (ret0,) = callee.call(store.as_context_mut(), ())?; - callee.post_return(store.as_context_mut())?; Ok(ret0) } pub fn call_flags_arg( @@ -982,7 +976,6 @@ pub mod exports { >::new_unchecked(self.flags_arg) }; let () = callee.call(store.as_context_mut(), (arg0,))?; - callee.post_return(store.as_context_mut())?; Ok(()) } pub fn call_flags_result( @@ -996,7 +989,6 @@ pub mod exports { >::new_unchecked(self.flags_result) }; let (ret0,) = callee.call(store.as_context_mut(), ())?; - callee.post_return(store.as_context_mut())?; Ok(ret0) } pub fn call_aggregate_arg( @@ -1011,7 +1003,6 @@ pub mod exports { >::new_unchecked(self.aggregate_arg) }; let () = callee.call(store.as_context_mut(), (arg0,))?; - callee.post_return(store.as_context_mut())?; Ok(()) } pub fn call_aggregate_result( @@ -1025,7 +1016,6 @@ pub mod exports { >::new_unchecked(self.aggregate_result) }; let (ret0,) = callee.call(store.as_context_mut(), ())?; - callee.post_return(store.as_context_mut())?; Ok(ret0) } pub fn call_typedef_inout( @@ -1040,7 +1030,6 @@ pub mod exports { >::new_unchecked(self.typedef_inout) }; let (ret0,) = callee.call(store.as_context_mut(), (arg0,))?; - callee.post_return(store.as_context_mut())?; Ok(ret0) } } diff --git a/crates/component-macro/tests/expanded/records_async.rs b/crates/component-macro/tests/expanded/records_async.rs index d9864b7058da..4453813966db 100644 --- a/crates/component-macro/tests/expanded/records_async.rs +++ b/crates/component-macro/tests/expanded/records_async.rs @@ -978,7 +978,6 @@ pub mod exports { let () = callee .call_async(store.as_context_mut(), (arg0,)) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(()) } pub async fn call_tuple_result( @@ -997,7 +996,6 @@ pub mod exports { let (ret0,) = callee .call_async(store.as_context_mut(), ()) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(ret0) } pub async fn call_empty_arg( @@ -1017,7 +1015,6 @@ pub mod exports { let () = callee .call_async(store.as_context_mut(), (arg0,)) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(()) } pub async fn call_empty_result( @@ -1036,7 +1033,6 @@ pub mod exports { let (ret0,) = callee .call_async(store.as_context_mut(), ()) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(ret0) } pub async fn call_scalar_arg( @@ -1056,7 +1052,6 @@ pub mod exports { let () = callee .call_async(store.as_context_mut(), (arg0,)) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(()) } pub async fn call_scalar_result( @@ -1075,7 +1070,6 @@ pub mod exports { let (ret0,) = callee .call_async(store.as_context_mut(), ()) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(ret0) } pub async fn call_flags_arg( @@ -1095,7 +1089,6 @@ pub mod exports { let () = callee .call_async(store.as_context_mut(), (arg0,)) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(()) } pub async fn call_flags_result( @@ -1114,7 +1107,6 @@ pub mod exports { let (ret0,) = callee .call_async(store.as_context_mut(), ()) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(ret0) } pub async fn call_aggregate_arg( @@ -1134,7 +1126,6 @@ pub mod exports { let () = callee .call_async(store.as_context_mut(), (arg0,)) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(()) } pub async fn call_aggregate_result( @@ -1153,7 +1144,6 @@ pub mod exports { let (ret0,) = callee .call_async(store.as_context_mut(), ()) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(ret0) } pub async fn call_typedef_inout( @@ -1173,7 +1163,6 @@ pub mod exports { let (ret0,) = callee .call_async(store.as_context_mut(), (arg0,)) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(ret0) } } diff --git a/crates/component-macro/tests/expanded/records_tracing_async.rs b/crates/component-macro/tests/expanded/records_tracing_async.rs index 9a45e17af333..dd8846d8e947 100644 --- a/crates/component-macro/tests/expanded/records_tracing_async.rs +++ b/crates/component-macro/tests/expanded/records_tracing_async.rs @@ -1145,10 +1145,6 @@ pub mod exports { .call_async(store.as_context_mut(), (arg0,)) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(()) } pub async fn call_tuple_result( @@ -1173,10 +1169,6 @@ pub mod exports { .call_async(store.as_context_mut(), ()) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(ret0) } pub async fn call_empty_arg( @@ -1202,10 +1194,6 @@ pub mod exports { .call_async(store.as_context_mut(), (arg0,)) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(()) } pub async fn call_empty_result( @@ -1230,10 +1218,6 @@ pub mod exports { .call_async(store.as_context_mut(), ()) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(ret0) } pub async fn call_scalar_arg( @@ -1259,10 +1243,6 @@ pub mod exports { .call_async(store.as_context_mut(), (arg0,)) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(()) } pub async fn call_scalar_result( @@ -1287,10 +1267,6 @@ pub mod exports { .call_async(store.as_context_mut(), ()) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(ret0) } pub async fn call_flags_arg( @@ -1316,10 +1292,6 @@ pub mod exports { .call_async(store.as_context_mut(), (arg0,)) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(()) } pub async fn call_flags_result( @@ -1344,10 +1316,6 @@ pub mod exports { .call_async(store.as_context_mut(), ()) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(ret0) } pub async fn call_aggregate_arg( @@ -1373,10 +1341,6 @@ pub mod exports { .call_async(store.as_context_mut(), (arg0,)) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(()) } pub async fn call_aggregate_result( @@ -1401,10 +1365,6 @@ pub mod exports { .call_async(store.as_context_mut(), ()) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(ret0) } pub async fn call_typedef_inout( @@ -1430,10 +1390,6 @@ pub mod exports { .call_async(store.as_context_mut(), (arg0,)) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(ret0) } } diff --git a/crates/component-macro/tests/expanded/resources-export.rs b/crates/component-macro/tests/expanded/resources-export.rs index 45f5d523e45b..1ea10ab962df 100644 --- a/crates/component-macro/tests/expanded/resources-export.rs +++ b/crates/component-macro/tests/expanded/resources-export.rs @@ -398,7 +398,6 @@ pub mod exports { >::new_unchecked(self.funcs.constructor_a_constructor) }; let (ret0,) = callee.call(store.as_context_mut(), ())?; - callee.post_return(store.as_context_mut())?; Ok(ret0) } pub fn call_static_a( @@ -412,7 +411,6 @@ pub mod exports { >::new_unchecked(self.funcs.static_a_static_a) }; let (ret0,) = callee.call(store.as_context_mut(), ())?; - callee.post_return(store.as_context_mut())?; Ok(ret0) } pub fn call_method_a( @@ -427,7 +425,6 @@ pub mod exports { >::new_unchecked(self.funcs.method_a_method_a) }; let (ret0,) = callee.call(store.as_context_mut(), (arg0,))?; - callee.post_return(store.as_context_mut())?; Ok(ret0) } } @@ -548,7 +545,6 @@ pub mod exports { >::new_unchecked(self.funcs.constructor_a_constructor) }; let (ret0,) = callee.call(store.as_context_mut(), (arg0,))?; - callee.post_return(store.as_context_mut())?; Ok(ret0) } pub fn call_static_a( @@ -562,7 +558,6 @@ pub mod exports { >::new_unchecked(self.funcs.static_a_static_a) }; let (ret0,) = callee.call(store.as_context_mut(), ())?; - callee.post_return(store.as_context_mut())?; Ok(ret0) } pub fn call_method_a( @@ -581,7 +576,6 @@ pub mod exports { >::new_unchecked(self.funcs.method_a_method_a) }; let (ret0,) = callee.call(store.as_context_mut(), (arg0, arg1))?; - callee.post_return(store.as_context_mut())?; Ok(ret0) } } @@ -673,7 +667,6 @@ pub mod exports { >::new_unchecked(self.funcs.constructor_a_constructor) }; let (ret0,) = callee.call(store.as_context_mut(), ())?; - callee.post_return(store.as_context_mut())?; Ok(ret0) } } @@ -767,7 +760,6 @@ pub mod exports { >::new_unchecked(self.funcs.constructor_b_constructor) }; let (ret0,) = callee.call(store.as_context_mut(), (arg0,))?; - callee.post_return(store.as_context_mut())?; Ok(ret0) } } diff --git a/crates/component-macro/tests/expanded/resources-export_async.rs b/crates/component-macro/tests/expanded/resources-export_async.rs index b76fe9a4db00..8700849d3218 100644 --- a/crates/component-macro/tests/expanded/resources-export_async.rs +++ b/crates/component-macro/tests/expanded/resources-export_async.rs @@ -408,7 +408,6 @@ pub mod exports { let (ret0,) = callee .call_async(store.as_context_mut(), ()) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(ret0) } pub async fn call_static_a( @@ -427,7 +426,6 @@ pub mod exports { let (ret0,) = callee .call_async(store.as_context_mut(), ()) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(ret0) } pub async fn call_method_a( @@ -447,7 +445,6 @@ pub mod exports { let (ret0,) = callee .call_async(store.as_context_mut(), (arg0,)) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(ret0) } } @@ -573,7 +570,6 @@ pub mod exports { let (ret0,) = callee .call_async(store.as_context_mut(), (arg0,)) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(ret0) } pub async fn call_static_a( @@ -592,7 +588,6 @@ pub mod exports { let (ret0,) = callee .call_async(store.as_context_mut(), ()) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(ret0) } pub async fn call_method_a( @@ -616,7 +611,6 @@ pub mod exports { let (ret0,) = callee .call_async(store.as_context_mut(), (arg0, arg1)) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(ret0) } } @@ -713,7 +707,6 @@ pub mod exports { let (ret0,) = callee .call_async(store.as_context_mut(), ()) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(ret0) } } @@ -812,7 +805,6 @@ pub mod exports { let (ret0,) = callee .call_async(store.as_context_mut(), (arg0,)) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(ret0) } } diff --git a/crates/component-macro/tests/expanded/resources-export_tracing_async.rs b/crates/component-macro/tests/expanded/resources-export_tracing_async.rs index d206775ffc78..fd10dcaa780e 100644 --- a/crates/component-macro/tests/expanded/resources-export_tracing_async.rs +++ b/crates/component-macro/tests/expanded/resources-export_tracing_async.rs @@ -414,10 +414,6 @@ pub mod exports { .call_async(store.as_context_mut(), ()) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(ret0) } pub async fn call_static_a( @@ -442,10 +438,6 @@ pub mod exports { .call_async(store.as_context_mut(), ()) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(ret0) } pub async fn call_method_a( @@ -471,10 +463,6 @@ pub mod exports { .call_async(store.as_context_mut(), (arg0,)) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(ret0) } } @@ -606,10 +594,6 @@ pub mod exports { .call_async(store.as_context_mut(), (arg0,)) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(ret0) } pub async fn call_static_a( @@ -635,10 +619,6 @@ pub mod exports { .call_async(store.as_context_mut(), ()) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(ret0) } pub async fn call_method_a( @@ -669,10 +649,6 @@ pub mod exports { .call_async(store.as_context_mut(), (arg0, arg1)) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(ret0) } } @@ -775,10 +751,6 @@ pub mod exports { .call_async(store.as_context_mut(), ()) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(ret0) } } @@ -883,10 +855,6 @@ pub mod exports { .call_async(store.as_context_mut(), (arg0,)) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(ret0) } } diff --git a/crates/component-macro/tests/expanded/resources-import.rs b/crates/component-macro/tests/expanded/resources-import.rs index d1bee31e25dd..529386a3aeaf 100644 --- a/crates/component-macro/tests/expanded/resources-import.rs +++ b/crates/component-macro/tests/expanded/resources-import.rs @@ -360,7 +360,6 @@ const _: () = { >::new_unchecked(self.some_world_func2) }; let (ret0,) = callee.call(store.as_context_mut(), ())?; - callee.post_return(store.as_context_mut())?; Ok(ret0) } pub fn foo_foo_uses_resource_transitively( @@ -1208,7 +1207,6 @@ pub mod exports { >::new_unchecked(self.handle) }; let () = callee.call(store.as_context_mut(), (arg0,))?; - callee.post_return(store.as_context_mut())?; Ok(()) } } diff --git a/crates/component-macro/tests/expanded/resources-import_async.rs b/crates/component-macro/tests/expanded/resources-import_async.rs index 4a052338652b..c340a80b057a 100644 --- a/crates/component-macro/tests/expanded/resources-import_async.rs +++ b/crates/component-macro/tests/expanded/resources-import_async.rs @@ -396,7 +396,6 @@ const _: () = { >::new_unchecked(self.some_world_func2) }; let (ret0,) = callee.call_async(store.as_context_mut(), ()).await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(ret0) } pub fn foo_foo_uses_resource_transitively( @@ -1400,7 +1399,6 @@ pub mod exports { let () = callee .call_async(store.as_context_mut(), (arg0,)) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(()) } } diff --git a/crates/component-macro/tests/expanded/resources-import_tracing_async.rs b/crates/component-macro/tests/expanded/resources-import_tracing_async.rs index f8c847b39cb8..7e2c631f5d56 100644 --- a/crates/component-macro/tests/expanded/resources-import_tracing_async.rs +++ b/crates/component-macro/tests/expanded/resources-import_tracing_async.rs @@ -459,7 +459,6 @@ const _: () = { .call_async(store.as_context_mut(), ()) .instrument(span.clone()) .await?; - callee.post_return_async(store.as_context_mut()).instrument(span).await?; Ok(ret0) } pub fn foo_foo_uses_resource_transitively( @@ -1823,10 +1822,6 @@ pub mod exports { .call_async(store.as_context_mut(), (arg0,)) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(()) } } diff --git a/crates/component-macro/tests/expanded/share-types.rs b/crates/component-macro/tests/expanded/share-types.rs index 01de354735af..c09a5e9fad58 100644 --- a/crates/component-macro/tests/expanded/share-types.rs +++ b/crates/component-macro/tests/expanded/share-types.rs @@ -386,7 +386,6 @@ pub mod exports { >::new_unchecked(self.handle_request) }; let (ret0,) = callee.call(store.as_context_mut(), (arg0,))?; - callee.post_return(store.as_context_mut())?; Ok(ret0) } } diff --git a/crates/component-macro/tests/expanded/share-types_async.rs b/crates/component-macro/tests/expanded/share-types_async.rs index 40df5be0fea8..38f3fbfaabd2 100644 --- a/crates/component-macro/tests/expanded/share-types_async.rs +++ b/crates/component-macro/tests/expanded/share-types_async.rs @@ -397,7 +397,6 @@ pub mod exports { >::new_unchecked(self.handle_request) }; let (ret0,) = callee.call_async(store.as_context_mut(), (arg0,)).await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(ret0) } } diff --git a/crates/component-macro/tests/expanded/share-types_tracing_async.rs b/crates/component-macro/tests/expanded/share-types_tracing_async.rs index 528b1bdfab18..8b2308e0f5de 100644 --- a/crates/component-macro/tests/expanded/share-types_tracing_async.rs +++ b/crates/component-macro/tests/expanded/share-types_tracing_async.rs @@ -421,7 +421,6 @@ pub mod exports { .call_async(store.as_context_mut(), (arg0,)) .instrument(span.clone()) .await?; - callee.post_return_async(store.as_context_mut()).instrument(span).await?; Ok(ret0) } } diff --git a/crates/component-macro/tests/expanded/simple-functions.rs b/crates/component-macro/tests/expanded/simple-functions.rs index b84b8ce9ae18..bb3ab3f3ec93 100644 --- a/crates/component-macro/tests/expanded/simple-functions.rs +++ b/crates/component-macro/tests/expanded/simple-functions.rs @@ -409,7 +409,6 @@ pub mod exports { >::new_unchecked(self.f1) }; let () = callee.call(store.as_context_mut(), ())?; - callee.post_return(store.as_context_mut())?; Ok(()) } pub fn call_f2( @@ -424,7 +423,6 @@ pub mod exports { >::new_unchecked(self.f2) }; let () = callee.call(store.as_context_mut(), (arg0,))?; - callee.post_return(store.as_context_mut())?; Ok(()) } pub fn call_f3( @@ -440,7 +438,6 @@ pub mod exports { >::new_unchecked(self.f3) }; let () = callee.call(store.as_context_mut(), (arg0, arg1))?; - callee.post_return(store.as_context_mut())?; Ok(()) } pub fn call_f4( @@ -454,7 +451,6 @@ pub mod exports { >::new_unchecked(self.f4) }; let (ret0,) = callee.call(store.as_context_mut(), ())?; - callee.post_return(store.as_context_mut())?; Ok(ret0) } pub fn call_f5( @@ -468,7 +464,6 @@ pub mod exports { >::new_unchecked(self.f5) }; let (ret0,) = callee.call(store.as_context_mut(), ())?; - callee.post_return(store.as_context_mut())?; Ok(ret0) } pub fn call_f6( @@ -486,7 +481,6 @@ pub mod exports { }; let (ret0,) = callee .call(store.as_context_mut(), (arg0, arg1, arg2))?; - callee.post_return(store.as_context_mut())?; Ok(ret0) } } diff --git a/crates/component-macro/tests/expanded/simple-functions_async.rs b/crates/component-macro/tests/expanded/simple-functions_async.rs index 8d657a642ab4..dd74e75b2604 100644 --- a/crates/component-macro/tests/expanded/simple-functions_async.rs +++ b/crates/component-macro/tests/expanded/simple-functions_async.rs @@ -452,7 +452,6 @@ pub mod exports { >::new_unchecked(self.f1) }; let () = callee.call_async(store.as_context_mut(), ()).await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(()) } pub async fn call_f2( @@ -472,7 +471,6 @@ pub mod exports { let () = callee .call_async(store.as_context_mut(), (arg0,)) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(()) } pub async fn call_f3( @@ -493,7 +491,6 @@ pub mod exports { let () = callee .call_async(store.as_context_mut(), (arg0, arg1)) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(()) } pub async fn call_f4( @@ -512,7 +509,6 @@ pub mod exports { let (ret0,) = callee .call_async(store.as_context_mut(), ()) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(ret0) } pub async fn call_f5( @@ -531,7 +527,6 @@ pub mod exports { let (ret0,) = callee .call_async(store.as_context_mut(), ()) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(ret0) } pub async fn call_f6( @@ -553,7 +548,6 @@ pub mod exports { let (ret0,) = callee .call_async(store.as_context_mut(), (arg0, arg1, arg2)) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(ret0) } } diff --git a/crates/component-macro/tests/expanded/simple-functions_tracing_async.rs b/crates/component-macro/tests/expanded/simple-functions_tracing_async.rs index da8d87114ba1..c52a322f375f 100644 --- a/crates/component-macro/tests/expanded/simple-functions_tracing_async.rs +++ b/crates/component-macro/tests/expanded/simple-functions_tracing_async.rs @@ -548,10 +548,6 @@ pub mod exports { .call_async(store.as_context_mut(), ()) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(()) } pub async fn call_f2( @@ -577,10 +573,6 @@ pub mod exports { .call_async(store.as_context_mut(), (arg0,)) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(()) } pub async fn call_f3( @@ -607,10 +599,6 @@ pub mod exports { .call_async(store.as_context_mut(), (arg0, arg1)) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(()) } pub async fn call_f4( @@ -635,10 +623,6 @@ pub mod exports { .call_async(store.as_context_mut(), ()) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(ret0) } pub async fn call_f5( @@ -663,10 +647,6 @@ pub mod exports { .call_async(store.as_context_mut(), ()) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(ret0) } pub async fn call_f6( @@ -694,10 +674,6 @@ pub mod exports { .call_async(store.as_context_mut(), (arg0, arg1, arg2)) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(ret0) } } diff --git a/crates/component-macro/tests/expanded/simple-lists.rs b/crates/component-macro/tests/expanded/simple-lists.rs index 4baa0f1e3511..a6cc8f30eb1e 100644 --- a/crates/component-macro/tests/expanded/simple-lists.rs +++ b/crates/component-macro/tests/expanded/simple-lists.rs @@ -444,7 +444,6 @@ pub mod exports { >::new_unchecked(self.simple_list1) }; let () = callee.call(store.as_context_mut(), (arg0,))?; - callee.post_return(store.as_context_mut())?; Ok(()) } pub fn call_simple_list2( @@ -458,7 +457,6 @@ pub mod exports { >::new_unchecked(self.simple_list2) }; let (ret0,) = callee.call(store.as_context_mut(), ())?; - callee.post_return(store.as_context_mut())?; Ok(ret0) } pub fn call_simple_list3( @@ -484,7 +482,6 @@ pub mod exports { >::new_unchecked(self.simple_list3) }; let (ret0,) = callee.call(store.as_context_mut(), (arg0, arg1))?; - callee.post_return(store.as_context_mut())?; Ok(ret0) } pub fn call_simple_list4( @@ -507,7 +504,6 @@ pub mod exports { >::new_unchecked(self.simple_list4) }; let (ret0,) = callee.call(store.as_context_mut(), (arg0,))?; - callee.post_return(store.as_context_mut())?; Ok(ret0) } } diff --git a/crates/component-macro/tests/expanded/simple-lists_async.rs b/crates/component-macro/tests/expanded/simple-lists_async.rs index 45351a32702a..d2270ce4667b 100644 --- a/crates/component-macro/tests/expanded/simple-lists_async.rs +++ b/crates/component-macro/tests/expanded/simple-lists_async.rs @@ -473,7 +473,6 @@ pub mod exports { let () = callee .call_async(store.as_context_mut(), (arg0,)) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(()) } pub async fn call_simple_list2( @@ -492,7 +491,6 @@ pub mod exports { let (ret0,) = callee .call_async(store.as_context_mut(), ()) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(ret0) } pub async fn call_simple_list3( @@ -523,7 +521,6 @@ pub mod exports { let (ret0,) = callee .call_async(store.as_context_mut(), (arg0, arg1)) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(ret0) } pub async fn call_simple_list4( @@ -551,7 +548,6 @@ pub mod exports { let (ret0,) = callee .call_async(store.as_context_mut(), (arg0,)) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(ret0) } } diff --git a/crates/component-macro/tests/expanded/simple-lists_tracing_async.rs b/crates/component-macro/tests/expanded/simple-lists_tracing_async.rs index a4dd7f2c92f6..3e3784d15cc5 100644 --- a/crates/component-macro/tests/expanded/simple-lists_tracing_async.rs +++ b/crates/component-macro/tests/expanded/simple-lists_tracing_async.rs @@ -540,10 +540,6 @@ pub mod exports { .call_async(store.as_context_mut(), (arg0,)) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(()) } pub async fn call_simple_list2( @@ -568,10 +564,6 @@ pub mod exports { .call_async(store.as_context_mut(), ()) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(ret0) } pub async fn call_simple_list3( @@ -608,10 +600,6 @@ pub mod exports { .call_async(store.as_context_mut(), (arg0, arg1)) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(ret0) } pub async fn call_simple_list4( @@ -645,10 +633,6 @@ pub mod exports { .call_async(store.as_context_mut(), (arg0,)) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(ret0) } } diff --git a/crates/component-macro/tests/expanded/small-anonymous.rs b/crates/component-macro/tests/expanded/small-anonymous.rs index b9fc3f175592..3d78db6a4080 100644 --- a/crates/component-macro/tests/expanded/small-anonymous.rs +++ b/crates/component-macro/tests/expanded/small-anonymous.rs @@ -420,7 +420,6 @@ pub mod exports { >::new_unchecked(self.option_test) }; let (ret0,) = callee.call(store.as_context_mut(), ())?; - callee.post_return(store.as_context_mut())?; Ok(ret0) } } diff --git a/crates/component-macro/tests/expanded/small-anonymous_async.rs b/crates/component-macro/tests/expanded/small-anonymous_async.rs index 8eefe0a159ed..db741f17d441 100644 --- a/crates/component-macro/tests/expanded/small-anonymous_async.rs +++ b/crates/component-macro/tests/expanded/small-anonymous_async.rs @@ -437,7 +437,6 @@ pub mod exports { let (ret0,) = callee .call_async(store.as_context_mut(), ()) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(ret0) } } diff --git a/crates/component-macro/tests/expanded/small-anonymous_tracing_async.rs b/crates/component-macro/tests/expanded/small-anonymous_tracing_async.rs index b1af31909f50..da5042425421 100644 --- a/crates/component-macro/tests/expanded/small-anonymous_tracing_async.rs +++ b/crates/component-macro/tests/expanded/small-anonymous_tracing_async.rs @@ -456,10 +456,6 @@ pub mod exports { .call_async(store.as_context_mut(), ()) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(ret0) } } diff --git a/crates/component-macro/tests/expanded/smoke-default.rs b/crates/component-macro/tests/expanded/smoke-default.rs index 9d963544c9ab..7ae565639242 100644 --- a/crates/component-macro/tests/expanded/smoke-default.rs +++ b/crates/component-macro/tests/expanded/smoke-default.rs @@ -188,7 +188,6 @@ const _: () = { wasmtime::component::TypedFunc::<(), ()>::new_unchecked(self.y) }; let () = callee.call(store.as_context_mut(), ())?; - callee.post_return(store.as_context_mut())?; Ok(()) } } diff --git a/crates/component-macro/tests/expanded/smoke-default_async.rs b/crates/component-macro/tests/expanded/smoke-default_async.rs index aac53efe6376..162c1f3a3930 100644 --- a/crates/component-macro/tests/expanded/smoke-default_async.rs +++ b/crates/component-macro/tests/expanded/smoke-default_async.rs @@ -191,7 +191,6 @@ const _: () = { wasmtime::component::TypedFunc::<(), ()>::new_unchecked(self.y) }; let () = callee.call_async(store.as_context_mut(), ()).await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(()) } } diff --git a/crates/component-macro/tests/expanded/smoke-default_tracing_async.rs b/crates/component-macro/tests/expanded/smoke-default_tracing_async.rs index be3c62e52f87..b7c0a8be5fad 100644 --- a/crates/component-macro/tests/expanded/smoke-default_tracing_async.rs +++ b/crates/component-macro/tests/expanded/smoke-default_tracing_async.rs @@ -199,7 +199,6 @@ const _: () = { .call_async(store.as_context_mut(), ()) .instrument(span.clone()) .await?; - callee.post_return_async(store.as_context_mut()).instrument(span).await?; Ok(()) } } diff --git a/crates/component-macro/tests/expanded/smoke-export.rs b/crates/component-macro/tests/expanded/smoke-export.rs index 258a0374112d..677cc4a8e2e2 100644 --- a/crates/component-macro/tests/expanded/smoke-export.rs +++ b/crates/component-macro/tests/expanded/smoke-export.rs @@ -238,7 +238,6 @@ pub mod exports { wasmtime::component::TypedFunc::<(), ()>::new_unchecked(self.y) }; let () = callee.call(store.as_context_mut(), ())?; - callee.post_return(store.as_context_mut())?; Ok(()) } } diff --git a/crates/component-macro/tests/expanded/smoke-export_async.rs b/crates/component-macro/tests/expanded/smoke-export_async.rs index e0ec6d94bf64..c58e52ffab26 100644 --- a/crates/component-macro/tests/expanded/smoke-export_async.rs +++ b/crates/component-macro/tests/expanded/smoke-export_async.rs @@ -241,7 +241,6 @@ pub mod exports { wasmtime::component::TypedFunc::<(), ()>::new_unchecked(self.y) }; let () = callee.call_async(store.as_context_mut(), ()).await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(()) } } diff --git a/crates/component-macro/tests/expanded/smoke-export_tracing_async.rs b/crates/component-macro/tests/expanded/smoke-export_tracing_async.rs index 2cd5f9675808..7cfb00cff927 100644 --- a/crates/component-macro/tests/expanded/smoke-export_tracing_async.rs +++ b/crates/component-macro/tests/expanded/smoke-export_tracing_async.rs @@ -249,7 +249,6 @@ pub mod exports { .call_async(store.as_context_mut(), ()) .instrument(span.clone()) .await?; - callee.post_return_async(store.as_context_mut()).instrument(span).await?; Ok(()) } } diff --git a/crates/component-macro/tests/expanded/strings.rs b/crates/component-macro/tests/expanded/strings.rs index c3abeab1c2b1..d3f3395eaa71 100644 --- a/crates/component-macro/tests/expanded/strings.rs +++ b/crates/component-macro/tests/expanded/strings.rs @@ -366,7 +366,6 @@ pub mod exports { >::new_unchecked(self.a) }; let () = callee.call(store.as_context_mut(), (arg0,))?; - callee.post_return(store.as_context_mut())?; Ok(()) } pub fn call_b( @@ -380,7 +379,6 @@ pub mod exports { >::new_unchecked(self.b) }; let (ret0,) = callee.call(store.as_context_mut(), ())?; - callee.post_return(store.as_context_mut())?; Ok(ret0) } pub fn call_c( @@ -396,7 +394,6 @@ pub mod exports { >::new_unchecked(self.c) }; let (ret0,) = callee.call(store.as_context_mut(), (arg0, arg1))?; - callee.post_return(store.as_context_mut())?; Ok(ret0) } } diff --git a/crates/component-macro/tests/expanded/strings_async.rs b/crates/component-macro/tests/expanded/strings_async.rs index 9c9b93d739e1..3fa28e332491 100644 --- a/crates/component-macro/tests/expanded/strings_async.rs +++ b/crates/component-macro/tests/expanded/strings_async.rs @@ -395,7 +395,6 @@ pub mod exports { let () = callee .call_async(store.as_context_mut(), (arg0,)) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(()) } pub async fn call_b( @@ -414,7 +413,6 @@ pub mod exports { let (ret0,) = callee .call_async(store.as_context_mut(), ()) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(ret0) } pub async fn call_c( @@ -435,7 +433,6 @@ pub mod exports { let (ret0,) = callee .call_async(store.as_context_mut(), (arg0, arg1)) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(ret0) } } diff --git a/crates/component-macro/tests/expanded/strings_tracing_async.rs b/crates/component-macro/tests/expanded/strings_tracing_async.rs index 834bbfe78d88..115d9abf328f 100644 --- a/crates/component-macro/tests/expanded/strings_tracing_async.rs +++ b/crates/component-macro/tests/expanded/strings_tracing_async.rs @@ -446,10 +446,6 @@ pub mod exports { .call_async(store.as_context_mut(), (arg0,)) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(()) } pub async fn call_b( @@ -474,10 +470,6 @@ pub mod exports { .call_async(store.as_context_mut(), ()) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(ret0) } pub async fn call_c( @@ -504,10 +496,6 @@ pub mod exports { .call_async(store.as_context_mut(), (arg0, arg1)) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(ret0) } } diff --git a/crates/component-macro/tests/expanded/variants.rs b/crates/component-macro/tests/expanded/variants.rs index dc2572b7de10..307e68f46f41 100644 --- a/crates/component-macro/tests/expanded/variants.rs +++ b/crates/component-macro/tests/expanded/variants.rs @@ -1549,7 +1549,6 @@ pub mod exports { >::new_unchecked(self.e1_arg) }; let () = callee.call(store.as_context_mut(), (arg0,))?; - callee.post_return(store.as_context_mut())?; Ok(()) } pub fn call_e1_result( @@ -1563,7 +1562,6 @@ pub mod exports { >::new_unchecked(self.e1_result) }; let (ret0,) = callee.call(store.as_context_mut(), ())?; - callee.post_return(store.as_context_mut())?; Ok(ret0) } pub fn call_v1_arg( @@ -1578,7 +1576,6 @@ pub mod exports { >::new_unchecked(self.v1_arg) }; let () = callee.call(store.as_context_mut(), (arg0,))?; - callee.post_return(store.as_context_mut())?; Ok(()) } pub fn call_v1_result( @@ -1592,7 +1589,6 @@ pub mod exports { >::new_unchecked(self.v1_result) }; let (ret0,) = callee.call(store.as_context_mut(), ())?; - callee.post_return(store.as_context_mut())?; Ok(ret0) } pub fn call_bool_arg( @@ -1607,7 +1603,6 @@ pub mod exports { >::new_unchecked(self.bool_arg) }; let () = callee.call(store.as_context_mut(), (arg0,))?; - callee.post_return(store.as_context_mut())?; Ok(()) } pub fn call_bool_result( @@ -1621,7 +1616,6 @@ pub mod exports { >::new_unchecked(self.bool_result) }; let (ret0,) = callee.call(store.as_context_mut(), ())?; - callee.post_return(store.as_context_mut())?; Ok(ret0) } pub fn call_option_arg( @@ -1652,7 +1646,6 @@ pub mod exports { store.as_context_mut(), (arg0, arg1, arg2, arg3, arg4, arg5), )?; - callee.post_return(store.as_context_mut())?; Ok(()) } pub fn call_option_result( @@ -1684,7 +1677,6 @@ pub mod exports { >::new_unchecked(self.option_result) }; let (ret0,) = callee.call(store.as_context_mut(), ())?; - callee.post_return(store.as_context_mut())?; Ok(ret0) } pub fn call_casts( @@ -1710,7 +1702,6 @@ pub mod exports { store.as_context_mut(), (arg0, arg1, arg2, arg3, arg4, arg5), )?; - callee.post_return(store.as_context_mut())?; Ok(ret0) } pub fn call_result_arg( @@ -1741,7 +1732,6 @@ pub mod exports { store.as_context_mut(), (arg0, arg1, arg2, arg3, arg4, arg5), )?; - callee.post_return(store.as_context_mut())?; Ok(()) } pub fn call_result_result( @@ -1779,7 +1769,6 @@ pub mod exports { >::new_unchecked(self.result_result) }; let (ret0,) = callee.call(store.as_context_mut(), ())?; - callee.post_return(store.as_context_mut())?; Ok(ret0) } pub fn call_return_result_sugar( @@ -1793,7 +1782,6 @@ pub mod exports { >::new_unchecked(self.return_result_sugar) }; let (ret0,) = callee.call(store.as_context_mut(), ())?; - callee.post_return(store.as_context_mut())?; Ok(ret0) } pub fn call_return_result_sugar2( @@ -1807,7 +1795,6 @@ pub mod exports { >::new_unchecked(self.return_result_sugar2) }; let (ret0,) = callee.call(store.as_context_mut(), ())?; - callee.post_return(store.as_context_mut())?; Ok(ret0) } pub fn call_return_result_sugar3( @@ -1821,7 +1808,6 @@ pub mod exports { >::new_unchecked(self.return_result_sugar3) }; let (ret0,) = callee.call(store.as_context_mut(), ())?; - callee.post_return(store.as_context_mut())?; Ok(ret0) } pub fn call_return_result_sugar4( @@ -1835,7 +1821,6 @@ pub mod exports { >::new_unchecked(self.return_result_sugar4) }; let (ret0,) = callee.call(store.as_context_mut(), ())?; - callee.post_return(store.as_context_mut())?; Ok(ret0) } pub fn call_return_option_sugar( @@ -1849,7 +1834,6 @@ pub mod exports { >::new_unchecked(self.return_option_sugar) }; let (ret0,) = callee.call(store.as_context_mut(), ())?; - callee.post_return(store.as_context_mut())?; Ok(ret0) } pub fn call_return_option_sugar2( @@ -1863,7 +1847,6 @@ pub mod exports { >::new_unchecked(self.return_option_sugar2) }; let (ret0,) = callee.call(store.as_context_mut(), ())?; - callee.post_return(store.as_context_mut())?; Ok(ret0) } pub fn call_result_simple( @@ -1877,7 +1860,6 @@ pub mod exports { >::new_unchecked(self.result_simple) }; let (ret0,) = callee.call(store.as_context_mut(), ())?; - callee.post_return(store.as_context_mut())?; Ok(ret0) } pub fn call_is_clone_arg( @@ -1892,7 +1874,6 @@ pub mod exports { >::new_unchecked(self.is_clone_arg) }; let () = callee.call(store.as_context_mut(), (arg0,))?; - callee.post_return(store.as_context_mut())?; Ok(()) } pub fn call_is_clone_return( @@ -1906,7 +1887,6 @@ pub mod exports { >::new_unchecked(self.is_clone_return) }; let (ret0,) = callee.call(store.as_context_mut(), ())?; - callee.post_return(store.as_context_mut())?; Ok(ret0) } } diff --git a/crates/component-macro/tests/expanded/variants_async.rs b/crates/component-macro/tests/expanded/variants_async.rs index 63fb6f556605..942c27cee235 100644 --- a/crates/component-macro/tests/expanded/variants_async.rs +++ b/crates/component-macro/tests/expanded/variants_async.rs @@ -1685,7 +1685,6 @@ pub mod exports { let () = callee .call_async(store.as_context_mut(), (arg0,)) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(()) } pub async fn call_e1_result( @@ -1704,7 +1703,6 @@ pub mod exports { let (ret0,) = callee .call_async(store.as_context_mut(), ()) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(ret0) } pub async fn call_v1_arg( @@ -1724,7 +1722,6 @@ pub mod exports { let () = callee .call_async(store.as_context_mut(), (arg0,)) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(()) } pub async fn call_v1_result( @@ -1743,7 +1740,6 @@ pub mod exports { let (ret0,) = callee .call_async(store.as_context_mut(), ()) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(ret0) } pub async fn call_bool_arg( @@ -1763,7 +1759,6 @@ pub mod exports { let () = callee .call_async(store.as_context_mut(), (arg0,)) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(()) } pub async fn call_bool_result( @@ -1782,7 +1777,6 @@ pub mod exports { let (ret0,) = callee .call_async(store.as_context_mut(), ()) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(ret0) } pub async fn call_option_arg( @@ -1817,7 +1811,6 @@ pub mod exports { (arg0, arg1, arg2, arg3, arg4, arg5), ) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(()) } pub async fn call_option_result( @@ -1854,7 +1847,6 @@ pub mod exports { let (ret0,) = callee .call_async(store.as_context_mut(), ()) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(ret0) } pub async fn call_casts( @@ -1884,7 +1876,6 @@ pub mod exports { (arg0, arg1, arg2, arg3, arg4, arg5), ) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(ret0) } pub async fn call_result_arg( @@ -1919,7 +1910,6 @@ pub mod exports { (arg0, arg1, arg2, arg3, arg4, arg5), ) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(()) } pub async fn call_result_result( @@ -1962,7 +1952,6 @@ pub mod exports { let (ret0,) = callee .call_async(store.as_context_mut(), ()) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(ret0) } pub async fn call_return_result_sugar( @@ -1981,7 +1970,6 @@ pub mod exports { let (ret0,) = callee .call_async(store.as_context_mut(), ()) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(ret0) } pub async fn call_return_result_sugar2( @@ -2000,7 +1988,6 @@ pub mod exports { let (ret0,) = callee .call_async(store.as_context_mut(), ()) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(ret0) } pub async fn call_return_result_sugar3( @@ -2019,7 +2006,6 @@ pub mod exports { let (ret0,) = callee .call_async(store.as_context_mut(), ()) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(ret0) } pub async fn call_return_result_sugar4( @@ -2038,7 +2024,6 @@ pub mod exports { let (ret0,) = callee .call_async(store.as_context_mut(), ()) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(ret0) } pub async fn call_return_option_sugar( @@ -2057,7 +2042,6 @@ pub mod exports { let (ret0,) = callee .call_async(store.as_context_mut(), ()) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(ret0) } pub async fn call_return_option_sugar2( @@ -2076,7 +2060,6 @@ pub mod exports { let (ret0,) = callee .call_async(store.as_context_mut(), ()) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(ret0) } pub async fn call_result_simple( @@ -2095,7 +2078,6 @@ pub mod exports { let (ret0,) = callee .call_async(store.as_context_mut(), ()) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(ret0) } pub async fn call_is_clone_arg( @@ -2115,7 +2097,6 @@ pub mod exports { let () = callee .call_async(store.as_context_mut(), (arg0,)) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(()) } pub async fn call_is_clone_return( @@ -2134,7 +2115,6 @@ pub mod exports { let (ret0,) = callee .call_async(store.as_context_mut(), ()) .await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(ret0) } } diff --git a/crates/component-macro/tests/expanded/variants_tracing_async.rs b/crates/component-macro/tests/expanded/variants_tracing_async.rs index b3bd51ad46c8..b51de12b4207 100644 --- a/crates/component-macro/tests/expanded/variants_tracing_async.rs +++ b/crates/component-macro/tests/expanded/variants_tracing_async.rs @@ -1989,10 +1989,6 @@ pub mod exports { .call_async(store.as_context_mut(), (arg0,)) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(()) } pub async fn call_e1_result( @@ -2017,10 +2013,6 @@ pub mod exports { .call_async(store.as_context_mut(), ()) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(ret0) } pub async fn call_v1_arg( @@ -2046,10 +2038,6 @@ pub mod exports { .call_async(store.as_context_mut(), (arg0,)) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(()) } pub async fn call_v1_result( @@ -2074,10 +2062,6 @@ pub mod exports { .call_async(store.as_context_mut(), ()) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(ret0) } pub async fn call_bool_arg( @@ -2103,10 +2087,6 @@ pub mod exports { .call_async(store.as_context_mut(), (arg0,)) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(()) } pub async fn call_bool_result( @@ -2131,10 +2111,6 @@ pub mod exports { .call_async(store.as_context_mut(), ()) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(ret0) } pub async fn call_option_arg( @@ -2175,10 +2151,6 @@ pub mod exports { ) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(()) } pub async fn call_option_result( @@ -2221,10 +2193,6 @@ pub mod exports { .call_async(store.as_context_mut(), ()) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(ret0) } pub async fn call_casts( @@ -2260,10 +2228,6 @@ pub mod exports { ) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(ret0) } pub async fn call_result_arg( @@ -2304,10 +2268,6 @@ pub mod exports { ) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(()) } pub async fn call_result_result( @@ -2356,10 +2316,6 @@ pub mod exports { .call_async(store.as_context_mut(), ()) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(ret0) } pub async fn call_return_result_sugar( @@ -2384,10 +2340,6 @@ pub mod exports { .call_async(store.as_context_mut(), ()) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(ret0) } pub async fn call_return_result_sugar2( @@ -2412,10 +2364,6 @@ pub mod exports { .call_async(store.as_context_mut(), ()) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(ret0) } pub async fn call_return_result_sugar3( @@ -2440,10 +2388,6 @@ pub mod exports { .call_async(store.as_context_mut(), ()) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(ret0) } pub async fn call_return_result_sugar4( @@ -2468,10 +2412,6 @@ pub mod exports { .call_async(store.as_context_mut(), ()) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(ret0) } pub async fn call_return_option_sugar( @@ -2496,10 +2436,6 @@ pub mod exports { .call_async(store.as_context_mut(), ()) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(ret0) } pub async fn call_return_option_sugar2( @@ -2524,10 +2460,6 @@ pub mod exports { .call_async(store.as_context_mut(), ()) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(ret0) } pub async fn call_result_simple( @@ -2552,10 +2484,6 @@ pub mod exports { .call_async(store.as_context_mut(), ()) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(ret0) } pub async fn call_is_clone_arg( @@ -2581,10 +2509,6 @@ pub mod exports { .call_async(store.as_context_mut(), (arg0,)) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(()) } pub async fn call_is_clone_return( @@ -2609,10 +2533,6 @@ pub mod exports { .call_async(store.as_context_mut(), ()) .instrument(span.clone()) .await?; - callee - .post_return_async(store.as_context_mut()) - .instrument(span) - .await?; Ok(ret0) } } diff --git a/crates/component-macro/tests/expanded/worlds-with-types.rs b/crates/component-macro/tests/expanded/worlds-with-types.rs index 851cbd9a2023..4e212025a442 100644 --- a/crates/component-macro/tests/expanded/worlds-with-types.rs +++ b/crates/component-macro/tests/expanded/worlds-with-types.rs @@ -227,7 +227,6 @@ const _: () = { wasmtime::component::TypedFunc::<(), ((T, U, R),)>::new_unchecked(self.f) }; let (ret0,) = callee.call(store.as_context_mut(), ())?; - callee.post_return(store.as_context_mut())?; Ok(ret0) } } diff --git a/crates/component-macro/tests/expanded/worlds-with-types_async.rs b/crates/component-macro/tests/expanded/worlds-with-types_async.rs index e15c9de984ba..0215a6561930 100644 --- a/crates/component-macro/tests/expanded/worlds-with-types_async.rs +++ b/crates/component-macro/tests/expanded/worlds-with-types_async.rs @@ -230,7 +230,6 @@ const _: () = { wasmtime::component::TypedFunc::<(), ((T, U, R),)>::new_unchecked(self.f) }; let (ret0,) = callee.call_async(store.as_context_mut(), ()).await?; - callee.post_return_async(store.as_context_mut()).await?; Ok(ret0) } } diff --git a/crates/component-macro/tests/expanded/worlds-with-types_tracing_async.rs b/crates/component-macro/tests/expanded/worlds-with-types_tracing_async.rs index 6222f35d2e9a..ae5286ec1b3b 100644 --- a/crates/component-macro/tests/expanded/worlds-with-types_tracing_async.rs +++ b/crates/component-macro/tests/expanded/worlds-with-types_tracing_async.rs @@ -238,7 +238,6 @@ const _: () = { .call_async(store.as_context_mut(), ()) .instrument(span.clone()) .await?; - callee.post_return_async(store.as_context_mut()).instrument(span).await?; Ok(ret0) } } From 72d8304da1f8f3873511657a6c5180a3eb714970 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Tue, 3 Feb 2026 11:45:38 -0700 Subject: [PATCH 6/6] remove obsolete post-return functions and fields Now that post-return calls are handled internally without requiring explicit action by the embedder, we can avoid unnecessary bookkeeping. --- .../src/component/vmcomponent_offsets.rs | 4 -- .../src/runtime/component/concurrent.rs | 6 +- .../runtime/component/concurrent_disabled.rs | 4 +- crates/wasmtime/src/runtime/component/func.rs | 72 ++++--------------- .../src/runtime/component/func/typed.rs | 6 +- .../wasmtime/src/runtime/component/store.rs | 17 ----- crates/wasmtime/src/runtime/vm/component.rs | 67 ----------------- 7 files changed, 22 insertions(+), 154 deletions(-) diff --git a/crates/environ/src/component/vmcomponent_offsets.rs b/crates/environ/src/component/vmcomponent_offsets.rs index 2fc76f7e03a5..12149161c02f 100644 --- a/crates/environ/src/component/vmcomponent_offsets.rs +++ b/crates/environ/src/component/vmcomponent_offsets.rs @@ -29,10 +29,6 @@ pub const VMCOMPONENT_MAGIC: u32 = u32::from_le_bytes(*b"comp"); /// canonical ABI flag `may_leave` pub const FLAG_MAY_LEAVE: i32 = 1 << 0; -/// Flag for the `VMComponentContext::flags` field which is set whenever a -/// function is called to indicate that `post_return` must be called next. -pub const FLAG_NEEDS_POST_RETURN: i32 = 1 << 2; - /// Runtime offsets within a `VMComponentContext` for a specific component. #[derive(Debug, Clone, Copy)] pub struct VMComponentOffsets

{ diff --git a/crates/wasmtime/src/runtime/component/concurrent.rs b/crates/wasmtime/src/runtime/component/concurrent.rs index 3b272e95a750..6c4323e4bc8f 100644 --- a/crates/wasmtime/src/runtime/component/concurrent.rs +++ b/crates/wasmtime/src/runtime/component/concurrent.rs @@ -1518,14 +1518,14 @@ impl StoreOpaque { /// - `self` has not been poisoned due to a trap. pub(crate) fn may_enter(&mut self, instance: RuntimeInstance) -> bool { if !self.concurrency_support() { - return self.may_enter_at_all(instance); + return !self.trapped(); } let state = self.concurrent_state_mut(); if let Some(caller) = state.guest_thread { instance != state.get_mut(caller.task).unwrap().instance && self.may_enter_from_caller(caller.task, instance) } else { - self.may_enter_at_all(instance) + !self.trapped() } } @@ -1543,7 +1543,7 @@ impl StoreOpaque { mut guest_task: TableId, instance: RuntimeInstance, ) -> bool { - self.may_enter_at_all(instance) && { + !self.trapped() && { let state = self.concurrent_state_mut(); let guest_instance = instance.instance; loop { diff --git a/crates/wasmtime/src/runtime/component/concurrent_disabled.rs b/crates/wasmtime/src/runtime/component/concurrent_disabled.rs index 5bfd79f762f6..629c2c1fc99d 100644 --- a/crates/wasmtime/src/runtime/component/concurrent_disabled.rs +++ b/crates/wasmtime/src/runtime/component/concurrent_disabled.rs @@ -172,7 +172,7 @@ impl StoreOpaque { Ok(()) } - pub(crate) fn may_enter(&mut self, instance: RuntimeInstance) -> bool { - self.may_enter_at_all(instance) + pub(crate) fn may_enter(&mut self, _instance: RuntimeInstance) -> bool { + !self.trapped() } } diff --git a/crates/wasmtime/src/runtime/component/func.rs b/crates/wasmtime/src/runtime/component/func.rs index 447d64617d04..481e0de6445d 100644 --- a/crates/wasmtime/src/runtime/component/func.rs +++ b/crates/wasmtime/src/runtime/component/func.rs @@ -439,7 +439,7 @@ impl Func { MAX_FLAT_PARAMS, false, move |func, store, params_out| { - func.with_lower_context(store, true, |cx, ty| { + func.with_lower_context(store, |cx, ty| { Self::lower_args(cx, ¶ms, ty, params_out) }) }, @@ -490,7 +490,7 @@ impl Func { // safe in Rust, however, due to `ValRaw` being a `union`. The // contents should dynamically not be read due to the type of the // function used here matching the actual lift. - unsafe { + let (_, post_return_arg) = unsafe { self.call_raw( store.as_context_mut(), |cx, ty, dst: &mut MaybeUninit<[MaybeUninit; MAX_FLAT_PARAMS]>| { @@ -510,9 +510,9 @@ impl Func { Ok(()) }, )? - } + }; - self.post_return_impl(store) + self.post_return_impl(store, post_return_arg) } pub(crate) fn lifted_core_func(&self, store: &mut StoreOpaque) -> NonNull { @@ -587,7 +587,7 @@ impl Func { &mut MaybeUninit, ) -> Result<()>, lift: impl FnOnce(&mut LiftContext<'_>, InterfaceType, &LowerReturn) -> Result, - ) -> Result + ) -> Result<(Return, ValRaw)> where LowerParams: Copy, LowerReturn: Copy, @@ -631,7 +631,7 @@ impl Func { assert!(mem::align_of_val(map_maybe_uninit!(space.params)) == val_align); assert!(mem::align_of_val(map_maybe_uninit!(space.ret)) == val_align); - self.with_lower_context(store.as_context_mut(), false, |cx, ty| { + self.with_lower_context(store.as_context_mut(), |cx, ty| { cx.enter_call(); lower(cx, ty, map_maybe_uninit!(space.params)) })?; @@ -671,23 +671,20 @@ impl Func { // is currently required to be 0 or 1 values according to the // canonical ABI, is saved within the `Store`'s `FuncData`. This'll // later get used in post-return. - // flags.set_needs_post_return(true); let val = self.with_lift_context(store.0, |cx, ty| lift(cx, ty, ret))?; // SAFETY: it's a contract of this function that `LowerReturn` is an // appropriate representation of the result of this function. let ret_slice = unsafe { storage_as_slice(ret) }; - self.instance.id().get_mut(store.0).post_return_arg_set( - self.index, + Ok(( + val, match ret_slice.len() { 0 => ValRaw::i32(0), 1 => ret_slice[0], _ => unreachable!(), }, - ); - - return Ok(val); + )) } #[doc(hidden)] @@ -703,7 +700,7 @@ impl Func { Ok(()) } - pub(crate) fn post_return_impl(&self, mut store: impl AsContextMut) -> Result<()> { + pub(crate) fn post_return_impl(&self, mut store: impl AsContextMut, arg: ValRaw) -> Result<()> { let mut store = store.as_context_mut(); let index = self.index; @@ -712,33 +709,9 @@ impl Func { let (_ty, _def, options) = component.export_lifted_function(index); let post_return = self.post_return_core_func(store.0); let flags = vminstance.instance_flags(component.env_component().options[options].instance); - let mut instance = self.instance.id().get_mut(store.0); - let post_return_arg = instance.as_mut().post_return_arg_take(index); unsafe { - // First assert that the instance is in a "needs post return" state. - // This will ensure that the previous action on the instance was a - // function call above. This flag is only set after a component - // function returns so this also can't be called (as expected) - // during a host import for example. - // - // Note, though, that this assert is not sufficient because it just - // means some function on this instance needs its post-return - // called. We need a precise post-return for a particular function - // which is the second assert here (the `.expect`). That will assert - // that this function itself needs to have its post-return called. - // - // The theory at least is that these two asserts ensure component - // model semantics are upheld where the host properly calls - // `post_return` on the right function despite the call being a - // separate step in the API. - assert!( - flags.needs_post_return(), - "post_return can only be called after a function has previously been called", - ); - let post_return_arg = post_return_arg.expect("calling post_return on wrong function"); - - call_post_return(&mut store, post_return, post_return_arg, flags)?; + call_post_return(&mut store, post_return, arg, flags)?; let (calls, host_table, _, instance) = store .0 @@ -866,11 +839,9 @@ impl Func { fn with_lower_context( self, mut store: StoreContextMut, - call_post_return_automatically: bool, lower: impl FnOnce(&mut LowerContext, InterfaceType) -> Result<()>, ) -> Result<()> { - let (options_idx, mut flags, ty, options) = self.abi_info(store.0); - let async_ = options.async_; + let (options_idx, mut flags, ty, _) = self.abi_info(store.0); // Perform the actual lowering, where while this is running the // component is forbidden from calling imports. @@ -882,17 +853,7 @@ impl Func { let param_ty = InterfaceType::Tuple(cx.types[ty].params); let result = lower(&mut cx, param_ty); unsafe { flags.set_may_leave(true) }; - result?; - - // If needed, flag a post-return call being required as we're about to - // enter wasm and afterwards need a post-return. - unsafe { - if !(call_post_return_automatically && async_) { - flags.set_needs_post_return(true); - } - } - - Ok(()) + result } /// Creates a `LiftContext` using the configuration values with this lifted @@ -951,11 +912,6 @@ pub(crate) unsafe fn call_post_return( mut flags: InstanceFlags, ) -> Result<()> { unsafe { - // Unset the "needs post return" flag now that post-return is being - // processed. This will cause future invocations of this method to - // panic, even if the function call below traps. - flags.set_needs_post_return(false); - // Post return functions are forbidden from calling imports or // intrinsics. flags.set_may_leave(false); @@ -966,7 +922,7 @@ pub(crate) unsafe fn call_post_return( crate::Func::call_unchecked_raw( &mut store.as_context_mut(), func, - std::slice::from_ref(&arg).into(), + core::slice::from_ref(&arg).into(), )?; } diff --git a/crates/wasmtime/src/runtime/component/func/typed.rs b/crates/wasmtime/src/runtime/component/func/typed.rs index d0c9e7e362e9..a8dd6607f7c5 100644 --- a/crates/wasmtime/src/runtime/component/func/typed.rs +++ b/crates/wasmtime/src/runtime/component/func/typed.rs @@ -380,7 +380,7 @@ where param_count, host_future_present, move |func, store, params_out| { - func.with_lower_context(store, true, |cx, ty| lower(cx, ty, params_out)) + func.with_lower_context(store, |cx, ty| lower(cx, ty, params_out)) }, move |func, store, results| { let result = if Return::flatten_count() <= max_results { @@ -439,7 +439,7 @@ where // safety requirements of `Lift` and `Lower` on `Params` and `Return` in // combination with checking the various possible branches here and // dispatching to appropriately typed functions. - let result = unsafe { + let (result, post_return_arg) = unsafe { // This type is used as `LowerParams` for `call_raw` which is either // `Params::Lower` or `ValRaw` representing it's either on the stack // or it's on the heap. This allocates 1 extra `ValRaw` on the stack @@ -473,7 +473,7 @@ where } }?; - self.func.post_return_impl(store)?; + self.func.post_return_impl(store, post_return_arg)?; Ok(result) } diff --git a/crates/wasmtime/src/runtime/component/store.rs b/crates/wasmtime/src/runtime/component/store.rs index 9402c209e144..0b2d571aa52d 100644 --- a/crates/wasmtime/src/runtime/component/store.rs +++ b/crates/wasmtime/src/runtime/component/store.rs @@ -34,23 +34,6 @@ impl StoreOpaque { pub(crate) fn set_trapped(&mut self) { self.store_data_mut().components.trapped = true; } - - /// Returns `false` if the specified instance may not be entered, regardless - /// of what's on a task's call stack. - /// - /// If this returns `true`, the instance may be entered as long as it isn't - /// on the task's call stack, if applicable. - pub(crate) fn may_enter_at_all(&mut self, instance: RuntimeInstance) -> bool { - if self.trapped() { - return false; - } - - let flags = self - .component_instance(instance.instance) - .instance_flags(instance.index); - - unsafe { !flags.needs_post_return() } - } } impl StoreData { diff --git a/crates/wasmtime/src/runtime/vm/component.rs b/crates/wasmtime/src/runtime/vm/component.rs index ed295cca0a4a..dfedb1b2fba1 100644 --- a/crates/wasmtime/src/runtime/vm/component.rs +++ b/crates/wasmtime/src/runtime/vm/component.rs @@ -148,12 +148,6 @@ pub struct ComponentInstance { /// Self-pointer back to `Store` and its functions. store: VMStoreRawPtr, - /// Cached ABI return value from the last-invoked function call along with - /// the function index that was invoked. - /// - /// Used in `post_return_arg_set` and `post_return_arg_take` below. - post_return_arg: Option<(ExportIndex, ValRaw)>, - /// Required by `InstanceLayout`, also required to be the last field (with /// repr(C)) vmctx: OwnedVMContext, @@ -341,7 +335,6 @@ impl ComponentInstance { resource_types, imports: imports.clone(), store: VMStoreRawPtr(store), - post_return_arg: None, vmctx: OwnedVMContext::new(), })?; unsafe { @@ -954,50 +947,6 @@ impl ComponentInstance { } } - /// Sets the cached argument for the canonical ABI option `post-return` to - /// the `arg` specified. - /// - /// This function is used in conjunction with function calls to record, - /// after a function call completes, the optional ABI return value. This - /// return value is cached within this instance for future use when the - /// `post_return` Rust-API-level function is invoked. - /// - /// Note that `index` here is the index of the export that was just - /// invoked, and this is used to ensure that `post_return` is called on the - /// same function afterwards. This restriction technically isn't necessary - /// though and may be one we want to lift in the future. - /// - /// # Panics - /// - /// This function will panic if `post_return_arg` is already set to `Some`. - pub fn post_return_arg_set(self: Pin<&mut Self>, index: ExportIndex, arg: ValRaw) { - assert!(self.post_return_arg.is_none()); - *self.post_return_arg_mut() = Some((index, arg)); - } - - /// Re-acquires the value originally saved via `post_return_arg_set`. - /// - /// This function will take a function `index` that's having its - /// `post_return` function called. If an argument was previously stored and - /// `index` matches the index that was stored then `Some(arg)` is returned. - /// Otherwise `None` is returned. - pub fn post_return_arg_take(self: Pin<&mut Self>, index: ExportIndex) -> Option { - let post_return_arg = self.post_return_arg_mut(); - let (expected_index, arg) = post_return_arg.take()?; - if index != expected_index { - *post_return_arg = Some((expected_index, arg)); - None - } else { - Some(arg) - } - } - - fn post_return_arg_mut(self: Pin<&mut Self>) -> &mut Option<(ExportIndex, ValRaw)> { - // SAFETY: we've chosen the `Pin` guarantee of `Self` to not apply to - // the map returned. - unsafe { &mut self.get_unchecked_mut().post_return_arg } - } - pub(crate) fn check_may_leave( &self, instance: RuntimeComponentInstanceIndex, @@ -1124,22 +1073,6 @@ impl InstanceFlags { } } - #[inline] - pub unsafe fn needs_post_return(&self) -> bool { - unsafe { *self.as_raw().as_ref().as_i32() & FLAG_NEEDS_POST_RETURN != 0 } - } - - #[inline] - pub unsafe fn set_needs_post_return(&mut self, val: bool) { - unsafe { - if val { - *self.as_raw().as_mut().as_i32_mut() |= FLAG_NEEDS_POST_RETURN; - } else { - *self.as_raw().as_mut().as_i32_mut() &= !FLAG_NEEDS_POST_RETURN; - } - } - } - #[inline] pub fn as_raw(&self) -> NonNull { self.0.as_non_null()