diff --git a/Cargo.lock b/Cargo.lock index 9cb180aa27..4386a8b9d2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3256,18 +3256,18 @@ checksum = "d554b7f530dee5964d9a9468d95c1f8b8acae4f282807e7d27d4b03099a46744" [[package]] name = "wasm-encoder" -version = "0.19.0" +version = "0.19.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5816e88e8ea7335016aa62eb0485747f786136d505a9b3890f8c400211d9b5f" +checksum = "9424cdab516a16d4ea03c8f4a01b14e7b2d04a129dcc2bcdde5bcc5f68f06c41" dependencies = [ "leb128", ] [[package]] name = "wasm-mutate" -version = "0.2.10" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95d890340857014cfaad5db9d37154416de7110520ee515b0d9b1d7f29c7b137" +checksum = "b48cf16265251b7e11c57686ea068a77c87a67aada5cff4ee8dd50382820f01b" dependencies = [ "egg", "log", @@ -3279,9 +3279,9 @@ dependencies = [ [[package]] name = "wasm-smith" -version = "0.11.7" +version = "0.11.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f89c6660d167214d00fc9e906c75ac1b1c22e1ca6f82f379440d804b63e6fcd5" +checksum = "f351bb8188460a311bceb4e2fd7423e09ba5c4a16fc03f3b258f454c4d706881" dependencies = [ "arbitrary", "flagset", @@ -3332,9 +3332,9 @@ dependencies = [ [[package]] name = "wasmparser" -version = "0.93.0" +version = "0.94.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5a4460aa3e271fa180b6a5d003e728f3963fb30e3ba0fa7c9634caa06049328" +checksum = "cdac7e1d98d70913ae3b4923dd7419c8ea7bdfd4c44a240a0ba305d929b7f191" dependencies = [ "indexmap", ] @@ -3350,9 +3350,9 @@ dependencies = [ [[package]] name = "wasmprinter" -version = "0.2.42" +version = "0.2.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c9f096ba095329c6aa55b7e9cafa26c5b50e9ab7fc2415fd0b26cb80dca8f05" +checksum = "9c093ddb9e6526cc59d93032b9be7a8d014cc997e8a9372f394c9624f820d209" dependencies = [ "anyhow", "wasmparser", @@ -3499,7 +3499,7 @@ dependencies = [ "wasmtime-wasi-crypto", "wasmtime-wasi-nn", "wasmtime-wast", - "wast 48.0.0", + "wast 49.0.0", "wat", "windows-sys", ] @@ -3768,7 +3768,7 @@ dependencies = [ "anyhow", "log", "wasmtime", - "wast 48.0.0", + "wast 49.0.0", ] [[package]] @@ -3793,9 +3793,9 @@ dependencies = [ [[package]] name = "wast" -version = "48.0.0" +version = "49.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84825b5ac7164df8260c9e2b2e814075334edbe7ac426f2469b93a5eeac23cce" +checksum = "05ef81fcd60d244cafffeafac3d17615fdb2fddda6aca18f34a8ae233353587c" dependencies = [ "leb128", "memchr", @@ -3805,11 +3805,11 @@ dependencies = [ [[package]] name = "wat" -version = "1.0.50" +version = "1.0.51" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "129da4a03ec6d2a815f42c88f641824e789d5be0d86d2f90aa8a218c7068e0be" +checksum = "4c347c4460ffb311e95aafccd8c29e4888f241b9e4b3bb0e0ccbd998de2c8c0d" dependencies = [ - "wast 48.0.0", + "wast 49.0.0", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 6e21908b08..235f312b31 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -154,13 +154,13 @@ winch-codegen = { path = "winch/codegen", version = "=0.2.0" } target-lexicon = { version = "0.12.3", default-features = false } anyhow = "1.0.22" -wasmparser = "0.93.0" -wat = "1.0.50" -wast = "48.0.0" -wasmprinter = "0.2.42" -wasm-encoder = "0.19.0" -wasm-smith = "0.11.7" -wasm-mutate = "0.2.10" +wasmparser = "0.94.0" +wat = "1.0.51" +wast = "49.0.0" +wasmprinter = "0.2.43" +wasm-encoder = "0.19.1" +wasm-smith = "0.11.8" +wasm-mutate = "0.2.11" windows-sys = "0.36.0" env_logger = "0.9" rustix = "0.35.10" diff --git a/cranelift/wasm/src/sections_translator.rs b/cranelift/wasm/src/sections_translator.rs index b48fdf38f4..78424eaeef 100644 --- a/cranelift/wasm/src/sections_translator.rs +++ b/cranelift/wasm/src/sections_translator.rs @@ -395,35 +395,27 @@ pub fn parse_name_section<'data>( ) -> WasmResult<()> { for subsection in names { match subsection? { - wasmparser::Name::Function(f) => { - let mut names = f.get_map()?; - for _ in 0..names.get_count() { - let Naming { index, name } = names.read()?; + wasmparser::Name::Function(names) => { + for name in names { + let Naming { index, name } = name?; // We reserve `u32::MAX` for our own use in cranelift-entity. if index != u32::max_value() { environ.declare_func_name(FuncIndex::from_u32(index), name); } } } - wasmparser::Name::Module(module) => { - let name = module.get_name()?; + wasmparser::Name::Module { name, .. } => { environ.declare_module_name(name); } - wasmparser::Name::Local(l) => { - let mut reader = l.get_indirect_map()?; - for _ in 0..reader.get_indirect_count() { - let f = reader.read()?; - if f.indirect_index == u32::max_value() { + wasmparser::Name::Local(reader) => { + for f in reader { + let f = f?; + if f.index == u32::max_value() { continue; } - let mut map = f.get_map()?; - for _ in 0..map.get_count() { - let Naming { index, name } = map.read()?; - environ.declare_local_name( - FuncIndex::from_u32(f.indirect_index), - index, - name, - ) + for name in f.names { + let Naming { index, name } = name?; + environ.declare_local_name(FuncIndex::from_u32(f.index), index, name) } } } diff --git a/crates/environ/src/module_environ.rs b/crates/environ/src/module_environ.rs index a48ad952f3..4c578165a1 100644 --- a/crates/environ/src/module_environ.rs +++ b/crates/environ/src/module_environ.rs @@ -774,10 +774,9 @@ and for re-adding support for interface types you can see this issue: fn name_section(&mut self, names: NameSectionReader<'data>) -> WasmResult<()> { for subsection in names { match subsection? { - wasmparser::Name::Function(f) => { - let mut names = f.get_map()?; - for _ in 0..names.get_count() { - let Naming { index, name } = names.read()?; + wasmparser::Name::Function(names) => { + for name in names { + let Naming { index, name } = name?; // Skip this naming if it's naming a function that // doesn't actually exist. if (index as usize) >= self.result.module.functions.len() { @@ -796,34 +795,31 @@ and for re-adding support for interface types you can see this issue: .insert(index, name); } } - wasmparser::Name::Module(module) => { - let name = module.get_name()?; + wasmparser::Name::Module { name, .. } => { self.result.module.name = Some(name.to_string()); if self.tunables.generate_native_debuginfo { self.result.debuginfo.name_section.module_name = Some(name); } } - wasmparser::Name::Local(l) => { + wasmparser::Name::Local(reader) => { if !self.tunables.generate_native_debuginfo { continue; } - let mut reader = l.get_indirect_map()?; - for _ in 0..reader.get_indirect_count() { - let f = reader.read()?; + for f in reader { + let f = f?; // Skip this naming if it's naming a function that // doesn't actually exist. - if (f.indirect_index as usize) >= self.result.module.functions.len() { + if (f.index as usize) >= self.result.module.functions.len() { continue; } - let mut map = f.get_map()?; - for _ in 0..map.get_count() { - let Naming { index, name } = map.read()?; + for name in f.names { + let Naming { index, name } = name?; self.result .debuginfo .name_section .locals_names - .entry(FuncIndex::from_u32(f.indirect_index)) + .entry(FuncIndex::from_u32(f.index)) .or_insert(HashMap::new()) .insert(index, name); } diff --git a/supply-chain/audits.toml b/supply-chain/audits.toml index 19645904af..76517096a2 100644 --- a/supply-chain/audits.toml +++ b/supply-chain/audits.toml @@ -370,6 +370,12 @@ criteria = "safe-to-deploy" version = "0.19.0" notes = "The Bytecode Alliance is the author of this crate." +[[audits.wasm-encoder]] +who = "Alex Crichton " +criteria = "safe-to-deploy" +delta = "0.19.0 -> 0.19.1" +notes = "The Bytecode Alliance is the author of this crate." + [[audits.wasm-mutate]] who = "Alex Crichton " criteria = "safe-to-deploy" @@ -406,6 +412,12 @@ criteria = "safe-to-run" version = "0.2.10" notes = "The Bytecode Alliance is the author of this crate." +[[audits.wasm-mutate]] +who = "Alex Crichton " +criteria = "safe-to-run" +version = "0.2.11" +notes = "The Bytecode Alliance is the author of this crate." + [[audits.wasm-smith]] who = "Alex Crichton " criteria = "safe-to-deploy" @@ -442,6 +454,12 @@ criteria = "safe-to-run" version = "0.11.7" notes = "The Bytecode Alliance is the author of this crate." +[[audits.wasm-smith]] +who = "Alex Crichton " +criteria = "safe-to-run" +version = "0.11.8" +notes = "The Bytecode Alliance is the author of this crate." + [[audits.wasmi_arena]] who = "Alex Crichton " criteria = "safe-to-run" @@ -505,6 +523,12 @@ criteria = "safe-to-deploy" version = "0.93.0" notes = "The Bytecode Alliance is the author of this crate." +[[audits.wasmparser]] +who = "Alex Crichton " +criteria = "safe-to-deploy" +version = "0.94.0" +notes = "The Bytecode Alliance is the author of this crate." + [[audits.wasmparser-nostd]] who = "Alex Crichton " criteria = "safe-to-run" @@ -552,6 +576,12 @@ criteria = "safe-to-deploy" version = "0.2.42" notes = "The Bytecode Alliance is the author of this crate." +[[audits.wasmprinter]] +who = "Alex Crichton " +criteria = "safe-to-deploy" +version = "0.2.43" +notes = "The Bytecode Alliance is the author of this crate." + [[audits.wast]] who = "Alex Crichton " criteria = "safe-to-deploy" @@ -594,6 +624,12 @@ criteria = "safe-to-deploy" version = "48.0.0" notes = "The Bytecode Alliance is the author of this crate." +[[audits.wast]] +who = "Alex Crichton " +criteria = "safe-to-deploy" +version = "49.0.0" +notes = "The Bytecode Alliance is the author of this crate." + [[audits.wat]] who = "Alex Crichton " criteria = "safe-to-deploy" @@ -618,6 +654,12 @@ criteria = "safe-to-deploy" version = "1.0.50" notes = "The Bytecode Alliance is the author of this crate." +[[audits.wat]] +who = "Alex Crichton " +criteria = "safe-to-deploy" +version = "1.0.51" +notes = "The Bytecode Alliance is the author of this crate." + [[audits.wat]] who = "Alex Crichton " criteria = "safe-to-deploy" diff --git a/winch/codegen/src/codegen.rs b/winch/codegen/src/codegen.rs index 5c1cd1c495..d78f61b2fc 100644 --- a/winch/codegen/src/codegen.rs +++ b/winch/codegen/src/codegen.rs @@ -94,21 +94,21 @@ where &mut self.regalloc, ); - let mut visitor = ValidateThenVisit(&mut validator, self); while !body.eof() { - body.visit_operator(&mut visitor)??; + let offset = body.original_position(); + body.visit_operator(&mut ValidateThenVisit(validator.visitor(offset), self))??; } validator.finish(body.original_position())?; return Ok(()); - struct ValidateThenVisit<'a, T, U>(&'a mut T, &'a mut U); + struct ValidateThenVisit<'a, T, U>(T, &'a mut U); macro_rules! validate_then_visit { ($( @$proposal:ident $op:ident $({ $($arg:ident: $argty:ty),* })? => $visit:ident)*) => { $( - fn $visit(&mut self, offset: usize $($(,$arg: $argty)*)?) -> Self::Output { - self.0.$visit(offset, $($($arg.clone()),*)?)?; - Ok(self.1.$visit(offset, $($($arg),*)?)) + fn $visit(&mut self $($(,$arg: $argty)*)?) -> Self::Output { + self.0.$visit($($($arg.clone()),*)?)?; + Ok(self.1.$visit($($($arg),*)?)) } )* }; diff --git a/winch/codegen/src/visitor.rs b/winch/codegen/src/visitor.rs index 73a1cbca48..10d0663265 100644 --- a/winch/codegen/src/visitor.rs +++ b/winch/codegen/src/visitor.rs @@ -62,7 +62,7 @@ macro_rules! def_unsupported { emit $op - fn $visit(&mut self, _offset: usize $($(,$arg: $argty)*)?) -> Self::Output { + fn $visit(&mut self $($(,$arg: $argty)*)?) -> Self::Output { $($(drop($arg);)*)? todo!(stringify!($op)) } @@ -85,11 +85,11 @@ where { type Output = (); - fn visit_i32_const(&mut self, _offset: usize, val: i32) { + fn visit_i32_const(&mut self, val: i32) { self.context.stack.push(Val::i32(val)); } - fn visit_i32_add(&mut self, _offset: usize) { + fn visit_i32_add(&mut self) { let is_const = self .context .stack @@ -104,9 +104,9 @@ where } } - fn visit_end(&mut self, _offset: usize) {} + fn visit_end(&mut self) {} - fn visit_local_get(&mut self, _offset: usize, index: u32) { + fn visit_local_get(&mut self, index: u32) { let context = &mut self.context; let slot = context .frame @@ -119,7 +119,7 @@ where } // TODO verify the case where the target local is on the stack. - fn visit_local_set(&mut self, _offset: usize, index: u32) { + fn visit_local_set(&mut self, index: u32) { let context = &mut self.context; let frame = context.frame; let slot = frame