diff --git a/crates/wasm-encoder/src/component/builder.rs b/crates/wasm-encoder/src/component/builder.rs index c76f7e2e33..d660ae55a7 100644 --- a/crates/wasm-encoder/src/component/builder.rs +++ b/crates/wasm-encoder/src/component/builder.rs @@ -481,15 +481,15 @@ impl ComponentBuilder { inc(&mut self.core_funcs) } - /// Declares a new `stream.close-readable` intrinsic. - pub fn stream_close_readable(&mut self, ty: u32) -> u32 { - self.canonical_functions().stream_close_readable(ty); + /// Declares a new `stream.drop-readable` intrinsic. + pub fn stream_drop_readable(&mut self, ty: u32) -> u32 { + self.canonical_functions().stream_drop_readable(ty); inc(&mut self.core_funcs) } - /// Declares a new `stream.close-writable` intrinsic. - pub fn stream_close_writable(&mut self, ty: u32) -> u32 { - self.canonical_functions().stream_close_writable(ty); + /// Declares a new `stream.drop-writable` intrinsic. + pub fn stream_drop_writable(&mut self, ty: u32) -> u32 { + self.canonical_functions().stream_drop_writable(ty); inc(&mut self.core_funcs) } @@ -531,15 +531,15 @@ impl ComponentBuilder { inc(&mut self.core_funcs) } - /// Declares a new `future.close-readable` intrinsic. - pub fn future_close_readable(&mut self, ty: u32) -> u32 { - self.canonical_functions().future_close_readable(ty); + /// Declares a new `future.drop-readable` intrinsic. + pub fn future_drop_readable(&mut self, ty: u32) -> u32 { + self.canonical_functions().future_drop_readable(ty); inc(&mut self.core_funcs) } - /// Declares a new `future.close-writable` intrinsic. - pub fn future_close_writable(&mut self, ty: u32) -> u32 { - self.canonical_functions().future_close_writable(ty); + /// Declares a new `future.drop-writable` intrinsic. + pub fn future_drop_writable(&mut self, ty: u32) -> u32 { + self.canonical_functions().future_drop_writable(ty); inc(&mut self.core_funcs) } diff --git a/crates/wasm-encoder/src/component/canonicals.rs b/crates/wasm-encoder/src/component/canonicals.rs index 867db047a2..2d4877c94f 100644 --- a/crates/wasm-encoder/src/component/canonicals.rs +++ b/crates/wasm-encoder/src/component/canonicals.rs @@ -327,18 +327,18 @@ impl CanonicalFunctionSection { self } - /// Defines a function to close the readable end of a `stream` of the + /// Defines a function to drop the readable end of a `stream` of the /// specified type. - pub fn stream_close_readable(&mut self, ty: u32) -> &mut Self { + pub fn stream_drop_readable(&mut self, ty: u32) -> &mut Self { self.bytes.push(0x13); ty.encode(&mut self.bytes); self.num_added += 1; self } - /// Defines a function to close the writable end of a `stream` of the + /// Defines a function to drop the writable end of a `stream` of the /// specified type. - pub fn stream_close_writable(&mut self, ty: u32) -> &mut Self { + pub fn stream_drop_writable(&mut self, ty: u32) -> &mut Self { self.bytes.push(0x14); ty.encode(&mut self.bytes); self.num_added += 1; @@ -400,18 +400,18 @@ impl CanonicalFunctionSection { self } - /// Defines a function to close the readable end of a `future` of the + /// Defines a function to drop the readable end of a `future` of the /// specified type. - pub fn future_close_readable(&mut self, ty: u32) -> &mut Self { + pub fn future_drop_readable(&mut self, ty: u32) -> &mut Self { self.bytes.push(0x1a); ty.encode(&mut self.bytes); self.num_added += 1; self } - /// Defines a function to close the writable end of a `future` of the + /// Defines a function to drop the writable end of a `future` of the /// specified type. - pub fn future_close_writable(&mut self, ty: u32) -> &mut Self { + pub fn future_drop_writable(&mut self, ty: u32) -> &mut Self { self.bytes.push(0x1b); ty.encode(&mut self.bytes); self.num_added += 1; diff --git a/crates/wasm-encoder/src/reencode/component.rs b/crates/wasm-encoder/src/reencode/component.rs index 718528c712..9f53eaed97 100644 --- a/crates/wasm-encoder/src/reencode/component.rs +++ b/crates/wasm-encoder/src/reencode/component.rs @@ -436,7 +436,7 @@ pub mod component_utils { .. } => (), wasmparser::Payload::Version { .. } => { - return Err(Error::UnexpectedNonComponentSection) + return Err(Error::UnexpectedNonComponentSection); } wasmparser::Payload::TypeSection(_) | wasmparser::Payload::ImportSection(_) @@ -452,7 +452,7 @@ pub mod component_utils { | wasmparser::Payload::DataSection(_) | wasmparser::Payload::CodeSectionStart { .. } | wasmparser::Payload::CodeSectionEntry(_) => { - return Err(Error::UnexpectedNonComponentSection) + return Err(Error::UnexpectedNonComponentSection); } wasmparser::Payload::ComponentTypeSection(section) => { let mut types = crate::ComponentTypeSection::new(); @@ -1027,11 +1027,11 @@ pub mod component_utils { wasmparser::CanonicalFunction::StreamCancelWrite { ty, async_ } => { section.stream_cancel_write(ty, async_); } - wasmparser::CanonicalFunction::StreamCloseReadable { ty } => { - section.stream_close_readable(reencoder.component_type_index(ty)); + wasmparser::CanonicalFunction::StreamDropReadable { ty } => { + section.stream_drop_readable(reencoder.component_type_index(ty)); } - wasmparser::CanonicalFunction::StreamCloseWritable { ty } => { - section.stream_close_writable(reencoder.component_type_index(ty)); + wasmparser::CanonicalFunction::StreamDropWritable { ty } => { + section.stream_drop_writable(reencoder.component_type_index(ty)); } wasmparser::CanonicalFunction::FutureNew { ty } => { section.future_new(reencoder.component_type_index(ty)); @@ -1056,11 +1056,11 @@ pub mod component_utils { wasmparser::CanonicalFunction::FutureCancelWrite { ty, async_ } => { section.future_cancel_write(ty, async_); } - wasmparser::CanonicalFunction::FutureCloseReadable { ty } => { - section.future_close_readable(reencoder.component_type_index(ty)); + wasmparser::CanonicalFunction::FutureDropReadable { ty } => { + section.future_drop_readable(reencoder.component_type_index(ty)); } - wasmparser::CanonicalFunction::FutureCloseWritable { ty } => { - section.future_close_writable(reencoder.component_type_index(ty)); + wasmparser::CanonicalFunction::FutureDropWritable { ty } => { + section.future_drop_writable(reencoder.component_type_index(ty)); } wasmparser::CanonicalFunction::ErrorContextNew { options } => { let options = options diff --git a/crates/wasm-wave/Cargo.toml b/crates/wasm-wave/Cargo.toml index 6bb4a25e26..f59ada626e 100644 --- a/crates/wasm-wave/Cargo.toml +++ b/crates/wasm-wave/Cargo.toml @@ -11,6 +11,9 @@ categories = ["wasm", "encoding", "parser-implementations"] repository = "https://github.com/bytecodealliance/wasm-tools/tree/main/crates/wasm-wave" readme = "README.md" +[lints] +workspace = true + [features] default = ["wit"] wit = ["dep:wit-parser"] diff --git a/crates/wasmparser/src/readers/component/canonicals.rs b/crates/wasmparser/src/readers/component/canonicals.rs index 61fb2a956c..2df2e9d1e6 100644 --- a/crates/wasmparser/src/readers/component/canonicals.rs +++ b/crates/wasmparser/src/readers/component/canonicals.rs @@ -161,15 +161,15 @@ pub enum CanonicalFunction { /// `BLOCKED`. async_: bool, }, - /// A function to close the readable end of a `stream` of the specified + /// A function to drop the readable end of a `stream` of the specified /// type. - StreamCloseReadable { + StreamDropReadable { /// The `stream` type to expect. ty: u32, }, - /// A function to close the writable end of a `stream` of the specified + /// A function to drop the writable end of a `stream` of the specified /// type. - StreamCloseWritable { + StreamDropWritable { /// The `stream` type to expect. ty: u32, }, @@ -212,15 +212,15 @@ pub enum CanonicalFunction { /// `BLOCKED`. async_: bool, }, - /// A function to close the readable end of a `future` of the specified + /// A function to drop the readable end of a `future` of the specified /// type. - FutureCloseReadable { + FutureDropReadable { /// The `future` type to expect. ty: u32, }, - /// A function to close the writable end of a `future` of the specified + /// A function to drop the writable end of a `future` of the specified /// type. - FutureCloseWritable { + FutureDropWritable { /// The `future` type to expect. ty: u32, }, @@ -331,8 +331,8 @@ impl<'a> FromReader<'a> for CanonicalFunction { ty: reader.read()?, async_: reader.read()?, }, - 0x13 => CanonicalFunction::StreamCloseReadable { ty: reader.read()? }, - 0x14 => CanonicalFunction::StreamCloseWritable { ty: reader.read()? }, + 0x13 => CanonicalFunction::StreamDropReadable { ty: reader.read()? }, + 0x14 => CanonicalFunction::StreamDropWritable { ty: reader.read()? }, 0x15 => CanonicalFunction::FutureNew { ty: reader.read()? }, 0x16 => CanonicalFunction::FutureRead { ty: reader.read()?, @@ -350,8 +350,8 @@ impl<'a> FromReader<'a> for CanonicalFunction { ty: reader.read()?, async_: reader.read()?, }, - 0x1a => CanonicalFunction::FutureCloseReadable { ty: reader.read()? }, - 0x1b => CanonicalFunction::FutureCloseWritable { ty: reader.read()? }, + 0x1a => CanonicalFunction::FutureDropReadable { ty: reader.read()? }, + 0x1b => CanonicalFunction::FutureDropWritable { ty: reader.read()? }, 0x1c => CanonicalFunction::ErrorContextNew { options: read_opts(reader)?, }, diff --git a/crates/wasmparser/src/validator/component.rs b/crates/wasmparser/src/validator/component.rs index 48b511bdb9..1eb0f63deb 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, ModuleType, RecordType, - Remap, Remapping, ResourceId, SubtypeCx, TupleType, VariantCase, VariantType, + ComponentValType, Context, CoreInstanceTypeKind, InstanceType, LoweredFuncType, ModuleType, + RecordType, Remap, Remapping, ResourceId, SubtypeCx, TupleType, VariantCase, VariantType, }, core::{InternRecGroup, Module}, types::{CoreTypeId, EntityType, TypeAlloc, TypeInfo, TypeList}, @@ -23,6 +23,7 @@ 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> { @@ -251,6 +252,7 @@ impl Concurrency { } } +#[derive(Clone, Copy)] pub(crate) struct CanonicalOptions { pub(crate) string_encoding: StringEncoding, pub(crate) memory: Option, @@ -344,7 +346,10 @@ impl CanonicalOptions { if let Some(idx) = self.post_return { let func_ty = types[state.core_function_at(idx, offset)?].unwrap_func(); if func_ty.params() != core_ty.results() || !func_ty.results().is_empty() { - bail!(offset, "canonical option `post-return` uses a core function with an incorrect signature"); + bail!( + offset, + "canonical option `post-return` uses a core function with an incorrect signature" + ); } } @@ -1194,11 +1199,11 @@ impl ComponentState { CanonicalFunction::StreamCancelWrite { ty, async_ } => { self.stream_cancel_write(ty, async_, types, offset) } - CanonicalFunction::StreamCloseReadable { ty } => { - self.stream_close_readable(ty, types, offset) + CanonicalFunction::StreamDropReadable { ty } => { + self.stream_drop_readable(ty, types, offset) } - CanonicalFunction::StreamCloseWritable { ty } => { - self.stream_close_writable(ty, types, offset) + CanonicalFunction::StreamDropWritable { ty } => { + self.stream_drop_writable(ty, types, offset) } CanonicalFunction::FutureNew { ty } => self.future_new(ty, types, offset), CanonicalFunction::FutureRead { ty, options } => { @@ -1213,11 +1218,11 @@ impl ComponentState { CanonicalFunction::FutureCancelWrite { ty, async_ } => { self.future_cancel_write(ty, async_, types, offset) } - CanonicalFunction::FutureCloseReadable { ty } => { - self.future_close_readable(ty, types, offset) + CanonicalFunction::FutureDropReadable { ty } => { + self.future_drop_readable(ty, types, offset) } - CanonicalFunction::FutureCloseWritable { ty } => { - self.future_close_writable(ty, types, offset) + CanonicalFunction::FutureDropWritable { ty } => { + self.future_drop_writable(ty, types, offset) } CanonicalFunction::ErrorContextNew { options } => { self.error_context_new(options.into_vec(), types, offset) @@ -1663,7 +1668,7 @@ impl ComponentState { Ok(()) } - fn stream_close_readable( + fn stream_drop_readable( &mut self, ty: u32, types: &mut TypeAlloc, @@ -1672,13 +1677,13 @@ impl ComponentState { if !self.features.cm_async() { bail!( offset, - "`stream.close-readable` requires the component model async feature" + "`stream.drop-readable` requires the component model async feature" ) } let ty = self.defined_type_at(ty, offset)?; let ComponentDefinedType::Stream(_) = &types[ty] else { - bail!(offset, "`stream.close-readable` requires a stream type") + bail!(offset, "`stream.drop-readable` requires a stream type") }; self.core_funcs @@ -1686,7 +1691,7 @@ impl ComponentState { Ok(()) } - fn stream_close_writable( + fn stream_drop_writable( &mut self, ty: u32, types: &mut TypeAlloc, @@ -1695,13 +1700,13 @@ impl ComponentState { if !self.features.cm_async() { bail!( offset, - "`stream.close-writable` requires the component model async feature" + "`stream.drop-writable` requires the component model async feature" ) } let ty = self.defined_type_at(ty, offset)?; let ComponentDefinedType::Stream(_) = &types[ty] else { - bail!(offset, "`stream.close-writable` requires a stream type") + bail!(offset, "`stream.drop-writable` requires a stream type") }; self.core_funcs @@ -1748,12 +1753,15 @@ impl ComponentState { let ty_id = self .check_options(types, options, offset)? - .require_memory(offset)? + .require_memory_if(offset, || elem_ty.is_some())? .require_realloc_if(offset, || elem_ty.is_some_and(|ty| ty.contains_ptr(types)))? .check_lower(offset)? .check_core_type( types, - FuncType::new([ValType::I32; 2], [ValType::I32]), + FuncType::new( + iter::repeat(ValType::I32).take(if elem_ty.is_some() { 2 } else { 1 }), + [ValType::I32], + ), offset, )?; @@ -1776,19 +1784,48 @@ impl ComponentState { } let ty = self.defined_type_at(ty, offset)?; - let ComponentDefinedType::Future(_) = &types[ty] else { + let ComponentDefinedType::Future(elem_ty) = &types[ty] else { bail!(offset, "`future.write` requires a future type") }; - let ty_id = self - .check_options(types, &options, offset)? - .require_memory(offset)? - .check_lower(offset)? - .check_core_type( - types, - FuncType::new([ValType::I32; 2], [ValType::I32]), + 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!( 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(()) @@ -1854,7 +1891,7 @@ impl ComponentState { Ok(()) } - fn future_close_readable( + fn future_drop_readable( &mut self, ty: u32, types: &mut TypeAlloc, @@ -1863,13 +1900,13 @@ impl ComponentState { if !self.features.cm_async() { bail!( offset, - "`future.close-readable` requires the component model async feature" + "`future.drop-readable` requires the component model async feature" ) } let ty = self.defined_type_at(ty, offset)?; let ComponentDefinedType::Future(_) = &types[ty] else { - bail!(offset, "`future.close-readable` requires a future type") + bail!(offset, "`future.drop-readable` requires a future type") }; self.core_funcs @@ -1877,7 +1914,7 @@ impl ComponentState { Ok(()) } - fn future_close_writable( + fn future_drop_writable( &mut self, ty: u32, types: &mut TypeAlloc, @@ -1886,13 +1923,13 @@ impl ComponentState { if !self.features.cm_async() { bail!( offset, - "`future.close-writable` requires the component model async feature" + "`future.drop-writable` requires the component model async feature" ) } let ty = self.defined_type_at(ty, offset)?; let ComponentDefinedType::Future(_) = &types[ty] else { - bail!(offset, "`future.close-writable` requires a future type") + bail!(offset, "`future.drop-writable` requires a future type") }; self.core_funcs @@ -2405,7 +2442,7 @@ impl ComponentState { return Err(BinaryReaderError::new( "canonical option `memory` is specified more than once", offset, - )) + )); } } } @@ -2429,7 +2466,7 @@ impl ComponentState { return Err(BinaryReaderError::new( "canonical option `realloc` is specified more than once", offset, - )) + )); } } } @@ -2440,7 +2477,7 @@ impl ComponentState { return Err(BinaryReaderError::new( "canonical option `post-return` is specified more than once", offset, - )) + )); } } } @@ -2468,7 +2505,7 @@ impl ComponentState { return Err(BinaryReaderError::new( "canonical option `callback` is specified more than once", offset, - )) + )); } } } @@ -2483,21 +2520,25 @@ impl ComponentState { } let ty = match self.core_type_at(*idx, offset)? { ComponentCoreTypeId::Sub(ty) => ty, - ComponentCoreTypeId::Module(_) => return Err(BinaryReaderError::new( - "canonical option `core type` must reference a core function \ + ComponentCoreTypeId::Module(_) => { + return Err(BinaryReaderError::new( + "canonical option `core type` must reference a core function \ type", - offset, - )), + offset, + )); + } }; match &types[ty].composite_type.inner { CompositeInnerType::Func(_) => {} - CompositeInnerType::Array(_) | - CompositeInnerType::Struct(_) | - CompositeInnerType::Cont(_) => return Err(BinaryReaderError::new( - "canonical option `core type` must reference a core function \ + CompositeInnerType::Array(_) + | CompositeInnerType::Struct(_) + | CompositeInnerType::Cont(_) => { + return Err(BinaryReaderError::new( + "canonical option `core type` must reference a core function \ type", - offset, - )), + offset, + )); + } } Some(ty) } @@ -2505,7 +2546,7 @@ impl ComponentState { return Err(BinaryReaderError::new( "canonical option `core type` is specified more than once", offset, - )) + )); } }; } diff --git a/crates/wasmprinter/src/component.rs b/crates/wasmprinter/src/component.rs index 1aa35ce84d..8880cec66f 100644 --- a/crates/wasmprinter/src/component.rs +++ b/crates/wasmprinter/src/component.rs @@ -1028,13 +1028,13 @@ impl Printer<'_, '_> { Ok(()) })?; } - CanonicalFunction::StreamCloseReadable { ty } => { - self.print_intrinsic(state, "canon stream.close-readable ", &|me, state| { + CanonicalFunction::StreamDropReadable { ty } => { + self.print_intrinsic(state, "canon stream.drop-readable ", &|me, state| { me.print_idx(&state.component.type_names, ty) })?; } - CanonicalFunction::StreamCloseWritable { ty } => { - self.print_intrinsic(state, "canon stream.close-writable ", &|me, state| { + CanonicalFunction::StreamDropWritable { ty } => { + self.print_intrinsic(state, "canon stream.drop-writable ", &|me, state| { me.print_idx(&state.component.type_names, ty) })?; } @@ -1073,13 +1073,13 @@ impl Printer<'_, '_> { Ok(()) })?; } - CanonicalFunction::FutureCloseReadable { ty } => { - self.print_intrinsic(state, "canon future.close-readable ", &|me, state| { + CanonicalFunction::FutureDropReadable { ty } => { + self.print_intrinsic(state, "canon future.drop-readable ", &|me, state| { me.print_idx(&state.component.type_names, ty) })?; } - CanonicalFunction::FutureCloseWritable { ty } => { - self.print_intrinsic(state, "canon future.close-writable ", &|me, state| { + CanonicalFunction::FutureDropWritable { ty } => { + self.print_intrinsic(state, "canon future.drop-writable ", &|me, state| { me.print_idx(&state.component.type_names, ty) })?; } diff --git a/crates/wast/src/component/binary.rs b/crates/wast/src/component/binary.rs index caf59e0bff..64d717d245 100644 --- a/crates/wast/src/component/binary.rs +++ b/crates/wast/src/component/binary.rs @@ -429,13 +429,13 @@ impl<'a> Encoder<'a> { self.core_func_names.push(name); self.funcs.stream_cancel_write(info.ty.into(), info.async_); } - CoreFuncKind::StreamCloseReadable(info) => { + CoreFuncKind::StreamDropReadable(info) => { self.core_func_names.push(name); - self.funcs.stream_close_readable(info.ty.into()); + self.funcs.stream_drop_readable(info.ty.into()); } - CoreFuncKind::StreamCloseWritable(info) => { + CoreFuncKind::StreamDropWritable(info) => { self.core_func_names.push(name); - self.funcs.stream_close_writable(info.ty.into()); + self.funcs.stream_drop_writable(info.ty.into()); } CoreFuncKind::FutureNew(info) => { self.core_func_names.push(name); @@ -459,13 +459,13 @@ impl<'a> Encoder<'a> { self.core_func_names.push(name); self.funcs.future_cancel_write(info.ty.into(), info.async_); } - CoreFuncKind::FutureCloseReadable(info) => { + CoreFuncKind::FutureDropReadable(info) => { self.core_func_names.push(name); - self.funcs.future_close_readable(info.ty.into()); + self.funcs.future_drop_readable(info.ty.into()); } - CoreFuncKind::FutureCloseWritable(info) => { + CoreFuncKind::FutureDropWritable(info) => { self.core_func_names.push(name); - self.funcs.future_close_writable(info.ty.into()); + self.funcs.future_drop_writable(info.ty.into()); } CoreFuncKind::ErrorContextNew(info) => { self.core_func_names.push(name); diff --git a/crates/wast/src/component/func.rs b/crates/wast/src/component/func.rs index 6d1fa031cd..e967bfbb65 100644 --- a/crates/wast/src/component/func.rs +++ b/crates/wast/src/component/func.rs @@ -67,15 +67,15 @@ pub enum CoreFuncKind<'a> { StreamWrite(CanonStreamWrite<'a>), StreamCancelRead(CanonStreamCancelRead<'a>), StreamCancelWrite(CanonStreamCancelWrite<'a>), - StreamCloseReadable(CanonStreamCloseReadable<'a>), - StreamCloseWritable(CanonStreamCloseWritable<'a>), + StreamDropReadable(CanonStreamDropReadable<'a>), + StreamDropWritable(CanonStreamDropWritable<'a>), FutureNew(CanonFutureNew<'a>), FutureRead(CanonFutureRead<'a>), FutureWrite(CanonFutureWrite<'a>), FutureCancelRead(CanonFutureCancelRead<'a>), FutureCancelWrite(CanonFutureCancelWrite<'a>), - FutureCloseReadable(CanonFutureCloseReadable<'a>), - FutureCloseWritable(CanonFutureCloseWritable<'a>), + FutureDropReadable(CanonFutureDropReadable<'a>), + FutureDropWritable(CanonFutureDropWritable<'a>), ErrorContextNew(CanonErrorContextNew<'a>), ErrorContextDebugMessage(CanonErrorContextDebugMessage<'a>), ErrorContextDrop, @@ -151,10 +151,10 @@ impl<'a> CoreFuncKind<'a> { Ok(CoreFuncKind::StreamCancelRead(parser.parse()?)) } else if l.peek::()? { Ok(CoreFuncKind::StreamCancelWrite(parser.parse()?)) - } else if l.peek::()? { - Ok(CoreFuncKind::StreamCloseReadable(parser.parse()?)) - } else if l.peek::()? { - Ok(CoreFuncKind::StreamCloseWritable(parser.parse()?)) + } else if l.peek::()? { + Ok(CoreFuncKind::StreamDropReadable(parser.parse()?)) + } else if l.peek::()? { + Ok(CoreFuncKind::StreamDropWritable(parser.parse()?)) } else if l.peek::()? { Ok(CoreFuncKind::FutureNew(parser.parse()?)) } else if l.peek::()? { @@ -165,10 +165,10 @@ impl<'a> CoreFuncKind<'a> { Ok(CoreFuncKind::FutureCancelRead(parser.parse()?)) } else if l.peek::()? { Ok(CoreFuncKind::FutureCancelWrite(parser.parse()?)) - } else if l.peek::()? { - Ok(CoreFuncKind::FutureCloseReadable(parser.parse()?)) - } else if l.peek::()? { - Ok(CoreFuncKind::FutureCloseWritable(parser.parse()?)) + } else if l.peek::()? { + Ok(CoreFuncKind::FutureDropReadable(parser.parse()?)) + } else if l.peek::()? { + Ok(CoreFuncKind::FutureDropWritable(parser.parse()?)) } else if l.peek::()? { Ok(CoreFuncKind::ErrorContextNew(parser.parse()?)) } else if l.peek::()? { @@ -729,16 +729,16 @@ impl<'a> Parse<'a> for CanonStreamCancelWrite<'a> { } } -/// Information relating to the `stream.close-readable` intrinsic. +/// Information relating to the `stream.drop-readable` intrinsic. #[derive(Debug)] -pub struct CanonStreamCloseReadable<'a> { - /// The stream type to close. +pub struct CanonStreamDropReadable<'a> { + /// The stream type to drop. pub ty: Index<'a>, } -impl<'a> Parse<'a> for CanonStreamCloseReadable<'a> { +impl<'a> Parse<'a> for CanonStreamDropReadable<'a> { fn parse(parser: Parser<'a>) -> Result { - parser.parse::()?; + parser.parse::()?; Ok(Self { ty: parser.parse()?, @@ -746,16 +746,16 @@ impl<'a> Parse<'a> for CanonStreamCloseReadable<'a> { } } -/// Information relating to the `stream.close-writable` intrinsic. +/// Information relating to the `stream.drop-writable` intrinsic. #[derive(Debug)] -pub struct CanonStreamCloseWritable<'a> { - /// The stream type to close. +pub struct CanonStreamDropWritable<'a> { + /// The stream type to drop. pub ty: Index<'a>, } -impl<'a> Parse<'a> for CanonStreamCloseWritable<'a> { +impl<'a> Parse<'a> for CanonStreamDropWritable<'a> { fn parse(parser: Parser<'a>) -> Result { - parser.parse::()?; + parser.parse::()?; Ok(Self { ty: parser.parse()?, @@ -862,16 +862,16 @@ impl<'a> Parse<'a> for CanonFutureCancelWrite<'a> { } } -/// Information relating to the `future.close-readable` intrinsic. +/// Information relating to the `future.drop-readable` intrinsic. #[derive(Debug)] -pub struct CanonFutureCloseReadable<'a> { - /// The future type to close. +pub struct CanonFutureDropReadable<'a> { + /// The future type to drop. pub ty: Index<'a>, } -impl<'a> Parse<'a> for CanonFutureCloseReadable<'a> { +impl<'a> Parse<'a> for CanonFutureDropReadable<'a> { fn parse(parser: Parser<'a>) -> Result { - parser.parse::()?; + parser.parse::()?; Ok(Self { ty: parser.parse()?, @@ -879,16 +879,16 @@ impl<'a> Parse<'a> for CanonFutureCloseReadable<'a> { } } -/// Information relating to the `future.close-writable` intrinsic. +/// Information relating to the `future.drop-writable` intrinsic. #[derive(Debug)] -pub struct CanonFutureCloseWritable<'a> { - /// The future type to close. +pub struct CanonFutureDropWritable<'a> { + /// The future type to drop. pub ty: Index<'a>, } -impl<'a> Parse<'a> for CanonFutureCloseWritable<'a> { +impl<'a> Parse<'a> for CanonFutureDropWritable<'a> { fn parse(parser: Parser<'a>) -> Result { - parser.parse::()?; + parser.parse::()?; Ok(Self { ty: parser.parse()?, diff --git a/crates/wast/src/component/resolve.rs b/crates/wast/src/component/resolve.rs index 13c4bd30ab..49144ac232 100644 --- a/crates/wast/src/component/resolve.rs +++ b/crates/wast/src/component/resolve.rs @@ -425,10 +425,10 @@ impl<'a> Resolver<'a> { CoreFuncKind::StreamCancelWrite(info) => { self.resolve_ns(&mut info.ty, Ns::Type)?; } - CoreFuncKind::StreamCloseReadable(info) => { + CoreFuncKind::StreamDropReadable(info) => { self.resolve_ns(&mut info.ty, Ns::Type)?; } - CoreFuncKind::StreamCloseWritable(info) => { + CoreFuncKind::StreamDropWritable(info) => { self.resolve_ns(&mut info.ty, Ns::Type)?; } CoreFuncKind::FutureNew(info) => { @@ -448,10 +448,10 @@ impl<'a> Resolver<'a> { CoreFuncKind::FutureCancelWrite(info) => { self.resolve_ns(&mut info.ty, Ns::Type)?; } - CoreFuncKind::FutureCloseReadable(info) => { + CoreFuncKind::FutureDropReadable(info) => { self.resolve_ns(&mut info.ty, Ns::Type)?; } - CoreFuncKind::FutureCloseWritable(info) => { + CoreFuncKind::FutureDropWritable(info) => { self.resolve_ns(&mut info.ty, Ns::Type)?; } CoreFuncKind::ErrorContextNew(info) => { @@ -861,7 +861,7 @@ impl<'a> Resolver<'a> { "outer item `{}` is not a module, type, or component", id.name(), ), - )) + )); } }, }, diff --git a/crates/wast/src/lib.rs b/crates/wast/src/lib.rs index 29ad9e297c..ee2e662267 100644 --- a/crates/wast/src/lib.rs +++ b/crates/wast/src/lib.rs @@ -570,15 +570,15 @@ pub mod kw { custom_keyword!(stream_write = "stream.write"); custom_keyword!(stream_cancel_read = "stream.cancel-read"); custom_keyword!(stream_cancel_write = "stream.cancel-write"); - custom_keyword!(stream_close_readable = "stream.close-readable"); - custom_keyword!(stream_close_writable = "stream.close-writable"); + custom_keyword!(stream_drop_readable = "stream.drop-readable"); + custom_keyword!(stream_drop_writable = "stream.drop-writable"); custom_keyword!(future_new = "future.new"); custom_keyword!(future_read = "future.read"); custom_keyword!(future_write = "future.write"); custom_keyword!(future_cancel_read = "future.cancel-read"); custom_keyword!(future_cancel_write = "future.cancel-write"); - custom_keyword!(future_close_readable = "future.close-readable"); - custom_keyword!(future_close_writable = "future.close-writable"); + custom_keyword!(future_drop_readable = "future.drop-readable"); + custom_keyword!(future_drop_writable = "future.drop-writable"); custom_keyword!(error_context_new = "error-context.new"); custom_keyword!(error_context_debug_message = "error-context.debug-message"); custom_keyword!(error_context_drop = "error-context.drop"); diff --git a/crates/wit-component/src/dummy.rs b/crates/wit-component/src/dummy.rs index 0cccff007b..bb0c291cf8 100644 --- a/crates/wit-component/src/dummy.rs +++ b/crates/wit-component/src/dummy.rs @@ -189,18 +189,32 @@ fn push_imported_future_and_stream_intrinsics( .enumerate() { match &resolve.types[id].kind { - TypeDefKind::Future(_) => { + 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::>() + .join(" "); + wat.push_str(&format!( r#" (import {module:?} "[future-new-{i}]{name}" (func (result i64))) -(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-read-{i}]{name}" (func (param {read_params}) (result i32))) +(import {module:?} "[future-write-{i}]{name}" (func (param {write_params}) (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-close-readable-{i}]{name}" (func (param i32))) -(import {module:?} "[future-close-writable-{i}]{name}" (func (param 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))) +(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))) ;; deferred behind 🚝 ;;(import {module:?} "[async-lower][future-cancel-read-{i}]{name}" (func (param i32) (result i32))) @@ -216,8 +230,8 @@ fn push_imported_future_and_stream_intrinsics( (import {module:?} "[stream-write-{i}]{name}" (func (param i32 i32 i32) (result i32))) (import {module:?} "[stream-cancel-read-{i}]{name}" (func (param i32) (result i32))) (import {module:?} "[stream-cancel-write-{i}]{name}" (func (param i32) (result i32))) -(import {module:?} "[stream-close-readable-{i}]{name}" (func (param i32))) -(import {module:?} "[stream-close-writable-{i}]{name}" (func (param i32))) +(import {module:?} "[stream-drop-readable-{i}]{name}" (func (param i32))) +(import {module:?} "[stream-drop-writable-{i}]{name}" (func (param i32))) (import {module:?} "[async-lower][stream-read-{i}]{name}" (func (param i32 i32 i32) (result i32))) (import {module:?} "[async-lower][stream-write-{i}]{name}" (func (param i32 i32 i32) (result i32))) diff --git a/crates/wit-component/src/encoding.rs b/crates/wit-component/src/encoding.rs index 51cf943d4b..98ca5740eb 100644 --- a/crates/wit-component/src/encoding.rs +++ b/crates/wit-component/src/encoding.rs @@ -1536,7 +1536,9 @@ impl<'a> EncodingState<'a> { ImportInstance::Names(names) => { let mut exports = Vec::new(); for (name, import) in names { - log::trace!("attempting to materialize import of `{core_wasm_name}::{name}` for {for_module:?}"); + log::trace!( + "attempting to materialize import of `{core_wasm_name}::{name}` for {for_module:?}" + ); let (kind, index) = self .materialize_import(&shims, for_module, import) .with_context(|| { @@ -1737,14 +1739,14 @@ impl<'a> EncodingState<'a> { let index = self.component.stream_cancel_write(ty, *async_); Ok((ExportKind::Func, index)) } - Import::StreamCloseReadable(info) => { + Import::StreamDropReadable(info) => { let type_index = self.payload_type_index(info)?; - let index = self.component.stream_close_readable(type_index); + let index = self.component.stream_drop_readable(type_index); Ok((ExportKind::Func, index)) } - Import::StreamCloseWritable(info) => { + Import::StreamDropWritable(info) => { let type_index = self.payload_type_index(info)?; - let index = self.component.stream_close_writable(type_index); + let index = self.component.stream_drop_writable(type_index); Ok((ExportKind::Func, index)) } Import::FutureNew(info) => { @@ -1774,14 +1776,14 @@ impl<'a> EncodingState<'a> { let index = self.component.future_cancel_write(ty, *async_); Ok((ExportKind::Func, index)) } - Import::FutureCloseReadable(info) => { + Import::FutureDropReadable(info) => { let type_index = self.payload_type_index(info)?; - let index = self.component.future_close_readable(type_index); + let index = self.component.future_drop_readable(type_index); Ok((ExportKind::Func, index)) } - Import::FutureCloseWritable(info) => { + Import::FutureDropWritable(info) => { let type_index = self.payload_type_index(info)?; - let index = self.component.future_close_writable(type_index); + let index = self.component.future_drop_writable(type_index); Ok((ExportKind::Func, index)) } Import::ErrorContextNew { encoding } => Ok(self.materialize_shim_import( @@ -2209,12 +2211,12 @@ impl<'a> Shims<'a> { | Import::StreamNew(..) | Import::FutureCancelRead { .. } | Import::FutureCancelWrite { .. } - | Import::FutureCloseWritable { .. } - | Import::FutureCloseReadable { .. } + | Import::FutureDropWritable { .. } + | Import::FutureDropReadable { .. } | Import::StreamCancelRead { .. } | Import::StreamCancelWrite { .. } - | Import::StreamCloseWritable { .. } - | Import::StreamCloseReadable { .. } + | Import::StreamDropWritable { .. } + | Import::StreamDropReadable { .. } | Import::WaitableSetNew | Import::WaitableSetDrop | Import::WaitableJoin @@ -2263,7 +2265,9 @@ impl<'a> Shims<'a> { *async_, info, PayloadFuncKind::FutureWrite, - vec![WasmType::I32; 2], + resolve + .future_write_wasm_signature(info.payload(resolve)) + .params, vec![WasmType::I32], ); } @@ -2275,7 +2279,14 @@ impl<'a> Shims<'a> { *async_, info, PayloadFuncKind::FutureRead, - vec![WasmType::I32; 2], + vec![ + WasmType::I32; + if info.payload(resolve).is_some() { + 2 + } else { + 1 + } + ], vec![WasmType::I32], ); } diff --git a/crates/wit-component/src/encoding/world.rs b/crates/wit-component/src/encoding/world.rs index c599230f98..91e64fe67d 100644 --- a/crates/wit-component/src/encoding/world.rs +++ b/crates/wit-component/src/encoding/world.rs @@ -387,15 +387,15 @@ impl<'a> ComponentWorld<'a> { | Import::StreamWrite { info, async_: _ } | Import::StreamCancelRead { info, async_: _ } | Import::StreamCancelWrite { info, async_: _ } - | Import::StreamCloseReadable(info) - | Import::StreamCloseWritable(info) + | Import::StreamDropReadable(info) + | Import::StreamDropWritable(info) | Import::FutureNew(info) | Import::FutureRead { info, async_: _ } | Import::FutureWrite { info, async_: _ } | Import::FutureCancelRead { info, async_: _ } | Import::FutureCancelWrite { info, async_: _ } - | Import::FutureCloseReadable(info) - | Import::FutureCloseWritable(info) => { + | Import::FutureDropReadable(info) + | Import::FutureDropWritable(info) => { live.add_type_id(resolve, info.ty); } diff --git a/crates/wit-component/src/validation.rs b/crates/wit-component/src/validation.rs index da43396829..5590c49b65 100644 --- a/crates/wit-component/src/validation.rs +++ b/crates/wit-component/src/validation.rs @@ -346,15 +346,15 @@ pub enum Import { /// (but which may have already partially or entirely completed). StreamCancelWrite { info: PayloadInfo, async_: bool }, - /// A `canon stream.close-readable` intrinsic. + /// A `canon stream.drop-readable` intrinsic. /// - /// This allows the guest to close the readable end of a `stream`. - StreamCloseReadable(PayloadInfo), + /// This allows the guest to drop the readable end of a `stream`. + StreamDropReadable(PayloadInfo), - /// A `canon stream.close-writable` intrinsic. + /// A `canon stream.drop-writable` intrinsic. /// - /// This allows the guest to close the writable end of a `stream`. - StreamCloseWritable(PayloadInfo), + /// This allows the guest to drop the writable end of a `stream`. + StreamDropWritable(PayloadInfo), /// A `canon future.new` intrinsic. /// @@ -384,15 +384,15 @@ pub enum Import { /// (but which may have already completed). FutureCancelWrite { info: PayloadInfo, async_: bool }, - /// A `canon future.close-readable` intrinsic. + /// A `canon future.drop-readable` intrinsic. /// - /// This allows the guest to close the readable end of a `future`. - FutureCloseReadable(PayloadInfo), + /// This allows the guest to drop the readable end of a `future`. + FutureDropReadable(PayloadInfo), - /// A `canon future.close-writable` intrinsic. + /// A `canon future.drop-writable` intrinsic. /// - /// This allows the guest to close the writable end of a `future`. - FutureCloseWritable(PayloadInfo), + /// This allows the guest to drop the writable end of a `future`. + FutureDropWritable(PayloadInfo), /// A `canon error-context.new` intrinsic. /// @@ -904,10 +904,22 @@ 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, &FuncType::new([ValType::I32; 2], [ValType::I32]), ty)?; + validate_func_sig( + name, + &wasm_sig_to_func_type(resolve.future_write_wasm_signature(info.payload(resolve))), + ty, + )?; Import::FutureWrite { async_, info } } else if let Some(info) = prefixed_payload("[future-read-") { - validate_func_sig(name, &FuncType::new([ValType::I32; 2], [ValType::I32]), ty)?; + 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, + )?; 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)?; @@ -915,18 +927,18 @@ impl ImportMap { } else if let Some(info) = prefixed_payload("[future-cancel-read-") { validate_func_sig(name, &FuncType::new([ValType::I32], [ValType::I32]), ty)?; Import::FutureCancelRead { async_, info } - } else if let Some(info) = prefixed_payload("[future-close-writable-") { + } else if let Some(info) = prefixed_payload("[future-drop-writable-") { if async_ { - bail!("async `future.close-writable` calls not supported"); + bail!("async `future.drop-writable` calls not supported"); } validate_func_sig(name, &FuncType::new([ValType::I32], []), ty)?; - Import::FutureCloseWritable(info) - } else if let Some(info) = prefixed_payload("[future-close-readable-") { + Import::FutureDropWritable(info) + } else if let Some(info) = prefixed_payload("[future-drop-readable-") { if async_ { - bail!("async `future.close-readable` calls not supported"); + bail!("async `future.drop-readable` calls not supported"); } validate_func_sig(name, &FuncType::new([ValType::I32], []), ty)?; - Import::FutureCloseReadable(info) + Import::FutureDropReadable(info) } else if let Some(info) = prefixed_payload("[stream-new-") { if async_ { bail!("async `stream.new` calls not supported"); @@ -945,18 +957,18 @@ impl ImportMap { } else if let Some(info) = prefixed_payload("[stream-cancel-read-") { validate_func_sig(name, &FuncType::new([ValType::I32], [ValType::I32]), ty)?; Import::StreamCancelRead { async_, info } - } else if let Some(info) = prefixed_payload("[stream-close-writable-") { + } else if let Some(info) = prefixed_payload("[stream-drop-writable-") { if async_ { - bail!("async `stream.close-writable` calls not supported"); + bail!("async `stream.drop-writable` calls not supported"); } validate_func_sig(name, &FuncType::new([ValType::I32], []), ty)?; - Import::StreamCloseWritable(info) - } else if let Some(info) = prefixed_payload("[stream-close-readable-") { + Import::StreamDropWritable(info) + } else if let Some(info) = prefixed_payload("[stream-drop-readable-") { if async_ { - bail!("async `stream.close-readable` calls not supported"); + bail!("async `stream.drop-readable` calls not supported"); } validate_func_sig(name, &FuncType::new([ValType::I32], []), ty)?; - Import::StreamCloseReadable(info) + Import::StreamDropReadable(info) } else { return Ok(None); }; diff --git a/crates/wit-component/tests/components/async-streams-and-futures/component.wat b/crates/wit-component/tests/components/async-streams-and-futures/component.wat index 04be22e995..a4a1ff8bfe 100644 --- a/crates/wit-component/tests/components/async-streams-and-futures/component.wat +++ b/crates/wit-component/tests/components/async-streams-and-futures/component.wat @@ -29,85 +29,85 @@ (import "$root" "[stream-write-2]foo" (func (;4;) (type 0))) (import "$root" "[stream-cancel-read-2]foo" (func (;5;) (type 2))) (import "$root" "[stream-cancel-write-2]foo" (func (;6;) (type 2))) - (import "$root" "[stream-close-readable-2]foo" (func (;7;) (type 3))) - (import "$root" "[stream-close-writable-2]foo" (func (;8;) (type 3))) + (import "$root" "[stream-drop-readable-2]foo" (func (;7;) (type 3))) + (import "$root" "[stream-drop-writable-2]foo" (func (;8;) (type 3))) (import "foo:foo/bar" "[stream-new-2]foo" (func (;9;) (type 1))) (import "foo:foo/bar" "[stream-read-2]foo" (func (;10;) (type 0))) (import "foo:foo/bar" "[stream-write-2]foo" (func (;11;) (type 0))) (import "foo:foo/bar" "[stream-cancel-read-2]foo" (func (;12;) (type 2))) (import "foo:foo/bar" "[stream-cancel-write-2]foo" (func (;13;) (type 2))) - (import "foo:foo/bar" "[stream-close-readable-2]foo" (func (;14;) (type 3))) - (import "foo:foo/bar" "[stream-close-writable-2]foo" (func (;15;) (type 3))) + (import "foo:foo/bar" "[stream-drop-readable-2]foo" (func (;14;) (type 3))) + (import "foo:foo/bar" "[stream-drop-writable-2]foo" (func (;15;) (type 3))) (import "$root" "[future-new-0]foo" (func (;16;) (type 1))) (import "$root" "[future-read-0]foo" (func (;17;) (type 4))) (import "$root" "[future-write-0]foo" (func (;18;) (type 4))) (import "$root" "[future-cancel-read-0]foo" (func (;19;) (type 2))) (import "$root" "[future-cancel-write-0]foo" (func (;20;) (type 2))) - (import "$root" "[future-close-readable-0]foo" (func (;21;) (type 3))) - (import "$root" "[future-close-writable-0]foo" (func (;22;) (type 3))) + (import "$root" "[future-drop-readable-0]foo" (func (;21;) (type 3))) + (import "$root" "[future-drop-writable-0]foo" (func (;22;) (type 3))) (import "foo:foo/bar" "[future-new-0]foo" (func (;23;) (type 1))) (import "foo:foo/bar" "[future-read-0]foo" (func (;24;) (type 4))) (import "foo:foo/bar" "[future-write-0]foo" (func (;25;) (type 4))) (import "foo:foo/bar" "[future-cancel-read-0]foo" (func (;26;) (type 2))) (import "foo:foo/bar" "[future-cancel-write-0]foo" (func (;27;) (type 2))) - (import "foo:foo/bar" "[future-close-readable-0]foo" (func (;28;) (type 3))) - (import "foo:foo/bar" "[future-close-writable-0]foo" (func (;29;) (type 3))) + (import "foo:foo/bar" "[future-drop-readable-0]foo" (func (;28;) (type 3))) + (import "foo:foo/bar" "[future-drop-writable-0]foo" (func (;29;) (type 3))) (import "$root" "[future-new-1]foo" (func (;30;) (type 1))) (import "$root" "[future-read-1]foo" (func (;31;) (type 4))) (import "$root" "[future-write-1]foo" (func (;32;) (type 4))) (import "$root" "[future-cancel-read-1]foo" (func (;33;) (type 2))) (import "$root" "[future-cancel-write-1]foo" (func (;34;) (type 2))) - (import "$root" "[future-close-readable-1]foo" (func (;35;) (type 3))) - (import "$root" "[future-close-writable-1]foo" (func (;36;) (type 3))) + (import "$root" "[future-drop-readable-1]foo" (func (;35;) (type 3))) + (import "$root" "[future-drop-writable-1]foo" (func (;36;) (type 3))) (import "foo:foo/bar" "[future-new-1]foo" (func (;37;) (type 1))) (import "foo:foo/bar" "[future-read-1]foo" (func (;38;) (type 4))) (import "foo:foo/bar" "[future-write-1]foo" (func (;39;) (type 4))) (import "foo:foo/bar" "[future-cancel-read-1]foo" (func (;40;) (type 2))) (import "foo:foo/bar" "[future-cancel-write-1]foo" (func (;41;) (type 2))) - (import "foo:foo/bar" "[future-close-readable-1]foo" (func (;42;) (type 3))) - (import "foo:foo/bar" "[future-close-writable-1]foo" (func (;43;) (type 3))) + (import "foo:foo/bar" "[future-drop-readable-1]foo" (func (;42;) (type 3))) + (import "foo:foo/bar" "[future-drop-writable-1]foo" (func (;43;) (type 3))) (import "[export]$root" "[stream-new-2]foo" (func (;44;) (type 1))) (import "[export]$root" "[stream-read-2]foo" (func (;45;) (type 0))) (import "[export]$root" "[stream-write-2]foo" (func (;46;) (type 0))) (import "[export]$root" "[stream-cancel-read-2]foo" (func (;47;) (type 2))) (import "[export]$root" "[stream-cancel-write-2]foo" (func (;48;) (type 2))) - (import "[export]$root" "[stream-close-readable-2]foo" (func (;49;) (type 3))) - (import "[export]$root" "[stream-close-writable-2]foo" (func (;50;) (type 3))) + (import "[export]$root" "[stream-drop-readable-2]foo" (func (;49;) (type 3))) + (import "[export]$root" "[stream-drop-writable-2]foo" (func (;50;) (type 3))) (import "[export]foo:foo/bar" "[stream-new-2]foo" (func (;51;) (type 1))) (import "[export]foo:foo/bar" "[stream-read-2]foo" (func (;52;) (type 0))) (import "[export]foo:foo/bar" "[stream-write-2]foo" (func (;53;) (type 0))) (import "[export]foo:foo/bar" "[stream-cancel-read-2]foo" (func (;54;) (type 2))) (import "[export]foo:foo/bar" "[stream-cancel-write-2]foo" (func (;55;) (type 2))) - (import "[export]foo:foo/bar" "[stream-close-readable-2]foo" (func (;56;) (type 3))) - (import "[export]foo:foo/bar" "[stream-close-writable-2]foo" (func (;57;) (type 3))) + (import "[export]foo:foo/bar" "[stream-drop-readable-2]foo" (func (;56;) (type 3))) + (import "[export]foo:foo/bar" "[stream-drop-writable-2]foo" (func (;57;) (type 3))) (import "[export]$root" "[future-new-0]foo" (func (;58;) (type 1))) (import "[export]$root" "[future-read-0]foo" (func (;59;) (type 4))) (import "[export]$root" "[future-write-0]foo" (func (;60;) (type 4))) (import "[export]$root" "[future-cancel-read-0]foo" (func (;61;) (type 2))) (import "[export]$root" "[future-cancel-write-0]foo" (func (;62;) (type 2))) - (import "[export]$root" "[future-close-readable-0]foo" (func (;63;) (type 3))) - (import "[export]$root" "[future-close-writable-0]foo" (func (;64;) (type 3))) + (import "[export]$root" "[future-drop-readable-0]foo" (func (;63;) (type 3))) + (import "[export]$root" "[future-drop-writable-0]foo" (func (;64;) (type 3))) (import "[export]foo:foo/bar" "[future-new-0]foo" (func (;65;) (type 1))) (import "[export]foo:foo/bar" "[future-read-0]foo" (func (;66;) (type 4))) (import "[export]foo:foo/bar" "[future-write-0]foo" (func (;67;) (type 4))) (import "[export]foo:foo/bar" "[future-cancel-read-0]foo" (func (;68;) (type 2))) (import "[export]foo:foo/bar" "[future-cancel-write-0]foo" (func (;69;) (type 2))) - (import "[export]foo:foo/bar" "[future-close-readable-0]foo" (func (;70;) (type 3))) - (import "[export]foo:foo/bar" "[future-close-writable-0]foo" (func (;71;) (type 3))) + (import "[export]foo:foo/bar" "[future-drop-readable-0]foo" (func (;70;) (type 3))) + (import "[export]foo:foo/bar" "[future-drop-writable-0]foo" (func (;71;) (type 3))) (import "[export]$root" "[future-new-1]foo" (func (;72;) (type 1))) (import "[export]$root" "[future-read-1]foo" (func (;73;) (type 4))) (import "[export]$root" "[future-write-1]foo" (func (;74;) (type 4))) (import "[export]$root" "[future-cancel-read-1]foo" (func (;75;) (type 2))) (import "[export]$root" "[future-cancel-write-1]foo" (func (;76;) (type 2))) - (import "[export]$root" "[future-close-readable-1]foo" (func (;77;) (type 3))) - (import "[export]$root" "[future-close-writable-1]foo" (func (;78;) (type 3))) + (import "[export]$root" "[future-drop-readable-1]foo" (func (;77;) (type 3))) + (import "[export]$root" "[future-drop-writable-1]foo" (func (;78;) (type 3))) (import "[export]foo:foo/bar" "[future-new-1]foo" (func (;79;) (type 1))) (import "[export]foo:foo/bar" "[future-read-1]foo" (func (;80;) (type 4))) (import "[export]foo:foo/bar" "[future-write-1]foo" (func (;81;) (type 4))) (import "[export]foo:foo/bar" "[future-cancel-read-1]foo" (func (;82;) (type 2))) (import "[export]foo:foo/bar" "[future-cancel-write-1]foo" (func (;83;) (type 2))) - (import "[export]foo:foo/bar" "[future-close-readable-1]foo" (func (;84;) (type 3))) - (import "[export]foo:foo/bar" "[future-close-writable-1]foo" (func (;85;) (type 3))) + (import "[export]foo:foo/bar" "[future-drop-readable-1]foo" (func (;84;) (type 3))) + (import "[export]foo:foo/bar" "[future-drop-writable-1]foo" (func (;85;) (type 3))) (memory (;0;) 1) (export "[async-lift-stackful]foo" (func 86)) (export "[async-lift-stackful]foo:foo/bar#foo" (func 87)) @@ -372,22 +372,22 @@ (alias core export 0 "2" (core func (;3;))) (core func (;4;) (canon stream.cancel-read 3)) (core func (;5;) (canon stream.cancel-write 3)) - (core func (;6;) (canon stream.close-readable 3)) - (core func (;7;) (canon stream.close-writable 3)) + (core func (;6;) (canon stream.drop-readable 3)) + (core func (;7;) (canon stream.drop-writable 3)) (core func (;8;) (canon future.new 1)) (alias core export 0 "3" (core func (;9;))) (alias core export 0 "4" (core func (;10;))) (core func (;11;) (canon future.cancel-read 1)) (core func (;12;) (canon future.cancel-write 1)) - (core func (;13;) (canon future.close-readable 1)) - (core func (;14;) (canon future.close-writable 1)) + (core func (;13;) (canon future.drop-readable 1)) + (core func (;14;) (canon future.drop-writable 1)) (core func (;15;) (canon future.new 2)) (alias core export 0 "5" (core func (;16;))) (alias core export 0 "6" (core func (;17;))) (core func (;18;) (canon future.cancel-read 2)) (core func (;19;) (canon future.cancel-write 2)) - (core func (;20;) (canon future.close-readable 2)) - (core func (;21;) (canon future.close-writable 2)) + (core func (;20;) (canon future.drop-readable 2)) + (core func (;21;) (canon future.drop-writable 2)) (core instance (;1;) (export "[async-lower]foo" (func 0)) (export "[stream-new-2]foo" (func 1)) @@ -395,22 +395,22 @@ (export "[stream-write-2]foo" (func 3)) (export "[stream-cancel-read-2]foo" (func 4)) (export "[stream-cancel-write-2]foo" (func 5)) - (export "[stream-close-readable-2]foo" (func 6)) - (export "[stream-close-writable-2]foo" (func 7)) + (export "[stream-drop-readable-2]foo" (func 6)) + (export "[stream-drop-writable-2]foo" (func 7)) (export "[future-new-0]foo" (func 8)) (export "[future-read-0]foo" (func 9)) (export "[future-write-0]foo" (func 10)) (export "[future-cancel-read-0]foo" (func 11)) (export "[future-cancel-write-0]foo" (func 12)) - (export "[future-close-readable-0]foo" (func 13)) - (export "[future-close-writable-0]foo" (func 14)) + (export "[future-drop-readable-0]foo" (func 13)) + (export "[future-drop-writable-0]foo" (func 14)) (export "[future-new-1]foo" (func 15)) (export "[future-read-1]foo" (func 16)) (export "[future-write-1]foo" (func 17)) (export "[future-cancel-read-1]foo" (func 18)) (export "[future-cancel-write-1]foo" (func 19)) - (export "[future-close-readable-1]foo" (func 20)) - (export "[future-close-writable-1]foo" (func 21)) + (export "[future-drop-readable-1]foo" (func 20)) + (export "[future-drop-writable-1]foo" (func 21)) ) (alias core export 0 "7" (core func (;22;))) (core func (;23;) (canon stream.new 3)) @@ -418,23 +418,23 @@ (alias core export 0 "9" (core func (;25;))) (core func (;26;) (canon stream.cancel-read 3)) (core func (;27;) (canon stream.cancel-write 3)) - (core func (;28;) (canon stream.close-readable 3)) - (core func (;29;) (canon stream.close-writable 3)) + (core func (;28;) (canon stream.drop-readable 3)) + (core func (;29;) (canon stream.drop-writable 3)) (core func (;30;) (canon future.new 1)) (alias core export 0 "10" (core func (;31;))) (alias core export 0 "11" (core func (;32;))) (core func (;33;) (canon future.cancel-read 1)) (core func (;34;) (canon future.cancel-write 1)) - (core func (;35;) (canon future.close-readable 1)) - (core func (;36;) (canon future.close-writable 1)) + (core func (;35;) (canon future.drop-readable 1)) + (core func (;36;) (canon future.drop-writable 1)) (type (;5;) (future 1)) (core func (;37;) (canon future.new 5)) (alias core export 0 "12" (core func (;38;))) (alias core export 0 "13" (core func (;39;))) (core func (;40;) (canon future.cancel-read 5)) (core func (;41;) (canon future.cancel-write 5)) - (core func (;42;) (canon future.close-readable 5)) - (core func (;43;) (canon future.close-writable 5)) + (core func (;42;) (canon future.drop-readable 5)) + (core func (;43;) (canon future.drop-writable 5)) (core instance (;2;) (export "[async-lower]foo" (func 22)) (export "[stream-new-2]foo" (func 23)) @@ -442,66 +442,66 @@ (export "[stream-write-2]foo" (func 25)) (export "[stream-cancel-read-2]foo" (func 26)) (export "[stream-cancel-write-2]foo" (func 27)) - (export "[stream-close-readable-2]foo" (func 28)) - (export "[stream-close-writable-2]foo" (func 29)) + (export "[stream-drop-readable-2]foo" (func 28)) + (export "[stream-drop-writable-2]foo" (func 29)) (export "[future-new-0]foo" (func 30)) (export "[future-read-0]foo" (func 31)) (export "[future-write-0]foo" (func 32)) (export "[future-cancel-read-0]foo" (func 33)) (export "[future-cancel-write-0]foo" (func 34)) - (export "[future-close-readable-0]foo" (func 35)) - (export "[future-close-writable-0]foo" (func 36)) + (export "[future-drop-readable-0]foo" (func 35)) + (export "[future-drop-writable-0]foo" (func 36)) (export "[future-new-1]foo" (func 37)) (export "[future-read-1]foo" (func 38)) (export "[future-write-1]foo" (func 39)) (export "[future-cancel-read-1]foo" (func 40)) (export "[future-cancel-write-1]foo" (func 41)) - (export "[future-close-readable-1]foo" (func 42)) - (export "[future-close-writable-1]foo" (func 43)) + (export "[future-drop-readable-1]foo" (func 42)) + (export "[future-drop-writable-1]foo" (func 43)) ) (core func (;44;) (canon stream.new 3)) (alias core export 0 "14" (core func (;45;))) (alias core export 0 "15" (core func (;46;))) (core func (;47;) (canon stream.cancel-read 3)) (core func (;48;) (canon stream.cancel-write 3)) - (core func (;49;) (canon stream.close-readable 3)) - (core func (;50;) (canon stream.close-writable 3)) + (core func (;49;) (canon stream.drop-readable 3)) + (core func (;50;) (canon stream.drop-writable 3)) (core func (;51;) (canon future.new 1)) (alias core export 0 "16" (core func (;52;))) (alias core export 0 "17" (core func (;53;))) (core func (;54;) (canon future.cancel-read 1)) (core func (;55;) (canon future.cancel-write 1)) - (core func (;56;) (canon future.close-readable 1)) - (core func (;57;) (canon future.close-writable 1)) + (core func (;56;) (canon future.drop-readable 1)) + (core func (;57;) (canon future.drop-writable 1)) (core func (;58;) (canon future.new 2)) (alias core export 0 "18" (core func (;59;))) (alias core export 0 "19" (core func (;60;))) (core func (;61;) (canon future.cancel-read 2)) (core func (;62;) (canon future.cancel-write 2)) - (core func (;63;) (canon future.close-readable 2)) - (core func (;64;) (canon future.close-writable 2)) + (core func (;63;) (canon future.drop-readable 2)) + (core func (;64;) (canon future.drop-writable 2)) (core instance (;3;) (export "[stream-new-2]foo" (func 44)) (export "[stream-read-2]foo" (func 45)) (export "[stream-write-2]foo" (func 46)) (export "[stream-cancel-read-2]foo" (func 47)) (export "[stream-cancel-write-2]foo" (func 48)) - (export "[stream-close-readable-2]foo" (func 49)) - (export "[stream-close-writable-2]foo" (func 50)) + (export "[stream-drop-readable-2]foo" (func 49)) + (export "[stream-drop-writable-2]foo" (func 50)) (export "[future-new-0]foo" (func 51)) (export "[future-read-0]foo" (func 52)) (export "[future-write-0]foo" (func 53)) (export "[future-cancel-read-0]foo" (func 54)) (export "[future-cancel-write-0]foo" (func 55)) - (export "[future-close-readable-0]foo" (func 56)) - (export "[future-close-writable-0]foo" (func 57)) + (export "[future-drop-readable-0]foo" (func 56)) + (export "[future-drop-writable-0]foo" (func 57)) (export "[future-new-1]foo" (func 58)) (export "[future-read-1]foo" (func 59)) (export "[future-write-1]foo" (func 60)) (export "[future-cancel-read-1]foo" (func 61)) (export "[future-cancel-write-1]foo" (func 62)) - (export "[future-close-readable-1]foo" (func 63)) - (export "[future-close-writable-1]foo" (func 64)) + (export "[future-drop-readable-1]foo" (func 63)) + (export "[future-drop-writable-1]foo" (func 64)) ) (type (;6;) (stream string)) (core func (;65;) (canon stream.new 6)) @@ -509,46 +509,46 @@ (alias core export 0 "21" (core func (;67;))) (core func (;68;) (canon stream.cancel-read 6)) (core func (;69;) (canon stream.cancel-write 6)) - (core func (;70;) (canon stream.close-readable 6)) - (core func (;71;) (canon stream.close-writable 6)) + (core func (;70;) (canon stream.drop-readable 6)) + (core func (;71;) (canon stream.drop-writable 6)) (type (;7;) (future u32)) (core func (;72;) (canon future.new 7)) (alias core export 0 "22" (core func (;73;))) (alias core export 0 "23" (core func (;74;))) (core func (;75;) (canon future.cancel-read 7)) (core func (;76;) (canon future.cancel-write 7)) - (core func (;77;) (canon future.close-readable 7)) - (core func (;78;) (canon future.close-writable 7)) + (core func (;77;) (canon future.drop-readable 7)) + (core func (;78;) (canon future.drop-writable 7)) (type (;8;) (future 7)) (core func (;79;) (canon future.new 8)) (alias core export 0 "24" (core func (;80;))) (alias core export 0 "25" (core func (;81;))) (core func (;82;) (canon future.cancel-read 8)) (core func (;83;) (canon future.cancel-write 8)) - (core func (;84;) (canon future.close-readable 8)) - (core func (;85;) (canon future.close-writable 8)) + (core func (;84;) (canon future.drop-readable 8)) + (core func (;85;) (canon future.drop-writable 8)) (core instance (;4;) (export "[stream-new-2]foo" (func 65)) (export "[stream-read-2]foo" (func 66)) (export "[stream-write-2]foo" (func 67)) (export "[stream-cancel-read-2]foo" (func 68)) (export "[stream-cancel-write-2]foo" (func 69)) - (export "[stream-close-readable-2]foo" (func 70)) - (export "[stream-close-writable-2]foo" (func 71)) + (export "[stream-drop-readable-2]foo" (func 70)) + (export "[stream-drop-writable-2]foo" (func 71)) (export "[future-new-0]foo" (func 72)) (export "[future-read-0]foo" (func 73)) (export "[future-write-0]foo" (func 74)) (export "[future-cancel-read-0]foo" (func 75)) (export "[future-cancel-write-0]foo" (func 76)) - (export "[future-close-readable-0]foo" (func 77)) - (export "[future-close-writable-0]foo" (func 78)) + (export "[future-drop-readable-0]foo" (func 77)) + (export "[future-drop-writable-0]foo" (func 78)) (export "[future-new-1]foo" (func 79)) (export "[future-read-1]foo" (func 80)) (export "[future-write-1]foo" (func 81)) (export "[future-cancel-read-1]foo" (func 82)) (export "[future-cancel-write-1]foo" (func 83)) - (export "[future-close-readable-1]foo" (func 84)) - (export "[future-close-writable-1]foo" (func 85)) + (export "[future-drop-readable-1]foo" (func 84)) + (export "[future-drop-writable-1]foo" (func 85)) ) (core instance (;5;) (instantiate 0 (with "$root" (instance 1)) diff --git a/crates/wit-component/tests/components/async-streams-and-futures/module.wat b/crates/wit-component/tests/components/async-streams-and-futures/module.wat index 60fe1bf35d..f48d93e8eb 100644 --- a/crates/wit-component/tests/components/async-streams-and-futures/module.wat +++ b/crates/wit-component/tests/components/async-streams-and-futures/module.wat @@ -6,85 +6,85 @@ (func (import "$root" "[stream-write-2]foo") (param i32 i32 i32) (result i32)) (func (import "$root" "[stream-cancel-read-2]foo") (param i32) (result i32)) (func (import "$root" "[stream-cancel-write-2]foo") (param i32) (result i32)) - (func (import "$root" "[stream-close-readable-2]foo") (param i32)) - (func (import "$root" "[stream-close-writable-2]foo") (param i32)) + (func (import "$root" "[stream-drop-readable-2]foo") (param i32)) + (func (import "$root" "[stream-drop-writable-2]foo") (param i32)) (func (import "foo:foo/bar" "[stream-new-2]foo") (result i64)) (func (import "foo:foo/bar" "[stream-read-2]foo") (param i32 i32 i32) (result i32)) (func (import "foo:foo/bar" "[stream-write-2]foo") (param i32 i32 i32) (result i32)) (func (import "foo:foo/bar" "[stream-cancel-read-2]foo") (param i32) (result i32)) (func (import "foo:foo/bar" "[stream-cancel-write-2]foo") (param i32) (result i32)) - (func (import "foo:foo/bar" "[stream-close-readable-2]foo") (param i32)) - (func (import "foo:foo/bar" "[stream-close-writable-2]foo") (param i32)) + (func (import "foo:foo/bar" "[stream-drop-readable-2]foo") (param i32)) + (func (import "foo:foo/bar" "[stream-drop-writable-2]foo") (param i32)) (func (import "$root" "[future-new-0]foo") (result i64)) (func (import "$root" "[future-read-0]foo") (param i32 i32) (result i32)) (func (import "$root" "[future-write-0]foo") (param i32 i32) (result i32)) (func (import "$root" "[future-cancel-read-0]foo") (param i32) (result i32)) (func (import "$root" "[future-cancel-write-0]foo") (param i32) (result i32)) - (func (import "$root" "[future-close-readable-0]foo") (param i32)) - (func (import "$root" "[future-close-writable-0]foo") (param i32)) + (func (import "$root" "[future-drop-readable-0]foo") (param i32)) + (func (import "$root" "[future-drop-writable-0]foo") (param i32)) (func (import "foo:foo/bar" "[future-new-0]foo") (result i64)) (func (import "foo:foo/bar" "[future-read-0]foo") (param i32 i32) (result i32)) (func (import "foo:foo/bar" "[future-write-0]foo") (param i32 i32) (result i32)) (func (import "foo:foo/bar" "[future-cancel-read-0]foo") (param i32) (result i32)) (func (import "foo:foo/bar" "[future-cancel-write-0]foo") (param i32) (result i32)) - (func (import "foo:foo/bar" "[future-close-readable-0]foo") (param i32)) - (func (import "foo:foo/bar" "[future-close-writable-0]foo") (param i32)) + (func (import "foo:foo/bar" "[future-drop-readable-0]foo") (param i32)) + (func (import "foo:foo/bar" "[future-drop-writable-0]foo") (param i32)) (func (import "$root" "[future-new-1]foo") (result i64)) (func (import "$root" "[future-read-1]foo") (param i32 i32) (result i32)) (func (import "$root" "[future-write-1]foo") (param i32 i32) (result i32)) (func (import "$root" "[future-cancel-read-1]foo") (param i32) (result i32)) (func (import "$root" "[future-cancel-write-1]foo") (param i32) (result i32)) - (func (import "$root" "[future-close-readable-1]foo") (param i32)) - (func (import "$root" "[future-close-writable-1]foo") (param i32)) + (func (import "$root" "[future-drop-readable-1]foo") (param i32)) + (func (import "$root" "[future-drop-writable-1]foo") (param i32)) (func (import "foo:foo/bar" "[future-new-1]foo") (result i64)) (func (import "foo:foo/bar" "[future-read-1]foo") (param i32 i32) (result i32)) (func (import "foo:foo/bar" "[future-write-1]foo") (param i32 i32) (result i32)) (func (import "foo:foo/bar" "[future-cancel-read-1]foo") (param i32) (result i32)) (func (import "foo:foo/bar" "[future-cancel-write-1]foo") (param i32) (result i32)) - (func (import "foo:foo/bar" "[future-close-readable-1]foo") (param i32)) - (func (import "foo:foo/bar" "[future-close-writable-1]foo") (param i32)) + (func (import "foo:foo/bar" "[future-drop-readable-1]foo") (param i32)) + (func (import "foo:foo/bar" "[future-drop-writable-1]foo") (param i32)) (func (import "[export]$root" "[stream-new-2]foo") (result i64)) (func (import "[export]$root" "[stream-read-2]foo") (param i32 i32 i32) (result i32)) (func (import "[export]$root" "[stream-write-2]foo") (param i32 i32 i32) (result i32)) (func (import "[export]$root" "[stream-cancel-read-2]foo") (param i32) (result i32)) (func (import "[export]$root" "[stream-cancel-write-2]foo") (param i32) (result i32)) - (func (import "[export]$root" "[stream-close-readable-2]foo") (param i32)) - (func (import "[export]$root" "[stream-close-writable-2]foo") (param i32)) + (func (import "[export]$root" "[stream-drop-readable-2]foo") (param i32)) + (func (import "[export]$root" "[stream-drop-writable-2]foo") (param i32)) (func (import "[export]foo:foo/bar" "[stream-new-2]foo") (result i64)) (func (import "[export]foo:foo/bar" "[stream-read-2]foo") (param i32 i32 i32) (result i32)) (func (import "[export]foo:foo/bar" "[stream-write-2]foo") (param i32 i32 i32) (result i32)) (func (import "[export]foo:foo/bar" "[stream-cancel-read-2]foo") (param i32) (result i32)) (func (import "[export]foo:foo/bar" "[stream-cancel-write-2]foo") (param i32) (result i32)) - (func (import "[export]foo:foo/bar" "[stream-close-readable-2]foo") (param i32)) - (func (import "[export]foo:foo/bar" "[stream-close-writable-2]foo") (param i32)) + (func (import "[export]foo:foo/bar" "[stream-drop-readable-2]foo") (param i32)) + (func (import "[export]foo:foo/bar" "[stream-drop-writable-2]foo") (param i32)) (func (import "[export]$root" "[future-new-0]foo") (result i64)) (func (import "[export]$root" "[future-read-0]foo") (param i32 i32) (result i32)) (func (import "[export]$root" "[future-write-0]foo") (param i32 i32) (result i32)) (func (import "[export]$root" "[future-cancel-read-0]foo") (param i32) (result i32)) (func (import "[export]$root" "[future-cancel-write-0]foo") (param i32) (result i32)) - (func (import "[export]$root" "[future-close-readable-0]foo") (param i32)) - (func (import "[export]$root" "[future-close-writable-0]foo") (param i32)) + (func (import "[export]$root" "[future-drop-readable-0]foo") (param i32)) + (func (import "[export]$root" "[future-drop-writable-0]foo") (param i32)) (func (import "[export]foo:foo/bar" "[future-new-0]foo") (result i64)) (func (import "[export]foo:foo/bar" "[future-read-0]foo") (param i32 i32) (result i32)) (func (import "[export]foo:foo/bar" "[future-write-0]foo") (param i32 i32) (result i32)) (func (import "[export]foo:foo/bar" "[future-cancel-read-0]foo") (param i32) (result i32)) (func (import "[export]foo:foo/bar" "[future-cancel-write-0]foo") (param i32) (result i32)) - (func (import "[export]foo:foo/bar" "[future-close-readable-0]foo") (param i32)) - (func (import "[export]foo:foo/bar" "[future-close-writable-0]foo") (param i32)) + (func (import "[export]foo:foo/bar" "[future-drop-readable-0]foo") (param i32)) + (func (import "[export]foo:foo/bar" "[future-drop-writable-0]foo") (param i32)) (func (import "[export]$root" "[future-new-1]foo") (result i64)) (func (import "[export]$root" "[future-read-1]foo") (param i32 i32) (result i32)) (func (import "[export]$root" "[future-write-1]foo") (param i32 i32) (result i32)) (func (import "[export]$root" "[future-cancel-read-1]foo") (param i32) (result i32)) (func (import "[export]$root" "[future-cancel-write-1]foo") (param i32) (result i32)) - (func (import "[export]$root" "[future-close-readable-1]foo") (param i32)) - (func (import "[export]$root" "[future-close-writable-1]foo") (param i32)) + (func (import "[export]$root" "[future-drop-readable-1]foo") (param i32)) + (func (import "[export]$root" "[future-drop-writable-1]foo") (param i32)) (func (import "[export]foo:foo/bar" "[future-new-1]foo") (result i64)) (func (import "[export]foo:foo/bar" "[future-read-1]foo") (param i32 i32) (result i32)) (func (import "[export]foo:foo/bar" "[future-write-1]foo") (param i32 i32) (result i32)) (func (import "[export]foo:foo/bar" "[future-cancel-read-1]foo") (param i32) (result i32)) (func (import "[export]foo:foo/bar" "[future-cancel-write-1]foo") (param i32) (result i32)) - (func (import "[export]foo:foo/bar" "[future-close-readable-1]foo") (param i32)) - (func (import "[export]foo:foo/bar" "[future-close-writable-1]foo") (param i32)) + (func (import "[export]foo:foo/bar" "[future-drop-readable-1]foo") (param i32)) + (func (import "[export]foo:foo/bar" "[future-drop-writable-1]foo") (param i32)) (func (export "[async-lift-stackful]foo") (param i32 i32) unreachable) (func (export "[async-lift-stackful]foo:foo/bar#foo") (param i32 i32) unreachable) (memory (export "memory") 1) diff --git a/crates/wit-parser/src/abi.rs b/crates/wit-parser/src/abi.rs index 8c69db34d8..a0260e8611 100644 --- a/crates/wit-parser/src/abi.rs +++ b/crates/wit-parser/src/abi.rs @@ -1,4 +1,5 @@ -use crate::{Function, Handle, Int, Resolve, Type, TypeDefKind}; +use crate::{Function, FunctionKind, Handle, Int, Resolve, Stability, Type, TypeDefKind}; +use core::iter; /// A core WebAssembly signature with params and results. #[derive(Clone, Debug, Hash, Eq, PartialEq, PartialOrd, Ord)] @@ -274,6 +275,28 @@ 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) -> 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, diff --git a/src/bin/wasm-tools/dump.rs b/src/bin/wasm-tools/dump.rs index ec218f8f08..8e6a3e4ea9 100644 --- a/src/bin/wasm-tools/dump.rs +++ b/src/bin/wasm-tools/dump.rs @@ -440,15 +440,15 @@ impl<'a> Dump<'a> { | CanonicalFunction::StreamWrite { .. } | CanonicalFunction::StreamCancelRead { .. } | CanonicalFunction::StreamCancelWrite { .. } - | CanonicalFunction::StreamCloseReadable { .. } - | CanonicalFunction::StreamCloseWritable { .. } + | CanonicalFunction::StreamDropReadable { .. } + | CanonicalFunction::StreamDropWritable { .. } | CanonicalFunction::FutureNew { .. } | CanonicalFunction::FutureRead { .. } | CanonicalFunction::FutureWrite { .. } | CanonicalFunction::FutureCancelRead { .. } | CanonicalFunction::FutureCancelWrite { .. } - | CanonicalFunction::FutureCloseReadable { .. } - | CanonicalFunction::FutureCloseWritable { .. } + | CanonicalFunction::FutureDropReadable { .. } + | CanonicalFunction::FutureDropWritable { .. } | CanonicalFunction::ErrorContextNew { .. } | CanonicalFunction::ErrorContextDebugMessage { .. } | CanonicalFunction::ErrorContextDrop => { diff --git a/tests/cli/component-model-async/futures.wast b/tests/cli/component-model-async/futures.wast index 6af20fc2bc..c36d96d0ea 100644 --- a/tests/cli/component-model-async/futures.wast +++ b/tests/cli/component-model-async/futures.wast @@ -35,6 +35,18 @@ (core instance $i (instantiate $m (with "" (instance (export "future.read" (func $future-read)))))) ) +;; 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))) + ) + (type $future-type (future)) + (core func $future-read (canon future.read $future-type async)) + (core instance $i (instantiate $m (with "" (instance (export "future.read" (func $future-read)))))) +) + ;; future.read; with realloc (component (core module $libc @@ -103,6 +115,42 @@ (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 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))) + ) + (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)))))) ) @@ -168,48 +216,48 @@ "type mismatch for export `future.cancel-write` of module instantiation argument ``" ) -;; future.close-readable +;; future.drop-readable (component (core module $m - (import "" "future.close-readable" (func $future-close-readable (param i32))) + (import "" "future.drop-readable" (func $future-drop-readable (param i32))) ) (type $future-type (future u8)) - (core func $future-close-readable (canon future.close-readable $future-type)) - (core instance $i (instantiate $m (with "" (instance (export "future.close-readable" (func $future-close-readable)))))) + (core func $future-drop-readable (canon future.drop-readable $future-type)) + (core instance $i (instantiate $m (with "" (instance (export "future.drop-readable" (func $future-drop-readable)))))) ) -;; future.close-readable; incorrect type +;; future.drop-readable; incorrect type (assert_invalid (component (core module $m - (import "" "future.close-readable" (func $future-close-readable (param i32) (result i32))) + (import "" "future.drop-readable" (func $future-drop-readable (param i32) (result i32))) ) (type $future-type (future u8)) - (core func $future-close-readable (canon future.close-readable $future-type)) - (core instance $i (instantiate $m (with "" (instance (export "future.close-readable" (func $future-close-readable)))))) + (core func $future-drop-readable (canon future.drop-readable $future-type)) + (core instance $i (instantiate $m (with "" (instance (export "future.drop-readable" (func $future-drop-readable)))))) ) - "type mismatch for export `future.close-readable` of module instantiation argument ``" + "type mismatch for export `future.drop-readable` of module instantiation argument ``" ) -;; future.close-writable +;; future.drop-writable (component (core module $m - (import "" "future.close-writable" (func $future-close-writable (param i32))) + (import "" "future.drop-writable" (func $future-drop-writable (param i32))) ) (type $future-type (future u8)) - (core func $future-close-writable (canon future.close-writable $future-type)) - (core instance $i (instantiate $m (with "" (instance (export "future.close-writable" (func $future-close-writable)))))) + (core func $future-drop-writable (canon future.drop-writable $future-type)) + (core instance $i (instantiate $m (with "" (instance (export "future.drop-writable" (func $future-drop-writable)))))) ) -;; future.close-writable; incorrect type +;; future.drop-writable; incorrect type (assert_invalid (component (core module $m - (import "" "future.close-writable" (func $future-close-writable (param i32 i32) (result i32))) + (import "" "future.drop-writable" (func $future-drop-writable (param i32 i32) (result i32))) ) (type $future-type (future u8)) - (core func $future-close-writable (canon future.close-writable $future-type)) - (core instance $i (instantiate $m (with "" (instance (export "future.close-writable" (func $future-close-writable)))))) + (core func $future-drop-writable (canon future.drop-writable $future-type)) + (core instance $i (instantiate $m (with "" (instance (export "future.drop-writable" (func $future-drop-writable)))))) ) - "type mismatch for export `future.close-writable` of module instantiation argument ``" + "type mismatch for export `future.drop-writable` of module instantiation argument ``" ) diff --git a/tests/cli/component-model-async/streams.wast b/tests/cli/component-model-async/streams.wast index 548bb3cddb..19a111dd84 100644 --- a/tests/cli/component-model-async/streams.wast +++ b/tests/cli/component-model-async/streams.wast @@ -168,48 +168,48 @@ "type mismatch for export `stream.cancel-write` of module instantiation argument ``" ) -;; stream.close-readable +;; stream.drop-readable (component (core module $m - (import "" "stream.close-readable" (func $stream-close-readable (param i32))) + (import "" "stream.drop-readable" (func $stream-drop-readable (param i32))) ) (type $stream-type (stream u8)) - (core func $stream-close-readable (canon stream.close-readable $stream-type)) - (core instance $i (instantiate $m (with "" (instance (export "stream.close-readable" (func $stream-close-readable)))))) + (core func $stream-drop-readable (canon stream.drop-readable $stream-type)) + (core instance $i (instantiate $m (with "" (instance (export "stream.drop-readable" (func $stream-drop-readable)))))) ) -;; stream.close-readable; incorrect type +;; stream.drop-readable; incorrect type (assert_invalid (component (core module $m - (import "" "stream.close-readable" (func $stream-close-readable (param i32) (result i32))) + (import "" "stream.drop-readable" (func $stream-drop-readable (param i32) (result i32))) ) (type $stream-type (stream u8)) - (core func $stream-close-readable (canon stream.close-readable $stream-type)) - (core instance $i (instantiate $m (with "" (instance (export "stream.close-readable" (func $stream-close-readable)))))) + (core func $stream-drop-readable (canon stream.drop-readable $stream-type)) + (core instance $i (instantiate $m (with "" (instance (export "stream.drop-readable" (func $stream-drop-readable)))))) ) - "type mismatch for export `stream.close-readable` of module instantiation argument ``" + "type mismatch for export `stream.drop-readable` of module instantiation argument ``" ) -;; stream.close-writable +;; stream.drop-writable (component (core module $m - (import "" "stream.close-writable" (func $stream-close-writable (param i32))) + (import "" "stream.drop-writable" (func $stream-drop-writable (param i32))) ) (type $stream-type (stream u8)) - (core func $stream-close-writable (canon stream.close-writable $stream-type)) - (core instance $i (instantiate $m (with "" (instance (export "stream.close-writable" (func $stream-close-writable)))))) + (core func $stream-drop-writable (canon stream.drop-writable $stream-type)) + (core instance $i (instantiate $m (with "" (instance (export "stream.drop-writable" (func $stream-drop-writable)))))) ) -;; stream.close-writable; incorrect type +;; stream.drop-writable; incorrect type (assert_invalid (component (core module $m - (import "" "stream.close-writable" (func $stream-close-writable (param i32 i32) (result i32))) + (import "" "stream.drop-writable" (func $stream-drop-writable (param i32 i32) (result i32))) ) (type $stream-type (stream u8)) - (core func $stream-close-writable (canon stream.close-writable $stream-type)) - (core instance $i (instantiate $m (with "" (instance (export "stream.close-writable" (func $stream-close-writable)))))) + (core func $stream-drop-writable (canon stream.drop-writable $stream-type)) + (core instance $i (instantiate $m (with "" (instance (export "stream.drop-writable" (func $stream-drop-writable)))))) ) - "type mismatch for export `stream.close-writable` of module instantiation argument ``" + "type mismatch for export `stream.drop-writable` of module instantiation argument ``" ) diff --git a/tests/cli/component-model-async/task-builtins.wast b/tests/cli/component-model-async/task-builtins.wast index 5399862391..47795fe36a 100644 --- a/tests/cli/component-model-async/task-builtins.wast +++ b/tests/cli/component-model-async/task-builtins.wast @@ -355,14 +355,14 @@ (canon future.cancel-write $f (core func)) (core func (canon stream.cancel-write $s)) (canon stream.cancel-write $s (core func)) - (core func (canon future.close-readable $f)) - (canon future.close-readable $f (core func)) - (core func (canon future.close-writable $f)) - (canon future.close-writable $f (core func)) - (core func (canon stream.close-readable $s)) - (canon stream.close-readable $s (core func)) - (core func (canon stream.close-writable $s)) - (canon stream.close-writable $s (core func)) + (core func (canon future.drop-readable $f)) + (canon future.drop-readable $f (core func)) + (core func (canon future.drop-writable $f)) + (canon future.drop-writable $f (core func)) + (core func (canon stream.drop-readable $s)) + (canon stream.drop-readable $s (core func)) + (core func (canon stream.drop-writable $s)) + (canon stream.drop-writable $s (core func)) (core func (canon future.read $f (memory $m))) (canon future.read $f (memory $m) (core func)) (core func (canon future.write $f (memory $m))) diff --git a/tests/cli/missing-features/component-model/async.wast b/tests/cli/missing-features/component-model/async.wast index b6c0167a33..f12c644c0a 100644 --- a/tests/cli/missing-features/component-model/async.wast +++ b/tests/cli/missing-features/component-model/async.wast @@ -217,28 +217,28 @@ "requires the component model async feature" ) -;; stream.close-readable +;; stream.drop-readable (assert_invalid (component (core module $m - (import "" "stream.close-readable" (func $stream-close-readable (param i32))) + (import "" "stream.drop-readable" (func $stream-drop-readable (param i32))) ) (type $stream-type (stream u8)) - (core func $stream-close-readable (canon stream.close-readable $stream-type)) - (core instance $i (instantiate $m (with "" (instance (export "stream.close-readable" (func $stream-close-readable)))))) + (core func $stream-drop-readable (canon stream.drop-readable $stream-type)) + (core instance $i (instantiate $m (with "" (instance (export "stream.drop-readable" (func $stream-drop-readable)))))) ) "requires the component model async feature" ) -;; stream.close-writable +;; stream.drop-writable (assert_invalid (component (core module $m - (import "" "stream.close-writable" (func $stream-close-writable (param i32 i32))) + (import "" "stream.drop-writable" (func $stream-drop-writable (param i32 i32))) ) (type $stream-type (stream u8)) - (core func $stream-close-writable (canon stream.close-writable $stream-type)) - (core instance $i (instantiate $m (with "" (instance (export "stream.close-writable" (func $stream-close-writable)))))) + (core func $stream-drop-writable (canon stream.drop-writable $stream-type)) + (core instance $i (instantiate $m (with "" (instance (export "stream.drop-writable" (func $stream-drop-writable)))))) ) "requires the component model async feature" ) @@ -312,28 +312,28 @@ "requires the component model async feature" ) -;; future.close-readable +;; future.drop-readable (assert_invalid (component (core module $m - (import "" "future.close-readable" (func $future-close-readable (param i32))) + (import "" "future.drop-readable" (func $future-drop-readable (param i32))) ) (type $future-type (future u8)) - (core func $future-close-readable (canon future.close-readable $future-type)) - (core instance $i (instantiate $m (with "" (instance (export "future.close-readable" (func $future-close-readable)))))) + (core func $future-drop-readable (canon future.drop-readable $future-type)) + (core instance $i (instantiate $m (with "" (instance (export "future.drop-readable" (func $future-drop-readable)))))) ) "requires the component model async feature" ) -;; future.close-writable +;; future.drop-writable (assert_invalid (component (core module $m - (import "" "future.close-writable" (func $future-close-writable (param i32 i32))) + (import "" "future.drop-writable" (func $future-drop-writable (param i32 i32))) ) (type $future-type (future u8)) - (core func $future-close-writable (canon future.close-writable $future-type)) - (core instance $i (instantiate $m (with "" (instance (export "future.close-writable" (func $future-close-writable)))))) + (core func $future-drop-writable (canon future.drop-writable $future-type)) + (core instance $i (instantiate $m (with "" (instance (export "future.drop-writable" (func $future-drop-writable)))))) ) "requires the component model async feature" ) diff --git a/tests/snapshots/cli/component-model-async/futures.wast.json b/tests/snapshots/cli/component-model-async/futures.wast.json index 0b3c58bba2..180c4a2c19 100644 --- a/tests/snapshots/cli/component-model-async/futures.wast.json +++ b/tests/snapshots/cli/component-model-async/futures.wast.json @@ -27,55 +27,53 @@ "module_type": "binary" }, { - "type": "assert_invalid", - "line": 55, + "type": "module", + "line": 51, "filename": "futures.4.wasm", - "module_type": "binary", - "text": "type mismatch for export `future.read` of module instantiation argument ``" + "module_type": "binary" }, { "type": "assert_invalid", - "line": 70, + "line": 67, "filename": "futures.5.wasm", "module_type": "binary", - "text": "`future.read` requires a future type" + "text": "type mismatch for export `future.read` of module instantiation argument ``" }, { "type": "assert_invalid", - "line": 85, + "line": 82, "filename": "futures.6.wasm", "module_type": "binary", - "text": "canonical option `realloc` is required" + "text": "`future.read` requires a future type" }, { - "type": "module", - "line": 99, + "type": "assert_invalid", + "line": 97, "filename": "futures.7.wasm", - "module_type": "binary" + "module_type": "binary", + "text": "canonical option `realloc` is required" }, { - "type": "assert_invalid", - "line": 112, + "type": "module", + "line": 111, "filename": "futures.8.wasm", - "module_type": "binary", - "text": "type mismatch for export `future.write` of module instantiation argument ``" + "module_type": "binary" }, { "type": "module", - "line": 126, + "line": 123, "filename": "futures.9.wasm", "module_type": "binary" }, { - "type": "assert_invalid", - "line": 137, + "type": "module", + "line": 135, "filename": "futures.10.wasm", - "module_type": "binary", - "text": "type mismatch for export `future.cancel-read` of module instantiation argument ``" + "module_type": "binary" }, { "type": "module", - "line": 149, + "line": 147, "filename": "futures.11.wasm", "module_type": "binary" }, @@ -84,33 +82,59 @@ "line": 160, "filename": "futures.12.wasm", "module_type": "binary", - "text": "type mismatch for export `future.cancel-write` of module instantiation argument ``" + "text": "type mismatch for export `future.write` of module instantiation argument ``" }, { "type": "module", - "line": 172, + "line": 174, "filename": "futures.13.wasm", "module_type": "binary" }, { "type": "assert_invalid", - "line": 183, + "line": 185, "filename": "futures.14.wasm", "module_type": "binary", - "text": "type mismatch for export `future.close-readable` of module instantiation argument ``" + "text": "type mismatch for export `future.cancel-read` of module instantiation argument ``" }, { "type": "module", - "line": 195, + "line": 197, "filename": "futures.15.wasm", "module_type": "binary" }, { "type": "assert_invalid", - "line": 206, + "line": 208, "filename": "futures.16.wasm", "module_type": "binary", - "text": "type mismatch for export `future.close-writable` of module instantiation argument ``" + "text": "type mismatch for export `future.cancel-write` of module instantiation argument ``" + }, + { + "type": "module", + "line": 220, + "filename": "futures.17.wasm", + "module_type": "binary" + }, + { + "type": "assert_invalid", + "line": 231, + "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 ``" } ] } \ No newline at end of file diff --git a/tests/snapshots/cli/component-model-async/futures.wast/10.print b/tests/snapshots/cli/component-model-async/futures.wast/10.print new file mode 100644 index 0000000000..d7115584d0 --- /dev/null +++ b/tests/snapshots/cli/component-model-async/futures.wast/10.print @@ -0,0 +1,21 @@ +(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 6e15e579bb..42604c7867 100644 --- a/tests/snapshots/cli/component-model-async/futures.wast/11.print +++ b/tests/snapshots/cli/component-model-async/futures.wast/11.print @@ -1,15 +1,22 @@ (component - (core module $m (;0;) - (type (;0;) (func (param i32) (result i32))) - (import "" "future.cancel-write" (func $future-cancel-write (;0;) (type 0))) + (core module $libc (;0;) + (memory (;0;) 1) + (export "memory" (memory 0)) ) - (type $future-type (;0;) (future u8)) - (core func $future-cancel-write (;0;) (canon future.cancel-write $future-type async)) - (core instance (;0;) - (export "future.cancel-write" (func $future-cancel-write)) + (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))) ) - (core instance $i (;1;) (instantiate $m - (with "" (instance 0)) + (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)) ) ) ) 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 7754683368..443e958b83 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))) - (import "" "future.close-readable" (func $future-close-readable (;0;) (type 0))) + (type (;0;) (func (param i32) (result i32))) + (import "" "future.cancel-read" (func $future-cancel-read (;0;) (type 0))) ) (type $future-type (;0;) (future u8)) - (core func $future-close-readable (;0;) (canon future.close-readable $future-type)) + (core func $future-cancel-read (;0;) (canon future.cancel-read $future-type async)) (core instance (;0;) - (export "future.close-readable" (func $future-close-readable)) + (export "future.cancel-read" (func $future-cancel-read)) ) (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 09be84a876..6e15e579bb 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))) - (import "" "future.close-writable" (func $future-close-writable (;0;) (type 0))) + (type (;0;) (func (param i32) (result i32))) + (import "" "future.cancel-write" (func $future-cancel-write (;0;) (type 0))) ) (type $future-type (;0;) (future u8)) - (core func $future-close-writable (;0;) (canon future.close-writable $future-type)) + (core func $future-cancel-write (;0;) (canon future.cancel-write $future-type async)) (core instance (;0;) - (export "future.close-writable" (func $future-close-writable)) + (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/17.print b/tests/snapshots/cli/component-model-async/futures.wast/17.print new file mode 100644 index 0000000000..44088d009e --- /dev/null +++ b/tests/snapshots/cli/component-model-async/futures.wast/17.print @@ -0,0 +1,15 @@ +(component + (core module $m (;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-drop-readable (;0;) (canon future.drop-readable $future-type)) + (core instance (;0;) + (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/19.print b/tests/snapshots/cli/component-model-async/futures.wast/19.print new file mode 100644 index 0000000000..5adf6b22b1 --- /dev/null +++ b/tests/snapshots/cli/component-model-async/futures.wast/19.print @@ -0,0 +1,15 @@ +(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 d08dbedf8e..6dd6a4551e 100644 --- a/tests/snapshots/cli/component-model-async/futures.wast/3.print +++ b/tests/snapshots/cli/component-model-async/futures.wast/3.print @@ -1,22 +1,15 @@ (component (core module $libc (;0;) - (type (;0;) (func (param i32 i32 i32 i32) (result i32))) (memory (;0;) 1) - (export "realloc" (func 0)) (export "memory" (memory 0)) - (func (;0;) (type 0) (param i32 i32 i32 i32) (result i32) - unreachable - ) ) (core instance $libc (;0;) (instantiate $libc)) (core module $m (;1;) - (type (;0;) (func (param i32 i32) (result i32))) + (type (;0;) (func (param i32) (result i32))) (import "" "future.read" (func $future-read (;0;) (type 0))) ) - (type $future-type (;0;) (future string)) - (alias core export $libc "memory" (core memory (;0;))) - (alias core export $libc "realloc" (core func (;0;))) - (core func $future-read (;1;) (canon future.read $future-type async (memory 0) (realloc 0))) + (type $future-type (;0;) (future)) + (core func $future-read (;0;) (canon future.read $future-type async)) (core instance (;1;) (export "future.read" (func $future-read)) ) diff --git a/tests/snapshots/cli/component-model-async/futures.wast/4.print b/tests/snapshots/cli/component-model-async/futures.wast/4.print new file mode 100644 index 0000000000..d08dbedf8e --- /dev/null +++ b/tests/snapshots/cli/component-model-async/futures.wast/4.print @@ -0,0 +1,27 @@ +(component + (core module $libc (;0;) + (type (;0;) (func (param i32 i32 i32 i32) (result i32))) + (memory (;0;) 1) + (export "realloc" (func 0)) + (export "memory" (memory 0)) + (func (;0;) (type 0) (param i32 i32 i32 i32) (result i32) + unreachable + ) + ) + (core instance $libc (;0;) (instantiate $libc)) + (core module $m (;1;) + (type (;0;) (func (param i32 i32) (result i32))) + (import "" "future.read" (func $future-read (;0;) (type 0))) + ) + (type $future-type (;0;) (future string)) + (alias core export $libc "memory" (core memory (;0;))) + (alias core export $libc "realloc" (core func (;0;))) + (core func $future-read (;1;) (canon future.read $future-type async (memory 0) (realloc 0))) + (core instance (;1;) + (export "future.read" (func $future-read)) + ) + (core instance $i (;2;) (instantiate $m + (with "" (instance 1)) + ) + ) +) diff --git a/tests/snapshots/cli/component-model-async/futures.wast/7.print b/tests/snapshots/cli/component-model-async/futures.wast/8.print similarity index 87% rename from tests/snapshots/cli/component-model-async/futures.wast/7.print rename to tests/snapshots/cli/component-model-async/futures.wast/8.print index a9ec39f18f..717a006a91 100644 --- a/tests/snapshots/cli/component-model-async/futures.wast/7.print +++ b/tests/snapshots/cli/component-model-async/futures.wast/8.print @@ -9,8 +9,7 @@ (import "" "future.write" (func $future-write (;0;) (type 0))) ) (type $future-type (;0;) (future u8)) - (alias core export $libc "memory" (core memory (;0;))) - (core func $future-write (;0;) (canon future.write $future-type async (memory 0))) + (core func $future-write (;0;) (canon future.write $future-type async)) (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 443e958b83..4d990008bb 100644 --- a/tests/snapshots/cli/component-model-async/futures.wast/9.print +++ b/tests/snapshots/cli/component-model-async/futures.wast/9.print @@ -1,15 +1,20 @@ (component - (core module $m (;0;) + (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))) - (import "" "future.cancel-read" (func $future-cancel-read (;0;) (type 0))) + (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 $future-type (;0;) (future)) + (core func $future-write (;0;) (canon future.write $future-type async)) + (core instance (;1;) + (export "future.write" (func $future-write)) ) - (core instance $i (;1;) (instantiate $m - (with "" (instance 0)) + (core instance $i (;2;) (instantiate $m + (with "" (instance 1)) ) ) ) diff --git a/tests/snapshots/cli/component-model-async/streams.wast.json b/tests/snapshots/cli/component-model-async/streams.wast.json index c86cad22ac..bcbc50fcf1 100644 --- a/tests/snapshots/cli/component-model-async/streams.wast.json +++ b/tests/snapshots/cli/component-model-async/streams.wast.json @@ -97,7 +97,7 @@ "line": 183, "filename": "streams.14.wasm", "module_type": "binary", - "text": "type mismatch for export `stream.close-readable` of module instantiation argument ``" + "text": "type mismatch for export `stream.drop-readable` of module instantiation argument ``" }, { "type": "module", @@ -110,7 +110,7 @@ "line": 206, "filename": "streams.16.wasm", "module_type": "binary", - "text": "type mismatch for export `stream.close-writable` of module instantiation argument ``" + "text": "type mismatch for export `stream.drop-writable` of module instantiation argument ``" } ] } \ No newline at end of file diff --git a/tests/snapshots/cli/component-model-async/streams.wast/13.print b/tests/snapshots/cli/component-model-async/streams.wast/13.print index 55c45e4b9d..3333c5fef7 100644 --- a/tests/snapshots/cli/component-model-async/streams.wast/13.print +++ b/tests/snapshots/cli/component-model-async/streams.wast/13.print @@ -1,12 +1,12 @@ (component (core module $m (;0;) (type (;0;) (func (param i32))) - (import "" "stream.close-readable" (func $stream-close-readable (;0;) (type 0))) + (import "" "stream.drop-readable" (func $stream-drop-readable (;0;) (type 0))) ) (type $stream-type (;0;) (stream u8)) - (core func $stream-close-readable (;0;) (canon stream.close-readable $stream-type)) + (core func $stream-drop-readable (;0;) (canon stream.drop-readable $stream-type)) (core instance (;0;) - (export "stream.close-readable" (func $stream-close-readable)) + (export "stream.drop-readable" (func $stream-drop-readable)) ) (core instance $i (;1;) (instantiate $m (with "" (instance 0)) diff --git a/tests/snapshots/cli/component-model-async/streams.wast/15.print b/tests/snapshots/cli/component-model-async/streams.wast/15.print index cd9e055616..83304c77b0 100644 --- a/tests/snapshots/cli/component-model-async/streams.wast/15.print +++ b/tests/snapshots/cli/component-model-async/streams.wast/15.print @@ -1,12 +1,12 @@ (component (core module $m (;0;) (type (;0;) (func (param i32))) - (import "" "stream.close-writable" (func $stream-close-writable (;0;) (type 0))) + (import "" "stream.drop-writable" (func $stream-drop-writable (;0;) (type 0))) ) (type $stream-type (;0;) (stream u8)) - (core func $stream-close-writable (;0;) (canon stream.close-writable $stream-type)) + (core func $stream-drop-writable (;0;) (canon stream.drop-writable $stream-type)) (core instance (;0;) - (export "stream.close-writable" (func $stream-close-writable)) + (export "stream.drop-writable" (func $stream-drop-writable)) ) (core instance $i (;1;) (instantiate $m (with "" (instance 0)) diff --git a/tests/snapshots/cli/component-model-async/task-builtins.wast/36.print b/tests/snapshots/cli/component-model-async/task-builtins.wast/36.print index 498add71f2..216e7af76f 100644 --- a/tests/snapshots/cli/component-model-async/task-builtins.wast/36.print +++ b/tests/snapshots/cli/component-model-async/task-builtins.wast/36.print @@ -40,14 +40,14 @@ (core func (;24;) (canon future.cancel-write $f)) (core func (;25;) (canon stream.cancel-write $s)) (core func (;26;) (canon stream.cancel-write $s)) - (core func (;27;) (canon future.close-readable $f)) - (core func (;28;) (canon future.close-readable $f)) - (core func (;29;) (canon future.close-writable $f)) - (core func (;30;) (canon future.close-writable $f)) - (core func (;31;) (canon stream.close-readable $s)) - (core func (;32;) (canon stream.close-readable $s)) - (core func (;33;) (canon stream.close-writable $s)) - (core func (;34;) (canon stream.close-writable $s)) + (core func (;27;) (canon future.drop-readable $f)) + (core func (;28;) (canon future.drop-readable $f)) + (core func (;29;) (canon future.drop-writable $f)) + (core func (;30;) (canon future.drop-writable $f)) + (core func (;31;) (canon stream.drop-readable $s)) + (core func (;32;) (canon stream.drop-readable $s)) + (core func (;33;) (canon stream.drop-writable $s)) + (core func (;34;) (canon stream.drop-writable $s)) (core func (;35;) (canon future.read $f (memory $m))) (core func (;36;) (canon future.read $f (memory $m))) (core func (;37;) (canon future.write $f (memory $m)))