Update wasm-tools crates (#5945)

This notably updates `wasmparser` for updates to the relaxed-simd
proposal and an implementation of the function-references proposal.
Additionally there are some minor bug fixes being picked up for WIT and
the component model.
This commit is contained in:
Alex Crichton
2023-03-06 17:47:34 -06:00
committed by GitHub
parent 58430b1dd7
commit 3c9fc3ec8c
19 changed files with 203 additions and 101 deletions

57
Cargo.lock generated
View File

@@ -3285,7 +3285,7 @@ checksum = "158180f35c9ba89a3e7763f20be93e77d5e41535c18e22c85d6dd5b5bce18108"
dependencies = [
"wasm-coredump-encoder",
"wasm-coredump-types",
"wasm-encoder",
"wasm-encoder 0.23.0",
]
[[package]]
@@ -3314,30 +3314,39 @@ dependencies = [
]
[[package]]
name = "wasm-mutate"
version = "0.2.18"
name = "wasm-encoder"
version = "0.25.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "87a229d5b8e4b2b78985dc905f0a033ba8a0bc948321622d41912238c6e0eab1"
checksum = "4eff853c4f09eec94d76af527eddad4e9de13b11d6286a1ef7134bc30135a2b7"
dependencies = [
"leb128",
]
[[package]]
name = "wasm-mutate"
version = "0.2.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "92ada47eda4f13d5dd83b77af7751dd44f1ab8120c01f2fca5b78b49080cf82c"
dependencies = [
"egg",
"log",
"rand 0.8.5",
"thiserror",
"wasm-encoder",
"wasm-encoder 0.25.0",
"wasmparser",
]
[[package]]
name = "wasm-smith"
version = "0.12.2"
version = "0.12.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "411278ee8e89067a252a3a6d6d578038251f9c0a1d4c088adf4162ad13e97b04"
checksum = "549cb78be46f43ad6746402871336cb6a989127fb847e93eb6ba0817647485a6"
dependencies = [
"arbitrary",
"flagset",
"indexmap",
"leb128",
"wasm-encoder",
"wasm-encoder 0.25.0",
"wasmparser",
]
@@ -3381,9 +3390,9 @@ dependencies = [
[[package]]
name = "wasmparser"
version = "0.100.0"
version = "0.102.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "64b20236ab624147dfbb62cf12a19aaf66af0e41b8398838b66e997d07d269d4"
checksum = "48134de3d7598219ab9eaf6b91b15d8e50d31da76b8519fe4ecfcec2cf35104b"
dependencies = [
"indexmap",
"url",
@@ -3400,9 +3409,9 @@ dependencies = [
[[package]]
name = "wasmprinter"
version = "0.2.50"
version = "0.2.53"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b2d3f7d7cb1e00ae9f91bb21f2856cdc68a913afb3b6b33fca5a83dba8c8c4eb"
checksum = "5aa44d546e4e4479f2e91035fa497c0a05cffbf22413ad05bf0b06a789b9118f"
dependencies = [
"anyhow",
"wasmparser",
@@ -3556,7 +3565,7 @@ dependencies = [
"wasmtime-wasi-nn",
"wasmtime-wasi-threads",
"wasmtime-wast",
"wast 53.0.0",
"wast 55.0.0",
"wat",
"windows-sys",
]
@@ -3628,7 +3637,7 @@ dependencies = [
"serde",
"target-lexicon",
"thiserror",
"wasm-encoder",
"wasm-encoder 0.25.0",
"wasmparser",
"wasmprinter",
"wasmtime-component-util",
@@ -3703,7 +3712,7 @@ dependencies = [
"target-lexicon",
"tempfile",
"v8",
"wasm-encoder",
"wasm-encoder 0.25.0",
"wasm-mutate",
"wasm-smith",
"wasm-spec-interpreter",
@@ -3844,7 +3853,7 @@ dependencies = [
"anyhow",
"log",
"wasmtime",
"wast 53.0.0",
"wast 55.0.0",
]
[[package]]
@@ -3879,23 +3888,23 @@ dependencies = [
[[package]]
name = "wast"
version = "53.0.0"
version = "55.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8244fa24196b1d8fd3ca4a96a3a164c40f846498c5deab6caf414c67340ca4af"
checksum = "4984d3e1406571f4930ba5cf79bd70f75f41d0e87e17506e0bd19b0e5d085f05"
dependencies = [
"leb128",
"memchr",
"unicode-width",
"wasm-encoder",
"wasm-encoder 0.25.0",
]
[[package]]
name = "wat"
version = "1.0.58"
version = "1.0.61"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4620f1059add6dad511decb9d5d88b4a0a0d3e2e315ed34f79b0dc0dce18aa4b"
checksum = "af2b53f4da14db05d32e70e9c617abdf6620c575bd5dd972b7400037b4df2091"
dependencies = [
"wast 53.0.0",
"wast 55.0.0",
]
[[package]]
@@ -4143,9 +4152,9 @@ dependencies = [
[[package]]
name = "wit-parser"
version = "0.6.1"
version = "0.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a84965789410bf21087f5a352703142f77b9b4d1478764c3f33a1ea8c7101f40"
checksum = "f887c3da527a51b321076ebe6a7513026a4757b6d4d144259946552d6fc728b3"
dependencies = [
"anyhow",
"id-arena",

View File

@@ -165,14 +165,14 @@ winch-test-macros = { path = "winch/test-macros" }
target-lexicon = { version = "0.12.3", default-features = false, features = ["std"] }
anyhow = "1.0.22"
wasmparser = "0.100.0"
wat = "1.0.57"
wast = "53.0.0"
wasmprinter = "0.2.50"
wasm-encoder = "0.23.0"
wasm-smith = "0.12.1"
wasm-mutate = "0.2.17"
wit-parser = "0.6.1"
wasmparser = "0.102.0"
wat = "1.0.61"
wast = "55.0.0"
wasmprinter = "0.2.53"
wasm-encoder = "0.25.0"
wasm-smith = "0.12.5"
wasm-mutate = "0.2.21"
wit-parser = "0.6.4"
windows-sys = "0.45.0"
env_logger = "0.9"
rustix = "0.36.7"

View File

@@ -1151,8 +1151,8 @@ pub fn translate_operator<FE: FuncEnvironment + ?Sized>(
Operator::F32Le | Operator::F64Le => {
translate_fcmp(FloatCC::LessThanOrEqual, builder, state)
}
Operator::RefNull { ty } => {
state.push1(environ.translate_ref_null(builder.cursor(), (*ty).try_into()?)?)
Operator::RefNull { hty } => {
state.push1(environ.translate_ref_null(builder.cursor(), (*hty).try_into()?)?)
}
Operator::RefIsNull => {
let value = state.pop1();
@@ -2157,14 +2157,14 @@ pub fn translate_operator<FE: FuncEnvironment + ?Sized>(
));
}
Operator::I8x16RelaxedSwizzle
| Operator::I32x4RelaxedTruncSatF32x4S
| Operator::I32x4RelaxedTruncSatF32x4U
| Operator::I32x4RelaxedTruncSatF64x2SZero
| Operator::I32x4RelaxedTruncSatF64x2UZero
| Operator::F32x4RelaxedFma
| Operator::F32x4RelaxedFnma
| Operator::F64x2RelaxedFma
| Operator::F64x2RelaxedFnma
| Operator::I32x4RelaxedTruncF32x4S
| Operator::I32x4RelaxedTruncF32x4U
| Operator::I32x4RelaxedTruncF64x2SZero
| Operator::I32x4RelaxedTruncF64x2UZero
| Operator::F32x4RelaxedMadd
| Operator::F32x4RelaxedNmadd
| Operator::F64x2RelaxedMadd
| Operator::F64x2RelaxedNmadd
| Operator::I8x16RelaxedLaneselect
| Operator::I16x8RelaxedLaneselect
| Operator::I32x4RelaxedLaneselect
@@ -2174,11 +2174,21 @@ pub fn translate_operator<FE: FuncEnvironment + ?Sized>(
| Operator::F64x2RelaxedMin
| Operator::F64x2RelaxedMax
| Operator::I16x8RelaxedQ15mulrS
| Operator::I16x8DotI8x16I7x16S
| Operator::I32x4DotI8x16I7x16AddS
| Operator::F32x4RelaxedDotBf16x8AddF32x4 => {
| Operator::I16x8RelaxedDotI8x16I7x16S
| Operator::I32x4RelaxedDotI8x16I7x16AddS => {
return Err(wasm_unsupported!("proposed relaxed-simd operator {:?}", op));
}
Operator::CallRef { .. }
| Operator::ReturnCallRef { .. }
| Operator::BrOnNull { .. }
| Operator::BrOnNonNull { .. }
| Operator::RefAsNonNull => {
return Err(wasm_unsupported!(
"proposed function-references operator {:?}",
op
));
}
};
Ok(())
}

View File

@@ -202,9 +202,13 @@ fn declare_locals<FE: FuncEnvironment + ?Sized>(
let constant_handle = builder.func.dfg.constants.insert([0; 16].to_vec().into());
builder.ins().vconst(ir::types::I8X16, constant_handle)
}
ExternRef | FuncRef => {
environ.translate_ref_null(builder.cursor(), wasm_type.try_into()?)?
}
Ref(wasmparser::RefType {
nullable: true,
heap_type,
}) => environ.translate_ref_null(builder.cursor(), heap_type.try_into()?)?,
Ref(wasmparser::RefType {
nullable: false, ..
}) => unreachable!(),
};
let ty = builder.func.dfg.value_type(zeroval);

View File

@@ -143,7 +143,7 @@ pub fn parse_table_section(
environ.reserve_tables(tables.count())?;
for entry in tables {
let ty = table(entry?)?;
let ty = table(entry?.ty)?;
environ.declare_table(ty)?;
}
@@ -198,7 +198,7 @@ pub fn parse_global_section(
Operator::V128Const { value } => {
GlobalInit::V128Const(u128::from_le_bytes(*value.bytes()))
}
Operator::RefNull { ty: _ } => GlobalInit::RefNullConst,
Operator::RefNull { hty: _ } => GlobalInit::RefNullConst,
Operator::RefFunc { function_index } => {
GlobalInit::RefFunc(FuncIndex::from_u32(function_index))
}

View File

@@ -37,8 +37,9 @@ where
wasmparser::ValType::F32 => &[wasmparser::ValType::F32],
wasmparser::ValType::F64 => &[wasmparser::ValType::F64],
wasmparser::ValType::V128 => &[wasmparser::ValType::V128],
wasmparser::ValType::ExternRef => &[wasmparser::ValType::ExternRef],
wasmparser::ValType::FuncRef => &[wasmparser::ValType::FuncRef],
wasmparser::ValType::EXTERNREF => &[wasmparser::ValType::EXTERNREF],
wasmparser::ValType::FUNCREF => &[wasmparser::ValType::FUNCREF],
wasmparser::ValType::Ref(_) => unimplemented!("function references proposal"),
};
(
itertools::Either::Left(params.iter().copied()),
@@ -79,7 +80,7 @@ pub fn block_with_params<PE: TargetEnvironment + ?Sized>(
wasmparser::ValType::F64 => {
builder.append_block_param(block, ir::types::F64);
}
wasmparser::ValType::ExternRef | wasmparser::ValType::FuncRef => {
wasmparser::ValType::Ref(ty) => {
builder.append_block_param(block, environ.reference_type(ty.try_into()?));
}
wasmparser::ValType::V128 => {

View File

@@ -2648,10 +2648,8 @@ impl Compiler<'_, '_> {
| (ValType::F64, ValType::F32)
// not used in the component model
| (ValType::ExternRef, _)
| (_, ValType::ExternRef)
| (ValType::FuncRef, _)
| (_, ValType::FuncRef)
| (ValType::Ref(_), _)
| (_, ValType::Ref(_))
| (ValType::V128, _)
| (_, ValType::V128) => {
panic!("cannot get {dst_ty:?} from {src_ty:?} local");
@@ -2705,10 +2703,8 @@ impl Compiler<'_, '_> {
| (ValType::F32, ValType::F64)
// not used in the component model
| (ValType::ExternRef, _)
| (_, ValType::ExternRef)
| (ValType::FuncRef, _)
| (_, ValType::FuncRef)
| (ValType::Ref(_), _)
| (_, ValType::Ref(_))
| (ValType::V128, _)
| (_, ValType::V128) => {
panic!("cannot get {dst_ty:?} from {src_ty:?} local");

View File

@@ -301,7 +301,7 @@ impl<'a, 'data> ModuleEnvironment<'a, 'data> {
self.result.module.table_plans.reserve_exact(cnt);
for entry in tables {
let table = entry?.try_into()?;
let table = entry?.ty.try_into()?;
let plan = TablePlan::for_table(table, &self.tunables);
self.result.module.table_plans.push(plan);
}
@@ -345,7 +345,7 @@ impl<'a, 'data> ModuleEnvironment<'a, 'data> {
Operator::V128Const { value } => {
GlobalInit::V128Const(u128::from_le_bytes(*value.bytes()))
}
Operator::RefNull { ty: _ } => GlobalInit::RefNullConst,
Operator::RefNull { hty: _ } => GlobalInit::RefNullConst,
Operator::RefFunc { function_index } => {
let index = FuncIndex::from_u32(function_index);
self.flag_func_escaped(index);

View File

@@ -122,7 +122,7 @@ impl Stacks {
types.function(vec![], vec![]);
let call_func_type = types.len();
types.function(vec![wasm_encoder::ValType::FuncRef], vec![]);
types.function(vec![wasm_encoder::ValType::FUNCREF], vec![]);
section(&mut module, types);
@@ -190,7 +190,7 @@ impl Stacks {
let mut elems = wasm_encoder::ElementSection::new();
elems.declared(
wasm_encoder::ValType::FuncRef,
wasm_encoder::RefType::FUNCREF,
wasm_encoder::Elements::Functions(
&(0..num_imported_funcs + u32::try_from(self.funcs.len()).unwrap())
.collect::<Vec<_>>(),

View File

@@ -4,8 +4,8 @@ use arbitrary::{Arbitrary, Result, Unstructured};
use std::ops::RangeInclusive;
use wasm_encoder::{
CodeSection, ConstExpr, EntityType, ExportKind, ExportSection, Function, FunctionSection,
GlobalSection, ImportSection, Instruction, Module, TableSection, TableType, TypeSection,
ValType,
GlobalSection, ImportSection, Instruction, Module, RefType, TableSection, TableType,
TypeSection, ValType,
};
/// A description of a Wasm module that makes a series of `externref` table
@@ -50,27 +50,27 @@ impl TableOps {
// dynamically adjusts the stack pointer for each call that uses
// return pointers rather than statically allocating space in the
// stack frame.
vec![ValType::ExternRef, ValType::ExternRef, ValType::ExternRef],
vec![ValType::EXTERNREF, ValType::EXTERNREF, ValType::EXTERNREF],
);
// 1: "run"
let mut params: Vec<ValType> = Vec::with_capacity(self.num_params as usize);
for _i in 0..self.num_params {
params.push(ValType::ExternRef);
params.push(ValType::EXTERNREF);
}
let results = vec![];
types.function(params, results);
// 2: `take_refs`
types.function(
vec![ValType::ExternRef, ValType::ExternRef, ValType::ExternRef],
vec![ValType::EXTERNREF, ValType::EXTERNREF, ValType::EXTERNREF],
vec![],
);
// 3: `make_refs`
types.function(
vec![],
vec![ValType::ExternRef, ValType::ExternRef, ValType::ExternRef],
vec![ValType::EXTERNREF, ValType::EXTERNREF, ValType::EXTERNREF],
);
// Import the GC function.
@@ -82,7 +82,7 @@ impl TableOps {
// Define our table.
let mut tables = TableSection::new();
tables.table(TableType {
element_type: ValType::ExternRef,
element_type: RefType::EXTERNREF,
minimum: self.table_size as u32,
maximum: None,
});
@@ -92,10 +92,10 @@ impl TableOps {
for _ in 0..self.num_globals {
globals.global(
wasm_encoder::GlobalType {
val_type: wasm_encoder::ValType::ExternRef,
val_type: wasm_encoder::ValType::EXTERNREF,
mutable: true,
},
&ConstExpr::ref_null(wasm_encoder::ValType::ExternRef),
&ConstExpr::ref_null(wasm_encoder::HeapType::Extern),
);
}
@@ -108,7 +108,7 @@ impl TableOps {
// Give ourselves one scratch local that we can use in various `TableOp`
// implementations.
let mut func = Function::new(vec![(1, ValType::ExternRef)]);
let mut func = Function::new(vec![(1, ValType::EXTERNREF)]);
func.instruction(&Instruction::Loop(wasm_encoder::BlockType::Empty));
for op in &self.ops {
@@ -261,7 +261,7 @@ impl TableOp {
func.instruction(&Instruction::Drop);
}
Self::Null => {
func.instruction(&Instruction::RefNull(wasm_encoder::ValType::ExternRef));
func.instruction(&Instruction::RefNull(wasm_encoder::HeapType::Extern));
}
}
}

View File

@@ -41,8 +41,36 @@ impl TryFrom<wasmparser::ValType> for WasmType {
F32 => Ok(WasmType::F32),
F64 => Ok(WasmType::F64),
V128 => Ok(WasmType::V128),
FuncRef => Ok(WasmType::FuncRef),
ExternRef => Ok(WasmType::ExternRef),
Ref(r) => r.try_into(),
}
}
}
impl TryFrom<wasmparser::RefType> for WasmType {
type Error = WasmError;
fn try_from(ty: wasmparser::RefType) -> Result<Self, Self::Error> {
match ty {
wasmparser::RefType::FUNCREF => Ok(WasmType::FuncRef),
wasmparser::RefType::EXTERNREF => Ok(WasmType::ExternRef),
_ => Err(WasmError::Unsupported(
"function references proposal".to_string(),
)),
}
}
}
impl TryFrom<wasmparser::HeapType> for WasmType {
type Error = WasmError;
fn try_from(ty: wasmparser::HeapType) -> Result<Self, Self::Error> {
match ty {
wasmparser::HeapType::Func => Ok(WasmType::FuncRef),
wasmparser::HeapType::Extern => Ok(WasmType::ExternRef),
// NB: when the function-references proposal is implemented this
// entire `impl` should probably go away to remove the need for not
// only this `unsupported` but everything.
_ => Err(WasmError::Unsupported(
"function references proposal".to_string(),
)),
}
}
}
@@ -55,8 +83,8 @@ impl From<WasmType> for wasmparser::ValType {
WasmType::F32 => wasmparser::ValType::F32,
WasmType::F64 => wasmparser::ValType::F64,
WasmType::V128 => wasmparser::ValType::V128,
WasmType::FuncRef => wasmparser::ValType::FuncRef,
WasmType::ExternRef => wasmparser::ValType::ExternRef,
WasmType::FuncRef => wasmparser::ValType::FUNCREF,
WasmType::ExternRef => wasmparser::ValType::EXTERNREF,
}
}
}

View File

@@ -187,6 +187,7 @@ impl Metadata {
relaxed_simd,
extended_const,
memory_control,
function_references,
// Always on; we don't currently have knobs for these.
mutable_global: _,
@@ -197,6 +198,7 @@ impl Metadata {
assert!(!memory_control);
assert!(!tail_call);
assert!(!function_references);
Metadata {
target: engine.compiler().triple().to_string(),

View File

@@ -43,4 +43,8 @@ skip-tree = [
# They want to publish version 2.0 to upgrade `hashbrown` so in the meantime
# it is duplicated for us.
{ name = "indexmap", depth = 2 },
# This is on and older version of `wasm-encoder` and is one we can't
# necessarily easily update, so let `wasm-encoder` get duplicated for now.
{ name = "wasm-coredump-builder", depth = 2 },
]

View File

@@ -870,6 +870,12 @@ criteria = "safe-to-deploy"
version = "0.23.0"
notes = "The Bytecode Alliance is the author of this crate."
[[audits.wasm-encoder]]
who = "Alex Crichton <alex@alexcrichton.com>"
criteria = "safe-to-deploy"
version = "0.25.0"
notes = "The Bytecode Alliance is the author of this crate."
[[audits.wasm-encoder]]
who = "Alex Crichton <alex@alexcrichton.com>"
criteria = "safe-to-deploy"
@@ -948,6 +954,12 @@ criteria = "safe-to-run"
version = "0.2.18"
notes = "The Bytecode Alliance is the author of this crate."
[[audits.wasm-mutate]]
who = "Alex Crichton <alex@alexcrichton.com>"
criteria = "safe-to-run"
version = "0.2.21"
notes = "The Bytecode Alliance is the author of this crate."
[[audits.wasm-smith]]
who = "Alex Crichton <alex@alexcrichton.com>"
criteria = "safe-to-deploy"
@@ -1020,6 +1032,12 @@ criteria = "safe-to-run"
version = "0.12.2"
notes = "The Bytecode Alliance is the author of this crate."
[[audits.wasm-smith]]
who = "Alex Crichton <alex@alexcrichton.com>"
criteria = "safe-to-run"
version = "0.12.5"
notes = "The Bytecode Alliance is the author of this crate."
[[audits.wasmi]]
who = "Robin Freyler <robin.freyler@gmail.com>"
criteria = "safe-to-run"
@@ -1140,6 +1158,12 @@ criteria = "safe-to-deploy"
version = "0.100.0"
notes = "The Bytecode Alliance is the author of this crate."
[[audits.wasmparser]]
who = "Alex Crichton <alex@alexcrichton.com>"
criteria = "safe-to-deploy"
version = "0.102.0"
notes = "The Bytecode Alliance is the author of this crate."
[[audits.wasmparser-nostd]]
who = "Alex Crichton <alex@alexcrichton.com>"
criteria = "safe-to-run"
@@ -1223,6 +1247,12 @@ criteria = "safe-to-deploy"
version = "0.2.50"
notes = "The Bytecode Alliance is the author of this crate."
[[audits.wasmprinter]]
who = "Alex Crichton <alex@alexcrichton.com>"
criteria = "safe-to-deploy"
version = "0.2.53"
notes = "The Bytecode Alliance is the author of this crate."
[[audits.wast]]
who = "Alex Crichton <alex@alexcrichton.com>"
criteria = "safe-to-deploy"
@@ -1295,6 +1325,12 @@ criteria = "safe-to-deploy"
version = "53.0.0"
notes = "The Bytecode Alliance is the author of this crate."
[[audits.wast]]
who = "Alex Crichton <alex@alexcrichton.com>"
criteria = "safe-to-deploy"
version = "55.0.0"
notes = "The Bytecode Alliance is the author of this crate."
[[audits.wat]]
who = "Alex Crichton <alex@alexcrichton.com>"
criteria = "safe-to-deploy"
@@ -1349,6 +1385,12 @@ criteria = "safe-to-deploy"
version = "1.0.58"
notes = "The Bytecode Alliance is the author of this crate."
[[audits.wat]]
who = "Alex Crichton <alex@alexcrichton.com>"
criteria = "safe-to-deploy"
version = "1.0.61"
notes = "The Bytecode Alliance is the author of this crate."
[[audits.wat]]
who = "Alex Crichton <alex@alexcrichton.com>"
criteria = "safe-to-deploy"
@@ -1511,3 +1553,9 @@ criteria = "safe-to-deploy"
version = "0.6.1"
notes = "The Bytecode Alliance is the author of this crate."
[[audits.wit-parser]]
who = "Alex Crichton <alex@alexcrichton.com>"
criteria = "safe-to-deploy"
version = "0.6.4"
notes = "The Bytecode Alliance is the author of this crate."

View File

@@ -1984,7 +1984,7 @@ fn drop_component_still_works() -> Result<()> {
(export "" (func $f_lower))
))
))
(func (export "f")
(func (export "g")
(canon lift
(core func $i "f")
)
@@ -2008,7 +2008,7 @@ fn drop_component_still_works() -> Result<()> {
(store, instance)
};
let f = instance.get_typed_func::<(), ()>(&mut store, "f")?;
let f = instance.get_typed_func::<(), ()>(&mut store, "g")?;
assert_eq!(*store.data(), 0);
f.call(&mut store, ())?;
assert_eq!(*store.data(), 2);
@@ -2202,7 +2202,7 @@ fn lower_then_lift() -> Result<()> {
(func $f2 (result s32)
(canon lift (core func $f_lower))
)
(export "f" (func $f2))
(export "f2" (func $f2))
)
"#;
@@ -2213,7 +2213,7 @@ fn lower_then_lift() -> Result<()> {
linker.root().func_wrap("f", |_, _: ()| Ok((2u32,)))?;
let instance = linker.instantiate(&mut store, &component)?;
let f = instance.get_typed_func::<(), (i32,)>(&mut store, "f")?;
let f = instance.get_typed_func::<(), (i32,)>(&mut store, "f2")?;
assert_eq!(f.call(&mut store, ())?, (2,));
// First test strings when the import/export ABI happen to line up

View File

@@ -685,10 +685,10 @@ fn bad_import_alignment() -> Result<()> {
))
))
(func (export "unaligned-retptr")
(func (export "unaligned-retptr2")
(canon lift (core func $m "unaligned-retptr"))
)
(func (export "unaligned-argptr")
(func (export "unaligned-argptr2")
(canon lift (core func $m "unaligned-argptr"))
)
)
@@ -723,7 +723,7 @@ fn bad_import_alignment() -> Result<()> {
let trap = linker
.instantiate(&mut store, &component)?
.get_typed_func::<(), ()>(&mut store, "unaligned-retptr")?
.get_typed_func::<(), ()>(&mut store, "unaligned-retptr2")?
.call(&mut store, ())
.unwrap_err();
assert!(
@@ -733,7 +733,7 @@ fn bad_import_alignment() -> Result<()> {
);
let trap = linker
.instantiate(&mut store, &component)?
.get_typed_func::<(), ()>(&mut store, "unaligned-argptr")?
.get_typed_func::<(), ()>(&mut store, "unaligned-argptr2")?
.call(&mut store, ())
.unwrap_err();
assert!(

View File

@@ -114,7 +114,7 @@ fn test_roundtrip(engine: &Engine, src: &str, dst: &str) -> Result<()> {
(with "libc" (instance $libc))
(with "" (instance (export "echo" (func $echo))))
))
(func (export "echo") (param "a" string) (result string)
(func (export "echo2") (param "a" string) (result string)
(canon lift
(core func $echo "echo")
(memory $libc "memory")
@@ -163,8 +163,8 @@ fn test_roundtrip(engine: &Engine, src: &str, dst: &str) -> Result<()> {
{dst}
(instance $dst (instantiate $dst (with "echo" (func $host))))
(instance $src (instantiate $src (with "echo" (func $dst "echo"))))
(export "echo" (func $src "echo"))
(instance $src (instantiate $src (with "echo" (func $dst "echo2"))))
(export "echo" (func $src "echo2"))
)
"#
);

View File

@@ -244,17 +244,17 @@
(export "" (func $import))
))
))
(func $export (export "thunk") (result u32)
(func $export (export "thunk2") (result u32)
(canon lift (core func $reexport "thunk"))
)
)
(instance $c1 (instantiate $c (with "thunk" (func $root))))
(instance $c2 (instantiate $c (with "thunk" (func $c1 "thunk"))))
(instance $c3 (instantiate $c (with "thunk" (func $c2 "thunk"))))
(instance $c4 (instantiate $c (with "thunk" (func $c3 "thunk"))))
(instance $c5 (instantiate $c (with "thunk" (func $c4 "thunk"))))
(instance $c6 (instantiate $c (with "thunk" (func $c5 "thunk"))))
(instance $c2 (instantiate $c (with "thunk" (func $c1 "thunk2"))))
(instance $c3 (instantiate $c (with "thunk" (func $c2 "thunk2"))))
(instance $c4 (instantiate $c (with "thunk" (func $c3 "thunk2"))))
(instance $c5 (instantiate $c (with "thunk" (func $c4 "thunk2"))))
(instance $c6 (instantiate $c (with "thunk" (func $c5 "thunk2"))))
(component $verify
(import "thunk" (func $thunk (result u32)))
@@ -276,7 +276,7 @@
))
))
)
(instance (instantiate $verify (with "thunk" (func $c6 "thunk"))))
(instance (instantiate $verify (with "thunk" (func $c6 "thunk2"))))
)
;; Fancy case of an adapter using an adapter. Note that this is silly and

View File

@@ -267,7 +267,7 @@
(export "a" (global i32))
))
(component (export "c")
(component (export "c2")
(export "m" (core module $c))
)
)
@@ -278,8 +278,8 @@
(instance $c1 (instantiate $c (with "c" (core module $m1))))
(instance $c2 (instantiate $c (with "c" (core module $m2))))
(instance $m1_container (instantiate (component $c1 "c")))
(instance $m2_container (instantiate (component $c2 "c")))
(instance $m1_container (instantiate (component $c1 "c2")))
(instance $m2_container (instantiate (component $c2 "c2")))
(core instance $core1 (instantiate (module $m1_container "m")))
(core instance $core2 (instantiate (module $m2_container "m")))