Update the wasm-tools family of crates (#5010)

* Update the wasm-tools family of crates

Only minor updates here, mostly internal changes and no binary-related
changes today.

* Fix test expectation
This commit is contained in:
Alex Crichton
2022-10-04 16:26:22 -05:00
committed by GitHub
parent d986b3cbc2
commit 2607590d8c
6 changed files with 99 additions and 57 deletions

30
Cargo.lock generated
View File

@@ -3231,18 +3231,18 @@ checksum = "d554b7f530dee5964d9a9468d95c1f8b8acae4f282807e7d27d4b03099a46744"
[[package]] [[package]]
name = "wasm-encoder" name = "wasm-encoder"
version = "0.17.0" version = "0.18.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7e7ca71c70a6de5b10968ae4d298e548366d9cd9588176e6ff8866f3c49c96ee" checksum = "c64ac98d5d61192cc45c701b7e4bd0b9aff91e2edfc7a088406cfe2288581e2c"
dependencies = [ dependencies = [
"leb128", "leb128",
] ]
[[package]] [[package]]
name = "wasm-mutate" name = "wasm-mutate"
version = "0.2.8" version = "0.2.9"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e8b98a1c3d9c5970ce9753e0e06c49974e01f5ab50cfca3c14010dd8bec2242d" checksum = "00f7cead43549f0307a400df44218c00ccd9b275ed87edb8862b99b000dc9011"
dependencies = [ dependencies = [
"egg", "egg",
"log", "log",
@@ -3254,9 +3254,9 @@ dependencies = [
[[package]] [[package]]
name = "wasm-smith" name = "wasm-smith"
version = "0.11.5" version = "0.11.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7b3aa9c99fbb0df9453b0ab577a797f3fc538882b9f070fd389600b843cd8878" checksum = "16f88ad106766ae5817d526cbf70576e4fdb4356ccf6814adff5a8553964feba"
dependencies = [ dependencies = [
"arbitrary", "arbitrary",
"flagset", "flagset",
@@ -3301,18 +3301,18 @@ dependencies = [
[[package]] [[package]]
name = "wasmparser" name = "wasmparser"
version = "0.91.0" version = "0.92.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "239cdca8b8f356af8118c522d5fea23da45b60832ed4e18ef90bb3c9d8dce24a" checksum = "7da34cec2a8c23db906cdf8b26e988d7a7f0d549eb5d51299129647af61a1b37"
dependencies = [ dependencies = [
"indexmap", "indexmap",
] ]
[[package]] [[package]]
name = "wasmprinter" name = "wasmprinter"
version = "0.2.40" version = "0.2.41"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "85b5931cf673c4bece6299719c024c08ebe52cbac7124160487a602c81e598c8" checksum = "ca4374ec27194a12b85aa0e1681a42d5800e97f11c036fa85dea8087c8ccb10b"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"wasmparser", "wasmparser",
@@ -3458,7 +3458,7 @@ dependencies = [
"wasmtime-wasi-crypto", "wasmtime-wasi-crypto",
"wasmtime-wasi-nn", "wasmtime-wasi-nn",
"wasmtime-wast", "wasmtime-wast",
"wast 47.0.0", "wast 47.0.1",
"wat", "wat",
"windows-sys", "windows-sys",
] ]
@@ -3718,7 +3718,7 @@ dependencies = [
"anyhow", "anyhow",
"log", "log",
"wasmtime", "wasmtime",
"wast 47.0.0", "wast 47.0.1",
] ]
[[package]] [[package]]
@@ -3732,9 +3732,9 @@ dependencies = [
[[package]] [[package]]
name = "wast" name = "wast"
version = "47.0.0" version = "47.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "117ccfc4262e62a28a13f0548a147f19ffe71e8a08be802af23ae4ea0bedad73" checksum = "02b98502f3978adea49551e801a6687678e6015317d7d9470a67fe813393f2a8"
dependencies = [ dependencies = [
"leb128", "leb128",
"memchr", "memchr",
@@ -3748,7 +3748,7 @@ version = "1.0.49"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7aab4e20c60429fbba9670a6cae0fff9520046ba0aa3e6d0b1cd2653bea14898" checksum = "7aab4e20c60429fbba9670a6cae0fff9520046ba0aa3e6d0b1cd2653bea14898"
dependencies = [ dependencies = [
"wast 47.0.0", "wast 47.0.1",
] ]
[[package]] [[package]]

View File

@@ -145,13 +145,13 @@ cranelift = { path = "cranelift/umbrella", version = "0.89.0" }
target-lexicon = { version = "0.12.3", default-features = false } target-lexicon = { version = "0.12.3", default-features = false }
anyhow = "1.0.22" anyhow = "1.0.22"
wasmparser = "0.91.0" wasmparser = "0.92.0"
wat = "1.0.49" wat = "1.0.49"
wast = "47.0.0" wast = "47.0.1"
wasmprinter = "0.2.40" wasmprinter = "0.2.41"
wasm-encoder = "0.17.0" wasm-encoder = "0.18.0"
wasm-smith = "0.11.5" wasm-smith = "0.11.6"
wasm-mutate = "0.2.8" wasm-mutate = "0.2.9"
windows-sys = "0.36.0" windows-sys = "0.36.0"
env_logger = "0.9" env_logger = "0.9"
rustix = "0.35.10" rustix = "0.35.10"

View File

@@ -249,13 +249,13 @@ pub fn translate_operator<FE: FuncEnvironment + ?Sized>(
* block and have already been translated) and modify the value stack to use the * block and have already been translated) and modify the value stack to use the
* possible `Block`'s arguments values. * possible `Block`'s arguments values.
***********************************************************************************/ ***********************************************************************************/
Operator::Block { ty } => { Operator::Block { blockty } => {
let (params, results) = blocktype_params_results(validator, *ty)?; let (params, results) = blocktype_params_results(validator, *blockty)?;
let next = block_with_params(builder, results.clone(), environ)?; let next = block_with_params(builder, results.clone(), environ)?;
state.push_block(next, params.len(), results.len()); state.push_block(next, params.len(), results.len());
} }
Operator::Loop { ty } => { Operator::Loop { blockty } => {
let (params, results) = blocktype_params_results(validator, *ty)?; let (params, results) = blocktype_params_results(validator, *blockty)?;
let loop_body = block_with_params(builder, params.clone(), environ)?; let loop_body = block_with_params(builder, params.clone(), environ)?;
let next = block_with_params(builder, results.clone(), environ)?; let next = block_with_params(builder, results.clone(), environ)?;
canonicalise_then_jump(builder, loop_body, state.peekn(params.len())); canonicalise_then_jump(builder, loop_body, state.peekn(params.len()));
@@ -271,10 +271,10 @@ pub fn translate_operator<FE: FuncEnvironment + ?Sized>(
builder.switch_to_block(loop_body); builder.switch_to_block(loop_body);
environ.translate_loop_header(builder)?; environ.translate_loop_header(builder)?;
} }
Operator::If { ty } => { Operator::If { blockty } => {
let val = state.pop1(); let val = state.pop1();
let (params, results) = blocktype_params_results(validator, *ty)?; let (params, results) = blocktype_params_results(validator, *blockty)?;
let (destination, else_data) = if params.clone().eq(results.clone()) { let (destination, else_data) = if params.clone().eq(results.clone()) {
// It is possible there is no `else` block, so we will only // It is possible there is no `else` block, so we will only
// allocate a block for it if/when we find the `else`. For now, // allocate a block for it if/when we find the `else`. For now,
@@ -307,7 +307,13 @@ pub fn translate_operator<FE: FuncEnvironment + ?Sized>(
// and we add nothing; // and we add nothing;
// - either the If have an Else clause, in that case the destination of this jump // - either the If have an Else clause, in that case the destination of this jump
// instruction will be changed later when we translate the Else operator. // instruction will be changed later when we translate the Else operator.
state.push_if(destination, else_data, params.len(), results.len(), *ty); state.push_if(
destination,
else_data,
params.len(),
results.len(),
*blockty,
);
} }
Operator::Else => { Operator::Else => {
let i = state.control_stack.len() - 1; let i = state.control_stack.len() - 1;
@@ -447,10 +453,10 @@ pub fn translate_operator<FE: FuncEnvironment + ?Sized>(
state.reachable = false; state.reachable = false;
} }
Operator::BrIf { relative_depth } => translate_br_if(*relative_depth, builder, state), Operator::BrIf { relative_depth } => translate_br_if(*relative_depth, builder, state),
Operator::BrTable { table } => { Operator::BrTable { targets } => {
let default = table.default(); let default = targets.default();
let mut min_depth = default; let mut min_depth = default;
for depth in table.targets() { for depth in targets.targets() {
let depth = depth?; let depth = depth?;
if depth < min_depth { if depth < min_depth {
min_depth = depth; min_depth = depth;
@@ -466,10 +472,10 @@ pub fn translate_operator<FE: FuncEnvironment + ?Sized>(
} }
}; };
let val = state.pop1(); let val = state.pop1();
let mut data = JumpTableData::with_capacity(table.len() as usize); let mut data = JumpTableData::with_capacity(targets.len() as usize);
if jump_args_count == 0 { if jump_args_count == 0 {
// No jump arguments // No jump arguments
for depth in table.targets() { for depth in targets.targets() {
let depth = depth?; let depth = depth?;
let block = { let block = {
let i = state.control_stack.len() - 1 - (depth as usize); let i = state.control_stack.len() - 1 - (depth as usize);
@@ -493,7 +499,7 @@ pub fn translate_operator<FE: FuncEnvironment + ?Sized>(
let return_count = jump_args_count; let return_count = jump_args_count;
let mut dest_block_sequence = vec![]; let mut dest_block_sequence = vec![];
let mut dest_block_map = HashMap::new(); let mut dest_block_map = HashMap::new();
for depth in table.targets() { for depth in targets.targets() {
let depth = depth?; let depth = depth?;
let branch_block = match dest_block_map.entry(depth as usize) { let branch_block = match dest_block_map.entry(depth as usize) {
hash_map::Entry::Occupied(entry) => *entry.get(), hash_map::Entry::Occupied(entry) => *entry.get(),
@@ -1289,11 +1295,11 @@ pub fn translate_operator<FE: FuncEnvironment + ?Sized>(
Operator::AtomicFence { .. } => { Operator::AtomicFence { .. } => {
builder.ins().fence(); builder.ins().fence();
} }
Operator::MemoryCopy { src, dst } => { Operator::MemoryCopy { src_mem, dst_mem } => {
let src_index = MemoryIndex::from_u32(*src); let src_index = MemoryIndex::from_u32(*src_mem);
let dst_index = MemoryIndex::from_u32(*dst); let dst_index = MemoryIndex::from_u32(*dst_mem);
let src_heap = state.get_heap(builder.func, *src, environ)?; let src_heap = state.get_heap(builder.func, *src_mem, environ)?;
let dst_heap = state.get_heap(builder.func, *dst, environ)?; let dst_heap = state.get_heap(builder.func, *dst_mem, environ)?;
let len = state.pop1(); let len = state.pop1();
let src_pos = state.pop1(); let src_pos = state.pop1();
let dst_pos = state.pop1(); let dst_pos = state.pop1();
@@ -1316,7 +1322,7 @@ pub fn translate_operator<FE: FuncEnvironment + ?Sized>(
let dest = state.pop1(); let dest = state.pop1();
environ.translate_memory_fill(builder.cursor(), heap_index, heap, dest, val, len)?; environ.translate_memory_fill(builder.cursor(), heap_index, heap, dest, val, len)?;
} }
Operator::MemoryInit { segment, mem } => { Operator::MemoryInit { data_index, mem } => {
let heap_index = MemoryIndex::from_u32(*mem); let heap_index = MemoryIndex::from_u32(*mem);
let heap = state.get_heap(builder.func, *mem, environ)?; let heap = state.get_heap(builder.func, *mem, environ)?;
let len = state.pop1(); let len = state.pop1();
@@ -1326,14 +1332,14 @@ pub fn translate_operator<FE: FuncEnvironment + ?Sized>(
builder.cursor(), builder.cursor(),
heap_index, heap_index,
heap, heap,
*segment, *data_index,
dest, dest,
src, src,
len, len,
)?; )?;
} }
Operator::DataDrop { segment } => { Operator::DataDrop { data_index } => {
environ.translate_data_drop(builder.cursor(), *segment)?; environ.translate_data_drop(builder.cursor(), *data_index)?;
} }
Operator::TableSize { table: index } => { Operator::TableSize { table: index } => {
let table = state.get_or_create_table(builder.func, *index, environ)?; let table = state.get_or_create_table(builder.func, *index, environ)?;
@@ -1397,7 +1403,7 @@ pub fn translate_operator<FE: FuncEnvironment + ?Sized>(
environ.translate_table_fill(builder.cursor(), table_index, dest, val, len)?; environ.translate_table_fill(builder.cursor(), table_index, dest, val, len)?;
} }
Operator::TableInit { Operator::TableInit {
segment, elem_index,
table: table_index, table: table_index,
} => { } => {
let table = state.get_or_create_table(builder.func, *table_index, environ)?; let table = state.get_or_create_table(builder.func, *table_index, environ)?;
@@ -1406,7 +1412,7 @@ pub fn translate_operator<FE: FuncEnvironment + ?Sized>(
let dest = state.pop1(); let dest = state.pop1();
environ.translate_table_init( environ.translate_table_init(
builder.cursor(), builder.cursor(),
*segment, *elem_index,
TableIndex::from_u32(*table_index), TableIndex::from_u32(*table_index),
table, table,
dest, dest,
@@ -1414,8 +1420,8 @@ pub fn translate_operator<FE: FuncEnvironment + ?Sized>(
len, len,
)?; )?;
} }
Operator::ElemDrop { segment } => { Operator::ElemDrop { elem_index } => {
environ.translate_elem_drop(builder.cursor(), *segment)?; environ.translate_elem_drop(builder.cursor(), *elem_index)?;
} }
Operator::V128Const { value } => { Operator::V128Const { value } => {
let data = value.bytes().to_vec().into(); let data = value.bytes().to_vec().into();
@@ -2043,7 +2049,7 @@ fn translate_unreachable_operator<FE: FuncEnvironment + ?Sized>(
) -> WasmResult<()> { ) -> WasmResult<()> {
debug_assert!(!state.reachable); debug_assert!(!state.reachable);
match *op { match *op {
Operator::If { ty } => { Operator::If { blockty } => {
// Push a placeholder control stack entry. The if isn't reachable, // Push a placeholder control stack entry. The if isn't reachable,
// so we don't have any branches anywhere. // so we don't have any branches anywhere.
state.push_if( state.push_if(
@@ -2053,10 +2059,10 @@ fn translate_unreachable_operator<FE: FuncEnvironment + ?Sized>(
}, },
0, 0,
0, 0,
ty, blockty,
); );
} }
Operator::Loop { ty: _ } | Operator::Block { ty: _ } => { Operator::Loop { blockty: _ } | Operator::Block { blockty: _ } => {
state.push_block(ir::Block::reserved_value(), 0, 0); state.push_block(ir::Block::reserved_value(), 0, 0);
} }
Operator::Else => { Operator::Else => {

View File

@@ -2718,22 +2718,22 @@ impl Compiler<'_, '_> {
fn i32_load8u(&mut self, mem: &Memory) { fn i32_load8u(&mut self, mem: &Memory) {
self.instruction(LocalGet(mem.addr.idx)); self.instruction(LocalGet(mem.addr.idx));
self.instruction(I32Load8_U(mem.memarg(0))); self.instruction(I32Load8U(mem.memarg(0)));
} }
fn i32_load8s(&mut self, mem: &Memory) { fn i32_load8s(&mut self, mem: &Memory) {
self.instruction(LocalGet(mem.addr.idx)); self.instruction(LocalGet(mem.addr.idx));
self.instruction(I32Load8_S(mem.memarg(0))); self.instruction(I32Load8S(mem.memarg(0)));
} }
fn i32_load16u(&mut self, mem: &Memory) { fn i32_load16u(&mut self, mem: &Memory) {
self.instruction(LocalGet(mem.addr.idx)); self.instruction(LocalGet(mem.addr.idx));
self.instruction(I32Load16_U(mem.memarg(1))); self.instruction(I32Load16U(mem.memarg(1)));
} }
fn i32_load16s(&mut self, mem: &Memory) { fn i32_load16s(&mut self, mem: &Memory) {
self.instruction(LocalGet(mem.addr.idx)); self.instruction(LocalGet(mem.addr.idx));
self.instruction(I32Load16_S(mem.memarg(1))); self.instruction(I32Load16S(mem.memarg(1)));
} }
fn i32_load(&mut self, mem: &Memory) { fn i32_load(&mut self, mem: &Memory) {

View File

@@ -237,13 +237,13 @@ impl TableOp {
} }
Self::TableGet(x) => { Self::TableGet(x) => {
func.instruction(&Instruction::I32Const(x)); func.instruction(&Instruction::I32Const(x));
func.instruction(&Instruction::TableGet { table: 0 }); func.instruction(&Instruction::TableGet(0));
} }
Self::TableSet(x) => { Self::TableSet(x) => {
func.instruction(&Instruction::LocalSet(scratch_local)); func.instruction(&Instruction::LocalSet(scratch_local));
func.instruction(&Instruction::I32Const(x)); func.instruction(&Instruction::I32Const(x));
func.instruction(&Instruction::LocalGet(scratch_local)); func.instruction(&Instruction::LocalGet(scratch_local));
func.instruction(&Instruction::TableSet { table: 0 }); func.instruction(&Instruction::TableSet(0));
} }
Self::GlobalGet(x) => { Self::GlobalGet(x) => {
func.instruction(&Instruction::GlobalGet(x)); func.instruction(&Instruction::GlobalGet(x));
@@ -325,7 +325,7 @@ mod tests {
(import "" "make_refs" (func (;2;) (type 3))) (import "" "make_refs" (func (;2;) (type 3)))
(func (;3;) (type 1) (param externref externref externref externref externref externref externref externref externref externref) (func (;3;) (type 1) (param externref externref externref externref externref externref externref externref externref externref)
(local externref) (local externref)
loop ;; label = @0 loop ;; label = @1
call 0 call 0
call 2 call 2
call 1 call 1

View File

@@ -247,6 +247,12 @@ criteria = "safe-to-deploy"
version = "0.17.0" version = "0.17.0"
notes = "The Bytecode Alliance is the author of this crate." 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.18.0"
notes = "The Bytecode Alliance is the author of this crate."
[[audits.wasm-mutate]] [[audits.wasm-mutate]]
who = "Alex Crichton <alex@alexcrichton.com>" who = "Alex Crichton <alex@alexcrichton.com>"
criteria = "safe-to-deploy" criteria = "safe-to-deploy"
@@ -271,6 +277,12 @@ criteria = "safe-to-deploy"
version = "0.2.8" version = "0.2.8"
notes = "The Bytecode Alliance is the author of this crate." 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.9"
notes = "The Bytecode Alliance is the author of this crate."
[[audits.wasm-smith]] [[audits.wasm-smith]]
who = "Alex Crichton <alex@alexcrichton.com>" who = "Alex Crichton <alex@alexcrichton.com>"
criteria = "safe-to-deploy" criteria = "safe-to-deploy"
@@ -295,6 +307,12 @@ criteria = "safe-to-deploy"
version = "0.11.5" version = "0.11.5"
notes = "The Bytecode Alliance is the author of this crate." 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.6"
notes = "The Bytecode Alliance is the author of this crate."
[[audits.wasmparser]] [[audits.wasmparser]]
who = "Alex Crichton <alex@alexcrichton.com>" who = "Alex Crichton <alex@alexcrichton.com>"
criteria = "safe-to-deploy" criteria = "safe-to-deploy"
@@ -325,6 +343,12 @@ criteria = "safe-to-deploy"
version = "0.91.0" version = "0.91.0"
notes = "The Bytecode Alliance is the author of this crate." notes = "The Bytecode Alliance is the author of this crate."
[[audits.wasmparser]]
who = "Alex Crichton <alex@alexcrichton.com>"
criteria = "safe-to-deploy"
version = "0.92.0"
notes = "The Bytecode Alliance is the author of this crate."
[[audits.wasmprinter]] [[audits.wasmprinter]]
who = "Alex Crichton <alex@alexcrichton.com>" who = "Alex Crichton <alex@alexcrichton.com>"
criteria = "safe-to-deploy" criteria = "safe-to-deploy"
@@ -349,6 +373,12 @@ criteria = "safe-to-deploy"
version = "0.2.40" version = "0.2.40"
notes = "The Bytecode Alliance is the author of this crate." 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.41"
notes = "The Bytecode Alliance is the author of this crate."
[[audits.wast]] [[audits.wast]]
who = "Alex Crichton <alex@alexcrichton.com>" who = "Alex Crichton <alex@alexcrichton.com>"
criteria = "safe-to-deploy" criteria = "safe-to-deploy"
@@ -379,6 +409,12 @@ criteria = "safe-to-deploy"
version = "47.0.0" version = "47.0.0"
notes = "The Bytecode Alliance is the author of this crate." 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.1"
notes = "The Bytecode Alliance is the author of this crate."
[[audits.wat]] [[audits.wat]]
who = "Alex Crichton <alex@alexcrichton.com>" who = "Alex Crichton <alex@alexcrichton.com>"
criteria = "safe-to-deploy" criteria = "safe-to-deploy"