Skip to content

Commit

Permalink
Update wasm-tools dependencies (bytecodealliance#4970)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
alexcrichton authored Sep 27, 2022
1 parent 10deb9b commit 29c7de7
Show file tree
Hide file tree
Showing 31 changed files with 407 additions and 331 deletions.
34 changes: 17 additions & 17 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
51 changes: 28 additions & 23 deletions cranelift/wasm/src/code_translator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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();

Expand All @@ -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),
Expand Down Expand Up @@ -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));
}
};
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
5 changes: 4 additions & 1 deletion cranelift/wasm/src/func_translator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
_ => {}
}
}
Expand Down
4 changes: 3 additions & 1 deletion cranelift/wasm/src/module_translator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)?;
}

Expand Down
7 changes: 4 additions & 3 deletions cranelift/wasm/src/sections_translator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
));
}
}
}
Expand Down
Loading

0 comments on commit 29c7de7

Please sign in to comment.