From 65486a0680a81a86f5992a92a8c30c70cd0d49f0 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 2 Feb 2022 09:45:43 -0800 Subject: [PATCH] Update wasm-tools crates Nothing major here, just a routine update with a few extra things to handle here-and-there. --- Cargo.lock | 28 +++++++------ Cargo.toml | 4 +- cranelift/wasm/Cargo.toml | 2 +- cranelift/wasm/src/code_translator.rs | 19 +++++++++ cranelift/wasm/src/sections_translator.rs | 13 +++++- crates/cranelift/Cargo.toml | 2 +- crates/environ/Cargo.toml | 2 +- crates/environ/src/module_environ.rs | 13 +++++- crates/fuzzing/Cargo.toml | 2 +- crates/types/Cargo.toml | 2 +- crates/wasmtime/Cargo.toml | 2 +- crates/wasmtime/src/module/serialization.rs | 42 +++++++++++++------ crates/wast/Cargo.toml | 2 +- crates/wast/src/wast.rs | 7 +++- tests/misc_testsuite/multi-memory/simple.wast | 4 +- 15 files changed, 102 insertions(+), 42 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bb5c56495a..38818aca14 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3033,9 +3033,9 @@ checksum = "bb0d2e7be6ae3a5fa87eed5fb451aff96f2573d2694942e40543ae0bbe19c796" [[package]] name = "unicode-width" -version = "0.1.8" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3" +checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973" [[package]] name = "unicode-xid" @@ -3340,15 +3340,15 @@ dependencies = [ [[package]] name = "wasmparser" -version = "0.81.0" +version = "0.82.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98930446519f63d00a836efdc22f67766ceae8dbcc1571379f2bcabc6b2b9abc" +checksum = "0559cc0f1779240d6f894933498877ea94f693d84f3ee39c9a9932c6c312bd70" [[package]] name = "wasmprinter" -version = "0.2.31" +version = "0.2.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a00ad4a51ba74183137c776ab37dea50b9f71db7454d7b654c2ba69ac5d9b223" +checksum = "6d7e1e9d5e3540363f038518bc21f568caabaad20d4e371deabe37424ef15a8d" dependencies = [ "anyhow", "wasmparser", @@ -3484,7 +3484,7 @@ dependencies = [ "wasmtime-wasi-crypto", "wasmtime-wasi-nn", "wasmtime-wast", - "wast 38.0.1", + "wast 39.0.0", "wat", "winapi", ] @@ -3672,7 +3672,7 @@ version = "0.33.0" dependencies = [ "anyhow", "wasmtime", - "wast 38.0.1", + "wast 39.0.0", ] [[package]] @@ -3686,20 +3686,22 @@ dependencies = [ [[package]] name = "wast" -version = "38.0.1" +version = "39.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae0d7b256bef26c898fa7344a2d627e8499f5a749432ce0a05eae1a64ff0c271" +checksum = "e9bbbd53432b267421186feee3e52436531fa69a7cfee9403f5204352df3dd05" dependencies = [ "leb128", + "memchr", + "unicode-width", ] [[package]] name = "wat" -version = "1.0.40" +version = "1.0.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adcfaeb27e2578d2c6271a45609f4a055e6d7ba3a12eff35b1fd5ba147bdf046" +checksum = "ab98ed25494f97c69f28758617f27c3e92e5336040b5c3a14634f2dd3fe61830" dependencies = [ - "wast 38.0.1", + "wast 39.0.0", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 5f7d11378b..1fb55378a2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -37,7 +37,7 @@ file-per-thread-logger = "0.1.1" libc = "0.2.60" rayon = "1.5.0" humantime = "2.0.0" -wasmparser = "0.81.0" +wasmparser = "0.82.0" lazy_static = "1.4.0" [target.'cfg(unix)'.dependencies] @@ -54,7 +54,7 @@ test-programs = { path = "crates/test-programs" } wasmtime-runtime = { path = "crates/runtime" } tokio = { version = "1.8.0", features = ["rt", "time", "macros", "rt-multi-thread"] } tracing-subscriber = "0.3.1" -wast = "38.0.0" +wast = "39.0.0" criterion = "0.3.4" num_cpus = "1.13.0" winapi = { version = "0.3.9", features = ['memoryapi'] } diff --git a/cranelift/wasm/Cargo.toml b/cranelift/wasm/Cargo.toml index 39b4956fd4..62508ab7ce 100644 --- a/cranelift/wasm/Cargo.toml +++ b/cranelift/wasm/Cargo.toml @@ -12,7 +12,7 @@ keywords = ["webassembly", "wasm"] edition = "2018" [dependencies] -wasmparser = { version = "0.81", default-features = false } +wasmparser = { version = "0.82", default-features = false } cranelift-codegen = { path = "../codegen", version = "0.80.0", default-features = false } cranelift-entity = { path = "../entity", version = "0.80.0" } cranelift-frontend = { path = "../frontend", version = "0.80.0", default-features = false } diff --git a/cranelift/wasm/src/code_translator.rs b/cranelift/wasm/src/code_translator.rs index 445c6ae64e..0c6d1026a9 100644 --- a/cranelift/wasm/src/code_translator.rs +++ b/cranelift/wasm/src/code_translator.rs @@ -2013,6 +2013,25 @@ pub fn translate_operator( Operator::ReturnCall { .. } | Operator::ReturnCallIndirect { .. } => { return Err(wasm_unsupported!("proposed tail-call operator {:?}", op)); } + Operator::I8x16SwizzleRelaxed + | Operator::I32x4TruncSatF32x4SRelaxed + | Operator::I32x4TruncSatF32x4URelaxed + | Operator::I32x4TruncSatF64x2SZeroRelaxed + | Operator::I32x4TruncSatF64x2UZeroRelaxed + | Operator::F32x4FmaRelaxed + | Operator::F32x4FmsRelaxed + | Operator::F64x2FmaRelaxed + | Operator::F64x2FmsRelaxed + | Operator::I8x16LaneSelect + | Operator::I16x8LaneSelect + | Operator::I32x4LaneSelect + | Operator::I64x2LaneSelect + | Operator::F32x4MinRelaxed + | Operator::F64x2MinRelaxed + | Operator::F32x4MaxRelaxed + | Operator::F64x2MaxRelaxed => { + return Err(wasm_unsupported!("proposed relaxed-simd operator {:?}", op)); + } }; Ok(()) } diff --git a/cranelift/wasm/src/sections_translator.rs b/cranelift/wasm/src/sections_translator.rs index 53bc7d7926..a052328bd3 100644 --- a/cranelift/wasm/src/sections_translator.rs +++ b/cranelift/wasm/src/sections_translator.rs @@ -362,7 +362,12 @@ pub fn parse_element_section<'data>( environ.reserve_table_elements(elements.get_count())?; for (index, entry) in elements.into_iter().enumerate() { - let Element { kind, items, ty: _ } = entry?; + let Element { + kind, + items, + ty: _, + range: _, + } = entry?; let segments = read_elems(&items)?; match kind { ElementKind::Active { @@ -409,7 +414,11 @@ pub fn parse_data_section<'data>( environ.reserve_data_initializers(data.get_count())?; for (index, entry) in data.into_iter().enumerate() { - let Data { kind, data } = entry?; + let Data { + kind, + data, + range: _, + } = entry?; match kind { DataKind::Active { memory_index, diff --git a/crates/cranelift/Cargo.toml b/crates/cranelift/Cargo.toml index c296d7d7bf..fd8bff2053 100644 --- a/crates/cranelift/Cargo.toml +++ b/crates/cranelift/Cargo.toml @@ -19,7 +19,7 @@ cranelift-codegen = { path = "../../cranelift/codegen", version = "0.80.0" } cranelift-frontend = { path = "../../cranelift/frontend", version = "0.80.0" } cranelift-entity = { path = "../../cranelift/entity", version = "0.80.0" } cranelift-native = { path = "../../cranelift/native", version = "0.80.0" } -wasmparser = "0.81.0" +wasmparser = "0.82.0" target-lexicon = "0.12" gimli = { version = "0.26.0", default-features = false, features = ['read', 'std'] } object = { version = "0.27.0", default-features = false, features = ['write'] } diff --git a/crates/environ/Cargo.toml b/crates/environ/Cargo.toml index f1f8ebb179..c5da182261 100644 --- a/crates/environ/Cargo.toml +++ b/crates/environ/Cargo.toml @@ -14,7 +14,7 @@ edition = "2018" anyhow = "1.0" cranelift-entity = { path = "../../cranelift/entity", version = "0.80.0" } wasmtime-types = { path = "../types", version = "0.33.0" } -wasmparser = "0.81" +wasmparser = "0.82" indexmap = { version = "1.0.2", features = ["serde-1"] } thiserror = "1.0.4" serde = { version = "1.0.94", features = ["derive"] } diff --git a/crates/environ/src/module_environ.rs b/crates/environ/src/module_environ.rs index e8f6ef0511..b352a2ce9c 100644 --- a/crates/environ/src/module_environ.rs +++ b/crates/environ/src/module_environ.rs @@ -516,7 +516,12 @@ impl<'data> ModuleEnvironment<'data> { self.result.module.table_initializers.reserve_exact(cnt); for (index, entry) in elements.into_iter().enumerate() { - let wasmparser::Element { kind, items, ty: _ } = entry?; + let wasmparser::Element { + kind, + items, + ty: _, + range: _, + } = entry?; // Build up a list of `FuncIndex` corresponding to all the // entries listed in this segment. Note that it's not @@ -646,7 +651,11 @@ impl<'data> ModuleEnvironment<'data> { self.result.data.reserve_exact(cnt); for (index, entry) in data.into_iter().enumerate() { - let wasmparser::Data { kind, data } = entry?; + let wasmparser::Data { + kind, + data, + range: _, + } = entry?; let mk_range = |total: &mut u32| -> Result<_, WasmError> { let range = u32::try_from(data.len()) .ok() diff --git a/crates/fuzzing/Cargo.toml b/crates/fuzzing/Cargo.toml index 5f0a2c1a66..6dbb6c9754 100644 --- a/crates/fuzzing/Cargo.toml +++ b/crates/fuzzing/Cargo.toml @@ -13,7 +13,7 @@ arbitrary = { version = "1.0.0", features = ["derive"] } env_logger = "0.8.1" log = "0.4.8" rayon = "1.2.1" -wasmparser = "0.81" +wasmparser = "0.82" wasmprinter = "0.2.31" wasmtime = { path = "../wasmtime" } wasmtime-wast = { path = "../wast" } diff --git a/crates/types/Cargo.toml b/crates/types/Cargo.toml index 5659d672f5..6f95339de8 100644 --- a/crates/types/Cargo.toml +++ b/crates/types/Cargo.toml @@ -12,4 +12,4 @@ edition = "2018" cranelift-entity = { path = "../../cranelift/entity", version = "0.80.0", features = ['enable-serde'] } serde = { version = "1.0.94", features = ["derive"] } thiserror = "1.0.4" -wasmparser = { version = "0.81", default-features = false } +wasmparser = { version = "0.82", default-features = false } diff --git a/crates/wasmtime/Cargo.toml b/crates/wasmtime/Cargo.toml index b5912ceb83..eb4b3ce344 100644 --- a/crates/wasmtime/Cargo.toml +++ b/crates/wasmtime/Cargo.toml @@ -20,7 +20,7 @@ wasmtime-cache = { path = "../cache", version = "=0.33.0", optional = true } wasmtime-fiber = { path = "../fiber", version = "=0.33.0", optional = true } wasmtime-cranelift = { path = "../cranelift", version = "=0.33.0", optional = true } target-lexicon = { version = "0.12.0", default-features = false } -wasmparser = "0.81" +wasmparser = "0.82" anyhow = "1.0.19" region = "2.2.0" libc = "0.2" diff --git a/crates/wasmtime/src/module/serialization.rs b/crates/wasmtime/src/module/serialization.rs index 740d1eab92..0b791aa81c 100644 --- a/crates/wasmtime/src/module/serialization.rs +++ b/crates/wasmtime/src/module/serialization.rs @@ -77,6 +77,8 @@ struct WasmFeatures { pub multi_memory: bool, pub exceptions: bool, pub memory64: bool, + pub relaxed_simd: bool, + pub extended_const: bool, } impl From<&wasmparser::WasmFeatures> for WasmFeatures { @@ -93,20 +95,24 @@ impl From<&wasmparser::WasmFeatures> for WasmFeatures { multi_memory, exceptions, memory64, - } = other; + relaxed_simd, + extended_const, + } = *other; Self { - reference_types: *reference_types, - multi_value: *multi_value, - bulk_memory: *bulk_memory, - module_linking: *module_linking, - simd: *simd, - threads: *threads, - tail_call: *tail_call, - deterministic_only: *deterministic_only, - multi_memory: *multi_memory, - exceptions: *exceptions, - memory64: *memory64, + reference_types, + multi_value, + bulk_memory, + module_linking, + simd, + threads, + tail_call, + deterministic_only, + multi_memory, + exceptions, + memory64, + relaxed_simd, + extended_const, } } } @@ -669,6 +675,8 @@ impl<'a> SerializedModule<'a> { multi_memory, exceptions, memory64, + relaxed_simd, + extended_const, } = self.metadata.features; Self::check_bool( @@ -714,6 +722,16 @@ impl<'a> SerializedModule<'a> { other.memory64, "WebAssembly 64-bit memory support", )?; + Self::check_bool( + extended_const, + other.extended_const, + "WebAssembly extended-const support", + )?; + Self::check_bool( + relaxed_simd, + other.relaxed_simd, + "WebAssembly relaxed-simd support", + )?; Ok(()) } diff --git a/crates/wast/Cargo.toml b/crates/wast/Cargo.toml index 3fd5bb5eb8..e3e57eb23b 100644 --- a/crates/wast/Cargo.toml +++ b/crates/wast/Cargo.toml @@ -12,7 +12,7 @@ edition = "2018" [dependencies] anyhow = "1.0.19" wasmtime = { path = "../wasmtime", version = "0.33.0", default-features = false, features = ['cranelift'] } -wast = "38.0.0" +wast = "39.0.0" [badges] maintenance = { status = "actively-developed" } diff --git a/crates/wast/src/wast.rs b/crates/wast/src/wast.rs index 0972a5cbea..b54ae273dc 100644 --- a/crates/wast/src/wast.rs +++ b/crates/wast/src/wast.rs @@ -4,6 +4,7 @@ use std::fmt::{Display, LowerHex}; use std::path::Path; use std::str; use wasmtime::*; +use wast::lexer::Lexer; use wast::Wat; use wast::{ parser::{self, ParseBuffer}, @@ -215,8 +216,10 @@ impl WastContext { err }; - let buf = wast::parser::ParseBuffer::new(wast).map_err(adjust_wast)?; - let ast = wast::parser::parse::(&buf).map_err(adjust_wast)?; + let mut lexer = Lexer::new(wast); + lexer.allow_confusing_unicode(filename.ends_with("names.wast")); + let buf = ParseBuffer::new_with_lexer(lexer).map_err(adjust_wast)?; + let ast = parser::parse::(&buf).map_err(adjust_wast)?; for directive in ast.directives { let sp = directive.span(); diff --git a/tests/misc_testsuite/multi-memory/simple.wast b/tests/misc_testsuite/multi-memory/simple.wast index 14b203b1be..d40e02709f 100644 --- a/tests/misc_testsuite/multi-memory/simple.wast +++ b/tests/misc_testsuite/multi-memory/simple.wast @@ -118,7 +118,7 @@ i32.const 1 i32.const 0 i32.const 4 - memory.init $d $m1 + memory.init $m1 $d i32.const 1 i32.load) @@ -126,7 +126,7 @@ i32.const 1 i32.const 4 i32.const 4 - memory.init $d $m2 + memory.init $m2 $d i32.const 1 i32.load (memory $m2))