From 489f9c7b5e99a3777fc2d33fc5f577f0a6b99f44 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 14 Apr 2025 15:47:53 -0700 Subject: [PATCH] Align subtask return codes with the spec Coupled with upstream changes to wasip3-prototyping... --- crates/guest-rust/rt/src/async_support/subtask.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/crates/guest-rust/rt/src/async_support/subtask.rs b/crates/guest-rust/rt/src/async_support/subtask.rs index ce480bc12..adab770d0 100644 --- a/crates/guest-rust/rt/src/async_support/subtask.rs +++ b/crates/guest-rust/rt/src/async_support/subtask.rs @@ -80,12 +80,10 @@ unsafe impl WaitableOp for SubtaskOps { let (ptr_params, cleanup) = Cleanup::new(T::ABI_LAYOUT); let ptr_results = ptr_params.add(T::RESULTS_OFFSET); T::params_lower(state.params, ptr_params); - let result = T::call_import(ptr_params, ptr_results); - // FIXME(bytecodealliance/wasip3-prototyping#99) the decoding of the - // result here isn't standards-compliant. - let code = result >> 30; - let subtask = - NonZeroU32::new((result << 2) >> 2).map(|handle| SubtaskHandle { handle }); + let packed = T::call_import(ptr_params, ptr_results); + let code = packed & 0xf; + let subtask = NonZeroU32::new(packed >> 4).map(|handle| SubtaskHandle { handle }); + rtdebug!("({ptr_params:?}, {ptr_results:?}) = ({code:#x}, {subtask:#x?})"); ( code,