From b79eccb00e9e7fa86d7d08e31823c92dd65fae65 Mon Sep 17 00:00:00 2001 From: Ben Brandt Date: Wed, 4 Sep 2024 23:52:06 +0200 Subject: [PATCH 1/2] Update deps --- Cargo.lock | 104 ++++++++++++++++++++++------------------------------- Cargo.toml | 13 ++++--- src/lib.rs | 63 ++++++++++++++++++-------------- 3 files changed, 86 insertions(+), 94 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bfd288d..4b296a6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -16,15 +16,15 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.81" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0952808a6c2afd1aa8947271f3a60f1a6763c7b912d210184c5149b5cf147247" +checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" [[package]] name = "async-trait" -version = "0.1.78" +version = "0.1.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "461abc97219de0eaaf81fe3ef974a540158f3d079c2ab200f891f1a2ef201e85" +checksum = "a27b8a3a6e1a44fa4c8baf1f653e4172e81486d4941f2237e20dc2d0cf4ddff1" dependencies = [ "proc-macro2", "quote", @@ -33,15 +33,15 @@ dependencies = [ [[package]] name = "autocfg" -version = "1.1.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "bitflags" -version = "2.4.2" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" [[package]] name = "cfg-if" @@ -57,8 +57,8 @@ dependencies = [ "async-trait", "futures", "wasm-convert", - "wasm-encoder 0.209.1", - "wasmparser 0.209.1", + "wasm-encoder", + "wasmparser", ] [[package]] @@ -158,9 +158,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.14.3" +version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" dependencies = [ "ahash", "serde", @@ -168,9 +168,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.2.5" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b0b929d511467233429c45a44ac1dcaa21ba0f5ba11e4879e6ed28ddb4f9df4" +checksum = "68b900aa2f7301e21c36462b170ee99994de34dff39a4a6a528e80e7376d07e5" dependencies = [ "equivalent", "hashbrown", @@ -185,9 +185,9 @@ checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" [[package]] name = "memchr" -version = "2.7.1" +version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "once_cell" @@ -197,9 +197,9 @@ checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "pin-project-lite" -version = "0.2.13" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" +checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" [[package]] name = "pin-utils" @@ -209,42 +209,42 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "proc-macro2" -version = "1.0.79" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.35" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" +checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" dependencies = [ "proc-macro2", ] [[package]] name = "semver" -version = "1.0.22" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92d43fe69e652f3df9bdc2b85b2854a0825b86e4fb76bc44d945137d053639ca" +checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" [[package]] name = "serde" -version = "1.0.203" +version = "1.0.209" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" +checksum = "99fce0ffe7310761ca6bf9faf5115afbc19688edd00171d81b1bb1b116c63e09" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.203" +version = "1.0.209" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" +checksum = "a5831b979fd7b5439637af1752d535ff49f4860c0f341d1baeb6faf0f4242170" dependencies = [ "proc-macro2", "quote", @@ -262,9 +262,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.53" +version = "2.0.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7383cd0e49fff4b6b90ca5670bfd3e9d6a733b3f90c686605aa7eec8c4996032" +checksum = "9f35bcdf61fd8e7be6caf75f429fdca8beb3ed76584befb503b1569faee373ed" dependencies = [ "proc-macro2", "quote", @@ -279,51 +279,33 @@ checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "version_check" -version = "0.9.4" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" [[package]] name = "wasm-convert" version = "0.1.0" -source = "git+https://github.com/dicej/wasm-convert#f4cb9b224b3e3f7799d84c031075982babbbc81d" +source = "git+https://github.com/benbrandt/wasm-convert?rev=4c5a4b58ce92185a8f8d24fdc297c7f2df664ce2#4c5a4b58ce92185a8f8d24fdc297c7f2df664ce2" dependencies = [ - "wasm-encoder 0.201.0", - "wasmparser 0.201.0", + "wasm-encoder", + "wasmparser", ] [[package]] name = "wasm-encoder" -version = "0.201.0" -source = "git+https://github.com/dicej/wasm-tools?branch=adapt-world-imports#a3e308dbe3b1555c7873ce199adf81e76ea01224" -dependencies = [ - "leb128", -] - -[[package]] -name = "wasm-encoder" -version = "0.209.1" +version = "0.216.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b4a05336882dae732ce6bd48b7e11fe597293cb72c13da4f35d7d5f8d53b2a7" +checksum = "04c23aebea22c8a75833ae08ed31ccc020835b12a41999e58c31464271b94a88" dependencies = [ "leb128", ] [[package]] name = "wasmparser" -version = "0.201.0" -source = "git+https://github.com/dicej/wasm-tools?branch=adapt-world-imports#a3e308dbe3b1555c7873ce199adf81e76ea01224" -dependencies = [ - "bitflags", - "indexmap", - "semver", -] - -[[package]] -name = "wasmparser" -version = "0.209.1" +version = "0.216.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07035cc9a9b41e62d3bb3a3815a66ab87c993c06fe1cf6b2a3f2a18499d937db" +checksum = "bcdee6bea3619d311fb4b299721e89a986c3470f804b6d534340e412589028e3" dependencies = [ "ahash", "bitflags", @@ -335,18 +317,18 @@ dependencies = [ [[package]] name = "zerocopy" -version = "0.7.34" +version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae87e3fcd617500e5d106f0380cf7b77f3c6092aae37191433159dda23cfb087" +checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.7.34" +version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15e934569e47891f7d9411f1a451d947a60e000ab3bd24fbb970f000387d1b3b" +checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index 26d8862..578a353 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,10 +4,9 @@ version = "0.1.0" edition = "2021" [dependencies] -anyhow = "1.0.71" -wasm-convert = { git = "https://github.com/dicej/wasm-convert" } -async-trait = "0.1.68" -futures = "0.3.28" -wasm-encoder = "0.209.1" -wasmparser = "0.209.1" - +anyhow = "1.0.86" +wasm-convert = { git = "https://github.com/benbrandt/wasm-convert", rev = "4c5a4b58ce92185a8f8d24fdc297c7f2df664ce2" } +async-trait = "0.1.82" +futures = "0.3.30" +wasm-encoder = "0.216.0" +wasmparser = "0.216.0" diff --git a/src/lib.rs b/src/lib.rs index 21f4e9f..ff5d5b4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -8,13 +8,15 @@ use { collections::{hash_map::Entry, HashMap}, convert, iter, }, - wasm_convert::{IntoConstExpr, IntoExportKind, IntoGlobalType, IntoMemoryType}, + wasm_convert::{ + IntoConstExpr, IntoEntityType, IntoExportKind, IntoGlobalType, IntoMemoryType, IntoValType, + }, wasm_encoder::{ Alias, CanonicalFunctionSection, CanonicalOption, CodeSection, Component, ComponentAliasSection, ComponentExportKind, ComponentExportSection, ComponentTypeSection, ComponentValType, ConstExpr, DataSection, ExportKind, ExportSection, Function, FunctionSection, GlobalSection, GlobalType, ImportSection, InstanceSection, - Instruction as Ins, MemArg, MemorySection, MemoryType, Module, ModuleArg, ModuleSection, + Instruction as Ins, MemArg, MemorySection, Module, ModuleArg, ModuleSection, NestedComponentSection, PrimitiveValType, RawSection, TypeSection, ValType, }, wasmparser::{ @@ -116,7 +118,9 @@ pub async fn initialize_staged( let payload = payload?; let section = payload.as_section(); match payload { - Payload::ComponentSection { unchecked_range, .. } => { + Payload::ComponentSection { + unchecked_range, .. + } => { let mut subcomponent = Component::new(); while let Some(payload) = parser.next() { let payload = payload?; @@ -133,7 +137,9 @@ pub async fn initialize_staged( instrumented_component.section(&NestedComponentSection(&subcomponent)); } - Payload::ModuleSection { unchecked_range, .. } => { + Payload::ModuleSection { + unchecked_range, .. + } => { let module_index = get_and_increment(&mut module_count); let mut global_types = Vec::new(); let mut empty = HashMap::new(); @@ -162,11 +168,7 @@ pub async fn initialize_staged( if memory_info.is_some() { bail!("only one memory allowed per component"); } - memory_info = Some(( - module_index, - "memory", - MemoryType::from(IntoMemoryType(memory?)), - )); + memory_info = Some((module_index, "memory", memory?)); } copy_module_section( section, @@ -178,14 +180,14 @@ pub async fn initialize_staged( Payload::GlobalSection(reader) => { for global in reader { let global = global?; - let ty = GlobalType::from(IntoGlobalType(global.ty)); + let ty = global.ty; global_types.push(ty); let global_index = get_and_increment(&mut global_count); if global.ty.mutable { globals_to_export .entry(module_index) .or_default() - .insert(global_index, (None, ty.val_type)); + .insert(global_index, (None, ty.content_type)); } } copy_module_section( @@ -382,20 +384,21 @@ pub async fn initialize_staged( let mut stack_pointers = Vec::new(); for (module_index, globals_to_export) in &globals_to_export { for (global_index, (name, ty)) in globals_to_export { + let ty = IntoValType(*ty).into(); let offset = types.len(); - types.function([], [*ty]); + types.function([], [ty]); let name = name.as_deref().unwrap(); imports.import( &module_index.to_string(), name, GlobalType { - val_type: *ty, + val_type: ty, mutable: true, - shared: false, + shared: false, }, ); if name == "__stack_pointer" { - stack_pointers.push((offset, *ty)); + stack_pointers.push((offset, ty)); } functions.function(offset); let mut function = Function::new([]); @@ -445,11 +448,15 @@ pub async fn initialize_staged( ), }; let offset = types.len(); - types.function([], [ValType::I32]); - imports.import(&module_index.to_string(), name, ty); + types.function([], [wasm_encoder::ValType::I32]); + imports.import( + &module_index.to_string(), + name, + IntoEntityType(TypeRef::Memory(ty)), + ); functions.function(offset); - let mut function = Function::new([(1, ValType::I32)]); + let mut function = Function::new([(1, wasm_encoder::ValType::I32)]); function.instruction(&Ins::GlobalGet(stack_pointer)); function.instruction(&Ins::I32Const(8)); function.instruction(&Ins::I32Sub); @@ -537,32 +544,32 @@ pub async fn initialize_staged( my_global_values.insert( *global_index, match ty { - ValType::I32 => ConstExpr::i32_const( + wasmparser::ValType::I32 => ConstExpr::i32_const( invoker .call_s32(name) .await .with_context(|| name.to_owned())?, ), - ValType::I64 => ConstExpr::i64_const( + wasmparser::ValType::I64 => ConstExpr::i64_const( invoker .call_s64(name) .await .with_context(|| name.to_owned())?, ), - ValType::F32 => ConstExpr::f32_const( + wasmparser::ValType::F32 => ConstExpr::f32_const( invoker .call_float32(name) .await .with_context(|| name.to_owned())?, ), - ValType::F64 => ConstExpr::f64_const( + wasmparser::ValType::F64 => ConstExpr::f64_const( invoker .call_float64(name) .await .with_context(|| name.to_owned())?, ), - ValType::V128 => bail!("V128 not yet supported"), - ValType::Ref(_) => bail!("reference types not supported"), + wasmparser::ValType::V128 => bail!("V128 not yet supported"), + wasmparser::ValType::Ref(_) => bail!("reference types not supported"), }, ); } @@ -589,7 +596,9 @@ pub async fn initialize_staged( let payload = payload?; let section = payload.as_section(); match payload { - Payload::ComponentSection { unchecked_range, .. } => { + Payload::ComponentSection { + unchecked_range, .. + } => { let mut subcomponent = Component::new(); while let Some(payload) = parser.next() { let payload = payload?; @@ -606,7 +615,9 @@ pub async fn initialize_staged( initialized_component.section(&NestedComponentSection(&subcomponent)); } - Payload::ModuleSection { unchecked_range, .. } => { + Payload::ModuleSection { + unchecked_range, .. + } => { let module_index = map_module_index(get_and_increment(&mut module_count)); let mut global_values = global_values.remove(&module_index); let mut initialized_module = Module::new(); From 92557a9c4297219bac17bfe6a2f0c07922b9c1bb Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Fri, 6 Sep 2024 14:36:43 -0600 Subject: [PATCH 2/2] switch back to upstream `wasm-convert` dep Signed-off-by: Joel Dice --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4b296a6..7d013f9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -286,7 +286,7 @@ checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" [[package]] name = "wasm-convert" version = "0.1.0" -source = "git+https://github.com/benbrandt/wasm-convert?rev=4c5a4b58ce92185a8f8d24fdc297c7f2df664ce2#4c5a4b58ce92185a8f8d24fdc297c7f2df664ce2" +source = "git+https://github.com/dicej/wasm-convert?rev=afbec48b#afbec48bf992946d34ead239c9be19a9d61772f2" dependencies = [ "wasm-encoder", "wasmparser", diff --git a/Cargo.toml b/Cargo.toml index 578a353..5ec3b77 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,7 @@ edition = "2021" [dependencies] anyhow = "1.0.86" -wasm-convert = { git = "https://github.com/benbrandt/wasm-convert", rev = "4c5a4b58ce92185a8f8d24fdc297c7f2df664ce2" } +wasm-convert = { git = "https://github.com/dicej/wasm-convert", rev = "afbec48b" } async-trait = "0.1.82" futures = "0.3.30" wasm-encoder = "0.216.0"