Update wasm-tools dependencies (#4970)

* Update wasm-tools dependencies

This update brings in a number of features such as:

* The component model binary format and AST has been slightly adjusted
  in a few locations. Names are dropped from parameters/results now in
  the internal representation since they were not used anyway. At this
  time the ability to bind a multi-return function has not been exposed.

* The `wasmparser` validator pass will now share allocations with prior
  functions, providing what's probably a very minor speedup for Wasmtime
  itself.

* The text format for many component-related tests now requires named
  parameters.

* Some new relaxed-simd instructions are updated to be ignored.

I hope to have a follow-up to expose the multi-return ability to the
embedding API of components.

* Update audit information for new crates
This commit is contained in:
Alex Crichton
2022-09-27 13:12:34 -05:00
committed by GitHub
parent 10deb9b7fe
commit 29c7de7340
31 changed files with 407 additions and 331 deletions

34
Cargo.lock generated
View File

@@ -3249,18 +3249,18 @@ checksum = "d554b7f530dee5964d9a9468d95c1f8b8acae4f282807e7d27d4b03099a46744"
[[package]]
name = "wasm-encoder"
version = "0.16.0"
version = "0.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d443c5a7daae71697d97ec12ad70b4fe8766d3a0f4db16158ac8b781365892f7"
checksum = "7e7ca71c70a6de5b10968ae4d298e548366d9cd9588176e6ff8866f3c49c96ee"
dependencies = [
"leb128",
]
[[package]]
name = "wasm-mutate"
version = "0.2.7"
version = "0.2.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f04ad5c8a18bf9d8d07ad9df8dea5e8ff701ab3472583a79350c3ab5b4766705"
checksum = "e8b98a1c3d9c5970ce9753e0e06c49974e01f5ab50cfca3c14010dd8bec2242d"
dependencies = [
"egg",
"log",
@@ -3272,9 +3272,9 @@ dependencies = [
[[package]]
name = "wasm-smith"
version = "0.11.4"
version = "0.11.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3daf8042376731e1873eae92dd609e1d0781105ffc3ffbc452f7bab719c887e2"
checksum = "7b3aa9c99fbb0df9453b0ab577a797f3fc538882b9f070fd389600b843cd8878"
dependencies = [
"arbitrary",
"flagset",
@@ -3319,18 +3319,18 @@ dependencies = [
[[package]]
name = "wasmparser"
version = "0.89.1"
version = "0.91.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ab5d3e08b13876f96dd55608d03cd4883a0545884932d5adf11925876c96daef"
checksum = "239cdca8b8f356af8118c522d5fea23da45b60832ed4e18ef90bb3c9d8dce24a"
dependencies = [
"indexmap",
]
[[package]]
name = "wasmprinter"
version = "0.2.39"
version = "0.2.40"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aa9e5ee2f56cc8a5da489558114e8c118e5a8416d96aefe63dcf1b5b05b858c6"
checksum = "85b5931cf673c4bece6299719c024c08ebe52cbac7124160487a602c81e598c8"
dependencies = [
"anyhow",
"wasmparser",
@@ -3476,7 +3476,7 @@ dependencies = [
"wasmtime-wasi-crypto",
"wasmtime-wasi-nn",
"wasmtime-wast",
"wast 46.0.0",
"wast 47.0.0",
"wat",
"windows-sys",
]
@@ -3736,7 +3736,7 @@ dependencies = [
"anyhow",
"log",
"wasmtime",
"wast 46.0.0",
"wast 47.0.0",
]
[[package]]
@@ -3750,9 +3750,9 @@ dependencies = [
[[package]]
name = "wast"
version = "46.0.0"
version = "47.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ea0ab19660e3ea6891bba69167b9be40fad00fb1fe3dd39c5eebcee15607131b"
checksum = "117ccfc4262e62a28a13f0548a147f19ffe71e8a08be802af23ae4ea0bedad73"
dependencies = [
"leb128",
"memchr",
@@ -3762,11 +3762,11 @@ dependencies = [
[[package]]
name = "wat"
version = "1.0.48"
version = "1.0.49"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f775282def4d5bffd94d60d6ecd57bfe6faa46171cdbf8d32bd5458842b1e3e"
checksum = "7aab4e20c60429fbba9670a6cae0fff9520046ba0aa3e6d0b1cd2653bea14898"
dependencies = [
"wast 46.0.0",
"wast 47.0.0",
]
[[package]]

View File

@@ -145,13 +145,13 @@ cranelift = { path = "cranelift/umbrella", version = "0.89.0" }
target-lexicon = { version = "0.12.3", default-features = false }
anyhow = "1.0.22"
wasmparser = "0.89.0"
wat = "1.0.48"
wast = "46.0.0"
wasmprinter = "0.2.39"
wasm-encoder = "0.16.0"
wasm-smith = "0.11.4"
wasm-mutate = "0.2.7"
wasmparser = "0.91.0"
wat = "1.0.49"
wast = "47.0.0"
wasmprinter = "0.2.40"
wasm-encoder = "0.17.0"
wasm-smith = "0.11.5"
wasm-mutate = "0.2.8"
windows-sys = "0.36.0"
env_logger = "0.9"
rustix = "0.35.10"

View File

@@ -94,7 +94,7 @@ use smallvec::SmallVec;
use std::cmp;
use std::convert::TryFrom;
use std::vec::Vec;
use wasmparser::{FuncValidator, MemoryImmediate, Operator, WasmModuleResources};
use wasmparser::{FuncValidator, MemArg, Operator, WasmModuleResources};
// Clippy warns about "align: _" but its important to document that the flags field is ignored
#[cfg_attr(
@@ -590,13 +590,14 @@ pub fn translate_operator<FE: FuncEnvironment + ?Sized>(
state.pushn(inst_results);
}
Operator::CallIndirect {
index,
type_index,
table_index,
table_byte: _,
} => {
// `index` is the index of the function's signature and `table_index` is the index of
// the table to search the function in.
let (sigref, num_args) = state.get_indirect_sig(builder.func, *index, environ)?;
// `type_index` is the index of the function's signature and
// `table_index` is the index of the table to search the function
// in.
let (sigref, num_args) = state.get_indirect_sig(builder.func, *type_index, environ)?;
let table = state.get_or_create_table(builder.func, *table_index, environ)?;
let callee = state.pop1();
@@ -608,7 +609,7 @@ pub fn translate_operator<FE: FuncEnvironment + ?Sized>(
builder,
TableIndex::from_u32(*table_index),
table,
TypeIndex::from_u32(*index),
TypeIndex::from_u32(*type_index),
sigref,
callee,
state.peekn(num_args),
@@ -2005,18 +2006,22 @@ pub fn translate_operator<FE: FuncEnvironment + ?Sized>(
| Operator::I32x4RelaxedTruncSatF32x4U
| Operator::I32x4RelaxedTruncSatF64x2SZero
| Operator::I32x4RelaxedTruncSatF64x2UZero
| Operator::F32x4Fma
| Operator::F32x4Fms
| Operator::F64x2Fma
| Operator::F64x2Fms
| Operator::I8x16LaneSelect
| Operator::I16x8LaneSelect
| Operator::I32x4LaneSelect
| Operator::I64x2LaneSelect
| Operator::F32x4RelaxedFma
| Operator::F32x4RelaxedFnma
| Operator::F64x2RelaxedFma
| Operator::F64x2RelaxedFnma
| Operator::I8x16RelaxedLaneselect
| Operator::I16x8RelaxedLaneselect
| Operator::I32x4RelaxedLaneselect
| Operator::I64x2RelaxedLaneselect
| Operator::F32x4RelaxedMin
| Operator::F32x4RelaxedMax
| Operator::F64x2RelaxedMin
| Operator::F64x2RelaxedMax => {
| Operator::F64x2RelaxedMax
| Operator::I16x8RelaxedQ15mulrS
| Operator::I16x8DotI8x16I7x16S
| Operator::I32x4DotI8x16I7x16AddS
| Operator::F32x4RelaxedDotBf16x8AddF32x4 => {
return Err(wasm_unsupported!("proposed relaxed-simd operator {:?}", op));
}
};
@@ -2165,7 +2170,7 @@ fn translate_unreachable_operator<FE: FuncEnvironment + ?Sized>(
/// various parameters are returned describing the valid heap address if
/// execution reaches that point.
fn prepare_addr<FE: FuncEnvironment + ?Sized>(
memarg: &MemoryImmediate,
memarg: &MemArg,
access_size: u32,
builder: &mut FunctionBuilder,
state: &mut FuncTranslationState,
@@ -2342,7 +2347,7 @@ fn prepare_addr<FE: FuncEnvironment + ?Sized>(
}
fn prepare_atomic_addr<FE: FuncEnvironment + ?Sized>(
memarg: &MemoryImmediate,
memarg: &MemArg,
loaded_bytes: u32,
builder: &mut FunctionBuilder,
state: &mut FuncTranslationState,
@@ -2394,7 +2399,7 @@ fn prepare_atomic_addr<FE: FuncEnvironment + ?Sized>(
/// Translate a load instruction.
fn translate_load<FE: FuncEnvironment + ?Sized>(
memarg: &MemoryImmediate,
memarg: &MemArg,
opcode: ir::Opcode,
result_ty: Type,
builder: &mut FunctionBuilder,
@@ -2415,7 +2420,7 @@ fn translate_load<FE: FuncEnvironment + ?Sized>(
/// Translate a store instruction.
fn translate_store<FE: FuncEnvironment + ?Sized>(
memarg: &MemoryImmediate,
memarg: &MemArg,
opcode: ir::Opcode,
builder: &mut FunctionBuilder,
state: &mut FuncTranslationState,
@@ -2460,7 +2465,7 @@ fn translate_atomic_rmw<FE: FuncEnvironment + ?Sized>(
widened_ty: Type,
access_ty: Type,
op: AtomicRmwOp,
memarg: &MemoryImmediate,
memarg: &MemArg,
builder: &mut FunctionBuilder,
state: &mut FuncTranslationState,
environ: &mut FE,
@@ -2503,7 +2508,7 @@ fn translate_atomic_rmw<FE: FuncEnvironment + ?Sized>(
fn translate_atomic_cas<FE: FuncEnvironment + ?Sized>(
widened_ty: Type,
access_ty: Type,
memarg: &MemoryImmediate,
memarg: &MemArg,
builder: &mut FunctionBuilder,
state: &mut FuncTranslationState,
environ: &mut FE,
@@ -2550,7 +2555,7 @@ fn translate_atomic_cas<FE: FuncEnvironment + ?Sized>(
fn translate_atomic_load<FE: FuncEnvironment + ?Sized>(
widened_ty: Type,
access_ty: Type,
memarg: &MemoryImmediate,
memarg: &MemArg,
builder: &mut FunctionBuilder,
state: &mut FuncTranslationState,
environ: &mut FE,
@@ -2583,7 +2588,7 @@ fn translate_atomic_load<FE: FuncEnvironment + ?Sized>(
fn translate_atomic_store<FE: FuncEnvironment + ?Sized>(
access_ty: Type,
memarg: &MemoryImmediate,
memarg: &MemArg,
builder: &mut FunctionBuilder,
state: &mut FuncTranslationState,
environ: &mut FE,

View File

@@ -406,7 +406,10 @@ mod tests {
let mut validator = Validator::new();
for payload in Parser::new(0).parse_all(wat) {
match validator.payload(&payload.unwrap()).unwrap() {
ValidPayload::Func(validator, body) => return (body, validator),
ValidPayload::Func(validator, body) => {
let validator = validator.into_validator(Default::default());
return (body, validator);
}
_ => {}
}
}

View File

@@ -91,7 +91,9 @@ pub fn translate_module<'data>(
}
Payload::CodeSectionEntry(body) => {
let func_validator = validator.code_section_entry(&body)?;
let func_validator = validator
.code_section_entry(&body)?
.into_validator(Default::default());
environ.define_function_body(func_validator, body)?;
}

View File

@@ -75,9 +75,10 @@ pub fn parse_type_section<'a>(
match entry? {
Type::Func(wasm_func_ty) => {
environ.declare_type_func(wasm_func_ty.clone().try_into()?)?;
module_translation_state
.wasm_types
.push((wasm_func_ty.params, wasm_func_ty.returns));
module_translation_state.wasm_types.push((
wasm_func_ty.params().to_vec().into(),
wasm_func_ty.results().to_vec().into(),
));
}
}
}

View File

@@ -30,6 +30,7 @@ use std::collections::HashMap;
use std::convert::TryFrom;
use std::mem;
use std::sync::{Arc, Mutex};
use wasmparser::{FuncValidatorAllocations, FunctionBody};
use wasmtime_environ::{
AddressMapSection, CacheStore, CompileError, FilePos, FlagValue, FunctionBodyData,
FunctionInfo, InstructionAddressMap, Module, ModuleTranslation, ModuleTypes, PtrSize,
@@ -51,6 +52,7 @@ struct CompilerContext {
func_translator: FuncTranslator,
codegen_context: Context,
incremental_cache_ctx: Option<IncrementalCacheContext>,
validator_allocations: FuncValidatorAllocations,
}
impl Default for CompilerContext {
@@ -59,6 +61,7 @@ impl Default for CompilerContext {
func_translator: FuncTranslator::new(),
codegen_context: Context::new(),
incremental_cache_ctx: None,
validator_allocations: Default::default(),
}
}
}
@@ -141,13 +144,13 @@ impl Compiler {
fn get_function_address_map(
&self,
context: &Context,
data: &FunctionBodyData<'_>,
body: &FunctionBody<'_>,
body_len: u32,
tunables: &Tunables,
) -> FunctionAddressMap {
// Generate artificial srcloc for function start/end to identify boundary
// within module.
let data = data.body.get_binary_reader();
let data = body.get_binary_reader();
let offset = data.original_position();
let len = data.bytes_remaining();
assert!((offset + len) <= u32::max_value() as usize);
@@ -186,7 +189,7 @@ impl wasmtime_environ::Compiler for Compiler {
&self,
translation: &ModuleTranslation<'_>,
func_index: DefinedFuncIndex,
mut input: FunctionBodyData<'_>,
input: FunctionBodyData<'_>,
tunables: &Tunables,
types: &ModuleTypes,
) -> Result<Box<dyn Any + Send>, CompileError> {
@@ -198,6 +201,7 @@ impl wasmtime_environ::Compiler for Compiler {
mut func_translator,
codegen_context: mut context,
incremental_cache_ctx: mut cache_ctx,
validator_allocations,
} = self.take_context();
context.func.signature = func_signature(isa, translation, types, func_index);
@@ -264,9 +268,11 @@ impl wasmtime_environ::Compiler for Compiler {
readonly: false,
});
context.func.stack_limit = Some(stack_limit);
let FunctionBodyData { validator, body } = input;
let mut validator = validator.into_validator(validator_allocations);
func_translator.translate_body(
&mut input.validator,
input.body.clone(),
&mut validator,
body.clone(),
&mut context.func,
&mut func_env,
)?;
@@ -300,7 +306,7 @@ impl wasmtime_environ::Compiler for Compiler {
};
let address_transform =
self.get_function_address_map(&context, &input, code_buf.len() as u32, tunables);
self.get_function_address_map(&context, &body, code_buf.len() as u32, tunables);
let ranges = if tunables.generate_native_debuginfo {
Some(context.compiled_code().unwrap().value_labels_ranges.clone())
@@ -320,6 +326,7 @@ impl wasmtime_environ::Compiler for Compiler {
func_translator,
codegen_context: context,
incremental_cache_ctx: cache_ctx,
validator_allocations: validator.into_allocations(),
});
Ok(Box::new(CompiledFunction {
@@ -566,6 +573,7 @@ impl Compiler {
mut func_translator,
codegen_context: mut context,
incremental_cache_ctx: mut cache_ctx,
validator_allocations,
} = self.take_context();
// The name doesn't matter here.
@@ -634,6 +642,7 @@ impl Compiler {
func_translator,
codegen_context: context,
incremental_cache_ctx: cache_ctx,
validator_allocations,
});
Ok(func)
}
@@ -679,6 +688,7 @@ impl Compiler {
mut func_translator,
codegen_context: mut context,
incremental_cache_ctx: mut cache_ctx,
validator_allocations,
} = self.take_context();
// The name doesn't matter here.
@@ -713,6 +723,7 @@ impl Compiler {
func_translator,
codegen_context: context,
incremental_cache_ctx: cache_ctx,
validator_allocations,
});
Ok(func)
}

View File

@@ -32,6 +32,7 @@ impl ComponentCompiler for Compiler {
mut func_translator,
codegen_context: mut context,
mut incremental_cache_ctx,
validator_allocations,
} = self.take_context();
context.func = ir::Function::with_name_signature(
@@ -156,6 +157,7 @@ impl ComponentCompiler for Compiler {
func_translator,
codegen_context: context,
incremental_cache_ctx,
validator_allocations,
});
Ok(Box::new(func))
}
@@ -166,6 +168,7 @@ impl ComponentCompiler for Compiler {
mut func_translator,
codegen_context: mut context,
mut incremental_cache_ctx,
validator_allocations,
} = self.take_context();
context.func = ir::Function::with_name_signature(
ir::UserFuncName::user(0, 0),
@@ -187,6 +190,7 @@ impl ComponentCompiler for Compiler {
func_translator,
codegen_context: context,
incremental_cache_ctx,
validator_allocations,
});
Ok(Box::new(func))
}
@@ -205,6 +209,7 @@ impl ComponentCompiler for Compiler {
mut func_translator,
codegen_context: mut context,
mut incremental_cache_ctx,
validator_allocations,
} = self.take_context();
context.func = ir::Function::with_name_signature(
@@ -226,6 +231,7 @@ impl ComponentCompiler for Compiler {
func_translator,
codegen_context: context,
incremental_cache_ctx,
validator_allocations,
});
Ok(Box::new(func))
}

View File

@@ -626,32 +626,6 @@ impl<'a, 'data> Translator<'a, 'data> {
// Aliases of instance exports (either core or component) will be
// recorded as an initializer of the appropriate type with outer
// aliases handled specially via upvars and type processing.
Payload::AliasSection(s) => {
self.validator.alias_section(&s)?;
for alias in s {
let init = match alias? {
wasmparser::Alias::InstanceExport {
kind,
instance_index,
name,
} => {
let instance = ModuleInstanceIndex::from_u32(instance_index);
self.alias_module_instance_export(kind, instance, name)
}
wasmparser::Alias::Outer {
kind: wasmparser::OuterAliasKind::Type,
count,
index,
} => {
let index = TypeIndex::from_u32(index);
let ty = self.types.core_outer_type(count, index);
self.types.push_core_typedef(ty);
continue;
}
};
self.result.initializers.push(init);
}
}
Payload::ComponentAliasSection(s) => {
self.validator.component_alias_section(&s)?;
for alias in s {
@@ -670,6 +644,14 @@ impl<'a, 'data> Translator<'a, 'data> {
self.alias_component_outer(kind, count, index);
continue;
}
wasmparser::ComponentAlias::CoreInstanceExport {
kind,
instance_index,
name,
} => {
let instance = ModuleInstanceIndex::from_u32(instance_index);
self.alias_module_instance_export(kind, instance, name)
}
};
self.result.initializers.push(init);
}

View File

@@ -509,19 +509,14 @@ impl ComponentTypesBuilder {
);
assert!(prev.is_none());
}
wasmparser::ModuleTypeDeclaration::Alias(alias) => match alias {
wasmparser::Alias::Outer {
kind: wasmparser::OuterAliasKind::Type,
count,
index,
} => {
let ty = self.core_outer_type(*count, TypeIndex::from_u32(*index));
self.push_core_typedef(ty);
}
wasmparser::Alias::InstanceExport { .. } => {
unreachable!("invalid alias {alias:?}")
}
},
wasmparser::ModuleTypeDeclaration::OuterAlias {
kind: wasmparser::OuterAliasKind::Type,
count,
index,
} => {
let ty = self.core_outer_type(*count, TypeIndex::from_u32(*index));
self.push_core_typedef(ty);
}
}
}
@@ -640,12 +635,12 @@ impl ComponentTypesBuilder {
params: ty
.params
.iter()
.map(|(name, ty)| (name.map(|s| s.to_string()), self.valtype(ty)))
.map(|(_name, ty)| self.valtype(ty))
.collect(),
results: ty
.results
.iter()
.map(|(name, ty)| (name.map(|s| s.to_string()), self.valtype(ty)))
.map(|(_name, ty)| self.valtype(ty))
.collect(),
};
self.add_func_type(ty)
@@ -998,9 +993,9 @@ pub struct TypeComponentInstance {
pub struct TypeFunc {
/// The list of optionally named parameters for this function, and their
/// types.
pub params: Box<[(Option<String>, InterfaceType)]>,
pub params: Box<[InterfaceType]>,
/// The return values of this function.
pub results: Box<[(Option<String>, InterfaceType)]>,
pub results: Box<[InterfaceType]>,
}
/// All possible interface types that values can have.

View File

@@ -37,7 +37,7 @@ impl ComponentTypesBuilder {
let mut params = match self.flatten_types(
&options.options,
MAX_FLAT_PARAMS,
ty.params.iter().map(|(_, ty)| *ty),
ty.params.iter().copied(),
) {
Some(list) => list,
None => {
@@ -50,7 +50,7 @@ impl ComponentTypesBuilder {
let results = match self.flatten_types(
&options.options,
MAX_FLAT_RESULTS,
ty.results.iter().map(|(_, ty)| *ty),
ty.results.iter().map(|ty| *ty),
) {
Some(list) => list,
None => {

View File

@@ -313,9 +313,9 @@ impl Compiler<'_, '_> {
fn translate_params(&mut self, adapter: &AdapterData, param_locals: &[(u32, ValType)]) {
let src_tys = &self.types[adapter.lower.ty].params;
let src_tys = src_tys.iter().map(|(_, ty)| *ty).collect::<Vec<_>>();
let src_tys = src_tys.iter().copied().collect::<Vec<_>>();
let dst_tys = &self.types[adapter.lift.ty].params;
let dst_tys = dst_tys.iter().map(|(_, ty)| *ty).collect::<Vec<_>>();
let dst_tys = dst_tys.iter().copied().collect::<Vec<_>>();
let lift_opts = &adapter.lift.options;
let lower_opts = &adapter.lower.options;
@@ -389,9 +389,9 @@ impl Compiler<'_, '_> {
result_locals: &[(u32, ValType)],
) {
let src_tys = &self.types[adapter.lift.ty].results;
let src_tys = src_tys.iter().map(|(_, ty)| *ty).collect::<Vec<_>>();
let src_tys = src_tys.iter().map(|ty| *ty).collect::<Vec<_>>();
let dst_tys = &self.types[adapter.lower.ty].results;
let dst_tys = dst_tys.iter().map(|(_, ty)| *ty).collect::<Vec<_>>();
let dst_tys = dst_tys.iter().map(|ty| *ty).collect::<Vec<_>>();
let lift_opts = &adapter.lift.options;
let lower_opts = &adapter.lower.options;

View File

@@ -14,9 +14,9 @@ use std::convert::{TryFrom, TryInto};
use std::path::PathBuf;
use std::sync::Arc;
use wasmparser::{
CustomSectionReader, DataKind, ElementItem, ElementKind, Encoding, ExternalKind, FuncValidator,
FunctionBody, NameSectionReader, Naming, Operator, Parser, Payload, Type, TypeRef, Validator,
ValidatorResources,
CustomSectionReader, DataKind, ElementItem, ElementKind, Encoding, ExternalKind,
FuncToValidate, FunctionBody, NameSectionReader, Naming, Operator, Parser, Payload, Type,
TypeRef, Validator, ValidatorResources,
};
/// Object containing the standalone environment information.
@@ -90,7 +90,7 @@ pub struct FunctionBodyData<'a> {
/// The body of the function, containing code and locals.
pub body: FunctionBody<'a>,
/// Validator for the function body
pub validator: FuncValidator<ValidatorResources>,
pub validator: FuncToValidate<ValidatorResources>,
}
#[derive(Debug, Default)]

View File

@@ -325,7 +325,7 @@ mod tests {
(import "" "make_refs" (func (;2;) (type 3)))
(func (;3;) (type 1) (param externref externref externref externref externref externref externref externref externref externref)
(local externref)
loop ;; label = @1
loop ;; label = @0
call 0
call 2
call 1

View File

@@ -129,15 +129,15 @@ impl TryFrom<wasmparser::FuncType> for WasmFuncType {
type Error = WasmError;
fn try_from(ty: wasmparser::FuncType) -> Result<Self, Self::Error> {
let params = ty
.params
.into_vec()
.into_iter()
.params()
.iter()
.copied()
.map(WasmType::try_from)
.collect::<Result<_, Self::Error>>()?;
let returns = ty
.returns
.into_vec()
.into_iter()
.results()
.iter()
.copied()
.map(WasmType::try_from)
.collect::<Result<_, Self::Error>>()?;
Ok(Self::new(params, returns))

View File

@@ -246,10 +246,8 @@ impl Func {
let data = &store[self.0];
let ty = &data.types[data.ty];
Params::typecheck_named_list(&ty.params, &data.types)
.context("type mismatch with parameters")?;
Return::typecheck_named_list(&ty.results, &data.types)
.context("type mismatch with results")?;
Params::typecheck_list(&ty.params, &data.types).context("type mismatch with parameters")?;
Return::typecheck_list(&ty.results, &data.types).context("type mismatch with results")?;
Ok(())
}
@@ -260,7 +258,7 @@ impl Func {
data.types[data.ty]
.params
.iter()
.map(|(_, ty)| Type::from(ty, &data.types))
.map(|ty| Type::from(ty, &data.types))
.collect()
}
@@ -270,7 +268,7 @@ impl Func {
data.types[data.ty]
.results
.iter()
.map(|(_, ty)| Type::from(ty, &data.types))
.map(|ty| Type::from(ty, &data.types))
.collect()
}

View File

@@ -89,16 +89,8 @@ impl HostFunc {
func: Box::new(DynamicContext {
func,
types: Types {
params: ty
.params
.iter()
.map(|(_, ty)| Type::from(ty, types))
.collect(),
results: ty
.results
.iter()
.map(|(_, ty)| Type::from(ty, types))
.collect(),
params: ty.params.iter().map(|ty| Type::from(ty, types)).collect(),
results: ty.results.iter().map(|ty| Type::from(ty, types)).collect(),
},
}),
})
@@ -123,8 +115,8 @@ where
R: ComponentNamedList + Lower,
{
let ty = &types[ty];
P::typecheck_named_list(&ty.params, types).context("type mismatch with parameters")?;
R::typecheck_named_list(&ty.results, types).context("type mismatch with results")?;
P::typecheck_list(&ty.params, types).context("type mismatch with parameters")?;
R::typecheck_list(&ty.results, types).context("type mismatch with results")?;
Ok(())
}

View File

@@ -308,10 +308,7 @@ pub unsafe trait ComponentNamedList: ComponentType {
/// Performs a typecheck to ensure that this `ComponentNamedList`
/// implementor matches the types of the types in `params`.
#[doc(hidden)]
fn typecheck_named_list(
params: &[(Option<String>, InterfaceType)],
types: &ComponentTypes,
) -> Result<()>;
fn typecheck_list(params: &[InterfaceType], types: &ComponentTypes) -> Result<()>;
}
/// A trait representing types which can be passed to and read from components
@@ -1965,14 +1962,14 @@ macro_rules! impl_component_ty_for_tuples {
unsafe impl<$($t,)*> ComponentNamedList for ($($t,)*)
where $($t: ComponentType),*
{
fn typecheck_named_list(
names: &[(Option<String>, InterfaceType)],
fn typecheck_list(
names: &[InterfaceType],
_types: &ComponentTypes,
) -> Result<()> {
if names.len() != $n {
bail!("expected {} types, found {}", $n, names.len());
}
let mut names = names.iter().map(|i| &i.1);
let mut names = names.iter();
$($t::typecheck(names.next().unwrap(), _types)?;)*
debug_assert!(names.next().is_none());
Ok(())

View File

@@ -590,7 +590,13 @@ impl Module {
}
}
engine.run_maybe_parallel(functions, |(mut validator, body)| validator.validate(&body))?;
engine.run_maybe_parallel(functions, |(validator, body)| {
// FIXME: it would be best here to use a rayon-specific parallel
// iterator that maintains state-per-thread to share the function
// validator allocations (`Default::default` here) across multiple
// functions.
validator.into_validator(Default::default()).validate(&body)
})?;
Ok(())
}

View File

@@ -212,6 +212,12 @@ criteria = "safe-to-deploy"
version = "0.16.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.17.0"
notes = "The Bytecode Alliance is the author of this crate."
[[audits.wasm-mutate]]
who = "Alex Crichton <alex@alexcrichton.com>"
criteria = "safe-to-deploy"
@@ -230,6 +236,12 @@ criteria = "safe-to-deploy"
version = "0.2.7"
notes = "The Bytecode Alliance is the author of this crate."
[[audits.wasm-mutate]]
who = "Alex Crichton <alex@alexcrichton.com>"
criteria = "safe-to-deploy"
version = "0.2.8"
notes = "The Bytecode Alliance is the author of this crate."
[[audits.wasm-smith]]
who = "Alex Crichton <alex@alexcrichton.com>"
criteria = "safe-to-deploy"
@@ -248,6 +260,12 @@ criteria = "safe-to-deploy"
version = "0.11.4"
notes = "The Bytecode Alliance is the author of this crate."
[[audits.wasm-smith]]
who = "Alex Crichton <alex@alexcrichton.com>"
criteria = "safe-to-deploy"
version = "0.11.5"
notes = "The Bytecode Alliance is the author of this crate."
[[audits.wasmparser]]
who = "Alex Crichton <alex@alexcrichton.com>"
criteria = "safe-to-deploy"
@@ -272,6 +290,12 @@ criteria = "safe-to-deploy"
version = "0.89.1"
notes = "The Bytecode Alliance is the author of this crate."
[[audits.wasmparser]]
who = "Alex Crichton <alex@alexcrichton.com>"
criteria = "safe-to-deploy"
version = "0.91.0"
notes = "The Bytecode Alliance is the author of this crate."
[[audits.wasmprinter]]
who = "Alex Crichton <alex@alexcrichton.com>"
criteria = "safe-to-deploy"
@@ -290,6 +314,12 @@ criteria = "safe-to-deploy"
version = "0.2.39"
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.40"
notes = "The Bytecode Alliance is the author of this crate."
[[audits.wast]]
who = "Alex Crichton <alex@alexcrichton.com>"
criteria = "safe-to-deploy"
@@ -314,6 +344,12 @@ criteria = "safe-to-deploy"
version = "46.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 = "47.0.0"
notes = "The Bytecode Alliance is the author of this crate."
[[audits.wat]]
who = "Alex Crichton <alex@alexcrichton.com>"
criteria = "safe-to-deploy"
@@ -332,3 +368,9 @@ criteria = "safe-to-deploy"
version = "1.0.48"
notes = "The Bytecode Alliance is the author of this crate."
[[audits.wat]]
who = "Alex Crichton <alex@alexcrichton.com>"
criteria = "safe-to-deploy"
delta = "1.0.48 -> 1.0.49"
notes = "The Bytecode Alliance is the author of this crate."

View File

@@ -54,10 +54,6 @@ criteria = "safe-to-deploy"
version = "0.1.8"
criteria = "safe-to-deploy"
[[exemptions.autocfg]]
version = "1.1.0"
criteria = "safe-to-deploy"
[[exemptions.base64]]
version = "0.13.0"
criteria = "safe-to-deploy"
@@ -338,10 +334,6 @@ criteria = "safe-to-deploy"
version = "1.8.2"
criteria = "safe-to-run"
[[exemptions.hashbrown]]
version = "0.12.1"
criteria = "safe-to-deploy"
[[exemptions.hermit-abi]]
version = "0.1.19"
criteria = "safe-to-deploy"
@@ -506,30 +498,10 @@ criteria = "safe-to-deploy"
version = "0.3.7"
criteria = "safe-to-deploy"
[[exemptions.num-bigint]]
version = "0.4.3"
criteria = "safe-to-deploy"
[[exemptions.num-bigint-dig]]
version = "0.7.0"
criteria = "safe-to-deploy"
[[exemptions.num-integer]]
version = "0.1.45"
criteria = "safe-to-deploy"
[[exemptions.num-iter]]
version = "0.1.43"
criteria = "safe-to-deploy"
[[exemptions.num-rational]]
version = "0.4.1"
criteria = "safe-to-deploy"
[[exemptions.num-traits]]
version = "0.2.15"
criteria = "safe-to-deploy"
[[exemptions.num_cpus]]
version = "1.13.1"
criteria = "safe-to-deploy"
@@ -698,10 +670,6 @@ criteria = "safe-to-deploy"
version = "2.0.1"
criteria = "safe-to-deploy"
[[exemptions.quote]]
version = "1.0.18"
criteria = "safe-to-deploy"
[[exemptions.rand]]
version = "0.7.3"
criteria = "safe-to-deploy"
@@ -782,10 +750,6 @@ criteria = "safe-to-deploy"
version = "0.5.0"
criteria = "safe-to-deploy"
[[exemptions.rustc_version]]
version = "0.4.0"
criteria = "safe-to-run"
[[exemptions.rustix]]
version = "0.35.10"
criteria = "safe-to-deploy"
@@ -914,10 +878,6 @@ criteria = "safe-to-deploy"
version = "1.0.92"
criteria = "safe-to-deploy"
[[exemptions.synstructure]]
version = "0.12.6"
criteria = "safe-to-deploy"
[[exemptions.target-lexicon]]
version = "0.12.3"
criteria = "safe-to-deploy"

View File

@@ -32,6 +32,12 @@ who = "Mike Hommey <mh+mozilla@glandium.org>"
criteria = "safe-to-deploy"
delta = "0.1.56 -> 0.1.57"
[[audits.mozilla.audits.autocfg]]
who = "Josh Stone <jistone@redhat.com>"
criteria = "safe-to-deploy"
version = "1.1.0"
notes = "All code written or reviewed by Josh Stone."
[[audits.mozilla.audits.bit-set]]
who = "Aria Beingessner <a.beingessner@gmail.com>"
criteria = "safe-to-deploy"
@@ -189,6 +195,42 @@ who = "Mike Hommey <mh+mozilla@glandium.org>"
criteria = "safe-to-deploy"
delta = "0.5.4 -> 0.5.7"
[[audits.mozilla.audits.num-bigint]]
who = "Josh Stone <jistone@redhat.com>"
criteria = "safe-to-deploy"
version = "0.2.6"
notes = "All code written or reviewed by Josh Stone."
[[audits.mozilla.audits.num-bigint]]
who = "Josh Stone <jistone@redhat.com>"
criteria = "safe-to-deploy"
version = "0.4.3"
notes = "All code written or reviewed by Josh Stone."
[[audits.mozilla.audits.num-integer]]
who = "Josh Stone <jistone@redhat.com>"
criteria = "safe-to-deploy"
version = "0.1.45"
notes = "All code written or reviewed by Josh Stone."
[[audits.mozilla.audits.num-iter]]
who = "Josh Stone <jistone@redhat.com>"
criteria = "safe-to-deploy"
version = "0.1.43"
notes = "All code written or reviewed by Josh Stone."
[[audits.mozilla.audits.num-rational]]
who = "Josh Stone <jistone@redhat.com>"
criteria = "safe-to-deploy"
version = "0.4.1"
notes = "All code written or reviewed by Josh Stone."
[[audits.mozilla.audits.num-traits]]
who = "Josh Stone <jistone@redhat.com>"
criteria = "safe-to-deploy"
version = "0.2.15"
notes = "All code written or reviewed by Josh Stone."
[[audits.mozilla.audits.once_cell]]
who = "Mike Hommey <mh+mozilla@glandium.org>"
criteria = "safe-to-deploy"
@@ -209,6 +251,21 @@ who = "Mike Hommey <mh+mozilla@glandium.org>"
criteria = "safe-to-deploy"
delta = "1.0.39 -> 1.0.43"
[[audits.mozilla.audits.quote]]
who = "Nika Layzell <nika@thelayzells.com>"
criteria = "safe-to-deploy"
version = "1.0.18"
notes = """
`quote` is a utility crate used by proc-macros to generate TokenStreams
conveniently from source code. The bulk of the logic is some complex
interlocking `macro_rules!` macros which are used to parse and build the
`TokenStream` within the proc-macro.
This crate contains no unsafe code, and the internal logic, while difficult to
read, is generally straightforward. I have audited the the quote macros, ident
formatter, and runtime logic.
"""
[[audits.mozilla.audits.quote]]
who = "Mike Hommey <mh+mozilla@glandium.org>"
criteria = "safe-to-deploy"
@@ -229,6 +286,15 @@ who = "Mike Hommey <mh+mozilla@glandium.org>"
criteria = "safe-to-deploy"
delta = "0.6.26 -> 0.6.27"
[[audits.mozilla.audits.rustc_version]]
who = "Nika Layzell <nika@thelayzells.com>"
criteria = "safe-to-run"
version = "0.4.0"
notes = """
Straightforward crate which runs `$RUSTC -vV` and parses the output into a
machine-interpretable form for build scripts.
"""
[[audits.mozilla.audits.ryu]]
who = "Mike Hommey <mh+mozilla@glandium.org>"
criteria = "safe-to-deploy"
@@ -284,6 +350,16 @@ who = "Mike Hommey <mh+mozilla@glandium.org>"
criteria = "safe-to-deploy"
delta = "1.0.96 -> 1.0.99"
[[audits.mozilla.audits.synstructure]]
who = "Nika Layzell <nika@thelayzells.com>"
criteria = "safe-to-deploy"
version = "0.12.6"
notes = """
I am the primary author of the `synstructure` crate, and its current
maintainer. The one use of `unsafe` is unnecessary, but documented and
harmless. It will be removed in the next version.
"""
[[audits.mozilla.audits.thiserror]]
who = "Mike Hommey <mh+mozilla@glandium.org>"
criteria = "safe-to-deploy"

View File

@@ -189,7 +189,7 @@ fn make_echo_component_with_params(type_definition: &str, params: &[Param]) -> S
(type $Foo {type_definition})
(func (export "echo") (param $Foo) (result $Foo)
(func (export "echo") (param "a" $Foo) (result "b" $Foo)
(canon lift
(core func $i "echo")
(memory $i "memory")

View File

@@ -60,10 +60,10 @@ fn typecheck() -> Result<()> {
(func (export "thunk")
(canon lift (core func $i "thunk"))
)
(func (export "tuple-thunk") (param (tuple)) (result (tuple))
(func (export "tuple-thunk") (param "a" (tuple)) (result (tuple))
(canon lift (core func $i "thunk"))
)
(func (export "take-string") (param string)
(func (export "take-string") (param "a" string)
(canon lift (core func $i "take-string") (memory $i "memory") (realloc (func $i "realloc")))
)
(func (export "take-two-args") (param "a" s32) (param "b" (list u8))
@@ -154,14 +154,14 @@ fn integers() -> Result<()> {
(func (export "ret-i32-100000") (result i32) i32.const 100000)
)
(core instance $i (instantiate (module $m)))
(func (export "take-u8") (param u8) (canon lift (core func $i "take-i32-100")))
(func (export "take-s8") (param s8) (canon lift (core func $i "take-i32-100")))
(func (export "take-u16") (param u16) (canon lift (core func $i "take-i32-100")))
(func (export "take-s16") (param s16) (canon lift (core func $i "take-i32-100")))
(func (export "take-u32") (param u32) (canon lift (core func $i "take-i32-100")))
(func (export "take-s32") (param s32) (canon lift (core func $i "take-i32-100")))
(func (export "take-u64") (param u64) (canon lift (core func $i "take-i64-100")))
(func (export "take-s64") (param s64) (canon lift (core func $i "take-i64-100")))
(func (export "take-u8") (param "a" u8) (canon lift (core func $i "take-i32-100")))
(func (export "take-s8") (param "a" s8) (canon lift (core func $i "take-i32-100")))
(func (export "take-u16") (param "a" u16) (canon lift (core func $i "take-i32-100")))
(func (export "take-s16") (param "a" s16) (canon lift (core func $i "take-i32-100")))
(func (export "take-u32") (param "a" u32) (canon lift (core func $i "take-i32-100")))
(func (export "take-s32") (param "a" s32) (canon lift (core func $i "take-i32-100")))
(func (export "take-u64") (param "a" u64) (canon lift (core func $i "take-i64-100")))
(func (export "take-s64") (param "a" s64) (canon lift (core func $i "take-i64-100")))
(func (export "ret-u8") (result u8) (canon lift (core func $i "ret-i32-0")))
(func (export "ret-s8") (result s8) (canon lift (core func $i "ret-i32-0")))
@@ -420,7 +420,7 @@ fn type_layers() -> Result<()> {
)
)
(core instance $i (instantiate $m))
(func (export "take-u32") (param u32) (canon lift (core func $i "take-i32-100")))
(func (export "take-u32") (param "a" u32) (canon lift (core func $i "take-i32-100")))
)
"#;
@@ -472,16 +472,16 @@ fn floats() -> Result<()> {
)
(core instance $i (instantiate $m))
(func (export "f32-to-u32") (param float32) (result u32)
(func (export "f32-to-u32") (param "a" float32) (result u32)
(canon lift (core func $i "i32.reinterpret_f32"))
)
(func (export "f64-to-u64") (param float64) (result u64)
(func (export "f64-to-u64") (param "a" float64) (result u64)
(canon lift (core func $i "i64.reinterpret_f64"))
)
(func (export "u32-to-f32") (param u32) (result float32)
(func (export "u32-to-f32") (param "a" u32) (result float32)
(canon lift (core func $i "f32.reinterpret_i32"))
)
(func (export "u64-to-f64") (param u64) (result float64)
(func (export "u64-to-f64") (param "a" u64) (result float64)
(canon lift (core func $i "f64.reinterpret_i64"))
)
)
@@ -545,10 +545,10 @@ fn bools() -> Result<()> {
)
(core instance $i (instantiate $m))
(func (export "u32-to-bool") (param u32) (result bool)
(func (export "u32-to-bool") (param "a" u32) (result bool)
(canon lift (core func $i "pass"))
)
(func (export "bool-to-u32") (param bool) (result u32)
(func (export "bool-to-u32") (param "a" bool) (result u32)
(canon lift (core func $i "pass"))
)
)
@@ -584,10 +584,10 @@ fn chars() -> Result<()> {
)
(core instance $i (instantiate $m))
(func (export "u32-to-char") (param u32) (result char)
(func (export "u32-to-char") (param "a" u32) (result char)
(canon lift (core func $i "pass"))
)
(func (export "char-to-u32") (param char) (result u32)
(func (export "char-to-u32") (param "a" char) (result u32)
(canon lift (core func $i "pass"))
)
)
@@ -722,21 +722,21 @@ fn strings() -> Result<()> {
)
(core instance $i (instantiate $m))
(func (export "list8-to-str") (param (list u8)) (result string)
(func (export "list8-to-str") (param "a" (list u8)) (result string)
(canon lift
(core func $i "roundtrip")
(memory $i "memory")
(realloc (func $i "realloc"))
)
)
(func (export "str-to-list8") (param string) (result (list u8))
(func (export "str-to-list8") (param "a" string) (result (list u8))
(canon lift
(core func $i "roundtrip")
(memory $i "memory")
(realloc (func $i "realloc"))
)
)
(func (export "list16-to-str") (param (list u16)) (result string)
(func (export "list16-to-str") (param "a" (list u16)) (result string)
(canon lift
(core func $i "roundtrip")
string-encoding=utf16
@@ -744,7 +744,7 @@ fn strings() -> Result<()> {
(realloc (func $i "realloc"))
)
)
(func (export "str-to-list16") (param string) (result (list u16))
(func (export "str-to-list16") (param "a" string) (result (list u16))
(canon lift
(core func $i "roundtrip")
string-encoding=utf16
@@ -1001,10 +1001,10 @@ fn some_traps() -> Result<()> {
)
(core instance $i (instantiate $m))
(func (export "take-list-unreachable") (param (list u8))
(func (export "take-list-unreachable") (param "a" (list u8))
(canon lift (core func $i "take-list") (memory $i "memory") (realloc (func $i "realloc")))
)
(func (export "take-string-unreachable") (param string)
(func (export "take-string-unreachable") (param "a" string)
(canon lift (core func $i "take-list") (memory $i "memory") (realloc (func $i "realloc")))
)
@@ -1034,10 +1034,10 @@ fn some_traps() -> Result<()> {
)
(core instance $i2 (instantiate $m2))
(func (export "take-list-base-oob") (param (list u8))
(func (export "take-list-base-oob") (param "a" (list u8))
(canon lift (core func $i2 "take-list") (memory $i2 "memory") (realloc (func $i2 "realloc")))
)
(func (export "take-string-base-oob") (param string)
(func (export "take-string-base-oob") (param "a" string)
(canon lift (core func $i2 "take-list") (memory $i2 "memory") (realloc (func $i2 "realloc")))
)
(func (export "take-many-base-oob") (type $t)
@@ -1054,10 +1054,10 @@ fn some_traps() -> Result<()> {
)
(core instance $i3 (instantiate $m3))
(func (export "take-list-end-oob") (param (list u8))
(func (export "take-list-end-oob") (param "a" (list u8))
(canon lift (core func $i3 "take-list") (memory $i3 "memory") (realloc (func $i3 "realloc")))
)
(func (export "take-string-end-oob") (param string)
(func (export "take-string-end-oob") (param "a" string)
(canon lift (core func $i3 "take-list") (memory $i3 "memory") (realloc (func $i3 "realloc")))
)
(func (export "take-many-end-oob") (type $t)
@@ -1453,23 +1453,23 @@ fn option() -> Result<()> {
)
(core instance $i (instantiate $m))
(func (export "option-unit-to-u32") (param (option (tuple))) (result u32)
(func (export "option-unit-to-u32") (param "a" (option (tuple))) (result u32)
(canon lift (core func $i "pass0"))
)
(func (export "option-u8-to-tuple") (param (option u8)) (result "a" u32) (result "b" u32)
(func (export "option-u8-to-tuple") (param "a" (option u8)) (result "a" u32) (result "b" u32)
(canon lift (core func $i "pass1") (memory $i "memory"))
)
(func (export "option-u32-to-tuple") (param (option u32)) (result "a" u32) (result "b" u32)
(func (export "option-u32-to-tuple") (param "a" (option u32)) (result "a" u32) (result "b" u32)
(canon lift (core func $i "pass1") (memory $i "memory"))
)
(func (export "option-string-to-tuple") (param (option string)) (result "a" u32) (result "b" string)
(func (export "option-string-to-tuple") (param "a" (option string)) (result "a" u32) (result "b" string)
(canon lift
(core func $i "pass2")
(memory $i "memory")
(realloc (func $i "realloc"))
)
)
(func (export "to-option-unit") (param u32) (result (option (tuple)))
(func (export "to-option-unit") (param "a" u32) (result (option (tuple)))
(canon lift (core func $i "pass0"))
)
(func (export "to-option-u8") (param "a" u32) (param "b" u32) (result (option u8))
@@ -1646,21 +1646,21 @@ fn expected() -> Result<()> {
)
(core instance $i (instantiate $m))
(func (export "take-expected-unit") (param (result)) (result u32)
(func (export "take-expected-unit") (param "a" (result)) (result u32)
(canon lift (core func $i "pass0"))
)
(func (export "take-expected-u8-f32") (param (result u8 (error float32))) (result "a" u32) (result "b" u32)
(func (export "take-expected-u8-f32") (param "a" (result u8 (error float32))) (result "a" u32) (result "b" u32)
(canon lift (core func $i "pass1") (memory $i "memory"))
)
(type $list (list u8))
(func (export "take-expected-string") (param (result string (error $list))) (result "a" u32) (result "b" string)
(func (export "take-expected-string") (param "a" (result string (error $list))) (result "a" u32) (result "b" string)
(canon lift
(core func $i "pass2")
(memory $i "memory")
(realloc (func $i "realloc"))
)
)
(func (export "to-expected-unit") (param u32) (result (result))
(func (export "to-expected-unit") (param "a" u32) (result (result))
(canon lift (core func $i "pass0"))
)
(func (export "to-expected-s16-f32") (param "a" u32) (param "b" u32) (result (result s16 (error float32)))
@@ -1782,7 +1782,7 @@ fn fancy_list() -> Result<()> {
(type $b (result (error string)))
(type $input (list (tuple $a $b)))
(func (export "take")
(param $input)
(param "a" $input)
(result "ptr" u32)
(result "len" u32)
(result "list" (list u8))
@@ -2226,7 +2226,7 @@ fn lower_then_lift() -> Result<()> {
let component = format!(
r#"
(component $c
(import "s" (func $f (param string)))
(import "s" (func $f (param "a" string)))
(core module $libc
(memory (export "memory") 1)
@@ -2237,7 +2237,7 @@ fn lower_then_lift() -> Result<()> {
(core func $f_lower
(canon lower (func $f) (memory $libc "memory"))
)
(func $f2 (param string)
(func $f2 (param "a" string)
(canon lift (core func $f_lower)
(memory $libc "memory")
(realloc (func $libc "realloc"))
@@ -2266,7 +2266,7 @@ fn lower_then_lift() -> Result<()> {
let component = format!(
r#"
(component $c
(import "s2" (func $f (param string) (result u32)))
(import "s2" (func $f (param "a" string) (result u32)))
(core module $libc
(memory (export "memory") 1)
@@ -2277,7 +2277,7 @@ fn lower_then_lift() -> Result<()> {
(core func $f_lower
(canon lower (func $f) (memory $libc "memory"))
)
(func $f2 (param string) (result string)
(func $f2 (param "a" string) (result string)
(canon lift (core func $f_lower)
(memory $libc "memory")
(realloc (func $libc "realloc"))
@@ -2328,7 +2328,7 @@ fn errors_that_poison_instance() -> Result<()> {
(memory (export "m") 1)
)
(core instance $m2 (instantiate $m2))
(func (export "f3") (param string)
(func (export "f3") (param "a" string)
(canon lift (core func $m2 "f") (realloc (func $m2 "r")) (memory $m2 "m"))
)
@@ -2398,7 +2398,7 @@ fn errors_that_poison_instance() -> Result<()> {
fn run_export_with_internal_adapter() -> Result<()> {
let component = r#"
(component
(type $t (func (param u32) (result u32)))
(type $t (func (param "a" u32) (result u32)))
(component $a
(core module $m
(func (export "add-five") (param i32) (result i32)

View File

@@ -26,7 +26,7 @@ fn can_compile() -> Result<()> {
&engine,
format!(
r#"(component
(import "" (func $f (param string)))
(import "" (func $f (param "a" string)))
{libc}
(core func (canon lower (func $f) (memory $libc "memory") (realloc (func $libc "realloc"))))
)"#
@@ -36,11 +36,11 @@ fn can_compile() -> Result<()> {
&engine,
format!(
r#"(component
(import "f1" (func $f1 (param string) (result string)))
(import "f1" (func $f1 (param "a" string) (result string)))
{libc}
(core func (canon lower (func $f1) (memory $libc "memory") (realloc (func $libc "realloc"))))
(import "f2" (func $f2 (param u32) (result (list u8))))
(import "f2" (func $f2 (param "a" u32) (result (list u8))))
(core instance $libc2 (instantiate $libc))
(core func (canon lower (func $f2) (memory $libc2 "memory") (realloc (func $libc2 "realloc"))))
@@ -53,7 +53,7 @@ fn can_compile() -> Result<()> {
&engine,
format!(
r#"(component
(import "log" (func $log (param string)))
(import "log" (func $log (param "a" string)))
{libc}
(core func $log_lower (canon lower (func $log) (memory $libc "memory") (realloc (func $libc "realloc"))))
@@ -84,7 +84,7 @@ fn can_compile() -> Result<()> {
fn simple() -> Result<()> {
let component = r#"
(component
(import "" (func $log (param string)))
(import "" (func $log (param "a" string)))
(core module $libc
(memory (export "memory") 1)
@@ -231,7 +231,7 @@ fn attempt_to_leave_during_malloc() -> Result<()> {
(func (export "run")
(canon lift (core func $m "run"))
)
(func (export "take-string") (param string)
(func (export "take-string") (param "a" string)
(canon lift (core func $m "take-string") (memory $m "memory") (realloc (func $m "realloc")))
)
)
@@ -395,10 +395,10 @@ fn stack_and_heap_args_and_rets() -> Result<()> {
string string string string
string string string string
string))
(import "f1" (func $f1 (param u32) (result u32)))
(import "f2" (func $f2 (param $many_params) (result u32)))
(import "f3" (func $f3 (param u32) (result string)))
(import "f4" (func $f4 (param $many_params) (result string)))
(import "f1" (func $f1 (param "a" u32) (result u32)))
(import "f2" (func $f2 (param "a" $many_params) (result u32)))
(import "f3" (func $f3 (param "a" u32) (result string)))
(import "f4" (func $f4 (param "a" $many_params) (result string)))
(core module $libc
{REALLOC_AND_FREE}
@@ -658,7 +658,7 @@ fn bad_import_alignment() -> Result<()> {
string string string string
string
))
(import "unaligned-argptr" (func $unaligned_argptr (param $many_arg)))
(import "unaligned-argptr" (func $unaligned_argptr (param "a" $many_arg)))
(core module $libc_panic
(memory (export "memory") 1)
(func (export "realloc") (param i32 i32 i32 i32) (result i32)

View File

@@ -109,10 +109,10 @@ fn thread_options_through_inner() -> Result<()> {
let component = format!(
r#"
(component
(import "hostfn" (func $host (param u32) (result string)))
(import "hostfn" (func $host (param "a" u32) (result string)))
(component $c
(import "hostfn" (func $host (param u32) (result string)))
(import "hostfn" (func $host (param "a" u32) (result string)))
(core module $libc
(memory (export "memory") 1)
@@ -144,7 +144,7 @@ fn thread_options_through_inner() -> Result<()> {
(with "libc" (instance $libc))
))
(func (export "run") (param u32) (result string)
(func (export "run") (param "a" u32) (result string)
(canon lift
(core func $m "run")
(memory $m "memory")

View File

@@ -103,7 +103,7 @@ fn test_roundtrip(engine: &Engine, src: &str, dst: &str) -> Result<()> {
format!(
r#"
(component {name}
(import "echo" (func $echo (param string) (result string)))
(import "echo" (func $echo (param "a" string) (result string)))
(core instance $libc (instantiate $libc))
(core func $echo (canon lower (func $echo)
(memory $libc "memory")
@@ -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 string) (result string)
(func (export "echo") (param "a" string) (result string)
(canon lift
(core func $echo "echo")
(memory $libc "memory")
@@ -132,7 +132,7 @@ fn test_roundtrip(engine: &Engine, src: &str, dst: &str) -> Result<()> {
let component = format!(
r#"
(component
(import "host" (func $host (param string) (result string)))
(import "host" (func $host (param "a" string) (result string)))
(core module $libc
(memory (export "memory") 1)
@@ -213,14 +213,14 @@ fn test_ptr_out_of_bounds(engine: &Engine, src: &str, dst: &str) -> Result<()> {
(memory (export "memory") 1)
)
(core instance $m (instantiate $m))
(func (export "") (param string)
(func (export "") (param "a" string)
(canon lift (core func $m "") (realloc (func $m "realloc")) (memory $m "memory")
string-encoding={dst})
)
)
(component $c2
(import "" (func $f (param string)))
(import "" (func $f (param "a" string)))
(core module $libc
(memory (export "memory") 1)
)
@@ -281,14 +281,14 @@ fn test_ptr_overflow(engine: &Engine, src: &str, dst: &str) -> Result<()> {
(memory (export "memory") 1)
)
(core instance $m (instantiate $m))
(func (export "") (param string)
(func (export "") (param "a" string)
(canon lift (core func $m "") (realloc (func $m "realloc")) (memory $m "memory")
string-encoding={dst})
)
)
(component $c2
(import "" (func $f (param string)))
(import "" (func $f (param "a" string)))
(core module $libc
(memory (export "memory") 1)
)
@@ -300,7 +300,7 @@ fn test_ptr_overflow(engine: &Engine, src: &str, dst: &str) -> Result<()> {
(func (export "f") (param i32) (call $f (i32.const 1000) (local.get 0)))
)
(core instance $m (instantiate $m (with "" (instance (export "" (func $f))))))
(func (export "f") (param u32) (canon lift (core func $m "f")))
(func (export "f") (param "a" u32) (canon lift (core func $m "f")))
)
(instance $c (instantiate $c))
@@ -386,14 +386,14 @@ fn test_realloc_oob(engine: &Engine, src: &str, dst: &str) -> Result<()> {
(memory (export "memory") 1)
)
(core instance $m (instantiate $m))
(func (export "") (param string)
(func (export "") (param "a" string)
(canon lift (core func $m "") (realloc (func $m "realloc")) (memory $m "memory")
string-encoding={dst})
)
)
(component $c2
(import "" (func $f (param string)))
(import "" (func $f (param "a" string)))
(core module $libc
(memory (export "memory") 1)
)
@@ -534,14 +534,14 @@ fn test_raw_when_encoded(
(memory (export "memory") 1)
)
(core instance $m (instantiate $m))
(func (export "") (param string)
(func (export "") (param "a" string)
(canon lift (core func $m "") (realloc (func $m "realloc")) (memory $m "memory")
string-encoding={dst})
)
)
(component $c2
(import "" (func $f (param string)))
(import "" (func $f (param "a" string)))
(core module $libc
(memory (export "memory") 1)
(func (export "realloc") (param i32 i32 i32 i32) (result i32) i32.const 0)

View File

@@ -35,7 +35,7 @@
)
(core instance $i (instantiate $m))
(func (export "thunk") (param string)
(func (export "thunk") (param "a" string)
(canon lift
(core func $i "")
(memory $i "memory")
@@ -43,7 +43,7 @@
)
)
(func (export "thunk8") (param string)
(func (export "thunk8") (param "a" string)
(canon lift
(core func $i "")
string-encoding=utf8
@@ -52,7 +52,7 @@
)
)
(func (export "thunk16") (param string)
(func (export "thunk16") (param "a" string)
(canon lift
(core func $i "")
string-encoding=utf16
@@ -61,7 +61,7 @@
)
)
(func (export "thunklatin16") (param string)
(func (export "thunklatin16") (param "a" string)
(canon lift
(core func $i "")
string-encoding=latin1+utf16
@@ -121,7 +121,7 @@
(memory (export "memory") 0)
)
(core instance $m (instantiate $m))
(func $f (param (list (record)))
(func $f (param "a" (list (record)))
(canon lift
(core func $m "x")
(realloc (func $m "realloc"))

View File

@@ -39,14 +39,14 @@
)
)
(core instance $m (instantiate $m))
(func $assert_true (param bool) (canon lift (core func $m "assert_true")))
(func $assert_false (param bool) (canon lift (core func $m "assert_false")))
(func $ret_bool (param u32) (result bool) (canon lift (core func $m "ret-bool")))
(func $assert_true (param "a" bool) (canon lift (core func $m "assert_true")))
(func $assert_false (param "a" bool) (canon lift (core func $m "assert_false")))
(func $ret_bool (param "a" u32) (result bool) (canon lift (core func $m "ret-bool")))
(component $c
(import "assert-true" (func $assert_true (param bool)))
(import "assert-false" (func $assert_false (param bool)))
(import "ret-bool" (func $ret_bool (param u32) (result bool)))
(import "assert-true" (func $assert_true (param "a" bool)))
(import "assert-false" (func $assert_false (param "a" bool)))
(import "ret-bool" (func $ret_bool (param "a" u32) (result bool)))
(core func $assert_true (canon lower (func $assert_true)))
(core func $assert_false (canon lower (func $assert_false)))
@@ -296,7 +296,7 @@
unreachable)
)
(core instance $realloc (instantiate $realloc))
(func $realloc (param (tuple u32 u32 u32 u32)) (result u32)
(func $realloc (param "a" (tuple u32 u32 u32 u32)) (result u32)
(canon lift (core func $realloc "realloc"))
)
(export "realloc" (func $realloc))
@@ -309,7 +309,7 @@
(func (export "foo") (param i32))
)
(core instance $m (instantiate $m))
(func $foo (param $tuple20)
(func $foo (param "a" $tuple20)
(canon lift
(core func $m "foo")
(memory $m "memory")
@@ -318,7 +318,7 @@
)
(component $c
(import "foo" (func $foo (param $tuple20)))
(import "foo" (func $foo (param "a" $tuple20)))
(core module $libc
(memory (export "memory") 1)
@@ -495,7 +495,7 @@
)
)
(core instance $m (instantiate $m))
(func (export "r") (param $in) (result $out)
(func (export "r") (param "a" $in) (result $out)
(canon lift (core func $m "r") (memory $m "memory"))
)
)
@@ -511,7 +511,7 @@
(field "x" u8)
(field "y" u32)
))
(import "r" (func $r (param $in) (result $out)))
(import "r" (func $r (param "a" $in) (result $out)))
(core module $libc (memory (export "memory") 1))
(core instance $libc (instantiate $libc))
(core func $r (canon lower (func $r) (memory $libc "memory")))
@@ -631,12 +631,12 @@
i32.const 1)
)
(core instance $m (instantiate $m))
(func (export "r") (param $big)
(func (export "r") (param "a" $big)
(canon lift (core func $m "r") (memory $m "memory") (realloc (func $m "realloc")))
)
)
(component $c2
(import "r" (func $r (param $big)))
(import "r" (func $r (param "a" $big)))
(core module $libc
(memory (export "memory") 1)
(func (export "realloc") (param i32 i32 i32 i32) (result i32) unreachable)
@@ -679,12 +679,12 @@
i32.const 4)
)
(core instance $m (instantiate $m))
(func (export "r") (param $big)
(func (export "r") (param "a" $big)
(canon lift (core func $m "r") (memory $m "memory") (realloc (func $m "realloc")))
)
)
(component $c2
(import "r" (func $r (param $big)))
(import "r" (func $r (param "a" $big)))
(core module $libc
(memory (export "memory") 1)
(func (export "realloc") (param i32 i32 i32 i32) (result i32) unreachable)
@@ -728,10 +728,10 @@
)
)
(core instance $m (instantiate $m))
(func (export "r") (param $a) (result $b) (canon lift (core func $m "r")))
(func (export "r") (param "a" $a) (result $b) (canon lift (core func $m "r")))
)
(component $c2
(import "r" (func $r (param $a) (result $b)))
(import "r" (func $r (param "a" $a) (result $b)))
(core func $r (canon lower (func $r)))
(core module $m
@@ -763,10 +763,10 @@
(func (export "r") (param i32))
)
(core instance $m (instantiate $m))
(func (export "r") (param $a) (canon lift (core func $m "r")))
(func (export "r") (param "a" $a) (canon lift (core func $m "r")))
)
(component $c2
(import "r" (func $r (param $a)))
(import "r" (func $r (param "a" $a)))
(core func $r (canon lower (func $r)))
(core module $m
@@ -829,17 +829,17 @@
)
)
(core instance $m (instantiate $m))
(func (export "u8") (param u8) (canon lift (core func $m "u")))
(func (export "u16") (param u16) (canon lift (core func $m "u")))
(func (export "s8") (param s8) (canon lift (core func $m "s")))
(func (export "s16") (param s16) (canon lift (core func $m "s")))
(func (export "u8") (param "a" u8) (canon lift (core func $m "u")))
(func (export "u16") (param "a" u16) (canon lift (core func $m "u")))
(func (export "s8") (param "a" s8) (canon lift (core func $m "s")))
(func (export "s16") (param "a" s16) (canon lift (core func $m "s")))
)
(component $c2
(import "" (instance $i
(export "u8" (func (param u8)))
(export "s8" (func (param s8)))
(export "u16" (func (param u16)))
(export "s16" (func (param s16)))
(export "u8" (func (param "a" u8)))
(export "s8" (func (param "a" s8)))
(export "u16" (func (param "a" u16)))
(export "s16" (func (param "a" s16)))
))
(core func $u8 (canon lower (func $i "u8")))
@@ -1121,11 +1121,11 @@
(func (export "a") (param i32) (result i32) local.get 0)
)
(core instance $m (instantiate $m))
(func (export "a") (param char) (result char) (canon lift (core func $m "a")))
(func (export "a") (param "a" char) (result char) (canon lift (core func $m "a")))
)
(component $c2
(import "" (instance $i
(export "a" (func (param char) (result char)))
(export "a" (func (param "a" char) (result char)))
))
(core func $a (canon lower (func $i "a")))
@@ -1155,7 +1155,7 @@
))
))
(func (export "roundtrip") (param char) (canon lift (core func $m "roundtrip")))
(func (export "roundtrip") (param "a" char) (canon lift (core func $m "roundtrip")))
)
(instance $c1 (instantiate $c1))
(instance $c2 (instantiate $c2 (with "" (instance $c1))))
@@ -1173,10 +1173,10 @@
(component $c1
(core module $m (func (export "a") (param i32)))
(core instance $m (instantiate $m))
(func (export "a") (param char) (canon lift (core func $m "a")))
(func (export "a") (param "a" char) (canon lift (core func $m "a")))
)
(component $c2
(import "" (instance $i (export "a" (func (param char)))))
(import "" (instance $i (export "a" (func (param "a" char)))))
(core func $a (canon lower (func $i "a")))
(core module $m
(import "" "a" (func $a (param i32)))
@@ -1194,10 +1194,10 @@
(component $c1
(core module $m (func (export "a") (param i32)))
(core instance $m (instantiate $m))
(func (export "a") (param char) (canon lift (core func $m "a")))
(func (export "a") (param "a" char) (canon lift (core func $m "a")))
)
(component $c2
(import "" (instance $i (export "a" (func (param char)))))
(import "" (instance $i (export "a" (func (param "a" char)))))
(core func $a (canon lower (func $i "a")))
(core module $m
(import "" "a" (func $a (param i32)))
@@ -1215,10 +1215,10 @@
(component $c1
(core module $m (func (export "a") (param i32)))
(core instance $m (instantiate $m))
(func (export "a") (param char) (canon lift (core func $m "a")))
(func (export "a") (param "a" char) (canon lift (core func $m "a")))
)
(component $c2
(import "" (instance $i (export "a" (func (param char)))))
(import "" (instance $i (export "a" (func (param "a" char)))))
(core func $a (canon lower (func $i "a")))
(core module $m
(import "" "a" (func $a (param i32)))
@@ -1318,31 +1318,31 @@
)
)
(core instance $m (instantiate $m))
(func (export "f0") (param $f0) (canon lift (core func $m "f0")))
(func (export "f1") (param $f1) (canon lift (core func $m "f1")))
(func (export "f8") (param $f8) (canon lift (core func $m "f8")))
(func (export "f9") (param $f9) (canon lift (core func $m "f9")))
(func (export "f16") (param $f16) (canon lift (core func $m "f16")))
(func (export "f17") (param $f17) (canon lift (core func $m "f17")))
(func (export "f32") (param $f32) (canon lift (core func $m "f32")))
(func (export "f33") (param $f33) (canon lift (core func $m "f33")))
(func (export "f64") (param $f64) (canon lift (core func $m "f64")))
(func (export "f65") (param $f65) (canon lift (core func $m "f65")))
(func (export "f0") (param "a" $f0) (canon lift (core func $m "f0")))
(func (export "f1") (param "a" $f1) (canon lift (core func $m "f1")))
(func (export "f8") (param "a" $f8) (canon lift (core func $m "f8")))
(func (export "f9") (param "a" $f9) (canon lift (core func $m "f9")))
(func (export "f16") (param "a" $f16) (canon lift (core func $m "f16")))
(func (export "f17") (param "a" $f17) (canon lift (core func $m "f17")))
(func (export "f32") (param "a" $f32) (canon lift (core func $m "f32")))
(func (export "f33") (param "a" $f33) (canon lift (core func $m "f33")))
(func (export "f64") (param "a" $f64) (canon lift (core func $m "f64")))
(func (export "f65") (param "a" $f65) (canon lift (core func $m "f65")))
)
(instance $c1 (instantiate $c1))
(component $c2
(import "" (instance $i
(export "f0" (func (param $f0)))
(export "f1" (func (param $f1)))
(export "f8" (func (param $f8)))
(export "f9" (func (param $f9)))
(export "f16" (func (param $f16)))
(export "f17" (func (param $f17)))
(export "f32" (func (param $f32)))
(export "f33" (func (param $f33)))
(export "f64" (func (param $f64)))
(export "f65" (func (param $f65)))
(export "f0" (func (param "a" $f0)))
(export "f1" (func (param "a" $f1)))
(export "f8" (func (param "a" $f8)))
(export "f9" (func (param "a" $f9)))
(export "f16" (func (param "a" $f16)))
(export "f17" (func (param "a" $f17)))
(export "f32" (func (param "a" $f32)))
(export "f33" (func (param "a" $f33)))
(export "f64" (func (param "a" $f64)))
(export "f65" (func (param "a" $f65)))
))
(core func $f0 (canon lower (func $i "f0")))
(core func $f1 (canon lower (func $i "f1")))

View File

@@ -8,13 +8,13 @@
(memory (export "memory") 1)
)
(core instance $m (instantiate $m))
(func (export "") (param string)
(func (export "") (param "a" string)
(canon lift (core func $m "") (realloc (func $m "realloc")) (memory $m "memory"))
)
)
(component $c2
(import "" (func $f (param string)))
(import "" (func $f (param "a" string)))
(core module $libc
(memory (export "memory") 1)
)
@@ -44,13 +44,13 @@
(memory (export "memory") 1)
)
(core instance $m (instantiate $m))
(func (export "") (param string)
(func (export "") (param "a" string)
(canon lift (core func $m "") (realloc (func $m "realloc")) (memory $m "memory"))
)
)
(component $c2
(import "" (func $f (param string)))
(import "" (func $f (param "a" string)))
(core module $libc
(memory (export "memory") 1)
)
@@ -80,14 +80,14 @@
(memory (export "memory") 1)
)
(core instance $m (instantiate $m))
(func (export "") (param string)
(func (export "") (param "a" string)
(canon lift (core func $m "") (realloc (func $m "realloc")) (memory $m "memory")
string-encoding=utf8)
)
)
(component $c2
(import "" (func $f (param string)))
(import "" (func $f (param "a" string)))
(core module $libc
(memory (export "memory") 1)
)

View File

@@ -1,6 +1,6 @@
(component
(type string)
(type (func (param string)))
(type (func (param "a" string)))
(type $r (record (field "x" (record)) (field "y" string)))
(type $u (union $r string))
(type $e (result $u (error u32)))
@@ -8,7 +8,7 @@
(type (result (error $u)))
(type (result))
(type (func (param $e) (result (option $r))))
(type (func (param "a" $e) (result (option $r))))
(type (variant
(case "a" string)
@@ -53,7 +53,7 @@
(component
(type $empty (func))
(type (func (param string) (result u32)))
(type (func (param "a" string) (result u32)))
(type (component))
(core type (module))
(core type (func))
@@ -119,11 +119,11 @@
(component
(core module $m (func (export "") (param i32) (result i32) local.get 0))
(core instance $m (instantiate $m))
(func (export "i-to-b") (param u32) (result bool) (canon lift (core func $m "")))
(func (export "i-to-u8") (param u32) (result u8) (canon lift (core func $m "")))
(func (export "i-to-s8") (param u32) (result s8) (canon lift (core func $m "")))
(func (export "i-to-u16") (param u32) (result u16) (canon lift (core func $m "")))
(func (export "i-to-s16") (param u32) (result s16) (canon lift (core func $m "")))
(func (export "i-to-b") (param "a" u32) (result bool) (canon lift (core func $m "")))
(func (export "i-to-u8") (param "a" u32) (result u8) (canon lift (core func $m "")))
(func (export "i-to-s8") (param "a" u32) (result s8) (canon lift (core func $m "")))
(func (export "i-to-u16") (param "a" u32) (result u16) (canon lift (core func $m "")))
(func (export "i-to-s16") (param "a" u32) (result s16) (canon lift (core func $m "")))
)
(assert_return (invoke "i-to-b" (u32.const 0)) (bool.const false))
(assert_return (invoke "i-to-b" (u32.const 1)) (bool.const true))