diff --git a/crates/wasm-compose/tests/compositions/connect-resources/composed.wat b/crates/wasm-compose/tests/compositions/connect-resources/composed.wat index 0e71b967ad..9afa7665b2 100644 --- a/crates/wasm-compose/tests/compositions/connect-resources/composed.wat +++ b/crates/wasm-compose/tests/compositions/connect-resources/composed.wat @@ -89,7 +89,7 @@ (export "get-logger" (func $import-get-logger-lowered)) ) (alias core export $module-indirect-instance "[dtor]logger" (core func $logger-dtor (;3;))) - (type $logger-resource (;2;) (resource (rep i32) (dtor (func $logger-dtor)))) + (type $logger-resource (;2;) (resource (rep i32) (dtor $logger-dtor))) (core func $logger-new (;4;) (canon resource.new $logger-resource)) (core instance $logger-new-instance (;2;) (export "[resource-new]logger" (func $logger-new)) diff --git a/crates/wasm-compose/tests/compositions/connect-resources/logger.wat b/crates/wasm-compose/tests/compositions/connect-resources/logger.wat index 125359a269..18c0a3da86 100644 --- a/crates/wasm-compose/tests/compositions/connect-resources/logger.wat +++ b/crates/wasm-compose/tests/compositions/connect-resources/logger.wat @@ -54,7 +54,7 @@ ) (alias core export $module-indirect-instance "[dtor]logger" (core func $logger-dtor)) - (type $logger-resource (resource (rep i32) (dtor (func $logger-dtor)))) + (type $logger-resource (resource (rep i32) (dtor (core func $logger-dtor)))) (core func $logger-new (canon resource.new $logger-resource)) (core instance $logger-new-instance (export "[resource-new]logger" (func $logger-new)) diff --git a/crates/wasmprinter/src/component.rs b/crates/wasmprinter/src/component.rs index 4ceed09fcc..af5217e465 100644 --- a/crates/wasmprinter/src/component.rs +++ b/crates/wasmprinter/src/component.rs @@ -568,10 +568,8 @@ impl Printer<'_, '_> { if let Some(dtor) = dtor { self.result.write_str(" ")?; self.start_group("dtor ")?; - self.start_group("func ")?; self.print_idx(&states.last().unwrap().core.func_names, dtor)?; self.end_group()?; - self.end_group()?; } self.end_group()?; } @@ -969,9 +967,7 @@ impl Printer<'_, '_> { self.print_intrinsic(state, "canon thread.spawn-indirect ", &|me, state| { me.print_idx(&state.core.type_names, func_ty_index)?; me.result.write_str(" ")?; - me.start_group("table ")?; - me.print_idx(&state.core.table_names, table_index)?; - me.end_group() + me.print_idx(&state.core.table_names, table_index) })?; } CanonicalFunction::ThreadAvailableParallelism => { @@ -1185,9 +1181,7 @@ impl Printer<'_, '_> { self.print_intrinsic(state, "canon thread.new-indirect ", &|me, state| { me.print_idx(&state.core.type_names, func_ty_index)?; me.result.write_str(" ")?; - me.start_group("table ")?; - me.print_idx(&state.core.table_names, table_index)?; - me.end_group() + me.print_idx(&state.core.table_names, table_index) })?; } CanonicalFunction::ThreadResumeLater => { diff --git a/crates/wast/src/component/binary.rs b/crates/wast/src/component/binary.rs index c58c0ce777..3116893764 100644 --- a/crates/wast/src/component/binary.rs +++ b/crates/wast/src/component/binary.rs @@ -344,24 +344,24 @@ impl<'a> Encoder<'a> { } CoreFuncKind::ResourceNew(info) => { self.core_func_names.push(name); - self.funcs.resource_new(info.ty.into()); + self.funcs.resource_new((&info.ty).into()); } CoreFuncKind::ResourceDrop(info) => { self.core_func_names.push(name); - self.funcs.resource_drop(info.ty.into()); + self.funcs.resource_drop((&info.ty).into()); } CoreFuncKind::ResourceRep(info) => { self.core_func_names.push(name); - self.funcs.resource_rep(info.ty.into()); + self.funcs.resource_rep((&info.ty).into()); } CoreFuncKind::ThreadSpawnRef(info) => { self.core_func_names.push(name); - self.funcs.thread_spawn_ref(info.ty.into()); + self.funcs.thread_spawn_ref(info.ty.idx.into()); } CoreFuncKind::ThreadSpawnIndirect(info) => { self.core_func_names.push(name); self.funcs - .thread_spawn_indirect(info.ty.into(), info.table.idx.into()); + .thread_spawn_indirect(info.ty.idx.into(), info.table.idx.into()); } CoreFuncKind::ThreadAvailableParallelism(_info) => { self.core_func_names.push(name); @@ -406,63 +406,67 @@ impl<'a> Encoder<'a> { } CoreFuncKind::StreamNew(info) => { self.core_func_names.push(name); - self.funcs.stream_new(info.ty.into()); + self.funcs.stream_new((&info.ty).into()); } CoreFuncKind::StreamRead(info) => { self.core_func_names.push(name); self.funcs - .stream_read(info.ty.into(), info.opts.iter().map(Into::into)); + .stream_read((&info.ty).into(), info.opts.iter().map(Into::into)); } CoreFuncKind::StreamWrite(info) => { self.core_func_names.push(name); self.funcs - .stream_write(info.ty.into(), info.opts.iter().map(Into::into)); + .stream_write((&info.ty).into(), info.opts.iter().map(Into::into)); } CoreFuncKind::StreamCancelRead(info) => { self.core_func_names.push(name); - self.funcs.stream_cancel_read(info.ty.into(), info.async_); + self.funcs + .stream_cancel_read((&info.ty).into(), info.async_); } CoreFuncKind::StreamCancelWrite(info) => { self.core_func_names.push(name); - self.funcs.stream_cancel_write(info.ty.into(), info.async_); + self.funcs + .stream_cancel_write((&info.ty).into(), info.async_); } CoreFuncKind::StreamDropReadable(info) => { self.core_func_names.push(name); - self.funcs.stream_drop_readable(info.ty.into()); + self.funcs.stream_drop_readable((&info.ty).into()); } CoreFuncKind::StreamDropWritable(info) => { self.core_func_names.push(name); - self.funcs.stream_drop_writable(info.ty.into()); + self.funcs.stream_drop_writable((&info.ty).into()); } CoreFuncKind::FutureNew(info) => { self.core_func_names.push(name); - self.funcs.future_new(info.ty.into()); + self.funcs.future_new((&info.ty).into()); } CoreFuncKind::FutureRead(info) => { self.core_func_names.push(name); self.funcs - .future_read(info.ty.into(), info.opts.iter().map(Into::into)); + .future_read((&info.ty).into(), info.opts.iter().map(Into::into)); } CoreFuncKind::FutureWrite(info) => { self.core_func_names.push(name); self.funcs - .future_write(info.ty.into(), info.opts.iter().map(Into::into)); + .future_write((&info.ty).into(), info.opts.iter().map(Into::into)); } CoreFuncKind::FutureCancelRead(info) => { self.core_func_names.push(name); - self.funcs.future_cancel_read(info.ty.into(), info.async_); + self.funcs + .future_cancel_read((&info.ty).into(), info.async_); } CoreFuncKind::FutureCancelWrite(info) => { self.core_func_names.push(name); - self.funcs.future_cancel_write(info.ty.into(), info.async_); + self.funcs + .future_cancel_write((&info.ty).into(), info.async_); } CoreFuncKind::FutureDropReadable(info) => { self.core_func_names.push(name); - self.funcs.future_drop_readable(info.ty.into()); + self.funcs.future_drop_readable((&info.ty).into()); } CoreFuncKind::FutureDropWritable(info) => { self.core_func_names.push(name); - self.funcs.future_drop_writable(info.ty.into()); + self.funcs.future_drop_writable((&info.ty).into()); } CoreFuncKind::ErrorContextNew(info) => { self.core_func_names.push(name); @@ -507,7 +511,7 @@ impl<'a> Encoder<'a> { CoreFuncKind::ThreadNewIndirect(info) => { self.core_func_names.push(name); self.funcs - .thread_new_indirect(info.ty.into(), info.table.idx.into()); + .thread_new_indirect(info.ty.idx.into(), info.table.idx.into()); } CoreFuncKind::ThreadResumeLater => { self.core_func_names.push(name); diff --git a/crates/wast/src/component/func.rs b/crates/wast/src/component/func.rs index eceebe72a8..1e38870b7a 100644 --- a/crates/wast/src/component/func.rs +++ b/crates/wast/src/component/func.rs @@ -461,7 +461,7 @@ impl Default for CanonLower<'_> { #[derive(Debug)] pub struct CanonResourceNew<'a> { /// The resource type that this intrinsic creates an owned reference to. - pub ty: Index<'a>, + pub ty: ItemRef<'a, kw::r#type>, } impl<'a> Parse<'a> for CanonResourceNew<'a> { @@ -469,7 +469,7 @@ impl<'a> Parse<'a> for CanonResourceNew<'a> { parser.parse::()?; Ok(Self { - ty: parser.parse()?, + ty: parser.parse::>()?.0, }) } } @@ -478,7 +478,7 @@ impl<'a> Parse<'a> for CanonResourceNew<'a> { #[derive(Debug)] pub struct CanonResourceDrop<'a> { /// The resource type that this intrinsic is dropping. - pub ty: Index<'a>, + pub ty: ItemRef<'a, kw::r#type>, } impl<'a> Parse<'a> for CanonResourceDrop<'a> { @@ -486,7 +486,7 @@ impl<'a> Parse<'a> for CanonResourceDrop<'a> { parser.parse::()?; Ok(Self { - ty: parser.parse()?, + ty: parser.parse::>()?.0, }) } } @@ -495,7 +495,7 @@ impl<'a> Parse<'a> for CanonResourceDrop<'a> { #[derive(Debug)] pub struct CanonResourceRep<'a> { /// The resource type that this intrinsic is accessing. - pub ty: Index<'a>, + pub ty: ItemRef<'a, kw::r#type>, } impl<'a> Parse<'a> for CanonResourceRep<'a> { @@ -503,7 +503,7 @@ impl<'a> Parse<'a> for CanonResourceRep<'a> { parser.parse::()?; Ok(Self { - ty: parser.parse()?, + ty: parser.parse::>()?.0, }) } } @@ -512,7 +512,7 @@ impl<'a> Parse<'a> for CanonResourceRep<'a> { #[derive(Debug)] pub struct CanonThreadSpawnRef<'a> { /// The function type that is being spawned. - pub ty: Index<'a>, + pub ty: CoreItemRef<'a, kw::r#type>, } impl<'a> Parse<'a> for CanonThreadSpawnRef<'a> { @@ -520,7 +520,7 @@ impl<'a> Parse<'a> for CanonThreadSpawnRef<'a> { parser.parse::()?; Ok(Self { - ty: parser.parse()?, + ty: parser.parse::>()?.0, }) } } @@ -531,7 +531,7 @@ impl<'a> Parse<'a> for CanonThreadSpawnRef<'a> { #[derive(Debug)] pub struct CanonThreadSpawnIndirect<'a> { /// The function type that is being spawned. - pub ty: Index<'a>, + pub ty: CoreItemRef<'a, kw::r#type>, /// The table that this spawn is going to be indexing. pub table: CoreItemRef<'a, kw::table>, } @@ -539,8 +539,8 @@ pub struct CanonThreadSpawnIndirect<'a> { impl<'a> Parse<'a> for CanonThreadSpawnIndirect<'a> { fn parse(parser: Parser<'a>) -> Result { parser.parse::()?; - let ty = parser.parse()?; - let table = parser.parens(|p| p.parse())?; + let ty = parser.parse::>()?.0; + let table = parser.parse::>()?.0; Ok(Self { ty, table }) } } @@ -597,7 +597,10 @@ impl<'a> Parse<'a> for CanonWaitableSetWait<'a> { fn parse(parser: Parser<'a>) -> Result { parser.parse::()?; let async_ = parser.parse::>()?.is_some(); - let memory = parser.parens(|p| p.parse())?; + let memory = parser.parens(|p| { + let kind = p.parse::()?; + parse_core_prefixed_contents(p, kind) + })?; Ok(Self { async_, memory }) } @@ -617,7 +620,10 @@ impl<'a> Parse<'a> for CanonWaitableSetPoll<'a> { fn parse(parser: Parser<'a>) -> Result { parser.parse::()?; let async_ = parser.parse::>()?.is_some(); - let memory = parser.parens(|p| p.parse())?; + let memory = parser.parens(|p| { + let kind = p.parse::()?; + parse_core_prefixed_contents(p, kind) + })?; Ok(Self { async_, memory }) } @@ -661,7 +667,7 @@ impl<'a> Parse<'a> for CanonSubtaskCancel { #[derive(Debug)] pub struct CanonStreamNew<'a> { /// The stream type to instantiate. - pub ty: Index<'a>, + pub ty: ItemRef<'a, kw::r#type>, } impl<'a> Parse<'a> for CanonStreamNew<'a> { @@ -669,7 +675,7 @@ impl<'a> Parse<'a> for CanonStreamNew<'a> { parser.parse::()?; Ok(Self { - ty: parser.parse()?, + ty: parser.parse::>()?.0, }) } } @@ -678,7 +684,7 @@ impl<'a> Parse<'a> for CanonStreamNew<'a> { #[derive(Debug)] pub struct CanonStreamRead<'a> { /// The stream type to instantiate. - pub ty: Index<'a>, + pub ty: ItemRef<'a, kw::r#type>, /// The canonical options for storing values. pub opts: Vec>, } @@ -688,7 +694,7 @@ impl<'a> Parse<'a> for CanonStreamRead<'a> { parser.parse::()?; Ok(Self { - ty: parser.parse()?, + ty: parser.parse::>()?.0, opts: parser.parse()?, }) } @@ -698,7 +704,7 @@ impl<'a> Parse<'a> for CanonStreamRead<'a> { #[derive(Debug)] pub struct CanonStreamWrite<'a> { /// The stream type to instantiate. - pub ty: Index<'a>, + pub ty: ItemRef<'a, kw::r#type>, /// The canonical options for loading values. pub opts: Vec>, } @@ -708,7 +714,7 @@ impl<'a> Parse<'a> for CanonStreamWrite<'a> { parser.parse::()?; Ok(Self { - ty: parser.parse()?, + ty: parser.parse::>()?.0, opts: parser.parse()?, }) } @@ -718,7 +724,7 @@ impl<'a> Parse<'a> for CanonStreamWrite<'a> { #[derive(Debug)] pub struct CanonStreamCancelRead<'a> { /// The stream type to instantiate. - pub ty: Index<'a>, + pub ty: ItemRef<'a, kw::r#type>, /// If false, block until cancel is finished; otherwise return BLOCKED if /// necessary. pub async_: bool, @@ -729,7 +735,7 @@ impl<'a> Parse<'a> for CanonStreamCancelRead<'a> { parser.parse::()?; Ok(Self { - ty: parser.parse()?, + ty: parser.parse::>()?.0, async_: parser.parse::>()?.is_some(), }) } @@ -739,7 +745,7 @@ impl<'a> Parse<'a> for CanonStreamCancelRead<'a> { #[derive(Debug)] pub struct CanonStreamCancelWrite<'a> { /// The stream type to instantiate. - pub ty: Index<'a>, + pub ty: ItemRef<'a, kw::r#type>, /// If false, block until cancel is finished; otherwise return BLOCKED if /// necessary. pub async_: bool, @@ -750,7 +756,7 @@ impl<'a> Parse<'a> for CanonStreamCancelWrite<'a> { parser.parse::()?; Ok(Self { - ty: parser.parse()?, + ty: parser.parse::>()?.0, async_: parser.parse::>()?.is_some(), }) } @@ -760,7 +766,7 @@ impl<'a> Parse<'a> for CanonStreamCancelWrite<'a> { #[derive(Debug)] pub struct CanonStreamDropReadable<'a> { /// The stream type to drop. - pub ty: Index<'a>, + pub ty: ItemRef<'a, kw::r#type>, } impl<'a> Parse<'a> for CanonStreamDropReadable<'a> { @@ -768,7 +774,7 @@ impl<'a> Parse<'a> for CanonStreamDropReadable<'a> { parser.parse::()?; Ok(Self { - ty: parser.parse()?, + ty: parser.parse::>()?.0, }) } } @@ -777,7 +783,7 @@ impl<'a> Parse<'a> for CanonStreamDropReadable<'a> { #[derive(Debug)] pub struct CanonStreamDropWritable<'a> { /// The stream type to drop. - pub ty: Index<'a>, + pub ty: ItemRef<'a, kw::r#type>, } impl<'a> Parse<'a> for CanonStreamDropWritable<'a> { @@ -785,7 +791,7 @@ impl<'a> Parse<'a> for CanonStreamDropWritable<'a> { parser.parse::()?; Ok(Self { - ty: parser.parse()?, + ty: parser.parse::>()?.0, }) } } @@ -794,7 +800,7 @@ impl<'a> Parse<'a> for CanonStreamDropWritable<'a> { #[derive(Debug)] pub struct CanonFutureNew<'a> { /// The future type to instantiate. - pub ty: Index<'a>, + pub ty: ItemRef<'a, kw::r#type>, } impl<'a> Parse<'a> for CanonFutureNew<'a> { @@ -802,7 +808,7 @@ impl<'a> Parse<'a> for CanonFutureNew<'a> { parser.parse::()?; Ok(Self { - ty: parser.parse()?, + ty: parser.parse::>()?.0, }) } } @@ -811,7 +817,7 @@ impl<'a> Parse<'a> for CanonFutureNew<'a> { #[derive(Debug)] pub struct CanonFutureRead<'a> { /// The future type to instantiate. - pub ty: Index<'a>, + pub ty: ItemRef<'a, kw::r#type>, /// The canonical options for storing values. pub opts: Vec>, } @@ -821,7 +827,7 @@ impl<'a> Parse<'a> for CanonFutureRead<'a> { parser.parse::()?; Ok(Self { - ty: parser.parse()?, + ty: parser.parse::>()?.0, opts: parser.parse()?, }) } @@ -831,7 +837,7 @@ impl<'a> Parse<'a> for CanonFutureRead<'a> { #[derive(Debug)] pub struct CanonFutureWrite<'a> { /// The future type to instantiate. - pub ty: Index<'a>, + pub ty: ItemRef<'a, kw::r#type>, /// The canonical options for loading values. pub opts: Vec>, } @@ -841,7 +847,7 @@ impl<'a> Parse<'a> for CanonFutureWrite<'a> { parser.parse::()?; Ok(Self { - ty: parser.parse()?, + ty: parser.parse::>()?.0, opts: parser.parse()?, }) } @@ -851,7 +857,7 @@ impl<'a> Parse<'a> for CanonFutureWrite<'a> { #[derive(Debug)] pub struct CanonFutureCancelRead<'a> { /// The future type to instantiate. - pub ty: Index<'a>, + pub ty: ItemRef<'a, kw::r#type>, /// If false, block until cancel is finished; otherwise return BLOCKED if /// necessary. pub async_: bool, @@ -862,7 +868,7 @@ impl<'a> Parse<'a> for CanonFutureCancelRead<'a> { parser.parse::()?; Ok(Self { - ty: parser.parse()?, + ty: parser.parse::>()?.0, async_: parser.parse::>()?.is_some(), }) } @@ -872,7 +878,7 @@ impl<'a> Parse<'a> for CanonFutureCancelRead<'a> { #[derive(Debug)] pub struct CanonFutureCancelWrite<'a> { /// The future type to instantiate. - pub ty: Index<'a>, + pub ty: ItemRef<'a, kw::r#type>, /// If false, block until cancel is finished; otherwise return BLOCKED if /// necessary. pub async_: bool, @@ -883,7 +889,7 @@ impl<'a> Parse<'a> for CanonFutureCancelWrite<'a> { parser.parse::()?; Ok(Self { - ty: parser.parse()?, + ty: parser.parse::>()?.0, async_: parser.parse::>()?.is_some(), }) } @@ -893,7 +899,7 @@ impl<'a> Parse<'a> for CanonFutureCancelWrite<'a> { #[derive(Debug)] pub struct CanonFutureDropReadable<'a> { /// The future type to drop. - pub ty: Index<'a>, + pub ty: ItemRef<'a, kw::r#type>, } impl<'a> Parse<'a> for CanonFutureDropReadable<'a> { @@ -901,7 +907,7 @@ impl<'a> Parse<'a> for CanonFutureDropReadable<'a> { parser.parse::()?; Ok(Self { - ty: parser.parse()?, + ty: parser.parse::>()?.0, }) } } @@ -910,7 +916,7 @@ impl<'a> Parse<'a> for CanonFutureDropReadable<'a> { #[derive(Debug)] pub struct CanonFutureDropWritable<'a> { /// The future type to drop. - pub ty: Index<'a>, + pub ty: ItemRef<'a, kw::r#type>, } impl<'a> Parse<'a> for CanonFutureDropWritable<'a> { @@ -918,7 +924,7 @@ impl<'a> Parse<'a> for CanonFutureDropWritable<'a> { parser.parse::()?; Ok(Self { - ty: parser.parse()?, + ty: parser.parse::>()?.0, }) } } @@ -961,7 +967,7 @@ impl<'a> Parse<'a> for CanonErrorContextDebugMessage<'a> { #[derive(Debug)] pub struct CanonThreadNewIndirect<'a> { /// The function type for the thread start function. - pub ty: Index<'a>, + pub ty: CoreItemRef<'a, kw::r#type>, /// The table to index. pub table: CoreItemRef<'a, kw::table>, } @@ -969,8 +975,8 @@ pub struct CanonThreadNewIndirect<'a> { impl<'a> Parse<'a> for CanonThreadNewIndirect<'a> { fn parse(parser: Parser<'a>) -> Result { parser.parse::()?; - let ty = parser.parse()?; - let table = parser.parens(|p| p.parse())?; + let ty = parser.parse::>()?.0; + let table = parser.parse::>()?.0; Ok(Self { ty, table }) } } @@ -1098,26 +1104,29 @@ impl<'a> Parse<'a> for CanonOpt<'a> { parser.parens(|parser| { let mut l = parser.lookahead1(); if l.peek::()? { - Ok(CanonOpt::Memory(parser.parse()?)) + let kind = parser.parse::()?; + Ok(CanonOpt::Memory(parse_core_prefixed_contents( + parser, kind, + )?)) } else if l.peek::()? { parser.parse::()?; Ok(CanonOpt::Realloc( - parser.parse::>()?.0, + parser.parse::>()?.0, )) } else if l.peek::()? { parser.parse::()?; Ok(CanonOpt::PostReturn( - parser.parse::>()?.0, + parser.parse::>()?.0, )) } else if l.peek::()? { parser.parse::()?; Ok(CanonOpt::Callback( - parser.parse::>()?.0, + parser.parse::>()?.0, )) } else if l.peek::()? { parser.parse::()?; Ok(CanonOpt::CoreType( - parser.parse::>()?.0, + parser.parse::>()?.0, )) } else { Err(l.error()) diff --git a/crates/wast/src/component/item_ref.rs b/crates/wast/src/component/item_ref.rs index cc8edc9b5b..0c71aa1995 100644 --- a/crates/wast/src/component/item_ref.rs +++ b/crates/wast/src/component/item_ref.rs @@ -1,6 +1,35 @@ +use crate::kw; use crate::parser::{Cursor, Parse, Parser, Peek, Result}; use crate::token::Index; +/// Returns whether the text parser accepts the legacy syntax for component +/// index references that predates WebAssembly/component-model#655. +/// +/// The component-model text format historically accepted references to core +/// items without a `core` prefix on the sort, such as `(realloc (func $f))`, +/// and additionally accepted an export name directly after some indices, such +/// as `(memory $i "mem")`. Upstream WebAssembly/component-model#655 +/// regularized the grammar such that these must now be written +/// `(realloc (core func $f))` and `(memory (core memory $i "mem"))` for +/// example. +/// +/// To smooth over this transition the legacy syntax is still accepted, by +/// default, in addition to the new syntax. Setting the environment variable +/// `WAST_STRICT_COMPONENT_INDICES` to `1` rejects the legacy syntax. The +/// default will be flipped to strict in the future, and eventually support +/// for the legacy syntax will be removed. +pub(crate) fn allow_legacy_indices() -> bool { + const DEFAULT: bool = true; + static ALLOW: std::sync::LazyLock = std::sync::LazyLock::new(|| { + match std::env::var("WAST_STRICT_COMPONENT_INDICES").as_deref() { + Ok("0") => true, + Ok(_) => false, + Err(_) => DEFAULT, + } + }); + *ALLOW +} + fn peek(cursor: Cursor) -> Result { // This is a little fancy because when parsing something like: // @@ -132,23 +161,98 @@ where } } -/// Convenience structure to parse `$f` or `(item $f)`. +/// Convenience structure to parse `core-prefix()` from the +/// component-model specification. +/// +/// This parses either: +/// +/// * a bare index: `$f` or `0` +/// * a parenthesized reference with a `core` prefix: `(core func $f)` or +/// `(core func $i "name")` +/// +/// When the `LEGACY` type parameter is `true`, and legacy syntax is enabled +/// (see the `allow_legacy_indices`) this additionally accepts the legacy syntax +/// which omits the `core` prefix: `(func $f)` or `(func $i "name")`. #[derive(Clone, Debug)] -pub struct IndexOrCoreRef<'a, K>(pub CoreItemRef<'a, K>); +pub struct CorePrefixedRef<'a, K, const LEGACY: bool>(pub CoreItemRef<'a, K>); -impl<'a, K> Parse<'a> for IndexOrCoreRef<'a, K> +impl<'a, K, const LEGACY: bool> Parse<'a> for CorePrefixedRef<'a, K, LEGACY> where - K: Parse<'a> + Default, + K: Parse<'a> + Peek + Default, { fn parse(parser: Parser<'a>) -> Result { if parser.peek::>()? { - Ok(IndexOrCoreRef(CoreItemRef { + return Ok(CorePrefixedRef(CoreItemRef { kind: K::default(), idx: parser.parse()?, export_name: None, - })) - } else { - Ok(IndexOrCoreRef(parser.parens(|p| p.parse())?)) + })); } + parser.parens(|parser| { + if LEGACY && parser.peek::()? { + if !allow_legacy_indices() { + let name = K::display().trim_matches('`'); + return Err(parser.error(format!( + "the `core` keyword is required in this reference: \ + `({name} ...)` should be written `(core {name} ...)` \ + (or set WAST_STRICT_COMPONENT_INDICES=0 to accept \ + the legacy syntax)" + ))); + } + } else { + parser.parse::()?; + } + let item = parser.parse::>()?; + Ok(CorePrefixedRef(item)) + }) } } + +/// Parses the contents of a reference to a core item where the sort keyword +/// `kind` doubles as the enclosing s-expression's keyword and has already +/// been consumed by the caller, e.g. the `(memory ...)` canonical ABI option. +/// +/// This parses either: +/// +/// * a bare index: `$m` or `0` +/// * a nested parenthesized reference with a `core` prefix: +/// `(core memory $m)` or `(core memory $i "name")` +/// +/// When legacy syntax is enabled (see `allow_legacy_indices`) this additionally +/// accepts the legacy syntax of an export name directly following the index: +/// `$i "name"`. +pub(crate) fn parse_core_prefixed_contents<'a, K>( + parser: Parser<'a>, + kind: K, +) -> Result> +where + K: Parse<'a> + Peek + Default, +{ + if parser.peek::>()? { + let idx = parser.parse()?; + let export_name = if parser.peek::<&str>()? { + if !allow_legacy_indices() { + let name = K::display().trim_matches('`'); + return Err(parser.error(format!( + "an export name must be written inside a nested \ + reference: `({name} $i \"name\")` should be written \ + `({name} (core {name} $i \"name\"))` \ + (or set WAST_STRICT_COMPONENT_INDICES=0 to accept \ + the legacy syntax)" + ))); + } + Some(parser.parse()?) + } else { + None + }; + return Ok(CoreItemRef { + kind, + idx, + export_name, + }); + } + parser.parens(|parser| { + parser.parse::()?; + parser.parse::>() + }) +} diff --git a/crates/wast/src/component/resolve.rs b/crates/wast/src/component/resolve.rs index 3978f9bf33..f85b651f1e 100644 --- a/crates/wast/src/component/resolve.rs +++ b/crates/wast/src/component/resolve.rs @@ -379,19 +379,19 @@ impl<'a> Resolver<'a> { self.canon_opts(&mut info.opts)?; } CoreFuncKind::ResourceNew(info) => { - self.resolve_ns(&mut info.ty, Ns::Type)?; + self.component_item_ref(&mut info.ty)?; } CoreFuncKind::ResourceRep(info) => { - self.resolve_ns(&mut info.ty, Ns::Type)?; + self.component_item_ref(&mut info.ty)?; } CoreFuncKind::ResourceDrop(info) => { - self.resolve_ns(&mut info.ty, Ns::Type)?; + self.component_item_ref(&mut info.ty)?; } CoreFuncKind::ThreadSpawnRef(info) => { - self.resolve_ns(&mut info.ty, Ns::CoreType)?; + self.core_item_ref(&mut info.ty)?; } CoreFuncKind::ThreadSpawnIndirect(info) => { - self.resolve_ns(&mut info.ty, Ns::CoreType)?; + self.core_item_ref(&mut info.ty)?; self.core_item_ref(&mut info.table)?; } CoreFuncKind::ThreadAvailableParallelism(_) @@ -410,50 +410,50 @@ impl<'a> Resolver<'a> { CoreFuncKind::ContextGet(ty, _) => self.ref_type(ty)?, CoreFuncKind::ContextSet(ty, _) => self.ref_type(ty)?, CoreFuncKind::StreamNew(info) => { - self.resolve_ns(&mut info.ty, Ns::Type)?; + self.component_item_ref(&mut info.ty)?; } CoreFuncKind::StreamRead(info) => { - self.resolve_ns(&mut info.ty, Ns::Type)?; + self.component_item_ref(&mut info.ty)?; self.canon_opts(&mut info.opts)?; } CoreFuncKind::StreamWrite(info) => { - self.resolve_ns(&mut info.ty, Ns::Type)?; + self.component_item_ref(&mut info.ty)?; self.canon_opts(&mut info.opts)?; } CoreFuncKind::StreamCancelRead(info) => { - self.resolve_ns(&mut info.ty, Ns::Type)?; + self.component_item_ref(&mut info.ty)?; } CoreFuncKind::StreamCancelWrite(info) => { - self.resolve_ns(&mut info.ty, Ns::Type)?; + self.component_item_ref(&mut info.ty)?; } CoreFuncKind::StreamDropReadable(info) => { - self.resolve_ns(&mut info.ty, Ns::Type)?; + self.component_item_ref(&mut info.ty)?; } CoreFuncKind::StreamDropWritable(info) => { - self.resolve_ns(&mut info.ty, Ns::Type)?; + self.component_item_ref(&mut info.ty)?; } CoreFuncKind::FutureNew(info) => { - self.resolve_ns(&mut info.ty, Ns::Type)?; + self.component_item_ref(&mut info.ty)?; } CoreFuncKind::FutureRead(info) => { - self.resolve_ns(&mut info.ty, Ns::Type)?; + self.component_item_ref(&mut info.ty)?; self.canon_opts(&mut info.opts)?; } CoreFuncKind::FutureWrite(info) => { - self.resolve_ns(&mut info.ty, Ns::Type)?; + self.component_item_ref(&mut info.ty)?; self.canon_opts(&mut info.opts)?; } CoreFuncKind::FutureCancelRead(info) => { - self.resolve_ns(&mut info.ty, Ns::Type)?; + self.component_item_ref(&mut info.ty)?; } CoreFuncKind::FutureCancelWrite(info) => { - self.resolve_ns(&mut info.ty, Ns::Type)?; + self.component_item_ref(&mut info.ty)?; } CoreFuncKind::FutureDropReadable(info) => { - self.resolve_ns(&mut info.ty, Ns::Type)?; + self.component_item_ref(&mut info.ty)?; } CoreFuncKind::FutureDropWritable(info) => { - self.resolve_ns(&mut info.ty, Ns::Type)?; + self.component_item_ref(&mut info.ty)?; } CoreFuncKind::ErrorContextNew(info) => { self.canon_opts(&mut info.opts)?; @@ -472,7 +472,7 @@ impl<'a> Resolver<'a> { CoreFuncKind::WaitableJoin => {} CoreFuncKind::ThreadIndex => {} CoreFuncKind::ThreadNewIndirect(info) => { - self.resolve_ns(&mut info.ty, Ns::CoreType)?; + self.core_item_ref(&mut info.ty)?; self.core_item_ref(&mut info.table)?; } CoreFuncKind::ThreadResumeLater => {} @@ -753,12 +753,33 @@ impl<'a> Resolver<'a> { return Ok(()); } + let span = item.idx.span(); + let kind = match item.kind.ns() { + ns @ (Ns::CoreFunc | Ns::CoreTable | Ns::CoreGlobal | Ns::CoreMemory | Ns::CoreTag) => { + ns.into() + } + Ns::CoreType + | Ns::CoreInstance + | Ns::CoreModule + | Ns::Func + | Ns::Type + | Ns::Instance + | Ns::Component + | Ns::Value => { + return Err(Error::new( + span, + "core instances cannot export this kind of item, so an \ + export name cannot be used to resolve this reference" + .to_string(), + )); + } + }; + // This is a reference to a core instance export let mut index = item.idx; self.resolve_ns(&mut index, Ns::CoreInstance)?; // Record an alias to reference the export - let span = item.idx.span(); let alias = Alias { span, id: None, @@ -766,7 +787,7 @@ impl<'a> Resolver<'a> { target: AliasTarget::CoreExport { instance: index, name: item.export_name.unwrap(), - kind: item.kind.ns().into(), + kind, }, }; diff --git a/crates/wast/src/component/types.rs b/crates/wast/src/component/types.rs index 7f11b387ee..3953ccf67c 100644 --- a/crates/wast/src/component/types.rs +++ b/crates/wast/src/component/types.rs @@ -967,7 +967,7 @@ impl<'a> Parse<'a> for ResourceType<'a> { } else { Some(parser.parens(|p| { p.parse::()?; - p.parens(|p| p.parse()) + Ok(p.parse::>()?.0) })?) }; Ok(Self { rep, dtor }) diff --git a/crates/wast/tests/parse-fail/core-instance-export-name.wat b/crates/wast/tests/parse-fail/core-instance-export-name.wat new file mode 100644 index 0000000000..bf58139c7b --- /dev/null +++ b/crates/wast/tests/parse-fail/core-instance-export-name.wat @@ -0,0 +1,10 @@ +;; Referencing a core instance export whose sort has no core export kind +;; (module instances cannot be exported from core instances) must be an +;; error, not a panic. Note that this syntax predates +;; WebAssembly/component-model#655 and panicked in wasm-tools 1.253.0 and +;; prior. +(component + (core module $m) + (core instance $i (instantiate $m)) + (core instance (instantiate $m (with "" (instance $i "x")))) +) diff --git a/crates/wast/tests/parse-fail/core-instance-export-name.wat.err b/crates/wast/tests/parse-fail/core-instance-export-name.wat.err new file mode 100644 index 0000000000..fb8c026d64 --- /dev/null +++ b/crates/wast/tests/parse-fail/core-instance-export-name.wat.err @@ -0,0 +1,5 @@ +core instances cannot export this kind of item, so an export name cannot be used to resolve this reference + --> tests/parse-fail/core-instance-export-name.wat:9:53 + | + 9 | (core instance (instantiate $m (with "" (instance $i "x")))) + | ^ diff --git a/crates/wast/tests/parse-fail/core-type-export-name.wat b/crates/wast/tests/parse-fail/core-type-export-name.wat new file mode 100644 index 0000000000..257840d913 --- /dev/null +++ b/crates/wast/tests/parse-fail/core-type-export-name.wat @@ -0,0 +1,8 @@ +;; Core instances cannot export types, so resolving a `(core type $i "x")` +;; reference through a core instance export must be an error, not a panic. +(component + (core module $m) + (core instance $i (instantiate $m)) + (import "f" (func $f)) + (core func (canon lower (func $f) (core-type (core type $i "t")))) +) diff --git a/crates/wast/tests/parse-fail/core-type-export-name.wat.err b/crates/wast/tests/parse-fail/core-type-export-name.wat.err new file mode 100644 index 0000000000..99feb815f4 --- /dev/null +++ b/crates/wast/tests/parse-fail/core-type-export-name.wat.err @@ -0,0 +1,5 @@ +core instances cannot export this kind of item, so an export name cannot be used to resolve this reference + --> tests/parse-fail/core-type-export-name.wat:7:59 + | + 7 | (core func (canon lower (func $f) (core-type (core type $i "t")))) + | ^ diff --git a/crates/wast/tests/parse-fail/core-type-export-name2.wat b/crates/wast/tests/parse-fail/core-type-export-name2.wat new file mode 100644 index 0000000000..5c93976ab1 --- /dev/null +++ b/crates/wast/tests/parse-fail/core-type-export-name2.wat @@ -0,0 +1,7 @@ +;; Same as core-type-export-name.wat but through a canon built-in's core type +;; index rather than a canonical ABI option. +(component + (core module $m) + (core instance $i (instantiate $m)) + (core func (canon thread.spawn-ref (core type $i "t"))) +) diff --git a/crates/wast/tests/parse-fail/core-type-export-name2.wat.err b/crates/wast/tests/parse-fail/core-type-export-name2.wat.err new file mode 100644 index 0000000000..4c830ffd2d --- /dev/null +++ b/crates/wast/tests/parse-fail/core-type-export-name2.wat.err @@ -0,0 +1,5 @@ +core instances cannot export this kind of item, so an export name cannot be used to resolve this reference + --> tests/parse-fail/core-type-export-name2.wat:6:49 + | + 6 | (core func (canon thread.spawn-ref (core type $i "t"))) + | ^ diff --git a/crates/wit-component/tests/components/cm32-names/component.wat b/crates/wit-component/tests/components/cm32-names/component.wat index 18b3b230d9..d9a8273829 100644 --- a/crates/wit-component/tests/components/cm32-names/component.wat +++ b/crates/wit-component/tests/components/cm32-names/component.wat @@ -182,9 +182,9 @@ ) (core instance $wit-component-shim-instance (;0;) (instantiate $wit-component-shim-module)) (alias core export $wit-component-shim-instance "5" (core func $dtor-r (;0;))) - (type $r (;3;) (resource (rep i32) (dtor (func $dtor-r)))) + (type $r (;3;) (resource (rep i32) (dtor $dtor-r))) (alias core export $wit-component-shim-instance "6" (core func $"#core-func1 dtor-r" (@name "dtor-r") (;1;))) - (type $"#type4 r" (@name "r") (;4;) (resource (rep i32) (dtor (func $"#core-func1 dtor-r")))) + (type $"#type4 r" (@name "r") (;4;) (resource (rep i32) (dtor $"#core-func1 dtor-r"))) (alias core export $wit-component-shim-instance "0" (core func $indirect-cm32p2-f (;2;))) (core instance $cm32p2 (;1;) (export "f" (func $indirect-cm32p2-f)) diff --git a/crates/wit-component/tests/components/export-resource/component.wat b/crates/wit-component/tests/components/export-resource/component.wat index 6c14b99e4f..b003781df9 100644 --- a/crates/wit-component/tests/components/export-resource/component.wat +++ b/crates/wit-component/tests/components/export-resource/component.wat @@ -48,7 +48,7 @@ ) (core instance $wit-component-shim-instance (;0;) (instantiate $wit-component-shim-module)) (alias core export $wit-component-shim-instance "0" (core func $dtor-a (;0;))) - (type $a (;0;) (resource (rep i32) (dtor (func $dtor-a)))) + (type $a (;0;) (resource (rep i32) (dtor $dtor-a))) (core func $resource.new (;1;) (canon resource.new $a)) (core func $resource.rep (;2;) (canon resource.rep $a)) (core func $resource.drop (;3;) (canon resource.drop $a)) diff --git a/crates/wit-component/tests/components/threading/component.wat b/crates/wit-component/tests/components/threading/component.wat index cf4f5aa7d3..386378f215 100644 --- a/crates/wit-component/tests/components/threading/component.wat +++ b/crates/wit-component/tests/components/threading/component.wat @@ -134,7 +134,7 @@ (core func $"#core-func15 task.return" (@name "task.return") (;15;) (canon task.return (result string) (memory $memory) string-encoding=utf8)) (core type $thread-start (;0;) (func (param i32))) (alias core export $main "__indirect_function_table" (core table $indirect-function-table (;1;))) - (core func $"#core-func16 thread.new-indirect" (@name "thread.new-indirect") (;16;) (canon thread.new-indirect $thread-start (table $indirect-function-table))) + (core func $"#core-func16 thread.new-indirect" (@name "thread.new-indirect") (;16;) (canon thread.new-indirect $thread-start $indirect-function-table)) (core instance $fixup-args (;5;) (export "$imports" (table $"shim table")) (export "0" (func $task.return)) diff --git a/tests/cli.rs b/tests/cli.rs index 6737c3c1ae..3516faec5a 100644 --- a/tests/cli.rs +++ b/tests/cli.rs @@ -112,21 +112,35 @@ fn run_test_directive( exe: &Path, tempdir: &TempDir, ) -> Result<()> { - let mut cmd = Command::new(exe); + let mut cmd = new_command(exe); let mut stdin = None; + let mut saw_subcommand = false; for arg in line.split_whitespace() { let arg = arg.replace("%tmpdir", tempdir.path().to_str().unwrap()); if arg == "|" { let output = execute(&mut cmd, stdin.as_deref(), false)?; stdin = Some(output.stdout); - cmd = Command::new(exe); + cmd = new_command(exe); + saw_subcommand = false; + } else if !saw_subcommand + && arg + .split_once('=') + .is_some_and(|(key, _)| !key.is_empty() && key.chars().all(is_env_var_char)) + { + // Like a POSIX shell, `KEY=VALUE` arguments before the + // subcommand name set environment variables for this command + // only, e.g. `RUN: WAST_STRICT_COMPONENT_INDICES=0 wast %`. + let (key, value) = arg.split_once('=').unwrap(); + cmd.env(key, value); } else if arg == "%" { // Pass the test path with forward slashes so a command that echoes // it back (such as `json-from-wast`'s `source_filename`) produces // the same output on windows and unix. cmd.arg(test.to_str().unwrap().replace("\\", "/")); + saw_subcommand = true; } else { cmd.arg(arg); + saw_subcommand = true; } } @@ -154,6 +168,23 @@ fn run_test_directive( Ok(()) } +fn new_command(exe: &Path) -> Command { + let mut cmd = Command::new(exe); + // This test suite runs in strict component-model index syntax mode by + // default to ensure that all tests are ready for when strictness becomes + // the default. Tests exercising the legacy syntax opt out with an + // explicit `WAST_STRICT_COMPONENT_INDICES=0` prefix in their directive. + // Note that this is unconditionally set, rather than inherited, so test + // results don't depend on the environment variables of the shell that + // spawned the test suite. + cmd.env("WAST_STRICT_COMPONENT_INDICES", "1"); + cmd +} + +fn is_env_var_char(c: char) -> bool { + c.is_ascii_uppercase() || c.is_ascii_digit() || c == '_' +} + fn execute(cmd: &mut Command, stdin: Option<&[u8]>, should_fail: bool) -> Result { cmd.stdin(Stdio::piped()); cmd.stdout(Stdio::piped()); diff --git a/tests/cli/component-model/adapt.wast b/tests/cli/component-model/adapt.wast index 8cc76f8ffd..44f195e20d 100644 --- a/tests/cli/component-model/adapt.wast +++ b/tests/cli/component-model/adapt.wast @@ -106,7 +106,7 @@ (import "i" (func $f)) (core module $m (memory (export "memory") 1)) (core instance $i (instantiate $m)) - (core func (canon lower (func $f) (memory $i "memory") (memory $i "memory"))) + (core func (canon lower (func $f) (memory (core memory $i "memory")) (memory (core memory $i "memory")))) ) "`memory` is specified more than once") @@ -129,7 +129,7 @@ (core instance $i (instantiate $m)) (func (param "p1" (list u8)) (canon lift (core func $i "f") - (memory $i "m") + (memory (core memory $i "m")) ) ) ) @@ -145,9 +145,9 @@ (core instance $i (instantiate $m)) (func (param "p1" (list u8)) (canon lift (core func $i "f") - (memory $i "m") - (realloc (func $i "r")) - (realloc (func $i "r")) + (memory (core memory $i "m")) + (realloc (core func $i "r")) + (realloc (core func $i "r")) ) ) ) @@ -163,8 +163,8 @@ (core instance $i (instantiate $m)) (func (param "p1" (list u8)) (canon lift (core func $i "f") - (memory $i "m") - (realloc (func $i "r")) + (memory (core memory $i "m")) + (realloc (core func $i "r")) ) ) ) @@ -181,9 +181,9 @@ (core instance $i (instantiate $m)) (func (result string) (canon lift (core func $i "f") - (memory $i "m") - (realloc (func $i "r")) - (post-return (func $i "p")) + (memory (core memory $i "m")) + (realloc (core func $i "r")) + (post-return (core func $i "p")) ) ) ) @@ -200,10 +200,10 @@ (core instance $i (instantiate $m)) (func (result string) (canon lift (core func $i "f") - (memory $i "m") - (realloc (func $i "r")) - (post-return (func $i "p")) - (post-return (func $i "p")) + (memory (core memory $i "m")) + (realloc (core func $i "r")) + (post-return (core func $i "p")) + (post-return (core func $i "p")) ) ) ) @@ -221,9 +221,9 @@ (core instance $i (instantiate $m)) (core func (canon lower (func $f) - (memory $i "m") - (realloc (func $i "r")) - (post-return (func $i "p")) + (memory (core memory $i "m")) + (realloc (core func $i "r")) + (post-return (core func $i "p")) ) ) ) @@ -239,9 +239,9 @@ (core instance $i (instantiate $m)) (func (result string) (canon lift (core func $i "f") - (memory $i "m") - (realloc (func $i "r")) - (post-return (func $i "p")) + (memory (core memory $i "m")) + (realloc (core func $i "r")) + (post-return (core func $i "p")) ) ) ) diff --git a/tests/cli/component-model/async/abi.wast b/tests/cli/component-model/async/abi.wast index 3117d1a117..347a251eb5 100644 --- a/tests/cli/component-model/async/abi.wast +++ b/tests/cli/component-model/async/abi.wast @@ -19,25 +19,25 @@ ;; async func() -> u32 (import "f3" (func $f3 async (result u32))) - (core func $f3 (canon lower (func $f3) async (memory $libc "memory"))) + (core func $f3 (canon lower (func $f3) async (memory (core memory $libc "memory")))) (core module $m3 (func (import "" "f") (param i32) (result i32))) (core instance (instantiate $m3 (with "" (instance (export "f" (func $f3)))))) ;; async func(x: u32, y: f32, z: string) (import "f4" (func $f4 async (param "x" u32) (param "y" f32) (param "z" string))) - (core func $f4 (canon lower (func $f4) async (memory $libc "memory"))) + (core func $f4 (canon lower (func $f4) async (memory (core memory $libc "memory")))) (core module $m4 (func (import "" "f") (param i32 f32 i32 i32) (result i32))) (core instance (instantiate $m4 (with "" (instance (export "f" (func $f4)))))) ;; async func() -> f32 (import "f5" (func $f5 async (result f32))) - (core func $f5 (canon lower (func $f5) async (memory $libc "memory"))) + (core func $f5 (canon lower (func $f5) async (memory (core memory $libc "memory")))) (core module $m5 (func (import "" "f") (param i32) (result i32))) (core instance (instantiate $m5 (with "" (instance (export "f" (func $f5)))))) ;; async func(x: list) -> f32 (import "f6" (func $f6 async (param "x" (list string 6)) (result f32))) - (core func $f6 (canon lower (func $f6) async (memory $libc "memory"))) + (core func $f6 (canon lower (func $f6) async (memory (core memory $libc "memory")))) (core module $m6 (func (import "" "f") (param i32 i32) (result i32))) (core instance (instantiate $m6 (with "" (instance (export "f" (func $f6)))))) ) @@ -50,7 +50,7 @@ (func (export "f") (result i32) unreachable)) (core instance $m1 (instantiate $m1)) (func async - (canon lift (core func $m1 "f") async (callback (func $m1 "cb")))) + (canon lift (core func $m1 "f") async (callback (core func $m1 "cb")))) ;; async func(x: u32) (core module $m2 @@ -58,7 +58,7 @@ (func (export "f") (param i32) (result i32) unreachable)) (core instance $m2 (instantiate $m2)) (func async (param "x" u32) - (canon lift (core func $m2 "f") async (callback (func $m2 "cb")))) + (canon lift (core func $m2 "f") async (callback (core func $m2 "cb")))) ;; async func() -> u32 (core module $m3 @@ -66,7 +66,7 @@ (func (export "f") (result i32) unreachable)) (core instance $m3 (instantiate $m3)) (func async (result u32) - (canon lift (core func $m3 "f") async (callback (func $m3 "cb")))) + (canon lift (core func $m3 "f") async (callback (core func $m3 "cb")))) ;; async func(x: f32) (core module $m4 @@ -74,7 +74,7 @@ (func (export "f") (param f32) (result i32) unreachable)) (core instance $m4 (instantiate $m4)) (func async (param "x" f32) - (canon lift (core func $m4 "f") async (callback (func $m4 "cb")))) + (canon lift (core func $m4 "f") async (callback (core func $m4 "cb")))) ;; async func(x: f32, y: string) (core module $m5 @@ -84,8 +84,8 @@ (func (export "f") (param f32 i32 i32) (result i32) unreachable)) (core instance $m5 (instantiate $m5)) (func async (param "x" f32) (param "y" string) - (canon lift (core func $m5 "f") async (callback (func $m5 "cb")) - (memory $m5 "memory") (realloc (func $m5 "realloc")))) + (canon lift (core func $m5 "f") async (callback (core func $m5 "cb")) + (memory (core memory $m5 "memory")) (realloc (core func $m5 "realloc")))) ;; async func(x: list) (core module $m6 @@ -95,8 +95,8 @@ (func (export "f") (param i32 i32 i32 i32 i32 i32 i32 i32) (result i32) unreachable)) (core instance $m6 (instantiate $m6)) (func async (param "x" (list string 4)) - (canon lift (core func $m6 "f") async (callback (func $m6 "cb")) - (memory $m6 "memory") (realloc (func $m6 "realloc")))) + (canon lift (core func $m6 "f") async (callback (core func $m6 "cb")) + (memory (core memory $m6 "memory")) (realloc (core func $m6 "realloc")))) ;; async func(x: list) (core module $m7 @@ -106,6 +106,6 @@ (func (export "f") (param i32) (result i32) unreachable)) (core instance $m7 (instantiate $m7)) (func async (param "x" (list string 10)) - (canon lift (core func $m7 "f") async (callback (func $m7 "cb")) - (memory $m7 "memory") (realloc (func $m7 "realloc")))) + (canon lift (core func $m7 "f") async (callback (core func $m7 "cb")) + (memory (core memory $m7 "memory")) (realloc (core func $m7 "realloc")))) ) diff --git a/tests/cli/component-model/async/futures.wast b/tests/cli/component-model/async/futures.wast index 8a2e24b93d..566fb59bc4 100644 --- a/tests/cli/component-model/async/futures.wast +++ b/tests/cli/component-model/async/futures.wast @@ -31,7 +31,7 @@ (import "" "future.read" (func $future-read (param i32 i32) (result i32))) ) (type $future-type (future u8)) - (core func $future-read (canon future.read $future-type async (memory $libc "memory"))) + (core func $future-read (canon future.read $future-type async (memory (core memory $libc "memory")))) (core instance $i (instantiate $m (with "" (instance (export "future.read" (func $future-read)))))) ) @@ -56,7 +56,7 @@ (import "" "future.read" (func $future-read (param i32 i32) (result i32))) ) (type $future-type (future string)) - (core func $future-read (canon future.read $future-type async (memory $libc "memory") (realloc (func $libc "realloc")))) + (core func $future-read (canon future.read $future-type async (memory (core memory $libc "memory")) (realloc (core func $libc "realloc")))) (core instance $i (instantiate $m (with "" (instance (export "future.read" (func $future-read)))))) ) @@ -69,7 +69,7 @@ (import "" "future.read" (func $future-read (param i32) (result i32))) ) (type $future-type (future u8)) - (core func $future-read (canon future.read $future-type async (memory $libc "memory"))) + (core func $future-read (canon future.read $future-type async (memory (core memory $libc "memory")))) (core instance $i (instantiate $m (with "" (instance (export "future.read" (func $future-read)))))) ) "type mismatch for export `future.read` of module instantiation argument ``" @@ -84,7 +84,7 @@ (import "" "future.read" (func $future-read (param i32 i32) (result i32))) ) (type $string-type string) - (core func $future-read (canon future.read $string-type async (memory $libc "memory"))) + (core func $future-read (canon future.read $string-type async (memory (core memory $libc "memory")))) (core instance $i (instantiate $m (with "" (instance (export "future.read" (func $future-read)))))) ) "`future.read` requires a future type" @@ -99,7 +99,7 @@ (import "" "future.read" (func $future-read (param i32 i32) (result i32))) ) (type $future-type (future string)) - (core func $future-read (canon future.read $future-type async (memory $libc "memory"))) + (core func $future-read (canon future.read $future-type async (memory (core memory $libc "memory")))) (core instance $i (instantiate $m (with "" (instance (export "future.read" (func $future-read)))))) ) "canonical option `realloc` is required" @@ -113,7 +113,7 @@ (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 (memory $libc "memory"))) + (core func $future-write (canon future.write $future-type async (memory (core memory $libc "memory")))) (core instance $i (instantiate $m (with "" (instance (export "future.write" (func $future-write)))))) ) @@ -136,7 +136,7 @@ (import "" "future.write" (func $future-write (param i32) (result i32))) ) (type $future-type (future u8)) - (core func $future-write (canon future.write $future-type async (memory $libc "memory"))) + (core func $future-write (canon future.write $future-type async (memory (core memory $libc "memory")))) (core instance $i (instantiate $m (with "" (instance (export "future.write" (func $future-write)))))) ) "type mismatch for export `future.write` of module instantiation argument ``" diff --git a/tests/cli/component-model/async/lift.wast b/tests/cli/component-model/async/lift.wast index 800f4797b5..45910155a4 100644 --- a/tests/cli/component-model/async/lift.wast +++ b/tests/cli/component-model/async/lift.wast @@ -10,7 +10,7 @@ (core instance $i (instantiate $m)) (func (export "foo") (param "p1" u32) (result u32) - (canon lift (core func $i "foo") async (post-return (func $i "post-return-foo"))) + (canon lift (core func $i "foo") async (post-return (core func $i "post-return-foo"))) ) ) "cannot specify post-return function in async" @@ -25,7 +25,7 @@ (core instance $i (instantiate $m)) (func (export "foo") async (param "p1" u32) (result u32) - (canon lift (core func $i "foo") async (callback (func $i "callback"))) + (canon lift (core func $i "foo") async (callback (core func $i "callback"))) ) ) @@ -39,7 +39,7 @@ (core instance $i (instantiate $m)) (func (export "foo") (param "p1" u32) (result u32) - (canon lift (core func $i "foo") async (callback (func $i "callback"))) + (canon lift (core func $i "foo") async (callback (core func $i "callback"))) ) ) "canonical option `callback` uses a core function with an incorrect signature" @@ -56,7 +56,7 @@ (core instance $i (instantiate $m)) (func (export "foo") (param "p1" u32) (result u32) - (canon lift (core func $i "foo") async (callback (func $i "callback")) (post-return (func $i "post-return-foo"))) + (canon lift (core func $i "foo") async (callback (core func $i "callback")) (post-return (core func $i "post-return-foo"))) ) ) "cannot specify post-return function in async" @@ -72,7 +72,7 @@ (core instance $i (instantiate $m)) (func (export "foo") async (param "p1" u32) (result u32) - (canon lift (core func $i "foo") async (callback (func $i "callback"))) + (canon lift (core func $i "foo") async (callback (core func $i "callback"))) ) ) "lowered parameter types `[I32]` do not match parameter types `[I32, I32]` of core function 0" @@ -87,7 +87,7 @@ (core instance $i (instantiate $m)) (func (export "foo") (param "p1" u32) (result u32) - (canon lift (core func $i "foo") async (callback (func $i "callback"))) + (canon lift (core func $i "foo") async (callback (core func $i "callback"))) ) ) "core instance 0 has no export named `callback`" @@ -103,7 +103,7 @@ (core instance $i (instantiate $m)) (func (export "foo") (param "p1" u32) (result u32) - (canon lift (core func $i "foo") (callback (func $i "callback"))) + (canon lift (core func $i "foo") (callback (core func $i "callback"))) ) ) "cannot specify callback without async" @@ -119,7 +119,7 @@ (core instance $i (instantiate $m)) (func (export "foo") async (result string) - (canon lift (core func $i "foo") async (callback (func $i "callback"))) + (canon lift (core func $i "foo") async (callback (core func $i "callback"))) ) ) "canonical option `memory` is required" @@ -135,7 +135,7 @@ (core instance $i (instantiate $m)) (func (export "foo") async (result (tuple u32 u32 u32 u32 u32 u32 u32 u32 u32 u32 u32 u32 u32 u32 u32 u32 u32)) - (canon lift (core func $i "foo") async (callback (func $i "callback"))) + (canon lift (core func $i "foo") async (callback (core func $i "callback"))) ) ) "canonical option `memory` is required" @@ -150,7 +150,7 @@ ) (core instance $i (instantiate $m)) - (func (canon lift (core func $i "foo") async (callback (func $i "callback")))) + (func (canon lift (core func $i "foo") async (callback (core func $i "callback")))) ) "the `async` canonical option requires an async function type" ) diff --git a/tests/cli/component-model/async/lower.wast b/tests/cli/component-model/async/lower.wast index 3d1a7b618d..3f62fa8e53 100644 --- a/tests/cli/component-model/async/lower.wast +++ b/tests/cli/component-model/async/lower.wast @@ -5,7 +5,7 @@ (import "foo" (func $foo async (param "p1" u32) (result u32))) (core module $libc (memory (export "memory") 1)) (core instance $libc (instantiate $libc)) - (core func $foo (canon lower (func $foo) async (memory $libc "memory"))) + (core func $foo (canon lower (func $foo) async (memory (core memory $libc "memory")))) (core module $m (func (import "" "foo") (param i32 i32) (result i32)) ) @@ -18,7 +18,7 @@ (import "foo" (func $foo async (param "p1" u32) (result u32))) (core module $libc (memory (export "memory") 1)) (core instance $libc (instantiate $libc)) - (core func $foo (canon lower (func $foo) async (memory $libc "memory"))) + (core func $foo (canon lower (func $foo) async (memory (core memory $libc "memory")))) (core module $m (func (import "" "foo") (param i32) (result i32)) ) diff --git a/tests/cli/component-model/async/stackful.wast b/tests/cli/component-model/async/stackful.wast index ed4f8b6dde..0d5fe23f1b 100644 --- a/tests/cli/component-model/async/stackful.wast +++ b/tests/cli/component-model/async/stackful.wast @@ -7,7 +7,7 @@ (core module $m (import "" "waitable-set.wait" (func $waitable-set-wait (param i32 i32) (result i32))) ) - (core func $waitable-set-wait (canon waitable-set.wait cancellable (memory $libc "memory"))) + (core func $waitable-set-wait (canon waitable-set.wait cancellable (memory (core memory $libc "memory")))) (core instance $i (instantiate $m (with "" (instance (export "waitable-set.wait" (func $waitable-set-wait)))))) ) @@ -19,7 +19,7 @@ (core module $m (import "" "waitable-set.wait" (func $waitable-set-wait (param i32) (result i32))) ) - (core func $waitable-set-wait (canon waitable-set.wait cancellable (memory $libc "memory"))) + (core func $waitable-set-wait (canon waitable-set.wait cancellable (memory (core memory $libc "memory")))) (core instance $i (instantiate $m (with "" (instance (export "waitable-set.wait" (func $waitable-set-wait)))))) ) "type mismatch for export `waitable-set.wait` of module instantiation argument ``" @@ -32,7 +32,7 @@ (core module $m (import "" "waitable-set.poll" (func $waitable-set-poll (param i32 i32) (result i32))) ) - (core func $waitable-set-poll (canon waitable-set.poll cancellable (memory $libc "memory"))) + (core func $waitable-set-poll (canon waitable-set.poll cancellable (memory (core memory $libc "memory")))) (core instance $i (instantiate $m (with "" (instance (export "waitable-set.poll" (func $waitable-set-poll)))))) ) @@ -44,7 +44,7 @@ (core module $m (import "" "waitable-set.poll" (func $waitable-set-poll (param i32) (result i32))) ) - (core func $waitable-set-poll (canon waitable-set.poll cancellable (memory $libc "memory"))) + (core func $waitable-set-poll (canon waitable-set.poll cancellable (memory (core memory $libc "memory")))) (core instance $i (instantiate $m (with "" (instance (export "waitable-set.poll" (func $waitable-set-poll)))))) ) "type mismatch for export `waitable-set.poll` of module instantiation argument ``" @@ -109,7 +109,7 @@ (core instance $m5 (instantiate $m5)) (func async (param "x" f32) (param "y" string) (canon lift (core func $m5 "f") async - (memory $m5 "memory") (realloc (func $m5 "realloc")))) + (memory (core memory $m5 "memory")) (realloc (core func $m5 "realloc")))) ;; async func(x: list) (core module $m6 @@ -119,7 +119,7 @@ (core instance $m6 (instantiate $m6)) (func async (param "x" (list string 4)) (canon lift (core func $m6 "f") async - (memory $m6 "memory") (realloc (func $m6 "realloc")))) + (memory (core memory $m6 "memory")) (realloc (core func $m6 "realloc")))) ;; async func(x: list) (core module $m7 @@ -129,7 +129,7 @@ (core instance $m7 (instantiate $m7)) (func async (param "x" (list string 10)) (canon lift (core func $m7 "f") async - (memory $m7 "memory") (realloc (func $m7 "realloc")))) + (memory (core memory $m7 "memory")) (realloc (core func $m7 "realloc")))) ) ;; async lift; no callback diff --git a/tests/cli/component-model/async/streams.wast b/tests/cli/component-model/async/streams.wast index 0bea0682b7..83a4c7f093 100644 --- a/tests/cli/component-model/async/streams.wast +++ b/tests/cli/component-model/async/streams.wast @@ -31,7 +31,7 @@ (import "" "stream.read" (func $stream-read (param i32 i32 i32) (result i32))) ) (type $stream-type (stream u8)) - (core func $stream-read (canon stream.read $stream-type async (memory $libc "memory"))) + (core func $stream-read (canon stream.read $stream-type async (memory (core memory $libc "memory")))) (core instance $i (instantiate $m (with "" (instance (export "stream.read" (func $stream-read)))))) ) @@ -56,7 +56,7 @@ (import "" "stream.read" (func $stream-read (param i32 i32 i32) (result i32))) ) (type $stream-type (stream string)) - (core func $stream-read (canon stream.read $stream-type async (memory $libc "memory") (realloc (func $libc "realloc")))) + (core func $stream-read (canon stream.read $stream-type async (memory (core memory $libc "memory")) (realloc (core func $libc "realloc")))) (core instance $i (instantiate $m (with "" (instance (export "stream.read" (func $stream-read)))))) ) @@ -69,7 +69,7 @@ (import "" "stream.read" (func $stream-read (param i32) (result i32))) ) (type $stream-type (stream u8)) - (core func $stream-read (canon stream.read $stream-type async (memory $libc "memory"))) + (core func $stream-read (canon stream.read $stream-type async (memory (core memory $libc "memory")))) (core instance $i (instantiate $m (with "" (instance (export "stream.read" (func $stream-read)))))) ) "type mismatch for export `stream.read` of module instantiation argument ``" @@ -84,7 +84,7 @@ (import "" "stream.read" (func $stream-read (param i32 i32 i32) (result i32))) ) (type $string-type string) - (core func $stream-read (canon stream.read $string-type async (memory $libc "memory"))) + (core func $stream-read (canon stream.read $string-type async (memory (core memory $libc "memory")))) (core instance $i (instantiate $m (with "" (instance (export "stream.read" (func $stream-read)))))) ) "`stream.read` requires a stream type" @@ -99,7 +99,7 @@ (import "" "stream.read" (func $stream-read (param i32 i32 i32) (result i32))) ) (type $stream-type (stream string)) - (core func $stream-read (canon stream.read $stream-type async (memory $libc "memory"))) + (core func $stream-read (canon stream.read $stream-type async (memory (core memory $libc "memory")))) (core instance $i (instantiate $m (with "" (instance (export "stream.read" (func $stream-read)))))) ) "canonical option `realloc` is required" @@ -113,7 +113,7 @@ (import "" "stream.write" (func $stream-write (param i32 i32 i32) (result i32))) ) (type $stream-type (stream u8)) - (core func $stream-write (canon stream.write $stream-type async (memory $libc "memory"))) + (core func $stream-write (canon stream.write $stream-type async (memory (core memory $libc "memory")))) (core instance $i (instantiate $m (with "" (instance (export "stream.write" (func $stream-write)))))) ) @@ -136,7 +136,7 @@ (import "" "stream.write" (func $stream-write (param i32) (result i32))) ) (type $stream-type (stream u8)) - (core func $stream-write (canon stream.write $stream-type async (memory $libc "memory"))) + (core func $stream-write (canon stream.write $stream-type async (memory (core memory $libc "memory")))) (core instance $i (instantiate $m (with "" (instance (export "stream.write" (func $stream-write)))))) ) "type mismatch for export `stream.write` 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 1f41779abc..1379229e12 100644 --- a/tests/cli/component-model/async/task-builtins.wast +++ b/tests/cli/component-model/async/task-builtins.wast @@ -83,7 +83,7 @@ (memory (export "m") 0) ) (core instance $m (instantiate $m)) - (core func $task-return (canon task.return (result u32) (realloc (func $m "r")) (memory $m "m"))) + (core func $task-return (canon task.return (result u32) (realloc (core func $m "r")) (memory (core memory $m "m")))) ) "cannot specify `realloc` option on `task.return`") @@ -95,7 +95,7 @@ (core func (canon task.return (result u32) string-encoding=utf8)) (core func (canon task.return (result u32) string-encoding=utf16)) (core func (canon task.return (result u32) string-encoding=latin1+utf16)) - (core func (canon task.return (result u32) (memory $i "m"))) + (core func (canon task.return (result u32) (memory (core memory $i "m")))) ) ;; task.cancel @@ -131,7 +131,7 @@ (core module $m (import "" "waitable-set.wait" (func $waitable-set-wait (param i32 i32) (result i32))) ) - (core func $waitable-set-wait (canon waitable-set.wait (memory $libc "memory"))) + (core func $waitable-set-wait (canon waitable-set.wait (memory (core memory $libc "memory")))) (core instance $i (instantiate $m (with "" (instance (export "waitable-set.wait" (func $waitable-set-wait)))))) ) @@ -143,7 +143,7 @@ (core module $m (import "" "waitable-set.wait" (func $waitable-set-wait (param i32) (result i32))) ) - (core func $waitable-set-wait (canon waitable-set.wait (memory $libc "memory"))) + (core func $waitable-set-wait (canon waitable-set.wait (memory (core memory $libc "memory")))) (core instance $i (instantiate $m (with "" (instance (export "waitable-set.wait" (func $waitable-set-wait)))))) ) "type mismatch for export `waitable-set.wait` of module instantiation argument ``" @@ -155,7 +155,7 @@ (core module $m (import "" "waitable-set.wait" (func $waitable-set-wait (param i32 i32) (result i32))) ) - (core func $waitable-set-wait (canon waitable-set.wait cancellable (memory $libc "memory"))) + (core func $waitable-set-wait (canon waitable-set.wait cancellable (memory (core memory $libc "memory")))) (core instance $i (instantiate $m (with "" (instance (export "waitable-set.wait" (func $waitable-set-wait)))))) ) @@ -166,7 +166,7 @@ (core module $m (import "" "waitable-set.poll" (func $waitable-set-poll (param i32 i32) (result i32))) ) - (core func $waitable-set-poll (canon waitable-set.poll (memory $libc "memory"))) + (core func $waitable-set-poll (canon waitable-set.poll (memory (core memory $libc "memory")))) (core instance $i (instantiate $m (with "" (instance (export "waitable-set.poll" (func $waitable-set-poll)))))) ) (component @@ -175,7 +175,7 @@ (core module $m (import "" "waitable-set.poll" (func $waitable-set-poll (param i32 i32) (result i32))) ) - (core func $waitable-set-poll (canon waitable-set.poll cancellable (memory $libc "memory"))) + (core func $waitable-set-poll (canon waitable-set.poll cancellable (memory (core memory $libc "memory")))) (core instance $i (instantiate $m (with "" (instance (export "waitable-set.poll" (func $waitable-set-poll)))))) ) @@ -187,7 +187,7 @@ (core module $m (import "" "waitable-set.poll" (func $waitable-set-poll (param i32) (result i32))) ) - (core func $waitable-set-poll (canon waitable-set.poll (memory $libc "memory"))) + (core func $waitable-set-poll (canon waitable-set.poll (memory (core memory $libc "memory")))) (core instance $i (instantiate $m (with "" (instance (export "waitable-set.poll" (func $waitable-set-poll)))))) ) "type mismatch for export `waitable-set.poll` of module instantiation argument ``" diff --git a/tests/cli/component-model/async/threading.wast b/tests/cli/component-model/async/threading.wast index 9034e10baa..5d9c1c8124 100644 --- a/tests/cli/component-model/async/threading.wast +++ b/tests/cli/component-model/async/threading.wast @@ -54,14 +54,14 @@ (core type $start (func (param $context i32))) (core module $libc (table (export "start-table") 1 (ref null func))) (core instance $libc (instantiate $libc)) - (core func $new-indirect (canon thread.new-indirect $start (table $libc "start-table"))) + (core func $new-indirect (canon thread.new-indirect $start (core table $libc "start-table"))) ) (component (core type $start (func (param $context i32))) (core module $libc (table (export "start-table") 1 (ref null func))) (core instance $libc (instantiate $libc)) - (core func $new-indirect (canon thread.new-indirect $start (table $libc "start-table"))) + (core func $new-indirect (canon thread.new-indirect $start (core table $libc "start-table"))) (core module $m (type $new-indirect-ty (func (param i32) (param i32) (result i32))) @@ -80,7 +80,7 @@ (core type $start (func (param i32))) ;; Refer to a non-existent table type (i.e., 0); validation ;; for `thread.new-indirect` happens first. - (core func $new-indirect (canon thread.new-indirect $start (table 0))) + (core func $new-indirect (canon thread.new-indirect $start (core table 0))) ) "unknown table 0: table index out of bounds" ) @@ -90,7 +90,7 @@ (core type $start (func)) (core module $libc (table (export "start-table") 1 (ref null func))) (core instance $libc (instantiate $libc)) - (core func $new-indirect (canon thread.new-indirect $start (table $libc "start-table"))) + (core func $new-indirect (canon thread.new-indirect $start (core table $libc "start-table"))) ) "start function must take a single `i32` argument" ) @@ -241,8 +241,8 @@ (canon context.set i32 1 (core func)) (core type $start (func (param i32))) - (core func (canon thread.new-indirect $start (table $start-table))) - (canon thread.new-indirect $start (table $start-table) (core func)) + (core func (canon thread.new-indirect $start (core table $start-table))) + (canon thread.new-indirect $start (core table $start-table) (core func)) (core func (canon thread.resume-later)) (canon thread.resume-later (core func)) diff --git a/tests/cli/component-model/big.wast b/tests/cli/component-model/big.wast index 770df0ab8a..e3f23ccf6a 100644 --- a/tests/cli/component-model/big.wast +++ b/tests/cli/component-model/big.wast @@ -11,7 +11,7 @@ (core instance $libc (instantiate $Libc)) (core func $log (canon lower (func $logging "log") - (memory $libc "memory") (realloc (func $libc "realloc")) + (memory (core memory $libc "memory")) (realloc (core func $libc "realloc")) )) (core module $Main (import "libc" "memory" (memory 1)) @@ -30,7 +30,7 @@ )) (func $run (param "in" string) (result string) (canon lift (core func $main "run") - (memory $libc "memory") (realloc (func $libc "realloc")) + (memory (core memory $libc "memory")) (realloc (core func $libc "realloc")) )) (export "run" (func $run)) ) diff --git a/tests/cli/component-model/custom-page-sizes.wast b/tests/cli/component-model/custom-page-sizes.wast index ef3c36f995..28c56f4d87 100644 --- a/tests/cli/component-model/custom-page-sizes.wast +++ b/tests/cli/component-model/custom-page-sizes.wast @@ -7,7 +7,7 @@ (memory (export "m") 1 (pagesize 65536)) ) (core instance $i (instantiate $m)) - (core func (canon lower (func $f) (memory $i "m"))) + (core func (canon lower (func $f) (memory (core memory $i "m")))) ) ;; compat with custom page sizes. @@ -17,7 +17,7 @@ (memory (export "m") 1 (pagesize 1)) ) (core instance $i (instantiate $m)) - (core func (canon lower (func $f) (memory $i "m"))) + (core func (canon lower (func $f) (memory (core memory $i "m")))) ) ;; subtyping works with explict page sizes diff --git a/tests/cli/component-model/error-context/error-context.wast b/tests/cli/component-model/error-context/error-context.wast index ead72e4f55..18b082624a 100644 --- a/tests/cli/component-model/error-context/error-context.wast +++ b/tests/cli/component-model/error-context/error-context.wast @@ -7,7 +7,7 @@ (core module $m (import "" "error-context.new" (func $error-context-new (param i32 i32) (result i32))) ) - (core func $error-context-new (canon error-context.new (memory $libc "memory"))) + (core func $error-context-new (canon error-context.new (memory (core memory $libc "memory")))) (core instance $i (instantiate $m (with "" (instance (export "error-context.new" (func $error-context-new)))))) ) @@ -19,7 +19,7 @@ (core module $m (import "" "error-context.new" (func $error-context-new (param i32) (result i32))) ) - (core func $error-context-new (canon error-context.new (memory $libc "memory"))) + (core func $error-context-new (canon error-context.new (memory (core memory $libc "memory")))) (core instance $i (instantiate $m (with "" (instance (export "error-context.new" (func $error-context-new)))))) ) "type mismatch for export `error-context.new` of module instantiation argument ``" @@ -35,7 +35,7 @@ (core module $m (import "" "error-context.debug-message" (func $error-context-debug-message (param i32 i32))) ) - (core func $error-context-debug-message (canon error-context.debug-message (memory $libc "memory") (realloc (func $libc "realloc")))) + (core func $error-context-debug-message (canon error-context.debug-message (memory (core memory $libc "memory")) (realloc (core func $libc "realloc")))) (core instance $i (instantiate $m (with "" (instance (export "error-context.debug-message" (func $error-context-debug-message)))))) ) @@ -50,7 +50,7 @@ (core module $m (import "" "error-context.debug-message" (func $error-context-debug-message (param i32) (result i32))) ) - (core func $error-context-debug-message (canon error-context.debug-message (memory $libc "memory") (realloc (func $libc "realloc")))) + (core func $error-context-debug-message (canon error-context.debug-message (memory (core memory $libc "memory")) (realloc (core func $libc "realloc")))) (core instance $i (instantiate $m (with "" (instance (export "error-context.debug-message" (func $error-context-debug-message)))))) ) "type mismatch for export `error-context.debug-message` of module instantiation argument ``" diff --git a/tests/cli/component-model/fixed-length-lists.wast b/tests/cli/component-model/fixed-length-lists.wast index 8a12cb059a..63c1e19200 100644 --- a/tests/cli/component-model/fixed-length-lists.wast +++ b/tests/cli/component-model/fixed-length-lists.wast @@ -8,7 +8,7 @@ (core instance $i (instantiate $m)) (func (export "ret-list") (result (list u32 4)) - (canon lift (core func $i "ret-list") (memory $i "memory")) + (canon lift (core func $i "ret-list") (memory (core memory $i "memory"))) ) ) @@ -32,7 +32,7 @@ (core instance $i (instantiate $m)) (func (export "ret-list") (result (list u32 0)) - (canon lift (core func $i "ret-list") (memory $i "memory")) + (canon lift (core func $i "ret-list") (memory (core memory $i "memory"))) ) ) "Fixed-length lists must have more than zero elements (at offset 0x54)" @@ -47,7 +47,7 @@ (core instance $i (instantiate $m)) (func (export "ret-list") (result (list u32 4294967295)) - (canon lift (core func $i "ret-list") (memory $i "memory")) + (canon lift (core func $i "ret-list") (memory (core memory $i "memory"))) ) ) "fixed-length list element count exceeds limit of 1073741824 (at offset 0x54)" diff --git a/tests/cli/component-model/func.wast b/tests/cli/component-model/func.wast index 4a207f9962..55ccca69d5 100644 --- a/tests/cli/component-model/func.wast +++ b/tests/cli/component-model/func.wast @@ -42,7 +42,7 @@ (memory (export "memory") 1) ) (core instance $libc (instantiate $libc)) - (core func (canon lower (func $log) (memory $libc "memory"))) + (core func (canon lower (func $log) (memory (core memory $libc "memory")))) ) (component @@ -53,7 +53,7 @@ (core instance $i (instantiate $m)) (func (export "ret-list") (result (list u8)) - (canon lift (core func $i "ret-list") (memory $i "memory")) + (canon lift (core func $i "ret-list") (memory (core memory $i "memory"))) ) ) @@ -69,7 +69,7 @@ (import "big" (func $big (type $big))) (core module $libc (memory (export "memory") 1)) (core instance $libc (instantiate $libc)) - (core func $big (canon lower (func $big) (memory $libc "memory"))) + (core func $big (canon lower (func $big) (memory (core memory $libc "memory")))) ) ) @@ -89,7 +89,7 @@ )) (func $roundtrip (type $roundtrip) - (canon lift (core func $m "roundtrip") (memory $m "memory")) + (canon lift (core func $m "roundtrip") (memory (core memory $m "memory"))) ) (export "roundtrip" (func $roundtrip)) ) @@ -103,7 +103,7 @@ (memory (export "memory") 1) ) (core instance $libc (instantiate $libc)) - (core func (canon lower (func $log) (memory $libc "memory"))) + (core func (canon lower (func $log) (memory (core memory $libc "memory")))) ) "canonical option `realloc` is required" ) @@ -117,7 +117,7 @@ (core instance $i (instantiate $m)) (func (export "param-list") (param "bytes" (list u8)) - (canon lift (core func $i "param-list") (memory $i "memory")) + (canon lift (core func $i "param-list") (memory (core memory $i "memory"))) ) ) "canonical option `realloc` is required" diff --git a/tests/cli/component-model/indices.wast b/tests/cli/component-model/indices.wast new file mode 100644 index 0000000000..69dc56a5ee --- /dev/null +++ b/tests/cli/component-model/indices.wast @@ -0,0 +1,252 @@ +;; RUN: wast --assert default --snapshot tests/snapshots % -f cm-threading +;; RUN[lenient]: WAST_STRICT_COMPONENT_INDICES=0 wast --assert default --snapshot tests/snapshots % -f cm-threading + +;; test component instantiate parsing +(component + (component + (component $C (import "x" (func))) + (import "f" (func $f)) + (instance (instantiate $C (with "x" (func $f)))) + (instance (instantiate $C (with "x" (func 0)))) + (import "i" (instance $i (export "f" (func)))) + (instance (instantiate $C (with "x" (func $i "f")))) + (import "j" (instance $j + (export "a" (instance + (export "b" (instance + (export "f" (func)))))))) + (instance (instantiate $C (with "x" (func $j "a" "b" "f")))) + ) + + (component + (component $C (import "x" (instance))) + (import "i" (instance $i)) + (instance (instantiate $C (with "x" (instance $i)))) + (import "j" (instance $j (export "k" (instance)))) + (instance (instantiate $C (with "x" (instance $j "k")))) + ) + + (component + (component $C (import "x" (component))) + (import "c" (component $c)) + (instance (instantiate $C (with "x" (component $c)))) + (import "i" (instance $i (export "c" (component)))) + (instance (instantiate $C (with "x" (component $i "c")))) + ) + + (component + (component $C (import "x" (type (sub resource)))) + (import "t" (type $t (sub resource))) + (instance (instantiate $C (with "x" (type $t)))) + (instance (instantiate $C (with "x" (type 0)))) + (import "i" (instance $i (export "t" (type (sub resource))))) + (instance (instantiate $C (with "x" (type $i "t")))) + ) + + (component + (component $C (import "x" (core module))) + (import "m" (core module $m)) + (instance (instantiate $C (with "x" (core module $m)))) + (instance (instantiate $C (with "x" (core module 0)))) + (import "i" (instance $i (export "m" (core module)))) + (instance (instantiate $C (with "x" (core module $i "m")))) + (import "j" (instance $j + (export "a" (instance + (export "m" (core module)))))) + (instance (instantiate $C (with "x" (core module $j "a" "m")))) + ) +) + +;; test core instantiate parsing +(component + (component + (core module $M (import "" "" (func))) + (core module $E (func (export ""))) + (core instance $e (instantiate $E)) + (core instance (instantiate $M (with "" (instance $e)))) + (core instance (instantiate $M (with "" (instance 0)))) + (core instance (instantiate $M + (with "" (instance (export "" (func $e "")))))) + ) +) + +;; test canon lower parsing +(component + (component + (import "f" (func $f)) + (import "i" (instance $i (export "f" (func)))) + (import "j" (instance $j + (export "n" (instance + (export "f" (func)))))) + (canon lower (func $f) (core func)) + (canon lower (func $i "f") (core func)) + (canon lower (func 0) (core func)) + (canon lower (func $j "n" "f") (core func)) + (core func (canon lower (func 0))) + (core func (canon lower (func $f))) + (core func (canon lower (func $i "f"))) + (core func (canon lower (func $j "n" "f"))) + ) + + (component + (import "f" (func $f (param "x" string))) + (core module $L + (memory (export "mem") 1) + (func (export "realloc") (param i32 i32 i32 i32) (result i32) unreachable)) + (core instance $libc (instantiate $L)) + (alias core export $libc "mem" (core memory $mem)) + (alias core export $libc "realloc" (core func $realloc)) + (canon lower (func $f) + (memory 0) (realloc 0) + (core func)) + (canon lower (func $f) + (memory $mem) (realloc $realloc) + (core func)) + (canon lower (func 0) + (memory (core memory 0)) (realloc 0) + (core func)) + (canon lower (func 0) + (memory 0) (realloc (core func 0)) + (core func)) + (canon lower (func 0) + (memory (core memory 0)) (realloc (core func 0)) + (core func)) + (canon lower (func $f) + (memory 0) (realloc (core func $realloc)) + (core func)) + (canon lower (func $f) + (memory (core memory $mem)) (realloc 0) + (core func)) + (canon lower (func $f) + (memory (core memory $mem)) (realloc (core func $realloc)) + (core func)) + (canon lower (func $f) + (memory (core memory $libc "mem")) (realloc (core func $libc "realloc")) + (core func)) + (core func (canon lower (func $f) + (memory 0) (realloc 0))) + (core func (canon lower (func $f) + (memory $mem) (realloc $realloc))) + (core func (canon lower (func 0) + (memory (core memory 0)) + (realloc (core func 0)))) + (core func (canon lower (func $f) + (memory (core memory $mem)) (realloc (core func $realloc)))) + (core func (canon lower (func $f) + (memory (core memory $libc "mem")) (realloc (core func $libc "realloc")))) + ) +) + +;; test canon lift parsing +(component + (component + (core module $M (func (export "f"))) + (core instance $m (instantiate $M)) + (alias core export $m "f" (core func $f)) + (canon lift (core func $f) (func)) + (canon lift (core func 0) (func)) + (canon lift (core func $m "f") (func)) + (func (canon lift (core func $f))) + (func (canon lift (core func 0))) + (func (canon lift (core func $m "f"))) + ) + + (component + (core module $M + (memory (export "mem") 1) + (func (export "realloc") (param i32 i32 i32 i32) (result i32) unreachable) + (func (export "run") (param i32 i32) (result i32) unreachable) + (func (export "post") (param i32)) + ) + (core instance $m (instantiate $M)) + (alias core export $m "mem" (core memory $mem)) + (alias core export $m "realloc" (core func $realloc)) + (alias core export $m "post" (core func $post)) + (canon lift (core func $m "run") + (memory 0) + (realloc 0) + (post-return 1) + (func (param "s" string) (result string))) + (canon lift (core func $m "run") + (memory $mem) + (realloc $realloc) + (post-return $post) + (func (param "s" string) (result string))) + (canon lift (core func $m "run") + (memory (core memory $m "mem")) + (realloc $realloc) + (post-return $post) + (func (param "s" string) (result string))) + (canon lift (core func $m "run") + (memory $mem) + (realloc (core func $m "realloc")) + (post-return $post) + (func (param "s" string) (result string))) + (canon lift (core func $m "run") + (memory $mem) + (realloc $realloc) + (post-return (core func $m "post")) + (func (param "s" string) (result string))) + (canon lift (core func $m "run") + (memory (core memory $m "mem")) + (realloc (core func $m "realloc")) + (post-return (core func $m "post")) + (func (param "s" string) (result string))) + ) +) + +;; test resource type parsing +(component + (component + (core module $M (func (export "dtor") (param i32))) + (core instance $m (instantiate $M)) + (alias core export $m "dtor" (core func $dtor)) + (type $R1 (resource (rep i32) (dtor $dtor))) + (type $R2 (resource (rep i32) (dtor 0))) + (type $R3 (resource (rep i32) (dtor (core func $dtor)))) + (type $R4 (resource (rep i32) (dtor (core func $m "dtor")))) + ) +) + +;; test waitable-set.wait/poll parsing +(component + (component + (core module $M (memory (export "mem") 1)) + (core instance $m (instantiate $M)) + (alias core export $m "mem" (core memory $mem)) + (canon waitable-set.wait (memory $mem) (core func)) + (canon waitable-set.wait (memory 0) (core func)) + (canon waitable-set.wait (memory (core memory $mem)) (core func)) + (canon waitable-set.wait (memory (core memory $m "mem")) (core func)) + (canon waitable-set.poll (memory (core memory $mem)) (core func)) + (canon waitable-set.poll (memory (core memory $m "mem")) (core func)) + ) +) + +;; test thread.new-indirect +(component + (component + (core type $ft (func (param i32))) + (core module $M (table (export "tbl") 1 funcref)) + (core instance $m (instantiate $M)) + (alias core export $m "tbl" (core table $tbl)) + (canon thread.new-indirect 0 0 (core func)) + (canon thread.new-indirect $ft $tbl (core func)) + (canon thread.new-indirect $ft (core table $tbl) (core func)) + (canon thread.new-indirect (core type $ft) $tbl (core func)) + (canon thread.new-indirect (core type $ft) (core table $tbl) (core func)) + (canon thread.new-indirect (core type $ft) (core table $m "tbl") (core func)) + ) +) + +;; test component-level typeidx in canon built-ins +(component + (component + (type $T (future u32)) + (import "i" (instance $i (export "T" (type (eq $T))))) + (canon future.new $T (core func)) + (canon future.new 0 (core func)) + (canon future.new (type $T) (core func)) + (canon future.new (type 0) (core func)) + (canon future.new (type $i "T") (core func)) + ) +) diff --git a/tests/cli/component-model/legacy-indices.wast b/tests/cli/component-model/legacy-indices.wast new file mode 100644 index 0000000000..bc8160b91d --- /dev/null +++ b/tests/cli/component-model/legacy-indices.wast @@ -0,0 +1,93 @@ +;; RUN: WAST_STRICT_COMPONENT_INDICES=0 wast --assert default --snapshot tests/snapshots % -f cm-async,cm-threading,shared-everything-threads,gc,cm-gc + +;; legacy `(memory $i "name")` and `(realloc (func ...))` in canonopts of +;; `canon lower` +(component + (import "f" (func $f (param "x" string))) + (core module $libc + (memory (export "mem") 1) + (func (export "realloc") (param i32 i32 i32 i32) (result i32) unreachable)) + (core instance $libc (instantiate $libc)) + (alias core export $libc "realloc" (core func $realloc)) + (core func (canon lower (func $f) + (memory $libc "mem") + (realloc (func $libc "realloc")))) + (core func (canon lower (func $f) + (memory $libc "mem") + (realloc (func $realloc)))) + (core func (canon lower (func $f) + (memory $libc "mem") + (realloc (func 0)))) +) + +;; legacy `(memory $i "name")`, `(realloc (func ...))` and +;; `(post-return (func ...))` in canonopts of `canon lift` +(component + (core module $m + (memory (export "mem") 1) + (func (export "realloc") (param i32 i32 i32 i32) (result i32) unreachable) + (func (export "run") (param i32 i32) (result i32) unreachable) + (func (export "post") (param i32))) + (core instance $m (instantiate $m)) + (func (export "run") (param "s" string) (result string) + (canon lift (core func $m "run") + (memory $m "mem") + (realloc (func $m "realloc")) + (post-return (func $m "post")))) +) + +;; legacy `(callback (func ...))` +(component + (core module $m + (func (export "cb") (param i32 i32 i32) (result i32) unreachable) + (func (export "f") (result i32) unreachable)) + (core instance $m (instantiate $m)) + (func async + (canon lift (core func $m "f") async (callback (func $m "cb")))) +) + +;; legacy `(dtor (func ...))` in resource types +(component + (core module $m (func (export "dtor") (param i32))) + (core instance $m (instantiate $m)) + (alias core export $m "dtor" (core func $dtor)) + (type $R1 (resource (rep i32) (dtor (func $dtor)))) + (type $R2 (resource (rep i32) (dtor (func 0)))) + (type $R3 (resource (rep i32) (dtor (func $m "dtor")))) +) + +;; legacy `(table ...)` in `thread.new-indirect` +(component + (core type $start (func (param $context i32))) + (core module $libc (table (export "start-table") 1 (ref null func))) + (core instance $libc (instantiate $libc)) + (alias core export $libc "start-table" (core table $tbl)) + (core func (canon thread.new-indirect $start (table $libc "start-table"))) + (core func (canon thread.new-indirect $start (table $tbl))) + (core func (canon thread.new-indirect $start (table 0))) +) + +;; legacy `(table ...)` in `thread.spawn-indirect` +(component + (core type $start (shared (func (param $context i32)))) + (core module $libc (table (export "start-table") shared 1 (ref null (shared func)))) + (core instance $libc (instantiate $libc)) + (core func (canon thread.spawn-indirect $start (table $libc "start-table"))) +) + +;; legacy `(memory $i "name")` in `waitable-set.wait` and `waitable-set.poll` +(component + (core module $libc (memory (export "memory") 1)) + (core instance $libc (instantiate $libc)) + (core func (canon waitable-set.wait (memory $libc "memory"))) + (core func (canon waitable-set.poll (memory $libc "memory"))) +) + +;; legacy `(core-type (type ...))` +(component + (core type $ty (func (param externref))) + (import "i" (instance $i + (export "r" (type $resource (sub resource))) + (export "f" (func (param "x" (own $resource)))))) + (core func (canon lower (func $i "f") gc string-encoding=utf8 (core-type (type $ty)))) +) diff --git a/tests/cli/component-model/map.wast b/tests/cli/component-model/map.wast index dc3c620727..709cd961ba 100644 --- a/tests/cli/component-model/map.wast +++ b/tests/cli/component-model/map.wast @@ -8,7 +8,7 @@ (core instance $i (instantiate $m)) (func (export "ret-map") (result (map string u32)) - (canon lift (core func $i "ret-map") (memory $i "memory")) + (canon lift (core func $i "ret-map") (memory (core memory $i "memory"))) ) ) @@ -21,7 +21,7 @@ (core instance $i (instantiate $m)) (func (export "param-map") (param "m" (map string u32)) - (canon lift (core func $i "param-map") (memory $i "memory") (realloc (func $i "realloc"))) + (canon lift (core func $i "param-map") (memory (core memory $i "memory")) (realloc (core func $i "realloc"))) ) ) diff --git a/tests/cli/component-model/memory64/list.wast b/tests/cli/component-model/memory64/list.wast index 1dd86f61c2..6017456402 100644 --- a/tests/cli/component-model/memory64/list.wast +++ b/tests/cli/component-model/memory64/list.wast @@ -8,6 +8,6 @@ ) (core instance $m (instantiate $m)) (func (export "a") (param "a" (list u8)) (result (list u8)) - (canon lift (core func $m "f") (realloc (func $m "realloc")) (memory $m "memory")) + (canon lift (core func $m "f") (realloc (core func $m "realloc")) (memory (core memory $m "memory"))) ) ) diff --git a/tests/cli/component-model/memory64/realloc.wast b/tests/cli/component-model/memory64/realloc.wast index 04249e8a97..313fed103f 100644 --- a/tests/cli/component-model/memory64/realloc.wast +++ b/tests/cli/component-model/memory64/realloc.wast @@ -9,8 +9,8 @@ (core instance $i (instantiate $m)) (func (result string) (canon lift (core func $i "f") - (memory $i "m") - (realloc (func $i "realloc")) + (memory (core memory $i "m")) + (realloc (core func $i "realloc")) ) ) ) @@ -25,8 +25,8 @@ (core instance $i (instantiate $m)) (func (param "p1" (list u8)) (canon lift (core func $i "f") - (memory $i "m") - (realloc (func $i "realloc")) + (memory (core memory $i "m")) + (realloc (core func $i "realloc")) ) ) ) @@ -42,8 +42,8 @@ (core instance $i (instantiate $m)) (func (param "p1" (list u8)) (canon lift (core func $i "f") - (memory $i "m") - (realloc (func $i "realloc")) + (memory (core memory $i "m")) + (realloc (core func $i "realloc")) ) ) ) diff --git a/tests/cli/component-model/memory64/resources.wast b/tests/cli/component-model/memory64/resources.wast index 3f71f65a98..d42b0f46a6 100644 --- a/tests/cli/component-model/memory64/resources.wast +++ b/tests/cli/component-model/memory64/resources.wast @@ -17,7 +17,7 @@ (func (export "dtor") (param i64)) ) (core instance $m (instantiate $m)) - (type $x (resource (rep i64) (dtor (func $m "dtor")))) + (type $x (resource (rep i64) (dtor (core func $m "dtor")))) (core func (canon resource.new $x)) ) @@ -48,7 +48,7 @@ (func (export "dtor") (param i32)) ) (core instance $m (instantiate $m)) - (type $x (resource (rep i64) (dtor (func $m "dtor")))) + (type $x (resource (rep i64) (dtor (core func $m "dtor")))) (core func (canon resource.new $x)) ) "wrong signature for a destructor") @@ -59,7 +59,7 @@ (func (export "dtor") (param i64)) ) (core instance $m (instantiate $m)) - (type $x (resource (rep i32) (dtor (func $m "dtor")))) + (type $x (resource (rep i32) (dtor (core func $m "dtor")))) (core func (canon resource.new $x)) ) "wrong signature for a destructor") diff --git a/tests/cli/component-model/memory64/string.wast b/tests/cli/component-model/memory64/string.wast index 12de7c8d9f..bd17b13897 100644 --- a/tests/cli/component-model/memory64/string.wast +++ b/tests/cli/component-model/memory64/string.wast @@ -8,6 +8,6 @@ ) (core instance $m (instantiate $m)) (func (export "a") (param "a" string) (result string) - (canon lift (core func $m "f") (realloc (func $m "realloc")) (memory $m "memory")) + (canon lift (core func $m "f") (realloc (core func $m "realloc")) (memory (core memory $m "memory"))) ) ) diff --git a/tests/cli/component-model/memory64/waitable-set.wast b/tests/cli/component-model/memory64/waitable-set.wast index 00641d1e77..9fc524d571 100644 --- a/tests/cli/component-model/memory64/waitable-set.wast +++ b/tests/cli/component-model/memory64/waitable-set.wast @@ -8,7 +8,7 @@ (core module $m (import "" "waitable-set.wait" (func $waitable-set-wait (param i32 i64) (result i32))) ) - (core func $waitable-set-wait (canon waitable-set.wait cancellable (memory $libc "memory"))) + (core func $waitable-set-wait (canon waitable-set.wait cancellable (memory (core memory $libc "memory")))) (core instance $i (instantiate $m (with "" (instance (export "waitable-set.wait" (func $waitable-set-wait)))))) ) @@ -19,7 +19,7 @@ (core module $m (import "" "waitable-set.wait" (func $waitable-set-wait (param i32 i64) (result i32))) ) - (core func $waitable-set-wait (canon waitable-set.wait cancellable (memory $libc "memory"))) + (core func $waitable-set-wait (canon waitable-set.wait cancellable (memory (core memory $libc "memory")))) (core instance $i (instantiate $m (with "" (instance (export "waitable-set.wait" (func $waitable-set-wait)))))) ) "type mismatch for export `waitable-set.wait`" @@ -32,7 +32,7 @@ (core module $m (import "" "waitable-set.wait" (func $waitable-set-wait (param i32 i32) (result i32))) ) - (core func $waitable-set-wait (canon waitable-set.wait cancellable (memory $libc "memory"))) + (core func $waitable-set-wait (canon waitable-set.wait cancellable (memory (core memory $libc "memory")))) (core instance $i (instantiate $m (with "" (instance (export "waitable-set.wait" (func $waitable-set-wait)))))) ) "type mismatch for export `waitable-set.wait`" @@ -47,7 +47,7 @@ (core module $m (import "" "waitable-set.poll" (func $waitable-set-poll (param i32 i64) (result i32))) ) - (core func $waitable-set-poll (canon waitable-set.poll cancellable (memory $libc "memory"))) + (core func $waitable-set-poll (canon waitable-set.poll cancellable (memory (core memory $libc "memory")))) (core instance $i (instantiate $m (with "" (instance (export "waitable-set.poll" (func $waitable-set-poll)))))) ) @@ -58,7 +58,7 @@ (core module $m (import "" "waitable-set.poll" (func $waitable-set-poll (param i32 i64) (result i32))) ) - (core func $waitable-set-poll (canon waitable-set.poll cancellable (memory $libc "memory"))) + (core func $waitable-set-poll (canon waitable-set.poll cancellable (memory (core memory $libc "memory")))) (core instance $i (instantiate $m (with "" (instance (export "waitable-set.poll" (func $waitable-set-poll)))))) ) "type mismatch for export `waitable-set.poll`" @@ -71,7 +71,7 @@ (core module $m (import "" "waitable-set.poll" (func $waitable-set-poll (param i32 i32) (result i32))) ) - (core func $waitable-set-poll (canon waitable-set.poll cancellable (memory $libc "memory"))) + (core func $waitable-set-poll (canon waitable-set.poll cancellable (memory (core memory $libc "memory")))) (core instance $i (instantiate $m (with "" (instance (export "waitable-set.poll" (func $waitable-set-poll)))))) ) "type mismatch for export `waitable-set.poll`" diff --git a/tests/cli/component-model/options.wast b/tests/cli/component-model/options.wast index 664ae42669..6cc572e7ef 100644 --- a/tests/cli/component-model/options.wast +++ b/tests/cli/component-model/options.wast @@ -10,9 +10,9 @@ (core instance $i (instantiate $m)) (func (canon lift (core func $i "f"))) - (func (canon lift (core func $i "f") (memory $i "m"))) - (func (canon lift (core func $i "f") (memory $i "m") (realloc (func $i "r")))) - (func (canon lift (core func $i "f") (realloc (func $i "r")) (memory $i "m"))) + (func (canon lift (core func $i "f") (memory (core memory $i "m")))) + (func (canon lift (core func $i "f") (memory (core memory $i "m")) (realloc (core func $i "r")))) + (func (canon lift (core func $i "f") (realloc (core func $i "r")) (memory (core memory $i "m")))) ) ;; `realloc` requires `memory` @@ -23,7 +23,7 @@ (func (export "f")) ) (core instance $i (instantiate $m)) - (func (canon lift (core func $i "f") (realloc (func $i "r")))) + (func (canon lift (core func $i "f") (realloc (core func $i "r")))) ) "canonical option `realloc` requires `memory` to also be specified") @@ -36,7 +36,7 @@ (func (export "f")) ) (core instance $i (instantiate $m)) - (func (canon lift (core func $i "f") (realloc (func $i "r")) (memory $i "m"))) + (func (canon lift (core func $i "f") (realloc (core func $i "r")) (memory (core memory $i "m")))) ) "canonical option `realloc` uses a core function with an incorrect signature") @@ -48,7 +48,7 @@ (func (export "f")) ) (core instance $i (instantiate $m)) - (func (canon lift (core func $i "f") (memory $i "m"))) + (func (canon lift (core func $i "f") (memory (core memory $i "m")))) ) "mismatch in the shared flag for memories") (assert_invalid @@ -58,6 +58,6 @@ (func (export "f")) ) (core instance $i (instantiate $m)) - (func (canon lift (core func $i "f") (memory $i "m"))) + (func (canon lift (core func $i "f") (memory (core memory $i "m")))) ) "64-bit memories require the `cm64` feature to be enabled") diff --git a/tests/cli/component-model/resources.wast b/tests/cli/component-model/resources.wast index d420a94059..1163588c9d 100644 --- a/tests/cli/component-model/resources.wast +++ b/tests/cli/component-model/resources.wast @@ -23,7 +23,7 @@ (func (export "dtor") (param i32)) ) (core instance $m (instantiate $m)) - (type $x (resource (rep i32) (dtor (func $m "dtor")))) + (type $x (resource (rep i32) (dtor (core func $m "dtor")))) (core func (canon resource.new $x)) ) @@ -127,14 +127,14 @@ (func (export "dtor")) ) (core instance $m (instantiate $m)) - (type $x (resource (rep i32) (dtor (func $m "dtor")))) + (type $x (resource (rep i32) (dtor (core func $m "dtor")))) (core func (canon resource.new $x)) ) "wrong signature for a destructor") (assert_invalid (component - (type (resource (rep i32) (dtor (func 100)))) + (type (resource (rep i32) (dtor (core func 100)))) ) "function index out of bounds") diff --git a/tests/cli/component-model/strict-legacy-callback.wat b/tests/cli/component-model/strict-legacy-callback.wat new file mode 100644 index 0000000000..50bf6e3347 --- /dev/null +++ b/tests/cli/component-model/strict-legacy-callback.wat @@ -0,0 +1,13 @@ +;; FAIL: parse % -o %tmpdir/strict.wasm +;; RUN[lenient]: WAST_STRICT_COMPONENT_INDICES=0 parse % -o %tmpdir/lenient.wasm + +;; The legacy `(callback (func ...))` syntax is rejected in strict mode; the +;; new spec requires `(callback (core func ...))`. +(component + (core module $m + (func (export "cb") (param i32 i32 i32) (result i32) unreachable) + (func (export "f") (result i32) unreachable)) + (core instance $m (instantiate $m)) + (func async + (canon lift (core func $m "f") async (callback (func $m "cb")))) +) diff --git a/tests/cli/component-model/strict-legacy-callback.wat.stderr b/tests/cli/component-model/strict-legacy-callback.wat.stderr new file mode 100644 index 0000000000..1470314fba --- /dev/null +++ b/tests/cli/component-model/strict-legacy-callback.wat.stderr @@ -0,0 +1,5 @@ +error: the `core` keyword is required in this reference: `(func ...)` should be written `(core func ...)` (or set WAST_STRICT_COMPONENT_INDICES=0 to accept the legacy syntax) + --> tests/cli/component-model/strict-legacy-callback.wat:12:53 + | + 12 | (canon lift (core func $m "f") async (callback (func $m "cb")))) + | ^ diff --git a/tests/cli/component-model/strict-legacy-core-type.wat b/tests/cli/component-model/strict-legacy-core-type.wat new file mode 100644 index 0000000000..584e4474fe --- /dev/null +++ b/tests/cli/component-model/strict-legacy-core-type.wat @@ -0,0 +1,12 @@ +;; FAIL: parse % -o %tmpdir/strict.wasm +;; RUN[lenient]: WAST_STRICT_COMPONENT_INDICES=0 parse % -o %tmpdir/lenient.wasm + +;; The legacy `(core-type (type ...))` syntax is rejected in strict mode; the +;; new spec requires a bare index or `(core-type (core type ...))`. +(component + (core type $ty (func (param externref))) + (import "i" (instance $i + (export "r" (type $resource (sub resource))) + (export "f" (func (param "x" (own $resource)))))) + (core func (canon lower (func $i "f") gc string-encoding=utf8 (core-type (type $ty)))) +) diff --git a/tests/cli/component-model/strict-legacy-core-type.wat.stderr b/tests/cli/component-model/strict-legacy-core-type.wat.stderr new file mode 100644 index 0000000000..3b96a3a621 --- /dev/null +++ b/tests/cli/component-model/strict-legacy-core-type.wat.stderr @@ -0,0 +1,5 @@ +error: the `core` keyword is required in this reference: `(type ...)` should be written `(core type ...)` (or set WAST_STRICT_COMPONENT_INDICES=0 to accept the legacy syntax) + --> tests/cli/component-model/strict-legacy-core-type.wat:11:77 + | + 11 | (core func (canon lower (func $i "f") gc string-encoding=utf8 (core-type (type $ty)))) + | ^ diff --git a/tests/cli/component-model/strict-legacy-dtor.wat b/tests/cli/component-model/strict-legacy-dtor.wat new file mode 100644 index 0000000000..a43d0f03da --- /dev/null +++ b/tests/cli/component-model/strict-legacy-dtor.wat @@ -0,0 +1,11 @@ +;; FAIL: parse % -o %tmpdir/strict.wasm +;; RUN[lenient]: WAST_STRICT_COMPONENT_INDICES=0 parse % -o %tmpdir/lenient.wasm + +;; The legacy `(dtor (func ...))` syntax is rejected in strict mode; the new +;; spec requires `(dtor )` or `(dtor (core func ...))`. +(component + (core module $m (func (export "dtor") (param i32))) + (core instance $m (instantiate $m)) + (alias core export $m "dtor" (core func $dtor)) + (type $R (resource (rep i32) (dtor (func $dtor)))) +) diff --git a/tests/cli/component-model/strict-legacy-dtor.wat.stderr b/tests/cli/component-model/strict-legacy-dtor.wat.stderr new file mode 100644 index 0000000000..b8d4577bb6 --- /dev/null +++ b/tests/cli/component-model/strict-legacy-dtor.wat.stderr @@ -0,0 +1,5 @@ +error: the `core` keyword is required in this reference: `(func ...)` should be written `(core func ...)` (or set WAST_STRICT_COMPONENT_INDICES=0 to accept the legacy syntax) + --> tests/cli/component-model/strict-legacy-dtor.wat:10:39 + | + 10 | (type $R (resource (rep i32) (dtor (func $dtor)))) + | ^ diff --git a/tests/cli/component-model/strict-legacy-memory.wat b/tests/cli/component-model/strict-legacy-memory.wat new file mode 100644 index 0000000000..e41904da75 --- /dev/null +++ b/tests/cli/component-model/strict-legacy-memory.wat @@ -0,0 +1,15 @@ +;; FAIL: parse % -o %tmpdir/strict.wasm +;; RUN[lenient]: WAST_STRICT_COMPONENT_INDICES=0 parse % -o %tmpdir/lenient.wasm + +;; The legacy `(memory $i "name")` syntax is rejected in strict mode; the new +;; spec requires `(memory (core memory $i "name"))`. +(component + (import "f" (func $f (param "x" string))) + (core module $libc + (memory (export "mem") 1) + (func (export "realloc") (param i32 i32 i32 i32) (result i32) unreachable)) + (core instance $libc (instantiate $libc)) + (core func (canon lower (func $f) + (memory $libc "mem") + (realloc (core func $libc "realloc")))) +) diff --git a/tests/cli/component-model/strict-legacy-memory.wat.stderr b/tests/cli/component-model/strict-legacy-memory.wat.stderr new file mode 100644 index 0000000000..468fd130d0 --- /dev/null +++ b/tests/cli/component-model/strict-legacy-memory.wat.stderr @@ -0,0 +1,5 @@ +error: an export name must be written inside a nested reference: `(memory $i "name")` should be written `(memory (core memory $i "name"))` (or set WAST_STRICT_COMPONENT_INDICES=0 to accept the legacy syntax) + --> tests/cli/component-model/strict-legacy-memory.wat:13:19 + | + 13 | (memory $libc "mem") + | ^ diff --git a/tests/cli/component-model/strict-legacy-post-return.wat b/tests/cli/component-model/strict-legacy-post-return.wat new file mode 100644 index 0000000000..fc51cb3399 --- /dev/null +++ b/tests/cli/component-model/strict-legacy-post-return.wat @@ -0,0 +1,18 @@ +;; FAIL: parse % -o %tmpdir/strict.wasm +;; RUN[lenient]: WAST_STRICT_COMPONENT_INDICES=0 parse % -o %tmpdir/lenient.wasm + +;; The legacy `(post-return (func ...))` syntax is rejected in strict mode; +;; the new spec requires `(post-return (core func ...))`. +(component + (core module $m + (memory (export "mem") 1) + (func (export "realloc") (param i32 i32 i32 i32) (result i32) unreachable) + (func (export "run") (param i32 i32) (result i32) unreachable) + (func (export "post") (param i32))) + (core instance $m (instantiate $m)) + (func (export "run") (param "s" string) (result string) + (canon lift (core func $m "run") + (memory 0) + (realloc (core func $m "realloc")) + (post-return (func $m "post")))) +) diff --git a/tests/cli/component-model/strict-legacy-post-return.wat.stderr b/tests/cli/component-model/strict-legacy-post-return.wat.stderr new file mode 100644 index 0000000000..36aeb78cc1 --- /dev/null +++ b/tests/cli/component-model/strict-legacy-post-return.wat.stderr @@ -0,0 +1,5 @@ +error: the `core` keyword is required in this reference: `(func ...)` should be written `(core func ...)` (or set WAST_STRICT_COMPONENT_INDICES=0 to accept the legacy syntax) + --> tests/cli/component-model/strict-legacy-post-return.wat:17:21 + | + 17 | (post-return (func $m "post")))) + | ^ diff --git a/tests/cli/component-model/strict-legacy-realloc.wat b/tests/cli/component-model/strict-legacy-realloc.wat new file mode 100644 index 0000000000..9f3ac18d02 --- /dev/null +++ b/tests/cli/component-model/strict-legacy-realloc.wat @@ -0,0 +1,15 @@ +;; FAIL: parse % -o %tmpdir/strict.wasm +;; RUN[lenient]: WAST_STRICT_COMPONENT_INDICES=0 parse % -o %tmpdir/lenient.wasm + +;; The legacy `(realloc (func ...))` syntax is rejected in strict mode; the +;; new spec requires `(realloc (core func ...))`. +(component + (import "f" (func $f (param "x" string))) + (core module $libc + (memory (export "mem") 1) + (func (export "realloc") (param i32 i32 i32 i32) (result i32) unreachable)) + (core instance $libc (instantiate $libc)) + (core func (canon lower (func $f) + (memory 0) + (realloc (func $libc "realloc")))) +) diff --git a/tests/cli/component-model/strict-legacy-realloc.wat.stderr b/tests/cli/component-model/strict-legacy-realloc.wat.stderr new file mode 100644 index 0000000000..9e9d51685d --- /dev/null +++ b/tests/cli/component-model/strict-legacy-realloc.wat.stderr @@ -0,0 +1,5 @@ +error: the `core` keyword is required in this reference: `(func ...)` should be written `(core func ...)` (or set WAST_STRICT_COMPONENT_INDICES=0 to accept the legacy syntax) + --> tests/cli/component-model/strict-legacy-realloc.wat:14:15 + | + 14 | (realloc (func $libc "realloc")))) + | ^ diff --git a/tests/cli/component-model/strict-legacy-table.wat b/tests/cli/component-model/strict-legacy-table.wat new file mode 100644 index 0000000000..0f6363afa1 --- /dev/null +++ b/tests/cli/component-model/strict-legacy-table.wat @@ -0,0 +1,12 @@ +;; FAIL: parse % -o %tmpdir/strict.wasm +;; RUN[lenient]: WAST_STRICT_COMPONENT_INDICES=0 parse % -o %tmpdir/lenient.wasm + +;; The legacy `(table ...)` syntax in `thread.new-indirect` and +;; `thread.spawn-indirect` is rejected in strict mode; the new spec requires +;; a bare index or `(core table ...)`. +(component + (core type $start (func (param $context i32))) + (core module $libc (table (export "start-table") 1 (ref null func))) + (core instance $libc (instantiate $libc)) + (core func (canon thread.new-indirect $start (table $libc "start-table"))) +) diff --git a/tests/cli/component-model/strict-legacy-table.wat.stderr b/tests/cli/component-model/strict-legacy-table.wat.stderr new file mode 100644 index 0000000000..05e5fa46c2 --- /dev/null +++ b/tests/cli/component-model/strict-legacy-table.wat.stderr @@ -0,0 +1,5 @@ +error: the `core` keyword is required in this reference: `(table ...)` should be written `(core table ...)` (or set WAST_STRICT_COMPONENT_INDICES=0 to accept the legacy syntax) + --> tests/cli/component-model/strict-legacy-table.wat:11:49 + | + 11 | (core func (canon thread.new-indirect $start (table $libc "start-table"))) + | ^ diff --git a/tests/cli/component-model/values/values.wast b/tests/cli/component-model/values/values.wast index 7e320a407c..9d63c7a892 100644 --- a/tests/cli/component-model/values/values.wast +++ b/tests/cli/component-model/values/values.wast @@ -129,9 +129,9 @@ (alias core export $main "start" (core func $main_func)) (func $start (param "p1" string) (result string) (canon lift (core func $main_func) - (memory $libc "memory") - (realloc (func $libc "canonical_abi_realloc")) - (post-return (func $main "start-post-return")) + (memory (core memory $libc "memory")) + (realloc (core func $libc "canonical_abi_realloc")) + (post-return (core func $main "start-post-return")) ) ) (start $start (value $name) (result (value $greeting))) diff --git a/tests/cli/component-model/virtualize.wast b/tests/cli/component-model/virtualize.wast index d60b73b947..d86f108fdd 100644 --- a/tests/cli/component-model/virtualize.wast +++ b/tests/cli/component-model/virtualize.wast @@ -26,8 +26,8 @@ (core func $wasi_file_read (canon lower (func $wasi-file "read") - (memory $libc "mem") - (realloc (func $libc "realloc")) + (memory (core memory $libc "mem")) + (realloc (core func $libc "realloc")) ) ) @@ -102,8 +102,8 @@ (core func $real-wasi-read (canon lower (func $real-wasi "read") - (memory $libc "mem") - (realloc (func $libc "realloc")) + (memory (core memory $libc "mem")) + (realloc (core func $libc "realloc")) ) ) @@ -111,8 +111,8 @@ (core instance $child (instantiate $CHILD (with "wasi-file" (instance $virt-wasi)))) (func (export "work") (canon lift (core func $child "play") - (memory $libc "mem") - (realloc (func $libc "realloc")) + (memory (core memory $libc "mem")) + (realloc (core func $libc "realloc")) ) ) ) diff --git a/tests/cli/dump/bundled.wat b/tests/cli/dump/bundled.wat index d42b366056..bbe4de8104 100644 --- a/tests/cli/dump/bundled.wat +++ b/tests/cli/dump/bundled.wat @@ -35,8 +35,8 @@ (core func $real-wasi-read (canon lower (func $real-wasi "read") - (memory $libc "mem") - (realloc (func $libc "realloc")) + (memory (core memory $libc "mem")) + (realloc (core func $libc "realloc")) ) ) @@ -44,8 +44,8 @@ (core instance $child (instantiate $CHILD (with "wasi-file" (instance $virt-wasi)))) (func (export "work") (canon lift (core func $child "play") - (memory $libc "mem") - (realloc (func $libc "realloc")) + (memory (core memory $libc "mem")) + (realloc (core func $libc "realloc")) ) ) ) diff --git a/tests/cli/missing-features/component-model/async-stackful.wast b/tests/cli/missing-features/component-model/async-stackful.wast index f1f50bef4d..72dd15eb1c 100644 --- a/tests/cli/missing-features/component-model/async-stackful.wast +++ b/tests/cli/missing-features/component-model/async-stackful.wast @@ -16,26 +16,26 @@ (component (core module $libc (memory (export "memory") 1)) (core instance $libc (instantiate $libc)) - (core func (canon waitable-set.wait cancellable (memory $libc "memory"))) + (core func (canon waitable-set.wait cancellable (memory (core memory $libc "memory")))) ) (component (core module $libc (memory (export "memory") 1)) (core instance $libc (instantiate $libc)) - (core func (canon waitable-set.wait (memory $libc "memory"))) + (core func (canon waitable-set.wait (memory (core memory $libc "memory")))) ) ;; waitable-set.poll cancellable (component (core module $libc (memory (export "memory") 1)) (core instance $libc (instantiate $libc)) - (core func (canon waitable-set.poll cancellable (memory $libc "memory"))) + (core func (canon waitable-set.poll cancellable (memory (core memory $libc "memory")))) ) (component (core module $libc (memory (export "memory") 1)) (core instance $libc (instantiate $libc)) - (core func (canon waitable-set.poll (memory $libc "memory"))) + (core func (canon waitable-set.poll (memory (core memory $libc "memory")))) ) ;; thread.yield diff --git a/tests/cli/missing-features/component-model/async.wast b/tests/cli/missing-features/component-model/async.wast index d5372dbec8..b7407e00f4 100644 --- a/tests/cli/missing-features/component-model/async.wast +++ b/tests/cli/missing-features/component-model/async.wast @@ -21,7 +21,7 @@ (import "foo" (func $foo (param "p1" u32) (result u32))) (core module $libc (memory (export "memory") 1)) (core instance $libc (instantiate $libc)) - (core func $foo (canon lower (func $foo) async (memory $libc "memory"))) + (core func $foo (canon lower (func $foo) async (memory (core memory $libc "memory")))) (core module $m (func (import "" "foo") (param i32 i32) (result i32)) ) @@ -92,7 +92,7 @@ (core module $m (import "" "waitable-set.wait" (func $waitable-set-wait (param i32) (result i32))) ) - (core func $waitable-set-wait (canon waitable-set.wait (memory $libc "memory"))) + (core func $waitable-set-wait (canon waitable-set.wait (memory (core memory $libc "memory")))) (core instance $i (instantiate $m (with "" (instance (export "waitable-set.wait" (func $waitable-set-wait)))))) ) "`waitable-set.wait` requires the component model async feature" @@ -106,7 +106,7 @@ (core module $m (import "" "waitable-set.poll" (func $waitable-set-poll (param i32) (result i32))) ) - (core func $waitable-set-poll (canon waitable-set.poll (memory $libc "memory"))) + (core func $waitable-set-poll (canon waitable-set.poll (memory (core memory $libc "memory")))) (core instance $i (instantiate $m (with "" (instance (export "waitable-set.poll" (func $waitable-set-poll)))))) ) "`waitable-set.poll` requires the component model async feature" @@ -170,7 +170,7 @@ (import "" "stream.read" (func $stream-read (param i32 i32 i32) (result i32))) ) (type $stream-type (stream u8)) - (core func $stream-read (canon stream.read $stream-type async (memory $libc "memory"))) + (core func $stream-read (canon stream.read $stream-type async (memory (core memory $libc "memory")))) (core instance $i (instantiate $m (with "" (instance (export "stream.read" (func $stream-read)))))) ) "requires the component model async feature" @@ -185,7 +185,7 @@ (import "" "stream.write" (func $stream-write (param i32 i32 i32) (result i32))) ) (type $stream-type (stream u8)) - (core func $stream-write (canon stream.write $stream-type async (memory $libc "memory"))) + (core func $stream-write (canon stream.write $stream-type async (memory (core memory $libc "memory")))) (core instance $i (instantiate $m (with "" (instance (export "stream.write" (func $stream-write)))))) ) "requires the component model async feature" @@ -265,7 +265,7 @@ (import "" "future.read" (func $future-read (param i32 i32) (result i32))) ) (type $future-type (future u8)) - (core func $future-read (canon future.read $future-type async (memory $libc "memory"))) + (core func $future-read (canon future.read $future-type async (memory (core memory $libc "memory")))) (core instance $i (instantiate $m (with "" (instance (export "future.read" (func $future-read)))))) ) "requires the component model async feature" @@ -280,7 +280,7 @@ (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 (memory $libc "memory"))) + (core func $future-write (canon future.write $future-type async (memory (core memory $libc "memory")))) (core instance $i (instantiate $m (with "" (instance (export "future.write" (func $future-write)))))) ) "requires the component model async feature" diff --git a/tests/cli/missing-features/component-model/error-context.wast b/tests/cli/missing-features/component-model/error-context.wast index 68b210438c..3293a934a2 100644 --- a/tests/cli/missing-features/component-model/error-context.wast +++ b/tests/cli/missing-features/component-model/error-context.wast @@ -16,7 +16,7 @@ (core module $m (import "" "error-context.new" (func $error-context-new (param i32 i32) (result i32))) ) - (core func $error-context-new (canon error-context.new (memory $libc "memory"))) + (core func $error-context-new (canon error-context.new (memory (core memory $libc "memory")))) (core instance $i (instantiate $m (with "" (instance (export "error-context.new" (func $error-context-new)))))) ) "`error-context.new` requires the component model error-context feature" @@ -33,7 +33,7 @@ (core module $m (import "" "error-context.debug-message" (func $error-context-debug-message (param i32 i32))) ) - (core func $error-context-debug-message (canon error-context.debug-message (memory $libc "memory") (realloc (func $libc "realloc")))) + (core func $error-context-debug-message (canon error-context.debug-message (memory (core memory $libc "memory")) (realloc (core func $libc "realloc")))) (core instance $i (instantiate $m (with "" (instance (export "error-context.debug-message" (func $error-context-debug-message)))))) ) "`error-context.debug-message` requires the component model error-context feature" diff --git a/tests/cli/missing-features/component-model/fixed-length-lists.wast b/tests/cli/missing-features/component-model/fixed-length-lists.wast index 5443b9ee00..bc71ee619c 100644 --- a/tests/cli/missing-features/component-model/fixed-length-lists.wast +++ b/tests/cli/missing-features/component-model/fixed-length-lists.wast @@ -9,7 +9,7 @@ (core instance $i (instantiate $m)) (func (export "ret-list") (result (list u32 4)) - (canon lift (core func $i "ret-list") (memory $i "memory")) + (canon lift (core func $i "ret-list") (memory (core memory $i "memory"))) ) ) "Fixed-length lists require the component model fixed-length lists feature (at offset 0x54)" diff --git a/tests/cli/missing-features/component-model/map.wast b/tests/cli/missing-features/component-model/map.wast index 8dda8e08cb..f01629e4d5 100644 --- a/tests/cli/missing-features/component-model/map.wast +++ b/tests/cli/missing-features/component-model/map.wast @@ -9,7 +9,7 @@ (core instance $i (instantiate $m)) (func (export "ret-map") (result (map string u32)) - (canon lift (core func $i "ret-map") (memory $i "memory")) + (canon lift (core func $i "ret-map") (memory (core memory $i "memory"))) ) ) "Maps require the component model map feature (at offset 0x54)" diff --git a/tests/cli/missing-features/component-model/shared-everything-threads-builtins.wast b/tests/cli/missing-features/component-model/shared-everything-threads-builtins.wast index e085c21292..b9bb4e4d7f 100644 --- a/tests/cli/missing-features/component-model/shared-everything-threads-builtins.wast +++ b/tests/cli/missing-features/component-model/shared-everything-threads-builtins.wast @@ -12,7 +12,7 @@ (component ;; Refer to a non-existent function and table types (i.e., 0); validation ;; for `thread.spawn-indirect` happens first. - (core func $spawn-indirect (canon thread.spawn-indirect 0 (table 0))) + (core func $spawn-indirect (canon thread.spawn-indirect 0 (core table 0))) ) "`thread.spawn-indirect` requires the shared-everything-threads proposal") diff --git a/tests/cli/missing-features/component-model/threading.wast b/tests/cli/missing-features/component-model/threading.wast index 65a87b2e7c..0699e0b5c0 100644 --- a/tests/cli/missing-features/component-model/threading.wast +++ b/tests/cli/missing-features/component-model/threading.wast @@ -7,7 +7,7 @@ "requires the component model threading feature") (assert_invalid - (component (core func (canon thread.new-indirect 0 (table 0)))) + (component (core func (canon thread.new-indirect 0 (core table 0)))) "requires the component model threading feature") (assert_invalid diff --git a/tests/cli/readme.wat b/tests/cli/readme.wat index 600aae76c5..c4c6f99be7 100644 --- a/tests/cli/readme.wat +++ b/tests/cli/readme.wat @@ -68,6 +68,11 @@ ;; validate ;; ;; here the `\` character is deleted and the next line is concatenated. +;; +;; Like in a POSIX shell, `KEY=VALUE` arguments before a subcommand name set +;; environment variables for that command: +;; +;; RUN[env]: FOO=bar validate % ;; this is the contents of the test, mostly empty in this case. diff --git a/tests/cli/shared-everything-threads/builtins.wast b/tests/cli/shared-everything-threads/builtins.wast index 6faae947f3..c36e3bc515 100644 --- a/tests/cli/shared-everything-threads/builtins.wast +++ b/tests/cli/shared-everything-threads/builtins.wast @@ -8,7 +8,7 @@ (core module $libc (table (export "start-table") shared 1 (ref null (shared func)))) (core instance $libc (instantiate $libc)) - (core func $spawn-indirect (canon thread.spawn-indirect $start (table $libc "start-table"))) + (core func $spawn-indirect (canon thread.spawn-indirect $start (core table $libc "start-table"))) (core func $parallelism (canon thread.available_parallelism)) ) @@ -19,7 +19,7 @@ (core module $libc (table (export "start-table") shared 1 (ref null (shared func)))) (core instance $libc (instantiate $libc)) - (core func $spawn-indirect (canon thread.spawn-indirect $start (table $libc "start-table"))) + (core func $spawn-indirect (canon thread.spawn-indirect $start (core table $libc "start-table"))) (core func $parallelism (canon thread.available_parallelism)) @@ -55,7 +55,7 @@ (core type $start (shared (func (param i32)))) ;; Refer to a non-existent table type (i.e., 0); validation ;; for `thread.spawn-indirect` happens first. - (core func $spawn-indirect (canon thread.spawn-indirect $start (table 0))) + (core func $spawn-indirect (canon thread.spawn-indirect $start (core table 0))) ) "unknown table 0: table index out of bounds" ) @@ -73,7 +73,7 @@ (core type $start (shared (func))) (core module $libc (table (export "start-table") shared 1 (ref null (shared func)))) (core instance $libc (instantiate $libc)) - (core func $spawn-indirect (canon thread.spawn-indirect $start (table $libc "start-table"))) + (core func $spawn-indirect (canon thread.spawn-indirect $start (core table $libc "start-table"))) ) "spawn function must take a single `i32` argument (currently)" ) @@ -83,7 +83,7 @@ (core type $start (shared (func (param i32)))) (core module $libc (table (export "start-table") 1 (ref null (shared func)))) (core instance $libc (instantiate $libc)) - (core func $spawn-indirect (canon thread.spawn-indirect $start (table $libc "start-table"))) + (core func $spawn-indirect (canon thread.spawn-indirect $start (core table $libc "start-table"))) ) "mismatch in the shared flag for tables" ) diff --git a/tests/snapshots/cli/component-model/async/threading.wast/25.print b/tests/snapshots/cli/component-model/async/threading.wast/25.print index 4bbea54627..c9bc6aca7f 100644 --- a/tests/snapshots/cli/component-model/async/threading.wast/25.print +++ b/tests/snapshots/cli/component-model/async/threading.wast/25.print @@ -10,8 +10,8 @@ (core func (;2;) (canon context.set i32 1)) (core func (;3;) (canon context.set i32 1)) (core type $start (;0;) (func (param i32))) - (core func (;4;) (canon thread.new-indirect $start (table $start-table))) - (core func (;5;) (canon thread.new-indirect $start (table $start-table))) + (core func (;4;) (canon thread.new-indirect $start $start-table)) + (core func (;5;) (canon thread.new-indirect $start $start-table)) (core func (;6;) (canon thread.resume-later)) (core func (;7;) (canon thread.resume-later)) (core func (;8;) (canon thread.suspend)) diff --git a/tests/snapshots/cli/component-model/async/threading.wast/7.print b/tests/snapshots/cli/component-model/async/threading.wast/7.print index 2cb7f3932a..79016d1f12 100644 --- a/tests/snapshots/cli/component-model/async/threading.wast/7.print +++ b/tests/snapshots/cli/component-model/async/threading.wast/7.print @@ -6,5 +6,5 @@ ) (core instance $libc (;0;) (instantiate $libc)) (alias core export $libc "start-table" (core table (;0;))) - (core func $new-indirect (;0;) (canon thread.new-indirect $start (table 0))) + (core func $new-indirect (;0;) (canon thread.new-indirect $start 0)) ) diff --git a/tests/snapshots/cli/component-model/async/threading.wast/8.print b/tests/snapshots/cli/component-model/async/threading.wast/8.print index dfb4c50512..c5401d9061 100644 --- a/tests/snapshots/cli/component-model/async/threading.wast/8.print +++ b/tests/snapshots/cli/component-model/async/threading.wast/8.print @@ -6,7 +6,7 @@ ) (core instance $libc (;0;) (instantiate $libc)) (alias core export $libc "start-table" (core table (;0;))) - (core func $new-indirect (;0;) (canon thread.new-indirect $start (table 0))) + (core func $new-indirect (;0;) (canon thread.new-indirect $start 0)) (core module $m (;1;) (type $new-indirect-ty (;0;) (func (param i32 i32) (result i32))) (import "" "thread.new-indirect" (func (;0;) (type $new-indirect-ty))) diff --git a/tests/snapshots/cli/component-model/indices.wast.json b/tests/snapshots/cli/component-model/indices.wast.json new file mode 100644 index 0000000000..b9b2f285b5 --- /dev/null +++ b/tests/snapshots/cli/component-model/indices.wast.json @@ -0,0 +1,53 @@ +{ + "source_filename": "tests/cli/component-model/indices.wast", + "commands": [ + { + "type": "module", + "line": 5, + "filename": "indices.0.wasm", + "module_type": "binary" + }, + { + "type": "module", + "line": 60, + "filename": "indices.1.wasm", + "module_type": "binary" + }, + { + "type": "module", + "line": 73, + "filename": "indices.2.wasm", + "module_type": "binary" + }, + { + "type": "module", + "line": 140, + "filename": "indices.3.wasm", + "module_type": "binary" + }, + { + "type": "module", + "line": 198, + "filename": "indices.4.wasm", + "module_type": "binary" + }, + { + "type": "module", + "line": 211, + "filename": "indices.5.wasm", + "module_type": "binary" + }, + { + "type": "module", + "line": 226, + "filename": "indices.6.wasm", + "module_type": "binary" + }, + { + "type": "module", + "line": 242, + "filename": "indices.7.wasm", + "module_type": "binary" + } + ] +} \ No newline at end of file diff --git a/tests/snapshots/cli/component-model/indices.wast/0.print b/tests/snapshots/cli/component-model/indices.wast/0.print new file mode 100644 index 0000000000..f3cc30495c --- /dev/null +++ b/tests/snapshots/cli/component-model/indices.wast/0.print @@ -0,0 +1,193 @@ +(component + (component (;0;) + (component $C (;0;) + (type (;0;) (func)) + (import "x" (func (;0;) (type 0))) + ) + (type (;0;) (func)) + (import "f" (func $f (;0;) (type 0))) + (instance (;0;) (instantiate $C + (with "x" (func $f)) + ) + ) + (instance (;1;) (instantiate $C + (with "x" (func $f)) + ) + ) + (type (;1;) + (instance + (type (;0;) (func)) + (export (;0;) "f" (func (type 0))) + ) + ) + (import "i" (instance $i (;2;) (type 1))) + (alias export $i "f" (func (;1;))) + (instance (;3;) (instantiate $C + (with "x" (func 1)) + ) + ) + (type (;2;) + (instance + (type (;0;) + (instance + (type (;0;) + (instance + (type (;0;) (func)) + (export (;0;) "f" (func (type 0))) + ) + ) + (export (;0;) "b" (instance (type 0))) + ) + ) + (export (;0;) "a" (instance (type 0))) + ) + ) + (import "j" (instance $j (;4;) (type 2))) + (alias export $j "a" (instance (;5;))) + (alias export 5 "b" (instance (;6;))) + (alias export 6 "f" (func (;2;))) + (instance (;7;) (instantiate $C + (with "x" (func 2)) + ) + ) + ) + (component (;1;) + (component $C (;0;) + (type (;0;) + (instance) + ) + (import "x" (instance (;0;) (type 0))) + ) + (type (;0;) + (instance) + ) + (import "i" (instance $i (;0;) (type 0))) + (instance (;1;) (instantiate $C + (with "x" (instance $i)) + ) + ) + (type (;1;) + (instance + (type (;0;) + (instance) + ) + (export (;0;) "k" (instance (type 0))) + ) + ) + (import "j" (instance $j (;2;) (type 1))) + (alias export $j "k" (instance (;3;))) + (instance (;4;) (instantiate $C + (with "x" (instance 3)) + ) + ) + ) + (component (;2;) + (component $C (;0;) + (type (;0;) + (component) + ) + (import "x" (component (;0;) (type 0))) + ) + (type (;0;) + (component) + ) + (import "c" (component $c (;1;) (type 0))) + (instance (;0;) (instantiate $C + (with "x" (component $c)) + ) + ) + (type (;1;) + (instance + (type (;0;) + (component) + ) + (export (;0;) "c" (component (type 0))) + ) + ) + (import "i" (instance $i (;1;) (type 1))) + (alias export $i "c" (component (;2;))) + (instance (;2;) (instantiate $C + (with "x" (component 2)) + ) + ) + ) + (component (;3;) + (component $C (;0;) + (import "x" (type (;0;) (sub resource))) + ) + (import "t" (type $t (;0;) (sub resource))) + (instance (;0;) (instantiate $C + (with "x" (type $t)) + ) + ) + (instance (;1;) (instantiate $C + (with "x" (type $t)) + ) + ) + (type (;1;) + (instance + (export (;0;) "t" (type (sub resource))) + ) + ) + (import "i" (instance $i (;2;) (type 1))) + (alias export $i "t" (type (;2;))) + (instance (;3;) (instantiate $C + (with "x" (type 2)) + ) + ) + ) + (component (;4;) + (component $C (;0;) + (core type (;0;) + (module) + ) + (import "x" (core module (;0;) (type 0))) + ) + (core type (;0;) + (module) + ) + (import "m" (core module $m (;0;) (type 0))) + (instance (;0;) (instantiate $C + (with "x" (core module $m)) + ) + ) + (instance (;1;) (instantiate $C + (with "x" (core module $m)) + ) + ) + (type (;0;) + (instance + (core type (;0;) + (module) + ) + (export (;0;) "m" (core module (type 0))) + ) + ) + (import "i" (instance $i (;2;) (type 0))) + (alias export $i "m" (core module (;1;))) + (instance (;3;) (instantiate $C + (with "x" (core module 1)) + ) + ) + (type (;1;) + (instance + (type (;0;) + (instance + (core type (;0;) + (module) + ) + (export (;0;) "m" (core module (type 0))) + ) + ) + (export (;0;) "a" (instance (type 0))) + ) + ) + (import "j" (instance $j (;4;) (type 1))) + (alias export $j "a" (instance (;5;))) + (alias export 5 "m" (core module (;2;))) + (instance (;6;) (instantiate $C + (with "x" (core module 2)) + ) + ) + ) +) diff --git a/tests/snapshots/cli/component-model/indices.wast/1.print b/tests/snapshots/cli/component-model/indices.wast/1.print new file mode 100644 index 0000000000..928e05d7ba --- /dev/null +++ b/tests/snapshots/cli/component-model/indices.wast/1.print @@ -0,0 +1,30 @@ +(component + (component (;0;) + (core module $M (;0;) + (type (;0;) (func)) + (import "" "" (func (;0;) (type 0))) + ) + (core module $E (;1;) + (type (;0;) (func)) + (export "" (func 0)) + (func (;0;) (type 0)) + ) + (core instance $e (;0;) (instantiate $E)) + (core instance (;1;) (instantiate $M + (with "" (instance $e)) + ) + ) + (core instance (;2;) (instantiate $M + (with "" (instance $e)) + ) + ) + (alias core export $e "" (core func (;0;))) + (core instance (;3;) + (export "" (func 0)) + ) + (core instance (;4;) (instantiate $M + (with "" (instance 3)) + ) + ) + ) +) diff --git a/tests/snapshots/cli/component-model/indices.wast/2.print b/tests/snapshots/cli/component-model/indices.wast/2.print new file mode 100644 index 0000000000..e6caccc963 --- /dev/null +++ b/tests/snapshots/cli/component-model/indices.wast/2.print @@ -0,0 +1,73 @@ +(component + (component (;0;) + (type (;0;) (func)) + (import "f" (func $f (;0;) (type 0))) + (type (;1;) + (instance + (type (;0;) (func)) + (export (;0;) "f" (func (type 0))) + ) + ) + (import "i" (instance $i (;0;) (type 1))) + (type (;2;) + (instance + (type (;0;) + (instance + (type (;0;) (func)) + (export (;0;) "f" (func (type 0))) + ) + ) + (export (;0;) "n" (instance (type 0))) + ) + ) + (import "j" (instance $j (;1;) (type 2))) + (core func (;0;) (canon lower (func $f))) + (alias export $i "f" (func (;1;))) + (core func (;1;) (canon lower (func 1))) + (core func (;2;) (canon lower (func $f))) + (alias export $j "n" (instance (;2;))) + (alias export 2 "f" (func (;2;))) + (core func (;3;) (canon lower (func 2))) + (core func (;4;) (canon lower (func $f))) + (core func (;5;) (canon lower (func $f))) + (alias export $i "f" (func (;3;))) + (core func (;6;) (canon lower (func 3))) + (alias export $j "n" (instance (;3;))) + (alias export 3 "f" (func (;4;))) + (core func (;7;) (canon lower (func 4))) + ) + (component (;1;) + (type (;0;) (func (param "x" string))) + (import "f" (func $f (;0;) (type 0))) + (core module $L (;0;) + (type (;0;) (func (param i32 i32 i32 i32) (result i32))) + (memory (;0;) 1) + (export "mem" (memory 0)) + (export "realloc" (func 0)) + (func (;0;) (type 0) (param i32 i32 i32 i32) (result i32) + unreachable + ) + ) + (core instance $libc (;0;) (instantiate $L)) + (alias core export $libc "mem" (core memory $mem (;0;))) + (alias core export $libc "realloc" (core func $realloc (;0;))) + (core func (;1;) (canon lower (func $f) (memory $mem) (realloc $realloc))) + (core func (;2;) (canon lower (func $f) (memory $mem) (realloc $realloc))) + (core func (;3;) (canon lower (func $f) (memory $mem) (realloc $realloc))) + (core func (;4;) (canon lower (func $f) (memory $mem) (realloc $realloc))) + (core func (;5;) (canon lower (func $f) (memory $mem) (realloc $realloc))) + (core func (;6;) (canon lower (func $f) (memory $mem) (realloc $realloc))) + (core func (;7;) (canon lower (func $f) (memory $mem) (realloc $realloc))) + (core func (;8;) (canon lower (func $f) (memory $mem) (realloc $realloc))) + (alias core export $libc "mem" (core memory (;1;))) + (alias core export $libc "realloc" (core func (;9;))) + (core func (;10;) (canon lower (func $f) (memory 1) (realloc 9))) + (core func (;11;) (canon lower (func $f) (memory $mem) (realloc $realloc))) + (core func (;12;) (canon lower (func $f) (memory $mem) (realloc $realloc))) + (core func (;13;) (canon lower (func $f) (memory $mem) (realloc $realloc))) + (core func (;14;) (canon lower (func $f) (memory $mem) (realloc $realloc))) + (alias core export $libc "mem" (core memory (;2;))) + (alias core export $libc "realloc" (core func (;15;))) + (core func (;16;) (canon lower (func $f) (memory 2) (realloc 15))) + ) +) diff --git a/tests/snapshots/cli/component-model/indices.wast/3.print b/tests/snapshots/cli/component-model/indices.wast/3.print new file mode 100644 index 0000000000..3407301cf8 --- /dev/null +++ b/tests/snapshots/cli/component-model/indices.wast/3.print @@ -0,0 +1,72 @@ +(component + (component (;0;) + (core module $M (;0;) + (type (;0;) (func)) + (export "f" (func 0)) + (func (;0;) (type 0)) + ) + (core instance $m (;0;) (instantiate $M)) + (alias core export $m "f" (core func $f (;0;))) + (type (;0;) (func)) + (func (;0;) (type 0) (canon lift (core func $f))) + (type (;1;) (func)) + (func (;1;) (type 1) (canon lift (core func $f))) + (type (;2;) (func)) + (alias core export $m "f" (core func (;1;))) + (func (;2;) (type 2) (canon lift (core func 1))) + (type (;3;) (func)) + (func (;3;) (type 3) (canon lift (core func $f))) + (type (;4;) (func)) + (func (;4;) (type 4) (canon lift (core func $f))) + (type (;5;) (func)) + (alias core export $m "f" (core func (;2;))) + (func (;5;) (type 5) (canon lift (core func 2))) + ) + (component (;1;) + (core module $M (;0;) + (type (;0;) (func (param i32 i32 i32 i32) (result i32))) + (type (;1;) (func (param i32 i32) (result i32))) + (type (;2;) (func (param i32))) + (memory (;0;) 1) + (export "mem" (memory 0)) + (export "realloc" (func 0)) + (export "run" (func 1)) + (export "post" (func 2)) + (func (;0;) (type 0) (param i32 i32 i32 i32) (result i32) + unreachable + ) + (func (;1;) (type 1) (param i32 i32) (result i32) + unreachable + ) + (func (;2;) (type 2) (param i32)) + ) + (core instance $m (;0;) (instantiate $M)) + (alias core export $m "mem" (core memory $mem (;0;))) + (alias core export $m "realloc" (core func $realloc (;0;))) + (alias core export $m "post" (core func $post (;1;))) + (type (;0;) (func (param "s" string) (result string))) + (alias core export $m "run" (core func (;2;))) + (func (;0;) (type 0) (canon lift (core func 2) (memory $mem) (realloc $realloc) (post-return $post))) + (type (;1;) (func (param "s" string) (result string))) + (alias core export $m "run" (core func (;3;))) + (func (;1;) (type 1) (canon lift (core func 3) (memory $mem) (realloc $realloc) (post-return $post))) + (type (;2;) (func (param "s" string) (result string))) + (alias core export $m "run" (core func (;4;))) + (alias core export $m "mem" (core memory (;1;))) + (func (;2;) (type 2) (canon lift (core func 4) (memory 1) (realloc $realloc) (post-return $post))) + (type (;3;) (func (param "s" string) (result string))) + (alias core export $m "run" (core func (;5;))) + (alias core export $m "realloc" (core func (;6;))) + (func (;3;) (type 3) (canon lift (core func 5) (memory $mem) (realloc 6) (post-return $post))) + (type (;4;) (func (param "s" string) (result string))) + (alias core export $m "run" (core func (;7;))) + (alias core export $m "post" (core func (;8;))) + (func (;4;) (type 4) (canon lift (core func 7) (memory $mem) (realloc $realloc) (post-return 8))) + (type (;5;) (func (param "s" string) (result string))) + (alias core export $m "run" (core func (;9;))) + (alias core export $m "mem" (core memory (;2;))) + (alias core export $m "realloc" (core func (;10;))) + (alias core export $m "post" (core func (;11;))) + (func (;5;) (type 5) (canon lift (core func 9) (memory 2) (realloc 10) (post-return 11))) + ) +) diff --git a/tests/snapshots/cli/component-model/indices.wast/4.print b/tests/snapshots/cli/component-model/indices.wast/4.print new file mode 100644 index 0000000000..d870078b63 --- /dev/null +++ b/tests/snapshots/cli/component-model/indices.wast/4.print @@ -0,0 +1,16 @@ +(component + (component (;0;) + (core module $M (;0;) + (type (;0;) (func (param i32))) + (export "dtor" (func 0)) + (func (;0;) (type 0) (param i32)) + ) + (core instance $m (;0;) (instantiate $M)) + (alias core export $m "dtor" (core func $dtor (;0;))) + (type $R1 (;0;) (resource (rep i32) (dtor $dtor))) + (type $R2 (;1;) (resource (rep i32) (dtor $dtor))) + (type $R3 (;2;) (resource (rep i32) (dtor $dtor))) + (alias core export $m "dtor" (core func (;1;))) + (type $R4 (;3;) (resource (rep i32) (dtor 1))) + ) +) diff --git a/tests/snapshots/cli/component-model/indices.wast/5.print b/tests/snapshots/cli/component-model/indices.wast/5.print new file mode 100644 index 0000000000..b9b1b0d78f --- /dev/null +++ b/tests/snapshots/cli/component-model/indices.wast/5.print @@ -0,0 +1,18 @@ +(component + (component (;0;) + (core module $M (;0;) + (memory (;0;) 1) + (export "mem" (memory 0)) + ) + (core instance $m (;0;) (instantiate $M)) + (alias core export $m "mem" (core memory $mem (;0;))) + (core func (;0;) (canon waitable-set.wait (memory $mem))) + (core func (;1;) (canon waitable-set.wait (memory $mem))) + (core func (;2;) (canon waitable-set.wait (memory $mem))) + (alias core export $m "mem" (core memory (;1;))) + (core func (;3;) (canon waitable-set.wait (memory 1))) + (core func (;4;) (canon waitable-set.poll (memory $mem))) + (alias core export $m "mem" (core memory (;2;))) + (core func (;5;) (canon waitable-set.poll (memory 2))) + ) +) diff --git a/tests/snapshots/cli/component-model/indices.wast/6.print b/tests/snapshots/cli/component-model/indices.wast/6.print new file mode 100644 index 0000000000..f3984d513d --- /dev/null +++ b/tests/snapshots/cli/component-model/indices.wast/6.print @@ -0,0 +1,18 @@ +(component + (component (;0;) + (core type $ft (;0;) (func (param i32))) + (core module $M (;0;) + (table (;0;) 1 funcref) + (export "tbl" (table 0)) + ) + (core instance $m (;0;) (instantiate $M)) + (alias core export $m "tbl" (core table $tbl (;0;))) + (core func (;0;) (canon thread.new-indirect $ft $tbl)) + (core func (;1;) (canon thread.new-indirect $ft $tbl)) + (core func (;2;) (canon thread.new-indirect $ft $tbl)) + (core func (;3;) (canon thread.new-indirect $ft $tbl)) + (core func (;4;) (canon thread.new-indirect $ft $tbl)) + (alias core export $m "tbl" (core table (;1;))) + (core func (;5;) (canon thread.new-indirect $ft 1)) + ) +) diff --git a/tests/snapshots/cli/component-model/indices.wast/7.print b/tests/snapshots/cli/component-model/indices.wast/7.print new file mode 100644 index 0000000000..f33659a13a --- /dev/null +++ b/tests/snapshots/cli/component-model/indices.wast/7.print @@ -0,0 +1,18 @@ +(component + (component (;0;) + (type $T (;0;) (future u32)) + (type (;1;) + (instance + (alias outer 1 $T (type (;0;))) + (export (;1;) "T" (type (eq 0))) + ) + ) + (import "i" (instance $i (;0;) (type 1))) + (core func (;0;) (canon future.new $T)) + (core func (;1;) (canon future.new $T)) + (core func (;2;) (canon future.new $T)) + (core func (;3;) (canon future.new $T)) + (alias export $i "T" (type (;2;))) + (core func (;4;) (canon future.new 2)) + ) +) diff --git a/tests/snapshots/cli/component-model/legacy-indices.wast.json b/tests/snapshots/cli/component-model/legacy-indices.wast.json new file mode 100644 index 0000000000..b31d1e30ae --- /dev/null +++ b/tests/snapshots/cli/component-model/legacy-indices.wast.json @@ -0,0 +1,53 @@ +{ + "source_filename": "tests/cli/component-model/legacy-indices.wast", + "commands": [ + { + "type": "module", + "line": 5, + "filename": "legacy-indices.0.wasm", + "module_type": "binary" + }, + { + "type": "module", + "line": 25, + "filename": "legacy-indices.1.wasm", + "module_type": "binary" + }, + { + "type": "module", + "line": 40, + "filename": "legacy-indices.2.wasm", + "module_type": "binary" + }, + { + "type": "module", + "line": 50, + "filename": "legacy-indices.3.wasm", + "module_type": "binary" + }, + { + "type": "module", + "line": 60, + "filename": "legacy-indices.4.wasm", + "module_type": "binary" + }, + { + "type": "module", + "line": 71, + "filename": "legacy-indices.5.wasm", + "module_type": "binary" + }, + { + "type": "module", + "line": 79, + "filename": "legacy-indices.6.wasm", + "module_type": "binary" + }, + { + "type": "module", + "line": 87, + "filename": "legacy-indices.7.wasm", + "module_type": "binary" + } + ] +} \ No newline at end of file diff --git a/tests/snapshots/cli/component-model/legacy-indices.wast/0.print b/tests/snapshots/cli/component-model/legacy-indices.wast/0.print new file mode 100644 index 0000000000..45dc0a52eb --- /dev/null +++ b/tests/snapshots/cli/component-model/legacy-indices.wast/0.print @@ -0,0 +1,22 @@ +(component + (type (;0;) (func (param "x" string))) + (import "f" (func $f (;0;) (type 0))) + (core module $libc (;0;) + (type (;0;) (func (param i32 i32 i32 i32) (result i32))) + (memory (;0;) 1) + (export "mem" (memory 0)) + (export "realloc" (func 0)) + (func (;0;) (type 0) (param i32 i32 i32 i32) (result i32) + unreachable + ) + ) + (core instance $libc (;0;) (instantiate $libc)) + (alias core export $libc "realloc" (core func $realloc (;0;))) + (alias core export $libc "mem" (core memory (;0;))) + (alias core export $libc "realloc" (core func (;1;))) + (core func (;2;) (canon lower (func $f) (memory 0) (realloc 1))) + (alias core export $libc "mem" (core memory (;1;))) + (core func (;3;) (canon lower (func $f) (memory 1) (realloc $realloc))) + (alias core export $libc "mem" (core memory (;2;))) + (core func (;4;) (canon lower (func $f) (memory 2) (realloc $realloc))) +) diff --git a/tests/snapshots/cli/component-model/legacy-indices.wast/1.print b/tests/snapshots/cli/component-model/legacy-indices.wast/1.print new file mode 100644 index 0000000000..ab35704cf1 --- /dev/null +++ b/tests/snapshots/cli/component-model/legacy-indices.wast/1.print @@ -0,0 +1,27 @@ +(component + (core module $m (;0;) + (type (;0;) (func (param i32 i32 i32 i32) (result i32))) + (type (;1;) (func (param i32 i32) (result i32))) + (type (;2;) (func (param i32))) + (memory (;0;) 1) + (export "mem" (memory 0)) + (export "realloc" (func 0)) + (export "run" (func 1)) + (export "post" (func 2)) + (func (;0;) (type 0) (param i32 i32 i32 i32) (result i32) + unreachable + ) + (func (;1;) (type 1) (param i32 i32) (result i32) + unreachable + ) + (func (;2;) (type 2) (param i32)) + ) + (core instance $m (;0;) (instantiate $m)) + (type (;0;) (func (param "s" string) (result string))) + (alias core export $m "run" (core func (;0;))) + (alias core export $m "mem" (core memory (;0;))) + (alias core export $m "realloc" (core func (;1;))) + (alias core export $m "post" (core func (;2;))) + (func (;0;) (type 0) (canon lift (core func 0) (memory 0) (realloc 1) (post-return 2))) + (export (;1;) "run" (func 0)) +) diff --git a/tests/snapshots/cli/component-model/legacy-indices.wast/2.print b/tests/snapshots/cli/component-model/legacy-indices.wast/2.print new file mode 100644 index 0000000000..19b6fd7fd3 --- /dev/null +++ b/tests/snapshots/cli/component-model/legacy-indices.wast/2.print @@ -0,0 +1,19 @@ +(component + (core module $m (;0;) + (type (;0;) (func (param i32 i32 i32) (result i32))) + (type (;1;) (func (result i32))) + (export "cb" (func 0)) + (export "f" (func 1)) + (func (;0;) (type 0) (param i32 i32 i32) (result i32) + unreachable + ) + (func (;1;) (type 1) (result i32) + unreachable + ) + ) + (core instance $m (;0;) (instantiate $m)) + (type (;0;) (func async)) + (alias core export $m "f" (core func (;0;))) + (alias core export $m "cb" (core func (;1;))) + (func (;0;) (type 0) (canon lift (core func 0) async (callback 1))) +) diff --git a/tests/snapshots/cli/component-model/legacy-indices.wast/3.print b/tests/snapshots/cli/component-model/legacy-indices.wast/3.print new file mode 100644 index 0000000000..e4eadf9609 --- /dev/null +++ b/tests/snapshots/cli/component-model/legacy-indices.wast/3.print @@ -0,0 +1,13 @@ +(component + (core module $m (;0;) + (type (;0;) (func (param i32))) + (export "dtor" (func 0)) + (func (;0;) (type 0) (param i32)) + ) + (core instance $m (;0;) (instantiate $m)) + (alias core export $m "dtor" (core func $dtor (;0;))) + (type $R1 (;0;) (resource (rep i32) (dtor $dtor))) + (type $R2 (;1;) (resource (rep i32) (dtor $dtor))) + (alias core export $m "dtor" (core func (;1;))) + (type $R3 (;2;) (resource (rep i32) (dtor 1))) +) diff --git a/tests/snapshots/cli/component-model/legacy-indices.wast/4.print b/tests/snapshots/cli/component-model/legacy-indices.wast/4.print new file mode 100644 index 0000000000..e4d44c69e6 --- /dev/null +++ b/tests/snapshots/cli/component-model/legacy-indices.wast/4.print @@ -0,0 +1,13 @@ +(component + (core type $start (;0;) (func (param i32))) + (core module $libc (;0;) + (table (;0;) 1 funcref) + (export "start-table" (table 0)) + ) + (core instance $libc (;0;) (instantiate $libc)) + (alias core export $libc "start-table" (core table $tbl (;0;))) + (alias core export $libc "start-table" (core table (;1;))) + (core func (;0;) (canon thread.new-indirect $start 1)) + (core func (;1;) (canon thread.new-indirect $start $tbl)) + (core func (;2;) (canon thread.new-indirect $start $tbl)) +) diff --git a/tests/snapshots/cli/component-model/legacy-indices.wast/5.print b/tests/snapshots/cli/component-model/legacy-indices.wast/5.print new file mode 100644 index 0000000000..cabf638866 --- /dev/null +++ b/tests/snapshots/cli/component-model/legacy-indices.wast/5.print @@ -0,0 +1,10 @@ +(component + (core type $start (;0;) (shared (func (param i32)))) + (core module $libc (;0;) + (table (;0;) shared 1 (ref null (shared func))) + (export "start-table" (table 0)) + ) + (core instance $libc (;0;) (instantiate $libc)) + (alias core export $libc "start-table" (core table (;0;))) + (core func (;0;) (canon thread.spawn-indirect $start 0)) +) diff --git a/tests/snapshots/cli/component-model/legacy-indices.wast/6.print b/tests/snapshots/cli/component-model/legacy-indices.wast/6.print new file mode 100644 index 0000000000..5dd3e2381b --- /dev/null +++ b/tests/snapshots/cli/component-model/legacy-indices.wast/6.print @@ -0,0 +1,11 @@ +(component + (core module $libc (;0;) + (memory (;0;) 1) + (export "memory" (memory 0)) + ) + (core instance $libc (;0;) (instantiate $libc)) + (alias core export $libc "memory" (core memory (;0;))) + (core func (;0;) (canon waitable-set.wait (memory 0))) + (alias core export $libc "memory" (core memory (;1;))) + (core func (;1;) (canon waitable-set.poll (memory 1))) +) diff --git a/tests/snapshots/cli/component-model/legacy-indices.wast/7.print b/tests/snapshots/cli/component-model/legacy-indices.wast/7.print new file mode 100644 index 0000000000..4e59d9737a --- /dev/null +++ b/tests/snapshots/cli/component-model/legacy-indices.wast/7.print @@ -0,0 +1,14 @@ +(component + (core type $ty (;0;) (func (param externref))) + (type (;0;) + (instance + (export (;0;) "r" (type (sub resource))) + (type (;1;) (own 0)) + (type (;2;) (func (param "x" 1))) + (export (;0;) "f" (func (type 2))) + ) + ) + (import "i" (instance $i (;0;) (type 0))) + (alias export $i "f" (func (;0;))) + (core func (;0;) (canon lower (func 0) gc string-encoding=utf8 (core-type $ty))) +) diff --git a/tests/snapshots/cli/component-model/memory64/resources.wast/2.print b/tests/snapshots/cli/component-model/memory64/resources.wast/2.print index 9b4fde2ae4..770f86d65c 100644 --- a/tests/snapshots/cli/component-model/memory64/resources.wast/2.print +++ b/tests/snapshots/cli/component-model/memory64/resources.wast/2.print @@ -6,6 +6,6 @@ ) (core instance $m (;0;) (instantiate $m)) (alias core export $m "dtor" (core func (;0;))) - (type $x (;0;) (resource (rep i64) (dtor (func 0)))) + (type $x (;0;) (resource (rep i64) (dtor 0))) (core func (;1;) (canon resource.new $x)) ) diff --git a/tests/snapshots/cli/component-model/resources.wast/3.print b/tests/snapshots/cli/component-model/resources.wast/3.print index 28b749ac58..4638465c3a 100644 --- a/tests/snapshots/cli/component-model/resources.wast/3.print +++ b/tests/snapshots/cli/component-model/resources.wast/3.print @@ -6,6 +6,6 @@ ) (core instance $m (;0;) (instantiate $m)) (alias core export $m "dtor" (core func (;0;))) - (type $x (;0;) (resource (rep i32) (dtor (func 0)))) + (type $x (;0;) (resource (rep i32) (dtor 0))) (core func (;1;) (canon resource.new $x)) ) diff --git a/tests/snapshots/cli/shared-everything-threads/builtins.wast/0.print b/tests/snapshots/cli/shared-everything-threads/builtins.wast/0.print index 3676e79227..c6181f4d96 100644 --- a/tests/snapshots/cli/shared-everything-threads/builtins.wast/0.print +++ b/tests/snapshots/cli/shared-everything-threads/builtins.wast/0.print @@ -7,6 +7,6 @@ ) (core instance $libc (;0;) (instantiate $libc)) (alias core export $libc "start-table" (core table (;0;))) - (core func $spawn-indirect (;1;) (canon thread.spawn-indirect $start (table 0))) + (core func $spawn-indirect (;1;) (canon thread.spawn-indirect $start 0)) (core func $parallelism (;2;) (canon thread.available_parallelism)) ) diff --git a/tests/snapshots/cli/shared-everything-threads/builtins.wast/1.print b/tests/snapshots/cli/shared-everything-threads/builtins.wast/1.print index 184f9eae50..e72ece54d5 100644 --- a/tests/snapshots/cli/shared-everything-threads/builtins.wast/1.print +++ b/tests/snapshots/cli/shared-everything-threads/builtins.wast/1.print @@ -7,7 +7,7 @@ ) (core instance $libc (;0;) (instantiate $libc)) (alias core export $libc "start-table" (core table (;0;))) - (core func $spawn-indirect (;1;) (canon thread.spawn-indirect $start (table 0))) + (core func $spawn-indirect (;1;) (canon thread.spawn-indirect $start 0)) (core func $parallelism (;2;) (canon thread.available_parallelism)) (core module $m (;1;) (type $spawned_func_ty (;0;) (shared (func (param i32))))