From de0b1e0680f1dc26205bfa4a0988090314b6593e Mon Sep 17 00:00:00 2001 From: Rainy Sinclair <844493+itsrainy@users.noreply.github.com> Date: Tue, 16 May 2023 21:14:37 -0400 Subject: [PATCH 1/3] Update wasm-tools crates to latest versions. This included stubbing out unimplemented GC-related things and updating coredump generation to include the coredump spec changes. --- Cargo.lock | 91 +++++++++++++-------- Cargo.toml | 14 ++-- cranelift/wasm/src/code_translator.rs | 3 + crates/wasmtime/src/engine/serialization.rs | 1 + src/commands/run.rs | 15 ++++ 5 files changed, 81 insertions(+), 43 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7c5c352f7dd7..c8c56ec17aae 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -677,7 +677,7 @@ dependencies = [ "target-lexicon", "thiserror", "toml", - "wasmparser 0.104.0", + "wasmparser 0.105.0", "wat", ] @@ -853,7 +853,7 @@ dependencies = [ "serde", "smallvec", "target-lexicon", - "wasmparser 0.104.0", + "wasmparser 0.105.0", "wasmtime-types", "wat", ] @@ -3636,6 +3636,15 @@ dependencies = [ "leb128", ] +[[package]] +name = "wasm-encoder" +version = "0.27.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e77053dc709db790691d3732cfc458adc5acc881dec524965c608effdcd9c581" +dependencies = [ + "leb128", +] + [[package]] name = "wasm-metadata" version = "0.5.0" @@ -3651,30 +3660,30 @@ dependencies = [ [[package]] name = "wasm-mutate" -version = "0.2.24" +version = "0.2.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77e6309ff390c0389b5ced7ad7812a0bc091976c606e661e71184f077bfd0ddc" +checksum = "7b8c74fd20d97b9ba8b1a6e3ccc6ec715e6c6d4605668926e582e88580180d96" dependencies = [ "egg", "log", "rand 0.8.5", "thiserror", - "wasm-encoder 0.26.0", - "wasmparser 0.104.0", + "wasm-encoder 0.27.0", + "wasmparser 0.105.0", ] [[package]] name = "wasm-smith" -version = "0.12.7" +version = "0.12.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "649447f144ee5db453e2b5ce7d3f60a9d7dd0bb5b2fde500125d3aa79a9387c8" +checksum = "13c11c745f6f4ff2f953d8a94ef056b04b468fc021285cfaf614e77791c05499" dependencies = [ "arbitrary", "flagset", "indexmap", "leb128", - "wasm-encoder 0.26.0", - "wasmparser 0.104.0", + "wasm-encoder 0.27.0", + "wasmparser 0.105.0", ] [[package]] @@ -3734,6 +3743,16 @@ dependencies = [ "url", ] +[[package]] +name = "wasmparser" +version = "0.105.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83be9e0b3f9570dc1979a33ae7b89d032c73211564232b99976553e5c155ec32" +dependencies = [ + "indexmap", + "url", +] + [[package]] name = "wasmparser-nostd" version = "0.91.0" @@ -3745,12 +3764,12 @@ dependencies = [ [[package]] name = "wasmprinter" -version = "0.2.56" +version = "0.2.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "731da2505d5437cd5d6feb09457835f76186be13be7677fe00781ae99d5bbe8a" +checksum = "50b0e5ed7a74a065637f0d7798ce5f29cadb064980d24b0c82af5200122fa0d8" dependencies = [ "anyhow", - "wasmparser 0.104.0", + "wasmparser 0.105.0", ] [[package]] @@ -3777,7 +3796,7 @@ dependencies = [ "target-lexicon", "tempfile", "wasi-cap-std-sync", - "wasmparser 0.104.0", + "wasmparser 0.105.0", "wasmtime-cache", "wasmtime-component-macro", "wasmtime-component-util", @@ -3892,8 +3911,8 @@ dependencies = [ "test-programs", "tokio", "walkdir", - "wasm-encoder 0.26.0", - "wasmparser 0.104.0", + "wasm-encoder 0.27.0", + "wasmparser 0.105.0", "wasmtime", "wasmtime-cache", "wasmtime-cli-flags", @@ -3908,7 +3927,7 @@ dependencies = [ "wasmtime-wasi-nn", "wasmtime-wasi-threads", "wasmtime-wast", - "wast 57.0.0", + "wast 58.0.0", "wat", "windows-sys 0.48.0", ] @@ -3961,7 +3980,7 @@ dependencies = [ "object", "target-lexicon", "thiserror", - "wasmparser 0.104.0", + "wasmparser 0.105.0", "wasmtime-cranelift-shared", "wasmtime-environ", ] @@ -3996,8 +4015,8 @@ dependencies = [ "serde", "target-lexicon", "thiserror", - "wasm-encoder 0.26.0", - "wasmparser 0.104.0", + "wasm-encoder 0.27.0", + "wasmparser 0.105.0", "wasmprinter", "wasmtime-component-util", "wasmtime-types", @@ -4012,7 +4031,7 @@ dependencies = [ "component-fuzz-util", "env_logger 0.10.0", "libfuzzer-sys", - "wasmparser 0.104.0", + "wasmparser 0.105.0", "wasmprinter", "wasmtime-environ", "wat", @@ -4066,7 +4085,7 @@ dependencies = [ "rand 0.8.5", "smallvec", "target-lexicon", - "wasmparser 0.104.0", + "wasmparser 0.105.0", "wasmtime", "wasmtime-fuzzing", ] @@ -4086,12 +4105,12 @@ dependencies = [ "target-lexicon", "tempfile", "v8", - "wasm-encoder 0.26.0", + "wasm-encoder 0.27.0", "wasm-mutate", "wasm-smith", "wasm-spec-interpreter", "wasmi", - "wasmparser 0.104.0", + "wasmparser 0.105.0", "wasmprinter", "wasmtime", "wasmtime-wast", @@ -4173,7 +4192,7 @@ dependencies = [ "cranelift-entity", "serde", "thiserror", - "wasmparser 0.104.0", + "wasmparser 0.105.0", ] [[package]] @@ -4247,7 +4266,7 @@ dependencies = [ "anyhow", "log", "wasmtime", - "wast 57.0.0", + "wast 58.0.0", ] [[package]] @@ -4259,7 +4278,7 @@ dependencies = [ "gimli", "object", "target-lexicon", - "wasmparser 0.104.0", + "wasmparser 0.105.0", "wasmtime-cranelift-shared", "wasmtime-environ", "winch-codegen", @@ -4286,23 +4305,23 @@ dependencies = [ [[package]] name = "wast" -version = "57.0.0" +version = "58.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6eb0f5ed17ac4421193c7477da05892c2edafd67f9639e3c11a82086416662dc" +checksum = "372eecae2d10a5091c2005b32377d7ecd6feecdf2c05838056d02d8b4f07c429" dependencies = [ "leb128", "memchr", "unicode-width", - "wasm-encoder 0.26.0", + "wasm-encoder 0.27.0", ] [[package]] name = "wat" -version = "1.0.63" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab9ab0d87337c3be2bb6fc5cd331c4ba9fd6bcb4ee85048a0dd59ed9ecf92e53" +checksum = "6d47446190e112ab1579ab40b3ad7e319d859d74e5134683f04e9f0747bf4173" dependencies = [ - "wast 57.0.0", + "wast 58.0.0", ] [[package]] @@ -4430,7 +4449,7 @@ dependencies = [ "regalloc2", "smallvec", "target-lexicon", - "wasmparser 0.104.0", + "wasmparser 0.105.0", "wasmtime-environ", ] @@ -4438,7 +4457,7 @@ dependencies = [ name = "winch-environ" version = "0.8.0" dependencies = [ - "wasmparser 0.104.0", + "wasmparser 0.105.0", "wasmtime-environ", "winch-codegen", ] @@ -4484,7 +4503,7 @@ dependencies = [ "similar", "target-lexicon", "toml", - "wasmparser 0.104.0", + "wasmparser 0.105.0", "wasmtime-environ", "wat", "winch-codegen", diff --git a/Cargo.toml b/Cargo.toml index d2333dff3876..4a60137e7269 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -181,13 +181,13 @@ byte-array-literals = { path = "crates/wasi-preview1-component-adapter/byte-arra target-lexicon = { version = "0.12.3", default-features = false, features = ["std"] } anyhow = "1.0.22" -wasmparser = "0.104.0" -wat = "1.0.63" -wast = "57.0.0" -wasmprinter = "0.2.56" -wasm-encoder = "0.26.0" -wasm-smith = "0.12.7" -wasm-mutate = "0.2.24" +wasmparser = "0.105.0" +wat = "1.0.64" +wast = "58.0.0" +wasmprinter = "0.2.57" +wasm-encoder = "0.27.0" +wasm-smith = "0.12.8" +wasm-mutate = "0.2.25" wit-parser = "0.7.1" windows-sys = "0.48.0" env_logger = "0.10" diff --git a/cranelift/wasm/src/code_translator.rs b/cranelift/wasm/src/code_translator.rs index 3f506374b622..030fe43c3b44 100644 --- a/cranelift/wasm/src/code_translator.rs +++ b/cranelift/wasm/src/code_translator.rs @@ -2347,6 +2347,9 @@ pub fn translate_operator( op )); } + Operator::I31New | Operator::I31GetS | Operator::I31GetU => { + unimplemented!("GC operators not yet implemented") + } }; Ok(()) } diff --git a/crates/wasmtime/src/engine/serialization.rs b/crates/wasmtime/src/engine/serialization.rs index eb73e969e662..18bcadc5c04f 100644 --- a/crates/wasmtime/src/engine/serialization.rs +++ b/crates/wasmtime/src/engine/serialization.rs @@ -194,6 +194,7 @@ impl Metadata { saturating_float_to_int: _, sign_extension: _, floats: _, + gc: _, } = engine.config().features; assert!(!memory_control); diff --git a/src/commands/run.rs b/src/commands/run.rs index 5b8be662049f..f8b43ee36d23 100644 --- a/src/commands/run.rs +++ b/src/commands/run.rs @@ -832,9 +832,20 @@ fn generate_coredump(err: &anyhow::Error, source_name: &str, coredump_path: &str .ok_or_else(|| anyhow!("no wasm backtrace found to generate coredump with"))?; let coredump = wasm_encoder::CoreDumpSection::new(source_name); + let mut coremodules = wasm_encoder::CoreDumpModulesSection::new(); let mut stacksection = wasm_encoder::CoreDumpStackSection::new("main"); + let mut modulenames = std::collections::HashSet::new(); for f in bt.frames() { + modulenames.insert(f.module_name().unwrap_or("")); + + // We don't have the information at this point to map frames to + // individual instances of a module, so we won't be able to create the + // "frame ∈ instance ∈ module" hierarchy described in the core dump spec + // until we move core dump generation into the runtime. So for now + // instanceidx will be 0 for all frames + let instanceidx = 0; stacksection.frame( + instanceidx, f.func_index(), u32::try_from(f.func_offset().unwrap_or(0)).unwrap(), // We don't currently have access to locals/stack values @@ -842,8 +853,12 @@ fn generate_coredump(err: &anyhow::Error, source_name: &str, coredump_path: &str [], ); } + for name in modulenames { + coremodules.module(name); + } let mut module = wasm_encoder::Module::new(); module.section(&coredump); + module.section(&coremodules); module.section(&stacksection); let mut f = File::create(coredump_path) From 13b583158c5b01a4c973995bcd0535cdec4aed76 Mon Sep 17 00:00:00 2001 From: Rainy Sinclair <844493+itsrainy@users.noreply.github.com> Date: Tue, 16 May 2023 21:20:55 -0400 Subject: [PATCH 2/3] cargo vet --- supply-chain/imports.lock | 49 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/supply-chain/imports.lock b/supply-chain/imports.lock index 89bcb5356565..76f004fe2b6d 100644 --- a/supply-chain/imports.lock +++ b/supply-chain/imports.lock @@ -57,6 +57,13 @@ user-id = 1 user-login = "alexcrichton" user-name = "Alex Crichton" +[[publisher.wasm-encoder]] +version = "0.27.0" +when = "2023-05-15" +user-id = 1 +user-login = "alexcrichton" +user-name = "Alex Crichton" + [[publisher.wasm-metadata]] version = "0.5.0" when = "2023-04-27" @@ -78,6 +85,13 @@ user-id = 1 user-login = "alexcrichton" user-name = "Alex Crichton" +[[publisher.wasm-mutate]] +version = "0.2.25" +when = "2023-05-15" +user-id = 1 +user-login = "alexcrichton" +user-name = "Alex Crichton" + [[publisher.wasm-smith]] version = "0.12.6" when = "2023-04-13" @@ -92,6 +106,13 @@ user-id = 1 user-login = "alexcrichton" user-name = "Alex Crichton" +[[publisher.wasm-smith]] +version = "0.12.8" +when = "2023-05-15" +user-id = 1 +user-login = "alexcrichton" +user-name = "Alex Crichton" + [[publisher.wasmparser]] version = "0.103.0" when = "2023-04-13" @@ -106,6 +127,13 @@ user-id = 1 user-login = "alexcrichton" user-name = "Alex Crichton" +[[publisher.wasmparser]] +version = "0.105.0" +when = "2023-05-15" +user-id = 1 +user-login = "alexcrichton" +user-name = "Alex Crichton" + [[publisher.wasmprinter]] version = "0.2.55" when = "2023-04-13" @@ -120,6 +148,13 @@ user-id = 1 user-login = "alexcrichton" user-name = "Alex Crichton" +[[publisher.wasmprinter]] +version = "0.2.57" +when = "2023-05-15" +user-id = 1 +user-login = "alexcrichton" +user-name = "Alex Crichton" + [[publisher.wast]] version = "56.0.0" when = "2023-04-13" @@ -134,6 +169,13 @@ user-id = 1 user-login = "alexcrichton" user-name = "Alex Crichton" +[[publisher.wast]] +version = "58.0.0" +when = "2023-05-15" +user-id = 1 +user-login = "alexcrichton" +user-name = "Alex Crichton" + [[publisher.wat]] version = "1.0.62" when = "2023-04-13" @@ -148,6 +190,13 @@ user-id = 1 user-login = "alexcrichton" user-name = "Alex Crichton" +[[publisher.wat]] +version = "1.0.64" +when = "2023-05-15" +user-id = 1 +user-login = "alexcrichton" +user-name = "Alex Crichton" + [[publisher.wit-bindgen]] version = "0.6.0" when = "2023-04-27" From 0b3b6c51b67cb62e023eb7edb6e62e40adc232c2 Mon Sep 17 00:00:00 2001 From: Rainy Sinclair <844493+itsrainy@users.noreply.github.com> Date: Tue, 16 May 2023 21:31:36 -0400 Subject: [PATCH 3/3] address review comments --- crates/wasmtime/src/engine/serialization.rs | 3 ++- src/commands/run.rs | 8 -------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/crates/wasmtime/src/engine/serialization.rs b/crates/wasmtime/src/engine/serialization.rs index 18bcadc5c04f..f3093bafcaee 100644 --- a/crates/wasmtime/src/engine/serialization.rs +++ b/crates/wasmtime/src/engine/serialization.rs @@ -188,18 +188,19 @@ impl Metadata { extended_const, memory_control, function_references, + gc, // Always on; we don't currently have knobs for these. mutable_global: _, saturating_float_to_int: _, sign_extension: _, floats: _, - gc: _, } = engine.config().features; assert!(!memory_control); assert!(!tail_call); assert!(!function_references); + assert!(!gc); Metadata { target: engine.compiler().triple().to_string(), diff --git a/src/commands/run.rs b/src/commands/run.rs index f8b43ee36d23..95c5fc43ef0b 100644 --- a/src/commands/run.rs +++ b/src/commands/run.rs @@ -832,12 +832,8 @@ fn generate_coredump(err: &anyhow::Error, source_name: &str, coredump_path: &str .ok_or_else(|| anyhow!("no wasm backtrace found to generate coredump with"))?; let coredump = wasm_encoder::CoreDumpSection::new(source_name); - let mut coremodules = wasm_encoder::CoreDumpModulesSection::new(); let mut stacksection = wasm_encoder::CoreDumpStackSection::new("main"); - let mut modulenames = std::collections::HashSet::new(); for f in bt.frames() { - modulenames.insert(f.module_name().unwrap_or("")); - // We don't have the information at this point to map frames to // individual instances of a module, so we won't be able to create the // "frame ∈ instance ∈ module" hierarchy described in the core dump spec @@ -853,12 +849,8 @@ fn generate_coredump(err: &anyhow::Error, source_name: &str, coredump_path: &str [], ); } - for name in modulenames { - coremodules.module(name); - } let mut module = wasm_encoder::Module::new(); module.section(&coredump); - module.section(&coremodules); module.section(&stacksection); let mut f = File::create(coredump_path)