Repository: bytecodealliance/wasm-tools
Pull request #2229 (2025-06-09 16:36:22)

partially revert `future.{read,write}` ABI changes
After Luke, Alex, and I reviewed the implementation details across `wasm-tools`, `wit-bindgen`, and `wasip3-prototyping`, we concluded that passing up to 4 flat parameters to `future.write` and removing the address param for no-payload `future.read` functions were both more trouble than they were worth.

This reverts those changes, meaning we're back to the original ABI except that the `memory` parameter is optional for no-payload futures.


Patch:
diff --git a/crates/wasmparser/src/validator/component.rs b/crates/wasmparser/src/validator/component.rs
index 1eb0f63d..78bf499b 100644
--- a/crates/wasmparser/src/validator/component.rs
+++ b/crates/wasmparser/src/validator/component.rs
@@ -7,8 +7,8 @@ use super::{
         ComponentCoreModuleTypeId, ComponentCoreTypeId, ComponentDefinedType,
         ComponentDefinedTypeId, ComponentEntityType, ComponentFuncType, ComponentFuncTypeId,
         ComponentInstanceType, ComponentInstanceTypeId, ComponentType, ComponentTypeId,
-        ComponentValType, Context, CoreInstanceTypeKind, InstanceType, LoweredFuncType, ModuleType,
-        RecordType, Remap, Remapping, ResourceId, SubtypeCx, TupleType, VariantCase, VariantType,
+        ComponentValType, Context, CoreInstanceTypeKind, InstanceType, ModuleType, RecordType,
+        Remap, Remapping, ResourceId, SubtypeCx, TupleType, VariantCase, VariantType,
     },
     core::{InternRecGroup, Module},
     types::{CoreTypeId, EntityType, TypeAlloc, TypeInfo, TypeList},
@@ -23,7 +23,6 @@ use crate::{
     ExternalKind, FuncType, GlobalType, InstantiationArgKind, MemoryType, PackedIndex, RefType,
     Result, SubType, TableType, TypeBounds, ValType, WasmFeatures,
 };
-use core::iter;
 use core::mem;
 
 fn to_kebab_str<'a>(s: &'a str, desc: &str, offset: usize) -> Result<&'a KebabStr> {
@@ -1758,10 +1757,7 @@ impl ComponentState {
             .check_lower(offset)?
             .check_core_type(
                 types,
-                FuncType::new(
-                    iter::repeat(ValType::I32).take(if elem_ty.is_some() { 2 } else { 1 }),
-                    [ValType::I32],
-                ),
+                FuncType::new([ValType::I32; 2], [ValType::I32]),
                 offset,
             )?;
 
@@ -1788,44 +1784,14 @@ impl ComponentState {
             bail!(offset, "`future.write` requires a future type")
         };
 
-        let options = self.check_options(types, &options, offset)?;
-        options.check_lower(offset)?;
-
-        let LoweredFuncType::New(func_ty) = ComponentFuncType {
-            info: TypeInfo::new(),
-            params: if let Some(elem_ty) = elem_ty {
-                Box::new([(KebabString::new("p").unwrap(), *elem_ty)])
-            } else {
-                Box::new([])
-            },
-            result: None,
-        }
-        .lower(
-            types,
-            &CanonicalOptions {
-                concurrency: Concurrency::Async { callback: None },
-                ..options
-            },
-            Abi::Lower,
-            offset,
-        )?
-        else {
-            // As of this writing, `ComponentFuncType::lower` returns
-            // `LoweredFuncType::New(_)` unless `options.gc` is true.
-            bail!(
+        let ty_id = self
+            .check_options(types, &options, offset)?
+            .require_memory_if(offset, || elem_ty.is_some())?
+            .check_core_type(
+                types,
+                FuncType::new([ValType::I32; 2], [ValType::I32]),
                 offset,
-                "todo: `future.write` with `gc` option not yet supported"
-            )
-        };
-
-        let ty_id = options.check_core_type(
-            types,
-            FuncType::new(
-                iter::once(ValType::I32).chain(func_ty.params().iter().copied()),
-                [ValType::I32],
-            ),
-            offset,
-        )?;
+            )?;
 
         self.core_funcs.push(ty_id);
         Ok(())
diff --git a/crates/wit-component/src/dummy.rs b/crates/wit-component/src/dummy.rs
index bb0c291c..50341052 100644
--- a/crates/wit-component/src/dummy.rs
+++ b/crates/wit-component/src/dummy.rs
@@ -189,32 +189,18 @@ fn push_imported_future_and_stream_intrinsics(
         .enumerate()
     {
         match &resolve.types[id].kind {
-            TypeDefKind::Future(ty) => {
-                let read_params = if ty.is_some() { "i32 i32" } else { "i32" };
-                let write_params = resolve
-                    .future_write_wasm_signature(*ty)
-                    .params
-                    .into_iter()
-                    .map(|ty| match ty {
-                        WasmType::I32 | WasmType::Pointer | WasmType::Length => "i32",
-                        WasmType::I64 | WasmType::PointerOrI64 => "i64",
-                        WasmType::F32 => "f32",
-                        WasmType::F64 => "f64",
-                    })
-                    .collect::<Vec<_>>()
-                    .join(" ");
-
+            TypeDefKind::Future(_) => {
                 wat.push_str(&format!(
                     r#"
 (import {module:?} "[future-new-{i}]{name}" (func (result i64)))
-(import {module:?} "[future-read-{i}]{name}" (func (param {read_params}) (result i32)))
-(import {module:?} "[future-write-{i}]{name}" (func (param {write_params}) (result i32)))
+(import {module:?} "[future-read-{i}]{name}" (func (param i32 i32) (result i32)))
+(import {module:?} "[future-write-{i}]{name}" (func (param i32 i32) (result i32)))
 (import {module:?} "[future-cancel-read-{i}]{name}" (func (param i32) (result i32)))
 (import {module:?} "[future-cancel-write-{i}]{name}" (func (param i32) (result i32)))
 (import {module:?} "[future-drop-readable-{i}]{name}" (func (param i32)))
 (import {module:?} "[future-drop-writable-{i}]{name}" (func (param i32)))
-(import {module:?} "[async-lower][future-read-{i}]{name}" (func (param {read_params}) (result i32)))
-(import {module:?} "[async-lower][future-write-{i}]{name}" (func (param {write_params}) (result i32)))
+(import {module:?} "[async-lower][future-read-{i}]{name}" (func (param i32 i32) (result i32)))
+(import {module:?} "[async-lower][future-write-{i}]{name}" (func (param i32 i32) (result i32)))
 
 ;; deferred behind 🚝
 ;;(import {module:?} "[async-lower][future-cancel-read-{i}]{name}" (func (param i32) (result i32)))
diff --git a/crates/wit-component/src/encoding.rs b/crates/wit-component/src/encoding.rs
index 98ca5740..d9eefc37 100644
--- a/crates/wit-component/src/encoding.rs
+++ b/crates/wit-component/src/encoding.rs
@@ -2265,9 +2265,7 @@ impl<'a> Shims<'a> {
                         *async_,
                         info,
                         PayloadFuncKind::FutureWrite,
-                        resolve
-                            .future_write_wasm_signature(info.payload(resolve))
-                            .params,
+                        vec![WasmType::I32; 2],
                         vec![WasmType::I32],
                     );
                 }
@@ -2279,14 +2277,7 @@ impl<'a> Shims<'a> {
                         *async_,
                         info,
                         PayloadFuncKind::FutureRead,
-                        vec![
-                            WasmType::I32;
-                            if info.payload(resolve).is_some() {
-                                2
-                            } else {
-                                1
-                            }
-                        ],
+                        vec![WasmType::I32; 2],
                         vec![WasmType::I32],
                     );
                 }
diff --git a/crates/wit-component/src/validation.rs b/crates/wit-component/src/validation.rs
index 5590c49b..a1f18e88 100644
--- a/crates/wit-component/src/validation.rs
+++ b/crates/wit-component/src/validation.rs
@@ -904,22 +904,10 @@ impl ImportMap {
             validate_func_sig(name, &FuncType::new([], [ValType::I64]), ty)?;
             Import::FutureNew(info)
         } else if let Some(info) = prefixed_payload("[future-write-") {
-            validate_func_sig(
-                name,
-                &wasm_sig_to_func_type(resolve.future_write_wasm_signature(info.payload(resolve))),
-                ty,
-            )?;
+            validate_func_sig(name, &FuncType::new([ValType::I32; 2], [ValType::I32]), ty)?;
             Import::FutureWrite { async_, info }
         } else if let Some(info) = prefixed_payload("[future-read-") {
-            validate_func_sig(
-                name,
-                &if info.payload(resolve).is_some() {
-                    FuncType::new([ValType::I32; 2], [ValType::I32])
-                } else {
-                    FuncType::new([ValType::I32], [ValType::I32])
-                },
-                ty,
-            )?;
+            validate_func_sig(name, &FuncType::new([ValType::I32; 2], [ValType::I32]), ty)?;
             Import::FutureRead { async_, info }
         } else if let Some(info) = prefixed_payload("[future-cancel-write-") {
             validate_func_sig(name, &FuncType::new([ValType::I32], [ValType::I32]), ty)?;
diff --git a/crates/wit-parser/src/abi.rs b/crates/wit-parser/src/abi.rs
index a0260e86..8c69db34 100644
--- a/crates/wit-parser/src/abi.rs
+++ b/crates/wit-parser/src/abi.rs
@@ -1,5 +1,4 @@
-use crate::{Function, FunctionKind, Handle, Int, Resolve, Stability, Type, TypeDefKind};
-use core::iter;
+use crate::{Function, Handle, Int, Resolve, Type, TypeDefKind};
 
 /// A core WebAssembly signature with params and results.
 #[derive(Clone, Debug, Hash, Eq, PartialEq, PartialOrd, Ord)]
@@ -275,28 +274,6 @@ impl Resolve {
         }
     }
 
-    /// Get the WebAssembly type signature for a `future.write` intrinsic with
-    /// the specified payload type.
-    pub fn future_write_wasm_signature(&self, payload: Option<Type>) -> WasmSignature {
-        let mut sig = self.wasm_signature(
-            AbiVariant::GuestImportAsync,
-            &Function {
-                name: String::new(),
-                kind: FunctionKind::Freestanding,
-                params: if let Some(payload) = payload {
-                    vec![(String::new(), payload)]
-                } else {
-                    Vec::new()
-                },
-                result: None,
-                docs: Default::default(),
-                stability: Stability::Unknown,
-            },
-        );
-        sig.params = iter::once(WasmType::I32).chain(sig.params).collect();
-        sig
-    }
-
     fn push_flat_list<'a>(
         &self,
         mut list: impl Iterator<Item = &'a Type>,


Test patch:
diff --git a/tests/cli/component-model-async/futures.wast b/tests/cli/component-model-async/futures.wast
index c36d96d0..f7370faf 100644
--- a/tests/cli/component-model-async/futures.wast
+++ b/tests/cli/component-model-async/futures.wast
@@ -37,10 +37,8 @@
 
 ;; future.read; no payload
 (component
-  (core module $libc (memory (export "memory") 1))
-  (core instance $libc (instantiate $libc))
   (core module $m
-    (import "" "future.read" (func $future-read (param i32) (result i32)))
+    (import "" "future.read" (func $future-read (param i32 i32) (result i32)))
   )
   (type $future-type (future))
   (core func $future-read (canon future.read $future-type async))
@@ -115,46 +113,20 @@
     (import "" "future.write" (func $future-write (param i32 i32) (result i32)))
   )
   (type $future-type (future u8))
-  (core func $future-write (canon future.write $future-type async))
+  (core func $future-write (canon future.write $future-type async (memory $libc "memory")))
   (core instance $i (instantiate $m (with "" (instance (export "future.write" (func $future-write))))))
 )
 
 ;; future.write; no payload
 (component
-  (core module $libc (memory (export "memory") 1))
-  (core instance $libc (instantiate $libc))
   (core module $m
-    (import "" "future.write" (func $future-write (param i32) (result i32)))
+    (import "" "future.write" (func $future-write (param i32 i32) (result i32)))
   )
   (type $future-type (future))
   (core func $future-write (canon future.write $future-type async))
   (core instance $i (instantiate $m (with "" (instance (export "future.write" (func $future-write))))))
 )
 
-;; future.write; flat payload spanning four core parameters
-(component
-  (core module $libc (memory (export "memory") 1))
-  (core instance $libc (instantiate $libc))
-  (core module $m
-    (import "" "future.write" (func $future-write (param i32 i32 i64 f32 f64) (result i32)))
-  )
-  (type $future-type (future (tuple s32 s64 f32 f64)))
-  (core func $future-write (canon future.write $future-type async))
-  (core instance $i (instantiate $m (with "" (instance (export "future.write" (func $future-write))))))
-)
-
-;; future.write; indirect payload
-(component
-  (core module $libc (memory (export "memory") 1))
-  (core instance $libc (instantiate $libc))
-  (core module $m
-    (import "" "future.write" (func $future-write (param i32 i32) (result i32)))
-  )
-  (type $future-type (future (tuple s32 s64 f32 f64 s32)))
-  (core func $future-write (canon future.write $future-type async (memory $libc "memory")))
-  (core instance $i (instantiate $m (with "" (instance (export "future.write" (func $future-write))))))
-)
-
 ;; future.write; incorrect type
 (assert_invalid
   (component
diff --git a/tests/snapshots/cli/component-model-async/futures.wast.json b/tests/snapshots/cli/component-model-async/futures.wast.json
index 180c4a2c..984dc36e 100644
--- a/tests/snapshots/cli/component-model-async/futures.wast.json
+++ b/tests/snapshots/cli/component-model-async/futures.wast.json
@@ -28,112 +28,100 @@
     },
     {
       "type": "module",
-      "line": 51,
+      "line": 49,
       "filename": "futures.4.wasm",
       "module_type": "binary"
     },
     {
       "type": "assert_invalid",
-      "line": 67,
+      "line": 65,
       "filename": "futures.5.wasm",
       "module_type": "binary",
       "text": "type mismatch for export `future.read` of module instantiation argument ``"
     },
     {
       "type": "assert_invalid",
-      "line": 82,
+      "line": 80,
       "filename": "futures.6.wasm",
       "module_type": "binary",
       "text": "`future.read` requires a future type"
     },
     {
       "type": "assert_invalid",
-      "line": 97,
+      "line": 95,
       "filename": "futures.7.wasm",
       "module_type": "binary",
       "text": "canonical option `realloc` is required"
     },
     {
       "type": "module",
-      "line": 111,
+      "line": 109,
       "filename": "futures.8.wasm",
       "module_type": "binary"
     },
     {
       "type": "module",
-      "line": 123,
+      "line": 121,
       "filename": "futures.9.wasm",
       "module_type": "binary"
     },
     {
-      "type": "module",
-      "line": 135,
+      "type": "assert_invalid",
+      "line": 132,
       "filename": "futures.10.wasm",
-      "module_type": "binary"
+      "module_type": "binary",
+      "text": "type mismatch for export `future.write` of module instantiation argument ``"
     },
     {
       "type": "module",
-      "line": 147,
+      "line": 146,
       "filename": "futures.11.wasm",
       "module_type": "binary"
     },
     {
       "type": "assert_invalid",
-      "line": 160,
+      "line": 157,
       "filename": "futures.12.wasm",
       "module_type": "binary",
-      "text": "type mismatch for export `future.write` of module instantiation argument ``"
+      "text": "type mismatch for export `future.cancel-read` of module instantiation argument ``"
     },
     {
       "type": "module",
-      "line": 174,
+      "line": 169,
       "filename": "futures.13.wasm",
       "module_type": "binary"
     },
     {
       "type": "assert_invalid",
-      "line": 185,
+      "line": 180,
       "filename": "futures.14.wasm",
       "module_type": "binary",
-      "text": "type mismatch for export `future.cancel-read` of module instantiation argument ``"
+      "text": "type mismatch for export `future.cancel-write` of module instantiation argument ``"
     },
     {
       "type": "module",
-      "line": 197,
+      "line": 192,
       "filename": "futures.15.wasm",
       "module_type": "binary"
     },
     {
       "type": "assert_invalid",
-      "line": 208,
+      "line": 203,
       "filename": "futures.16.wasm",
       "module_type": "binary",
-      "text": "type mismatch for export `future.cancel-write` of module instantiation argument ``"
+      "text": "type mismatch for export `future.drop-readable` of module instantiation argument ``"
     },
     {
       "type": "module",
-      "line": 220,
+      "line": 215,
       "filename": "futures.17.wasm",
       "module_type": "binary"
     },
     {
       "type": "assert_invalid",
-      "line": 231,
+      "line": 226,
       "filename": "futures.18.wasm",
       "module_type": "binary",
-      "text": "type mismatch for export `future.drop-readable` of module instantiation argument ``"
-    },
-    {
-      "type": "module",
-      "line": 243,
-      "filename": "futures.19.wasm",
-      "module_type": "binary"
-    },
-    {
-      "type": "assert_invalid",
-      "line": 254,
-      "filename": "futures.20.wasm",
-      "module_type": "binary",
       "text": "type mismatch for export `future.drop-writable` of module instantiation argument ``"
     }
   ]
diff --git a/tests/snapshots/cli/component-model-async/futures.wast/10.print b/tests/snapshots/cli/component-model-async/futures.wast/10.print
deleted file mode 100644
index d7115584..00000000
--- a/tests/snapshots/cli/component-model-async/futures.wast/10.print
+++ /dev/null
@@ -1,21 +0,0 @@
-(component
-  (core module $libc (;0;)
-    (memory (;0;) 1)
-    (export "memory" (memory 0))
-  )
-  (core instance $libc (;0;) (instantiate $libc))
-  (core module $m (;1;)
-    (type (;0;) (func (param i32 i32 i64 f32 f64) (result i32)))
-    (import "" "future.write" (func $future-write (;0;) (type 0)))
-  )
-  (type (;0;) (tuple s32 s64 f32 f64))
-  (type $future-type (;1;) (future 0))
-  (core func $future-write (;0;) (canon future.write $future-type async))
-  (core instance (;1;)
-    (export "future.write" (func $future-write))
-  )
-  (core instance $i (;2;) (instantiate $m
-      (with "" (instance 1))
-    )
-  )
-)
diff --git a/tests/snapshots/cli/component-model-async/futures.wast/11.print b/tests/snapshots/cli/component-model-async/futures.wast/11.print
index 42604c78..443e958b 100644
--- a/tests/snapshots/cli/component-model-async/futures.wast/11.print
+++ b/tests/snapshots/cli/component-model-async/futures.wast/11.print
@@ -1,22 +1,15 @@
 (component
-  (core module $libc (;0;)
-    (memory (;0;) 1)
-    (export "memory" (memory 0))
+  (core module $m (;0;)
+    (type (;0;) (func (param i32) (result i32)))
+    (import "" "future.cancel-read" (func $future-cancel-read (;0;) (type 0)))
   )
-  (core instance $libc (;0;) (instantiate $libc))
-  (core module $m (;1;)
-    (type (;0;) (func (param i32 i32) (result i32)))
-    (import "" "future.write" (func $future-write (;0;) (type 0)))
+  (type $future-type (;0;) (future u8))
+  (core func $future-cancel-read (;0;) (canon future.cancel-read $future-type async))
+  (core instance (;0;)
+    (export "future.cancel-read" (func $future-cancel-read))
   )
-  (type (;0;) (tuple s32 s64 f32 f64 s32))
-  (type $future-type (;1;) (future 0))
-  (alias core export $libc "memory" (core memory (;0;)))
-  (core func $future-write (;0;) (canon future.write $future-type async (memory 0)))
-  (core instance (;1;)
-    (export "future.write" (func $future-write))
-  )
-  (core instance $i (;2;) (instantiate $m
-      (with "" (instance 1))
+  (core instance $i (;1;) (instantiate $m
+      (with "" (instance 0))
     )
   )
 )
diff --git a/tests/snapshots/cli/component-model-async/futures.wast/13.print b/tests/snapshots/cli/component-model-async/futures.wast/13.print
index 443e958b..6e15e579 100644
--- a/tests/snapshots/cli/component-model-async/futures.wast/13.print
+++ b/tests/snapshots/cli/component-model-async/futures.wast/13.print
@@ -1,12 +1,12 @@
 (component
   (core module $m (;0;)
     (type (;0;) (func (param i32) (result i32)))
-    (import "" "future.cancel-read" (func $future-cancel-read (;0;) (type 0)))
+    (import "" "future.cancel-write" (func $future-cancel-write (;0;) (type 0)))
   )
   (type $future-type (;0;) (future u8))
-  (core func $future-cancel-read (;0;) (canon future.cancel-read $future-type async))
+  (core func $future-cancel-write (;0;) (canon future.cancel-write $future-type async))
   (core instance (;0;)
-    (export "future.cancel-read" (func $future-cancel-read))
+    (export "future.cancel-write" (func $future-cancel-write))
   )
   (core instance $i (;1;) (instantiate $m
       (with "" (instance 0))
diff --git a/tests/snapshots/cli/component-model-async/futures.wast/15.print b/tests/snapshots/cli/component-model-async/futures.wast/15.print
index 6e15e579..44088d00 100644
--- a/tests/snapshots/cli/component-model-async/futures.wast/15.print
+++ b/tests/snapshots/cli/component-model-async/futures.wast/15.print
@@ -1,12 +1,12 @@
 (component
   (core module $m (;0;)
-    (type (;0;) (func (param i32) (result i32)))
-    (import "" "future.cancel-write" (func $future-cancel-write (;0;) (type 0)))
+    (type (;0;) (func (param i32)))
+    (import "" "future.drop-readable" (func $future-drop-readable (;0;) (type 0)))
   )
   (type $future-type (;0;) (future u8))
-  (core func $future-cancel-write (;0;) (canon future.cancel-write $future-type async))
+  (core func $future-drop-readable (;0;) (canon future.drop-readable $future-type))
   (core instance (;0;)
-    (export "future.cancel-write" (func $future-cancel-write))
+    (export "future.drop-readable" (func $future-drop-readable))
   )
   (core instance $i (;1;) (instantiate $m
       (with "" (instance 0))
diff --git a/tests/snapshots/cli/component-model-async/futures.wast/17.print b/tests/snapshots/cli/component-model-async/futures.wast/17.print
index 44088d00..5adf6b22 100644
--- a/tests/snapshots/cli/component-model-async/futures.wast/17.print
+++ b/tests/snapshots/cli/component-model-async/futures.wast/17.print
@@ -1,12 +1,12 @@
 (component
   (core module $m (;0;)
     (type (;0;) (func (param i32)))
-    (import "" "future.drop-readable" (func $future-drop-readable (;0;) (type 0)))
+    (import "" "future.drop-writable" (func $future-drop-writable (;0;) (type 0)))
   )
   (type $future-type (;0;) (future u8))
-  (core func $future-drop-readable (;0;) (canon future.drop-readable $future-type))
+  (core func $future-drop-writable (;0;) (canon future.drop-writable $future-type))
   (core instance (;0;)
-    (export "future.drop-readable" (func $future-drop-readable))
+    (export "future.drop-writable" (func $future-drop-writable))
   )
   (core instance $i (;1;) (instantiate $m
       (with "" (instance 0))
diff --git a/tests/snapshots/cli/component-model-async/futures.wast/19.print b/tests/snapshots/cli/component-model-async/futures.wast/19.print
deleted file mode 100644
index 5adf6b22..00000000
--- a/tests/snapshots/cli/component-model-async/futures.wast/19.print
+++ /dev/null
@@ -1,15 +0,0 @@
-(component
-  (core module $m (;0;)
-    (type (;0;) (func (param i32)))
-    (import "" "future.drop-writable" (func $future-drop-writable (;0;) (type 0)))
-  )
-  (type $future-type (;0;) (future u8))
-  (core func $future-drop-writable (;0;) (canon future.drop-writable $future-type))
-  (core instance (;0;)
-    (export "future.drop-writable" (func $future-drop-writable))
-  )
-  (core instance $i (;1;) (instantiate $m
-      (with "" (instance 0))
-    )
-  )
-)
diff --git a/tests/snapshots/cli/component-model-async/futures.wast/3.print b/tests/snapshots/cli/component-model-async/futures.wast/3.print
index 6dd6a455..112260a5 100644
--- a/tests/snapshots/cli/component-model-async/futures.wast/3.print
+++ b/tests/snapshots/cli/component-model-async/futures.wast/3.print
@@ -1,20 +1,15 @@
 (component
-  (core module $libc (;0;)
-    (memory (;0;) 1)
-    (export "memory" (memory 0))
-  )
-  (core instance $libc (;0;) (instantiate $libc))
-  (core module $m (;1;)
-    (type (;0;) (func (param i32) (result i32)))
+  (core module $m (;0;)
+    (type (;0;) (func (param i32 i32) (result i32)))
     (import "" "future.read" (func $future-read (;0;) (type 0)))
   )
   (type $future-type (;0;) (future))
   (core func $future-read (;0;) (canon future.read $future-type async))
-  (core instance (;1;)
+  (core instance (;0;)
     (export "future.read" (func $future-read))
   )
-  (core instance $i (;2;) (instantiate $m
-      (with "" (instance 1))
+  (core instance $i (;1;) (instantiate $m
+      (with "" (instance 0))
     )
   )
 )
diff --git a/tests/snapshots/cli/component-model-async/futures.wast/8.print b/tests/snapshots/cli/component-model-async/futures.wast/8.print
index 717a006a..a9ec39f1 100644
--- a/tests/snapshots/cli/component-model-async/futures.wast/8.print
+++ b/tests/snapshots/cli/component-model-async/futures.wast/8.print
@@ -9,7 +9,8 @@
     (import "" "future.write" (func $future-write (;0;) (type 0)))
   )
   (type $future-type (;0;) (future u8))
-  (core func $future-write (;0;) (canon future.write $future-type async))
+  (alias core export $libc "memory" (core memory (;0;)))
+  (core func $future-write (;0;) (canon future.write $future-type async (memory 0)))
   (core instance (;1;)
     (export "future.write" (func $future-write))
   )
diff --git a/tests/snapshots/cli/component-model-async/futures.wast/9.print b/tests/snapshots/cli/component-model-async/futures.wast/9.print
index 4d990008..a78631e6 100644
--- a/tests/snapshots/cli/component-model-async/futures.wast/9.print
+++ b/tests/snapshots/cli/component-model-async/futures.wast/9.print
@@ -1,20 +1,15 @@
 (component
-  (core module $libc (;0;)
-    (memory (;0;) 1)
-    (export "memory" (memory 0))
-  )
-  (core instance $libc (;0;) (instantiate $libc))
-  (core module $m (;1;)
-    (type (;0;) (func (param i32) (result i32)))
+  (core module $m (;0;)
+    (type (;0;) (func (param i32 i32) (result i32)))
     (import "" "future.write" (func $future-write (;0;) (type 0)))
   )
   (type $future-type (;0;) (future))
   (core func $future-write (;0;) (canon future.write $future-type async))
-  (core instance (;1;)
+  (core instance (;0;)
     (export "future.write" (func $future-write))
   )
-  (core instance $i (;2;) (instantiate $m
-      (with "" (instance 1))
+  (core instance $i (;1;) (instantiate $m
+      (with "" (instance 0))
     )
   )
 )