From dd28e21996d5251b371cbb699ed3bea45c12be75 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Fri, 31 Oct 2025 16:45:35 -0600 Subject: [PATCH] handle more canon functions; update wasm-tools again; etc. This also enables all Wasm features supported by `wasmparser` when validating. Signed-off-by: Joel Dice --- Cargo.lock | 69 ++++++++++++++++++++++++++++++++++++++------ transform/src/lib.rs | 21 ++++++++++++-- 2 files changed, 78 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7f3c1f1..73ecf13 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -407,9 +407,9 @@ dependencies = [ "anyhow", "async-trait", "futures", - "wasm-encoder 0.238.1", - "wasm-metadata", - "wasmparser 0.238.1", + "wasm-encoder 0.240.0", + "wasm-metadata 0.240.0", + "wasmparser 0.240.0", ] [[package]] @@ -423,7 +423,7 @@ dependencies = [ "tokio", "wasmtime", "wasmtime-wasi", - "wat", + "wat 1.240.0", ] [[package]] @@ -2129,11 +2129,31 @@ dependencies = [ "wasmparser 0.238.1", ] +[[package]] +name = "wasm-encoder" +version = "0.240.0" +source = "git+https://github.com/bytecodealliance/wasm-tools?rev=b1d8ff59#b1d8ff591bcb8c052b54c3c17495bbbef401897c" +dependencies = [ + "leb128fmt", + "wasmparser 0.240.0", +] + [[package]] name = "wasm-metadata" version = "0.238.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "00094573b000c92134f2ef0f8afa4f6f892de37e78442988c946243a8c44364e" +dependencies = [ + "anyhow", + "indexmap", + "wasm-encoder 0.238.1", + "wasmparser 0.238.1", +] + +[[package]] +name = "wasm-metadata" +version = "0.240.0" +source = "git+https://github.com/bytecodealliance/wasm-tools?rev=b1d8ff59#b1d8ff591bcb8c052b54c3c17495bbbef401897c" dependencies = [ "anyhow", "auditable-serde", @@ -2144,8 +2164,8 @@ dependencies = [ "serde_json", "spdx", "url", - "wasm-encoder 0.238.1", - "wasmparser 0.238.1", + "wasm-encoder 0.240.0", + "wasmparser 0.240.0", ] [[package]] @@ -2166,6 +2186,17 @@ name = "wasmparser" version = "0.238.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fa99c8328024423875ae4a55345cfde8f0371327fb2d0f33b0f52a06fc44408" +dependencies = [ + "bitflags", + "hashbrown", + "indexmap", + "semver", +] + +[[package]] +name = "wasmparser" +version = "0.240.0" +source = "git+https://github.com/bytecodealliance/wasm-tools?rev=b1d8ff59#b1d8ff591bcb8c052b54c3c17495bbbef401897c" dependencies = [ "bitflags", "hashbrown", @@ -2236,7 +2267,7 @@ dependencies = [ "wasmtime-internal-unwinder", "wasmtime-internal-versioned-export-macros", "wasmtime-internal-winch", - "wat", + "wat 1.238.1", "windows-sys 0.60.2", ] @@ -2519,6 +2550,18 @@ dependencies = [ "wasm-encoder 0.238.1", ] +[[package]] +name = "wast" +version = "240.0.0" +source = "git+https://github.com/bytecodealliance/wasm-tools?rev=b1d8ff59#b1d8ff591bcb8c052b54c3c17495bbbef401897c" +dependencies = [ + "bumpalo", + "leb128fmt", + "memchr", + "unicode-width", + "wasm-encoder 0.240.0", +] + [[package]] name = "wat" version = "1.238.1" @@ -2528,6 +2571,14 @@ dependencies = [ "wast 238.0.1", ] +[[package]] +name = "wat" +version = "1.240.0" +source = "git+https://github.com/bytecodealliance/wasm-tools?rev=b1d8ff59#b1d8ff591bcb8c052b54c3c17495bbbef401897c" +dependencies = [ + "wast 240.0.0", +] + [[package]] name = "wiggle" version = "36.0.2" @@ -2896,7 +2947,7 @@ dependencies = [ "indexmap", "prettyplease", "syn", - "wasm-metadata", + "wasm-metadata 0.238.1", "wit-bindgen-core", "wit-component", ] @@ -2930,7 +2981,7 @@ dependencies = [ "serde_derive", "serde_json", "wasm-encoder 0.238.1", - "wasm-metadata", + "wasm-metadata 0.238.1", "wasmparser 0.238.1", "wit-parser 0.238.1", ] diff --git a/transform/src/lib.rs b/transform/src/lib.rs index f88a924..cf0fd4c 100644 --- a/transform/src/lib.rs +++ b/transform/src/lib.rs @@ -20,7 +20,7 @@ use { }, wasmparser::{ CanonicalFunction, ComponentAlias, ComponentExternalKind, ComponentTypeRef, ExternalKind, - Instance, Operator, Parser, Payload, TypeRef, Validator, + Instance, Operator, Parser, Payload, TypeRef, Validator, WasmFeatures, }, }; @@ -72,7 +72,7 @@ pub async fn initialize_staged( // component. let (instrumented_component, instrumentation) = instrument(component_stage1)?; - Validator::new().validate_all(&instrumented_component)?; + Validator::new_with_features(WasmFeatures::all()).validate_all(&instrumented_component)?; // A component runtime will instantiate the component and run its component init function. let mut invoker = initialize(instrumented_component).await?; @@ -510,6 +510,7 @@ fn instrument(component_stage1: &[u8]) -> Result<(Vec, Instrumentation)> { | CanonicalFunction::BackpressureInc | CanonicalFunction::BackpressureDec | CanonicalFunction::TaskCancel + | CanonicalFunction::TaskReturn { .. } | CanonicalFunction::ContextGet(_) | CanonicalFunction::ContextSet(_) | CanonicalFunction::ThreadYield { .. } @@ -519,6 +520,20 @@ fn instrument(component_stage1: &[u8]) -> Result<(Vec, Instrumentation)> { | CanonicalFunction::WaitableSetPoll { .. } | CanonicalFunction::WaitableSetDrop | CanonicalFunction::WaitableJoin + | CanonicalFunction::StreamNew { .. } + | CanonicalFunction::StreamRead { .. } + | CanonicalFunction::StreamWrite { .. } + | CanonicalFunction::StreamCancelRead { .. } + | CanonicalFunction::StreamCancelWrite { .. } + | CanonicalFunction::StreamDropReadable { .. } + | CanonicalFunction::StreamDropWritable { .. } + | CanonicalFunction::FutureNew { .. } + | CanonicalFunction::FutureRead { .. } + | CanonicalFunction::FutureWrite { .. } + | CanonicalFunction::FutureCancelRead { .. } + | CanonicalFunction::FutureCancelWrite { .. } + | CanonicalFunction::FutureDropReadable { .. } + | CanonicalFunction::FutureDropWritable { .. } | CanonicalFunction::ErrorContextNew { .. } | CanonicalFunction::ErrorContextDebugMessage { .. } | CanonicalFunction::ErrorContextDrop => { @@ -873,7 +888,7 @@ fn apply( let initialized_component = add.to_wasm(&initialized_component)?; - Validator::new().validate_all(&initialized_component)?; + Validator::new_with_features(WasmFeatures::all()).validate_all(&initialized_component)?; Ok(initialized_component) }