From 7d1182574dd6478e45ad912baedbb96cccdfc033 Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Thu, 12 Nov 2020 13:53:26 -0800 Subject: [PATCH 001/212] Initial, empty commit --- crates/wizer/.gitignore | 2 ++ crates/wizer/Cargo.toml | 9 +++++++++ crates/wizer/src/bin/wizer.rs | 3 +++ crates/wizer/src/lib.rs | 7 +++++++ 4 files changed, 21 insertions(+) create mode 100644 crates/wizer/.gitignore create mode 100644 crates/wizer/Cargo.toml create mode 100644 crates/wizer/src/bin/wizer.rs create mode 100644 crates/wizer/src/lib.rs diff --git a/crates/wizer/.gitignore b/crates/wizer/.gitignore new file mode 100644 index 000000000000..96ef6c0b944e --- /dev/null +++ b/crates/wizer/.gitignore @@ -0,0 +1,2 @@ +/target +Cargo.lock diff --git a/crates/wizer/Cargo.toml b/crates/wizer/Cargo.toml new file mode 100644 index 000000000000..6afedd062285 --- /dev/null +++ b/crates/wizer/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "wizer" +version = "0.1.0" +authors = ["Nick Fitzgerald "] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/crates/wizer/src/bin/wizer.rs b/crates/wizer/src/bin/wizer.rs new file mode 100644 index 000000000000..0672e510676c --- /dev/null +++ b/crates/wizer/src/bin/wizer.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, World!"); +} diff --git a/crates/wizer/src/lib.rs b/crates/wizer/src/lib.rs new file mode 100644 index 000000000000..31e1bb209f98 --- /dev/null +++ b/crates/wizer/src/lib.rs @@ -0,0 +1,7 @@ +#[cfg(test)] +mod tests { + #[test] + fn it_works() { + assert_eq!(2 + 2, 4); + } +} From c4c88fefed6b1d931dca84661a3335f117215d0a Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Thu, 12 Nov 2020 16:43:08 -0800 Subject: [PATCH 002/212] Wow, it works for simple Wasm programs! --- crates/wizer/Cargo.toml | 15 + crates/wizer/src/bin/wizer.rs | 60 ++- crates/wizer/src/lib.rs | 821 +++++++++++++++++++++++++++++++++- crates/wizer/tests/tests.rs | 57 +++ 4 files changed, 946 insertions(+), 7 deletions(-) create mode 100644 crates/wizer/tests/tests.rs diff --git a/crates/wizer/Cargo.toml b/crates/wizer/Cargo.toml index 6afedd062285..33d2f71a2f70 100644 --- a/crates/wizer/Cargo.toml +++ b/crates/wizer/Cargo.toml @@ -6,4 +6,19 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +[[bin]] +name = "wizer" +required-features = ["env_logger", "structopt"] + [dependencies] +wasmtime = { path = "../wasmtime/crates/wasmtime" } +wasm-encoder = { path = "../wasm-tools/crates/wasm-encoder" } +structopt = { version = "0.3.20", optional = true } +anyhow = "1.0.34" +wasmparser = "0.68.0" +log = "0.4.11" +env_logger = { version = "0.8.1", optional = true } + +[dev-dependencies] +wat = "1.0.28" +env_logger = "0.8.2" diff --git a/crates/wizer/src/bin/wizer.rs b/crates/wizer/src/bin/wizer.rs index 0672e510676c..d5cb411af776 100644 --- a/crates/wizer/src/bin/wizer.rs +++ b/crates/wizer/src/bin/wizer.rs @@ -1,3 +1,59 @@ -fn main() { - println!("Hello, World!"); +use anyhow::Context; +use std::fs; +use std::io::{self, BufRead, Write}; +use std::path::PathBuf; +use structopt::StructOpt; +use wizer::Wizer; + +#[derive(StructOpt)] +pub struct Options { + /// The input Wasm module's file path. + /// + /// If not specified, then `stdin` is used. + #[structopt(parse(from_os_str))] + input: Option, + + /// The file path to write the output Wasm module to. + /// + /// If not specified, then `stdout` is used. + #[structopt(short = "o", parse(from_os_str))] + output: Option, + + #[structopt(flatten)] + wizer: Wizer, +} + +fn main() -> anyhow::Result<()> { + env_logger::init(); + let options = Options::from_args(); + + let stdin = io::stdin(); + let mut input: Box = if let Some(input) = options.input.as_ref() { + Box::new(io::BufReader::new( + fs::File::open(input).context("failed to open input file")?, + )) + } else { + Box::new(stdin.lock()) + }; + + let mut output: Box = if let Some(output) = options.output.as_ref() { + Box::new(io::BufWriter::new( + fs::File::create(output).context("failed to create output file")?, + )) + } else { + Box::new(io::stdout()) + }; + + let mut input_wasm = vec![]; + input + .read_to_end(&mut input_wasm) + .context("failed to read input Wasm module")?; + + let output_wasm = options.wizer.run(&input_wasm)?; + + output + .write_all(&output_wasm) + .context("failed to write to output")?; + + Ok(()) } diff --git a/crates/wizer/src/lib.rs b/crates/wizer/src/lib.rs index 31e1bb209f98..8d8e0fb1554c 100644 --- a/crates/wizer/src/lib.rs +++ b/crates/wizer/src/lib.rs @@ -1,7 +1,818 @@ -#[cfg(test)] -mod tests { - #[test] - fn it_works() { - assert_eq!(2 + 2, 4); +//! TODO FITZGEN + +#![deny(missing_docs)] + +use anyhow::Context; +use std::convert::TryFrom; +use structopt::StructOpt; + +/// Wizer: the WebAssembly initializer. +/// +/// Don't wait for your Wasm module to initialize itself, pre-initialize it! +/// Wizer instantiates your WebAssembly module, executes its initialization +/// function, and then serializes the instance's initialized state out into a +/// new WebAssembly module. Now you can use this new, pre-initialized +/// WebAssembly module to hit the ground running, without making your users wait +/// for that first-time set up code to complete. +/// +/// ## Caveats +/// +/// * The initialization function may not call any imported functions. Doing so +/// will trigger a trap and `wizer` will exit. +/// +/// * The Wasm module may not import globals, tables, or memories. +/// +/// * Reference types are not supported yet. This is tricky because it would +/// allow the Wasm module to mutate tables, and we would need to be able to +/// diff the initial table state with the new table state, but funcrefs and +/// externrefs aren't comparable in the Wasm spec, which makes diffing +/// problematic. +#[cfg_attr(feature = "structopt", derive(StructOpt))] +#[derive(Clone, Debug)] +pub struct Wizer { + /// The Wasm export name of the function that should be executed to + /// initialize the Wasm module. + #[structopt(short = "f", long = "init-func", default_value = "wizer.initialize")] + init_func: String, +} + +fn translate_val_type(ty: wasmparser::Type) -> wasm_encoder::ValType { + use wasm_encoder::ValType; + use wasmparser::Type::*; + match ty { + I32 => ValType::I32, + I64 => ValType::I64, + F32 => ValType::F32, + F64 => ValType::F64, + V128 | FuncRef | ExternRef | ExnRef => panic!("not supported"), + Func | EmptyBlockType => unreachable!(), + } +} + +fn translate_limits(limits: wasmparser::ResizableLimits) -> wasm_encoder::Limits { + wasm_encoder::Limits { + min: limits.initial, + max: limits.maximum, + } +} + +fn translate_table_type(ty: wasmparser::TableType) -> anyhow::Result { + anyhow::ensure!( + ty.element_type == wasmparser::Type::FuncRef, + "only funcref tables are supported" + ); + Ok(wasm_encoder::TableType { + limits: translate_limits(ty.limits), + }) +} + +fn translate_memory_type(ty: wasmparser::MemoryType) -> anyhow::Result { + match ty { + wasmparser::MemoryType::M32 { limits, shared } => { + anyhow::ensure!(!shared, "shared memories are not supported yet"); + Ok(wasm_encoder::MemoryType { + limits: translate_limits(limits), + }) + } + wasmparser::MemoryType::M64 { .. } => { + anyhow::bail!("64-bit memories not supported yet") + } + } +} + +fn translate_global_type(ty: wasmparser::GlobalType) -> wasm_encoder::GlobalType { + wasm_encoder::GlobalType { + val_type: translate_val_type(ty.content_type), + mutable: ty.mutable, + } +} + +fn translate_init_expr(expr: wasmparser::InitExpr) -> anyhow::Result { + let mut ops = expr.get_operators_reader(); + let init = match ops.read()? { + wasmparser::Operator::GlobalGet { global_index } => { + wasm_encoder::Instruction::GlobalGet(global_index) + } + wasmparser::Operator::I32Const { value } => wasm_encoder::Instruction::I32Const(value), + wasmparser::Operator::I64Const { value } => wasm_encoder::Instruction::I64Const(value), + wasmparser::Operator::F32Const { value } => { + wasm_encoder::Instruction::F32Const(f32::from_bits(value.bits())) + } + wasmparser::Operator::F64Const { value } => { + wasm_encoder::Instruction::F64Const(f64::from_bits(value.bits())) + } + _ => anyhow::bail!("unsupported init expr"), + }; + anyhow::ensure!( + matches!(ops.read()?, wasmparser::Operator::End), + "expected `end` instruction" + ); + ops.ensure_end()?; + Ok(init) +} + +impl Wizer { + /// Construct a new `Wizer` builder. + pub fn new() -> Self { + Wizer { + init_func: "wizer.initialize".into(), + } } + + /// The export name of the initializer function. + /// + /// Defaults to `"wizer.initialize"`. + pub fn init_func(&mut self, init_func: impl Into) -> &mut Self { + self.init_func = init_func.into(); + self + } + + /// Initialize the given Wasm, snapshot it, and return the serialized + /// snapshot as a new, pre-initialized Wasm module. + pub fn run(&self, wasm: &[u8]) -> anyhow::Result> { + // Make sure we're given valid Wasm from the get go. + self.wasm_validate(wasm)?; + + let wasm = self.prepare_input_wasm(wasm)?; + debug_assert!( + self.wasm_validate(&wasm).is_ok(), + "if the Wasm was originally valid, then our preparation step shouldn't invalidate it" + ); + + let store = wasmtime::Store::default(); + let module = wasmtime::Module::new(store.engine(), &wasm)?; + self.validate_init_func(&module)?; + let imports = self.dummy_imports(&store, &module)?; + let instance = wasmtime::Instance::new(&store, &module, &imports)?; + + self.initialize(&instance)?; + let diff = self.diff(&instance); + let initialized_wasm = self.rewrite(&wasm, &diff); + + Ok(initialized_wasm) + } + + fn wasm_features(&self) -> wasmparser::WasmFeatures { + wasmparser::WasmFeatures { + // Proposals that we support. + multi_memory: true, + multi_value: true, + + // Proposals that we should add support for. + reference_types: false, + module_linking: false, + simd: false, + threads: false, + tail_call: false, + bulk_memory: false, + memory64: false, + exceptions: false, + + // We will never want to enable this. + deterministic_only: false, + } + } + + fn wasm_validate(&self, wasm: &[u8]) -> anyhow::Result<()> { + log::debug!("Validating input Wasm"); + let mut validator = wasmparser::Validator::new(); + validator.wasm_features(self.wasm_features()); + validator.validate_all(wasm)?; + Ok(()) + } + + /// Rewrite the input Wasm with our own custom exports for all globals, and + /// memories. This way we can reflect on their values later on in the diff + /// phase. + /// + /// TODO: will have to also export tables once we support reference types. + fn prepare_input_wasm(&self, full_wasm: &[u8]) -> anyhow::Result> { + log::debug!("Preparing input Wasm"); + + let mut wasm = full_wasm; + let mut parser = wasmparser::Parser::new(0); + let mut module = wasm_encoder::Module::new(); + + // Count how many globals and memories we see in this module, so that we + // can export them all. + let mut memory_count = 0; + let mut global_count = 0; + + loop { + let (payload, consumed) = + match parser.parse(wasm, true).context("failed to parse Wasm")? { + wasmparser::Chunk::NeedMoreData(_) => anyhow::bail!("invalid Wasm module"), + wasmparser::Chunk::Parsed { payload, consumed } => (payload, consumed), + }; + wasm = &wasm[consumed..]; + + use wasmparser::Payload::*; + match payload { + Version { .. } => continue, + TypeSection(mut types) => { + let count = types.get_count(); + let mut types_encoder = wasm_encoder::TypeSection::new(); + for _ in 0..count { + match types.read()? { + wasmparser::TypeDef::Func(ft) => { + types_encoder.function( + ft.params.iter().copied().map(translate_val_type), + ft.returns.iter().copied().map(translate_val_type), + ); + } + wasmparser::TypeDef::Instance(_) | wasmparser::TypeDef::Module(_) => { + anyhow::bail!("module linking is not supported yet"); + } + } + } + module.section(&types_encoder); + } + ImportSection(mut imports) => { + let count = imports.get_count(); + let mut imports_encoder = wasm_encoder::ImportSection::new(); + for _ in 0..count { + let imp = imports.read()?; + imports_encoder.import( + imp.module, + imp.field.expect( + "should always be `Some` when module linking isn't enabled", + ), + match imp.ty { + wasmparser::ImportSectionEntryType::Function(ty) => { + wasm_encoder::ImportType::Function(ty) + } + wasmparser::ImportSectionEntryType::Table(ty) => { + translate_table_type(ty)?.into() + } + wasmparser::ImportSectionEntryType::Memory(ty) => { + memory_count += 1; + translate_memory_type(ty)?.into() + } + wasmparser::ImportSectionEntryType::Global(ty) => { + global_count += 1; + translate_global_type(ty).into() + } + wasmparser::ImportSectionEntryType::Module(_) + | wasmparser::ImportSectionEntryType::Instance(_) => { + anyhow::bail!("module linking is not supported yet") + } + wasmparser::ImportSectionEntryType::Event(_) => { + anyhow::bail!("exceptions are not supported yet") + } + }, + ); + } + module.section(&imports_encoder); + } + AliasSection(_) | InstanceSection(_) | ModuleSection(_) => { + anyhow::bail!("module linking is not supported yet") + } + FunctionSection(mut funcs) => { + let count = funcs.get_count(); + let mut funcs_encoder = wasm_encoder::FunctionSection::new(); + for _ in 0..count { + let ty_idx = funcs.read()?; + funcs_encoder.function(ty_idx); + } + module.section(&funcs_encoder); + } + TableSection(mut tables) => { + let count = tables.get_count(); + let mut tables_encoder = wasm_encoder::TableSection::new(); + for _ in 0..count { + let table_ty = tables.read()?; + tables_encoder.table(translate_table_type(table_ty)?); + } + module.section(&tables_encoder); + } + MemorySection(mut mems) => { + let count = mems.get_count(); + memory_count += count; + let mut mems_encoder = wasm_encoder::MemorySection::new(); + for _ in 0..count { + let mem_ty = mems.read()?; + mems_encoder.memory(translate_memory_type(mem_ty)?); + } + module.section(&mems_encoder); + } + GlobalSection(mut globals) => { + let count = globals.get_count(); + global_count += count; + let mut globals_encoder = wasm_encoder::GlobalSection::new(); + for _ in 0..count { + let global = globals.read()?; + globals_encoder.global( + translate_global_type(global.ty), + translate_init_expr(global.init_expr)?, + ); + } + module.section(&globals_encoder); + } + ExportSection(mut exports) => { + let count = exports.get_count(); + let mut exports_encoder = wasm_encoder::ExportSection::new(); + for _ in 0..count { + let export = exports.read()?; + exports_encoder.export( + export.field, + match export.kind { + wasmparser::ExternalKind::Function => { + wasm_encoder::Export::Function(export.index) + } + wasmparser::ExternalKind::Table => { + wasm_encoder::Export::Table(export.index) + } + wasmparser::ExternalKind::Memory => { + wasm_encoder::Export::Memory(export.index) + } + wasmparser::ExternalKind::Global => { + wasm_encoder::Export::Global(export.index) + } + wasmparser::ExternalKind::Type + | wasmparser::ExternalKind::Module + | wasmparser::ExternalKind::Instance => { + anyhow::bail!("module linking is not supported yet"); + } + wasmparser::ExternalKind::Event => { + anyhow::bail!("exceptions are not supported yet") + } + }, + ); + } + // Export all of the globals and memories under known names + // so we can manipulate them later. + for i in 0..global_count { + let name = format!("__wizer_global_{}", i); + exports_encoder.export(&name, wasm_encoder::Export::Global(i)); + } + for i in 0..memory_count { + let name = format!("__wizer_memory_{}", i); + exports_encoder.export(&name, wasm_encoder::Export::Memory(i)); + } + module.section(&exports_encoder); + } + StartSection { func, range: _ } => { + module.section(&wasm_encoder::StartSection { + function_index: func, + }); + } + ElementSection(mut elems) => { + let count = elems.get_count(); + let mut elems_encoder = wasm_encoder::ElementSection::new(); + for _ in 0..count { + let elem = elems.read()?; + match elem.kind { + wasmparser::ElementKind::Active { + table_index, + init_expr, + } => { + let init_expr = translate_init_expr(init_expr)?; + let mut items = elem.items.get_items_reader()?; + let mut funcs = Vec::with_capacity(items.get_count() as usize); + for _ in 0..items.get_count() { + funcs.push(match items.read()? { + wasmparser::ElementItem::Func(idx) => idx, + wasmparser::ElementItem::Null(_) => { + anyhow::bail!("reference types are not supported yet") + } + }); + } + elems_encoder.active(table_index, init_expr, funcs.drain(..)); + } + wasmparser::ElementKind::Passive + | wasmparser::ElementKind::Declared => { + anyhow::bail!("bulk memory is not supported yet") + } + } + } + module.section(&elems_encoder); + } + DataCountSection { .. } => anyhow::bail!("bulk memory is not supported yet"), + DataSection(mut data) => { + let count = data.get_count(); + let mut data_encoder = wasm_encoder::DataSection::new(); + for _ in 0..count { + let segment = data.read()?; + match segment.kind { + wasmparser::DataKind::Active { + memory_index, + init_expr, + } => { + let init_expr = translate_init_expr(init_expr)?; + data_encoder.active( + memory_index, + init_expr, + segment.data.iter().copied(), + ); + } + wasmparser::DataKind::Passive => { + anyhow::bail!("bulk memory is not supported yet") + } + } + } + module.section(&data_encoder); + } + CustomSection { + name, + data, + data_offset: _, + } => { + module.section(&wasm_encoder::CustomSection { name, data }); + } + CodeSectionStart { + range, + count: _, + size: _, + } => { + let data = &full_wasm[range.start..range.end]; + module.section(&wasm_encoder::RawSection { + id: wasm_encoder::SectionId::Code as u8, + data, + }); + } + CodeSectionEntry(_) => continue, + ModuleCodeSectionStart { .. } | ModuleCodeSectionEntry { .. } => { + anyhow::bail!("module linking is not supported yet") + } + UnknownSection { .. } => anyhow::bail!("unknown section"), + EventSection(_) => anyhow::bail!("exceptions are not supported yet"), + End => return Ok(module.finish()), + } + } + } + + /// Check that the module exports an initialization function, and that the + /// function has the correct type. + fn validate_init_func(&self, module: &wasmtime::Module) -> anyhow::Result<()> { + log::debug!("Validating the exported initialization function"); + match module.get_export(&self.init_func) { + Some(wasmtime::ExternType::Func(func_ty)) => { + if func_ty.params().len() != 0 || func_ty.results().len() != 0 { + anyhow::bail!( + "the Wasm module's `{}` function export does not have type `[] -> []`", + &self.init_func + ); + } + } + Some(_) => anyhow::bail!( + "the Wasm module's `{}` export is not a function", + &self.init_func + ), + None => anyhow::bail!( + "the Wasm module does not have a `{}` export", + &self.init_func + ), + } + Ok(()) + } + + /// Create dummy imports for instantiating the module. + fn dummy_imports( + &self, + store: &wasmtime::Store, + module: &wasmtime::Module, + ) -> anyhow::Result> { + log::debug!("Creating dummy imports"); + + let mut imports = Vec::with_capacity(module.imports().len()); + for imp in module.imports() { + imports.push(match imp.ty() { + wasmtime::ExternType::Func(func_ty) => { + let trap = wasmtime::Trap::new(format!( + "cannot call imports within the initialization function; attempted \ + to call `'{}' '{}'`", + imp.module(), + imp.name() + )); + wasmtime::Func::new(store, func_ty, move |_caller, _params, _results| { + Err(trap.clone()) + }) + .into() + } + wasmtime::ExternType::Global(_global_ty) => { + // The Wasm module could use `global.get` to read the + // imported value and branch on that or use `global.set` to + // update it if it's mutable. We can't create a trapping + // dummy value, like we can for functions, and we can't + // define a "global segment" to update any imported values + // (although I suppose we could inject a `start` function). + anyhow::bail!("cannot initialize Wasm modules that import globals") + } + wasmtime::ExternType::Table(_table_ty) => { + // TODO: we could import a dummy table full of trapping + // functions *if* the reference types proposal is not + // enabled, so there is no way the Wasm module can + // manipulate the table. This would allow initializing such + // modules, as long as the initialization didn't do any + // `call_indirect`s. + anyhow::bail!("cannot initialize Wasm modules that import tables") + } + wasmtime::ExternType::Memory(_memory_ty) => { + // The Wasm module could read the memory and branch on its + // contents, and since we can't create a dummy memory that + // matches the "real" import, nor can we create a trapping + // dummy version like we can for functions, we can't support + // imported memories. + anyhow::bail!("cannot initialize Wasm modules that import memories") + } + wasmtime::ExternType::Module(_) | wasmtime::ExternType::Instance(_) => { + anyhow::bail!("module linking is not supported yet") + } + }); + } + Ok(imports) + } + + /// Call the initialization function. + fn initialize(&self, instance: &wasmtime::Instance) -> anyhow::Result<()> { + log::debug!("Calling the initialization function"); + let init_func = instance + .get_func(&self.init_func) + .expect("checked by `validate_init_func`") + .get0::<()>() + .expect("checked by `validate_init_func`"); + init_func().with_context(|| format!("the `{}` function trapped", self.init_func))?; + Ok(()) + } + + /// Diff the given instance's globals, memories, and tables from the Wasm + /// defaults. + /// + /// TODO: when we support reference types, we will have to diff tables. + fn diff<'a>(&self, instance: &'a wasmtime::Instance) -> Diff<'a> { + // Get the initialized values of all globals. + log::debug!("Diffing global values"); + let mut globals = vec![]; + let mut global_index = 0; + loop { + let name = format!("__wizer_global_{}", global_index); + match instance.get_global(&name) { + None => break, + Some(global) => { + globals.push(global.get()); + global_index += 1; + } + } + } + + // Find and record non-zero regions of memory. + // + // TODO: This could be really slow for large memories. Instead, we + // should bring our own memories, protect the pages, and keep a table + // with a dirty bit for each page, so we can just diff the pages that + // actually got changed to non-zero values. + log::debug!("Diffing memories"); + let mut data_segments = vec![]; + let mut memory_index = 0; + loop { + let name = format!("__wizer_memory_{}", memory_index); + match instance.get_memory(&name) { + None => break, + Some(memory) => { + let memory: &'a [u8] = unsafe { + // Safe because no one else has a (potentially mutable) + // view to this memory and we know the memory will live + // as long as the instance is alive. + std::slice::from_raw_parts(memory.data_ptr(), memory.data_size()) + }; + + let mut i = 0; + loop { + // Search for the start of a non-zero region of + // memory. After the loop `i` will either be out of + // bounds, or be the start of the non-zero region. + while i < memory.len() && memory[i] == 0 { + i += 1; + continue; + } + + if i >= memory.len() { + break; + } + + // We found the start of a non-zero region, now + // search for its end. `j` will be the end of the + // non-zero region. + let mut j = i + 1; + while j < memory.len() && memory[j] != 0 { + j += 1; + } + + // Remember this non-zero region as a data segment + // for the pre-initialized module. + debug_assert!(memory[i..j].iter().all(|b| *b != 0)); + data_segments.push(( + memory_index, + u32::try_from(i).unwrap(), + &memory[i..j], + )); + + // Continue the search for the start of a non-zero + // region from the end of this non-zero region. + i = j + 1; + } + + memory_index += 1; + } + } + } + + Diff { + globals, + data_segments, + } + } + + fn rewrite(&self, full_wasm: &[u8], diff: &Diff) -> Vec { + log::debug!("Rewriting input Wasm to pre-initialized state"); + + let mut wasm = full_wasm; + let mut parser = wasmparser::Parser::new(0); + let mut module = wasm_encoder::Module::new(); + + // Encode the initialized data segments from the diff rather + // than the original, uninitialized data segments. + let mut added_data = false; + let mut add_data_section = |module: &mut wasm_encoder::Module| { + if added_data || diff.data_segments.is_empty() { + return; + } + let mut data_section = wasm_encoder::DataSection::new(); + for &(memory_index, offset, data) in &diff.data_segments { + data_section.active( + memory_index, + wasm_encoder::Instruction::I32Const(offset as i32), + data.iter().copied(), + ); + } + module.section(&data_section); + added_data = true; + }; + + loop { + let (payload, consumed) = match parser.parse(wasm, true).unwrap() { + wasmparser::Chunk::NeedMoreData(_) => unreachable!(), + wasmparser::Chunk::Parsed { payload, consumed } => (payload, consumed), + }; + wasm = &wasm[consumed..]; + + use wasmparser::Payload::*; + use wasmparser::SectionReader; + match payload { + Version { .. } => continue, + TypeSection(types) => { + module.section(&wasm_encoder::RawSection { + id: wasm_encoder::SectionId::Type as u8, + data: &full_wasm[types.range().start..types.range().end], + }); + } + ImportSection(imports) => { + module.section(&wasm_encoder::RawSection { + id: wasm_encoder::SectionId::Import as u8, + data: &full_wasm[imports.range().start..imports.range().end], + }); + } + AliasSection(_) | InstanceSection(_) | ModuleSection(_) => { + unreachable!() + } + FunctionSection(funcs) => { + module.section(&wasm_encoder::RawSection { + id: wasm_encoder::SectionId::Function as u8, + data: &full_wasm[funcs.range().start..funcs.range().end], + }); + } + TableSection(tables) => { + module.section(&wasm_encoder::RawSection { + id: wasm_encoder::SectionId::Table as u8, + data: &full_wasm[tables.range().start..tables.range().end], + }); + } + MemorySection(mems) => { + module.section(&wasm_encoder::RawSection { + id: wasm_encoder::SectionId::Memory as u8, + data: &full_wasm[mems.range().start..mems.range().end], + }); + } + GlobalSection(mut globals) => { + // Encode the initialized values from the diff, rather than + // the original values. + let mut globals_encoder = wasm_encoder::GlobalSection::new(); + for i in 0..globals.get_count() { + let global = globals.read().unwrap(); + globals_encoder.global( + translate_global_type(global.ty), + match diff.globals[i as usize] { + wasmtime::Val::I32(x) => wasm_encoder::Instruction::I32Const(x), + wasmtime::Val::I64(x) => wasm_encoder::Instruction::I64Const(x), + wasmtime::Val::F32(x) => { + wasm_encoder::Instruction::F32Const(f32::from_bits(x)) + } + wasmtime::Val::F64(x) => { + wasm_encoder::Instruction::F64Const(f64::from_bits(x)) + } + _ => unreachable!(), + }, + ); + } + module.section(&globals_encoder); + } + ExportSection(mut exports) => { + // Remove the `__wizer_*` exports we added during the + // preparation phase. + let count = exports.get_count(); + let mut exports_encoder = wasm_encoder::ExportSection::new(); + for _ in 0..count { + let export = exports.read().unwrap(); + if export.field.starts_with("__wizer_") { + continue; + } + exports_encoder.export( + export.field, + match export.kind { + wasmparser::ExternalKind::Function => { + wasm_encoder::Export::Function(export.index) + } + wasmparser::ExternalKind::Table => { + wasm_encoder::Export::Table(export.index) + } + wasmparser::ExternalKind::Memory => { + wasm_encoder::Export::Memory(export.index) + } + wasmparser::ExternalKind::Global => { + wasm_encoder::Export::Global(export.index) + } + wasmparser::ExternalKind::Type + | wasmparser::ExternalKind::Module + | wasmparser::ExternalKind::Instance + | wasmparser::ExternalKind::Event => { + unreachable!() + } + }, + ); + } + module.section(&exports_encoder); + } + StartSection { .. } => { + // Skip the `start` function -- it's already been run! + continue; + } + ElementSection(elems) => { + module.section(&wasm_encoder::RawSection { + id: wasm_encoder::SectionId::Element as u8, + data: &full_wasm[elems.range().start..elems.range().end], + }); + } + DataCountSection { .. } => unreachable!(), + DataSection(_) => { + // TODO: supporting bulk memory will require copying over + // any active or declared segments. + add_data_section(&mut module); + } + CustomSection { + name, + data, + data_offset: _, + } => { + // Some tools expect the name custom section to come last, + // even though custom sections are allowed in any order. + if name == "name" { + add_data_section(&mut module); + } + + module.section(&wasm_encoder::CustomSection { name, data }); + } + CodeSectionStart { + range, + count: _, + size: _, + } => { + let data = &full_wasm[range.start..range.end]; + module.section(&wasm_encoder::RawSection { + id: wasm_encoder::SectionId::Code as u8, + data, + }); + } + CodeSectionEntry(_) => continue, + ModuleCodeSectionStart { .. } + | ModuleCodeSectionEntry { .. } + | UnknownSection { .. } + | EventSection(_) => unreachable!(), + End => { + add_data_section(&mut module); + return module.finish(); + } + } + } + } +} + +/// A "diff" of Wasm state from its default value after having been initialized. +struct Diff<'a> { + /// Maps global index to its initialized value. + globals: Vec, + + /// Segments of non-zero memory. + /// + /// `(memory_index, offset, data)`. + data_segments: Vec<(u32, u32, &'a [u8])>, } diff --git a/crates/wizer/tests/tests.rs b/crates/wizer/tests/tests.rs new file mode 100644 index 000000000000..98bfb6bdeebf --- /dev/null +++ b/crates/wizer/tests/tests.rs @@ -0,0 +1,57 @@ +use wat::parse_str as wat_to_wasm; +use wizer::Wizer; + +fn run_test(expected: i32, wat: &str) -> anyhow::Result<()> { + let _ = env_logger::try_init(); + let wasm = wat_to_wasm(wat)?; + let wasm = Wizer::new().run(&wasm)?; + let store = wasmtime::Store::default(); + let module = wasmtime::Module::new(store.engine(), wasm)?; + let instance = wasmtime::Instance::new(&store, &module, &[])?; + let run = instance + .get_func("run") + .ok_or_else(|| anyhow::anyhow!("the test Wasm module does not export a `run` function"))? + .get0::()?; + let actual = run()?; + anyhow::ensure!( + expected == actual, + "expected `{}`, found `{}`", + expected, + actual, + ); + Ok(()) +} + +#[test] +fn basic_global() -> anyhow::Result<()> { + run_test( + 42, + r#" +(module + (global $g (mut i32) i32.const 0) + (func (export "wizer.initialize") + i32.const 42 + global.set $g) + (func (export "run") (result i32) + global.get $g)) + "#, + ) +} + +#[test] +fn basic_memory() -> anyhow::Result<()> { + run_test( + 42, + r#" +(module + (memory 1) + (func (export "wizer.initialize") + i32.const 0 + i32.const 42 + i32.store offset=1337) + (func (export "run") (result i32) + i32.const 0 + i32.load offset=1337)) + "#, + ) +} From db859bdf6914c1f50d39ea470447c102995184c8 Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Thu, 19 Nov 2020 15:49:07 -0800 Subject: [PATCH 003/212] Copy sections during preparation phase Instead of parsing them and then just calling builder functions to re-encode them. --- crates/wizer/src/lib.rs | 192 ++++++++++------------------------------ 1 file changed, 47 insertions(+), 145 deletions(-) diff --git a/crates/wizer/src/lib.rs b/crates/wizer/src/lib.rs index 8d8e0fb1554c..d99c8c196471 100644 --- a/crates/wizer/src/lib.rs +++ b/crates/wizer/src/lib.rs @@ -1,4 +1,6 @@ -//! TODO FITZGEN +//! Wizer: the WebAssembly initializer! +//! +//! See the [`Wizer`] struct for details. #![deny(missing_docs)] @@ -6,7 +8,7 @@ use anyhow::Context; use std::convert::TryFrom; use structopt::StructOpt; -/// Wizer: the WebAssembly initializer. +/// Wizer: the WebAssembly initializer! /// /// Don't wait for your Wasm module to initialize itself, pre-initialize it! /// Wizer instantiates your WebAssembly module, executes its initialization @@ -207,106 +209,49 @@ impl Wizer { wasm = &wasm[consumed..]; use wasmparser::Payload::*; + use wasmparser::SectionReader; match payload { Version { .. } => continue, - TypeSection(mut types) => { - let count = types.get_count(); - let mut types_encoder = wasm_encoder::TypeSection::new(); - for _ in 0..count { - match types.read()? { - wasmparser::TypeDef::Func(ft) => { - types_encoder.function( - ft.params.iter().copied().map(translate_val_type), - ft.returns.iter().copied().map(translate_val_type), - ); - } - wasmparser::TypeDef::Instance(_) | wasmparser::TypeDef::Module(_) => { - anyhow::bail!("module linking is not supported yet"); - } - } - } - module.section(&types_encoder); + TypeSection(types) => { + module.section(&wasm_encoder::RawSection { + id: wasm_encoder::SectionId::Type as u8, + data: &full_wasm[types.range().start..types.range().end], + }); } - ImportSection(mut imports) => { - let count = imports.get_count(); - let mut imports_encoder = wasm_encoder::ImportSection::new(); - for _ in 0..count { - let imp = imports.read()?; - imports_encoder.import( - imp.module, - imp.field.expect( - "should always be `Some` when module linking isn't enabled", - ), - match imp.ty { - wasmparser::ImportSectionEntryType::Function(ty) => { - wasm_encoder::ImportType::Function(ty) - } - wasmparser::ImportSectionEntryType::Table(ty) => { - translate_table_type(ty)?.into() - } - wasmparser::ImportSectionEntryType::Memory(ty) => { - memory_count += 1; - translate_memory_type(ty)?.into() - } - wasmparser::ImportSectionEntryType::Global(ty) => { - global_count += 1; - translate_global_type(ty).into() - } - wasmparser::ImportSectionEntryType::Module(_) - | wasmparser::ImportSectionEntryType::Instance(_) => { - anyhow::bail!("module linking is not supported yet") - } - wasmparser::ImportSectionEntryType::Event(_) => { - anyhow::bail!("exceptions are not supported yet") - } - }, - ); - } - module.section(&imports_encoder); + ImportSection(imports) => { + module.section(&wasm_encoder::RawSection { + id: wasm_encoder::SectionId::Import as u8, + data: &full_wasm[imports.range().start..imports.range().end], + }); } AliasSection(_) | InstanceSection(_) | ModuleSection(_) => { anyhow::bail!("module linking is not supported yet") } - FunctionSection(mut funcs) => { - let count = funcs.get_count(); - let mut funcs_encoder = wasm_encoder::FunctionSection::new(); - for _ in 0..count { - let ty_idx = funcs.read()?; - funcs_encoder.function(ty_idx); - } - module.section(&funcs_encoder); + FunctionSection(funcs) => { + module.section(&wasm_encoder::RawSection { + id: wasm_encoder::SectionId::Function as u8, + data: &full_wasm[funcs.range().start..funcs.range().end], + }); } - TableSection(mut tables) => { - let count = tables.get_count(); - let mut tables_encoder = wasm_encoder::TableSection::new(); - for _ in 0..count { - let table_ty = tables.read()?; - tables_encoder.table(translate_table_type(table_ty)?); - } - module.section(&tables_encoder); + TableSection(tables) => { + module.section(&wasm_encoder::RawSection { + id: wasm_encoder::SectionId::Table as u8, + data: &full_wasm[tables.range().start..tables.range().end], + }); } - MemorySection(mut mems) => { - let count = mems.get_count(); - memory_count += count; - let mut mems_encoder = wasm_encoder::MemorySection::new(); - for _ in 0..count { - let mem_ty = mems.read()?; - mems_encoder.memory(translate_memory_type(mem_ty)?); - } - module.section(&mems_encoder); + MemorySection(mems) => { + memory_count += mems.get_count(); + module.section(&wasm_encoder::RawSection { + id: wasm_encoder::SectionId::Memory as u8, + data: &full_wasm[mems.range().start..mems.range().end], + }); } - GlobalSection(mut globals) => { - let count = globals.get_count(); - global_count += count; - let mut globals_encoder = wasm_encoder::GlobalSection::new(); - for _ in 0..count { - let global = globals.read()?; - globals_encoder.global( - translate_global_type(global.ty), - translate_init_expr(global.init_expr)?, - ); - } - module.section(&globals_encoder); + GlobalSection(globals) => { + global_count += globals.get_count(); + module.section(&wasm_encoder::RawSection { + id: wasm_encoder::SectionId::Global as u8, + data: &full_wasm[globals.range().start..globals.range().end], + }); } ExportSection(mut exports) => { let count = exports.get_count(); @@ -356,61 +301,18 @@ impl Wizer { function_index: func, }); } - ElementSection(mut elems) => { - let count = elems.get_count(); - let mut elems_encoder = wasm_encoder::ElementSection::new(); - for _ in 0..count { - let elem = elems.read()?; - match elem.kind { - wasmparser::ElementKind::Active { - table_index, - init_expr, - } => { - let init_expr = translate_init_expr(init_expr)?; - let mut items = elem.items.get_items_reader()?; - let mut funcs = Vec::with_capacity(items.get_count() as usize); - for _ in 0..items.get_count() { - funcs.push(match items.read()? { - wasmparser::ElementItem::Func(idx) => idx, - wasmparser::ElementItem::Null(_) => { - anyhow::bail!("reference types are not supported yet") - } - }); - } - elems_encoder.active(table_index, init_expr, funcs.drain(..)); - } - wasmparser::ElementKind::Passive - | wasmparser::ElementKind::Declared => { - anyhow::bail!("bulk memory is not supported yet") - } - } - } - module.section(&elems_encoder); + ElementSection(elems) => { + module.section(&wasm_encoder::RawSection { + id: wasm_encoder::SectionId::Element as u8, + data: &full_wasm[elems.range().start..elems.range().end], + }); } DataCountSection { .. } => anyhow::bail!("bulk memory is not supported yet"), - DataSection(mut data) => { - let count = data.get_count(); - let mut data_encoder = wasm_encoder::DataSection::new(); - for _ in 0..count { - let segment = data.read()?; - match segment.kind { - wasmparser::DataKind::Active { - memory_index, - init_expr, - } => { - let init_expr = translate_init_expr(init_expr)?; - data_encoder.active( - memory_index, - init_expr, - segment.data.iter().copied(), - ); - } - wasmparser::DataKind::Passive => { - anyhow::bail!("bulk memory is not supported yet") - } - } - } - module.section(&data_encoder); + DataSection(data) => { + module.section(&wasm_encoder::RawSection { + id: wasm_encoder::SectionId::Data as u8, + data: &full_wasm[data.range().start..data.range().end], + }); } CustomSection { name, From f80bd0286f6d77861e251599de283f0584c3c11e Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Thu, 19 Nov 2020 16:54:21 -0800 Subject: [PATCH 004/212] Allow WASI to be used during initialization --- crates/wizer/Cargo.toml | 16 +- crates/wizer/src/lib.rs | 184 +++++++++++++---------- crates/wizer/tests/regex-test/Cargo.toml | 13 ++ crates/wizer/tests/regex-test/README.md | 8 + crates/wizer/tests/regex-test/src/lib.rs | 22 +++ crates/wizer/tests/tests.rs | 48 +++++- 6 files changed, 199 insertions(+), 92 deletions(-) create mode 100644 crates/wizer/tests/regex-test/Cargo.toml create mode 100644 crates/wizer/tests/regex-test/README.md create mode 100644 crates/wizer/tests/regex-test/src/lib.rs diff --git a/crates/wizer/Cargo.toml b/crates/wizer/Cargo.toml index 33d2f71a2f70..37aca39ecb51 100644 --- a/crates/wizer/Cargo.toml +++ b/crates/wizer/Cargo.toml @@ -11,14 +11,20 @@ name = "wizer" required-features = ["env_logger", "structopt"] [dependencies] -wasmtime = { path = "../wasmtime/crates/wasmtime" } -wasm-encoder = { path = "../wasm-tools/crates/wasm-encoder" } -structopt = { version = "0.3.20", optional = true } anyhow = "1.0.34" -wasmparser = "0.68.0" -log = "0.4.11" env_logger = { version = "0.8.1", optional = true } +log = "0.4.11" +structopt = { version = "0.3.20", optional = true } +wasm-encoder = { path = "../wasm-tools/crates/wasm-encoder" } +wasmparser = "0.68.0" +wasmtime = "0.21.0" +wasmtime-wasi = "0.21.0" [dev-dependencies] wat = "1.0.28" env_logger = "0.8.2" + +[workspace] +members = [ + "tests/regex-test" +] diff --git a/crates/wizer/src/lib.rs b/crates/wizer/src/lib.rs index d99c8c196471..a097dae974f0 100644 --- a/crates/wizer/src/lib.rs +++ b/crates/wizer/src/lib.rs @@ -6,6 +6,7 @@ use anyhow::Context; use std::convert::TryFrom; +#[cfg(feature = "structopt")] use structopt::StructOpt; /// Wizer: the WebAssembly initializer! @@ -34,8 +35,26 @@ use structopt::StructOpt; pub struct Wizer { /// The Wasm export name of the function that should be executed to /// initialize the Wasm module. - #[structopt(short = "f", long = "init-func", default_value = "wizer.initialize")] + #[cfg_attr( + feature = "structopt", + structopt(short = "f", long = "init-func", default_value = "wizer.initialize") + )] init_func: String, + + /// Allow WASI imports to be called during initialization. + /// + /// This can introduce diverging semantics because the initialization can + /// observe nondeterminism that might have gone a different way at runtime + /// than it did at initialization time. + /// + /// If your Wasm module uses WASI's `get_random` to add randomness to + /// something as a security mitigation (e.g. something akin to ASLR or the + /// way Rust's hash maps incorporate a random nonce) then note that, if the + /// randomization is added during initialization time and you don't ever + /// re-randomize at runtime, then that randomization will become per-module + /// rather than per-instance. + #[cfg_attr(feature = "structopt", structopt(long = "allow-wasi"))] + allow_wasi: bool, } fn translate_val_type(ty: wasmparser::Type) -> wasm_encoder::ValType { @@ -51,37 +70,6 @@ fn translate_val_type(ty: wasmparser::Type) -> wasm_encoder::ValType { } } -fn translate_limits(limits: wasmparser::ResizableLimits) -> wasm_encoder::Limits { - wasm_encoder::Limits { - min: limits.initial, - max: limits.maximum, - } -} - -fn translate_table_type(ty: wasmparser::TableType) -> anyhow::Result { - anyhow::ensure!( - ty.element_type == wasmparser::Type::FuncRef, - "only funcref tables are supported" - ); - Ok(wasm_encoder::TableType { - limits: translate_limits(ty.limits), - }) -} - -fn translate_memory_type(ty: wasmparser::MemoryType) -> anyhow::Result { - match ty { - wasmparser::MemoryType::M32 { limits, shared } => { - anyhow::ensure!(!shared, "shared memories are not supported yet"); - Ok(wasm_encoder::MemoryType { - limits: translate_limits(limits), - }) - } - wasmparser::MemoryType::M64 { .. } => { - anyhow::bail!("64-bit memories not supported yet") - } - } -} - fn translate_global_type(ty: wasmparser::GlobalType) -> wasm_encoder::GlobalType { wasm_encoder::GlobalType { val_type: translate_val_type(ty.content_type), @@ -89,35 +77,12 @@ fn translate_global_type(ty: wasmparser::GlobalType) -> wasm_encoder::GlobalType } } -fn translate_init_expr(expr: wasmparser::InitExpr) -> anyhow::Result { - let mut ops = expr.get_operators_reader(); - let init = match ops.read()? { - wasmparser::Operator::GlobalGet { global_index } => { - wasm_encoder::Instruction::GlobalGet(global_index) - } - wasmparser::Operator::I32Const { value } => wasm_encoder::Instruction::I32Const(value), - wasmparser::Operator::I64Const { value } => wasm_encoder::Instruction::I64Const(value), - wasmparser::Operator::F32Const { value } => { - wasm_encoder::Instruction::F32Const(f32::from_bits(value.bits())) - } - wasmparser::Operator::F64Const { value } => { - wasm_encoder::Instruction::F64Const(f64::from_bits(value.bits())) - } - _ => anyhow::bail!("unsupported init expr"), - }; - anyhow::ensure!( - matches!(ops.read()?, wasmparser::Operator::End), - "expected `end` instruction" - ); - ops.ensure_end()?; - Ok(init) -} - impl Wizer { /// Construct a new `Wizer` builder. pub fn new() -> Self { Wizer { init_func: "wizer.initialize".into(), + allow_wasi: false, } } @@ -129,6 +94,25 @@ impl Wizer { self } + /// Allow WASI imports to be called during initialization? + /// + /// This can introduce diverging semantics because the initialization can + /// observe nondeterminism that might have gone a different way at runtime + /// than it did at initialization time. + /// + /// If your Wasm module uses WASI's `get_random` to add randomness to + /// something as a security mitigation (e.g. something akin to ASLR or the + /// way Rust's hash maps incorporate a random nonce) then note that, if the + /// randomization is added during initialization time and you don't ever + /// re-randomize at runtime, then that randomization will become per-module + /// rather than per-instance. + /// + /// Defaults to `false`. + pub fn allow_wasi(&mut self, allow: bool) -> &mut Self { + self.allow_wasi = allow; + self + } + /// Initialize the given Wasm, snapshot it, and return the serialized /// snapshot as a new, pre-initialized Wasm module. pub fn run(&self, wasm: &[u8]) -> anyhow::Result> { @@ -144,10 +128,8 @@ impl Wizer { let store = wasmtime::Store::default(); let module = wasmtime::Module::new(store.engine(), &wasm)?; self.validate_init_func(&module)?; - let imports = self.dummy_imports(&store, &module)?; - let instance = wasmtime::Instance::new(&store, &module, &imports)?; - self.initialize(&instance)?; + let instance = self.initialize(&store, &module)?; let diff = self.diff(&instance); let initialized_wasm = self.rewrite(&wasm, &diff); @@ -373,12 +355,17 @@ impl Wizer { &self, store: &wasmtime::Store, module: &wasmtime::Module, - ) -> anyhow::Result> { + linker: &mut wasmtime::Linker, + ) -> anyhow::Result<()> { log::debug!("Creating dummy imports"); - let mut imports = Vec::with_capacity(module.imports().len()); for imp in module.imports() { - imports.push(match imp.ty() { + if linker.get_one_by_name(imp.module(), imp.name()).is_ok() { + // Already defined, must be part of WASI. + continue; + } + + match imp.ty() { wasmtime::ExternType::Func(func_ty) => { let trap = wasmtime::Trap::new(format!( "cannot call imports within the initialization function; attempted \ @@ -386,10 +373,15 @@ impl Wizer { imp.module(), imp.name() )); - wasmtime::Func::new(store, func_ty, move |_caller, _params, _results| { - Err(trap.clone()) - }) - .into() + linker.define( + imp.module(), + imp.name(), + wasmtime::Func::new( + store, + func_ty, + move |_caller: wasmtime::Caller, _params, _results| Err(trap.clone()), + ), + )?; } wasmtime::ExternType::Global(_global_ty) => { // The Wasm module could use `global.get` to read the @@ -417,24 +409,37 @@ impl Wizer { // imported memories. anyhow::bail!("cannot initialize Wasm modules that import memories") } - wasmtime::ExternType::Module(_) | wasmtime::ExternType::Instance(_) => { - anyhow::bail!("module linking is not supported yet") - } - }); + }; } - Ok(imports) + + Ok(()) } - /// Call the initialization function. - fn initialize(&self, instance: &wasmtime::Instance) -> anyhow::Result<()> { + /// Instantiate the module and call its initialization function. + fn initialize( + &self, + store: &wasmtime::Store, + module: &wasmtime::Module, + ) -> anyhow::Result { log::debug!("Calling the initialization function"); + + let mut linker = wasmtime::Linker::new(store); + if self.allow_wasi { + let ctx = wasmtime_wasi::WasiCtx::new(None::)?; + let wasi = wasmtime_wasi::Wasi::new(store, ctx); + wasi.add_to_linker(&mut linker)?; + } + self.dummy_imports(&store, &module, &mut linker)?; + let instance = linker.instantiate(module)?; + let init_func = instance .get_func(&self.init_func) .expect("checked by `validate_init_func`") .get0::<()>() .expect("checked by `validate_init_func`"); init_func().with_context(|| format!("the `{}` function trapped", self.init_func))?; - Ok(()) + + Ok(instance) } /// Diff the given instance's globals, memories, and tables from the Wasm @@ -464,6 +469,7 @@ impl Wizer { // with a dirty bit for each page, so we can just diff the pages that // actually got changed to non-zero values. log::debug!("Diffing memories"); + let mut memory_mins = vec![]; let mut data_segments = vec![]; let mut memory_index = 0; loop { @@ -471,6 +477,8 @@ impl Wizer { match instance.get_memory(&name) { None => break, Some(memory) => { + memory_mins.push(memory.size()); + let memory: &'a [u8] = unsafe { // Safe because no one else has a (potentially mutable) // view to this memory and we know the memory will live @@ -521,6 +529,7 @@ impl Wizer { Diff { globals, + memory_mins, data_segments, } } @@ -589,11 +598,25 @@ impl Wizer { data: &full_wasm[tables.range().start..tables.range().end], }); } - MemorySection(mems) => { - module.section(&wasm_encoder::RawSection { - id: wasm_encoder::SectionId::Memory as u8, - data: &full_wasm[mems.range().start..mems.range().end], - }); + MemorySection(mut mems) => { + // Set the minimum size of each memory to the diff's + // initialized size for that memory. + let mut memory_encoder = wasm_encoder::MemorySection::new(); + for i in 0..mems.get_count() { + let memory = mems.read().unwrap(); + match memory { + wasmparser::MemoryType::M32 { limits, shared: _ } => { + memory_encoder.memory(wasm_encoder::MemoryType { + limits: wasm_encoder::Limits { + min: diff.memory_mins[i as usize], + max: limits.maximum, + }, + }); + } + _ => unreachable!(), + } + } + module.section(&memory_encoder); } GlobalSection(mut globals) => { // Encode the initialized values from the diff, rather than @@ -713,6 +736,9 @@ struct Diff<'a> { /// Maps global index to its initialized value. globals: Vec, + /// A new minimum size for each memory (in units of pages). + memory_mins: Vec, + /// Segments of non-zero memory. /// /// `(memory_index, offset, data)`. diff --git a/crates/wizer/tests/regex-test/Cargo.toml b/crates/wizer/tests/regex-test/Cargo.toml new file mode 100644 index 000000000000..60c1e9827891 --- /dev/null +++ b/crates/wizer/tests/regex-test/Cargo.toml @@ -0,0 +1,13 @@ +[package] +name = "regex-test" +version = "0.1.0" +authors = ["Nick Fitzgerald "] +edition = "2018" + +[lib] +crate-type = ["cdylib"] + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +regex = "1.4.2" diff --git a/crates/wizer/tests/regex-test/README.md b/crates/wizer/tests/regex-test/README.md new file mode 100644 index 000000000000..103b4d203c5b --- /dev/null +++ b/crates/wizer/tests/regex-test/README.md @@ -0,0 +1,8 @@ +Source code used to create `/wizer/tests/regex_test.wasm`. + +Rebuild with: + +``` +$ cargo build --release --target wasm32-wasi -p regex-test +$ cp target/wasm32-wasi/release/regex_test.wasm tests/regex_test.wasm +``` diff --git a/crates/wizer/tests/regex-test/src/lib.rs b/crates/wizer/tests/regex-test/src/lib.rs new file mode 100644 index 000000000000..1d71433f7a9e --- /dev/null +++ b/crates/wizer/tests/regex-test/src/lib.rs @@ -0,0 +1,22 @@ +use regex::Regex; + +/// A regex that matches numbers that start with "1". +static mut REGEX: Option = None; + +#[export_name = "wizer.initialize"] +pub fn init() { + unsafe { + REGEX = Some(Regex::new(r"^1\d*$").unwrap()); + } +} + +#[no_mangle] +pub fn run(n: i32) -> i32 { + let s = format!("{}", n); + let regex = unsafe { REGEX.as_ref().unwrap() }; + if regex.is_match(&s) { + 42 + } else { + 0 + } +} diff --git a/crates/wizer/tests/tests.rs b/crates/wizer/tests/tests.rs index 98bfb6bdeebf..bce6112a745e 100644 --- a/crates/wizer/tests/tests.rs +++ b/crates/wizer/tests/tests.rs @@ -1,30 +1,52 @@ use wat::parse_str as wat_to_wasm; use wizer::Wizer; -fn run_test(expected: i32, wat: &str) -> anyhow::Result<()> { +fn run_wat(args: &[wasmtime::Val], expected: i32, wat: &str) -> anyhow::Result<()> { let _ = env_logger::try_init(); let wasm = wat_to_wasm(wat)?; - let wasm = Wizer::new().run(&wasm)?; + run_wasm(args, expected, &wasm) +} + +fn run_wasm(args: &[wasmtime::Val], expected: i32, wasm: &[u8]) -> anyhow::Result<()> { + let _ = env_logger::try_init(); + + let mut wizer = Wizer::new(); + wizer.allow_wasi(true); + let wasm = wizer.run(&wasm)?; + let store = wasmtime::Store::default(); let module = wasmtime::Module::new(store.engine(), wasm)?; - let instance = wasmtime::Instance::new(&store, &module, &[])?; + + let mut linker = wasmtime::Linker::new(&store); + let ctx = wasmtime_wasi::WasiCtx::new(None::)?; + let wasi = wasmtime_wasi::Wasi::new(&store, ctx); + wasi.add_to_linker(&mut linker)?; + let instance = linker.instantiate(&module)?; + let run = instance .get_func("run") - .ok_or_else(|| anyhow::anyhow!("the test Wasm module does not export a `run` function"))? - .get0::()?; - let actual = run()?; + .ok_or_else(|| anyhow::anyhow!("the test Wasm module does not export a `run` function"))?; + + let actual = run.call(args)?; + anyhow::ensure!(actual.len() == 1, "expected one result"); + let actual = match actual[0] { + wasmtime::Val::I32(x) => x, + _ => anyhow::bail!("expected an i32 result"), + }; anyhow::ensure!( expected == actual, "expected `{}`, found `{}`", expected, actual, ); + Ok(()) } #[test] fn basic_global() -> anyhow::Result<()> { - run_test( + run_wat( + &[], 42, r#" (module @@ -40,7 +62,8 @@ fn basic_global() -> anyhow::Result<()> { #[test] fn basic_memory() -> anyhow::Result<()> { - run_test( + run_wat( + &[], 42, r#" (module @@ -55,3 +78,12 @@ fn basic_memory() -> anyhow::Result<()> { "#, ) } + +#[test] +fn rust_regex() -> anyhow::Result<()> { + run_wasm( + &[wasmtime::Val::I32(13)], + 42, + &include_bytes!("./regex_test.wasm")[..], + ) +} From 3506aff40d8bf202a54fbc5cc7eeb24d3a42b20e Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Mon, 23 Nov 2020 14:22:52 -0800 Subject: [PATCH 005/212] deps: Use the published version of wasm-encoder --- crates/wizer/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/wizer/Cargo.toml b/crates/wizer/Cargo.toml index 37aca39ecb51..30050e3df660 100644 --- a/crates/wizer/Cargo.toml +++ b/crates/wizer/Cargo.toml @@ -15,7 +15,7 @@ anyhow = "1.0.34" env_logger = { version = "0.8.1", optional = true } log = "0.4.11" structopt = { version = "0.3.20", optional = true } -wasm-encoder = { path = "../wasm-tools/crates/wasm-encoder" } +wasm-encoder = "0.1.0" wasmparser = "0.68.0" wasmtime = "0.21.0" wasmtime-wasi = "0.21.0" From 34606830c10a159cef6c091dc63206d94c386054 Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Tue, 24 Nov 2020 09:06:40 -0800 Subject: [PATCH 006/212] Add a simple benchmark The benchmark measures instantiating a module that compiles a regex and matches it against an input string. The wizer version pre-compiles the regex while the control version does not. --- crates/wizer/Cargo.toml | 11 ++++- crates/wizer/benches/regex-bench/Cargo.toml | 16 +++++++ crates/wizer/benches/regex-bench/README.md | 11 +++++ crates/wizer/benches/regex-bench/src/lib.rs | 24 ++++++++++ crates/wizer/benches/regex.rs | 53 +++++++++++++++++++++ 5 files changed, 114 insertions(+), 1 deletion(-) create mode 100644 crates/wizer/benches/regex-bench/Cargo.toml create mode 100644 crates/wizer/benches/regex-bench/README.md create mode 100644 crates/wizer/benches/regex-bench/src/lib.rs create mode 100644 crates/wizer/benches/regex.rs diff --git a/crates/wizer/Cargo.toml b/crates/wizer/Cargo.toml index 30050e3df660..3151ac062d18 100644 --- a/crates/wizer/Cargo.toml +++ b/crates/wizer/Cargo.toml @@ -10,6 +10,10 @@ edition = "2018" name = "wizer" required-features = ["env_logger", "structopt"] +[[bench]] +name = "regex" +harness = false + [dependencies] anyhow = "1.0.34" env_logger = { version = "0.8.1", optional = true } @@ -23,8 +27,13 @@ wasmtime-wasi = "0.21.0" [dev-dependencies] wat = "1.0.28" env_logger = "0.8.2" +criterion = "0.3.3" [workspace] members = [ - "tests/regex-test" + "benches/regex-bench", + "tests/regex-test", ] + +[profile.bench] +debug = true diff --git a/crates/wizer/benches/regex-bench/Cargo.toml b/crates/wizer/benches/regex-bench/Cargo.toml new file mode 100644 index 000000000000..36d53cc164cb --- /dev/null +++ b/crates/wizer/benches/regex-bench/Cargo.toml @@ -0,0 +1,16 @@ +[package] +name = "regex-bench" +version = "0.1.0" +authors = ["Nick Fitzgerald "] +edition = "2018" + +[lib] +crate-type = ["cdylib"] + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +regex = "1.4.2" + +[features] +wizer = [] diff --git a/crates/wizer/benches/regex-bench/README.md b/crates/wizer/benches/regex-bench/README.md new file mode 100644 index 000000000000..effacb3ace12 --- /dev/null +++ b/crates/wizer/benches/regex-bench/README.md @@ -0,0 +1,11 @@ +Source code used to create `/wizer/benches/regex_bench.{control,wizer}.wasm`. + +From within this directory, rebuild via: + +``` +$ cargo build --release --target wasm32-wasi +$ cp ../../target/wasm32-wasi/release/regex_bench.wasm ../regex_bench.control.wasm +$ cargo build --release --target wasm32-wasi --features wizer +$ cd ../.. +$ cargo run --all-features -- --allow-wasi target/wasm32-wasi/release/regex_bench.wasm -o benches/regex_bench.wizer.wasm +``` diff --git a/crates/wizer/benches/regex-bench/src/lib.rs b/crates/wizer/benches/regex-bench/src/lib.rs new file mode 100644 index 000000000000..cef08b3bd1ca --- /dev/null +++ b/crates/wizer/benches/regex-bench/src/lib.rs @@ -0,0 +1,24 @@ +use regex::Regex; + +/// A regex that matches numbers that start with "1". +static mut REGEX: Option = None; + +#[export_name = "wizer.initialize"] +pub extern "C" fn init() { + unsafe { + REGEX = Some(Regex::new(r"^1\d*$").unwrap()); + } +} + +#[export_name = "run"] +pub extern "C" fn run(ptr: *mut u8, len: usize) -> i32 { + #[cfg(not(feature = "wizer"))] + init(); + + let s = unsafe { + let slice = std::slice::from_raw_parts(ptr, len); + std::str::from_utf8(slice).unwrap() + }; + let regex = unsafe { REGEX.as_ref().unwrap() }; + regex.is_match(&s) as u8 as i32 +} diff --git a/crates/wizer/benches/regex.rs b/crates/wizer/benches/regex.rs new file mode 100644 index 000000000000..f4b17ebf2717 --- /dev/null +++ b/crates/wizer/benches/regex.rs @@ -0,0 +1,53 @@ +use criterion::{criterion_group, criterion_main, Criterion}; +use std::convert::TryFrom; + +fn run_iter(linker: &wasmtime::Linker, module: &wasmtime::Module) { + let instance = linker.instantiate(module).unwrap(); + + let memory = instance.get_memory("memory").unwrap(); + let data = unsafe { memory.data_unchecked_mut() }; + let ptr = data.len() - 5; + data[ptr..].copy_from_slice(b"hello"); + + let run = instance.get_func("run").unwrap(); + let result = run + .call(&[ + wasmtime::Val::I32(i32::try_from(ptr).unwrap()), + wasmtime::Val::I32(5), + ]) + .unwrap(); + assert_eq!(result.len(), 1); + assert_eq!(result[0].i32(), Some(0)); +} + +fn linker(store: &wasmtime::Store) -> wasmtime::Linker { + let mut linker = wasmtime::Linker::new(&store); + let ctx = wasmtime_wasi::WasiCtx::new(None::).unwrap(); + let wasi = wasmtime_wasi::Wasi::new(&store, ctx); + wasi.add_to_linker(&mut linker).unwrap(); + linker +} + +fn bench_regex(c: &mut Criterion) { + let mut group = c.benchmark_group("regex"); + group.bench_function("control", |b| { + let store = wasmtime::Store::default(); + let module = + wasmtime::Module::new(store.engine(), &include_bytes!("regex_bench.control.wasm")) + .unwrap(); + let linker = linker(&store); + b.iter(|| run_iter(&linker, &module)); + }); + group.bench_function("wizer", |b| { + let store = wasmtime::Store::default(); + let module = + wasmtime::Module::new(store.engine(), &include_bytes!("regex_bench.wizer.wasm")) + .unwrap(); + let linker = linker(&store); + b.iter(|| run_iter(&linker, &module)); + }); + group.finish(); +} + +criterion_group!(benches, bench_regex); +criterion_main!(benches); From ee19d503d5b3b9b8765477ed0903baea027f547c Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Tue, 24 Nov 2020 10:05:13 -0800 Subject: [PATCH 007/212] Diff memory at the native page granularity --- crates/wizer/Cargo.toml | 1 + crates/wizer/src/lib.rs | 70 ++++++++++++++++++++--------------------- 2 files changed, 35 insertions(+), 36 deletions(-) diff --git a/crates/wizer/Cargo.toml b/crates/wizer/Cargo.toml index 3151ac062d18..dfcaebc98111 100644 --- a/crates/wizer/Cargo.toml +++ b/crates/wizer/Cargo.toml @@ -23,6 +23,7 @@ wasm-encoder = "0.1.0" wasmparser = "0.68.0" wasmtime = "0.21.0" wasmtime-wasi = "0.21.0" +rayon = "1.5.0" [dev-dependencies] wat = "1.0.28" diff --git a/crates/wizer/src/lib.rs b/crates/wizer/src/lib.rs index a097dae974f0..7feb47c1c171 100644 --- a/crates/wizer/src/lib.rs +++ b/crates/wizer/src/lib.rs @@ -5,10 +5,13 @@ #![deny(missing_docs)] use anyhow::Context; -use std::convert::TryFrom; +use rayon::iter::{IntoParallelIterator, ParallelExtend, ParallelIterator}; #[cfg(feature = "structopt")] use structopt::StructOpt; +const WASM_PAGE_SIZE: u32 = 65_536; +const NATIVE_PAGE_SIZE: u32 = 4_096; + /// Wizer: the WebAssembly initializer! /// /// Don't wait for your Wasm module to initialize itself, pre-initialize it! @@ -479,6 +482,9 @@ impl Wizer { Some(memory) => { memory_mins.push(memory.size()); + let num_wasm_pages = memory.size(); + let num_native_pages = num_wasm_pages * (WASM_PAGE_SIZE / NATIVE_PAGE_SIZE); + let memory: &'a [u8] = unsafe { // Safe because no one else has a (potentially mutable) // view to this memory and we know the memory will live @@ -486,47 +492,39 @@ impl Wizer { std::slice::from_raw_parts(memory.data_ptr(), memory.data_size()) }; - let mut i = 0; - loop { - // Search for the start of a non-zero region of - // memory. After the loop `i` will either be out of - // bounds, or be the start of the non-zero region. - while i < memory.len() && memory[i] == 0 { - i += 1; - continue; - } - - if i >= memory.len() { - break; - } - - // We found the start of a non-zero region, now - // search for its end. `j` will be the end of the - // non-zero region. - let mut j = i + 1; - while j < memory.len() && memory[j] != 0 { - j += 1; - } - - // Remember this non-zero region as a data segment - // for the pre-initialized module. - debug_assert!(memory[i..j].iter().all(|b| *b != 0)); - data_segments.push(( - memory_index, - u32::try_from(i).unwrap(), - &memory[i..j], - )); - - // Continue the search for the start of a non-zero - // region from the end of this non-zero region. - i = j + 1; - } + // Consider each "native" page of the memory. (Scare quotes + // because we have no guarantee that anyone isn't using huge + // page sizes or something). Process each page in + // parallel. If any byte has changed, add the whole page as + // a data segment. This means that the resulting Wasm module + // should instantiate faster, since there are fewer segments + // to bounds check on instantiation. Engines could even + // theoretically recognize that each of these segments is + // page sized and aligned, and use lazy copy-on-write + // initialization of each instance's memory. + data_segments.par_extend((0..num_native_pages).into_par_iter().filter_map( + |i| { + let start = i * NATIVE_PAGE_SIZE; + let end = ((i + 1) * NATIVE_PAGE_SIZE) as usize; + let page = &memory[start as usize..end]; + for byte in page { + if *byte != 0 { + return Some((memory_index, start, page)); + } + } + None + }, + )); memory_index += 1; } } } + // Sort data segments to enforce determinism in the face of the + // parallelism above. + data_segments.sort_by_key(|(m, i, _)| (*m, *i)); + Diff { globals, memory_mins, From 5a5e8df60d2503d67a93495b19b65fa1b441a045 Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Wed, 25 Nov 2020 14:38:50 -0800 Subject: [PATCH 008/212] Remove the init function's export when rewriting --- crates/wizer/src/lib.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/crates/wizer/src/lib.rs b/crates/wizer/src/lib.rs index 7feb47c1c171..e8d75eb0437c 100644 --- a/crates/wizer/src/lib.rs +++ b/crates/wizer/src/lib.rs @@ -641,12 +641,15 @@ impl Wizer { } ExportSection(mut exports) => { // Remove the `__wizer_*` exports we added during the - // preparation phase. + // preparation phase, as well as the initialization + // function's export. Removing the latter will enable + // further Wasm optimizations (notably GC'ing unused + // functions) via `wasm-opt` and similar tools. let count = exports.get_count(); let mut exports_encoder = wasm_encoder::ExportSection::new(); for _ in 0..count { let export = exports.read().unwrap(); - if export.field.starts_with("__wizer_") { + if export.field.starts_with("__wizer_") || export.field == self.init_func { continue; } exports_encoder.export( From 4c3dbec920bfaf4db7e254f57c076e4688cf65cb Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Thu, 3 Dec 2020 14:11:53 -0800 Subject: [PATCH 009/212] Merge contiguous dirty pages into a single data segment --- crates/wizer/src/lib.rs | 66 +++++++++++++++++++++++++++++++++++------ 1 file changed, 57 insertions(+), 9 deletions(-) diff --git a/crates/wizer/src/lib.rs b/crates/wizer/src/lib.rs index e8d75eb0437c..15d7bffeacc2 100644 --- a/crates/wizer/src/lib.rs +++ b/crates/wizer/src/lib.rs @@ -6,6 +6,7 @@ use anyhow::Context; use rayon::iter::{IntoParallelIterator, ParallelExtend, ParallelIterator}; +use std::convert::TryFrom; #[cfg(feature = "structopt")] use structopt::StructOpt; @@ -465,7 +466,7 @@ impl Wizer { } } - // Find and record non-zero regions of memory. + // Find and record non-zero regions of memory (in parallel). // // TODO: This could be really slow for large memories. Instead, we // should bring our own memories, protect the pages, and keep a table @@ -509,7 +510,11 @@ impl Wizer { let page = &memory[start as usize..end]; for byte in page { if *byte != 0 { - return Some((memory_index, start, page)); + return Some(DataSegment { + memory_index, + offset: start as u32, + data: page, + }); } } None @@ -523,7 +528,38 @@ impl Wizer { // Sort data segments to enforce determinism in the face of the // parallelism above. - data_segments.sort_by_key(|(m, i, _)| (*m, *i)); + data_segments.sort_by_key(|s| (s.memory_index, s.offset)); + + // Merge any contiguous pages, so that the engine can initialize them + // all at once (ideally with a single copy-on-write `mmap`) rather than + // initializing each data segment individually. + for i in (1..data_segments.len()).rev() { + let a = &data_segments[i - 1]; + let b = &data_segments[i]; + + // Only merge segments for the same memory. + if a.memory_index != b.memory_index { + continue; + } + + // Only merge segments if they are contiguous. + if a.offset + u32::try_from(a.data.len()).unwrap() != b.offset { + continue; + } + + // Okay, merge them together into `a` (so that the next iteration + // can merge it with its predecessor) and then remove `b`! + data_segments[i - 1].data = unsafe { + debug_assert_eq!( + a.data + .as_ptr() + .offset(isize::try_from(a.data.len()).unwrap()), + b.data.as_ptr() + ); + std::slice::from_raw_parts(a.data.as_ptr(), a.data.len() + b.data.len()) + }; + data_segments.remove(i); + } Diff { globals, @@ -547,10 +583,15 @@ impl Wizer { return; } let mut data_section = wasm_encoder::DataSection::new(); - for &(memory_index, offset, data) in &diff.data_segments { + for DataSegment { + memory_index, + offset, + data, + } in &diff.data_segments + { data_section.active( - memory_index, - wasm_encoder::Instruction::I32Const(offset as i32), + *memory_index, + wasm_encoder::Instruction::I32Const(*offset as i32), data.iter().copied(), ); } @@ -741,7 +782,14 @@ struct Diff<'a> { memory_mins: Vec, /// Segments of non-zero memory. - /// - /// `(memory_index, offset, data)`. - data_segments: Vec<(u32, u32, &'a [u8])>, + data_segments: Vec>, +} + +struct DataSegment<'a> { + /// The index of this data segment's memory. + memory_index: u32, + /// The offset within the memory that `data` should be copied to. + offset: u32, + /// This segment's (non-zero) data. + data: &'a [u8], } From 1d5684ee7c91d9aa5f8786509c1c9df21c1c7606 Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Wed, 9 Dec 2020 09:58:02 -0800 Subject: [PATCH 010/212] Introduce a UAP benchmark This new benchmark creates a `RegexSet` from the user agent parsing regexes from the browserscope project and then tests whether the input is known user agent. --- crates/wizer/.gitmodules | 3 + crates/wizer/Cargo.toml | 5 ++ crates/wizer/benches/regex-bench/README.md | 11 ++-- crates/wizer/benches/regex-bench/build.sh | 9 +++ crates/wizer/benches/uap-bench/Cargo.toml | 18 ++++++ crates/wizer/benches/uap-bench/README.md | 11 ++++ crates/wizer/benches/uap-bench/build.sh | 9 +++ crates/wizer/benches/uap-bench/src/lib.rs | 67 ++++++++++++++++++++++ crates/wizer/benches/uap-bench/uap-core | 1 + crates/wizer/benches/uap.rs | 67 ++++++++++++++++++++++ 10 files changed, 195 insertions(+), 6 deletions(-) create mode 100644 crates/wizer/.gitmodules create mode 100755 crates/wizer/benches/regex-bench/build.sh create mode 100644 crates/wizer/benches/uap-bench/Cargo.toml create mode 100644 crates/wizer/benches/uap-bench/README.md create mode 100755 crates/wizer/benches/uap-bench/build.sh create mode 100644 crates/wizer/benches/uap-bench/src/lib.rs create mode 160000 crates/wizer/benches/uap-bench/uap-core create mode 100644 crates/wizer/benches/uap.rs diff --git a/crates/wizer/.gitmodules b/crates/wizer/.gitmodules new file mode 100644 index 000000000000..9d47e3e62af0 --- /dev/null +++ b/crates/wizer/.gitmodules @@ -0,0 +1,3 @@ +[submodule "benches/uap-bench/uap-core"] + path = benches/uap-bench/uap-core + url = https://github.com/ua-parser/uap-core.git diff --git a/crates/wizer/Cargo.toml b/crates/wizer/Cargo.toml index dfcaebc98111..3e4abcc471fc 100644 --- a/crates/wizer/Cargo.toml +++ b/crates/wizer/Cargo.toml @@ -14,6 +14,10 @@ required-features = ["env_logger", "structopt"] name = "regex" harness = false +[[bench]] +name = "uap" +harness = false + [dependencies] anyhow = "1.0.34" env_logger = { version = "0.8.1", optional = true } @@ -33,6 +37,7 @@ criterion = "0.3.3" [workspace] members = [ "benches/regex-bench", + "benches/uap-bench", "tests/regex-test", ] diff --git a/crates/wizer/benches/regex-bench/README.md b/crates/wizer/benches/regex-bench/README.md index effacb3ace12..d6838d45079e 100644 --- a/crates/wizer/benches/regex-bench/README.md +++ b/crates/wizer/benches/regex-bench/README.md @@ -1,11 +1,10 @@ Source code used to create `/wizer/benches/regex_bench.{control,wizer}.wasm`. -From within this directory, rebuild via: +Compiles a simple regular expression in the initialization function and the main +function checks whether the regex matches an input string. + +Rebuild via: ``` -$ cargo build --release --target wasm32-wasi -$ cp ../../target/wasm32-wasi/release/regex_bench.wasm ../regex_bench.control.wasm -$ cargo build --release --target wasm32-wasi --features wizer -$ cd ../.. -$ cargo run --all-features -- --allow-wasi target/wasm32-wasi/release/regex_bench.wasm -o benches/regex_bench.wizer.wasm +$ ./build.sh ``` diff --git a/crates/wizer/benches/regex-bench/build.sh b/crates/wizer/benches/regex-bench/build.sh new file mode 100755 index 000000000000..4e27374f057a --- /dev/null +++ b/crates/wizer/benches/regex-bench/build.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +set -ex +cd "$(dirname $0)" +cargo build --target wasm32-wasi --release +cp ../../target/wasm32-wasi/release/regex_bench.wasm ../regex_bench.control.wasm +cargo build --target wasm32-wasi --release --features wizer +cd ../.. +cargo run --all-features -- --allow-wasi target/wasm32-wasi/release/regex_bench.wasm -o benches/regex_bench.wizer.wasm diff --git a/crates/wizer/benches/uap-bench/Cargo.toml b/crates/wizer/benches/uap-bench/Cargo.toml new file mode 100644 index 000000000000..f4d87bff9f45 --- /dev/null +++ b/crates/wizer/benches/uap-bench/Cargo.toml @@ -0,0 +1,18 @@ +[package] +name = "uap-bench" +version = "0.1.0" +authors = ["Nick Fitzgerald "] +edition = "2018" + +[lib] +crate-type = ["cdylib"] + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +serde = { version = "1.0.117", features = ["derive"] } +regex = "1.4.2" +serde_yaml = "0.8.14" + +[features] +wizer = [] diff --git a/crates/wizer/benches/uap-bench/README.md b/crates/wizer/benches/uap-bench/README.md new file mode 100644 index 000000000000..d5b0f25ef275 --- /dev/null +++ b/crates/wizer/benches/uap-bench/README.md @@ -0,0 +1,11 @@ +Source code used to create `/wizer/benches/uap_bench.{control,wizer}.wasm`. + +Creates a `RegexSet` from the user agent parsing regexes from the browserscope +project in the initialization function and then tests whether the input string +is a known user agent. + +Rebuild via: + +``` +$ ./build.sh +``` diff --git a/crates/wizer/benches/uap-bench/build.sh b/crates/wizer/benches/uap-bench/build.sh new file mode 100755 index 000000000000..0327f62ce014 --- /dev/null +++ b/crates/wizer/benches/uap-bench/build.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +set -ex +cd "$(dirname $0)" +cargo build --target wasm32-wasi --release +cp ../../target/wasm32-wasi/release/uap_bench.wasm ../uap_bench.control.wasm +cargo build --target wasm32-wasi --release --features wizer +cd ../.. +cargo run --all-features -- --allow-wasi target/wasm32-wasi/release/uap_bench.wasm -o benches/uap_bench.wizer.wasm diff --git a/crates/wizer/benches/uap-bench/src/lib.rs b/crates/wizer/benches/uap-bench/src/lib.rs new file mode 100644 index 000000000000..00bed5d37e7e --- /dev/null +++ b/crates/wizer/benches/uap-bench/src/lib.rs @@ -0,0 +1,67 @@ +use regex::RegexSet; +use serde::Deserialize; + +static mut UA_REGEX_SET: Option = None; + +#[derive(Deserialize)] +struct UserAgentParsers { + user_agent_parsers: Vec, +} + +#[derive(Deserialize)] +struct UserAgentParserEntry { + regex: String, + // family_replacement: Option, + // brand_replacement: Option, + // model_replacement: Option, + // os_replacement: Option, + // v1_replacement: Option, + // v2_replacement: Option, + // os_v1_replacement: Option, + // os_v2_replacement: Option, + // os_v3_replacement: Option, +} + +#[export_name = "wizer.initialize"] +pub extern "C" fn init() { + let uap_yaml = include_str!("../uap-core/regexes.yaml"); + let parsers: UserAgentParsers = serde_yaml::from_str(uap_yaml).unwrap(); + let regex_set = RegexSet::new( + parsers + .user_agent_parsers + .iter() + .map(|e| e.regex.replace("\\/", "/").replace("\\!", "!")), + ) + .unwrap(); + unsafe { + assert!(UA_REGEX_SET.is_none()); + UA_REGEX_SET = Some(regex_set); + } +} + +#[export_name = "run"] +pub extern "C" fn run(ptr: *mut u8, len: usize) -> i32 { + #[cfg(not(feature = "wizer"))] + init(); + + let s = unsafe { + let slice = std::slice::from_raw_parts(ptr, len); + std::str::from_utf8(slice).unwrap() + }; + let regex_set = unsafe { UA_REGEX_SET.as_ref().unwrap() }; + regex_set.is_match(&s) as u8 as i32 +} + +#[export_name = "alloc"] +pub extern "C" fn alloc(size: usize, align: usize) -> *mut u8 { + let layout = std::alloc::Layout::from_size_align(size, align).unwrap(); + unsafe { std::alloc::alloc(layout) } +} + +#[export_name = "dealloc"] +pub extern "C" fn dealloc(ptr: *mut u8, size: usize, align: usize) { + let layout = std::alloc::Layout::from_size_align(size, align).unwrap(); + unsafe { + std::alloc::dealloc(ptr, layout); + } +} diff --git a/crates/wizer/benches/uap-bench/uap-core b/crates/wizer/benches/uap-bench/uap-core new file mode 160000 index 000000000000..f21592418f63 --- /dev/null +++ b/crates/wizer/benches/uap-bench/uap-core @@ -0,0 +1 @@ +Subproject commit f21592418f6323f9ce32f10e231841cf8e782b43 diff --git a/crates/wizer/benches/uap.rs b/crates/wizer/benches/uap.rs new file mode 100644 index 000000000000..1ffef7043056 --- /dev/null +++ b/crates/wizer/benches/uap.rs @@ -0,0 +1,67 @@ +use criterion::{criterion_group, criterion_main, Criterion}; +use std::convert::TryFrom; + +fn run_iter(linker: &wasmtime::Linker, module: &wasmtime::Module) { + let instance = linker.instantiate(module).unwrap(); + + let ua = "Mozilla/5.0 (X11; Linux x86_64; rv:85.0) Gecko/20100101 Firefox/85.0"; + + let alloc = instance + .get_func("alloc") + .unwrap() + .get2::() + .unwrap(); + let ptr = alloc(ua.len() as u32, 1).unwrap() as usize; + + let memory = instance.get_memory("memory").unwrap(); + let data = unsafe { memory.data_unchecked_mut() }; + data[ptr..ptr + ua.len()].copy_from_slice(ua.as_bytes()); + + let run = instance.get_func("run").unwrap(); + let result = run + .call(&[ + wasmtime::Val::I32(i32::try_from(ptr).unwrap()), + wasmtime::Val::I32(5), + ]) + .unwrap(); + assert_eq!(result.len(), 1); + assert_eq!(result[0].i32(), Some(0)); + + let dealloc = instance + .get_func("dealloc") + .unwrap() + .get3::() + .unwrap(); + dealloc(ptr as u32, ua.len() as u32, 1).unwrap(); +} + +fn linker(store: &wasmtime::Store) -> wasmtime::Linker { + let mut linker = wasmtime::Linker::new(&store); + let ctx = wasmtime_wasi::WasiCtx::new(None::).unwrap(); + let wasi = wasmtime_wasi::Wasi::new(&store, ctx); + wasi.add_to_linker(&mut linker).unwrap(); + linker +} + +fn bench_uap(c: &mut Criterion) { + let mut group = c.benchmark_group("uap"); + group.bench_function("control", |b| { + let store = wasmtime::Store::default(); + let module = + wasmtime::Module::new(store.engine(), &include_bytes!("uap_bench.control.wasm")) + .unwrap(); + let linker = linker(&store); + b.iter(|| run_iter(&linker, &module)); + }); + group.bench_function("wizer", |b| { + let store = wasmtime::Store::default(); + let module = + wasmtime::Module::new(store.engine(), &include_bytes!("uap_bench.wizer.wasm")).unwrap(); + let linker = linker(&store); + b.iter(|| run_iter(&linker, &module)); + }); + group.finish(); +} + +criterion_group!(benches, bench_uap); +criterion_main!(benches); From 08773c1156ce6e8025cef920e37c0d3957d4fa65 Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Wed, 9 Dec 2020 11:26:25 -0800 Subject: [PATCH 011/212] Add a README --- crates/wizer/README.md | 156 ++++++++++++++++++++++++++++++++++++++++ crates/wizer/src/lib.rs | 4 +- 2 files changed, 158 insertions(+), 2 deletions(-) create mode 100644 crates/wizer/README.md diff --git a/crates/wizer/README.md b/crates/wizer/README.md new file mode 100644 index 000000000000..2f34dcf7e456 --- /dev/null +++ b/crates/wizer/README.md @@ -0,0 +1,156 @@ +
+

Wizer

+ +

+ The WebAssembly Pre-Initializer! +

+ + A Bytecode Alliance project + +

+ build status + zulip chat + min rustc + Documentation Status +

+ +

+ API Docs + | + Contributing + | + Chat +

+
+ +* [About](#about) +* [Install](#install) +* [Example Usage](#example-usage) +* [Caveats](#caveats) +* [Using Wizer as a Library](#using-wizer-as-a-library) +* [How Does it Work?](#how-does-it-work) + +## About + +Don't wait for your Wasm module to initialize itself, pre-initialize it! Wizer +instantiates your WebAssembly module, executes its initialization function, and +then snapshots the initialized state out into a new WebAssembly module. Now you +can use this new, pre-initialized WebAssembly module to hit the ground running, +without making your users wait for that first-time set up code to complete. + +The improvements to start up latency you can expect will depend on how much +initialization work your WebAssembly module needs to do before it's ready. Some +initial benchmarking shows between 1.35 to 6.00 times faster instantiation and +initialization with Wizer, depending on the workload: + +| Program | Without Wizer | With Wizer | Speedup | +|------------------------|--------------:|-----------:|-----------------:| +| [`regex`][regex-bench] | 248.85 us | 183.99 us | **1.35x faster** | +| [UAP][uap-bench] | 98.297 ms | 16.385 ms | **6.00x faster** | + +[regex-bench]: https://github.com/bytecodealliance/wizer/tree/main/benches/regex-bench +[uap-bench]: https://github.com/bytecodealliance/wizer/tree/main/benches/uap-bench + +The `regex` benchmark compiles a simple regular expression and tests whether it +matches an input string. When Wizer is used, the regular expression is +pre-compiled inside the initialization function. + +The UAP benchmark creates a `RegexSet` from [the user agent parsing regexes from +the BrowserScope project](https://github.com/ua-parser/uap-core) and then tests +whether the input string is a known user agent. When Wizer is used, the +`RegexSet` is pre-compiled inside the initialization function. + +Not every program will see an improvement to instantiation and start up +latency. For example, Wizer will often increase the size of the Wasm module's +`Data` section, which could negatively impact network transfer times on the +Web. However, the best way to find out if your Wasm module will see an +improvement is to try it out! Adding an initialization function isn't too hard. + +Finally, you can likely see further improvements by running +[`wasm-opt`][binaryen] on the pre-initialized module. Beyond the usual benefits +that `wasm-opt` brings, the module likely has a bunch of initialization-only +code that is no longer needed now that the module is already initialized, and +which `wasm-opt` can remove. + +[binaryen]: https://github.com/WebAssembly/binaryen + +## Install + +Install via `cargo`: + +```shell-session +$ cargo install wizer --all-features +``` + +## Example Usage + +First, make sure your Wasm module exports an initialization function named +`wizer.initialize`. For example, in Rust you can export it like this: + +```rust +#[export_name = "wizer.initialize"] +pub extern "C" fn init() { + // Your initialization code goes here... +} +``` + +Then, if your Wasm module is named `input.wasm`, run the `wizer` CLI: + +```shell-session +$ wizer input.wasm -o initialized.wasm +``` + +Now you have a pre-initialized version of your Wasm module at +`initialized.wasm`! + +More details, flags, and options can be found via `--help`: + +```shell-session +$ wizer --help +``` + +## Caveats + +* The initialization function may not call any imported functions. Doing so will + trigger a trap and `wizer` will exit. You can, however, allow WASI calls via + the `--allow-wasi` flag. + +* The Wasm module may not import globals, tables, or memories. + +* Reference types are not supported yet. It isn't 100% clear yet what the best + approach to snapshotting `externref` tables is. + +## Using Wizer as a Library + +Add a dependency in your `Cargo.toml`: + +```toml +# Cargo.toml + +[dependencies] +wizer = "" +``` + +And then use the `wizer::Wizer` builder to configure and run Wizer: + +```rust +use wizer::Wizer; + +let input_wasm = get_input_wasm_bytes(); + +let initialized_wasm_bytes = Wizer::new() + .allow_wasi(true) + .run(&input_wasm)?; +``` + +## How Does it Work? + +First we instantiate the input Wasm module with Wasmtime and run the +initialization function. Then we record the Wasm instance's state: + +* What are the values of its globals? +* What regions of memory are non-zero? + +Then we rewrite the Wasm binary by intializing its globals directly to their +recorded state, and removing the module's old data segments and replacing them +with data segments for each of the non-zero regions of memory we recorded. diff --git a/crates/wizer/src/lib.rs b/crates/wizer/src/lib.rs index 15d7bffeacc2..3d88c9eb56d9 100644 --- a/crates/wizer/src/lib.rs +++ b/crates/wizer/src/lib.rs @@ -1,4 +1,4 @@ -//! Wizer: the WebAssembly initializer! +//! Wizer: the WebAssembly pre-initializer! //! //! See the [`Wizer`] struct for details. @@ -13,7 +13,7 @@ use structopt::StructOpt; const WASM_PAGE_SIZE: u32 = 65_536; const NATIVE_PAGE_SIZE: u32 = 4_096; -/// Wizer: the WebAssembly initializer! +/// Wizer: the WebAssembly pre-initializer! /// /// Don't wait for your Wasm module to initialize itself, pre-initialize it! /// Wizer instantiates your WebAssembly module, executes its initialization From d66e9f552beb5e1ceb6549c84388e012c2b38ee5 Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Wed, 9 Dec 2020 11:45:10 -0800 Subject: [PATCH 012/212] Add CONTRIBUTING.md, CODE_OF_CONDUCT.md, and ORG_CODE_OF_CONDUCT.md --- crates/wizer/CODE_OF_CONDUCT.md | 49 ++++++++++ crates/wizer/CONTRIBUTING.md | 28 ++++++ crates/wizer/ORG_CODE_OF_CONDUCT.md | 143 ++++++++++++++++++++++++++++ 3 files changed, 220 insertions(+) create mode 100644 crates/wizer/CODE_OF_CONDUCT.md create mode 100644 crates/wizer/CONTRIBUTING.md create mode 100644 crates/wizer/ORG_CODE_OF_CONDUCT.md diff --git a/crates/wizer/CODE_OF_CONDUCT.md b/crates/wizer/CODE_OF_CONDUCT.md new file mode 100644 index 000000000000..14db69404fe7 --- /dev/null +++ b/crates/wizer/CODE_OF_CONDUCT.md @@ -0,0 +1,49 @@ +# Contributor Covenant Code of Conduct + +*Note*: this Code of Conduct pertains to individuals' behavior. Please also see the [Organizational Code of Conduct][OCoC]. + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the Bytecode Alliance CoC team at [report@bytecodealliance.org](mailto:report@bytecodealliance.org). The CoC team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The CoC team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the Bytecode Alliance's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] + +[OCoC]: https://github.com/bytecodealliance/wasmtime/blob/main/ORG_CODE_OF_CONDUCT.md +[homepage]: https://www.contributor-covenant.org +[version]: https://www.contributor-covenant.org/version/1/4/ diff --git a/crates/wizer/CONTRIBUTING.md b/crates/wizer/CONTRIBUTING.md new file mode 100644 index 000000000000..17f77c3fdb1c --- /dev/null +++ b/crates/wizer/CONTRIBUTING.md @@ -0,0 +1,28 @@ +# Contributing to Wizer + +## Code of Conduct + +Wizer is a [Bytecode Alliance] project. It follows the Bytecode Alliance's [Code +of Conduct] and [Organizational Code of Conduct]. + +[Bytecode Alliance]: https://bytecodealliance.org/ +[Code of Conduct]: CODE_OF_CONDUCT.md +[Organizational Code of Conduct]: ORG_CODE_OF_CONDUCT.md + +## Building + +``` +$ cargo build +``` + +## Testing + +``` +$ cargo test +``` + +## Benchmarking + +``` +$ cargo bench +``` diff --git a/crates/wizer/ORG_CODE_OF_CONDUCT.md b/crates/wizer/ORG_CODE_OF_CONDUCT.md new file mode 100644 index 000000000000..6f4fb3f537d1 --- /dev/null +++ b/crates/wizer/ORG_CODE_OF_CONDUCT.md @@ -0,0 +1,143 @@ +# Bytecode Alliance Organizational Code of Conduct (OCoC) + +*Note*: this Code of Conduct pertains to organizations' behavior. Please also see the [Individual Code of Conduct](CODE_OF_CONDUCT.md). + +## Preamble + +The Bytecode Alliance (BA) welcomes involvement from organizations, +including commercial organizations. This document is an +*organizational* code of conduct, intended particularly to provide +guidance to commercial organizations. It is distinct from the +[Individual Code of Conduct (ICoC)](CODE_OF_CONDUCT.md), and does not +replace the ICoC. This OCoC applies to any group of people acting in +concert as a BA member or as a participant in BA activities, whether +or not that group is formally incorporated in some jurisdiction. + +The code of conduct described below is not a set of rigid rules, and +we did not write it to encompass every conceivable scenario that might +arise. For example, it is theoretically possible there would be times +when asserting patents is in the best interest of the BA community as +a whole. In such instances, consult with the BA, strive for +consensus, and interpret these rules with an intent that is generous +to the community the BA serves. + +While we may revise these guidelines from time to time based on +real-world experience, overall they are based on a simple principle: + +*Bytecode Alliance members should observe the distinction between + public community functions and private functions — especially + commercial ones — and should ensure that the latter support, or at + least do not harm, the former.* + +## Guidelines + + * **Do not cause confusion about Wasm standards or interoperability.** + + Having an interoperable WebAssembly core is a high priority for + the BA, and members should strive to preserve that core. It is fine + to develop additional non-standard features or APIs, but they + should always be clearly distinguished from the core interoperable + Wasm. + + Treat the WebAssembly name and any BA-associated names with + respect, and follow BA trademark and branding guidelines. If you + distribute a customized version of software originally produced by + the BA, or if you build a product or service using BA-derived + software, use names that clearly distinguish your work from the + original. (You should still provide proper attribution to the + original, of course, wherever such attribution would normally be + given.) + + Further, do not use the WebAssembly name or BA-associated names in + other public namespaces in ways that could cause confusion, e.g., + in company names, names of commercial service offerings, domain + names, publicly-visible social media accounts or online service + accounts, etc. It may sometimes be reasonable, however, to + register such a name in a new namespace and then immediately donate + control of that account to the BA, because that would help the project + maintain its identity. + + For further guidance, see the BA Trademark and Branding Policy + [TODO: create policy, then insert link]. + + * **Do not restrict contributors.** If your company requires + employees or contractors to sign non-compete agreements, those + agreements must not prevent people from participating in the BA or + contributing to related projects. + + This does not mean that all non-compete agreements are incompatible + with this code of conduct. For example, a company may restrict an + employee's ability to solicit the company's customers. However, an + agreement must not block any form of technical or social + participation in BA activities, including but not limited to the + implementation of particular features. + + The accumulation of experience and expertise in individual persons, + who are ultimately free to direct their energy and attention as + they decide, is one of the most important drivers of progress in + open source projects. A company that limits this freedom may hinder + the success of the BA's efforts. + + * **Do not use patents as offensive weapons.** If any BA participant + prevents the adoption or development of BA technologies by + asserting its patents, that undermines the purpose of the + coalition. The collaboration fostered by the BA cannot include + members who act to undermine its work. + + * **Practice responsible disclosure** for security vulnerabilities. + Use designated, non-public reporting channels to disclose technical + vulnerabilities, and give the project a reasonable period to + respond, remediate, and patch. [TODO: optionally include the + security vulnerability reporting URL here.] + + Vulnerability reporters may patch their company's own offerings, as + long as that patching does not significantly delay the reporting of + the vulnerability. Vulnerability information should never be used + for unilateral commercial advantage. Vendors may legitimately + compete on the speed and reliability with which they deploy + security fixes, but withholding vulnerability information damages + everyone in the long run by risking harm to the BA project's + reputation and to the security of all users. + + * **Respect the letter and spirit of open source practice.** While + there is not space to list here all possible aspects of standard + open source practice, some examples will help show what we mean: + + * Abide by all applicable open source license terms. Do not engage + in copyright violation or misattribution of any kind. + + * Do not claim others' ideas or designs as your own. + + * When others engage in publicly visible work (e.g., an upcoming + demo that is coordinated in a public issue tracker), do not + unilaterally announce early releases or early demonstrations of + that work ahead of their schedule in order to secure private + advantage (such as marketplace advantage) for yourself. + + The BA reserves the right to determine what constitutes good open + source practices and to take action as it deems appropriate to + encourage, and if necessary enforce, such practices. + +## Enforcement + +Instances of organizational behavior in violation of the OCoC may +be reported by contacting the Bytecode Alliance CoC team at +[report@bytecodealliance.org](mailto:report@bytecodealliance.org). The +CoC team will review and investigate all complaints, and will respond +in a way that it deems appropriate to the circumstances. The CoC team +is obligated to maintain confidentiality with regard to the reporter of +an incident. Further details of specific enforcement policies may be +posted separately. + +When the BA deems an organization in violation of this OCoC, the BA +will, at its sole discretion, determine what action to take. The BA +will decide what type, degree, and duration of corrective action is +needed, if any, before a violating organization can be considered for +membership (if it was not already a member) or can have its membership +reinstated (if it was a member and the BA canceled its membership due +to the violation). + +In practice, the BA's first approach will be to start a conversation, +with punitive enforcement used only as a last resort. Violations +often turn out to be unintentional and swiftly correctable with all +parties acting in good faith. From 1a7bc3d8d3cc8adba94ad60a3532500a2c14c59b Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Wed, 9 Dec 2020 11:49:33 -0800 Subject: [PATCH 013/212] Add Cargo.toml metadata; license file --- crates/wizer/Cargo.toml | 11 +- crates/wizer/LICENSE | 220 ++++++++++++++++++++++++++++++++++++++++ crates/wizer/README.md | 2 +- 3 files changed, 230 insertions(+), 3 deletions(-) create mode 100644 crates/wizer/LICENSE diff --git a/crates/wizer/Cargo.toml b/crates/wizer/Cargo.toml index 3e4abcc471fc..316a0cc4aaab 100644 --- a/crates/wizer/Cargo.toml +++ b/crates/wizer/Cargo.toml @@ -1,8 +1,15 @@ [package] -name = "wizer" -version = "0.1.0" authors = ["Nick Fitzgerald "] +categories = ["command-line-utilities", "development-tools", "wasm"] +description = "The WebAssembly Pre-Initializer" +documentation = "https://docs.rs/wizer" edition = "2018" +homepage = "https://github.com/bytecodealliance/wizer" +license = "Apache-2.0 WITH LLVM-exception" +name = "wizer" +readme = "./README.md" +repository = "https://github.com/bytecodealliance/wizer" +version = "1.0.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/crates/wizer/LICENSE b/crates/wizer/LICENSE new file mode 100644 index 000000000000..f9d81955f4bc --- /dev/null +++ b/crates/wizer/LICENSE @@ -0,0 +1,220 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + +--- LLVM Exceptions to the Apache 2.0 License ---- + +As an exception, if, as a result of your compiling your source code, portions +of this Software are embedded into an Object form of such source code, you +may redistribute such embedded portions in such Object form without complying +with the conditions of Sections 4(a), 4(b) and 4(d) of the License. + +In addition, if you combine or link compiled forms of this Software with +software that is licensed under the GPLv2 ("Combined Software") and if a +court of competent jurisdiction determines that the patent provision (Section +3), the indemnity provision (Section 9) or other Section of the License +conflicts with the conditions of the GPLv2, you may retroactively and +prospectively choose to deem waived or otherwise exclude such Section(s) of +the License, but only in their entirety and only with respect to the Combined +Software. + diff --git a/crates/wizer/README.md b/crates/wizer/README.md index 2f34dcf7e456..c3a099ea2b0a 100644 --- a/crates/wizer/README.md +++ b/crates/wizer/README.md @@ -128,7 +128,7 @@ Add a dependency in your `Cargo.toml`: # Cargo.toml [dependencies] -wizer = "" +wizer = "1" ``` And then use the `wizer::Wizer` builder to configure and run Wizer: From fa7aa0fb69f4290e2905431c9384e1dd8ae8491b Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Wed, 9 Dec 2020 11:51:42 -0800 Subject: [PATCH 014/212] README: don't spend too much time talking about the benchmark programs We link to them and their READMEs anyways --- crates/wizer/README.md | 9 --------- 1 file changed, 9 deletions(-) diff --git a/crates/wizer/README.md b/crates/wizer/README.md index c3a099ea2b0a..979112679232 100644 --- a/crates/wizer/README.md +++ b/crates/wizer/README.md @@ -51,15 +51,6 @@ initialization with Wizer, depending on the workload: [regex-bench]: https://github.com/bytecodealliance/wizer/tree/main/benches/regex-bench [uap-bench]: https://github.com/bytecodealliance/wizer/tree/main/benches/uap-bench -The `regex` benchmark compiles a simple regular expression and tests whether it -matches an input string. When Wizer is used, the regular expression is -pre-compiled inside the initialization function. - -The UAP benchmark creates a `RegexSet` from [the user agent parsing regexes from -the BrowserScope project](https://github.com/ua-parser/uap-core) and then tests -whether the input string is a known user agent. When Wizer is used, the -`RegexSet` is pre-compiled inside the initialization function. - Not every program will see an improvement to instantiation and start up latency. For example, Wizer will often increase the size of the Wasm module's `Data` section, which could negatively impact network transfer times on the From eff88f0a2bced56a2de0e43a9c7640fa04ee6ae4 Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Wed, 9 Dec 2020 12:03:02 -0800 Subject: [PATCH 015/212] Don't commit to a minimum rust version at the moment --- crates/wizer/README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/crates/wizer/README.md b/crates/wizer/README.md index 979112679232..4b000939ab1f 100644 --- a/crates/wizer/README.md +++ b/crates/wizer/README.md @@ -10,7 +10,6 @@

build status zulip chat - min rustc Documentation Status

From 350285477bba4a8e230aebb3e96443cfcc793f0f Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Thu, 7 Jan 2021 14:38:46 -0800 Subject: [PATCH 016/212] deps: Update `wasm-encoder` to version 0.3.1 --- crates/wizer/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/wizer/Cargo.toml b/crates/wizer/Cargo.toml index 316a0cc4aaab..6d2faeace963 100644 --- a/crates/wizer/Cargo.toml +++ b/crates/wizer/Cargo.toml @@ -30,7 +30,7 @@ anyhow = "1.0.34" env_logger = { version = "0.8.1", optional = true } log = "0.4.11" structopt = { version = "0.3.20", optional = true } -wasm-encoder = "0.1.0" +wasm-encoder = "0.3.1" wasmparser = "0.68.0" wasmtime = "0.21.0" wasmtime-wasi = "0.21.0" From 36fd4c25b04fd9f9f19a5265eccf00c3f754c571 Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Thu, 7 Jan 2021 14:39:58 -0800 Subject: [PATCH 017/212] Bump to version 1.0.1 --- crates/wizer/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/wizer/Cargo.toml b/crates/wizer/Cargo.toml index 6d2faeace963..5f92b4ac5be0 100644 --- a/crates/wizer/Cargo.toml +++ b/crates/wizer/Cargo.toml @@ -9,7 +9,7 @@ license = "Apache-2.0 WITH LLVM-exception" name = "wizer" readme = "./README.md" repository = "https://github.com/bytecodealliance/wizer" -version = "1.0.0" +version = "1.0.1" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html From 0aed20b69fc2c77b50914a668f865c364d9605de Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Thu, 7 Jan 2021 14:42:09 -0800 Subject: [PATCH 018/212] Keep the `Cargo.lock` file in git history --- crates/wizer/.gitignore | 1 - crates/wizer/Cargo.lock | 1925 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 1925 insertions(+), 1 deletion(-) create mode 100644 crates/wizer/Cargo.lock diff --git a/crates/wizer/.gitignore b/crates/wizer/.gitignore index 96ef6c0b944e..ea8c4bf7f35f 100644 --- a/crates/wizer/.gitignore +++ b/crates/wizer/.gitignore @@ -1,2 +1 @@ /target -Cargo.lock diff --git a/crates/wizer/Cargo.lock b/crates/wizer/Cargo.lock new file mode 100644 index 000000000000..74619b411cb2 --- /dev/null +++ b/crates/wizer/Cargo.lock @@ -0,0 +1,1925 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "addr2line" +version = "0.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a55f82cfe485775d02112886f4169bde0c5894d75e79ead7eafe7e40a25e45f7" +dependencies = [ + "gimli 0.23.0", +] + +[[package]] +name = "adler" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee2a4ec343196209d6594e19543ae87a39f96d5534d7174822a3ad825dd6ed7e" + +[[package]] +name = "aho-corasick" +version = "0.7.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7404febffaa47dac81aa44dba71523c9d069b1bdc50a77db41195149e17f68e5" +dependencies = [ + "memchr", +] + +[[package]] +name = "ansi_term" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" +dependencies = [ + "winapi", +] + +[[package]] +name = "anyhow" +version = "1.0.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee67c11feeac938fae061b232e38e0b6d94f97a9df10e6271319325ac4c56a86" + +[[package]] +name = "atty" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +dependencies = [ + "hermit-abi", + "libc", + "winapi", +] + +[[package]] +name = "autocfg" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" + +[[package]] +name = "backtrace" +version = "0.3.55" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef5140344c85b01f9bbb4d4b7288a8aa4b3287ccef913a14bcc78a1063623598" +dependencies = [ + "addr2line", + "cfg-if 1.0.0", + "libc", + "miniz_oxide", + "object 0.22.0", + "rustc-demangle", +] + +[[package]] +name = "base64" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3441f0f7b02788e948e47f457ca01f1d7e6d92c693bc132c22b087d3141c03ff" + +[[package]] +name = "bincode" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f30d3a39baa26f9651f17b375061f3233dde33424a8b72b0dbe93a68a0bc896d" +dependencies = [ + "byteorder", + "serde", +] + +[[package]] +name = "bitflags" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" + +[[package]] +name = "block-buffer" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" +dependencies = [ + "block-padding", + "byte-tools", + "byteorder", + "generic-array", +] + +[[package]] +name = "block-padding" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5" +dependencies = [ + "byte-tools", +] + +[[package]] +name = "bstr" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "473fc6b38233f9af7baa94fb5852dca389e3d95b8e21c8e3719301462c5d9faf" +dependencies = [ + "lazy_static", + "memchr", + "regex-automata", + "serde", +] + +[[package]] +name = "bumpalo" +version = "3.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e8c087f005730276d1096a652e92a8bacee2e2472bcc9715a74d2bec38b5820" + +[[package]] +name = "byte-tools" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" + +[[package]] +name = "byteorder" +version = "1.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" + +[[package]] +name = "cast" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b9434b9a5aa1450faa3f9cb14ea0e8c53bb5d2b3c1bfd1ab4fc03e9f33fbfb0" +dependencies = [ + "rustc_version", +] + +[[package]] +name = "cc" +version = "1.0.66" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c0496836a84f8d0495758516b8621a622beb77c0fed418570e50764093ced48" +dependencies = [ + "jobserver", +] + +[[package]] +name = "cfg-if" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "clap" +version = "2.33.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002" +dependencies = [ + "ansi_term", + "atty", + "bitflags", + "strsim", + "textwrap", + "unicode-width", + "vec_map", +] + +[[package]] +name = "const_fn" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28b9d6de7f49e22cf97ad17fc4036ece69300032f45f78f30b4a4482cdc3f4a6" + +[[package]] +name = "cpu-time" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9e393a7668fe1fad3075085b86c781883000b4ede868f43627b34a87c8b7ded" +dependencies = [ + "libc", + "winapi", +] + +[[package]] +name = "cranelift-bforest" +version = "0.68.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9221545c0507dc08a62b2d8b5ffe8e17ac580b0a74d1813b496b8d70b070fbd0" +dependencies = [ + "cranelift-entity", +] + +[[package]] +name = "cranelift-codegen" +version = "0.68.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e9936ea608b6cd176f107037f6adbb4deac933466fc7231154f96598b2d3ab1" +dependencies = [ + "byteorder", + "cranelift-bforest", + "cranelift-codegen-meta", + "cranelift-codegen-shared", + "cranelift-entity", + "gimli 0.22.0", + "log", + "regalloc", + "serde", + "smallvec", + "target-lexicon", + "thiserror", +] + +[[package]] +name = "cranelift-codegen-meta" +version = "0.68.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ef2b2768568306540f4c8db3acce9105534d34c4a1e440529c1e702d7f8c8d7" +dependencies = [ + "cranelift-codegen-shared", + "cranelift-entity", +] + +[[package]] +name = "cranelift-codegen-shared" +version = "0.68.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6759012d6d19c4caec95793f052613e9d4113e925e7f14154defbac0f1d4c938" + +[[package]] +name = "cranelift-entity" +version = "0.68.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86badbce14e15f52a45b666b38abe47b204969dd7f8fb7488cb55dd46b361fa6" +dependencies = [ + "serde", +] + +[[package]] +name = "cranelift-frontend" +version = "0.68.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b608bb7656c554d0a4cf8f50c7a10b857e80306f6ff829ad6d468a7e2323c8d8" +dependencies = [ + "cranelift-codegen", + "log", + "smallvec", + "target-lexicon", +] + +[[package]] +name = "cranelift-native" +version = "0.68.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5246a1af14b7812ee4d94a3f0c4b295ec02c370c08b0ecc3dec512890fdad175" +dependencies = [ + "cranelift-codegen", + "raw-cpuid", + "target-lexicon", +] + +[[package]] +name = "cranelift-wasm" +version = "0.68.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ef491714e82f9fb910547e2047a3b1c47c03861eca67540c5abd0416371a2ac" +dependencies = [ + "cranelift-codegen", + "cranelift-entity", + "cranelift-frontend", + "itertools", + "log", + "serde", + "smallvec", + "thiserror", + "wasmparser 0.65.0", +] + +[[package]] +name = "crc32fast" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81156fece84ab6a9f2afdb109ce3ae577e42b1228441eded99bd77f627953b1a" +dependencies = [ + "cfg-if 1.0.0", +] + +[[package]] +name = "criterion" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70daa7ceec6cf143990669a04c7df13391d55fb27bd4079d252fca774ba244d8" +dependencies = [ + "atty", + "cast", + "clap", + "criterion-plot", + "csv", + "itertools", + "lazy_static", + "num-traits", + "oorandom", + "plotters", + "rayon", + "regex", + "serde", + "serde_cbor", + "serde_derive", + "serde_json", + "tinytemplate", + "walkdir", +] + +[[package]] +name = "criterion-plot" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e022feadec601fba1649cfa83586381a4ad31c6bf3a9ab7d408118b05dd9889d" +dependencies = [ + "cast", + "itertools", +] + +[[package]] +name = "crossbeam-channel" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dca26ee1f8d361640700bde38b2c37d8c22b3ce2d360e1fc1c74ea4b0aa7d775" +dependencies = [ + "cfg-if 1.0.0", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-deque" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94af6efb46fef72616855b036a624cf27ba656ffc9be1b9a3c931cfc7749a9a9" +dependencies = [ + "cfg-if 1.0.0", + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1aaa739f95311c2c7887a76863f500026092fb1dce0161dab577e559ef3569d" +dependencies = [ + "cfg-if 1.0.0", + "const_fn", + "crossbeam-utils", + "lazy_static", + "memoffset 0.6.1", + "scopeguard", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02d96d1e189ef58269ebe5b97953da3274d83a93af647c2ddd6f9dab28cedb8d" +dependencies = [ + "autocfg", + "cfg-if 1.0.0", + "lazy_static", +] + +[[package]] +name = "csv" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9d58633299b24b515ac72a3f869f8b91306a3cec616a602843a383acd6f9e97" +dependencies = [ + "bstr", + "csv-core", + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "csv-core" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b2466559f260f48ad25fe6317b3c8dac77b5bdb5763ac7d9d6103530663bc90" +dependencies = [ + "memchr", +] + +[[package]] +name = "cvt" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34ac344c7efccb80cd25bc61b2170aec26f2f693fd40e765a539a1243db48c71" +dependencies = [ + "cfg-if 0.1.10", +] + +[[package]] +name = "digest" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" +dependencies = [ + "generic-array", +] + +[[package]] +name = "directories-next" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a28ccebc1239c5c57f0c55986e2ac03f49af0d0ca3dff29bfcad39d60a8be56" +dependencies = [ + "cfg-if 1.0.0", + "dirs-sys-next", +] + +[[package]] +name = "dirs-next" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b98cf8ebf19c3d1b223e151f99a4f9f0690dca41414773390fc824184ac833e1" +dependencies = [ + "cfg-if 1.0.0", + "dirs-sys-next", +] + +[[package]] +name = "dirs-sys-next" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99de365f605554ae33f115102a02057d4fc18b01f3284d6870be0938743cfe7d" +dependencies = [ + "libc", + "redox_users", + "winapi", +] + +[[package]] +name = "dtoa" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88d7ed2934d741c6b37e33e3832298e8850b53fd2d2bea03873375596c7cea4e" + +[[package]] +name = "either" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" + +[[package]] +name = "env_logger" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36" +dependencies = [ + "atty", + "humantime 1.3.0", + "log", + "regex", + "termcolor", +] + +[[package]] +name = "env_logger" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26ecb66b4bdca6c1409b40fb255eefc2bd4f6d135dab3c3124f80ffa2a9661e" +dependencies = [ + "atty", + "humantime 2.0.1", + "log", + "regex", + "termcolor", +] + +[[package]] +name = "errno" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa68f2fb9cae9d37c9b2b3584aba698a2e97f72d7aef7b9f7aa71d8b54ce46fe" +dependencies = [ + "errno-dragonfly", + "libc", + "winapi", +] + +[[package]] +name = "errno-dragonfly" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14ca354e36190500e1e1fb267c647932382b54053c50b14970856c0b00a35067" +dependencies = [ + "gcc", + "libc", +] + +[[package]] +name = "fake-simd" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" + +[[package]] +name = "fallible-iterator" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" + +[[package]] +name = "file-per-thread-logger" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fdbe0d94371f9ce939b555dd342d0686cc4c0cadbcd4b61d70af5ff97eb4126" +dependencies = [ + "env_logger 0.7.1", + "log", +] + +[[package]] +name = "filetime" +version = "0.2.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c122a393ea57648015bf06fbd3d372378992e86b9ff5a7a497b076a28c79efe" +dependencies = [ + "cfg-if 1.0.0", + "libc", + "redox_syscall", + "winapi", +] + +[[package]] +name = "gcc" +version = "0.3.55" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" + +[[package]] +name = "generic-array" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec" +dependencies = [ + "typenum", +] + +[[package]] +name = "getrandom" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" +dependencies = [ + "cfg-if 1.0.0", + "libc", + "wasi", +] + +[[package]] +name = "gimli" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aaf91faf136cb47367fa430cd46e37a788775e7fa104f8b4bcb3861dc389b724" +dependencies = [ + "fallible-iterator", + "indexmap", + "stable_deref_trait", +] + +[[package]] +name = "gimli" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6503fe142514ca4799d4c26297c4248239fe8838d827db6bd6065c6ed29a6ce" + +[[package]] +name = "glob" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" + +[[package]] +name = "half" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d36fab90f82edc3c747f9d438e06cf0a491055896f2a279638bb5beed6c40177" + +[[package]] +name = "hashbrown" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04" + +[[package]] +name = "heck" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cbf45460356b7deeb5e3415b5563308c0a9b057c85e12b06ad551f98d0a6ac" +dependencies = [ + "unicode-segmentation", +] + +[[package]] +name = "hermit-abi" +version = "0.1.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5aca5565f760fb5b220e499d72710ed156fdb74e631659e99377d9ebfbd13ae8" +dependencies = [ + "libc", +] + +[[package]] +name = "humantime" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f" +dependencies = [ + "quick-error", +] + +[[package]] +name = "humantime" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c1ad908cc71012b7bea4d0c53ba96a8cba9962f048fa68d143376143d863b7a" + +[[package]] +name = "indexmap" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fb1fa934250de4de8aef298d81c729a7d33d8c239daa3a7575e6b92bfc7313b" +dependencies = [ + "autocfg", + "hashbrown", + "serde", +] + +[[package]] +name = "itertools" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "284f18f85651fe11e8a991b2adb42cb078325c996ed026d994719efcfca1d54b" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736" + +[[package]] +name = "jobserver" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c71313ebb9439f74b00d9d2dcec36440beaf57a6aa0623068441dd7cd81a7f2" +dependencies = [ + "libc", +] + +[[package]] +name = "js-sys" +version = "0.3.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf3d7383929f7c9c7c2d0fa596f325832df98c3704f2c60553080f7127a58175" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "leb128" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3576a87f2ba00f6f106fdfcd16db1d698d648a26ad8e0573cad8537c3c362d2a" + +[[package]] +name = "libc" +version = "0.2.81" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1482821306169ec4d07f6aca392a4681f66c75c9918aa49641a2595db64053cb" + +[[package]] +name = "linked-hash-map" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8dd5a6d5999d9907cda8ed67bbd137d3af8085216c2ac62de5be860bd41f304a" + +[[package]] +name = "log" +version = "0.4.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fabed175da42fed1fa0746b0ea71f412aa9d35e76e95e59b192c64b9dc2bf8b" +dependencies = [ + "cfg-if 0.1.10", +] + +[[package]] +name = "mach" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b823e83b2affd8f40a9ee8c29dbc56404c1e34cd2710921f2801e2cf29527afa" +dependencies = [ + "libc", +] + +[[package]] +name = "memchr" +version = "2.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525" + +[[package]] +name = "memoffset" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "043175f069eda7b85febe4a74abbaeff828d9f8b448515d3151a14a3542811aa" +dependencies = [ + "autocfg", +] + +[[package]] +name = "memoffset" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "157b4208e3059a8f9e78d559edc658e13df41410cb3ae03979c83130067fdd87" +dependencies = [ + "autocfg", +] + +[[package]] +name = "miniz_oxide" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f2d26ec3309788e423cfbf68ad1800f061638098d76a83681af979dc4eda19d" +dependencies = [ + "adler", + "autocfg", +] + +[[package]] +name = "more-asserts" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0debeb9fcf88823ea64d64e4a815ab1643f33127d995978e099942ce38f25238" + +[[package]] +name = "num-traits" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" +dependencies = [ + "autocfg", +] + +[[package]] +name = "num_cpus" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3" +dependencies = [ + "hermit-abi", + "libc", +] + +[[package]] +name = "object" +version = "0.21.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37fd5004feb2ce328a52b0b3d01dbf4ffff72583493900ed15f22d4111c51693" +dependencies = [ + "crc32fast", + "indexmap", + "wasmparser 0.57.0", +] + +[[package]] +name = "object" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d3b63360ec3cb337817c2dbd47ab4a0f170d285d8e5a2064600f3def1402397" + +[[package]] +name = "oorandom" +version = "11.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575" + +[[package]] +name = "opaque-debug" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" + +[[package]] +name = "pin-project-lite" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e36743d754ccdf9954c2e352ce2d4b106e024c814f6499c2dadff80da9a442d8" + +[[package]] +name = "plotters" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d1685fbe7beba33de0330629da9d955ac75bd54f33d7b79f9a895590124f6bb" +dependencies = [ + "js-sys", + "num-traits", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "proc-macro-error" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" +dependencies = [ + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn", + "version_check", +] + +[[package]] +name = "proc-macro-error-attr" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" +dependencies = [ + "proc-macro2", + "quote", + "version_check", +] + +[[package]] +name = "proc-macro2" +version = "1.0.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "psm" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3abf49e5417290756acfd26501536358560c4a5cc4a0934d390939acb3e7083a" +dependencies = [ + "cc", +] + +[[package]] +name = "quick-error" +version = "1.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" + +[[package]] +name = "quote" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "991431c3519a3f36861882da93630ce66b52918dcf1b8e2fd66b397fc96f28df" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "raw-cpuid" +version = "7.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "beb71f708fe39b2c5e98076204c3cc094ee5a4c12c4cdb119a2b72dc34164f41" +dependencies = [ + "bitflags", + "cc", + "rustc_version", +] + +[[package]] +name = "rayon" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b0d8e0819fadc20c74ea8373106ead0600e3a67ef1fe8da56e39b9ae7275674" +dependencies = [ + "autocfg", + "crossbeam-deque", + "either", + "rayon-core", +] + +[[package]] +name = "rayon-core" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ab346ac5921dc62ffa9f89b7a773907511cdfa5490c572ae9be1be33e8afa4a" +dependencies = [ + "crossbeam-channel", + "crossbeam-deque", + "crossbeam-utils", + "lazy_static", + "num_cpus", +] + +[[package]] +name = "redox_syscall" +version = "0.1.57" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" + +[[package]] +name = "redox_users" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de0737333e7a9502c789a36d7c7fa6092a49895d4faa31ca5df163857ded2e9d" +dependencies = [ + "getrandom", + "redox_syscall", +] + +[[package]] +name = "regalloc" +version = "0.0.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "571f7f397d61c4755285cd37853fe8e03271c243424a907415909379659381c5" +dependencies = [ + "log", + "rustc-hash", + "smallvec", +] + +[[package]] +name = "regex" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38cf2c13ed4745de91a5eb834e11c00bcc3709e773173b2ce4c56c9fbde04b9c" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", + "thread_local", +] + +[[package]] +name = "regex-automata" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae1ded71d66a4a97f5e961fd0cb25a5f366a42a41570d16a763a69c092c26ae4" +dependencies = [ + "byteorder", +] + +[[package]] +name = "regex-bench" +version = "0.1.0" +dependencies = [ + "regex", +] + +[[package]] +name = "regex-syntax" +version = "0.6.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b181ba2dcf07aaccad5448e8ead58db5b742cf85dfe035e2227f137a539a189" + +[[package]] +name = "regex-test" +version = "0.1.0" +dependencies = [ + "regex", +] + +[[package]] +name = "region" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877e54ea2adcd70d80e9179344c97f93ef0dffd6b03e1f4529e6e83ab2fa9ae0" +dependencies = [ + "bitflags", + "libc", + "mach", + "winapi", +] + +[[package]] +name = "rustc-demangle" +version = "0.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e3bad0ee36814ca07d7968269dd4b7ec89ec2da10c4bb613928d3077083c232" + +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + +[[package]] +name = "rustc_version" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" +dependencies = [ + "semver", +] + +[[package]] +name = "ryu" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" + +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "scopeguard" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" + +[[package]] +name = "scroll" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fda28d4b4830b807a8b43f7b0e6b5df875311b3e7621d84577188c175b6ec1ec" +dependencies = [ + "scroll_derive", +] + +[[package]] +name = "scroll_derive" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b12bd20b94c7cdfda8c7ba9b92ad0d9a56e3fa018c25fca83b51aa664c9b4c0d" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "semver" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" +dependencies = [ + "semver-parser", +] + +[[package]] +name = "semver-parser" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" + +[[package]] +name = "serde" +version = "1.0.118" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06c64263859d87aa2eb554587e2d23183398d617427327cf2b3d0ed8c69e4800" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_cbor" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e18acfa2f90e8b735b2836ab8d538de304cbb6729a7360729ea5a895d15a622" +dependencies = [ + "half", + "serde", +] + +[[package]] +name = "serde_derive" +version = "1.0.118" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c84d3526699cd55261af4b941e4e725444df67aa4f9e6a3564f18030d12672df" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.61" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fceb2595057b6891a4ee808f70054bd2d12f0e97f1cbb78689b59f676df325a" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "serde_yaml" +version = "0.8.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "971be8f6e4d4a47163b405a3df70d14359186f9ab0f3a3ec37df144ca1ce089f" +dependencies = [ + "dtoa", + "linked-hash-map", + "serde", + "yaml-rust", +] + +[[package]] +name = "sha2" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a256f46ea78a0c0d9ff00077504903ac881a1dafdc20da66545699e7776b3e69" +dependencies = [ + "block-buffer", + "digest", + "fake-simd", + "opaque-debug", +] + +[[package]] +name = "shellexpand" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83bdb7831b2d85ddf4a7b148aa19d0587eddbe8671a436b7bd1182eaad0f2829" +dependencies = [ + "dirs-next", +] + +[[package]] +name = "smallvec" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a55ca5f3b68e41c979bf8c46a6f1da892ca4db8f94023ce0bd32407573b1ac0" + +[[package]] +name = "stable_deref_trait" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" + +[[package]] +name = "strsim" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" + +[[package]] +name = "structopt" +version = "0.3.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5277acd7ee46e63e5168a80734c9f6ee81b1367a7d8772a2d765df2a3705d28c" +dependencies = [ + "clap", + "lazy_static", + "structopt-derive", +] + +[[package]] +name = "structopt-derive" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ba9cdfda491b814720b6b06e0cac513d922fc407582032e8706e9f137976f90" +dependencies = [ + "heck", + "proc-macro-error", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "syn" +version = "1.0.58" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc60a3d73ea6594cd712d830cc1f0390fd71542d8c8cd24e70cc54cdfd5e05d5" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "target-lexicon" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ee5a98e506fb7231a304c3a1bd7c132a55016cf65001e0282480665870dfcb9" + +[[package]] +name = "termcolor" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dfed899f0eb03f32ee8c6a0aabdb8a7949659e3466561fc0adf54e26d88c5f4" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "textwrap" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" +dependencies = [ + "unicode-width", +] + +[[package]] +name = "thiserror" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76cc616c6abf8c8928e2fdcc0dbfab37175edd8fb49a4641066ad1364fdab146" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9be73a2caec27583d0046ef3796c3794f868a5bc813db689eed00c7631275cd1" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "thread_local" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14" +dependencies = [ + "lazy_static", +] + +[[package]] +name = "tinytemplate" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2ada8616fad06a2d0c455adc530de4ef57605a8120cc65da9653e0e9623ca74" +dependencies = [ + "serde", + "serde_json", +] + +[[package]] +name = "toml" +version = "0.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a31142970826733df8241ef35dc040ef98c679ab14d7c3e54d827099b3acecaa" +dependencies = [ + "serde", +] + +[[package]] +name = "tracing" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f47026cdc4080c07e49b37087de021820269d996f581aac150ef9e5583eefe3" +dependencies = [ + "cfg-if 1.0.0", + "log", + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80e0ccfc3378da0cce270c946b676a376943f5cd16aeba64568e7939806f4ada" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tracing-core" +version = "0.1.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f50de3927f93d202783f4513cda820ab47ef17f624b03c096e86ef00c67e6b5f" +dependencies = [ + "lazy_static", +] + +[[package]] +name = "typenum" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "373c8a200f9e67a0c95e62a4f52fbf80c23b4381c05a17845531982fa99e6b33" + +[[package]] +name = "uap-bench" +version = "0.1.0" +dependencies = [ + "regex", + "serde", + "serde_yaml", +] + +[[package]] +name = "unicode-segmentation" +version = "1.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb0d2e7be6ae3a5fa87eed5fb451aff96f2573d2694942e40543ae0bbe19c796" + +[[package]] +name = "unicode-width" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3" + +[[package]] +name = "unicode-xid" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" + +[[package]] +name = "vec_map" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" + +[[package]] +name = "version_check" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed" + +[[package]] +name = "walkdir" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "777182bc735b6424e1a57516d35ed72cb8019d85c8c9bf536dccb3445c1a2f7d" +dependencies = [ + "same-file", + "winapi", + "winapi-util", +] + +[[package]] +name = "wasi" +version = "0.9.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" + +[[package]] +name = "wasi-common" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b02e7034147dcfbfe1f45f648061bb6007419b62c2e0d9e9d4930bae0c772d0" +dependencies = [ + "anyhow", + "cfg-if 1.0.0", + "cpu-time", + "filetime", + "getrandom", + "lazy_static", + "libc", + "thiserror", + "tracing", + "wig", + "wiggle", + "winapi", + "winx", + "yanix", +] + +[[package]] +name = "wasm-bindgen" +version = "0.2.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3cd364751395ca0f68cafb17666eee36b63077fb5ecd972bbcd74c90c4bf736e" +dependencies = [ + "cfg-if 1.0.0", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1114f89ab1f4106e5b55e688b828c0ab0ea593a1ea7c094b141b14cbaaec2d62" +dependencies = [ + "bumpalo", + "lazy_static", + "log", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a6ac8995ead1f084a8dea1e65f194d0973800c7f571f6edd70adf06ecf77084" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5a48c72f299d80557c7c62e37e7225369ecc0c963964059509fbafe917c7549" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e7811dd7f9398f14cc76efd356f98f03aa30419dea46aa810d71e819fc97158" + +[[package]] +name = "wasm-encoder" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de1e5cf9b74ddfb73b85e09c95ce8b5992fe32ec5200cca44a8a4e85b1095670" +dependencies = [ + "leb128", +] + +[[package]] +name = "wasmparser" +version = "0.57.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32fddd575d477c6e9702484139cf9f23dcd554b06d185ed0f56c857dd3a47aa6" + +[[package]] +name = "wasmparser" +version = "0.65.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc2fe6350834b4e528ba0901e7aa405d78b89dc1fa3145359eb4de0e323fcf" + +[[package]] +name = "wasmparser" +version = "0.68.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29a00e14eed9c2ecbbdbdd4fb284f49d21b6808965de24769a6379a13ec47d4c" + +[[package]] +name = "wasmtime" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a4d945221f4d29feecdac80514c1ef1527dfcdcc7715ff1b4a5161fe5c8ebab" +dependencies = [ + "anyhow", + "backtrace", + "bincode", + "cfg-if 1.0.0", + "lazy_static", + "libc", + "log", + "region", + "rustc-demangle", + "serde", + "smallvec", + "target-lexicon", + "wasmparser 0.65.0", + "wasmtime-cache", + "wasmtime-environ", + "wasmtime-jit", + "wasmtime-profiling", + "wasmtime-runtime", + "wat", + "winapi", +] + +[[package]] +name = "wasmtime-cache" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b27d71f896587548eeafb5f63daad596330fd161620d9048e251917926622fb5" +dependencies = [ + "anyhow", + "base64", + "bincode", + "directories-next", + "errno", + "file-per-thread-logger", + "libc", + "log", + "serde", + "sha2", + "toml", + "winapi", + "zstd", +] + +[[package]] +name = "wasmtime-cranelift" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1e55c17317922951a9bdd5547b527d2cc7be3cea118dc17ad7c05a4c8e67c7a" +dependencies = [ + "cranelift-codegen", + "cranelift-entity", + "cranelift-frontend", + "cranelift-wasm", + "wasmtime-environ", +] + +[[package]] +name = "wasmtime-debug" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a576daa6b228f8663c38bede2f7f23d094d578b0061c39fc122cc28eee1e2c18" +dependencies = [ + "anyhow", + "gimli 0.22.0", + "more-asserts", + "object 0.21.1", + "target-lexicon", + "thiserror", + "wasmparser 0.65.0", + "wasmtime-environ", +] + +[[package]] +name = "wasmtime-environ" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "396ceda32fd67205235c098e092a85716942883bfd2c773c250cf5f2457b8307" +dependencies = [ + "anyhow", + "cfg-if 1.0.0", + "cranelift-codegen", + "cranelift-entity", + "cranelift-wasm", + "gimli 0.22.0", + "indexmap", + "log", + "more-asserts", + "serde", + "thiserror", + "wasmparser 0.65.0", +] + +[[package]] +name = "wasmtime-jit" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2a45f6dd5bdf12d41f10100482d58d9cb160a85af5884dfd41a2861af4b0f50" +dependencies = [ + "anyhow", + "cfg-if 1.0.0", + "cranelift-codegen", + "cranelift-entity", + "cranelift-frontend", + "cranelift-native", + "cranelift-wasm", + "gimli 0.22.0", + "log", + "more-asserts", + "object 0.21.1", + "rayon", + "region", + "serde", + "target-lexicon", + "thiserror", + "wasmparser 0.65.0", + "wasmtime-cranelift", + "wasmtime-debug", + "wasmtime-environ", + "wasmtime-obj", + "wasmtime-profiling", + "wasmtime-runtime", + "winapi", +] + +[[package]] +name = "wasmtime-obj" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a84aebe3b4331a603625f069944192fa3f6ffe499802ef91273fd73af9a8087d" +dependencies = [ + "anyhow", + "more-asserts", + "object 0.21.1", + "target-lexicon", + "wasmtime-debug", + "wasmtime-environ", +] + +[[package]] +name = "wasmtime-profiling" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25f27fda1b81d701f7ea1da9ae51b5b62d4cdc37ca5b93eae771ca2cde53b70c" +dependencies = [ + "anyhow", + "cfg-if 1.0.0", + "gimli 0.22.0", + "lazy_static", + "libc", + "object 0.21.1", + "scroll", + "serde", + "target-lexicon", + "wasmtime-environ", + "wasmtime-runtime", +] + +[[package]] +name = "wasmtime-runtime" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e452b8b3b32dbf1b831f05003a740581cc2c3c2122f5806bae9f167495e1e66c" +dependencies = [ + "backtrace", + "cc", + "cfg-if 1.0.0", + "indexmap", + "lazy_static", + "libc", + "log", + "memoffset 0.5.6", + "more-asserts", + "psm", + "region", + "thiserror", + "wasmtime-environ", + "winapi", +] + +[[package]] +name = "wasmtime-wasi" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a03ea22e53498c52f2fcd478a31aa64d5196377a953f043498646a88c0f90389" +dependencies = [ + "anyhow", + "tracing", + "wasi-common", + "wasmtime", + "wasmtime-runtime", + "wasmtime-wiggle", + "wig", + "wiggle", +] + +[[package]] +name = "wasmtime-wiggle" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3a493af6f344f3c503e09dca361527087e4de497d46015397f438ddcc51cd2e" +dependencies = [ + "wasmtime", + "wasmtime-wiggle-macro", + "wiggle", + "witx", +] + +[[package]] +name = "wasmtime-wiggle-macro" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c97e63ea6637a5d6977b4951715ba26b2bc92d210debe6d5ddc6178040a235a" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wiggle-generate", + "witx", +] + +[[package]] +name = "wast" +version = "22.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe1220ed7f824992b426a76125a3403d048eaf0f627918e97ade0d9b9d510d20" +dependencies = [ + "leb128", +] + +[[package]] +name = "wast" +version = "30.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b79907b22f740634810e882d8d1d9d0f9563095a8ab94e786e370242bff5cd2" +dependencies = [ + "leb128", +] + +[[package]] +name = "wat" +version = "1.0.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8279a02835bf12e61ed2b3c3cbc6ecf9918762fd97e036917c11a09ec20ca44" +dependencies = [ + "wast 30.0.0", +] + +[[package]] +name = "web-sys" +version = "0.3.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "222b1ef9334f92a21d3fb53dc3fd80f30836959a90f9274a626d7e06315ba3c3" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "wig" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a41001cacf8d23e98d33d715477a9a19d4d34f75cf07110d25b96be73f4bf62" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "witx", +] + +[[package]] +name = "wiggle" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d884714a403aad1a568f4a0399216c7a35145a8f68ec8770305875282d211e97" +dependencies = [ + "thiserror", + "tracing", + "wiggle-macro", + "witx", +] + +[[package]] +name = "wiggle-generate" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75911fa619340aac4735fd2e646d8fd421e955908a4b1795df2f9a1d4121f674" +dependencies = [ + "anyhow", + "heck", + "proc-macro2", + "quote", + "shellexpand", + "syn", + "witx", +] + +[[package]] +name = "wiggle-macro" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3df990808f3e4ace81d172a95049a76be252f3886e1dc3484f2c06da33bcc26" +dependencies = [ + "quote", + "syn", + "wiggle-generate", + "witx", +] + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +dependencies = [ + "winapi", +] + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "winx" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bcaffab7dbdc695c5d1e8adc37247111444c44f2df159f730d7ac85dbc27b5f" +dependencies = [ + "bitflags", + "cvt", + "winapi", +] + +[[package]] +name = "witx" +version = "0.8.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1be02433ed9b7ddcebf9431066d96d7f62d0de3bfa3b9a2af4a239303da575e4" +dependencies = [ + "anyhow", + "log", + "thiserror", + "wast 22.0.0", +] + +[[package]] +name = "wizer" +version = "1.0.1" +dependencies = [ + "anyhow", + "criterion", + "env_logger 0.8.2", + "log", + "rayon", + "structopt", + "wasm-encoder", + "wasmparser 0.68.0", + "wasmtime", + "wasmtime-wasi", + "wat", +] + +[[package]] +name = "yaml-rust" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56c1936c4cc7a1c9ab21a1ebb602eb942ba868cbd44a99cb7cdc5892335e1c85" +dependencies = [ + "linked-hash-map", +] + +[[package]] +name = "yanix" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d845725b158616b297eec5df1a39e5a4a30b35e9014cb863ad99e3380b398a70" +dependencies = [ + "bitflags", + "cfg-if 1.0.0", + "filetime", + "libc", + "tracing", +] + +[[package]] +name = "zstd" +version = "0.5.4+zstd.1.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69996ebdb1ba8b1517f61387a883857818a66c8a295f487b1ffd8fd9d2c82910" +dependencies = [ + "zstd-safe", +] + +[[package]] +name = "zstd-safe" +version = "2.0.6+zstd.1.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98aa931fb69ecee256d44589d19754e61851ae4769bf963b385119b1cc37a49e" +dependencies = [ + "libc", + "zstd-sys", +] + +[[package]] +name = "zstd-sys" +version = "1.4.18+zstd.1.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1e6e8778706838f43f771d80d37787cb2fe06dafe89dd3aebaf6721b9eaec81" +dependencies = [ + "cc", + "glob", + "itertools", + "libc", +] From 7adc4c9f7638c1e97b5b0a37871b3802ae546e01 Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Mon, 11 Jan 2021 13:50:46 -0800 Subject: [PATCH 019/212] Add github actions CI --- crates/wizer/.github/workflows/ci.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 crates/wizer/.github/workflows/ci.yml diff --git a/crates/wizer/.github/workflows/ci.yml b/crates/wizer/.github/workflows/ci.yml new file mode 100644 index 000000000000..fd457217c8b0 --- /dev/null +++ b/crates/wizer/.github/workflows/ci.yml @@ -0,0 +1,20 @@ +name: CI + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +env: + CARGO_TERM_COLOR: always + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Build + run: cargo build --verbose + - name: Run tests + run: cargo test --verbose From 7e1a89624ed83d857f26a92d9fb2730bacec2921 Mon Sep 17 00:00:00 2001 From: Radu M Date: Wed, 13 Jan 2021 19:19:42 -0800 Subject: [PATCH 020/212] Update Wasmtime to 0.22 This commit updates the wasmtime and wasmtime-wasi crates to 0.22 and handles the API changes. Signed-off-by: Radu M --- crates/wizer/Cargo.lock | 305 +++++++++++++++++++--------------------- crates/wizer/Cargo.toml | 4 +- crates/wizer/src/lib.rs | 13 +- 3 files changed, 150 insertions(+), 172 deletions(-) diff --git a/crates/wizer/Cargo.lock b/crates/wizer/Cargo.lock index 74619b411cb2..33d5d312ae1b 100644 --- a/crates/wizer/Cargo.lock +++ b/crates/wizer/Cargo.lock @@ -6,7 +6,7 @@ version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a55f82cfe485775d02112886f4169bde0c5894d75e79ead7eafe7e40a25e45f7" dependencies = [ - "gimli 0.23.0", + "gimli", ] [[package]] @@ -66,15 +66,15 @@ dependencies = [ "cfg-if 1.0.0", "libc", "miniz_oxide", - "object 0.22.0", + "object", "rustc-demangle", ] [[package]] name = "base64" -version = "0.12.3" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3441f0f7b02788e948e47f457ca01f1d7e6d92c693bc132c22b087d3141c03ff" +checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" [[package]] name = "bincode" @@ -94,25 +94,13 @@ checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" [[package]] name = "block-buffer" -version = "0.7.3" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" +checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" dependencies = [ - "block-padding", - "byte-tools", - "byteorder", "generic-array", ] -[[package]] -name = "block-padding" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5" -dependencies = [ - "byte-tools", -] - [[package]] name = "bstr" version = "0.2.14" @@ -131,12 +119,6 @@ version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2e8c087f005730276d1096a652e92a8bacee2e2472bcc9715a74d2bec38b5820" -[[package]] -name = "byte-tools" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" - [[package]] name = "byteorder" version = "1.3.4" @@ -194,6 +176,16 @@ version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "28b9d6de7f49e22cf97ad17fc4036ece69300032f45f78f30b4a4482cdc3f4a6" +[[package]] +name = "cpp_demangle" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44919ecaf6f99e8e737bc239408931c9a01e9a6c74814fee8242dd2506b65390" +dependencies = [ + "cfg-if 1.0.0", + "glob", +] + [[package]] name = "cpu-time" version = "1.0.0" @@ -204,27 +196,33 @@ dependencies = [ "winapi", ] +[[package]] +name = "cpuid-bool" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8aebca1129a03dc6dc2b127edd729435bbc4a37e1d5f4d7513165089ceb02634" + [[package]] name = "cranelift-bforest" -version = "0.68.0" +version = "0.69.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9221545c0507dc08a62b2d8b5ffe8e17ac580b0a74d1813b496b8d70b070fbd0" +checksum = "4066fd63b502d73eb8c5fa6bcab9c7962b05cd580f6b149ee83a8e730d8ce7fb" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-codegen" -version = "0.68.0" +version = "0.69.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e9936ea608b6cd176f107037f6adbb4deac933466fc7231154f96598b2d3ab1" +checksum = "1a54e4beb833a3c873a18a8fe735d73d732044004c7539a072c8faa35ccb0c60" dependencies = [ "byteorder", "cranelift-bforest", "cranelift-codegen-meta", "cranelift-codegen-shared", "cranelift-entity", - "gimli 0.22.0", + "gimli", "log", "regalloc", "serde", @@ -235,9 +233,9 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.68.0" +version = "0.69.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ef2b2768568306540f4c8db3acce9105534d34c4a1e440529c1e702d7f8c8d7" +checksum = "c54cac7cacb443658d8f0ff36a3545822613fa202c946c0891897843bc933810" dependencies = [ "cranelift-codegen-shared", "cranelift-entity", @@ -245,24 +243,24 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" -version = "0.68.0" +version = "0.69.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6759012d6d19c4caec95793f052613e9d4113e925e7f14154defbac0f1d4c938" +checksum = "a109760aff76788b2cdaeefad6875a73c2b450be13906524f6c2a81e05b8d83c" [[package]] name = "cranelift-entity" -version = "0.68.0" +version = "0.69.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86badbce14e15f52a45b666b38abe47b204969dd7f8fb7488cb55dd46b361fa6" +checksum = "3b044234aa32531f89a08b487630ddc6744696ec04c8123a1ad388de837f5de3" dependencies = [ "serde", ] [[package]] name = "cranelift-frontend" -version = "0.68.0" +version = "0.69.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b608bb7656c554d0a4cf8f50c7a10b857e80306f6ff829ad6d468a7e2323c8d8" +checksum = "5452b3e4e97538ee5ef2cc071301c69a86c7adf2770916b9d04e9727096abd93" dependencies = [ "cranelift-codegen", "log", @@ -272,9 +270,9 @@ dependencies = [ [[package]] name = "cranelift-native" -version = "0.68.0" +version = "0.69.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5246a1af14b7812ee4d94a3f0c4b295ec02c370c08b0ecc3dec512890fdad175" +checksum = "f68035c10b2e80f26cc29c32fa824380877f38483504c2a47b54e7da311caaf3" dependencies = [ "cranelift-codegen", "raw-cpuid", @@ -283,9 +281,9 @@ dependencies = [ [[package]] name = "cranelift-wasm" -version = "0.68.0" +version = "0.69.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ef491714e82f9fb910547e2047a3b1c47c03861eca67540c5abd0416371a2ac" +checksum = "a530eb9d1c95b3309deb24c3d179d8b0ba5837ed98914a429787c395f614949d" dependencies = [ "cranelift-codegen", "cranelift-entity", @@ -295,7 +293,7 @@ dependencies = [ "serde", "smallvec", "thiserror", - "wasmparser 0.65.0", + "wasmparser 0.71.0", ] [[package]] @@ -374,7 +372,7 @@ dependencies = [ "const_fn", "crossbeam-utils", "lazy_static", - "memoffset 0.6.1", + "memoffset", "scopeguard", ] @@ -422,18 +420,18 @@ dependencies = [ [[package]] name = "digest" -version = "0.8.1" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" +checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" dependencies = [ "generic-array", ] [[package]] name = "directories-next" -version = "1.0.3" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a28ccebc1239c5c57f0c55986e2ac03f49af0d0ca3dff29bfcad39d60a8be56" +checksum = "339ee130d97a610ea5a5872d2bbb130fdf68884ff09d3028b81bec8a1ac23bbc" dependencies = [ "cfg-if 1.0.0", "dirs-sys-next", @@ -519,12 +517,6 @@ dependencies = [ "libc", ] -[[package]] -name = "fake-simd" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" - [[package]] name = "fallible-iterator" version = "0.2.0" @@ -561,11 +553,12 @@ checksum = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" [[package]] name = "generic-array" -version = "0.12.3" +version = "0.14.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec" +checksum = "501466ecc8a30d1d3b7fc9229b122b2ce8ed6e9d9223f1138d4babb253e51817" dependencies = [ "typenum", + "version_check", ] [[package]] @@ -576,18 +569,18 @@ checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" dependencies = [ "cfg-if 1.0.0", "libc", - "wasi", + "wasi 0.9.0+wasi-snapshot-preview1", ] [[package]] -name = "gimli" -version = "0.22.0" +name = "getrandom" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aaf91faf136cb47367fa430cd46e37a788775e7fa104f8b4bcb3861dc389b724" +checksum = "4060f4657be78b8e766215b02b18a2e862d83745545de804638e2b545e81aee6" dependencies = [ - "fallible-iterator", - "indexmap", - "stable_deref_trait", + "cfg-if 1.0.0", + "libc", + "wasi 0.10.1+wasi-snapshot-preview1", ] [[package]] @@ -595,6 +588,11 @@ name = "gimli" version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f6503fe142514ca4799d4c26297c4248239fe8838d827db6bd6065c6ed29a6ce" +dependencies = [ + "fallible-iterator", + "indexmap", + "stable_deref_trait", +] [[package]] name = "glob" @@ -739,15 +737,6 @@ version = "2.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525" -[[package]] -name = "memoffset" -version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "043175f069eda7b85febe4a74abbaeff828d9f8b448515d3151a14a3542811aa" -dependencies = [ - "autocfg", -] - [[package]] name = "memoffset" version = "0.6.1" @@ -794,21 +783,14 @@ dependencies = [ [[package]] name = "object" -version = "0.21.1" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37fd5004feb2ce328a52b0b3d01dbf4ffff72583493900ed15f22d4111c51693" +checksum = "8d3b63360ec3cb337817c2dbd47ab4a0f170d285d8e5a2064600f3def1402397" dependencies = [ "crc32fast", "indexmap", - "wasmparser 0.57.0", ] -[[package]] -name = "object" -version = "0.22.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d3b63360ec3cb337817c2dbd47ab4a0f170d285d8e5a2064600f3def1402397" - [[package]] name = "oorandom" version = "11.1.3" @@ -817,9 +799,9 @@ checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575" [[package]] name = "opaque-debug" -version = "0.2.3" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" +checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" [[package]] name = "pin-project-lite" @@ -898,9 +880,9 @@ dependencies = [ [[package]] name = "raw-cpuid" -version = "7.0.4" +version = "8.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "beb71f708fe39b2c5e98076204c3cc094ee5a4c12c4cdb119a2b72dc34164f41" +checksum = "1fdf7d9dbd43f3d81d94a49c1c3df73cc2b3827995147e6cf7f89d4ec5483e73" dependencies = [ "bitflags", "cc", @@ -944,7 +926,7 @@ version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "de0737333e7a9502c789a36d7c7fa6092a49895d4faa31ca5df163857ded2e9d" dependencies = [ - "getrandom", + "getrandom 0.1.16", "redox_syscall", ] @@ -1144,13 +1126,14 @@ dependencies = [ [[package]] name = "sha2" -version = "0.8.2" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a256f46ea78a0c0d9ff00077504903ac881a1dafdc20da66545699e7776b3e69" +checksum = "6e7aab86fe2149bad8c507606bdb3f4ef5e7b2380eb92350f56122cca72a42a8" dependencies = [ "block-buffer", + "cfg-if 1.0.0", + "cpuid-bool", "digest", - "fake-simd", "opaque-debug", ] @@ -1383,22 +1366,27 @@ version = "0.9.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" +[[package]] +name = "wasi" +version = "0.10.1+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93c6c3420963c5c64bca373b25e77acb562081b9bb4dd5bb864187742186cea9" + [[package]] name = "wasi-common" -version = "0.21.0" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b02e7034147dcfbfe1f45f648061bb6007419b62c2e0d9e9d4930bae0c772d0" +checksum = "843c91a27e7b6a80bdc38b4383eec42e46bc81962dbf016f32a298c9126327a1" dependencies = [ "anyhow", "cfg-if 1.0.0", "cpu-time", "filetime", - "getrandom", + "getrandom 0.2.1", "lazy_static", "libc", "thiserror", "tracing", - "wig", "wiggle", "winapi", "winx", @@ -1470,33 +1458,28 @@ dependencies = [ [[package]] name = "wasmparser" -version = "0.57.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32fddd575d477c6e9702484139cf9f23dcd554b06d185ed0f56c857dd3a47aa6" - -[[package]] -name = "wasmparser" -version = "0.65.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87cc2fe6350834b4e528ba0901e7aa405d78b89dc1fa3145359eb4de0e323fcf" +checksum = "29a00e14eed9c2ecbbdbdd4fb284f49d21b6808965de24769a6379a13ec47d4c" [[package]] name = "wasmparser" -version = "0.68.0" +version = "0.71.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29a00e14eed9c2ecbbdbdd4fb284f49d21b6808965de24769a6379a13ec47d4c" +checksum = "89a30c99437829ede826802bfcf28500cf58df00e66cb9114df98813bc145ff1" [[package]] name = "wasmtime" -version = "0.21.0" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a4d945221f4d29feecdac80514c1ef1527dfcdcc7715ff1b4a5161fe5c8ebab" +checksum = "7426055cb92bd9a1e9469b48154d8d6119cd8c498c8b70284e420342c05dc45d" dependencies = [ "anyhow", "backtrace", "bincode", "cfg-if 1.0.0", - "lazy_static", + "cpp_demangle", + "indexmap", "libc", "log", "region", @@ -1504,7 +1487,7 @@ dependencies = [ "serde", "smallvec", "target-lexicon", - "wasmparser 0.65.0", + "wasmparser 0.71.0", "wasmtime-cache", "wasmtime-environ", "wasmtime-jit", @@ -1516,9 +1499,9 @@ dependencies = [ [[package]] name = "wasmtime-cache" -version = "0.21.0" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b27d71f896587548eeafb5f63daad596330fd161620d9048e251917926622fb5" +checksum = "c01d9287e36921e46f5887a47007824ae5dbb9b7517a2d565660ab4471478709" dependencies = [ "anyhow", "base64", @@ -1537,9 +1520,9 @@ dependencies = [ [[package]] name = "wasmtime-cranelift" -version = "0.21.0" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1e55c17317922951a9bdd5547b527d2cc7be3cea118dc17ad7c05a4c8e67c7a" +checksum = "4134ed3a4316cd0de0e546c6004850afe472b0fa3fcdc2f2c15f8d449562d962" dependencies = [ "cranelift-codegen", "cranelift-entity", @@ -1550,46 +1533,47 @@ dependencies = [ [[package]] name = "wasmtime-debug" -version = "0.21.0" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a576daa6b228f8663c38bede2f7f23d094d578b0061c39fc122cc28eee1e2c18" +checksum = "e91fa931df6dd8af2b02606307674d3bad23f55473d5f4c809dddf7e4c4dc411" dependencies = [ "anyhow", - "gimli 0.22.0", + "gimli", "more-asserts", - "object 0.21.1", + "object", "target-lexicon", "thiserror", - "wasmparser 0.65.0", + "wasmparser 0.71.0", "wasmtime-environ", ] [[package]] name = "wasmtime-environ" -version = "0.21.0" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "396ceda32fd67205235c098e092a85716942883bfd2c773c250cf5f2457b8307" +checksum = "a1098871dc3120aaf8190d79153e470658bb79f63ee9ca31716711e123c28220" dependencies = [ "anyhow", "cfg-if 1.0.0", "cranelift-codegen", "cranelift-entity", "cranelift-wasm", - "gimli 0.22.0", + "gimli", "indexmap", "log", "more-asserts", "serde", "thiserror", - "wasmparser 0.65.0", + "wasmparser 0.71.0", ] [[package]] name = "wasmtime-jit" -version = "0.21.0" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2a45f6dd5bdf12d41f10100482d58d9cb160a85af5884dfd41a2861af4b0f50" +checksum = "738bfcd1561ede8bb174215776fd7d9a95d5f0a47ca3deabe0282c55f9a89f68" dependencies = [ + "addr2line", "anyhow", "cfg-if 1.0.0", "cranelift-codegen", @@ -1597,16 +1581,16 @@ dependencies = [ "cranelift-frontend", "cranelift-native", "cranelift-wasm", - "gimli 0.22.0", + "gimli", "log", "more-asserts", - "object 0.21.1", + "object", "rayon", "region", "serde", "target-lexicon", "thiserror", - "wasmparser 0.65.0", + "wasmparser 0.71.0", "wasmtime-cranelift", "wasmtime-debug", "wasmtime-environ", @@ -1618,13 +1602,13 @@ dependencies = [ [[package]] name = "wasmtime-obj" -version = "0.21.0" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a84aebe3b4331a603625f069944192fa3f6ffe499802ef91273fd73af9a8087d" +checksum = "3e96d77f1801131c5e86d93e42a3cf8a35402107332c202c245c83f34888a906" dependencies = [ "anyhow", "more-asserts", - "object 0.21.1", + "object", "target-lexicon", "wasmtime-debug", "wasmtime-environ", @@ -1632,16 +1616,16 @@ dependencies = [ [[package]] name = "wasmtime-profiling" -version = "0.21.0" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25f27fda1b81d701f7ea1da9ae51b5b62d4cdc37ca5b93eae771ca2cde53b70c" +checksum = "60bb672c9d894776d7b9250dd9b4fe890f8760201ee4f53e5f2da772b6c4debb" dependencies = [ "anyhow", "cfg-if 1.0.0", - "gimli 0.22.0", + "gimli", "lazy_static", "libc", - "object 0.21.1", + "object", "scroll", "serde", "target-lexicon", @@ -1651,9 +1635,9 @@ dependencies = [ [[package]] name = "wasmtime-runtime" -version = "0.21.0" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e452b8b3b32dbf1b831f05003a740581cc2c3c2122f5806bae9f167495e1e66c" +checksum = "a978086740949eeedfefcee667b57a9e98d9a7fc0de382fcfa0da30369e3530d" dependencies = [ "backtrace", "cc", @@ -1662,7 +1646,7 @@ dependencies = [ "lazy_static", "libc", "log", - "memoffset 0.5.6", + "memoffset", "more-asserts", "psm", "region", @@ -1673,9 +1657,9 @@ dependencies = [ [[package]] name = "wasmtime-wasi" -version = "0.21.0" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a03ea22e53498c52f2fcd478a31aa64d5196377a953f043498646a88c0f90389" +checksum = "ff7b445df9bc7da40c357b0b05d6ed30c5f5376fde7ee5e86b25564ce8e54e2d" dependencies = [ "anyhow", "tracing", @@ -1683,27 +1667,27 @@ dependencies = [ "wasmtime", "wasmtime-runtime", "wasmtime-wiggle", - "wig", "wiggle", ] [[package]] name = "wasmtime-wiggle" -version = "0.21.0" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3a493af6f344f3c503e09dca361527087e4de497d46015397f438ddcc51cd2e" +checksum = "d5a63659462abadf28ceb61f20f3456b792b16cdaf20207faea9124886aed392" dependencies = [ "wasmtime", "wasmtime-wiggle-macro", "wiggle", + "wiggle-borrow", "witx", ] [[package]] name = "wasmtime-wiggle-macro" -version = "0.21.0" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c97e63ea6637a5d6977b4951715ba26b2bc92d210debe6d5ddc6178040a235a" +checksum = "e60d0d185876a2eec2b56ed470de91cf1e9860a099953ec54fd88bd28c5002ef" dependencies = [ "proc-macro2", "quote", @@ -1750,34 +1734,31 @@ dependencies = [ ] [[package]] -name = "wig" -version = "0.21.0" +name = "wiggle" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a41001cacf8d23e98d33d715477a9a19d4d34f75cf07110d25b96be73f4bf62" +checksum = "b1ca41d22d39db23fe440022aa010a84da3854e27f32e239e5ecc1d8cd2227fa" dependencies = [ - "heck", - "proc-macro2", - "quote", + "thiserror", + "tracing", + "wiggle-macro", "witx", ] [[package]] -name = "wiggle" -version = "0.21.0" +name = "wiggle-borrow" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d884714a403aad1a568f4a0399216c7a35145a8f68ec8770305875282d211e97" +checksum = "9765eec737f8a36b6060d94d34954d48f353a91694811510d08b2141cba51726" dependencies = [ - "thiserror", - "tracing", - "wiggle-macro", - "witx", + "wiggle", ] [[package]] name = "wiggle-generate" -version = "0.21.0" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75911fa619340aac4735fd2e646d8fd421e955908a4b1795df2f9a1d4121f674" +checksum = "ea1b6a09972d1a154b0d3c4cded3469c4639fa7bc200309e053ff943b9034147" dependencies = [ "anyhow", "heck", @@ -1790,9 +1771,9 @@ dependencies = [ [[package]] name = "wiggle-macro" -version = "0.21.0" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3df990808f3e4ace81d172a95049a76be252f3886e1dc3484f2c06da33bcc26" +checksum = "62ed20d774be09682f68b8c519a6abaa5fc279479c048cca7db019a7fa3ce361" dependencies = [ "quote", "syn", @@ -1833,9 +1814,9 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "winx" -version = "0.21.0" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bcaffab7dbdc695c5d1e8adc37247111444c44f2df159f730d7ac85dbc27b5f" +checksum = "f7d35176e4c7e0daf9d8da18b7e9df81a8f2358fb3d6feea775ce810f974a512" dependencies = [ "bitflags", "cvt", @@ -1882,9 +1863,9 @@ dependencies = [ [[package]] name = "yanix" -version = "0.21.0" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d845725b158616b297eec5df1a39e5a4a30b35e9014cb863ad99e3380b398a70" +checksum = "0504d76a87b9e77f1057d419a51acb4344b9e14eaf37dde22cf1fd0ec28901db" dependencies = [ "bitflags", "cfg-if 1.0.0", diff --git a/crates/wizer/Cargo.toml b/crates/wizer/Cargo.toml index 5f92b4ac5be0..3038d0c7db10 100644 --- a/crates/wizer/Cargo.toml +++ b/crates/wizer/Cargo.toml @@ -32,8 +32,8 @@ log = "0.4.11" structopt = { version = "0.3.20", optional = true } wasm-encoder = "0.3.1" wasmparser = "0.68.0" -wasmtime = "0.21.0" -wasmtime-wasi = "0.21.0" +wasmtime = "0.22.0" +wasmtime-wasi = "0.22.0" rayon = "1.5.0" [dev-dependencies] diff --git a/crates/wizer/src/lib.rs b/crates/wizer/src/lib.rs index 3d88c9eb56d9..3b2c35f6927b 100644 --- a/crates/wizer/src/lib.rs +++ b/crates/wizer/src/lib.rs @@ -375,11 +375,11 @@ impl Wizer { "cannot call imports within the initialization function; attempted \ to call `'{}' '{}'`", imp.module(), - imp.name() + imp.name().unwrap() )); linker.define( imp.module(), - imp.name(), + imp.name().unwrap(), wasmtime::Func::new( store, func_ty, @@ -413,6 +413,7 @@ impl Wizer { // imported memories. anyhow::bail!("cannot initialize Wasm modules that import memories") } + _ => anyhow::bail!("module linking is not supported yet"), }; } @@ -622,9 +623,7 @@ impl Wizer { data: &full_wasm[imports.range().start..imports.range().end], }); } - AliasSection(_) | InstanceSection(_) | ModuleSection(_) => { - unreachable!() - } + AliasSection(_) | InstanceSection(_) | ModuleSection(_) => unreachable!(), FunctionSection(funcs) => { module.section(&wasm_encoder::RawSection { id: wasm_encoder::SectionId::Function as u8, @@ -711,9 +710,7 @@ impl Wizer { wasmparser::ExternalKind::Type | wasmparser::ExternalKind::Module | wasmparser::ExternalKind::Instance - | wasmparser::ExternalKind::Event => { - unreachable!() - } + | wasmparser::ExternalKind::Event => unreachable!(), }, ); } From a3c6858063f44fedf24ee5c8c3c7cd95c61d363a Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Thu, 14 Jan 2021 09:31:03 -0800 Subject: [PATCH 021/212] Bump to version 1.0.2 --- crates/wizer/Cargo.lock | 2 +- crates/wizer/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/wizer/Cargo.lock b/crates/wizer/Cargo.lock index 33d5d312ae1b..03bab2707080 100644 --- a/crates/wizer/Cargo.lock +++ b/crates/wizer/Cargo.lock @@ -1837,7 +1837,7 @@ dependencies = [ [[package]] name = "wizer" -version = "1.0.1" +version = "1.0.2" dependencies = [ "anyhow", "criterion", diff --git a/crates/wizer/Cargo.toml b/crates/wizer/Cargo.toml index 3038d0c7db10..795b2ee8d3d5 100644 --- a/crates/wizer/Cargo.toml +++ b/crates/wizer/Cargo.toml @@ -9,7 +9,7 @@ license = "Apache-2.0 WITH LLVM-exception" name = "wizer" readme = "./README.md" repository = "https://github.com/bytecodealliance/wizer" -version = "1.0.1" +version = "1.0.2" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html From 37e4e43f452a5c218be0bf536f56405b4e3b6f66 Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Thu, 14 Jan 2021 09:36:36 -0800 Subject: [PATCH 022/212] Check rustfmt in CI --- crates/wizer/.github/workflows/ci.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/crates/wizer/.github/workflows/ci.yml b/crates/wizer/.github/workflows/ci.yml index fd457217c8b0..47f4daaed14b 100644 --- a/crates/wizer/.github/workflows/ci.yml +++ b/crates/wizer/.github/workflows/ci.yml @@ -18,3 +18,12 @@ jobs: run: cargo build --verbose - name: Run tests run: cargo test --verbose + + rustfmt: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - run: rustup update stable --no-self-update + - run: rustup default stable + - run: rustup component add rustfmt + - run: cargo fmt --all -- --check From 041c60f69746fb7ca75a8eca8f45df5230e7fc53 Mon Sep 17 00:00:00 2001 From: Chris Fallin Date: Tue, 9 Feb 2021 22:32:09 -0800 Subject: [PATCH 023/212] Add Wizer option to rename functions. When initializing a module, it is sometimes useful to rename a function after the module has been modified. For example, we may wish to substitute an alternate entry point (for WASI, this is `_start()`) since we have already performed some initialization that the normal entry point would do. This PR adds a `-r` option to allow such renaming. For example, $ wizer -r _start=my_new_start -o out.wasm in.wasm will rename the `my_new_start` export in `in.wasm` to `_start` in `out.wasm`, replacing the old `_start` export. Multiple renamings are supported at once. --- crates/wizer/src/lib.rs | 90 +++++++++++++++++++++++++++++++++++-- crates/wizer/tests/tests.rs | 42 +++++++++++++++++ 2 files changed, 129 insertions(+), 3 deletions(-) diff --git a/crates/wizer/src/lib.rs b/crates/wizer/src/lib.rs index 3b2c35f6927b..029f99bdd188 100644 --- a/crates/wizer/src/lib.rs +++ b/crates/wizer/src/lib.rs @@ -6,7 +6,9 @@ use anyhow::Context; use rayon::iter::{IntoParallelIterator, ParallelExtend, ParallelIterator}; +use std::collections::{HashMap, HashSet}; use std::convert::TryFrom; +use std::fmt::Display; #[cfg(feature = "structopt")] use structopt::StructOpt; @@ -45,6 +47,20 @@ pub struct Wizer { )] init_func: String, + /// Any function renamings to perform. + /// + /// A renaming specification `dst=src` renames a function export `src` to + /// `dst`, overwriting any previous `dst` export. + /// + /// Multiple renamings can be specified. It is an error to specify more than + /// one source to rename to a destination name, or to specify more than one + /// renaming destination for one source. + /// + /// This option can be used, for example, to replace a `_start` entry point + /// in an initialized module with an alternate entry point. + #[cfg_attr(feature = "structopt", structopt(short = "r", long = "func-rename"))] + func_renames: Vec, + /// Allow WASI imports to be called during initialization. /// /// This can introduce diverging semantics because the initialization can @@ -81,11 +97,53 @@ fn translate_global_type(ty: wasmparser::GlobalType) -> wasm_encoder::GlobalType } } +struct FuncRenames { + /// For a given export name that we encounter in the original module, a map + /// to a new name, if any, to emit in the output module. + rename_src_to_dst: HashMap, + /// A set of export names that we ignore in the original module (because + /// they are overwritten by renamings). + rename_dsts: HashSet, +} + +impl FuncRenames { + fn parse(renames: &Vec) -> anyhow::Result { + let mut ret = FuncRenames { + rename_src_to_dst: HashMap::new(), + rename_dsts: HashSet::new(), + }; + if renames.is_empty() { + return Ok(ret); + } + + for rename_spec in renames { + let equal = rename_spec + .trim() + .find('=') + .ok_or_else(|| anyhow::anyhow!("Invalid function rename part: {}", rename_spec))?; + // TODO: use .split_off() when the API is stabilized. + let dst = rename_spec[..equal].to_owned(); + let src = rename_spec[equal + 1..].to_owned(); + if ret.rename_dsts.contains(&dst) { + anyhow::bail!("Duplicated function rename dst {}", dst); + } + if ret.rename_src_to_dst.contains_key(&src) { + anyhow::bail!("Duplicated function rename src {}", src); + } + ret.rename_dsts.insert(dst.clone()); + ret.rename_src_to_dst.insert(src, dst); + } + + Ok(ret) + } +} + impl Wizer { /// Construct a new `Wizer` builder. pub fn new() -> Self { Wizer { init_func: "wizer.initialize".into(), + func_renames: vec![], allow_wasi: false, } } @@ -98,6 +156,12 @@ impl Wizer { self } + /// Add a function rename to perform. + pub fn func_rename(&mut self, new_name: impl Display, old_name: impl Display) -> &mut Self { + self.func_renames.push(format!("{}={}", new_name, old_name)); + self + } + /// Allow WASI imports to be called during initialization? /// /// This can introduce diverging semantics because the initialization can @@ -120,6 +184,9 @@ impl Wizer { /// Initialize the given Wasm, snapshot it, and return the serialized /// snapshot as a new, pre-initialized Wasm module. pub fn run(&self, wasm: &[u8]) -> anyhow::Result> { + // Parse rename spec. + let renames = FuncRenames::parse(&self.func_renames)?; + // Make sure we're given valid Wasm from the get go. self.wasm_validate(wasm)?; @@ -135,7 +202,7 @@ impl Wizer { let instance = self.initialize(&store, &module)?; let diff = self.diff(&instance); - let initialized_wasm = self.rewrite(&wasm, &diff); + let initialized_wasm = self.rewrite(&wasm, &diff, &renames); Ok(initialized_wasm) } @@ -569,7 +636,7 @@ impl Wizer { } } - fn rewrite(&self, full_wasm: &[u8], diff: &Diff) -> Vec { + fn rewrite(&self, full_wasm: &[u8], diff: &Diff, renames: &FuncRenames) -> Vec { log::debug!("Rewriting input Wasm to pre-initialized state"); let mut wasm = full_wasm; @@ -685,6 +752,10 @@ impl Wizer { // function's export. Removing the latter will enable // further Wasm optimizations (notably GC'ing unused // functions) via `wasm-opt` and similar tools. + // + // We also perform renames at this stage. We have + // precomputed the list of old dsts to remove, and the + // mapping from srcs to dsts, so we can do this in one pass. let count = exports.get_count(); let mut exports_encoder = wasm_encoder::ExportSection::new(); for _ in 0..count { @@ -692,8 +763,21 @@ impl Wizer { if export.field.starts_with("__wizer_") || export.field == self.init_func { continue; } + if !renames.rename_src_to_dst.contains_key(export.field) + && renames.rename_dsts.contains(export.field) + { + // A rename overwrites this export, and it is not renamed to another + // export, so skip it. + continue; + } + let field = match renames.rename_src_to_dst.get(export.field) { + None => export.field, + // A rename spec renames the export to this new + // name, so use it. + Some(dst) => dst, + }; exports_encoder.export( - export.field, + field, match export.kind { wasmparser::ExternalKind::Function => { wasm_encoder::Export::Function(export.index) diff --git a/crates/wizer/tests/tests.rs b/crates/wizer/tests/tests.rs index bce6112a745e..8ddd6fb0509d 100644 --- a/crates/wizer/tests/tests.rs +++ b/crates/wizer/tests/tests.rs @@ -87,3 +87,45 @@ fn rust_regex() -> anyhow::Result<()> { &include_bytes!("./regex_test.wasm")[..], ) } + +#[test] +fn rename_functions() -> anyhow::Result<()> { + let wat = r#" +(module + (func (export "wizer.initialize")) + (func (export "func_a") (result i32) + i32.const 1) + (func (export "func_b") (result i32) + i32.const 2) + (func (export "func_c") (result i32) + i32.const 3)) + "#; + + let wasm = wat_to_wasm(wat)?; + let mut wizer = Wizer::new(); + wizer.allow_wasi(true); + wizer.func_rename("func_a", "func_b"); + wizer.func_rename("func_b", "func_c"); + let wasm = wizer.run(&wasm)?; + + let expected_wat = r#" +(module + (type (;0;) (func)) + (type (;1;) (func (result i32))) + (func (;0;) (type 0)) + (func (;1;) (type 1) (result i32) + i32.const 1) + (func (;2;) (type 1) (result i32) + i32.const 2) + (func (;3;) (type 1) (result i32) + i32.const 3) + (export "func_a" (func 2)) + (export "func_b" (func 3))) + "#; + + let expected_wasm = wat_to_wasm(expected_wat)?; + + assert_eq!(expected_wasm, wasm); + + Ok(()) +} From 9ab84eeaea7597fcf258c406a52a053eba920103 Mon Sep 17 00:00:00 2001 From: Chris Fallin Date: Tue, 9 Feb 2021 22:35:30 -0800 Subject: [PATCH 024/212] Add C++ example using function renaming to handle ctors properly. Previously, it was difficult to properly use Wizer with C++ programs that have static constructors. These constructors are normally run before `main()` is invoked by some libc/linker plumbing at the usual entry point. This causes a set of undesirable problems: - In the Wizer initialization entry point, our globals' constructors have not yet run. - If we manually invoke the constructors to resolve the first issue, then they will be *re*-invoked when the program's main entry point is run on the initialized module. This may cause surprising or inconsistent results. In order to properly handle this, we add a `wizer.h` header with a convenient macro that allows specifying a user initialization function, and adds an exported top-level Wizer initialization entry point and an exported replacement main entry point. The generated initialization entry point invokes any global constructors (using the function `__wasm_call_ctors()` which is generated by `wasm-ld`) then invokes the user's initialization function. The generated main entry point is meant to replace `_start` and performs the same work, *except* that it does not re-invoke constructors. Instead, it immediately invokes `main()` (because everything has already been initialized) and then calls destructors and exits. Taken together, the two entry points match the code that is present in `_start` in an ordinary Wasm binary compiled by wasi-sdk. This approach should be relatively stable, as long as the symbols `__wasm_call_ctors()`, `__wasm_call_dtors()`, and `__original_main()` are not renamed in the WASI SDK (this seems unlikely). --- crates/wizer/examples/.gitignore | 1 + crates/wizer/examples/cpp/Makefile | 21 ++++++ crates/wizer/examples/cpp/main.cpp | 34 +++++++++ crates/wizer/include/wizer.h | 107 +++++++++++++++++++++++++++++ 4 files changed, 163 insertions(+) create mode 100644 crates/wizer/examples/.gitignore create mode 100644 crates/wizer/examples/cpp/Makefile create mode 100644 crates/wizer/examples/cpp/main.cpp create mode 100644 crates/wizer/include/wizer.h diff --git a/crates/wizer/examples/.gitignore b/crates/wizer/examples/.gitignore new file mode 100644 index 000000000000..19e1bced9ad8 --- /dev/null +++ b/crates/wizer/examples/.gitignore @@ -0,0 +1 @@ +*.wasm diff --git a/crates/wizer/examples/cpp/Makefile b/crates/wizer/examples/cpp/Makefile new file mode 100644 index 000000000000..90d7e884b2f9 --- /dev/null +++ b/crates/wizer/examples/cpp/Makefile @@ -0,0 +1,21 @@ +CXX := /opt/wasi-sdk/bin/clang++ +CXXFLAGS := -O2 -I ../../include/ +WIZER := ../../target/release/wizer +WASMTIME := wasmtime + +.PHONY: all +all: main_initialized.wasm + +main.wasm: main.cpp + $(CXX) $(CXXFLAGS) -o $@ $^ + +main_initialized.wasm: main.wasm + $(WIZER) --allow-wasi -r _start=wizer.resume -o $@ $^ + +.PHONY: test +test: main_initialized.wasm + $(WASMTIME) run $^ + +.PHONY: clean +clean: + rm -f *.wasm diff --git a/crates/wizer/examples/cpp/main.cpp b/crates/wizer/examples/cpp/main.cpp new file mode 100644 index 000000000000..6bf27571311f --- /dev/null +++ b/crates/wizer/examples/cpp/main.cpp @@ -0,0 +1,34 @@ +#include +#include + +class Test { + public: + Test() : value(1) { + printf( + "global constructor (should be the first printed line)\n"); + } + ~Test() { + printf("global destructor (should be the last printed line)\n"); + } + int value; +}; + +bool initialized = false; +int orig_value = 0; +Test t; + +static void init_func() { + // This should run after the ctor for `t`, and before `main`. + orig_value = t.value; + t.value = 2; + initialized = true; +} + +WIZER_INIT(init_func); + +int main(int argc, char** argv) { + if (!initialized) init_func(); + printf("argc (should not be baked into snapshot): %d\n", argc); + printf("orig_value (should be 1): %d\n", orig_value); + printf("t.value (should be 2): %d\n", t.value); +} diff --git a/crates/wizer/include/wizer.h b/crates/wizer/include/wizer.h new file mode 100644 index 000000000000..3fcf169aa3e7 --- /dev/null +++ b/crates/wizer/include/wizer.h @@ -0,0 +1,107 @@ +/* + * Wizer interface for Wasm module to be initialized. + * + * This header provides several macros that allow a Wasm module written in C/C++ + * to declare an initializer function, and ensure that global constructors (in + * C++'s case) are run at initialization time rather than on startup of the + * pre-initialized module. + */ +#ifndef _WIZER_H_ +#define _WIZER_H_ + +#ifdef __cplusplus +#define __WIZER_EXTERN_C extern "C" +#else +#define __WIZER_EXTERN_C extern +#endif + +/* + * This macro inserts the exported functions necessary to allow Wizer to + * pre-initialize a Wasm module. + * + * To use, simply invoke the macro in exactly one compilation unit (C/C++ file) + * that is compiled into the Wasm module to be pre-initialized: + * + * static void my_init_function() { ... } + * + * WIZER_INIT(my_init_function); + * + * (The macro refers to the provided init function, so it must have been defined + * or must have a forward declaration at the point the macro is used.) + * + * The resulting module should be processed by Wizer as follows: + * + * $ wizer -r _start=wizer.resume -o out.wasm in.wasm + * + * The result of this will be the following behavior: + * + * - If the `in.wasm` (the direct compilation output of a program including this + * macro invocation) is run directly according to the WASI ABI (i.e., by + * invoking `_start`), then nothing changes: global constructors are run, + * `main()` is invoked, then global destructors are run. The initialization + * function is *not* run in this case. + * + * - During pre-initialization (i.e., during this `wizer` invocation), global + * constructors will run, and then the provided initialization function will + * run. The module's memory and global-variable state is then snapshotted and + * saved into `out.wasm`. + * + * All other Wizer restrictions apply (see Wizer documentation for details): + * for example, WASI hostcalls may be blocked, depending on options, and + * invoking any other imported function will result in an immediate trap + * and failure of the Wizer run. + * + * - If the resulting `out.wasm` is then run using the WASI ABI, the program's + * global constructors are *not* re-run. Instead, execution starts directly at + * `main()`, using the heap and global-variable state left by the global + * constructor and initialization function execution during the Wizer + * invocation. + * + * If no initialization function is needed (i.e., only C++ global constructors + * should be run), use `WIZER_DEFAULT_INIT()` instead. + */ +#define WIZER_INIT(init_func) \ + __WIZER_EXTERN_C void __wasm_call_ctors(); \ + __WIZER_EXTERN_C void __wasm_call_dtors(); \ + __WIZER_EXTERN_C int __original_main(); \ + /* This function's export name `wizer.initialize` is specially */ \ + /* recognized by Wizer. It is the direct entry point for pre-init. */ \ + __attribute__((export_name("wizer.initialize"))) void \ + __wizer_initialize() { \ + /* `__wasm_call_ctors()` is generated by `wasm-ld` and invokes all */ \ + /* of the global constructors. It is safe (and in fact necessary) */ \ + /* to manually invoke it here because `wizer.initialize` is the */ \ + /* direct entry point, and no libc startup (crt1.o or equivalent) */ \ + /* is executed before this code does. */ \ + __wasm_call_ctors(); \ + /* We now invoke the provided init function before returning. */ \ + init_func(); \ + } \ + /* This function replaces `_start` (the WASI-specified entry point) in */ \ + /* the pre-initialized Wasm module. */ \ + __attribute__((export_name("wizer.resume"))) void __wizer_resume() { \ + /* `__original_main()` is defined by the WASI SDK toolchain due to */ \ + /* special semantics in C/C++ for the `main()` function, i.e., ito */ \ + /* can either take argc/argv or not. It collects arguments using */ \ + /* the appropriate WASI calls and then invokes the user program's */ \ + /* `main()`. This may change in the future; when it does, we will */ \ + /* coordinate with the WASI-SDK toolchain to implement this entry */ \ + /* point in an alternate way. */ \ + __original_main(); \ + /* Because we are replacing `_start()`, we need to manually invoke */ \ + /* destructors as well. */ \ + __wasm_call_dtors(); \ + } + +/* + * This macro is like `WIZER_INIT()`, but takes no initialization function. + * Instead, the pre-initialization phase only executes C++ global constructors + * before snapshotting the module state. + * + * See documentation for `WIZER_INIT()` for more details and usage instructions. + */ +#define WIZER_DEFAULT_INIT() \ + static void __empty_init() {} \ + WIZER_INIT(__empty_init) + +#endif // _WIZER_H_ From 7d4bdb61963875deb1f1478a9f7227816bdd02af Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Thu, 11 Feb 2021 10:51:08 -0800 Subject: [PATCH 025/212] Bump to version 1.1.0 --- crates/wizer/Cargo.lock | 2 +- crates/wizer/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/wizer/Cargo.lock b/crates/wizer/Cargo.lock index 03bab2707080..5d8bb8379551 100644 --- a/crates/wizer/Cargo.lock +++ b/crates/wizer/Cargo.lock @@ -1837,7 +1837,7 @@ dependencies = [ [[package]] name = "wizer" -version = "1.0.2" +version = "1.1.0" dependencies = [ "anyhow", "criterion", diff --git a/crates/wizer/Cargo.toml b/crates/wizer/Cargo.toml index 795b2ee8d3d5..521243b6c2ea 100644 --- a/crates/wizer/Cargo.toml +++ b/crates/wizer/Cargo.toml @@ -9,7 +9,7 @@ license = "Apache-2.0 WITH LLVM-exception" name = "wizer" readme = "./README.md" repository = "https://github.com/bytecodealliance/wizer" -version = "1.0.2" +version = "1.1.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html From cf715d5b7f78c9e37440aacd7815d8f3766881a8 Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Tue, 16 Feb 2021 11:17:45 -0800 Subject: [PATCH 026/212] Make config knobs for our supported Wasm proposals --- crates/wizer/src/lib.rs | 60 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 57 insertions(+), 3 deletions(-) diff --git a/crates/wizer/src/lib.rs b/crates/wizer/src/lib.rs index 029f99bdd188..d5bc13f88fe6 100644 --- a/crates/wizer/src/lib.rs +++ b/crates/wizer/src/lib.rs @@ -15,6 +15,9 @@ use structopt::StructOpt; const WASM_PAGE_SIZE: u32 = 65_536; const NATIVE_PAGE_SIZE: u32 = 4_096; +const DEFAULT_WASM_MULTI_VALUE: bool = true; +const DEFAULT_WASM_MULTI_MEMORY: bool = true; + /// Wizer: the WebAssembly pre-initializer! /// /// Don't wait for your Wasm module to initialize itself, pre-initialize it! @@ -75,6 +78,18 @@ pub struct Wizer { /// rather than per-instance. #[cfg_attr(feature = "structopt", structopt(long = "allow-wasi"))] allow_wasi: bool, + + /// Enable or disable Wasm multi-memory proposal. + /// + /// Enabled by default. + #[cfg_attr(feature = "structopt", structopt(long, value_name = "true|false"))] + wasm_multi_memory: Option, + + /// Enable or disable the Wasm multi-value proposal. + /// + /// Enabled by default. + #[cfg_attr(feature = "structopt", structopt(long, value_name = "true|false"))] + wasm_multi_value: Option, } fn translate_val_type(ty: wasmparser::Type) -> wasm_encoder::ValType { @@ -145,6 +160,8 @@ impl Wizer { init_func: "wizer.initialize".into(), func_renames: vec![], allow_wasi: false, + wasm_multi_memory: None, + wasm_multi_value: None, } } @@ -181,6 +198,22 @@ impl Wizer { self } + /// Enable or disable the Wasm multi-memory proposal. + /// + /// Defaults to `true`. + pub fn wasm_multi_memory(&mut self, enable: bool) -> &mut Self { + self.wasm_multi_memory = Some(enable); + self + } + + /// Enable or disable the Wasm multi-value proposal. + /// + /// Defaults to `true`. + pub fn wasm_multi_value(&mut self, enable: bool) -> &mut Self { + self.wasm_multi_value = Some(enable); + self + } + /// Initialize the given Wasm, snapshot it, and return the serialized /// snapshot as a new, pre-initialized Wasm module. pub fn run(&self, wasm: &[u8]) -> anyhow::Result> { @@ -196,7 +229,9 @@ impl Wizer { "if the Wasm was originally valid, then our preparation step shouldn't invalidate it" ); - let store = wasmtime::Store::default(); + let config = self.wasmtime_config(); + let engine = wasmtime::Engine::new(&config); + let store = wasmtime::Store::new(&engine); let module = wasmtime::Module::new(store.engine(), &wasm)?; self.validate_init_func(&module)?; @@ -207,11 +242,30 @@ impl Wizer { Ok(initialized_wasm) } + // NB: keep this in sync with the wasmparser features. + fn wasmtime_config(&self) -> wasmtime::Config { + let mut config = wasmtime::Config::new(); + + // Proposals we support. + config.wasm_multi_memory(self.wasm_multi_memory.unwrap_or(DEFAULT_WASM_MULTI_MEMORY)); + config.wasm_multi_value(self.wasm_multi_value.unwrap_or(DEFAULT_WASM_MULTI_VALUE)); + + // Proposoals that we should add support for. + config.wasm_reference_types(false); + config.wasm_module_linking(false); + config.wasm_simd(false); + config.wasm_threads(false); + config.wasm_bulk_memory(false); + + config + } + + // NB: keep this in sync with the Wasmtime config. fn wasm_features(&self) -> wasmparser::WasmFeatures { wasmparser::WasmFeatures { // Proposals that we support. - multi_memory: true, - multi_value: true, + multi_memory: self.wasm_multi_memory.unwrap_or(DEFAULT_WASM_MULTI_MEMORY), + multi_value: self.wasm_multi_value.unwrap_or(DEFAULT_WASM_MULTI_VALUE), // Proposals that we should add support for. reference_types: false, From 5c91035b5a02fce96452a5a8bee0cb758711dc07 Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Tue, 16 Feb 2021 11:40:25 -0800 Subject: [PATCH 027/212] Rename `--func-rename` to `--rename-func` Keeps an alias around so the old flag will keep working. Also provides a "value name" so that the generated help text shows "" instead of "". --- crates/wizer/src/lib.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/crates/wizer/src/lib.rs b/crates/wizer/src/lib.rs index d5bc13f88fe6..311793981d3b 100644 --- a/crates/wizer/src/lib.rs +++ b/crates/wizer/src/lib.rs @@ -61,7 +61,15 @@ pub struct Wizer { /// /// This option can be used, for example, to replace a `_start` entry point /// in an initialized module with an alternate entry point. - #[cfg_attr(feature = "structopt", structopt(short = "r", long = "func-rename"))] + #[cfg_attr( + feature = "structopt", + structopt( + short = "r", + long = "rename-func", + alias = "func-rename", + value_name = "dst=src" + ) + )] func_renames: Vec, /// Allow WASI imports to be called during initialization. From 4662bef522cf8832cebaeca4391a85387a948aa3 Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Tue, 16 Feb 2021 12:07:22 -0800 Subject: [PATCH 028/212] Add a test for multi-memory Wasm modules --- crates/wizer/tests/tests.rs | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/crates/wizer/tests/tests.rs b/crates/wizer/tests/tests.rs index 8ddd6fb0509d..382dede1409d 100644 --- a/crates/wizer/tests/tests.rs +++ b/crates/wizer/tests/tests.rs @@ -14,7 +14,12 @@ fn run_wasm(args: &[wasmtime::Val], expected: i32, wasm: &[u8]) -> anyhow::Resul wizer.allow_wasi(true); let wasm = wizer.run(&wasm)?; - let store = wasmtime::Store::default(); + let mut config = wasmtime::Config::new(); + config.wasm_multi_memory(true); + config.wasm_multi_value(true); + + let engine = wasmtime::Engine::new(&config); + let store = wasmtime::Store::new(&engine); let module = wasmtime::Module::new(store.engine(), wasm)?; let mut linker = wasmtime::Linker::new(&store); @@ -79,6 +84,32 @@ fn basic_memory() -> anyhow::Result<()> { ) } +#[test] +fn multi_memory() -> anyhow::Result<()> { + run_wat( + &[], + 42, + r#" +(module + (memory $m1 1) + (memory $m2 1) + (func (export "wizer.initialize") + i32.const 0 + i32.const 41 + i32.store $m1 offset=1337 + i32.const 0 + i32.const 1 + i32.store $m2 offset=1337) + (func (export "run") (result i32) + i32.const 0 + i32.load $m1 offset=1337 + i32.const 0 + i32.load $m2 offset=1337 + i32.add)) +"#, + ) +} + #[test] fn rust_regex() -> anyhow::Result<()> { run_wasm( From 6f6ecc985f8c7298a08006605b005974dd3c6851 Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Tue, 16 Feb 2021 13:14:29 -0800 Subject: [PATCH 029/212] Upgrade dependencies --- crates/wizer/Cargo.lock | 77 ++++++++++++++++++++++++------------- crates/wizer/Cargo.toml | 16 ++++---- crates/wizer/src/lib.rs | 14 +++---- crates/wizer/tests/tests.rs | 8 ++-- 4 files changed, 70 insertions(+), 45 deletions(-) diff --git a/crates/wizer/Cargo.lock b/crates/wizer/Cargo.lock index 5d8bb8379551..c732eaae97da 100644 --- a/crates/wizer/Cargo.lock +++ b/crates/wizer/Cargo.lock @@ -35,9 +35,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.37" +version = "1.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee67c11feeac938fae061b232e38e0b6d94f97a9df10e6271319325ac4c56a86" +checksum = "afddf7f520a80dbf76e6f50a35bca42a2331ef227a28b3b6dc5c2e2338d114b1" [[package]] name = "atty" @@ -288,7 +288,7 @@ dependencies = [ "cranelift-codegen", "cranelift-entity", "cranelift-frontend", - "itertools", + "itertools 0.9.0", "log", "serde", "smallvec", @@ -307,16 +307,16 @@ dependencies = [ [[package]] name = "criterion" -version = "0.3.3" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70daa7ceec6cf143990669a04c7df13391d55fb27bd4079d252fca774ba244d8" +checksum = "ab327ed7354547cc2ef43cbe20ef68b988e70b4b593cbd66a2a61733123a3d23" dependencies = [ "atty", "cast", "clap", "criterion-plot", "csv", - "itertools", + "itertools 0.10.0", "lazy_static", "num-traits", "oorandom", @@ -338,7 +338,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e022feadec601fba1649cfa83586381a4ad31c6bf3a9ab7d408118b05dd9889d" dependencies = [ "cast", - "itertools", + "itertools 0.9.0", ] [[package]] @@ -665,6 +665,15 @@ dependencies = [ "either", ] +[[package]] +name = "itertools" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37d572918e350e82412fe766d24b15e6682fb2ed2bbe018280caa810397cb319" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "0.4.7" @@ -715,11 +724,11 @@ checksum = "8dd5a6d5999d9907cda8ed67bbd137d3af8085216c2ac62de5be860bd41f304a" [[package]] name = "log" -version = "0.4.11" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fabed175da42fed1fa0746b0ea71f412aa9d35e76e95e59b192c64b9dc2bf8b" +checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" dependencies = [ - "cfg-if 0.1.10", + "cfg-if 1.0.0", ] [[package]] @@ -811,16 +820,32 @@ checksum = "e36743d754ccdf9954c2e352ce2d4b106e024c814f6499c2dadff80da9a442d8" [[package]] name = "plotters" -version = "0.2.15" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d1685fbe7beba33de0330629da9d955ac75bd54f33d7b79f9a895590124f6bb" +checksum = "45ca0ae5f169d0917a7c7f5a9c1a3d3d9598f18f529dd2b8373ed988efea307a" dependencies = [ - "js-sys", "num-traits", + "plotters-backend", + "plotters-svg", "wasm-bindgen", "web-sys", ] +[[package]] +name = "plotters-backend" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b07fffcddc1cb3a1de753caa4e4df03b79922ba43cf882acc1bdd7e8df9f4590" + +[[package]] +name = "plotters-svg" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b38a02e23bd9604b842a812063aec4ef702b57989c37b655254bb61c471ad211" +dependencies = [ + "plotters-backend", +] + [[package]] name = "proc-macro-error" version = "1.0.4" @@ -1449,24 +1474,24 @@ checksum = "7e7811dd7f9398f14cc76efd356f98f03aa30419dea46aa810d71e819fc97158" [[package]] name = "wasm-encoder" -version = "0.3.1" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de1e5cf9b74ddfb73b85e09c95ce8b5992fe32ec5200cca44a8a4e85b1095670" +checksum = "c75fa62cf1464aa6655479ae454202a159cc82b7b4d66e8f174409669c0654c5" dependencies = [ "leb128", ] [[package]] name = "wasmparser" -version = "0.68.0" +version = "0.71.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29a00e14eed9c2ecbbdbdd4fb284f49d21b6808965de24769a6379a13ec47d4c" +checksum = "89a30c99437829ede826802bfcf28500cf58df00e66cb9114df98813bc145ff1" [[package]] name = "wasmparser" -version = "0.71.0" +version = "0.74.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89a30c99437829ede826802bfcf28500cf58df00e66cb9114df98813bc145ff1" +checksum = "4a4d63608421d9a22d4bce220f2841f3b609a5aaabd3ed3aeeb5fed2702c3c78" [[package]] name = "wasmtime" @@ -1707,20 +1732,20 @@ dependencies = [ [[package]] name = "wast" -version = "30.0.0" +version = "33.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b79907b22f740634810e882d8d1d9d0f9563095a8ab94e786e370242bff5cd2" +checksum = "1d04fe175c7f78214971293e7d8875673804e736092206a3a4544dbc12811c1b" dependencies = [ "leb128", ] [[package]] name = "wat" -version = "1.0.31" +version = "1.0.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8279a02835bf12e61ed2b3c3cbc6ecf9918762fd97e036917c11a09ec20ca44" +checksum = "7ec9c6ee01ae07a26adadcdfed22c7a97e0b8cbee9c06e0e96076ece5aeb5cfe" dependencies = [ - "wast 30.0.0", + "wast 33.0.0", ] [[package]] @@ -1846,7 +1871,7 @@ dependencies = [ "rayon", "structopt", "wasm-encoder", - "wasmparser 0.68.0", + "wasmparser 0.74.0", "wasmtime", "wasmtime-wasi", "wat", @@ -1901,6 +1926,6 @@ checksum = "a1e6e8778706838f43f771d80d37787cb2fe06dafe89dd3aebaf6721b9eaec81" dependencies = [ "cc", "glob", - "itertools", + "itertools 0.9.0", "libc", ] diff --git a/crates/wizer/Cargo.toml b/crates/wizer/Cargo.toml index 521243b6c2ea..d48dccc0d4c0 100644 --- a/crates/wizer/Cargo.toml +++ b/crates/wizer/Cargo.toml @@ -26,20 +26,20 @@ name = "uap" harness = false [dependencies] -anyhow = "1.0.34" -env_logger = { version = "0.8.1", optional = true } -log = "0.4.11" -structopt = { version = "0.3.20", optional = true } -wasm-encoder = "0.3.1" -wasmparser = "0.68.0" +anyhow = "1.0.38" +env_logger = { version = "0.8.2", optional = true } +log = "0.4.14" +structopt = { version = "0.3.21", optional = true } +wasm-encoder = "0.4.0" +wasmparser = "0.74.0" wasmtime = "0.22.0" wasmtime-wasi = "0.22.0" rayon = "1.5.0" [dev-dependencies] -wat = "1.0.28" +wat = "1.0.34" env_logger = "0.8.2" -criterion = "0.3.3" +criterion = "0.3.4" [workspace] members = [ diff --git a/crates/wizer/src/lib.rs b/crates/wizer/src/lib.rs index 311793981d3b..4b88eccbdceb 100644 --- a/crates/wizer/src/lib.rs +++ b/crates/wizer/src/lib.rs @@ -339,7 +339,10 @@ impl Wizer { data: &full_wasm[imports.range().start..imports.range().end], }); } - AliasSection(_) | InstanceSection(_) | ModuleSection(_) => { + AliasSection(_) + | InstanceSection(_) + | ModuleSectionStart { .. } + | ModuleSectionEntry { .. } => { anyhow::bail!("module linking is not supported yet") } FunctionSection(funcs) => { @@ -448,9 +451,6 @@ impl Wizer { }); } CodeSectionEntry(_) => continue, - ModuleCodeSectionStart { .. } | ModuleCodeSectionEntry { .. } => { - anyhow::bail!("module linking is not supported yet") - } UnknownSection { .. } => anyhow::bail!("unknown section"), EventSection(_) => anyhow::bail!("exceptions are not supported yet"), End => return Ok(module.finish()), @@ -752,7 +752,7 @@ impl Wizer { data: &full_wasm[imports.range().start..imports.range().end], }); } - AliasSection(_) | InstanceSection(_) | ModuleSection(_) => unreachable!(), + AliasSection(_) | InstanceSection(_) => unreachable!(), FunctionSection(funcs) => { module.section(&wasm_encoder::RawSection { id: wasm_encoder::SectionId::Function as u8, @@ -903,8 +903,8 @@ impl Wizer { }); } CodeSectionEntry(_) => continue, - ModuleCodeSectionStart { .. } - | ModuleCodeSectionEntry { .. } + ModuleSectionStart { .. } + | ModuleSectionEntry { .. } | UnknownSection { .. } | EventSection(_) => unreachable!(), End => { diff --git a/crates/wizer/tests/tests.rs b/crates/wizer/tests/tests.rs index 382dede1409d..3d0c0e670dd3 100644 --- a/crates/wizer/tests/tests.rs +++ b/crates/wizer/tests/tests.rs @@ -96,15 +96,15 @@ fn multi_memory() -> anyhow::Result<()> { (func (export "wizer.initialize") i32.const 0 i32.const 41 - i32.store $m1 offset=1337 + i32.store (memory $m1) offset=1337 i32.const 0 i32.const 1 - i32.store $m2 offset=1337) + i32.store (memory $m2) offset=1337) (func (export "run") (result i32) i32.const 0 - i32.load $m1 offset=1337 + i32.load (memory $m1) offset=1337 i32.const 0 - i32.load $m2 offset=1337 + i32.load (memory $m2) offset=1337 i32.add)) "#, ) From 13bd26f0b3cd7bd7c3f1f6d21a4c8025322fac3d Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Thu, 18 Feb 2021 11:20:20 -0800 Subject: [PATCH 030/212] Update Wasmtime to 0.23.0 --- crates/wizer/Cargo.lock | 598 +++++++++++++++++++++++------------- crates/wizer/Cargo.toml | 7 +- crates/wizer/src/lib.rs | 5 +- crates/wizer/tests/tests.rs | 2 +- 4 files changed, 395 insertions(+), 217 deletions(-) diff --git a/crates/wizer/Cargo.lock b/crates/wizer/Cargo.lock index c732eaae97da..666ab57e099e 100644 --- a/crates/wizer/Cargo.lock +++ b/crates/wizer/Cargo.lock @@ -58,9 +58,9 @@ checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" [[package]] name = "backtrace" -version = "0.3.55" +version = "0.3.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef5140344c85b01f9bbb4d4b7288a8aa4b3287ccef913a14bcc78a1063623598" +checksum = "9d117600f438b1707d4e4ae15d3595657288f8235a0eb593e80ecc98ab34e1bc" dependencies = [ "addr2line", "cfg-if 1.0.0", @@ -103,9 +103,9 @@ dependencies = [ [[package]] name = "bstr" -version = "0.2.14" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "473fc6b38233f9af7baa94fb5852dca389e3d95b8e21c8e3719301462c5d9faf" +checksum = "a40b47ad93e1a5404e6c18dec46b628214fee441c70f4ab5d6942142cc268a3d" dependencies = [ "lazy_static", "memchr", @@ -115,15 +115,80 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.4.0" +version = "3.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e8c087f005730276d1096a652e92a8bacee2e2472bcc9715a74d2bec38b5820" +checksum = "099e596ef14349721d9016f6b80dd3419ea1bf289ab9b44df8e4dfd3a005d5d9" [[package]] name = "byteorder" -version = "1.3.4" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae44d1a3d5a19df61dd0c8beb138458ac2a53a7ac09eba97d55592540004306b" + +[[package]] +name = "cap-fs-ext" +version = "0.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "209aca9ff6a807ff2df9f0b75634f5680cad4e86b1712516ed3aa82053e16466" +dependencies = [ + "cap-primitives", + "cap-std", + "rustc_version 0.3.3", + "unsafe-io", + "winapi", +] + +[[package]] +name = "cap-primitives" +version = "0.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6da225ce9df468bef6626bfe020c00269f8f2b54086aaef0605665762a77be9a" +dependencies = [ + "errno", + "fs-set-times", + "ipnet", + "libc", + "maybe-owned", + "once_cell", + "posish", + "rustc_version 0.3.3", + "unsafe-io", + "winapi", + "winapi-util", + "winx", +] + +[[package]] +name = "cap-rand" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd7853689263850e5b446c252e4a0a7876ca8e739c791953c41566fea8204019" +dependencies = [ + "rand", +] + +[[package]] +name = "cap-std" +version = "0.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1304c7889d8a5f9f9fdf6df401c026ac95b3a628ded9d890058e802125d72fa2" +dependencies = [ + "cap-primitives", + "rustc_version 0.3.3", + "unsafe-io", +] + +[[package]] +name = "cap-time-ext" +version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" +checksum = "5e30af4a25ca95711d1aef0cd53e534c24e77f49907c35aa3465fb3f44431265" +dependencies = [ + "cap-primitives", + "once_cell", + "posish", + "winx", +] [[package]] name = "cast" @@ -131,7 +196,7 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4b9434b9a5aa1450faa3f9cb14ea0e8c53bb5d2b3c1bfd1ab4fc03e9f33fbfb0" dependencies = [ - "rustc_version", + "rustc_version 0.2.3", ] [[package]] @@ -186,16 +251,6 @@ dependencies = [ "glob", ] -[[package]] -name = "cpu-time" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9e393a7668fe1fad3075085b86c781883000b4ede868f43627b34a87c8b7ded" -dependencies = [ - "libc", - "winapi", -] - [[package]] name = "cpuid-bool" version = "0.1.2" @@ -204,18 +259,18 @@ checksum = "8aebca1129a03dc6dc2b127edd729435bbc4a37e1d5f4d7513165089ceb02634" [[package]] name = "cranelift-bforest" -version = "0.69.0" +version = "0.70.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4066fd63b502d73eb8c5fa6bcab9c7962b05cd580f6b149ee83a8e730d8ce7fb" +checksum = "31f782ffb172d8095cbb4c6464d85432c3bcfa8609b0bb1dc27cfd35bd90e052" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-codegen" -version = "0.69.0" +version = "0.70.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a54e4beb833a3c873a18a8fe735d73d732044004c7539a072c8faa35ccb0c60" +checksum = "91e0910022b490bd0a65d5baa1693b0475cdbeea1c26472343f2acea1f1f55b8" dependencies = [ "byteorder", "cranelift-bforest", @@ -233,9 +288,9 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.69.0" +version = "0.70.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c54cac7cacb443658d8f0ff36a3545822613fa202c946c0891897843bc933810" +checksum = "7cafe95cb5ac659e113549b2794a2c8d3a14f36e1a98728a6e0ea7a773be2129" dependencies = [ "cranelift-codegen-shared", "cranelift-entity", @@ -243,24 +298,24 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" -version = "0.69.0" +version = "0.70.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a109760aff76788b2cdaeefad6875a73c2b450be13906524f6c2a81e05b8d83c" +checksum = "8d1bd002e42cc094a131a8227d06d48df28ea3b9127e5e3bc3010e079858e9af" [[package]] name = "cranelift-entity" -version = "0.69.0" +version = "0.70.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b044234aa32531f89a08b487630ddc6744696ec04c8123a1ad388de837f5de3" +checksum = "e55e9043403f0dec775f317280015150e78b2352fb947d2f37407fd4ce6311c7" dependencies = [ "serde", ] [[package]] name = "cranelift-frontend" -version = "0.69.0" +version = "0.70.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5452b3e4e97538ee5ef2cc071301c69a86c7adf2770916b9d04e9727096abd93" +checksum = "0153680ebce89aac7cad90a5442bb136faacfc86ea62587a01b8e8e79f8249c9" dependencies = [ "cranelift-codegen", "log", @@ -270,30 +325,29 @@ dependencies = [ [[package]] name = "cranelift-native" -version = "0.69.0" +version = "0.70.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f68035c10b2e80f26cc29c32fa824380877f38483504c2a47b54e7da311caaf3" +checksum = "d742cf2c28699eeea26b9a7f6a53b5976fb4a7ca4778e736c063ab57592dc0cb" dependencies = [ "cranelift-codegen", - "raw-cpuid", "target-lexicon", ] [[package]] name = "cranelift-wasm" -version = "0.69.0" +version = "0.70.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a530eb9d1c95b3309deb24c3d179d8b0ba5837ed98914a429787c395f614949d" +checksum = "9e59effbaf9386ffa6742a737c159178f2085cf19634bcd8381caa87b48cd689" dependencies = [ "cranelift-codegen", "cranelift-entity", "cranelift-frontend", - "itertools 0.9.0", + "itertools 0.10.0", "log", "serde", "smallvec", "thiserror", - "wasmparser 0.71.0", + "wasmparser 0.73.1", ] [[package]] @@ -449,9 +503,9 @@ dependencies = [ [[package]] name = "dirs-sys-next" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99de365f605554ae33f115102a02057d4fc18b01f3284d6870be0938743cfe7d" +checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d" dependencies = [ "libc", "redox_users", @@ -485,12 +539,12 @@ dependencies = [ [[package]] name = "env_logger" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26ecb66b4bdca6c1409b40fb255eefc2bd4f6d135dab3c3124f80ffa2a9661e" +checksum = "17392a012ea30ef05a610aa97dfb49496e71c9f676b27879922ea5bdf60d9d3f" dependencies = [ "atty", - "humantime 2.0.1", + "humantime 2.1.0", "log", "regex", "termcolor", @@ -534,14 +588,12 @@ dependencies = [ ] [[package]] -name = "filetime" -version = "0.2.13" +name = "fs-set-times" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c122a393ea57648015bf06fbd3d372378992e86b9ff5a7a497b076a28c79efe" +checksum = "e0700f6e5d24b4556cc0807148ed978a5f5b12c942528aed44bd8f02967bc70c" dependencies = [ - "cfg-if 1.0.0", - "libc", - "redox_syscall", + "posish", "winapi", ] @@ -563,24 +615,13 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.1.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" -dependencies = [ - "cfg-if 1.0.0", - "libc", - "wasi 0.9.0+wasi-snapshot-preview1", -] - -[[package]] -name = "getrandom" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4060f4657be78b8e766215b02b18a2e862d83745545de804638e2b545e81aee6" +checksum = "c9495705279e7140bf035dde1f6e750c162df8b625267cd52cc44e0b156732c8" dependencies = [ "cfg-if 1.0.0", "libc", - "wasi 0.10.1+wasi-snapshot-preview1", + "wasi", ] [[package]] @@ -602,9 +643,9 @@ checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" [[package]] name = "half" -version = "1.6.0" +version = "1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d36fab90f82edc3c747f9d438e06cf0a491055896f2a279638bb5beed6c40177" +checksum = "62aca2aba2d62b4a7f5b33f3712cb1b0692779a56fb510499d5c0aa594daeaf3" [[package]] name = "hashbrown" @@ -623,9 +664,9 @@ dependencies = [ [[package]] name = "hermit-abi" -version = "0.1.17" +version = "0.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aca5565f760fb5b220e499d72710ed156fdb74e631659e99377d9ebfbd13ae8" +checksum = "322f4de77956e22ed0e5032c359a0f1273f1f7f0d79bfa3b8ffbc730d7fbcc5c" dependencies = [ "libc", ] @@ -641,9 +682,9 @@ dependencies = [ [[package]] name = "humantime" -version = "2.0.1" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c1ad908cc71012b7bea4d0c53ba96a8cba9962f048fa68d143376143d863b7a" +checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "indexmap" @@ -656,6 +697,12 @@ dependencies = [ "serde", ] +[[package]] +name = "ipnet" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47be2f14c678be2fdcab04ab1171db51b2762ce6f0a8ee87c8dd4a04ed216135" + [[package]] name = "itertools" version = "0.9.0" @@ -691,9 +738,9 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.46" +version = "0.3.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf3d7383929f7c9c7c2d0fa596f325832df98c3704f2c60553080f7127a58175" +checksum = "5cfb73131c35423a367daf8cbd24100af0d077668c8c2943f0e7dd775fef0f65" dependencies = [ "wasm-bindgen", ] @@ -712,15 +759,15 @@ checksum = "3576a87f2ba00f6f106fdfcd16db1d698d648a26ad8e0573cad8537c3c362d2a" [[package]] name = "libc" -version = "0.2.81" +version = "0.2.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1482821306169ec4d07f6aca392a4681f66c75c9918aa49641a2595db64053cb" +checksum = "b7282d924be3275cec7f6756ff4121987bc6481325397dde6ba3e7802b1a8b1c" [[package]] name = "linked-hash-map" -version = "0.5.3" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8dd5a6d5999d9907cda8ed67bbd137d3af8085216c2ac62de5be860bd41f304a" +checksum = "7fb9b38af92608140b86b693604b9ffcc5824240a484d1ecd4795bacb2fe88f3" [[package]] name = "log" @@ -740,6 +787,12 @@ dependencies = [ "libc", ] +[[package]] +name = "maybe-owned" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4facc753ae494aeb6e3c22f839b158aebd4f9270f55cd3c79906c45476c47ab4" + [[package]] name = "memchr" version = "2.3.4" @@ -792,14 +845,20 @@ dependencies = [ [[package]] name = "object" -version = "0.22.0" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d3b63360ec3cb337817c2dbd47ab4a0f170d285d8e5a2064600f3def1402397" +checksum = "a9a7ab5d64814df0fe4a4b5ead45ed6c5f181ee3ff04ba344313a6c80446c5d4" dependencies = [ "crc32fast", "indexmap", ] +[[package]] +name = "once_cell" +version = "1.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13bd41f508810a131401606d54ac32a467c97172d74ba7662562ebba5ad07fa0" + [[package]] name = "oorandom" version = "11.1.3" @@ -812,11 +871,20 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" +[[package]] +name = "pest" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10f4872ae94d7b90ae48754df22fd42ad52ce740b8f370b03da4835417403e53" +dependencies = [ + "ucd-trie", +] + [[package]] name = "pin-project-lite" -version = "0.2.1" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e36743d754ccdf9954c2e352ce2d4b106e024c814f6499c2dadff80da9a442d8" +checksum = "439697af366c49a6d0a010c56a0d97685bc140ce0d377b13a2ea2aa42d64a827" [[package]] name = "plotters" @@ -846,6 +914,25 @@ dependencies = [ "plotters-backend", ] +[[package]] +name = "posish" +version = "0.5.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0590fc1e852795610551182100874078cd243f6c43d1066338a6bdc38d7b187" +dependencies = [ + "bitflags", + "cfg-if 1.0.0", + "errno", + "itoa", + "libc", +] + +[[package]] +name = "ppv-lite86" +version = "0.2.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857" + [[package]] name = "proc-macro-error" version = "1.0.4" @@ -896,22 +983,51 @@ checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" [[package]] name = "quote" -version = "1.0.8" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "991431c3519a3f36861882da93630ce66b52918dcf1b8e2fd66b397fc96f28df" +checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7" dependencies = [ "proc-macro2", ] [[package]] -name = "raw-cpuid" -version = "8.1.2" +name = "rand" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fdf7d9dbd43f3d81d94a49c1c3df73cc2b3827995147e6cf7f89d4ec5483e73" +checksum = "0ef9e7e66b4468674bfcb0c81af8b7fa0bb154fa9f28eb840da5c447baeb8d7e" dependencies = [ - "bitflags", - "cc", - "rustc_version", + "libc", + "rand_chacha", + "rand_core", + "rand_hc", +] + +[[package]] +name = "rand_chacha" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e12735cf05c9e10bf21534da50a147b924d555dc7a547c42e6bb2d5b6017ae0d" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34cf66eb183df1c5876e2dcf6b13d57340741e8dc255b48e40a26de954d06ae7" +dependencies = [ + "getrandom", +] + +[[package]] +name = "rand_hc" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3190ef7066a446f2e7f42e239d161e905420ccab01eb967c9eb27d21b2322a73" +dependencies = [ + "rand_core", ] [[package]] @@ -941,17 +1057,20 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.1.57" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" +checksum = "94341e4e44e24f6b591b59e47a8a027df12e008d73fd5672dbea9cc22f4507d9" +dependencies = [ + "bitflags", +] [[package]] name = "redox_users" -version = "0.3.5" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de0737333e7a9502c789a36d7c7fa6092a49895d4faa31ca5df163857ded2e9d" +checksum = "528532f3d801c87aec9def2add9ca802fe569e44a544afe633765267840abe64" dependencies = [ - "getrandom 0.1.16", + "getrandom", "redox_syscall", ] @@ -963,14 +1082,15 @@ checksum = "571f7f397d61c4755285cd37853fe8e03271c243424a907415909379659381c5" dependencies = [ "log", "rustc-hash", + "serde", "smallvec", ] [[package]] name = "regex" -version = "1.4.2" +version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38cf2c13ed4745de91a5eb834e11c00bcc3709e773173b2ce4c56c9fbde04b9c" +checksum = "d9251239e129e16308e70d853559389de218ac275b515068abc96829d05b948a" dependencies = [ "aho-corasick", "memchr", @@ -996,9 +1116,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.6.21" +version = "0.6.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b181ba2dcf07aaccad5448e8ead58db5b742cf85dfe035e2227f137a539a189" +checksum = "b5eb417147ba9860a96cfe72a0b93bf88fee1744b5636ec99ab20c1aa9376581" [[package]] name = "regex-test" @@ -1037,7 +1157,16 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" dependencies = [ - "semver", + "semver 0.9.0", +] + +[[package]] +name = "rustc_version" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0dfe2087c51c460008730de8b57e6a320782fbfb312e1f4d520e6c6fae155ee" +dependencies = [ + "semver 0.11.0", ] [[package]] @@ -1072,9 +1201,9 @@ dependencies = [ [[package]] name = "scroll_derive" -version = "0.10.4" +version = "0.10.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b12bd20b94c7cdfda8c7ba9b92ad0d9a56e3fa018c25fca83b51aa664c9b4c0d" +checksum = "aaaae8f38bb311444cfb7f1979af0bc9240d95795f75f9ceddf6a59b79ceffa0" dependencies = [ "proc-macro2", "quote", @@ -1087,7 +1216,16 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" dependencies = [ - "semver-parser", + "semver-parser 0.7.0", +] + +[[package]] +name = "semver" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6" +dependencies = [ + "semver-parser 0.10.2", ] [[package]] @@ -1096,11 +1234,20 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" +[[package]] +name = "semver-parser" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0bef5b7f9e0df16536d3961cfb6e84331c065b4066afb39768d0e319411f7" +dependencies = [ + "pest", +] + [[package]] name = "serde" -version = "1.0.118" +version = "1.0.123" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06c64263859d87aa2eb554587e2d23183398d617427327cf2b3d0ed8c69e4800" +checksum = "92d5161132722baa40d802cc70b15262b98258453e85e5d1d365c757c73869ae" dependencies = [ "serde_derive", ] @@ -1117,9 +1264,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.118" +version = "1.0.123" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c84d3526699cd55261af4b941e4e725444df67aa4f9e6a3564f18030d12672df" +checksum = "9391c295d64fc0abb2c556bad848f33cb8296276b1ad2677d1ae1ace4f258f31" dependencies = [ "proc-macro2", "quote", @@ -1128,9 +1275,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.61" +version = "1.0.62" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fceb2595057b6891a4ee808f70054bd2d12f0e97f1cbb78689b59f676df325a" +checksum = "ea1c6153794552ea7cf7cf63b1231a25de00ec90db326ba6264440fa08e31486" dependencies = [ "itoa", "ryu", @@ -1139,9 +1286,9 @@ dependencies = [ [[package]] name = "serde_yaml" -version = "0.8.15" +version = "0.8.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "971be8f6e4d4a47163b405a3df70d14359186f9ab0f3a3ec37df144ca1ce089f" +checksum = "15654ed4ab61726bf918a39cb8d98a2e2995b002387807fa6ba58fdf7f59bb23" dependencies = [ "dtoa", "linked-hash-map", @@ -1151,9 +1298,9 @@ dependencies = [ [[package]] name = "sha2" -version = "0.9.2" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e7aab86fe2149bad8c507606bdb3f4ef5e7b2380eb92350f56122cca72a42a8" +checksum = "fa827a14b29ab7f44778d14a88d3cb76e949c45083f7dbfa507d0cb699dc12de" dependencies = [ "block-buffer", "cfg-if 1.0.0", @@ -1173,9 +1320,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.6.0" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a55ca5f3b68e41c979bf8c46a6f1da892ca4db8f94023ce0bd32407573b1ac0" +checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e" [[package]] name = "stable_deref_trait" @@ -1215,20 +1362,37 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.58" +version = "1.0.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc60a3d73ea6594cd712d830cc1f0390fd71542d8c8cd24e70cc54cdfd5e05d5" +checksum = "c700597eca8a5a762beb35753ef6b94df201c81cca676604f547495a0d7f0081" dependencies = [ "proc-macro2", "quote", "unicode-xid", ] +[[package]] +name = "system-interface" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a720af6fce4a6ffcf53ffb4d0e15aeb86c90e96fc21b44eb104a1b43e31014ac" +dependencies = [ + "atty", + "bitflags", + "cap-fs-ext", + "cap-std", + "posish", + "rustc_version 0.3.3", + "unsafe-io", + "winapi", + "winx", +] + [[package]] name = "target-lexicon" -version = "0.11.1" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ee5a98e506fb7231a304c3a1bd7c132a55016cf65001e0282480665870dfcb9" +checksum = "422045212ea98508ae3d28025bc5aaa2bd4a9cdaecd442a08da2ee620ee9ea95" [[package]] name = "termcolor" @@ -1270,11 +1434,11 @@ dependencies = [ [[package]] name = "thread_local" -version = "1.0.1" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14" +checksum = "8018d24e04c95ac8790716a5987d0fec4f8b27249ffa0f7d33f1369bdfb88cbd" dependencies = [ - "lazy_static", + "once_cell", ] [[package]] @@ -1298,9 +1462,9 @@ dependencies = [ [[package]] name = "tracing" -version = "0.1.22" +version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f47026cdc4080c07e49b37087de021820269d996f581aac150ef9e5583eefe3" +checksum = "f7d40a22fd029e33300d8d89a5cc8ffce18bb7c587662f54629e94c9de5487f3" dependencies = [ "cfg-if 1.0.0", "log", @@ -1311,9 +1475,9 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.11" +version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80e0ccfc3378da0cce270c946b676a376943f5cd16aeba64568e7939806f4ada" +checksum = "43f080ea7e4107844ef4766459426fa2d5c1ada2e47edba05dc7fa99d9629f47" dependencies = [ "proc-macro2", "quote", @@ -1344,6 +1508,12 @@ dependencies = [ "serde_yaml", ] +[[package]] +name = "ucd-trie" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c" + [[package]] name = "unicode-segmentation" version = "1.7.1" @@ -1362,6 +1532,15 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" +[[package]] +name = "unsafe-io" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd35327a2b46b3350186b75a3a337d4517e5ca08118c4e54175d49d7832578d8" +dependencies = [ + "rustc_version 0.3.3", +] + [[package]] name = "vec_map" version = "0.8.2" @@ -1387,42 +1566,54 @@ dependencies = [ [[package]] name = "wasi" -version = "0.9.0+wasi-snapshot-preview1" +version = "0.10.2+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" +checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" [[package]] -name = "wasi" -version = "0.10.1+wasi-snapshot-preview1" +name = "wasi-cap-std-sync" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93c6c3420963c5c64bca373b25e77acb562081b9bb4dd5bb864187742186cea9" +checksum = "0d03faceaadebcd4fff2fc7ff9be5327d61fda990396d3379677fac18ff4e2ed" +dependencies = [ + "anyhow", + "bitflags", + "cap-fs-ext", + "cap-rand", + "cap-std", + "cap-time-ext", + "fs-set-times", + "lazy_static", + "libc", + "system-interface", + "tracing", + "unsafe-io", + "wasi-common", + "winapi", +] [[package]] name = "wasi-common" -version = "0.22.0" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "843c91a27e7b6a80bdc38b4383eec42e46bc81962dbf016f32a298c9126327a1" +checksum = "424508503b311d67c83dd909d6237ca6474a638c7d8d40b9d654daedd1e2543a" dependencies = [ "anyhow", - "cfg-if 1.0.0", - "cpu-time", - "filetime", - "getrandom 0.2.1", - "lazy_static", + "bitflags", + "cap-rand", + "cap-std", "libc", "thiserror", "tracing", "wiggle", "winapi", - "winx", - "yanix", ] [[package]] name = "wasm-bindgen" -version = "0.2.69" +version = "0.2.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3cd364751395ca0f68cafb17666eee36b63077fb5ecd972bbcd74c90c4bf736e" +checksum = "55c0f7123de74f0dab9b7d00fd614e7b19349cd1e2f5252bbe9b1754b59433be" dependencies = [ "cfg-if 1.0.0", "wasm-bindgen-macro", @@ -1430,9 +1621,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.69" +version = "0.2.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1114f89ab1f4106e5b55e688b828c0ab0ea593a1ea7c094b141b14cbaaec2d62" +checksum = "7bc45447f0d4573f3d65720f636bbcc3dd6ce920ed704670118650bcd47764c7" dependencies = [ "bumpalo", "lazy_static", @@ -1445,9 +1636,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.69" +version = "0.2.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a6ac8995ead1f084a8dea1e65f194d0973800c7f571f6edd70adf06ecf77084" +checksum = "3b8853882eef39593ad4174dd26fc9865a64e84026d223f63bb2c42affcbba2c" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -1455,9 +1646,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.69" +version = "0.2.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5a48c72f299d80557c7c62e37e7225369ecc0c963964059509fbafe917c7549" +checksum = "4133b5e7f2a531fa413b3a1695e925038a05a71cf67e87dafa295cb645a01385" dependencies = [ "proc-macro2", "quote", @@ -1468,9 +1659,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.69" +version = "0.2.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e7811dd7f9398f14cc76efd356f98f03aa30419dea46aa810d71e819fc97158" +checksum = "dd4945e4943ae02d15c13962b38a5b1e81eadd4b71214eee75af64a4d6a4fd64" [[package]] name = "wasm-encoder" @@ -1483,9 +1674,9 @@ dependencies = [ [[package]] name = "wasmparser" -version = "0.71.0" +version = "0.73.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89a30c99437829ede826802bfcf28500cf58df00e66cb9114df98813bc145ff1" +checksum = "b8526ab131cbc49495a483c98954913ae7b83551adacab5e294cf77992e70ee7" [[package]] name = "wasmparser" @@ -1495,9 +1686,9 @@ checksum = "4a4d63608421d9a22d4bce220f2841f3b609a5aaabd3ed3aeeb5fed2702c3c78" [[package]] name = "wasmtime" -version = "0.22.0" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7426055cb92bd9a1e9469b48154d8d6119cd8c498c8b70284e420342c05dc45d" +checksum = "8878f1f740127905dd8eddadfeaeea786f81856369eecc65e6c83ac909633cda" dependencies = [ "anyhow", "backtrace", @@ -1512,7 +1703,7 @@ dependencies = [ "serde", "smallvec", "target-lexicon", - "wasmparser 0.71.0", + "wasmparser 0.73.1", "wasmtime-cache", "wasmtime-environ", "wasmtime-jit", @@ -1524,9 +1715,9 @@ dependencies = [ [[package]] name = "wasmtime-cache" -version = "0.22.0" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c01d9287e36921e46f5887a47007824ae5dbb9b7517a2d565660ab4471478709" +checksum = "7b28e400f6a4d5d8e0086b3a2999e03be217a807f3f376dbdac5136a81ec6f79" dependencies = [ "anyhow", "base64", @@ -1545,22 +1736,23 @@ dependencies = [ [[package]] name = "wasmtime-cranelift" -version = "0.22.0" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4134ed3a4316cd0de0e546c6004850afe472b0fa3fcdc2f2c15f8d449562d962" +checksum = "0c0a13645a4b833dba480a18f048b8cebae06e70f9aa86313d779541cc1847ad" dependencies = [ "cranelift-codegen", "cranelift-entity", "cranelift-frontend", "cranelift-wasm", + "wasmparser 0.73.1", "wasmtime-environ", ] [[package]] name = "wasmtime-debug" -version = "0.22.0" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e91fa931df6dd8af2b02606307674d3bad23f55473d5f4c809dddf7e4c4dc411" +checksum = "a53b773abc89fed963d64969e38a08ed1cbc8fef43ac7383ad3f489e1a2b50ac" dependencies = [ "anyhow", "gimli", @@ -1568,15 +1760,15 @@ dependencies = [ "object", "target-lexicon", "thiserror", - "wasmparser 0.71.0", + "wasmparser 0.73.1", "wasmtime-environ", ] [[package]] name = "wasmtime-environ" -version = "0.22.0" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1098871dc3120aaf8190d79153e470658bb79f63ee9ca31716711e123c28220" +checksum = "f2bb053d9d3db2bbae51f87b11879386d472bf2b1dfdde8f413ae2ae0c8b9ddb" dependencies = [ "anyhow", "cfg-if 1.0.0", @@ -1589,14 +1781,14 @@ dependencies = [ "more-asserts", "serde", "thiserror", - "wasmparser 0.71.0", + "wasmparser 0.73.1", ] [[package]] name = "wasmtime-jit" -version = "0.22.0" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "738bfcd1561ede8bb174215776fd7d9a95d5f0a47ca3deabe0282c55f9a89f68" +checksum = "fcbf76a9b7da95c6099acf5610594f7e4eac462b163e75eb1fc333b6053c6e01" dependencies = [ "addr2line", "anyhow", @@ -1615,7 +1807,7 @@ dependencies = [ "serde", "target-lexicon", "thiserror", - "wasmparser 0.71.0", + "wasmparser 0.73.1", "wasmtime-cranelift", "wasmtime-debug", "wasmtime-environ", @@ -1627,9 +1819,9 @@ dependencies = [ [[package]] name = "wasmtime-obj" -version = "0.22.0" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e96d77f1801131c5e86d93e42a3cf8a35402107332c202c245c83f34888a906" +checksum = "f4909472de9ea73609551d883a27ab7c2b04a1c7b90bb3d25cf1314ccaf7f3d4" dependencies = [ "anyhow", "more-asserts", @@ -1641,9 +1833,9 @@ dependencies = [ [[package]] name = "wasmtime-profiling" -version = "0.22.0" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60bb672c9d894776d7b9250dd9b4fe890f8760201ee4f53e5f2da772b6c4debb" +checksum = "a04a0119d0a30f8341d436b834da16a3cd23115045fb024f44b062d3abd29ae7" dependencies = [ "anyhow", "cfg-if 1.0.0", @@ -1660,9 +1852,9 @@ dependencies = [ [[package]] name = "wasmtime-runtime" -version = "0.22.0" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a978086740949eeedfefcee667b57a9e98d9a7fc0de382fcfa0da30369e3530d" +checksum = "dac84560e3a8d378d76cc6c25cca5ad216a9ad85fc03ac06f91ecdf4bbbb62b8" dependencies = [ "backtrace", "cc", @@ -1682,37 +1874,34 @@ dependencies = [ [[package]] name = "wasmtime-wasi" -version = "0.22.0" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff7b445df9bc7da40c357b0b05d6ed30c5f5376fde7ee5e86b25564ce8e54e2d" +checksum = "6b545359011c26641fbc080eafa9e74516d4c929fd34d8d4fdb91021929bc0f4" dependencies = [ "anyhow", - "tracing", "wasi-common", "wasmtime", - "wasmtime-runtime", "wasmtime-wiggle", "wiggle", ] [[package]] name = "wasmtime-wiggle" -version = "0.22.0" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5a63659462abadf28ceb61f20f3456b792b16cdaf20207faea9124886aed392" +checksum = "1200f57e8b7b9aba73fcf908e6d89aa1720d879532948653e1548c180790dc35" dependencies = [ "wasmtime", "wasmtime-wiggle-macro", "wiggle", "wiggle-borrow", - "witx", ] [[package]] name = "wasmtime-wiggle-macro" -version = "0.22.0" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e60d0d185876a2eec2b56ed470de91cf1e9860a099953ec54fd88bd28c5002ef" +checksum = "6a38e270c5d1e318f0748847f39774f0fd036b61bd9c0781fd170921171a0573" dependencies = [ "proc-macro2", "quote", @@ -1750,9 +1939,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.46" +version = "0.3.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "222b1ef9334f92a21d3fb53dc3fd80f30836959a90f9274a626d7e06315ba3c3" +checksum = "c40dc691fc48003eba817c38da7113c15698142da971298003cac3ef175680b3" dependencies = [ "js-sys", "wasm-bindgen", @@ -1760,10 +1949,11 @@ dependencies = [ [[package]] name = "wiggle" -version = "0.22.0" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1ca41d22d39db23fe440022aa010a84da3854e27f32e239e5ecc1d8cd2227fa" +checksum = "b7b3d7fa155c0809b3b7c0c043fe41171d0a1d6669a7e566728c5285d52beebb" dependencies = [ + "bitflags", "thiserror", "tracing", "wiggle-macro", @@ -1772,18 +1962,18 @@ dependencies = [ [[package]] name = "wiggle-borrow" -version = "0.22.0" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9765eec737f8a36b6060d94d34954d48f353a91694811510d08b2141cba51726" +checksum = "f2fa06922b25613c70df086ee95dce9ad240d2a30659f4bacfc6868aeeb55009" dependencies = [ "wiggle", ] [[package]] name = "wiggle-generate" -version = "0.22.0" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea1b6a09972d1a154b0d3c4cded3469c4639fa7bc200309e053ff943b9034147" +checksum = "fff9a8db03f14e9c1eec259353863be8818cfb5bfafa6211d4a3af409c008de8" dependencies = [ "anyhow", "heck", @@ -1796,9 +1986,9 @@ dependencies = [ [[package]] name = "wiggle-macro" -version = "0.22.0" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62ed20d774be09682f68b8c519a6abaa5fc279479c048cca7db019a7fa3ce361" +checksum = "8e3d20ca8d19ab366f4a085328344dc592396d91a99d84448fae92c177dbd42e" dependencies = [ "quote", "syn", @@ -1866,10 +2056,11 @@ version = "1.1.0" dependencies = [ "anyhow", "criterion", - "env_logger 0.8.2", + "env_logger 0.8.3", "log", "rayon", "structopt", + "wasi-cap-std-sync", "wasm-encoder", "wasmparser 0.74.0", "wasmtime", @@ -1886,33 +2077,20 @@ dependencies = [ "linked-hash-map", ] -[[package]] -name = "yanix" -version = "0.22.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0504d76a87b9e77f1057d419a51acb4344b9e14eaf37dde22cf1fd0ec28901db" -dependencies = [ - "bitflags", - "cfg-if 1.0.0", - "filetime", - "libc", - "tracing", -] - [[package]] name = "zstd" -version = "0.5.4+zstd.1.4.7" +version = "0.6.0+zstd.1.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69996ebdb1ba8b1517f61387a883857818a66c8a295f487b1ffd8fd9d2c82910" +checksum = "d4e44664feba7f2f1a9f300c1f6157f2d1bfc3c15c6f3cf4beabf3f5abe9c237" dependencies = [ "zstd-safe", ] [[package]] name = "zstd-safe" -version = "2.0.6+zstd.1.4.7" +version = "3.0.0+zstd.1.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98aa931fb69ecee256d44589d19754e61851ae4769bf963b385119b1cc37a49e" +checksum = "d9447afcd795693ad59918c7bbffe42fdd6e467d708f3537e3dc14dc598c573f" dependencies = [ "libc", "zstd-sys", @@ -1920,9 +2098,9 @@ dependencies = [ [[package]] name = "zstd-sys" -version = "1.4.18+zstd.1.4.7" +version = "1.4.19+zstd.1.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1e6e8778706838f43f771d80d37787cb2fe06dafe89dd3aebaf6721b9eaec81" +checksum = "ec24a9273d24437afb8e71b16f3d9a5d569193cccdb7896213b59f552f387674" dependencies = [ "cc", "glob", diff --git a/crates/wizer/Cargo.toml b/crates/wizer/Cargo.toml index d48dccc0d4c0..432109e6f654 100644 --- a/crates/wizer/Cargo.toml +++ b/crates/wizer/Cargo.toml @@ -29,12 +29,13 @@ harness = false anyhow = "1.0.38" env_logger = { version = "0.8.2", optional = true } log = "0.4.14" +rayon = "1.5.0" structopt = { version = "0.3.21", optional = true } +wasi-cap-std-sync = "0.23.0" wasm-encoder = "0.4.0" wasmparser = "0.74.0" -wasmtime = "0.22.0" -wasmtime-wasi = "0.22.0" -rayon = "1.5.0" +wasmtime = "0.23.0" +wasmtime-wasi = "0.23.0" [dev-dependencies] wat = "1.0.34" diff --git a/crates/wizer/src/lib.rs b/crates/wizer/src/lib.rs index 4b88eccbdceb..3c2e6bd6030d 100644 --- a/crates/wizer/src/lib.rs +++ b/crates/wizer/src/lib.rs @@ -559,9 +559,8 @@ impl Wizer { let mut linker = wasmtime::Linker::new(store); if self.allow_wasi { - let ctx = wasmtime_wasi::WasiCtx::new(None::)?; - let wasi = wasmtime_wasi::Wasi::new(store, ctx); - wasi.add_to_linker(&mut linker)?; + let ctx = wasi_cap_std_sync::WasiCtxBuilder::new().build()?; + wasmtime_wasi::Wasi::new(store, ctx).add_to_linker(&mut linker)?; } self.dummy_imports(&store, &module, &mut linker)?; let instance = linker.instantiate(module)?; diff --git a/crates/wizer/tests/tests.rs b/crates/wizer/tests/tests.rs index 3d0c0e670dd3..5b18e0200a04 100644 --- a/crates/wizer/tests/tests.rs +++ b/crates/wizer/tests/tests.rs @@ -23,7 +23,7 @@ fn run_wasm(args: &[wasmtime::Val], expected: i32, wasm: &[u8]) -> anyhow::Resul let module = wasmtime::Module::new(store.engine(), wasm)?; let mut linker = wasmtime::Linker::new(&store); - let ctx = wasmtime_wasi::WasiCtx::new(None::)?; + let ctx = wasi_cap_std_sync::WasiCtxBuilder::new().build()?; let wasi = wasmtime_wasi::Wasi::new(&store, ctx); wasi.add_to_linker(&mut linker)?; let instance = linker.instantiate(&module)?; From 3b858aae94d82829487bd6591f673a0b7b8e0c37 Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Thu, 18 Mar 2021 09:58:23 -0700 Subject: [PATCH 031/212] Enable Wasmtime's code cache This makes it so that repeated wizenings of the same Wasm module (e.g. with different WASI inputs) doesn't require re-compiling the Wasm to native code every time. Fixes #9 --- crates/wizer/src/lib.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/crates/wizer/src/lib.rs b/crates/wizer/src/lib.rs index 3c2e6bd6030d..e2193ba40496 100644 --- a/crates/wizer/src/lib.rs +++ b/crates/wizer/src/lib.rs @@ -237,7 +237,7 @@ impl Wizer { "if the Wasm was originally valid, then our preparation step shouldn't invalidate it" ); - let config = self.wasmtime_config(); + let config = self.wasmtime_config()?; let engine = wasmtime::Engine::new(&config); let store = wasmtime::Store::new(&engine); let module = wasmtime::Module::new(store.engine(), &wasm)?; @@ -251,9 +251,14 @@ impl Wizer { } // NB: keep this in sync with the wasmparser features. - fn wasmtime_config(&self) -> wasmtime::Config { + fn wasmtime_config(&self) -> anyhow::Result { let mut config = wasmtime::Config::new(); + // Enable Wasmtime's code cache. This makes it so that repeated + // wizenings of the same Wasm module (e.g. with different WASI inputs) + // doesn't require re-compiling the Wasm to native code every time. + config.cache_config_load_default()?; + // Proposals we support. config.wasm_multi_memory(self.wasm_multi_memory.unwrap_or(DEFAULT_WASM_MULTI_MEMORY)); config.wasm_multi_value(self.wasm_multi_value.unwrap_or(DEFAULT_WASM_MULTI_VALUE)); @@ -265,7 +270,7 @@ impl Wizer { config.wasm_threads(false); config.wasm_bulk_memory(false); - config + Ok(config) } // NB: keep this in sync with the Wasmtime config. From 45ee0763ed64ff413ee6445662febdc10ec3e174 Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Thu, 18 Mar 2021 11:00:35 -0700 Subject: [PATCH 032/212] Bump to version 1.1.1 --- crates/wizer/Cargo.lock | 2 +- crates/wizer/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/wizer/Cargo.lock b/crates/wizer/Cargo.lock index 666ab57e099e..41d6e701fda5 100644 --- a/crates/wizer/Cargo.lock +++ b/crates/wizer/Cargo.lock @@ -2052,7 +2052,7 @@ dependencies = [ [[package]] name = "wizer" -version = "1.1.0" +version = "1.1.1" dependencies = [ "anyhow", "criterion", diff --git a/crates/wizer/Cargo.toml b/crates/wizer/Cargo.toml index 432109e6f654..2aa989f5836c 100644 --- a/crates/wizer/Cargo.toml +++ b/crates/wizer/Cargo.toml @@ -9,7 +9,7 @@ license = "Apache-2.0 WITH LLVM-exception" name = "wizer" readme = "./README.md" repository = "https://github.com/bytecodealliance/wizer" -version = "1.1.0" +version = "1.1.1" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html From 691b6f42f8d65d5ee0ac4c59b05dfd920b7ca481 Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Thu, 18 Mar 2021 13:07:33 -0700 Subject: [PATCH 033/212] Update Wasmtime and other deps --- crates/wizer/Cargo.lock | 524 ++++++++++++++++++++---------------- crates/wizer/Cargo.toml | 6 +- crates/wizer/src/lib.rs | 10 +- crates/wizer/tests/tests.rs | 2 +- 4 files changed, 303 insertions(+), 239 deletions(-) diff --git a/crates/wizer/Cargo.lock b/crates/wizer/Cargo.lock index 41d6e701fda5..ef3c3a341f42 100644 --- a/crates/wizer/Cargo.lock +++ b/crates/wizer/Cargo.lock @@ -11,9 +11,9 @@ dependencies = [ [[package]] name = "adler" -version = "0.2.3" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee2a4ec343196209d6594e19543ae87a39f96d5534d7174822a3ad825dd6ed7e" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "aho-corasick" @@ -39,6 +39,17 @@ version = "1.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "afddf7f520a80dbf76e6f50a35bca42a2331ef227a28b3b6dc5c2e2338d114b1" +[[package]] +name = "async-trait" +version = "0.1.48" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36ea56748e10732c49404c153638a15ec3d6211ec5ff35d9bb20e13b93576adf" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "atty" version = "0.2.14" @@ -63,7 +74,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d117600f438b1707d4e4ae15d3595657288f8235a0eb593e80ecc98ab34e1bc" dependencies = [ "addr2line", - "cfg-if 1.0.0", + "cfg-if", "libc", "miniz_oxide", "object", @@ -78,9 +89,9 @@ checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" [[package]] name = "bincode" -version = "1.3.1" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f30d3a39baa26f9651f17b375061f3233dde33424a8b72b0dbe93a68a0bc896d" +checksum = "d175dfa69e619905c4c3cdb7c3c203fa3bdd5d51184e3afdb2742c0280493772" dependencies = [ "byteorder", "serde", @@ -115,21 +126,21 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.6.0" +version = "3.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "099e596ef14349721d9016f6b80dd3419ea1bf289ab9b44df8e4dfd3a005d5d9" +checksum = "63396b8a4b9de3f4fdfb320ab6080762242f66a8ef174c49d8e19b674db4cdbe" [[package]] name = "byteorder" -version = "1.4.2" +version = "1.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae44d1a3d5a19df61dd0c8beb138458ac2a53a7ac09eba97d55592540004306b" +checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" [[package]] name = "cap-fs-ext" -version = "0.13.3" +version = "0.13.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "209aca9ff6a807ff2df9f0b75634f5680cad4e86b1712516ed3aa82053e16466" +checksum = "dee87a3a916d6f051fc6809c39c4627f0c3a73b2a803bcfbb5fdf2bdfa1da0cb" dependencies = [ "cap-primitives", "cap-std", @@ -140,9 +151,9 @@ dependencies = [ [[package]] name = "cap-primitives" -version = "0.13.3" +version = "0.13.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6da225ce9df468bef6626bfe020c00269f8f2b54086aaef0605665762a77be9a" +checksum = "3c3e3ea29994a34f3bc67b5396a43c87597d302d9e2e5e3b3d5ba952d86c7b41" dependencies = [ "errno", "fs-set-times", @@ -160,29 +171,30 @@ dependencies = [ [[package]] name = "cap-rand" -version = "0.13.2" +version = "0.13.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd7853689263850e5b446c252e4a0a7876ca8e739c791953c41566fea8204019" +checksum = "a0418058b38db7efc6021c5ce012e3a39c57e1a4d7bf2ddcd3789771de505d2f" dependencies = [ - "rand", + "rand 0.8.3", ] [[package]] name = "cap-std" -version = "0.13.3" +version = "0.13.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1304c7889d8a5f9f9fdf6df401c026ac95b3a628ded9d890058e802125d72fa2" +checksum = "f5f20cbb3055e9c72b16ba45913fe9f92836d2aa7a880e1ffacb8d244f454319" dependencies = [ "cap-primitives", + "posish", "rustc_version 0.3.3", "unsafe-io", ] [[package]] name = "cap-time-ext" -version = "0.13.2" +version = "0.13.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e30af4a25ca95711d1aef0cd53e534c24e77f49907c35aa3465fb3f44431265" +checksum = "6b684f9db089b0558520076b4eeda2b719a5c4c06f329be96c9497f2b48c3944" dependencies = [ "cap-primitives", "once_cell", @@ -201,19 +213,13 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.66" +version = "1.0.67" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c0496836a84f8d0495758516b8621a622beb77c0fed418570e50764093ced48" +checksum = "e3c69b077ad434294d3ce9f1f6143a2a4b89a8a2d54ef813d85003a4fd1137fd" dependencies = [ "jobserver", ] -[[package]] -name = "cfg-if" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" - [[package]] name = "cfg-if" version = "1.0.0" @@ -235,19 +241,13 @@ dependencies = [ "vec_map", ] -[[package]] -name = "const_fn" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28b9d6de7f49e22cf97ad17fc4036ece69300032f45f78f30b4a4482cdc3f4a6" - [[package]] name = "cpp_demangle" version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "44919ecaf6f99e8e737bc239408931c9a01e9a6c74814fee8242dd2506b65390" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "glob", ] @@ -259,18 +259,18 @@ checksum = "8aebca1129a03dc6dc2b127edd729435bbc4a37e1d5f4d7513165089ceb02634" [[package]] name = "cranelift-bforest" -version = "0.70.0" +version = "0.72.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31f782ffb172d8095cbb4c6464d85432c3bcfa8609b0bb1dc27cfd35bd90e052" +checksum = "841476ab6d3530136b5162b64a2c6969d68141843ad2fd59126e5ea84fd9b5fe" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-codegen" -version = "0.70.0" +version = "0.72.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91e0910022b490bd0a65d5baa1693b0475cdbeea1c26472343f2acea1f1f55b8" +checksum = "2b5619cef8d19530298301f91e9a0390d369260799a3d8dd01e28fc88e53637a" dependencies = [ "byteorder", "cranelift-bforest", @@ -288,9 +288,9 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.70.0" +version = "0.72.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cafe95cb5ac659e113549b2794a2c8d3a14f36e1a98728a6e0ea7a773be2129" +checksum = "2a319709b8267939155924114ea83f2a5b5af65ece3ac6f703d4735f3c66bb0d" dependencies = [ "cranelift-codegen-shared", "cranelift-entity", @@ -298,24 +298,27 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" -version = "0.70.0" +version = "0.72.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d1bd002e42cc094a131a8227d06d48df28ea3b9127e5e3bc3010e079858e9af" +checksum = "15925b23cd3a448443f289d85a8f53f3cf7a80f0137aa53c8e3b01ae8aefaef7" +dependencies = [ + "serde", +] [[package]] name = "cranelift-entity" -version = "0.70.0" +version = "0.72.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e55e9043403f0dec775f317280015150e78b2352fb947d2f37407fd4ce6311c7" +checksum = "610cf464396c89af0f9f7c64b5aa90aa9e8812ac84084098f1565b40051bc415" dependencies = [ "serde", ] [[package]] name = "cranelift-frontend" -version = "0.70.0" +version = "0.72.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0153680ebce89aac7cad90a5442bb136faacfc86ea62587a01b8e8e79f8249c9" +checksum = "4d20c8bd4a1c41ded051734f0e33ad1d843a0adc98b9bd975ee6657e2c70cdc9" dependencies = [ "cranelift-codegen", "log", @@ -325,9 +328,9 @@ dependencies = [ [[package]] name = "cranelift-native" -version = "0.70.0" +version = "0.72.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d742cf2c28699eeea26b9a7f6a53b5976fb4a7ca4778e736c063ab57592dc0cb" +checksum = "304e100df41f34a5a15291b37bfe0fd7abd0427a2c84195cc69578b4137f9099" dependencies = [ "cranelift-codegen", "target-lexicon", @@ -335,9 +338,9 @@ dependencies = [ [[package]] name = "cranelift-wasm" -version = "0.70.0" +version = "0.72.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e59effbaf9386ffa6742a737c159178f2085cf19634bcd8381caa87b48cd689" +checksum = "4efd473b2917303957e0bfaea6ea9d08b8c93695bee015a611a2514ce5254abc" dependencies = [ "cranelift-codegen", "cranelift-entity", @@ -347,7 +350,7 @@ dependencies = [ "serde", "smallvec", "thiserror", - "wasmparser 0.73.1", + "wasmparser 0.76.0", ] [[package]] @@ -356,7 +359,7 @@ version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "81156fece84ab6a9f2afdb109ce3ae577e42b1228441eded99bd77f627953b1a" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", ] [[package]] @@ -401,7 +404,7 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dca26ee1f8d361640700bde38b2c37d8c22b3ce2d360e1fc1c74ea4b0aa7d775" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "crossbeam-utils", ] @@ -411,19 +414,18 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94af6efb46fef72616855b036a624cf27ba656ffc9be1b9a3c931cfc7749a9a9" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "crossbeam-epoch", "crossbeam-utils", ] [[package]] name = "crossbeam-epoch" -version = "0.9.1" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1aaa739f95311c2c7887a76863f500026092fb1dce0161dab577e559ef3569d" +checksum = "2584f639eb95fea8c798496315b297cf81b9b58b6d30ab066a75455333cf4b12" dependencies = [ - "cfg-if 1.0.0", - "const_fn", + "cfg-if", "crossbeam-utils", "lazy_static", "memoffset", @@ -432,20 +434,20 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.1" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02d96d1e189ef58269ebe5b97953da3274d83a93af647c2ddd6f9dab28cedb8d" +checksum = "e7e9d99fa91428effe99c5c6d4634cdeba32b8cf784fc428a2a687f61a952c49" dependencies = [ "autocfg", - "cfg-if 1.0.0", + "cfg-if", "lazy_static", ] [[package]] name = "csv" -version = "1.1.5" +version = "1.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9d58633299b24b515ac72a3f869f8b91306a3cec616a602843a383acd6f9e97" +checksum = "22813a6dc45b335f9bade10bf7271dc477e81113e89eb251a0bc2a8a81c536e1" dependencies = [ "bstr", "csv-core", @@ -463,15 +465,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "cvt" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34ac344c7efccb80cd25bc61b2170aec26f2f693fd40e765a539a1243db48c71" -dependencies = [ - "cfg-if 0.1.10", -] - [[package]] name = "digest" version = "0.9.0" @@ -487,7 +480,7 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "339ee130d97a610ea5a5872d2bbb130fdf68884ff09d3028b81bec8a1ac23bbc" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "dirs-sys-next", ] @@ -497,7 +490,7 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b98cf8ebf19c3d1b223e151f99a4f9f0690dca41414773390fc824184ac833e1" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "dirs-sys-next", ] @@ -589,11 +582,12 @@ dependencies = [ [[package]] name = "fs-set-times" -version = "0.2.3" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0700f6e5d24b4556cc0807148ed978a5f5b12c942528aed44bd8f02967bc70c" +checksum = "28f1ca01f517bba5770c067dc6c466d290b962e08214c8f2598db98d66087e55" dependencies = [ "posish", + "unsafe-io", "winapi", ] @@ -613,15 +607,26 @@ dependencies = [ "version_check", ] +[[package]] +name = "getrandom" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" +dependencies = [ + "cfg-if", + "libc", + "wasi 0.9.0+wasi-snapshot-preview1", +] + [[package]] name = "getrandom" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c9495705279e7140bf035dde1f6e750c162df8b625267cd52cc44e0b156732c8" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "libc", - "wasi", + "wasi 0.10.2+wasi-snapshot-preview1", ] [[package]] @@ -688,9 +693,9 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "indexmap" -version = "1.6.1" +version = "1.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb1fa934250de4de8aef298d81c729a7d33d8c239daa3a7575e6b92bfc7313b" +checksum = "824845a0bf897a9042383849b02c1bc219c2383772efcd5c6f9766fa4b81aef3" dependencies = [ "autocfg", "hashbrown", @@ -738,9 +743,9 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.47" +version = "0.3.49" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cfb73131c35423a367daf8cbd24100af0d077668c8c2943f0e7dd775fef0f65" +checksum = "dc15e39392125075f60c95ba416f5381ff6c3a948ff02ab12464715adf56c821" dependencies = [ "wasm-bindgen", ] @@ -759,9 +764,9 @@ checksum = "3576a87f2ba00f6f106fdfcd16db1d698d648a26ad8e0573cad8537c3c362d2a" [[package]] name = "libc" -version = "0.2.86" +version = "0.2.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7282d924be3275cec7f6756ff4121987bc6481325397dde6ba3e7802b1a8b1c" +checksum = "ba4aede83fc3617411dc6993bc8c70919750c1c257c6ca6a502aed6e0e2394ae" [[package]] name = "linked-hash-map" @@ -775,7 +780,7 @@ version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", ] [[package]] @@ -810,9 +815,9 @@ dependencies = [ [[package]] name = "miniz_oxide" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f2d26ec3309788e423cfbf68ad1800f061638098d76a83681af979dc4eda19d" +checksum = "a92518e98c078586bc6c934028adcca4c92a53d6a958196de835170a01d84e4b" dependencies = [ "adler", "autocfg", @@ -855,9 +860,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.5.2" +version = "1.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13bd41f508810a131401606d54ac32a467c97172d74ba7662562ebba5ad07fa0" +checksum = "af8b08b04175473088b46763e51ee54da5f9a164bc162f615b91bc179dbf15a3" [[package]] name = "oorandom" @@ -871,6 +876,12 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" +[[package]] +name = "paste" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acbf547ad0c65e31259204bd90935776d1c693cec2f4ff7abb7a1bbbd40dfe58" + [[package]] name = "pest" version = "2.1.3" @@ -882,9 +893,9 @@ dependencies = [ [[package]] name = "pin-project-lite" -version = "0.2.4" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "439697af366c49a6d0a010c56a0d97685bc140ce0d377b13a2ea2aa42d64a827" +checksum = "dc0e1f259c92177c30a4c9d177246edd0a3568b25756a977d0632cf8fa37e905" [[package]] name = "plotters" @@ -916,15 +927,16 @@ dependencies = [ [[package]] name = "posish" -version = "0.5.10" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0590fc1e852795610551182100874078cd243f6c43d1066338a6bdc38d7b187" +checksum = "df1601f90b2342aaf3aadb891b71f584155d176b0e891bea92eeb11995e0ab25" dependencies = [ "bitflags", - "cfg-if 1.0.0", + "cfg-if", "errno", "itoa", "libc", + "unsafe-io", ] [[package]] @@ -990,6 +1002,19 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "rand" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" +dependencies = [ + "getrandom 0.1.16", + "libc", + "rand_chacha 0.2.2", + "rand_core 0.5.1", + "rand_hc 0.2.0", +] + [[package]] name = "rand" version = "0.8.3" @@ -997,9 +1022,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ef9e7e66b4468674bfcb0c81af8b7fa0bb154fa9f28eb840da5c447baeb8d7e" dependencies = [ "libc", - "rand_chacha", - "rand_core", - "rand_hc", + "rand_chacha 0.3.0", + "rand_core 0.6.2", + "rand_hc 0.3.0", +] + +[[package]] +name = "rand_chacha" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" +dependencies = [ + "ppv-lite86", + "rand_core 0.5.1", ] [[package]] @@ -1009,7 +1044,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e12735cf05c9e10bf21534da50a147b924d555dc7a547c42e6bb2d5b6017ae0d" dependencies = [ "ppv-lite86", - "rand_core", + "rand_core 0.6.2", +] + +[[package]] +name = "rand_core" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" +dependencies = [ + "getrandom 0.1.16", ] [[package]] @@ -1018,7 +1062,16 @@ version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34cf66eb183df1c5876e2dcf6b13d57340741e8dc255b48e40a26de954d06ae7" dependencies = [ - "getrandom", + "getrandom 0.2.2", +] + +[[package]] +name = "rand_hc" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" +dependencies = [ + "rand_core 0.5.1", ] [[package]] @@ -1027,7 +1080,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3190ef7066a446f2e7f42e239d161e905420ccab01eb967c9eb27d21b2322a73" dependencies = [ - "rand_core", + "rand_core 0.6.2", ] [[package]] @@ -1070,7 +1123,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "528532f3d801c87aec9def2add9ca802fe569e44a544afe633765267840abe64" dependencies = [ - "getrandom", + "getrandom 0.2.2", "redox_syscall", ] @@ -1088,14 +1141,13 @@ dependencies = [ [[package]] name = "regex" -version = "1.4.3" +version = "1.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9251239e129e16308e70d853559389de218ac275b515068abc96829d05b948a" +checksum = "957056ecddbeba1b26965114e191d2e8589ce74db242b6ea25fc4062427a5c19" dependencies = [ "aho-corasick", "memchr", "regex-syntax", - "thread_local", ] [[package]] @@ -1116,9 +1168,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.6.22" +version = "0.6.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5eb417147ba9860a96cfe72a0b93bf88fee1744b5636ec99ab20c1aa9376581" +checksum = "24d5f089152e60f62d28b835fbff2cd2e8dc0baf1ac13343bef92ab7eed84548" [[package]] name = "regex-test" @@ -1245,9 +1297,9 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.123" +version = "1.0.124" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92d5161132722baa40d802cc70b15262b98258453e85e5d1d365c757c73869ae" +checksum = "bd761ff957cb2a45fbb9ab3da6512de9de55872866160b23c25f1a841e99d29f" dependencies = [ "serde_derive", ] @@ -1264,9 +1316,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.123" +version = "1.0.124" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9391c295d64fc0abb2c556bad848f33cb8296276b1ad2677d1ae1ace4f258f31" +checksum = "1800f7693e94e186f5e25a28291ae1570da908aff7d97a095dec1e56ff99069b" dependencies = [ "proc-macro2", "quote", @@ -1275,9 +1327,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.62" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea1c6153794552ea7cf7cf63b1231a25de00ec90db326ba6264440fa08e31486" +checksum = "799e97dc9fdae36a5c8b8f2cae9ce2ee9fdce2058c57a93e6099d919fd982f79" dependencies = [ "itoa", "ryu", @@ -1303,7 +1355,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fa827a14b29ab7f44778d14a88d3cb76e949c45083f7dbfa507d0cb699dc12de" dependencies = [ "block-buffer", - "cfg-if 1.0.0", + "cfg-if", "cpuid-bool", "digest", "opaque-debug", @@ -1362,9 +1414,9 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.60" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c700597eca8a5a762beb35753ef6b94df201c81cca676604f547495a0d7f0081" +checksum = "3fd9d1e9976102a03c542daa2eff1b43f9d72306342f3f8b3ed5fb8908195d6f" dependencies = [ "proc-macro2", "quote", @@ -1373,9 +1425,9 @@ dependencies = [ [[package]] name = "system-interface" -version = "0.6.1" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a720af6fce4a6ffcf53ffb4d0e15aeb86c90e96fc21b44eb104a1b43e31014ac" +checksum = "1fd411f50bd848d1efefd5957d494eddc80979380e3c4f80b4ba2ebd26d1b673" dependencies = [ "atty", "bitflags", @@ -1390,9 +1442,9 @@ dependencies = [ [[package]] name = "target-lexicon" -version = "0.11.2" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "422045212ea98508ae3d28025bc5aaa2bd4a9cdaecd442a08da2ee620ee9ea95" +checksum = "62b29e388d11a2c0605bdc806ce6ed1d623a5bdbbdd5b423053444999331184e" [[package]] name = "termcolor" @@ -1414,38 +1466,29 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.23" +version = "1.0.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76cc616c6abf8c8928e2fdcc0dbfab37175edd8fb49a4641066ad1364fdab146" +checksum = "e0f4a65597094d4483ddaed134f409b2cb7c1beccf25201a9f73c719254fa98e" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.23" +version = "1.0.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9be73a2caec27583d0046ef3796c3794f868a5bc813db689eed00c7631275cd1" +checksum = "7765189610d8241a44529806d6fd1f2e0a08734313a35d5b3a556f92b381f3c0" dependencies = [ "proc-macro2", "quote", "syn", ] -[[package]] -name = "thread_local" -version = "1.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8018d24e04c95ac8790716a5987d0fec4f8b27249ffa0f7d33f1369bdfb88cbd" -dependencies = [ - "once_cell", -] - [[package]] name = "tinytemplate" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2ada8616fad06a2d0c455adc530de4ef57605a8120cc65da9653e0e9623ca74" +checksum = "be4d6b5f19ff7664e8c98d03e2139cb510db9b0a60b55f8e8709b689d939b6bc" dependencies = [ "serde", "serde_json", @@ -1462,11 +1505,11 @@ dependencies = [ [[package]] name = "tracing" -version = "0.1.23" +version = "0.1.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7d40a22fd029e33300d8d89a5cc8ffce18bb7c587662f54629e94c9de5487f3" +checksum = "01ebdc2bb4498ab1ab5f5b73c5803825e60199229ccba0698170e3be0e7f959f" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "log", "pin-project-lite", "tracing-attributes", @@ -1475,9 +1518,9 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.12" +version = "0.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43f080ea7e4107844ef4766459426fa2d5c1ada2e47edba05dc7fa99d9629f47" +checksum = "c42e6fa53307c8a17e4ccd4dc81cf5ec38db9209f59b222210375b54ee40d1e2" dependencies = [ "proc-macro2", "quote", @@ -1495,9 +1538,9 @@ dependencies = [ [[package]] name = "typenum" -version = "1.12.0" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "373c8a200f9e67a0c95e62a4f52fbf80c23b4381c05a17845531982fa99e6b33" +checksum = "879f6906492a7cd215bfa4cf595b600146ccfac0c79bcbd1f3000162af5e8b06" [[package]] name = "uap-bench" @@ -1534,11 +1577,12 @@ checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" [[package]] name = "unsafe-io" -version = "0.3.0" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd35327a2b46b3350186b75a3a337d4517e5ca08118c4e54175d49d7832578d8" +checksum = "0301dd0f2c21baed606faa2717fbfbb1a68b7e289ea29b40bc21a16f5ae9f5aa" dependencies = [ "rustc_version 0.3.3", + "winapi", ] [[package]] @@ -1549,9 +1593,9 @@ checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" [[package]] name = "version_check" -version = "0.9.2" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed" +checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe" [[package]] name = "walkdir" @@ -1564,6 +1608,12 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "wasi" +version = "0.9.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" + [[package]] name = "wasi" version = "0.10.2+wasi-snapshot-preview1" @@ -1572,9 +1622,9 @@ checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" [[package]] name = "wasi-cap-std-sync" -version = "0.23.0" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d03faceaadebcd4fff2fc7ff9be5327d61fda990396d3379677fac18ff4e2ed" +checksum = "b935979b43ace1ed03b14bb90598114822583c77b7616b39f62b0a91952bdc34" dependencies = [ "anyhow", "bitflags", @@ -1594,9 +1644,9 @@ dependencies = [ [[package]] name = "wasi-common" -version = "0.23.0" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "424508503b311d67c83dd909d6237ca6474a638c7d8d40b9d654daedd1e2543a" +checksum = "40b42cc1c6e2f8485b2a3d9f70f13d734225f99e748ef33d88f2ae78592072cc" dependencies = [ "anyhow", "bitflags", @@ -1611,19 +1661,19 @@ dependencies = [ [[package]] name = "wasm-bindgen" -version = "0.2.70" +version = "0.2.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55c0f7123de74f0dab9b7d00fd614e7b19349cd1e2f5252bbe9b1754b59433be" +checksum = "8fe8f61dba8e5d645a4d8132dc7a0a66861ed5e1045d2c0ed940fab33bac0fbe" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "wasm-bindgen-macro", ] [[package]] name = "wasm-bindgen-backend" -version = "0.2.70" +version = "0.2.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7bc45447f0d4573f3d65720f636bbcc3dd6ce920ed704670118650bcd47764c7" +checksum = "046ceba58ff062da072c7cb4ba5b22a37f00a302483f7e2a6cdc18fedbdc1fd3" dependencies = [ "bumpalo", "lazy_static", @@ -1636,9 +1686,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.70" +version = "0.2.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b8853882eef39593ad4174dd26fc9865a64e84026d223f63bb2c42affcbba2c" +checksum = "0ef9aa01d36cda046f797c57959ff5f3c615c9cc63997a8d545831ec7976819b" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -1646,9 +1696,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.70" +version = "0.2.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4133b5e7f2a531fa413b3a1695e925038a05a71cf67e87dafa295cb645a01385" +checksum = "96eb45c1b2ee33545a813a92dbb53856418bf7eb54ab34f7f7ff1448a5b3735d" dependencies = [ "proc-macro2", "quote", @@ -1659,9 +1709,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.70" +version = "0.2.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd4945e4943ae02d15c13962b38a5b1e81eadd4b71214eee75af64a4d6a4fd64" +checksum = "b7148f4696fb4960a346eaa60bbfb42a1ac4ebba21f750f75fc1375b098d5ffa" [[package]] name = "wasm-encoder" @@ -1674,38 +1724,40 @@ dependencies = [ [[package]] name = "wasmparser" -version = "0.73.1" +version = "0.74.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8526ab131cbc49495a483c98954913ae7b83551adacab5e294cf77992e70ee7" +checksum = "4a4d63608421d9a22d4bce220f2841f3b609a5aaabd3ed3aeeb5fed2702c3c78" [[package]] name = "wasmparser" -version = "0.74.0" +version = "0.76.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a4d63608421d9a22d4bce220f2841f3b609a5aaabd3ed3aeeb5fed2702c3c78" +checksum = "755a9a4afe3f6cccbbe6d7e965eef44cf260b001f93e547eba84255c1d0187d8" [[package]] name = "wasmtime" -version = "0.23.0" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8878f1f740127905dd8eddadfeaeea786f81856369eecc65e6c83ac909633cda" +checksum = "26ea2ad49bb047e10ca292f55cd67040bef14b676d07e7b04ed65fd312d52ece" dependencies = [ "anyhow", "backtrace", "bincode", - "cfg-if 1.0.0", + "cfg-if", "cpp_demangle", "indexmap", "libc", "log", + "paste", "region", "rustc-demangle", "serde", "smallvec", "target-lexicon", - "wasmparser 0.73.1", + "wasmparser 0.76.0", "wasmtime-cache", "wasmtime-environ", + "wasmtime-fiber", "wasmtime-jit", "wasmtime-profiling", "wasmtime-runtime", @@ -1715,9 +1767,9 @@ dependencies = [ [[package]] name = "wasmtime-cache" -version = "0.23.0" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b28e400f6a4d5d8e0086b3a2999e03be217a807f3f376dbdac5136a81ec6f79" +checksum = "9353a705eb98838d885a4d0186c087167fd5ea087ef3511bdbdf1a79420a1d2d" dependencies = [ "anyhow", "base64", @@ -1736,23 +1788,23 @@ dependencies = [ [[package]] name = "wasmtime-cranelift" -version = "0.23.0" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c0a13645a4b833dba480a18f048b8cebae06e70f9aa86313d779541cc1847ad" +checksum = "5e769b80abbb89255926f69ba37085f7dd6608c980134838c3c89d7bf6e776bc" dependencies = [ "cranelift-codegen", "cranelift-entity", "cranelift-frontend", "cranelift-wasm", - "wasmparser 0.73.1", + "wasmparser 0.76.0", "wasmtime-environ", ] [[package]] name = "wasmtime-debug" -version = "0.23.0" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a53b773abc89fed963d64969e38a08ed1cbc8fef43ac7383ad3f489e1a2b50ac" +checksum = "38501788c936a4932b0ddf61135963a4b7d1f549f63a6908ae56a1c86d74fc7b" dependencies = [ "anyhow", "gimli", @@ -1760,18 +1812,18 @@ dependencies = [ "object", "target-lexicon", "thiserror", - "wasmparser 0.73.1", + "wasmparser 0.76.0", "wasmtime-environ", ] [[package]] name = "wasmtime-environ" -version = "0.23.0" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2bb053d9d3db2bbae51f87b11879386d472bf2b1dfdde8f413ae2ae0c8b9ddb" +checksum = "fae793ea1387b2fede277d209bb27285366df58f0a3ae9d59e58a7941dce60fa" dependencies = [ "anyhow", - "cfg-if 1.0.0", + "cfg-if", "cranelift-codegen", "cranelift-entity", "cranelift-wasm", @@ -1779,20 +1831,32 @@ dependencies = [ "indexmap", "log", "more-asserts", + "region", "serde", "thiserror", - "wasmparser 0.73.1", + "wasmparser 0.76.0", +] + +[[package]] +name = "wasmtime-fiber" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c479ba281bc54236209f43a954fc2a874ca3e5fa90116576b1ae23782948783f" +dependencies = [ + "cc", + "libc", + "winapi", ] [[package]] name = "wasmtime-jit" -version = "0.23.0" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcbf76a9b7da95c6099acf5610594f7e4eac462b163e75eb1fc333b6053c6e01" +checksum = "9b3bd0fae8396473a68a1491559d61776127bb9bea75c9a6a6c038ae4a656eb2" dependencies = [ "addr2line", "anyhow", - "cfg-if 1.0.0", + "cfg-if", "cranelift-codegen", "cranelift-entity", "cranelift-frontend", @@ -1807,7 +1871,7 @@ dependencies = [ "serde", "target-lexicon", "thiserror", - "wasmparser 0.73.1", + "wasmparser 0.76.0", "wasmtime-cranelift", "wasmtime-debug", "wasmtime-environ", @@ -1819,9 +1883,9 @@ dependencies = [ [[package]] name = "wasmtime-obj" -version = "0.23.0" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4909472de9ea73609551d883a27ab7c2b04a1c7b90bb3d25cf1314ccaf7f3d4" +checksum = "a79fa098a3be8fabc50f5be60f8e47694d569afdc255de37850fc80295485012" dependencies = [ "anyhow", "more-asserts", @@ -1833,12 +1897,12 @@ dependencies = [ [[package]] name = "wasmtime-profiling" -version = "0.23.0" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a04a0119d0a30f8341d436b834da16a3cd23115045fb024f44b062d3abd29ae7" +checksum = "d81e2106efeef4c01917fd16956a91d39bb78c07cf97027abdba9ca98da3f258" dependencies = [ "anyhow", - "cfg-if 1.0.0", + "cfg-if", "gimli", "lazy_static", "libc", @@ -1852,13 +1916,14 @@ dependencies = [ [[package]] name = "wasmtime-runtime" -version = "0.23.0" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dac84560e3a8d378d76cc6c25cca5ad216a9ad85fc03ac06f91ecdf4bbbb62b8" +checksum = "f747c656ca4680cad7846ae91c57d03f2dd4f4170da77a700df4e21f0d805378" dependencies = [ + "anyhow", "backtrace", "cc", - "cfg-if 1.0.0", + "cfg-if", "indexmap", "lazy_static", "libc", @@ -1866,6 +1931,7 @@ dependencies = [ "memoffset", "more-asserts", "psm", + "rand 0.7.3", "region", "thiserror", "wasmtime-environ", @@ -1874,9 +1940,9 @@ dependencies = [ [[package]] name = "wasmtime-wasi" -version = "0.23.0" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b545359011c26641fbc080eafa9e74516d4c929fd34d8d4fdb91021929bc0f4" +checksum = "af5ebd3cfc82606e0332437cb370a9a018e8e2e8480c1bdcc10da93620ffad9e" dependencies = [ "anyhow", "wasi-common", @@ -1887,9 +1953,9 @@ dependencies = [ [[package]] name = "wasmtime-wiggle" -version = "0.23.0" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1200f57e8b7b9aba73fcf908e6d89aa1720d879532948653e1548c180790dc35" +checksum = "aa44fba6a1709e2f8d59535796e38332121ba86823ce78cc4d3c8e7b3ed531da" dependencies = [ "wasmtime", "wasmtime-wiggle-macro", @@ -1899,9 +1965,9 @@ dependencies = [ [[package]] name = "wasmtime-wiggle-macro" -version = "0.23.0" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a38e270c5d1e318f0748847f39774f0fd036b61bd9c0781fd170921171a0573" +checksum = "8505a6f708e4db716f6c8936cee36e7d869448b38961b1b788be0e1852da8ad9" dependencies = [ "proc-macro2", "quote", @@ -1912,36 +1978,36 @@ dependencies = [ [[package]] name = "wast" -version = "22.0.0" +version = "33.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe1220ed7f824992b426a76125a3403d048eaf0f627918e97ade0d9b9d510d20" +checksum = "1d04fe175c7f78214971293e7d8875673804e736092206a3a4544dbc12811c1b" dependencies = [ "leb128", ] [[package]] name = "wast" -version = "33.0.0" +version = "35.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d04fe175c7f78214971293e7d8875673804e736092206a3a4544dbc12811c1b" +checksum = "db5ae96da18bb5926341516fd409b5a8ce4e4714da7f0a1063d3b20ac9f9a1e1" dependencies = [ "leb128", ] [[package]] name = "wat" -version = "1.0.34" +version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ec9c6ee01ae07a26adadcdfed22c7a97e0b8cbee9c06e0e96076ece5aeb5cfe" +checksum = "0b0fa059022c5dabe129f02b429d67086400deb8277f89c975555dacc1dadbcc" dependencies = [ - "wast 33.0.0", + "wast 35.0.0", ] [[package]] name = "web-sys" -version = "0.3.47" +version = "0.3.49" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c40dc691fc48003eba817c38da7113c15698142da971298003cac3ef175680b3" +checksum = "59fe19d70f5dacc03f6e46777213facae5ac3801575d56ca6cbd4c93dcd12310" dependencies = [ "js-sys", "wasm-bindgen", @@ -1949,10 +2015,11 @@ dependencies = [ [[package]] name = "wiggle" -version = "0.23.0" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7b3d7fa155c0809b3b7c0c043fe41171d0a1d6669a7e566728c5285d52beebb" +checksum = "d80697b8479b8aea64dfa454d593a35d46c2530c30d3e54f1c9c3bf934b52f9b" dependencies = [ + "async-trait", "bitflags", "thiserror", "tracing", @@ -1962,18 +2029,18 @@ dependencies = [ [[package]] name = "wiggle-borrow" -version = "0.23.0" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2fa06922b25613c70df086ee95dce9ad240d2a30659f4bacfc6868aeeb55009" +checksum = "df677e1a757a4d3bd4b4ff632a23059cd8570dd93b73962dc96a6eb64e824228" dependencies = [ "wiggle", ] [[package]] name = "wiggle-generate" -version = "0.23.0" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fff9a8db03f14e9c1eec259353863be8818cfb5bfafa6211d4a3af409c008de8" +checksum = "b6a47a1cf5407c9e45c2b0144dae3780bb9812093fd59d69e517239b229173a8" dependencies = [ "anyhow", "heck", @@ -1986,9 +2053,9 @@ dependencies = [ [[package]] name = "wiggle-macro" -version = "0.23.0" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e3d20ca8d19ab366f4a085328344dc592396d91a99d84448fae92c177dbd42e" +checksum = "91f4d7ee3dac8c22934a18b52269b63e1cfe75b75575821d756f5f34a2a4ca78" dependencies = [ "quote", "syn", @@ -2029,25 +2096,24 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "winx" -version = "0.22.0" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7d35176e4c7e0daf9d8da18b7e9df81a8f2358fb3d6feea775ce810f974a512" +checksum = "a316462681accd062e32c37f9d78128691a4690764917d13bd8ea041baf2913e" dependencies = [ "bitflags", - "cvt", "winapi", ] [[package]] name = "witx" -version = "0.8.8" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1be02433ed9b7ddcebf9431066d96d7f62d0de3bfa3b9a2af4a239303da575e4" +checksum = "df4a58e03db38d5e0762afc768ac9abacf826de59602b0a1dfa1b9099f03388e" dependencies = [ "anyhow", "log", "thiserror", - "wast 22.0.0", + "wast 33.0.0", ] [[package]] @@ -2079,18 +2145,18 @@ dependencies = [ [[package]] name = "zstd" -version = "0.6.0+zstd.1.4.8" +version = "0.6.1+zstd.1.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4e44664feba7f2f1a9f300c1f6157f2d1bfc3c15c6f3cf4beabf3f5abe9c237" +checksum = "5de55e77f798f205d8561b8fe2ef57abfb6e0ff2abe7fd3c089e119cdb5631a3" dependencies = [ "zstd-safe", ] [[package]] name = "zstd-safe" -version = "3.0.0+zstd.1.4.8" +version = "3.0.1+zstd.1.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9447afcd795693ad59918c7bbffe42fdd6e467d708f3537e3dc14dc598c573f" +checksum = "1387cabcd938127b30ce78c4bf00b30387dddf704e3f0881dbc4ff62b5566f8c" dependencies = [ "libc", "zstd-sys", @@ -2098,12 +2164,10 @@ dependencies = [ [[package]] name = "zstd-sys" -version = "1.4.19+zstd.1.4.8" +version = "1.4.20+zstd.1.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec24a9273d24437afb8e71b16f3d9a5d569193cccdb7896213b59f552f387674" +checksum = "ebd5b733d7cf2d9447e2c3e76a5589b4f5e5ae065c22a2bc0b023cbc331b6c8e" dependencies = [ "cc", - "glob", - "itertools 0.9.0", "libc", ] diff --git a/crates/wizer/Cargo.toml b/crates/wizer/Cargo.toml index 2aa989f5836c..3befe5af7684 100644 --- a/crates/wizer/Cargo.toml +++ b/crates/wizer/Cargo.toml @@ -31,11 +31,11 @@ env_logger = { version = "0.8.2", optional = true } log = "0.4.14" rayon = "1.5.0" structopt = { version = "0.3.21", optional = true } -wasi-cap-std-sync = "0.23.0" +wasi-cap-std-sync = "0.25.0" wasm-encoder = "0.4.0" wasmparser = "0.74.0" -wasmtime = "0.23.0" -wasmtime-wasi = "0.23.0" +wasmtime = "0.25.0" +wasmtime-wasi = "0.25.0" [dev-dependencies] wat = "1.0.34" diff --git a/crates/wizer/src/lib.rs b/crates/wizer/src/lib.rs index e2193ba40496..ea6ffc702233 100644 --- a/crates/wizer/src/lib.rs +++ b/crates/wizer/src/lib.rs @@ -238,7 +238,7 @@ impl Wizer { ); let config = self.wasmtime_config()?; - let engine = wasmtime::Engine::new(&config); + let engine = wasmtime::Engine::new(&config)?; let store = wasmtime::Store::new(&engine); let module = wasmtime::Module::new(store.engine(), &wasm)?; self.validate_init_func(&module)?; @@ -571,11 +571,11 @@ impl Wizer { let instance = linker.instantiate(module)?; let init_func = instance - .get_func(&self.init_func) - .expect("checked by `validate_init_func`") - .get0::<()>() + .get_typed_func::<(), ()>(&self.init_func) .expect("checked by `validate_init_func`"); - init_func().with_context(|| format!("the `{}` function trapped", self.init_func))?; + init_func + .call(()) + .with_context(|| format!("the `{}` function trapped", self.init_func))?; Ok(instance) } diff --git a/crates/wizer/tests/tests.rs b/crates/wizer/tests/tests.rs index 5b18e0200a04..cb4ed0d55088 100644 --- a/crates/wizer/tests/tests.rs +++ b/crates/wizer/tests/tests.rs @@ -18,7 +18,7 @@ fn run_wasm(args: &[wasmtime::Val], expected: i32, wasm: &[u8]) -> anyhow::Resul config.wasm_multi_memory(true); config.wasm_multi_value(true); - let engine = wasmtime::Engine::new(&config); + let engine = wasmtime::Engine::new(&config)?; let store = wasmtime::Store::new(&engine); let module = wasmtime::Module::new(store.engine(), wasm)?; From 168e51454efe77f721f70d5cd44e75c6338b830e Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Thu, 18 Mar 2021 13:08:15 -0700 Subject: [PATCH 034/212] Bump to 1.1.2 --- crates/wizer/Cargo.lock | 2 +- crates/wizer/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/wizer/Cargo.lock b/crates/wizer/Cargo.lock index ef3c3a341f42..cf1739e32279 100644 --- a/crates/wizer/Cargo.lock +++ b/crates/wizer/Cargo.lock @@ -2118,7 +2118,7 @@ dependencies = [ [[package]] name = "wizer" -version = "1.1.1" +version = "1.1.2" dependencies = [ "anyhow", "criterion", diff --git a/crates/wizer/Cargo.toml b/crates/wizer/Cargo.toml index 3befe5af7684..e26263dd458c 100644 --- a/crates/wizer/Cargo.toml +++ b/crates/wizer/Cargo.toml @@ -9,7 +9,7 @@ license = "Apache-2.0 WITH LLVM-exception" name = "wizer" readme = "./README.md" repository = "https://github.com/bytecodealliance/wizer" -version = "1.1.1" +version = "1.1.2" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html From 0f1329decc1626c67d9d83acc2374267a802bc50 Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Thu, 18 Mar 2021 14:42:21 -0700 Subject: [PATCH 035/212] Add knobs for WASI inheriting stdio and env vars --- crates/wizer/src/lib.rs | 52 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/crates/wizer/src/lib.rs b/crates/wizer/src/lib.rs index ea6ffc702233..2d369607a503 100644 --- a/crates/wizer/src/lib.rs +++ b/crates/wizer/src/lib.rs @@ -15,6 +15,9 @@ use structopt::StructOpt; const WASM_PAGE_SIZE: u32 = 65_536; const NATIVE_PAGE_SIZE: u32 = 4_096; +const DEFAULT_INHERIT_STDIO: bool = true; +const DEFAULT_INHERIT_ENV: bool = false; + const DEFAULT_WASM_MULTI_VALUE: bool = true; const DEFAULT_WASM_MULTI_MEMORY: bool = true; @@ -87,6 +90,26 @@ pub struct Wizer { #[cfg_attr(feature = "structopt", structopt(long = "allow-wasi"))] allow_wasi: bool, + /// When using WASI during initialization, should `stdin`, `stderr`, and + /// `stdout` be inherited? + /// + /// This is true by default. + #[cfg_attr( + feature = "structopt", + structopt(long = "inherit-stdio", value_name = "true|false") + )] + inherit_stdio: Option, + + /// When using WASI during initialization, should environment variables be + /// inherited? + /// + /// This is false by default. + #[cfg_attr( + feature = "structopt", + structopt(long = "inherit-env", value_name = "true|false") + )] + inherit_env: Option, + /// Enable or disable Wasm multi-memory proposal. /// /// Enabled by default. @@ -168,6 +191,8 @@ impl Wizer { init_func: "wizer.initialize".into(), func_renames: vec![], allow_wasi: false, + inherit_stdio: None, + inherit_env: None, wasm_multi_memory: None, wasm_multi_value: None, } @@ -206,6 +231,24 @@ impl Wizer { self } + /// When using WASI during initialization, should `stdin`, `stdout`, and + /// `stderr` be inherited? + /// + /// Defaults to `true`. + pub fn inherit_stdio(&mut self, inherit: bool) -> &mut Self { + self.inherit_stdio = Some(inherit); + self + } + + /// When using WASI during initialization, should the environment variables + /// be inherited? + /// + /// Defaults to `false`. + pub fn inherit_env(&mut self, inherit: bool) -> &mut Self { + self.inherit_env = Some(inherit); + self + } + /// Enable or disable the Wasm multi-memory proposal. /// /// Defaults to `true`. @@ -564,7 +607,14 @@ impl Wizer { let mut linker = wasmtime::Linker::new(store); if self.allow_wasi { - let ctx = wasi_cap_std_sync::WasiCtxBuilder::new().build()?; + let mut ctx = wasi_cap_std_sync::WasiCtxBuilder::new(); + if self.inherit_stdio.unwrap_or(DEFAULT_INHERIT_STDIO) { + ctx = ctx.inherit_stdio(); + } + if self.inherit_env.unwrap_or(DEFAULT_INHERIT_ENV) { + ctx = ctx.inherit_env()?; + } + let ctx = ctx.build()?; wasmtime_wasi::Wasi::new(store, ctx).add_to_linker(&mut linker)?; } self.dummy_imports(&store, &module, &mut linker)?; From 0d700cbbf5a78c56cbff0c0e137910e41d5a4141 Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Thu, 18 Mar 2021 16:27:19 -0700 Subject: [PATCH 036/212] Bump to version 1.2.0 --- crates/wizer/Cargo.lock | 2 +- crates/wizer/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/wizer/Cargo.lock b/crates/wizer/Cargo.lock index cf1739e32279..9dda27d5fb26 100644 --- a/crates/wizer/Cargo.lock +++ b/crates/wizer/Cargo.lock @@ -2118,7 +2118,7 @@ dependencies = [ [[package]] name = "wizer" -version = "1.1.2" +version = "1.2.0" dependencies = [ "anyhow", "criterion", diff --git a/crates/wizer/Cargo.toml b/crates/wizer/Cargo.toml index e26263dd458c..f7d69d8b9e11 100644 --- a/crates/wizer/Cargo.toml +++ b/crates/wizer/Cargo.toml @@ -9,7 +9,7 @@ license = "Apache-2.0 WITH LLVM-exception" name = "wizer" readme = "./README.md" repository = "https://github.com/bytecodealliance/wizer" -version = "1.1.2" +version = "1.2.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html From 963b7372d2b677bf54ecaf1e836e391ce75bc162 Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Thu, 25 Mar 2021 10:45:34 -0700 Subject: [PATCH 037/212] Rename "diff" to "snapshot" Although we are implicitly recording only the state that is different from the default (e.g. non-zero regions of memory) we aren't actually *computing* the difference between anything. The word "diff" makes me think of things like `git diff` that do edit distance-style computations, which we definitely aren't doing. I think "snapshot" more correctly reflects the implementation. --- crates/wizer/src/lib.rs | 56 ++++++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/crates/wizer/src/lib.rs b/crates/wizer/src/lib.rs index 2d369607a503..b9b3b405d846 100644 --- a/crates/wizer/src/lib.rs +++ b/crates/wizer/src/lib.rs @@ -39,9 +39,9 @@ const DEFAULT_WASM_MULTI_MEMORY: bool = true; /// /// * Reference types are not supported yet. This is tricky because it would /// allow the Wasm module to mutate tables, and we would need to be able to -/// diff the initial table state with the new table state, but funcrefs and -/// externrefs aren't comparable in the Wasm spec, which makes diffing -/// problematic. +/// snapshot the new table state, but funcrefs and externrefs don't have +/// identity and aren't comparable in the Wasm spec, which makes snapshotting +/// difficult. #[cfg_attr(feature = "structopt", derive(StructOpt))] #[derive(Clone, Debug)] pub struct Wizer { @@ -287,8 +287,8 @@ impl Wizer { self.validate_init_func(&module)?; let instance = self.initialize(&store, &module)?; - let diff = self.diff(&instance); - let initialized_wasm = self.rewrite(&wasm, &diff, &renames); + let snapshot = self.snapshot(&instance); + let initialized_wasm = self.rewrite(&wasm, &snapshot, &renames); Ok(initialized_wasm) } @@ -347,8 +347,8 @@ impl Wizer { } /// Rewrite the input Wasm with our own custom exports for all globals, and - /// memories. This way we can reflect on their values later on in the diff - /// phase. + /// memories. This way we can reflect on their values later on in the + /// snapshot phase. /// /// TODO: will have to also export tables once we support reference types. fn prepare_input_wasm(&self, full_wasm: &[u8]) -> anyhow::Result> { @@ -630,13 +630,12 @@ impl Wizer { Ok(instance) } - /// Diff the given instance's globals, memories, and tables from the Wasm - /// defaults. + /// Snapshot the given instance's globals, memories, and tables. /// - /// TODO: when we support reference types, we will have to diff tables. - fn diff<'a>(&self, instance: &'a wasmtime::Instance) -> Diff<'a> { + /// TODO: when we support reference types, we will have to snapshot tables. + fn snapshot<'a>(&self, instance: &'a wasmtime::Instance) -> Snapshot<'a> { // Get the initialized values of all globals. - log::debug!("Diffing global values"); + log::debug!("Snapshotting global values"); let mut globals = vec![]; let mut global_index = 0; loop { @@ -654,9 +653,9 @@ impl Wizer { // // TODO: This could be really slow for large memories. Instead, we // should bring our own memories, protect the pages, and keep a table - // with a dirty bit for each page, so we can just diff the pages that - // actually got changed to non-zero values. - log::debug!("Diffing memories"); + // with a dirty bit for each page, so we can just snapshot the pages + // that actually got changed to non-zero values. + log::debug!("Snapshotting memories"); let mut memory_mins = vec![]; let mut data_segments = vec![]; let mut memory_index = 0; @@ -745,25 +744,25 @@ impl Wizer { data_segments.remove(i); } - Diff { + Snapshot { globals, memory_mins, data_segments, } } - fn rewrite(&self, full_wasm: &[u8], diff: &Diff, renames: &FuncRenames) -> Vec { + fn rewrite(&self, full_wasm: &[u8], snapshot: &Snapshot, renames: &FuncRenames) -> Vec { log::debug!("Rewriting input Wasm to pre-initialized state"); let mut wasm = full_wasm; let mut parser = wasmparser::Parser::new(0); let mut module = wasm_encoder::Module::new(); - // Encode the initialized data segments from the diff rather - // than the original, uninitialized data segments. + // Encode the initialized data segments from the snapshot rather than + // the original, uninitialized data segments. let mut added_data = false; let mut add_data_section = |module: &mut wasm_encoder::Module| { - if added_data || diff.data_segments.is_empty() { + if added_data || snapshot.data_segments.is_empty() { return; } let mut data_section = wasm_encoder::DataSection::new(); @@ -771,7 +770,7 @@ impl Wizer { memory_index, offset, data, - } in &diff.data_segments + } in &snapshot.data_segments { data_section.active( *memory_index, @@ -820,7 +819,7 @@ impl Wizer { }); } MemorySection(mut mems) => { - // Set the minimum size of each memory to the diff's + // Set the minimum size of each memory to the snapshot's // initialized size for that memory. let mut memory_encoder = wasm_encoder::MemorySection::new(); for i in 0..mems.get_count() { @@ -829,7 +828,7 @@ impl Wizer { wasmparser::MemoryType::M32 { limits, shared: _ } => { memory_encoder.memory(wasm_encoder::MemoryType { limits: wasm_encoder::Limits { - min: diff.memory_mins[i as usize], + min: snapshot.memory_mins[i as usize], max: limits.maximum, }, }); @@ -840,14 +839,14 @@ impl Wizer { module.section(&memory_encoder); } GlobalSection(mut globals) => { - // Encode the initialized values from the diff, rather than - // the original values. + // Encode the initialized values from the snapshot, rather + // than the original values. let mut globals_encoder = wasm_encoder::GlobalSection::new(); for i in 0..globals.get_count() { let global = globals.read().unwrap(); globals_encoder.global( translate_global_type(global.ty), - match diff.globals[i as usize] { + match snapshot.globals[i as usize] { wasmtime::Val::I32(x) => wasm_encoder::Instruction::I32Const(x), wasmtime::Val::I64(x) => wasm_encoder::Instruction::I64Const(x), wasmtime::Val::F32(x) => { @@ -970,8 +969,9 @@ impl Wizer { } } -/// A "diff" of Wasm state from its default value after having been initialized. -struct Diff<'a> { +/// A "snapshot" of non-default Wasm state after an instance has been +/// initialized. +struct Snapshot<'a> { /// Maps global index to its initialized value. globals: Vec, From 13e9de347c5028b3b87bc72d0457835a82e38cf5 Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Thu, 25 Mar 2021 13:48:20 -0700 Subject: [PATCH 038/212] Add the ability to preopen dirs during WASI initialization --- crates/wizer/Cargo.lock | 1 + crates/wizer/Cargo.toml | 1 + crates/wizer/src/lib.rs | 29 +++++++++++++++++++++++++++++ 3 files changed, 31 insertions(+) diff --git a/crates/wizer/Cargo.lock b/crates/wizer/Cargo.lock index 9dda27d5fb26..2d436aae03f7 100644 --- a/crates/wizer/Cargo.lock +++ b/crates/wizer/Cargo.lock @@ -2121,6 +2121,7 @@ name = "wizer" version = "1.2.0" dependencies = [ "anyhow", + "cap-std", "criterion", "env_logger 0.8.3", "log", diff --git a/crates/wizer/Cargo.toml b/crates/wizer/Cargo.toml index f7d69d8b9e11..4f5a8fd2a80a 100644 --- a/crates/wizer/Cargo.toml +++ b/crates/wizer/Cargo.toml @@ -27,6 +27,7 @@ harness = false [dependencies] anyhow = "1.0.38" +cap-std = "0.13.7" env_logger = { version = "0.8.2", optional = true } log = "0.4.14" rayon = "1.5.0" diff --git a/crates/wizer/src/lib.rs b/crates/wizer/src/lib.rs index b9b3b405d846..0462cd844a72 100644 --- a/crates/wizer/src/lib.rs +++ b/crates/wizer/src/lib.rs @@ -9,6 +9,7 @@ use rayon::iter::{IntoParallelIterator, ParallelExtend, ParallelIterator}; use std::collections::{HashMap, HashSet}; use std::convert::TryFrom; use std::fmt::Display; +use std::path::PathBuf; #[cfg(feature = "structopt")] use structopt::StructOpt; @@ -110,6 +111,16 @@ pub struct Wizer { )] inherit_env: Option, + /// When using WASI during initialization, which file system directories + /// should be made available? + /// + /// None are available by default. + #[cfg_attr( + feature = "structopt", + structopt(long = "dir", parse(from_os_str), value_name = "directory") + )] + dirs: Vec, + /// Enable or disable Wasm multi-memory proposal. /// /// Enabled by default. @@ -193,6 +204,7 @@ impl Wizer { allow_wasi: false, inherit_stdio: None, inherit_env: None, + dirs: vec![], wasm_multi_memory: None, wasm_multi_value: None, } @@ -249,6 +261,15 @@ impl Wizer { self } + /// When using WASI during initialization, which file system directories + /// should be made available? + /// + /// None are available by default. + pub fn dir(&mut self, directory: impl Into) -> &mut Self { + self.dirs.push(directory.into()); + self + } + /// Enable or disable the Wasm multi-memory proposal. /// /// Defaults to `true`. @@ -614,6 +635,14 @@ impl Wizer { if self.inherit_env.unwrap_or(DEFAULT_INHERIT_ENV) { ctx = ctx.inherit_env()?; } + for dir in &self.dirs { + log::debug!("Preopening directory: {}", dir.display()); + let preopened = unsafe { + cap_std::fs::Dir::open_ambient_dir(dir) + .with_context(|| format!("failed to open directory: {}", dir.display()))? + }; + ctx = ctx.preopened_dir(preopened, dir)?; + } let ctx = ctx.build()?; wasmtime_wasi::Wasi::new(store, ctx).add_to_linker(&mut linker)?; } From 9e8634f52b86475564fb309ea4e1bb6642647fbc Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Thu, 25 Mar 2021 13:52:55 -0700 Subject: [PATCH 039/212] Bump to version 1.3.0 --- crates/wizer/Cargo.lock | 4 +++- crates/wizer/Cargo.toml | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/wizer/Cargo.lock b/crates/wizer/Cargo.lock index 2d436aae03f7..78d37d8fe631 100644 --- a/crates/wizer/Cargo.lock +++ b/crates/wizer/Cargo.lock @@ -1,5 +1,7 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +version = 3 + [[package]] name = "addr2line" version = "0.14.1" @@ -2118,7 +2120,7 @@ dependencies = [ [[package]] name = "wizer" -version = "1.2.0" +version = "1.3.0" dependencies = [ "anyhow", "cap-std", diff --git a/crates/wizer/Cargo.toml b/crates/wizer/Cargo.toml index 4f5a8fd2a80a..7776660f2a1b 100644 --- a/crates/wizer/Cargo.toml +++ b/crates/wizer/Cargo.toml @@ -9,7 +9,7 @@ license = "Apache-2.0 WITH LLVM-exception" name = "wizer" readme = "./README.md" repository = "https://github.com/bytecodealliance/wizer" -version = "1.2.0" +version = "1.3.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html From 18686da4a516440cfbcf7c29f5563629cd5a54f8 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Mon, 19 Apr 2021 02:00:44 -0500 Subject: [PATCH 040/212] Add C++ example to Readme --- crates/wizer/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/wizer/README.md b/crates/wizer/README.md index 4b000939ab1f..554395cf04bc 100644 --- a/crates/wizer/README.md +++ b/crates/wizer/README.md @@ -84,6 +84,8 @@ pub extern "C" fn init() { } ``` +For a complete C++ example, see [this](https://github.com/bytecodealliance/wizer/tree/main/examples/cpp). + Then, if your Wasm module is named `input.wasm`, run the `wizer` CLI: ```shell-session From e4b38e80eea18b05775b3487170a7512ef083cdd Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Mon, 1 Mar 2021 10:46:55 -0800 Subject: [PATCH 041/212] Add module linking support to Wizer This commit adds support for 99% of module linking to Wizer. This allows modules within the "bundle" to import/export memories, globals, tables, and instances from/to each other, but the root module still cannot import any external state. The one big feature from module linking that isn't supported yet is importing and exporting modules, rather than instances. More on this restriction later. Module linking breaks Wizer's previous assumption that a module is instantiated and initialized exactly once (or, at least, that if it were instantiated and initialized multiple times you would get the same result every time due to the restrictions on imports and what can be used during initialization). Module linking allows the same module to be instantiated multiple times and have a different set of functions called on each instance during initialization. This can lead to distinct initialized states for each instantiation. Here is a simple example: ```wat (module (module $A (global $g (mut i32) (i32.const 0)) (func (export "f") global.get $g i32.const 1 i32.add global.set $g)) (instance $a1 (instantiate $A)) (instance $a2 (instantiate $A)) (func (export "wizer.initialize") call (func $a1 "f") call (func $a2 "f") call (func $a2 "f"))) ``` After initialization, the `$a1` instance has had its `f` function export called once and therefore its global's value is 1, while `$a2` has had its `f` function export called twice and therefore its global's value is 2. Because each instantiation has its own initialized state, we need to emit a pre-initialized module for _each_ instantiation in the bundle. At the same time, however, we do _not_ want to duplicate the `f` function across each pre-initialized module! The code section is generally the largest section in a Wasm module, and if we naively duplicated the code section for each instantiation, we could get exponential code size blow ups. (For example, consider a module linking bundle that contains a leaf module named `$Module1` that is instantiated twice in another module called `$Module2`, which is in turn instantiated twice in `$Module4`, which is in turn instantiated twice in `$Module8`, etc... If the last module in this chain is instantiated `n` times, then `$Module1` is instantiated `2^n` times, and if we duplicate the code section for each instantiation we've got `2^n` copies of `$Module1`'s code section.) The solution is to split out a "code module" containing only the static sections from the original module. All the state in the module (memories, globals, and nested instantiations) are imported via a `__wizer_state` instance import. Then, each instantiation defines its own "state module" which contains the specific initialized state for that instance, and which is instantiated exactly once. To create the initialized version of the original instantiation, we join the state with the code by instantiating the code module and passing in this instantiation's state instance. Let's return to our original example from above. Here is the input Wasm again: ```wat (module (module $A (global $g (mut i32) (i32.const 0)) (func (export "f") global.get $g i32.const 1 i32.add global.set $g)) (instance $a1 (instantiate $A)) (instance $a2 (instantiate $A)) (func (export "wizer.initialize") call (func $a1 "f") call (func $a2 "f") call (func $a2 "f"))) ``` And this is roughly what it looks like after wizening: ```wat (module ;; The code module for $A. (module $A_code ;; Note that the code module imports state, rather than defining it. (import "__wizer_state" (instance (export "__wizer_global_0" (global $g (mut i32))))) (func (export "f") global.get $g i32.const 1 i32.add global.set $g)) ;; State module for $a1. Global is initialized to 1 since $a1's `f` ;; function was called once in the initialization. (module $a1_state_module (global (export "__wizer_global_0" (mut i32) (i32.const 1)))) ;; The state instance for $a1. (instance $a1_state_instance (instantiate $a1_state_module)) ;; Finally, we join the code+state together to create $a1. (instance $a1 (instantiate $A_code (import "__wizer_state" $a1_state_instance))) ;; State module for $a2. Global is initialized to 2 since $a2's `f` ;; function was called twice in the initialization. (module $a2_state_module (global (export "__wizer_global_0" (mut i32) (i32.const 2)))) ;; The state instance for $a2. (instance $a2_state_instance (instantiate $a2_state_module)) ;; Finally, we join the code+state together to create $a2. (instance $a2 (instantiate $A_code (import "__wizer_state" $a2_state_instance))) ;; Initialization function removed. ) ``` Using this code splitting technique allows us to avoid unnecessary duplication for each instantiation. The only bits that are duplicated are the things that are inherently different across instantiations: the instantiation's internal state. The reason we don't allow importing and exporting modules within the bundle is that two different modules that have the same module type signature could have two different sets of internal, not-exported state. This throws a wrench in the instrumentation pass, which needs to force export all internal state, and in this case could make the modules have incompatible type signatures, so they couldn't both be imported by the same module anymore. That, in turn, would force us to duplicate and specialize modules that import other modules for each instantiation. This is do-able, but requires significant additional engineering work. Therefore, this feature is left for some time in the future. As a final note, adding support for module linking required pretty much a full rewrite of Wizer. It no longer just parses the Wasm section by section, tweaking it in place. Instead, there is an initial "parse" phase that creates a `ModuleInfo` tree that serves as an AST. Our subsequent passes -- the instrumentation and rewriting passes -- process the `ModuleInfo` tree rather than reparsing the input Wasm and tweaking it directly. --- crates/wizer/Cargo.lock | 238 ++--- crates/wizer/Cargo.toml | 13 +- crates/wizer/src/dummy.rs | 623 +++++++++++++ crates/wizer/src/info.rs | 333 +++++++ crates/wizer/src/instrument.rs | 252 ++++++ crates/wizer/src/lib.rs | 748 +++------------- crates/wizer/src/parse.rs | 566 ++++++++++++ crates/wizer/src/rewrite.rs | 1092 +++++++++++++++++++++++ crates/wizer/src/rewrite/renumbering.rs | 57 ++ crates/wizer/src/snapshot.rs | 185 ++++ crates/wizer/src/stack_ext.rs | 16 + crates/wizer/src/translate.rs | 104 +++ crates/wizer/tests/tests.rs | 407 ++++++++- 13 files changed, 3864 insertions(+), 770 deletions(-) create mode 100644 crates/wizer/src/dummy.rs create mode 100644 crates/wizer/src/info.rs create mode 100644 crates/wizer/src/instrument.rs create mode 100644 crates/wizer/src/parse.rs create mode 100644 crates/wizer/src/rewrite.rs create mode 100644 crates/wizer/src/rewrite/renumbering.rs create mode 100644 crates/wizer/src/snapshot.rs create mode 100644 crates/wizer/src/stack_ext.rs create mode 100644 crates/wizer/src/translate.rs diff --git a/crates/wizer/Cargo.lock b/crates/wizer/Cargo.lock index 78d37d8fe631..00f611b0ed32 100644 --- a/crates/wizer/Cargo.lock +++ b/crates/wizer/Cargo.lock @@ -177,7 +177,7 @@ version = "0.13.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a0418058b38db7efc6021c5ce012e3a39c57e1a4d7bf2ddcd3789771de505d2f" dependencies = [ - "rand 0.8.3", + "rand", ] [[package]] @@ -261,18 +261,18 @@ checksum = "8aebca1129a03dc6dc2b127edd729435bbc4a37e1d5f4d7513165089ceb02634" [[package]] name = "cranelift-bforest" -version = "0.72.0" +version = "0.73.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "841476ab6d3530136b5162b64a2c6969d68141843ad2fd59126e5ea84fd9b5fe" +checksum = "07f641ec9146b7d7498d78cd832007d66ca44a9b61f23474d1fb78e5a3701e99" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-codegen" -version = "0.72.0" +version = "0.73.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b5619cef8d19530298301f91e9a0390d369260799a3d8dd01e28fc88e53637a" +checksum = "fd1f2c0cd4ac12c954116ab2e26e40df0d51db322a855b5664fa208bc32d6686" dependencies = [ "byteorder", "cranelift-bforest", @@ -290,9 +290,9 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.72.0" +version = "0.73.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a319709b8267939155924114ea83f2a5b5af65ece3ac6f703d4735f3c66bb0d" +checksum = "105e11b2f0ff7ac81f80dd05ec938ce529a75e36f3d598360d806bb5bfa75e5a" dependencies = [ "cranelift-codegen-shared", "cranelift-entity", @@ -300,27 +300,27 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" -version = "0.72.0" +version = "0.73.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15925b23cd3a448443f289d85a8f53f3cf7a80f0137aa53c8e3b01ae8aefaef7" +checksum = "51e5eba2c1858d50abf023be4d88bd0450cb12d4ec2ba3ffac56353e6d09caf2" dependencies = [ "serde", ] [[package]] name = "cranelift-entity" -version = "0.72.0" +version = "0.73.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "610cf464396c89af0f9f7c64b5aa90aa9e8812ac84084098f1565b40051bc415" +checksum = "79fa6fdd77a8d317763cd21668d3e72b96e09ac8a974326c6149f7de5aafa8ed" dependencies = [ "serde", ] [[package]] name = "cranelift-frontend" -version = "0.72.0" +version = "0.73.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d20c8bd4a1c41ded051734f0e33ad1d843a0adc98b9bd975ee6657e2c70cdc9" +checksum = "ae11da9ca99f987c29e3eb39ebe10e9b879ecca30f3aeaee13db5e8e02b80fb6" dependencies = [ "cranelift-codegen", "log", @@ -330,9 +330,9 @@ dependencies = [ [[package]] name = "cranelift-native" -version = "0.72.0" +version = "0.73.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "304e100df41f34a5a15291b37bfe0fd7abd0427a2c84195cc69578b4137f9099" +checksum = "100ca4810058e23a5c4dcaedfa25289d1853f4a899d0960265aa7c54a4789351" dependencies = [ "cranelift-codegen", "target-lexicon", @@ -340,9 +340,9 @@ dependencies = [ [[package]] name = "cranelift-wasm" -version = "0.72.0" +version = "0.73.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4efd473b2917303957e0bfaea6ea9d08b8c93695bee015a611a2514ce5254abc" +checksum = "607826643d74cf2cc36973ebffd1790a11d1781e14e3f95cf5529942b2168a67" dependencies = [ "cranelift-codegen", "cranelift-entity", @@ -352,7 +352,7 @@ dependencies = [ "serde", "smallvec", "thiserror", - "wasmparser 0.76.0", + "wasmparser 0.77.0", ] [[package]] @@ -609,17 +609,6 @@ dependencies = [ "version_check", ] -[[package]] -name = "getrandom" -version = "0.1.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" -dependencies = [ - "cfg-if", - "libc", - "wasi 0.9.0+wasi-snapshot-preview1", -] - [[package]] name = "getrandom" version = "0.2.2" @@ -628,7 +617,7 @@ checksum = "c9495705279e7140bf035dde1f6e750c162df8b625267cd52cc44e0b156732c8" dependencies = [ "cfg-if", "libc", - "wasi 0.10.2+wasi-snapshot-preview1", + "wasi", ] [[package]] @@ -1004,19 +993,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "rand" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" -dependencies = [ - "getrandom 0.1.16", - "libc", - "rand_chacha 0.2.2", - "rand_core 0.5.1", - "rand_hc 0.2.0", -] - [[package]] name = "rand" version = "0.8.3" @@ -1024,19 +1000,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ef9e7e66b4468674bfcb0c81af8b7fa0bb154fa9f28eb840da5c447baeb8d7e" dependencies = [ "libc", - "rand_chacha 0.3.0", - "rand_core 0.6.2", - "rand_hc 0.3.0", -] - -[[package]] -name = "rand_chacha" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" -dependencies = [ - "ppv-lite86", - "rand_core 0.5.1", + "rand_chacha", + "rand_core", + "rand_hc", ] [[package]] @@ -1046,16 +1012,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e12735cf05c9e10bf21534da50a147b924d555dc7a547c42e6bb2d5b6017ae0d" dependencies = [ "ppv-lite86", - "rand_core 0.6.2", -] - -[[package]] -name = "rand_core" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" -dependencies = [ - "getrandom 0.1.16", + "rand_core", ] [[package]] @@ -1064,16 +1021,7 @@ version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34cf66eb183df1c5876e2dcf6b13d57340741e8dc255b48e40a26de954d06ae7" dependencies = [ - "getrandom 0.2.2", -] - -[[package]] -name = "rand_hc" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" -dependencies = [ - "rand_core 0.5.1", + "getrandom", ] [[package]] @@ -1082,7 +1030,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3190ef7066a446f2e7f42e239d161e905420ccab01eb967c9eb27d21b2322a73" dependencies = [ - "rand_core 0.6.2", + "rand_core", ] [[package]] @@ -1125,7 +1073,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "528532f3d801c87aec9def2add9ca802fe569e44a544afe633765267840abe64" dependencies = [ - "getrandom 0.2.2", + "getrandom", "redox_syscall", ] @@ -1444,9 +1392,9 @@ dependencies = [ [[package]] name = "target-lexicon" -version = "0.11.3" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b29e388d11a2c0605bdc806ce6ed1d623a5bdbbdd5b423053444999331184e" +checksum = "64ae3b39281e4b14b8123bdbaddd472b7dfe215e444181f2f9d2443c2444f834" [[package]] name = "termcolor" @@ -1610,12 +1558,6 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "wasi" -version = "0.9.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" - [[package]] name = "wasi" version = "0.10.2+wasi-snapshot-preview1" @@ -1624,9 +1566,9 @@ checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" [[package]] name = "wasi-cap-std-sync" -version = "0.25.0" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b935979b43ace1ed03b14bb90598114822583c77b7616b39f62b0a91952bdc34" +checksum = "9b0ff7337ab1e95198840773d6fbed15efbad72727d023f2ee68f8a6836d675f" dependencies = [ "anyhow", "bitflags", @@ -1646,9 +1588,9 @@ dependencies = [ [[package]] name = "wasi-common" -version = "0.25.0" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40b42cc1c6e2f8485b2a3d9f70f13d734225f99e748ef33d88f2ae78592072cc" +checksum = "ea27f1c1d537ae46f5666cee2fab6e8e286a022a5232c4be02de62d715d2f84a" dependencies = [ "anyhow", "bitflags", @@ -1717,30 +1659,40 @@ checksum = "b7148f4696fb4960a346eaa60bbfb42a1ac4ebba21f750f75fc1375b098d5ffa" [[package]] name = "wasm-encoder" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c75fa62cf1464aa6655479ae454202a159cc82b7b4d66e8f174409669c0654c5" +checksum = "51b4949d4f2b25a4b208317dcf86aacef9e7a5884e48dfc45d4aeb91808d6f86" dependencies = [ "leb128", ] [[package]] name = "wasmparser" -version = "0.74.0" +version = "0.77.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a4d63608421d9a22d4bce220f2841f3b609a5aaabd3ed3aeeb5fed2702c3c78" +checksum = "b35c86d22e720a07d954ebbed772d01180501afe7d03d464f413bb5f8914a8d6" [[package]] name = "wasmparser" -version = "0.76.0" +version = "0.78.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "755a9a4afe3f6cccbbe6d7e965eef44cf260b001f93e547eba84255c1d0187d8" +checksum = "6c7a8b20306d43c09c2c34e0ef68bf2959a11b01a5cae35e4c5dc1e7145547b6" + +[[package]] +name = "wasmprinter" +version = "0.2.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ccec894c70710c2e4669320a532cb2b9cfb97adb0429745642f8ce76916ed85" +dependencies = [ + "anyhow", + "wasmparser 0.78.0", +] [[package]] name = "wasmtime" -version = "0.25.0" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26ea2ad49bb047e10ca292f55cd67040bef14b676d07e7b04ed65fd312d52ece" +checksum = "4da03115f8ad36e50edeb6640f4ba27ed7e9a6f05c2f98f728c762966f7054c6" dependencies = [ "anyhow", "backtrace", @@ -1748,15 +1700,17 @@ dependencies = [ "cfg-if", "cpp_demangle", "indexmap", + "lazy_static", "libc", "log", "paste", + "psm", "region", "rustc-demangle", "serde", "smallvec", "target-lexicon", - "wasmparser 0.76.0", + "wasmparser 0.77.0", "wasmtime-cache", "wasmtime-environ", "wasmtime-fiber", @@ -1769,9 +1723,9 @@ dependencies = [ [[package]] name = "wasmtime-cache" -version = "0.25.0" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9353a705eb98838d885a4d0186c087167fd5ea087ef3511bdbdf1a79420a1d2d" +checksum = "abd77ef355ee65dc5147a9d4a3d7419b94b03068fc486dc9008fb2d947724efb" dependencies = [ "anyhow", "base64", @@ -1790,23 +1744,23 @@ dependencies = [ [[package]] name = "wasmtime-cranelift" -version = "0.25.0" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e769b80abbb89255926f69ba37085f7dd6608c980134838c3c89d7bf6e776bc" +checksum = "b73c47553954eab22f432a7a60bcd695eb46508c2088cb0aa1cfd060538db3b6" dependencies = [ "cranelift-codegen", "cranelift-entity", "cranelift-frontend", "cranelift-wasm", - "wasmparser 0.76.0", + "wasmparser 0.77.0", "wasmtime-environ", ] [[package]] name = "wasmtime-debug" -version = "0.25.0" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38501788c936a4932b0ddf61135963a4b7d1f549f63a6908ae56a1c86d74fc7b" +checksum = "5241e603c262b2ee0dfb5b2245ad539d0a99f0589909fbffc91d2a8035f2d20a" dependencies = [ "anyhow", "gimli", @@ -1814,15 +1768,15 @@ dependencies = [ "object", "target-lexicon", "thiserror", - "wasmparser 0.76.0", + "wasmparser 0.77.0", "wasmtime-environ", ] [[package]] name = "wasmtime-environ" -version = "0.25.0" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fae793ea1387b2fede277d209bb27285366df58f0a3ae9d59e58a7941dce60fa" +checksum = "fb8d356abc04754f5936b9377441a4a202f6bba7ad997d2cd66acb3908bc85a3" dependencies = [ "anyhow", "cfg-if", @@ -1836,14 +1790,14 @@ dependencies = [ "region", "serde", "thiserror", - "wasmparser 0.76.0", + "wasmparser 0.77.0", ] [[package]] name = "wasmtime-fiber" -version = "0.25.0" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c479ba281bc54236209f43a954fc2a874ca3e5fa90116576b1ae23782948783f" +checksum = "8ef51f16bbe65951ac8b7780c70eec963a20d6c87c59eefc6423c0ca323a6a02" dependencies = [ "cc", "libc", @@ -1852,9 +1806,9 @@ dependencies = [ [[package]] name = "wasmtime-jit" -version = "0.25.0" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b3bd0fae8396473a68a1491559d61776127bb9bea75c9a6a6c038ae4a656eb2" +checksum = "81b066a3290a903c5beb7d765b3e82e00cd4f8ac0475297f91330fbe8e16bb17" dependencies = [ "addr2line", "anyhow", @@ -1873,7 +1827,7 @@ dependencies = [ "serde", "target-lexicon", "thiserror", - "wasmparser 0.76.0", + "wasmparser 0.77.0", "wasmtime-cranelift", "wasmtime-debug", "wasmtime-environ", @@ -1885,9 +1839,9 @@ dependencies = [ [[package]] name = "wasmtime-obj" -version = "0.25.0" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a79fa098a3be8fabc50f5be60f8e47694d569afdc255de37850fc80295485012" +checksum = "bd9d5c6c8924ea1fb2372d26c0546a8c5aab94001d5ddedaa36fd7b090c04de2" dependencies = [ "anyhow", "more-asserts", @@ -1899,9 +1853,9 @@ dependencies = [ [[package]] name = "wasmtime-profiling" -version = "0.25.0" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d81e2106efeef4c01917fd16956a91d39bb78c07cf97027abdba9ca98da3f258" +checksum = "44760e80dd5f53e9af6c976120f9f1d35908ee0c646a3144083f0a57b7123ba7" dependencies = [ "anyhow", "cfg-if", @@ -1918,9 +1872,9 @@ dependencies = [ [[package]] name = "wasmtime-runtime" -version = "0.25.0" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f747c656ca4680cad7846ae91c57d03f2dd4f4170da77a700df4e21f0d805378" +checksum = "9701c6412897ba3a10fb4e17c4ec29723ed33d6feaaaeaf59f53799107ce7351" dependencies = [ "anyhow", "backtrace", @@ -1930,23 +1884,25 @@ dependencies = [ "lazy_static", "libc", "log", + "mach", "memoffset", "more-asserts", - "psm", - "rand 0.7.3", + "rand", "region", "thiserror", "wasmtime-environ", + "wasmtime-fiber", "winapi", ] [[package]] name = "wasmtime-wasi" -version = "0.25.0" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af5ebd3cfc82606e0332437cb370a9a018e8e2e8480c1bdcc10da93620ffad9e" +checksum = "7bfa935e8a475ca6616aecc8481dfc3dcf12ad42cdaeb30746eb4addaf0316af" dependencies = [ "anyhow", + "wasi-cap-std-sync", "wasi-common", "wasmtime", "wasmtime-wiggle", @@ -1955,9 +1911,9 @@ dependencies = [ [[package]] name = "wasmtime-wiggle" -version = "0.25.0" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa44fba6a1709e2f8d59535796e38332121ba86823ce78cc4d3c8e7b3ed531da" +checksum = "1a1782208ad6f89e8cccb56ae9366d65d75400cc5c94ba3e54456e80f3b0bf7d" dependencies = [ "wasmtime", "wasmtime-wiggle-macro", @@ -1967,9 +1923,9 @@ dependencies = [ [[package]] name = "wasmtime-wiggle-macro" -version = "0.25.0" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8505a6f708e4db716f6c8936cee36e7d869448b38961b1b788be0e1852da8ad9" +checksum = "4b638b65b2daabc68d8e728d4a545ea5b2c7349e4fbf299011c7e7436c365d37" dependencies = [ "proc-macro2", "quote", @@ -1998,9 +1954,9 @@ dependencies = [ [[package]] name = "wat" -version = "1.0.36" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b0fa059022c5dabe129f02b429d67086400deb8277f89c975555dacc1dadbcc" +checksum = "8ec280a739b69173e0ffd12c1658507996836ba4e992ed9bc1e5385a0bd72a02" dependencies = [ "wast 35.0.0", ] @@ -2017,9 +1973,9 @@ dependencies = [ [[package]] name = "wiggle" -version = "0.25.0" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d80697b8479b8aea64dfa454d593a35d46c2530c30d3e54f1c9c3bf934b52f9b" +checksum = "bb3b6f32e575442f4710afb1d9cb8e4ac6873017fc4e8ce24c9154b1f4df02fa" dependencies = [ "async-trait", "bitflags", @@ -2031,18 +1987,18 @@ dependencies = [ [[package]] name = "wiggle-borrow" -version = "0.25.0" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df677e1a757a4d3bd4b4ff632a23059cd8570dd93b73962dc96a6eb64e824228" +checksum = "8df875ad2e22a79cf238fb56c4fcb1c9128857993d74d21a47c8bf8cd1d3968e" dependencies = [ "wiggle", ] [[package]] name = "wiggle-generate" -version = "0.25.0" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6a47a1cf5407c9e45c2b0144dae3780bb9812093fd59d69e517239b229173a8" +checksum = "8fe31034c216a6f33ceea8d84bbfb9c4aa982ee94367e35468cb91b129766910" dependencies = [ "anyhow", "heck", @@ -2055,10 +2011,11 @@ dependencies = [ [[package]] name = "wiggle-macro" -version = "0.25.0" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91f4d7ee3dac8c22934a18b52269b63e1cfe75b75575821d756f5f34a2a4ca78" +checksum = "ab77c4b75302a25083b675e535a63e6156f12ac3c2d33c89064b6b3c8152e920" dependencies = [ + "proc-macro2", "quote", "syn", "wiggle-generate", @@ -2131,7 +2088,8 @@ dependencies = [ "structopt", "wasi-cap-std-sync", "wasm-encoder", - "wasmparser 0.74.0", + "wasmparser 0.78.0", + "wasmprinter", "wasmtime", "wasmtime-wasi", "wat", diff --git a/crates/wizer/Cargo.toml b/crates/wizer/Cargo.toml index 7776660f2a1b..79a3351adbbf 100644 --- a/crates/wizer/Cargo.toml +++ b/crates/wizer/Cargo.toml @@ -32,16 +32,17 @@ env_logger = { version = "0.8.2", optional = true } log = "0.4.14" rayon = "1.5.0" structopt = { version = "0.3.21", optional = true } -wasi-cap-std-sync = "0.25.0" +wasi-cap-std-sync = "0.26.0" wasm-encoder = "0.4.0" -wasmparser = "0.74.0" -wasmtime = "0.25.0" -wasmtime-wasi = "0.25.0" +wasmparser = "0.78.0" +wasmtime = "0.26.0" +wasmtime-wasi = "0.26.0" [dev-dependencies] -wat = "1.0.34" -env_logger = "0.8.2" criterion = "0.3.4" +env_logger = "0.8.2" +wasmprinter = "0.2.26" +wat = "1.0.36" [workspace] members = [ diff --git a/crates/wizer/src/dummy.rs b/crates/wizer/src/dummy.rs new file mode 100644 index 000000000000..67c4f049ca68 --- /dev/null +++ b/crates/wizer/src/dummy.rs @@ -0,0 +1,623 @@ +//! Dummy implementations of things that a Wasm module can import. +//! +//! Forked from `wasmtime/crates/fuzzing/src/oracles/dummy.rs`. + +use std::fmt::Write; +use wasmtime::*; + +/// Create dummy imports for instantiating the module. +pub fn dummy_imports( + store: &wasmtime::Store, + module: &wasmtime::Module, + linker: &mut wasmtime::Linker, +) -> anyhow::Result<()> { + log::debug!("Creating dummy imports"); + + for imp in module.imports() { + match imp.name() { + Some(name) => { + if linker.get_one_by_name(imp.module(), Some(name)).is_ok() { + // Already defined, must be part of WASI. + continue; + } + + linker + .define(imp.module(), name, dummy_extern(store, imp.ty())) + .unwrap(); + } + None => match imp.ty() { + wasmtime::ExternType::Instance(ty) => { + for ty in ty.exports() { + if linker + .get_one_by_name(imp.module(), Some(ty.name())) + .is_ok() + { + // Already defined, must be part of WASI. + continue; + } + + linker + .define(imp.module(), ty.name(), dummy_extern(store, ty.ty())) + .unwrap(); + } + } + other => { + if linker.get_one_by_name(imp.module(), None).is_ok() { + // Already defined, must be part of WASI. + continue; + } + + linker + .define_name(imp.module(), dummy_extern(store, other)) + .unwrap(); + } + }, + } + } + + Ok(()) +} + +/// Construct a dummy `Extern` from its type signature +pub fn dummy_extern(store: &Store, ty: ExternType) -> Extern { + match ty { + ExternType::Func(func_ty) => Extern::Func(dummy_func(store, func_ty)), + ExternType::Global(global_ty) => Extern::Global(dummy_global(store, global_ty)), + ExternType::Table(table_ty) => Extern::Table(dummy_table(store, table_ty)), + ExternType::Memory(mem_ty) => Extern::Memory(dummy_memory(store, mem_ty)), + ExternType::Instance(instance_ty) => Extern::Instance(dummy_instance(store, instance_ty)), + ExternType::Module(module_ty) => Extern::Module(dummy_module(store, module_ty)), + } +} + +/// Construct a dummy function for the given function type +pub fn dummy_func(store: &Store, ty: FuncType) -> Func { + Func::new(store, ty.clone(), move |_, _, results| { + for (ret_ty, result) in ty.results().zip(results) { + *result = dummy_value(ret_ty); + } + Ok(()) + }) +} + +/// Construct a dummy value for the given value type. +pub fn dummy_value(val_ty: ValType) -> Val { + match val_ty { + ValType::I32 => Val::I32(0), + ValType::I64 => Val::I64(0), + ValType::F32 => Val::F32(0), + ValType::F64 => Val::F64(0), + ValType::V128 => Val::V128(0), + ValType::ExternRef => Val::ExternRef(None), + ValType::FuncRef => Val::FuncRef(None), + } +} + +/// Construct a dummy global for the given global type. +pub fn dummy_global(store: &Store, ty: GlobalType) -> Global { + let val = dummy_value(ty.content().clone()); + Global::new(store, ty, val).unwrap() +} + +/// Construct a dummy table for the given table type. +pub fn dummy_table(store: &Store, ty: TableType) -> Table { + let init_val = dummy_value(ty.element().clone()); + Table::new(store, ty, init_val).unwrap() +} + +/// Construct a dummy memory for the given memory type. +pub fn dummy_memory(store: &Store, ty: MemoryType) -> Memory { + Memory::new(store, ty) +} + +/// Construct a dummy instance for the given instance type. +/// +/// This is done by using the expected type to generate a module on-the-fly +/// which we the instantiate. +pub fn dummy_instance(store: &Store, ty: InstanceType) -> Instance { + let mut wat = WatGenerator::new(); + for ty in ty.exports() { + wat.export(&ty); + } + let module = Module::new(store.engine(), &wat.finish()).unwrap(); + Instance::new(store, &module, &[]).unwrap() +} + +/// Construct a dummy module for the given module type. +/// +/// This is done by using the expected type to generate a module on-the-fly. +pub fn dummy_module(store: &Store, ty: ModuleType) -> Module { + let mut wat = WatGenerator::new(); + for ty in ty.imports() { + wat.import(&ty); + } + for ty in ty.exports() { + wat.export(&ty); + } + Module::new(store.engine(), &wat.finish()).unwrap() +} + +struct WatGenerator { + tmp: usize, + dst: String, +} + +impl WatGenerator { + fn new() -> WatGenerator { + WatGenerator { + tmp: 0, + dst: String::from("(module\n"), + } + } + + fn finish(mut self) -> String { + self.dst.push_str(")\n"); + self.dst + } + + fn import(&mut self, ty: &ImportType<'_>) { + write!(self.dst, "(import ").unwrap(); + self.str(ty.module()); + write!(self.dst, " ").unwrap(); + if let Some(field) = ty.name() { + self.str(field); + write!(self.dst, " ").unwrap(); + } + self.item_ty(&ty.ty()); + writeln!(self.dst, ")").unwrap(); + } + + fn item_ty(&mut self, ty: &ExternType) { + match ty { + ExternType::Memory(mem) => { + write!( + self.dst, + "(memory {} {})", + mem.limits().min(), + match mem.limits().max() { + Some(max) => max.to_string(), + None => String::new(), + } + ) + .unwrap(); + } + ExternType::Table(table) => { + write!( + self.dst, + "(table {} {} {})", + table.limits().min(), + match table.limits().max() { + Some(max) => max.to_string(), + None => String::new(), + }, + wat_ty(table.element()), + ) + .unwrap(); + } + ExternType::Global(ty) => { + if ty.mutability() == Mutability::Const { + write!(self.dst, "(global {})", wat_ty(ty.content())).unwrap(); + } else { + write!(self.dst, "(global (mut {}))", wat_ty(ty.content())).unwrap(); + } + } + ExternType::Func(ty) => { + write!(self.dst, "(func ").unwrap(); + self.func_sig(ty); + write!(self.dst, ")").unwrap(); + } + ExternType::Instance(ty) => { + writeln!(self.dst, "(instance").unwrap(); + for ty in ty.exports() { + write!(self.dst, "(export ").unwrap(); + self.str(ty.name()); + write!(self.dst, " ").unwrap(); + self.item_ty(&ty.ty()); + writeln!(self.dst, ")").unwrap(); + } + write!(self.dst, ")").unwrap(); + } + ExternType::Module(ty) => { + writeln!(self.dst, "(module").unwrap(); + for ty in ty.imports() { + self.import(&ty); + writeln!(self.dst, "").unwrap(); + } + for ty in ty.exports() { + write!(self.dst, "(export ").unwrap(); + self.str(ty.name()); + write!(self.dst, " ").unwrap(); + self.item_ty(&ty.ty()); + writeln!(self.dst, ")").unwrap(); + } + write!(self.dst, ")").unwrap(); + } + } + } + + fn export(&mut self, ty: &ExportType<'_>) { + let wat_name = format!("item{}", self.tmp); + self.tmp += 1; + let item_ty = ty.ty(); + self.item(&wat_name, &item_ty); + + write!(self.dst, "(export ").unwrap(); + self.str(ty.name()); + write!(self.dst, " (").unwrap(); + match item_ty { + ExternType::Memory(_) => write!(self.dst, "memory").unwrap(), + ExternType::Global(_) => write!(self.dst, "global").unwrap(), + ExternType::Func(_) => write!(self.dst, "func").unwrap(), + ExternType::Instance(_) => write!(self.dst, "instance").unwrap(), + ExternType::Table(_) => write!(self.dst, "table").unwrap(), + ExternType::Module(_) => write!(self.dst, "module").unwrap(), + } + writeln!(self.dst, " ${}))", wat_name).unwrap(); + } + + fn item(&mut self, name: &str, ty: &ExternType) { + match ty { + ExternType::Memory(mem) => { + write!( + self.dst, + "(memory ${} {} {})\n", + name, + mem.limits().min(), + match mem.limits().max() { + Some(max) => max.to_string(), + None => String::new(), + } + ) + .unwrap(); + } + ExternType::Table(table) => { + write!( + self.dst, + "(table ${} {} {} {})\n", + name, + table.limits().min(), + match table.limits().max() { + Some(max) => max.to_string(), + None => String::new(), + }, + wat_ty(table.element()), + ) + .unwrap(); + } + ExternType::Global(ty) => { + write!(self.dst, "(global ${} ", name).unwrap(); + if ty.mutability() == Mutability::Var { + write!(self.dst, "(mut ").unwrap(); + } + write!(self.dst, "{}", wat_ty(ty.content())).unwrap(); + if ty.mutability() == Mutability::Var { + write!(self.dst, ")").unwrap(); + } + write!(self.dst, " (").unwrap(); + self.value(ty.content()); + writeln!(self.dst, "))").unwrap(); + } + ExternType::Func(ty) => { + write!(self.dst, "(func ${} ", name).unwrap(); + self.func_sig(ty); + for ty in ty.results() { + writeln!(self.dst, "").unwrap(); + self.value(&ty); + } + writeln!(self.dst, ")").unwrap(); + } + ExternType::Module(ty) => { + writeln!(self.dst, "(module ${}", name).unwrap(); + for ty in ty.imports() { + self.import(&ty); + } + for ty in ty.exports() { + self.export(&ty); + } + self.dst.push_str(")\n"); + } + ExternType::Instance(ty) => { + writeln!(self.dst, "(module ${}_module", name).unwrap(); + for ty in ty.exports() { + self.export(&ty); + } + self.dst.push_str(")\n"); + writeln!(self.dst, "(instance ${} (instantiate ${0}_module))", name).unwrap(); + } + } + } + + fn func_sig(&mut self, ty: &FuncType) { + write!(self.dst, "(param ").unwrap(); + for ty in ty.params() { + write!(self.dst, "{} ", wat_ty(&ty)).unwrap(); + } + write!(self.dst, ") (result ").unwrap(); + for ty in ty.results() { + write!(self.dst, "{} ", wat_ty(&ty)).unwrap(); + } + write!(self.dst, ")").unwrap(); + } + + fn value(&mut self, ty: &ValType) { + match ty { + ValType::I32 => write!(self.dst, "i32.const 0").unwrap(), + ValType::I64 => write!(self.dst, "i64.const 0").unwrap(), + ValType::F32 => write!(self.dst, "f32.const 0").unwrap(), + ValType::F64 => write!(self.dst, "f64.const 0").unwrap(), + ValType::V128 => write!(self.dst, "v128.const i32x4 0 0 0 0").unwrap(), + ValType::ExternRef => write!(self.dst, "ref.null extern").unwrap(), + ValType::FuncRef => write!(self.dst, "ref.null func").unwrap(), + } + } + + fn str(&mut self, name: &str) { + let mut bytes = [0; 4]; + self.dst.push_str("\""); + for c in name.chars() { + let v = c as u32; + if v >= 0x20 && v < 0x7f && c != '"' && c != '\\' && v < 0xff { + self.dst.push(c); + } else { + for byte in c.encode_utf8(&mut bytes).as_bytes() { + self.hex_byte(*byte); + } + } + } + self.dst.push_str("\""); + } + + fn hex_byte(&mut self, byte: u8) { + fn to_hex(b: u8) -> char { + if b < 10 { + (b'0' + b) as char + } else { + (b'a' + b - 10) as char + } + } + self.dst.push('\\'); + self.dst.push(to_hex((byte >> 4) & 0xf)); + self.dst.push(to_hex(byte & 0xf)); + } +} + +fn wat_ty(ty: &ValType) -> &'static str { + match ty { + ValType::I32 => "i32", + ValType::I64 => "i64", + ValType::F32 => "f32", + ValType::F64 => "f64", + ValType::V128 => "v128", + ValType::ExternRef => "externref", + ValType::FuncRef => "funcref", + } +} + +#[cfg(test)] +mod tests { + use super::*; + use std::collections::HashSet; + + fn store() -> Store { + let mut config = Config::default(); + config.wasm_module_linking(true); + config.wasm_multi_memory(true); + let engine = wasmtime::Engine::new(&config).unwrap(); + Store::new(&engine) + } + + #[test] + fn dummy_table_import() { + let store = store(); + let table = dummy_table( + &store, + TableType::new(ValType::ExternRef, Limits::at_least(10)), + ); + assert_eq!(table.size(), 10); + for i in 0..10 { + assert!(table.get(i).unwrap().unwrap_externref().is_none()); + } + } + + #[test] + fn dummy_global_import() { + let store = store(); + let global = dummy_global(&store, GlobalType::new(ValType::I32, Mutability::Const)); + assert_eq!(global.val_type(), ValType::I32); + assert_eq!(global.mutability(), Mutability::Const); + } + + #[test] + fn dummy_memory_import() { + let store = store(); + let memory = dummy_memory(&store, MemoryType::new(Limits::at_least(1))); + assert_eq!(memory.size(), 1); + } + + #[test] + fn dummy_function_import() { + let store = store(); + let func_ty = FuncType::new(vec![ValType::I32], vec![ValType::I64]); + let func = dummy_func(&store, func_ty.clone()); + assert_eq!(func.ty(), func_ty); + } + + #[test] + fn dummy_instance_import() { + let store = store(); + + let mut instance_ty = InstanceType::new(); + + // Functions. + instance_ty.add_named_export("func0", FuncType::new(vec![ValType::I32], vec![]).into()); + instance_ty.add_named_export("func1", FuncType::new(vec![], vec![ValType::I64]).into()); + + // Globals. + instance_ty.add_named_export( + "global0", + GlobalType::new(ValType::I32, Mutability::Const).into(), + ); + instance_ty.add_named_export( + "global1", + GlobalType::new(ValType::I64, Mutability::Var).into(), + ); + + // Tables. + instance_ty.add_named_export( + "table0", + TableType::new(ValType::ExternRef, Limits::at_least(1)).into(), + ); + instance_ty.add_named_export( + "table1", + TableType::new(ValType::ExternRef, Limits::at_least(1)).into(), + ); + + // Memories. + instance_ty.add_named_export("memory0", MemoryType::new(Limits::at_least(1)).into()); + instance_ty.add_named_export("memory1", MemoryType::new(Limits::at_least(1)).into()); + + // Modules. + instance_ty.add_named_export("module0", ModuleType::new().into()); + instance_ty.add_named_export("module1", ModuleType::new().into()); + + // Instances. + instance_ty.add_named_export("instance0", InstanceType::new().into()); + instance_ty.add_named_export("instance1", InstanceType::new().into()); + + let instance = dummy_instance(&store, instance_ty.clone()); + + let mut expected_exports = vec![ + "func0", + "func1", + "global0", + "global1", + "table0", + "table1", + "memory0", + "memory1", + "module0", + "module1", + "instance0", + "instance1", + ] + .into_iter() + .collect::>(); + for exp in instance.ty().exports() { + let was_expected = expected_exports.remove(exp.name()); + assert!(was_expected); + } + assert!(expected_exports.is_empty()); + } + + #[test] + fn dummy_module_import() { + let store = store(); + + let mut module_ty = ModuleType::new(); + + // Multiple exported and imported functions. + module_ty.add_named_export("func0", FuncType::new(vec![ValType::I32], vec![]).into()); + module_ty.add_named_export("func1", FuncType::new(vec![], vec![ValType::I64]).into()); + module_ty.add_named_import( + "func2", + None, + FuncType::new(vec![ValType::I64], vec![]).into(), + ); + module_ty.add_named_import( + "func3", + None, + FuncType::new(vec![], vec![ValType::I32]).into(), + ); + + // Multiple exported and imported globals. + module_ty.add_named_export( + "global0", + GlobalType::new(ValType::I32, Mutability::Const).into(), + ); + module_ty.add_named_export( + "global1", + GlobalType::new(ValType::I64, Mutability::Var).into(), + ); + module_ty.add_named_import( + "global2", + None, + GlobalType::new(ValType::I32, Mutability::Var).into(), + ); + module_ty.add_named_import( + "global3", + None, + GlobalType::new(ValType::I64, Mutability::Const).into(), + ); + + // Multiple exported and imported tables. + module_ty.add_named_export( + "table0", + TableType::new(ValType::ExternRef, Limits::at_least(1)).into(), + ); + module_ty.add_named_export( + "table1", + TableType::new(ValType::ExternRef, Limits::at_least(1)).into(), + ); + module_ty.add_named_import( + "table2", + None, + TableType::new(ValType::ExternRef, Limits::at_least(1)).into(), + ); + module_ty.add_named_import( + "table3", + None, + TableType::new(ValType::ExternRef, Limits::at_least(1)).into(), + ); + + // Multiple exported and imported memories. + module_ty.add_named_export("memory0", MemoryType::new(Limits::at_least(1)).into()); + module_ty.add_named_export("memory1", MemoryType::new(Limits::at_least(1)).into()); + module_ty.add_named_import("memory2", None, MemoryType::new(Limits::at_least(1)).into()); + module_ty.add_named_import("memory3", None, MemoryType::new(Limits::at_least(1)).into()); + + // An exported and an imported module. + module_ty.add_named_export("module0", ModuleType::new().into()); + module_ty.add_named_import("module1", None, ModuleType::new().into()); + + // An exported and an imported instance. + module_ty.add_named_export("instance0", InstanceType::new().into()); + module_ty.add_named_import("instance1", None, InstanceType::new().into()); + + // Create the module. + let module = dummy_module(&store, module_ty); + + // Check that we have the expected exports. + assert!(module.get_export("func0").is_some()); + assert!(module.get_export("func1").is_some()); + assert!(module.get_export("global0").is_some()); + assert!(module.get_export("global1").is_some()); + assert!(module.get_export("table0").is_some()); + assert!(module.get_export("table1").is_some()); + assert!(module.get_export("memory0").is_some()); + assert!(module.get_export("memory1").is_some()); + assert!(module.get_export("instance0").is_some()); + assert!(module.get_export("module0").is_some()); + + // Check that we have the exported imports. + let mut expected_imports = vec![ + "func2", + "func3", + "global2", + "global3", + "table2", + "table3", + "memory2", + "memory3", + "instance1", + "module1", + ] + .into_iter() + .collect::>(); + for imp in module.imports() { + assert!(imp.name().is_none()); + let was_expected = expected_imports.remove(imp.module()); + assert!(was_expected); + } + assert!(expected_imports.is_empty()); + } +} diff --git a/crates/wizer/src/info.rs b/crates/wizer/src/info.rs new file mode 100644 index 000000000000..39539fcf1444 --- /dev/null +++ b/crates/wizer/src/info.rs @@ -0,0 +1,333 @@ +use wasm_encoder::SectionId; + +use crate::translate; +use std::collections::BTreeMap; +use std::convert::TryFrom; + +/// Info that we keep track of on a per module-within-a-module-linking-bundle +/// basis. +/// +/// These are created during during our `parse` pass and then used throughout +/// our later passes. +#[derive(Clone)] +pub(crate) struct ModuleInfo<'a> { + /// This module's id (i.e. its pre-order traversal index). + pub id: u32, + + /// The raw sections from the original Wasm input. + pub raw_sections: Vec>, + + /// This vector has `n` entries when the module has `n` import sections. The + /// `i`th entry is a count of how many instance imports are in the `i`th + /// import section. + pub instance_import_counts: Vec, + + /// Types available in this module. + /// + /// We keep track of these for determining how many things we need to + /// re-export for new instantiations and for inner module's aliases. + pub types: Vec>, + + /// Imports made by this module. + pub imports: Vec>, + + /// Aliases that this module defines. + pub aliases: Vec>, + + /// How many more not-yet-parsed child modules are expected for this module? + /// + /// This is only used during parsing. + pub child_modules_expected: u32, + + /// Directly nested inner modules of this module. + /// + /// These entries are populated as we finish instrumenting the inner + /// modules. + pub modules: Vec>, + + /// A map from instance indices to each instance's type for all defined, + /// imported, and aliased instances. + pub instances: Vec>, + + /// A map from indices of defined instantiations (as opposed to imported or + /// aliased instantiations) to the id of the module that was instantiated + /// and the import arguments. + pub instantiations: BTreeMap>)>, + + /// A map from global indices to each global's type for all defined, + /// imported, and aliased globals. + pub globals: Vec, + + /// The index within the global index space where defined globals (as + /// opposed to imported or aliased) begin. + /// + /// If this is `None`, then there are no locally defined globals. + pub defined_globals_index: Option, + + /// This module's exports. + /// + /// This is used later on, in the rewrite phase, when we are inserting state + /// instance imports. + /// + /// Note that this does *not* include the `__wizer_thing_N` exports that + /// this instrumentation pass adds. + pub exports: Vec>, + + /// A currently-being-encoded module section. + /// + /// As we finish instrumenting child modules, we add them here. If we aren't + /// currently processing this module's children, then this is `None`. + pub module_section: Option, + + /// Maps from function index to the function's type index for all functions + /// defined, imported, and aliased in this module. + pub functions: Vec, + + /// Maps from table index to the table's type for all tables defined, + /// imported, and aliased in this module. + pub tables: Vec, + + /// Maps from memory index to the memory's type for all memories defined, + /// imported, and aliased in this module. + pub memories: Vec, + + /// The index within the memory index space where defined memories (as + /// opposed to imported or aliased) begin. + /// + /// If this is `None`, then there are no locally defined memories. + pub defined_memories_index: Option, +} + +impl<'a> ModuleInfo<'a> { + /// Create the `ModuleInfo` for the root of a module-linking bundle. + pub fn for_root() -> Self { + Self { + id: 0, + raw_sections: vec![], + instance_import_counts: vec![], + modules: vec![], + types: vec![], + imports: vec![], + aliases: vec![], + globals: vec![], + defined_globals_index: None, + instances: vec![], + instantiations: BTreeMap::new(), + child_modules_expected: 0, + module_section: None, + exports: vec![], + functions: vec![], + tables: vec![], + memories: vec![], + defined_memories_index: None, + } + } + + /// Create a new `ModuleInfo` for an inner module. + pub fn for_inner(id: u32) -> Self { + Self { + id, + raw_sections: vec![], + instance_import_counts: vec![], + modules: vec![], + types: vec![], + imports: vec![], + aliases: vec![], + globals: vec![], + defined_globals_index: None, + instances: vec![], + instantiations: BTreeMap::new(), + child_modules_expected: 0, + module_section: None, + exports: vec![], + functions: vec![], + tables: vec![], + memories: vec![], + defined_memories_index: None, + } + } + + /// Add a new raw section to this module info during parsing. + pub fn add_raw_section( + &mut self, + id: SectionId, + range: wasmparser::Range, + full_wasm: &'a [u8], + ) { + self.raw_sections.push(wasm_encoder::RawSection { + id: id as u8, + data: &full_wasm[range.start..range.end], + }) + } + + /// Is this the root of the module linking bundle? + pub fn is_root(&self) -> bool { + self.id == 0 + } + + /// Define an instance type for this module's exports. + /// + /// Returns the index of the type and updates the total count of types in + /// `num_types`. + pub fn define_instance_type( + &self, + num_types: &mut u32, + types: &mut wasm_encoder::TypeSection, + ) -> u32 { + let ty_index = *num_types; + types.instance(self.exports.iter().map(|e| { + let name = e.field; + let index = usize::try_from(e.index).unwrap(); + let item = match e.kind { + wasmparser::ExternalKind::Function => { + let func_ty = self.functions[index]; + wasm_encoder::EntityType::Function(func_ty) + } + wasmparser::ExternalKind::Table => { + let ty = self.tables[index]; + wasm_encoder::EntityType::Table(translate::table_type(ty)) + } + wasmparser::ExternalKind::Memory => { + let ty = self.memories[index]; + wasm_encoder::EntityType::Memory(translate::memory_type(ty)) + } + wasmparser::ExternalKind::Global => { + let ty = self.globals[index]; + wasm_encoder::EntityType::Global(translate::global_type(ty)) + } + wasmparser::ExternalKind::Instance => wasm_encoder::EntityType::Instance(e.index), + wasmparser::ExternalKind::Module + | wasmparser::ExternalKind::Type + | wasmparser::ExternalKind::Event => unreachable!(), + }; + (name, item) + })); + *num_types += 1; + ty_index + } + + /// Construct an instance type for instances of this module. + pub fn instance_type(&self) -> wasmparser::InstanceType<'a> { + wasmparser::InstanceType { + exports: self + .exports + .iter() + .map(|e| { + let index = usize::try_from(e.index).unwrap(); + wasmparser::ExportType { + name: e.field, + ty: match e.kind { + wasmparser::ExternalKind::Function => { + let func_ty = self.functions[index]; + wasmparser::ImportSectionEntryType::Function(func_ty) + } + wasmparser::ExternalKind::Table => { + let ty = self.tables[index]; + wasmparser::ImportSectionEntryType::Table(ty) + } + wasmparser::ExternalKind::Memory => { + let ty = self.memories[index]; + wasmparser::ImportSectionEntryType::Memory(ty) + } + wasmparser::ExternalKind::Global => { + let ty = self.globals[index]; + wasmparser::ImportSectionEntryType::Global(ty) + } + wasmparser::ExternalKind::Instance => { + wasmparser::ImportSectionEntryType::Instance(e.index) + } + wasmparser::ExternalKind::Module + | wasmparser::ExternalKind::Type + | wasmparser::ExternalKind::Event => unreachable!(), + }, + } + }) + .collect::>() + .into_boxed_slice(), + } + } + + /// Get an export from the `n`th instance by name. + pub fn instance_export( + &self, + instance: u32, + name: &str, + ) -> Option { + let instance = usize::try_from(instance).unwrap(); + let instance = &self.instances[instance]; + instance + .exports + .iter() + .find(|e| e.name == name) + .map(|e| e.ty) + } + + /// Do a pre-order traversal over this module tree. + pub fn pre_order<'b, F>(&'b self, mut f: F) + where + F: FnMut(&'b ModuleInfo<'a>), + { + let mut stack = vec![self]; + while let Some(info) = stack.pop() { + f(info); + stack.extend(info.modules.iter().rev()); + } + } + + /// The number of defined memories in this module. + pub fn defined_memories_len(&self) -> usize { + self.defined_memories_index.map_or(0, |n| { + let n = usize::try_from(n).unwrap(); + assert!(self.memories.len() > n); + self.memories.len() - n + }) + } + + /// Iterate over the defined memories in this module. + pub fn defined_memories<'b>(&'b self) -> impl Iterator + 'b { + self.memories + .iter() + .skip( + self.defined_memories_index + .map_or(self.memories.len(), |i| usize::try_from(i).unwrap()), + ) + .copied() + } + + /// The number of defined globals in this module. + pub fn defined_globals_len(&self) -> usize { + self.defined_globals_index.map_or(0, |n| { + let n = usize::try_from(n).unwrap(); + assert!(self.globals.len() > n); + self.globals.len() - n + }) + } + + /// Iterate over the defined globals in this module. + pub fn defined_globals<'b>(&'b self) -> impl Iterator + 'b { + self.globals + .iter() + .skip( + self.defined_globals_index + .map_or(self.globals.len(), |i| usize::try_from(i).unwrap()), + ) + .copied() + } + + /// Iterate over the initial sections in this Wasm module. + pub fn initial_sections<'b>( + &'b self, + ) -> impl Iterator + 'b { + self.raw_sections + .iter() + .filter(|s| s.id != SectionId::Custom.into()) + .take_while(|s| match s.id { + x if x == SectionId::Type.into() => true, + x if x == SectionId::Import.into() => true, + x if x == SectionId::Alias.into() => true, + x if x == SectionId::Module.into() => true, + x if x == SectionId::Instance.into() => true, + _ => false, + }) + } +} diff --git a/crates/wizer/src/instrument.rs b/crates/wizer/src/instrument.rs new file mode 100644 index 000000000000..25a66648a463 --- /dev/null +++ b/crates/wizer/src/instrument.rs @@ -0,0 +1,252 @@ +//! The initial instrumentation pass. + +use crate::info::ModuleInfo; +use crate::stack_ext::StackExt; +use std::convert::TryFrom; +use wasm_encoder::SectionId; + +/// Instrument the input Wasm so that it exports its memories and globals, +/// allowing us to inspect their state after the module is instantiated and +/// initialized. +/// +/// For example, given this input module: +/// +/// ```wat +/// (module $A +/// (module $B +/// (memory $B_mem) +/// (global $B_glob (mut i32)) +/// ) +/// +/// (instance $x (instantiate $B)) +/// (instance $y (instantiate $B)) +/// +/// (memory $A_mem) +/// (global $A_glob (mut i32)) +/// ) +/// ``` +/// +/// this pass will produce the following instrumented module: +/// +/// ```wat +/// (module $A +/// (module $B +/// (memory $B_mem) +/// (global $B_glob (mut i32)) +/// +/// ;; Export all state. +/// (export "__wizer_memory_0" (memory $B_mem)) +/// (export "__wizer_global_0" (global $B_glob)) +/// ) +/// +/// (instance $x (instantiate $B)) +/// (instance $y (instantiate $B)) +/// +/// (memory $A_mem) +/// (global $A_glob (mut i32)) +/// +/// ;; Export of all state (including transitively re-exporting nested +/// ;; instantiations' state). +/// (export "__wizer_memory_0" (memory $A_mem)) +/// (export "__wizer_global_0" (global $A_glob)) +/// (export "__wizer_instance_0" (instance $x)) +/// (export "__wizer_instance_1" (instance $y)) +/// ) +/// ``` +/// +/// NB: we re-export nested instantiations as a whole instance export because we +/// can do this without disturbing existing isntances' indices. If we were to +/// export their memories and globals individually, that would disturb the +/// modules locally defined memoryies' and globals' indices, which would require +/// rewriting the code section, which would break debug info offsets. +pub(crate) fn instrument(root_info: &ModuleInfo) -> Vec { + log::debug!("Instrumenting the input Wasm"); + + struct StackEntry<'a> { + /// This entry's module info. + info: &'a ModuleInfo<'a>, + + /// The work-in-progress encoding of the new, instrumented module. + module: wasm_encoder::Module, + + /// Sections in this module info that we are iterating over. + sections: std::slice::Iter<'a, wasm_encoder::RawSection<'a>>, + + /// The index of this entry's parent module on the stack. `None` if this + /// is the root module. + parent_index: Option, + + /// Nested child modules that still need to be instrumented and added to + /// one of this entry's module's module sections. + children: std::slice::Iter<'a, ModuleInfo<'a>>, + + /// The current module section we are building for this entry's + /// module. Only `Some` if we are currently processing this module's + /// (transitive) children, i.e. this is not the module on the top of the + /// stack. + module_section: Option, + + /// The number of children still remaining to be interested for the + /// current module section. + children_remaining: usize, + } + + let mut stack = vec![StackEntry { + info: root_info, + module: wasm_encoder::Module::new(), + sections: root_info.raw_sections.iter(), + parent_index: None, + children: root_info.modules.iter(), + module_section: None, + children_remaining: 0, + }]; + + loop { + assert!(!stack.is_empty()); + + match stack.top_mut().sections.next() { + // For the exports section, we need to transitively export internal + // state so that we can read the initialized state after we call the + // initialization function. + Some(section) if section.id == SectionId::Export.into() => { + let entry = stack.top_mut(); + let mut exports = wasm_encoder::ExportSection::new(); + + // First, copy over all the original exports. + for export in &entry.info.exports { + exports.export( + export.field, + match export.kind { + wasmparser::ExternalKind::Function => { + wasm_encoder::Export::Function(export.index) + } + wasmparser::ExternalKind::Table => { + wasm_encoder::Export::Table(export.index) + } + wasmparser::ExternalKind::Memory => { + wasm_encoder::Export::Memory(export.index) + } + wasmparser::ExternalKind::Global => { + wasm_encoder::Export::Global(export.index) + } + wasmparser::ExternalKind::Instance => { + wasm_encoder::Export::Instance(export.index) + } + wasmparser::ExternalKind::Module + | wasmparser::ExternalKind::Type + | wasmparser::ExternalKind::Event => { + unreachable!("should have been rejected in validation/parsing") + } + }, + ); + } + + // Now export all of this module's defined globals, memories, + // and instantiations under well-known names so we can inspect + // them after initialization. + for (i, j) in (entry.info.defined_globals_index.unwrap_or(u32::MAX) + ..u32::try_from(entry.info.globals.len()).unwrap()) + .enumerate() + { + let name = format!("__wizer_global_{}", i); + exports.export(&name, wasm_encoder::Export::Global(j)); + } + for (i, j) in (entry.info.defined_memories_index.unwrap_or(u32::MAX) + ..u32::try_from(entry.info.memories.len()).unwrap()) + .enumerate() + { + let name = format!("__wizer_memory_{}", i); + exports.export(&name, wasm_encoder::Export::Memory(j)); + } + for (i, j) in entry.info.instantiations.keys().enumerate() { + let name = format!("__wizer_instance_{}", i); + exports.export(&name, wasm_encoder::Export::Instance(*j)); + } + + entry.module.section(&exports); + } + + // Nested module sections need to recursively instrument each child + // module. + Some(section) if section.id == SectionId::Module.into() => { + let reader = wasmparser::ModuleSectionReader::new(section.data, 0).unwrap(); + let count = usize::try_from(reader.get_count()).unwrap(); + + assert!(stack.top().module_section.is_none()); + if count == 0 { + continue; + } + + stack.top_mut().module_section = Some(wasm_encoder::ModuleSection::new()); + + assert_eq!(stack.top().children_remaining, 0); + stack.top_mut().children_remaining = count; + + let children = stack + .top_mut() + .children + .by_ref() + .take(count) + .collect::>(); + + assert_eq!( + children.len(), + count, + "shouldn't ever have fewer children than expected" + ); + + let parent_index = Some(stack.len() - 1); + stack.extend( + children + .into_iter() + // Reverse so that we pop them off the stack in order. + .rev() + .map(|c| StackEntry { + info: c, + module: wasm_encoder::Module::new(), + sections: c.raw_sections.iter(), + parent_index, + children: c.modules.iter(), + module_section: None, + children_remaining: 0, + }), + ); + } + + // End of the current module: if this is the root, return the + // instrumented module, otherwise add it as an entry in its parent's + // module section. + None => { + let entry = stack.pop().unwrap(); + assert!(entry.module_section.is_none()); + assert_eq!(entry.children_remaining, 0); + + if entry.info.is_root() { + assert!(stack.is_empty()); + return entry.module.finish(); + } + + let parent = &mut stack[entry.parent_index.unwrap()]; + parent + .module_section + .as_mut() + .unwrap() + .module(&entry.module); + + assert!(parent.children_remaining > 0); + parent.children_remaining -= 1; + + if parent.children_remaining == 0 { + let module_section = parent.module_section.take().unwrap(); + parent.module.section(&module_section); + } + } + + // All other sections don't need instrumentation and can be copied + // over directly. + Some(section) => { + stack.top_mut().module.section(section); + } + } + } +} diff --git a/crates/wizer/src/lib.rs b/crates/wizer/src/lib.rs index 0462cd844a72..c24d27908e00 100644 --- a/crates/wizer/src/lib.rs +++ b/crates/wizer/src/lib.rs @@ -4,23 +4,28 @@ #![deny(missing_docs)] +mod dummy; +mod info; +mod instrument; +mod parse; +mod rewrite; +mod snapshot; +mod stack_ext; +mod translate; + use anyhow::Context; -use rayon::iter::{IntoParallelIterator, ParallelExtend, ParallelIterator}; +use dummy::dummy_imports; use std::collections::{HashMap, HashSet}; -use std::convert::TryFrom; use std::fmt::Display; use std::path::PathBuf; #[cfg(feature = "structopt")] use structopt::StructOpt; -const WASM_PAGE_SIZE: u32 = 65_536; -const NATIVE_PAGE_SIZE: u32 = 4_096; - const DEFAULT_INHERIT_STDIO: bool = true; const DEFAULT_INHERIT_ENV: bool = false; - const DEFAULT_WASM_MULTI_VALUE: bool = true; const DEFAULT_WASM_MULTI_MEMORY: bool = true; +const DEFAULT_WASM_MODULE_LINKING: bool = false; /// Wizer: the WebAssembly pre-initializer! /// @@ -65,6 +70,9 @@ pub struct Wizer { /// /// This option can be used, for example, to replace a `_start` entry point /// in an initialized module with an alternate entry point. + /// + /// When module linking is enabled, these renames are only applied to the + /// outermost module. #[cfg_attr( feature = "structopt", structopt( @@ -132,26 +140,12 @@ pub struct Wizer { /// Enabled by default. #[cfg_attr(feature = "structopt", structopt(long, value_name = "true|false"))] wasm_multi_value: Option, -} -fn translate_val_type(ty: wasmparser::Type) -> wasm_encoder::ValType { - use wasm_encoder::ValType; - use wasmparser::Type::*; - match ty { - I32 => ValType::I32, - I64 => ValType::I64, - F32 => ValType::F32, - F64 => ValType::F64, - V128 | FuncRef | ExternRef | ExnRef => panic!("not supported"), - Func | EmptyBlockType => unreachable!(), - } -} - -fn translate_global_type(ty: wasmparser::GlobalType) -> wasm_encoder::GlobalType { - wasm_encoder::GlobalType { - val_type: translate_val_type(ty.content_type), - mutable: ty.mutable, - } + /// Enable or disable the Wasm module-linking proposal. + /// + /// Disabled by default. + #[cfg_attr(feature = "structopt", structopt(long, value_name = "true|false"))] + wasm_module_linking: Option, } struct FuncRenames { @@ -207,6 +201,7 @@ impl Wizer { dirs: vec![], wasm_multi_memory: None, wasm_multi_value: None, + wasm_module_linking: None, } } @@ -286,6 +281,14 @@ impl Wizer { self } + /// Enable or disable the Wasm module-linking proposal. + /// + /// Defaults to `false`. + pub fn wasm_module_linking(&mut self, enable: bool) -> &mut Self { + self.wasm_module_linking = Some(enable); + self + } + /// Initialize the given Wasm, snapshot it, and return the serialized /// snapshot as a new, pre-initialized Wasm module. pub fn run(&self, wasm: &[u8]) -> anyhow::Result> { @@ -293,23 +296,33 @@ impl Wizer { let renames = FuncRenames::parse(&self.func_renames)?; // Make sure we're given valid Wasm from the get go. - self.wasm_validate(wasm)?; + self.wasm_validate(&wasm)?; - let wasm = self.prepare_input_wasm(wasm)?; - debug_assert!( - self.wasm_validate(&wasm).is_ok(), - "if the Wasm was originally valid, then our preparation step shouldn't invalidate it" - ); + let info = parse::parse(wasm)?; + let wasm = instrument::instrument(&info); + + if cfg!(debug_assertions) { + if let Err(error) = self.wasm_validate(&wasm) { + panic!("instrumented Wasm is not valid: {:?}", error); + } + } let config = self.wasmtime_config()?; let engine = wasmtime::Engine::new(&config)?; let store = wasmtime::Store::new(&engine); - let module = wasmtime::Module::new(store.engine(), &wasm)?; + let module = + wasmtime::Module::new(&engine, &wasm).context("failed to compile the Wasm module")?; self.validate_init_func(&module)?; let instance = self.initialize(&store, &module)?; - let snapshot = self.snapshot(&instance); - let initialized_wasm = self.rewrite(&wasm, &snapshot, &renames); + let snapshot = snapshot::snapshot(&store, &instance); + let initialized_wasm = self.rewrite(&snapshot, &info, &renames); + + if cfg!(debug_assertions) { + if let Err(error) = self.wasm_validate(&initialized_wasm) { + panic!("rewritten Wasm is not valid: {:?}", error); + } + } Ok(initialized_wasm) } @@ -326,10 +339,13 @@ impl Wizer { // Proposals we support. config.wasm_multi_memory(self.wasm_multi_memory.unwrap_or(DEFAULT_WASM_MULTI_MEMORY)); config.wasm_multi_value(self.wasm_multi_value.unwrap_or(DEFAULT_WASM_MULTI_VALUE)); + config.wasm_module_linking( + self.wasm_module_linking + .unwrap_or(DEFAULT_WASM_MODULE_LINKING), + ); // Proposoals that we should add support for. config.wasm_reference_types(false); - config.wasm_module_linking(false); config.wasm_simd(false); config.wasm_threads(false); config.wasm_bulk_memory(false); @@ -343,17 +359,43 @@ impl Wizer { // Proposals that we support. multi_memory: self.wasm_multi_memory.unwrap_or(DEFAULT_WASM_MULTI_MEMORY), multi_value: self.wasm_multi_value.unwrap_or(DEFAULT_WASM_MULTI_VALUE), + module_linking: self + .wasm_module_linking + .unwrap_or(DEFAULT_WASM_MODULE_LINKING), // Proposals that we should add support for. reference_types: false, - module_linking: false, simd: false, threads: false, tail_call: false, - bulk_memory: false, memory64: false, exceptions: false, + // XXX: Though we don't actually support bulk memory yet, we + // unconditionally turn it on. + // + // Many parsers, notably our own `wasmparser`, assume that which + // Wasm features are enabled or disabled cannot affect parsing, only + // validation. That assumption is incorrect when it comes to data + // segments, the multi-memory proposal, and the bulk memory + // proposal. A `0x01` prefix of a data segment can either mean "this + // is a passive segment" if bulk memory is enabled or "this segment + // is referring to memory index 1" if both bulk memory is disabled + // and multi-memory is enabled. `wasmparser` fails to handle this + // edge case, which means that everything built on top of it, like + // Wasmtime, also fail to handle this edge case. However, because + // bulk memory is merged into the spec proper and is no longer + // technically a "proposal", and because a fix would require + // significant refactoring and API changes to give a + // `wasmparser::Parser` a `wasmparser::WasmFeatures`, we won't ever + // resolve this discrepancy in `wasmparser`. + // + // So we enable bulk memory during parsing, validation, and + // execution, but we add our own custom validation pass to ensure + // that no table-mutating instructions exist in our input modules + // until we *actually* support bulk memory. + bulk_memory: true, + // We will never want to enable this. deterministic_only: false, } @@ -361,170 +403,66 @@ impl Wizer { fn wasm_validate(&self, wasm: &[u8]) -> anyhow::Result<()> { log::debug!("Validating input Wasm"); + let mut validator = wasmparser::Validator::new(); validator.wasm_features(self.wasm_features()); validator.validate_all(wasm)?; - Ok(()) - } - - /// Rewrite the input Wasm with our own custom exports for all globals, and - /// memories. This way we can reflect on their values later on in the - /// snapshot phase. - /// - /// TODO: will have to also export tables once we support reference types. - fn prepare_input_wasm(&self, full_wasm: &[u8]) -> anyhow::Result> { - log::debug!("Preparing input Wasm"); - - let mut wasm = full_wasm; - let mut parser = wasmparser::Parser::new(0); - let mut module = wasm_encoder::Module::new(); - - // Count how many globals and memories we see in this module, so that we - // can export them all. - let mut memory_count = 0; - let mut global_count = 0; - - loop { - let (payload, consumed) = - match parser.parse(wasm, true).context("failed to parse Wasm")? { - wasmparser::Chunk::NeedMoreData(_) => anyhow::bail!("invalid Wasm module"), - wasmparser::Chunk::Parsed { payload, consumed } => (payload, consumed), - }; - wasm = &wasm[consumed..]; - use wasmparser::Payload::*; - use wasmparser::SectionReader; - match payload { - Version { .. } => continue, - TypeSection(types) => { - module.section(&wasm_encoder::RawSection { - id: wasm_encoder::SectionId::Type as u8, - data: &full_wasm[types.range().start..types.range().end], - }); - } - ImportSection(imports) => { - module.section(&wasm_encoder::RawSection { - id: wasm_encoder::SectionId::Import as u8, - data: &full_wasm[imports.range().start..imports.range().end], - }); - } - AliasSection(_) - | InstanceSection(_) - | ModuleSectionStart { .. } - | ModuleSectionEntry { .. } => { - anyhow::bail!("module linking is not supported yet") - } - FunctionSection(funcs) => { - module.section(&wasm_encoder::RawSection { - id: wasm_encoder::SectionId::Function as u8, - data: &full_wasm[funcs.range().start..funcs.range().end], - }); - } - TableSection(tables) => { - module.section(&wasm_encoder::RawSection { - id: wasm_encoder::SectionId::Table as u8, - data: &full_wasm[tables.range().start..tables.range().end], - }); + // Reject bulk memory stuff that manipulates state we don't + // snapshot. See the comment inside `wasm_features`. + let mut wasm = wasm; + let mut parsers = vec![wasmparser::Parser::new(0)]; + while !parsers.is_empty() { + let payload = match parsers.last_mut().unwrap().parse(wasm, true).unwrap() { + wasmparser::Chunk::NeedMoreData(_) => unreachable!(), + wasmparser::Chunk::Parsed { consumed, payload } => { + wasm = &wasm[consumed..]; + payload } - MemorySection(mems) => { - memory_count += mems.get_count(); - module.section(&wasm_encoder::RawSection { - id: wasm_encoder::SectionId::Memory as u8, - data: &full_wasm[mems.range().start..mems.range().end], - }); + }; + match payload { + wasmparser::Payload::CodeSectionEntry(code) => { + let mut ops = code.get_operators_reader().unwrap(); + while !ops.eof() { + match ops.read().unwrap() { + wasmparser::Operator::TableCopy { .. } => { + anyhow::bail!("unsupported `table.copy` instruction") + } + wasmparser::Operator::TableInit { .. } => { + anyhow::bail!("unsupported `table.init` instruction") + } + wasmparser::Operator::ElemDrop { .. } => { + anyhow::bail!("unsupported `elem.drop` instruction") + } + wasmparser::Operator::DataDrop { .. } => { + anyhow::bail!("unsupported `data.drop` instruction") + } + wasmparser::Operator::TableSet { .. } => { + unreachable!("part of reference types") + } + _ => continue, + } + } } - GlobalSection(globals) => { - global_count += globals.get_count(); - module.section(&wasm_encoder::RawSection { - id: wasm_encoder::SectionId::Global as u8, - data: &full_wasm[globals.range().start..globals.range().end], - }); + wasmparser::Payload::ModuleSectionEntry { parser, .. } => { + parsers.push(parser); } - ExportSection(mut exports) => { - let count = exports.get_count(); - let mut exports_encoder = wasm_encoder::ExportSection::new(); + wasmparser::Payload::DataSection(mut data) => { + let count = data.get_count(); for _ in 0..count { - let export = exports.read()?; - exports_encoder.export( - export.field, - match export.kind { - wasmparser::ExternalKind::Function => { - wasm_encoder::Export::Function(export.index) - } - wasmparser::ExternalKind::Table => { - wasm_encoder::Export::Table(export.index) - } - wasmparser::ExternalKind::Memory => { - wasm_encoder::Export::Memory(export.index) - } - wasmparser::ExternalKind::Global => { - wasm_encoder::Export::Global(export.index) - } - wasmparser::ExternalKind::Type - | wasmparser::ExternalKind::Module - | wasmparser::ExternalKind::Instance => { - anyhow::bail!("module linking is not supported yet"); - } - wasmparser::ExternalKind::Event => { - anyhow::bail!("exceptions are not supported yet") - } - }, - ); - } - // Export all of the globals and memories under known names - // so we can manipulate them later. - for i in 0..global_count { - let name = format!("__wizer_global_{}", i); - exports_encoder.export(&name, wasm_encoder::Export::Global(i)); - } - for i in 0..memory_count { - let name = format!("__wizer_memory_{}", i); - exports_encoder.export(&name, wasm_encoder::Export::Memory(i)); + if let wasmparser::DataKind::Passive = data.read().unwrap().kind { + anyhow::bail!("unsupported passive data segment"); + } } - module.section(&exports_encoder); - } - StartSection { func, range: _ } => { - module.section(&wasm_encoder::StartSection { - function_index: func, - }); - } - ElementSection(elems) => { - module.section(&wasm_encoder::RawSection { - id: wasm_encoder::SectionId::Element as u8, - data: &full_wasm[elems.range().start..elems.range().end], - }); - } - DataCountSection { .. } => anyhow::bail!("bulk memory is not supported yet"), - DataSection(data) => { - module.section(&wasm_encoder::RawSection { - id: wasm_encoder::SectionId::Data as u8, - data: &full_wasm[data.range().start..data.range().end], - }); } - CustomSection { - name, - data, - data_offset: _, - } => { - module.section(&wasm_encoder::CustomSection { name, data }); + wasmparser::Payload::End => { + parsers.pop(); } - CodeSectionStart { - range, - count: _, - size: _, - } => { - let data = &full_wasm[range.start..range.end]; - module.section(&wasm_encoder::RawSection { - id: wasm_encoder::SectionId::Code as u8, - data, - }); - } - CodeSectionEntry(_) => continue, - UnknownSection { .. } => anyhow::bail!("unknown section"), - EventSection(_) => anyhow::bail!("exceptions are not supported yet"), - End => return Ok(module.finish()), + _ => continue, } } + + Ok(()) } /// Check that the module exports an initialization function, and that the @@ -552,72 +490,6 @@ impl Wizer { Ok(()) } - /// Create dummy imports for instantiating the module. - fn dummy_imports( - &self, - store: &wasmtime::Store, - module: &wasmtime::Module, - linker: &mut wasmtime::Linker, - ) -> anyhow::Result<()> { - log::debug!("Creating dummy imports"); - - for imp in module.imports() { - if linker.get_one_by_name(imp.module(), imp.name()).is_ok() { - // Already defined, must be part of WASI. - continue; - } - - match imp.ty() { - wasmtime::ExternType::Func(func_ty) => { - let trap = wasmtime::Trap::new(format!( - "cannot call imports within the initialization function; attempted \ - to call `'{}' '{}'`", - imp.module(), - imp.name().unwrap() - )); - linker.define( - imp.module(), - imp.name().unwrap(), - wasmtime::Func::new( - store, - func_ty, - move |_caller: wasmtime::Caller, _params, _results| Err(trap.clone()), - ), - )?; - } - wasmtime::ExternType::Global(_global_ty) => { - // The Wasm module could use `global.get` to read the - // imported value and branch on that or use `global.set` to - // update it if it's mutable. We can't create a trapping - // dummy value, like we can for functions, and we can't - // define a "global segment" to update any imported values - // (although I suppose we could inject a `start` function). - anyhow::bail!("cannot initialize Wasm modules that import globals") - } - wasmtime::ExternType::Table(_table_ty) => { - // TODO: we could import a dummy table full of trapping - // functions *if* the reference types proposal is not - // enabled, so there is no way the Wasm module can - // manipulate the table. This would allow initializing such - // modules, as long as the initialization didn't do any - // `call_indirect`s. - anyhow::bail!("cannot initialize Wasm modules that import tables") - } - wasmtime::ExternType::Memory(_memory_ty) => { - // The Wasm module could read the memory and branch on its - // contents, and since we can't create a dummy memory that - // matches the "real" import, nor can we create a trapping - // dummy version like we can for functions, we can't support - // imported memories. - anyhow::bail!("cannot initialize Wasm modules that import memories") - } - _ => anyhow::bail!("module linking is not supported yet"), - }; - } - - Ok(()) - } - /// Instantiate the module and call its initialization function. fn initialize( &self, @@ -646,8 +518,12 @@ impl Wizer { let ctx = ctx.build()?; wasmtime_wasi::Wasi::new(store, ctx).add_to_linker(&mut linker)?; } - self.dummy_imports(&store, &module, &mut linker)?; - let instance = linker.instantiate(module)?; + + dummy_imports(&store, &module, &mut linker)?; + + let instance = linker + .instantiate(module) + .context("failed to instantiate the Wasm module")?; let init_func = instance .get_typed_func::<(), ()>(&self.init_func) @@ -658,364 +534,4 @@ impl Wizer { Ok(instance) } - - /// Snapshot the given instance's globals, memories, and tables. - /// - /// TODO: when we support reference types, we will have to snapshot tables. - fn snapshot<'a>(&self, instance: &'a wasmtime::Instance) -> Snapshot<'a> { - // Get the initialized values of all globals. - log::debug!("Snapshotting global values"); - let mut globals = vec![]; - let mut global_index = 0; - loop { - let name = format!("__wizer_global_{}", global_index); - match instance.get_global(&name) { - None => break, - Some(global) => { - globals.push(global.get()); - global_index += 1; - } - } - } - - // Find and record non-zero regions of memory (in parallel). - // - // TODO: This could be really slow for large memories. Instead, we - // should bring our own memories, protect the pages, and keep a table - // with a dirty bit for each page, so we can just snapshot the pages - // that actually got changed to non-zero values. - log::debug!("Snapshotting memories"); - let mut memory_mins = vec![]; - let mut data_segments = vec![]; - let mut memory_index = 0; - loop { - let name = format!("__wizer_memory_{}", memory_index); - match instance.get_memory(&name) { - None => break, - Some(memory) => { - memory_mins.push(memory.size()); - - let num_wasm_pages = memory.size(); - let num_native_pages = num_wasm_pages * (WASM_PAGE_SIZE / NATIVE_PAGE_SIZE); - - let memory: &'a [u8] = unsafe { - // Safe because no one else has a (potentially mutable) - // view to this memory and we know the memory will live - // as long as the instance is alive. - std::slice::from_raw_parts(memory.data_ptr(), memory.data_size()) - }; - - // Consider each "native" page of the memory. (Scare quotes - // because we have no guarantee that anyone isn't using huge - // page sizes or something). Process each page in - // parallel. If any byte has changed, add the whole page as - // a data segment. This means that the resulting Wasm module - // should instantiate faster, since there are fewer segments - // to bounds check on instantiation. Engines could even - // theoretically recognize that each of these segments is - // page sized and aligned, and use lazy copy-on-write - // initialization of each instance's memory. - data_segments.par_extend((0..num_native_pages).into_par_iter().filter_map( - |i| { - let start = i * NATIVE_PAGE_SIZE; - let end = ((i + 1) * NATIVE_PAGE_SIZE) as usize; - let page = &memory[start as usize..end]; - for byte in page { - if *byte != 0 { - return Some(DataSegment { - memory_index, - offset: start as u32, - data: page, - }); - } - } - None - }, - )); - - memory_index += 1; - } - } - } - - // Sort data segments to enforce determinism in the face of the - // parallelism above. - data_segments.sort_by_key(|s| (s.memory_index, s.offset)); - - // Merge any contiguous pages, so that the engine can initialize them - // all at once (ideally with a single copy-on-write `mmap`) rather than - // initializing each data segment individually. - for i in (1..data_segments.len()).rev() { - let a = &data_segments[i - 1]; - let b = &data_segments[i]; - - // Only merge segments for the same memory. - if a.memory_index != b.memory_index { - continue; - } - - // Only merge segments if they are contiguous. - if a.offset + u32::try_from(a.data.len()).unwrap() != b.offset { - continue; - } - - // Okay, merge them together into `a` (so that the next iteration - // can merge it with its predecessor) and then remove `b`! - data_segments[i - 1].data = unsafe { - debug_assert_eq!( - a.data - .as_ptr() - .offset(isize::try_from(a.data.len()).unwrap()), - b.data.as_ptr() - ); - std::slice::from_raw_parts(a.data.as_ptr(), a.data.len() + b.data.len()) - }; - data_segments.remove(i); - } - - Snapshot { - globals, - memory_mins, - data_segments, - } - } - - fn rewrite(&self, full_wasm: &[u8], snapshot: &Snapshot, renames: &FuncRenames) -> Vec { - log::debug!("Rewriting input Wasm to pre-initialized state"); - - let mut wasm = full_wasm; - let mut parser = wasmparser::Parser::new(0); - let mut module = wasm_encoder::Module::new(); - - // Encode the initialized data segments from the snapshot rather than - // the original, uninitialized data segments. - let mut added_data = false; - let mut add_data_section = |module: &mut wasm_encoder::Module| { - if added_data || snapshot.data_segments.is_empty() { - return; - } - let mut data_section = wasm_encoder::DataSection::new(); - for DataSegment { - memory_index, - offset, - data, - } in &snapshot.data_segments - { - data_section.active( - *memory_index, - wasm_encoder::Instruction::I32Const(*offset as i32), - data.iter().copied(), - ); - } - module.section(&data_section); - added_data = true; - }; - - loop { - let (payload, consumed) = match parser.parse(wasm, true).unwrap() { - wasmparser::Chunk::NeedMoreData(_) => unreachable!(), - wasmparser::Chunk::Parsed { payload, consumed } => (payload, consumed), - }; - wasm = &wasm[consumed..]; - - use wasmparser::Payload::*; - use wasmparser::SectionReader; - match payload { - Version { .. } => continue, - TypeSection(types) => { - module.section(&wasm_encoder::RawSection { - id: wasm_encoder::SectionId::Type as u8, - data: &full_wasm[types.range().start..types.range().end], - }); - } - ImportSection(imports) => { - module.section(&wasm_encoder::RawSection { - id: wasm_encoder::SectionId::Import as u8, - data: &full_wasm[imports.range().start..imports.range().end], - }); - } - AliasSection(_) | InstanceSection(_) => unreachable!(), - FunctionSection(funcs) => { - module.section(&wasm_encoder::RawSection { - id: wasm_encoder::SectionId::Function as u8, - data: &full_wasm[funcs.range().start..funcs.range().end], - }); - } - TableSection(tables) => { - module.section(&wasm_encoder::RawSection { - id: wasm_encoder::SectionId::Table as u8, - data: &full_wasm[tables.range().start..tables.range().end], - }); - } - MemorySection(mut mems) => { - // Set the minimum size of each memory to the snapshot's - // initialized size for that memory. - let mut memory_encoder = wasm_encoder::MemorySection::new(); - for i in 0..mems.get_count() { - let memory = mems.read().unwrap(); - match memory { - wasmparser::MemoryType::M32 { limits, shared: _ } => { - memory_encoder.memory(wasm_encoder::MemoryType { - limits: wasm_encoder::Limits { - min: snapshot.memory_mins[i as usize], - max: limits.maximum, - }, - }); - } - _ => unreachable!(), - } - } - module.section(&memory_encoder); - } - GlobalSection(mut globals) => { - // Encode the initialized values from the snapshot, rather - // than the original values. - let mut globals_encoder = wasm_encoder::GlobalSection::new(); - for i in 0..globals.get_count() { - let global = globals.read().unwrap(); - globals_encoder.global( - translate_global_type(global.ty), - match snapshot.globals[i as usize] { - wasmtime::Val::I32(x) => wasm_encoder::Instruction::I32Const(x), - wasmtime::Val::I64(x) => wasm_encoder::Instruction::I64Const(x), - wasmtime::Val::F32(x) => { - wasm_encoder::Instruction::F32Const(f32::from_bits(x)) - } - wasmtime::Val::F64(x) => { - wasm_encoder::Instruction::F64Const(f64::from_bits(x)) - } - _ => unreachable!(), - }, - ); - } - module.section(&globals_encoder); - } - ExportSection(mut exports) => { - // Remove the `__wizer_*` exports we added during the - // preparation phase, as well as the initialization - // function's export. Removing the latter will enable - // further Wasm optimizations (notably GC'ing unused - // functions) via `wasm-opt` and similar tools. - // - // We also perform renames at this stage. We have - // precomputed the list of old dsts to remove, and the - // mapping from srcs to dsts, so we can do this in one pass. - let count = exports.get_count(); - let mut exports_encoder = wasm_encoder::ExportSection::new(); - for _ in 0..count { - let export = exports.read().unwrap(); - if export.field.starts_with("__wizer_") || export.field == self.init_func { - continue; - } - if !renames.rename_src_to_dst.contains_key(export.field) - && renames.rename_dsts.contains(export.field) - { - // A rename overwrites this export, and it is not renamed to another - // export, so skip it. - continue; - } - let field = match renames.rename_src_to_dst.get(export.field) { - None => export.field, - // A rename spec renames the export to this new - // name, so use it. - Some(dst) => dst, - }; - exports_encoder.export( - field, - match export.kind { - wasmparser::ExternalKind::Function => { - wasm_encoder::Export::Function(export.index) - } - wasmparser::ExternalKind::Table => { - wasm_encoder::Export::Table(export.index) - } - wasmparser::ExternalKind::Memory => { - wasm_encoder::Export::Memory(export.index) - } - wasmparser::ExternalKind::Global => { - wasm_encoder::Export::Global(export.index) - } - wasmparser::ExternalKind::Type - | wasmparser::ExternalKind::Module - | wasmparser::ExternalKind::Instance - | wasmparser::ExternalKind::Event => unreachable!(), - }, - ); - } - module.section(&exports_encoder); - } - StartSection { .. } => { - // Skip the `start` function -- it's already been run! - continue; - } - ElementSection(elems) => { - module.section(&wasm_encoder::RawSection { - id: wasm_encoder::SectionId::Element as u8, - data: &full_wasm[elems.range().start..elems.range().end], - }); - } - DataCountSection { .. } => unreachable!(), - DataSection(_) => { - // TODO: supporting bulk memory will require copying over - // any active or declared segments. - add_data_section(&mut module); - } - CustomSection { - name, - data, - data_offset: _, - } => { - // Some tools expect the name custom section to come last, - // even though custom sections are allowed in any order. - if name == "name" { - add_data_section(&mut module); - } - - module.section(&wasm_encoder::CustomSection { name, data }); - } - CodeSectionStart { - range, - count: _, - size: _, - } => { - let data = &full_wasm[range.start..range.end]; - module.section(&wasm_encoder::RawSection { - id: wasm_encoder::SectionId::Code as u8, - data, - }); - } - CodeSectionEntry(_) => continue, - ModuleSectionStart { .. } - | ModuleSectionEntry { .. } - | UnknownSection { .. } - | EventSection(_) => unreachable!(), - End => { - add_data_section(&mut module); - return module.finish(); - } - } - } - } -} - -/// A "snapshot" of non-default Wasm state after an instance has been -/// initialized. -struct Snapshot<'a> { - /// Maps global index to its initialized value. - globals: Vec, - - /// A new minimum size for each memory (in units of pages). - memory_mins: Vec, - - /// Segments of non-zero memory. - data_segments: Vec>, -} - -struct DataSegment<'a> { - /// The index of this data segment's memory. - memory_index: u32, - /// The offset within the memory that `data` should be copied to. - offset: u32, - /// This segment's (non-zero) data. - data: &'a [u8], } diff --git a/crates/wizer/src/parse.rs b/crates/wizer/src/parse.rs new file mode 100644 index 000000000000..1dee3cdc9209 --- /dev/null +++ b/crates/wizer/src/parse.rs @@ -0,0 +1,566 @@ +use crate::info::ModuleInfo; +use crate::stack_ext::StackExt; +use anyhow::{Context, Result}; +use std::convert::TryFrom; +use wasm_encoder::SectionId; +use wasmparser::{SectionReader, SectionWithLimitedItems}; + +/// Parse the given Wasm bytes into a `ModuleInfo` tree. +pub(crate) fn parse<'a>(full_wasm: &'a [u8]) -> anyhow::Result> { + log::debug!("Parsing the input Wasm"); + + // The wasm we are currently parsing. This is advanced as the parser + // consumes input. + let mut wasm = full_wasm; + + // The counter for making unique-within-the-whole-bundle module identifiers + // (i.e. the module's pre-order traversal index). + let mut id_counter = 0; + + // The stack of module infos we are parsing. As we visit inner modules + // during parsing, we push new entries, and when we finish processing them, + // we pop them. + let mut stack = vec![ModuleInfo::for_root()]; + + // Stack of parsers for each module we are parsing. Has a parallel structure + // to `stack`. + let mut parsers = vec![wasmparser::Parser::new(0)]; + + loop { + assert_eq!(stack.len(), parsers.len()); + + let (payload, consumed) = match parsers + .top_mut() + .parse(wasm, true) + .context("failed to parse Wasm")? + { + wasmparser::Chunk::NeedMoreData(_) => anyhow::bail!("invalid Wasm module"), + wasmparser::Chunk::Parsed { payload, consumed } => (payload, consumed), + }; + wasm = &wasm[consumed..]; + + use wasmparser::Payload::*; + match payload { + Version { .. } => continue, + TypeSection(types) => type_section(&mut stack, full_wasm, types)?, + ImportSection(imports) => import_section(&mut stack, full_wasm, imports)?, + AliasSection(aliases) => alias_section(&mut stack, full_wasm, aliases)?, + InstanceSection(instances) => instance_section(&mut stack, full_wasm, instances)?, + ModuleSectionStart { + range, + size: _, + count: _, + } => { + let info = stack.top_mut(); + info.add_raw_section(SectionId::Module, range, full_wasm); + } + ModuleSectionEntry { parser, range: _ } => { + id_counter += 1; + stack.push(ModuleInfo::for_inner(id_counter)); + parsers.push(parser); + } + FunctionSection(funcs) => function_section(&mut stack, full_wasm, funcs)?, + TableSection(tables) => table_section(&mut stack, full_wasm, tables)?, + MemorySection(mems) => memory_section(&mut stack, full_wasm, mems)?, + GlobalSection(globals) => global_section(&mut stack, full_wasm, globals)?, + ExportSection(exports) => export_section(&mut stack, full_wasm, exports)?, + StartSection { func: _, range } => { + stack + .top_mut() + .add_raw_section(SectionId::Start, range, full_wasm) + } + ElementSection(elems) => { + stack + .top_mut() + .add_raw_section(SectionId::Element, elems.range(), full_wasm) + } + DataCountSection { .. } => unreachable!("validation rejects bulk memory"), + DataSection(data) => { + stack + .top_mut() + .add_raw_section(SectionId::Data, data.range(), full_wasm) + } + CustomSection { range, .. } => { + stack + .top_mut() + .add_raw_section(SectionId::Custom, range, full_wasm) + } + CodeSectionStart { + range, + count: _, + size, + } => { + parsers.top_mut().skip_section(); + wasm = &wasm[usize::try_from(size).unwrap()..]; + stack + .top_mut() + .add_raw_section(SectionId::Code, range, full_wasm) + } + CodeSectionEntry(_) => unreachable!(), + UnknownSection { .. } => anyhow::bail!("unknown section"), + EventSection(_) => anyhow::bail!("exceptions are not supported yet"), + End => { + let info = stack.pop().unwrap(); + parsers.pop(); + + // If we finished parsing the root Wasm module, then we're done. + if info.is_root() { + assert!(stack.is_empty()); + assert!(parsers.is_empty()); + return Ok(info); + } + + // Otherwise, we need to add this module to its parent's module + // section. + let parent = stack.top_mut(); + parent.modules.push(info); + } + } + } +} + +fn type_section<'a>( + stack: &mut Vec>, + full_wasm: &'a [u8], + mut types: wasmparser::TypeSectionReader<'a>, +) -> anyhow::Result<()> { + let info = stack.top_mut(); + info.add_raw_section(SectionId::Type, types.range(), full_wasm); + + // Parse out types, as we will need them later when processing + // instance imports. + let count = usize::try_from(types.get_count()).unwrap(); + info.types.reserve(count); + for _ in 0..count { + let ty = types.read()?; + match ty { + wasmparser::TypeDef::Func(_) | wasmparser::TypeDef::Instance(_) => { + info.types.push(ty); + } + wasmparser::TypeDef::Module(_) => Err(anyhow::anyhow!( + "wizer does not support importing or exporting modules" + ) + .context("module types are not supported"))?, + } + } + + Ok(()) +} + +fn import_section<'a>( + stack: &mut Vec>, + full_wasm: &'a [u8], + mut imports: wasmparser::ImportSectionReader<'a>, +) -> anyhow::Result<()> { + stack + .top_mut() + .add_raw_section(SectionId::Import, imports.range(), full_wasm); + + let mut instance_import_count = 0; + + // Check that we can properly handle all imports. + let count = imports.get_count(); + for _ in 0..count { + let imp = imports.read()?; + stack.top_mut().imports.push(imp); + check_import_type(&stack.top().types, stack.top().is_root(), &imp.ty)?; + + if imp.module.starts_with("__wizer_") + || imp.field.map_or(false, |f| f.starts_with("__wizer_")) + { + anyhow::bail!( + "input Wasm module already imports entities named with the `__wizer_*` prefix" + ); + } + + // Add the import to the appropriate index space for our current module. + match imp.ty { + wasmparser::ImportSectionEntryType::Memory(ty) => { + assert!(stack.top().defined_memories_index.is_none()); + stack.top_mut().memories.push(ty); + } + wasmparser::ImportSectionEntryType::Global(ty) => { + assert!(stack.top().defined_globals_index.is_none()); + stack.top_mut().globals.push(ty); + } + wasmparser::ImportSectionEntryType::Instance(ty_idx) => { + let info = stack.top_mut(); + let ty = match &info.types[usize::try_from(ty_idx).unwrap()] { + wasmparser::TypeDef::Instance(ty) => ty.clone(), + _ => unreachable!(), + }; + info.instances.push(ty); + instance_import_count += 1; + } + wasmparser::ImportSectionEntryType::Function(func_ty) => { + stack.top_mut().functions.push(func_ty); + } + wasmparser::ImportSectionEntryType::Table(ty) => { + stack.top_mut().tables.push(ty); + } + + wasmparser::ImportSectionEntryType::Module(_) => { + unreachable!("should have been rejected by `check_import_type`") + } + wasmparser::ImportSectionEntryType::Event(_) => { + unreachable!("should have been rejected by validation") + } + } + } + + stack + .top_mut() + .instance_import_counts + .push(instance_import_count); + + Ok(()) +} + +fn check_import_type( + types: &[wasmparser::TypeDef], + is_root: bool, + ty: &wasmparser::ImportSectionEntryType, +) -> Result<()> { + match ty { + wasmparser::ImportSectionEntryType::Module(_) => { + // We need to disallow module imports, even within nested modules + // that only ever have other nested modules supplied as + // arguments. Two different modules could be supplied for two + // different instantiations of the module-importing module, but then + // after we export all modules' globals in our instrumentation + // phase, those two different module arguments could become + // type-incompatible with each other: + // + // ``` + // (module + // + // ;; Module A exports and `f` function. Internally it has + // ;; one global. + // (module $A + // (global $g ...) + // (func (export "f") ...)) + // + // ;; Module B has an identical interface as A. Internally + // ;; it has two globals. + // (module $B + // (global $g ...) + // (global $h ...) + // (func (export "f") ...)) + // + // ;; Module C imports any module that exports an `f` + // ;; function. It instantiates this imported module. + // (module $C + // (import "env" "module" + // (module (export "f" (func))) + // (instance 0))) + // + // ;; C is instantiated with both A and B. + // (instance $C (import "env" "module" $A)) + // (instance $C (import "env" "module" $B)) + // ) + // ``` + // + // After this instrumentation pass, we need to make module C + // transitively export all of the globals from its inner + // instances. Which means that the module type used in the module + // import needs to specify how many modules are in the imported + // module, but in our two instantiations, we have two different + // numbers of globals defined in each module! The only way to + // resolve this would be to duplicate and specialize module C for + // each instantiation, which we don't want to do for complexity and + // code size reasons. + anyhow::bail!("imported modules are not supported by Wizer") + } + wasmparser::ImportSectionEntryType::Instance(inst_ty_index) => { + // We allow importing instances that only export things that are + // acceptable imports. This is equivalent to a two-layer import. + match &types[usize::try_from(*inst_ty_index).unwrap()] { + wasmparser::TypeDef::Instance(inst_ty) => { + for e in inst_ty.exports.iter() { + check_import_type(&types, is_root, &e.ty)?; + } + Ok(()) + } + _ => unreachable!(), + } + } + wasmparser::ImportSectionEntryType::Memory(mem_ty) => match mem_ty { + wasmparser::MemoryType::M32 { limits: _, shared } => { + anyhow::ensure!(!shared, "shared memories are not supported by Wizer yet"); + anyhow::ensure!( + !is_root, + "memory imports are not allowed in the root Wasm module" + ); + Ok(()) + } + wasmparser::MemoryType::M64 { .. } => { + anyhow::bail!("the memory64 proposal is not supported by Wizer yet") + } + }, + wasmparser::ImportSectionEntryType::Event(_) => { + unreachable!("validation should have rejected the exceptions proposal") + } + wasmparser::ImportSectionEntryType::Function(_) => Ok(()), + wasmparser::ImportSectionEntryType::Table(_) + | wasmparser::ImportSectionEntryType::Global(_) => { + anyhow::ensure!( + !is_root, + "table and global imports are not allowed in the root Wasm module" + ); + Ok(()) + } + } +} + +fn alias_section<'a>( + stack: &mut Vec>, + full_wasm: &'a [u8], + mut aliases: wasmparser::AliasSectionReader<'a>, +) -> anyhow::Result<()> { + stack + .top_mut() + .add_raw_section(SectionId::Alias, aliases.range(), full_wasm); + + // Clone any aliases over into this module's index spaces. + for _ in 0..aliases.get_count() { + let alias = aliases.read()?; + match &alias { + wasmparser::Alias::OuterType { + relative_depth, + index, + } => { + let relative_depth = usize::try_from(*relative_depth).unwrap(); + let index = usize::try_from(*index).unwrap(); + // NB: `- 2` rather than `- 1` because + // `relative_depth=0` means this module's immediate + // parent, not this module itself. + let ty = stack[stack.len() - 2 - relative_depth].types[index].clone(); + stack.top_mut().types.push(ty); + } + wasmparser::Alias::OuterModule { + relative_depth, + index, + } => { + let relative_depth = usize::try_from(*relative_depth).unwrap(); + let index = usize::try_from(*index).unwrap(); + // Ditto regarding `- 2`. + let module = stack[stack.len() - 2 - relative_depth].modules[index].clone(); + stack.top_mut().modules.push(module); + } + wasmparser::Alias::InstanceExport { + instance, + kind, + export, + } => match kind { + wasmparser::ExternalKind::Module => { + anyhow::bail!("exported modules are not supported yet") + } + wasmparser::ExternalKind::Instance => { + let info = stack.top_mut(); + let inst_ty_idx = match info.instance_export(*instance, export) { + Some(wasmparser::ImportSectionEntryType::Instance(i)) => i, + _ => unreachable!(), + }; + let inst_ty = match &info.types[usize::try_from(inst_ty_idx).unwrap()] { + wasmparser::TypeDef::Instance(ty) => ty.clone(), + _ => unreachable!(), + }; + info.instances.push(inst_ty); + } + wasmparser::ExternalKind::Function => { + let info = stack.top_mut(); + let func_ty_idx = match info.instance_export(*instance, export) { + Some(wasmparser::ImportSectionEntryType::Function(i)) => i, + _ => unreachable!(), + }; + info.functions.push(func_ty_idx); + } + wasmparser::ExternalKind::Table => { + let info = stack.top_mut(); + let table_ty = match info.instance_export(*instance, export) { + Some(wasmparser::ImportSectionEntryType::Table(ty)) => ty, + _ => unreachable!(), + }; + info.tables.push(table_ty); + } + wasmparser::ExternalKind::Memory => { + let info = stack.top_mut(); + assert!(info.defined_memories_index.is_none()); + let ty = match info.instance_export(*instance, export) { + Some(wasmparser::ImportSectionEntryType::Memory(ty)) => ty, + _ => unreachable!(), + }; + info.memories.push(ty); + } + wasmparser::ExternalKind::Global => { + let info = stack.top_mut(); + assert!(info.defined_globals_index.is_none()); + let ty = match info.instance_export(*instance, export) { + Some(wasmparser::ImportSectionEntryType::Global(ty)) => ty, + _ => unreachable!(), + }; + info.globals.push(ty); + } + wasmparser::ExternalKind::Event => { + unreachable!("validation should reject the exceptions proposal") + } + wasmparser::ExternalKind::Type => unreachable!("can't export types"), + }, + } + stack.top_mut().aliases.push(alias); + } + + Ok(()) +} + +fn instance_section<'a>( + stack: &mut Vec>, + full_wasm: &'a [u8], + mut instances: wasmparser::InstanceSectionReader<'a>, +) -> anyhow::Result<()> { + stack + .top_mut() + .add_raw_section(SectionId::Instance, instances.range(), full_wasm); + + // Record the instantiations made in this module, and which modules were + // instantiated. + let info = stack.top_mut(); + for _ in 0..instances.get_count() { + let inst = instances.read()?; + let module_index: usize = usize::try_from(inst.module()).unwrap(); + let module = &info.modules[module_index]; + let module_id = module.id; + let inst_ty = module.instance_type(); + + let mut import_args_reader = inst.args()?; + let import_args_count = usize::try_from(import_args_reader.get_count()).unwrap(); + let mut import_args = Vec::with_capacity(import_args_count); + for _ in 0..import_args_count { + import_args.push(import_args_reader.read()?); + } + + info.instantiations.insert( + u32::try_from(info.instances.len()).unwrap(), + (module_id, import_args), + ); + info.instances.push(inst_ty); + } + + Ok(()) +} + +fn function_section<'a>( + stack: &mut Vec>, + full_wasm: &'a [u8], + mut funcs: wasmparser::FunctionSectionReader<'a>, +) -> anyhow::Result<()> { + stack + .top_mut() + .add_raw_section(SectionId::Function, funcs.range(), full_wasm); + + let info = stack.top_mut(); + let count = usize::try_from(funcs.get_count()).unwrap(); + info.functions.reserve(count); + for _ in 0..count { + let ty = funcs.read()?; + info.functions.push(ty); + } + Ok(()) +} + +fn table_section<'a>( + stack: &mut Vec>, + full_wasm: &'a [u8], + mut tables: wasmparser::TableSectionReader<'a>, +) -> anyhow::Result<()> { + stack + .top_mut() + .add_raw_section(SectionId::Table, tables.range(), full_wasm); + + let info = stack.top_mut(); + let count = usize::try_from(tables.get_count()).unwrap(); + info.tables.reserve(count); + for _ in 0..count { + info.tables.push(tables.read()?); + } + Ok(()) +} + +fn memory_section<'a>( + stack: &mut Vec>, + full_wasm: &'a [u8], + mut mems: wasmparser::MemorySectionReader<'a>, +) -> anyhow::Result<()> { + let info = stack.top_mut(); + info.add_raw_section(SectionId::Memory, mems.range(), full_wasm); + + assert!(info.defined_memories_index.is_none()); + info.defined_memories_index = Some(u32::try_from(info.memories.len()).unwrap()); + + let count = usize::try_from(mems.get_count()).unwrap(); + info.memories.reserve(count); + for _ in 0..count { + let m = mems.read()?; + info.memories.push(m); + } + Ok(()) +} + +fn global_section<'a>( + stack: &mut Vec>, + full_wasm: &'a [u8], + mut globals: wasmparser::GlobalSectionReader<'a>, +) -> anyhow::Result<()> { + let info = stack.top_mut(); + info.add_raw_section(SectionId::Global, globals.range(), full_wasm); + + assert!(info.defined_globals_index.is_none()); + info.defined_globals_index = Some(u32::try_from(info.globals.len()).unwrap()); + + let count = usize::try_from(globals.get_count()).unwrap(); + info.globals.reserve(count); + for _ in 0..count { + let g = globals.read()?; + info.globals.push(g.ty); + } + + Ok(()) +} + +fn export_section<'a>( + stack: &mut Vec>, + full_wasm: &'a [u8], + mut exports: wasmparser::ExportSectionReader<'a>, +) -> anyhow::Result<()> { + stack + .top_mut() + .add_raw_section(SectionId::Export, exports.range(), full_wasm); + + let info = stack.top_mut(); + for _ in 0..exports.get_count() { + let export = exports.read()?; + + if export.field.starts_with("__wizer_") { + anyhow::bail!( + "input Wasm module already exports entities named with the `__wizer_*` prefix" + ); + } + + match export.kind { + wasmparser::ExternalKind::Module => { + anyhow::bail!("Wizer does not support importing and exporting modules") + } + wasmparser::ExternalKind::Type | wasmparser::ExternalKind::Event => { + unreachable!("checked in validation") + } + wasmparser::ExternalKind::Function + | wasmparser::ExternalKind::Table + | wasmparser::ExternalKind::Memory + | wasmparser::ExternalKind::Global + | wasmparser::ExternalKind::Instance => { + info.exports.push(export.clone()); + } + } + } + Ok(()) +} diff --git a/crates/wizer/src/rewrite.rs b/crates/wizer/src/rewrite.rs new file mode 100644 index 000000000000..82dde1614328 --- /dev/null +++ b/crates/wizer/src/rewrite.rs @@ -0,0 +1,1092 @@ +//! Final rewrite pass. + +mod renumbering; + +use crate::{info::ModuleInfo, snapshot::Snapshot, translate, FuncRenames, Wizer}; +use renumbering::Renumbering; +use std::{convert::TryFrom, iter}; +use wasm_encoder::SectionId; + +impl Wizer { + /// Given the initialized snapshot, rewrite the Wasm so that it is already + /// initialized. + /// + /// ## Code Shape + /// + /// With module linking, we rewrite each nested module into a *code module* + /// that doesn't define any internal state (i.e. memories, globals, and + /// nested instances) and imports a *state instance* that exports all of + /// these things instead. For each instantiation of a nested module, we have + /// a *state module* that defines the already-initialized state for that + /// instantiation, we instantiate that state module to create one such state + /// instance, and then use this as an import argument in the instantiation + /// of the original code module. This way, we do not duplicate shared code + /// bodies across multiple instantiations of the same module. + /// + /// Note that the root module is not split into a code module and state + /// instance. We can, essentially, assume that there is only one instance of + /// the root module, and rewrite it in place, without factoring the state + /// out into a separate instance. This is because the root is not allowed to + /// import any external state, so even if it were instantiated multiple + /// times, it would still end up in the same place anyways. (This is kinda + /// the whole reason why Wizer works at all.) + /// + /// For example, given this input Wasm module: + /// + /// ```wat + /// (module $A + /// (module $B + /// (memory $B_mem) + /// (global $B_glob (mut i32)) + /// (func (export "f") ...) + /// ) + /// + /// (instance $x (instantiate $B)) + /// (instance $y (instantiate $B)) + /// + /// (memory $A_mem) + /// (global $A_glob (mut i32)) + /// + /// (func (export "g") ...) + /// ) + /// ``` + /// + /// and some post-initialization state, this rewrite pass will produce the + /// following pre-initialized module: + /// + /// ```wat + /// (module $A + /// (module $B + /// ;; Locally defined state is replaced by a state instance import. + /// (import "__wizer_state" + /// (instance + /// (export "__wizer_memory_0" (memory $B_mem)) + /// (export "__wizer_global_0" (global $B_glob (mut i32))) + /// ) + /// ) + /// (func (export "f") ...) + /// ) + /// + /// ;; Instantiations are replaced with specialized state modules that get + /// ;; instantiated exactly once to produce state instances, and finally + /// ;; the original instantiations are rewritten into instantiations of + /// ;; the corresponding code module with the state instance as an import + /// ;; argument. + /// + /// ;; State module for `$x`. + /// (module $x_state_module + /// (memory (export "__wizer_memory_0") (memory)) + /// ;; Data segments to initialize the memory based on our snapshot + /// ;; would go here... + /// + /// (global (export "__wizer_global_0") + /// (global (mut i32) (i32.const (; ...snapshot's initialized value goes here... ;))) + /// ) + /// ) + /// + /// ;; State instance for `$x`. + /// (instance $x_state (instantiate $x_state_module)) + /// + /// ;; The instantiation of `$x` is now rewritten to use our state + /// ;; instance. + /// (instance $x (instantiate $B (import "__wizer_state" $x_state))) + /// + /// ;; Same goes for the `$y` instantiation. + /// (module $y_state_module + /// (memory (export "__wizer_memory_0") (memory)) + /// ;; Data segments... + /// (global (export "__wizer_global_0") + /// (global (mut i32) (i32.const (; ...snapshot's initialized value goes here... ;))) + /// ) + /// ) + /// (instance $y_state (instantiate $y_state_module)) + /// (instance $y (instantiate $B (import "__wizer_state" $y_state))) + /// + /// (memory $A_mem) + /// (global $A_glob (mut i32)) + /// ) + /// ``` + /// + /// ## Implementation + /// + /// To implement this transformation, we first do a pre-order walk of the + /// module tree and emit the code modules as a flat sequence. Why a flat + /// sequence? The code modules cannot contain nested instantiations, because + /// nested instantiations are state that is not necessarily shared across + /// all instantiations of the outer module. And if we are already lifting + /// out nested instantiations, we need to also make nested modules available + /// for those lifted instantiations, and the easiest way to do that is to + /// flatten the code module tree (as opposed to re-exporting the nested + /// modules under well-known symbols). The pre-order traversal ensures that + /// the `ModuleInfo::id` we assigned during the instrumentation phase + /// matches the module's place in the index space. The state modules, + /// however, remain a nested tree, and we emit them in a traversal of the + /// `Snapshot` instance tree. This is safe because, unlike code modules, + /// each state module is only instantiated exactly once. The instantiations' + /// references to nested modules become outer aliases pointing to the + /// module's position in the parent's flat sequence of nested modules. + pub(crate) fn rewrite( + &self, + snapshot: &Snapshot, + info: &ModuleInfo, + renames: &FuncRenames, + ) -> Vec { + log::debug!("Rewriting input Wasm to pre-initialized state"); + + let mut root = wasm_encoder::Module::new(); + + let types = make_complete_type_section(info); + root.section(&types); + + let mut id_to_module_info = vec![]; + make_id_to_module_info(&mut id_to_module_info, info); + + let (code_modules, num_code_modules) = rewrite_code_modules(info, &id_to_module_info); + // Only add the module section if there are multiple code modules, + // so that we avoid introducing the module section when module + // linking isn't in use. + if num_code_modules > 0 { + root.section(&code_modules); + + let state_modules = + rewrite_state_modules(info, &id_to_module_info, &snapshot.instantiations, 0); + root.section(&state_modules); + } + + self.rewrite_root(&mut root, info, snapshot, renames, num_code_modules); + + root.finish() + } + + fn rewrite_root( + &self, + root: &mut wasm_encoder::Module, + root_info: &ModuleInfo, + snapshot: &Snapshot, + renames: &FuncRenames, + num_code_modules: u32, + ) { + // Encode the initialized data segments from the snapshot rather + // than the original, uninitialized data segments. + let mut data_section = if snapshot.data_segments.is_empty() { + None + } else { + let mut data_section = wasm_encoder::DataSection::new(); + for seg in &snapshot.data_segments { + data_section.active( + seg.memory_index, + wasm_encoder::Instruction::I32Const(seg.offset as i32), + seg.data.iter().copied(), + ); + } + Some(data_section) + }; + + // There are multiple places were we potentially need to check whether + // we've added the data section already and if we haven't yet, then do + // so. For example, the original Wasm might not have a data section at + // all, and so we have to potentially add it at the end of iterating + // over the original sections. This closure encapsulates all that + // add-it-if-we-haven't-already logic in one place. + let mut add_data_section = |module: &mut wasm_encoder::Module| { + if let Some(data_section) = data_section.take() { + module.section(&data_section); + } + }; + + // A map from the original Wasm's instance numbering to the newly rewritten + // instance numbering. + let mut instance_renumbering = Renumbering::default(); + + let mut instance_import_counts = root_info.instance_import_counts.iter().copied(); + let mut instantiations = root_info.instantiations.values().enumerate(); + let mut aliases = root_info.aliases.iter(); + + for section in &root_info.raw_sections { + match section { + // Some tools expect the name custom section to come last, even + // though custom sections are allowed in any order. Therefore, + // make sure we've added our data section by now. + s if is_name_section(s) => { + add_data_section(root); + root.section(s); + } + + s if s.id == SectionId::Custom.into() => { + root.section(s); + } + + // These were already added in `make_complete_type_section`. + s if s.id == SectionId::Type.into() => { + continue; + } + + // These were already taken care of in `rewrite_code_modules`. + s if s.id == SectionId::Module.into() => { + continue; + } + + // Import sections are just copied over, but we additionally + // must make sure that our count of how many instances are + // currently in this module's instance export space and map from + // old instance numbering to new instance numbering are + // correctly updated for any instances that were imported in + // this section. + s if s.id == SectionId::Import.into() => { + root.section(s); + + let instance_import_count = instance_import_counts.next().unwrap(); + for _ in 0..instance_import_count { + instance_renumbering.add_import(); + } + } + + // Instantiations from the original Wasm become two + // instantiations in the rewritten Wasm: + // + // 1. First, we instantiate the state module for this instance + // to create the rewritten state instance. + // + // 2. Then, we instantiate this instance's code module, passing + // it the state instance and any other import arguments it + // originally had. This, finally, is the rewritten version of + // the original instance. + // + // Because there are two instances, where previously there was + // one, we are forced to renumber the instance index space. + s if s.id == SectionId::Instance.into() => { + let mut instances = wasm_encoder::InstanceSection::new(); + let count = wasmparser::InstanceSectionReader::new(s.data, 0) + .unwrap() + .get_count(); + for (nth_defined_inst, (module_id, instance_args)) in instantiations + .by_ref() + .take(usize::try_from(count).unwrap()) + { + // Instantiate the state module. + let args: Vec<_> = instance_args + .iter() + .map(|arg| { + let mut arg = translate::instance_arg(arg); + if let (_name, wasm_encoder::Export::Instance(ref mut index)) = arg + { + *index = instance_renumbering.lookup(*index); + } + arg + }) + .collect(); + instances.instantiate( + num_code_modules + u32::try_from(nth_defined_inst).unwrap(), + args, + ); + let state_instance_index = instance_renumbering.define_new(); + + // Instantiate the code module with our state instance + // and the original import arguments. + let args: Vec<_> = iter::once(( + "__wizer_state", + wasm_encoder::Export::Instance(state_instance_index), + )) + .chain(instance_args.iter().map(|arg| { + let mut arg = translate::instance_arg(arg); + if let (_name, wasm_encoder::Export::Instance(ref mut index)) = arg { + *index = instance_renumbering.lookup(*index); + } + arg + })) + .collect(); + instances.instantiate(module_id - 1, args); + instance_renumbering.define_both(); + } + root.section(&instances); + } + + // For the alias section, we update instance export aliases to + // use the new instance numbering. + s if s.id == SectionId::Alias.into() => { + let count = wasmparser::AliasSectionReader::new(s.data, 0) + .unwrap() + .get_count(); + let mut section = wasm_encoder::AliasSection::new(); + for alias in aliases.by_ref().take(usize::try_from(count).unwrap()) { + match alias { + wasmparser::Alias::InstanceExport { + instance, + kind, + export, + } => { + section.instance_export( + instance_renumbering.lookup(*instance), + translate::item_kind(*kind), + export, + ); + // If this brought a new instance into our + // instance index space, update our renumbering + // map. + if let wasmparser::ExternalKind::Instance = kind { + instance_renumbering.add_alias(); + } + } + wasmparser::Alias::OuterType { .. } + | wasmparser::Alias::OuterModule { .. } => { + unreachable!( + "the root can't alias any outer entities because there are \ + no entities outside the root module" + ) + } + } + } + root.section(§ion); + } + + s if s.id == SectionId::Function.into() => { + root.section(s); + } + + s if s.id == SectionId::Table.into() => { + root.section(s); + } + + // For the memory section, we update the minimum size of each + // defined memory to the snapshot's initialized size for that + // memory. + s if s.id == SectionId::Memory.into() => { + let mut memories = wasm_encoder::MemorySection::new(); + assert_eq!(root_info.defined_memories_len(), snapshot.memory_mins.len()); + for (mem, new_min) in root_info + .defined_memories() + .zip(snapshot.memory_mins.iter().copied()) + { + let mut mem = translate::memory_type(mem); + mem.limits.min = new_min; + memories.memory(mem); + } + root.section(&memories); + } + + // Encode the initialized global values from the snapshot, + // rather than the original values. + s if s.id == SectionId::Global.into() => { + let mut globals = wasm_encoder::GlobalSection::new(); + for (glob_ty, val) in root_info.defined_globals().zip(snapshot.globals.iter()) { + let glob_ty = translate::global_type(glob_ty); + globals.global( + glob_ty, + match val { + wasmtime::Val::I32(x) => wasm_encoder::Instruction::I32Const(*x), + wasmtime::Val::I64(x) => wasm_encoder::Instruction::I64Const(*x), + wasmtime::Val::F32(x) => { + wasm_encoder::Instruction::F32Const(f32::from_bits(*x)) + } + wasmtime::Val::F64(x) => { + wasm_encoder::Instruction::F64Const(f64::from_bits(*x)) + } + _ => unreachable!(), + }, + ); + } + root.section(&globals); + } + + // Remove the initialization function's export and perform any + // requested renames. + s if s.id == SectionId::Export.into() => { + let mut exports = wasm_encoder::ExportSection::new(); + for export in &root_info.exports { + if export.field == self.init_func { + continue; + } + + if !renames.rename_src_to_dst.contains_key(export.field) + && renames.rename_dsts.contains(export.field) + { + // A rename overwrites this export, and it is not + // renamed to another export, so skip it. + continue; + } + + let field = renames + .rename_src_to_dst + .get(export.field) + .map_or(export.field, |f| f.as_str()); + + let mut export = translate::export(export.kind, export.index); + if let wasm_encoder::Export::Instance(ref mut index) = export { + *index = instance_renumbering.lookup(*index); + } + + exports.export(field, export); + } + root.section(&exports); + } + + // Skip the `start` function -- it's already been run! + s if s.id == SectionId::Start.into() => { + continue; + } + + s if s.id == SectionId::Element.into() => { + root.section(s); + } + + s if s.id == SectionId::Data.into() => { + // TODO: supporting bulk memory will require copying over + // any passive and declared segments. + add_data_section(root); + } + + s if s.id == SectionId::Code.into() => { + root.section(s); + } + + _ => unreachable!(), + } + } + + // Make sure that we've added our data section to the module. + add_data_section(root); + } +} + +fn is_name_section(s: &wasm_encoder::RawSection) -> bool { + s.id == SectionId::Custom.into() && { + let mut reader = wasmparser::BinaryReader::new(s.data); + matches!(reader.read_string(), Ok("name")) + } +} + +/// Rewrite nested modules into a flat sequence, and where they import their +/// state, rather than define it locally. +/// +/// Returns the modules encoded in a module section and total number of code +/// modules defined. +fn rewrite_code_modules( + root_info: &ModuleInfo, + id_to_module_info: &Vec<&ModuleInfo>, +) -> (wasm_encoder::ModuleSection, u32) { + let mut modules = wasm_encoder::ModuleSection::new(); + let mut num_code_modules = 0; + + root_info.pre_order(|info| { + // The root module is handled by `rewrite_root`; we are only dealing + // with nested children here. + if info.is_root() { + return; + } + + let mut module = wasm_encoder::Module::new(); + + // We generally try to avoid renumbering entities in Wizer -- + // particularly any entities referenced from the code section, where + // renumbering could change the size of a LEB128 index and break DWARF + // debug info offsets -- because it means we can't copy whole sections + // from the original, input Wasm module. But we run into a conflicting + // constraints here with regards to instances: + // + // 1. Ideally we would import our state instance last, so that we don't + // perturb with our instance index space. + // + // 2. Locally-defined instances are state, and therefore must be pulled + // out of these code modules into our imported state instance, and + // then referenced via alias. + // + // (1) and (2) are in conflict because we can't create aliases of + // instances on the imported state instance until *after* the state + // instance is imported, which means we need to import our state + // instance first, which means we are forced to perturb the instance + // index space. + // + // Therefore, the first thing we add to each code module is an import + // section that imports the state instance. We need to explicitly + // rewrite all references to these instances (e.g. instance export + // aliases) to add one to their index so that they refer to the correct + // instance again. Luckily instances are never referenced from the code + // section, so DWARF debug info doesn't get invalidated. + // + // Finally, importing the state instance requires that we define the + // state instance's type. We really don't want to renumber types because + // those *are* referenced from the code section via `call_indirect`. To + // avoid renumbering types, we do a first pass over this module's types + // and build out a full type section with the same numbering as the + // original module, and then append the state import's type at the end. + let mut types = make_complete_type_section(info); + let import = make_state_import(info, &mut types, id_to_module_info); + module.section(&types); + module.section(&import); + + // Now rewrite the initial sections one at a time. + // + // Note that the initial sections can occur repeatedly and in any + // order. This means that we only ever add, for example, `n` imports to + // the rewritten module when a particular import section defines `n` + // imports. We do *not* add all imports all at once. This is because + // imports and aliases might be interleaved, and adding all imports all + // at once could perturb entity numbering. + let mut sections = info.raw_sections.iter(); + let mut imports = info.imports.iter(); + let mut instantiations = 0..info.instantiations.len(); + let mut aliases = info.aliases.iter(); + let mut first_non_initial_section = None; + for section in sections.by_ref() { + match section { + // We handled this in `make_complete_type_section` above. + s if s.id == SectionId::Type.into() => continue, + + // These are handled in subsequent steps of this pre-order + // traversal. + s if s.id == SectionId::Module.into() => continue, + + s if s.id == SectionId::Import.into() => { + let count = wasmparser::ImportSectionReader::new(s.data, 0) + .unwrap() + .get_count(); + let mut section = wasm_encoder::ImportSection::new(); + for imp in imports.by_ref().take(usize::try_from(count).unwrap()) { + section.import(imp.module, imp.field, translate::entity_type(imp.ty)); + } + module.section(§ion); + } + + // The actual instantiations are pulled out and handled in + // `rewrite_instantiations` and then we get them here via the + // state import. We need to bring them into scope via instance + // export aliases, however. + s if s.id == SectionId::Instance.into() => { + let count = wasmparser::InstanceSectionReader::new(s.data, 0) + .unwrap() + .get_count(); + let mut section = wasm_encoder::AliasSection::new(); + for idx in instantiations + .by_ref() + .take(usize::try_from(count).unwrap()) + { + // Our imported state instance is always instance 0. + let from_instance = 0; + let name = format!("__wizer_instance_{}", idx); + section.instance_export( + from_instance, + wasm_encoder::ItemKind::Instance, + &name, + ); + } + module.section(§ion); + } + + s if s.id == SectionId::Alias.into() => { + let count = wasmparser::AliasSectionReader::new(s.data, 0) + .unwrap() + .get_count(); + let mut section = wasm_encoder::AliasSection::new(); + for alias in aliases.by_ref().take(usize::try_from(count).unwrap()) { + match alias { + // We don't make any instantiations so we don't need + // modules here anymore. + wasmparser::Alias::OuterModule { .. } => continue, + // We already created a complete type section, + // including any aliases, above. + wasmparser::Alias::OuterType { .. } => continue, + // Copy over instance export aliases. + // however. + wasmparser::Alias::InstanceExport { + instance, + kind, + export, + } => { + // We need to add one to the instance's index + // because our state instance import shifted + // everything off by one. + let from_instance = instance + 1; + section.instance_export( + from_instance, + translate::item_kind(*kind), + export, + ); + } + } + } + module.section(§ion); + } + + s => { + assert!(first_non_initial_section.is_none()); + first_non_initial_section = Some(s); + break; + } + } + } + + // We don't define the memories from the original memory section, but we + // do add instance export aliases for each of them from our imported + // state instance. These aliases need to be in an alias section, which + // is an initial section and must come before the rest of the + // non-initial sections. But it must also come *after* any memories that + // might have been imported, so that we don't mess up the + // numbering. Therefore we add these aliases here, after we've processed + // the initial sections, but before we start with the rest of the + // sections. + if let Some(defined_memories_index) = info.defined_memories_index { + let mut section = wasm_encoder::AliasSection::new(); + let num_defined_memories = + info.memories.len() - usize::try_from(defined_memories_index).unwrap(); + for mem in 0..num_defined_memories { + // Our state instance is always instance 0. + let from_instance = 0; + let name = format!("__wizer_memory_{}", mem); + section.instance_export(from_instance, wasm_encoder::ItemKind::Memory, &name); + } + module.section(§ion); + } + + // Globals are handled the same way as memories. + if let Some(defined_globals_index) = info.defined_globals_index { + let mut section = wasm_encoder::AliasSection::new(); + let num_defined_globals = + info.globals.len() - usize::try_from(defined_globals_index).unwrap(); + for mem in 0..num_defined_globals { + // Our state instance is always instance 0. + let from_instance = 0; + let name = format!("__wizer_global_{}", mem); + section.instance_export(from_instance, wasm_encoder::ItemKind::Global, &name); + } + module.section(§ion); + } + + // Process the rest of the non-initial sections. + for section in first_non_initial_section.into_iter().chain(sections) { + match section { + // We replaced these with instance export aliases from our state + // instance above. + s if s.id == SectionId::Memory.into() => continue, + s if s.id == SectionId::Global.into() => continue, + + // We ignore the original data segments. We don't define + // memories anymore and state instances will define their own + // data segments based on the snapshot. + s if s.id == SectionId::Data.into() => continue, + s if s.id == SectionId::DataCount.into() => continue, + + // The start function has already been run! + s if s.id == SectionId::Start.into() => continue, + + // Finally, everything else is copied over as-is! + s => { + module.section(s); + } + } + } + + modules.module(&module); + num_code_modules += 1; + }); + + (modules, num_code_modules) +} + +/// Flatten the `ModuleInfo` tree into a vector that maps each module id +/// (i.e. pre-order index) to the associated module info. +fn make_id_to_module_info<'a>(id_to_info: &mut Vec<&'a ModuleInfo<'a>>, info: &'a ModuleInfo<'a>) { + debug_assert_eq!(u32::try_from(id_to_info.len()).unwrap(), info.id); + id_to_info.push(info); + for m in &info.modules { + make_id_to_module_info(id_to_info, m); + } +} + +/// Make a single complete type section for the given module info, regardless of +/// how many initial type sections these types might have been defined within in +/// the original module's serialization. +fn make_complete_type_section(info: &ModuleInfo) -> wasm_encoder::TypeSection { + let mut types = wasm_encoder::TypeSection::new(); + for ty in &info.types { + match ty { + wasmparser::TypeDef::Func(func_ty) => { + types.function( + func_ty.params.iter().map(|ty| translate::val_type(*ty)), + func_ty.returns.iter().map(|ty| translate::val_type(*ty)), + ); + } + wasmparser::TypeDef::Instance(inst_ty) => { + types.instance( + inst_ty + .exports + .iter() + .map(|e| (e.name, translate::entity_type(e.ty))), + ); + } + wasmparser::TypeDef::Module(_) => { + unreachable!( + "we don't support importing/exporting modules so don't have to deal \ + with module types" + ) + } + } + } + types +} + +/// Make an import section that imports a code module's state instance import. +fn make_state_import( + info: &ModuleInfo, + types: &mut wasm_encoder::TypeSection, + id_to_module_info: &Vec<&ModuleInfo>, +) -> wasm_encoder::ImportSection { + let mut num_types = u32::try_from(info.types.len()).unwrap(); + + // Define instance types for each of the instances that we + // previously instantiated locally so that we can refer to + // these types in the state instance's type. + let instance_types = info + .instantiations + .values() + .map(|(m, _)| { + id_to_module_info[usize::try_from(*m).unwrap()] + .define_instance_type(&mut num_types, types) + }) + .collect::>(); + + // Define the state instance's type. + let state_instance_exports = info + .defined_globals() + .enumerate() + .map(|(i, g)| { + ( + format!("__wizer_global_{}", i), + wasm_encoder::EntityType::Global(translate::global_type(g)), + ) + }) + .chain(info.defined_memories().enumerate().map(|(i, m)| { + ( + format!("__wizer_memory_{}", i), + wasm_encoder::EntityType::Memory(translate::memory_type(m)), + ) + })) + .chain(instance_types.iter().enumerate().map(|(i, type_index)| { + ( + format!("__wizer_instance_{}", i), + wasm_encoder::EntityType::Instance(*type_index), + ) + })) + .collect::>(); + let state_instance_type_index = num_types; + types.instance( + state_instance_exports + .iter() + .map(|(name, e)| (name.as_str(), *e)), + ); + + // Define the import of the state instance, using the type + // we just defined. + let mut imports = wasm_encoder::ImportSection::new(); + imports.import( + "__wizer_state", + None, + wasm_encoder::EntityType::Instance(state_instance_type_index), + ); + imports +} + +/// Define the state modules for each instantiation. +/// +/// These are modules that just define the memories/globals/nested instances of +/// a particular instantiation and initialize them to the snapshot's state. They +/// have no imports and export all of their internal state entities. +/// +/// This does *not* instantiate the state modules in the resulting module +/// section, just defines them (although nested state modules within these top +/// level-state modules are instantiated inside these top-level state +/// modules). That is because instantiation is handled differently depending on +/// if the instantiation happens directly inside the root module (see the +/// handling of instance sections in `rewrite_root`) or in a deeply nested +/// module (in which case it is instantiated by its parent state module, +/// i.e. another recursive invocation of this function that is one frame up the +/// stack). +fn rewrite_state_modules( + info: &ModuleInfo, + id_to_module_info: &Vec<&ModuleInfo>, + snapshots: &[Snapshot], + depth: u32, +) -> wasm_encoder::ModuleSection { + let mut modules = wasm_encoder::ModuleSection::new(); + + assert_eq!(snapshots.len(), info.instantiations.len()); + for (snapshot, (module_id, _)) in snapshots.iter().zip(info.instantiations.values()) { + let module_info = &id_to_module_info[usize::try_from(*module_id).unwrap()]; + let state_module = + rewrite_one_state_module(module_info, id_to_module_info, snapshot, depth); + modules.module(&state_module); + } + + modules +} + +fn rewrite_one_state_module( + info: &ModuleInfo, + id_to_module_info: &Vec<&ModuleInfo>, + snapshot: &Snapshot, + depth: u32, +) -> wasm_encoder::Module { + let mut state_module = wasm_encoder::Module::new(); + let mut exports = wasm_encoder::ExportSection::new(); + + // If there are nested instantiations, then define the nested state + // modules and then instantiate them. + assert_eq!(info.instantiations.len(), snapshot.instantiations.len()); + if !snapshot.instantiations.is_empty() { + // We create nested instantiations such that each state module has + // the following module index space: + // + // [ + // alias instantiation[0]'s code module, + // alias instantiation[1]'s code module, + // ... + // alias instantiation[N]'s code module, + // define instantiation[0]'s state module, + // define instantiation[1]'s state module, + // ... + // define instantiation[N]'s state module, + // ] + // + // That is, the `i`th nested instantiation's code module is the `i`th + // module in the index space, and its state module is at index `N+i`. + // + // The instance index space is more complicated because of potential + // instance imports and aliasing imported instance's exported nested + // instances. These imported/aliased instances can then be used as + // arguments to a nested instantiation, and then the resulting instance + // can also be used as an argument to further nested instantiations. To + // handle all this, we use a `Renumbering` map for tracking instance + // indices. + let mut instance_renumbering = Renumbering::default(); + + let types = make_complete_type_section(&info); + state_module.section(&types); + + let mut instance_import_counts = info.instance_import_counts.iter().copied(); + let mut aliases = info.aliases.iter(); + let mut instantiations = info.instantiations.values().enumerate(); + + for section in info.initial_sections() { + match section { + // Handled by `make_complete_type_section` above. + s if s.id == SectionId::Type.into() => continue, + + // Copy the imports over and update our renumbering for any + // imported instances. + s if s.id == SectionId::Import.into() => { + state_module.section(s); + let instance_import_count = instance_import_counts.next().unwrap(); + for _ in 0..instance_import_count { + instance_renumbering.add_import(); + } + } + + // Update instance export aliases to use the numbered instance + // indices. Also update the renumbering for any aliased + // instances brought into scope. + s if s.id == SectionId::Alias.into() => { + let count = wasmparser::AliasSectionReader::new(s.data, 0) + .unwrap() + .get_count(); + let mut section = wasm_encoder::AliasSection::new(); + for alias in aliases.by_ref().take(usize::try_from(count).unwrap()) { + match alias { + wasmparser::Alias::InstanceExport { + instance, + kind, + export, + } => { + section.instance_export( + instance_renumbering.lookup(*instance), + translate::item_kind(*kind), + export, + ); + // If this brought a new instance into our + // instance index space, update our renumbering + // map. + if let wasmparser::ExternalKind::Instance = kind { + instance_renumbering.add_alias(); + } + } + // Handled by `make_complete_type_section`. + wasmparser::Alias::OuterType { .. } => continue, + // Ignore these because we alias only the modules we + // need for nested instantiations below. + wasmparser::Alias::OuterModule { .. } => continue, + } + } + state_module.section(§ion); + } + + // We alias only the modules we need for nested instantiations + // below. + s if s.id == SectionId::Module.into() => continue, + + // For each nested instantiation in this section, alias its code + // module, define its state module, instantiate the state module + // to create the state instance, instantiate the code module + // with the state instance, and finally export the code+state + // instance. + s if s.id == SectionId::Instance.into() => { + let count = wasmparser::InstanceSectionReader::new(s.data, 0) + .unwrap() + .get_count(); + let mut alias_section = wasm_encoder::AliasSection::new(); + let mut instance_section = wasm_encoder::InstanceSection::new(); + let mut module_section = wasm_encoder::ModuleSection::new(); + for (i, (module_id, instance_args)) in instantiations + .by_ref() + .take(usize::try_from(count).unwrap()) + { + // Alias this instantiation's code module. + // + // Because we flatten the code modules into the root + // with a pre-order traversal, the module id is the + // module's pre-order index, and the root module is not + // in the flattened list, this instantiation's code + // module is the `module_id - 1`th module in the root + // module's module index space. + let root_module_index = *module_id - 1; + alias_section.outer_module(depth, root_module_index); + + // Define the state module for this instantiation. + let state_module = rewrite_one_state_module( + id_to_module_info[usize::try_from(*module_id).unwrap()], + id_to_module_info, + &snapshot.instantiations[i], + depth + 1, + ); + module_section.module(&state_module); + + // Instantiate the state module to create the state + // instance. + let args: Vec<_> = instance_args + .iter() + .map(|arg| { + let mut arg = translate::instance_arg(arg); + if let (_name, wasm_encoder::Export::Instance(ref mut index)) = arg + { + *index = instance_renumbering.lookup(*index); + } + arg + }) + .collect(); + instance_section.instantiate( + u32::try_from(snapshot.instantiations.len() + i).unwrap(), + args, + ); + let state_instance_index = instance_renumbering.define_new(); + + // Then instantiate the associated code module, passing it this + // state instance and whatever other arguments it expects. + let args: Vec<_> = iter::once(( + "__wizer_state", + wasm_encoder::Export::Instance(state_instance_index), + )) + .chain(instance_args.iter().map(|arg| { + let mut arg = translate::instance_arg(arg); + if let (_name, wasm_encoder::Export::Instance(ref mut index)) = arg { + *index = instance_renumbering.lookup(*index); + } + arg + })) + .collect(); + instance_section.instantiate(u32::try_from(i).unwrap(), args); + let (_, code_and_state_instance_index) = instance_renumbering.define_both(); + + // Add the export for this nested instance. + let name = format!("__wizer_instance_{}", i); + exports.export( + &name, + wasm_encoder::Export::Instance( + u32::try_from(code_and_state_instance_index).unwrap(), + ), + ); + } + state_module.section(&alias_section); + state_module.section(&module_section); + state_module.section(&instance_section); + } + + _ => unreachable!(), + } + } + } + + // Add defined memories. + assert_eq!(info.defined_memories_len(), snapshot.memory_mins.len()); + if info.defined_memories_index.is_some() { + let mut memories = wasm_encoder::MemorySection::new(); + for (i, (new_min, mem)) in snapshot + .memory_mins + .iter() + .copied() + .zip(info.defined_memories()) + .enumerate() + { + let mut mem = translate::memory_type(mem); + assert!(new_min >= mem.limits.min); + assert!(new_min <= mem.limits.max.unwrap_or(u32::MAX)); + mem.limits.min = new_min; + memories.memory(mem); + + let name = format!("__wizer_memory_{}", i); + exports.export( + &name, + wasm_encoder::Export::Memory(u32::try_from(i).unwrap()), + ); + } + state_module.section(&memories); + } + + // Add defined globals. + assert_eq!(info.defined_globals_len(), snapshot.globals.len()); + if info.defined_globals_index.is_some() { + let mut globals = wasm_encoder::GlobalSection::new(); + for (i, (val, glob_ty)) in snapshot + .globals + .iter() + .zip(info.defined_globals()) + .enumerate() + { + let glob_ty = translate::global_type(glob_ty); + globals.global( + glob_ty, + match val { + wasmtime::Val::I32(x) => wasm_encoder::Instruction::I32Const(*x), + wasmtime::Val::I64(x) => wasm_encoder::Instruction::I64Const(*x), + wasmtime::Val::F32(x) => { + wasm_encoder::Instruction::F32Const(f32::from_bits(*x)) + } + wasmtime::Val::F64(x) => { + wasm_encoder::Instruction::F64Const(f64::from_bits(*x)) + } + _ => unreachable!(), + }, + ); + + let name = format!("__wizer_global_{}", i); + exports.export( + &name, + wasm_encoder::Export::Global(u32::try_from(i).unwrap()), + ); + } + state_module.section(&globals); + } + + state_module.section(&exports); + + // Add data segments. + if !snapshot.data_segments.is_empty() { + let mut data = wasm_encoder::DataSection::new(); + for seg in &snapshot.data_segments { + data.active( + seg.memory_index, + wasm_encoder::Instruction::I32Const(seg.offset as i32), + seg.data.iter().copied(), + ); + } + state_module.section(&data); + } + + state_module +} diff --git a/crates/wizer/src/rewrite/renumbering.rs b/crates/wizer/src/rewrite/renumbering.rs new file mode 100644 index 000000000000..1d17017f0636 --- /dev/null +++ b/crates/wizer/src/rewrite/renumbering.rs @@ -0,0 +1,57 @@ +use std::convert::TryFrom; + +/// A renumbering of indices. +/// +/// Keeps track of which indices in the original Wasm map to which indices in +/// the rewritten Wasm. +/// +/// Only supports injective renumberings: every old index has a corresponding +/// unique new index, but each new index does not need to have a corresponding +/// old index. +#[derive(Default, Debug)] +pub struct Renumbering { + old_count: u32, + new_count: u32, + old_to_new: Vec, +} + +impl Renumbering { + /// Define an entry in both the old and new index spaces. Returns a tuple of + /// the old and new indices. + pub fn define_both(&mut self) -> (u32, u32) { + debug_assert_eq!( + self.old_to_new.len(), + usize::try_from(self.old_count).unwrap() + ); + self.old_to_new.push(self.new_count); + self.old_count += 1; + self.new_count += 1; + (self.old_count - 1, self.new_count - 1) + } + + /// Add an import to both the old and new index spaces. Returns a tuple of + /// the old and new indices. + pub fn add_import(&mut self) -> (u32, u32) { + self.define_both() + } + + /// Add an alias to both the old and new index spaces. Returns a tuple of + /// the old and new indices. + pub fn add_alias(&mut self) -> (u32, u32) { + self.define_both() + } + + /// Add an entry to the new index space. Returns the entry's index in the + /// new index space. + pub fn define_new(&mut self) -> u32 { + self.new_count += 1; + self.new_count - 1 + } + + /// Get the new index for the given old index. + /// + /// Panics when `old` is not in the old index space. + pub fn lookup(&self, old: u32) -> u32 { + self.old_to_new[usize::try_from(old).unwrap()] + } +} diff --git a/crates/wizer/src/snapshot.rs b/crates/wizer/src/snapshot.rs new file mode 100644 index 000000000000..e6aa0c1b2790 --- /dev/null +++ b/crates/wizer/src/snapshot.rs @@ -0,0 +1,185 @@ +use rayon::iter::{IntoParallelIterator, ParallelExtend, ParallelIterator}; +use std::convert::TryFrom; + +const WASM_PAGE_SIZE: u32 = 65_536; +const NATIVE_PAGE_SIZE: u32 = 4_096; + +/// A "snapshot" of Wasm state from its default value after having been initialized. +pub struct Snapshot<'a> { + /// Maps global index to its initialized value. + pub globals: Vec, + + /// A new minimum size for each memory (in units of pages). + pub memory_mins: Vec, + + /// Segments of non-zero memory. + pub data_segments: Vec>, + + /// Snapshots for each nested instantiation. + pub instantiations: Vec>, +} + +/// A data segment initializer for a memory. +pub struct DataSegment<'a> { + /// The index of this data segment's memory. + pub memory_index: u32, + /// The offset within the memory that `data` should be copied to. + pub offset: u32, + /// This segment's (non-zero) data. + pub data: &'a [u8], +} + +/// Snapshot the given instance's globals, memories, and instances from the Wasm +/// defaults. +// +// TODO: when we support reference types, we will have to snapshot tables. +pub fn snapshot<'a>(store: &'a wasmtime::Store, instance: &wasmtime::Instance) -> Snapshot<'a> { + log::debug!("Snapshotting the initialized state"); + + assert!(wasmtime::Store::same(store, &instance.store())); + + let globals = snapshot_globals(instance); + let (memory_mins, data_segments) = snapshot_memories(instance); + let instantiations = snapshot_instantiations(store, instance); + + Snapshot { + globals, + memory_mins, + data_segments, + instantiations, + } +} + +/// Get the initialized values of all globals. +fn snapshot_globals(instance: &wasmtime::Instance) -> Vec { + log::debug!("Snapshotting global values"); + let mut globals = vec![]; + let mut index = 0; + loop { + let name = format!("__wizer_global_{}", index); + match instance.get_global(&name) { + None => break, + Some(global) => { + globals.push(global.get()); + index += 1; + } + } + } + globals +} + +/// Find the initialized minimum page size of each memory, as well as all +/// regions of non-zero memory. +fn snapshot_memories<'a>(instance: &wasmtime::Instance) -> (Vec, Vec>) { + log::debug!("Snapshotting memories"); + + // Find and record non-zero regions of memory (in parallel). + let mut memory_mins = vec![]; + let mut data_segments = vec![]; + let mut memory_index = 0; + loop { + let name = format!("__wizer_memory_{}", memory_index); + match instance.get_memory(&name) { + None => break, + Some(memory) => { + memory_mins.push(memory.size()); + + let num_wasm_pages = memory.size(); + let num_native_pages = num_wasm_pages * (WASM_PAGE_SIZE / NATIVE_PAGE_SIZE); + + let memory: &'a [u8] = unsafe { + // Safe because no one else has a (potentially mutable) + // view to this memory and we know the memory will live + // as long as the store is alive. + std::slice::from_raw_parts(memory.data_ptr(), memory.data_size()) + }; + + // Consider each "native" page of the memory. (Scare quotes + // because we have no guarantee that anyone isn't using huge + // page sizes or something). Process each page in + // parallel. If any byte has changed, add the whole page as + // a data segment. This means that the resulting Wasm module + // should instantiate faster, since there are fewer segments + // to bounds check on instantiation. Engines could even + // theoretically recognize that each of these segments is + // page sized and aligned, and use lazy copy-on-write + // initialization of each instance's memory. + data_segments.par_extend((0..num_native_pages).into_par_iter().filter_map(|i| { + let start = i * NATIVE_PAGE_SIZE; + let end = ((i + 1) * NATIVE_PAGE_SIZE) as usize; + let page = &memory[start as usize..end]; + for byte in page { + if *byte != 0 { + return Some(DataSegment { + memory_index, + offset: start as u32, + data: page, + }); + } + } + None + })); + + memory_index += 1; + } + } + } + + // Sort data segments to enforce determinism in the face of the + // parallelism above. + data_segments.sort_by_key(|s| (s.memory_index, s.offset)); + + // Merge any contiguous pages, so that the engine can initialize them + // all at once (ideally with a single copy-on-write `mmap`) rather than + // initializing each data segment individually. + for i in (1..data_segments.len()).rev() { + let a = &data_segments[i - 1]; + let b = &data_segments[i]; + + // Only merge segments for the same memory. + if a.memory_index != b.memory_index { + continue; + } + + // Only merge segments if they are contiguous. + if a.offset + u32::try_from(a.data.len()).unwrap() != b.offset { + continue; + } + + // Okay, merge them together into `a` (so that the next iteration + // can merge it with its predecessor) and then remove `b`! + data_segments[i - 1].data = unsafe { + debug_assert_eq!( + a.data + .as_ptr() + .offset(isize::try_from(a.data.len()).unwrap()), + b.data.as_ptr() + ); + std::slice::from_raw_parts(a.data.as_ptr(), a.data.len() + b.data.len()) + }; + data_segments.remove(i); + } + + (memory_mins, data_segments) +} + +fn snapshot_instantiations<'a>( + store: &'a wasmtime::Store, + instance: &wasmtime::Instance, +) -> Vec> { + log::debug!("Snapshotting nested instantiations"); + let mut instantiations = vec![]; + let mut index = 0; + loop { + let name = format!("__wizer_instance_{}", index); + match instance.get_export(&name) { + None => break, + Some(wasmtime::Extern::Instance(instance)) => { + instantiations.push(snapshot(store, &instance)); + index += 1; + } + Some(_) => unreachable!(), + } + } + instantiations +} diff --git a/crates/wizer/src/stack_ext.rs b/crates/wizer/src/stack_ext.rs new file mode 100644 index 000000000000..e5ec5a0382ac --- /dev/null +++ b/crates/wizer/src/stack_ext.rs @@ -0,0 +1,16 @@ +/// An extension trait for getting the top element on a stack with an implicit +/// unwrap for if the stack is empty. +pub(crate) trait StackExt { + fn top(&self) -> &T; + fn top_mut(&mut self) -> &mut T; +} + +impl StackExt for Vec { + fn top(&self) -> &T { + self.last().unwrap() + } + + fn top_mut(&mut self) -> &mut T { + self.last_mut().unwrap() + } +} diff --git a/crates/wizer/src/translate.rs b/crates/wizer/src/translate.rs new file mode 100644 index 000000000000..758dc490cb0a --- /dev/null +++ b/crates/wizer/src/translate.rs @@ -0,0 +1,104 @@ +//! Type translator functions from `wasmparser` to `wasm_encoder`. + +pub(crate) fn table_type(table_ty: wasmparser::TableType) -> wasm_encoder::TableType { + wasm_encoder::TableType { + element_type: val_type(table_ty.element_type), + limits: limits(table_ty.limits), + } +} + +pub(crate) fn val_type(ty: wasmparser::Type) -> wasm_encoder::ValType { + use wasm_encoder::ValType; + use wasmparser::Type::*; + match ty { + I32 => ValType::I32, + I64 => ValType::I64, + F32 => ValType::F32, + F64 => ValType::F64, + FuncRef => ValType::FuncRef, + V128 | ExternRef | ExnRef => panic!("not supported"), + Func | EmptyBlockType => unreachable!(), + } +} + +pub(crate) fn global_type(ty: wasmparser::GlobalType) -> wasm_encoder::GlobalType { + wasm_encoder::GlobalType { + val_type: val_type(ty.content_type), + mutable: ty.mutable, + } +} + +pub(crate) fn memory_type(ty: wasmparser::MemoryType) -> wasm_encoder::MemoryType { + match ty { + wasmparser::MemoryType::M32 { + shared: false, + limits: lims, + } => wasm_encoder::MemoryType { + limits: limits(lims), + }, + _ => unreachable!("handled in validation"), + } +} + +pub(crate) fn limits(limits: wasmparser::ResizableLimits) -> wasm_encoder::Limits { + wasm_encoder::Limits { + min: limits.initial, + max: limits.maximum, + } +} + +pub(crate) fn entity_type(ty: wasmparser::ImportSectionEntryType) -> wasm_encoder::EntityType { + match ty { + wasmparser::ImportSectionEntryType::Function(f) => wasm_encoder::EntityType::Function(f), + wasmparser::ImportSectionEntryType::Table(tty) => { + wasm_encoder::EntityType::Table(table_type(tty)) + } + wasmparser::ImportSectionEntryType::Memory(mty) => { + wasm_encoder::EntityType::Memory(memory_type(mty)) + } + wasmparser::ImportSectionEntryType::Global(gty) => { + wasm_encoder::EntityType::Global(global_type(gty)) + } + wasmparser::ImportSectionEntryType::Instance(ity) => { + wasm_encoder::EntityType::Instance(ity) + } + wasmparser::ImportSectionEntryType::Module(_) => { + unreachable!( + "we disallow importing/exporting modules so we shouldn't \ + have module types" + ) + } + wasmparser::ImportSectionEntryType::Event(_) => unreachable!(), + } +} + +pub(crate) fn item_kind(kind: wasmparser::ExternalKind) -> wasm_encoder::ItemKind { + match kind { + wasmparser::ExternalKind::Function => wasm_encoder::ItemKind::Function, + wasmparser::ExternalKind::Table => wasm_encoder::ItemKind::Table, + wasmparser::ExternalKind::Memory => wasm_encoder::ItemKind::Memory, + wasmparser::ExternalKind::Global => wasm_encoder::ItemKind::Global, + wasmparser::ExternalKind::Module => wasm_encoder::ItemKind::Module, + wasmparser::ExternalKind::Instance => wasm_encoder::ItemKind::Instance, + wasmparser::ExternalKind::Type | wasmparser::ExternalKind::Event => unreachable!(), + } +} + +pub(crate) fn export(kind: wasmparser::ExternalKind, index: u32) -> wasm_encoder::Export { + match kind { + wasmparser::ExternalKind::Function => wasm_encoder::Export::Function(index), + wasmparser::ExternalKind::Global => wasm_encoder::Export::Global(index), + wasmparser::ExternalKind::Table => wasm_encoder::Export::Table(index), + wasmparser::ExternalKind::Memory => wasm_encoder::Export::Memory(index), + wasmparser::ExternalKind::Instance => wasm_encoder::Export::Instance(index), + wasmparser::ExternalKind::Event + | wasmparser::ExternalKind::Type + | wasmparser::ExternalKind::Module => unreachable!(), + } +} + +pub(crate) fn instance_arg<'a>( + arg: &wasmparser::InstanceArg<'a>, +) -> (&'a str, wasm_encoder::Export) { + (arg.name, export(arg.kind, arg.index)) +} diff --git a/crates/wizer/tests/tests.rs b/crates/wizer/tests/tests.rs index cb4ed0d55088..daacf4db6371 100644 --- a/crates/wizer/tests/tests.rs +++ b/crates/wizer/tests/tests.rs @@ -1,3 +1,4 @@ +use anyhow::Context; use wat::parse_str as wat_to_wasm; use wizer::Wizer; @@ -12,15 +13,19 @@ fn run_wasm(args: &[wasmtime::Val], expected: i32, wasm: &[u8]) -> anyhow::Resul let mut wizer = Wizer::new(); wizer.allow_wasi(true); + wizer.wasm_multi_memory(true); + wizer.wasm_module_linking(true); let wasm = wizer.run(&wasm)?; let mut config = wasmtime::Config::new(); config.wasm_multi_memory(true); config.wasm_multi_value(true); + config.wasm_module_linking(true); let engine = wasmtime::Engine::new(&config)?; let store = wasmtime::Store::new(&engine); - let module = wasmtime::Module::new(store.engine(), wasm)?; + let module = + wasmtime::Module::new(store.engine(), wasm).context("Wasm test case failed to compile")?; let mut linker = wasmtime::Linker::new(&store); let ctx = wasi_cap_std_sync::WasiCtxBuilder::new().build()?; @@ -110,6 +115,394 @@ fn multi_memory() -> anyhow::Result<()> { ) } +#[test] +fn reject_imported_memory() -> anyhow::Result<()> { + assert!(run_wat( + &[], + 42, + r#" +(module + (import "" "" (memory 1))) +"#, + ) + .is_err()); + Ok(()) +} + +#[test] +fn reject_imported_global() -> anyhow::Result<()> { + assert!(run_wat( + &[], + 42, + r#" +(module + (import "" "" (global i32))) +"#, + ) + .is_err()); + Ok(()) +} + +#[test] +fn reject_imported_table() -> anyhow::Result<()> { + assert!(run_wat( + &[], + 42, + r#" +(module + (import "" "" (table))) +"#, + ) + .is_err()); + Ok(()) +} + +#[test] +fn reject_bulk_memory() -> anyhow::Result<()> { + let result = run_wat( + &[], + 42, + r#" +(module + (table 3 funcref) + + (func $f (result i32) (i32.const 0)) + (func $g (result i32) (i32.const 0)) + (func $h (result i32) (i32.const 0)) + + (func (export "main") + i32.const 0 + i32.const 1 + i32.const 1 + table.copy) + + (elem (i32.const 0) $f $g $h) +) +"#, + ); + assert!(result.is_err()); + + let err = result.unwrap_err(); + assert!(err + .to_string() + .contains("unsupported `table.copy` instruction")); + + Ok(()) +} + +#[test] +fn accept_module_linking_import_memory() -> anyhow::Result<()> { + run_wat( + &[], + 42, + r#" +(module + (module $A + (memory (export "memory") 1)) + (instance $a (instantiate $A)) + + (module $B + (import "x" (instance $x (export "memory" (memory 1))))) + (instance $b (instantiate $B (import "x" (instance $a)))) + + (func (export "wizer.initialize") + nop) + + (func (export "run") (result i32) + i32.const 42) +) +"#, + ) +} + +#[test] +fn accept_module_linking_import_global() -> anyhow::Result<()> { + run_wat( + &[], + 42, + r#" +(module + (module $A + (global (export "global") i32 (i32.const 1337))) + (instance $a (instantiate $A)) + + (module $B + (import "x" (instance $x (export "global" (global i32))))) + (instance $b (instantiate $B (import "x" (instance $a)))) + + (func (export "wizer.initialize") + nop) + + (func (export "run") (result i32) + i32.const 42) +) +"#, + ) +} + +#[test] +fn accept_module_linking_import_table() -> anyhow::Result<()> { + run_wat( + &[], + 42, + r#" +(module + (module $A + (table (export "table") 0 funcref)) + (instance $a (instantiate $A)) + + (module $B + (import "x" (instance $x (export "table" (table 0 funcref))))) + (instance $b (instantiate $B (import "x" (instance $a)))) + + (func (export "wizer.initialize") + nop) + + (func (export "run") (result i32) + i32.const 42) +) +"#, + ) +} + +#[test] +fn module_linking_actually_works() -> anyhow::Result<()> { + run_wat( + &[], + 42, + r#" +(module + (module $memory-module + (memory (export "memory") 1)) + (instance $memory-instance (instantiate $memory-module)) + + (module $use-memory + (import "x" (instance $m (export "memory" (memory 1)))) + (func (export "init") + i32.const 0 + i32.const 42 + i32.store (memory $m "memory") offset=1337)) + (instance $use-memory-instance + (instantiate $use-memory + (import "x" (instance $memory-instance)))) + + (func (export "wizer.initialize") + (call (func $use-memory-instance "init"))) + + (func (export "run") (result i32) + i32.const 0 + i32.load (memory $memory-instance "memory") offset=1337) +) +"#, + ) +} + +#[test] +fn module_linking_nested_instantiations_1() -> anyhow::Result<()> { + run_wat( + &[], + 8, + r#" +(module + (module $A + (import "global" (global (mut i32))) + + (module $B + (import "global" (global (mut i32))) + + (module $C + (import "global" (global (mut i32))) + + (func (export "f") + i32.const 1 + global.get 0 + i32.add + global.set 0 + ) + ) + + (instance $c1 (instantiate $C (import "global" (global 0)))) + (instance $c2 (instantiate $C (import "global" (global 0)))) + + (func (export "f") + call (func $c1 "f") + call (func $c2 "f") + ) + ) + + (instance $b1 (instantiate $B (import "global" (global 0)))) + (instance $b2 (instantiate $B (import "global" (global 0)))) + + (func (export "f") + call (func $b1 "f") + call (func $b2 "f") + ) + ) + + (module $DefinesGlobal + (global (export "global") (mut i32) (i32.const 0))) + (instance $global_instance (instantiate $DefinesGlobal)) + + (instance $a1 (instantiate $A (import "global" (global $global_instance "global")))) + (instance $a2 (instantiate $A (import "global" (global $global_instance "global")))) + + (func (export "wizer.initialize") + call (func $a1 "f") + call (func $a2 "f")) + + (func (export "run") (result i32) + global.get (global $global_instance "global")) +) +"#, + ) +} + +#[test] +fn module_linking_nested_instantiations_0() -> anyhow::Result<()> { + run_wat( + &[], + 42, + r#" +(module + (module $A + (import "global" (global (mut i32))) + + (module $B + (import "global" (global (mut i32))) + + (func (export "f") + i32.const 42 + global.set 0 + ) + ) + + (instance $b (instantiate $B (import "global" (global 0)))) + + (func (export "f") + call (func $b "f") + ) + ) + + (module $G + (global (export "global") (mut i32) (i32.const 0))) + + (instance $g (instantiate $G)) + + (instance $a (instantiate $A (import "global" (global $g "global")))) + + (func (export "wizer.initialize") + call (func $a "f") + ) + + (func (export "run") (result i32) + global.get (global $g "global") + ) +) +"#, + ) +} + +// Test that we handle repeated and interleaved initial sections. +#[test] +fn multiple_initial_sections() -> anyhow::Result<()> { + run_wat( + &[], + 42, + r#" +(module + ;; Module section. + (module $A + (memory (export "memory") 1) + ) + + ;; Instance section. + (instance $a (instantiate $A)) + + ;; Alias section. + (alias $a "memory" (memory $memory)) + + ;; Module section. + (module $B + (import "memory" (memory 1)) + (func (export "init") + i32.const 0 + i32.const 42 + i32.store offset=1337 + ) + ) + + ;; Instance section. + (instance $b (instantiate $B (import "memory" (memory $memory)))) + + ;; Alias section. + (alias $b "init" (func $b-init)) + + ;; Module section. + (module $C + (import "memory" (memory 1)) + (func (export "run") (result i32) + i32.const 0 + i32.load offset=1337 + ) + ) + + ;; Instance section. + (instance $c (instantiate $C (import "memory" (memory $memory)))) + + ;; Alias section. + (alias $c "run" (func $c-run)) + + ;; Done with initial sections. + + (func (export "wizer.initialize") + call $b-init + ) + + (func (export "run") (result i32) + call $c-run + ) +) +"#, + ) +} + +#[test] +fn start_sections_in_nested_modules() -> anyhow::Result<()> { + run_wat( + &[], + 42, + r#" +(module + (module $A + (import "global" (global $g (mut i32))) + (func $init + i32.const 41 + global.set $g) + (start $init) + ) + + (module $B + (global (export "global") (mut i32) (i32.const 0)) + ) + + (instance $b (instantiate $B)) + (alias $b "global" (global $g)) + (instance $a (instantiate $A (import "global" (global $g)))) + + (func (export "wizer.initialize") + global.get $g + i32.const 1 + i32.add + global.set $g + ) + (func (export "run") (result i32) + global.get $g + ) +) +"#, + ) +} + #[test] fn rust_regex() -> anyhow::Result<()> { run_wasm( @@ -125,11 +518,11 @@ fn rename_functions() -> anyhow::Result<()> { (module (func (export "wizer.initialize")) (func (export "func_a") (result i32) - i32.const 1) + i32.const 1) (func (export "func_b") (result i32) - i32.const 2) + i32.const 2) (func (export "func_c") (result i32) - i32.const 3)) + i32.const 3)) "#; let wasm = wat_to_wasm(wat)?; @@ -138,6 +531,7 @@ fn rename_functions() -> anyhow::Result<()> { wizer.func_rename("func_a", "func_b"); wizer.func_rename("func_b", "func_c"); let wasm = wizer.run(&wasm)?; + let wat = wasmprinter::print_bytes(&wasm)?; let expected_wat = r#" (module @@ -154,9 +548,6 @@ fn rename_functions() -> anyhow::Result<()> { (export "func_b" (func 3))) "#; - let expected_wasm = wat_to_wasm(expected_wat)?; - - assert_eq!(expected_wasm, wasm); - + assert_eq!(wat.trim(), expected_wat.trim()); Ok(()) } From d688764fe850227a86b1dbe6ff5c1479b3ddf216 Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Mon, 26 Apr 2021 16:32:34 -0700 Subject: [PATCH 042/212] Add a fuzz target for Wizer This fuzz target checks that we get the same result whether we 1. Call the initialization function 2. Call the main function or 1. Call the initialization function 2. Snapshot with Wizer 3. Instantiate the snapshot 4. Call the instantiated snapshot's main function When checking that we get the same result, we don't just consider the main function's results: we also consider memories and globals. I've been running this locally for a couple days and, while there was an initial flurry of failures and panics, it's been about a day since it fell over. I think module linking support is in a good enough place where we can land it and continue to bug fix in tree as we find new failures. --- crates/wizer/Cargo.lock | 55 +++++ crates/wizer/Cargo.toml | 1 + crates/wizer/fuzz/.gitignore | 5 + crates/wizer/fuzz/Cargo.toml | 27 +++ crates/wizer/fuzz/fuzz_targets/same_result.rs | 228 ++++++++++++++++++ crates/wizer/src/dummy.rs | 6 + crates/wizer/src/lib.rs | 4 + 7 files changed, 326 insertions(+) create mode 100644 crates/wizer/fuzz/.gitignore create mode 100644 crates/wizer/fuzz/Cargo.toml create mode 100644 crates/wizer/fuzz/fuzz_targets/same_result.rs diff --git a/crates/wizer/Cargo.lock b/crates/wizer/Cargo.lock index 00f611b0ed32..616049253ebb 100644 --- a/crates/wizer/Cargo.lock +++ b/crates/wizer/Cargo.lock @@ -41,6 +41,15 @@ version = "1.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "afddf7f520a80dbf76e6f50a35bca42a2331ef227a28b3b6dc5c2e2338d114b1" +[[package]] +name = "arbitrary" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "698b65a961a9d730fb45b6b0327e20207810c9f61ee421b082b27ba003f49e2b" +dependencies = [ + "derive_arbitrary", +] + [[package]] name = "async-trait" version = "0.1.48" @@ -467,6 +476,17 @@ dependencies = [ "memchr", ] +[[package]] +name = "derive_arbitrary" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df89dd0d075dea5cc5fdd6d5df6b8a61172a710b3efac1d6bdb9dd8b78f82c1a" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "digest" version = "0.9.0" @@ -759,6 +779,16 @@ version = "0.2.90" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ba4aede83fc3617411dc6993bc8c70919750c1c257c6ca6a502aed6e0e2394ae" +[[package]] +name = "libfuzzer-sys" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86c975d637bc2a2f99440932b731491fc34c7f785d239e38af3addd3c2fd0e46" +dependencies = [ + "arbitrary", + "cc", +] + [[package]] name = "linked-hash-map" version = "0.5.4" @@ -1666,6 +1696,18 @@ dependencies = [ "leb128", ] +[[package]] +name = "wasm-smith" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a982408719f704307ac7f45247350f06ce739d759362ef8293ed7b4d922adee8" +dependencies = [ + "arbitrary", + "indexmap", + "leb128", + "wasm-encoder", +] + [[package]] name = "wasmparser" version = "0.77.0" @@ -2095,6 +2137,19 @@ dependencies = [ "wat", ] +[[package]] +name = "wizer-fuzz" +version = "0.0.0" +dependencies = [ + "env_logger 0.8.3", + "libfuzzer-sys", + "log", + "wasm-smith", + "wasmprinter", + "wasmtime", + "wizer", +] + [[package]] name = "yaml-rust" version = "0.4.5" diff --git a/crates/wizer/Cargo.toml b/crates/wizer/Cargo.toml index 79a3351adbbf..20dc91fdfcf6 100644 --- a/crates/wizer/Cargo.toml +++ b/crates/wizer/Cargo.toml @@ -48,6 +48,7 @@ wat = "1.0.36" members = [ "benches/regex-bench", "benches/uap-bench", + "fuzz", "tests/regex-test", ] diff --git a/crates/wizer/fuzz/.gitignore b/crates/wizer/fuzz/.gitignore new file mode 100644 index 000000000000..62f1add3f688 --- /dev/null +++ b/crates/wizer/fuzz/.gitignore @@ -0,0 +1,5 @@ +test.wasm +test.wat +target +corpus +artifacts diff --git a/crates/wizer/fuzz/Cargo.toml b/crates/wizer/fuzz/Cargo.toml new file mode 100644 index 000000000000..1860cc9f0763 --- /dev/null +++ b/crates/wizer/fuzz/Cargo.toml @@ -0,0 +1,27 @@ + +[package] +name = "wizer-fuzz" +version = "0.0.0" +authors = ["Automatically generated"] +publish = false +edition = "2018" + +[package.metadata] +cargo-fuzz = true + +[dependencies] +env_logger = "0.8.3" +libfuzzer-sys = "0.4" +log = "0.4.14" +wasm-smith = "0.4.0" +wasmprinter = "0.2.26" +wasmtime = "0.26.0" + +[dependencies.wizer] +path = ".." + +[[bin]] +name = "same_result" +path = "fuzz_targets/same_result.rs" +test = false +doc = false diff --git a/crates/wizer/fuzz/fuzz_targets/same_result.rs b/crates/wizer/fuzz/fuzz_targets/same_result.rs new file mode 100644 index 000000000000..7a46e95e11aa --- /dev/null +++ b/crates/wizer/fuzz/fuzz_targets/same_result.rs @@ -0,0 +1,228 @@ +//! Check that we get the same result whether we +//! +//! 1. Call the initialization function +//! 2. Call the main function +//! +//! or +//! +//! 1. Call the initialization function +//! 2. Snapshot with Wizer +//! 3. Instantiate the snapshot +//! 4. Call the instantiated snapshot's main function +//! +//! When checking that we get the same result, we don't just consider the main +//! function's results: we also consider memories and globals. + +#![no_main] + +use libfuzzer_sys::{arbitrary, fuzz_target}; +use wasmtime::*; + +const FUEL: u32 = 1_000; + +fuzz_target!(|module: wasm_smith::ConfiguredModule| { + let _ = env_logger::try_init(); + + let mut module = module; + module.ensure_termination(FUEL); + let wasm = module.to_bytes(); + + if log::log_enabled!(log::Level::Debug) { + log::debug!("Writing test case to `test.wasm`"); + std::fs::write("test.wasm", &wasm).unwrap(); + if let Ok(wat) = wasmprinter::print_bytes(&wasm) { + log::debug!("Writing disassembly to `test.wat`"); + std::fs::write("test.wat", wat).unwrap(); + } + } + + let mut config = Config::new(); + config.cache_config_load_default().unwrap(); + config.wasm_module_linking(true); + config.wasm_multi_memory(true); + config.wasm_multi_value(true); + + let engine = Engine::new(&config).unwrap(); + let module = Module::new(&engine, &wasm).unwrap(); + if module.imports().len() > 0 { + // Not using the `WasmConfig` for this because we want to encourage + // imports/exports between modules within the bundle, just not at the + // top level. + return; + } + + let mut main_funcs = vec![]; + let mut init_funcs = vec![]; + for exp in module.exports() { + if let ExternType::Func(ty) = exp.ty() { + main_funcs.push(exp.name()); + if ty.params().len() == 0 && ty.results().len() == 0 { + init_funcs.push(exp.name()); + } + } + } + + 'init_loop: for init_func in init_funcs { + log::debug!("Using initialization function: {:?}", init_func); + + // Create a wizened snapshot of the given Wasm using `init_func` as the + // initialization routine. + let mut wizer = wizer::Wizer::new(); + wizer + .wasm_module_linking(true) + .wasm_multi_memory(true) + .wasm_multi_value(true) + .init_func(init_func); + let snapshot_wasm = match wizer.run(&wasm) { + Err(_) => continue 'init_loop, + Ok(s) => s, + }; + let snapshot_module = + Module::new(&engine, &snapshot_wasm).expect("snapshot should be valid wasm"); + + // Now check that each "main" function behaves the same whether we call + // it on an instantiated snapshot or if we instantiate the original + // Wasm, call the initialization routine, and then call the "main" + // function. + 'main_loop: for main_func in &main_funcs { + if *main_func == init_func { + // Wizer un-exports the initialization function, so we can't use + // it as a main function. + continue 'main_loop; + } + log::debug!("Using main function: {:?}", main_func); + + let store = Store::new(&engine); + + // Instantiate the snapshot and call the main function. + let snapshot_instance = Instance::new(&store, &snapshot_module, &[]).unwrap(); + let snapshot_main_func = snapshot_instance.get_func(main_func).unwrap(); + let main_args = wizer::dummy::dummy_values(snapshot_main_func.ty().params()); + let snapshot_result = snapshot_main_func.call(&main_args); + + // Instantiate the original Wasm and then call the initialization + // and main functions back to back. + let instance = Instance::new(&store, &module, &[]).unwrap(); + let init_func = instance.get_typed_func::<(), ()>(init_func).unwrap(); + init_func.call(()).unwrap(); + let main_func = instance.get_func(main_func).unwrap(); + let result = main_func.call(&main_args); + + // Check that the function return values / traps are the same. + match (snapshot_result, result) { + // Both did not trap. + (Ok(snapshot_result), Ok(result)) => { + assert_eq!(snapshot_result.len(), result.len()); + for (s, r) in snapshot_result.iter().zip(result.iter()) { + assert_val_eq(s, r); + } + } + + // Both trapped. + (Err(_), Err(_)) => {} + + // Divergence. + (s, r) => { + panic!( + "divergence between whether the main function traps or not!\n\n\ + no snapshotting result = {:?}\n\n\ + snapshotted result = {:?}", + r, s, + ); + } + } + + // Assert that all other exports have the same state as well. + for export in snapshot_instance.exports() { + let name = export.name().to_string(); + match export.into_extern() { + Extern::Global(snapshot_global) => { + let global = instance.get_global(&name).unwrap(); + assert_val_eq(&snapshot_global.get(), &global.get()); + } + Extern::Memory(snapshot_memory) => { + let memory = instance.get_memory(&name).unwrap(); + unsafe { + let snapshot_memory = snapshot_memory.data_unchecked(); + let memory = memory.data_unchecked(); + assert_eq!(snapshot_memory.len(), memory.len()); + // NB: Don't use `assert_eq` here so that we don't + // try to print the full memories' debug + // representations on failure. + if snapshot_memory != memory { + panic!("divergence between snapshot and non-snapshot memories"); + } + } + } + Extern::Instance(_) + | Extern::Func(_) + | Extern::Table(_) + | Extern::Module(_) => continue, + } + } + } + } +}); + +fn assert_val_eq(a: &Val, b: &Val) { + match (a, b) { + (Val::I32(a), Val::I32(b)) => assert_eq!(a, b), + (Val::I64(a), Val::I64(b)) => assert_eq!(a, b), + (Val::F32(a), Val::F32(b)) => assert!({ + let a = f32::from_bits(*a); + let b = f32::from_bits(*b); + a == b || (a.is_nan() && b.is_nan()) + }), + (Val::F64(a), Val::F64(b)) => assert!({ + let a = f64::from_bits(*a); + let b = f64::from_bits(*b); + a == b || (a.is_nan() && b.is_nan()) + }), + _ => panic!("{:?} != {:?}", a, b), + } +} + +#[derive(Clone, Default, Debug)] +struct WasmConfig; + +impl<'a> arbitrary::Arbitrary<'a> for WasmConfig { + fn arbitrary(_: &mut arbitrary::Unstructured<'a>) -> arbitrary::Result { + Ok(WasmConfig) + } +} + +impl wasm_smith::Config for WasmConfig { + fn module_linking_enabled(&self) -> bool { + true + } + + fn max_memories(&self) -> usize { + 10 + } + + fn max_memory_pages(&self) -> u32 { + // We want small memories that are quick to compare, but we also want to + // allow memories to grow so we can shake out any memory-growth-related + // bugs, so we choose `2` instead of `1`. + 2 + } + + fn min_funcs(&self) -> usize { + // Always generate at least one function that we can hopefully use as an + // initialization function. + 1 + } + + fn min_exports(&self) -> usize { + // Always at least one export, hopefully a function we can use as an + // initialization routine. + 1 + } + + fn memory_offset_choices(&self) -> (u32, u32, u32) { + // Always use an offset immediate that is within the memory's minimum + // size. This should make trapping on loads/stores a little less + // frequent. + (1, 0, 0) + } +} diff --git a/crates/wizer/src/dummy.rs b/crates/wizer/src/dummy.rs index 67c4f049ca68..d72d54b35c78 100644 --- a/crates/wizer/src/dummy.rs +++ b/crates/wizer/src/dummy.rs @@ -93,6 +93,12 @@ pub fn dummy_value(val_ty: ValType) -> Val { } } +/// Construct a sequence of dummy values for the given types. +#[cfg(fuzzing)] +pub fn dummy_values(val_tys: impl IntoIterator) -> Vec { + val_tys.into_iter().map(dummy_value).collect() +} + /// Construct a dummy global for the given global type. pub fn dummy_global(store: &Store, ty: GlobalType) -> Global { let val = dummy_value(ty.content().clone()); diff --git a/crates/wizer/src/lib.rs b/crates/wizer/src/lib.rs index c24d27908e00..cd30c24366b0 100644 --- a/crates/wizer/src/lib.rs +++ b/crates/wizer/src/lib.rs @@ -4,7 +4,11 @@ #![deny(missing_docs)] +#[cfg(fuzzing)] +pub mod dummy; +#[cfg(not(fuzzing))] mod dummy; + mod info; mod instrument; mod parse; From 1fbff10f778042dc8e34d06aeba8c7c7b837f995 Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Wed, 28 Apr 2021 12:30:23 -0700 Subject: [PATCH 043/212] Derive `Debug` to make `ModuleInfo` construction simpler --- crates/wizer/src/info.rs | 41 +++------------------------------------- 1 file changed, 3 insertions(+), 38 deletions(-) diff --git a/crates/wizer/src/info.rs b/crates/wizer/src/info.rs index 39539fcf1444..3d2204b8ad40 100644 --- a/crates/wizer/src/info.rs +++ b/crates/wizer/src/info.rs @@ -9,7 +9,7 @@ use std::convert::TryFrom; /// /// These are created during during our `parse` pass and then used throughout /// our later passes. -#[derive(Clone)] +#[derive(Clone, Default)] pub(crate) struct ModuleInfo<'a> { /// This module's id (i.e. its pre-order traversal index). pub id: u32, @@ -101,49 +101,14 @@ pub(crate) struct ModuleInfo<'a> { impl<'a> ModuleInfo<'a> { /// Create the `ModuleInfo` for the root of a module-linking bundle. pub fn for_root() -> Self { - Self { - id: 0, - raw_sections: vec![], - instance_import_counts: vec![], - modules: vec![], - types: vec![], - imports: vec![], - aliases: vec![], - globals: vec![], - defined_globals_index: None, - instances: vec![], - instantiations: BTreeMap::new(), - child_modules_expected: 0, - module_section: None, - exports: vec![], - functions: vec![], - tables: vec![], - memories: vec![], - defined_memories_index: None, - } + Self::default() } /// Create a new `ModuleInfo` for an inner module. pub fn for_inner(id: u32) -> Self { Self { id, - raw_sections: vec![], - instance_import_counts: vec![], - modules: vec![], - types: vec![], - imports: vec![], - aliases: vec![], - globals: vec![], - defined_globals_index: None, - instances: vec![], - instantiations: BTreeMap::new(), - child_modules_expected: 0, - module_section: None, - exports: vec![], - functions: vec![], - tables: vec![], - memories: vec![], - defined_memories_index: None, + ..Self::default() } } From 4fde9522e16f713b98714b235e315f762b0cfd19 Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Wed, 28 Apr 2021 12:31:34 -0700 Subject: [PATCH 044/212] Collect into a boxed slice directly Rather than collecting into a vec and then turning the vec into a boxed slice. --- crates/wizer/src/info.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/wizer/src/info.rs b/crates/wizer/src/info.rs index 3d2204b8ad40..cfc8a4c633ee 100644 --- a/crates/wizer/src/info.rs +++ b/crates/wizer/src/info.rs @@ -207,8 +207,7 @@ impl<'a> ModuleInfo<'a> { }, } }) - .collect::>() - .into_boxed_slice(), + .collect(), } } From 907316416ff33b1b16c342ebe97ad9a75ac14651 Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Wed, 28 Apr 2021 12:37:50 -0700 Subject: [PATCH 045/212] We can't ever get `NeedMoreData` from the parser We always pass `true` to the `eof` argument, which means it will never return `NeedMoreData`. --- crates/wizer/src/parse.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/wizer/src/parse.rs b/crates/wizer/src/parse.rs index 1dee3cdc9209..6f6e8adc4f79 100644 --- a/crates/wizer/src/parse.rs +++ b/crates/wizer/src/parse.rs @@ -34,7 +34,7 @@ pub(crate) fn parse<'a>(full_wasm: &'a [u8]) -> anyhow::Result> { .parse(wasm, true) .context("failed to parse Wasm")? { - wasmparser::Chunk::NeedMoreData(_) => anyhow::bail!("invalid Wasm module"), + wasmparser::Chunk::NeedMoreData(_) => unreachable!(), wasmparser::Chunk::Parsed { payload, consumed } => (payload, consumed), }; wasm = &wasm[consumed..]; From 5b62b68c390a33e226565293e9a51f1b2948d81f Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Wed, 28 Apr 2021 12:39:05 -0700 Subject: [PATCH 046/212] Use `{}` instead of `continue` when it doesn't matter Easier for readers, who might otherwise expect that there is some bit of logic after the match at the end of the loop body that is being skipped. --- crates/wizer/src/parse.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/wizer/src/parse.rs b/crates/wizer/src/parse.rs index 6f6e8adc4f79..15ed4107f320 100644 --- a/crates/wizer/src/parse.rs +++ b/crates/wizer/src/parse.rs @@ -41,7 +41,7 @@ pub(crate) fn parse<'a>(full_wasm: &'a [u8]) -> anyhow::Result> { use wasmparser::Payload::*; match payload { - Version { .. } => continue, + Version { .. } => {} TypeSection(types) => type_section(&mut stack, full_wasm, types)?, ImportSection(imports) => import_section(&mut stack, full_wasm, imports)?, AliasSection(aliases) => alias_section(&mut stack, full_wasm, aliases)?, From 5ed3405934e472bef3fb839953ed9a38fa3912ae Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Wed, 28 Apr 2021 12:47:27 -0700 Subject: [PATCH 047/212] Turn some `anyhow::bail!`s into `unreachable!()`s Because earlier validation/parsing would have already rejected these cases. --- crates/wizer/src/parse.rs | 104 ++++++++++++++++++++------------------ 1 file changed, 55 insertions(+), 49 deletions(-) diff --git a/crates/wizer/src/parse.rs b/crates/wizer/src/parse.rs index 15ed4107f320..50ff063007e6 100644 --- a/crates/wizer/src/parse.rs +++ b/crates/wizer/src/parse.rs @@ -137,8 +137,60 @@ fn type_section<'a>( wasmparser::TypeDef::Func(_) | wasmparser::TypeDef::Instance(_) => { info.types.push(ty); } + + // We need to disallow module imports, even within nested modules + // that only ever have other nested modules supplied as + // arguments. Two different modules could be supplied for two + // different instantiations of the module-importing module, but then + // after we export all modules' globals in our instrumentation + // phase, those two different module arguments could become + // type-incompatible with each other: + // + // ``` + // (module + // + // ;; Module A exports and `f` function. Internally it has + // ;; one global. + // (module $A + // (global $g ...) + // (func (export "f") ...)) + // + // ;; Module B has an identical interface as A. Internally + // ;; it has two globals. + // (module $B + // (global $g ...) + // (global $h ...) + // (func (export "f") ...)) + // + // ;; Module C imports any module that exports an `f` + // ;; function. It instantiates this imported module. + // (module $C + // (import "env" "module" + // (module (export "f" (func))) + // (instance 0))) + // + // ;; C is instantiated with both A and B. + // (instance $C (import "env" "module" $A)) + // (instance $C (import "env" "module" $B)) + // ) + // ``` + // + // After this instrumentation pass, we need to make module C + // transitively export all of the globals from its inner + // instances. Which means that the module type used in the module + // import needs to specify how many modules are in the imported + // module, but in our two instantiations, we have two different + // numbers of globals defined in each module! The only way to + // resolve this would be to duplicate and specialize module C for + // each instantiation, which we don't want to do for complexity and + // code size reasons. + // + // Since module types are only used with importing and exporting + // modules, which we don't intend to support as described above, we + // can disallow module types to reject all of them in one fell + // swoop. wasmparser::TypeDef::Module(_) => Err(anyhow::anyhow!( - "wizer does not support importing or exporting modules" + "wizer does not support importing or exporting modules or module types" ) .context("module types are not supported"))?, } @@ -200,7 +252,7 @@ fn import_section<'a>( } wasmparser::ImportSectionEntryType::Module(_) => { - unreachable!("should have been rejected by `check_import_type`") + unreachable!() } wasmparser::ImportSectionEntryType::Event(_) => { unreachable!("should have been rejected by validation") @@ -223,53 +275,7 @@ fn check_import_type( ) -> Result<()> { match ty { wasmparser::ImportSectionEntryType::Module(_) => { - // We need to disallow module imports, even within nested modules - // that only ever have other nested modules supplied as - // arguments. Two different modules could be supplied for two - // different instantiations of the module-importing module, but then - // after we export all modules' globals in our instrumentation - // phase, those two different module arguments could become - // type-incompatible with each other: - // - // ``` - // (module - // - // ;; Module A exports and `f` function. Internally it has - // ;; one global. - // (module $A - // (global $g ...) - // (func (export "f") ...)) - // - // ;; Module B has an identical interface as A. Internally - // ;; it has two globals. - // (module $B - // (global $g ...) - // (global $h ...) - // (func (export "f") ...)) - // - // ;; Module C imports any module that exports an `f` - // ;; function. It instantiates this imported module. - // (module $C - // (import "env" "module" - // (module (export "f" (func))) - // (instance 0))) - // - // ;; C is instantiated with both A and B. - // (instance $C (import "env" "module" $A)) - // (instance $C (import "env" "module" $B)) - // ) - // ``` - // - // After this instrumentation pass, we need to make module C - // transitively export all of the globals from its inner - // instances. Which means that the module type used in the module - // import needs to specify how many modules are in the imported - // module, but in our two instantiations, we have two different - // numbers of globals defined in each module! The only way to - // resolve this would be to duplicate and specialize module C for - // each instantiation, which we don't want to do for complexity and - // code size reasons. - anyhow::bail!("imported modules are not supported by Wizer") + unreachable!(); } wasmparser::ImportSectionEntryType::Instance(inst_ty_index) => { // We allow importing instances that only export things that are From 01a93fae55547a1262a4eecd457e9ff5beb58a0e Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Wed, 28 Apr 2021 13:49:04 -0700 Subject: [PATCH 048/212] Remove unnecessary parameter Due to some churn/refactoring, it was always given the same value. Therefore we can inline it and remove the parameter. --- crates/wizer/src/rewrite.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/crates/wizer/src/rewrite.rs b/crates/wizer/src/rewrite.rs index 82dde1614328..b71125b0af81 100644 --- a/crates/wizer/src/rewrite.rs +++ b/crates/wizer/src/rewrite.rs @@ -149,7 +149,7 @@ impl Wizer { root.section(&code_modules); let state_modules = - rewrite_state_modules(info, &id_to_module_info, &snapshot.instantiations, 0); + rewrite_state_modules(info, &id_to_module_info, &snapshot.instantiations); root.section(&state_modules); } @@ -804,15 +804,13 @@ fn rewrite_state_modules( info: &ModuleInfo, id_to_module_info: &Vec<&ModuleInfo>, snapshots: &[Snapshot], - depth: u32, ) -> wasm_encoder::ModuleSection { let mut modules = wasm_encoder::ModuleSection::new(); assert_eq!(snapshots.len(), info.instantiations.len()); for (snapshot, (module_id, _)) in snapshots.iter().zip(info.instantiations.values()) { let module_info = &id_to_module_info[usize::try_from(*module_id).unwrap()]; - let state_module = - rewrite_one_state_module(module_info, id_to_module_info, snapshot, depth); + let state_module = rewrite_one_state_module(module_info, id_to_module_info, snapshot, 0); modules.module(&state_module); } From 62c9c23a33df83e9b456c8ebae7a20d6ba68d388 Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Wed, 28 Apr 2021 13:54:57 -0700 Subject: [PATCH 049/212] Get rid of an extra level of indention --- crates/wizer/src/snapshot.rs | 83 ++++++++++++++++++------------------ 1 file changed, 41 insertions(+), 42 deletions(-) diff --git a/crates/wizer/src/snapshot.rs b/crates/wizer/src/snapshot.rs index e6aa0c1b2790..8111ec637542 100644 --- a/crates/wizer/src/snapshot.rs +++ b/crates/wizer/src/snapshot.rs @@ -79,50 +79,49 @@ fn snapshot_memories<'a>(instance: &wasmtime::Instance) -> (Vec, Vec break, - Some(memory) => { - memory_mins.push(memory.size()); - - let num_wasm_pages = memory.size(); - let num_native_pages = num_wasm_pages * (WASM_PAGE_SIZE / NATIVE_PAGE_SIZE); - - let memory: &'a [u8] = unsafe { - // Safe because no one else has a (potentially mutable) - // view to this memory and we know the memory will live - // as long as the store is alive. - std::slice::from_raw_parts(memory.data_ptr(), memory.data_size()) - }; - - // Consider each "native" page of the memory. (Scare quotes - // because we have no guarantee that anyone isn't using huge - // page sizes or something). Process each page in - // parallel. If any byte has changed, add the whole page as - // a data segment. This means that the resulting Wasm module - // should instantiate faster, since there are fewer segments - // to bounds check on instantiation. Engines could even - // theoretically recognize that each of these segments is - // page sized and aligned, and use lazy copy-on-write - // initialization of each instance's memory. - data_segments.par_extend((0..num_native_pages).into_par_iter().filter_map(|i| { - let start = i * NATIVE_PAGE_SIZE; - let end = ((i + 1) * NATIVE_PAGE_SIZE) as usize; - let page = &memory[start as usize..end]; - for byte in page { - if *byte != 0 { - return Some(DataSegment { - memory_index, - offset: start as u32, - data: page, - }); - } - } - None - })); - - memory_index += 1; + Some(memory) => memory, + }; + memory_mins.push(memory.size()); + + let num_wasm_pages = memory.size(); + let num_native_pages = num_wasm_pages * (WASM_PAGE_SIZE / NATIVE_PAGE_SIZE); + + let memory: &'a [u8] = unsafe { + // Safe because no one else has a (potentially mutable) + // view to this memory and we know the memory will live + // as long as the store is alive. + std::slice::from_raw_parts(memory.data_ptr(), memory.data_size()) + }; + + // Consider each "native" page of the memory. (Scare quotes + // because we have no guarantee that anyone isn't using huge + // page sizes or something). Process each page in + // parallel. If any byte has changed, add the whole page as + // a data segment. This means that the resulting Wasm module + // should instantiate faster, since there are fewer segments + // to bounds check on instantiation. Engines could even + // theoretically recognize that each of these segments is + // page sized and aligned, and use lazy copy-on-write + // initialization of each instance's memory. + data_segments.par_extend((0..num_native_pages).into_par_iter().filter_map(|i| { + let start = i * NATIVE_PAGE_SIZE; + let end = ((i + 1) * NATIVE_PAGE_SIZE) as usize; + let page = &memory[start as usize..end]; + for byte in page { + if *byte != 0 { + return Some(DataSegment { + memory_index, + offset: start as u32, + data: page, + }); + } } - } + None + })); + + memory_index += 1; } // Sort data segments to enforce determinism in the face of the From ddd648f7f0dd56e85ed9a9c71bc3aa02f0e9b446 Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Wed, 28 Apr 2021 13:56:06 -0700 Subject: [PATCH 050/212] Remove manual computation of a variable we can instead derive --- crates/wizer/src/snapshot.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/crates/wizer/src/snapshot.rs b/crates/wizer/src/snapshot.rs index 8111ec637542..1e91a871a506 100644 --- a/crates/wizer/src/snapshot.rs +++ b/crates/wizer/src/snapshot.rs @@ -168,14 +168,12 @@ fn snapshot_instantiations<'a>( ) -> Vec> { log::debug!("Snapshotting nested instantiations"); let mut instantiations = vec![]; - let mut index = 0; loop { - let name = format!("__wizer_instance_{}", index); + let name = format!("__wizer_instance_{}", instantiations.len()); match instance.get_export(&name) { None => break, Some(wasmtime::Extern::Instance(instance)) => { instantiations.push(snapshot(store, &instance)); - index += 1; } Some(_) => unreachable!(), } From a30c52ab31af03201b0d708f32a0b92bb61f3eea Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Thu, 29 Apr 2021 10:52:22 -0700 Subject: [PATCH 051/212] Use `wasmtime`'s cache in tests The rust regex test is big enough that avoiding recompilations would be nice. --- crates/wizer/tests/tests.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/wizer/tests/tests.rs b/crates/wizer/tests/tests.rs index daacf4db6371..1a928fa7c50a 100644 --- a/crates/wizer/tests/tests.rs +++ b/crates/wizer/tests/tests.rs @@ -18,6 +18,7 @@ fn run_wasm(args: &[wasmtime::Val], expected: i32, wasm: &[u8]) -> anyhow::Resul let wasm = wizer.run(&wasm)?; let mut config = wasmtime::Config::new(); + config.cache_config_load_default().unwrap(); config.wasm_multi_memory(true); config.wasm_multi_value(true); config.wasm_module_linking(true); From b01815f25f8c7ef5d9f433f6e527acebcea5e5a1 Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Mon, 3 May 2021 14:16:53 -0700 Subject: [PATCH 052/212] Switch to an arena AST representation and fix outer module aliases This switches the AST representation from having children as a `Vec` to (essentially) a `Vec`. It also introduces a `ModuleContext`, which is the arena within which all modules within a given module linking bundle are stored. This makes it so that when we alias an outer module, we aren't deep cloning whole trees of modules anymore. Furthermore, we now differentiate between aliased and defined modules at the AST level, fixing support for outer module aliases at the same time. --- crates/wizer/src/info.rs | 489 +++++++++++++++++++++++++++------ crates/wizer/src/instrument.rs | 56 ++-- crates/wizer/src/lib.rs | 6 +- crates/wizer/src/parse.rs | 335 ++++++++++------------ crates/wizer/src/rewrite.rs | 196 ++++++------- crates/wizer/tests/tests.rs | 35 +++ 6 files changed, 701 insertions(+), 416 deletions(-) diff --git a/crates/wizer/src/info.rs b/crates/wizer/src/info.rs index cfc8a4c633ee..8e1e7c929fd6 100644 --- a/crates/wizer/src/info.rs +++ b/crates/wizer/src/info.rs @@ -4,65 +4,115 @@ use crate::translate; use std::collections::BTreeMap; use std::convert::TryFrom; +/// A collection of info about modules within a module linking bundle. +#[derive(Default)] +pub(crate) struct ModuleContext<'a> { + arena: Vec>, +} + +impl<'a> ModuleContext<'a> { + /// Construct a new `ModuleContext`, pre-populated with an empty root + /// module. + pub fn new() -> Self { + Self { + arena: vec![ModuleInfo::Defined(DefinedModuleInfo::default())], + } + } + + /// Get the root module. + pub fn root(&self) -> Module { + Module { id: 0 } + } + + /// Get a shared reference to the `DefinedModuleInfo` for this module, + /// following through aliases. + fn resolve(&self, module: Module) -> &DefinedModuleInfo<'a> { + let mut id = module.id; + loop { + match &self.arena[id] { + ModuleInfo::Aliased(AliasedModuleInfo { alias_of, .. }) => { + id = *alias_of; + } + ModuleInfo::Defined(d) => return d, + } + } + } + + /// Get an exclusive reference to the `DefinedModuleInfo` for this module. + /// + /// Does not resolve through aliases, because you shouldn't ever mutate + /// aliased modules. + fn defined_mut(&mut self, module: Module) -> &mut DefinedModuleInfo<'a> { + match &mut self.arena[module.id] { + ModuleInfo::Aliased(_) => panic!("not a defined module"), + ModuleInfo::Defined(d) => d, + } + } +} + +enum ModuleInfo<'a> { + Aliased(AliasedModuleInfo), + Defined(DefinedModuleInfo<'a>), +} + +struct AliasedModuleInfo { + /// This module's id. + pub id: usize, + /// The id of the other module that this is an alias of. + pub alias_of: usize, +} + /// Info that we keep track of on a per module-within-a-module-linking-bundle /// basis. /// /// These are created during during our `parse` pass and then used throughout /// our later passes. -#[derive(Clone, Default)] -pub(crate) struct ModuleInfo<'a> { - /// This module's id (i.e. its pre-order traversal index). - pub id: u32, - +#[derive(Default)] +struct DefinedModuleInfo<'a> { /// The raw sections from the original Wasm input. - pub raw_sections: Vec>, + raw_sections: Vec>, /// This vector has `n` entries when the module has `n` import sections. The /// `i`th entry is a count of how many instance imports are in the `i`th /// import section. - pub instance_import_counts: Vec, + instance_import_counts: Vec, /// Types available in this module. /// /// We keep track of these for determining how many things we need to /// re-export for new instantiations and for inner module's aliases. - pub types: Vec>, + types: Vec>, /// Imports made by this module. - pub imports: Vec>, + imports: Vec>, /// Aliases that this module defines. - pub aliases: Vec>, - - /// How many more not-yet-parsed child modules are expected for this module? - /// - /// This is only used during parsing. - pub child_modules_expected: u32, + aliases: Vec>, /// Directly nested inner modules of this module. /// /// These entries are populated as we finish instrumenting the inner /// modules. - pub modules: Vec>, + modules: Vec, /// A map from instance indices to each instance's type for all defined, /// imported, and aliased instances. - pub instances: Vec>, + instances: Vec>, /// A map from indices of defined instantiations (as opposed to imported or /// aliased instantiations) to the id of the module that was instantiated /// and the import arguments. - pub instantiations: BTreeMap>)>, + instantiations: BTreeMap>)>, /// A map from global indices to each global's type for all defined, /// imported, and aliased globals. - pub globals: Vec, + globals: Vec, /// The index within the global index space where defined globals (as /// opposed to imported or aliased) begin. /// /// If this is `None`, then there are no locally defined globals. - pub defined_globals_index: Option, + defined_globals_index: Option, /// This module's exports. /// @@ -71,62 +121,208 @@ pub(crate) struct ModuleInfo<'a> { /// /// Note that this does *not* include the `__wizer_thing_N` exports that /// this instrumentation pass adds. - pub exports: Vec>, - - /// A currently-being-encoded module section. - /// - /// As we finish instrumenting child modules, we add them here. If we aren't - /// currently processing this module's children, then this is `None`. - pub module_section: Option, + exports: Vec>, /// Maps from function index to the function's type index for all functions /// defined, imported, and aliased in this module. - pub functions: Vec, + functions: Vec, /// Maps from table index to the table's type for all tables defined, /// imported, and aliased in this module. - pub tables: Vec, + tables: Vec, /// Maps from memory index to the memory's type for all memories defined, /// imported, and aliased in this module. - pub memories: Vec, + memories: Vec, /// The index within the memory index space where defined memories (as /// opposed to imported or aliased) begin. /// /// If this is `None`, then there are no locally defined memories. - pub defined_memories_index: Option, + defined_memories_index: Option, } -impl<'a> ModuleInfo<'a> { - /// Create the `ModuleInfo` for the root of a module-linking bundle. - pub fn for_root() -> Self { - Self::default() +/// A module inside a module linking bundle. +/// +/// This is a small, copy-able type that essentially just indexes into a +/// `ModuleContext`. +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] +pub(crate) struct Module { + /// This module's id, aka its pre-order traversal index, aka its index in + /// `Modules::arena`. + id: usize, +} + +impl Module { + /// Construct a new, defined module. + pub fn new_defined(cx: &mut ModuleContext) -> Self { + let id = cx.arena.len(); + cx.arena.push(ModuleInfo::Defined(Default::default())); + Module { id } } - /// Create a new `ModuleInfo` for an inner module. - pub fn for_inner(id: u32) -> Self { - Self { + /// Construct a new module that is an alias of the given module. + pub fn new_aliased(cx: &mut ModuleContext, alias_of: Module) -> Self { + let id = cx.arena.len(); + cx.arena.push(ModuleInfo::Aliased(AliasedModuleInfo { id, - ..Self::default() - } + alias_of: alias_of.id, + })); + Module { id } + } + + /// Get the pre-order traversal index of this module in its associated + /// module linking bundle. + pub fn pre_order_index(self) -> u32 { + u32::try_from(self.id).unwrap() } /// Add a new raw section to this module info during parsing. - pub fn add_raw_section( - &mut self, + pub fn add_raw_section<'a>( + self, + cx: &mut ModuleContext<'a>, id: SectionId, range: wasmparser::Range, full_wasm: &'a [u8], ) { - self.raw_sections.push(wasm_encoder::RawSection { - id: id as u8, - data: &full_wasm[range.start..range.end], - }) + cx.defined_mut(self) + .raw_sections + .push(wasm_encoder::RawSection { + id: id as u8, + data: &full_wasm[range.start..range.end], + }) + } + + /// Push a new type into this module's types space. + pub fn push_type<'a>(self, cx: &mut ModuleContext<'a>, ty: wasmparser::TypeDef<'a>) { + cx.defined_mut(self).types.push(ty); + } + + /// Push a new module onto this module's list of nested child modules. + pub fn push_child_module(self, cx: &mut ModuleContext<'_>, child: Module) { + cx.defined_mut(self).modules.push(child); + } + + /// Push a new, aliased instance into this module's instance index space. + pub fn push_aliased_instance<'a>( + self, + cx: &mut ModuleContext<'a>, + instance_type: wasmparser::InstanceType<'a>, + ) { + cx.defined_mut(self).instances.push(instance_type); + } + + /// Push a new, imported instance into this module's instance index space. + pub fn push_imported_instance<'a>( + self, + cx: &mut ModuleContext<'a>, + instance_type: wasmparser::InstanceType<'a>, + ) { + cx.defined_mut(self).instances.push(instance_type); + } + + /// Push a new, imported instance into this module's instance index space. + pub fn push_defined_instance<'a>( + self, + cx: &mut ModuleContext<'a>, + instance_type: wasmparser::InstanceType<'a>, + module: Module, + args: Vec>, + ) { + let info = cx.defined_mut(self); + let index = u32::try_from(info.instances.len()).unwrap(); + info.instances.push(instance_type); + info.instantiations.insert(index, (module, args)); + } + + /// Push a new imported memory into this module's memory index space. + pub fn push_imported_memory(self, cx: &mut ModuleContext, memory_type: wasmparser::MemoryType) { + let info = cx.defined_mut(self); + assert!(info.defined_memories_index.is_none()); + info.memories.push(memory_type); + } + + /// Push a new defined memory into this module's memory index space. + pub fn push_defined_memory(self, cx: &mut ModuleContext, memory_type: wasmparser::MemoryType) { + let info = cx.defined_mut(self); + if info.defined_memories_index.is_none() { + info.defined_memories_index = Some(u32::try_from(info.memories.len()).unwrap()); + } + info.memories.push(memory_type); + } + + /// Push a new imported global into this module's global index space. + pub fn push_imported_global(self, cx: &mut ModuleContext, global_type: wasmparser::GlobalType) { + let info = cx.defined_mut(self); + assert!(info.defined_globals_index.is_none()); + info.globals.push(global_type); + } + + /// Push a new defined global into this module's global index space. + pub fn push_defined_global(self, cx: &mut ModuleContext, global_type: wasmparser::GlobalType) { + let info = cx.defined_mut(self); + if info.defined_globals_index.is_none() { + info.defined_globals_index = Some(u32::try_from(info.globals.len()).unwrap()); + } + info.globals.push(global_type); + } + + /// Push a new function into this module's function index space. + pub fn push_function(self, cx: &mut ModuleContext, func_type: u32) { + cx.defined_mut(self).functions.push(func_type); + } + + /// Push a new table into this module's table index space. + pub fn push_table(self, cx: &mut ModuleContext, table_type: wasmparser::TableType) { + cx.defined_mut(self).tables.push(table_type); + } + + /// Push a new import into this module. + pub fn push_import<'a>(self, cx: &mut ModuleContext<'a>, import: wasmparser::Import<'a>) { + cx.defined_mut(self).imports.push(import); + + // Add the import to the appropriate index space for our current module. + match import.ty { + wasmparser::ImportSectionEntryType::Memory(ty) => { + self.push_imported_memory(cx, ty); + } + wasmparser::ImportSectionEntryType::Global(ty) => { + self.push_imported_global(cx, ty); + } + wasmparser::ImportSectionEntryType::Instance(ty_idx) => { + let ty = self.instance_type_at(cx, ty_idx).clone(); + self.push_imported_instance(cx, ty); + } + wasmparser::ImportSectionEntryType::Function(func_ty) => { + self.push_function(cx, func_ty); + } + wasmparser::ImportSectionEntryType::Table(ty) => { + self.push_table(cx, ty); + } + wasmparser::ImportSectionEntryType::Module(_) + | wasmparser::ImportSectionEntryType::Event(_) => { + unreachable!() + } + } + } + + /// Push a count of how many instance imports an import section had. + pub fn push_instance_import_count(self, cx: &mut ModuleContext, count: u32) { + cx.defined_mut(self).instance_import_counts.push(count); + } + + /// Push an alias into this module. + pub fn push_alias<'a>(self, cx: &mut ModuleContext<'a>, alias: wasmparser::Alias<'a>) { + cx.defined_mut(self).aliases.push(alias); + } + + /// Push an export into this module. + pub fn push_export<'a>(self, cx: &mut ModuleContext<'a>, export: wasmparser::Export<'a>) { + cx.defined_mut(self).exports.push(export); } /// Is this the root of the module linking bundle? - pub fn is_root(&self) -> bool { + pub fn is_root(self) -> bool { self.id == 0 } @@ -135,29 +331,31 @@ impl<'a> ModuleInfo<'a> { /// Returns the index of the type and updates the total count of types in /// `num_types`. pub fn define_instance_type( - &self, + self, + cx: &ModuleContext<'_>, num_types: &mut u32, types: &mut wasm_encoder::TypeSection, ) -> u32 { let ty_index = *num_types; - types.instance(self.exports.iter().map(|e| { + let info = cx.resolve(self); + types.instance(info.exports.iter().map(|e| { let name = e.field; let index = usize::try_from(e.index).unwrap(); let item = match e.kind { wasmparser::ExternalKind::Function => { - let func_ty = self.functions[index]; + let func_ty = info.functions[index]; wasm_encoder::EntityType::Function(func_ty) } wasmparser::ExternalKind::Table => { - let ty = self.tables[index]; + let ty = info.tables[index]; wasm_encoder::EntityType::Table(translate::table_type(ty)) } wasmparser::ExternalKind::Memory => { - let ty = self.memories[index]; + let ty = info.memories[index]; wasm_encoder::EntityType::Memory(translate::memory_type(ty)) } wasmparser::ExternalKind::Global => { - let ty = self.globals[index]; + let ty = info.globals[index]; wasm_encoder::EntityType::Global(translate::global_type(ty)) } wasmparser::ExternalKind::Instance => wasm_encoder::EntityType::Instance(e.index), @@ -172,9 +370,10 @@ impl<'a> ModuleInfo<'a> { } /// Construct an instance type for instances of this module. - pub fn instance_type(&self) -> wasmparser::InstanceType<'a> { + pub fn instance_type<'a>(self, cx: &ModuleContext<'a>) -> wasmparser::InstanceType<'a> { + let info = cx.resolve(self); wasmparser::InstanceType { - exports: self + exports: info .exports .iter() .map(|e| { @@ -183,19 +382,19 @@ impl<'a> ModuleInfo<'a> { name: e.field, ty: match e.kind { wasmparser::ExternalKind::Function => { - let func_ty = self.functions[index]; + let func_ty = info.functions[index]; wasmparser::ImportSectionEntryType::Function(func_ty) } wasmparser::ExternalKind::Table => { - let ty = self.tables[index]; + let ty = info.tables[index]; wasmparser::ImportSectionEntryType::Table(ty) } wasmparser::ExternalKind::Memory => { - let ty = self.memories[index]; + let ty = info.memories[index]; wasmparser::ImportSectionEntryType::Memory(ty) } wasmparser::ExternalKind::Global => { - let ty = self.globals[index]; + let ty = info.globals[index]; wasmparser::ImportSectionEntryType::Global(ty) } wasmparser::ExternalKind::Instance => { @@ -211,14 +410,27 @@ impl<'a> ModuleInfo<'a> { } } + /// Get the count of how many instance imports are in each import section in + /// this module. + pub fn instance_import_counts<'b>(self, cx: &'b ModuleContext<'_>) -> &'b [u32] { + &cx.resolve(self).instance_import_counts + } + + /// Get the aliases defined in this module. + pub fn aliases<'a, 'b>(self, cx: &'b ModuleContext<'a>) -> &'b [wasmparser::Alias<'a>] { + &cx.resolve(self).aliases + } + /// Get an export from the `n`th instance by name. pub fn instance_export( - &self, + self, + cx: &ModuleContext<'_>, instance: u32, name: &str, ) -> Option { let instance = usize::try_from(instance).unwrap(); - let instance = &self.instances[instance]; + let info = cx.resolve(self); + let instance = &info.instances[instance]; instance .exports .iter() @@ -227,62 +439,91 @@ impl<'a> ModuleInfo<'a> { } /// Do a pre-order traversal over this module tree. - pub fn pre_order<'b, F>(&'b self, mut f: F) + pub fn pre_order(self, cx: &ModuleContext<'_>, mut f: F) where - F: FnMut(&'b ModuleInfo<'a>), + F: FnMut(Module), { let mut stack = vec![self]; - while let Some(info) = stack.pop() { - f(info); - stack.extend(info.modules.iter().rev()); + while let Some(module) = stack.pop() { + f(module); + let info = cx.resolve(module); + stack.extend(info.modules.iter().copied().rev()); } } + /// Get the first index in the memory space where a memory is defined rather + /// than aliased or imported. + pub fn defined_memories_index(self, cx: &ModuleContext) -> Option { + cx.resolve(self).defined_memories_index + } + /// The number of defined memories in this module. - pub fn defined_memories_len(&self) -> usize { - self.defined_memories_index.map_or(0, |n| { + pub fn defined_memories_len(self, cx: &ModuleContext) -> usize { + let info = cx.resolve(self); + info.defined_memories_index.map_or(0, |n| { let n = usize::try_from(n).unwrap(); - assert!(self.memories.len() > n); - self.memories.len() - n + assert!(info.memories.len() > n); + info.memories.len() - n }) } /// Iterate over the defined memories in this module. - pub fn defined_memories<'b>(&'b self) -> impl Iterator + 'b { - self.memories + pub fn defined_memories<'b>( + self, + cx: &'b ModuleContext<'_>, + ) -> impl Iterator + 'b { + let info = cx.resolve(self); + info.memories .iter() + .copied() + .enumerate() .skip( - self.defined_memories_index - .map_or(self.memories.len(), |i| usize::try_from(i).unwrap()), + info.defined_memories_index + .map_or(info.memories.len(), |i| usize::try_from(i).unwrap()), ) - .copied() + .map(|(i, m)| (u32::try_from(i).unwrap(), m)) + } + + /// Get the first index in the global space where a global is defined rather + /// than aliased or imported. + pub fn defined_globals_index(self, cx: &ModuleContext) -> Option { + cx.resolve(self).defined_globals_index } /// The number of defined globals in this module. - pub fn defined_globals_len(&self) -> usize { - self.defined_globals_index.map_or(0, |n| { + pub fn defined_globals_len(self, cx: &ModuleContext<'_>) -> usize { + let info = cx.resolve(self); + info.defined_globals_index.map_or(0, |n| { let n = usize::try_from(n).unwrap(); - assert!(self.globals.len() > n); - self.globals.len() - n + assert!(info.globals.len() > n); + info.globals.len() - n }) } /// Iterate over the defined globals in this module. - pub fn defined_globals<'b>(&'b self) -> impl Iterator + 'b { - self.globals + pub fn defined_globals<'b>( + self, + cx: &'b ModuleContext<'_>, + ) -> impl Iterator + 'b { + let info = cx.resolve(self); + info.globals .iter() + .copied() + .enumerate() .skip( - self.defined_globals_index - .map_or(self.globals.len(), |i| usize::try_from(i).unwrap()), + info.defined_globals_index + .map_or(info.globals.len(), |i| usize::try_from(i).unwrap()), ) - .copied() + .map(|(i, g)| (u32::try_from(i).unwrap(), g)) } /// Iterate over the initial sections in this Wasm module. - pub fn initial_sections<'b>( - &'b self, - ) -> impl Iterator + 'b { - self.raw_sections + pub fn initial_sections<'a, 'b>( + self, + cx: &'b ModuleContext<'a>, + ) -> impl Iterator> + 'b { + let info = cx.resolve(self); + info.raw_sections .iter() .filter(|s| s.id != SectionId::Custom.into()) .take_while(|s| match s.id { @@ -294,4 +535,76 @@ impl<'a> ModuleInfo<'a> { _ => false, }) } + + /// Get a slice of this module's original raw sections. + pub fn raw_sections<'a, 'b>( + self, + cx: &'b ModuleContext<'a>, + ) -> &'b [wasm_encoder::RawSection<'a>] { + &cx.resolve(self).raw_sections + } + + /// Get a slice of this module's nested child modules. + pub fn child_modules<'b>(self, cx: &'b ModuleContext<'_>) -> &'b [Module] { + &cx.resolve(self).modules + } + + /// Get a slice of this module's exports. + pub fn exports<'a, 'b>(self, cx: &'b ModuleContext<'a>) -> &'b [wasmparser::Export<'a>] { + &cx.resolve(self).exports + } + + /// Get a slice of this module's imports. + pub fn imports<'a, 'b>(self, cx: &'b ModuleContext<'a>) -> &'b [wasmparser::Import<'a>] { + &cx.resolve(self).imports + } + + /// Get this module's defined (as opposed to imported or aliased) + /// instantiations. + /// + /// The return value maps an instance index to the module that was + /// instantiated and the associated instantiation arguments. + pub fn instantiations<'a, 'b>( + self, + cx: &'b ModuleContext<'a>, + ) -> &'b BTreeMap>)> { + &cx.resolve(self).instantiations + } + + /// Get this module's `n`th nested child module. + pub fn child_module_at(self, cx: &ModuleContext<'_>, n: u32) -> Module { + cx.resolve(self).modules[usize::try_from(n).unwrap()] + } + + /// Get the full types index space for this module. + pub fn types<'a, 'b>(self, cx: &'b ModuleContext<'a>) -> &'b [wasmparser::TypeDef<'a>] { + &cx.resolve(self).types + } + + /// Get the type at the given index. + /// + /// Panics if the types index space does not contain the given index. + pub fn type_at<'a, 'b>( + self, + cx: &'b ModuleContext<'a>, + type_index: u32, + ) -> &'b wasmparser::TypeDef<'a> { + &cx.resolve(self).types[usize::try_from(type_index).unwrap()] + } + + /// Get the instance type at the given type index. + /// + /// Panics if the types index space does not contain the given index or the + /// type at the index is not an instance type. + pub fn instance_type_at<'a, 'b>( + self, + cx: &'b ModuleContext<'a>, + type_index: u32, + ) -> &'b wasmparser::InstanceType<'a> { + if let wasmparser::TypeDef::Instance(ity) = self.type_at(cx, type_index) { + ity + } else { + panic!("not an instance type") + } + } } diff --git a/crates/wizer/src/instrument.rs b/crates/wizer/src/instrument.rs index 25a66648a463..37aeb6e47bb0 100644 --- a/crates/wizer/src/instrument.rs +++ b/crates/wizer/src/instrument.rs @@ -1,6 +1,6 @@ //! The initial instrumentation pass. -use crate::info::ModuleInfo; +use crate::info::{Module, ModuleContext}; use crate::stack_ext::StackExt; use std::convert::TryFrom; use wasm_encoder::SectionId; @@ -59,15 +59,15 @@ use wasm_encoder::SectionId; /// export their memories and globals individually, that would disturb the /// modules locally defined memoryies' and globals' indices, which would require /// rewriting the code section, which would break debug info offsets. -pub(crate) fn instrument(root_info: &ModuleInfo) -> Vec { +pub(crate) fn instrument(cx: &ModuleContext<'_>) -> Vec { log::debug!("Instrumenting the input Wasm"); struct StackEntry<'a> { - /// This entry's module info. - info: &'a ModuleInfo<'a>, + /// This entry's module. + module: Module, /// The work-in-progress encoding of the new, instrumented module. - module: wasm_encoder::Module, + encoder: wasm_encoder::Module, /// Sections in this module info that we are iterating over. sections: std::slice::Iter<'a, wasm_encoder::RawSection<'a>>, @@ -78,7 +78,7 @@ pub(crate) fn instrument(root_info: &ModuleInfo) -> Vec { /// Nested child modules that still need to be instrumented and added to /// one of this entry's module's module sections. - children: std::slice::Iter<'a, ModuleInfo<'a>>, + children: std::slice::Iter<'a, Module>, /// The current module section we are building for this entry's /// module. Only `Some` if we are currently processing this module's @@ -91,12 +91,13 @@ pub(crate) fn instrument(root_info: &ModuleInfo) -> Vec { children_remaining: usize, } + let root = cx.root(); let mut stack = vec![StackEntry { - info: root_info, - module: wasm_encoder::Module::new(), - sections: root_info.raw_sections.iter(), + module: root, + encoder: wasm_encoder::Module::new(), + sections: root.raw_sections(cx).iter(), parent_index: None, - children: root_info.modules.iter(), + children: root.child_modules(cx).iter(), module_section: None, children_remaining: 0, }]; @@ -113,7 +114,7 @@ pub(crate) fn instrument(root_info: &ModuleInfo) -> Vec { let mut exports = wasm_encoder::ExportSection::new(); // First, copy over all the original exports. - for export in &entry.info.exports { + for export in entry.module.exports(cx) { exports.export( export.field, match export.kind { @@ -144,26 +145,20 @@ pub(crate) fn instrument(root_info: &ModuleInfo) -> Vec { // Now export all of this module's defined globals, memories, // and instantiations under well-known names so we can inspect // them after initialization. - for (i, j) in (entry.info.defined_globals_index.unwrap_or(u32::MAX) - ..u32::try_from(entry.info.globals.len()).unwrap()) - .enumerate() - { + for (i, (j, _)) in entry.module.defined_globals(cx).enumerate() { let name = format!("__wizer_global_{}", i); exports.export(&name, wasm_encoder::Export::Global(j)); } - for (i, j) in (entry.info.defined_memories_index.unwrap_or(u32::MAX) - ..u32::try_from(entry.info.memories.len()).unwrap()) - .enumerate() - { + for (i, (j, _)) in entry.module.defined_memories(cx).enumerate() { let name = format!("__wizer_memory_{}", i); exports.export(&name, wasm_encoder::Export::Memory(j)); } - for (i, j) in entry.info.instantiations.keys().enumerate() { + for (i, j) in entry.module.instantiations(cx).keys().enumerate() { let name = format!("__wizer_instance_{}", i); exports.export(&name, wasm_encoder::Export::Instance(*j)); } - entry.module.section(&exports); + entry.encoder.section(&exports); } // Nested module sections need to recursively instrument each child @@ -186,6 +181,7 @@ pub(crate) fn instrument(root_info: &ModuleInfo) -> Vec { .top_mut() .children .by_ref() + .copied() .take(count) .collect::>(); @@ -202,11 +198,11 @@ pub(crate) fn instrument(root_info: &ModuleInfo) -> Vec { // Reverse so that we pop them off the stack in order. .rev() .map(|c| StackEntry { - info: c, - module: wasm_encoder::Module::new(), - sections: c.raw_sections.iter(), + module: c, + encoder: wasm_encoder::Module::new(), + sections: c.raw_sections(cx).iter(), parent_index, - children: c.modules.iter(), + children: c.child_modules(cx).iter(), module_section: None, children_remaining: 0, }), @@ -221,9 +217,9 @@ pub(crate) fn instrument(root_info: &ModuleInfo) -> Vec { assert!(entry.module_section.is_none()); assert_eq!(entry.children_remaining, 0); - if entry.info.is_root() { + if entry.module.is_root() { assert!(stack.is_empty()); - return entry.module.finish(); + return entry.encoder.finish(); } let parent = &mut stack[entry.parent_index.unwrap()]; @@ -231,21 +227,21 @@ pub(crate) fn instrument(root_info: &ModuleInfo) -> Vec { .module_section .as_mut() .unwrap() - .module(&entry.module); + .module(&entry.encoder); assert!(parent.children_remaining > 0); parent.children_remaining -= 1; if parent.children_remaining == 0 { let module_section = parent.module_section.take().unwrap(); - parent.module.section(&module_section); + parent.encoder.section(&module_section); } } // All other sections don't need instrumentation and can be copied // over directly. Some(section) => { - stack.top_mut().module.section(section); + stack.top_mut().encoder.section(section); } } } diff --git a/crates/wizer/src/lib.rs b/crates/wizer/src/lib.rs index cd30c24366b0..a504b4144383 100644 --- a/crates/wizer/src/lib.rs +++ b/crates/wizer/src/lib.rs @@ -302,8 +302,8 @@ impl Wizer { // Make sure we're given valid Wasm from the get go. self.wasm_validate(&wasm)?; - let info = parse::parse(wasm)?; - let wasm = instrument::instrument(&info); + let cx = parse::parse(wasm)?; + let wasm = instrument::instrument(&cx); if cfg!(debug_assertions) { if let Err(error) = self.wasm_validate(&wasm) { @@ -320,7 +320,7 @@ impl Wizer { let instance = self.initialize(&store, &module)?; let snapshot = snapshot::snapshot(&store, &instance); - let initialized_wasm = self.rewrite(&snapshot, &info, &renames); + let initialized_wasm = self.rewrite(&cx, &snapshot, &renames); if cfg!(debug_assertions) { if let Err(error) = self.wasm_validate(&initialized_wasm) { diff --git a/crates/wizer/src/parse.rs b/crates/wizer/src/parse.rs index 50ff063007e6..6437afeca305 100644 --- a/crates/wizer/src/parse.rs +++ b/crates/wizer/src/parse.rs @@ -1,36 +1,34 @@ -use crate::info::ModuleInfo; +use crate::info::{Module, ModuleContext}; use crate::stack_ext::StackExt; use anyhow::{Context, Result}; use std::convert::TryFrom; use wasm_encoder::SectionId; use wasmparser::{SectionReader, SectionWithLimitedItems}; +struct StackEntry { + parser: wasmparser::Parser, + module: Module, +} + /// Parse the given Wasm bytes into a `ModuleInfo` tree. -pub(crate) fn parse<'a>(full_wasm: &'a [u8]) -> anyhow::Result> { +pub(crate) fn parse<'a>(full_wasm: &'a [u8]) -> anyhow::Result> { log::debug!("Parsing the input Wasm"); + let mut cx = ModuleContext::new(); + // The wasm we are currently parsing. This is advanced as the parser // consumes input. let mut wasm = full_wasm; - // The counter for making unique-within-the-whole-bundle module identifiers - // (i.e. the module's pre-order traversal index). - let mut id_counter = 0; - - // The stack of module infos we are parsing. As we visit inner modules - // during parsing, we push new entries, and when we finish processing them, - // we pop them. - let mut stack = vec![ModuleInfo::for_root()]; - - // Stack of parsers for each module we are parsing. Has a parallel structure - // to `stack`. - let mut parsers = vec![wasmparser::Parser::new(0)]; + let mut stack = vec![StackEntry { + parser: wasmparser::Parser::new(0), + module: cx.root(), + }]; loop { - assert_eq!(stack.len(), parsers.len()); - - let (payload, consumed) = match parsers + let (payload, consumed) = match stack .top_mut() + .parser .parse(wasm, true) .context("failed to parse Wasm")? { @@ -42,100 +40,110 @@ pub(crate) fn parse<'a>(full_wasm: &'a [u8]) -> anyhow::Result> { use wasmparser::Payload::*; match payload { Version { .. } => {} - TypeSection(types) => type_section(&mut stack, full_wasm, types)?, - ImportSection(imports) => import_section(&mut stack, full_wasm, imports)?, - AliasSection(aliases) => alias_section(&mut stack, full_wasm, aliases)?, - InstanceSection(instances) => instance_section(&mut stack, full_wasm, instances)?, + TypeSection(types) => type_section(&mut cx, &mut stack, full_wasm, types)?, + ImportSection(imports) => import_section(&mut cx, &mut stack, full_wasm, imports)?, + AliasSection(aliases) => alias_section(&mut cx, &mut stack, full_wasm, aliases)?, + InstanceSection(instances) => { + instance_section(&mut cx, &mut stack, full_wasm, instances)? + } ModuleSectionStart { range, size: _, count: _, } => { - let info = stack.top_mut(); - info.add_raw_section(SectionId::Module, range, full_wasm); + stack.top_mut().module.add_raw_section( + &mut cx, + SectionId::Module, + range, + full_wasm, + ); } ModuleSectionEntry { parser, range: _ } => { - id_counter += 1; - stack.push(ModuleInfo::for_inner(id_counter)); - parsers.push(parser); + stack.push(StackEntry { + parser, + module: Module::new_defined(&mut cx), + }); } - FunctionSection(funcs) => function_section(&mut stack, full_wasm, funcs)?, - TableSection(tables) => table_section(&mut stack, full_wasm, tables)?, - MemorySection(mems) => memory_section(&mut stack, full_wasm, mems)?, - GlobalSection(globals) => global_section(&mut stack, full_wasm, globals)?, - ExportSection(exports) => export_section(&mut stack, full_wasm, exports)?, + FunctionSection(funcs) => function_section(&mut cx, &mut stack, full_wasm, funcs)?, + TableSection(tables) => table_section(&mut cx, &mut stack, full_wasm, tables)?, + MemorySection(mems) => memory_section(&mut cx, &mut stack, full_wasm, mems)?, + GlobalSection(globals) => global_section(&mut cx, &mut stack, full_wasm, globals)?, + ExportSection(exports) => export_section(&mut cx, &mut stack, full_wasm, exports)?, StartSection { func: _, range } => { stack .top_mut() - .add_raw_section(SectionId::Start, range, full_wasm) - } - ElementSection(elems) => { - stack - .top_mut() - .add_raw_section(SectionId::Element, elems.range(), full_wasm) + .module + .add_raw_section(&mut cx, SectionId::Start, range, full_wasm) } + ElementSection(elems) => stack.top_mut().module.add_raw_section( + &mut cx, + SectionId::Element, + elems.range(), + full_wasm, + ), DataCountSection { .. } => unreachable!("validation rejects bulk memory"), - DataSection(data) => { - stack - .top_mut() - .add_raw_section(SectionId::Data, data.range(), full_wasm) - } + DataSection(data) => stack.top_mut().module.add_raw_section( + &mut cx, + SectionId::Data, + data.range(), + full_wasm, + ), CustomSection { range, .. } => { stack .top_mut() - .add_raw_section(SectionId::Custom, range, full_wasm) + .module + .add_raw_section(&mut cx, SectionId::Custom, range, full_wasm) } CodeSectionStart { range, count: _, size, } => { - parsers.top_mut().skip_section(); wasm = &wasm[usize::try_from(size).unwrap()..]; - stack - .top_mut() - .add_raw_section(SectionId::Code, range, full_wasm) + let entry = stack.top_mut(); + entry.parser.skip_section(); + entry + .module + .add_raw_section(&mut cx, SectionId::Code, range, full_wasm) } CodeSectionEntry(_) => unreachable!(), UnknownSection { .. } => anyhow::bail!("unknown section"), EventSection(_) => anyhow::bail!("exceptions are not supported yet"), End => { - let info = stack.pop().unwrap(); - parsers.pop(); + let entry = stack.pop().unwrap(); // If we finished parsing the root Wasm module, then we're done. - if info.is_root() { + if entry.module.is_root() { assert!(stack.is_empty()); - assert!(parsers.is_empty()); - return Ok(info); + return Ok(cx); } // Otherwise, we need to add this module to its parent's module // section. let parent = stack.top_mut(); - parent.modules.push(info); + parent.module.push_child_module(&mut cx, entry.module); } } } } fn type_section<'a>( - stack: &mut Vec>, + cx: &mut ModuleContext<'a>, + stack: &mut Vec, full_wasm: &'a [u8], mut types: wasmparser::TypeSectionReader<'a>, ) -> anyhow::Result<()> { - let info = stack.top_mut(); - info.add_raw_section(SectionId::Type, types.range(), full_wasm); + let module = stack.top().module; + module.add_raw_section(cx, SectionId::Type, types.range(), full_wasm); // Parse out types, as we will need them later when processing // instance imports. let count = usize::try_from(types.get_count()).unwrap(); - info.types.reserve(count); for _ in 0..count { let ty = types.read()?; match ty { wasmparser::TypeDef::Func(_) | wasmparser::TypeDef::Instance(_) => { - info.types.push(ty); + module.push_type(cx, ty); } // We need to disallow module imports, even within nested modules @@ -190,7 +198,7 @@ fn type_section<'a>( // can disallow module types to reject all of them in one fell // swoop. wasmparser::TypeDef::Module(_) => Err(anyhow::anyhow!( - "wizer does not support importing or exporting modules or module types" + "wizer does not support importing or exporting modules" ) .context("module types are not supported"))?, } @@ -200,13 +208,16 @@ fn type_section<'a>( } fn import_section<'a>( - stack: &mut Vec>, + cx: &mut ModuleContext<'a>, + stack: &mut Vec, full_wasm: &'a [u8], mut imports: wasmparser::ImportSectionReader<'a>, ) -> anyhow::Result<()> { + let module = stack.top().module; stack .top_mut() - .add_raw_section(SectionId::Import, imports.range(), full_wasm); + .module + .add_raw_section(cx, SectionId::Import, imports.range(), full_wasm); let mut instance_import_count = 0; @@ -214,8 +225,6 @@ fn import_section<'a>( let count = imports.get_count(); for _ in 0..count { let imp = imports.read()?; - stack.top_mut().imports.push(imp); - check_import_type(&stack.top().types, stack.top().is_root(), &imp.ty)?; if imp.module.starts_with("__wizer_") || imp.field.map_or(false, |f| f.starts_with("__wizer_")) @@ -225,46 +234,18 @@ fn import_section<'a>( ); } - // Add the import to the appropriate index space for our current module. - match imp.ty { - wasmparser::ImportSectionEntryType::Memory(ty) => { - assert!(stack.top().defined_memories_index.is_none()); - stack.top_mut().memories.push(ty); - } - wasmparser::ImportSectionEntryType::Global(ty) => { - assert!(stack.top().defined_globals_index.is_none()); - stack.top_mut().globals.push(ty); - } - wasmparser::ImportSectionEntryType::Instance(ty_idx) => { - let info = stack.top_mut(); - let ty = match &info.types[usize::try_from(ty_idx).unwrap()] { - wasmparser::TypeDef::Instance(ty) => ty.clone(), - _ => unreachable!(), - }; - info.instances.push(ty); - instance_import_count += 1; - } - wasmparser::ImportSectionEntryType::Function(func_ty) => { - stack.top_mut().functions.push(func_ty); - } - wasmparser::ImportSectionEntryType::Table(ty) => { - stack.top_mut().tables.push(ty); - } - - wasmparser::ImportSectionEntryType::Module(_) => { - unreachable!() - } - wasmparser::ImportSectionEntryType::Event(_) => { - unreachable!("should have been rejected by validation") - } + check_import_type( + &stack.top().module.types(cx), + stack.top().module.is_root(), + &imp.ty, + )?; + if let wasmparser::ImportSectionEntryType::Instance(_) = imp.ty { + instance_import_count += 1; } + module.push_import(cx, imp); } - stack - .top_mut() - .instance_import_counts - .push(instance_import_count); - + module.push_instance_import_count(cx, instance_import_count); Ok(()) } @@ -319,13 +300,13 @@ fn check_import_type( } fn alias_section<'a>( - stack: &mut Vec>, + cx: &mut ModuleContext<'a>, + stack: &mut Vec, full_wasm: &'a [u8], mut aliases: wasmparser::AliasSectionReader<'a>, ) -> anyhow::Result<()> { - stack - .top_mut() - .add_raw_section(SectionId::Alias, aliases.range(), full_wasm); + let module = stack.top().module; + module.add_raw_section(cx, SectionId::Alias, aliases.range(), full_wasm); // Clone any aliases over into this module's index spaces. for _ in 0..aliases.get_count() { @@ -336,22 +317,26 @@ fn alias_section<'a>( index, } => { let relative_depth = usize::try_from(*relative_depth).unwrap(); - let index = usize::try_from(*index).unwrap(); // NB: `- 2` rather than `- 1` because // `relative_depth=0` means this module's immediate // parent, not this module itself. - let ty = stack[stack.len() - 2 - relative_depth].types[index].clone(); - stack.top_mut().types.push(ty); + let ty = stack[stack.len() - 2 - relative_depth] + .module + .type_at(cx, *index) + .clone(); + module.push_type(cx, ty); } wasmparser::Alias::OuterModule { relative_depth, index, } => { let relative_depth = usize::try_from(*relative_depth).unwrap(); - let index = usize::try_from(*index).unwrap(); // Ditto regarding `- 2`. - let module = stack[stack.len() - 2 - relative_depth].modules[index].clone(); - stack.top_mut().modules.push(module); + let alias_of = stack[stack.len() - 2 - relative_depth] + .module + .child_module_at(cx, *index); + let aliased = Module::new_aliased(cx, alias_of); + module.push_child_module(cx, aliased); } wasmparser::Alias::InstanceExport { instance, @@ -362,50 +347,40 @@ fn alias_section<'a>( anyhow::bail!("exported modules are not supported yet") } wasmparser::ExternalKind::Instance => { - let info = stack.top_mut(); - let inst_ty_idx = match info.instance_export(*instance, export) { + let inst_ty_idx = match module.instance_export(cx, *instance, export) { Some(wasmparser::ImportSectionEntryType::Instance(i)) => i, _ => unreachable!(), }; - let inst_ty = match &info.types[usize::try_from(inst_ty_idx).unwrap()] { - wasmparser::TypeDef::Instance(ty) => ty.clone(), - _ => unreachable!(), - }; - info.instances.push(inst_ty); + let inst_ty = module.instance_type_at(cx, inst_ty_idx).clone(); + module.push_aliased_instance(cx, inst_ty); } wasmparser::ExternalKind::Function => { - let info = stack.top_mut(); - let func_ty_idx = match info.instance_export(*instance, export) { + let func_ty_idx = match module.instance_export(cx, *instance, export) { Some(wasmparser::ImportSectionEntryType::Function(i)) => i, _ => unreachable!(), }; - info.functions.push(func_ty_idx); + module.push_function(cx, func_ty_idx); } wasmparser::ExternalKind::Table => { - let info = stack.top_mut(); - let table_ty = match info.instance_export(*instance, export) { + let table_ty = match module.instance_export(cx, *instance, export) { Some(wasmparser::ImportSectionEntryType::Table(ty)) => ty, _ => unreachable!(), }; - info.tables.push(table_ty); + module.push_table(cx, table_ty); } wasmparser::ExternalKind::Memory => { - let info = stack.top_mut(); - assert!(info.defined_memories_index.is_none()); - let ty = match info.instance_export(*instance, export) { + let ty = match module.instance_export(cx, *instance, export) { Some(wasmparser::ImportSectionEntryType::Memory(ty)) => ty, _ => unreachable!(), }; - info.memories.push(ty); + module.push_imported_memory(cx, ty); } wasmparser::ExternalKind::Global => { - let info = stack.top_mut(); - assert!(info.defined_globals_index.is_none()); - let ty = match info.instance_export(*instance, export) { + let ty = match module.instance_export(cx, *instance, export) { Some(wasmparser::ImportSectionEntryType::Global(ty)) => ty, _ => unreachable!(), }; - info.globals.push(ty); + module.push_imported_global(cx, ty); } wasmparser::ExternalKind::Event => { unreachable!("validation should reject the exceptions proposal") @@ -413,136 +388,118 @@ fn alias_section<'a>( wasmparser::ExternalKind::Type => unreachable!("can't export types"), }, } - stack.top_mut().aliases.push(alias); + module.push_alias(cx, alias); } Ok(()) } fn instance_section<'a>( - stack: &mut Vec>, + cx: &mut ModuleContext<'a>, + stack: &mut Vec, full_wasm: &'a [u8], mut instances: wasmparser::InstanceSectionReader<'a>, ) -> anyhow::Result<()> { - stack - .top_mut() - .add_raw_section(SectionId::Instance, instances.range(), full_wasm); + let module = stack.top().module; + module.add_raw_section(cx, SectionId::Instance, instances.range(), full_wasm); // Record the instantiations made in this module, and which modules were // instantiated. - let info = stack.top_mut(); for _ in 0..instances.get_count() { let inst = instances.read()?; - let module_index: usize = usize::try_from(inst.module()).unwrap(); - let module = &info.modules[module_index]; - let module_id = module.id; - let inst_ty = module.instance_type(); - - let mut import_args_reader = inst.args()?; - let import_args_count = usize::try_from(import_args_reader.get_count()).unwrap(); - let mut import_args = Vec::with_capacity(import_args_count); - for _ in 0..import_args_count { - import_args.push(import_args_reader.read()?); + let module_index = inst.module(); + let child_module = module.child_module_at(cx, module_index); + let inst_ty = child_module.instance_type(cx); + + let mut instance_args_reader = inst.args()?; + let instance_args_count = usize::try_from(instance_args_reader.get_count()).unwrap(); + let mut instance_args = Vec::with_capacity(instance_args_count); + for _ in 0..instance_args_count { + instance_args.push(instance_args_reader.read()?); } - info.instantiations.insert( - u32::try_from(info.instances.len()).unwrap(), - (module_id, import_args), - ); - info.instances.push(inst_ty); + module.push_defined_instance(cx, inst_ty, child_module, instance_args); } Ok(()) } fn function_section<'a>( - stack: &mut Vec>, + cx: &mut ModuleContext<'a>, + stack: &mut Vec, full_wasm: &'a [u8], mut funcs: wasmparser::FunctionSectionReader<'a>, ) -> anyhow::Result<()> { - stack - .top_mut() - .add_raw_section(SectionId::Function, funcs.range(), full_wasm); + let module = stack.top().module; + module.add_raw_section(cx, SectionId::Function, funcs.range(), full_wasm); - let info = stack.top_mut(); let count = usize::try_from(funcs.get_count()).unwrap(); - info.functions.reserve(count); for _ in 0..count { let ty = funcs.read()?; - info.functions.push(ty); + module.push_function(cx, ty); } Ok(()) } fn table_section<'a>( - stack: &mut Vec>, + cx: &mut ModuleContext<'a>, + stack: &mut Vec, full_wasm: &'a [u8], mut tables: wasmparser::TableSectionReader<'a>, ) -> anyhow::Result<()> { - stack - .top_mut() - .add_raw_section(SectionId::Table, tables.range(), full_wasm); + let module = stack.top().module; + module.add_raw_section(cx, SectionId::Table, tables.range(), full_wasm); - let info = stack.top_mut(); let count = usize::try_from(tables.get_count()).unwrap(); - info.tables.reserve(count); for _ in 0..count { - info.tables.push(tables.read()?); + module.push_table(cx, tables.read()?); } Ok(()) } fn memory_section<'a>( - stack: &mut Vec>, + cx: &mut ModuleContext<'a>, + stack: &mut Vec, full_wasm: &'a [u8], mut mems: wasmparser::MemorySectionReader<'a>, ) -> anyhow::Result<()> { - let info = stack.top_mut(); - info.add_raw_section(SectionId::Memory, mems.range(), full_wasm); - - assert!(info.defined_memories_index.is_none()); - info.defined_memories_index = Some(u32::try_from(info.memories.len()).unwrap()); + let module = stack.top().module; + module.add_raw_section(cx, SectionId::Memory, mems.range(), full_wasm); let count = usize::try_from(mems.get_count()).unwrap(); - info.memories.reserve(count); for _ in 0..count { let m = mems.read()?; - info.memories.push(m); + module.push_defined_memory(cx, m); } Ok(()) } fn global_section<'a>( - stack: &mut Vec>, + cx: &mut ModuleContext<'a>, + stack: &mut Vec, full_wasm: &'a [u8], mut globals: wasmparser::GlobalSectionReader<'a>, ) -> anyhow::Result<()> { - let info = stack.top_mut(); - info.add_raw_section(SectionId::Global, globals.range(), full_wasm); - - assert!(info.defined_globals_index.is_none()); - info.defined_globals_index = Some(u32::try_from(info.globals.len()).unwrap()); + let module = stack.top().module; + module.add_raw_section(cx, SectionId::Global, globals.range(), full_wasm); let count = usize::try_from(globals.get_count()).unwrap(); - info.globals.reserve(count); for _ in 0..count { let g = globals.read()?; - info.globals.push(g.ty); + module.push_defined_global(cx, g.ty); } - Ok(()) } fn export_section<'a>( - stack: &mut Vec>, + cx: &mut ModuleContext<'a>, + stack: &mut Vec, full_wasm: &'a [u8], mut exports: wasmparser::ExportSectionReader<'a>, ) -> anyhow::Result<()> { - stack - .top_mut() - .add_raw_section(SectionId::Export, exports.range(), full_wasm); + let module = stack.top().module; + module.add_raw_section(cx, SectionId::Export, exports.range(), full_wasm); - let info = stack.top_mut(); for _ in 0..exports.get_count() { let export = exports.read()?; @@ -564,7 +521,7 @@ fn export_section<'a>( | wasmparser::ExternalKind::Memory | wasmparser::ExternalKind::Global | wasmparser::ExternalKind::Instance => { - info.exports.push(export.clone()); + module.push_export(cx, export); } } } diff --git a/crates/wizer/src/rewrite.rs b/crates/wizer/src/rewrite.rs index b71125b0af81..1925ceb07728 100644 --- a/crates/wizer/src/rewrite.rs +++ b/crates/wizer/src/rewrite.rs @@ -2,7 +2,11 @@ mod renumbering; -use crate::{info::ModuleInfo, snapshot::Snapshot, translate, FuncRenames, Wizer}; +use crate::{ + info::{Module, ModuleContext}, + snapshot::Snapshot, + translate, FuncRenames, Wizer, +}; use renumbering::Renumbering; use std::{convert::TryFrom, iter}; use wasm_encoder::SectionId; @@ -118,54 +122,53 @@ impl Wizer { /// for those lifted instantiations, and the easiest way to do that is to /// flatten the code module tree (as opposed to re-exporting the nested /// modules under well-known symbols). The pre-order traversal ensures that - /// the `ModuleInfo::id` we assigned during the instrumentation phase - /// matches the module's place in the index space. The state modules, - /// however, remain a nested tree, and we emit them in a traversal of the - /// `Snapshot` instance tree. This is safe because, unlike code modules, - /// each state module is only instantiated exactly once. The instantiations' - /// references to nested modules become outer aliases pointing to the - /// module's position in the parent's flat sequence of nested modules. + /// the `Module::id` we assigned during the instrumentation phase matches + /// the module's place in the index space. The state modules, however, + /// remain a nested tree, and we emit them in a traversal of the `Snapshot` + /// instance tree. This is safe because, unlike code modules, each state + /// module is only instantiated exactly once. The instantiations' references + /// to nested modules become outer aliases pointing to the module's position + /// in the parent's flat sequence of nested modules. pub(crate) fn rewrite( &self, + cx: &ModuleContext, snapshot: &Snapshot, - info: &ModuleInfo, renames: &FuncRenames, ) -> Vec { log::debug!("Rewriting input Wasm to pre-initialized state"); + let root_info = cx.root(); let mut root = wasm_encoder::Module::new(); - let types = make_complete_type_section(info); + let types = make_complete_type_section(cx, root_info); root.section(&types); - let mut id_to_module_info = vec![]; - make_id_to_module_info(&mut id_to_module_info, info); - - let (code_modules, num_code_modules) = rewrite_code_modules(info, &id_to_module_info); + let (code_modules, num_code_modules) = rewrite_code_modules(cx); // Only add the module section if there are multiple code modules, // so that we avoid introducing the module section when module // linking isn't in use. if num_code_modules > 0 { root.section(&code_modules); - let state_modules = - rewrite_state_modules(info, &id_to_module_info, &snapshot.instantiations); + let state_modules = rewrite_state_modules(cx, &snapshot.instantiations); root.section(&state_modules); } - self.rewrite_root(&mut root, info, snapshot, renames, num_code_modules); + self.rewrite_root(cx, &mut root, snapshot, renames, num_code_modules); root.finish() } fn rewrite_root( &self, + cx: &ModuleContext, root: &mut wasm_encoder::Module, - root_info: &ModuleInfo, snapshot: &Snapshot, renames: &FuncRenames, num_code_modules: u32, ) { + let root_info = cx.root(); + // Encode the initialized data segments from the snapshot rather // than the original, uninitialized data segments. let mut data_section = if snapshot.data_segments.is_empty() { @@ -198,11 +201,11 @@ impl Wizer { // instance numbering. let mut instance_renumbering = Renumbering::default(); - let mut instance_import_counts = root_info.instance_import_counts.iter().copied(); - let mut instantiations = root_info.instantiations.values().enumerate(); - let mut aliases = root_info.aliases.iter(); + let mut instance_import_counts = root_info.instance_import_counts(cx).iter().copied(); + let mut instantiations = root_info.instantiations(cx).values().enumerate(); + let mut aliases = root_info.aliases(cx).iter(); - for section in &root_info.raw_sections { + for section in root_info.raw_sections(cx) { match section { // Some tools expect the name custom section to come last, even // though custom sections are allowed in any order. Therefore, @@ -259,7 +262,7 @@ impl Wizer { let count = wasmparser::InstanceSectionReader::new(s.data, 0) .unwrap() .get_count(); - for (nth_defined_inst, (module_id, instance_args)) in instantiations + for (nth_defined_inst, (module, instance_args)) in instantiations .by_ref() .take(usize::try_from(count).unwrap()) { @@ -295,7 +298,7 @@ impl Wizer { arg })) .collect(); - instances.instantiate(module_id - 1, args); + instances.instantiate(module.pre_order_index() - 1, args); instance_renumbering.define_both(); } root.section(&instances); @@ -352,9 +355,12 @@ impl Wizer { // memory. s if s.id == SectionId::Memory.into() => { let mut memories = wasm_encoder::MemorySection::new(); - assert_eq!(root_info.defined_memories_len(), snapshot.memory_mins.len()); - for (mem, new_min) in root_info - .defined_memories() + assert_eq!( + root_info.defined_memories_len(cx), + snapshot.memory_mins.len() + ); + for ((_, mem), new_min) in root_info + .defined_memories(cx) .zip(snapshot.memory_mins.iter().copied()) { let mut mem = translate::memory_type(mem); @@ -368,7 +374,9 @@ impl Wizer { // rather than the original values. s if s.id == SectionId::Global.into() => { let mut globals = wasm_encoder::GlobalSection::new(); - for (glob_ty, val) in root_info.defined_globals().zip(snapshot.globals.iter()) { + for ((_, glob_ty), val) in + root_info.defined_globals(cx).zip(snapshot.globals.iter()) + { let glob_ty = translate::global_type(glob_ty); globals.global( glob_ty, @@ -392,7 +400,7 @@ impl Wizer { // requested renames. s if s.id == SectionId::Export.into() => { let mut exports = wasm_encoder::ExportSection::new(); - for export in &root_info.exports { + for export in root_info.exports(cx) { if export.field == self.init_func { continue; } @@ -460,14 +468,11 @@ fn is_name_section(s: &wasm_encoder::RawSection) -> bool { /// /// Returns the modules encoded in a module section and total number of code /// modules defined. -fn rewrite_code_modules( - root_info: &ModuleInfo, - id_to_module_info: &Vec<&ModuleInfo>, -) -> (wasm_encoder::ModuleSection, u32) { +fn rewrite_code_modules(cx: &ModuleContext) -> (wasm_encoder::ModuleSection, u32) { let mut modules = wasm_encoder::ModuleSection::new(); let mut num_code_modules = 0; - root_info.pre_order(|info| { + cx.root().pre_order(cx, |info| { // The root module is handled by `rewrite_root`; we are only dealing // with nested children here. if info.is_root() { @@ -509,8 +514,8 @@ fn rewrite_code_modules( // avoid renumbering types, we do a first pass over this module's types // and build out a full type section with the same numbering as the // original module, and then append the state import's type at the end. - let mut types = make_complete_type_section(info); - let import = make_state_import(info, &mut types, id_to_module_info); + let mut types = make_complete_type_section(cx, info); + let import = make_state_import(cx, info, &mut types); module.section(&types); module.section(&import); @@ -522,10 +527,10 @@ fn rewrite_code_modules( // imports. We do *not* add all imports all at once. This is because // imports and aliases might be interleaved, and adding all imports all // at once could perturb entity numbering. - let mut sections = info.raw_sections.iter(); - let mut imports = info.imports.iter(); - let mut instantiations = 0..info.instantiations.len(); - let mut aliases = info.aliases.iter(); + let mut sections = info.raw_sections(cx).iter(); + let mut imports = info.imports(cx).iter(); + let mut instantiations = 0..info.instantiations(cx).len(); + let mut aliases = info.aliases(cx).iter(); let mut first_non_initial_section = None; for section in sections.by_ref() { match section { @@ -624,28 +629,23 @@ fn rewrite_code_modules( // numbering. Therefore we add these aliases here, after we've processed // the initial sections, but before we start with the rest of the // sections. - if let Some(defined_memories_index) = info.defined_memories_index { + if info.defined_memories_index(cx).is_some() { let mut section = wasm_encoder::AliasSection::new(); - let num_defined_memories = - info.memories.len() - usize::try_from(defined_memories_index).unwrap(); - for mem in 0..num_defined_memories { + for (i, _) in info.defined_memories(cx).enumerate() { // Our state instance is always instance 0. let from_instance = 0; - let name = format!("__wizer_memory_{}", mem); + let name = format!("__wizer_memory_{}", i); section.instance_export(from_instance, wasm_encoder::ItemKind::Memory, &name); } module.section(§ion); } // Globals are handled the same way as memories. - if let Some(defined_globals_index) = info.defined_globals_index { + if info.defined_globals_index(cx).is_some() { let mut section = wasm_encoder::AliasSection::new(); - let num_defined_globals = - info.globals.len() - usize::try_from(defined_globals_index).unwrap(); - for mem in 0..num_defined_globals { - // Our state instance is always instance 0. + for (i, _) in info.defined_globals(cx).enumerate() { let from_instance = 0; - let name = format!("__wizer_global_{}", mem); + let name = format!("__wizer_global_{}", i); section.instance_export(from_instance, wasm_encoder::ItemKind::Global, &name); } module.section(§ion); @@ -682,22 +682,12 @@ fn rewrite_code_modules( (modules, num_code_modules) } -/// Flatten the `ModuleInfo` tree into a vector that maps each module id -/// (i.e. pre-order index) to the associated module info. -fn make_id_to_module_info<'a>(id_to_info: &mut Vec<&'a ModuleInfo<'a>>, info: &'a ModuleInfo<'a>) { - debug_assert_eq!(u32::try_from(id_to_info.len()).unwrap(), info.id); - id_to_info.push(info); - for m in &info.modules { - make_id_to_module_info(id_to_info, m); - } -} - /// Make a single complete type section for the given module info, regardless of /// how many initial type sections these types might have been defined within in /// the original module's serialization. -fn make_complete_type_section(info: &ModuleInfo) -> wasm_encoder::TypeSection { +fn make_complete_type_section(cx: &ModuleContext, info: Module) -> wasm_encoder::TypeSection { let mut types = wasm_encoder::TypeSection::new(); - for ty in &info.types { + for ty in info.types(cx) { match ty { wasmparser::TypeDef::Func(func_ty) => { types.function( @@ -726,35 +716,32 @@ fn make_complete_type_section(info: &ModuleInfo) -> wasm_encoder::TypeSection { /// Make an import section that imports a code module's state instance import. fn make_state_import( - info: &ModuleInfo, + cx: &ModuleContext, + info: Module, types: &mut wasm_encoder::TypeSection, - id_to_module_info: &Vec<&ModuleInfo>, ) -> wasm_encoder::ImportSection { - let mut num_types = u32::try_from(info.types.len()).unwrap(); + let mut num_types = u32::try_from(info.types(cx).len()).unwrap(); // Define instance types for each of the instances that we // previously instantiated locally so that we can refer to // these types in the state instance's type. let instance_types = info - .instantiations + .instantiations(cx) .values() - .map(|(m, _)| { - id_to_module_info[usize::try_from(*m).unwrap()] - .define_instance_type(&mut num_types, types) - }) + .map(|(m, _)| m.define_instance_type(cx, &mut num_types, types)) .collect::>(); // Define the state instance's type. let state_instance_exports = info - .defined_globals() + .defined_globals(cx) .enumerate() - .map(|(i, g)| { + .map(|(i, (_, g))| { ( format!("__wizer_global_{}", i), wasm_encoder::EntityType::Global(translate::global_type(g)), ) }) - .chain(info.defined_memories().enumerate().map(|(i, m)| { + .chain(info.defined_memories(cx).enumerate().map(|(i, (_, m))| { ( format!("__wizer_memory_{}", i), wasm_encoder::EntityType::Memory(translate::memory_type(m)), @@ -801,16 +788,14 @@ fn make_state_import( /// i.e. another recursive invocation of this function that is one frame up the /// stack). fn rewrite_state_modules( - info: &ModuleInfo, - id_to_module_info: &Vec<&ModuleInfo>, + cx: &ModuleContext, snapshots: &[Snapshot], ) -> wasm_encoder::ModuleSection { let mut modules = wasm_encoder::ModuleSection::new(); - assert_eq!(snapshots.len(), info.instantiations.len()); - for (snapshot, (module_id, _)) in snapshots.iter().zip(info.instantiations.values()) { - let module_info = &id_to_module_info[usize::try_from(*module_id).unwrap()]; - let state_module = rewrite_one_state_module(module_info, id_to_module_info, snapshot, 0); + assert_eq!(snapshots.len(), cx.root().instantiations(cx).len()); + for (snapshot, (module, _)) in snapshots.iter().zip(cx.root().instantiations(cx).values()) { + let state_module = rewrite_one_state_module(cx, *module, snapshot, 0); modules.module(&state_module); } @@ -818,8 +803,8 @@ fn rewrite_state_modules( } fn rewrite_one_state_module( - info: &ModuleInfo, - id_to_module_info: &Vec<&ModuleInfo>, + cx: &ModuleContext, + info: Module, snapshot: &Snapshot, depth: u32, ) -> wasm_encoder::Module { @@ -828,7 +813,7 @@ fn rewrite_one_state_module( // If there are nested instantiations, then define the nested state // modules and then instantiate them. - assert_eq!(info.instantiations.len(), snapshot.instantiations.len()); + assert_eq!(info.instantiations(cx).len(), snapshot.instantiations.len()); if !snapshot.instantiations.is_empty() { // We create nested instantiations such that each state module has // the following module index space: @@ -856,14 +841,14 @@ fn rewrite_one_state_module( // indices. let mut instance_renumbering = Renumbering::default(); - let types = make_complete_type_section(&info); + let types = make_complete_type_section(cx, info); state_module.section(&types); - let mut instance_import_counts = info.instance_import_counts.iter().copied(); - let mut aliases = info.aliases.iter(); - let mut instantiations = info.instantiations.values().enumerate(); + let mut instance_import_counts = info.instance_import_counts(cx).iter().copied(); + let mut aliases = info.aliases(cx).iter(); + let mut instantiations = info.instantiations(cx).values().enumerate(); - for section in info.initial_sections() { + for section in info.initial_sections(cx) { match section { // Handled by `make_complete_type_section` above. s if s.id == SectionId::Type.into() => continue, @@ -931,25 +916,24 @@ fn rewrite_one_state_module( let mut alias_section = wasm_encoder::AliasSection::new(); let mut instance_section = wasm_encoder::InstanceSection::new(); let mut module_section = wasm_encoder::ModuleSection::new(); - for (i, (module_id, instance_args)) in instantiations + for (i, (module, instance_args)) in instantiations .by_ref() .take(usize::try_from(count).unwrap()) { // Alias this instantiation's code module. // // Because we flatten the code modules into the root - // with a pre-order traversal, the module id is the - // module's pre-order index, and the root module is not - // in the flattened list, this instantiation's code - // module is the `module_id - 1`th module in the root - // module's module index space. - let root_module_index = *module_id - 1; - alias_section.outer_module(depth, root_module_index); + // with a pre-order traversal, and the root module is + // not in the flattened list, this instantiation's code + // module is the `module.pre_order_index() - 1`th module + // in the root module's module index space. + let code_module_index_in_root = module.pre_order_index() - 1; + alias_section.outer_module(depth, code_module_index_in_root); // Define the state module for this instantiation. let state_module = rewrite_one_state_module( - id_to_module_info[usize::try_from(*module_id).unwrap()], - id_to_module_info, + cx, + *module, &snapshot.instantiations[i], depth + 1, ); @@ -1011,14 +995,14 @@ fn rewrite_one_state_module( } // Add defined memories. - assert_eq!(info.defined_memories_len(), snapshot.memory_mins.len()); - if info.defined_memories_index.is_some() { + assert_eq!(info.defined_memories_len(cx), snapshot.memory_mins.len()); + if info.defined_memories_index(cx).is_some() { let mut memories = wasm_encoder::MemorySection::new(); - for (i, (new_min, mem)) in snapshot + for (i, (new_min, (_, mem))) in snapshot .memory_mins .iter() .copied() - .zip(info.defined_memories()) + .zip(info.defined_memories(cx)) .enumerate() { let mut mem = translate::memory_type(mem); @@ -1037,13 +1021,13 @@ fn rewrite_one_state_module( } // Add defined globals. - assert_eq!(info.defined_globals_len(), snapshot.globals.len()); - if info.defined_globals_index.is_some() { + assert_eq!(info.defined_globals_len(cx), snapshot.globals.len()); + if info.defined_globals_index(cx).is_some() { let mut globals = wasm_encoder::GlobalSection::new(); - for (i, (val, glob_ty)) in snapshot + for (i, (val, (_, glob_ty))) in snapshot .globals .iter() - .zip(info.defined_globals()) + .zip(info.defined_globals(cx)) .enumerate() { let glob_ty = translate::global_type(glob_ty); diff --git a/crates/wizer/tests/tests.rs b/crates/wizer/tests/tests.rs index 1a928fa7c50a..2460d9032cfa 100644 --- a/crates/wizer/tests/tests.rs +++ b/crates/wizer/tests/tests.rs @@ -504,6 +504,41 @@ fn start_sections_in_nested_modules() -> anyhow::Result<()> { ) } +#[test] +fn outer_module_alias() -> anyhow::Result<()> { + run_wat( + &[], + 42, + r#" +(module + (module $A + (global (export "g") (mut i32) (i32.const 0)) + ) + + (module $B + (alias outer 0 0 (module $A)) + (instance $a (instantiate $A)) + (func (export "init") + i32.const 42 + global.set (global $a "g") + ) + (func (export "run") (result i32) + global.get (global $a "g") + ) + ) + (instance $b (instantiate $B)) + + (func (export "wizer.initialize") + call (func $b "init") + ) + (func (export "run") (result i32) + call (func $b "run") + ) +) +"#, + ) +} + #[test] fn rust_regex() -> anyhow::Result<()> { run_wasm( From adc3832cbb32abbda340b05172ee8f6ee6e7aecd Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Mon, 3 May 2021 15:22:29 -0700 Subject: [PATCH 053/212] Split out separate code paths for when module linking is vs is not enabled This will make it easier to more radically change emitted code shape when module linking is enabled, which is coming in follow up commits. --- crates/wizer/Cargo.toml | 7 ++ crates/wizer/src/info.rs | 12 +++ crates/wizer/src/lib.rs | 33 +++++-- crates/wizer/src/rewrite.rs | 175 ++++++++++++++++++++++++++++++++++-- 4 files changed, 209 insertions(+), 18 deletions(-) diff --git a/crates/wizer/Cargo.toml b/crates/wizer/Cargo.toml index 20dc91fdfcf6..c4afbdd6059f 100644 --- a/crates/wizer/Cargo.toml +++ b/crates/wizer/Cargo.toml @@ -38,6 +38,13 @@ wasmparser = "0.78.0" wasmtime = "0.26.0" wasmtime-wasi = "0.26.0" +# Enable this dependency to get messages with WAT disassemblies when certain +# internal panics occur. +[dependencies.wasmprinter] +version = "0.2.26" +optional = true + + [dev-dependencies] criterion = "0.3.4" env_logger = "0.8.2" diff --git a/crates/wizer/src/info.rs b/crates/wizer/src/info.rs index 8e1e7c929fd6..0af8df227dc2 100644 --- a/crates/wizer/src/info.rs +++ b/crates/wizer/src/info.rs @@ -24,6 +24,18 @@ impl<'a> ModuleContext<'a> { Module { id: 0 } } + /// Does this context represent a single Wasm module that doesn't use module + /// linking, or does it represent a bundle of one or more Wasm modules that + /// use module linking? + pub fn uses_module_linking(&self) -> bool { + self.arena.len() > 1 + || self.root().initial_sections(self).any(|s| { + s.id == SectionId::Alias.into() + || s.id == SectionId::Module.into() + || s.id == SectionId::Instance.into() + }) + } + /// Get a shared reference to the `DefinedModuleInfo` for this module, /// following through aliases. fn resolve(&self, module: Module) -> &DefinedModuleInfo<'a> { diff --git a/crates/wizer/src/lib.rs b/crates/wizer/src/lib.rs index a504b4144383..ba81fce51640 100644 --- a/crates/wizer/src/lib.rs +++ b/crates/wizer/src/lib.rs @@ -303,32 +303,47 @@ impl Wizer { self.wasm_validate(&wasm)?; let cx = parse::parse(wasm)?; - let wasm = instrument::instrument(&cx); + let instrumented_wasm = instrument::instrument(&cx); if cfg!(debug_assertions) { - if let Err(error) = self.wasm_validate(&wasm) { - panic!("instrumented Wasm is not valid: {:?}", error); + if let Err(error) = self.wasm_validate(&instrumented_wasm) { + let wat = if cfg!(feature = "wasmprinter") { + wasmprinter::print_bytes(&wasm) + .unwrap_or_else(|e| format!("Disassembling to WAT failed: {}", e)) + } else { + "`wasmprinter` cargo feature is not enabled".into() + }; + panic!( + "instrumented Wasm is not valid: {:?}\n\nWAT:\n{}", + error, wat + ); } } let config = self.wasmtime_config()?; let engine = wasmtime::Engine::new(&config)?; let store = wasmtime::Store::new(&engine); - let module = - wasmtime::Module::new(&engine, &wasm).context("failed to compile the Wasm module")?; + let module = wasmtime::Module::new(&engine, &instrumented_wasm) + .context("failed to compile the Wasm module")?; self.validate_init_func(&module)?; let instance = self.initialize(&store, &module)?; let snapshot = snapshot::snapshot(&store, &instance); - let initialized_wasm = self.rewrite(&cx, &snapshot, &renames); + let rewritten_wasm = self.rewrite(&cx, &snapshot, &renames); if cfg!(debug_assertions) { - if let Err(error) = self.wasm_validate(&initialized_wasm) { - panic!("rewritten Wasm is not valid: {:?}", error); + if let Err(error) = self.wasm_validate(&rewritten_wasm) { + let wat = if cfg!(feature = "wasmprinter") { + wasmprinter::print_bytes(&rewritten_wasm) + .unwrap_or_else(|e| format!("Disassembling to WAT failed: {}", e)) + } else { + "`wasmprinter` cargo feature is not enabled".into() + }; + panic!("rewritten Wasm is not valid: {:?}\n\nWAT:\n{}", error, wat); } } - Ok(initialized_wasm) + Ok(rewritten_wasm) } // NB: keep this in sync with the wasmparser features. diff --git a/crates/wizer/src/rewrite.rs b/crates/wizer/src/rewrite.rs index 1925ceb07728..2abbe03ef834 100644 --- a/crates/wizer/src/rewrite.rs +++ b/crates/wizer/src/rewrite.rs @@ -137,6 +137,168 @@ impl Wizer { ) -> Vec { log::debug!("Rewriting input Wasm to pre-initialized state"); + if cx.uses_module_linking() { + self.rewrite_with_module_linking(cx, snapshot, renames) + } else { + self.rewrite_without_module_linking(cx, snapshot, renames) + } + } + + /// Rewrite a root Wasm module that has no children and doesn't use module + /// linking at all. + fn rewrite_without_module_linking( + &self, + cx: &ModuleContext, + snapshot: &Snapshot, + renames: &FuncRenames, + ) -> Vec { + assert!(snapshot.instantiations.is_empty()); + + let mut encoder = wasm_encoder::Module::new(); + let module = cx.root(); + + // Encode the initialized data segments from the snapshot rather + // than the original, uninitialized data segments. + let mut data_section = if snapshot.data_segments.is_empty() { + None + } else { + let mut data_section = wasm_encoder::DataSection::new(); + for seg in &snapshot.data_segments { + data_section.active( + seg.memory_index, + wasm_encoder::Instruction::I32Const(seg.offset as i32), + seg.data.iter().copied(), + ); + } + Some(data_section) + }; + + // There are multiple places were we potentially need to check whether + // we've added the data section already and if we haven't yet, then do + // so. For example, the original Wasm might not have a data section at + // all, and so we have to potentially add it at the end of iterating + // over the original sections. This closure encapsulates all that + // add-it-if-we-haven't-already logic in one place. + let mut add_data_section = |module: &mut wasm_encoder::Module| { + if let Some(data_section) = data_section.take() { + module.section(&data_section); + } + }; + + for section in module.raw_sections(cx) { + match section { + // Some tools expect the name custom section to come last, even + // though custom sections are allowed in any order. Therefore, + // make sure we've added our data section by now. + s if is_name_section(s) => { + add_data_section(&mut encoder); + encoder.section(s); + } + + // For the memory section, we update the minimum size of each + // defined memory to the snapshot's initialized size for that + // memory. + s if s.id == SectionId::Memory.into() => { + let mut memories = wasm_encoder::MemorySection::new(); + assert_eq!(module.defined_memories_len(cx), snapshot.memory_mins.len()); + for ((_, mem), new_min) in module + .defined_memories(cx) + .zip(snapshot.memory_mins.iter().copied()) + { + let mut mem = translate::memory_type(mem); + mem.limits.min = new_min; + memories.memory(mem); + } + encoder.section(&memories); + } + + // Encode the initialized global values from the snapshot, + // rather than the original values. + s if s.id == SectionId::Global.into() => { + let mut globals = wasm_encoder::GlobalSection::new(); + for ((_, glob_ty), val) in + module.defined_globals(cx).zip(snapshot.globals.iter()) + { + let glob_ty = translate::global_type(glob_ty); + globals.global( + glob_ty, + match val { + wasmtime::Val::I32(x) => wasm_encoder::Instruction::I32Const(*x), + wasmtime::Val::I64(x) => wasm_encoder::Instruction::I64Const(*x), + wasmtime::Val::F32(x) => { + wasm_encoder::Instruction::F32Const(f32::from_bits(*x)) + } + wasmtime::Val::F64(x) => { + wasm_encoder::Instruction::F64Const(f64::from_bits(*x)) + } + _ => unreachable!(), + }, + ); + } + encoder.section(&globals); + } + + // Remove the initialization function's export and perform any + // requested renames. + s if s.id == SectionId::Export.into() => { + let mut exports = wasm_encoder::ExportSection::new(); + for export in module.exports(cx) { + if export.field == self.init_func { + continue; + } + + if !renames.rename_src_to_dst.contains_key(export.field) + && renames.rename_dsts.contains(export.field) + { + // A rename overwrites this export, and it is not + // renamed to another export, so skip it. + continue; + } + + let field = renames + .rename_src_to_dst + .get(export.field) + .map_or(export.field, |f| f.as_str()); + + let export = translate::export(export.kind, export.index); + exports.export(field, export); + } + encoder.section(&exports); + } + + // Skip the `start` function -- it's already been run! + s if s.id == SectionId::Start.into() => { + continue; + } + + s if s.id == SectionId::Data.into() => { + // TODO: supporting bulk memory will require copying over + // any passive and declared segments. + add_data_section(&mut encoder); + } + + s if s.id == SectionId::Module.into() => unreachable!(), + s if s.id == SectionId::Instance.into() => unreachable!(), + s if s.id == SectionId::Alias.into() => unreachable!(), + + s => { + encoder.section(s); + } + } + } + + // Make sure that we've added our data section to the module. + add_data_section(&mut encoder); + encoder.finish() + } + + /// Rewrite a module linking bundle. + fn rewrite_with_module_linking( + &self, + cx: &ModuleContext<'_>, + snapshot: &Snapshot, + renames: &FuncRenames, + ) -> Vec { let root_info = cx.root(); let mut root = wasm_encoder::Module::new(); @@ -144,15 +306,10 @@ impl Wizer { root.section(&types); let (code_modules, num_code_modules) = rewrite_code_modules(cx); - // Only add the module section if there are multiple code modules, - // so that we avoid introducing the module section when module - // linking isn't in use. - if num_code_modules > 0 { - root.section(&code_modules); - - let state_modules = rewrite_state_modules(cx, &snapshot.instantiations); - root.section(&state_modules); - } + root.section(&code_modules); + + let state_modules = rewrite_state_modules(cx, &snapshot.instantiations); + root.section(&state_modules); self.rewrite_root(cx, &mut root, snapshot, renames, num_code_modules); From 5277bfc08e42ff1357a2972142a05f16260cfe06 Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Mon, 17 May 2021 11:14:30 -0700 Subject: [PATCH 054/212] Get instances without entries in the type section and implicit instance injection working --- crates/wizer/Cargo.lock | 8 +- crates/wizer/Cargo.toml | 2 +- crates/wizer/src/info.rs | 302 +++++--- crates/wizer/src/info/types_interner.rs | 205 +++++ crates/wizer/src/lib.rs | 26 +- crates/wizer/src/parse.rs | 118 ++- crates/wizer/src/rewrite.rs | 969 +++++++++++------------- crates/wizer/tests/tests.rs | 212 ++++++ 8 files changed, 1126 insertions(+), 716 deletions(-) create mode 100644 crates/wizer/src/info/types_interner.rs diff --git a/crates/wizer/Cargo.lock b/crates/wizer/Cargo.lock index 616049253ebb..0ae283f91da8 100644 --- a/crates/wizer/Cargo.lock +++ b/crates/wizer/Cargo.lock @@ -1716,9 +1716,9 @@ checksum = "b35c86d22e720a07d954ebbed772d01180501afe7d03d464f413bb5f8914a8d6" [[package]] name = "wasmparser" -version = "0.78.0" +version = "0.78.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c7a8b20306d43c09c2c34e0ef68bf2959a11b01a5cae35e4c5dc1e7145547b6" +checksum = "52144d4c78e5cf8b055ceab8e5fa22814ce4315d6002ad32cfd914f37c12fd65" [[package]] name = "wasmprinter" @@ -1727,7 +1727,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2ccec894c70710c2e4669320a532cb2b9cfb97adb0429745642f8ce76916ed85" dependencies = [ "anyhow", - "wasmparser 0.78.0", + "wasmparser 0.78.2", ] [[package]] @@ -2130,7 +2130,7 @@ dependencies = [ "structopt", "wasi-cap-std-sync", "wasm-encoder", - "wasmparser 0.78.0", + "wasmparser 0.78.2", "wasmprinter", "wasmtime", "wasmtime-wasi", diff --git a/crates/wizer/Cargo.toml b/crates/wizer/Cargo.toml index c4afbdd6059f..7fdaa191a1d8 100644 --- a/crates/wizer/Cargo.toml +++ b/crates/wizer/Cargo.toml @@ -34,7 +34,7 @@ rayon = "1.5.0" structopt = { version = "0.3.21", optional = true } wasi-cap-std-sync = "0.26.0" wasm-encoder = "0.4.0" -wasmparser = "0.78.0" +wasmparser = "0.78.2" wasmtime = "0.26.0" wasmtime-wasi = "0.26.0" diff --git a/crates/wizer/src/info.rs b/crates/wizer/src/info.rs index 0af8df227dc2..c839258b9f16 100644 --- a/crates/wizer/src/info.rs +++ b/crates/wizer/src/info.rs @@ -1,13 +1,15 @@ use wasm_encoder::SectionId; -use crate::translate; +pub mod types_interner; + use std::collections::BTreeMap; use std::convert::TryFrom; +use types_interner::{EntityType, InstanceType, Type, TypeId, TypesInterner}; /// A collection of info about modules within a module linking bundle. -#[derive(Default)] pub(crate) struct ModuleContext<'a> { arena: Vec>, + types: TypesInterner<'a>, } impl<'a> ModuleContext<'a> { @@ -16,6 +18,7 @@ impl<'a> ModuleContext<'a> { pub fn new() -> Self { Self { arena: vec![ModuleInfo::Defined(DefinedModuleInfo::default())], + types: TypesInterner::default(), } } @@ -24,6 +27,11 @@ impl<'a> ModuleContext<'a> { Module { id: 0 } } + /// Get the interned types set for this module context. + pub fn types(&self) -> &TypesInterner<'a> { + &self.types + } + /// Does this context represent a single Wasm module that doesn't use module /// linking, or does it represent a bundle of one or more Wasm modules that /// use module linking? @@ -93,7 +101,7 @@ struct DefinedModuleInfo<'a> { /// /// We keep track of these for determining how many things we need to /// re-export for new instantiations and for inner module's aliases. - types: Vec>, + types: Vec, /// Imports made by this module. imports: Vec>, @@ -109,7 +117,7 @@ struct DefinedModuleInfo<'a> { /// A map from instance indices to each instance's type for all defined, /// imported, and aliased instances. - instances: Vec>, + instances: Vec, /// A map from indices of defined instantiations (as opposed to imported or /// aliased instantiations) to the id of the module that was instantiated @@ -137,7 +145,7 @@ struct DefinedModuleInfo<'a> { /// Maps from function index to the function's type index for all functions /// defined, imported, and aliased in this module. - functions: Vec, + functions: Vec, /// Maps from table index to the table's type for all tables defined, /// imported, and aliased in this module. @@ -189,6 +197,40 @@ impl Module { u32::try_from(self.id).unwrap() } + /// Get the defined module that this module is an alias of, if any. + /// + /// This will see through all aliases. + pub fn get_aliased(self, cx: &ModuleContext<'_>) -> Option { + if matches!(cx.arena[self.id], ModuleInfo::Defined(_)) { + return None; + } + + let mut id = self.id; + loop { + match &cx.arena[id] { + ModuleInfo::Aliased(AliasedModuleInfo { alias_of, .. }) => { + id = *alias_of; + } + ModuleInfo::Defined(_) => return Some(Module { id }), + } + } + } + + /// Translate the given `wasmparser` entity type into its interned + /// representation using this module's types space. + pub fn entity_type( + self, + cx: &ModuleContext<'_>, + ty: wasmparser::ImportSectionEntryType, + ) -> EntityType { + let module = self.get_aliased(cx).unwrap_or(self); + let types_space = match &cx.arena[module.id] { + ModuleInfo::Aliased(_) => unreachable!(), + ModuleInfo::Defined(d) => &d.types, + }; + cx.types().entity_type(ty, types_space) + } + /// Add a new raw section to this module info during parsing. pub fn add_raw_section<'a>( self, @@ -207,6 +249,16 @@ impl Module { /// Push a new type into this module's types space. pub fn push_type<'a>(self, cx: &mut ModuleContext<'a>, ty: wasmparser::TypeDef<'a>) { + let types_space = match &cx.arena[self.id] { + ModuleInfo::Aliased(_) => panic!("not a defined module"), + ModuleInfo::Defined(d) => &d.types, + }; + let ty = cx.types.insert_wasmparser(ty, types_space); + cx.defined_mut(self).types.push(ty); + } + + /// Push an aliased type into this module's types space. + pub fn push_aliased_type(self, cx: &mut ModuleContext<'_>, ty: TypeId) { cx.defined_mut(self).types.push(ty); } @@ -216,20 +268,14 @@ impl Module { } /// Push a new, aliased instance into this module's instance index space. - pub fn push_aliased_instance<'a>( - self, - cx: &mut ModuleContext<'a>, - instance_type: wasmparser::InstanceType<'a>, - ) { + pub fn push_aliased_instance<'a>(self, cx: &mut ModuleContext<'a>, instance_type: TypeId) { + assert!(cx.types.get(instance_type).is_instance()); cx.defined_mut(self).instances.push(instance_type); } /// Push a new, imported instance into this module's instance index space. - pub fn push_imported_instance<'a>( - self, - cx: &mut ModuleContext<'a>, - instance_type: wasmparser::InstanceType<'a>, - ) { + pub fn push_imported_instance<'a>(self, cx: &mut ModuleContext<'a>, instance_type: TypeId) { + assert!(cx.types.get(instance_type).is_instance()); cx.defined_mut(self).instances.push(instance_type); } @@ -237,10 +283,11 @@ impl Module { pub fn push_defined_instance<'a>( self, cx: &mut ModuleContext<'a>, - instance_type: wasmparser::InstanceType<'a>, + instance_type: TypeId, module: Module, args: Vec>, ) { + assert!(cx.types.get(instance_type).is_instance()); let info = cx.defined_mut(self); let index = u32::try_from(info.instances.len()).unwrap(); info.instances.push(instance_type); @@ -280,7 +327,8 @@ impl Module { } /// Push a new function into this module's function index space. - pub fn push_function(self, cx: &mut ModuleContext, func_type: u32) { + pub fn push_function(self, cx: &mut ModuleContext, func_type: TypeId) { + assert!(cx.types.get(func_type).is_func()); cx.defined_mut(self).functions.push(func_type); } @@ -305,8 +353,9 @@ impl Module { let ty = self.instance_type_at(cx, ty_idx).clone(); self.push_imported_instance(cx, ty); } - wasmparser::ImportSectionEntryType::Function(func_ty) => { - self.push_function(cx, func_ty); + wasmparser::ImportSectionEntryType::Function(ty_idx) => { + let ty = self.type_id_at(cx, ty_idx); + self.push_function(cx, ty); } wasmparser::ImportSectionEntryType::Table(ty) => { self.push_table(cx, ty); @@ -319,10 +368,21 @@ impl Module { } /// Push a count of how many instance imports an import section had. - pub fn push_instance_import_count(self, cx: &mut ModuleContext, count: u32) { + pub fn push_instance_import_count(self, cx: &mut ModuleContext<'_>, count: u32) { cx.defined_mut(self).instance_import_counts.push(count); } + /// Push an instance implicitly created by a two-level import into this + /// module. + pub fn push_implicit_instance<'a>( + self, + cx: &mut ModuleContext<'a>, + instance_type: InstanceType<'a>, + ) { + let ty = cx.types.insert(Type::Instance(instance_type)); + cx.defined_mut(self).instances.push(ty); + } + /// Push an alias into this module. pub fn push_alias<'a>(self, cx: &mut ModuleContext<'a>, alias: wasmparser::Alias<'a>) { cx.defined_mut(self).aliases.push(alias); @@ -342,84 +402,94 @@ impl Module { /// /// Returns the index of the type and updates the total count of types in /// `num_types`. - pub fn define_instance_type( - self, - cx: &ModuleContext<'_>, - num_types: &mut u32, - types: &mut wasm_encoder::TypeSection, - ) -> u32 { - let ty_index = *num_types; - let info = cx.resolve(self); - types.instance(info.exports.iter().map(|e| { - let name = e.field; - let index = usize::try_from(e.index).unwrap(); - let item = match e.kind { - wasmparser::ExternalKind::Function => { - let func_ty = info.functions[index]; - wasm_encoder::EntityType::Function(func_ty) - } - wasmparser::ExternalKind::Table => { - let ty = info.tables[index]; - wasm_encoder::EntityType::Table(translate::table_type(ty)) - } - wasmparser::ExternalKind::Memory => { - let ty = info.memories[index]; - wasm_encoder::EntityType::Memory(translate::memory_type(ty)) - } - wasmparser::ExternalKind::Global => { - let ty = info.globals[index]; - wasm_encoder::EntityType::Global(translate::global_type(ty)) + pub fn define_instance_type(self, cx: &mut ModuleContext<'_>) -> TypeId { + // Inline `cx.resolve(self)` to avoid borrowck errors. + let info = { + let mut id = self.id; + loop { + match &cx.arena[id] { + ModuleInfo::Aliased(AliasedModuleInfo { alias_of, .. }) => { + id = *alias_of; + } + ModuleInfo::Defined(d) => break d, } - wasmparser::ExternalKind::Instance => wasm_encoder::EntityType::Instance(e.index), - wasmparser::ExternalKind::Module - | wasmparser::ExternalKind::Type - | wasmparser::ExternalKind::Event => unreachable!(), - }; - (name, item) - })); - *num_types += 1; - ty_index - } + } + }; - /// Construct an instance type for instances of this module. - pub fn instance_type<'a>(self, cx: &ModuleContext<'a>) -> wasmparser::InstanceType<'a> { - let info = cx.resolve(self); - wasmparser::InstanceType { + cx.types.insert(Type::Instance(InstanceType { exports: info .exports .iter() .map(|e| { + let name = e.field.into(); let index = usize::try_from(e.index).unwrap(); - wasmparser::ExportType { - name: e.field, - ty: match e.kind { - wasmparser::ExternalKind::Function => { - let func_ty = info.functions[index]; - wasmparser::ImportSectionEntryType::Function(func_ty) - } - wasmparser::ExternalKind::Table => { - let ty = info.tables[index]; - wasmparser::ImportSectionEntryType::Table(ty) - } - wasmparser::ExternalKind::Memory => { - let ty = info.memories[index]; - wasmparser::ImportSectionEntryType::Memory(ty) - } - wasmparser::ExternalKind::Global => { - let ty = info.globals[index]; - wasmparser::ImportSectionEntryType::Global(ty) - } - wasmparser::ExternalKind::Instance => { - wasmparser::ImportSectionEntryType::Instance(e.index) - } - wasmparser::ExternalKind::Module - | wasmparser::ExternalKind::Type - | wasmparser::ExternalKind::Event => unreachable!(), - }, - } + let entity = match e.kind { + wasmparser::ExternalKind::Function => { + let func_ty = info.functions[index]; + EntityType::Function(func_ty) + } + wasmparser::ExternalKind::Table => { + let ty = info.tables[index]; + EntityType::Table(ty) + } + wasmparser::ExternalKind::Memory => { + let ty = info.memories[index]; + EntityType::Memory(ty) + } + wasmparser::ExternalKind::Global => { + let ty = info.globals[index]; + EntityType::Global(ty) + } + wasmparser::ExternalKind::Instance => { + EntityType::Instance(info.instances[index]) + } + wasmparser::ExternalKind::Module + | wasmparser::ExternalKind::Type + | wasmparser::ExternalKind::Event => unreachable!(), + }; + (name, entity) }) .collect(), - } + })) + } + + /// Define an instance type for this module's state. + pub fn define_state_instance_type(self, cx: &mut ModuleContext<'_>) -> TypeId { + // Define instance types for each of the instances that we instantiate + // locally so that we can refer to these types in the state instance's + // type. + let instantiated_modules: Vec<_> = + self.instantiations(cx).values().map(|(m, _)| *m).collect(); + let instance_types = instantiated_modules + .into_iter() + .map(|m| m.define_instance_type(cx)) + .collect::>(); + + // Define the state instance type. + cx.types.insert(Type::Instance(InstanceType { + exports: self + .defined_globals(cx) + .enumerate() + .map(|(i, (_, g))| { + ( + format!("__wizer_global_{}", i).into(), + EntityType::Global(g), + ) + }) + .chain(self.defined_memories(cx).enumerate().map(|(i, (_, m))| { + ( + format!("__wizer_memory_{}", i).into(), + EntityType::Memory(m), + ) + })) + .chain(instance_types.iter().enumerate().map(|(i, ty)| { + ( + format!("__wizer_instance_{}", i).into(), + EntityType::Instance(*ty), + ) + })) + .collect(), + })) } /// Get the count of how many instance imports are in each import section in @@ -434,30 +504,30 @@ impl Module { } /// Get an export from the `n`th instance by name. - pub fn instance_export( + pub fn instance_export<'b>( self, - cx: &ModuleContext<'_>, + cx: &'b ModuleContext<'_>, instance: u32, name: &str, - ) -> Option { + ) -> Option<&'b EntityType> { let instance = usize::try_from(instance).unwrap(); let info = cx.resolve(self); - let instance = &info.instances[instance]; - instance - .exports - .iter() - .find(|e| e.name == name) - .map(|e| e.ty) + let type_id = info.instances[instance]; + let instance = match cx.types.get(type_id) { + Type::Instance(i) => i, + _ => unreachable!(), + }; + instance.exports.get(name) } /// Do a pre-order traversal over this module tree. - pub fn pre_order(self, cx: &ModuleContext<'_>, mut f: F) + pub fn pre_order<'a, F>(self, cx: &mut ModuleContext<'a>, mut f: F) where - F: FnMut(Module), + F: FnMut(&mut ModuleContext<'a>, Module), { let mut stack = vec![self]; while let Some(module) = stack.pop() { - f(module); + f(cx, module); let info = cx.resolve(module); stack.extend(info.modules.iter().copied().rev()); } @@ -589,32 +659,32 @@ impl Module { } /// Get the full types index space for this module. - pub fn types<'a, 'b>(self, cx: &'b ModuleContext<'a>) -> &'b [wasmparser::TypeDef<'a>] { + pub fn types<'a, 'b>(self, cx: &'b ModuleContext<'a>) -> &'b [TypeId] { &cx.resolve(self).types } /// Get the type at the given index. /// /// Panics if the types index space does not contain the given index. - pub fn type_at<'a, 'b>( - self, - cx: &'b ModuleContext<'a>, - type_index: u32, - ) -> &'b wasmparser::TypeDef<'a> { - &cx.resolve(self).types[usize::try_from(type_index).unwrap()] + pub fn type_at<'a, 'b>(self, cx: &'b ModuleContext<'a>, type_index: u32) -> &'b Type<'a> { + let id = self.type_id_at(cx, type_index); + cx.types.get(id) } - /// Get the instance type at the given type index. + /// Get the type at the given index. + /// + /// Panics if the types index space does not contain the given index. + pub fn type_id_at(self, cx: &ModuleContext<'_>, type_index: u32) -> TypeId { + cx.resolve(self).types[usize::try_from(type_index).unwrap()] + } + + /// Get the id for instance type at the given type index. /// /// Panics if the types index space does not contain the given index or the /// type at the index is not an instance type. - pub fn instance_type_at<'a, 'b>( - self, - cx: &'b ModuleContext<'a>, - type_index: u32, - ) -> &'b wasmparser::InstanceType<'a> { - if let wasmparser::TypeDef::Instance(ity) = self.type_at(cx, type_index) { - ity + pub fn instance_type_at<'a, 'b>(self, cx: &'b ModuleContext<'a>, type_index: u32) -> TypeId { + if let Type::Instance(_) = self.type_at(cx, type_index) { + self.types(cx)[usize::try_from(type_index).unwrap()] } else { panic!("not an instance type") } diff --git a/crates/wizer/src/info/types_interner.rs b/crates/wizer/src/info/types_interner.rs new file mode 100644 index 000000000000..b6179b718b16 --- /dev/null +++ b/crates/wizer/src/info/types_interner.rs @@ -0,0 +1,205 @@ +use std::{ + borrow::Cow, + collections::{BTreeMap, HashMap}, + convert::TryFrom, + rc::Rc, +}; + +/// A de-duplicated set of type definitions. +/// +/// We insert new entries via hash consing, to de-duplicate entries. +/// +/// This is shared across all modules in a module linking bundle. +/// +/// We assign and track a unique index for each type we insert. These end up +/// being the indices of each type in the root Wasm module. All nested modules +/// refer to these types, and pull them into their nested types index space, via +/// outer type aliases. +#[derive(Default)] +pub struct TypesInterner<'a> { + /// The interned types. + types: Vec>>, + + /// An map from a type to its index in `self.types`. + type_to_index: HashMap>, u32>, +} + +/// An interned Wasm type definition. +#[derive(PartialEq, Eq, Hash)] +pub enum Type<'a> { + Func(wasmparser::FuncType), + Instance(InstanceType<'a>), + Module(ModuleType<'a>), +} + +impl Type<'_> { + pub fn is_instance(&self) -> bool { + matches!(self, Type::Instance(_)) + } + + pub fn is_func(&self) -> bool { + matches!(self, Type::Func(_)) + } +} + +/// An interned Wasm instance type. +#[derive(PartialEq, Eq, Hash)] +pub struct InstanceType<'a> { + pub exports: BTreeMap, EntityType>, +} + +/// An interned type for some kind of Wasm entity. +#[derive(PartialEq, Eq, Hash)] +pub enum EntityType { + Function(TypeId), + Table(wasmparser::TableType), + Memory(wasmparser::MemoryType), + Global(wasmparser::GlobalType), + Module(TypeId), + Instance(TypeId), +} + +/// An interned Wasm module type. +#[derive(PartialEq, Eq, Hash)] +pub struct ModuleType<'a> { + pub imports: BTreeMap<(Cow<'a, str>, Option>), EntityType>, + pub exports: BTreeMap, EntityType>, +} + +/// An id of a type in a `TypesInterner` type set. +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] +pub struct TypeId { + index: u32, +} + +impl TypeId { + /// Get the index of this type inside its `TypesInterner`. + /// + /// This index is *not* the same as the index within a particular module's + /// index space, it is within the `TypesInterner`'s index space (except for + /// the eventual umbrella module, whose types index space matches the + /// interner's index space). + pub fn index(self) -> u32 { + self.index + } +} + +impl<'a> TypesInterner<'a> { + /// Iterate over the types defined in this type set and their index. + pub fn iter<'b>(&'b self) -> impl Iterator)> + 'b { + assert!((self.types.len() as u64) < (u32::MAX as u64)); + self.types + .iter() + .enumerate() + .map(|(idx, ty)| (u32::try_from(idx).unwrap(), &**ty)) + } + + /// Get a type by id. + pub fn get(&self, id: TypeId) -> &Type<'a> { + &*self.types[usize::try_from(id.index).unwrap()] + } + + /// Intern a `wasmparser` type into this type set and get its id. + /// + /// The provided `types_space` must be a slice of the defining module's + /// types index space. + /// + /// If the type has already been inserted and assigned an id before, then + /// that entry and its id are reused. + pub fn insert_wasmparser( + &mut self, + ty: wasmparser::TypeDef<'a>, + types_space: &[TypeId], + ) -> TypeId { + match ty { + wasmparser::TypeDef::Func(func_ty) => self.insert(Type::Func(func_ty)), + wasmparser::TypeDef::Instance(inst_ty) => { + self.insert_wasmparser_instance_type(inst_ty, types_space) + } + wasmparser::TypeDef::Module(module_ty) => { + self.insert_wasmparser_module_type(module_ty, types_space) + } + } + } + + /// Insert a new type into this type set and get its id. + /// + /// If the type has already been inserted and assigned an id before, then + /// that entry and its id are reused. + pub fn insert(&mut self, ty: Type<'a>) -> TypeId { + if let Some(index) = self.type_to_index.get(&ty).copied() { + return TypeId { index }; + } + + let index = u32::try_from(self.types.len()).unwrap(); + let ty = Rc::new(ty); + self.type_to_index.insert(ty.clone(), index); + self.types.push(ty); + TypeId { index } + } + + /// Convert a `wasmparser::ImportSectionEntryType` into an interned + /// `EntityType`. + /// + /// The provided `types_space` must be a slice of the defining module's + /// types index space. + pub fn entity_type( + &self, + ty: wasmparser::ImportSectionEntryType, + types_space: &[TypeId], + ) -> EntityType { + match ty { + wasmparser::ImportSectionEntryType::Function(idx) => { + EntityType::Function(types_space[usize::try_from(idx).unwrap()]) + } + wasmparser::ImportSectionEntryType::Table(ty) => EntityType::Table(ty), + wasmparser::ImportSectionEntryType::Memory(ty) => EntityType::Memory(ty), + wasmparser::ImportSectionEntryType::Global(ty) => EntityType::Global(ty), + wasmparser::ImportSectionEntryType::Module(idx) => { + EntityType::Module(types_space[usize::try_from(idx).unwrap()]) + } + wasmparser::ImportSectionEntryType::Instance(idx) => { + EntityType::Instance(types_space[usize::try_from(idx).unwrap()]) + } + wasmparser::ImportSectionEntryType::Event(_) => unreachable!(), + } + } + + fn insert_wasmparser_instance_type( + &mut self, + inst_ty: wasmparser::InstanceType<'a>, + types_space: &[TypeId], + ) -> TypeId { + self.insert(Type::Instance(InstanceType { + exports: inst_ty + .exports + .iter() + .map(|exp| (exp.name.into(), self.entity_type(exp.ty, types_space))) + .collect(), + })) + } + + fn insert_wasmparser_module_type( + &mut self, + module_ty: wasmparser::ModuleType<'a>, + types_space: &[TypeId], + ) -> TypeId { + self.insert(Type::Module(ModuleType { + imports: module_ty + .imports + .iter() + .map(|imp| { + ( + (imp.module.into(), imp.field.map(Cow::from)), + self.entity_type(imp.ty, types_space), + ) + }) + .collect(), + exports: module_ty + .exports + .iter() + .map(|exp| (exp.name.into(), self.entity_type(exp.ty, types_space))) + .collect(), + })) + } +} diff --git a/crates/wizer/src/lib.rs b/crates/wizer/src/lib.rs index ba81fce51640..8f49cd122e9d 100644 --- a/crates/wizer/src/lib.rs +++ b/crates/wizer/src/lib.rs @@ -302,17 +302,16 @@ impl Wizer { // Make sure we're given valid Wasm from the get go. self.wasm_validate(&wasm)?; - let cx = parse::parse(wasm)?; + let mut cx = parse::parse(wasm)?; let instrumented_wasm = instrument::instrument(&cx); if cfg!(debug_assertions) { if let Err(error) = self.wasm_validate(&instrumented_wasm) { - let wat = if cfg!(feature = "wasmprinter") { - wasmprinter::print_bytes(&wasm) - .unwrap_or_else(|e| format!("Disassembling to WAT failed: {}", e)) - } else { - "`wasmprinter` cargo feature is not enabled".into() - }; + #[cfg(feature = "wasmprinter")] + let wat = wasmprinter::print_bytes(&wasm) + .unwrap_or_else(|e| format!("Disassembling to WAT failed: {}", e)); + #[cfg(not(feature = "wasmprinter"))] + let wat = "`wasmprinter` cargo feature is not enabled".to_string(); panic!( "instrumented Wasm is not valid: {:?}\n\nWAT:\n{}", error, wat @@ -329,16 +328,15 @@ impl Wizer { let instance = self.initialize(&store, &module)?; let snapshot = snapshot::snapshot(&store, &instance); - let rewritten_wasm = self.rewrite(&cx, &snapshot, &renames); + let rewritten_wasm = self.rewrite(&mut cx, &snapshot, &renames); if cfg!(debug_assertions) { if let Err(error) = self.wasm_validate(&rewritten_wasm) { - let wat = if cfg!(feature = "wasmprinter") { - wasmprinter::print_bytes(&rewritten_wasm) - .unwrap_or_else(|e| format!("Disassembling to WAT failed: {}", e)) - } else { - "`wasmprinter` cargo feature is not enabled".into() - }; + #[cfg(feature = "wasmprinter")] + let wat = wasmprinter::print_bytes(&wasm) + .unwrap_or_else(|e| format!("Disassembling to WAT failed: {}", e)); + #[cfg(not(feature = "wasmprinter"))] + let wat = "`wasmprinter` cargo feature is not enabled".to_string(); panic!("rewritten Wasm is not valid: {:?}\n\nWAT:\n{}", error, wat); } } diff --git a/crates/wizer/src/parse.rs b/crates/wizer/src/parse.rs index 6437afeca305..bbdce060baba 100644 --- a/crates/wizer/src/parse.rs +++ b/crates/wizer/src/parse.rs @@ -1,4 +1,7 @@ -use crate::info::{Module, ModuleContext}; +use crate::info::{ + types_interner::{EntityType, InstanceType, Type, TypeId}, + Module, ModuleContext, +}; use crate::stack_ext::StackExt; use anyhow::{Context, Result}; use std::convert::TryFrom; @@ -221,6 +224,28 @@ fn import_section<'a>( let mut instance_import_count = 0; + // Two-level imports implicitly create an instance import. That is, this + // + // (import "env" "f" (func)) + // (import "env" "g" (func)) + // + // is implicitly translated into roughly + // + // (import "env" (instance (export "f" (func)) + // (export "g" (func)))) + // (alias 0 "f") + // (alias 0 "g") + // + // However not that this is _not_ a WAT-level desugaring where we only have + // to deal with the expanded form! We have to perform this translation + // ourselves as we parse the imports. + // + // This variable keeps track of the implicit instance import that we are + // currently building. Whenever we see a consecutive run of two-level + // imports for the same module, we coalesce them into an implicit instance + // import. + let mut implicit_instance_import: Option<(&str, InstanceType)> = None; + // Check that we can properly handle all imports. let count = imports.get_count(); for _ in 0..count { @@ -234,10 +259,34 @@ fn import_section<'a>( ); } + match (implicit_instance_import.as_mut(), imp.field) { + (Some((implicit_module, instance_ty)), Some(field)) + if *implicit_module == imp.module => + { + let ty = module.entity_type(cx, imp.ty); + let old = instance_ty.exports.insert(field.into(), ty); + debug_assert!(old.is_none(), "checked by validation"); + } + _ => { + if let Some((_, instance_ty)) = implicit_instance_import.take() { + module.push_implicit_instance(cx, instance_ty); + instance_import_count += 1; + } + if let Some(field) = imp.field { + let field_ty = module.entity_type(cx, imp.ty); + let instance_ty = InstanceType { + exports: Some((field.into(), field_ty)).into_iter().collect(), + }; + implicit_instance_import = Some((imp.module, instance_ty)); + } + } + } + check_import_type( - &stack.top().module.types(cx), + cx, + stack.top().module.types(cx), stack.top().module.is_root(), - &imp.ty, + &module.entity_type(cx, imp.ty), )?; if let wasmparser::ImportSectionEntryType::Instance(_) = imp.ty { instance_import_count += 1; @@ -245,33 +294,37 @@ fn import_section<'a>( module.push_import(cx, imp); } + if let Some((_, instance_ty)) = implicit_instance_import.take() { + module.push_implicit_instance(cx, instance_ty); + instance_import_count += 1; + } + module.push_instance_import_count(cx, instance_import_count); Ok(()) } fn check_import_type( - types: &[wasmparser::TypeDef], + cx: &ModuleContext, + types: &[TypeId], is_root: bool, - ty: &wasmparser::ImportSectionEntryType, + ty: &EntityType, ) -> Result<()> { match ty { - wasmparser::ImportSectionEntryType::Module(_) => { - unreachable!(); - } - wasmparser::ImportSectionEntryType::Instance(inst_ty_index) => { + EntityType::Function(_) => Ok(()), + EntityType::Instance(inst_ty) => { // We allow importing instances that only export things that are // acceptable imports. This is equivalent to a two-layer import. - match &types[usize::try_from(*inst_ty_index).unwrap()] { - wasmparser::TypeDef::Instance(inst_ty) => { - for e in inst_ty.exports.iter() { - check_import_type(&types, is_root, &e.ty)?; + match cx.types().get(*inst_ty) { + Type::Instance(inst_ty) => { + for ty in inst_ty.exports.values() { + check_import_type(cx, types, is_root, ty)?; } Ok(()) } _ => unreachable!(), } } - wasmparser::ImportSectionEntryType::Memory(mem_ty) => match mem_ty { + EntityType::Memory(mem_ty) => match mem_ty { wasmparser::MemoryType::M32 { limits: _, shared } => { anyhow::ensure!(!shared, "shared memories are not supported by Wizer yet"); anyhow::ensure!( @@ -284,18 +337,16 @@ fn check_import_type( anyhow::bail!("the memory64 proposal is not supported by Wizer yet") } }, - wasmparser::ImportSectionEntryType::Event(_) => { - unreachable!("validation should have rejected the exceptions proposal") - } - wasmparser::ImportSectionEntryType::Function(_) => Ok(()), - wasmparser::ImportSectionEntryType::Table(_) - | wasmparser::ImportSectionEntryType::Global(_) => { + EntityType::Table(_) | EntityType::Global(_) => { anyhow::ensure!( !is_root, "table and global imports are not allowed in the root Wasm module" ); Ok(()) } + EntityType::Module(_) => { + unreachable!(); + } } } @@ -322,9 +373,8 @@ fn alias_section<'a>( // parent, not this module itself. let ty = stack[stack.len() - 2 - relative_depth] .module - .type_at(cx, *index) - .clone(); - module.push_type(cx, ty); + .type_id_at(cx, *index); + module.push_aliased_type(cx, ty); } wasmparser::Alias::OuterModule { relative_depth, @@ -347,37 +397,36 @@ fn alias_section<'a>( anyhow::bail!("exported modules are not supported yet") } wasmparser::ExternalKind::Instance => { - let inst_ty_idx = match module.instance_export(cx, *instance, export) { - Some(wasmparser::ImportSectionEntryType::Instance(i)) => i, + let inst_ty = match module.instance_export(cx, *instance, export) { + Some(EntityType::Instance(i)) => *i, _ => unreachable!(), }; - let inst_ty = module.instance_type_at(cx, inst_ty_idx).clone(); module.push_aliased_instance(cx, inst_ty); } wasmparser::ExternalKind::Function => { - let func_ty_idx = match module.instance_export(cx, *instance, export) { - Some(wasmparser::ImportSectionEntryType::Function(i)) => i, + let func_ty = match module.instance_export(cx, *instance, export) { + Some(EntityType::Function(ty)) => *ty, _ => unreachable!(), }; - module.push_function(cx, func_ty_idx); + module.push_function(cx, func_ty); } wasmparser::ExternalKind::Table => { let table_ty = match module.instance_export(cx, *instance, export) { - Some(wasmparser::ImportSectionEntryType::Table(ty)) => ty, + Some(EntityType::Table(ty)) => *ty, _ => unreachable!(), }; module.push_table(cx, table_ty); } wasmparser::ExternalKind::Memory => { let ty = match module.instance_export(cx, *instance, export) { - Some(wasmparser::ImportSectionEntryType::Memory(ty)) => ty, + Some(EntityType::Memory(ty)) => *ty, _ => unreachable!(), }; module.push_imported_memory(cx, ty); } wasmparser::ExternalKind::Global => { let ty = match module.instance_export(cx, *instance, export) { - Some(wasmparser::ImportSectionEntryType::Global(ty)) => ty, + Some(EntityType::Global(ty)) => *ty, _ => unreachable!(), }; module.push_imported_global(cx, ty); @@ -409,7 +458,7 @@ fn instance_section<'a>( let inst = instances.read()?; let module_index = inst.module(); let child_module = module.child_module_at(cx, module_index); - let inst_ty = child_module.instance_type(cx); + let inst_ty = child_module.define_instance_type(cx); let mut instance_args_reader = inst.args()?; let instance_args_count = usize::try_from(instance_args_reader.get_count()).unwrap(); @@ -435,7 +484,8 @@ fn function_section<'a>( let count = usize::try_from(funcs.get_count()).unwrap(); for _ in 0..count { - let ty = funcs.read()?; + let ty_idx = funcs.read()?; + let ty = module.type_id_at(cx, ty_idx); module.push_function(cx, ty); } Ok(()) diff --git a/crates/wizer/src/rewrite.rs b/crates/wizer/src/rewrite.rs index 2abbe03ef834..b8c4f6fa21b9 100644 --- a/crates/wizer/src/rewrite.rs +++ b/crates/wizer/src/rewrite.rs @@ -3,7 +3,10 @@ mod renumbering; use crate::{ - info::{Module, ModuleContext}, + info::{ + types_interner::{EntityType, Type}, + Module, ModuleContext, + }, snapshot::Snapshot, translate, FuncRenames, Wizer, }; @@ -15,123 +18,9 @@ impl Wizer { /// Given the initialized snapshot, rewrite the Wasm so that it is already /// initialized. /// - /// ## Code Shape - /// - /// With module linking, we rewrite each nested module into a *code module* - /// that doesn't define any internal state (i.e. memories, globals, and - /// nested instances) and imports a *state instance* that exports all of - /// these things instead. For each instantiation of a nested module, we have - /// a *state module* that defines the already-initialized state for that - /// instantiation, we instantiate that state module to create one such state - /// instance, and then use this as an import argument in the instantiation - /// of the original code module. This way, we do not duplicate shared code - /// bodies across multiple instantiations of the same module. - /// - /// Note that the root module is not split into a code module and state - /// instance. We can, essentially, assume that there is only one instance of - /// the root module, and rewrite it in place, without factoring the state - /// out into a separate instance. This is because the root is not allowed to - /// import any external state, so even if it were instantiated multiple - /// times, it would still end up in the same place anyways. (This is kinda - /// the whole reason why Wizer works at all.) - /// - /// For example, given this input Wasm module: - /// - /// ```wat - /// (module $A - /// (module $B - /// (memory $B_mem) - /// (global $B_glob (mut i32)) - /// (func (export "f") ...) - /// ) - /// - /// (instance $x (instantiate $B)) - /// (instance $y (instantiate $B)) - /// - /// (memory $A_mem) - /// (global $A_glob (mut i32)) - /// - /// (func (export "g") ...) - /// ) - /// ``` - /// - /// and some post-initialization state, this rewrite pass will produce the - /// following pre-initialized module: - /// - /// ```wat - /// (module $A - /// (module $B - /// ;; Locally defined state is replaced by a state instance import. - /// (import "__wizer_state" - /// (instance - /// (export "__wizer_memory_0" (memory $B_mem)) - /// (export "__wizer_global_0" (global $B_glob (mut i32))) - /// ) - /// ) - /// (func (export "f") ...) - /// ) - /// - /// ;; Instantiations are replaced with specialized state modules that get - /// ;; instantiated exactly once to produce state instances, and finally - /// ;; the original instantiations are rewritten into instantiations of - /// ;; the corresponding code module with the state instance as an import - /// ;; argument. - /// - /// ;; State module for `$x`. - /// (module $x_state_module - /// (memory (export "__wizer_memory_0") (memory)) - /// ;; Data segments to initialize the memory based on our snapshot - /// ;; would go here... - /// - /// (global (export "__wizer_global_0") - /// (global (mut i32) (i32.const (; ...snapshot's initialized value goes here... ;))) - /// ) - /// ) - /// - /// ;; State instance for `$x`. - /// (instance $x_state (instantiate $x_state_module)) - /// - /// ;; The instantiation of `$x` is now rewritten to use our state - /// ;; instance. - /// (instance $x (instantiate $B (import "__wizer_state" $x_state))) - /// - /// ;; Same goes for the `$y` instantiation. - /// (module $y_state_module - /// (memory (export "__wizer_memory_0") (memory)) - /// ;; Data segments... - /// (global (export "__wizer_global_0") - /// (global (mut i32) (i32.const (; ...snapshot's initialized value goes here... ;))) - /// ) - /// ) - /// (instance $y_state (instantiate $y_state_module)) - /// (instance $y (instantiate $B (import "__wizer_state" $y_state))) - /// - /// (memory $A_mem) - /// (global $A_glob (mut i32)) - /// ) - /// ``` - /// - /// ## Implementation - /// - /// To implement this transformation, we first do a pre-order walk of the - /// module tree and emit the code modules as a flat sequence. Why a flat - /// sequence? The code modules cannot contain nested instantiations, because - /// nested instantiations are state that is not necessarily shared across - /// all instantiations of the outer module. And if we are already lifting - /// out nested instantiations, we need to also make nested modules available - /// for those lifted instantiations, and the easiest way to do that is to - /// flatten the code module tree (as opposed to re-exporting the nested - /// modules under well-known symbols). The pre-order traversal ensures that - /// the `Module::id` we assigned during the instrumentation phase matches - /// the module's place in the index space. The state modules, however, - /// remain a nested tree, and we emit them in a traversal of the `Snapshot` - /// instance tree. This is safe because, unlike code modules, each state - /// module is only instantiated exactly once. The instantiations' references - /// to nested modules become outer aliases pointing to the module's position - /// in the parent's flat sequence of nested modules. pub(crate) fn rewrite( &self, - cx: &ModuleContext, + cx: &mut ModuleContext<'_>, snapshot: &Snapshot, renames: &FuncRenames, ) -> Vec { @@ -148,7 +37,7 @@ impl Wizer { /// linking at all. fn rewrite_without_module_linking( &self, - cx: &ModuleContext, + cx: &ModuleContext<'_>, snapshot: &Snapshot, renames: &FuncRenames, ) -> Vec { @@ -293,324 +182,344 @@ impl Wizer { } /// Rewrite a module linking bundle. + /// + /// ## Code Shape + /// + /// With module linking, we rewrite each module in the original bundle into + /// a *code module* that doesn't define any internal state (i.e. memories, + /// globals, and nested instances) and instead imports a *state instance* + /// that exports all of these things. For each instantiation, we have a + /// *state module* that defines the already-initialized state for that + /// instantiation, we instantiate that state module to create one such state + /// instance, and then use this as an import argument in the instantiation + /// of the original code module. This way, we do not duplicate shared code + /// bodies across multiple instantiations of the same module. + /// + /// Note that the root module is also split out into a code module and state + /// module, even though it is never explicitly instantiated inside the + /// bundle. + /// + /// The new root is an "umbrella" module that defines all the types used + /// within the whole bundle. Each nested module then aliases its types from + /// the umbrella module. The umbrella module aliases all exports of the + /// original root and re-exports them. + /// + /// For example, given this input Wasm module: + /// + /// ```wat + /// (module $A + /// (module $B + /// (memory $B_mem) + /// (global $B_glob (mut i32)) + /// (func (export "f") ...) + /// ) + /// + /// (instance $x (instantiate $B)) + /// (instance $y (instantiate $B)) + /// + /// (memory $A_mem) + /// (global $A_glob (mut i32)) + /// + /// (func (export "g") ...) + /// ) + /// ``` + /// + /// and some post-initialization state, this rewrite pass will produce the + /// following pre-initialized module: + /// + /// ```wat + /// (module $Umbrella + /// (module $A + /// ;; Locally defined state is replaced by a state instance import. + /// (import "__wizer_state" + /// (instance + /// (export "__wizer_memory_0" (memory $A_mem)) + /// (export "__wizer_global_0" (global $A_glob (mut i32))) + /// (export "__wizer_instance_0" (instance $x (export "f" (func)))) + /// (export "__wizer_instance_1" (instance $y (export "f" (func)))) + /// ) + /// ) + /// (func (export "g") ...) + /// ) + /// + /// (module $B + /// ;; Locally defined state is replaced by a state instance import. + /// (import "__wizer_state" + /// (instance + /// (export "__wizer_memory_0" (memory $B_mem)) + /// (export "__wizer_global_0" (global $B_glob (mut i32))) + /// ) + /// ) + /// (func (export "f") ...) + /// ) + /// + /// ;; Instantiations are replaced with specialized state modules that get + /// ;; instantiated exactly once to produce state instances, and finally + /// ;; the original instantiations are rewritten into instantiations of + /// ;; the corresponding code module with the state instance as an import + /// ;; argument. + /// + /// ;; State module for `$A`. + /// (module $A_state_module + /// ;; State module for `$x`. + /// (module $x_state_module + /// (memory (export "__wizer_memory_0") (memory)) + /// ;; Data segments to initialize the memory based on our snapshot + /// ;; would go here... + /// + /// (global (export "__wizer_global_0") + /// (global (mut i32) (i32.const (; ...snapshot's initialized value goes here... ;))) + /// ) + /// ) + /// + /// ;; State instance for `$x`. + /// (instance $x_state (instantiate $x_state_module)) + /// + /// ;; The instantiation of `$x` is now rewritten to use our state + /// ;; instance. + /// (instance $x (instantiate $B (import "__wizer_state" $x_state))) + /// + /// ;; Same goes for the `$y` instantiation. + /// (module $y_state_module + /// (memory (export "__wizer_memory_0") (memory)) + /// ;; Data segments... + /// (global (export "__wizer_global_0") + /// (global (mut i32) (i32.const (; ...snapshot's initialized value goes here... ;))) + /// ) + /// ) + /// (instance $y_state (instantiate $y_state_module)) + /// (instance $y (instantiate $B (import "__wizer_state" $y_state))) + /// + /// (memory $A_mem) + /// (global $A_glob (mut i32)) + /// ) + /// + /// ;; State instance for `$A`. + /// (instance $a_state (instantiate $A_state_module)) + /// + /// ;; The state is now joined with the code. + /// (instance $a_instance (instantiate $A (import "__wizer_state" $a_state))) + /// + /// ;; And finally we re-export all of our old root's exports. + /// (export "g" (func $a_instance "g")) + /// ) + /// ``` + /// + /// ## Implementation + /// + /// To implement this transformation, we first do a pre-order walk of the + /// module tree and emit the code modules as a flat sequence. Why a flat + /// sequence? The code modules cannot contain nested instantiations, because + /// nested instantiations are state that is not necessarily shared across + /// all instantiations of the outer module. And if we are already lifting + /// out nested instantiations, we need to also make nested modules available + /// for those lifted instantiations, and the easiest way to do that is to + /// flatten the code module tree (as opposed to re-exporting the nested + /// modules under well-known symbols). The pre-order traversal ensures that + /// the `Module::id` we assigned during the instrumentation phase matches + /// the module's place in the index space. + /// + /// The state modules, however, remain a nested tree, and we emit them in a + /// traversal of the `Snapshot` instance tree. We can do this because, + /// unlike code modules, each state module is only instantiated exactly + /// once. The instantiations' references to nested modules become outer + /// aliases pointing to the module's position in the parent's flat sequence + /// of nested modules. fn rewrite_with_module_linking( &self, - cx: &ModuleContext<'_>, + cx: &mut ModuleContext<'_>, snapshot: &Snapshot, renames: &FuncRenames, ) -> Vec { - let root_info = cx.root(); - let mut root = wasm_encoder::Module::new(); + let mut umbrella = wasm_encoder::Module::new(); - let types = make_complete_type_section(cx, root_info); - root.section(&types); + // Counts of various entities defined inside the umbrella module thus + // far. + let mut umbrella_funcs = 0; + let mut umbrella_tables = 0; + let mut umbrella_memories = 0; + let mut umbrella_globals = 0; + let mut umbrella_instances = 0; let (code_modules, num_code_modules) = rewrite_code_modules(cx); - root.section(&code_modules); - - let state_modules = rewrite_state_modules(cx, &snapshot.instantiations); - root.section(&state_modules); - - self.rewrite_root(cx, &mut root, snapshot, renames, num_code_modules); - - root.finish() - } - - fn rewrite_root( - &self, - cx: &ModuleContext, - root: &mut wasm_encoder::Module, - snapshot: &Snapshot, - renames: &FuncRenames, - num_code_modules: u32, - ) { - let root_info = cx.root(); - - // Encode the initialized data segments from the snapshot rather - // than the original, uninitialized data segments. - let mut data_section = if snapshot.data_segments.is_empty() { - None - } else { - let mut data_section = wasm_encoder::DataSection::new(); - for seg in &snapshot.data_segments { - data_section.active( - seg.memory_index, - wasm_encoder::Instruction::I32Const(seg.offset as i32), - seg.data.iter().copied(), - ); - } - Some(data_section) - }; - // There are multiple places were we potentially need to check whether - // we've added the data section already and if we haven't yet, then do - // so. For example, the original Wasm might not have a data section at - // all, and so we have to potentially add it at the end of iterating - // over the original sections. This closure encapsulates all that - // add-it-if-we-haven't-already logic in one place. - let mut add_data_section = |module: &mut wasm_encoder::Module| { - if let Some(data_section) = data_section.take() { - module.section(&data_section); + let root_state_module = rewrite_state_module(cx, cx.root(), &snapshot, 0); + let mut modules = wasm_encoder::ModuleSection::new(); + modules.module(&root_state_module); + let root_state_module_index = num_code_modules; + + // Imports that we will need to pass through from the umbrella to the + // root instance. + let import_sections: Vec<_> = cx + .root() + .initial_sections(cx) + .filter(|s| s.id == SectionId::Import.into()) + .collect(); + + // Instantiate the root state module by forwarding imports from the + // umbrella to the root instantiation. + // + // There is some trickery for implicit instance imports. We forward the + // implicit instance as an instantiation argument, since we can't + // provide two-level instantiation arguments, which means we need to + // determine when implicit imports are injected again. + let mut instances = wasm_encoder::InstanceSection::new(); + let mut args = vec![]; + let mut imports = cx.root().imports(cx).iter().peekable(); + loop { + let (module, is_two_level) = match imports.peek() { + Some(imp) => (imp.module, imp.field.is_some()), + None => break, + }; + + if is_two_level { + args.push((module, wasm_encoder::Export::Instance(umbrella_instances))); + umbrella_instances += 1; } - }; - - // A map from the original Wasm's instance numbering to the newly rewritten - // instance numbering. - let mut instance_renumbering = Renumbering::default(); - - let mut instance_import_counts = root_info.instance_import_counts(cx).iter().copied(); - let mut instantiations = root_info.instantiations(cx).values().enumerate(); - let mut aliases = root_info.aliases(cx).iter(); - - for section in root_info.raw_sections(cx) { - match section { - // Some tools expect the name custom section to come last, even - // though custom sections are allowed in any order. Therefore, - // make sure we've added our data section by now. - s if is_name_section(s) => { - add_data_section(root); - root.section(s); - } - - s if s.id == SectionId::Custom.into() => { - root.section(s); - } - - // These were already added in `make_complete_type_section`. - s if s.id == SectionId::Type.into() => { - continue; - } - - // These were already taken care of in `rewrite_code_modules`. - s if s.id == SectionId::Module.into() => { - continue; - } - - // Import sections are just copied over, but we additionally - // must make sure that our count of how many instances are - // currently in this module's instance export space and map from - // old instance numbering to new instance numbering are - // correctly updated for any instances that were imported in - // this section. - s if s.id == SectionId::Import.into() => { - root.section(s); - - let instance_import_count = instance_import_counts.next().unwrap(); - for _ in 0..instance_import_count { - instance_renumbering.add_import(); - } - } - - // Instantiations from the original Wasm become two - // instantiations in the rewritten Wasm: - // - // 1. First, we instantiate the state module for this instance - // to create the rewritten state instance. - // - // 2. Then, we instantiate this instance's code module, passing - // it the state instance and any other import arguments it - // originally had. This, finally, is the rewritten version of - // the original instance. - // - // Because there are two instances, where previously there was - // one, we are forced to renumber the instance index space. - s if s.id == SectionId::Instance.into() => { - let mut instances = wasm_encoder::InstanceSection::new(); - let count = wasmparser::InstanceSectionReader::new(s.data, 0) - .unwrap() - .get_count(); - for (nth_defined_inst, (module, instance_args)) in instantiations - .by_ref() - .take(usize::try_from(count).unwrap()) - { - // Instantiate the state module. - let args: Vec<_> = instance_args - .iter() - .map(|arg| { - let mut arg = translate::instance_arg(arg); - if let (_name, wasm_encoder::Export::Instance(ref mut index)) = arg - { - *index = instance_renumbering.lookup(*index); - } - arg - }) - .collect(); - instances.instantiate( - num_code_modules + u32::try_from(nth_defined_inst).unwrap(), - args, - ); - let state_instance_index = instance_renumbering.define_new(); - - // Instantiate the code module with our state instance - // and the original import arguments. - let args: Vec<_> = iter::once(( - "__wizer_state", - wasm_encoder::Export::Instance(state_instance_index), - )) - .chain(instance_args.iter().map(|arg| { - let mut arg = translate::instance_arg(arg); - if let (_name, wasm_encoder::Export::Instance(ref mut index)) = arg { - *index = instance_renumbering.lookup(*index); - } - arg - })) - .collect(); - instances.instantiate(module.pre_order_index() - 1, args); - instance_renumbering.define_both(); + while imports.peek().map_or(false, |imp| imp.module == module) { + let imp = imports.next().unwrap(); + let export = match imp.ty { + wasmparser::ImportSectionEntryType::Function(_) => { + umbrella_funcs += 1; + wasm_encoder::Export::Function(umbrella_funcs - 1) } - root.section(&instances); - } - - // For the alias section, we update instance export aliases to - // use the new instance numbering. - s if s.id == SectionId::Alias.into() => { - let count = wasmparser::AliasSectionReader::new(s.data, 0) - .unwrap() - .get_count(); - let mut section = wasm_encoder::AliasSection::new(); - for alias in aliases.by_ref().take(usize::try_from(count).unwrap()) { - match alias { - wasmparser::Alias::InstanceExport { - instance, - kind, - export, - } => { - section.instance_export( - instance_renumbering.lookup(*instance), - translate::item_kind(*kind), - export, - ); - // If this brought a new instance into our - // instance index space, update our renumbering - // map. - if let wasmparser::ExternalKind::Instance = kind { - instance_renumbering.add_alias(); - } - } - wasmparser::Alias::OuterType { .. } - | wasmparser::Alias::OuterModule { .. } => { - unreachable!( - "the root can't alias any outer entities because there are \ - no entities outside the root module" - ) - } - } + wasmparser::ImportSectionEntryType::Instance(_) => { + umbrella_instances += 1; + wasm_encoder::Export::Instance(umbrella_instances - 1) } - root.section(§ion); + _ => unreachable!(), + }; + if !is_two_level { + args.push((module, export)); } + } + } + instances.instantiate(root_state_module_index, args.iter().cloned()); + let root_state_instance_index = umbrella_instances; + umbrella_instances += 1; + + // Instantiate the root code module with the root state module. + let root_module_index = cx.root().pre_order_index(); + args.push(( + "__wizer_state", + wasm_encoder::Export::Instance(root_state_instance_index), + )); + instances.instantiate(root_module_index, args); + let root_instance_index = umbrella_instances; + umbrella_instances += 1; + + // Alias the root instance's exports and then re-export them. + let mut aliases = wasm_encoder::AliasSection::new(); + let mut exports = wasm_encoder::ExportSection::new(); + for exp in cx.root().exports(cx) { + if exp.field == self.init_func { + continue; + } - s if s.id == SectionId::Function.into() => { - root.section(s); - } + if !renames.rename_src_to_dst.contains_key(exp.field) + && renames.rename_dsts.contains(exp.field) + { + // A rename overwrites this export, and it is not renamed to + // another export, so skip it. + continue; + } - s if s.id == SectionId::Table.into() => { - root.section(s); - } + let kind = translate::item_kind(exp.kind); + aliases.instance_export(root_instance_index, kind, exp.field); - // For the memory section, we update the minimum size of each - // defined memory to the snapshot's initialized size for that - // memory. - s if s.id == SectionId::Memory.into() => { - let mut memories = wasm_encoder::MemorySection::new(); - assert_eq!( - root_info.defined_memories_len(cx), - snapshot.memory_mins.len() - ); - for ((_, mem), new_min) in root_info - .defined_memories(cx) - .zip(snapshot.memory_mins.iter().copied()) - { - let mut mem = translate::memory_type(mem); - mem.limits.min = new_min; - memories.memory(mem); + let field = renames + .rename_src_to_dst + .get(exp.field) + .map_or(exp.field, |f| f.as_str()); + exports.export( + field, + match kind { + wasm_encoder::ItemKind::Function => { + umbrella_funcs += 1; + wasm_encoder::Export::Function(umbrella_funcs - 1) } - root.section(&memories); - } - - // Encode the initialized global values from the snapshot, - // rather than the original values. - s if s.id == SectionId::Global.into() => { - let mut globals = wasm_encoder::GlobalSection::new(); - for ((_, glob_ty), val) in - root_info.defined_globals(cx).zip(snapshot.globals.iter()) - { - let glob_ty = translate::global_type(glob_ty); - globals.global( - glob_ty, - match val { - wasmtime::Val::I32(x) => wasm_encoder::Instruction::I32Const(*x), - wasmtime::Val::I64(x) => wasm_encoder::Instruction::I64Const(*x), - wasmtime::Val::F32(x) => { - wasm_encoder::Instruction::F32Const(f32::from_bits(*x)) - } - wasmtime::Val::F64(x) => { - wasm_encoder::Instruction::F64Const(f64::from_bits(*x)) - } - _ => unreachable!(), - }, - ); + wasm_encoder::ItemKind::Table => { + umbrella_tables += 1; + wasm_encoder::Export::Table(umbrella_tables - 1) } - root.section(&globals); - } - - // Remove the initialization function's export and perform any - // requested renames. - s if s.id == SectionId::Export.into() => { - let mut exports = wasm_encoder::ExportSection::new(); - for export in root_info.exports(cx) { - if export.field == self.init_func { - continue; - } - - if !renames.rename_src_to_dst.contains_key(export.field) - && renames.rename_dsts.contains(export.field) - { - // A rename overwrites this export, and it is not - // renamed to another export, so skip it. - continue; - } - - let field = renames - .rename_src_to_dst - .get(export.field) - .map_or(export.field, |f| f.as_str()); - - let mut export = translate::export(export.kind, export.index); - if let wasm_encoder::Export::Instance(ref mut index) = export { - *index = instance_renumbering.lookup(*index); - } - - exports.export(field, export); + wasm_encoder::ItemKind::Memory => { + umbrella_memories += 1; + wasm_encoder::Export::Memory(umbrella_memories - 1) } - root.section(&exports); - } - - // Skip the `start` function -- it's already been run! - s if s.id == SectionId::Start.into() => { - continue; - } + wasm_encoder::ItemKind::Global => { + umbrella_globals += 1; + wasm_encoder::Export::Global(umbrella_globals - 1) + } + wasm_encoder::ItemKind::Instance => { + umbrella_instances += 1; + wasm_encoder::Export::Instance(umbrella_instances - 1) + } + wasm_encoder::ItemKind::Module => unreachable!(), + }, + ); + } - s if s.id == SectionId::Element.into() => { - root.section(s); - } + // NB: We encode the types last, even though it is the first section we + // place in the umbrella module, since adding state imports may need to + // define new instance types. + let types = umbrella_type_section(cx); + + // Now combine all our sections together in the umbrella module. + umbrella.section(&types); + umbrella.section(&code_modules); + umbrella.section(&modules); + for s in import_sections { + umbrella.section(s); + } + umbrella.section(&instances); + umbrella.section(&aliases); + umbrella.section(&exports); - s if s.id == SectionId::Data.into() => { - // TODO: supporting bulk memory will require copying over - // any passive and declared segments. - add_data_section(root); - } + umbrella.finish() + } +} - s if s.id == SectionId::Code.into() => { - root.section(s); - } +/// Create a type section with everything in the whole interned types set. +fn umbrella_type_section(cx: &ModuleContext<'_>) -> wasm_encoder::TypeSection { + let mut types = wasm_encoder::TypeSection::new(); - _ => unreachable!(), - } - } + let interned_entity_to_encoder_entity = |ty: &EntityType| match ty { + EntityType::Function(ty) => wasm_encoder::EntityType::Function(ty.index()), + EntityType::Table(ty) => wasm_encoder::EntityType::Table(translate::table_type(*ty)), + EntityType::Memory(ty) => wasm_encoder::EntityType::Memory(translate::memory_type(*ty)), + EntityType::Global(ty) => wasm_encoder::EntityType::Global(translate::global_type(*ty)), + EntityType::Module(ty) => wasm_encoder::EntityType::Module(ty.index()), + EntityType::Instance(ty) => wasm_encoder::EntityType::Instance(ty.index()), + }; - // Make sure that we've added our data section to the module. - add_data_section(root); + for (_index, ty) in cx.types().iter() { + match ty { + Type::Func(f) => types.function( + f.params.iter().copied().map(translate::val_type), + f.returns.iter().copied().map(translate::val_type), + ), + Type::Instance(inst) => types.instance( + inst.exports + .iter() + .map(|(name, ty)| (name.as_ref(), interned_entity_to_encoder_entity(ty))), + ), + Type::Module(module) => types.module( + module.imports.iter().map(|((module, name), ty)| { + ( + module.as_ref(), + name.as_ref().map(|n| n.as_ref()), + interned_entity_to_encoder_entity(ty), + ) + }), + module + .exports + .iter() + .map(|(name, ty)| (name.as_ref(), interned_entity_to_encoder_entity(ty))), + ), + }; } + + types } fn is_name_section(s: &wasm_encoder::RawSection) -> bool { @@ -625,14 +534,21 @@ fn is_name_section(s: &wasm_encoder::RawSection) -> bool { /// /// Returns the modules encoded in a module section and total number of code /// modules defined. -fn rewrite_code_modules(cx: &ModuleContext) -> (wasm_encoder::ModuleSection, u32) { - let mut modules = wasm_encoder::ModuleSection::new(); +fn rewrite_code_modules(cx: &mut ModuleContext) -> (wasm_encoder::ModuleSection, u32) { + let mut code_modules = wasm_encoder::ModuleSection::new(); let mut num_code_modules = 0; - cx.root().pre_order(cx, |info| { - // The root module is handled by `rewrite_root`; we are only dealing - // with nested children here. - if info.is_root() { + cx.root().pre_order(cx, |cx, info| { + if info.get_aliased(cx).is_some() { + // Add a dummy module. This isn't ever actually used, since we will + // instead resolve the alias at the use sites and then use the + // aliased referent instead. If we had an alias kind like "alias a + // module from this index space" we would use that here. But we have + // to add an entry to the module index space to preserve our + // invariant that a code module is at its pre-order index in the + // umbrella's module index space. + code_modules.module(&wasm_encoder::Module::new()); + num_code_modules += 1; return; } @@ -671,10 +587,12 @@ fn rewrite_code_modules(cx: &ModuleContext) -> (wasm_encoder::ModuleSection, u32 // avoid renumbering types, we do a first pass over this module's types // and build out a full type section with the same numbering as the // original module, and then append the state import's type at the end. - let mut types = make_complete_type_section(cx, info); - let import = make_state_import(cx, info, &mut types); - module.section(&types); - module.section(&import); + let type_aliases = make_aliased_type_section(cx, info, 0); + module.section(&type_aliases); + let sections = make_state_import(cx, info); + for s in sections { + module.section(&s); + } // Now rewrite the initial sections one at a time. // @@ -691,7 +609,7 @@ fn rewrite_code_modules(cx: &ModuleContext) -> (wasm_encoder::ModuleSection, u32 let mut first_non_initial_section = None; for section in sections.by_ref() { match section { - // We handled this in `make_complete_type_section` above. + // We handled this above. s if s.id == SectionId::Type.into() => continue, // These are handled in subsequent steps of this pre-order @@ -832,91 +750,45 @@ fn rewrite_code_modules(cx: &ModuleContext) -> (wasm_encoder::ModuleSection, u32 } } - modules.module(&module); + code_modules.module(&module); num_code_modules += 1; }); - (modules, num_code_modules) + (code_modules, num_code_modules) } -/// Make a single complete type section for the given module info, regardless of -/// how many initial type sections these types might have been defined within in -/// the original module's serialization. -fn make_complete_type_section(cx: &ModuleContext, info: Module) -> wasm_encoder::TypeSection { - let mut types = wasm_encoder::TypeSection::new(); - for ty in info.types(cx) { - match ty { - wasmparser::TypeDef::Func(func_ty) => { - types.function( - func_ty.params.iter().map(|ty| translate::val_type(*ty)), - func_ty.returns.iter().map(|ty| translate::val_type(*ty)), - ); - } - wasmparser::TypeDef::Instance(inst_ty) => { - types.instance( - inst_ty - .exports - .iter() - .map(|e| (e.name, translate::entity_type(e.ty))), - ); - } - wasmparser::TypeDef::Module(_) => { - unreachable!( - "we don't support importing/exporting modules so don't have to deal \ - with module types" - ) - } - } +/// Make the equivalent of the given module's type section from outer type +/// aliases that bring types from the umbrella module's types space into this +/// code module's types space. +fn make_aliased_type_section( + cx: &ModuleContext<'_>, + module: Module, + depth: u32, +) -> wasm_encoder::AliasSection { + let mut aliases = wasm_encoder::AliasSection::new(); + for ty in module.types(cx) { + aliases.outer_type(depth, ty.index()); } - types + aliases } /// Make an import section that imports a code module's state instance import. fn make_state_import( - cx: &ModuleContext, - info: Module, - types: &mut wasm_encoder::TypeSection, -) -> wasm_encoder::ImportSection { - let mut num_types = u32::try_from(info.types(cx).len()).unwrap(); - - // Define instance types for each of the instances that we - // previously instantiated locally so that we can refer to - // these types in the state instance's type. - let instance_types = info - .instantiations(cx) - .values() - .map(|(m, _)| m.define_instance_type(cx, &mut num_types, types)) - .collect::>(); + cx: &mut ModuleContext<'_>, + module: Module, +) -> Vec { + let mut sections = vec![]; // Define the state instance's type. - let state_instance_exports = info - .defined_globals(cx) - .enumerate() - .map(|(i, (_, g))| { - ( - format!("__wizer_global_{}", i), - wasm_encoder::EntityType::Global(translate::global_type(g)), - ) - }) - .chain(info.defined_memories(cx).enumerate().map(|(i, (_, m))| { - ( - format!("__wizer_memory_{}", i), - wasm_encoder::EntityType::Memory(translate::memory_type(m)), - ) - })) - .chain(instance_types.iter().enumerate().map(|(i, type_index)| { - ( - format!("__wizer_instance_{}", i), - wasm_encoder::EntityType::Instance(*type_index), - ) - })) - .collect::>(); - let state_instance_type_index = num_types; - types.instance( - state_instance_exports - .iter() - .map(|(name, e)| (name.as_str(), *e)), - ); + let state_instance_ty = module.define_state_instance_type(cx); + + // Alias the state instance type from the umbrella. + let mut alias = wasm_encoder::AliasSection::new(); + alias.outer_type(0, state_instance_ty.index()); + sections.push(StateImportSection::Alias(alias)); + + let state_instance_type_index = u32::try_from(module.types(cx).len()).unwrap(); + module.push_aliased_type(cx, state_instance_ty); // Define the import of the state instance, using the type // we just defined. @@ -926,41 +798,39 @@ fn make_state_import( None, wasm_encoder::EntityType::Instance(state_instance_type_index), ); - imports -} + sections.push(StateImportSection::Import(imports)); -/// Define the state modules for each instantiation. -/// -/// These are modules that just define the memories/globals/nested instances of -/// a particular instantiation and initialize them to the snapshot's state. They -/// have no imports and export all of their internal state entities. -/// -/// This does *not* instantiate the state modules in the resulting module -/// section, just defines them (although nested state modules within these top -/// level-state modules are instantiated inside these top-level state -/// modules). That is because instantiation is handled differently depending on -/// if the instantiation happens directly inside the root module (see the -/// handling of instance sections in `rewrite_root`) or in a deeply nested -/// module (in which case it is instantiated by its parent state module, -/// i.e. another recursive invocation of this function that is one frame up the -/// stack). -fn rewrite_state_modules( - cx: &ModuleContext, - snapshots: &[Snapshot], -) -> wasm_encoder::ModuleSection { - let mut modules = wasm_encoder::ModuleSection::new(); - - assert_eq!(snapshots.len(), cx.root().instantiations(cx).len()); - for (snapshot, (module, _)) in snapshots.iter().zip(cx.root().instantiations(cx).values()) { - let state_module = rewrite_one_state_module(cx, *module, snapshot, 0); - modules.module(&state_module); + return sections; + + enum StateImportSection { + Alias(wasm_encoder::AliasSection), + Import(wasm_encoder::ImportSection), } - modules + impl wasm_encoder::Section for StateImportSection { + fn id(&self) -> u8 { + match self { + StateImportSection::Alias(s) => s.id(), + StateImportSection::Import(s) => s.id(), + } + } + + fn encode(&self, sink: &mut S) + where + S: Extend, + { + match self { + StateImportSection::Alias(s) => s.encode(sink), + StateImportSection::Import(s) => s.encode(sink), + } + } + } } -fn rewrite_one_state_module( - cx: &ModuleContext, +/// Create the state module the given module instantiation and recursively do +/// the same for its nested instantiations. +fn rewrite_state_module( + cx: &ModuleContext<'_>, info: Module, snapshot: &Snapshot, depth: u32, @@ -989,17 +859,34 @@ fn rewrite_one_state_module( // That is, the `i`th nested instantiation's code module is the `i`th // module in the index space, and its state module is at index `N+i`. // - // The instance index space is more complicated because of potential - // instance imports and aliasing imported instance's exported nested - // instances. These imported/aliased instances can then be used as - // arguments to a nested instantiation, and then the resulting instance - // can also be used as an argument to further nested instantiations. To - // handle all this, we use a `Renumbering` map for tracking instance - // indices. + // We define all the code module aliases up front. Nested instantiations + // may require aliasing instance exports from earlier instantiations, so + // we interleave those in the same order that they appeared in the + // original Wasm binary below. + let mut alias_section = wasm_encoder::AliasSection::new(); + for (module, _) in info.instantiations(cx).values() { + let module = module.get_aliased(cx).unwrap_or(*module); + + // Because we flatten the code modules into the umbrella module with + // a pre-order traversal, this instantiation's code module is the + // `module.pre_order_index()`th module in the root module's module + // index space. + let code_module_index_in_root = module.pre_order_index(); + alias_section.outer_module(depth, code_module_index_in_root); + } + state_module.section(&alias_section); + + // The instance index space is more complicated than the module index + // space because of potential instance imports and aliasing imported + // instance's exported nested instances. These imported/aliased + // instances can then be used as arguments to a nested instantiation, + // and then the resulting instance can also be used as an argument to + // further nested instantiations. To handle all this, we use a + // `Renumbering` map for tracking instance indices. let mut instance_renumbering = Renumbering::default(); - let types = make_complete_type_section(cx, info); - state_module.section(&types); + let aliased_types = make_aliased_type_section(cx, info, depth); + state_module.section(&aliased_types); let mut instance_import_counts = info.instance_import_counts(cx).iter().copied(); let mut aliases = info.aliases(cx).iter(); @@ -1007,7 +894,7 @@ fn rewrite_one_state_module( for section in info.initial_sections(cx) { match section { - // Handled by `make_complete_type_section` above. + // Handled above. s if s.id == SectionId::Type.into() => continue, // Copy the imports over and update our renumbering for any @@ -1070,25 +957,14 @@ fn rewrite_one_state_module( let count = wasmparser::InstanceSectionReader::new(s.data, 0) .unwrap() .get_count(); - let mut alias_section = wasm_encoder::AliasSection::new(); let mut instance_section = wasm_encoder::InstanceSection::new(); let mut module_section = wasm_encoder::ModuleSection::new(); for (i, (module, instance_args)) in instantiations .by_ref() .take(usize::try_from(count).unwrap()) { - // Alias this instantiation's code module. - // - // Because we flatten the code modules into the root - // with a pre-order traversal, and the root module is - // not in the flattened list, this instantiation's code - // module is the `module.pre_order_index() - 1`th module - // in the root module's module index space. - let code_module_index_in_root = module.pre_order_index() - 1; - alias_section.outer_module(depth, code_module_index_in_root); - // Define the state module for this instantiation. - let state_module = rewrite_one_state_module( + let state_module = rewrite_state_module( cx, *module, &snapshot.instantiations[i], @@ -1141,7 +1017,6 @@ fn rewrite_one_state_module( ), ); } - state_module.section(&alias_section); state_module.section(&module_section); state_module.section(&instance_section); } diff --git a/crates/wizer/tests/tests.rs b/crates/wizer/tests/tests.rs index 2460d9032cfa..d748b94dc331 100644 --- a/crates/wizer/tests/tests.rs +++ b/crates/wizer/tests/tests.rs @@ -16,6 +16,12 @@ fn run_wasm(args: &[wasmtime::Val], expected: i32, wasm: &[u8]) -> anyhow::Resul wizer.wasm_multi_memory(true); wizer.wasm_module_linking(true); let wasm = wizer.run(&wasm)?; + log::debug!( + "=== Wizened Wasm ==========================================================\n\ + {}\n\ + ===========================================================================", + wasmprinter::print_bytes(&wasm).unwrap() + ); let mut config = wasmtime::Config::new(); config.cache_config_load_default().unwrap(); @@ -28,7 +34,14 @@ fn run_wasm(args: &[wasmtime::Val], expected: i32, wasm: &[u8]) -> anyhow::Resul let module = wasmtime::Module::new(store.engine(), wasm).context("Wasm test case failed to compile")?; + let dummy_module = wasmtime::Module::new(store.engine(), &wat::parse_str("(module)")?)?; + let dummy_instance = wasmtime::Instance::new(&store, &dummy_module, &[])?; + let mut linker = wasmtime::Linker::new(&store); + linker + .define_name("dummy_func", wasmtime::Func::wrap(&store, || {}))? + .define("env", "f", wasmtime::Func::wrap(&store, || {}))? + .define_name("dummy_instance", dummy_instance)?; let ctx = wasi_cap_std_sync::WasiCtxBuilder::new().build()?; let wasi = wasmtime_wasi::Wasi::new(&store, ctx); wasi.add_to_linker(&mut linker)?; @@ -504,6 +517,31 @@ fn start_sections_in_nested_modules() -> anyhow::Result<()> { ) } +#[test] +fn allow_function_imports_module_linking() -> anyhow::Result<()> { + // Make sure that the umbrella module passes imports through to its + // instantiation of the root, and that the root can pass them along to its + // nested instantiations as well. + run_wat( + &[], + 42, + r#" +(module + (import "dummy_func" (func $dummy)) + (module $A + (import "dummy_func" (func))) + (instance (instantiate $A (import "dummy_func" (func $dummy)))) + (func (export "wizer.initialize") + nop + ) + (func (export "run") (result i32) + i32.const 42 + ) +) +"#, + ) +} + #[test] fn outer_module_alias() -> anyhow::Result<()> { run_wat( @@ -539,6 +577,132 @@ fn outer_module_alias() -> anyhow::Result<()> { ) } +#[test] +fn instance_alias_without_entry_in_type_section() -> anyhow::Result<()> { + run_wat( + &[], + 42, + r#" +(module + (module $CHILD + (module $a) + (instance $a (instantiate $a)) + (export "a" (instance $a))) + (instance $child (instantiate $CHILD)) + + ;; This root module doesn't ever declare an instance type for this alias. + (alias $child "a" (instance $no_type_for_this_instance)) + + (func (export "wizer.initialize") + nop + ) + (func (export "run") (result i32) + i32.const 42 + ) +) +"#, + ) +} + +#[test] +fn two_level_imports_and_implicit_instance_imports() -> anyhow::Result<()> { + run_wat( + &[], + 42, + r#" +(module + ;; First, import an instance to make sure that we are accounting for already + ;; imported instances when forwarding implicit instances and are getting the + ;; index space correct. + (import "dummy_instance" (instance)) + + ;; This implicitly creates an instance import like: + ;; + ;; (import (env (instance (export "f" (func $f))))) + ;; + ;; We will have to forward this implicit instance from the umbrella to the + ;; root instantiation. + (import "env" "f" (func $f)) + + (module $A + (import "env" "f" (func))) + + ;; Pass that implicit instance through when instantiating `$A`. + (instance $a (instantiate $A (import "env" (instance 1)))) + + (func (export "wizer.initialize") + nop + ) + (func (export "run") (result i32) + i32.const 42 + ) +) +"#, + ) +} + +#[test] +fn implicit_instance_imports_and_other_instances() -> anyhow::Result<()> { + // Test how implicit instance import injection interacts with explicit + // instance imports and explicit instantiations. + run_wat( + &[], + 42, + r#" +(module + (module $A + ;; This implicitly creates an instance import like: + ;; + ;; (import (env (instance (export "f" (func $f (result i32)))))) + (import "env" "f" (func $f (result i32))) + + (import "env2" (instance $env2 (export "g" (func (result i32))))) + + (module $B + (func (export "h") (result i32) + i32.const 1 + ) + ) + (instance $b (instantiate $B)) + + (func (export "run") (result i32) + call $f + call (func $env2 "g") + call (func $b "h") + i32.add + i32.add + ) + ) + + (module $Env + (func (export "f") (result i32) + i32.const 2 + ) + ) + (instance $env (instantiate $Env)) + + (module $Env2 + (func (export "g") (result i32) + i32.const 39 + ) + ) + (instance $env2 (instantiate $Env2)) + + (instance $a (instantiate $A + (import "env" (instance $env)) + (import "env2" (instance $env2)))) + + (func (export "wizer.initialize") + nop + ) + (func (export "run") (result i32) + call (func $a "run") + ) +) +"#, + ) +} + #[test] fn rust_regex() -> anyhow::Result<()> { run_wasm( @@ -587,3 +751,51 @@ fn rename_functions() -> anyhow::Result<()> { assert_eq!(wat.trim(), expected_wat.trim()); Ok(()) } + +#[test] +fn renames_and_module_linking() -> anyhow::Result<()> { + let wat = r#" +(module + (module $A + (func (export "a") (result i32) + i32.const 1) + (func (export "b") (result i32) + i32.const 2) + (func (export "c") (result i32) + i32.const 3) + ) + (instance $a (instantiate $A)) + (func (export "wizer.initialize") + nop + ) + (func (export "a") (result i32) + call (func $a "a") + ) + (func (export "b") (result i32) + call (func $a "b") + ) + (func (export "c") (result i32) + call (func $a "c") + ) +) + "#; + + let wasm = wat_to_wasm(wat)?; + let mut wizer = Wizer::new(); + wizer.wasm_module_linking(true); + wizer.allow_wasi(true); + wizer.func_rename("a", "b"); + wizer.func_rename("b", "c"); + let wasm = wizer.run(&wasm)?; + let wat = wasmprinter::print_bytes(&wasm)?; + + let expected_wat = r#" + (alias 1 "b" (func (;0;))) + (alias 1 "c" (func (;1;))) + (export "a" (func 0)) + (export "b" (func 1))) + "#; + + assert!(wat.trim().ends_with(expected_wat.trim())); + Ok(()) +} From 51b5d5befc20728bda789205641c811d69db6ed1 Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Wed, 19 May 2021 11:43:35 -0700 Subject: [PATCH 055/212] Rename `ModuleContext::resolve` to `ModuleContext::defined` This is more consistent with the `defined_mut` method. --- crates/wizer/src/info.rs | 42 ++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/crates/wizer/src/info.rs b/crates/wizer/src/info.rs index c839258b9f16..dce747960023 100644 --- a/crates/wizer/src/info.rs +++ b/crates/wizer/src/info.rs @@ -46,7 +46,7 @@ impl<'a> ModuleContext<'a> { /// Get a shared reference to the `DefinedModuleInfo` for this module, /// following through aliases. - fn resolve(&self, module: Module) -> &DefinedModuleInfo<'a> { + fn defined(&self, module: Module) -> &DefinedModuleInfo<'a> { let mut id = module.id; loop { match &self.arena[id] { @@ -403,7 +403,7 @@ impl Module { /// Returns the index of the type and updates the total count of types in /// `num_types`. pub fn define_instance_type(self, cx: &mut ModuleContext<'_>) -> TypeId { - // Inline `cx.resolve(self)` to avoid borrowck errors. + // Inline `cx.defined(self)` to avoid borrowck errors. let info = { let mut id = self.id; loop { @@ -495,12 +495,12 @@ impl Module { /// Get the count of how many instance imports are in each import section in /// this module. pub fn instance_import_counts<'b>(self, cx: &'b ModuleContext<'_>) -> &'b [u32] { - &cx.resolve(self).instance_import_counts + &cx.defined(self).instance_import_counts } /// Get the aliases defined in this module. pub fn aliases<'a, 'b>(self, cx: &'b ModuleContext<'a>) -> &'b [wasmparser::Alias<'a>] { - &cx.resolve(self).aliases + &cx.defined(self).aliases } /// Get an export from the `n`th instance by name. @@ -511,7 +511,7 @@ impl Module { name: &str, ) -> Option<&'b EntityType> { let instance = usize::try_from(instance).unwrap(); - let info = cx.resolve(self); + let info = cx.defined(self); let type_id = info.instances[instance]; let instance = match cx.types.get(type_id) { Type::Instance(i) => i, @@ -528,7 +528,7 @@ impl Module { let mut stack = vec![self]; while let Some(module) = stack.pop() { f(cx, module); - let info = cx.resolve(module); + let info = cx.defined(module); stack.extend(info.modules.iter().copied().rev()); } } @@ -536,12 +536,12 @@ impl Module { /// Get the first index in the memory space where a memory is defined rather /// than aliased or imported. pub fn defined_memories_index(self, cx: &ModuleContext) -> Option { - cx.resolve(self).defined_memories_index + cx.defined(self).defined_memories_index } /// The number of defined memories in this module. pub fn defined_memories_len(self, cx: &ModuleContext) -> usize { - let info = cx.resolve(self); + let info = cx.defined(self); info.defined_memories_index.map_or(0, |n| { let n = usize::try_from(n).unwrap(); assert!(info.memories.len() > n); @@ -554,7 +554,7 @@ impl Module { self, cx: &'b ModuleContext<'_>, ) -> impl Iterator + 'b { - let info = cx.resolve(self); + let info = cx.defined(self); info.memories .iter() .copied() @@ -569,12 +569,12 @@ impl Module { /// Get the first index in the global space where a global is defined rather /// than aliased or imported. pub fn defined_globals_index(self, cx: &ModuleContext) -> Option { - cx.resolve(self).defined_globals_index + cx.defined(self).defined_globals_index } /// The number of defined globals in this module. pub fn defined_globals_len(self, cx: &ModuleContext<'_>) -> usize { - let info = cx.resolve(self); + let info = cx.defined(self); info.defined_globals_index.map_or(0, |n| { let n = usize::try_from(n).unwrap(); assert!(info.globals.len() > n); @@ -587,7 +587,7 @@ impl Module { self, cx: &'b ModuleContext<'_>, ) -> impl Iterator + 'b { - let info = cx.resolve(self); + let info = cx.defined(self); info.globals .iter() .copied() @@ -604,7 +604,7 @@ impl Module { self, cx: &'b ModuleContext<'a>, ) -> impl Iterator> + 'b { - let info = cx.resolve(self); + let info = cx.defined(self); info.raw_sections .iter() .filter(|s| s.id != SectionId::Custom.into()) @@ -623,22 +623,22 @@ impl Module { self, cx: &'b ModuleContext<'a>, ) -> &'b [wasm_encoder::RawSection<'a>] { - &cx.resolve(self).raw_sections + &cx.defined(self).raw_sections } /// Get a slice of this module's nested child modules. pub fn child_modules<'b>(self, cx: &'b ModuleContext<'_>) -> &'b [Module] { - &cx.resolve(self).modules + &cx.defined(self).modules } /// Get a slice of this module's exports. pub fn exports<'a, 'b>(self, cx: &'b ModuleContext<'a>) -> &'b [wasmparser::Export<'a>] { - &cx.resolve(self).exports + &cx.defined(self).exports } /// Get a slice of this module's imports. pub fn imports<'a, 'b>(self, cx: &'b ModuleContext<'a>) -> &'b [wasmparser::Import<'a>] { - &cx.resolve(self).imports + &cx.defined(self).imports } /// Get this module's defined (as opposed to imported or aliased) @@ -650,17 +650,17 @@ impl Module { self, cx: &'b ModuleContext<'a>, ) -> &'b BTreeMap>)> { - &cx.resolve(self).instantiations + &cx.defined(self).instantiations } /// Get this module's `n`th nested child module. pub fn child_module_at(self, cx: &ModuleContext<'_>, n: u32) -> Module { - cx.resolve(self).modules[usize::try_from(n).unwrap()] + cx.defined(self).modules[usize::try_from(n).unwrap()] } /// Get the full types index space for this module. pub fn types<'a, 'b>(self, cx: &'b ModuleContext<'a>) -> &'b [TypeId] { - &cx.resolve(self).types + &cx.defined(self).types } /// Get the type at the given index. @@ -675,7 +675,7 @@ impl Module { /// /// Panics if the types index space does not contain the given index. pub fn type_id_at(self, cx: &ModuleContext<'_>, type_index: u32) -> TypeId { - cx.resolve(self).types[usize::try_from(type_index).unwrap()] + cx.defined(self).types[usize::try_from(type_index).unwrap()] } /// Get the id for instance type at the given type index. From 50bd7f45b2c46ccc76ec6b6faa3117aadae92dc2 Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Wed, 19 May 2021 11:44:52 -0700 Subject: [PATCH 056/212] Use the `ModuleContext::defined` helper inside `ModuleContext::entity_type` It was using an open-coded equivalent before due to some refactoring accidents. --- crates/wizer/src/info.rs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/crates/wizer/src/info.rs b/crates/wizer/src/info.rs index dce747960023..59be1b77def8 100644 --- a/crates/wizer/src/info.rs +++ b/crates/wizer/src/info.rs @@ -223,12 +223,7 @@ impl Module { cx: &ModuleContext<'_>, ty: wasmparser::ImportSectionEntryType, ) -> EntityType { - let module = self.get_aliased(cx).unwrap_or(self); - let types_space = match &cx.arena[module.id] { - ModuleInfo::Aliased(_) => unreachable!(), - ModuleInfo::Defined(d) => &d.types, - }; - cx.types().entity_type(ty, types_space) + cx.types().entity_type(ty, &cx.defined(self).types) } /// Add a new raw section to this module info during parsing. From 5974bb1f04cec63da4314f32d8a4e601cf1f1597 Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Wed, 19 May 2021 11:46:50 -0700 Subject: [PATCH 057/212] Add more descriptive diagnostics for an `unreachable!()` --- crates/wizer/src/info.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/crates/wizer/src/info.rs b/crates/wizer/src/info.rs index 59be1b77def8..92e9540092cd 100644 --- a/crates/wizer/src/info.rs +++ b/crates/wizer/src/info.rs @@ -355,9 +355,11 @@ impl Module { wasmparser::ImportSectionEntryType::Table(ty) => { self.push_table(cx, ty); } - wasmparser::ImportSectionEntryType::Module(_) - | wasmparser::ImportSectionEntryType::Event(_) => { - unreachable!() + wasmparser::ImportSectionEntryType::Module(_) => { + unreachable!("we disallow module imports; checked in validation") + } + wasmparser::ImportSectionEntryType::Event(_) => { + unreachable!("exceptions are unsupported; checked in validation") } } } From e442ab489cc87f21ed5157b26d95eb6494bdd7d3 Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Wed, 19 May 2021 13:41:26 -0700 Subject: [PATCH 058/212] Do not create "native" sized/aligned data segments Instead, create minimally sized pages (modulo when it is more size efficient to merge to nearby segments together due to the size overhead of defining an active data segment). The thinking previously was that Wasm engines could recognize when segments were page sized and aligned and then do virtual memory tricks to lazily initialize Wasm memories, do copy on write, etc... But they can do this kind of thing by preprocessing data segments themselves in the module compilation phase (and both Wasmtime and Lucet do some of this today) and no engine (to my knowledge) will recognize when the segments are already processed in this manner but won't preprocess them itself. --- crates/wizer/src/snapshot.rs | 90 +++++++++++++++++++++--------------- 1 file changed, 52 insertions(+), 38 deletions(-) diff --git a/crates/wizer/src/snapshot.rs b/crates/wizer/src/snapshot.rs index 1e91a871a506..a2eab69114c5 100644 --- a/crates/wizer/src/snapshot.rs +++ b/crates/wizer/src/snapshot.rs @@ -2,7 +2,6 @@ use rayon::iter::{IntoParallelIterator, ParallelExtend, ParallelIterator}; use std::convert::TryFrom; const WASM_PAGE_SIZE: u32 = 65_536; -const NATIVE_PAGE_SIZE: u32 = 4_096; /// A "snapshot" of Wasm state from its default value after having been initialized. pub struct Snapshot<'a> { @@ -20,6 +19,7 @@ pub struct Snapshot<'a> { } /// A data segment initializer for a memory. +#[derive(Clone, Copy)] pub struct DataSegment<'a> { /// The index of this data segment's memory. pub memory_index: u32, @@ -86,7 +86,6 @@ fn snapshot_memories<'a>(instance: &wasmtime::Instance) -> (Vec, Vec(instance: &wasmtime::Instance) -> (Vec, Vec break, + Some(i) => i, + }; + start += nonzero; + let zero = memory[start..page_end] + .iter() + .position(|byte| *byte == 0) + .unwrap_or(page_end); + let end = start + zero; + segments.push(DataSegment { + memory_index, + offset: start as u32, + data: &memory[start..end], + }); + start = end; } - None + segments })); memory_index += 1; } + if data_segments.is_empty() { + return (memory_mins, data_segments); + } + // Sort data segments to enforce determinism in the face of the // parallelism above. data_segments.sort_by_key(|s| (s.memory_index, s.offset)); - // Merge any contiguous pages, so that the engine can initialize them - // all at once (ideally with a single copy-on-write `mmap`) rather than - // initializing each data segment individually. - for i in (1..data_segments.len()).rev() { - let a = &data_segments[i - 1]; - let b = &data_segments[i]; + // Merge any contiguous segments (caused by spanning a Wasm page boundary, + // and therefore created in separate logical threads above) or pages that + // are within four bytes of each other. Four because this is the minimum + // overhead of defining a new active data segment: one for the memory index + // LEB, two for the memory offset init expression (one for the `i32.const` + // opcode and another for the constant immediate LEB), and finally one for + // the data length LEB). + const MIN_ACTIVE_SEGMENT_OVERHEAD: u32 = 4; + let mut merged_data_segments = Vec::with_capacity(data_segments.len()); + merged_data_segments.push(data_segments[0]); + for b in &data_segments[1..] { + let a = merged_data_segments.last_mut().unwrap(); // Only merge segments for the same memory. if a.memory_index != b.memory_index { + merged_data_segments.push(*b); continue; } - // Only merge segments if they are contiguous. - if a.offset + u32::try_from(a.data.len()).unwrap() != b.offset { + // Only merge segments if they are contiguous or if it is definitely + // more size efficient than leaving them apart. + let distance = b.offset - (a.offset + u32::try_from(a.data.len()).unwrap()); + if distance > MIN_ACTIVE_SEGMENT_OVERHEAD { + merged_data_segments.push(*b); continue; } // Okay, merge them together into `a` (so that the next iteration // can merge it with its predecessor) and then remove `b`! - data_segments[i - 1].data = unsafe { + a.data = unsafe { + let distance = usize::try_from(distance).unwrap(); debug_assert_eq!( a.data .as_ptr() - .offset(isize::try_from(a.data.len()).unwrap()), + .offset(isize::try_from(a.data.len() + distance).unwrap()), b.data.as_ptr() ); - std::slice::from_raw_parts(a.data.as_ptr(), a.data.len() + b.data.len()) + std::slice::from_raw_parts(a.data.as_ptr(), a.data.len() + distance + b.data.len()) }; - data_segments.remove(i); } - (memory_mins, data_segments) + (memory_mins, merged_data_segments) } fn snapshot_instantiations<'a>( From 9493fded8d7b50875ba7f601bc58d3f59c4ee2e0 Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Wed, 19 May 2021 13:49:17 -0700 Subject: [PATCH 059/212] Run `cargo update` --- crates/wizer/Cargo.lock | 294 ++++++++++++++++++++-------------------- 1 file changed, 147 insertions(+), 147 deletions(-) diff --git a/crates/wizer/Cargo.lock b/crates/wizer/Cargo.lock index 0ae283f91da8..9ecfa1bed48b 100644 --- a/crates/wizer/Cargo.lock +++ b/crates/wizer/Cargo.lock @@ -8,7 +8,16 @@ version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a55f82cfe485775d02112886f4169bde0c5894d75e79ead7eafe7e40a25e45f7" dependencies = [ - "gimli", + "gimli 0.23.0", +] + +[[package]] +name = "addr2line" +version = "0.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03345e98af8f3d786b6d9f656ccfa6ac316d954e92bc4841f0bba20789d5fb5a" +dependencies = [ + "gimli 0.24.0", ] [[package]] @@ -19,9 +28,9 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "aho-corasick" -version = "0.7.15" +version = "0.7.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7404febffaa47dac81aa44dba71523c9d069b1bdc50a77db41195149e17f68e5" +checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f" dependencies = [ "memchr", ] @@ -37,9 +46,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.38" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afddf7f520a80dbf76e6f50a35bca42a2331ef227a28b3b6dc5c2e2338d114b1" +checksum = "28b2cd92db5cbd74e8e5028f7e27dd7aa3090e89e4f2a197cc7c8dfb69c7063b" [[package]] name = "arbitrary" @@ -52,9 +61,9 @@ dependencies = [ [[package]] name = "async-trait" -version = "0.1.48" +version = "0.1.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36ea56748e10732c49404c153638a15ec3d6211ec5ff35d9bb20e13b93576adf" +checksum = "0b98e84bbb4cbcdd97da190ba0c58a1bb0de2c1fdf67d159e192ed766aeca722" dependencies = [ "proc-macro2", "quote", @@ -80,15 +89,16 @@ checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" [[package]] name = "backtrace" -version = "0.3.56" +version = "0.3.59" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d117600f438b1707d4e4ae15d3595657288f8235a0eb593e80ecc98ab34e1bc" +checksum = "4717cfcbfaa661a0fd48f8453951837ae7e8f81e481fbb136e3202d72805a744" dependencies = [ - "addr2line", + "addr2line 0.15.1", + "cc", "cfg-if", "libc", "miniz_oxide", - "object", + "object 0.24.0", "rustc-demangle", ] @@ -100,11 +110,10 @@ checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" [[package]] name = "bincode" -version = "1.3.2" +version = "1.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d175dfa69e619905c4c3cdb7c3c203fa3bdd5d51184e3afdb2742c0280493772" +checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" dependencies = [ - "byteorder", "serde", ] @@ -125,9 +134,9 @@ dependencies = [ [[package]] name = "bstr" -version = "0.2.15" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a40b47ad93e1a5404e6c18dec46b628214fee441c70f4ab5d6942142cc268a3d" +checksum = "90682c8d613ad3373e66de8c6411e0ae2ab2571e879d2efbf73558cc66f21279" dependencies = [ "lazy_static", "memchr", @@ -143,28 +152,28 @@ checksum = "63396b8a4b9de3f4fdfb320ab6080762242f66a8ef174c49d8e19b674db4cdbe" [[package]] name = "byteorder" -version = "1.3.4" +version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" +checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" [[package]] name = "cap-fs-ext" -version = "0.13.7" +version = "0.13.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dee87a3a916d6f051fc6809c39c4627f0c3a73b2a803bcfbb5fdf2bdfa1da0cb" +checksum = "ff3a1e32332db9ad29d6da34693ce9a7ac26a9edf96abb5c1788d193410031ab" dependencies = [ "cap-primitives", "cap-std", - "rustc_version 0.3.3", + "rustc_version", "unsafe-io", "winapi", ] [[package]] name = "cap-primitives" -version = "0.13.7" +version = "0.13.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c3e3ea29994a34f3bc67b5396a43c87597d302d9e2e5e3b3d5ba952d86c7b41" +checksum = "2d253b74de50b097594462618e7dd17b93b3e3bef19f32d2e512996f9095661f" dependencies = [ "errno", "fs-set-times", @@ -173,7 +182,7 @@ dependencies = [ "maybe-owned", "once_cell", "posish", - "rustc_version 0.3.3", + "rustc_version", "unsafe-io", "winapi", "winapi-util", @@ -182,30 +191,30 @@ dependencies = [ [[package]] name = "cap-rand" -version = "0.13.7" +version = "0.13.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0418058b38db7efc6021c5ce012e3a39c57e1a4d7bf2ddcd3789771de505d2f" +checksum = "458e98ed00e4276d0ac60da888d80957a177dfa7efa8dbb3be59f1e2b0e02ae5" dependencies = [ "rand", ] [[package]] name = "cap-std" -version = "0.13.7" +version = "0.13.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5f20cbb3055e9c72b16ba45913fe9f92836d2aa7a880e1ffacb8d244f454319" +checksum = "7019d48ea53c5f378e0fdab0fe5f627fc00e76d65e75dffd6fb1cbc0c9b382ee" dependencies = [ "cap-primitives", "posish", - "rustc_version 0.3.3", + "rustc_version", "unsafe-io", ] [[package]] name = "cap-time-ext" -version = "0.13.7" +version = "0.13.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b684f9db089b0558520076b4eeda2b719a5c4c06f329be96c9497f2b48c3944" +checksum = "90585adeada7f804e6dcf71b8ff74217ad8742188fc870b9da5deab4722baa04" dependencies = [ "cap-primitives", "once_cell", @@ -215,11 +224,11 @@ dependencies = [ [[package]] name = "cast" -version = "0.2.3" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b9434b9a5aa1450faa3f9cb14ea0e8c53bb5d2b3c1bfd1ab4fc03e9f33fbfb0" +checksum = "57cdfa5d50aad6cb4d44dcab6101a7f79925bd59d82ca42f38a9856a28865374" dependencies = [ - "rustc_version 0.2.3", + "rustc_version", ] [[package]] @@ -263,10 +272,13 @@ dependencies = [ ] [[package]] -name = "cpuid-bool" -version = "0.1.2" +name = "cpufeatures" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8aebca1129a03dc6dc2b127edd729435bbc4a37e1d5f4d7513165089ceb02634" +checksum = "ed00c67cb5d0a7d64a44f6ad2668db7e7530311dd53ea79bcd4fb022c64911c8" +dependencies = [ + "libc", +] [[package]] name = "cranelift-bforest" @@ -288,7 +300,7 @@ dependencies = [ "cranelift-codegen-meta", "cranelift-codegen-shared", "cranelift-entity", - "gimli", + "gimli 0.23.0", "log", "regalloc", "serde", @@ -411,9 +423,9 @@ dependencies = [ [[package]] name = "crossbeam-channel" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dca26ee1f8d361640700bde38b2c37d8c22b3ce2d360e1fc1c74ea4b0aa7d775" +checksum = "06ed27e177f16d65f0f0c22a213e17c696ace5dd64b14258b52f9417ccb52db4" dependencies = [ "cfg-if", "crossbeam-utils", @@ -432,9 +444,9 @@ dependencies = [ [[package]] name = "crossbeam-epoch" -version = "0.9.3" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2584f639eb95fea8c798496315b297cf81b9b58b6d30ab066a75455333cf4b12" +checksum = "52fb27eab85b17fbb9f6fd667089e07d6a2eb8743d02639ee7f6a7a7729c9c94" dependencies = [ "cfg-if", "crossbeam-utils", @@ -445,9 +457,9 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.3" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7e9d99fa91428effe99c5c6d4634cdeba32b8cf784fc428a2a687f61a952c49" +checksum = "4feb231f0d4d6af81aed15928e58ecf5816aa62a2393e2c82f46973e92a9a278" dependencies = [ "autocfg", "cfg-if", @@ -529,9 +541,9 @@ dependencies = [ [[package]] name = "dtoa" -version = "0.4.7" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88d7ed2934d741c6b37e33e3832298e8850b53fd2d2bea03873375596c7cea4e" +checksum = "56899898ce76aaf4a0f24d914c97ea6ed976d42fec6ad33fcbb0a1103e07b2b0" [[package]] name = "either" @@ -651,6 +663,12 @@ dependencies = [ "stable_deref_trait", ] +[[package]] +name = "gimli" +version = "0.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e4075386626662786ddb0ec9081e7c7eeb1ba31951f447ca780ef9f5d568189" + [[package]] name = "glob" version = "0.3.0" @@ -745,18 +763,18 @@ checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736" [[package]] name = "jobserver" -version = "0.1.21" +version = "0.1.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c71313ebb9439f74b00d9d2dcec36440beaf57a6aa0623068441dd7cd81a7f2" +checksum = "972f5ae5d1cb9c6ae417789196c803205313edde988685da5e3aae0827b9e7fd" dependencies = [ "libc", ] [[package]] name = "js-sys" -version = "0.3.49" +version = "0.3.51" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc15e39392125075f60c95ba416f5381ff6c3a948ff02ab12464715adf56c821" +checksum = "83bdfbace3a0e81a4253f73b49e960b053e396a11012cbd49b9b74d6a2b67062" dependencies = [ "wasm-bindgen", ] @@ -775,15 +793,15 @@ checksum = "3576a87f2ba00f6f106fdfcd16db1d698d648a26ad8e0573cad8537c3c362d2a" [[package]] name = "libc" -version = "0.2.90" +version = "0.2.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba4aede83fc3617411dc6993bc8c70919750c1c257c6ca6a502aed6e0e2394ae" +checksum = "18794a8ad5b29321f790b55d93dfba91e125cb1a9edbd4f8e3150acc771c1a5e" [[package]] name = "libfuzzer-sys" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86c975d637bc2a2f99440932b731491fc34c7f785d239e38af3addd3c2fd0e46" +checksum = "8a9dc6556604b8ad76486563d5a47fad989b643932fa006e76e23d948bef0f5b" dependencies = [ "arbitrary", "cc", @@ -821,15 +839,15 @@ checksum = "4facc753ae494aeb6e3c22f839b158aebd4f9270f55cd3c79906c45476c47ab4" [[package]] name = "memchr" -version = "2.3.4" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525" +checksum = "b16bd47d9e329435e309c58469fe0791c2d0d1ba96ec0954152a5ae2b04387dc" [[package]] name = "memoffset" -version = "0.6.1" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "157b4208e3059a8f9e78d559edc658e13df41410cb3ae03979c83130067fdd87" +checksum = "f83fb6581e8ed1f85fd45c116db8405483899489e38406156c25eb743554361d" dependencies = [ "autocfg", ] @@ -879,6 +897,12 @@ dependencies = [ "indexmap", ] +[[package]] +name = "object" +version = "0.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a5b3dd1c072ee7963717671d1ca129f1048fda25edea6b752bfc71ac8854170" + [[package]] name = "once_cell" version = "1.7.2" @@ -992,9 +1016,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.24" +version = "1.0.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71" +checksum = "a152013215dca273577e18d2bf00fa862b89b24169fb78c4c95aeb07992c9cec" dependencies = [ "unicode-xid", ] @@ -1065,9 +1089,9 @@ dependencies = [ [[package]] name = "rayon" -version = "1.5.0" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b0d8e0819fadc20c74ea8373106ead0600e3a67ef1fe8da56e39b9ae7275674" +checksum = "c06aca804d41dbc8ba42dfd964f0d01334eceb64314b9ecf7c5fad5188a06d90" dependencies = [ "autocfg", "crossbeam-deque", @@ -1077,9 +1101,9 @@ dependencies = [ [[package]] name = "rayon-core" -version = "1.9.0" +version = "1.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ab346ac5921dc62ffa9f89b7a773907511cdfa5490c572ae9be1be33e8afa4a" +checksum = "d78120e2c850279833f1dd3582f730c4ab53ed95aeaaaa862a2a5c71b1656d8e" dependencies = [ "crossbeam-channel", "crossbeam-deque", @@ -1090,9 +1114,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.2.5" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94341e4e44e24f6b591b59e47a8a027df12e008d73fd5672dbea9cc22f4507d9" +checksum = "742739e41cd49414de871ea5e549afb7e2a3ac77b589bcbebe8c82fab37147fc" dependencies = [ "bitflags", ] @@ -1121,9 +1145,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.4.5" +version = "1.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "957056ecddbeba1b26965114e191d2e8589ce74db242b6ea25fc4062427a5c19" +checksum = "d07a8629359eb56f1e2fb1652bb04212c072a87ba68546a04065d525673ac461" dependencies = [ "aho-corasick", "memchr", @@ -1148,9 +1172,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.6.23" +version = "0.6.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24d5f089152e60f62d28b835fbff2cd2e8dc0baf1ac13343bef92ab7eed84548" +checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b" [[package]] name = "regex-test" @@ -1173,9 +1197,9 @@ dependencies = [ [[package]] name = "rustc-demangle" -version = "0.1.18" +version = "0.1.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e3bad0ee36814ca07d7968269dd4b7ec89ec2da10c4bb613928d3077083c232" +checksum = "410f7acf3cb3a44527c5d9546bad4bf4e6c460915d5f9f2fc524498bfe8f70ce" [[package]] name = "rustc-hash" @@ -1183,22 +1207,13 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" -[[package]] -name = "rustc_version" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" -dependencies = [ - "semver 0.9.0", -] - [[package]] name = "rustc_version" version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f0dfe2087c51c460008730de8b57e6a320782fbfb312e1f4d520e6c6fae155ee" dependencies = [ - "semver 0.11.0", + "semver", ] [[package]] @@ -1242,30 +1257,15 @@ dependencies = [ "syn", ] -[[package]] -name = "semver" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" -dependencies = [ - "semver-parser 0.7.0", -] - [[package]] name = "semver" version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6" dependencies = [ - "semver-parser 0.10.2", + "semver-parser", ] -[[package]] -name = "semver-parser" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" - [[package]] name = "semver-parser" version = "0.10.2" @@ -1277,9 +1277,9 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.124" +version = "1.0.126" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd761ff957cb2a45fbb9ab3da6512de9de55872866160b23c25f1a841e99d29f" +checksum = "ec7505abeacaec74ae4778d9d9328fe5a5d04253220a85c4ee022239fc996d03" dependencies = [ "serde_derive", ] @@ -1296,9 +1296,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.124" +version = "1.0.126" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1800f7693e94e186f5e25a28291ae1570da908aff7d97a095dec1e56ff99069b" +checksum = "963a7dbc9895aeac7ac90e74f34a5d5261828f79df35cbed41e10189d3804d43" dependencies = [ "proc-macro2", "quote", @@ -1330,13 +1330,13 @@ dependencies = [ [[package]] name = "sha2" -version = "0.9.3" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa827a14b29ab7f44778d14a88d3cb76e949c45083f7dbfa507d0cb699dc12de" +checksum = "b362ae5752fd2137731f9fa25fd4d9058af34666ca1966fb969119cc35719f12" dependencies = [ "block-buffer", "cfg-if", - "cpuid-bool", + "cpufeatures", "digest", "opaque-debug", ] @@ -1394,9 +1394,9 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.64" +version = "1.0.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fd9d1e9976102a03c542daa2eff1b43f9d72306342f3f8b3ed5fb8908195d6f" +checksum = "a1e8cdbefb79a9a5a65e0db8b47b723ee907b7c7f8496c76a1770b5c310bab82" dependencies = [ "proc-macro2", "quote", @@ -1405,16 +1405,16 @@ dependencies = [ [[package]] name = "system-interface" -version = "0.6.3" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fd411f50bd848d1efefd5957d494eddc80979380e3c4f80b4ba2ebd26d1b673" +checksum = "ff09d1260270c02199b44e68140aab5225c27b365a38684e0d7b6155f0c37ffb" dependencies = [ "atty", "bitflags", "cap-fs-ext", "cap-std", "posish", - "rustc_version 0.3.3", + "rustc_version", "unsafe-io", "winapi", "winx", @@ -1485,9 +1485,9 @@ dependencies = [ [[package]] name = "tracing" -version = "0.1.25" +version = "0.1.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01ebdc2bb4498ab1ab5f5b73c5803825e60199229ccba0698170e3be0e7f959f" +checksum = "09adeb8c97449311ccd28a427f96fb563e7fd31aabf994189879d9da2394b89d" dependencies = [ "cfg-if", "log", @@ -1509,9 +1509,9 @@ dependencies = [ [[package]] name = "tracing-core" -version = "0.1.17" +version = "0.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f50de3927f93d202783f4513cda820ab47ef17f624b03c096e86ef00c67e6b5f" +checksum = "a9ff14f98b1a4b289c6248a023c1c2fa1491062964e9fed67ab29c4e4da4a052" dependencies = [ "lazy_static", ] @@ -1551,17 +1551,17 @@ checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3" [[package]] name = "unicode-xid" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" +checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" [[package]] name = "unsafe-io" -version = "0.6.2" +version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0301dd0f2c21baed606faa2717fbfbb1a68b7e289ea29b40bc21a16f5ae9f5aa" +checksum = "9473bb9ba1745271fb13229bfa04a70c8a698e69cf9721b8a1f5393b22735a33" dependencies = [ - "rustc_version 0.3.3", + "rustc_version", "winapi", ] @@ -1579,9 +1579,9 @@ checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe" [[package]] name = "walkdir" -version = "2.3.1" +version = "2.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "777182bc735b6424e1a57516d35ed72cb8019d85c8c9bf536dccb3445c1a2f7d" +checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56" dependencies = [ "same-file", "winapi", @@ -1635,9 +1635,9 @@ dependencies = [ [[package]] name = "wasm-bindgen" -version = "0.2.72" +version = "0.2.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fe8f61dba8e5d645a4d8132dc7a0a66861ed5e1045d2c0ed940fab33bac0fbe" +checksum = "d54ee1d4ed486f78874278e63e4069fc1ab9f6a18ca492076ffb90c5eb2997fd" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -1645,9 +1645,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.72" +version = "0.2.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "046ceba58ff062da072c7cb4ba5b22a37f00a302483f7e2a6cdc18fedbdc1fd3" +checksum = "3b33f6a0694ccfea53d94db8b2ed1c3a8a4c86dd936b13b9f0a15ec4a451b900" dependencies = [ "bumpalo", "lazy_static", @@ -1660,9 +1660,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.72" +version = "0.2.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ef9aa01d36cda046f797c57959ff5f3c615c9cc63997a8d545831ec7976819b" +checksum = "088169ca61430fe1e58b8096c24975251700e7b1f6fd91cc9d59b04fb9b18bd4" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -1670,9 +1670,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.72" +version = "0.2.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96eb45c1b2ee33545a813a92dbb53856418bf7eb54ab34f7f7ff1448a5b3735d" +checksum = "be2241542ff3d9f241f5e2cb6dd09b37efe786df8851c54957683a49f0987a97" dependencies = [ "proc-macro2", "quote", @@ -1683,9 +1683,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.72" +version = "0.2.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7148f4696fb4960a346eaa60bbfb42a1ac4ebba21f750f75fc1375b098d5ffa" +checksum = "d7cff876b8f18eed75a66cf49b65e7f967cb354a7aa16003fb55dbfd25b44b4f" [[package]] name = "wasm-encoder" @@ -1805,9 +1805,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5241e603c262b2ee0dfb5b2245ad539d0a99f0589909fbffc91d2a8035f2d20a" dependencies = [ "anyhow", - "gimli", + "gimli 0.23.0", "more-asserts", - "object", + "object 0.23.0", "target-lexicon", "thiserror", "wasmparser 0.77.0", @@ -1825,7 +1825,7 @@ dependencies = [ "cranelift-codegen", "cranelift-entity", "cranelift-wasm", - "gimli", + "gimli 0.23.0", "indexmap", "log", "more-asserts", @@ -1852,7 +1852,7 @@ version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "81b066a3290a903c5beb7d765b3e82e00cd4f8ac0475297f91330fbe8e16bb17" dependencies = [ - "addr2line", + "addr2line 0.14.1", "anyhow", "cfg-if", "cranelift-codegen", @@ -1860,10 +1860,10 @@ dependencies = [ "cranelift-frontend", "cranelift-native", "cranelift-wasm", - "gimli", + "gimli 0.23.0", "log", "more-asserts", - "object", + "object 0.23.0", "rayon", "region", "serde", @@ -1887,7 +1887,7 @@ checksum = "bd9d5c6c8924ea1fb2372d26c0546a8c5aab94001d5ddedaa36fd7b090c04de2" dependencies = [ "anyhow", "more-asserts", - "object", + "object 0.23.0", "target-lexicon", "wasmtime-debug", "wasmtime-environ", @@ -1901,10 +1901,10 @@ checksum = "44760e80dd5f53e9af6c976120f9f1d35908ee0c646a3144083f0a57b7123ba7" dependencies = [ "anyhow", "cfg-if", - "gimli", + "gimli 0.23.0", "lazy_static", "libc", - "object", + "object 0.23.0", "scroll", "serde", "target-lexicon", @@ -1987,9 +1987,9 @@ dependencies = [ [[package]] name = "wast" -version = "35.0.0" +version = "35.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db5ae96da18bb5926341516fd409b5a8ce4e4714da7f0a1063d3b20ac9f9a1e1" +checksum = "2ef140f1b49946586078353a453a1d28ba90adfc54dde75710bc1931de204d68" dependencies = [ "leb128", ] @@ -2000,14 +2000,14 @@ version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ec280a739b69173e0ffd12c1658507996836ba4e992ed9bc1e5385a0bd72a02" dependencies = [ - "wast 35.0.0", + "wast 35.0.2", ] [[package]] name = "web-sys" -version = "0.3.49" +version = "0.3.51" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59fe19d70f5dacc03f6e46777213facae5ac3801575d56ca6cbd4c93dcd12310" +checksum = "e828417b379f3df7111d3a2a9e5753706cae29c41f7c4029ee9fd77f3e09e582" dependencies = [ "js-sys", "wasm-bindgen", @@ -2097,9 +2097,9 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "winx" -version = "0.23.0" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a316462681accd062e32c37f9d78128691a4690764917d13bd8ea041baf2913e" +checksum = "2bdb79e12a5ac98f09e863b99c38c72f942a41f643ae0bb05d4d6d2633481341" dependencies = [ "bitflags", "winapi", From e49c2d28b0971d8f50805721daab56ef3b38fb01 Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Thu, 20 May 2021 13:04:20 -0700 Subject: [PATCH 060/212] Fix a bug with data segments at the end of memory --- crates/wizer/src/snapshot.rs | 5 ++--- crates/wizer/tests/tests.rs | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/crates/wizer/src/snapshot.rs b/crates/wizer/src/snapshot.rs index a2eab69114c5..ec6ce76d62bc 100644 --- a/crates/wizer/src/snapshot.rs +++ b/crates/wizer/src/snapshot.rs @@ -106,11 +106,10 @@ fn snapshot_memories<'a>(instance: &wasmtime::Instance) -> (Vec, Vec i, }; start += nonzero; - let zero = memory[start..page_end] + let end = memory[start..page_end] .iter() .position(|byte| *byte == 0) - .unwrap_or(page_end); - let end = start + zero; + .map_or(page_end, |zero| start + zero); segments.push(DataSegment { memory_index, offset: start as u32, diff --git a/crates/wizer/tests/tests.rs b/crates/wizer/tests/tests.rs index d748b94dc331..cd324c552370 100644 --- a/crates/wizer/tests/tests.rs +++ b/crates/wizer/tests/tests.rs @@ -712,6 +712,31 @@ fn rust_regex() -> anyhow::Result<()> { ) } +#[test] +fn data_segment_at_end_of_memory() -> anyhow::Result<()> { + // Test that we properly synthesize data segments for data at the end of + // memory. + run_wat( + &[], + 42, + r#" +(module + (memory 1) + (func (export "wizer.initialize") + ;; Store 42 to the last byte in memory. + i32.const 0 + i32.const 42 + i32.store8 offset=65535 + ) + (func (export "run") (result i32) + i32.const 0 + i32.load8_u offset=65535 + ) +) +"#, + ) +} + #[test] fn rename_functions() -> anyhow::Result<()> { let wat = r#" From 1e04e56e3961dbed16fd74dfdff358698ee6edf8 Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Mon, 28 Jun 2021 09:43:38 -0700 Subject: [PATCH 061/212] Update deps; wasmtime to 0.27.0 --- crates/wizer/Cargo.lock | 428 ++++++++++++++++++----------------- crates/wizer/Cargo.toml | 6 +- crates/wizer/fuzz/Cargo.toml | 2 +- crates/wizer/src/dummy.rs | 21 +- crates/wizer/src/info.rs | 3 - crates/wizer/src/lib.rs | 2 +- crates/wizer/tests/tests.rs | 2 +- 7 files changed, 233 insertions(+), 231 deletions(-) diff --git a/crates/wizer/Cargo.lock b/crates/wizer/Cargo.lock index 9ecfa1bed48b..411c7b1b4f50 100644 --- a/crates/wizer/Cargo.lock +++ b/crates/wizer/Cargo.lock @@ -4,20 +4,11 @@ version = 3 [[package]] name = "addr2line" -version = "0.14.1" +version = "0.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a55f82cfe485775d02112886f4169bde0c5894d75e79ead7eafe7e40a25e45f7" +checksum = "e7a2e47a1fbe209ee101dd6d61285226744c6c8d3c21c8dc878ba6cb9f467f3a" dependencies = [ - "gimli 0.23.0", -] - -[[package]] -name = "addr2line" -version = "0.15.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03345e98af8f3d786b6d9f656ccfa6ac316d954e92bc4841f0bba20789d5fb5a" -dependencies = [ - "gimli 0.24.0", + "gimli", ] [[package]] @@ -46,15 +37,15 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.40" +version = "1.0.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28b2cd92db5cbd74e8e5028f7e27dd7aa3090e89e4f2a197cc7c8dfb69c7063b" +checksum = "15af2628f6890fe2609a3b91bef4c83450512802e59489f9c1cb1fa5df064a61" [[package]] name = "arbitrary" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "698b65a961a9d730fb45b6b0327e20207810c9f61ee421b082b27ba003f49e2b" +checksum = "237430fd6ed3740afe94eefcc278ae21e050285be882804e0d6e8695f0c94691" dependencies = [ "derive_arbitrary", ] @@ -89,16 +80,16 @@ checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" [[package]] name = "backtrace" -version = "0.3.59" +version = "0.3.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4717cfcbfaa661a0fd48f8453951837ae7e8f81e481fbb136e3202d72805a744" +checksum = "b7815ea54e4d821e791162e078acbebfd6d8c8939cd559c9335dceb1c8ca7282" dependencies = [ - "addr2line 0.15.1", + "addr2line", "cc", "cfg-if", "libc", "miniz_oxide", - "object 0.24.0", + "object 0.25.3", "rustc-demangle", ] @@ -146,15 +137,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.6.1" +version = "3.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63396b8a4b9de3f4fdfb320ab6080762242f66a8ef174c49d8e19b674db4cdbe" - -[[package]] -name = "byteorder" -version = "1.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" +checksum = "9c59e7af012c713f529e7a3ee57ce9b31ddd858d4b512923602f74608b009631" [[package]] name = "cap-fs-ext" @@ -164,7 +149,7 @@ checksum = "ff3a1e32332db9ad29d6da34693ce9a7ac26a9edf96abb5c1788d193410031ab" dependencies = [ "cap-primitives", "cap-std", - "rustc_version", + "rustc_version 0.3.3", "unsafe-io", "winapi", ] @@ -182,7 +167,7 @@ dependencies = [ "maybe-owned", "once_cell", "posish", - "rustc_version", + "rustc_version 0.3.3", "unsafe-io", "winapi", "winapi-util", @@ -206,7 +191,7 @@ checksum = "7019d48ea53c5f378e0fdab0fe5f627fc00e76d65e75dffd6fb1cbc0c9b382ee" dependencies = [ "cap-primitives", "posish", - "rustc_version", + "rustc_version 0.3.3", "unsafe-io", ] @@ -228,14 +213,14 @@ version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "57cdfa5d50aad6cb4d44dcab6101a7f79925bd59d82ca42f38a9856a28865374" dependencies = [ - "rustc_version", + "rustc_version 0.3.3", ] [[package]] name = "cc" -version = "1.0.67" +version = "1.0.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3c69b077ad434294d3ce9f1f6143a2a4b89a8a2d54ef813d85003a4fd1137fd" +checksum = "4a72c244c1ff497a746a7e1fb3d14bd08420ecda70c8f25c7112f2781652d787" dependencies = [ "jobserver", ] @@ -273,47 +258,45 @@ dependencies = [ [[package]] name = "cpufeatures" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed00c67cb5d0a7d64a44f6ad2668db7e7530311dd53ea79bcd4fb022c64911c8" +checksum = "66c99696f6c9dd7f35d486b9d04d7e6e202aa3e8c40d553f2fdf5e7e0c6a71ef" dependencies = [ "libc", ] [[package]] name = "cranelift-bforest" -version = "0.73.0" +version = "0.74.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07f641ec9146b7d7498d78cd832007d66ca44a9b61f23474d1fb78e5a3701e99" +checksum = "c8ca3560686e7c9c7ed7e0fe77469f2410ba5d7781b1acaa9adc8d8deea28e3e" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-codegen" -version = "0.73.0" +version = "0.74.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd1f2c0cd4ac12c954116ab2e26e40df0d51db322a855b5664fa208bc32d6686" +checksum = "baf9bf1ffffb6ce3d2e5ebc83549bd2436426c99b31cc550d521364cbe35d276" dependencies = [ - "byteorder", "cranelift-bforest", "cranelift-codegen-meta", "cranelift-codegen-shared", "cranelift-entity", - "gimli 0.23.0", + "gimli", "log", "regalloc", "serde", "smallvec", "target-lexicon", - "thiserror", ] [[package]] name = "cranelift-codegen-meta" -version = "0.73.0" +version = "0.74.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "105e11b2f0ff7ac81f80dd05ec938ce529a75e36f3d598360d806bb5bfa75e5a" +checksum = "4cc21936a5a6d07e23849ffe83e5c1f6f50305c074f4b2970ca50c13bf55b821" dependencies = [ "cranelift-codegen-shared", "cranelift-entity", @@ -321,27 +304,27 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" -version = "0.73.0" +version = "0.74.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51e5eba2c1858d50abf023be4d88bd0450cb12d4ec2ba3ffac56353e6d09caf2" +checksum = "ca5b6ffaa87560bebe69a5446449da18090b126037920b0c1c6d5945f72faf6b" dependencies = [ "serde", ] [[package]] name = "cranelift-entity" -version = "0.73.0" +version = "0.74.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79fa6fdd77a8d317763cd21668d3e72b96e09ac8a974326c6149f7de5aafa8ed" +checksum = "7d6b4a8bef04f82e4296782646f733c641d09497df2fabf791323fefaa44c64c" dependencies = [ "serde", ] [[package]] name = "cranelift-frontend" -version = "0.73.0" +version = "0.74.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae11da9ca99f987c29e3eb39ebe10e9b879ecca30f3aeaee13db5e8e02b80fb6" +checksum = "c31b783b351f966fce33e3c03498cb116d16d97a8f9978164a60920bd0d3a99c" dependencies = [ "cranelift-codegen", "log", @@ -351,9 +334,9 @@ dependencies = [ [[package]] name = "cranelift-native" -version = "0.73.0" +version = "0.74.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "100ca4810058e23a5c4dcaedfa25289d1853f4a899d0960265aa7c54a4789351" +checksum = "a77c88d3dd48021ff1e37e978a00098524abd3513444ae252c08d37b310b3d2a" dependencies = [ "cranelift-codegen", "target-lexicon", @@ -361,19 +344,19 @@ dependencies = [ [[package]] name = "cranelift-wasm" -version = "0.73.0" +version = "0.74.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "607826643d74cf2cc36973ebffd1790a11d1781e14e3f95cf5529942b2168a67" +checksum = "edb6d408e2da77cdbbd65466298d44c86ae71c1785d2ab0d8657753cdb4d9d89" dependencies = [ "cranelift-codegen", "cranelift-entity", "cranelift-frontend", - "itertools 0.10.0", + "itertools 0.10.1", "log", "serde", "smallvec", "thiserror", - "wasmparser 0.77.0", + "wasmparser 0.78.2", ] [[package]] @@ -396,7 +379,7 @@ dependencies = [ "clap", "criterion-plot", "csv", - "itertools 0.10.0", + "itertools 0.10.1", "lazy_static", "num-traits", "oorandom", @@ -444,9 +427,9 @@ dependencies = [ [[package]] name = "crossbeam-epoch" -version = "0.9.4" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52fb27eab85b17fbb9f6fd667089e07d6a2eb8743d02639ee7f6a7a7729c9c94" +checksum = "4ec02e091aa634e2c3ada4a392989e7c3116673ef0ac5b72232439094d73b7fd" dependencies = [ "cfg-if", "crossbeam-utils", @@ -457,11 +440,10 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.4" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4feb231f0d4d6af81aed15928e58ecf5816aa62a2393e2c82f46973e92a9a278" +checksum = "d82cfc11ce7f2c3faef78d8a684447b40d503d9681acebed6cb728d45940c4db" dependencies = [ - "autocfg", "cfg-if", "lazy_static", ] @@ -490,9 +472,9 @@ dependencies = [ [[package]] name = "derive_arbitrary" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df89dd0d075dea5cc5fdd6d5df6b8a61172a710b3efac1d6bdb9dd8b78f82c1a" +checksum = "5f1281ee141df08871db9fe261ab5312179eac32d1e314134ceaa8dd7c042f5a" dependencies = [ "proc-macro2", "quote", @@ -566,9 +548,9 @@ dependencies = [ [[package]] name = "env_logger" -version = "0.8.3" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17392a012ea30ef05a610aa97dfb49496e71c9f676b27879922ea5bdf60d9d3f" +checksum = "a19187fea3ac7e84da7dacf48de0c45d63c6a76f9490dae389aead16c243fce3" dependencies = [ "atty", "humantime 2.1.0", @@ -643,9 +625,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9495705279e7140bf035dde1f6e750c162df8b625267cd52cc44e0b156732c8" +checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753" dependencies = [ "cfg-if", "libc", @@ -654,21 +636,15 @@ dependencies = [ [[package]] name = "gimli" -version = "0.23.0" +version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6503fe142514ca4799d4c26297c4248239fe8838d827db6bd6065c6ed29a6ce" +checksum = "0e4075386626662786ddb0ec9081e7c7eeb1ba31951f447ca780ef9f5d568189" dependencies = [ "fallible-iterator", "indexmap", "stable_deref_trait", ] -[[package]] -name = "gimli" -version = "0.24.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e4075386626662786ddb0ec9081e7c7eeb1ba31951f447ca780ef9f5d568189" - [[package]] name = "glob" version = "0.3.0" @@ -689,18 +665,18 @@ checksum = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04" [[package]] name = "heck" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87cbf45460356b7deeb5e3415b5563308c0a9b057c85e12b06ad551f98d0a6ac" +checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" dependencies = [ "unicode-segmentation", ] [[package]] name = "hermit-abi" -version = "0.1.18" +version = "0.1.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "322f4de77956e22ed0e5032c359a0f1273f1f7f0d79bfa3b8ffbc730d7fbcc5c" +checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" dependencies = [ "libc", ] @@ -731,11 +707,22 @@ dependencies = [ "serde", ] +[[package]] +name = "io-lifetimes" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "609c23089c52d7edcf39d6cfd2cf581dcea7e059f80f1d91130887dceac77c1f" +dependencies = [ + "libc", + "rustc_version 0.4.0", + "winapi", +] + [[package]] name = "ipnet" -version = "2.3.0" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47be2f14c678be2fdcab04ab1171db51b2762ce6f0a8ee87c8dd4a04ed216135" +checksum = "68f2d64f2edebec4ce84ad108148e67e1064789bee435edc5b60ad398714a3a9" [[package]] name = "itertools" @@ -748,9 +735,9 @@ dependencies = [ [[package]] name = "itertools" -version = "0.10.0" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37d572918e350e82412fe766d24b15e6682fb2ed2bbe018280caa810397cb319" +checksum = "69ddb889f9d0d08a67338271fa9b62996bc788c7796a5c18cf057420aaed5eaf" dependencies = [ "either", ] @@ -793,18 +780,19 @@ checksum = "3576a87f2ba00f6f106fdfcd16db1d698d648a26ad8e0573cad8537c3c362d2a" [[package]] name = "libc" -version = "0.2.94" +version = "0.2.97" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18794a8ad5b29321f790b55d93dfba91e125cb1a9edbd4f8e3150acc771c1a5e" +checksum = "12b8adadd720df158f4d70dfe7ccc6adb0472d7c55ca83445f6a5ab3e36f8fb6" [[package]] name = "libfuzzer-sys" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a9dc6556604b8ad76486563d5a47fad989b643932fa006e76e23d948bef0f5b" +checksum = "36a9a84a6e8b55dfefb04235e55edb2b9a2a18488fcae777a6bdaa6f06f1deb3" dependencies = [ "arbitrary", "cc", + "once_cell", ] [[package]] @@ -845,9 +833,9 @@ checksum = "b16bd47d9e329435e309c58469fe0791c2d0d1ba96ec0954152a5ae2b04387dc" [[package]] name = "memoffset" -version = "0.6.3" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f83fb6581e8ed1f85fd45c116db8405483899489e38406156c25eb743554361d" +checksum = "59accc507f1338036a0477ef61afdae33cde60840f4dfe481319ce3ad116ddf9" dependencies = [ "autocfg", ] @@ -889,9 +877,9 @@ dependencies = [ [[package]] name = "object" -version = "0.23.0" +version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9a7ab5d64814df0fe4a4b5ead45ed6c5f181ee3ff04ba344313a6c80446c5d4" +checksum = "1a5b3dd1c072ee7963717671d1ca129f1048fda25edea6b752bfc71ac8854170" dependencies = [ "crc32fast", "indexmap", @@ -899,15 +887,18 @@ dependencies = [ [[package]] name = "object" -version = "0.24.0" +version = "0.25.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a5b3dd1c072ee7963717671d1ca129f1048fda25edea6b752bfc71ac8854170" +checksum = "a38f2be3697a57b4060074ff41b44c16870d916ad7877c17696e063257482bc7" +dependencies = [ + "memchr", +] [[package]] name = "once_cell" -version = "1.7.2" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af8b08b04175473088b46763e51ee54da5f9a164bc162f615b91bc179dbf15a3" +checksum = "692fcb63b64b1758029e0a96ee63e049ce8c5948587f2f7208df04625e5f6b56" [[package]] name = "oorandom" @@ -938,15 +929,15 @@ dependencies = [ [[package]] name = "pin-project-lite" -version = "0.2.6" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc0e1f259c92177c30a4c9d177246edd0a3568b25756a977d0632cf8fa37e905" +checksum = "8d31d11c69a6b52a174b42bdc0c30e5e11670f90788b2c471c31c1d17d449443" [[package]] name = "plotters" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45ca0ae5f169d0917a7c7f5a9c1a3d3d9598f18f529dd2b8373ed988efea307a" +checksum = "32a3fd9ec30b9749ce28cd91f255d569591cdf937fe280c312143e3c4bad6f2a" dependencies = [ "num-traits", "plotters-backend", @@ -972,9 +963,9 @@ dependencies = [ [[package]] name = "posish" -version = "0.6.1" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df1601f90b2342aaf3aadb891b71f584155d176b0e891bea92eeb11995e0ab25" +checksum = "89cfd94d463bd7f94d4dc43af1117881afdc654d389a1917b41fc0326e3b0806" dependencies = [ "bitflags", "cfg-if", @@ -1016,18 +1007,18 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.26" +version = "1.0.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a152013215dca273577e18d2bf00fa862b89b24169fb78c4c95aeb07992c9cec" +checksum = "f0d8caf72986c1a598726adc988bb5984792ef84f5ee5aa50209145ee8077038" dependencies = [ "unicode-xid", ] [[package]] name = "psm" -version = "0.1.12" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3abf49e5417290756acfd26501536358560c4a5cc4a0934d390939acb3e7083a" +checksum = "21ff0279b4a85e576b97e4a21d13e437ebcd56612706cde5d3f0d5c9399490c0" dependencies = [ "cc", ] @@ -1049,9 +1040,9 @@ dependencies = [ [[package]] name = "rand" -version = "0.8.3" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ef9e7e66b4468674bfcb0c81af8b7fa0bb154fa9f28eb840da5c447baeb8d7e" +checksum = "2e7573632e6454cf6b99d7aac4ccca54be06da05aca2ef7423d22d27d4d4bcd8" dependencies = [ "libc", "rand_chacha", @@ -1061,9 +1052,9 @@ dependencies = [ [[package]] name = "rand_chacha" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e12735cf05c9e10bf21534da50a147b924d555dc7a547c42e6bb2d5b6017ae0d" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" dependencies = [ "ppv-lite86", "rand_core", @@ -1071,18 +1062,18 @@ dependencies = [ [[package]] name = "rand_core" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34cf66eb183df1c5876e2dcf6b13d57340741e8dc255b48e40a26de954d06ae7" +checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7" dependencies = [ "getrandom", ] [[package]] name = "rand_hc" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3190ef7066a446f2e7f42e239d161e905420ccab01eb967c9eb27d21b2322a73" +checksum = "d51e9f596de227fda2ea6c84607f5558e196eeaf43c986b724ba4fb8fdf497e7" dependencies = [ "rand_core", ] @@ -1114,9 +1105,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.2.8" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "742739e41cd49414de871ea5e549afb7e2a3ac77b589bcbebe8c82fab37147fc" +checksum = "5ab49abadf3f9e1c4bc499e8845e152ad87d2ad2d30371841171169e9d75feee" dependencies = [ "bitflags", ] @@ -1156,12 +1147,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.1.9" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae1ded71d66a4a97f5e961fd0cb25a5f366a42a41570d16a763a69c092c26ae4" -dependencies = [ - "byteorder", -] +checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" [[package]] name = "regex-bench" @@ -1197,9 +1185,9 @@ dependencies = [ [[package]] name = "rustc-demangle" -version = "0.1.19" +version = "0.1.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "410f7acf3cb3a44527c5d9546bad4bf4e6c460915d5f9f2fc524498bfe8f70ce" +checksum = "dead70b0b5e03e9c814bcb6b01e03e68f7c57a80aa48c72ec92152ab3e818d49" [[package]] name = "rustc-hash" @@ -1213,7 +1201,16 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f0dfe2087c51c460008730de8b57e6a320782fbfb312e1f4d520e6c6fae155ee" dependencies = [ - "semver", + "semver 0.11.0", +] + +[[package]] +name = "rustc_version" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +dependencies = [ + "semver 1.0.3", ] [[package]] @@ -1266,6 +1263,12 @@ dependencies = [ "semver-parser", ] +[[package]] +name = "semver" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f3aac57ee7f3272d8395c6e4f502f434f0e289fcd62876f70daa008c20dcabe" + [[package]] name = "semver-parser" version = "0.10.2" @@ -1394,9 +1397,9 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.72" +version = "1.0.73" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1e8cdbefb79a9a5a65e0db8b47b723ee907b7c7f8496c76a1770b5c310bab82" +checksum = "f71489ff30030d2ae598524f61326b902466f72a0fb1a8564c001cc63425bcc7" dependencies = [ "proc-macro2", "quote", @@ -1405,16 +1408,16 @@ dependencies = [ [[package]] name = "system-interface" -version = "0.6.4" +version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff09d1260270c02199b44e68140aab5225c27b365a38684e0d7b6155f0c37ffb" +checksum = "ef194146527a71113b76650b19c509b6537aa20b91f6702f1933e7b96b347736" dependencies = [ "atty", "bitflags", "cap-fs-ext", "cap-std", "posish", - "rustc_version", + "rustc_version 0.4.0", "unsafe-io", "winapi", "winx", @@ -1446,18 +1449,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.24" +version = "1.0.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0f4a65597094d4483ddaed134f409b2cb7c1beccf25201a9f73c719254fa98e" +checksum = "fa6f76457f59514c7eeb4e59d891395fab0b2fd1d40723ae737d64153392e9c6" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.24" +version = "1.0.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7765189610d8241a44529806d6fd1f2e0a08734313a35d5b3a556f92b381f3c0" +checksum = "8a36768c0fbf1bb15eca10defa29526bda730a2376c2ab4393ccfa16fb1a318d" dependencies = [ "proc-macro2", "quote", @@ -1557,11 +1560,12 @@ checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" [[package]] name = "unsafe-io" -version = "0.6.6" +version = "0.6.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9473bb9ba1745271fb13229bfa04a70c8a698e69cf9721b8a1f5393b22735a33" +checksum = "1598c579f79cdd11e677b3942b7bed5cb3369464cfd240f4c4a308ffaed6f5e4" dependencies = [ - "rustc_version", + "io-lifetimes", + "rustc_version 0.3.3", "winapi", ] @@ -1596,11 +1600,12 @@ checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" [[package]] name = "wasi-cap-std-sync" -version = "0.26.0" +version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b0ff7337ab1e95198840773d6fbed15efbad72727d023f2ee68f8a6836d675f" +checksum = "452fc482d6c9cbd07451e62dfbae1dc381504028406fed3fed54e9dbcae820aa" dependencies = [ "anyhow", + "async-trait", "bitflags", "cap-fs-ext", "cap-rand", @@ -1618,9 +1623,9 @@ dependencies = [ [[package]] name = "wasi-common" -version = "0.26.0" +version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea27f1c1d537ae46f5666cee2fab6e8e286a022a5232c4be02de62d715d2f84a" +checksum = "8a46e511a0783c3b416e6d643cd5f52d0a2749d7d5e6299728bfd4fc80fe3cf4" dependencies = [ "anyhow", "bitflags", @@ -1698,9 +1703,9 @@ dependencies = [ [[package]] name = "wasm-smith" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a982408719f704307ac7f45247350f06ce739d759362ef8293ed7b4d922adee8" +checksum = "f7e95fdeed16adeffed44efdc7ccf27d4f57ff2e99de417c75bcee7dee09049b" dependencies = [ "arbitrary", "indexmap", @@ -1710,31 +1715,31 @@ dependencies = [ [[package]] name = "wasmparser" -version = "0.77.0" +version = "0.78.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b35c86d22e720a07d954ebbed772d01180501afe7d03d464f413bb5f8914a8d6" +checksum = "52144d4c78e5cf8b055ceab8e5fa22814ce4315d6002ad32cfd914f37c12fd65" [[package]] name = "wasmparser" -version = "0.78.2" +version = "0.79.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52144d4c78e5cf8b055ceab8e5fa22814ce4315d6002ad32cfd914f37c12fd65" +checksum = "5b5894be15a559c85779254700e1d35f02f843b5a69152e5c82c626d9fd66c0e" [[package]] name = "wasmprinter" -version = "0.2.26" +version = "0.2.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ccec894c70710c2e4669320a532cb2b9cfb97adb0429745642f8ce76916ed85" +checksum = "fe6f65000c9b653a87ba9b8bebe9230371337db2b7e70db724ee4b79d2b9936f" dependencies = [ "anyhow", - "wasmparser 0.78.2", + "wasmparser 0.79.0", ] [[package]] name = "wasmtime" -version = "0.26.0" +version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4da03115f8ad36e50edeb6640f4ba27ed7e9a6f05c2f98f728c762966f7054c6" +checksum = "b310b9d20fcf59385761d1ade7a3ef06aecc380e3d3172035b919eaf7465d9f7" dependencies = [ "anyhow", "backtrace", @@ -1752,7 +1757,7 @@ dependencies = [ "serde", "smallvec", "target-lexicon", - "wasmparser 0.77.0", + "wasmparser 0.78.2", "wasmtime-cache", "wasmtime-environ", "wasmtime-fiber", @@ -1765,9 +1770,9 @@ dependencies = [ [[package]] name = "wasmtime-cache" -version = "0.26.0" +version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abd77ef355ee65dc5147a9d4a3d7419b94b03068fc486dc9008fb2d947724efb" +checksum = "d14d500d5c3dc5f5c097158feee123d64b3097f0d836a2a27dff9c761c73c843" dependencies = [ "anyhow", "base64", @@ -1786,60 +1791,59 @@ dependencies = [ [[package]] name = "wasmtime-cranelift" -version = "0.26.0" +version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b73c47553954eab22f432a7a60bcd695eb46508c2088cb0aa1cfd060538db3b6" +checksum = "c525b39f062eada7db3c1298287b96dcb6e472b9f6b22501300b28d9fa7582f6" dependencies = [ "cranelift-codegen", "cranelift-entity", "cranelift-frontend", "cranelift-wasm", - "wasmparser 0.77.0", + "target-lexicon", + "wasmparser 0.78.2", "wasmtime-environ", ] [[package]] name = "wasmtime-debug" -version = "0.26.0" +version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5241e603c262b2ee0dfb5b2245ad539d0a99f0589909fbffc91d2a8035f2d20a" +checksum = "c5d2a763e7a6fc734218e0e463196762a4f409c483063d81e0e85f96343b2e0a" dependencies = [ "anyhow", - "gimli 0.23.0", + "gimli", "more-asserts", - "object 0.23.0", + "object 0.24.0", "target-lexicon", "thiserror", - "wasmparser 0.77.0", + "wasmparser 0.78.2", "wasmtime-environ", ] [[package]] name = "wasmtime-environ" -version = "0.26.0" +version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb8d356abc04754f5936b9377441a4a202f6bba7ad997d2cd66acb3908bc85a3" +checksum = "f64d0c2d881c31b0d65c1f2695e022d71eb60b9fbdd336aacca28208b58eac90" dependencies = [ - "anyhow", "cfg-if", "cranelift-codegen", "cranelift-entity", "cranelift-wasm", - "gimli 0.23.0", + "gimli", "indexmap", "log", "more-asserts", - "region", "serde", "thiserror", - "wasmparser 0.77.0", + "wasmparser 0.78.2", ] [[package]] name = "wasmtime-fiber" -version = "0.26.0" +version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ef51f16bbe65951ac8b7780c70eec963a20d6c87c59eefc6423c0ca323a6a02" +checksum = "a089d44cd7e2465d41a53b840a5b4fca1bf6d1ecfebc970eac9592b34ea5f0b3" dependencies = [ "cc", "libc", @@ -1848,11 +1852,11 @@ dependencies = [ [[package]] name = "wasmtime-jit" -version = "0.26.0" +version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81b066a3290a903c5beb7d765b3e82e00cd4f8ac0475297f91330fbe8e16bb17" +checksum = "4d4539ea734422b7c868107e2187d7746d8affbcaa71916d72639f53757ad707" dependencies = [ - "addr2line 0.14.1", + "addr2line", "anyhow", "cfg-if", "cranelift-codegen", @@ -1860,16 +1864,16 @@ dependencies = [ "cranelift-frontend", "cranelift-native", "cranelift-wasm", - "gimli 0.23.0", + "gimli", "log", "more-asserts", - "object 0.23.0", + "object 0.24.0", "rayon", "region", "serde", "target-lexicon", "thiserror", - "wasmparser 0.77.0", + "wasmparser 0.78.2", "wasmtime-cranelift", "wasmtime-debug", "wasmtime-environ", @@ -1881,13 +1885,13 @@ dependencies = [ [[package]] name = "wasmtime-obj" -version = "0.26.0" +version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd9d5c6c8924ea1fb2372d26c0546a8c5aab94001d5ddedaa36fd7b090c04de2" +checksum = "8e1a8ff85246d091828e2225af521a6208ed28c997bb5c39eb697366dc2e2f2b" dependencies = [ "anyhow", "more-asserts", - "object 0.23.0", + "object 0.24.0", "target-lexicon", "wasmtime-debug", "wasmtime-environ", @@ -1895,16 +1899,16 @@ dependencies = [ [[package]] name = "wasmtime-profiling" -version = "0.26.0" +version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44760e80dd5f53e9af6c976120f9f1d35908ee0c646a3144083f0a57b7123ba7" +checksum = "e24364d522dcd67c897c8fffc42e5bdfc57207bbb6d7eeade0da9d4a7d70105b" dependencies = [ "anyhow", "cfg-if", - "gimli 0.23.0", + "gimli", "lazy_static", "libc", - "object 0.23.0", + "object 0.24.0", "scroll", "serde", "target-lexicon", @@ -1914,9 +1918,9 @@ dependencies = [ [[package]] name = "wasmtime-runtime" -version = "0.26.0" +version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9701c6412897ba3a10fb4e17c4ec29723ed33d6feaaaeaf59f53799107ce7351" +checksum = "c51e57976e8a19a18a18e002c6eb12e5769554204238e47ff155fda1809ef0f7" dependencies = [ "anyhow", "backtrace", @@ -1939,9 +1943,9 @@ dependencies = [ [[package]] name = "wasmtime-wasi" -version = "0.26.0" +version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7bfa935e8a475ca6616aecc8481dfc3dcf12ad42cdaeb30746eb4addaf0316af" +checksum = "7f9c1b1c56676f6a50ecd2bb5c75b13de8097c63c684daa69555e742bc7c3d87" dependencies = [ "anyhow", "wasi-cap-std-sync", @@ -1953,9 +1957,9 @@ dependencies = [ [[package]] name = "wasmtime-wiggle" -version = "0.26.0" +version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a1782208ad6f89e8cccb56ae9366d65d75400cc5c94ba3e54456e80f3b0bf7d" +checksum = "1d1bbcb131716ca1a27300b9ff7d91e1c4e1e273ef27634933d908a9d681a193" dependencies = [ "wasmtime", "wasmtime-wiggle-macro", @@ -1965,9 +1969,9 @@ dependencies = [ [[package]] name = "wasmtime-wiggle-macro" -version = "0.26.0" +version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b638b65b2daabc68d8e728d4a545ea5b2c7349e4fbf299011c7e7436c365d37" +checksum = "c548467efc78fbdb9b5e558b2ee7142621ec14a30f6f82ff18c2a36a7f4507e0" dependencies = [ "proc-macro2", "quote", @@ -1978,29 +1982,29 @@ dependencies = [ [[package]] name = "wast" -version = "33.0.0" +version = "35.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d04fe175c7f78214971293e7d8875673804e736092206a3a4544dbc12811c1b" +checksum = "2ef140f1b49946586078353a453a1d28ba90adfc54dde75710bc1931de204d68" dependencies = [ "leb128", ] [[package]] name = "wast" -version = "35.0.2" +version = "36.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ef140f1b49946586078353a453a1d28ba90adfc54dde75710bc1931de204d68" +checksum = "8b5d7ba374a364571da1cb0a379a3dc302582a2d9937a183bfe35b68ad5bb9c4" dependencies = [ "leb128", ] [[package]] name = "wat" -version = "1.0.37" +version = "1.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ec280a739b69173e0ffd12c1658507996836ba4e992ed9bc1e5385a0bd72a02" +checksum = "16383df7f0e3901484c2dda6294ed6895caa3627ce4f6584141dcf30a33a23e6" dependencies = [ - "wast 35.0.2", + "wast 36.0.0", ] [[package]] @@ -2015,9 +2019,9 @@ dependencies = [ [[package]] name = "wiggle" -version = "0.26.0" +version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb3b6f32e575442f4710afb1d9cb8e4ac6873017fc4e8ce24c9154b1f4df02fa" +checksum = "9665f60d7e1f59c9ee9b09355b800c9d72c14c7b7216115f5a9f9e40fb203d62" dependencies = [ "async-trait", "bitflags", @@ -2029,18 +2033,18 @@ dependencies = [ [[package]] name = "wiggle-borrow" -version = "0.26.0" +version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8df875ad2e22a79cf238fb56c4fcb1c9128857993d74d21a47c8bf8cd1d3968e" +checksum = "1318f02c7d38d591986b978b5da75edabcf1d841929f57d58fc3c4ecebefb8cb" dependencies = [ "wiggle", ] [[package]] name = "wiggle-generate" -version = "0.26.0" +version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fe31034c216a6f33ceea8d84bbfb9c4aa982ee94367e35468cb91b129766910" +checksum = "0e5c3eda0ea38a5263bcb350e5cb932f9c9a1978c10dcf9944cad0f6b83d85eb" dependencies = [ "anyhow", "heck", @@ -2053,9 +2057,9 @@ dependencies = [ [[package]] name = "wiggle-macro" -version = "0.26.0" +version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab77c4b75302a25083b675e535a63e6156f12ac3c2d33c89064b6b3c8152e920" +checksum = "703d6175e622c766710a1fa3eb0e06ac05d4f7ef4b91f4e85a54c0f0679b7c07" dependencies = [ "proc-macro2", "quote", @@ -2107,14 +2111,14 @@ dependencies = [ [[package]] name = "witx" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df4a58e03db38d5e0762afc768ac9abacf826de59602b0a1dfa1b9099f03388e" +checksum = "e366f27a5cabcddb2706a78296a40b8fcc451e1a6aba2fc1d94b4a01bdaaef4b" dependencies = [ "anyhow", "log", "thiserror", - "wast 33.0.0", + "wast 35.0.2", ] [[package]] @@ -2124,7 +2128,7 @@ dependencies = [ "anyhow", "cap-std", "criterion", - "env_logger 0.8.3", + "env_logger 0.8.4", "log", "rayon", "structopt", @@ -2141,7 +2145,7 @@ dependencies = [ name = "wizer-fuzz" version = "0.0.0" dependencies = [ - "env_logger 0.8.3", + "env_logger 0.8.4", "libfuzzer-sys", "log", "wasm-smith", diff --git a/crates/wizer/Cargo.toml b/crates/wizer/Cargo.toml index 7fdaa191a1d8..7700ab1b4295 100644 --- a/crates/wizer/Cargo.toml +++ b/crates/wizer/Cargo.toml @@ -32,11 +32,11 @@ env_logger = { version = "0.8.2", optional = true } log = "0.4.14" rayon = "1.5.0" structopt = { version = "0.3.21", optional = true } -wasi-cap-std-sync = "0.26.0" +wasi-cap-std-sync = "0.27.0" wasm-encoder = "0.4.0" wasmparser = "0.78.2" -wasmtime = "0.26.0" -wasmtime-wasi = "0.26.0" +wasmtime = "0.27.0" +wasmtime-wasi = "0.27.0" # Enable this dependency to get messages with WAT disassemblies when certain # internal panics occur. diff --git a/crates/wizer/fuzz/Cargo.toml b/crates/wizer/fuzz/Cargo.toml index 1860cc9f0763..a1ab4660f1bf 100644 --- a/crates/wizer/fuzz/Cargo.toml +++ b/crates/wizer/fuzz/Cargo.toml @@ -15,7 +15,7 @@ libfuzzer-sys = "0.4" log = "0.4.14" wasm-smith = "0.4.0" wasmprinter = "0.2.26" -wasmtime = "0.26.0" +wasmtime = "0.27.0" [dependencies.wizer] path = ".." diff --git a/crates/wizer/src/dummy.rs b/crates/wizer/src/dummy.rs index d72d54b35c78..8f53c708a090 100644 --- a/crates/wizer/src/dummy.rs +++ b/crates/wizer/src/dummy.rs @@ -2,6 +2,7 @@ //! //! Forked from `wasmtime/crates/fuzzing/src/oracles/dummy.rs`. +use anyhow::Result; use std::fmt::Write; use wasmtime::*; @@ -10,7 +11,7 @@ pub fn dummy_imports( store: &wasmtime::Store, module: &wasmtime::Module, linker: &mut wasmtime::Linker, -) -> anyhow::Result<()> { +) -> Result<()> { log::debug!("Creating dummy imports"); for imp in module.imports() { @@ -22,7 +23,7 @@ pub fn dummy_imports( } linker - .define(imp.module(), name, dummy_extern(store, imp.ty())) + .define(imp.module(), name, dummy_extern(store, imp.ty())?) .unwrap(); } None => match imp.ty() { @@ -37,7 +38,7 @@ pub fn dummy_imports( } linker - .define(imp.module(), ty.name(), dummy_extern(store, ty.ty())) + .define(imp.module(), ty.name(), dummy_extern(store, ty.ty())?) .unwrap(); } } @@ -48,7 +49,7 @@ pub fn dummy_imports( } linker - .define_name(imp.module(), dummy_extern(store, other)) + .define_name(imp.module(), dummy_extern(store, other)?) .unwrap(); } }, @@ -59,15 +60,15 @@ pub fn dummy_imports( } /// Construct a dummy `Extern` from its type signature -pub fn dummy_extern(store: &Store, ty: ExternType) -> Extern { - match ty { +pub fn dummy_extern(store: &Store, ty: ExternType) -> Result { + Ok(match ty { ExternType::Func(func_ty) => Extern::Func(dummy_func(store, func_ty)), ExternType::Global(global_ty) => Extern::Global(dummy_global(store, global_ty)), ExternType::Table(table_ty) => Extern::Table(dummy_table(store, table_ty)), - ExternType::Memory(mem_ty) => Extern::Memory(dummy_memory(store, mem_ty)), + ExternType::Memory(mem_ty) => Extern::Memory(dummy_memory(store, mem_ty)?), ExternType::Instance(instance_ty) => Extern::Instance(dummy_instance(store, instance_ty)), ExternType::Module(module_ty) => Extern::Module(dummy_module(store, module_ty)), - } + }) } /// Construct a dummy function for the given function type @@ -112,7 +113,7 @@ pub fn dummy_table(store: &Store, ty: TableType) -> Table { } /// Construct a dummy memory for the given memory type. -pub fn dummy_memory(store: &Store, ty: MemoryType) -> Memory { +pub fn dummy_memory(store: &Store, ty: MemoryType) -> Result { Memory::new(store, ty) } @@ -436,7 +437,7 @@ mod tests { #[test] fn dummy_memory_import() { let store = store(); - let memory = dummy_memory(&store, MemoryType::new(Limits::at_least(1))); + let memory = dummy_memory(&store, MemoryType::new(Limits::at_least(1))).unwrap(); assert_eq!(memory.size(), 1); } diff --git a/crates/wizer/src/info.rs b/crates/wizer/src/info.rs index 92e9540092cd..738157a353c8 100644 --- a/crates/wizer/src/info.rs +++ b/crates/wizer/src/info.rs @@ -76,8 +76,6 @@ enum ModuleInfo<'a> { } struct AliasedModuleInfo { - /// This module's id. - pub id: usize, /// The id of the other module that this is an alias of. pub alias_of: usize, } @@ -185,7 +183,6 @@ impl Module { pub fn new_aliased(cx: &mut ModuleContext, alias_of: Module) -> Self { let id = cx.arena.len(); cx.arena.push(ModuleInfo::Aliased(AliasedModuleInfo { - id, alias_of: alias_of.id, })); Module { id } diff --git a/crates/wizer/src/lib.rs b/crates/wizer/src/lib.rs index 8f49cd122e9d..49288fc5b857 100644 --- a/crates/wizer/src/lib.rs +++ b/crates/wizer/src/lib.rs @@ -532,7 +532,7 @@ impl Wizer { }; ctx = ctx.preopened_dir(preopened, dir)?; } - let ctx = ctx.build()?; + let ctx = ctx.build(); wasmtime_wasi::Wasi::new(store, ctx).add_to_linker(&mut linker)?; } diff --git a/crates/wizer/tests/tests.rs b/crates/wizer/tests/tests.rs index cd324c552370..cf8ce5043891 100644 --- a/crates/wizer/tests/tests.rs +++ b/crates/wizer/tests/tests.rs @@ -42,7 +42,7 @@ fn run_wasm(args: &[wasmtime::Val], expected: i32, wasm: &[u8]) -> anyhow::Resul .define_name("dummy_func", wasmtime::Func::wrap(&store, || {}))? .define("env", "f", wasmtime::Func::wrap(&store, || {}))? .define_name("dummy_instance", dummy_instance)?; - let ctx = wasi_cap_std_sync::WasiCtxBuilder::new().build()?; + let ctx = wasi_cap_std_sync::WasiCtxBuilder::new().build(); let wasi = wasmtime_wasi::Wasi::new(&store, ctx); wasi.add_to_linker(&mut linker)?; let instance = linker.instantiate(&module)?; From 632b950d284c09e35874d9ec1ce22bcc95fb7d42 Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Mon, 28 Jun 2021 09:44:28 -0700 Subject: [PATCH 062/212] Bump to version 1.3.1 --- crates/wizer/Cargo.lock | 2 +- crates/wizer/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/wizer/Cargo.lock b/crates/wizer/Cargo.lock index 411c7b1b4f50..a597cd4a4fa9 100644 --- a/crates/wizer/Cargo.lock +++ b/crates/wizer/Cargo.lock @@ -2123,7 +2123,7 @@ dependencies = [ [[package]] name = "wizer" -version = "1.3.0" +version = "1.3.1" dependencies = [ "anyhow", "cap-std", diff --git a/crates/wizer/Cargo.toml b/crates/wizer/Cargo.toml index 7700ab1b4295..8217bfb15c59 100644 --- a/crates/wizer/Cargo.toml +++ b/crates/wizer/Cargo.toml @@ -9,7 +9,7 @@ license = "Apache-2.0 WITH LLVM-exception" name = "wizer" readme = "./README.md" repository = "https://github.com/bytecodealliance/wizer" -version = "1.3.0" +version = "1.3.1" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html From 59fde4262519d6c83ba610be0f2722d84ced64ea Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Wed, 14 Jul 2021 13:53:24 -0700 Subject: [PATCH 063/212] Add a test for creating too many data segments in a snapshot --- crates/wizer/tests/tests.rs | 48 +++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/crates/wizer/tests/tests.rs b/crates/wizer/tests/tests.rs index cf8ce5043891..c049dd6f5c03 100644 --- a/crates/wizer/tests/tests.rs +++ b/crates/wizer/tests/tests.rs @@ -22,6 +22,9 @@ fn run_wasm(args: &[wasmtime::Val], expected: i32, wasm: &[u8]) -> anyhow::Resul ===========================================================================", wasmprinter::print_bytes(&wasm).unwrap() ); + if log::log_enabled!(log::Level::Debug) { + std::fs::write("test.wasm", &wasm).unwrap(); + } let mut config = wasmtime::Config::new(); config.cache_config_load_default().unwrap(); @@ -737,6 +740,51 @@ fn data_segment_at_end_of_memory() -> anyhow::Result<()> { ) } +#[test] +fn too_many_data_segments_for_engines() -> anyhow::Result<()> { + run_wat( + &[], + 42, + r#" +(module + ;; Enough memory to create more segments than engines will allow: + ;; + ;; // The maximum number of segments that engines will allow a module to + ;; // have. + ;; let max_segments = 100_000; + ;; + ;; // The minimum gap that Wizer won't automatically merge two data + ;; // segments (see `MIN_ACTIVE_SEGMENT_OVERHEAD`). + ;; let wizer_min_gap = 6; + ;; + ;; // Wasm page size. + ;; let wasm_page_size = 65_536; + ;; + ;; let num_pages = round_up(max_segments * wizer_min_gap / wasm_page_size); + (memory 10) + + (func (export "wizer.initialize") + (local i32) + loop + (i32.ge_u (local.get 0) (i32.const 655360)) ;; 10 * wasm_page_size + if + return + end + + (i32.store8 (local.get 0) (i32.const 42)) + (local.set 0 (i32.add (local.get 0) (i32.const 6))) + br 0 + end + ) + (func (export "run") (result i32) + i32.const 0 + i32.load8_u + ) +) +"#, + ) +} + #[test] fn rename_functions() -> anyhow::Result<()> { let wat = r#" From 2187986e49f768f4ad65ff2deecc85d942d593be Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Wed, 14 Jul 2021 13:58:17 -0700 Subject: [PATCH 064/212] Do not generate modules with >= 100_000 data segments Engines have a limit of 100_000 data segments per Wasm module, and will reject the module if it has too many segments. If our snapshot captures more than that many, merge together N data segments that are closest together so that we bloat the snapshot as little as possible while still fitting within the segments limit. --- crates/wizer/src/snapshot.rs | 116 ++++++++++++++++++++++++++++++----- 1 file changed, 101 insertions(+), 15 deletions(-) diff --git a/crates/wizer/src/snapshot.rs b/crates/wizer/src/snapshot.rs index ec6ce76d62bc..e39a2d1031ed 100644 --- a/crates/wizer/src/snapshot.rs +++ b/crates/wizer/src/snapshot.rs @@ -1,8 +1,11 @@ use rayon::iter::{IntoParallelIterator, ParallelExtend, ParallelIterator}; -use std::convert::TryFrom; +use std::{collections::BinaryHeap, convert::TryFrom}; const WASM_PAGE_SIZE: u32 = 65_536; +/// The maximum number of data segments that most engines support. +const MAX_DATA_SEGMENTS: usize = 100_000; + /// A "snapshot" of Wasm state from its default value after having been initialized. pub struct Snapshot<'a> { /// Maps global index to its initialized value. @@ -29,6 +32,42 @@ pub struct DataSegment<'a> { pub data: &'a [u8], } +impl<'a> DataSegment<'a> { + /// What is the gap between two consecutive data segments? + /// + /// `self` must be in front of `other` and they must not overlap with each + /// other. + fn gap(&self, other: &Self) -> u32 { + let self_len = u32::try_from(self.data.len()).unwrap(); + debug_assert!(self.offset + self_len <= other.offset); + other.offset - (self.offset + self_len) + } + + /// Get a slice of the merged data for two consecutive data segments. + /// + /// # Safety + /// + /// Both `self` and `other` must be segments whose data are from the same + /// Wasm linear memory. + /// + /// `self` must be in front of `other` and they must not overlap with each + /// other. + unsafe fn merge(&self, other: &Self) -> &'a [u8] { + debug_assert_eq!(self.memory_index, other.memory_index); + + let gap = self.gap(other); + let gap = usize::try_from(gap).unwrap(); + + debug_assert_eq!( + self.data + .as_ptr() + .offset(isize::try_from(self.data.len() + gap).unwrap()), + other.data.as_ptr(), + ); + std::slice::from_raw_parts(self.data.as_ptr(), self.data.len() + gap + other.data.len()) + } +} + /// Snapshot the given instance's globals, memories, and instances from the Wasm /// defaults. // @@ -152,24 +191,71 @@ fn snapshot_memories<'a>(instance: &wasmtime::Instance) -> (Vec, Vec MIN_ACTIVE_SEGMENT_OVERHEAD { + let gap = a.gap(b); + if gap > MIN_ACTIVE_SEGMENT_OVERHEAD { merged_data_segments.push(*b); continue; } - // Okay, merge them together into `a` (so that the next iteration - // can merge it with its predecessor) and then remove `b`! - a.data = unsafe { - let distance = usize::try_from(distance).unwrap(); - debug_assert_eq!( - a.data - .as_ptr() - .offset(isize::try_from(a.data.len() + distance).unwrap()), - b.data.as_ptr() - ); - std::slice::from_raw_parts(a.data.as_ptr(), a.data.len() + distance + b.data.len()) - }; + // Okay, merge them together into `a` (so that the next iteration can + // merge it with its predecessor) and then omit `b`! + let merged_data = unsafe { a.merge(b) }; + a.data = merged_data; + } + + // Engines apply a limit on how many segments a module may contain, and + // Wizer can run afoul of it. In this case, we need to merge data segments + // together until our number of data segments fits within the limit. + if merged_data_segments.len() >= MAX_DATA_SEGMENTS { + // We need to remove `excess` data segments. Find the `excess` smallest + // gaps between the start of one segment and the next. We will merge + // these segments together. Because they are the smallest gaps, this + // will bloat the size of our data segment the least. + let excess = merged_data_segments.len() - MAX_DATA_SEGMENTS; + + #[derive(Clone, Copy, PartialEq, Eq)] + struct GapIndex { + gap: u32, + index: usize, + } + impl Ord for GapIndex { + fn cmp(&self, other: &Self) -> std::cmp::Ordering { + // NB: Bigger gaps first. + other + .gap + .cmp(&self.gap) + .then_with(|| self.index.cmp(&other.index)) + } + } + impl PartialOrd for GapIndex { + fn partial_cmp(&self, other: &Self) -> Option { + Some(self.cmp(other)) + } + } + + let mut smallest_gaps = BinaryHeap::::with_capacity(excess + 1); + for i in 0..merged_data_segments.len() - 1 { + debug_assert!(smallest_gaps.len() <= excess); + let gap = merged_data_segments[i].gap(&merged_data_segments[i + 1]); + smallest_gaps.push(GapIndex { gap, index: i }); + if smallest_gaps.len() > excess { + let entry = smallest_gaps.pop(); + debug_assert!(entry.unwrap().gap >= gap); + debug_assert_eq!(smallest_gaps.len(), excess); + } + } + + // Now merge the chosen segments together in reverse order so that + // merging two segments doesn't mess up the index of the next segments + // we will to merge. + let mut indices: Vec<_> = smallest_gaps.into_iter().map(|g| g.index).collect(); + indices.sort_unstable_by(|a, b| a.cmp(b).reverse()); + for i in indices { + let merged_data = + unsafe { merged_data_segments[i].merge(&merged_data_segments[i + 1]) }; + merged_data_segments[i].data = merged_data; + merged_data_segments.remove(i + 1); + } } (memory_mins, merged_data_segments) From f861e6f867788126ea68a9700b01780bdd23e675 Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Wed, 14 Jul 2021 14:07:42 -0700 Subject: [PATCH 065/212] Bump to version 1.3.2 --- crates/wizer/Cargo.lock | 2 +- crates/wizer/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/wizer/Cargo.lock b/crates/wizer/Cargo.lock index a597cd4a4fa9..afc4aaca6e63 100644 --- a/crates/wizer/Cargo.lock +++ b/crates/wizer/Cargo.lock @@ -2123,7 +2123,7 @@ dependencies = [ [[package]] name = "wizer" -version = "1.3.1" +version = "1.3.2" dependencies = [ "anyhow", "cap-std", diff --git a/crates/wizer/Cargo.toml b/crates/wizer/Cargo.toml index 8217bfb15c59..277a4db0144a 100644 --- a/crates/wizer/Cargo.toml +++ b/crates/wizer/Cargo.toml @@ -9,7 +9,7 @@ license = "Apache-2.0 WITH LLVM-exception" name = "wizer" readme = "./README.md" repository = "https://github.com/bytecodealliance/wizer" -version = "1.3.1" +version = "1.3.2" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html From cb4f92559c1e7a3ba45458dfcdae14879235a54b Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Wed, 14 Jul 2021 14:32:17 -0700 Subject: [PATCH 066/212] Use `windows` instead of manual indexing to compare consecutive items in list --- crates/wizer/src/snapshot.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/wizer/src/snapshot.rs b/crates/wizer/src/snapshot.rs index e39a2d1031ed..2b872dec81c1 100644 --- a/crates/wizer/src/snapshot.rs +++ b/crates/wizer/src/snapshot.rs @@ -234,9 +234,9 @@ fn snapshot_memories<'a>(instance: &wasmtime::Instance) -> (Vec, Vec::with_capacity(excess + 1); - for i in 0..merged_data_segments.len() - 1 { + for (i, w) in merged_data_segments.windows(2).enumerate() { debug_assert!(smallest_gaps.len() <= excess); - let gap = merged_data_segments[i].gap(&merged_data_segments[i + 1]); + let gap = w[0].gap(&w[1]); smallest_gaps.push(GapIndex { gap, index: i }); if smallest_gaps.len() > excess { let entry = smallest_gaps.pop(); From 799f04673b2f58d4e931026971bd2e7217370adc Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Thu, 15 Jul 2021 13:14:05 -0700 Subject: [PATCH 067/212] Avoid accidental quadratic behavior when removing excess data segments Well, not really "accidental" in that I knew it was there, but I thought it wouldn't matter in practice. Turns out it does, and removing many M elements from a large N vector is, indeed, slow. Luckily, we can use `swap_remove` in this case, which is O(1). --- crates/wizer/src/snapshot.rs | 109 ++++++++++++++++++----------------- 1 file changed, 57 insertions(+), 52 deletions(-) diff --git a/crates/wizer/src/snapshot.rs b/crates/wizer/src/snapshot.rs index 2b872dec81c1..07da9ef2a1d5 100644 --- a/crates/wizer/src/snapshot.rs +++ b/crates/wizer/src/snapshot.rs @@ -1,5 +1,5 @@ use rayon::iter::{IntoParallelIterator, ParallelExtend, ParallelIterator}; -use std::{collections::BinaryHeap, convert::TryFrom}; +use std::convert::TryFrom; const WASM_PAGE_SIZE: u32 = 65_536; @@ -203,62 +203,67 @@ fn snapshot_memories<'a>(instance: &wasmtime::Instance) -> (Vec, Vec= MAX_DATA_SEGMENTS { - // We need to remove `excess` data segments. Find the `excess` smallest - // gaps between the start of one segment and the next. We will merge - // these segments together. Because they are the smallest gaps, this - // will bloat the size of our data segment the least. - let excess = merged_data_segments.len() - MAX_DATA_SEGMENTS; - - #[derive(Clone, Copy, PartialEq, Eq)] - struct GapIndex { - gap: u32, - index: usize, - } - impl Ord for GapIndex { - fn cmp(&self, other: &Self) -> std::cmp::Ordering { - // NB: Bigger gaps first. - other - .gap - .cmp(&self.gap) - .then_with(|| self.index.cmp(&other.index)) - } - } - impl PartialOrd for GapIndex { - fn partial_cmp(&self, other: &Self) -> Option { - Some(self.cmp(other)) - } - } + remove_excess_segments(&mut merged_data_segments); - let mut smallest_gaps = BinaryHeap::::with_capacity(excess + 1); - for (i, w) in merged_data_segments.windows(2).enumerate() { - debug_assert!(smallest_gaps.len() <= excess); - let gap = w[0].gap(&w[1]); - smallest_gaps.push(GapIndex { gap, index: i }); - if smallest_gaps.len() > excess { - let entry = smallest_gaps.pop(); - debug_assert!(entry.unwrap().gap >= gap); - debug_assert_eq!(smallest_gaps.len(), excess); - } - } + (memory_mins, merged_data_segments) +} - // Now merge the chosen segments together in reverse order so that - // merging two segments doesn't mess up the index of the next segments - // we will to merge. - let mut indices: Vec<_> = smallest_gaps.into_iter().map(|g| g.index).collect(); - indices.sort_unstable_by(|a, b| a.cmp(b).reverse()); - for i in indices { - let merged_data = - unsafe { merged_data_segments[i].merge(&merged_data_segments[i + 1]) }; - merged_data_segments[i].data = merged_data; - merged_data_segments.remove(i + 1); +/// Engines apply a limit on how many segments a module may contain, and Wizer +/// can run afoul of it. When that happens, we need to merge data segments +/// together until our number of data segments fits within the limit. +fn remove_excess_segments(merged_data_segments: &mut Vec>) { + if merged_data_segments.len() < MAX_DATA_SEGMENTS { + return; + } + + // We need to remove `excess` number of data segments. + let excess = merged_data_segments.len() - MAX_DATA_SEGMENTS; + + #[derive(Clone, Copy, PartialEq, Eq)] + struct GapIndex { + gap: u32, + // Use a `u32` instead of `usize` to fit `GapIndex` within a word on + // 64-bit systems, using less memory. + index: u32, + } + + // Find the gaps between the start of one segment and the next (if they are + // both in the same memory). We will merge the `excess` segments with the + // smallest gaps together. Because they are the smallest gaps, this will + // bloat the size of our data segment the least. + let mut smallest_gaps = Vec::with_capacity(merged_data_segments.len() - 1); + for (index, w) in merged_data_segments.windows(2).enumerate() { + if w[0].memory_index != w[1].memory_index { + continue; } + let gap = w[0].gap(&w[1]); + let index = u32::try_from(index).unwrap(); + smallest_gaps.push(GapIndex { gap, index }); + } + smallest_gaps.sort_unstable_by_key(|g| g.gap); + smallest_gaps.truncate(excess); + + // Now merge the chosen segments together in reverse index order so that + // merging two segments doesn't mess up the index of the next segments we + // will to merge. + smallest_gaps.sort_unstable_by(|a, b| a.index.cmp(&b.index).reverse()); + for GapIndex { index, .. } in smallest_gaps { + let index = usize::try_from(index).unwrap(); + let merged_data = + unsafe { merged_data_segments[index].merge(&merged_data_segments[index + 1]) }; + merged_data_segments[index].data = merged_data; + + // Okay to use `swap_remove` here because, even though it makes + // `merged_data_segments` unsorted, the segments are still sorted within + // the range `0..index` and future iterations will only operate within + // that subregion because we are iterating over largest to smallest + // indices. + merged_data_segments.swap_remove(index + 1); } - (memory_mins, merged_data_segments) + // Finally, sort the data segments again so that our output is + // deterministic. + merged_data_segments.sort_by_key(|s| (s.memory_index, s.offset)); } fn snapshot_instantiations<'a>( From eff61056c8f75b63ceec606b98c6b6e35609a8fb Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Thu, 15 Jul 2021 13:18:25 -0700 Subject: [PATCH 068/212] Bump to version 1.3.3 --- crates/wizer/Cargo.lock | 2 +- crates/wizer/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/wizer/Cargo.lock b/crates/wizer/Cargo.lock index afc4aaca6e63..5e3fe7a1a5a0 100644 --- a/crates/wizer/Cargo.lock +++ b/crates/wizer/Cargo.lock @@ -2123,7 +2123,7 @@ dependencies = [ [[package]] name = "wizer" -version = "1.3.2" +version = "1.3.3" dependencies = [ "anyhow", "cap-std", diff --git a/crates/wizer/Cargo.toml b/crates/wizer/Cargo.toml index 277a4db0144a..b5357a697987 100644 --- a/crates/wizer/Cargo.toml +++ b/crates/wizer/Cargo.toml @@ -9,7 +9,7 @@ license = "Apache-2.0 WITH LLVM-exception" name = "wizer" readme = "./README.md" repository = "https://github.com/bytecodealliance/wizer" -version = "1.3.2" +version = "1.3.3" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html From 859957add7e7c23d3ecd0ad652baa33fdd4f14e1 Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Tue, 20 Jul 2021 14:20:35 -0700 Subject: [PATCH 069/212] Update to Wasmtime 0.28 --- crates/wizer/Cargo.lock | 160 +++++++++++++---------------------- crates/wizer/Cargo.toml | 8 +- crates/wizer/fuzz/Cargo.toml | 2 +- crates/wizer/src/dummy.rs | 78 +++++++++-------- crates/wizer/src/lib.rs | 74 ++++++++++------ crates/wizer/src/rewrite.rs | 15 ++-- crates/wizer/src/snapshot.rs | 130 ++++++++++++++-------------- crates/wizer/tests/tests.rs | 23 ++--- 8 files changed, 242 insertions(+), 248 deletions(-) diff --git a/crates/wizer/Cargo.lock b/crates/wizer/Cargo.lock index 5e3fe7a1a5a0..50fa2dfaea01 100644 --- a/crates/wizer/Cargo.lock +++ b/crates/wizer/Cargo.lock @@ -89,7 +89,7 @@ dependencies = [ "cfg-if", "libc", "miniz_oxide", - "object 0.25.3", + "object", "rustc-demangle", ] @@ -267,18 +267,18 @@ dependencies = [ [[package]] name = "cranelift-bforest" -version = "0.74.0" +version = "0.75.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8ca3560686e7c9c7ed7e0fe77469f2410ba5d7781b1acaa9adc8d8deea28e3e" +checksum = "df3f8dd4f920a422c96c53fb6a91cc7932b865fdb60066ae9df7c329342d303f" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-codegen" -version = "0.74.0" +version = "0.75.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf9bf1ffffb6ce3d2e5ebc83549bd2436426c99b31cc550d521364cbe35d276" +checksum = "ebe85f9a8dbf3c9dfa47ecb89828a7dc17c0b62015b84b5505fd4beba61c542c" dependencies = [ "cranelift-bforest", "cranelift-codegen-meta", @@ -294,9 +294,9 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.74.0" +version = "0.75.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cc21936a5a6d07e23849ffe83e5c1f6f50305c074f4b2970ca50c13bf55b821" +checksum = "12bc4be68da214a56bf9beea4212eb3b9eac16ca9f0b47762f907c4cd4684073" dependencies = [ "cranelift-codegen-shared", "cranelift-entity", @@ -304,27 +304,27 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" -version = "0.74.0" +version = "0.75.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca5b6ffaa87560bebe69a5446449da18090b126037920b0c1c6d5945f72faf6b" +checksum = "a0c87b69923825cfbc3efde17d929a68cd5b50a4016b2bd0eb8c3933cc5bd8cd" dependencies = [ "serde", ] [[package]] name = "cranelift-entity" -version = "0.74.0" +version = "0.75.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d6b4a8bef04f82e4296782646f733c641d09497df2fabf791323fefaa44c64c" +checksum = "fe683e7ec6e627facf44b2eab4b263507be4e7ef7ea06eb8cee5283d9b45370e" dependencies = [ "serde", ] [[package]] name = "cranelift-frontend" -version = "0.74.0" +version = "0.75.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c31b783b351f966fce33e3c03498cb116d16d97a8f9978164a60920bd0d3a99c" +checksum = "5da80025ca214f0118273f8b94c4790add3b776f0dc97afba6b711757497743b" dependencies = [ "cranelift-codegen", "log", @@ -334,9 +334,9 @@ dependencies = [ [[package]] name = "cranelift-native" -version = "0.74.0" +version = "0.75.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a77c88d3dd48021ff1e37e978a00098524abd3513444ae252c08d37b310b3d2a" +checksum = "e1c0e8c56f9a63f352a64aaa9c9eef7c205008b03593af7b128a3fbc46eae7e9" dependencies = [ "cranelift-codegen", "target-lexicon", @@ -344,9 +344,9 @@ dependencies = [ [[package]] name = "cranelift-wasm" -version = "0.74.0" +version = "0.75.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edb6d408e2da77cdbbd65466298d44c86ae71c1785d2ab0d8657753cdb4d9d89" +checksum = "d10ddafc5f1230d2190eb55018fcdecfcce728c9c2b975f2690ef13691d18eb5" dependencies = [ "cranelift-codegen", "cranelift-entity", @@ -780,9 +780,9 @@ checksum = "3576a87f2ba00f6f106fdfcd16db1d698d648a26ad8e0573cad8537c3c362d2a" [[package]] name = "libc" -version = "0.2.97" +version = "0.2.98" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12b8adadd720df158f4d70dfe7ccc6adb0472d7c55ca83445f6a5ab3e36f8fb6" +checksum = "320cfe77175da3a483efed4bc0adc1968ca050b098ce4f2f1c13a56626128790" [[package]] name = "libfuzzer-sys" @@ -875,22 +875,14 @@ dependencies = [ "libc", ] -[[package]] -name = "object" -version = "0.24.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a5b3dd1c072ee7963717671d1ca129f1048fda25edea6b752bfc71ac8854170" -dependencies = [ - "crc32fast", - "indexmap", -] - [[package]] name = "object" version = "0.25.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a38f2be3697a57b4060074ff41b44c16870d916ad7877c17696e063257482bc7" dependencies = [ + "crc32fast", + "indexmap", "memchr", ] @@ -1600,9 +1592,9 @@ checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" [[package]] name = "wasi-cap-std-sync" -version = "0.27.0" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "452fc482d6c9cbd07451e62dfbae1dc381504028406fed3fed54e9dbcae820aa" +checksum = "54ed414ed6ff3b95653ea07b237cf03c513015d94169aac159755e05a2eaa80f" dependencies = [ "anyhow", "async-trait", @@ -1623,9 +1615,9 @@ dependencies = [ [[package]] name = "wasi-common" -version = "0.27.0" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a46e511a0783c3b416e6d643cd5f52d0a2749d7d5e6299728bfd4fc80fe3cf4" +checksum = "6c67b1e49ae6d9bcab37a6f13594aed98d8ab8f5c2117b3bed543d8019688733" dependencies = [ "anyhow", "bitflags", @@ -1737,9 +1729,9 @@ dependencies = [ [[package]] name = "wasmtime" -version = "0.27.0" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b310b9d20fcf59385761d1ade7a3ef06aecc380e3d3172035b919eaf7465d9f7" +checksum = "56828b11cd743a0e9b4207d1c7a8c1a66cb32d14601df10422072802a6aee86c" dependencies = [ "anyhow", "backtrace", @@ -1770,9 +1762,9 @@ dependencies = [ [[package]] name = "wasmtime-cache" -version = "0.27.0" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d14d500d5c3dc5f5c097158feee123d64b3097f0d836a2a27dff9c761c73c843" +checksum = "99aca6335ad194d795342137a92afaec9338a2bfcf4caa4c667b5ece16c2bfa9" dependencies = [ "anyhow", "base64", @@ -1791,9 +1783,9 @@ dependencies = [ [[package]] name = "wasmtime-cranelift" -version = "0.27.0" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c525b39f062eada7db3c1298287b96dcb6e472b9f6b22501300b28d9fa7582f6" +checksum = "519fa80abe29dc46fc43177cbe391e38c8613c59229c8d1d90d7f226c3c7cede" dependencies = [ "cranelift-codegen", "cranelift-entity", @@ -1806,14 +1798,14 @@ dependencies = [ [[package]] name = "wasmtime-debug" -version = "0.27.0" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5d2a763e7a6fc734218e0e463196762a4f409c483063d81e0e85f96343b2e0a" +checksum = "6ddf6e9bca2f3bc1dd499db2a93d35c735176cff0de7daacdc18c3794f7082e0" dependencies = [ "anyhow", "gimli", "more-asserts", - "object 0.24.0", + "object", "target-lexicon", "thiserror", "wasmparser 0.78.2", @@ -1822,9 +1814,9 @@ dependencies = [ [[package]] name = "wasmtime-environ" -version = "0.27.0" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f64d0c2d881c31b0d65c1f2695e022d71eb60b9fbdd336aacca28208b58eac90" +checksum = "0a991635b1cf1d1336fbea7a5f2c0e1dafaa54cb21c632d8414885278fa5d1b1" dependencies = [ "cfg-if", "cranelift-codegen", @@ -1841,9 +1833,9 @@ dependencies = [ [[package]] name = "wasmtime-fiber" -version = "0.27.0" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a089d44cd7e2465d41a53b840a5b4fca1bf6d1ecfebc970eac9592b34ea5f0b3" +checksum = "7ab6bb95303636d1eba6f7fd2b67c1cd583f73303c73b1a3259b46bb1c2eb299" dependencies = [ "cc", "libc", @@ -1852,9 +1844,9 @@ dependencies = [ [[package]] name = "wasmtime-jit" -version = "0.27.0" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d4539ea734422b7c868107e2187d7746d8affbcaa71916d72639f53757ad707" +checksum = "5f33a0ae79b7c8d050156b22e10fdc49dfb09cc482c251d12bf10e8a833498fb" dependencies = [ "addr2line", "anyhow", @@ -1867,7 +1859,7 @@ dependencies = [ "gimli", "log", "more-asserts", - "object 0.24.0", + "object", "rayon", "region", "serde", @@ -1885,13 +1877,13 @@ dependencies = [ [[package]] name = "wasmtime-obj" -version = "0.27.0" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e1a8ff85246d091828e2225af521a6208ed28c997bb5c39eb697366dc2e2f2b" +checksum = "4a879f03d416615f322dcb3aa5cb4cbc47b64b12be6aa235a64ab63a4281d50a" dependencies = [ "anyhow", "more-asserts", - "object 0.24.0", + "object", "target-lexicon", "wasmtime-debug", "wasmtime-environ", @@ -1899,16 +1891,16 @@ dependencies = [ [[package]] name = "wasmtime-profiling" -version = "0.27.0" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e24364d522dcd67c897c8fffc42e5bdfc57207bbb6d7eeade0da9d4a7d70105b" +checksum = "171ae3107e8502667b16d336a1dd03e370aa6630a1ce26559aba572ade1031d1" dependencies = [ "anyhow", "cfg-if", "gimli", "lazy_static", "libc", - "object 0.24.0", + "object", "scroll", "serde", "target-lexicon", @@ -1918,9 +1910,9 @@ dependencies = [ [[package]] name = "wasmtime-runtime" -version = "0.27.0" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c51e57976e8a19a18a18e002c6eb12e5769554204238e47ff155fda1809ef0f7" +checksum = "0404e10f8b07f940be42aa4b8785b4ab42e96d7167ccc92e35d36eee040309c2" dependencies = [ "anyhow", "backtrace", @@ -1943,43 +1935,17 @@ dependencies = [ [[package]] name = "wasmtime-wasi" -version = "0.27.0" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f9c1b1c56676f6a50ecd2bb5c75b13de8097c63c684daa69555e742bc7c3d87" +checksum = "39d75f21122ec134c8bfc8840a8742c0d406a65560fb9716b23800bd7cfd6ae5" dependencies = [ "anyhow", "wasi-cap-std-sync", "wasi-common", "wasmtime", - "wasmtime-wiggle", "wiggle", ] -[[package]] -name = "wasmtime-wiggle" -version = "0.27.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d1bbcb131716ca1a27300b9ff7d91e1c4e1e273ef27634933d908a9d681a193" -dependencies = [ - "wasmtime", - "wasmtime-wiggle-macro", - "wiggle", - "wiggle-borrow", -] - -[[package]] -name = "wasmtime-wiggle-macro" -version = "0.27.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c548467efc78fbdb9b5e558b2ee7142621ec14a30f6f82ff18c2a36a7f4507e0" -dependencies = [ - "proc-macro2", - "quote", - "syn", - "wiggle-generate", - "witx", -] - [[package]] name = "wast" version = "35.0.2" @@ -2019,32 +1985,24 @@ dependencies = [ [[package]] name = "wiggle" -version = "0.27.0" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9665f60d7e1f59c9ee9b09355b800c9d72c14c7b7216115f5a9f9e40fb203d62" +checksum = "79ca01f1388a549eb3eaa221a072c3cfd3e383618ec6b423e82f2734ee28dd40" dependencies = [ + "anyhow", "async-trait", "bitflags", "thiserror", "tracing", + "wasmtime", "wiggle-macro", - "witx", -] - -[[package]] -name = "wiggle-borrow" -version = "0.27.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1318f02c7d38d591986b978b5da75edabcf1d841929f57d58fc3c4ecebefb8cb" -dependencies = [ - "wiggle", ] [[package]] name = "wiggle-generate" -version = "0.27.0" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e5c3eda0ea38a5263bcb350e5cb932f9c9a1978c10dcf9944cad0f6b83d85eb" +checksum = "544fd41029c33b179656ab1674cd813db7cd473f38f1976ae6e08effb46dd269" dependencies = [ "anyhow", "heck", @@ -2057,9 +2015,9 @@ dependencies = [ [[package]] name = "wiggle-macro" -version = "0.27.0" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "703d6175e622c766710a1fa3eb0e06ac05d4f7ef4b91f4e85a54c0f0679b7c07" +checksum = "9e31ae77a274c9800e6f1342fa4a6dde5e2d72eb9d9b2e0418781be6efc35b58" dependencies = [ "proc-macro2", "quote", diff --git a/crates/wizer/Cargo.toml b/crates/wizer/Cargo.toml index b5357a697987..7d72649fefef 100644 --- a/crates/wizer/Cargo.toml +++ b/crates/wizer/Cargo.toml @@ -27,16 +27,16 @@ harness = false [dependencies] anyhow = "1.0.38" -cap-std = "0.13.7" +cap-std = "0.13.10" env_logger = { version = "0.8.2", optional = true } log = "0.4.14" rayon = "1.5.0" structopt = { version = "0.3.21", optional = true } -wasi-cap-std-sync = "0.27.0" +wasi-cap-std-sync = "0.28.0" wasm-encoder = "0.4.0" wasmparser = "0.78.2" -wasmtime = "0.27.0" -wasmtime-wasi = "0.27.0" +wasmtime = "0.28.0" +wasmtime-wasi = "0.28.0" # Enable this dependency to get messages with WAT disassemblies when certain # internal panics occur. diff --git a/crates/wizer/fuzz/Cargo.toml b/crates/wizer/fuzz/Cargo.toml index a1ab4660f1bf..f7f40fcac31f 100644 --- a/crates/wizer/fuzz/Cargo.toml +++ b/crates/wizer/fuzz/Cargo.toml @@ -15,7 +15,7 @@ libfuzzer-sys = "0.4" log = "0.4.14" wasm-smith = "0.4.0" wasmprinter = "0.2.26" -wasmtime = "0.27.0" +wasmtime = "0.28.0" [dependencies.wizer] path = ".." diff --git a/crates/wizer/src/dummy.rs b/crates/wizer/src/dummy.rs index 8f53c708a090..e2ae1551b6b6 100644 --- a/crates/wizer/src/dummy.rs +++ b/crates/wizer/src/dummy.rs @@ -8,48 +8,48 @@ use wasmtime::*; /// Create dummy imports for instantiating the module. pub fn dummy_imports( - store: &wasmtime::Store, + store: &mut crate::Store, module: &wasmtime::Module, - linker: &mut wasmtime::Linker, + linker: &mut crate::Linker, ) -> Result<()> { log::debug!("Creating dummy imports"); for imp in module.imports() { match imp.name() { Some(name) => { - if linker.get_one_by_name(imp.module(), Some(name)).is_ok() { + if linker.get(&mut *store, imp.module(), Some(name)).is_some() { // Already defined, must be part of WASI. continue; } linker - .define(imp.module(), name, dummy_extern(store, imp.ty())?) + .define(imp.module(), name, dummy_extern(&mut *store, imp.ty())?) .unwrap(); } None => match imp.ty() { wasmtime::ExternType::Instance(ty) => { for ty in ty.exports() { if linker - .get_one_by_name(imp.module(), Some(ty.name())) - .is_ok() + .get(&mut *store, imp.module(), Some(ty.name())) + .is_some() { // Already defined, must be part of WASI. continue; } linker - .define(imp.module(), ty.name(), dummy_extern(store, ty.ty())?) + .define(imp.module(), ty.name(), dummy_extern(&mut *store, ty.ty())?) .unwrap(); } } other => { - if linker.get_one_by_name(imp.module(), None).is_ok() { + if linker.get(&mut *store, imp.module(), None).is_some() { // Already defined, must be part of WASI. continue; } linker - .define_name(imp.module(), dummy_extern(store, other)?) + .define_name(imp.module(), dummy_extern(&mut *store, other)?) .unwrap(); } }, @@ -60,7 +60,7 @@ pub fn dummy_imports( } /// Construct a dummy `Extern` from its type signature -pub fn dummy_extern(store: &Store, ty: ExternType) -> Result { +pub fn dummy_extern(store: &mut crate::Store, ty: ExternType) -> Result { Ok(match ty { ExternType::Func(func_ty) => Extern::Func(dummy_func(store, func_ty)), ExternType::Global(global_ty) => Extern::Global(dummy_global(store, global_ty)), @@ -72,7 +72,7 @@ pub fn dummy_extern(store: &Store, ty: ExternType) -> Result { } /// Construct a dummy function for the given function type -pub fn dummy_func(store: &Store, ty: FuncType) -> Func { +pub fn dummy_func(store: &mut crate::Store, ty: FuncType) -> Func { Func::new(store, ty.clone(), move |_, _, results| { for (ret_ty, result) in ty.results().zip(results) { *result = dummy_value(ret_ty); @@ -101,19 +101,19 @@ pub fn dummy_values(val_tys: impl IntoIterator) -> Vec { } /// Construct a dummy global for the given global type. -pub fn dummy_global(store: &Store, ty: GlobalType) -> Global { +pub fn dummy_global(store: &mut crate::Store, ty: GlobalType) -> Global { let val = dummy_value(ty.content().clone()); Global::new(store, ty, val).unwrap() } /// Construct a dummy table for the given table type. -pub fn dummy_table(store: &Store, ty: TableType) -> Table { +pub fn dummy_table(store: &mut crate::Store, ty: TableType) -> Table { let init_val = dummy_value(ty.element().clone()); Table::new(store, ty, init_val).unwrap() } /// Construct a dummy memory for the given memory type. -pub fn dummy_memory(store: &Store, ty: MemoryType) -> Result { +pub fn dummy_memory(store: &mut crate::Store, ty: MemoryType) -> Result { Memory::new(store, ty) } @@ -121,7 +121,7 @@ pub fn dummy_memory(store: &Store, ty: MemoryType) -> Result { /// /// This is done by using the expected type to generate a module on-the-fly /// which we the instantiate. -pub fn dummy_instance(store: &Store, ty: InstanceType) -> Instance { +pub fn dummy_instance(store: &mut crate::Store, ty: InstanceType) -> Instance { let mut wat = WatGenerator::new(); for ty in ty.exports() { wat.export(&ty); @@ -133,7 +133,7 @@ pub fn dummy_instance(store: &Store, ty: InstanceType) -> Instance { /// Construct a dummy module for the given module type. /// /// This is done by using the expected type to generate a module on-the-fly. -pub fn dummy_module(store: &Store, ty: ModuleType) -> Module { +pub fn dummy_module(store: &mut crate::Store, ty: ModuleType) -> Module { let mut wat = WatGenerator::new(); for ty in ty.imports() { wat.import(&ty); @@ -405,53 +405,57 @@ mod tests { use super::*; use std::collections::HashSet; - fn store() -> Store { + fn store() -> crate::Store { let mut config = Config::default(); config.wasm_module_linking(true); config.wasm_multi_memory(true); let engine = wasmtime::Engine::new(&config).unwrap(); - Store::new(&engine) + Store::new(&engine, None) } #[test] fn dummy_table_import() { - let store = store(); + let mut store = store(); let table = dummy_table( - &store, + &mut store, TableType::new(ValType::ExternRef, Limits::at_least(10)), ); - assert_eq!(table.size(), 10); + assert_eq!(table.size(&store), 10); for i in 0..10 { - assert!(table.get(i).unwrap().unwrap_externref().is_none()); + assert!(table + .get(&mut store, i) + .unwrap() + .unwrap_externref() + .is_none()); } } #[test] fn dummy_global_import() { - let store = store(); - let global = dummy_global(&store, GlobalType::new(ValType::I32, Mutability::Const)); - assert_eq!(global.val_type(), ValType::I32); - assert_eq!(global.mutability(), Mutability::Const); + let mut store = store(); + let global = dummy_global(&mut store, GlobalType::new(ValType::I32, Mutability::Const)); + assert_eq!(*global.ty(&store).content(), ValType::I32); + assert_eq!(global.ty(&store).mutability(), Mutability::Const); } #[test] fn dummy_memory_import() { - let store = store(); - let memory = dummy_memory(&store, MemoryType::new(Limits::at_least(1))).unwrap(); - assert_eq!(memory.size(), 1); + let mut store = store(); + let memory = dummy_memory(&mut store, MemoryType::new(Limits::at_least(1))).unwrap(); + assert_eq!(memory.size(&store), 1); } #[test] fn dummy_function_import() { - let store = store(); + let mut store = store(); let func_ty = FuncType::new(vec![ValType::I32], vec![ValType::I64]); - let func = dummy_func(&store, func_ty.clone()); - assert_eq!(func.ty(), func_ty); + let func = dummy_func(&mut store, func_ty.clone()); + assert_eq!(func.ty(&store), func_ty); } #[test] fn dummy_instance_import() { - let store = store(); + let mut store = store(); let mut instance_ty = InstanceType::new(); @@ -491,7 +495,7 @@ mod tests { instance_ty.add_named_export("instance0", InstanceType::new().into()); instance_ty.add_named_export("instance1", InstanceType::new().into()); - let instance = dummy_instance(&store, instance_ty.clone()); + let instance = dummy_instance(&mut store, instance_ty.clone()); let mut expected_exports = vec![ "func0", @@ -509,7 +513,7 @@ mod tests { ] .into_iter() .collect::>(); - for exp in instance.ty().exports() { + for exp in instance.ty(&store).exports() { let was_expected = expected_exports.remove(exp.name()); assert!(was_expected); } @@ -518,7 +522,7 @@ mod tests { #[test] fn dummy_module_import() { - let store = store(); + let mut store = store(); let mut module_ty = ModuleType::new(); @@ -591,7 +595,7 @@ mod tests { module_ty.add_named_import("instance1", None, InstanceType::new().into()); // Create the module. - let module = dummy_module(&store, module_ty); + let module = dummy_module(&mut store, module_ty); // Check that we have the expected exports. assert!(module.get_export("func0").is_some()); diff --git a/crates/wizer/src/lib.rs b/crates/wizer/src/lib.rs index 49288fc5b857..b25115e662b7 100644 --- a/crates/wizer/src/lib.rs +++ b/crates/wizer/src/lib.rs @@ -24,6 +24,7 @@ use std::fmt::Display; use std::path::PathBuf; #[cfg(feature = "structopt")] use structopt::StructOpt; +use wasmtime_wasi::WasiCtx; const DEFAULT_INHERIT_STDIO: bool = true; const DEFAULT_INHERIT_ENV: bool = false; @@ -31,6 +32,14 @@ const DEFAULT_WASM_MULTI_VALUE: bool = true; const DEFAULT_WASM_MULTI_MEMORY: bool = true; const DEFAULT_WASM_MODULE_LINKING: bool = false; +/// We only ever use `Store` with a fixed `T` that is our optional WASI +/// context. +pub(crate) type Store = wasmtime::Store>; + +/// We only ever use `Linker` with a fixed `T` that is our optional WASI +/// context. +pub(crate) type Linker = wasmtime::Linker>; + /// Wizer: the WebAssembly pre-initializer! /// /// Don't wait for your Wasm module to initialize itself, pre-initialize it! @@ -321,14 +330,15 @@ impl Wizer { let config = self.wasmtime_config()?; let engine = wasmtime::Engine::new(&config)?; - let store = wasmtime::Store::new(&engine); + let wasi_ctx = self.wasi_context()?; + let mut store = wasmtime::Store::new(&engine, wasi_ctx); let module = wasmtime::Module::new(&engine, &instrumented_wasm) .context("failed to compile the Wasm module")?; self.validate_init_func(&module)?; - let instance = self.initialize(&store, &module)?; - let snapshot = snapshot::snapshot(&store, &instance); - let rewritten_wasm = self.rewrite(&mut cx, &snapshot, &renames); + let instance = self.initialize(&mut store, &module)?; + let snapshot = snapshot::snapshot(&mut store, &instance); + let rewritten_wasm = self.rewrite(&mut cx, &mut store, &snapshot, &renames); if cfg!(debug_assertions) { if let Err(error) = self.wasm_validate(&rewritten_wasm) { @@ -507,46 +517,56 @@ impl Wizer { Ok(()) } + fn wasi_context(&self) -> anyhow::Result> { + if !self.allow_wasi { + return Ok(None); + } + + let mut ctx = wasi_cap_std_sync::WasiCtxBuilder::new(); + if self.inherit_stdio.unwrap_or(DEFAULT_INHERIT_STDIO) { + ctx = ctx.inherit_stdio(); + } + if self.inherit_env.unwrap_or(DEFAULT_INHERIT_ENV) { + ctx = ctx.inherit_env()?; + } + for dir in &self.dirs { + log::debug!("Preopening directory: {}", dir.display()); + let preopened = unsafe { + cap_std::fs::Dir::open_ambient_dir(dir) + .with_context(|| format!("failed to open directory: {}", dir.display()))? + }; + ctx = ctx.preopened_dir(preopened, dir)?; + } + Ok(Some(ctx.build())) + } + /// Instantiate the module and call its initialization function. fn initialize( &self, - store: &wasmtime::Store, + store: &mut Store, module: &wasmtime::Module, ) -> anyhow::Result { log::debug!("Calling the initialization function"); - let mut linker = wasmtime::Linker::new(store); + let mut linker = wasmtime::Linker::new(store.engine()); + if self.allow_wasi { - let mut ctx = wasi_cap_std_sync::WasiCtxBuilder::new(); - if self.inherit_stdio.unwrap_or(DEFAULT_INHERIT_STDIO) { - ctx = ctx.inherit_stdio(); - } - if self.inherit_env.unwrap_or(DEFAULT_INHERIT_ENV) { - ctx = ctx.inherit_env()?; - } - for dir in &self.dirs { - log::debug!("Preopening directory: {}", dir.display()); - let preopened = unsafe { - cap_std::fs::Dir::open_ambient_dir(dir) - .with_context(|| format!("failed to open directory: {}", dir.display()))? - }; - ctx = ctx.preopened_dir(preopened, dir)?; - } - let ctx = ctx.build(); - wasmtime_wasi::Wasi::new(store, ctx).add_to_linker(&mut linker)?; + wasmtime_wasi::add_to_linker(&mut linker, |ctx: &mut Option| { + ctx.as_mut().unwrap() + })?; } - dummy_imports(&store, &module, &mut linker)?; + dummy_imports(&mut *store, &module, &mut linker)?; let instance = linker - .instantiate(module) + .instantiate(&mut *store, module) .context("failed to instantiate the Wasm module")?; let init_func = instance - .get_typed_func::<(), ()>(&self.init_func) + .get_typed_func::<(), (), _>(&mut *store, &self.init_func) .expect("checked by `validate_init_func`"); init_func - .call(()) + .call(&mut *store, ()) .with_context(|| format!("the `{}` function trapped", self.init_func))?; Ok(instance) diff --git a/crates/wizer/src/rewrite.rs b/crates/wizer/src/rewrite.rs index b8c4f6fa21b9..48f51de5f56d 100644 --- a/crates/wizer/src/rewrite.rs +++ b/crates/wizer/src/rewrite.rs @@ -21,15 +21,16 @@ impl Wizer { pub(crate) fn rewrite( &self, cx: &mut ModuleContext<'_>, + store: &crate::Store, snapshot: &Snapshot, renames: &FuncRenames, ) -> Vec { log::debug!("Rewriting input Wasm to pre-initialized state"); if cx.uses_module_linking() { - self.rewrite_with_module_linking(cx, snapshot, renames) + self.rewrite_with_module_linking(cx, store, snapshot, renames) } else { - self.rewrite_without_module_linking(cx, snapshot, renames) + self.rewrite_without_module_linking(cx, store, snapshot, renames) } } @@ -38,6 +39,7 @@ impl Wizer { fn rewrite_without_module_linking( &self, cx: &ModuleContext<'_>, + store: &crate::Store, snapshot: &Snapshot, renames: &FuncRenames, ) -> Vec { @@ -56,7 +58,7 @@ impl Wizer { data_section.active( seg.memory_index, wasm_encoder::Instruction::I32Const(seg.offset as i32), - seg.data.iter().copied(), + seg.data(store).iter().copied(), ); } Some(data_section) @@ -328,6 +330,7 @@ impl Wizer { fn rewrite_with_module_linking( &self, cx: &mut ModuleContext<'_>, + store: &crate::Store, snapshot: &Snapshot, renames: &FuncRenames, ) -> Vec { @@ -343,7 +346,7 @@ impl Wizer { let (code_modules, num_code_modules) = rewrite_code_modules(cx); - let root_state_module = rewrite_state_module(cx, cx.root(), &snapshot, 0); + let root_state_module = rewrite_state_module(cx, store, cx.root(), &snapshot, 0); let mut modules = wasm_encoder::ModuleSection::new(); modules.module(&root_state_module); let root_state_module_index = num_code_modules; @@ -831,6 +834,7 @@ fn make_state_import( /// the same for its nested instantiations. fn rewrite_state_module( cx: &ModuleContext<'_>, + store: &crate::Store, info: Module, snapshot: &Snapshot, depth: u32, @@ -966,6 +970,7 @@ fn rewrite_state_module( // Define the state module for this instantiation. let state_module = rewrite_state_module( cx, + store, *module, &snapshot.instantiations[i], depth + 1, @@ -1096,7 +1101,7 @@ fn rewrite_state_module( data.active( seg.memory_index, wasm_encoder::Instruction::I32Const(seg.offset as i32), - seg.data.iter().copied(), + seg.data(store).iter().copied(), ); } state_module.section(&data); diff --git a/crates/wizer/src/snapshot.rs b/crates/wizer/src/snapshot.rs index 07da9ef2a1d5..c80f2c124e6b 100644 --- a/crates/wizer/src/snapshot.rs +++ b/crates/wizer/src/snapshot.rs @@ -1,5 +1,6 @@ use rayon::iter::{IntoParallelIterator, ParallelExtend, ParallelIterator}; use std::convert::TryFrom; +use wasmtime::{AsContext, AsContextMut}; const WASM_PAGE_SIZE: u32 = 65_536; @@ -7,7 +8,7 @@ const WASM_PAGE_SIZE: u32 = 65_536; const MAX_DATA_SEGMENTS: usize = 100_000; /// A "snapshot" of Wasm state from its default value after having been initialized. -pub struct Snapshot<'a> { +pub struct Snapshot { /// Maps global index to its initialized value. pub globals: Vec, @@ -15,56 +16,59 @@ pub struct Snapshot<'a> { pub memory_mins: Vec, /// Segments of non-zero memory. - pub data_segments: Vec>, + pub data_segments: Vec, /// Snapshots for each nested instantiation. - pub instantiations: Vec>, + pub instantiations: Vec, } /// A data segment initializer for a memory. #[derive(Clone, Copy)] -pub struct DataSegment<'a> { +pub struct DataSegment { /// The index of this data segment's memory. pub memory_index: u32, + + /// This data segment's initialized memory that it originated from. + pub memory: wasmtime::Memory, + /// The offset within the memory that `data` should be copied to. pub offset: u32, - /// This segment's (non-zero) data. - pub data: &'a [u8], + + /// This segment's length. + pub len: u32, } -impl<'a> DataSegment<'a> { +impl DataSegment { + pub fn data<'a>(&self, ctx: &'a impl AsContext) -> &'a [u8] { + let start = usize::try_from(self.offset).unwrap(); + let end = start + usize::try_from(self.len).unwrap(); + &self.memory.data(ctx)[start..end] + } +} + +impl DataSegment { /// What is the gap between two consecutive data segments? /// /// `self` must be in front of `other` and they must not overlap with each /// other. fn gap(&self, other: &Self) -> u32 { - let self_len = u32::try_from(self.data.len()).unwrap(); - debug_assert!(self.offset + self_len <= other.offset); - other.offset - (self.offset + self_len) + debug_assert_eq!(self.memory_index, other.memory_index); + debug_assert!(self.offset + self.len <= other.offset); + other.offset - (self.offset + self.len) } - /// Get a slice of the merged data for two consecutive data segments. - /// - /// # Safety - /// - /// Both `self` and `other` must be segments whose data are from the same - /// Wasm linear memory. + /// Merge two consecutive data segments. /// /// `self` must be in front of `other` and they must not overlap with each /// other. - unsafe fn merge(&self, other: &Self) -> &'a [u8] { - debug_assert_eq!(self.memory_index, other.memory_index); - + fn merge(&self, other: &Self) -> DataSegment { let gap = self.gap(other); - let gap = usize::try_from(gap).unwrap(); - - debug_assert_eq!( - self.data - .as_ptr() - .offset(isize::try_from(self.data.len() + gap).unwrap()), - other.data.as_ptr(), - ); - std::slice::from_raw_parts(self.data.as_ptr(), self.data.len() + gap + other.data.len()) + + DataSegment { + offset: self.offset, + len: self.len + gap + other.len, + ..*self + } } } @@ -72,14 +76,12 @@ impl<'a> DataSegment<'a> { /// defaults. // // TODO: when we support reference types, we will have to snapshot tables. -pub fn snapshot<'a>(store: &'a wasmtime::Store, instance: &wasmtime::Instance) -> Snapshot<'a> { +pub fn snapshot(ctx: &mut impl AsContextMut, instance: &wasmtime::Instance) -> Snapshot { log::debug!("Snapshotting the initialized state"); - assert!(wasmtime::Store::same(store, &instance.store())); - - let globals = snapshot_globals(instance); - let (memory_mins, data_segments) = snapshot_memories(instance); - let instantiations = snapshot_instantiations(store, instance); + let globals = snapshot_globals(&mut *ctx, instance); + let (memory_mins, data_segments) = snapshot_memories(&mut *ctx, instance); + let instantiations = snapshot_instantiations(&mut *ctx, instance); Snapshot { globals, @@ -90,16 +92,19 @@ pub fn snapshot<'a>(store: &'a wasmtime::Store, instance: &wasmtime::Instance) - } /// Get the initialized values of all globals. -fn snapshot_globals(instance: &wasmtime::Instance) -> Vec { +fn snapshot_globals( + ctx: &mut impl AsContextMut, + instance: &wasmtime::Instance, +) -> Vec { log::debug!("Snapshotting global values"); let mut globals = vec![]; let mut index = 0; loop { let name = format!("__wizer_global_{}", index); - match instance.get_global(&name) { + match instance.get_global(&mut *ctx, &name) { None => break, Some(global) => { - globals.push(global.get()); + globals.push(global.get(&mut *ctx)); index += 1; } } @@ -109,7 +114,10 @@ fn snapshot_globals(instance: &wasmtime::Instance) -> Vec { /// Find the initialized minimum page size of each memory, as well as all /// regions of non-zero memory. -fn snapshot_memories<'a>(instance: &wasmtime::Instance) -> (Vec, Vec>) { +fn snapshot_memories( + ctx: &mut impl AsContextMut, + instance: &wasmtime::Instance, +) -> (Vec, Vec) { log::debug!("Snapshotting memories"); // Find and record non-zero regions of memory (in parallel). @@ -118,20 +126,15 @@ fn snapshot_memories<'a>(instance: &wasmtime::Instance) -> (Vec, Vec break, Some(memory) => memory, }; - memory_mins.push(memory.size()); + memory_mins.push(memory.size(&*ctx)); - let num_wasm_pages = memory.size(); + let num_wasm_pages = memory.size(&*ctx); - let memory: &'a [u8] = unsafe { - // Safe because no one else has a (potentially mutable) - // view to this memory and we know the memory will live - // as long as the store is alive. - std::slice::from_raw_parts(memory.data_ptr(), memory.data_size()) - }; + let memory_data = memory.data(&*ctx); // Consider each Wasm page in parallel. Create data segments for each // region of non-zero memory. @@ -140,19 +143,23 @@ fn snapshot_memories<'a>(instance: &wasmtime::Instance) -> (Vec, Vec break, Some(i) => i, }; start += nonzero; - let end = memory[start..page_end] + let end = memory_data[start..page_end] .iter() .position(|byte| *byte == 0) .map_or(page_end, |zero| start + zero); segments.push(DataSegment { memory_index, - offset: start as u32, - data: &memory[start..end], + memory, + offset: u32::try_from(start).unwrap(), + len: u32::try_from(end - start).unwrap(), }); start = end; } @@ -199,8 +206,8 @@ fn snapshot_memories<'a>(instance: &wasmtime::Instance) -> (Vec, Vec(instance: &wasmtime::Instance) -> (Vec, Vec>) { +fn remove_excess_segments(merged_data_segments: &mut Vec) { if merged_data_segments.len() < MAX_DATA_SEGMENTS { return; } @@ -249,9 +256,8 @@ fn remove_excess_segments(merged_data_segments: &mut Vec>) { smallest_gaps.sort_unstable_by(|a, b| a.index.cmp(&b.index).reverse()); for GapIndex { index, .. } in smallest_gaps { let index = usize::try_from(index).unwrap(); - let merged_data = - unsafe { merged_data_segments[index].merge(&merged_data_segments[index + 1]) }; - merged_data_segments[index].data = merged_data; + let merged = merged_data_segments[index].merge(&merged_data_segments[index + 1]); + merged_data_segments[index] = merged; // Okay to use `swap_remove` here because, even though it makes // `merged_data_segments` unsorted, the segments are still sorted within @@ -266,18 +272,18 @@ fn remove_excess_segments(merged_data_segments: &mut Vec>) { merged_data_segments.sort_by_key(|s| (s.memory_index, s.offset)); } -fn snapshot_instantiations<'a>( - store: &'a wasmtime::Store, +fn snapshot_instantiations( + ctx: &mut impl AsContextMut, instance: &wasmtime::Instance, -) -> Vec> { +) -> Vec { log::debug!("Snapshotting nested instantiations"); let mut instantiations = vec![]; loop { let name = format!("__wizer_instance_{}", instantiations.len()); - match instance.get_export(&name) { + match instance.get_export(&mut *ctx, &name) { None => break, Some(wasmtime::Extern::Instance(instance)) => { - instantiations.push(snapshot(store, &instance)); + instantiations.push(snapshot(&mut *ctx, &instance)); } Some(_) => unreachable!(), } diff --git a/crates/wizer/tests/tests.rs b/crates/wizer/tests/tests.rs index c049dd6f5c03..9c00d8c5bb4c 100644 --- a/crates/wizer/tests/tests.rs +++ b/crates/wizer/tests/tests.rs @@ -33,28 +33,29 @@ fn run_wasm(args: &[wasmtime::Val], expected: i32, wasm: &[u8]) -> anyhow::Resul config.wasm_module_linking(true); let engine = wasmtime::Engine::new(&config)?; - let store = wasmtime::Store::new(&engine); + let wasi_ctx = wasi_cap_std_sync::WasiCtxBuilder::new().build(); + let mut store = wasmtime::Store::new(&engine, wasi_ctx); let module = wasmtime::Module::new(store.engine(), wasm).context("Wasm test case failed to compile")?; let dummy_module = wasmtime::Module::new(store.engine(), &wat::parse_str("(module)")?)?; - let dummy_instance = wasmtime::Instance::new(&store, &dummy_module, &[])?; + let dummy_instance = wasmtime::Instance::new(&mut store, &dummy_module, &[])?; - let mut linker = wasmtime::Linker::new(&store); + let mut linker = wasmtime::Linker::new(&engine); linker - .define_name("dummy_func", wasmtime::Func::wrap(&store, || {}))? - .define("env", "f", wasmtime::Func::wrap(&store, || {}))? + .define_name("dummy_func", wasmtime::Func::wrap(&mut store, || {}))? + .define("env", "f", wasmtime::Func::wrap(&mut store, || {}))? .define_name("dummy_instance", dummy_instance)?; - let ctx = wasi_cap_std_sync::WasiCtxBuilder::new().build(); - let wasi = wasmtime_wasi::Wasi::new(&store, ctx); - wasi.add_to_linker(&mut linker)?; - let instance = linker.instantiate(&module)?; + + wasmtime_wasi::add_to_linker(&mut linker, |wasi| wasi)?; + + let instance = linker.instantiate(&mut store, &module)?; let run = instance - .get_func("run") + .get_func(&mut store, "run") .ok_or_else(|| anyhow::anyhow!("the test Wasm module does not export a `run` function"))?; - let actual = run.call(args)?; + let actual = run.call(&mut store, args)?; anyhow::ensure!(actual.len() == 1, "expected one result"); let actual = match actual[0] { wasmtime::Val::I32(x) => x, From 7988f550c604063dc329910ea1c093c3dfe6705b Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Tue, 20 Jul 2021 14:25:33 -0700 Subject: [PATCH 070/212] Add link to wasm summit talk on Wizer --- crates/wizer/README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/crates/wizer/README.md b/crates/wizer/README.md index 554395cf04bc..0af45fd5c15d 100644 --- a/crates/wizer/README.md +++ b/crates/wizer/README.md @@ -146,3 +146,8 @@ initialization function. Then we record the Wasm instance's state: Then we rewrite the Wasm binary by intializing its globals directly to their recorded state, and removing the module's old data segments and replacing them with data segments for each of the non-zero regions of memory we recorded. + +Want some more details? Check out the talk ["Hit the Ground Running: Wasm +Snapshots for Fast Start +Up"](https://fitzgeraldnick.com/2021/05/10/wasm-summit-2021.html) from the 2021 +WebAssembly Summit. From ae2471aa364c91176864424f29f43d3935ec6cb8 Mon Sep 17 00:00:00 2001 From: Maxime Bedard Date: Wed, 4 Aug 2021 13:32:17 -0400 Subject: [PATCH 071/212] update wasmtime to 0.29 --- crates/wizer/Cargo.lock | 332 +++++++++++++++++++++++----------- crates/wizer/Cargo.toml | 6 +- crates/wizer/benches/regex.rs | 52 +++--- crates/wizer/benches/uap.rs | 63 +++---- crates/wizer/fuzz/Cargo.toml | 2 +- crates/wizer/src/lib.rs | 6 +- 6 files changed, 289 insertions(+), 172 deletions(-) diff --git a/crates/wizer/Cargo.lock b/crates/wizer/Cargo.lock index 50fa2dfaea01..c6aadba40001 100644 --- a/crates/wizer/Cargo.lock +++ b/crates/wizer/Cargo.lock @@ -4,9 +4,9 @@ version = 3 [[package]] name = "addr2line" -version = "0.15.2" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7a2e47a1fbe209ee101dd6d61285226744c6c8d3c21c8dc878ba6cb9f467f3a" +checksum = "3e61f2b7f93d2c7d2b08263acaa4a363b3e276806c68af6134c44f523bf1aacd" dependencies = [ "gimli", ] @@ -26,6 +26,12 @@ dependencies = [ "memchr", ] +[[package]] +name = "ambient-authority" +version = "0.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec8ad6edb4840b78c5c3d88de606b22252d552b55f3a4699fbb10fc070ec3049" + [[package]] name = "ansi_term" version = "0.11.0" @@ -80,9 +86,9 @@ checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" [[package]] name = "backtrace" -version = "0.3.60" +version = "0.3.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7815ea54e4d821e791162e078acbebfd6d8c8939cd559c9335dceb1c8ca7282" +checksum = "e7a905d892734eea339e896738c14b9afce22b5318f64b951e70bf3844419b01" dependencies = [ "addr2line", "cc", @@ -143,14 +149,14 @@ checksum = "9c59e7af012c713f529e7a3ee57ce9b31ddd858d4b512923602f74608b009631" [[package]] name = "cap-fs-ext" -version = "0.13.10" +version = "0.16.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff3a1e32332db9ad29d6da34693ce9a7ac26a9edf96abb5c1788d193410031ab" +checksum = "69402a517c39296432e46cee816c0d1cd1b7b5d4380eccdc1b6f056bcc2a0f08" dependencies = [ - "cap-primitives", - "cap-std", - "rustc_version 0.3.3", - "unsafe-io", + "cap-primitives 0.16.3", + "cap-std 0.16.3", + "io-lifetimes 0.2.0", + "rustc_version 0.4.0", "winapi", ] @@ -161,25 +167,47 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2d253b74de50b097594462618e7dd17b93b3e3bef19f32d2e512996f9095661f" dependencies = [ "errno", - "fs-set-times", + "fs-set-times 0.3.1", "ipnet", "libc", "maybe-owned", "once_cell", - "posish", + "posish 0.6.3", "rustc_version 0.3.3", - "unsafe-io", + "unsafe-io 0.6.12", + "winapi", + "winapi-util", + "winx 0.25.0", +] + +[[package]] +name = "cap-primitives" +version = "0.16.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b125e71bcf1e3fa14cddaff42ac9f5c279783146588c83831604ac5f9ad54ad" +dependencies = [ + "ambient-authority", + "errno", + "fs-set-times 0.6.0", + "io-lifetimes 0.2.0", + "ipnet", + "maybe-owned", + "once_cell", + "posish 0.16.4", + "rustc_version 0.4.0", + "unsafe-io 0.7.1", "winapi", "winapi-util", - "winx", + "winx 0.27.0", ] [[package]] name = "cap-rand" -version = "0.13.10" +version = "0.16.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "458e98ed00e4276d0ac60da888d80957a177dfa7efa8dbb3be59f1e2b0e02ae5" +checksum = "0baa8df304520077e895d98be27193fa5b6a9aff3a6fdd6e6c9dbf46c5354a23" dependencies = [ + "ambient-authority", "rand", ] @@ -189,22 +217,36 @@ version = "0.13.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7019d48ea53c5f378e0fdab0fe5f627fc00e76d65e75dffd6fb1cbc0c9b382ee" dependencies = [ - "cap-primitives", - "posish", + "cap-primitives 0.13.10", + "posish 0.6.3", "rustc_version 0.3.3", - "unsafe-io", + "unsafe-io 0.6.12", +] + +[[package]] +name = "cap-std" +version = "0.16.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e52811b9a742bf0430321fb193d6d37005609f770ed7b303f90604a19dc64f4c" +dependencies = [ + "cap-primitives 0.16.3", + "io-lifetimes 0.2.0", + "ipnet", + "posish 0.16.4", + "rustc_version 0.4.0", + "unsafe-io 0.7.1", ] [[package]] name = "cap-time-ext" -version = "0.13.10" +version = "0.16.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90585adeada7f804e6dcf71b8ff74217ad8742188fc870b9da5deab4722baa04" +checksum = "36d5a4732bc93b04b791053c69a05cd120ede893e71e26cc7ab206e9699cb177" dependencies = [ - "cap-primitives", + "cap-primitives 0.16.3", "once_cell", - "posish", - "winx", + "posish 0.16.4", + "winx 0.27.0", ] [[package]] @@ -267,18 +309,18 @@ dependencies = [ [[package]] name = "cranelift-bforest" -version = "0.75.0" +version = "0.76.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df3f8dd4f920a422c96c53fb6a91cc7932b865fdb60066ae9df7c329342d303f" +checksum = "7e6bea67967505247f54fa2c85cf4f6e0e31c4e5692c9b70e4ae58e339067333" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-codegen" -version = "0.75.0" +version = "0.76.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebe85f9a8dbf3c9dfa47ecb89828a7dc17c0b62015b84b5505fd4beba61c542c" +checksum = "48194035d2752bdd5bdae429e3ab88676e95f52a2b1355a5d4e809f9e39b1d74" dependencies = [ "cranelift-bforest", "cranelift-codegen-meta", @@ -294,9 +336,9 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.75.0" +version = "0.76.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12bc4be68da214a56bf9beea4212eb3b9eac16ca9f0b47762f907c4cd4684073" +checksum = "976efb22fcab4f2cd6bd4e9913764616a54d895c1a23530128d04e03633c555f" dependencies = [ "cranelift-codegen-shared", "cranelift-entity", @@ -304,27 +346,27 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" -version = "0.75.0" +version = "0.76.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0c87b69923825cfbc3efde17d929a68cd5b50a4016b2bd0eb8c3933cc5bd8cd" +checksum = "9dabb5fe66e04d4652e434195b45ae65b5c8172d520247b8f66d8df42b2b45dc" dependencies = [ "serde", ] [[package]] name = "cranelift-entity" -version = "0.75.0" +version = "0.76.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe683e7ec6e627facf44b2eab4b263507be4e7ef7ea06eb8cee5283d9b45370e" +checksum = "3329733e4d4b8e91c809efcaa4faee80bf66f20164e3dd16d707346bd3494799" dependencies = [ "serde", ] [[package]] name = "cranelift-frontend" -version = "0.75.0" +version = "0.76.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5da80025ca214f0118273f8b94c4790add3b776f0dc97afba6b711757497743b" +checksum = "279afcc0d3e651b773f94837c3d581177b348c8d69e928104b2e9fccb226f921" dependencies = [ "cranelift-codegen", "log", @@ -334,19 +376,20 @@ dependencies = [ [[package]] name = "cranelift-native" -version = "0.75.0" +version = "0.76.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1c0e8c56f9a63f352a64aaa9c9eef7c205008b03593af7b128a3fbc46eae7e9" +checksum = "4c04d1fe6a5abb5bb0edc78baa8ef238370fb8e389cc88b6d153f7c3e9680425" dependencies = [ "cranelift-codegen", + "libc", "target-lexicon", ] [[package]] name = "cranelift-wasm" -version = "0.75.0" +version = "0.76.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d10ddafc5f1230d2190eb55018fcdecfcce728c9c2b975f2690ef13691d18eb5" +checksum = "e0d260ad44f6fd2c91f7f5097191a2a9e3edcbb36df1fb787b600dad5ea148ec" dependencies = [ "cranelift-codegen", "cranelift-entity", @@ -356,7 +399,7 @@ dependencies = [ "serde", "smallvec", "thiserror", - "wasmparser 0.78.2", + "wasmparser 0.79.0", ] [[package]] @@ -448,6 +491,16 @@ dependencies = [ "lazy_static", ] +[[package]] +name = "cstr" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c11a39d776a3b35896711da8a04dc1835169dcd36f710878187637314e47941b" +dependencies = [ + "proc-macro2", + "quote", +] + [[package]] name = "csv" version = "1.1.6" @@ -602,8 +655,19 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "28f1ca01f517bba5770c067dc6c466d290b962e08214c8f2598db98d66087e55" dependencies = [ - "posish", - "unsafe-io", + "posish 0.6.3", + "unsafe-io 0.6.12", + "winapi", +] + +[[package]] +name = "fs-set-times" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56af20dae05f9fae64574ead745ced5f08ae7dc6f42b9facd93a43d4b7adf982" +dependencies = [ + "io-lifetimes 0.2.0", + "posish 0.16.4", "winapi", ] @@ -636,9 +700,9 @@ dependencies = [ [[package]] name = "gimli" -version = "0.24.0" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e4075386626662786ddb0ec9081e7c7eeb1ba31951f447ca780ef9f5d568189" +checksum = "f0a01e0497841a3b2db4f8afa483cce65f7e96a3498bd6c541734792aeac8fe7" dependencies = [ "fallible-iterator", "indexmap", @@ -718,6 +782,17 @@ dependencies = [ "winapi", ] +[[package]] +name = "io-lifetimes" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78d009010297118b0a443fef912b92e3482e6e6f46ab31e5d60f68b39a553ca9" +dependencies = [ + "libc", + "rustc_version 0.4.0", + "winapi", +] + [[package]] name = "ipnet" version = "2.3.1" @@ -801,6 +876,12 @@ version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7fb9b38af92608140b86b693604b9ffcc5824240a484d1ecd4795bacb2fe88f3" +[[package]] +name = "linux-raw-sys" +version = "0.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58ae91cec8978ea160429d0609ec47da5d65a858725701b77df198ecf985d6bd" + [[package]] name = "log" version = "0.4.14" @@ -877,9 +958,9 @@ dependencies = [ [[package]] name = "object" -version = "0.25.3" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a38f2be3697a57b4060074ff41b44c16870d916ad7877c17696e063257482bc7" +checksum = "c55827317fb4c08822499848a14237d2874d6f139828893017237e7ab93eb386" dependencies = [ "crc32fast", "indexmap", @@ -964,7 +1045,25 @@ dependencies = [ "errno", "itoa", "libc", - "unsafe-io", + "unsafe-io 0.6.12", +] + +[[package]] +name = "posish" +version = "0.16.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "694eb323d25f129d533cdff030813ccfd708170f46625c238839941f50372d2e" +dependencies = [ + "bitflags", + "cc", + "cstr", + "errno", + "io-lifetimes 0.2.0", + "itoa", + "libc", + "linux-raw-sys", + "once_cell", + "rustc_version 0.4.0", ] [[package]] @@ -1400,19 +1499,19 @@ dependencies = [ [[package]] name = "system-interface" -version = "0.6.6" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef194146527a71113b76650b19c509b6537aa20b91f6702f1933e7b96b347736" +checksum = "7adf9f33595b165d9d2897c548750a1141fc531a2492f7d365b71190c063e836" dependencies = [ "atty", "bitflags", "cap-fs-ext", - "cap-std", - "posish", + "cap-std 0.16.3", + "io-lifetimes 0.2.0", + "posish 0.16.4", "rustc_version 0.4.0", - "unsafe-io", "winapi", - "winx", + "winx 0.27.0", ] [[package]] @@ -1556,11 +1655,22 @@ version = "0.6.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1598c579f79cdd11e677b3942b7bed5cb3369464cfd240f4c4a308ffaed6f5e4" dependencies = [ - "io-lifetimes", + "io-lifetimes 0.1.1", "rustc_version 0.3.3", "winapi", ] +[[package]] +name = "unsafe-io" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f56d1d7067d6e88dfdede7f668ea51800785fc8fcaf82d8fecdeaa678491e629" +dependencies = [ + "io-lifetimes 0.2.0", + "rustc_version 0.4.0", + "winapi", +] + [[package]] name = "vec_map" version = "0.8.2" @@ -1592,38 +1702,39 @@ checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" [[package]] name = "wasi-cap-std-sync" -version = "0.28.0" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54ed414ed6ff3b95653ea07b237cf03c513015d94169aac159755e05a2eaa80f" +checksum = "6e16618e7792b042b3ed0fdc93bcd6d7e272290d4fc73228334af91f6e0084a0" dependencies = [ "anyhow", "async-trait", "bitflags", "cap-fs-ext", "cap-rand", - "cap-std", + "cap-std 0.16.3", "cap-time-ext", - "fs-set-times", + "fs-set-times 0.6.0", + "io-lifetimes 0.2.0", "lazy_static", - "libc", + "posish 0.16.4", "system-interface", "tracing", - "unsafe-io", "wasi-common", "winapi", ] [[package]] name = "wasi-common" -version = "0.28.0" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c67b1e49ae6d9bcab37a6f13594aed98d8ab8f5c2117b3bed543d8019688733" +checksum = "30e106f32f2af1c50386bf75376f63705a45ed51d4f6a510cb300bf5dc0126e5" dependencies = [ "anyhow", "bitflags", "cap-rand", - "cap-std", - "libc", + "cap-std 0.16.3", + "io-lifetimes 0.2.0", + "posish 0.16.4", "thiserror", "tracing", "wiggle", @@ -1729,9 +1840,9 @@ dependencies = [ [[package]] name = "wasmtime" -version = "0.28.0" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56828b11cd743a0e9b4207d1c7a8c1a66cb32d14601df10422072802a6aee86c" +checksum = "8bbb8a082a8ef50f7eeb8b82dda9709ef1e68963ea3c94e45581644dd4041835" dependencies = [ "anyhow", "backtrace", @@ -1749,7 +1860,7 @@ dependencies = [ "serde", "smallvec", "target-lexicon", - "wasmparser 0.78.2", + "wasmparser 0.79.0", "wasmtime-cache", "wasmtime-environ", "wasmtime-fiber", @@ -1762,9 +1873,9 @@ dependencies = [ [[package]] name = "wasmtime-cache" -version = "0.28.0" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99aca6335ad194d795342137a92afaec9338a2bfcf4caa4c667b5ece16c2bfa9" +checksum = "d73391579ca7f24573138ef768b73b2aed5f9d542385c64979b65d60d0912399" dependencies = [ "anyhow", "base64", @@ -1783,24 +1894,24 @@ dependencies = [ [[package]] name = "wasmtime-cranelift" -version = "0.28.0" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "519fa80abe29dc46fc43177cbe391e38c8613c59229c8d1d90d7f226c3c7cede" +checksum = "81c6f5ae9205382345c7cd7454932a906186836999a2161c385e38a15f52e1fe" dependencies = [ "cranelift-codegen", "cranelift-entity", "cranelift-frontend", "cranelift-wasm", "target-lexicon", - "wasmparser 0.78.2", + "wasmparser 0.79.0", "wasmtime-environ", ] [[package]] name = "wasmtime-debug" -version = "0.28.0" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ddf6e9bca2f3bc1dd499db2a93d35c735176cff0de7daacdc18c3794f7082e0" +checksum = "c69e08f55e12f15f50b1b533bc3626723e7224254a065de6576934c86258c9e8" dependencies = [ "anyhow", "gimli", @@ -1808,15 +1919,15 @@ dependencies = [ "object", "target-lexicon", "thiserror", - "wasmparser 0.78.2", + "wasmparser 0.79.0", "wasmtime-environ", ] [[package]] name = "wasmtime-environ" -version = "0.28.0" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a991635b1cf1d1336fbea7a5f2c0e1dafaa54cb21c632d8414885278fa5d1b1" +checksum = "005d93174040af37fb8625f891cd9827afdad314261f7ec4ee61ec497d6e9d3c" dependencies = [ "cfg-if", "cranelift-codegen", @@ -1828,14 +1939,14 @@ dependencies = [ "more-asserts", "serde", "thiserror", - "wasmparser 0.78.2", + "wasmparser 0.79.0", ] [[package]] name = "wasmtime-fiber" -version = "0.28.0" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ab6bb95303636d1eba6f7fd2b67c1cd583f73303c73b1a3259b46bb1c2eb299" +checksum = "afa8d00a477a43848dc84cb83f097e8dc8aacd57fd4e763f232416aa27cb137c" dependencies = [ "cc", "libc", @@ -1844,9 +1955,9 @@ dependencies = [ [[package]] name = "wasmtime-jit" -version = "0.28.0" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f33a0ae79b7c8d050156b22e10fdc49dfb09cc482c251d12bf10e8a833498fb" +checksum = "d0bf1dfb213a35d8f21aefae40e597fe72778a907011ffdff7affb029a02af9a" dependencies = [ "addr2line", "anyhow", @@ -1865,7 +1976,7 @@ dependencies = [ "serde", "target-lexicon", "thiserror", - "wasmparser 0.78.2", + "wasmparser 0.79.0", "wasmtime-cranelift", "wasmtime-debug", "wasmtime-environ", @@ -1877,9 +1988,9 @@ dependencies = [ [[package]] name = "wasmtime-obj" -version = "0.28.0" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a879f03d416615f322dcb3aa5cb4cbc47b64b12be6aa235a64ab63a4281d50a" +checksum = "d231491878e710c68015228c9f9fc5955fe5c96dbf1485c15f7bed55b622c83c" dependencies = [ "anyhow", "more-asserts", @@ -1891,9 +2002,9 @@ dependencies = [ [[package]] name = "wasmtime-profiling" -version = "0.28.0" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "171ae3107e8502667b16d336a1dd03e370aa6630a1ce26559aba572ade1031d1" +checksum = "21486cfb5255c2069666c1f116f9e949d4e35c9a494f11112fa407879e42198d" dependencies = [ "anyhow", "cfg-if", @@ -1910,9 +2021,9 @@ dependencies = [ [[package]] name = "wasmtime-runtime" -version = "0.28.0" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0404e10f8b07f940be42aa4b8785b4ab42e96d7167ccc92e35d36eee040309c2" +checksum = "d7ddfdf32e0a20d81f48be9dacd31612bc61de5a174d1356fef806d300f507de" dependencies = [ "anyhow", "backtrace", @@ -1935,9 +2046,9 @@ dependencies = [ [[package]] name = "wasmtime-wasi" -version = "0.28.0" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39d75f21122ec134c8bfc8840a8742c0d406a65560fb9716b23800bd7cfd6ae5" +checksum = "37ad5c1b8c8e5720dc2580818d34210792a93b3892cd2da90b152b51c73716dc" dependencies = [ "anyhow", "wasi-cap-std-sync", @@ -1985,9 +2096,9 @@ dependencies = [ [[package]] name = "wiggle" -version = "0.28.0" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79ca01f1388a549eb3eaa221a072c3cfd3e383618ec6b423e82f2734ee28dd40" +checksum = "7cf200553298de4898eed65b047b4dfa315cb027f3873d20c62abb871f5b3314" dependencies = [ "anyhow", "async-trait", @@ -2000,9 +2111,9 @@ dependencies = [ [[package]] name = "wiggle-generate" -version = "0.28.0" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "544fd41029c33b179656ab1674cd813db7cd473f38f1976ae6e08effb46dd269" +checksum = "39f96d7da4bf1b09c9a8aa02643462cf43b21126c410aa72e4e39601389c180f" dependencies = [ "anyhow", "heck", @@ -2015,9 +2126,9 @@ dependencies = [ [[package]] name = "wiggle-macro" -version = "0.28.0" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e31ae77a274c9800e6f1342fa4a6dde5e2d72eb9d9b2e0418781be6efc35b58" +checksum = "2593ede4cf0e8f6a4dcd118013399c977047f0f7d549991490b508604dde8634" dependencies = [ "proc-macro2", "quote", @@ -2067,6 +2178,17 @@ dependencies = [ "winapi", ] +[[package]] +name = "winx" +version = "0.27.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc8ca6af61cfeed1e071b19f44cf4a7683addd863f28fef69cdf251bc034050e" +dependencies = [ + "bitflags", + "io-lifetimes 0.2.0", + "winapi", +] + [[package]] name = "witx" version = "0.9.1" @@ -2084,7 +2206,7 @@ name = "wizer" version = "1.3.3" dependencies = [ "anyhow", - "cap-std", + "cap-std 0.13.10", "criterion", "env_logger 0.8.4", "log", @@ -2123,18 +2245,18 @@ dependencies = [ [[package]] name = "zstd" -version = "0.6.1+zstd.1.4.9" +version = "0.9.0+zstd.1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5de55e77f798f205d8561b8fe2ef57abfb6e0ff2abe7fd3c089e119cdb5631a3" +checksum = "07749a5dc2cb6b36661290245e350f15ec3bbb304e493db54a1d354480522ccd" dependencies = [ "zstd-safe", ] [[package]] name = "zstd-safe" -version = "3.0.1+zstd.1.4.9" +version = "4.1.1+zstd.1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1387cabcd938127b30ce78c4bf00b30387dddf704e3f0881dbc4ff62b5566f8c" +checksum = "c91c90f2c593b003603e5e0493c837088df4469da25aafff8bce42ba48caf079" dependencies = [ "libc", "zstd-sys", @@ -2142,9 +2264,9 @@ dependencies = [ [[package]] name = "zstd-sys" -version = "1.4.20+zstd.1.4.9" +version = "1.6.1+zstd.1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebd5b733d7cf2d9447e2c3e76a5589b4f5e5ae065c22a2bc0b023cbc331b6c8e" +checksum = "615120c7a2431d16cf1cf979e7fc31ba7a5b5e5707b29c8a99e5dbf8a8392a33" dependencies = [ "cc", "libc", diff --git a/crates/wizer/Cargo.toml b/crates/wizer/Cargo.toml index 7d72649fefef..958fd35dfd53 100644 --- a/crates/wizer/Cargo.toml +++ b/crates/wizer/Cargo.toml @@ -32,11 +32,11 @@ env_logger = { version = "0.8.2", optional = true } log = "0.4.14" rayon = "1.5.0" structopt = { version = "0.3.21", optional = true } -wasi-cap-std-sync = "0.28.0" +wasi-cap-std-sync = "0.29.0" wasm-encoder = "0.4.0" wasmparser = "0.78.2" -wasmtime = "0.28.0" -wasmtime-wasi = "0.28.0" +wasmtime = "0.29.0" +wasmtime-wasi = "0.29.0" # Enable this dependency to get messages with WAT disassemblies when certain # internal panics occur. diff --git a/crates/wizer/benches/regex.rs b/crates/wizer/benches/regex.rs index f4b17ebf2717..51de568e2fdd 100644 --- a/crates/wizer/benches/regex.rs +++ b/crates/wizer/benches/regex.rs @@ -1,17 +1,21 @@ use criterion::{criterion_group, criterion_main, Criterion}; use std::convert::TryFrom; -fn run_iter(linker: &wasmtime::Linker, module: &wasmtime::Module) { - let instance = linker.instantiate(module).unwrap(); +fn run_iter( + linker: &wasmtime::Linker, + module: &wasmtime::Module, + mut store: &mut wasmtime::Store +) { + let instance = linker.instantiate(&mut store, module).unwrap(); - let memory = instance.get_memory("memory").unwrap(); - let data = unsafe { memory.data_unchecked_mut() }; + let memory = instance.get_memory(&mut store, "memory").unwrap(); + let data = memory.data_mut(&mut store); let ptr = data.len() - 5; data[ptr..].copy_from_slice(b"hello"); - let run = instance.get_func("run").unwrap(); + let run = instance.get_func(&mut store, "run").unwrap(); let result = run - .call(&[ + .call(&mut store, &[ wasmtime::Val::I32(i32::try_from(ptr).unwrap()), wasmtime::Val::I32(5), ]) @@ -20,31 +24,27 @@ fn run_iter(linker: &wasmtime::Linker, module: &wasmtime::Module) { assert_eq!(result[0].i32(), Some(0)); } -fn linker(store: &wasmtime::Store) -> wasmtime::Linker { - let mut linker = wasmtime::Linker::new(&store); - let ctx = wasmtime_wasi::WasiCtx::new(None::).unwrap(); - let wasi = wasmtime_wasi::Wasi::new(&store, ctx); - wasi.add_to_linker(&mut linker).unwrap(); - linker -} - fn bench_regex(c: &mut Criterion) { let mut group = c.benchmark_group("regex"); group.bench_function("control", |b| { - let store = wasmtime::Store::default(); - let module = - wasmtime::Module::new(store.engine(), &include_bytes!("regex_bench.control.wasm")) - .unwrap(); - let linker = linker(&store); - b.iter(|| run_iter(&linker, &module)); + let engine = wasmtime::Engine::default(); + let wasi = wasmtime_wasi::WasiCtxBuilder::new().build(); + let mut store = wasmtime::Store::new(&engine, wasi); + let module = wasmtime::Module::new(store.engine(), &include_bytes!("regex_bench.control.wasm")).unwrap(); + let mut linker = wasmtime::Linker::new(&engine); + wasmtime_wasi::sync::add_to_linker(&mut linker, |s| s).unwrap(); + + b.iter(|| run_iter(&linker, &module, &mut store)); }); group.bench_function("wizer", |b| { - let store = wasmtime::Store::default(); - let module = - wasmtime::Module::new(store.engine(), &include_bytes!("regex_bench.wizer.wasm")) - .unwrap(); - let linker = linker(&store); - b.iter(|| run_iter(&linker, &module)); + let engine = wasmtime::Engine::default(); + let wasi = wasmtime_wasi::WasiCtxBuilder::new().build(); + let mut store = wasmtime::Store::new(&engine, wasi); + let module = wasmtime::Module::new(store.engine(), &include_bytes!("regex_bench.control.wasm")).unwrap(); + let mut linker = wasmtime::Linker::new(&engine); + wasmtime_wasi::sync::add_to_linker(&mut linker, |s| s).unwrap(); + + b.iter(|| run_iter(&linker, &module, &mut store)); }); group.finish(); } diff --git a/crates/wizer/benches/uap.rs b/crates/wizer/benches/uap.rs index 1ffef7043056..7109143beb22 100644 --- a/crates/wizer/benches/uap.rs +++ b/crates/wizer/benches/uap.rs @@ -1,25 +1,27 @@ use criterion::{criterion_group, criterion_main, Criterion}; use std::convert::TryFrom; -fn run_iter(linker: &wasmtime::Linker, module: &wasmtime::Module) { - let instance = linker.instantiate(module).unwrap(); +fn run_iter( + linker: &wasmtime::Linker, + module: &wasmtime::Module, + mut store: &mut wasmtime::Store, +) { + let instance = linker.instantiate(&mut store, module).unwrap(); let ua = "Mozilla/5.0 (X11; Linux x86_64; rv:85.0) Gecko/20100101 Firefox/85.0"; let alloc = instance - .get_func("alloc") - .unwrap() - .get2::() + .get_typed_func::<(u32, u32), u32, _>(&mut store, "alloc") .unwrap(); - let ptr = alloc(ua.len() as u32, 1).unwrap() as usize; + let ptr = alloc.call(&mut store, (ua.len() as u32, 1)).unwrap() as usize; - let memory = instance.get_memory("memory").unwrap(); - let data = unsafe { memory.data_unchecked_mut() }; + let memory = instance.get_memory(&mut store, "memory").unwrap(); + let data = memory.data_mut(&mut store); data[ptr..ptr + ua.len()].copy_from_slice(ua.as_bytes()); - let run = instance.get_func("run").unwrap(); + let run = instance.get_func(&mut store, "run").unwrap(); let result = run - .call(&[ + .call(&mut store, &[ wasmtime::Val::I32(i32::try_from(ptr).unwrap()), wasmtime::Val::I32(5), ]) @@ -28,37 +30,32 @@ fn run_iter(linker: &wasmtime::Linker, module: &wasmtime::Module) { assert_eq!(result[0].i32(), Some(0)); let dealloc = instance - .get_func("dealloc") - .unwrap() - .get3::() + .get_typed_func::<(u32, u32, u32), (), _>(&mut store, "dealloc") .unwrap(); - dealloc(ptr as u32, ua.len() as u32, 1).unwrap(); -} - -fn linker(store: &wasmtime::Store) -> wasmtime::Linker { - let mut linker = wasmtime::Linker::new(&store); - let ctx = wasmtime_wasi::WasiCtx::new(None::).unwrap(); - let wasi = wasmtime_wasi::Wasi::new(&store, ctx); - wasi.add_to_linker(&mut linker).unwrap(); - linker + dealloc.call(&mut store, (ptr as u32, ua.len() as u32, 1)).unwrap(); } fn bench_uap(c: &mut Criterion) { let mut group = c.benchmark_group("uap"); group.bench_function("control", |b| { - let store = wasmtime::Store::default(); - let module = - wasmtime::Module::new(store.engine(), &include_bytes!("uap_bench.control.wasm")) - .unwrap(); - let linker = linker(&store); - b.iter(|| run_iter(&linker, &module)); + let engine = wasmtime::Engine::default(); + let wasi = wasmtime_wasi::WasiCtxBuilder::new().build(); + let mut store = wasmtime::Store::new(&engine, wasi); + let module = wasmtime::Module::new(store.engine(), &include_bytes!("uap_bench.control.wasm")).unwrap(); + let mut linker = wasmtime::Linker::new(&engine); + wasmtime_wasi::sync::add_to_linker(&mut linker, |s| s).unwrap(); + + b.iter(|| run_iter(&linker, &module, &mut store)); }); group.bench_function("wizer", |b| { - let store = wasmtime::Store::default(); - let module = - wasmtime::Module::new(store.engine(), &include_bytes!("uap_bench.wizer.wasm")).unwrap(); - let linker = linker(&store); - b.iter(|| run_iter(&linker, &module)); + let engine = wasmtime::Engine::default(); + let wasi = wasmtime_wasi::WasiCtxBuilder::new().build(); + let mut store = wasmtime::Store::new(&engine, wasi); + let module =wasmtime::Module::new(store.engine(), &include_bytes!("uap_bench.wizer.wasm")).unwrap(); + let mut linker = wasmtime::Linker::new(&engine); + wasmtime_wasi::sync::add_to_linker(&mut linker, |s| s).unwrap(); + + b.iter(|| run_iter(&linker, &module, &mut store)); }); group.finish(); } diff --git a/crates/wizer/fuzz/Cargo.toml b/crates/wizer/fuzz/Cargo.toml index f7f40fcac31f..89295f8e5dd1 100644 --- a/crates/wizer/fuzz/Cargo.toml +++ b/crates/wizer/fuzz/Cargo.toml @@ -15,7 +15,7 @@ libfuzzer-sys = "0.4" log = "0.4.14" wasm-smith = "0.4.0" wasmprinter = "0.2.26" -wasmtime = "0.28.0" +wasmtime = "0.29.0" [dependencies.wizer] path = ".." diff --git a/crates/wizer/src/lib.rs b/crates/wizer/src/lib.rs index b25115e662b7..125fc0d19ad5 100644 --- a/crates/wizer/src/lib.rs +++ b/crates/wizer/src/lib.rs @@ -531,10 +531,8 @@ impl Wizer { } for dir in &self.dirs { log::debug!("Preopening directory: {}", dir.display()); - let preopened = unsafe { - cap_std::fs::Dir::open_ambient_dir(dir) - .with_context(|| format!("failed to open directory: {}", dir.display()))? - }; + let preopened = wasmtime_wasi::sync::Dir::open_ambient_dir(dir, wasmtime_wasi::sync::ambient_authority()) + .with_context(|| format!("failed to open directory: {}", dir.display()))?; ctx = ctx.preopened_dir(preopened, dir)?; } Ok(Some(ctx.build())) From f6856085563197273945b2c2f50b99518ac2e0fc Mon Sep 17 00:00:00 2001 From: Maxime Bedard Date: Wed, 4 Aug 2021 13:32:43 -0400 Subject: [PATCH 072/212] fmt --- crates/wizer/benches/regex.rs | 21 ++++++++++++++------- crates/wizer/benches/uap.rs | 22 +++++++++++++++------- crates/wizer/src/lib.rs | 7 +++++-- 3 files changed, 34 insertions(+), 16 deletions(-) diff --git a/crates/wizer/benches/regex.rs b/crates/wizer/benches/regex.rs index 51de568e2fdd..9324e755a999 100644 --- a/crates/wizer/benches/regex.rs +++ b/crates/wizer/benches/regex.rs @@ -4,7 +4,7 @@ use std::convert::TryFrom; fn run_iter( linker: &wasmtime::Linker, module: &wasmtime::Module, - mut store: &mut wasmtime::Store + mut store: &mut wasmtime::Store, ) { let instance = linker.instantiate(&mut store, module).unwrap(); @@ -15,10 +15,13 @@ fn run_iter( let run = instance.get_func(&mut store, "run").unwrap(); let result = run - .call(&mut store, &[ - wasmtime::Val::I32(i32::try_from(ptr).unwrap()), - wasmtime::Val::I32(5), - ]) + .call( + &mut store, + &[ + wasmtime::Val::I32(i32::try_from(ptr).unwrap()), + wasmtime::Val::I32(5), + ], + ) .unwrap(); assert_eq!(result.len(), 1); assert_eq!(result[0].i32(), Some(0)); @@ -30,7 +33,9 @@ fn bench_regex(c: &mut Criterion) { let engine = wasmtime::Engine::default(); let wasi = wasmtime_wasi::WasiCtxBuilder::new().build(); let mut store = wasmtime::Store::new(&engine, wasi); - let module = wasmtime::Module::new(store.engine(), &include_bytes!("regex_bench.control.wasm")).unwrap(); + let module = + wasmtime::Module::new(store.engine(), &include_bytes!("regex_bench.control.wasm")) + .unwrap(); let mut linker = wasmtime::Linker::new(&engine); wasmtime_wasi::sync::add_to_linker(&mut linker, |s| s).unwrap(); @@ -40,7 +45,9 @@ fn bench_regex(c: &mut Criterion) { let engine = wasmtime::Engine::default(); let wasi = wasmtime_wasi::WasiCtxBuilder::new().build(); let mut store = wasmtime::Store::new(&engine, wasi); - let module = wasmtime::Module::new(store.engine(), &include_bytes!("regex_bench.control.wasm")).unwrap(); + let module = + wasmtime::Module::new(store.engine(), &include_bytes!("regex_bench.control.wasm")) + .unwrap(); let mut linker = wasmtime::Linker::new(&engine); wasmtime_wasi::sync::add_to_linker(&mut linker, |s| s).unwrap(); diff --git a/crates/wizer/benches/uap.rs b/crates/wizer/benches/uap.rs index 7109143beb22..ddfb862d6854 100644 --- a/crates/wizer/benches/uap.rs +++ b/crates/wizer/benches/uap.rs @@ -21,10 +21,13 @@ fn run_iter( let run = instance.get_func(&mut store, "run").unwrap(); let result = run - .call(&mut store, &[ - wasmtime::Val::I32(i32::try_from(ptr).unwrap()), - wasmtime::Val::I32(5), - ]) + .call( + &mut store, + &[ + wasmtime::Val::I32(i32::try_from(ptr).unwrap()), + wasmtime::Val::I32(5), + ], + ) .unwrap(); assert_eq!(result.len(), 1); assert_eq!(result[0].i32(), Some(0)); @@ -32,7 +35,9 @@ fn run_iter( let dealloc = instance .get_typed_func::<(u32, u32, u32), (), _>(&mut store, "dealloc") .unwrap(); - dealloc.call(&mut store, (ptr as u32, ua.len() as u32, 1)).unwrap(); + dealloc + .call(&mut store, (ptr as u32, ua.len() as u32, 1)) + .unwrap(); } fn bench_uap(c: &mut Criterion) { @@ -41,7 +46,9 @@ fn bench_uap(c: &mut Criterion) { let engine = wasmtime::Engine::default(); let wasi = wasmtime_wasi::WasiCtxBuilder::new().build(); let mut store = wasmtime::Store::new(&engine, wasi); - let module = wasmtime::Module::new(store.engine(), &include_bytes!("uap_bench.control.wasm")).unwrap(); + let module = + wasmtime::Module::new(store.engine(), &include_bytes!("uap_bench.control.wasm")) + .unwrap(); let mut linker = wasmtime::Linker::new(&engine); wasmtime_wasi::sync::add_to_linker(&mut linker, |s| s).unwrap(); @@ -51,7 +58,8 @@ fn bench_uap(c: &mut Criterion) { let engine = wasmtime::Engine::default(); let wasi = wasmtime_wasi::WasiCtxBuilder::new().build(); let mut store = wasmtime::Store::new(&engine, wasi); - let module =wasmtime::Module::new(store.engine(), &include_bytes!("uap_bench.wizer.wasm")).unwrap(); + let module = + wasmtime::Module::new(store.engine(), &include_bytes!("uap_bench.wizer.wasm")).unwrap(); let mut linker = wasmtime::Linker::new(&engine); wasmtime_wasi::sync::add_to_linker(&mut linker, |s| s).unwrap(); diff --git a/crates/wizer/src/lib.rs b/crates/wizer/src/lib.rs index 125fc0d19ad5..43481ee4bc78 100644 --- a/crates/wizer/src/lib.rs +++ b/crates/wizer/src/lib.rs @@ -531,8 +531,11 @@ impl Wizer { } for dir in &self.dirs { log::debug!("Preopening directory: {}", dir.display()); - let preopened = wasmtime_wasi::sync::Dir::open_ambient_dir(dir, wasmtime_wasi::sync::ambient_authority()) - .with_context(|| format!("failed to open directory: {}", dir.display()))?; + let preopened = wasmtime_wasi::sync::Dir::open_ambient_dir( + dir, + wasmtime_wasi::sync::ambient_authority(), + ) + .with_context(|| format!("failed to open directory: {}", dir.display()))?; ctx = ctx.preopened_dir(preopened, dir)?; } Ok(Some(ctx.build())) From 0bc58295da67e47a69f2a3a7c9464abaa4f6b39e Mon Sep 17 00:00:00 2001 From: Maxime Bedard Date: Wed, 4 Aug 2021 16:31:11 -0400 Subject: [PATCH 073/212] check benches on CI --- crates/wizer/.github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/wizer/.github/workflows/ci.yml b/crates/wizer/.github/workflows/ci.yml index 47f4daaed14b..913d4c36f5cb 100644 --- a/crates/wizer/.github/workflows/ci.yml +++ b/crates/wizer/.github/workflows/ci.yml @@ -18,6 +18,8 @@ jobs: run: cargo build --verbose - name: Run tests run: cargo test --verbose + - name: Checking benches + run : cargo check --benches rustfmt: runs-on: ubuntu-latest From 3972bc13d1b981e78c8dfcdaa3ecf09956e3ad93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C3=BAl=20Cabrera?= Date: Mon, 6 Sep 2021 19:26:12 -0400 Subject: [PATCH 074/212] docs: Fix typo --- crates/wizer/src/instrument.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/wizer/src/instrument.rs b/crates/wizer/src/instrument.rs index 37aeb6e47bb0..377cbabac99a 100644 --- a/crates/wizer/src/instrument.rs +++ b/crates/wizer/src/instrument.rs @@ -55,7 +55,7 @@ use wasm_encoder::SectionId; /// ``` /// /// NB: we re-export nested instantiations as a whole instance export because we -/// can do this without disturbing existing isntances' indices. If we were to +/// can do this without disturbing existing instances' indices. If we were to /// export their memories and globals individually, that would disturb the /// modules locally defined memoryies' and globals' indices, which would require /// rewriting the code section, which would break debug info offsets. From 8a48a71f0b6e4ba0c151d8519128bcea1ea63c5e Mon Sep 17 00:00:00 2001 From: Till Schneidereit Date: Sun, 19 Sep 2021 12:07:08 +0200 Subject: [PATCH 075/212] Update wasmtime to 0.30.0 and wasm-encoder to 0.6.0 This requires some changes because of tweaked APIs, but nothing too bad, I think. --- crates/wizer/Cargo.lock | 663 ++++++++++++++++------------------ crates/wizer/Cargo.toml | 8 +- crates/wizer/fuzz/Cargo.toml | 2 +- crates/wizer/src/dummy.rs | 48 +-- crates/wizer/src/rewrite.rs | 8 +- crates/wizer/src/snapshot.rs | 6 +- crates/wizer/src/translate.rs | 14 +- 7 files changed, 349 insertions(+), 400 deletions(-) diff --git a/crates/wizer/Cargo.lock b/crates/wizer/Cargo.lock index c6aadba40001..8ec02dfd1e3a 100644 --- a/crates/wizer/Cargo.lock +++ b/crates/wizer/Cargo.lock @@ -43,24 +43,24 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.41" +version = "1.0.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15af2628f6890fe2609a3b91bef4c83450512802e59489f9c1cb1fa5df064a61" +checksum = "61604a8f862e1d5c3229fdd78f8b02c68dcf73a4c4b05fd636d12240aaa242c1" [[package]] name = "arbitrary" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "237430fd6ed3740afe94eefcc278ae21e050285be882804e0d6e8695f0c94691" +checksum = "577b08a4acd7b99869f863c50011b01eb73424ccc798ecd996f2e24817adfca7" dependencies = [ "derive_arbitrary", ] [[package]] name = "async-trait" -version = "0.1.50" +version = "0.1.51" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b98e84bbb4cbcdd97da190ba0c58a1bb0de2c1fdf67d159e192ed766aeca722" +checksum = "44318e776df68115a881de9a8fd1b9e53368d7a4a5ce4cc48517da3393233a5e" dependencies = [ "proc-macro2", "quote", @@ -116,9 +116,9 @@ dependencies = [ [[package]] name = "bitflags" -version = "1.2.1" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "block-buffer" @@ -143,19 +143,19 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.7.0" +version = "3.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c59e7af012c713f529e7a3ee57ce9b31ddd858d4b512923602f74608b009631" +checksum = "d9df67f7bf9ef8498769f994239c45613ef0c5899415fb58e9add412d2c1a538" [[package]] name = "cap-fs-ext" -version = "0.16.3" +version = "0.19.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69402a517c39296432e46cee816c0d1cd1b7b5d4380eccdc1b6f056bcc2a0f08" +checksum = "1bf5c3b436b94a1adac74032ff35d8aa5bae6ec2a7900e76432c9ae8dac4d673" dependencies = [ - "cap-primitives 0.16.3", - "cap-std 0.16.3", - "io-lifetimes 0.2.0", + "cap-primitives 0.19.1", + "cap-std 0.19.1", + "io-lifetimes 0.3.1", "rustc_version 0.4.0", "winapi", ] @@ -172,7 +172,7 @@ dependencies = [ "libc", "maybe-owned", "once_cell", - "posish 0.6.3", + "posish", "rustc_version 0.3.3", "unsafe-io 0.6.12", "winapi", @@ -182,30 +182,30 @@ dependencies = [ [[package]] name = "cap-primitives" -version = "0.16.3" +version = "0.19.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b125e71bcf1e3fa14cddaff42ac9f5c279783146588c83831604ac5f9ad54ad" +checksum = "b51bd736eec54ae6552d18b0c958885b01d88c84c5fe6985e28c2b57ff385e94" dependencies = [ "ambient-authority", "errno", - "fs-set-times 0.6.0", - "io-lifetimes 0.2.0", + "fs-set-times 0.12.0", + "io-lifetimes 0.3.1", "ipnet", "maybe-owned", "once_cell", - "posish 0.16.4", + "rsix 0.23.3", "rustc_version 0.4.0", - "unsafe-io 0.7.1", + "unsafe-io 0.9.1", "winapi", "winapi-util", - "winx 0.27.0", + "winx 0.29.1", ] [[package]] name = "cap-rand" -version = "0.16.3" +version = "0.19.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0baa8df304520077e895d98be27193fa5b6a9aff3a6fdd6e6c9dbf46c5354a23" +checksum = "6e6e89d00b0cebeb6da7a459b81e6a49cf2092cc4afe03f28eb99b8f0e889344" dependencies = [ "ambient-authority", "rand", @@ -218,51 +218,51 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7019d48ea53c5f378e0fdab0fe5f627fc00e76d65e75dffd6fb1cbc0c9b382ee" dependencies = [ "cap-primitives 0.13.10", - "posish 0.6.3", + "posish", "rustc_version 0.3.3", "unsafe-io 0.6.12", ] [[package]] name = "cap-std" -version = "0.16.3" +version = "0.19.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e52811b9a742bf0430321fb193d6d37005609f770ed7b303f90604a19dc64f4c" +checksum = "037334fe2f30ec71bcc51af1e8cbb8a9f9ac6a6b8cbd657d58dfef2ad5b9f19a" dependencies = [ - "cap-primitives 0.16.3", - "io-lifetimes 0.2.0", + "cap-primitives 0.19.1", + "io-lifetimes 0.3.1", "ipnet", - "posish 0.16.4", + "rsix 0.23.3", "rustc_version 0.4.0", - "unsafe-io 0.7.1", + "unsafe-io 0.9.1", ] [[package]] name = "cap-time-ext" -version = "0.16.3" +version = "0.19.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36d5a4732bc93b04b791053c69a05cd120ede893e71e26cc7ab206e9699cb177" +checksum = "aea5319ada3a9517fc70eafe9cf3275f04da795c53770ebc5d91f4a33f4dd2b5" dependencies = [ - "cap-primitives 0.16.3", + "cap-primitives 0.19.1", "once_cell", - "posish 0.16.4", - "winx 0.27.0", + "rsix 0.23.3", + "winx 0.29.1", ] [[package]] name = "cast" -version = "0.2.6" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57cdfa5d50aad6cb4d44dcab6101a7f79925bd59d82ca42f38a9856a28865374" +checksum = "4c24dab4283a142afa2fdca129b80ad2c6284e073930f964c3a1293c225ee39a" dependencies = [ - "rustc_version 0.3.3", + "rustc_version 0.4.0", ] [[package]] name = "cc" -version = "1.0.68" +version = "1.0.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a72c244c1ff497a746a7e1fb3d14bd08420ecda70c8f25c7112f2781652d787" +checksum = "d26a6ce4b6a484fa3edb70f7efa6fc430fd2b87285fe8b84304fd0936faa0dc0" dependencies = [ "jobserver", ] @@ -290,37 +290,36 @@ dependencies = [ [[package]] name = "cpp_demangle" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44919ecaf6f99e8e737bc239408931c9a01e9a6c74814fee8242dd2506b65390" +checksum = "8ea47428dc9d2237f3c6bc134472edfd63ebba0af932e783506dcfd66f10d18a" dependencies = [ "cfg-if", - "glob", ] [[package]] name = "cpufeatures" -version = "0.1.5" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66c99696f6c9dd7f35d486b9d04d7e6e202aa3e8c40d553f2fdf5e7e0c6a71ef" +checksum = "95059428f66df56b63431fdb4e1947ed2190586af5c5a8a8b71122bdf5a7f469" dependencies = [ "libc", ] [[package]] name = "cranelift-bforest" -version = "0.76.0" +version = "0.77.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e6bea67967505247f54fa2c85cf4f6e0e31c4e5692c9b70e4ae58e339067333" +checksum = "15013642ddda44eebcf61365b2052a23fd8b7314f90ba44aa059ec02643c5139" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-codegen" -version = "0.76.0" +version = "0.77.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48194035d2752bdd5bdae429e3ab88676e95f52a2b1355a5d4e809f9e39b1d74" +checksum = "298f2a7ed5fdcb062d8e78b7496b0f4b95265d20245f2d0ca88f846dd192a3a3" dependencies = [ "cranelift-bforest", "cranelift-codegen-meta", @@ -329,16 +328,15 @@ dependencies = [ "gimli", "log", "regalloc", - "serde", "smallvec", "target-lexicon", ] [[package]] name = "cranelift-codegen-meta" -version = "0.76.0" +version = "0.77.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "976efb22fcab4f2cd6bd4e9913764616a54d895c1a23530128d04e03633c555f" +checksum = "5cf504261ac62dfaf4ffb3f41d88fd885e81aba947c1241275043885bc5f0bac" dependencies = [ "cranelift-codegen-shared", "cranelift-entity", @@ -346,27 +344,24 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" -version = "0.76.0" +version = "0.77.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9dabb5fe66e04d4652e434195b45ae65b5c8172d520247b8f66d8df42b2b45dc" -dependencies = [ - "serde", -] +checksum = "1cd2a72db4301dbe7e5a4499035eedc1e82720009fb60603e20504d8691fa9cd" [[package]] name = "cranelift-entity" -version = "0.76.0" +version = "0.77.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3329733e4d4b8e91c809efcaa4faee80bf66f20164e3dd16d707346bd3494799" +checksum = "48868faa07cacf948dc4a1773648813c0e453ff9467e800ff10f6a78c021b546" dependencies = [ "serde", ] [[package]] name = "cranelift-frontend" -version = "0.76.0" +version = "0.77.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "279afcc0d3e651b773f94837c3d581177b348c8d69e928104b2e9fccb226f921" +checksum = "351c9d13b4ecd1a536215ec2fd1c3ee9ee8bc31af172abf1e45ed0adb7a931df" dependencies = [ "cranelift-codegen", "log", @@ -376,9 +371,9 @@ dependencies = [ [[package]] name = "cranelift-native" -version = "0.76.0" +version = "0.77.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c04d1fe6a5abb5bb0edc78baa8ef238370fb8e389cc88b6d153f7c3e9680425" +checksum = "6df8b556663d7611b137b24db7f6c8d9a8a27d7f29c7ea7835795152c94c1b75" dependencies = [ "cranelift-codegen", "libc", @@ -387,19 +382,18 @@ dependencies = [ [[package]] name = "cranelift-wasm" -version = "0.76.0" +version = "0.77.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0d260ad44f6fd2c91f7f5097191a2a9e3edcbb36df1fb787b600dad5ea148ec" +checksum = "7a69816d90db694fa79aa39b89dda7208a4ac74b6f2b8f3c4da26ee1c8bdfc5e" dependencies = [ "cranelift-codegen", "cranelift-entity", "cranelift-frontend", - "itertools 0.10.1", + "itertools", "log", - "serde", "smallvec", - "thiserror", - "wasmparser 0.79.0", + "wasmparser 0.80.1", + "wasmtime-types", ] [[package]] @@ -413,16 +407,16 @@ dependencies = [ [[package]] name = "criterion" -version = "0.3.4" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab327ed7354547cc2ef43cbe20ef68b988e70b4b593cbd66a2a61733123a3d23" +checksum = "1604dafd25fba2fe2d5895a9da139f8dc9b319a5fe5354ca137cbbce4e178d10" dependencies = [ "atty", "cast", "clap", "criterion-plot", "csv", - "itertools 0.10.1", + "itertools", "lazy_static", "num-traits", "oorandom", @@ -439,12 +433,12 @@ dependencies = [ [[package]] name = "criterion-plot" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e022feadec601fba1649cfa83586381a4ad31c6bf3a9ab7d408118b05dd9889d" +checksum = "d00996de9f2f7559f7f4dc286073197f83e92256a59ed395f9aac01fe717da57" dependencies = [ "cast", - "itertools 0.9.0", + "itertools", ] [[package]] @@ -459,9 +453,9 @@ dependencies = [ [[package]] name = "crossbeam-deque" -version = "0.8.0" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94af6efb46fef72616855b036a624cf27ba656ffc9be1b9a3c931cfc7749a9a9" +checksum = "6455c0ca19f0d2fbf751b908d5c55c1f5cbc65e03c4225427254b46890bdde1e" dependencies = [ "cfg-if", "crossbeam-epoch", @@ -491,16 +485,6 @@ dependencies = [ "lazy_static", ] -[[package]] -name = "cstr" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c11a39d776a3b35896711da8a04dc1835169dcd36f710878187637314e47941b" -dependencies = [ - "proc-macro2", - "quote", -] - [[package]] name = "csv" version = "1.1.6" @@ -525,9 +509,9 @@ dependencies = [ [[package]] name = "derive_arbitrary" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f1281ee141df08871db9fe261ab5312179eac32d1e314134ceaa8dd7c042f5a" +checksum = "b24629208e87a2d8b396ff43b15c4afb0a69cea3fbbaa9ed9b92b7c02f0aed73" dependencies = [ "proc-macro2", "quote", @@ -655,19 +639,30 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "28f1ca01f517bba5770c067dc6c466d290b962e08214c8f2598db98d66087e55" dependencies = [ - "posish 0.6.3", + "posish", "unsafe-io 0.6.12", "winapi", ] [[package]] name = "fs-set-times" -version = "0.6.0" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b05f9ac4aceff7d9f3cd1701217aa72f87a0bf7c6592886efe819727292a4c7f" +dependencies = [ + "io-lifetimes 0.3.1", + "rsix 0.22.4", + "winapi", +] + +[[package]] +name = "fs-set-times" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56af20dae05f9fae64574ead745ced5f08ae7dc6f42b9facd93a43d4b7adf982" +checksum = "807e3ef0de04fbe498bebd560ae041e006d97bf9f726dc0b485a86316be0ebc8" dependencies = [ - "io-lifetimes 0.2.0", - "posish 0.16.4", + "io-lifetimes 0.3.1", + "rsix 0.23.3", "winapi", ] @@ -709,12 +704,6 @@ dependencies = [ "stable_deref_trait", ] -[[package]] -name = "glob" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" - [[package]] name = "half" version = "1.7.1" @@ -723,9 +712,9 @@ checksum = "62aca2aba2d62b4a7f5b33f3712cb1b0692779a56fb510499d5c0aa594daeaf3" [[package]] name = "hashbrown" -version = "0.9.1" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04" +checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" [[package]] name = "heck" @@ -762,9 +751,9 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "indexmap" -version = "1.6.2" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "824845a0bf897a9042383849b02c1bc219c2383772efcd5c6f9766fa4b81aef3" +checksum = "bc633605454125dec4b66843673f01c7df2b89479b32e0ed634e43a91cff62a5" dependencies = [ "autocfg", "hashbrown", @@ -784,11 +773,10 @@ dependencies = [ [[package]] name = "io-lifetimes" -version = "0.2.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78d009010297118b0a443fef912b92e3482e6e6f46ab31e5d60f68b39a553ca9" +checksum = "47f5ce4afb9bf504b9f496a3307676bc232122f91a93c4da6d540aa99a0a0e0b" dependencies = [ - "libc", "rustc_version 0.4.0", "winapi", ] @@ -799,15 +787,6 @@ version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68f2d64f2edebec4ce84ad108148e67e1064789bee435edc5b60ad398714a3a9" -[[package]] -name = "itertools" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "284f18f85651fe11e8a991b2adb42cb078325c996ed026d994719efcfca1d54b" -dependencies = [ - "either", -] - [[package]] name = "itertools" version = "0.10.1" @@ -819,24 +798,24 @@ dependencies = [ [[package]] name = "itoa" -version = "0.4.7" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736" +checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4" [[package]] name = "jobserver" -version = "0.1.22" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "972f5ae5d1cb9c6ae417789196c803205313edde988685da5e3aae0827b9e7fd" +checksum = "af25a77299a7f711a01975c35a6a424eb6862092cc2d6c72c4ed6cbc56dfc1fa" dependencies = [ "libc", ] [[package]] name = "js-sys" -version = "0.3.51" +version = "0.3.55" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83bdfbace3a0e81a4253f73b49e960b053e396a11012cbd49b9b74d6a2b67062" +checksum = "7cc9ffccd38c451a86bf13657df244e9c3f37493cce8e5e21e940963777acc84" dependencies = [ "wasm-bindgen", ] @@ -855,9 +834,9 @@ checksum = "3576a87f2ba00f6f106fdfcd16db1d698d648a26ad8e0573cad8537c3c362d2a" [[package]] name = "libc" -version = "0.2.98" +version = "0.2.102" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "320cfe77175da3a483efed4bc0adc1968ca050b098ce4f2f1c13a56626128790" +checksum = "a2a5ac8f984bfcf3a823267e5fde638acc3325f6496633a5da6bb6eb2171e103" [[package]] name = "libfuzzer-sys" @@ -878,9 +857,15 @@ checksum = "7fb9b38af92608140b86b693604b9ffcc5824240a484d1ecd4795bacb2fe88f3" [[package]] name = "linux-raw-sys" -version = "0.0.17" +version = "0.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58ae91cec8978ea160429d0609ec47da5d65a858725701b77df198ecf985d6bd" +checksum = "5802c30e8a573a9af97d504e9e66a076e0b881112222a67a8e037a79658447d6" + +[[package]] +name = "linux-raw-sys" +version = "0.0.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13d803e4a041d0deed25db109ac7ba704d1edd62588b623feb8beed5da78e579" [[package]] name = "log" @@ -908,9 +893,9 @@ checksum = "4facc753ae494aeb6e3c22f839b158aebd4f9270f55cd3c79906c45476c47ab4" [[package]] name = "memchr" -version = "2.4.0" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b16bd47d9e329435e309c58469fe0791c2d0d1ba96ec0954152a5ae2b04387dc" +checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" [[package]] name = "memoffset" @@ -958,9 +943,9 @@ dependencies = [ [[package]] name = "object" -version = "0.26.0" +version = "0.26.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c55827317fb4c08822499848a14237d2874d6f139828893017237e7ab93eb386" +checksum = "39f37e50073ccad23b6d09bcb5b263f4e76d3bb6038e4a3c08e52162ffa8abc2" dependencies = [ "crc32fast", "indexmap", @@ -1021,15 +1006,15 @@ dependencies = [ [[package]] name = "plotters-backend" -version = "0.3.0" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b07fffcddc1cb3a1de753caa4e4df03b79922ba43cf882acc1bdd7e8df9f4590" +checksum = "d88417318da0eaf0fdcdb51a0ee6c3bed624333bff8f946733049380be67ac1c" [[package]] name = "plotters-svg" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b38a02e23bd9604b842a812063aec4ef702b57989c37b655254bb61c471ad211" +checksum = "521fa9638fa597e1dc53e9412a4f9cefb01187ee1f7413076f9e6749e2885ba9" dependencies = [ "plotters-backend", ] @@ -1048,24 +1033,6 @@ dependencies = [ "unsafe-io 0.6.12", ] -[[package]] -name = "posish" -version = "0.16.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "694eb323d25f129d533cdff030813ccfd708170f46625c238839941f50372d2e" -dependencies = [ - "bitflags", - "cc", - "cstr", - "errno", - "io-lifetimes 0.2.0", - "itoa", - "libc", - "linux-raw-sys", - "once_cell", - "rustc_version 0.4.0", -] - [[package]] name = "ppv-lite86" version = "0.2.10" @@ -1098,18 +1065,18 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.27" +version = "1.0.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0d8caf72986c1a598726adc988bb5984792ef84f5ee5aa50209145ee8077038" +checksum = "b9f5105d4fdaab20335ca9565e106a5d9b82b6219b5ba735731124ac6711d23d" dependencies = [ "unicode-xid", ] [[package]] name = "psm" -version = "0.1.13" +version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21ff0279b4a85e576b97e4a21d13e437ebcd56612706cde5d3f0d5c9399490c0" +checksum = "cd136ff4382c4753fc061cb9e4712ab2af263376b95bbd5bd8cd50c020b78e69" dependencies = [ "cc", ] @@ -1196,9 +1163,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.2.9" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ab49abadf3f9e1c4bc499e8845e152ad87d2ad2d30371841171169e9d75feee" +checksum = "8383f39639269cde97d255a32bdb68c047337295414940c68bdd30c2e13203ff" dependencies = [ "bitflags", ] @@ -1221,7 +1188,6 @@ checksum = "571f7f397d61c4755285cd37853fe8e03271c243424a907415909379659381c5" dependencies = [ "log", "rustc-hash", - "serde", "smallvec", ] @@ -1274,11 +1240,45 @@ dependencies = [ "winapi", ] +[[package]] +name = "rsix" +version = "0.22.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19dc84e006a7522c44207fcd9c1f504f7c9a503093070840105930a685e299a0" +dependencies = [ + "bitflags", + "cc", + "errno", + "io-lifetimes 0.3.1", + "itoa", + "libc", + "linux-raw-sys 0.0.23", + "once_cell", + "rustc_version 0.4.0", +] + +[[package]] +name = "rsix" +version = "0.23.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42c1009c55805746a0708950240c26a0c51c750e1efc94691e40dc4d69d3f117" +dependencies = [ + "bitflags", + "cc", + "errno", + "io-lifetimes 0.3.1", + "itoa", + "libc", + "linux-raw-sys 0.0.24", + "once_cell", + "rustc_version 0.4.0", +] + [[package]] name = "rustc-demangle" -version = "0.1.20" +version = "0.1.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dead70b0b5e03e9c814bcb6b01e03e68f7c57a80aa48c72ec92152ab3e818d49" +checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342" [[package]] name = "rustc-hash" @@ -1301,7 +1301,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" dependencies = [ - "semver 1.0.3", + "semver 1.0.4", ] [[package]] @@ -1325,26 +1325,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" -[[package]] -name = "scroll" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fda28d4b4830b807a8b43f7b0e6b5df875311b3e7621d84577188c175b6ec1ec" -dependencies = [ - "scroll_derive", -] - -[[package]] -name = "scroll_derive" -version = "0.10.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aaaae8f38bb311444cfb7f1979af0bc9240d95795f75f9ceddf6a59b79ceffa0" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "semver" version = "0.11.0" @@ -1356,9 +1336,9 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.3" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f3aac57ee7f3272d8395c6e4f502f434f0e289fcd62876f70daa008c20dcabe" +checksum = "568a8e6258aa33c13358f81fd834adb854c6f7c9468520910a9b1e8fac068012" [[package]] name = "semver-parser" @@ -1371,18 +1351,18 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.126" +version = "1.0.130" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec7505abeacaec74ae4778d9d9328fe5a5d04253220a85c4ee022239fc996d03" +checksum = "f12d06de37cf59146fbdecab66aa99f9fe4f78722e3607577a5375d66bd0c913" dependencies = [ "serde_derive", ] [[package]] name = "serde_cbor" -version = "0.11.1" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e18acfa2f90e8b735b2836ab8d538de304cbb6729a7360729ea5a895d15a622" +checksum = "2bef2ebfde456fb76bbcf9f59315333decc4fda0b2b44b420243c11e0f5ec1f5" dependencies = [ "half", "serde", @@ -1390,9 +1370,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.126" +version = "1.0.130" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "963a7dbc9895aeac7ac90e74f34a5d5261828f79df35cbed41e10189d3804d43" +checksum = "d7bc1a1ab1961464eae040d96713baa5a724a8152c1222492465b54322ec508b" dependencies = [ "proc-macro2", "quote", @@ -1401,9 +1381,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.64" +version = "1.0.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "799e97dc9fdae36a5c8b8f2cae9ce2ee9fdce2058c57a93e6099d919fd982f79" +checksum = "0f690853975602e1bfe1ccbf50504d67174e3bcf340f23b5ea9992e0587a52d8" dependencies = [ "itoa", "ryu", @@ -1412,21 +1392,21 @@ dependencies = [ [[package]] name = "serde_yaml" -version = "0.8.17" +version = "0.8.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15654ed4ab61726bf918a39cb8d98a2e2995b002387807fa6ba58fdf7f59bb23" +checksum = "d8c608a35705a5d3cdc9fbe403147647ff34b921f8e833e49306df898f9b20af" dependencies = [ "dtoa", - "linked-hash-map", + "indexmap", "serde", "yaml-rust", ] [[package]] name = "sha2" -version = "0.9.5" +version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b362ae5752fd2137731f9fa25fd4d9058af34666ca1966fb969119cc35719f12" +checksum = "b69f9a4c9740d74c5baa3fd2e547f9525fa8088a8a958e0ca2409a514e33f5fa" dependencies = [ "block-buffer", "cfg-if", @@ -1464,9 +1444,9 @@ checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" [[package]] name = "structopt" -version = "0.3.21" +version = "0.3.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5277acd7ee46e63e5168a80734c9f6ee81b1367a7d8772a2d765df2a3705d28c" +checksum = "bf9d950ef167e25e0bdb073cf1d68e9ad2795ac826f2f3f59647817cf23c0bfa" dependencies = [ "clap", "lazy_static", @@ -1475,9 +1455,9 @@ dependencies = [ [[package]] name = "structopt-derive" -version = "0.4.14" +version = "0.4.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ba9cdfda491b814720b6b06e0cac513d922fc407582032e8706e9f137976f90" +checksum = "134d838a2c9943ac3125cf6df165eda53493451b719f3255b2a26b85f772d0ba" dependencies = [ "heck", "proc-macro-error", @@ -1488,9 +1468,9 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.73" +version = "1.0.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f71489ff30030d2ae598524f61326b902466f72a0fb1a8564c001cc63425bcc7" +checksum = "c6f107db402c2c2055242dbf4d2af0e69197202e9faacbef9571bbe47f5a1b84" dependencies = [ "proc-macro2", "quote", @@ -1499,26 +1479,26 @@ dependencies = [ [[package]] name = "system-interface" -version = "0.8.0" +version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7adf9f33595b165d9d2897c548750a1141fc531a2492f7d365b71190c063e836" +checksum = "024bceeab03feb74fb78395d5628df5664a7b6b849155f5e5db05e7e7b962128" dependencies = [ "atty", "bitflags", "cap-fs-ext", - "cap-std 0.16.3", - "io-lifetimes 0.2.0", - "posish 0.16.4", + "cap-std 0.19.1", + "io-lifetimes 0.3.1", + "rsix 0.23.3", "rustc_version 0.4.0", "winapi", - "winx 0.27.0", + "winx 0.29.1", ] [[package]] name = "target-lexicon" -version = "0.12.0" +version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64ae3b39281e4b14b8123bdbaddd472b7dfe215e444181f2f9d2443c2444f834" +checksum = "d9bffcddbc2458fa3e6058414599e3c838a022abae82e5c67b4f7f80298d5bff" [[package]] name = "termcolor" @@ -1540,18 +1520,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.25" +version = "1.0.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa6f76457f59514c7eeb4e59d891395fab0b2fd1d40723ae737d64153392e9c6" +checksum = "602eca064b2d83369e2b2f34b09c70b605402801927c65c11071ac911d299b88" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.25" +version = "1.0.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a36768c0fbf1bb15eca10defa29526bda730a2376c2ab4393ccfa16fb1a318d" +checksum = "bad553cc2c78e8de258400763a647e80e6d1b31ee237275d756f6836d204494c" dependencies = [ "proc-macro2", "quote", @@ -1579,9 +1559,9 @@ dependencies = [ [[package]] name = "tracing" -version = "0.1.26" +version = "0.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09adeb8c97449311ccd28a427f96fb563e7fd31aabf994189879d9da2394b89d" +checksum = "84f96e095c0c82419687c20ddf5cb3eadb61f4e1405923c9dc8e53a1adacbda8" dependencies = [ "cfg-if", "log", @@ -1592,9 +1572,9 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.15" +version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c42e6fa53307c8a17e4ccd4dc81cf5ec38db9209f59b222210375b54ee40d1e2" +checksum = "98863d0dd09fa59a1b79c6750ad80dbda6b75f4e71c437a6a1a8cb91a8bcbd77" dependencies = [ "proc-macro2", "quote", @@ -1603,18 +1583,18 @@ dependencies = [ [[package]] name = "tracing-core" -version = "0.1.18" +version = "0.1.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9ff14f98b1a4b289c6248a023c1c2fa1491062964e9fed67ab29c4e4da4a052" +checksum = "46125608c26121c81b0c6d693eab5a420e416da7e43c426d2e8f7df8da8a3acf" dependencies = [ "lazy_static", ] [[package]] name = "typenum" -version = "1.13.0" +version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "879f6906492a7cd215bfa4cf595b600146ccfac0c79bcbd1f3000162af5e8b06" +checksum = "b63708a265f51345575b27fe43f9500ad611579e764c79edbc2037b1121959ec" [[package]] name = "uap-bench" @@ -1633,15 +1613,15 @@ checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c" [[package]] name = "unicode-segmentation" -version = "1.7.1" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb0d2e7be6ae3a5fa87eed5fb451aff96f2573d2694942e40543ae0bbe19c796" +checksum = "8895849a949e7845e06bd6dc1aa51731a103c42707010a5b591c0038fb73385b" [[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" @@ -1662,11 +1642,11 @@ dependencies = [ [[package]] name = "unsafe-io" -version = "0.7.1" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f56d1d7067d6e88dfdede7f668ea51800785fc8fcaf82d8fecdeaa678491e629" +checksum = "11e8cceed59fe60bd092be347343917cbc14b9239536980f09fe34e22c8efbc7" dependencies = [ - "io-lifetimes 0.2.0", + "io-lifetimes 0.3.1", "rustc_version 0.4.0", "winapi", ] @@ -1702,21 +1682,21 @@ checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" [[package]] name = "wasi-cap-std-sync" -version = "0.29.0" +version = "0.30.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e16618e7792b042b3ed0fdc93bcd6d7e272290d4fc73228334af91f6e0084a0" +checksum = "f9d864043ca88090ab06a24318b6447c7558eb797390ff312f4cc8d36348622f" dependencies = [ "anyhow", "async-trait", "bitflags", "cap-fs-ext", "cap-rand", - "cap-std 0.16.3", + "cap-std 0.19.1", "cap-time-ext", - "fs-set-times 0.6.0", - "io-lifetimes 0.2.0", + "fs-set-times 0.11.0", + "io-lifetimes 0.3.1", "lazy_static", - "posish 0.16.4", + "rsix 0.22.4", "system-interface", "tracing", "wasi-common", @@ -1725,16 +1705,16 @@ dependencies = [ [[package]] name = "wasi-common" -version = "0.29.0" +version = "0.30.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30e106f32f2af1c50386bf75376f63705a45ed51d4f6a510cb300bf5dc0126e5" +checksum = "f782e345db0464507cff47673c18b2765c020e8086e16a008a2bfffe0c78c819" dependencies = [ "anyhow", "bitflags", "cap-rand", - "cap-std 0.16.3", - "io-lifetimes 0.2.0", - "posish 0.16.4", + "cap-std 0.19.1", + "io-lifetimes 0.3.1", + "rsix 0.22.4", "thiserror", "tracing", "wiggle", @@ -1743,9 +1723,9 @@ dependencies = [ [[package]] name = "wasm-bindgen" -version = "0.2.74" +version = "0.2.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d54ee1d4ed486f78874278e63e4069fc1ab9f6a18ca492076ffb90c5eb2997fd" +checksum = "632f73e236b219150ea279196e54e610f5dbafa5d61786303d4da54f84e47fce" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -1753,9 +1733,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.74" +version = "0.2.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b33f6a0694ccfea53d94db8b2ed1c3a8a4c86dd936b13b9f0a15ec4a451b900" +checksum = "a317bf8f9fba2476b4b2c85ef4c4af8ff39c3c7f0cdfeed4f82c34a880aa837b" dependencies = [ "bumpalo", "lazy_static", @@ -1768,9 +1748,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.74" +version = "0.2.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "088169ca61430fe1e58b8096c24975251700e7b1f6fd91cc9d59b04fb9b18bd4" +checksum = "d56146e7c495528bf6587663bea13a8eb588d39b36b679d83972e1a2dbbdacf9" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -1778,9 +1758,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.74" +version = "0.2.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be2241542ff3d9f241f5e2cb6dd09b37efe786df8851c54957683a49f0987a97" +checksum = "7803e0eea25835f8abdc585cd3021b3deb11543c6fe226dcd30b228857c5c5ab" dependencies = [ "proc-macro2", "quote", @@ -1791,9 +1771,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.74" +version = "0.2.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7cff876b8f18eed75a66cf49b65e7f967cb354a7aa16003fb55dbfd25b44b4f" +checksum = "0237232789cf037d5480773fe568aac745bfe2afbc11a863e97901780a6b47cc" [[package]] name = "wasm-encoder" @@ -1804,6 +1784,15 @@ dependencies = [ "leb128", ] +[[package]] +name = "wasm-encoder" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2caacc74c68c74f0008c4055cdf509c43e623775eaf73323bb818dcf666ed9bd" +dependencies = [ + "leb128", +] + [[package]] name = "wasm-smith" version = "0.4.5" @@ -1813,7 +1802,7 @@ dependencies = [ "arbitrary", "indexmap", "leb128", - "wasm-encoder", + "wasm-encoder 0.4.1", ] [[package]] @@ -1824,25 +1813,25 @@ checksum = "52144d4c78e5cf8b055ceab8e5fa22814ce4315d6002ad32cfd914f37c12fd65" [[package]] name = "wasmparser" -version = "0.79.0" +version = "0.80.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b5894be15a559c85779254700e1d35f02f843b5a69152e5c82c626d9fd66c0e" +checksum = "be92b6dcaa5af4b2a176b29be3bf1402fab9e69d313141185099c7d1684f2dca" [[package]] name = "wasmprinter" -version = "0.2.27" +version = "0.2.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe6f65000c9b653a87ba9b8bebe9230371337db2b7e70db724ee4b79d2b9936f" +checksum = "f62f18810edc34db799bcb3d555835b2eecc9b6b221f8ee74fdb5aae0bffa176" dependencies = [ "anyhow", - "wasmparser 0.79.0", + "wasmparser 0.80.1", ] [[package]] name = "wasmtime" -version = "0.29.0" +version = "0.30.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bbb8a082a8ef50f7eeb8b82dda9709ef1e68963ea3c94e45581644dd4041835" +checksum = "899b1e5261e3d3420860dacfb952871ace9d7ba9f953b314f67aaf9f8e2a4d89" dependencies = [ "anyhow", "backtrace", @@ -1853,19 +1842,20 @@ dependencies = [ "lazy_static", "libc", "log", + "object", "paste", "psm", + "rayon", "region", "rustc-demangle", "serde", - "smallvec", "target-lexicon", - "wasmparser 0.79.0", + "wasmparser 0.80.1", "wasmtime-cache", + "wasmtime-cranelift", "wasmtime-environ", "wasmtime-fiber", "wasmtime-jit", - "wasmtime-profiling", "wasmtime-runtime", "wat", "winapi", @@ -1873,9 +1863,9 @@ dependencies = [ [[package]] name = "wasmtime-cache" -version = "0.29.0" +version = "0.30.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d73391579ca7f24573138ef768b73b2aed5f9d542385c64979b65d60d0912399" +checksum = "e2493b81d7a9935f7af15e06beec806f256bc974a90a843685f3d61f2fc97058" dependencies = [ "anyhow", "base64", @@ -1894,59 +1884,51 @@ dependencies = [ [[package]] name = "wasmtime-cranelift" -version = "0.29.0" +version = "0.30.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81c6f5ae9205382345c7cd7454932a906186836999a2161c385e38a15f52e1fe" +checksum = "99706bacdf5143f7f967d417f0437cce83a724cf4518cb1a3ff40e519d793021" dependencies = [ + "anyhow", "cranelift-codegen", "cranelift-entity", "cranelift-frontend", + "cranelift-native", "cranelift-wasm", - "target-lexicon", - "wasmparser 0.79.0", - "wasmtime-environ", -] - -[[package]] -name = "wasmtime-debug" -version = "0.29.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c69e08f55e12f15f50b1b533bc3626723e7224254a065de6576934c86258c9e8" -dependencies = [ - "anyhow", "gimli", "more-asserts", "object", "target-lexicon", "thiserror", - "wasmparser 0.79.0", + "wasmparser 0.80.1", "wasmtime-environ", ] [[package]] name = "wasmtime-environ" -version = "0.29.0" +version = "0.30.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "005d93174040af37fb8625f891cd9827afdad314261f7ec4ee61ec497d6e9d3c" +checksum = "ac42cb562a2f98163857605f02581d719a410c5abe93606128c59a10e84de85b" dependencies = [ + "anyhow", "cfg-if", - "cranelift-codegen", "cranelift-entity", - "cranelift-wasm", "gimli", "indexmap", "log", "more-asserts", + "object", "serde", + "target-lexicon", "thiserror", - "wasmparser 0.79.0", + "wasmparser 0.80.1", + "wasmtime-types", ] [[package]] name = "wasmtime-fiber" -version = "0.29.0" +version = "0.30.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afa8d00a477a43848dc84cb83f097e8dc8aacd57fd4e763f232416aa27cb137c" +checksum = "8779dd78755a248512233df4f6eaa6ba075c41bea2085fec750ed2926897bf95" dependencies = [ "cc", "libc", @@ -1955,75 +1937,34 @@ dependencies = [ [[package]] name = "wasmtime-jit" -version = "0.29.0" +version = "0.30.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0bf1dfb213a35d8f21aefae40e597fe72778a907011ffdff7affb029a02af9a" +checksum = "24f46dd757225f29a419be415ea6fb8558df9b0194f07e3a6a9c99d0e14dd534" dependencies = [ "addr2line", "anyhow", + "bincode", "cfg-if", - "cranelift-codegen", - "cranelift-entity", - "cranelift-frontend", - "cranelift-native", - "cranelift-wasm", "gimli", + "libc", "log", "more-asserts", "object", - "rayon", "region", "serde", "target-lexicon", "thiserror", - "wasmparser 0.79.0", - "wasmtime-cranelift", - "wasmtime-debug", + "wasmparser 0.80.1", "wasmtime-environ", - "wasmtime-obj", - "wasmtime-profiling", "wasmtime-runtime", "winapi", ] -[[package]] -name = "wasmtime-obj" -version = "0.29.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d231491878e710c68015228c9f9fc5955fe5c96dbf1485c15f7bed55b622c83c" -dependencies = [ - "anyhow", - "more-asserts", - "object", - "target-lexicon", - "wasmtime-debug", - "wasmtime-environ", -] - -[[package]] -name = "wasmtime-profiling" -version = "0.29.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21486cfb5255c2069666c1f116f9e949d4e35c9a494f11112fa407879e42198d" -dependencies = [ - "anyhow", - "cfg-if", - "gimli", - "lazy_static", - "libc", - "object", - "scroll", - "serde", - "target-lexicon", - "wasmtime-environ", - "wasmtime-runtime", -] - [[package]] name = "wasmtime-runtime" -version = "0.29.0" +version = "0.30.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7ddfdf32e0a20d81f48be9dacd31612bc61de5a174d1356fef806d300f507de" +checksum = "0122215a44923f395487048cb0a1d60b5b32c73aab15cf9364b798dbaff0996f" dependencies = [ "anyhow", "backtrace", @@ -2044,11 +1985,23 @@ dependencies = [ "winapi", ] +[[package]] +name = "wasmtime-types" +version = "0.30.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9b01caf8a204ef634ebac99700e77ba716d3ebbb68a1abbc2ceb6b16dbec9e4" +dependencies = [ + "cranelift-entity", + "serde", + "thiserror", + "wasmparser 0.80.1", +] + [[package]] name = "wasmtime-wasi" -version = "0.29.0" +version = "0.30.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37ad5c1b8c8e5720dc2580818d34210792a93b3892cd2da90b152b51c73716dc" +checksum = "12b0e75c044aa4afba7f274a625a43260390fbdd8ca79e4aeed6827f7760fba2" dependencies = [ "anyhow", "wasi-cap-std-sync", @@ -2068,27 +2021,27 @@ dependencies = [ [[package]] name = "wast" -version = "36.0.0" +version = "38.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b5d7ba374a364571da1cb0a379a3dc302582a2d9937a183bfe35b68ad5bb9c4" +checksum = "0ebc29df4629f497e0893aacd40f13a4a56b85ef6eb4ab6d603f07244f1a7bf2" dependencies = [ "leb128", ] [[package]] name = "wat" -version = "1.0.38" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16383df7f0e3901484c2dda6294ed6895caa3627ce4f6584141dcf30a33a23e6" +checksum = "adcfaeb27e2578d2c6271a45609f4a055e6d7ba3a12eff35b1fd5ba147bdf046" dependencies = [ - "wast 36.0.0", + "wast 38.0.0", ] [[package]] name = "web-sys" -version = "0.3.51" +version = "0.3.55" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e828417b379f3df7111d3a2a9e5753706cae29c41f7c4029ee9fd77f3e09e582" +checksum = "38eb105f1c59d9eaa6b5cdc92b859d85b926e82cb2e0945cd0c9259faa6fe9fb" dependencies = [ "js-sys", "wasm-bindgen", @@ -2096,9 +2049,9 @@ dependencies = [ [[package]] name = "wiggle" -version = "0.29.0" +version = "0.30.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cf200553298de4898eed65b047b4dfa315cb027f3873d20c62abb871f5b3314" +checksum = "cbd408c06047cf3aa2d0408a34817da7863bcfc1e7d16c154ef92864b5fa456a" dependencies = [ "anyhow", "async-trait", @@ -2111,9 +2064,9 @@ dependencies = [ [[package]] name = "wiggle-generate" -version = "0.29.0" +version = "0.30.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39f96d7da4bf1b09c9a8aa02643462cf43b21126c410aa72e4e39601389c180f" +checksum = "02575a1580353bd15a0bce308887ff6c9dae13fb3c60d49caf2e6dabf944b14d" dependencies = [ "anyhow", "heck", @@ -2126,9 +2079,9 @@ dependencies = [ [[package]] name = "wiggle-macro" -version = "0.29.0" +version = "0.30.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2593ede4cf0e8f6a4dcd118013399c977047f0f7d549991490b508604dde8634" +checksum = "74b91f637729488f0318db544b24493788a3228fed1e1ccd24abbe4fc4f92663" dependencies = [ "proc-macro2", "quote", @@ -2180,12 +2133,12 @@ dependencies = [ [[package]] name = "winx" -version = "0.27.0" +version = "0.29.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc8ca6af61cfeed1e071b19f44cf4a7683addd863f28fef69cdf251bc034050e" +checksum = "4ecd175b4077107a91bb6bbb34aa9a691d8b45314791776f78b63a1cb8a08928" dependencies = [ "bitflags", - "io-lifetimes 0.2.0", + "io-lifetimes 0.3.1", "winapi", ] @@ -2213,7 +2166,7 @@ dependencies = [ "rayon", "structopt", "wasi-cap-std-sync", - "wasm-encoder", + "wasm-encoder 0.6.0", "wasmparser 0.78.2", "wasmprinter", "wasmtime", diff --git a/crates/wizer/Cargo.toml b/crates/wizer/Cargo.toml index 958fd35dfd53..dfd5a31cac1b 100644 --- a/crates/wizer/Cargo.toml +++ b/crates/wizer/Cargo.toml @@ -32,11 +32,11 @@ env_logger = { version = "0.8.2", optional = true } log = "0.4.14" rayon = "1.5.0" structopt = { version = "0.3.21", optional = true } -wasi-cap-std-sync = "0.29.0" -wasm-encoder = "0.4.0" +wasi-cap-std-sync = "0.30.0" +wasm-encoder = "0.6.0" wasmparser = "0.78.2" -wasmtime = "0.29.0" -wasmtime-wasi = "0.29.0" +wasmtime = "0.30.0" +wasmtime-wasi = "0.30.0" # Enable this dependency to get messages with WAT disassemblies when certain # internal panics occur. diff --git a/crates/wizer/fuzz/Cargo.toml b/crates/wizer/fuzz/Cargo.toml index 89295f8e5dd1..80af5f599497 100644 --- a/crates/wizer/fuzz/Cargo.toml +++ b/crates/wizer/fuzz/Cargo.toml @@ -15,7 +15,7 @@ libfuzzer-sys = "0.4" log = "0.4.14" wasm-smith = "0.4.0" wasmprinter = "0.2.26" -wasmtime = "0.29.0" +wasmtime = "0.30.0" [dependencies.wizer] path = ".." diff --git a/crates/wizer/src/dummy.rs b/crates/wizer/src/dummy.rs index e2ae1551b6b6..b60a1294d218 100644 --- a/crates/wizer/src/dummy.rs +++ b/crates/wizer/src/dummy.rs @@ -180,8 +180,8 @@ impl WatGenerator { write!( self.dst, "(memory {} {})", - mem.limits().min(), - match mem.limits().max() { + mem.minimum(), + match mem.maximum() { Some(max) => max.to_string(), None => String::new(), } @@ -192,12 +192,12 @@ impl WatGenerator { write!( self.dst, "(table {} {} {})", - table.limits().min(), - match table.limits().max() { + table.minimum(), + match table.maximum() { Some(max) => max.to_string(), None => String::new(), }, - wat_ty(table.element()), + wat_ty(&table.element()), ) .unwrap(); } @@ -269,8 +269,8 @@ impl WatGenerator { self.dst, "(memory ${} {} {})\n", name, - mem.limits().min(), - match mem.limits().max() { + mem.minimum(), + match mem.maximum() { Some(max) => max.to_string(), None => String::new(), } @@ -282,12 +282,12 @@ impl WatGenerator { self.dst, "(table ${} {} {} {})\n", name, - table.limits().min(), - match table.limits().max() { + table.minimum(), + match table.maximum() { Some(max) => max.to_string(), None => String::new(), }, - wat_ty(table.element()), + wat_ty(&table.element()), ) .unwrap(); } @@ -418,7 +418,7 @@ mod tests { let mut store = store(); let table = dummy_table( &mut store, - TableType::new(ValType::ExternRef, Limits::at_least(10)), + TableType::new(ValType::ExternRef, 10, None), ); assert_eq!(table.size(&store), 10); for i in 0..10 { @@ -441,7 +441,7 @@ mod tests { #[test] fn dummy_memory_import() { let mut store = store(); - let memory = dummy_memory(&mut store, MemoryType::new(Limits::at_least(1))).unwrap(); + let memory = dummy_memory(&mut store, MemoryType::new(1, None)).unwrap(); assert_eq!(memory.size(&store), 1); } @@ -476,16 +476,16 @@ mod tests { // Tables. instance_ty.add_named_export( "table0", - TableType::new(ValType::ExternRef, Limits::at_least(1)).into(), + TableType::new(ValType::ExternRef, 1, None).into(), ); instance_ty.add_named_export( "table1", - TableType::new(ValType::ExternRef, Limits::at_least(1)).into(), + TableType::new(ValType::ExternRef, 1, None).into(), ); // Memories. - instance_ty.add_named_export("memory0", MemoryType::new(Limits::at_least(1)).into()); - instance_ty.add_named_export("memory1", MemoryType::new(Limits::at_least(1)).into()); + instance_ty.add_named_export("memory0", MemoryType::new(1, None).into()); + instance_ty.add_named_export("memory1", MemoryType::new(1, None).into()); // Modules. instance_ty.add_named_export("module0", ModuleType::new().into()); @@ -563,28 +563,28 @@ mod tests { // Multiple exported and imported tables. module_ty.add_named_export( "table0", - TableType::new(ValType::ExternRef, Limits::at_least(1)).into(), + TableType::new(ValType::ExternRef, 1, None).into(), ); module_ty.add_named_export( "table1", - TableType::new(ValType::ExternRef, Limits::at_least(1)).into(), + TableType::new(ValType::ExternRef, 1, None).into(), ); module_ty.add_named_import( "table2", None, - TableType::new(ValType::ExternRef, Limits::at_least(1)).into(), + TableType::new(ValType::ExternRef, 1, None).into(), ); module_ty.add_named_import( "table3", None, - TableType::new(ValType::ExternRef, Limits::at_least(1)).into(), + TableType::new(ValType::ExternRef, 1, None).into(), ); // Multiple exported and imported memories. - module_ty.add_named_export("memory0", MemoryType::new(Limits::at_least(1)).into()); - module_ty.add_named_export("memory1", MemoryType::new(Limits::at_least(1)).into()); - module_ty.add_named_import("memory2", None, MemoryType::new(Limits::at_least(1)).into()); - module_ty.add_named_import("memory3", None, MemoryType::new(Limits::at_least(1)).into()); + module_ty.add_named_export("memory0", MemoryType::new(1, None).into()); + module_ty.add_named_export("memory1", MemoryType::new(1, None).into()); + module_ty.add_named_import("memory2", None, MemoryType::new(1, None).into()); + module_ty.add_named_import("memory3", None, MemoryType::new(1, None).into()); // An exported and an imported module. module_ty.add_named_export("module0", ModuleType::new().into()); diff --git a/crates/wizer/src/rewrite.rs b/crates/wizer/src/rewrite.rs index 48f51de5f56d..e9a37a7307d6 100644 --- a/crates/wizer/src/rewrite.rs +++ b/crates/wizer/src/rewrite.rs @@ -97,7 +97,7 @@ impl Wizer { .zip(snapshot.memory_mins.iter().copied()) { let mut mem = translate::memory_type(mem); - mem.limits.min = new_min; + mem.minimum = new_min; memories.memory(mem); } encoder.section(&memories); @@ -1043,9 +1043,9 @@ fn rewrite_state_module( .enumerate() { let mut mem = translate::memory_type(mem); - assert!(new_min >= mem.limits.min); - assert!(new_min <= mem.limits.max.unwrap_or(u32::MAX)); - mem.limits.min = new_min; + assert!(new_min >= mem.minimum); + assert!(new_min <= mem.maximum.unwrap_or(u64::MAX)); + mem.minimum = new_min; memories.memory(mem); let name = format!("__wizer_memory_{}", i); diff --git a/crates/wizer/src/snapshot.rs b/crates/wizer/src/snapshot.rs index c80f2c124e6b..d2bc3b014824 100644 --- a/crates/wizer/src/snapshot.rs +++ b/crates/wizer/src/snapshot.rs @@ -2,7 +2,7 @@ use rayon::iter::{IntoParallelIterator, ParallelExtend, ParallelIterator}; use std::convert::TryFrom; use wasmtime::{AsContext, AsContextMut}; -const WASM_PAGE_SIZE: u32 = 65_536; +const WASM_PAGE_SIZE: u64 = 65_536; /// The maximum number of data segments that most engines support. const MAX_DATA_SEGMENTS: usize = 100_000; @@ -13,7 +13,7 @@ pub struct Snapshot { pub globals: Vec, /// A new minimum size for each memory (in units of pages). - pub memory_mins: Vec, + pub memory_mins: Vec, /// Segments of non-zero memory. pub data_segments: Vec, @@ -117,7 +117,7 @@ fn snapshot_globals( fn snapshot_memories( ctx: &mut impl AsContextMut, instance: &wasmtime::Instance, -) -> (Vec, Vec) { +) -> (Vec, Vec) { log::debug!("Snapshotting memories"); // Find and record non-zero regions of memory (in parallel). diff --git a/crates/wizer/src/translate.rs b/crates/wizer/src/translate.rs index 758dc490cb0a..fd1bf6c220f5 100644 --- a/crates/wizer/src/translate.rs +++ b/crates/wizer/src/translate.rs @@ -3,7 +3,8 @@ pub(crate) fn table_type(table_ty: wasmparser::TableType) -> wasm_encoder::TableType { wasm_encoder::TableType { element_type: val_type(table_ty.element_type), - limits: limits(table_ty.limits), + minimum: table_ty.limits.initial, + maximum: table_ty.limits.maximum, } } @@ -34,19 +35,14 @@ pub(crate) fn memory_type(ty: wasmparser::MemoryType) -> wasm_encoder::MemoryTyp shared: false, limits: lims, } => wasm_encoder::MemoryType { - limits: limits(lims), + minimum: lims.initial as u64, + maximum: lims.maximum.map(|val| val as u64), + memory64: false, }, _ => unreachable!("handled in validation"), } } -pub(crate) fn limits(limits: wasmparser::ResizableLimits) -> wasm_encoder::Limits { - wasm_encoder::Limits { - min: limits.initial, - max: limits.maximum, - } -} - pub(crate) fn entity_type(ty: wasmparser::ImportSectionEntryType) -> wasm_encoder::EntityType { match ty { wasmparser::ImportSectionEntryType::Function(f) => wasm_encoder::EntityType::Function(f), From 153022d36e8dbb28f83279d81b63c7690db4441b Mon Sep 17 00:00:00 2001 From: Till Schneidereit Date: Fri, 24 Sep 2021 15:38:41 +0200 Subject: [PATCH 076/212] Update fuzz target to wasmtime 0.30.0 --- crates/wizer/fuzz/fuzz_targets/same_result.rs | 56 ++++++++++--------- 1 file changed, 30 insertions(+), 26 deletions(-) diff --git a/crates/wizer/fuzz/fuzz_targets/same_result.rs b/crates/wizer/fuzz/fuzz_targets/same_result.rs index 7a46e95e11aa..24bd14b13041 100644 --- a/crates/wizer/fuzz/fuzz_targets/same_result.rs +++ b/crates/wizer/fuzz/fuzz_targets/same_result.rs @@ -92,21 +92,23 @@ fuzz_target!(|module: wasm_smith::ConfiguredModule| { } log::debug!("Using main function: {:?}", main_func); - let store = Store::new(&engine); + let mut store = Store::new(&engine, ()); // Instantiate the snapshot and call the main function. - let snapshot_instance = Instance::new(&store, &snapshot_module, &[]).unwrap(); - let snapshot_main_func = snapshot_instance.get_func(main_func).unwrap(); - let main_args = wizer::dummy::dummy_values(snapshot_main_func.ty().params()); - let snapshot_result = snapshot_main_func.call(&main_args); + let snapshot_instance = Instance::new(&mut store, &snapshot_module, &[]).unwrap(); + let snapshot_main_func = snapshot_instance.get_func(&mut store, main_func).unwrap(); + let main_args = wizer::dummy::dummy_values(snapshot_main_func.ty(&store).params()); + let snapshot_result = snapshot_main_func.call(&mut store, &main_args); // Instantiate the original Wasm and then call the initialization // and main functions back to back. - let instance = Instance::new(&store, &module, &[]).unwrap(); - let init_func = instance.get_typed_func::<(), ()>(init_func).unwrap(); - init_func.call(()).unwrap(); - let main_func = instance.get_func(main_func).unwrap(); - let result = main_func.call(&main_args); + let instance = Instance::new(&mut store, &module, &[]).unwrap(); + let init_func = instance + .get_typed_func::<(), (), _>(&mut store, init_func) + .unwrap(); + init_func.call(&mut store, ()).unwrap(); + let main_func = instance.get_func(&mut store, main_func).unwrap(); + let result = main_func.call(&mut store, &main_args); // Check that the function return values / traps are the same. match (snapshot_result, result) { @@ -133,25 +135,27 @@ fuzz_target!(|module: wasm_smith::ConfiguredModule| { } // Assert that all other exports have the same state as well. - for export in snapshot_instance.exports() { - let name = export.name().to_string(); - match export.into_extern() { + let exports = snapshot_instance + .exports(&mut store) + .map(|export| export.name().to_string()) + .collect::>(); + for name in exports.iter() { + let export = snapshot_instance.get_export(&mut store, &name).unwrap(); + match export { Extern::Global(snapshot_global) => { - let global = instance.get_global(&name).unwrap(); - assert_val_eq(&snapshot_global.get(), &global.get()); + let global = instance.get_global(&mut store, &name).unwrap(); + assert_val_eq(&snapshot_global.get(&mut store), &global.get(&mut store)); } Extern::Memory(snapshot_memory) => { - let memory = instance.get_memory(&name).unwrap(); - unsafe { - let snapshot_memory = snapshot_memory.data_unchecked(); - let memory = memory.data_unchecked(); - assert_eq!(snapshot_memory.len(), memory.len()); - // NB: Don't use `assert_eq` here so that we don't - // try to print the full memories' debug - // representations on failure. - if snapshot_memory != memory { - panic!("divergence between snapshot and non-snapshot memories"); - } + let memory = instance.get_memory(&mut store, &name).unwrap(); + let snapshot_memory = snapshot_memory.data(&store); + let memory = memory.data(&store); + assert_eq!(snapshot_memory.len(), memory.len()); + // NB: Don't use `assert_eq` here so that we don't + // try to print the full memories' debug + // representations on failure. + if snapshot_memory != memory { + panic!("divergence between snapshot and non-snapshot memories"); } } Extern::Instance(_) From 319af543209c728c8da0557d9696f306d91ba1e3 Mon Sep 17 00:00:00 2001 From: Till Schneidereit Date: Tue, 12 Oct 2021 13:03:22 +0200 Subject: [PATCH 077/212] Address review comment and format code --- crates/wizer/src/dummy.rs | 25 +++++-------------------- crates/wizer/src/translate.rs | 4 ++-- 2 files changed, 7 insertions(+), 22 deletions(-) diff --git a/crates/wizer/src/dummy.rs b/crates/wizer/src/dummy.rs index b60a1294d218..4e54396f3b1c 100644 --- a/crates/wizer/src/dummy.rs +++ b/crates/wizer/src/dummy.rs @@ -416,10 +416,7 @@ mod tests { #[test] fn dummy_table_import() { let mut store = store(); - let table = dummy_table( - &mut store, - TableType::new(ValType::ExternRef, 10, None), - ); + let table = dummy_table(&mut store, TableType::new(ValType::ExternRef, 10, None)); assert_eq!(table.size(&store), 10); for i in 0..10 { assert!(table @@ -474,14 +471,8 @@ mod tests { ); // Tables. - instance_ty.add_named_export( - "table0", - TableType::new(ValType::ExternRef, 1, None).into(), - ); - instance_ty.add_named_export( - "table1", - TableType::new(ValType::ExternRef, 1, None).into(), - ); + instance_ty.add_named_export("table0", TableType::new(ValType::ExternRef, 1, None).into()); + instance_ty.add_named_export("table1", TableType::new(ValType::ExternRef, 1, None).into()); // Memories. instance_ty.add_named_export("memory0", MemoryType::new(1, None).into()); @@ -561,14 +552,8 @@ mod tests { ); // Multiple exported and imported tables. - module_ty.add_named_export( - "table0", - TableType::new(ValType::ExternRef, 1, None).into(), - ); - module_ty.add_named_export( - "table1", - TableType::new(ValType::ExternRef, 1, None).into(), - ); + module_ty.add_named_export("table0", TableType::new(ValType::ExternRef, 1, None).into()); + module_ty.add_named_export("table1", TableType::new(ValType::ExternRef, 1, None).into()); module_ty.add_named_import( "table2", None, diff --git a/crates/wizer/src/translate.rs b/crates/wizer/src/translate.rs index fd1bf6c220f5..2e17ee2f22b6 100644 --- a/crates/wizer/src/translate.rs +++ b/crates/wizer/src/translate.rs @@ -35,8 +35,8 @@ pub(crate) fn memory_type(ty: wasmparser::MemoryType) -> wasm_encoder::MemoryTyp shared: false, limits: lims, } => wasm_encoder::MemoryType { - minimum: lims.initial as u64, - maximum: lims.maximum.map(|val| val as u64), + minimum: lims.initial.into(), + maximum: lims.maximum.map(|val| val.into()), memory64: false, }, _ => unreachable!("handled in validation"), From 09f37b2cafb8270736564858e9af47eb95e6c637 Mon Sep 17 00:00:00 2001 From: Till Schneidereit Date: Tue, 12 Oct 2021 13:08:23 +0200 Subject: [PATCH 078/212] Bump to version 1.3.4 --- crates/wizer/Cargo.lock | 2 +- crates/wizer/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/wizer/Cargo.lock b/crates/wizer/Cargo.lock index 8ec02dfd1e3a..c259bcc04f14 100644 --- a/crates/wizer/Cargo.lock +++ b/crates/wizer/Cargo.lock @@ -2156,7 +2156,7 @@ dependencies = [ [[package]] name = "wizer" -version = "1.3.3" +version = "1.3.4" dependencies = [ "anyhow", "cap-std 0.13.10", diff --git a/crates/wizer/Cargo.toml b/crates/wizer/Cargo.toml index dfd5a31cac1b..476acb5e075f 100644 --- a/crates/wizer/Cargo.toml +++ b/crates/wizer/Cargo.toml @@ -9,7 +9,7 @@ license = "Apache-2.0 WITH LLVM-exception" name = "wizer" readme = "./README.md" repository = "https://github.com/bytecodealliance/wizer" -version = "1.3.3" +version = "1.3.4" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html From e8d2ce8653383b15af17f22dcc80391e340d89ce Mon Sep 17 00:00:00 2001 From: Till Schneidereit Date: Mon, 18 Oct 2021 15:46:18 +0200 Subject: [PATCH 079/212] Publish binary releases of the `wizer` CLI tool This adds automation to publish releases for Linux, macOS, and Windows, all 64bit. Same as for Wasmtime, releases are published under the `dev` tag whenever a PR is merged, and whenever a commit is tagged. This is based on what Wasmtime used to do and what fastly/js-compute-runtime still does. There's quite a bit of duplication of project names and the likes going on, which would be nice to clean up, but I'd expect that to take meaningful amounts of time that I can't currently spend :( --- crates/wizer/.github/workflows/ci.yml | 90 ++++++++++++++++++++++++++- crates/wizer/ci/build-tarballs.sh | 41 ++++++++++++ 2 files changed, 130 insertions(+), 1 deletion(-) create mode 100755 crates/wizer/ci/build-tarballs.sh diff --git a/crates/wizer/.github/workflows/ci.yml b/crates/wizer/.github/workflows/ci.yml index 913d4c36f5cb..c6251bf3aeec 100644 --- a/crates/wizer/.github/workflows/ci.yml +++ b/crates/wizer/.github/workflows/ci.yml @@ -11,7 +11,16 @@ env: jobs: build: - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} + strategy: + matrix: + include: + - build: x86_64-linux + os: ubuntu-latest + - build: x86_64-macos + os: macos-latest + - build: x86_64-windows + os: windows-latest steps: - uses: actions/checkout@v2 - name: Build @@ -20,6 +29,22 @@ jobs: run: cargo test --verbose - name: Checking benches run : cargo check --benches + - name: Build release binary + run: cargo build --release --bin wizer --features="env_logger structopt" + + - name: Create dist + run: mkdir dist + + # Move binaries to dist folder + - run: cp target/release/wizer dist + if: matrix.os != 'windows-latest' && matrix.target == '' + - run: cp target/release/wizer.exe dist + if: matrix.build == 'x86_64-windows' + + - uses: actions/upload-artifact@v1 + with: + name: bins-${{ matrix.build }} + path: dist rustfmt: runs-on: ubuntu-latest @@ -29,3 +54,66 @@ jobs: - run: rustup default stable - run: rustup component add rustfmt - run: cargo fmt --all -- --check + + + # Consumes all published artifacts from all the previous build steps, creates + # a bunch of tarballs for all of them, and then publishes the tarballs + # themselves as an artifact (for inspection) and then optionally creates + # github releases and/or tags for pushes. + publish: + name: Publish + needs: [build, rustfmt] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + # Download all the artifacts that we'll be publishing. Should keep an eye on + # the `download-artifact` repository to see if we can ever get something + # like "download all artifacts" or "download this list of artifacts" + - name: Download x86_64 macOS binaries + uses: actions/download-artifact@v1 + with: + name: bins-x86_64-macos + - name: Download x86_64 Linux binaries + uses: actions/download-artifact@v1 + with: + name: bins-x86_64-linux + - name: Download x86_64 Windows binaries + uses: actions/download-artifact@v1 + with: + name: bins-x86_64-windows + + - name: Calculate tag name + run: | + name=dev + if [[ $GITHUB_REF == refs/tags/v* ]]; then + name=${GITHUB_REF:10} + fi + echo ::set-output name=val::$name + echo TAG=$name >> $GITHUB_ENV + id: tagname + + # Assemble all the build artifacts into tarballs and zip archives. + - name: Assemble tarballs + run: | + ./ci/build-tarballs.sh x86_64-linux + ./ci/build-tarballs.sh x86_64-macos + ./ci/build-tarballs.sh x86_64-windows .exe + + # Upload all assembled tarballs as an artifact of the github action run, so + # that way even PRs can inspect the output. + - uses: actions/upload-artifact@v1 + with: + name: tarballs + path: dist + + # ... and if this was an actual push (tag or `main`) then we publish a + # new release. This'll automatically publish a tag release or update `dev` + # with this `sha` + - name: Publish Release + uses: ./.github/actions/github-release + if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')) + with: + files: "dist/*" + name: ${{ steps.tagname.outputs.val }} + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/crates/wizer/ci/build-tarballs.sh b/crates/wizer/ci/build-tarballs.sh new file mode 100755 index 000000000000..530d70473729 --- /dev/null +++ b/crates/wizer/ci/build-tarballs.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +# A small shell script invoked from CI on the final Linux builder which actually +# assembles the release artifacts for a particular platform. This will take the +# binary artifacts of previous builders and create associated tarballs to +# publish to GitHub. +# +# The first argument of this is the "platform" name to put into the tarball, and +# the second argument is the name of the github actions platform which is where +# we source binaries from. The final third argument is ".exe" on Windows to +# handle executable extensions right. +# +# Usage: build-tarballs.sh PLATFORM [.exe] + +# where PLATFORM is e.g. x86_64-linux, aarch64-linux, ... + +set -ex + +platform=$1 +exe=$2 + +rm -rf tmp +mkdir tmp +mkdir -p dist + +mktarball() { + dir=$1 + if [ "$exe" = "" ]; then + tar cJf dist/$dir.tar.xz -C tmp $dir + else + (cd tmp && zip -r ../dist/$dir.zip $dir) + fi +} + +# Create the main tarball of binaries +bin_pkgname=wizer-$TAG-$platform +mkdir tmp/$bin_pkgname +cp README.md tmp/$bin_pkgname +mv bins-$platform/wizer$exe tmp/$bin_pkgname +chmod +x tmp/$bin_pkgname/wizer$exe +mktarball $bin_pkgname From 4feb9e8cec768db2073dc68f4f5aa4e3ea1a658a Mon Sep 17 00:00:00 2001 From: Cheng Shao Date: Fri, 3 Dec 2021 15:35:07 +0000 Subject: [PATCH 080/212] Don't export _initialize during rewriting --- crates/wizer/src/rewrite.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/crates/wizer/src/rewrite.rs b/crates/wizer/src/rewrite.rs index e9a37a7307d6..663f6e8b5746 100644 --- a/crates/wizer/src/rewrite.rs +++ b/crates/wizer/src/rewrite.rs @@ -129,12 +129,13 @@ impl Wizer { encoder.section(&globals); } - // Remove the initialization function's export and perform any - // requested renames. + // Remove exports for the wizer initialization + // function and WASI reactor _initialize function, + // then perform any requested renames. s if s.id == SectionId::Export.into() => { let mut exports = wasm_encoder::ExportSection::new(); for export in module.exports(cx) { - if export.field == self.init_func { + if export.field == self.init_func || export.field == "_initialize" { continue; } @@ -415,7 +416,7 @@ impl Wizer { let mut aliases = wasm_encoder::AliasSection::new(); let mut exports = wasm_encoder::ExportSection::new(); for exp in cx.root().exports(cx) { - if exp.field == self.init_func { + if exp.field == self.init_func || exp.field == "_initialize" { continue; } From f7a10021ec8053a8de9952f482c469843a8d92a2 Mon Sep 17 00:00:00 2001 From: Cheng Shao Date: Sat, 4 Dec 2021 02:03:58 +0000 Subject: [PATCH 081/212] Call _initialize before calling init_func --- crates/wizer/src/lib.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/crates/wizer/src/lib.rs b/crates/wizer/src/lib.rs index 43481ee4bc78..de8276068720 100644 --- a/crates/wizer/src/lib.rs +++ b/crates/wizer/src/lib.rs @@ -24,6 +24,7 @@ use std::fmt::Display; use std::path::PathBuf; #[cfg(feature = "structopt")] use structopt::StructOpt; +use wasmtime::Extern; use wasmtime_wasi::WasiCtx; const DEFAULT_INHERIT_STDIO: bool = true; @@ -563,6 +564,14 @@ impl Wizer { .instantiate(&mut *store, module) .context("failed to instantiate the Wasm module")?; + if let Some(export) = instance.get_export(&mut *store, "_initialize") { + if let Extern::Func(func) = export { + func.typed::<(), (), _>(&store) + .and_then(|f| f.call(&mut *store, ()).map_err(Into::into)) + .context("calling the Reactor initialization function")?; + } + } + let init_func = instance .get_typed_func::<(), (), _>(&mut *store, &self.init_func) .expect("checked by `validate_init_func`"); From ad5d8cb27ffb169f2af2d801e92cbb4b243c46b6 Mon Sep 17 00:00:00 2001 From: Cheng Shao Date: Sat, 4 Dec 2021 02:12:40 +0000 Subject: [PATCH 082/212] Add wasi_reactor test case --- crates/wizer/tests/tests.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/crates/wizer/tests/tests.rs b/crates/wizer/tests/tests.rs index 9c00d8c5bb4c..4a857e760ddd 100644 --- a/crates/wizer/tests/tests.rs +++ b/crates/wizer/tests/tests.rs @@ -873,3 +873,26 @@ fn renames_and_module_linking() -> anyhow::Result<()> { assert!(wat.trim().ends_with(expected_wat.trim())); Ok(()) } + +#[test] +fn wasi_reactor() -> anyhow::Result<()> { + run_wat( + &[], + 42, + r#" +(module + (global $g (mut i32) i32.const 0) + (func (export "_initialize") + i32.const 6 + global.set $g + ) + (func (export "wizer.initialize") + global.get $g + i32.const 7 + i32.mul + global.set $g) + (func (export "run") (result i32) + global.get $g)) + "#, + ) +} From 717a3799c111aa6defdd1b1a2162f357e2ff7c6c Mon Sep 17 00:00:00 2001 From: Cheng Shao Date: Mon, 6 Dec 2021 19:37:37 +0000 Subject: [PATCH 083/212] Strip _initialize only when it's called during snapshotting --- crates/wizer/src/lib.rs | 21 ++++++++++++++++----- crates/wizer/src/rewrite.rs | 13 +++++++++---- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/crates/wizer/src/lib.rs b/crates/wizer/src/lib.rs index de8276068720..f1b62a971b94 100644 --- a/crates/wizer/src/lib.rs +++ b/crates/wizer/src/lib.rs @@ -337,9 +337,15 @@ impl Wizer { .context("failed to compile the Wasm module")?; self.validate_init_func(&module)?; - let instance = self.initialize(&mut store, &module)?; + let (instance, has_wasi_initialize) = self.initialize(&mut store, &module)?; let snapshot = snapshot::snapshot(&mut store, &instance); - let rewritten_wasm = self.rewrite(&mut cx, &mut store, &snapshot, &renames); + let rewritten_wasm = self.rewrite( + &mut cx, + &mut store, + &snapshot, + &renames, + has_wasi_initialize, + ); if cfg!(debug_assertions) { if let Err(error) = self.wasm_validate(&rewritten_wasm) { @@ -547,7 +553,7 @@ impl Wizer { &self, store: &mut Store, module: &wasmtime::Module, - ) -> anyhow::Result { + ) -> anyhow::Result<(wasmtime::Instance, bool)> { log::debug!("Calling the initialization function"); let mut linker = wasmtime::Linker::new(store.engine()); @@ -564,10 +570,15 @@ impl Wizer { .instantiate(&mut *store, module) .context("failed to instantiate the Wasm module")?; + let mut has_wasi_initialize = false; + if let Some(export) = instance.get_export(&mut *store, "_initialize") { if let Extern::Func(func) = export { func.typed::<(), (), _>(&store) - .and_then(|f| f.call(&mut *store, ()).map_err(Into::into)) + .and_then(|f| { + has_wasi_initialize = true; + f.call(&mut *store, ()).map_err(Into::into) + }) .context("calling the Reactor initialization function")?; } } @@ -579,6 +590,6 @@ impl Wizer { .call(&mut *store, ()) .with_context(|| format!("the `{}` function trapped", self.init_func))?; - Ok(instance) + Ok((instance, has_wasi_initialize)) } } diff --git a/crates/wizer/src/rewrite.rs b/crates/wizer/src/rewrite.rs index 663f6e8b5746..a88048adc608 100644 --- a/crates/wizer/src/rewrite.rs +++ b/crates/wizer/src/rewrite.rs @@ -24,13 +24,14 @@ impl Wizer { store: &crate::Store, snapshot: &Snapshot, renames: &FuncRenames, + has_wasi_initialize: bool, ) -> Vec { log::debug!("Rewriting input Wasm to pre-initialized state"); if cx.uses_module_linking() { - self.rewrite_with_module_linking(cx, store, snapshot, renames) + self.rewrite_with_module_linking(cx, store, snapshot, renames, has_wasi_initialize) } else { - self.rewrite_without_module_linking(cx, store, snapshot, renames) + self.rewrite_without_module_linking(cx, store, snapshot, renames, has_wasi_initialize) } } @@ -42,6 +43,7 @@ impl Wizer { store: &crate::Store, snapshot: &Snapshot, renames: &FuncRenames, + has_wasi_initialize: bool, ) -> Vec { assert!(snapshot.instantiations.is_empty()); @@ -135,7 +137,9 @@ impl Wizer { s if s.id == SectionId::Export.into() => { let mut exports = wasm_encoder::ExportSection::new(); for export in module.exports(cx) { - if export.field == self.init_func || export.field == "_initialize" { + if export.field == self.init_func + || (has_wasi_initialize && export.field == "_initialize") + { continue; } @@ -334,6 +338,7 @@ impl Wizer { store: &crate::Store, snapshot: &Snapshot, renames: &FuncRenames, + has_wasi_initialize: bool, ) -> Vec { let mut umbrella = wasm_encoder::Module::new(); @@ -416,7 +421,7 @@ impl Wizer { let mut aliases = wasm_encoder::AliasSection::new(); let mut exports = wasm_encoder::ExportSection::new(); for exp in cx.root().exports(cx) { - if exp.field == self.init_func || exp.field == "_initialize" { + if exp.field == self.init_func || (has_wasi_initialize && exp.field == "_initialize") { continue; } From 8e6ad72a5e555dbb2a917e01f26741e142bc4532 Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Tue, 4 Jan 2022 16:18:24 -0800 Subject: [PATCH 084/212] Dummy functions should trap, not return dummy values If an unknown function import is called during Wasm initialization, we need to trap, not return a placeholder value. This was the result of some bad copy-pasting from other code that produces dummy imports for an arbitrary Wasm module. Fixes #39 --- crates/wizer/Cargo.lock | 491 ++++++++++++---------------------- crates/wizer/Cargo.toml | 8 +- crates/wizer/benches/regex.rs | 15 +- crates/wizer/benches/uap.rs | 15 +- crates/wizer/fuzz/Cargo.toml | 2 +- crates/wizer/src/dummy.rs | 468 +++++++------------------------- crates/wizer/tests/tests.rs | 256 +++++++++++++----- 7 files changed, 481 insertions(+), 774 deletions(-) diff --git a/crates/wizer/Cargo.lock b/crates/wizer/Cargo.lock index c259bcc04f14..f0fbec3a5255 100644 --- a/crates/wizer/Cargo.lock +++ b/crates/wizer/Cargo.lock @@ -8,7 +8,16 @@ version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3e61f2b7f93d2c7d2b08263acaa4a363b3e276806c68af6134c44f523bf1aacd" dependencies = [ - "gimli", + "gimli 0.25.0", +] + +[[package]] +name = "addr2line" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9ecd88a8c8378ca913a680cd98f0f13ac67383d35993f86c90a70e3f137816b" +dependencies = [ + "gimli 0.26.1", ] [[package]] @@ -90,12 +99,12 @@ version = "0.3.61" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e7a905d892734eea339e896738c14b9afce22b5318f64b951e70bf3844419b01" dependencies = [ - "addr2line", + "addr2line 0.16.0", "cc", "cfg-if", "libc", "miniz_oxide", - "object", + "object 0.26.2", "rustc-demangle", ] @@ -149,63 +158,42 @@ checksum = "d9df67f7bf9ef8498769f994239c45613ef0c5899415fb58e9add412d2c1a538" [[package]] name = "cap-fs-ext" -version = "0.19.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bf5c3b436b94a1adac74032ff35d8aa5bae6ec2a7900e76432c9ae8dac4d673" -dependencies = [ - "cap-primitives 0.19.1", - "cap-std 0.19.1", - "io-lifetimes 0.3.1", - "rustc_version 0.4.0", - "winapi", -] - -[[package]] -name = "cap-primitives" -version = "0.13.10" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d253b74de50b097594462618e7dd17b93b3e3bef19f32d2e512996f9095661f" +checksum = "4f8499797f7e264c83334d9fc98b2c9889ebe5839514a14d81769ca09d71fd1d" dependencies = [ - "errno", - "fs-set-times 0.3.1", - "ipnet", - "libc", - "maybe-owned", - "once_cell", - "posish", - "rustc_version 0.3.3", - "unsafe-io 0.6.12", + "cap-primitives", + "cap-std", + "io-lifetimes", + "rustc_version", "winapi", - "winapi-util", - "winx 0.25.0", ] [[package]] name = "cap-primitives" -version = "0.19.1" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b51bd736eec54ae6552d18b0c958885b01d88c84c5fe6985e28c2b57ff385e94" +checksum = "c5998b8b3a49736500aec3c123fa3f6f605a125b41a6df725e6b7c924a612ab4" dependencies = [ "ambient-authority", "errno", - "fs-set-times 0.12.0", - "io-lifetimes 0.3.1", + "fs-set-times", + "io-extras", + "io-lifetimes", "ipnet", "maybe-owned", - "once_cell", - "rsix 0.23.3", - "rustc_version 0.4.0", - "unsafe-io 0.9.1", + "rustc_version", + "rustix", "winapi", "winapi-util", - "winx 0.29.1", + "winx", ] [[package]] name = "cap-rand" -version = "0.19.1" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e6e89d00b0cebeb6da7a459b81e6a49cf2092cc4afe03f28eb99b8f0e889344" +checksum = "fafda903eb4a85903b106439cf62524275f3ae0609bb9e1ae9da7e7c26d4150c" dependencies = [ "ambient-authority", "rand", @@ -213,40 +201,28 @@ dependencies = [ [[package]] name = "cap-std" -version = "0.13.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7019d48ea53c5f378e0fdab0fe5f627fc00e76d65e75dffd6fb1cbc0c9b382ee" -dependencies = [ - "cap-primitives 0.13.10", - "posish", - "rustc_version 0.3.3", - "unsafe-io 0.6.12", -] - -[[package]] -name = "cap-std" -version = "0.19.1" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "037334fe2f30ec71bcc51af1e8cbb8a9f9ac6a6b8cbd657d58dfef2ad5b9f19a" +checksum = "811de89a7ede4ba32f2b75fe5c668a534da24942d81c081248a9d2843ebd517d" dependencies = [ - "cap-primitives 0.19.1", - "io-lifetimes 0.3.1", + "cap-primitives", + "io-extras", + "io-lifetimes", "ipnet", - "rsix 0.23.3", - "rustc_version 0.4.0", - "unsafe-io 0.9.1", + "rustc_version", + "rustix", ] [[package]] name = "cap-time-ext" -version = "0.19.1" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aea5319ada3a9517fc70eafe9cf3275f04da795c53770ebc5d91f4a33f4dd2b5" +checksum = "85f263d62447efe8829efdf947bbb4824ba2a3e2852b3be1d62f76fc05c326b0" dependencies = [ - "cap-primitives 0.19.1", + "cap-primitives", "once_cell", - "rsix 0.23.3", - "winx 0.29.1", + "rustix", + "winx", ] [[package]] @@ -255,7 +231,7 @@ version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4c24dab4283a142afa2fdca129b80ad2c6284e073930f964c3a1293c225ee39a" dependencies = [ - "rustc_version 0.4.0", + "rustc_version", ] [[package]] @@ -308,60 +284,60 @@ dependencies = [ [[package]] name = "cranelift-bforest" -version = "0.77.0" +version = "0.79.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15013642ddda44eebcf61365b2052a23fd8b7314f90ba44aa059ec02643c5139" +checksum = "f0fb5e025141af5b9cbfff4351dc393596d017725f126c954bf472ce78dbba6b" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-codegen" -version = "0.77.0" +version = "0.79.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "298f2a7ed5fdcb062d8e78b7496b0f4b95265d20245f2d0ca88f846dd192a3a3" +checksum = "a278c67cc48d0e8ff2275fb6fc31527def4be8f3d81640ecc8cd005a3aa45ded" dependencies = [ "cranelift-bforest", "cranelift-codegen-meta", "cranelift-codegen-shared", "cranelift-entity", - "gimli", + "gimli 0.26.1", "log", "regalloc", + "sha2", "smallvec", "target-lexicon", ] [[package]] name = "cranelift-codegen-meta" -version = "0.77.0" +version = "0.79.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cf504261ac62dfaf4ffb3f41d88fd885e81aba947c1241275043885bc5f0bac" +checksum = "28274c1916c931c5603d94c5479d2ddacaaa574d298814ac1c99964ce92cbe85" dependencies = [ "cranelift-codegen-shared", - "cranelift-entity", ] [[package]] name = "cranelift-codegen-shared" -version = "0.77.0" +version = "0.79.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cd2a72db4301dbe7e5a4499035eedc1e82720009fb60603e20504d8691fa9cd" +checksum = "5411cf49ab440b749d4da5129dfc45caf6e5fb7b2742b1fe1a421964fda2ee88" [[package]] name = "cranelift-entity" -version = "0.77.0" +version = "0.79.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48868faa07cacf948dc4a1773648813c0e453ff9467e800ff10f6a78c021b546" +checksum = "64dde596f98462a37b029d81c8567c23cc68b8356b017f12945c545ac0a83203" dependencies = [ "serde", ] [[package]] name = "cranelift-frontend" -version = "0.77.0" +version = "0.79.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "351c9d13b4ecd1a536215ec2fd1c3ee9ee8bc31af172abf1e45ed0adb7a931df" +checksum = "544605d400710bd9c89924050b30c2e0222a387a5a8b5f04da9a9fdcbd8656a5" dependencies = [ "cranelift-codegen", "log", @@ -371,9 +347,9 @@ dependencies = [ [[package]] name = "cranelift-native" -version = "0.77.0" +version = "0.79.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6df8b556663d7611b137b24db7f6c8d9a8a27d7f29c7ea7835795152c94c1b75" +checksum = "b7f8839befb64f7a39cb855241ae2c8eb74cea27c97fff2a007075fdb8a7f7d4" dependencies = [ "cranelift-codegen", "libc", @@ -382,9 +358,9 @@ dependencies = [ [[package]] name = "cranelift-wasm" -version = "0.77.0" +version = "0.79.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a69816d90db694fa79aa39b89dda7208a4ac74b6f2b8f3c4da26ee1c8bdfc5e" +checksum = "80c9e14062c6a1cd2367dd30ea8945976639d5fe2062da8bdd40ada9ce3cb82e" dependencies = [ "cranelift-codegen", "cranelift-entity", @@ -392,7 +368,7 @@ dependencies = [ "itertools", "log", "smallvec", - "wasmparser 0.80.1", + "wasmparser 0.81.0", "wasmtime-types", ] @@ -598,9 +574,9 @@ dependencies = [ [[package]] name = "errno" -version = "0.2.7" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa68f2fb9cae9d37c9b2b3584aba698a2e97f72d7aef7b9f7aa71d8b54ce46fe" +checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1" dependencies = [ "errno-dragonfly", "libc", @@ -635,34 +611,12 @@ dependencies = [ [[package]] name = "fs-set-times" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28f1ca01f517bba5770c067dc6c466d290b962e08214c8f2598db98d66087e55" -dependencies = [ - "posish", - "unsafe-io 0.6.12", - "winapi", -] - -[[package]] -name = "fs-set-times" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b05f9ac4aceff7d9f3cd1701217aa72f87a0bf7c6592886efe819727292a4c7f" -dependencies = [ - "io-lifetimes 0.3.1", - "rsix 0.22.4", - "winapi", -] - -[[package]] -name = "fs-set-times" -version = "0.12.0" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "807e3ef0de04fbe498bebd560ae041e006d97bf9f726dc0b485a86316be0ebc8" +checksum = "aa838950e8e36a567ce96a945c303e88d9916ff97df27c315a0d263a72bd816f" dependencies = [ - "io-lifetimes 0.3.1", - "rsix 0.23.3", + "io-lifetimes", + "rustix", "winapi", ] @@ -698,6 +652,12 @@ name = "gimli" version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f0a01e0497841a3b2db4f8afa483cce65f7e96a3498bd6c541734792aeac8fe7" + +[[package]] +name = "gimli" +version = "0.26.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78cc372d058dcf6d5ecd98510e7fbc9e5aec4d21de70f65fea8fecebcd881bd4" dependencies = [ "fallible-iterator", "indexmap", @@ -761,23 +721,23 @@ dependencies = [ ] [[package]] -name = "io-lifetimes" -version = "0.1.1" +name = "io-extras" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "609c23089c52d7edcf39d6cfd2cf581dcea7e059f80f1d91130887dceac77c1f" +checksum = "2a1d9a66d8b0312e3601a04a2dcf8f0ddd873319560ddeabe2110fa1e5af781a" dependencies = [ - "libc", - "rustc_version 0.4.0", + "io-lifetimes", + "rustc_version", "winapi", ] [[package]] name = "io-lifetimes" -version = "0.3.1" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47f5ce4afb9bf504b9f496a3307676bc232122f91a93c4da6d540aa99a0a0e0b" +checksum = "278e90d6f8a6c76a8334b336e306efa3c5f2b604048cbfd486d6f49878e3af14" dependencies = [ - "rustc_version 0.4.0", + "rustc_version", "winapi", ] @@ -857,15 +817,9 @@ checksum = "7fb9b38af92608140b86b693604b9ffcc5824240a484d1ecd4795bacb2fe88f3" [[package]] name = "linux-raw-sys" -version = "0.0.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5802c30e8a573a9af97d504e9e66a076e0b881112222a67a8e037a79658447d6" - -[[package]] -name = "linux-raw-sys" -version = "0.0.24" +version = "0.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13d803e4a041d0deed25db109ac7ba704d1edd62588b623feb8beed5da78e579" +checksum = "a261afc61b7a5e323933b402ca6a1765183687c614789b1e4db7762ed4230bca" [[package]] name = "log" @@ -946,6 +900,15 @@ name = "object" version = "0.26.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "39f37e50073ccad23b6d09bcb5b263f4e76d3bb6038e4a3c08e52162ffa8abc2" +dependencies = [ + "memchr", +] + +[[package]] +name = "object" +version = "0.27.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67ac1d3f9a1d3616fd9a60c8d74296f22406a238b6a72f5cc1e6f314df4ffbf9" dependencies = [ "crc32fast", "indexmap", @@ -976,15 +939,6 @@ version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "acbf547ad0c65e31259204bd90935776d1c693cec2f4ff7abb7a1bbbd40dfe58" -[[package]] -name = "pest" -version = "2.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10f4872ae94d7b90ae48754df22fd42ad52ce740b8f370b03da4835417403e53" -dependencies = [ - "ucd-trie", -] - [[package]] name = "pin-project-lite" version = "0.2.7" @@ -1019,20 +973,6 @@ dependencies = [ "plotters-backend", ] -[[package]] -name = "posish" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89cfd94d463bd7f94d4dc43af1117881afdc654d389a1917b41fc0326e3b0806" -dependencies = [ - "bitflags", - "cfg-if", - "errno", - "itoa", - "libc", - "unsafe-io 0.6.12", -] - [[package]] name = "ppv-lite86" version = "0.2.10" @@ -1182,9 +1122,9 @@ dependencies = [ [[package]] name = "regalloc" -version = "0.0.31" +version = "0.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "571f7f397d61c4755285cd37853fe8e03271c243424a907415909379659381c5" +checksum = "7d808cff91dfca7b239d40b972ba628add94892b1d9e19a842aedc5cfae8ab1a" dependencies = [ "log", "rustc-hash", @@ -1240,40 +1180,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "rsix" -version = "0.22.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19dc84e006a7522c44207fcd9c1f504f7c9a503093070840105930a685e299a0" -dependencies = [ - "bitflags", - "cc", - "errno", - "io-lifetimes 0.3.1", - "itoa", - "libc", - "linux-raw-sys 0.0.23", - "once_cell", - "rustc_version 0.4.0", -] - -[[package]] -name = "rsix" -version = "0.23.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42c1009c55805746a0708950240c26a0c51c750e1efc94691e40dc4d69d3f117" -dependencies = [ - "bitflags", - "cc", - "errno", - "io-lifetimes 0.3.1", - "itoa", - "libc", - "linux-raw-sys 0.0.24", - "once_cell", - "rustc_version 0.4.0", -] - [[package]] name = "rustc-demangle" version = "0.1.21" @@ -1288,20 +1194,28 @@ checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" [[package]] name = "rustc_version" -version = "0.3.3" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0dfe2087c51c460008730de8b57e6a320782fbfb312e1f4d520e6c6fae155ee" +checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" dependencies = [ - "semver 0.11.0", + "semver", ] [[package]] -name = "rustc_version" -version = "0.4.0" +name = "rustix" +version = "0.26.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +checksum = "18c44018277ec7195538f5631b90def7ad975bb46370cb0f4eff4012de9333f8" dependencies = [ - "semver 1.0.4", + "bitflags", + "errno", + "io-lifetimes", + "itoa", + "libc", + "linux-raw-sys", + "once_cell", + "rustc_version", + "winapi", ] [[package]] @@ -1325,30 +1239,12 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" -[[package]] -name = "semver" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6" -dependencies = [ - "semver-parser", -] - [[package]] name = "semver" version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "568a8e6258aa33c13358f81fd834adb854c6f7c9468520910a9b1e8fac068012" -[[package]] -name = "semver-parser" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00b0bef5b7f9e0df16536d3961cfb6e84331c065b4066afb39768d0e319411f7" -dependencies = [ - "pest", -] - [[package]] name = "serde" version = "1.0.130" @@ -1479,19 +1375,19 @@ dependencies = [ [[package]] name = "system-interface" -version = "0.14.1" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "024bceeab03feb74fb78395d5628df5664a7b6b849155f5e5db05e7e7b962128" +checksum = "b1b5163055c386394170493ec1827cf7975035dc0bb23dcb7070bd1b1f672baa" dependencies = [ "atty", "bitflags", "cap-fs-ext", - "cap-std 0.19.1", - "io-lifetimes 0.3.1", - "rsix 0.23.3", - "rustc_version 0.4.0", + "cap-std", + "io-lifetimes", + "rustc_version", + "rustix", "winapi", - "winx 0.29.1", + "winx", ] [[package]] @@ -1605,12 +1501,6 @@ dependencies = [ "serde_yaml", ] -[[package]] -name = "ucd-trie" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c" - [[package]] name = "unicode-segmentation" version = "1.8.0" @@ -1629,28 +1519,6 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" -[[package]] -name = "unsafe-io" -version = "0.6.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1598c579f79cdd11e677b3942b7bed5cb3369464cfd240f4c4a308ffaed6f5e4" -dependencies = [ - "io-lifetimes 0.1.1", - "rustc_version 0.3.3", - "winapi", -] - -[[package]] -name = "unsafe-io" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11e8cceed59fe60bd092be347343917cbc14b9239536980f09fe34e22c8efbc7" -dependencies = [ - "io-lifetimes 0.3.1", - "rustc_version 0.4.0", - "winapi", -] - [[package]] name = "vec_map" version = "0.8.2" @@ -1682,21 +1550,20 @@ checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" [[package]] name = "wasi-cap-std-sync" -version = "0.30.0" +version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9d864043ca88090ab06a24318b6447c7558eb797390ff312f4cc8d36348622f" +checksum = "f23cb8c01ff3b733418d594df1fab090a4ece29a1260c5364df67e8fe7e08634" dependencies = [ "anyhow", "async-trait", - "bitflags", "cap-fs-ext", "cap-rand", - "cap-std 0.19.1", + "cap-std", "cap-time-ext", - "fs-set-times 0.11.0", - "io-lifetimes 0.3.1", + "fs-set-times", + "io-lifetimes", "lazy_static", - "rsix 0.22.4", + "rustix", "system-interface", "tracing", "wasi-common", @@ -1705,16 +1572,15 @@ dependencies = [ [[package]] name = "wasi-common" -version = "0.30.0" +version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f782e345db0464507cff47673c18b2765c020e8086e16a008a2bfffe0c78c819" +checksum = "6c1e8cb75656702a5b843ef609c4e49b7a257f3bfcbf95ce9f32e4d1c9cf933b" dependencies = [ "anyhow", "bitflags", "cap-rand", - "cap-std 0.19.1", - "io-lifetimes 0.3.1", - "rsix 0.22.4", + "cap-std", + "rustix", "thiserror", "tracing", "wiggle", @@ -1817,6 +1683,12 @@ version = "0.80.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "be92b6dcaa5af4b2a176b29be3bf1402fab9e69d313141185099c7d1684f2dca" +[[package]] +name = "wasmparser" +version = "0.81.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98930446519f63d00a836efdc22f67766ceae8dbcc1571379f2bcabc6b2b9abc" + [[package]] name = "wasmprinter" version = "0.2.29" @@ -1829,11 +1701,12 @@ dependencies = [ [[package]] name = "wasmtime" -version = "0.30.0" +version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "899b1e5261e3d3420860dacfb952871ace9d7ba9f953b314f67aaf9f8e2a4d89" +checksum = "5d59b4bcc681f894d018e7032ba3149ab8e5f86828fab0b6ff31999c5691f20b" dependencies = [ "anyhow", + "async-trait", "backtrace", "bincode", "cfg-if", @@ -1842,7 +1715,7 @@ dependencies = [ "lazy_static", "libc", "log", - "object", + "object 0.27.1", "paste", "psm", "rayon", @@ -1850,7 +1723,7 @@ dependencies = [ "rustc-demangle", "serde", "target-lexicon", - "wasmparser 0.80.1", + "wasmparser 0.81.0", "wasmtime-cache", "wasmtime-cranelift", "wasmtime-environ", @@ -1863,18 +1736,17 @@ dependencies = [ [[package]] name = "wasmtime-cache" -version = "0.30.0" +version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2493b81d7a9935f7af15e06beec806f256bc974a90a843685f3d61f2fc97058" +checksum = "ce455e29b5289c13ff1fc2453303e9df982c7ac59e03caeac2e22e9dddf94d3f" dependencies = [ "anyhow", "base64", "bincode", "directories-next", - "errno", "file-per-thread-logger", - "libc", "log", + "rustix", "serde", "sha2", "toml", @@ -1884,9 +1756,9 @@ dependencies = [ [[package]] name = "wasmtime-cranelift" -version = "0.30.0" +version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99706bacdf5143f7f967d417f0437cce83a724cf4518cb1a3ff40e519d793021" +checksum = "30d079ceda53d15a5d29e8f4f8d3fcf9a9bb589c05e29b49ea10d129b5ff8e09" dependencies = [ "anyhow", "cranelift-codegen", @@ -1894,67 +1766,64 @@ dependencies = [ "cranelift-frontend", "cranelift-native", "cranelift-wasm", - "gimli", + "gimli 0.26.1", + "log", "more-asserts", - "object", + "object 0.27.1", "target-lexicon", "thiserror", - "wasmparser 0.80.1", + "wasmparser 0.81.0", "wasmtime-environ", ] [[package]] name = "wasmtime-environ" -version = "0.30.0" +version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac42cb562a2f98163857605f02581d719a410c5abe93606128c59a10e84de85b" +checksum = "c39e4ba1fb154cca6a0f2350acc83248e22defb0cc647ae78879fe246a49dd61" dependencies = [ "anyhow", - "cfg-if", "cranelift-entity", - "gimli", + "gimli 0.26.1", "indexmap", "log", "more-asserts", - "object", + "object 0.27.1", "serde", "target-lexicon", "thiserror", - "wasmparser 0.80.1", + "wasmparser 0.81.0", "wasmtime-types", ] [[package]] name = "wasmtime-fiber" -version = "0.30.0" +version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8779dd78755a248512233df4f6eaa6ba075c41bea2085fec750ed2926897bf95" +checksum = "12fe33f65dbc891fece3a7986e0d328c4ad79af83b2e79099a4f039bde1762d0" dependencies = [ "cc", - "libc", + "rustix", "winapi", ] [[package]] name = "wasmtime-jit" -version = "0.30.0" +version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24f46dd757225f29a419be415ea6fb8558df9b0194f07e3a6a9c99d0e14dd534" +checksum = "3dd538de9501eb0f2c4c7b3d8acc7f918276ca28591a67d4ebe0672ebd558b65" dependencies = [ - "addr2line", + "addr2line 0.17.0", "anyhow", "bincode", "cfg-if", - "gimli", - "libc", - "log", - "more-asserts", - "object", + "gimli 0.26.1", + "object 0.27.1", "region", + "rustix", "serde", "target-lexicon", "thiserror", - "wasmparser 0.80.1", "wasmtime-environ", "wasmtime-runtime", "winapi", @@ -1962,9 +1831,9 @@ dependencies = [ [[package]] name = "wasmtime-runtime" -version = "0.30.0" +version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0122215a44923f395487048cb0a1d60b5b32c73aab15cf9364b798dbaff0996f" +checksum = "910ccbd8cc18a02f626a1b2c7a7ddb57808db3c1780fd0af0aa5a5dae86c610b" dependencies = [ "anyhow", "backtrace", @@ -1979,6 +1848,7 @@ dependencies = [ "more-asserts", "rand", "region", + "rustix", "thiserror", "wasmtime-environ", "wasmtime-fiber", @@ -1987,21 +1857,21 @@ dependencies = [ [[package]] name = "wasmtime-types" -version = "0.30.0" +version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9b01caf8a204ef634ebac99700e77ba716d3ebbb68a1abbc2ceb6b16dbec9e4" +checksum = "115bfe5c6eb6aba7e4eaa931ce225871c40280fb2cfb4ce4d3ab98d082e52fc4" dependencies = [ "cranelift-entity", "serde", "thiserror", - "wasmparser 0.80.1", + "wasmparser 0.81.0", ] [[package]] name = "wasmtime-wasi" -version = "0.30.0" +version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12b0e75c044aa4afba7f274a625a43260390fbdd8ca79e4aeed6827f7760fba2" +checksum = "4ddf6d392acc19ec77ef8d9fef14475ece646b5245e14ac0231437c605b19869" dependencies = [ "anyhow", "wasi-cap-std-sync", @@ -2049,9 +1919,9 @@ dependencies = [ [[package]] name = "wiggle" -version = "0.30.0" +version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbd408c06047cf3aa2d0408a34817da7863bcfc1e7d16c154ef92864b5fa456a" +checksum = "c2b956030cc391da52988f56bfbd43fed8c3d761fe20cf511e3eddb6cbc15c8c" dependencies = [ "anyhow", "async-trait", @@ -2064,9 +1934,9 @@ dependencies = [ [[package]] name = "wiggle-generate" -version = "0.30.0" +version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02575a1580353bd15a0bce308887ff6c9dae13fb3c60d49caf2e6dabf944b14d" +checksum = "10f3fd4dc7e543742f782816877768b6b5b2bd6e8998a9c377d898dbff964dcb" dependencies = [ "anyhow", "heck", @@ -2079,15 +1949,14 @@ dependencies = [ [[package]] name = "wiggle-macro" -version = "0.30.0" +version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74b91f637729488f0318db544b24493788a3228fed1e1ccd24abbe4fc4f92663" +checksum = "4444dd08ea99536640db03740c04245e9e2763607a4ab58440eb852789e86283" dependencies = [ "proc-macro2", "quote", "syn", "wiggle-generate", - "witx", ] [[package]] @@ -2121,16 +1990,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -[[package]] -name = "winx" -version = "0.25.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bdb79e12a5ac98f09e863b99c38c72f942a41f643ae0bb05d4d6d2633481341" -dependencies = [ - "bitflags", - "winapi", -] - [[package]] name = "winx" version = "0.29.1" @@ -2138,7 +1997,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ecd175b4077107a91bb6bbb34aa9a691d8b45314791776f78b63a1cb8a08928" dependencies = [ "bitflags", - "io-lifetimes 0.3.1", + "io-lifetimes", "winapi", ] @@ -2159,7 +2018,7 @@ name = "wizer" version = "1.3.4" dependencies = [ "anyhow", - "cap-std 0.13.10", + "cap-std", "criterion", "env_logger 0.8.4", "log", diff --git a/crates/wizer/Cargo.toml b/crates/wizer/Cargo.toml index 476acb5e075f..09606a0aa688 100644 --- a/crates/wizer/Cargo.toml +++ b/crates/wizer/Cargo.toml @@ -27,16 +27,16 @@ harness = false [dependencies] anyhow = "1.0.38" -cap-std = "0.13.10" +cap-std = "0.21.1" env_logger = { version = "0.8.2", optional = true } log = "0.4.14" rayon = "1.5.0" structopt = { version = "0.3.21", optional = true } -wasi-cap-std-sync = "0.30.0" +wasi-cap-std-sync = "0.32.0" wasm-encoder = "0.6.0" wasmparser = "0.78.2" -wasmtime = "0.30.0" -wasmtime-wasi = "0.30.0" +wasmtime = "0.32.0" +wasmtime-wasi = "0.32.0" # Enable this dependency to get messages with WAT disassemblies when certain # internal panics occur. diff --git a/crates/wizer/benches/regex.rs b/crates/wizer/benches/regex.rs index 9324e755a999..c7fc2a983abf 100644 --- a/crates/wizer/benches/regex.rs +++ b/crates/wizer/benches/regex.rs @@ -13,18 +13,13 @@ fn run_iter( let ptr = data.len() - 5; data[ptr..].copy_from_slice(b"hello"); - let run = instance.get_func(&mut store, "run").unwrap(); + let run = instance + .get_typed_func::<(i32, i32), i32, _>(&mut store, "run") + .unwrap(); let result = run - .call( - &mut store, - &[ - wasmtime::Val::I32(i32::try_from(ptr).unwrap()), - wasmtime::Val::I32(5), - ], - ) + .call(&mut store, (i32::try_from(ptr).unwrap(), 5)) .unwrap(); - assert_eq!(result.len(), 1); - assert_eq!(result[0].i32(), Some(0)); + assert_eq!(result, 0); } fn bench_regex(c: &mut Criterion) { diff --git a/crates/wizer/benches/uap.rs b/crates/wizer/benches/uap.rs index ddfb862d6854..a92a1e506700 100644 --- a/crates/wizer/benches/uap.rs +++ b/crates/wizer/benches/uap.rs @@ -19,18 +19,13 @@ fn run_iter( let data = memory.data_mut(&mut store); data[ptr..ptr + ua.len()].copy_from_slice(ua.as_bytes()); - let run = instance.get_func(&mut store, "run").unwrap(); + let run = instance + .get_typed_func::<(i32, i32), i32, _>(&mut store, "run") + .unwrap(); let result = run - .call( - &mut store, - &[ - wasmtime::Val::I32(i32::try_from(ptr).unwrap()), - wasmtime::Val::I32(5), - ], - ) + .call(&mut store, (i32::try_from(ptr).unwrap(), 5)) .unwrap(); - assert_eq!(result.len(), 1); - assert_eq!(result[0].i32(), Some(0)); + assert_eq!(result, 0); let dealloc = instance .get_typed_func::<(u32, u32, u32), (), _>(&mut store, "dealloc") diff --git a/crates/wizer/fuzz/Cargo.toml b/crates/wizer/fuzz/Cargo.toml index 80af5f599497..f8e7efc51ade 100644 --- a/crates/wizer/fuzz/Cargo.toml +++ b/crates/wizer/fuzz/Cargo.toml @@ -15,7 +15,7 @@ libfuzzer-sys = "0.4" log = "0.4.14" wasm-smith = "0.4.0" wasmprinter = "0.2.26" -wasmtime = "0.30.0" +wasmtime = "0.32.0" [dependencies.wizer] path = ".." diff --git a/crates/wizer/src/dummy.rs b/crates/wizer/src/dummy.rs index 4e54396f3b1c..0ccc1c73d0cb 100644 --- a/crates/wizer/src/dummy.rs +++ b/crates/wizer/src/dummy.rs @@ -23,7 +23,15 @@ pub fn dummy_imports( } linker - .define(imp.module(), name, dummy_extern(&mut *store, imp.ty())?) + .define( + imp.module(), + name, + dummy_extern( + &mut *store, + imp.ty(), + &format!("'{}' '{}'", imp.module(), name), + )?, + ) .unwrap(); } None => match imp.ty() { @@ -38,7 +46,11 @@ pub fn dummy_imports( } linker - .define(imp.module(), ty.name(), dummy_extern(&mut *store, ty.ty())?) + .define( + imp.module(), + ty.name(), + dummy_extern(&mut *store, ty.ty(), &format!("'{}'", imp.module()))?, + ) .unwrap(); } } @@ -49,7 +61,10 @@ pub fn dummy_imports( } linker - .define_name(imp.module(), dummy_extern(&mut *store, other)?) + .define_name( + imp.module(), + dummy_extern(&mut *store, other, &format!("'{}'", imp.module()))?, + ) .unwrap(); } }, @@ -60,28 +75,40 @@ pub fn dummy_imports( } /// Construct a dummy `Extern` from its type signature -pub fn dummy_extern(store: &mut crate::Store, ty: ExternType) -> Result { +pub fn dummy_extern(store: &mut crate::Store, ty: ExternType, name: &str) -> Result { Ok(match ty { - ExternType::Func(func_ty) => Extern::Func(dummy_func(store, func_ty)), - ExternType::Global(global_ty) => Extern::Global(dummy_global(store, global_ty)), - ExternType::Table(table_ty) => Extern::Table(dummy_table(store, table_ty)), - ExternType::Memory(mem_ty) => Extern::Memory(dummy_memory(store, mem_ty)?), - ExternType::Instance(instance_ty) => Extern::Instance(dummy_instance(store, instance_ty)), - ExternType::Module(module_ty) => Extern::Module(dummy_module(store, module_ty)), + ExternType::Func(func_ty) => Extern::Func(dummy_func(store, func_ty, name)), + ExternType::Instance(instance_ty) => { + Extern::Instance(dummy_instance(store, instance_ty, name)?) + } + ExternType::Global(_) => { + anyhow::bail!("Error: attempted to import unknown global: {}", name) + } + ExternType::Table(_) => anyhow::bail!("Error: attempted to import unknown table: {}", name), + ExternType::Memory(_) => { + anyhow::bail!("Error: attempted to import unknown memory: {}", name) + } + ExternType::Module(_) => { + anyhow::bail!("Error: attempted to import unknown module: {}", name) + } }) } /// Construct a dummy function for the given function type -pub fn dummy_func(store: &mut crate::Store, ty: FuncType) -> Func { - Func::new(store, ty.clone(), move |_, _, results| { - for (ret_ty, result) in ty.results().zip(results) { - *result = dummy_value(ret_ty); - } - Ok(()) +pub fn dummy_func(store: &mut crate::Store, ty: FuncType, name: &str) -> Func { + let name = name.to_string(); + Func::new(store, ty.clone(), move |_caller, _params, _results| { + Err(Trap::new(format!( + "Error: attempted to call an unknown imported function: {}\n\ + \n\ + You cannot call arbitrary imported functions during Wizer initialization.", + name, + ))) }) } /// Construct a dummy value for the given value type. +#[cfg(fuzzing)] pub fn dummy_value(val_ty: ValType) -> Val { match val_ty { ValType::I32 => Val::I32(0), @@ -100,48 +127,17 @@ pub fn dummy_values(val_tys: impl IntoIterator) -> Vec { val_tys.into_iter().map(dummy_value).collect() } -/// Construct a dummy global for the given global type. -pub fn dummy_global(store: &mut crate::Store, ty: GlobalType) -> Global { - let val = dummy_value(ty.content().clone()); - Global::new(store, ty, val).unwrap() -} - -/// Construct a dummy table for the given table type. -pub fn dummy_table(store: &mut crate::Store, ty: TableType) -> Table { - let init_val = dummy_value(ty.element().clone()); - Table::new(store, ty, init_val).unwrap() -} - -/// Construct a dummy memory for the given memory type. -pub fn dummy_memory(store: &mut crate::Store, ty: MemoryType) -> Result { - Memory::new(store, ty) -} - /// Construct a dummy instance for the given instance type. /// /// This is done by using the expected type to generate a module on-the-fly /// which we the instantiate. -pub fn dummy_instance(store: &mut crate::Store, ty: InstanceType) -> Instance { +pub fn dummy_instance(store: &mut crate::Store, ty: InstanceType, name: &str) -> Result { let mut wat = WatGenerator::new(); for ty in ty.exports() { - wat.export(&ty); + wat.export(&ty, name)?; } let module = Module::new(store.engine(), &wat.finish()).unwrap(); - Instance::new(store, &module, &[]).unwrap() -} - -/// Construct a dummy module for the given module type. -/// -/// This is done by using the expected type to generate a module on-the-fly. -pub fn dummy_module(store: &mut crate::Store, ty: ModuleType) -> Module { - let mut wat = WatGenerator::new(); - for ty in ty.imports() { - wat.import(&ty); - } - for ty in ty.exports() { - wat.export(&ty); - } - Module::new(store.engine(), &wat.finish()).unwrap() + Ok(Instance::new(store, &module, &[])?) } struct WatGenerator { @@ -162,148 +158,51 @@ impl WatGenerator { self.dst } - fn import(&mut self, ty: &ImportType<'_>) { - write!(self.dst, "(import ").unwrap(); - self.str(ty.module()); - write!(self.dst, " ").unwrap(); - if let Some(field) = ty.name() { - self.str(field); - write!(self.dst, " ").unwrap(); - } - self.item_ty(&ty.ty()); - writeln!(self.dst, ")").unwrap(); - } - - fn item_ty(&mut self, ty: &ExternType) { - match ty { - ExternType::Memory(mem) => { - write!( - self.dst, - "(memory {} {})", - mem.minimum(), - match mem.maximum() { - Some(max) => max.to_string(), - None => String::new(), - } - ) - .unwrap(); - } - ExternType::Table(table) => { - write!( - self.dst, - "(table {} {} {})", - table.minimum(), - match table.maximum() { - Some(max) => max.to_string(), - None => String::new(), - }, - wat_ty(&table.element()), - ) - .unwrap(); - } - ExternType::Global(ty) => { - if ty.mutability() == Mutability::Const { - write!(self.dst, "(global {})", wat_ty(ty.content())).unwrap(); - } else { - write!(self.dst, "(global (mut {}))", wat_ty(ty.content())).unwrap(); - } - } - ExternType::Func(ty) => { - write!(self.dst, "(func ").unwrap(); - self.func_sig(ty); - write!(self.dst, ")").unwrap(); - } - ExternType::Instance(ty) => { - writeln!(self.dst, "(instance").unwrap(); - for ty in ty.exports() { - write!(self.dst, "(export ").unwrap(); - self.str(ty.name()); - write!(self.dst, " ").unwrap(); - self.item_ty(&ty.ty()); - writeln!(self.dst, ")").unwrap(); - } - write!(self.dst, ")").unwrap(); - } - ExternType::Module(ty) => { - writeln!(self.dst, "(module").unwrap(); - for ty in ty.imports() { - self.import(&ty); - writeln!(self.dst, "").unwrap(); - } - for ty in ty.exports() { - write!(self.dst, "(export ").unwrap(); - self.str(ty.name()); - write!(self.dst, " ").unwrap(); - self.item_ty(&ty.ty()); - writeln!(self.dst, ")").unwrap(); - } - write!(self.dst, ")").unwrap(); - } - } - } - - fn export(&mut self, ty: &ExportType<'_>) { + fn export(&mut self, ty: &ExportType<'_>, instance_name: &str) -> Result<()> { let wat_name = format!("item{}", self.tmp); self.tmp += 1; let item_ty = ty.ty(); - self.item(&wat_name, &item_ty); + self.item(&wat_name, &item_ty, instance_name, ty.name())?; write!(self.dst, "(export ").unwrap(); self.str(ty.name()); write!(self.dst, " (").unwrap(); match item_ty { - ExternType::Memory(_) => write!(self.dst, "memory").unwrap(), - ExternType::Global(_) => write!(self.dst, "global").unwrap(), ExternType::Func(_) => write!(self.dst, "func").unwrap(), ExternType::Instance(_) => write!(self.dst, "instance").unwrap(), - ExternType::Table(_) => write!(self.dst, "table").unwrap(), - ExternType::Module(_) => write!(self.dst, "module").unwrap(), + ExternType::Memory(_) => anyhow::bail!( + "Error: attempted to import unknown memory: '{}' '{}'", + instance_name, + ty.name() + ), + ExternType::Global(_) => anyhow::bail!( + "Error: attempted to import unknown global: '{}' '{}'", + instance_name, + ty.name() + ), + ExternType::Table(_) => anyhow::bail!( + "Error: attempted to import unknown table: '{}' '{}'", + instance_name, + ty.name() + ), + ExternType::Module(_) => anyhow::bail!( + "Error: attempted to import unknown module: '{}' '{}'", + instance_name, + ty.name() + ), } writeln!(self.dst, " ${}))", wat_name).unwrap(); + Ok(()) } - fn item(&mut self, name: &str, ty: &ExternType) { + fn item( + &mut self, + name: &str, + ty: &ExternType, + instance_name: &str, + item_name: &str, + ) -> Result<()> { match ty { - ExternType::Memory(mem) => { - write!( - self.dst, - "(memory ${} {} {})\n", - name, - mem.minimum(), - match mem.maximum() { - Some(max) => max.to_string(), - None => String::new(), - } - ) - .unwrap(); - } - ExternType::Table(table) => { - write!( - self.dst, - "(table ${} {} {} {})\n", - name, - table.minimum(), - match table.maximum() { - Some(max) => max.to_string(), - None => String::new(), - }, - wat_ty(&table.element()), - ) - .unwrap(); - } - ExternType::Global(ty) => { - write!(self.dst, "(global ${} ", name).unwrap(); - if ty.mutability() == Mutability::Var { - write!(self.dst, "(mut ").unwrap(); - } - write!(self.dst, "{}", wat_ty(ty.content())).unwrap(); - if ty.mutability() == Mutability::Var { - write!(self.dst, ")").unwrap(); - } - write!(self.dst, " (").unwrap(); - self.value(ty.content()); - writeln!(self.dst, "))").unwrap(); - } ExternType::Func(ty) => { write!(self.dst, "(func ${} ", name).unwrap(); self.func_sig(ty); @@ -313,25 +212,36 @@ impl WatGenerator { } writeln!(self.dst, ")").unwrap(); } - ExternType::Module(ty) => { - writeln!(self.dst, "(module ${}", name).unwrap(); - for ty in ty.imports() { - self.import(&ty); - } - for ty in ty.exports() { - self.export(&ty); - } - self.dst.push_str(")\n"); - } ExternType::Instance(ty) => { writeln!(self.dst, "(module ${}_module", name).unwrap(); for ty in ty.exports() { - self.export(&ty); + self.export(&ty, instance_name)?; } self.dst.push_str(")\n"); writeln!(self.dst, "(instance ${} (instantiate ${0}_module))", name).unwrap(); } + ExternType::Memory(_) => anyhow::bail!( + "Error: attempted to import unknown memory: '{}' '{}'", + instance_name, + item_name + ), + ExternType::Global(_) => anyhow::bail!( + "Error: attempted to import unknown global: '{}' '{}'", + instance_name, + item_name + ), + ExternType::Table(_) => anyhow::bail!( + "Error: attempted to import unknown table: '{}' '{}'", + instance_name, + item_name + ), + ExternType::Module(_) => anyhow::bail!( + "Error: attempted to import unknown module: '{}' '{}'", + instance_name, + item_name + ), } + Ok(()) } fn func_sig(&mut self, ty: &FuncType) { @@ -413,40 +323,11 @@ mod tests { Store::new(&engine, None) } - #[test] - fn dummy_table_import() { - let mut store = store(); - let table = dummy_table(&mut store, TableType::new(ValType::ExternRef, 10, None)); - assert_eq!(table.size(&store), 10); - for i in 0..10 { - assert!(table - .get(&mut store, i) - .unwrap() - .unwrap_externref() - .is_none()); - } - } - - #[test] - fn dummy_global_import() { - let mut store = store(); - let global = dummy_global(&mut store, GlobalType::new(ValType::I32, Mutability::Const)); - assert_eq!(*global.ty(&store).content(), ValType::I32); - assert_eq!(global.ty(&store).mutability(), Mutability::Const); - } - - #[test] - fn dummy_memory_import() { - let mut store = store(); - let memory = dummy_memory(&mut store, MemoryType::new(1, None)).unwrap(); - assert_eq!(memory.size(&store), 1); - } - #[test] fn dummy_function_import() { let mut store = store(); let func_ty = FuncType::new(vec![ValType::I32], vec![ValType::I64]); - let func = dummy_func(&mut store, func_ty.clone()); + let func = dummy_func(&mut store, func_ty.clone(), "f"); assert_eq!(func.ty(&store), func_ty); } @@ -460,160 +341,19 @@ mod tests { instance_ty.add_named_export("func0", FuncType::new(vec![ValType::I32], vec![]).into()); instance_ty.add_named_export("func1", FuncType::new(vec![], vec![ValType::I64]).into()); - // Globals. - instance_ty.add_named_export( - "global0", - GlobalType::new(ValType::I32, Mutability::Const).into(), - ); - instance_ty.add_named_export( - "global1", - GlobalType::new(ValType::I64, Mutability::Var).into(), - ); - - // Tables. - instance_ty.add_named_export("table0", TableType::new(ValType::ExternRef, 1, None).into()); - instance_ty.add_named_export("table1", TableType::new(ValType::ExternRef, 1, None).into()); - - // Memories. - instance_ty.add_named_export("memory0", MemoryType::new(1, None).into()); - instance_ty.add_named_export("memory1", MemoryType::new(1, None).into()); - - // Modules. - instance_ty.add_named_export("module0", ModuleType::new().into()); - instance_ty.add_named_export("module1", ModuleType::new().into()); - // Instances. instance_ty.add_named_export("instance0", InstanceType::new().into()); instance_ty.add_named_export("instance1", InstanceType::new().into()); - let instance = dummy_instance(&mut store, instance_ty.clone()); - - let mut expected_exports = vec![ - "func0", - "func1", - "global0", - "global1", - "table0", - "table1", - "memory0", - "memory1", - "module0", - "module1", - "instance0", - "instance1", - ] - .into_iter() - .collect::>(); + let instance = dummy_instance(&mut store, instance_ty.clone(), "instance").unwrap(); + + let mut expected_exports = vec!["func0", "func1", "instance0", "instance1"] + .into_iter() + .collect::>(); for exp in instance.ty(&store).exports() { let was_expected = expected_exports.remove(exp.name()); assert!(was_expected); } assert!(expected_exports.is_empty()); } - - #[test] - fn dummy_module_import() { - let mut store = store(); - - let mut module_ty = ModuleType::new(); - - // Multiple exported and imported functions. - module_ty.add_named_export("func0", FuncType::new(vec![ValType::I32], vec![]).into()); - module_ty.add_named_export("func1", FuncType::new(vec![], vec![ValType::I64]).into()); - module_ty.add_named_import( - "func2", - None, - FuncType::new(vec![ValType::I64], vec![]).into(), - ); - module_ty.add_named_import( - "func3", - None, - FuncType::new(vec![], vec![ValType::I32]).into(), - ); - - // Multiple exported and imported globals. - module_ty.add_named_export( - "global0", - GlobalType::new(ValType::I32, Mutability::Const).into(), - ); - module_ty.add_named_export( - "global1", - GlobalType::new(ValType::I64, Mutability::Var).into(), - ); - module_ty.add_named_import( - "global2", - None, - GlobalType::new(ValType::I32, Mutability::Var).into(), - ); - module_ty.add_named_import( - "global3", - None, - GlobalType::new(ValType::I64, Mutability::Const).into(), - ); - - // Multiple exported and imported tables. - module_ty.add_named_export("table0", TableType::new(ValType::ExternRef, 1, None).into()); - module_ty.add_named_export("table1", TableType::new(ValType::ExternRef, 1, None).into()); - module_ty.add_named_import( - "table2", - None, - TableType::new(ValType::ExternRef, 1, None).into(), - ); - module_ty.add_named_import( - "table3", - None, - TableType::new(ValType::ExternRef, 1, None).into(), - ); - - // Multiple exported and imported memories. - module_ty.add_named_export("memory0", MemoryType::new(1, None).into()); - module_ty.add_named_export("memory1", MemoryType::new(1, None).into()); - module_ty.add_named_import("memory2", None, MemoryType::new(1, None).into()); - module_ty.add_named_import("memory3", None, MemoryType::new(1, None).into()); - - // An exported and an imported module. - module_ty.add_named_export("module0", ModuleType::new().into()); - module_ty.add_named_import("module1", None, ModuleType::new().into()); - - // An exported and an imported instance. - module_ty.add_named_export("instance0", InstanceType::new().into()); - module_ty.add_named_import("instance1", None, InstanceType::new().into()); - - // Create the module. - let module = dummy_module(&mut store, module_ty); - - // Check that we have the expected exports. - assert!(module.get_export("func0").is_some()); - assert!(module.get_export("func1").is_some()); - assert!(module.get_export("global0").is_some()); - assert!(module.get_export("global1").is_some()); - assert!(module.get_export("table0").is_some()); - assert!(module.get_export("table1").is_some()); - assert!(module.get_export("memory0").is_some()); - assert!(module.get_export("memory1").is_some()); - assert!(module.get_export("instance0").is_some()); - assert!(module.get_export("module0").is_some()); - - // Check that we have the exported imports. - let mut expected_imports = vec![ - "func2", - "func3", - "global2", - "global3", - "table2", - "table3", - "memory2", - "memory3", - "instance1", - "module1", - ] - .into_iter() - .collect::>(); - for imp in module.imports() { - assert!(imp.name().is_none()); - let was_expected = expected_imports.remove(imp.module()); - assert!(was_expected); - } - assert!(expected_imports.is_empty()); - } } diff --git a/crates/wizer/tests/tests.rs b/crates/wizer/tests/tests.rs index 4a857e760ddd..c747cd074d37 100644 --- a/crates/wizer/tests/tests.rs +++ b/crates/wizer/tests/tests.rs @@ -1,21 +1,25 @@ -use anyhow::Context; +use anyhow::{Context, Result}; use wat::parse_str as wat_to_wasm; use wizer::Wizer; -fn run_wat(args: &[wasmtime::Val], expected: i32, wat: &str) -> anyhow::Result<()> { +fn run_wat(args: &[wasmtime::Val], expected: i32, wat: &str) -> Result<()> { let _ = env_logger::try_init(); let wasm = wat_to_wasm(wat)?; run_wasm(args, expected, &wasm) } -fn run_wasm(args: &[wasmtime::Val], expected: i32, wasm: &[u8]) -> anyhow::Result<()> { - let _ = env_logger::try_init(); - +fn get_wizer() -> Wizer { let mut wizer = Wizer::new(); wizer.allow_wasi(true); wizer.wasm_multi_memory(true); wizer.wasm_module_linking(true); - let wasm = wizer.run(&wasm)?; + wizer +} + +fn run_wasm(args: &[wasmtime::Val], expected: i32, wasm: &[u8]) -> Result<()> { + let _ = env_logger::try_init(); + + let wasm = get_wizer().run(&wasm)?; log::debug!( "=== Wizened Wasm ==========================================================\n\ {}\n\ @@ -45,6 +49,8 @@ fn run_wasm(args: &[wasmtime::Val], expected: i32, wasm: &[u8]) -> anyhow::Resul linker .define_name("dummy_func", wasmtime::Func::wrap(&mut store, || {}))? .define("env", "f", wasmtime::Func::wrap(&mut store, || {}))? + .define_name("f", wasmtime::Func::wrap(&mut store, || {}))? + .define("x", "f", wasmtime::Func::wrap(&mut store, || {}))? .define_name("dummy_instance", dummy_instance)?; wasmtime_wasi::add_to_linker(&mut linker, |wasi| wasi)?; @@ -55,7 +61,8 @@ fn run_wasm(args: &[wasmtime::Val], expected: i32, wasm: &[u8]) -> anyhow::Resul .get_func(&mut store, "run") .ok_or_else(|| anyhow::anyhow!("the test Wasm module does not export a `run` function"))?; - let actual = run.call(&mut store, args)?; + let mut actual = vec![wasmtime::Val::I32(0)]; + run.call(&mut store, args, &mut actual)?; anyhow::ensure!(actual.len() == 1, "expected one result"); let actual = match actual[0] { wasmtime::Val::I32(x) => x, @@ -71,8 +78,30 @@ fn run_wasm(args: &[wasmtime::Val], expected: i32, wasm: &[u8]) -> anyhow::Resul Ok(()) } +fn fails_wizening(wat: &str) -> Result<()> { + let _ = env_logger::try_init(); + + let wasm = wat_to_wasm(wat)?; + + let mut validator = wasmparser::Validator::new(); + validator.wasm_features(wasmparser::WasmFeatures { + module_linking: true, + multi_memory: true, + ..Default::default() + }); + validator + .validate_all(&wasm) + .context("initial Wasm should be valid")?; + + anyhow::ensure!( + get_wizer().run(&wasm).is_err(), + "Expected an error when wizening, but didn't get one" + ); + Ok(()) +} + #[test] -fn basic_global() -> anyhow::Result<()> { +fn basic_global() -> Result<()> { run_wat( &[], 42, @@ -89,7 +118,7 @@ fn basic_global() -> anyhow::Result<()> { } #[test] -fn basic_memory() -> anyhow::Result<()> { +fn basic_memory() -> Result<()> { run_wat( &[], 42, @@ -108,7 +137,7 @@ fn basic_memory() -> anyhow::Result<()> { } #[test] -fn multi_memory() -> anyhow::Result<()> { +fn multi_memory() -> Result<()> { run_wat( &[], 42, @@ -134,49 +163,37 @@ fn multi_memory() -> anyhow::Result<()> { } #[test] -fn reject_imported_memory() -> anyhow::Result<()> { - assert!(run_wat( - &[], - 42, +fn reject_imported_memory() -> Result<()> { + fails_wizening( r#" -(module - (import "" "" (memory 1))) -"#, + (module + (import "" "" (memory 1))) + "#, ) - .is_err()); - Ok(()) } #[test] -fn reject_imported_global() -> anyhow::Result<()> { - assert!(run_wat( - &[], - 42, +fn reject_imported_global() -> Result<()> { + fails_wizening( r#" -(module - (import "" "" (global i32))) -"#, + (module + (import "" "" (global i32))) + "#, ) - .is_err()); - Ok(()) } #[test] -fn reject_imported_table() -> anyhow::Result<()> { - assert!(run_wat( - &[], - 42, +fn reject_imported_table() -> Result<()> { + fails_wizening( r#" -(module - (import "" "" (table))) -"#, + (module + (import "" "" (table 0 externref))) + "#, ) - .is_err()); - Ok(()) } #[test] -fn reject_bulk_memory() -> anyhow::Result<()> { +fn reject_bulk_memory() -> Result<()> { let result = run_wat( &[], 42, @@ -209,7 +226,7 @@ fn reject_bulk_memory() -> anyhow::Result<()> { } #[test] -fn accept_module_linking_import_memory() -> anyhow::Result<()> { +fn accept_module_linking_import_memory() -> Result<()> { run_wat( &[], 42, @@ -234,7 +251,7 @@ fn accept_module_linking_import_memory() -> anyhow::Result<()> { } #[test] -fn accept_module_linking_import_global() -> anyhow::Result<()> { +fn accept_module_linking_import_global() -> Result<()> { run_wat( &[], 42, @@ -259,7 +276,7 @@ fn accept_module_linking_import_global() -> anyhow::Result<()> { } #[test] -fn accept_module_linking_import_table() -> anyhow::Result<()> { +fn accept_module_linking_import_table() -> Result<()> { run_wat( &[], 42, @@ -284,7 +301,7 @@ fn accept_module_linking_import_table() -> anyhow::Result<()> { } #[test] -fn module_linking_actually_works() -> anyhow::Result<()> { +fn module_linking_actually_works() -> Result<()> { run_wat( &[], 42, @@ -316,7 +333,7 @@ fn module_linking_actually_works() -> anyhow::Result<()> { } #[test] -fn module_linking_nested_instantiations_1() -> anyhow::Result<()> { +fn module_linking_nested_instantiations_1() -> Result<()> { run_wat( &[], 8, @@ -376,7 +393,7 @@ fn module_linking_nested_instantiations_1() -> anyhow::Result<()> { } #[test] -fn module_linking_nested_instantiations_0() -> anyhow::Result<()> { +fn module_linking_nested_instantiations_0() -> Result<()> { run_wat( &[], 42, @@ -422,7 +439,7 @@ fn module_linking_nested_instantiations_0() -> anyhow::Result<()> { // Test that we handle repeated and interleaved initial sections. #[test] -fn multiple_initial_sections() -> anyhow::Result<()> { +fn multiple_initial_sections() -> Result<()> { run_wat( &[], 42, @@ -485,7 +502,7 @@ fn multiple_initial_sections() -> anyhow::Result<()> { } #[test] -fn start_sections_in_nested_modules() -> anyhow::Result<()> { +fn start_sections_in_nested_modules() -> Result<()> { run_wat( &[], 42, @@ -522,7 +539,7 @@ fn start_sections_in_nested_modules() -> anyhow::Result<()> { } #[test] -fn allow_function_imports_module_linking() -> anyhow::Result<()> { +fn allow_function_imports_module_linking() -> Result<()> { // Make sure that the umbrella module passes imports through to its // instantiation of the root, and that the root can pass them along to its // nested instantiations as well. @@ -547,7 +564,7 @@ fn allow_function_imports_module_linking() -> anyhow::Result<()> { } #[test] -fn outer_module_alias() -> anyhow::Result<()> { +fn outer_module_alias() -> Result<()> { run_wat( &[], 42, @@ -582,7 +599,7 @@ fn outer_module_alias() -> anyhow::Result<()> { } #[test] -fn instance_alias_without_entry_in_type_section() -> anyhow::Result<()> { +fn instance_alias_without_entry_in_type_section() -> Result<()> { run_wat( &[], 42, @@ -609,7 +626,7 @@ fn instance_alias_without_entry_in_type_section() -> anyhow::Result<()> { } #[test] -fn two_level_imports_and_implicit_instance_imports() -> anyhow::Result<()> { +fn two_level_imports_and_implicit_instance_imports() -> Result<()> { run_wat( &[], 42, @@ -646,7 +663,7 @@ fn two_level_imports_and_implicit_instance_imports() -> anyhow::Result<()> { } #[test] -fn implicit_instance_imports_and_other_instances() -> anyhow::Result<()> { +fn implicit_instance_imports_and_other_instances() -> Result<()> { // Test how implicit instance import injection interacts with explicit // instance imports and explicit instantiations. run_wat( @@ -708,7 +725,7 @@ fn implicit_instance_imports_and_other_instances() -> anyhow::Result<()> { } #[test] -fn rust_regex() -> anyhow::Result<()> { +fn rust_regex() -> Result<()> { run_wasm( &[wasmtime::Val::I32(13)], 42, @@ -717,7 +734,7 @@ fn rust_regex() -> anyhow::Result<()> { } #[test] -fn data_segment_at_end_of_memory() -> anyhow::Result<()> { +fn data_segment_at_end_of_memory() -> Result<()> { // Test that we properly synthesize data segments for data at the end of // memory. run_wat( @@ -742,7 +759,7 @@ fn data_segment_at_end_of_memory() -> anyhow::Result<()> { } #[test] -fn too_many_data_segments_for_engines() -> anyhow::Result<()> { +fn too_many_data_segments_for_engines() -> Result<()> { run_wat( &[], 42, @@ -787,7 +804,7 @@ fn too_many_data_segments_for_engines() -> anyhow::Result<()> { } #[test] -fn rename_functions() -> anyhow::Result<()> { +fn rename_functions() -> Result<()> { let wat = r#" (module (func (export "wizer.initialize")) @@ -827,7 +844,7 @@ fn rename_functions() -> anyhow::Result<()> { } #[test] -fn renames_and_module_linking() -> anyhow::Result<()> { +fn renames_and_module_linking() -> Result<()> { let wat = r#" (module (module $A @@ -880,19 +897,120 @@ fn wasi_reactor() -> anyhow::Result<()> { &[], 42, r#" -(module - (global $g (mut i32) i32.const 0) - (func (export "_initialize") - i32.const 6 - global.set $g - ) - (func (export "wizer.initialize") - global.get $g - i32.const 7 - i32.mul - global.set $g) - (func (export "run") (result i32) - global.get $g)) + (module + (global $g (mut i32) i32.const 0) + (func (export "_initialize") + i32.const 6 + global.set $g + ) + (func (export "wizer.initialize") + global.get $g + i32.const 7 + i32.mul + global.set $g) + (func (export "run") (result i32) + global.get $g + ) + ) + "#, + ) +} + +#[test] +fn call_undefined_import_function_during_init() -> Result<()> { + fails_wizening( + r#" + (module + (import "x" "f" (func $import)) + (func (export "wizer.initialize") + (call $import) + ) + ) + "#, + ) +} + +#[test] +fn allow_undefined_import_function() -> Result<()> { + run_wat( + &[], + 42, + r#" + (module + (import "x" "f" (func $import)) + (func (export "wizer.initialize")) + (func (export "run") (result i32) + i32.const 42 + ) + ) + "#, + ) +} + +#[test] +fn call_undefined_instance_import_function_during_init() -> Result<()> { + fails_wizening( + r#" + (module + (import "x" (instance (export "f" (func)))) + (alias 0 "f" (func $import)) + (func (export "wizer.initialize") + (call $import) + ) + ) + "#, + ) +} + +#[test] +fn allow_undefined_instance_import_function() -> Result<()> { + run_wat( + &[], + 42, + r#" + (module + (import "x" (instance (export "f" (func)))) + (func (export "wizer.initialize")) + (func (export "run") (result i32) + i32.const 42 + ) + ) + "#, + ) +} + +#[test] +fn reject_import_instance_global() -> Result<()> { + fails_wizening( + r#" + (module + (import "x" (instance (export "g" (global i32)))) + (func (export "wizer.initialize")) + ) + "#, + ) +} + +#[test] +fn reject_import_instance_table() -> Result<()> { + fails_wizening( + r#" + (module + (import "x" (instance (export "t" (table 0 externref)))) + (func (export "wizer.initialize")) + ) + "#, + ) +} + +#[test] +fn reject_import_instance_memory() -> Result<()> { + fails_wizening( + r#" + (module + (import "x" (instance (export "m" (memory 0)))) + (func (export "wizer.initialize")) + ) "#, ) } From 6e6baedb192f39abfc371a6d0f7eb1bf671e497d Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Wed, 5 Jan 2022 12:48:47 -0800 Subject: [PATCH 085/212] Add a CI job to check that the fuzz targets build okay --- crates/wizer/.github/workflows/ci.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/crates/wizer/.github/workflows/ci.yml b/crates/wizer/.github/workflows/ci.yml index c6251bf3aeec..194bba16a0a9 100644 --- a/crates/wizer/.github/workflows/ci.yml +++ b/crates/wizer/.github/workflows/ci.yml @@ -46,6 +46,13 @@ jobs: name: bins-${{ matrix.build }} path: dist + check_fuzz: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - run: cargo install cargo-fuzz + - run: cargo fuzz build --dev -s none + rustfmt: runs-on: ubuntu-latest steps: From 785440bc2ea11e9b192ca4efa062b3cc8cca7c53 Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Wed, 5 Jan 2022 13:00:46 -0800 Subject: [PATCH 086/212] Fix the fuzz target for the recent Wasmtime dep upgrade --- crates/wizer/fuzz/fuzz_targets/same_result.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/crates/wizer/fuzz/fuzz_targets/same_result.rs b/crates/wizer/fuzz/fuzz_targets/same_result.rs index 24bd14b13041..f943136764b0 100644 --- a/crates/wizer/fuzz/fuzz_targets/same_result.rs +++ b/crates/wizer/fuzz/fuzz_targets/same_result.rs @@ -98,7 +98,10 @@ fuzz_target!(|module: wasm_smith::ConfiguredModule| { let snapshot_instance = Instance::new(&mut store, &snapshot_module, &[]).unwrap(); let snapshot_main_func = snapshot_instance.get_func(&mut store, main_func).unwrap(); let main_args = wizer::dummy::dummy_values(snapshot_main_func.ty(&store).params()); - let snapshot_result = snapshot_main_func.call(&mut store, &main_args); + let mut snapshot_result = + vec![wasmtime::Val::I32(0); snapshot_main_func.ty(&store).results().len()]; + let snapshot_call_result = + snapshot_main_func.call(&mut store, &main_args, &mut snapshot_result); // Instantiate the original Wasm and then call the initialization // and main functions back to back. @@ -108,12 +111,13 @@ fuzz_target!(|module: wasm_smith::ConfiguredModule| { .unwrap(); init_func.call(&mut store, ()).unwrap(); let main_func = instance.get_func(&mut store, main_func).unwrap(); - let result = main_func.call(&mut store, &main_args); + let mut result = vec![wasmtime::Val::I32(0); main_func.ty(&store).results().len()]; + let call_result = main_func.call(&mut store, &main_args, &mut result); // Check that the function return values / traps are the same. - match (snapshot_result, result) { + match (snapshot_call_result, call_result) { // Both did not trap. - (Ok(snapshot_result), Ok(result)) => { + (Ok(()), Ok(())) => { assert_eq!(snapshot_result.len(), result.len()); for (s, r) in snapshot_result.iter().zip(result.iter()) { assert_val_eq(s, r); From ca909f63ea8a964b762fa4e73ac241c5d12d3ddb Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Wed, 5 Jan 2022 13:01:30 -0800 Subject: [PATCH 087/212] Bump to version 1.3.5 --- crates/wizer/Cargo.lock | 2 +- crates/wizer/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/wizer/Cargo.lock b/crates/wizer/Cargo.lock index f0fbec3a5255..5e4a4448de48 100644 --- a/crates/wizer/Cargo.lock +++ b/crates/wizer/Cargo.lock @@ -2015,7 +2015,7 @@ dependencies = [ [[package]] name = "wizer" -version = "1.3.4" +version = "1.3.5" dependencies = [ "anyhow", "cap-std", diff --git a/crates/wizer/Cargo.toml b/crates/wizer/Cargo.toml index 09606a0aa688..08e6ec50a7a3 100644 --- a/crates/wizer/Cargo.toml +++ b/crates/wizer/Cargo.toml @@ -9,7 +9,7 @@ license = "Apache-2.0 WITH LLVM-exception" name = "wizer" readme = "./README.md" repository = "https://github.com/bytecodealliance/wizer" -version = "1.3.4" +version = "1.3.5" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html From 2e0ecdd2d3c55f70799bf6587077b677896a38e4 Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Tue, 25 Jan 2022 18:49:45 +0900 Subject: [PATCH 088/212] Allow to map host directory as arbitary guest path --- crates/wizer/src/lib.rs | 46 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/crates/wizer/src/lib.rs b/crates/wizer/src/lib.rs index f1b62a971b94..6b694aaf33b8 100644 --- a/crates/wizer/src/lib.rs +++ b/crates/wizer/src/lib.rs @@ -41,6 +41,15 @@ pub(crate) type Store = wasmtime::Store>; /// context. pub(crate) type Linker = wasmtime::Linker>; +#[cfg(feature = "structopt")] +fn parse_map_dirs(s: &str) -> anyhow::Result<(PathBuf, PathBuf)> { + let parts: Vec<&str> = s.split("::").collect(); + if parts.len() != 2 { + anyhow::bail!("must contain exactly one double colon ('::')"); + } + Ok((parts[0].into(), parts[1].into())) +} + /// Wizer: the WebAssembly pre-initializer! /// /// Don't wait for your Wasm module to initialize itself, pre-initialize it! @@ -143,6 +152,16 @@ pub struct Wizer { )] dirs: Vec, + /// When using WASI during initialization, which file guest system directories + /// should be mapped as a host directory? + /// + /// None are mapped by default. + #[cfg_attr( + feature = "structopt", + structopt(long = "mapdir", value_name = "GUEST_DIR::HOST_DIR", parse(try_from_str = parse_map_dirs)) + )] + map_dirs: Vec<(PathBuf, PathBuf)>, + /// Enable or disable Wasm multi-memory proposal. /// /// Enabled by default. @@ -213,6 +232,7 @@ impl Wizer { inherit_stdio: None, inherit_env: None, dirs: vec![], + map_dirs: vec![], wasm_multi_memory: None, wasm_multi_value: None, wasm_module_linking: None, @@ -279,6 +299,19 @@ impl Wizer { self } + /// When using WASI during initialization, which file guest system directories + /// should be mapped as a host directory? + /// + /// None are mapped by default. + pub fn map_dir( + &mut self, + guest_dir: impl Into, + host_dir: impl Into, + ) -> &mut Self { + self.map_dirs.push((guest_dir.into(), host_dir.into())); + self + } + /// Enable or disable the Wasm multi-memory proposal. /// /// Defaults to `true`. @@ -545,6 +578,19 @@ impl Wizer { .with_context(|| format!("failed to open directory: {}", dir.display()))?; ctx = ctx.preopened_dir(preopened, dir)?; } + for (guest_dir, host_dir) in &self.map_dirs { + log::debug!( + "Preopening directory: {}::{}", + guest_dir.display(), + host_dir.display() + ); + let preopened = wasmtime_wasi::sync::Dir::open_ambient_dir( + host_dir, + wasmtime_wasi::sync::ambient_authority(), + ) + .with_context(|| format!("failed to open directory: {}", host_dir.display()))?; + ctx = ctx.preopened_dir(preopened, guest_dir)?; + } Ok(Some(ctx.build())) } From 7917216415c3eaee640c4eba90730358f9c43a82 Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Wed, 26 Jan 2022 12:40:15 -0800 Subject: [PATCH 089/212] Update docs for `--mapdir` --- crates/wizer/src/lib.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/crates/wizer/src/lib.rs b/crates/wizer/src/lib.rs index 6b694aaf33b8..16802a379d70 100644 --- a/crates/wizer/src/lib.rs +++ b/crates/wizer/src/lib.rs @@ -152,8 +152,12 @@ pub struct Wizer { )] dirs: Vec, - /// When using WASI during initialization, which file guest system directories - /// should be mapped as a host directory? + /// When using WASI during initialization, which guest directories should be + /// mapped to a host directory? + /// + /// The `--mapdir` option differs from `--dir` in that it allows giving a + /// custom guest name to the directory that is different from its name in + /// the host. /// /// None are mapped by default. #[cfg_attr( From 2c22b468c905004f041cae9b8038af44699e49a3 Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Wed, 26 Jan 2022 12:40:30 -0800 Subject: [PATCH 090/212] Update docs for `Wizer::map_dir` --- crates/wizer/src/lib.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/crates/wizer/src/lib.rs b/crates/wizer/src/lib.rs index 16802a379d70..8d5d1fb2bdc1 100644 --- a/crates/wizer/src/lib.rs +++ b/crates/wizer/src/lib.rs @@ -303,8 +303,11 @@ impl Wizer { self } - /// When using WASI during initialization, which file guest system directories - /// should be mapped as a host directory? + /// When using WASI during initialization, which guest directories should be + /// mapped to a host directory? + /// + /// The `map_dir` method differs from `dir` in that it allows giving a custom + /// guest name to the directory that is different from its name in the host. /// /// None are mapped by default. pub fn map_dir( From 657fa6f90962c73bf88a21af6118c69e75ed50b1 Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Wed, 26 Jan 2022 21:49:07 +0900 Subject: [PATCH 091/212] Add an option to keep init-func after initialization --- crates/wizer/src/lib.rs | 19 +++++++++++++++++++ crates/wizer/src/rewrite.rs | 7 ++++--- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/crates/wizer/src/lib.rs b/crates/wizer/src/lib.rs index 8d5d1fb2bdc1..290dd6dcdfea 100644 --- a/crates/wizer/src/lib.rs +++ b/crates/wizer/src/lib.rs @@ -29,6 +29,7 @@ use wasmtime_wasi::WasiCtx; const DEFAULT_INHERIT_STDIO: bool = true; const DEFAULT_INHERIT_ENV: bool = false; +const DEFAULT_KEEP_INIT_FUNC: bool = false; const DEFAULT_WASM_MULTI_VALUE: bool = true; const DEFAULT_WASM_MULTI_MEMORY: bool = true; const DEFAULT_WASM_MODULE_LINKING: bool = false; @@ -142,6 +143,15 @@ pub struct Wizer { )] inherit_env: Option, + /// After initialization, should `init_func` be removed from the module? + /// + /// This is false by default. + #[cfg_attr( + feature = "structopt", + structopt(long = "keep-init-func", value_name = "true|false") + )] + keep_init_func: Option, + /// When using WASI during initialization, which file system directories /// should be made available? /// @@ -235,6 +245,7 @@ impl Wizer { allow_wasi: false, inherit_stdio: None, inherit_env: None, + keep_init_func: None, dirs: vec![], map_dirs: vec![], wasm_multi_memory: None, @@ -294,6 +305,14 @@ impl Wizer { self } + /// After initialization, should `init_func` be removed from the module? + /// + /// Defaults to `false`. + pub fn keep_init_func(&mut self, keep: bool) -> &mut Self { + self.keep_init_func = Some(keep); + self + } + /// When using WASI during initialization, which file system directories /// should be made available? /// diff --git a/crates/wizer/src/rewrite.rs b/crates/wizer/src/rewrite.rs index a88048adc608..35fa834ad748 100644 --- a/crates/wizer/src/rewrite.rs +++ b/crates/wizer/src/rewrite.rs @@ -8,7 +8,7 @@ use crate::{ Module, ModuleContext, }, snapshot::Snapshot, - translate, FuncRenames, Wizer, + translate, FuncRenames, Wizer, DEFAULT_KEEP_INIT_FUNC, }; use renumbering::Renumbering; use std::{convert::TryFrom, iter}; @@ -137,8 +137,9 @@ impl Wizer { s if s.id == SectionId::Export.into() => { let mut exports = wasm_encoder::ExportSection::new(); for export in module.exports(cx) { - if export.field == self.init_func - || (has_wasi_initialize && export.field == "_initialize") + if !self.keep_init_func.unwrap_or(DEFAULT_KEEP_INIT_FUNC) + && (export.field == self.init_func + || (has_wasi_initialize && export.field == "_initialize")) { continue; } From 0071978ac3362788dca5abf637e6ba6a47ba8fad Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Thu, 27 Jan 2022 12:45:44 +0900 Subject: [PATCH 092/212] Apply suggestions from code review Co-authored-by: Nick Fitzgerald --- crates/wizer/src/lib.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/crates/wizer/src/lib.rs b/crates/wizer/src/lib.rs index 290dd6dcdfea..98939a6c8fba 100644 --- a/crates/wizer/src/lib.rs +++ b/crates/wizer/src/lib.rs @@ -143,9 +143,11 @@ pub struct Wizer { )] inherit_env: Option, - /// After initialization, should `init_func` be removed from the module? + /// After initialization, should the Wasm module still export the + /// initialization function? /// - /// This is false by default. + /// This is `false` by default, meaning that the initialization function is + /// no longer exported from the Wasm module. #[cfg_attr( feature = "structopt", structopt(long = "keep-init-func", value_name = "true|false") @@ -305,9 +307,11 @@ impl Wizer { self } - /// After initialization, should `init_func` be removed from the module? + /// After initialization, should the Wasm module still export the + /// initialization function? /// - /// Defaults to `false`. + /// This is `false` by default, meaning that the initialization function is + /// no longer exported from the Wasm module. pub fn keep_init_func(&mut self, keep: bool) -> &mut Self { self.keep_init_func = Some(keep); self From 5448560336be0b4e673e7fd71e96be72234123df Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Thu, 27 Jan 2022 12:48:58 +0900 Subject: [PATCH 093/212] Keep init func for module-linking in the same way --- crates/wizer/src/rewrite.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/wizer/src/rewrite.rs b/crates/wizer/src/rewrite.rs index 35fa834ad748..2a25b9ad4496 100644 --- a/crates/wizer/src/rewrite.rs +++ b/crates/wizer/src/rewrite.rs @@ -422,7 +422,10 @@ impl Wizer { let mut aliases = wasm_encoder::AliasSection::new(); let mut exports = wasm_encoder::ExportSection::new(); for exp in cx.root().exports(cx) { - if exp.field == self.init_func || (has_wasi_initialize && exp.field == "_initialize") { + if !self.keep_init_func.unwrap_or(DEFAULT_KEEP_INIT_FUNC) + && (exp.field == self.init_func + || (has_wasi_initialize && exp.field == "_initialize")) + { continue; } From d58581029fe8eaf924922dfe1d55bf5fc21ba3ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C3=BAl=20Cabrera?= Date: Fri, 28 Jan 2022 10:16:19 -0500 Subject: [PATCH 094/212] chore: Bump wasmtime to 0.33.0 --- crates/wizer/Cargo.lock | 304 ++++++++++++++++++++++++----------- crates/wizer/Cargo.toml | 6 +- crates/wizer/fuzz/Cargo.toml | 2 +- 3 files changed, 212 insertions(+), 100 deletions(-) diff --git a/crates/wizer/Cargo.lock b/crates/wizer/Cargo.lock index 5e4a4448de48..40dc7dac5e8a 100644 --- a/crates/wizer/Cargo.lock +++ b/crates/wizer/Cargo.lock @@ -158,14 +158,13 @@ checksum = "d9df67f7bf9ef8498769f994239c45613ef0c5899415fb58e9add412d2c1a538" [[package]] name = "cap-fs-ext" -version = "0.21.1" +version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f8499797f7e264c83334d9fc98b2c9889ebe5839514a14d81769ca09d71fd1d" +checksum = "68548ec86cd6e80bd3a82f6e1f9fdf7f0855d82fca10a4351734e0b458768e1a" dependencies = [ - "cap-primitives", - "cap-std", - "io-lifetimes", - "rustc_version", + "cap-primitives 0.22.1", + "cap-std 0.22.1", + "io-lifetimes 0.4.4", "winapi", ] @@ -177,23 +176,42 @@ checksum = "c5998b8b3a49736500aec3c123fa3f6f605a125b41a6df725e6b7c924a612ab4" dependencies = [ "ambient-authority", "errno", - "fs-set-times", - "io-extras", - "io-lifetimes", + "fs-set-times 0.13.1", + "io-extras 0.11.2", + "io-lifetimes 0.3.3", "ipnet", "maybe-owned", "rustc_version", - "rustix", + "rustix 0.26.2", + "winapi", + "winapi-util", + "winx 0.29.1", +] + +[[package]] +name = "cap-primitives" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa4885ffa2fcd32e04f2e2828537d760cba3aae7f3642e72195272b856ae7d71" +dependencies = [ + "ambient-authority", + "errno", + "fs-set-times 0.14.2", + "io-extras 0.12.2", + "io-lifetimes 0.4.4", + "ipnet", + "maybe-owned", + "rustix 0.31.3", "winapi", "winapi-util", - "winx", + "winx 0.30.0", ] [[package]] name = "cap-rand" -version = "0.21.1" +version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fafda903eb4a85903b106439cf62524275f3ae0609bb9e1ae9da7e7c26d4150c" +checksum = "34f7d4fff11afb2e0ff27ff4c761fe6fbf2b592bdd4e3b65eb264b8da7631286" dependencies = [ "ambient-authority", "rand", @@ -205,24 +223,37 @@ version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "811de89a7ede4ba32f2b75fe5c668a534da24942d81c081248a9d2843ebd517d" dependencies = [ - "cap-primitives", - "io-extras", - "io-lifetimes", + "cap-primitives 0.21.1", + "io-extras 0.11.2", + "io-lifetimes 0.3.3", "ipnet", "rustc_version", - "rustix", + "rustix 0.26.2", +] + +[[package]] +name = "cap-std" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d3500cb800c41283d7ba1e541609c041378410494cfdc43232220d63d240e5d" +dependencies = [ + "cap-primitives 0.22.1", + "io-extras 0.12.2", + "io-lifetimes 0.4.4", + "ipnet", + "rustix 0.31.3", ] [[package]] name = "cap-time-ext" -version = "0.21.1" +version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85f263d62447efe8829efdf947bbb4824ba2a3e2852b3be1d62f76fc05c326b0" +checksum = "a837533cbe6037743926538ab7ec292026b99e0823967bef984778dd92e40c9c" dependencies = [ - "cap-primitives", + "cap-primitives 0.22.1", "once_cell", - "rustix", - "winx", + "rustix 0.31.3", + "winx 0.30.0", ] [[package]] @@ -284,18 +315,18 @@ dependencies = [ [[package]] name = "cranelift-bforest" -version = "0.79.0" +version = "0.80.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0fb5e025141af5b9cbfff4351dc393596d017725f126c954bf472ce78dbba6b" +checksum = "9516ba6b2ba47b4cbf63b713f75b432fafa0a0e0464ec8381ec76e6efe931ab3" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-codegen" -version = "0.79.0" +version = "0.80.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a278c67cc48d0e8ff2275fb6fc31527def4be8f3d81640ecc8cd005a3aa45ded" +checksum = "489e5d0081f7edff6be12d71282a8bf387b5df64d5592454b75d662397f2d642" dependencies = [ "cranelift-bforest", "cranelift-codegen-meta", @@ -304,40 +335,39 @@ dependencies = [ "gimli 0.26.1", "log", "regalloc", - "sha2", "smallvec", "target-lexicon", ] [[package]] name = "cranelift-codegen-meta" -version = "0.79.0" +version = "0.80.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28274c1916c931c5603d94c5479d2ddacaaa574d298814ac1c99964ce92cbe85" +checksum = "d36ee1140371bb0f69100e734b30400157a4adf7b86148dee8b0a438763ead48" dependencies = [ "cranelift-codegen-shared", ] [[package]] name = "cranelift-codegen-shared" -version = "0.79.0" +version = "0.80.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5411cf49ab440b749d4da5129dfc45caf6e5fb7b2742b1fe1a421964fda2ee88" +checksum = "981da52d8f746af1feb96290c83977ff8d41071a7499e991d8abae0d4869f564" [[package]] name = "cranelift-entity" -version = "0.79.0" +version = "0.80.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64dde596f98462a37b029d81c8567c23cc68b8356b017f12945c545ac0a83203" +checksum = "a2906740053dd3bcf95ce53df0fd9b5649c68ae4bd9adada92b406f059eae461" dependencies = [ "serde", ] [[package]] name = "cranelift-frontend" -version = "0.79.0" +version = "0.80.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "544605d400710bd9c89924050b30c2e0222a387a5a8b5f04da9a9fdcbd8656a5" +checksum = "b7cb156de1097f567d46bf57a0cd720a72c3e15e1a2bd8b1041ba2fc894471b7" dependencies = [ "cranelift-codegen", "log", @@ -347,9 +377,9 @@ dependencies = [ [[package]] name = "cranelift-native" -version = "0.79.0" +version = "0.80.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7f8839befb64f7a39cb855241ae2c8eb74cea27c97fff2a007075fdb8a7f7d4" +checksum = "166028ca0343a6ee7bddac0e70084e142b23f99c701bd6f6ea9123afac1a7a46" dependencies = [ "cranelift-codegen", "libc", @@ -358,9 +388,9 @@ dependencies = [ [[package]] name = "cranelift-wasm" -version = "0.79.0" +version = "0.80.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80c9e14062c6a1cd2367dd30ea8945976639d5fe2062da8bdd40ada9ce3cb82e" +checksum = "5012a1cde0c8b3898770b711490d803018ae9bec2d60674ba0e5b2058a874f80" dependencies = [ "cranelift-codegen", "cranelift-entity", @@ -469,7 +499,7 @@ checksum = "22813a6dc45b335f9bade10bf7271dc477e81113e89eb251a0bc2a8a81c536e1" dependencies = [ "bstr", "csv-core", - "itoa", + "itoa 0.4.8", "ryu", "serde", ] @@ -615,8 +645,19 @@ version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aa838950e8e36a567ce96a945c303e88d9916ff97df27c315a0d263a72bd816f" dependencies = [ - "io-lifetimes", - "rustix", + "io-lifetimes 0.3.3", + "rustix 0.26.2", + "winapi", +] + +[[package]] +name = "fs-set-times" +version = "0.14.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40c496df0e588acbc672c912b4eb48ca7912164e89498ffad89969492f8e958f" +dependencies = [ + "io-lifetimes 0.4.4", + "rustix 0.32.1", "winapi", ] @@ -726,11 +767,21 @@ version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2a1d9a66d8b0312e3601a04a2dcf8f0ddd873319560ddeabe2110fa1e5af781a" dependencies = [ - "io-lifetimes", + "io-lifetimes 0.3.3", "rustc_version", "winapi", ] +[[package]] +name = "io-extras" +version = "0.12.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c9132d2d6504f4e348b8e16787f01613b4d0e587458641a40e727304416ac8d" +dependencies = [ + "io-lifetimes 0.4.4", + "winapi", +] + [[package]] name = "io-lifetimes" version = "0.3.3" @@ -741,6 +792,15 @@ dependencies = [ "winapi", ] +[[package]] +name = "io-lifetimes" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6ef6787e7f0faedc040f95716bdd0e62bcfcf4ba93da053b62dea2691c13864" +dependencies = [ + "winapi", +] + [[package]] name = "ipnet" version = "2.3.1" @@ -762,6 +822,12 @@ version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4" +[[package]] +name = "itoa" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1aab8fc367588b89dcee83ab0fd66b72b50b72fa1904d7095045ace2b0c81c35" + [[package]] name = "jobserver" version = "0.1.24" @@ -794,9 +860,9 @@ checksum = "3576a87f2ba00f6f106fdfcd16db1d698d648a26ad8e0573cad8537c3c362d2a" [[package]] name = "libc" -version = "0.2.102" +version = "0.2.115" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2a5ac8f984bfcf3a823267e5fde638acc3325f6496633a5da6bb6eb2171e103" +checksum = "0a8d982fa7a96a000f6ec4cfe966de9703eccde29750df2bb8949da91b0e818d" [[package]] name = "libfuzzer-sys" @@ -821,6 +887,12 @@ version = "0.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a261afc61b7a5e323933b402ca6a1765183687c614789b1e4db7762ed4230bca" +[[package]] +name = "linux-raw-sys" +version = "0.0.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95f5690fef754d905294c56f7ac815836f2513af966aa47f2e07ac79be07827f" + [[package]] name = "log" version = "0.4.14" @@ -1209,15 +1281,45 @@ checksum = "18c44018277ec7195538f5631b90def7ad975bb46370cb0f4eff4012de9333f8" dependencies = [ "bitflags", "errno", - "io-lifetimes", - "itoa", + "io-lifetimes 0.3.3", + "itoa 0.4.8", "libc", - "linux-raw-sys", + "linux-raw-sys 0.0.36", "once_cell", "rustc_version", "winapi", ] +[[package]] +name = "rustix" +version = "0.31.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2dcfc2778a90e38f56a708bfc90572422e11d6c7ee233d053d1f782cf9df6d2" +dependencies = [ + "bitflags", + "errno", + "io-lifetimes 0.4.4", + "itoa 1.0.1", + "libc", + "linux-raw-sys 0.0.36", + "once_cell", + "winapi", +] + +[[package]] +name = "rustix" +version = "0.32.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7cee647393af53c750e15dcbf7781cdd2e550b246bde76e46c326e7ea3c73773" +dependencies = [ + "bitflags", + "errno", + "io-lifetimes 0.4.4", + "libc", + "linux-raw-sys 0.0.37", + "winapi", +] + [[package]] name = "ryu" version = "1.0.5" @@ -1281,7 +1383,7 @@ version = "1.0.68" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0f690853975602e1bfe1ccbf50504d67174e3bcf340f23b5ea9992e0587a52d8" dependencies = [ - "itoa", + "itoa 0.4.8", "ryu", "serde", ] @@ -1375,19 +1477,18 @@ dependencies = [ [[package]] name = "system-interface" -version = "0.16.0" +version = "0.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1b5163055c386394170493ec1827cf7975035dc0bb23dcb7070bd1b1f672baa" +checksum = "56154c0a9e540ca0e204475913b1fccee114865b647d2019191fade73a8e4b56" dependencies = [ "atty", "bitflags", "cap-fs-ext", - "cap-std", - "io-lifetimes", - "rustc_version", - "rustix", + "cap-std 0.22.1", + "io-lifetimes 0.4.4", + "rustix 0.31.3", "winapi", - "winx", + "winx 0.30.0", ] [[package]] @@ -1550,20 +1651,20 @@ checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" [[package]] name = "wasi-cap-std-sync" -version = "0.32.0" +version = "0.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f23cb8c01ff3b733418d594df1fab090a4ece29a1260c5364df67e8fe7e08634" +checksum = "11be3f8de85a747166e53b0bec8ae65945df476ba1048bbfca35292ad398b161" dependencies = [ "anyhow", "async-trait", "cap-fs-ext", "cap-rand", - "cap-std", + "cap-std 0.22.1", "cap-time-ext", - "fs-set-times", - "io-lifetimes", + "fs-set-times 0.14.2", + "io-lifetimes 0.4.4", "lazy_static", - "rustix", + "rustix 0.31.3", "system-interface", "tracing", "wasi-common", @@ -1572,15 +1673,15 @@ dependencies = [ [[package]] name = "wasi-common" -version = "0.32.0" +version = "0.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c1e8cb75656702a5b843ef609c4e49b7a257f3bfcbf95ce9f32e4d1c9cf933b" +checksum = "e8e3aed634c018892c52a25239f3f23b97d5a70c9790e6a9299cb32d30fc5542" dependencies = [ "anyhow", "bitflags", "cap-rand", - "cap-std", - "rustix", + "cap-std 0.22.1", + "rustix 0.31.3", "thiserror", "tracing", "wiggle", @@ -1701,9 +1802,9 @@ dependencies = [ [[package]] name = "wasmtime" -version = "0.32.0" +version = "0.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d59b4bcc681f894d018e7032ba3149ab8e5f86828fab0b6ff31999c5691f20b" +checksum = "414be1bc5ca12e755ffd3ff7acc3a6d1979922f8237fc34068b2156cebcc3270" dependencies = [ "anyhow", "async-trait", @@ -1736,9 +1837,9 @@ dependencies = [ [[package]] name = "wasmtime-cache" -version = "0.32.0" +version = "0.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce455e29b5289c13ff1fc2453303e9df982c7ac59e03caeac2e22e9dddf94d3f" +checksum = "8b9b4cd1949206fda9241faf8c460a7d797aa1692594d3dd6bc1cbfa57ee20d0" dependencies = [ "anyhow", "base64", @@ -1746,7 +1847,7 @@ dependencies = [ "directories-next", "file-per-thread-logger", "log", - "rustix", + "rustix 0.31.3", "serde", "sha2", "toml", @@ -1756,9 +1857,9 @@ dependencies = [ [[package]] name = "wasmtime-cranelift" -version = "0.32.0" +version = "0.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30d079ceda53d15a5d29e8f4f8d3fcf9a9bb589c05e29b49ea10d129b5ff8e09" +checksum = "a4693d33725773615a4c9957e4aa731af57b27dca579702d1d8ed5750760f1a9" dependencies = [ "anyhow", "cranelift-codegen", @@ -1778,9 +1879,9 @@ dependencies = [ [[package]] name = "wasmtime-environ" -version = "0.32.0" +version = "0.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c39e4ba1fb154cca6a0f2350acc83248e22defb0cc647ae78879fe246a49dd61" +checksum = "5b17e47116a078b9770e6fb86cff8b9a660826623cebcfff251b047c8d8993ef" dependencies = [ "anyhow", "cranelift-entity", @@ -1798,20 +1899,20 @@ dependencies = [ [[package]] name = "wasmtime-fiber" -version = "0.32.0" +version = "0.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12fe33f65dbc891fece3a7986e0d328c4ad79af83b2e79099a4f039bde1762d0" +checksum = "044d9108ee9851547d8bc4e700be4479fde51efff3a81b1bc43219fc7e3310b0" dependencies = [ "cc", - "rustix", + "rustix 0.31.3", "winapi", ] [[package]] name = "wasmtime-jit" -version = "0.32.0" +version = "0.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3dd538de9501eb0f2c4c7b3d8acc7f918276ca28591a67d4ebe0672ebd558b65" +checksum = "60ea5b380bdf92e32911400375aeefb900ac9d3f8e350bb6ba555a39315f2ee7" dependencies = [ "addr2line 0.17.0", "anyhow", @@ -1820,7 +1921,7 @@ dependencies = [ "gimli 0.26.1", "object 0.27.1", "region", - "rustix", + "rustix 0.31.3", "serde", "target-lexicon", "thiserror", @@ -1831,9 +1932,9 @@ dependencies = [ [[package]] name = "wasmtime-runtime" -version = "0.32.0" +version = "0.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "910ccbd8cc18a02f626a1b2c7a7ddb57808db3c1780fd0af0aa5a5dae86c610b" +checksum = "abc7cd79937edd6e238b337608ebbcaf9c086a8457f01dfd598324f7fa56d81a" dependencies = [ "anyhow", "backtrace", @@ -1848,7 +1949,7 @@ dependencies = [ "more-asserts", "rand", "region", - "rustix", + "rustix 0.31.3", "thiserror", "wasmtime-environ", "wasmtime-fiber", @@ -1857,9 +1958,9 @@ dependencies = [ [[package]] name = "wasmtime-types" -version = "0.32.0" +version = "0.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "115bfe5c6eb6aba7e4eaa931ce225871c40280fb2cfb4ce4d3ab98d082e52fc4" +checksum = "d9e5e51a461a2cf2b69e1fc48f325b17d78a8582816e18479e8ead58844b23f8" dependencies = [ "cranelift-entity", "serde", @@ -1869,9 +1970,9 @@ dependencies = [ [[package]] name = "wasmtime-wasi" -version = "0.32.0" +version = "0.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ddf6d392acc19ec77ef8d9fef14475ece646b5245e14ac0231437c605b19869" +checksum = "33235c2f566f307802eefde34366660d81a6c159da4e96e92be168c019bf2685" dependencies = [ "anyhow", "wasi-cap-std-sync", @@ -1919,9 +2020,9 @@ dependencies = [ [[package]] name = "wiggle" -version = "0.32.0" +version = "0.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2b956030cc391da52988f56bfbd43fed8c3d761fe20cf511e3eddb6cbc15c8c" +checksum = "3c8d701567bd2e7f303248d4f92f5a22145b282234a28bd82d62fd9ef6dc215c" dependencies = [ "anyhow", "async-trait", @@ -1934,9 +2035,9 @@ dependencies = [ [[package]] name = "wiggle-generate" -version = "0.32.0" +version = "0.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10f3fd4dc7e543742f782816877768b6b5b2bd6e8998a9c377d898dbff964dcb" +checksum = "c87f4a07fca63f501eda1bb964ed1350195e02e340bc54ee53ee0d3fdef1f1bf" dependencies = [ "anyhow", "heck", @@ -1949,9 +2050,9 @@ dependencies = [ [[package]] name = "wiggle-macro" -version = "0.32.0" +version = "0.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4444dd08ea99536640db03740c04245e9e2763607a4ab58440eb852789e86283" +checksum = "d93dd9ccf857924ed83c5d6365ea77cda1ed15bbf352dce54912432708091663" dependencies = [ "proc-macro2", "quote", @@ -1997,7 +2098,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ecd175b4077107a91bb6bbb34aa9a691d8b45314791776f78b63a1cb8a08928" dependencies = [ "bitflags", - "io-lifetimes", + "io-lifetimes 0.3.3", + "winapi", +] + +[[package]] +name = "winx" +version = "0.30.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c54de2ce52a3e5839e129c7859e2b1f581769bbef57c0a2a09a12a5a3a5b3c2a" +dependencies = [ + "bitflags", + "io-lifetimes 0.4.4", "winapi", ] @@ -2018,7 +2130,7 @@ name = "wizer" version = "1.3.5" dependencies = [ "anyhow", - "cap-std", + "cap-std 0.21.1", "criterion", "env_logger 0.8.4", "log", diff --git a/crates/wizer/Cargo.toml b/crates/wizer/Cargo.toml index 08e6ec50a7a3..b529e5d88e39 100644 --- a/crates/wizer/Cargo.toml +++ b/crates/wizer/Cargo.toml @@ -32,11 +32,11 @@ env_logger = { version = "0.8.2", optional = true } log = "0.4.14" rayon = "1.5.0" structopt = { version = "0.3.21", optional = true } -wasi-cap-std-sync = "0.32.0" +wasi-cap-std-sync = "0.33.0" wasm-encoder = "0.6.0" wasmparser = "0.78.2" -wasmtime = "0.32.0" -wasmtime-wasi = "0.32.0" +wasmtime = "0.33.0" +wasmtime-wasi = "0.33.0" # Enable this dependency to get messages with WAT disassemblies when certain # internal panics occur. diff --git a/crates/wizer/fuzz/Cargo.toml b/crates/wizer/fuzz/Cargo.toml index f8e7efc51ade..d1820217a495 100644 --- a/crates/wizer/fuzz/Cargo.toml +++ b/crates/wizer/fuzz/Cargo.toml @@ -15,7 +15,7 @@ libfuzzer-sys = "0.4" log = "0.4.14" wasm-smith = "0.4.0" wasmprinter = "0.2.26" -wasmtime = "0.32.0" +wasmtime = "0.33.0" [dependencies.wizer] path = ".." From a6483ca2a509a28cdca4f049167574b2d2bbaf06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C3=BAl=20Cabrera?= Date: Tue, 22 Feb 2022 11:13:58 -0500 Subject: [PATCH 095/212] chore: Update to wasmtime v0.34.1 --- crates/wizer/Cargo.lock | 288 ++++++++++++++++++----------------- crates/wizer/Cargo.toml | 6 +- crates/wizer/fuzz/Cargo.toml | 2 +- 3 files changed, 154 insertions(+), 142 deletions(-) diff --git a/crates/wizer/Cargo.lock b/crates/wizer/Cargo.lock index 40dc7dac5e8a..4f20e756ca90 100644 --- a/crates/wizer/Cargo.lock +++ b/crates/wizer/Cargo.lock @@ -82,7 +82,7 @@ version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" dependencies = [ - "hermit-abi", + "hermit-abi 0.1.19", "libc", "winapi", ] @@ -158,13 +158,13 @@ checksum = "d9df67f7bf9ef8498769f994239c45613ef0c5899415fb58e9add412d2c1a538" [[package]] name = "cap-fs-ext" -version = "0.22.1" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68548ec86cd6e80bd3a82f6e1f9fdf7f0855d82fca10a4351734e0b458768e1a" +checksum = "71f5b22f0dc04ed3404bfae102654978bfd425c5568851a89eb4d4b8f58e9590" dependencies = [ - "cap-primitives 0.22.1", - "cap-std 0.22.1", - "io-lifetimes 0.4.4", + "cap-primitives 0.24.1", + "cap-std 0.24.1", + "io-lifetimes 0.5.3", "winapi", ] @@ -190,28 +190,28 @@ dependencies = [ [[package]] name = "cap-primitives" -version = "0.22.1" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa4885ffa2fcd32e04f2e2828537d760cba3aae7f3642e72195272b856ae7d71" +checksum = "defd283f080043a702c362203c2646a4e0a2fff99baede1eea1416239f0af220" dependencies = [ "ambient-authority", "errno", - "fs-set-times 0.14.2", - "io-extras 0.12.2", - "io-lifetimes 0.4.4", + "fs-set-times 0.15.0", + "io-extras 0.13.2", + "io-lifetimes 0.5.3", "ipnet", "maybe-owned", - "rustix 0.31.3", + "rustix 0.33.2", "winapi", "winapi-util", - "winx 0.30.0", + "winx 0.31.0", ] [[package]] name = "cap-rand" -version = "0.22.1" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34f7d4fff11afb2e0ff27ff4c761fe6fbf2b592bdd4e3b65eb264b8da7631286" +checksum = "12627a93bdbbe4fb32c1ea2b2c2665ba54c49eb48f1139440ce4c6a279701461" dependencies = [ "ambient-authority", "rand", @@ -233,27 +233,27 @@ dependencies = [ [[package]] name = "cap-std" -version = "0.22.1" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d3500cb800c41283d7ba1e541609c041378410494cfdc43232220d63d240e5d" +checksum = "7cbe56c8ed4cdf8360deb80dcced538968d3bac45e71befee65e95a0e262caf2" dependencies = [ - "cap-primitives 0.22.1", - "io-extras 0.12.2", - "io-lifetimes 0.4.4", + "cap-primitives 0.24.1", + "io-extras 0.13.2", + "io-lifetimes 0.5.3", "ipnet", - "rustix 0.31.3", + "rustix 0.33.2", ] [[package]] name = "cap-time-ext" -version = "0.22.1" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a837533cbe6037743926538ab7ec292026b99e0823967bef984778dd92e40c9c" +checksum = "7a34e5a4375b768b3acaec25dd7b53bcc15c801258c43a0ef2da2027f2028e46" dependencies = [ - "cap-primitives 0.22.1", + "cap-primitives 0.24.1", "once_cell", - "rustix 0.31.3", - "winx 0.30.0", + "rustix 0.33.2", + "winx 0.31.0", ] [[package]] @@ -315,18 +315,18 @@ dependencies = [ [[package]] name = "cranelift-bforest" -version = "0.80.0" +version = "0.81.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9516ba6b2ba47b4cbf63b713f75b432fafa0a0e0464ec8381ec76e6efe931ab3" +checksum = "32f027f29ace03752bb83c112eb4f53744bc4baadf19955e67fcde1d71d2f39d" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-codegen" -version = "0.80.0" +version = "0.81.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "489e5d0081f7edff6be12d71282a8bf387b5df64d5592454b75d662397f2d642" +checksum = "6c10af69cbf4e228c11bdc26d8f9d5276773909152a769649a160571b282f92f" dependencies = [ "cranelift-bforest", "cranelift-codegen-meta", @@ -341,33 +341,33 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.80.0" +version = "0.81.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d36ee1140371bb0f69100e734b30400157a4adf7b86148dee8b0a438763ead48" +checksum = "290ac14d2cef43cbf1b53ad5c1b34216c9e32e00fa9b6ac57b5e5a2064369e02" dependencies = [ "cranelift-codegen-shared", ] [[package]] name = "cranelift-codegen-shared" -version = "0.80.0" +version = "0.81.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "981da52d8f746af1feb96290c83977ff8d41071a7499e991d8abae0d4869f564" +checksum = "beb9142d134a03d01e3995e6d8dd3aecf16312261d0cb0c5dcd73d5be2528c1c" [[package]] name = "cranelift-entity" -version = "0.80.0" +version = "0.81.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2906740053dd3bcf95ce53df0fd9b5649c68ae4bd9adada92b406f059eae461" +checksum = "1268a50b7cbbfee8514d417fc031cedd9965b15fa9e5ed1d4bc16de86f76765e" dependencies = [ "serde", ] [[package]] name = "cranelift-frontend" -version = "0.80.0" +version = "0.81.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7cb156de1097f567d46bf57a0cd720a72c3e15e1a2bd8b1041ba2fc894471b7" +checksum = "97ac0d440469e19ab12183e31a9e41b4efd8a4ca5fbde2a10c78c7bb857cc2a4" dependencies = [ "cranelift-codegen", "log", @@ -377,9 +377,9 @@ dependencies = [ [[package]] name = "cranelift-native" -version = "0.80.0" +version = "0.81.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "166028ca0343a6ee7bddac0e70084e142b23f99c701bd6f6ea9123afac1a7a46" +checksum = "794cd1a5694a01c68957f9cfdc5ac092cf8b4e9c2d1697c4a5100f90103e9e9e" dependencies = [ "cranelift-codegen", "libc", @@ -388,9 +388,9 @@ dependencies = [ [[package]] name = "cranelift-wasm" -version = "0.80.0" +version = "0.81.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5012a1cde0c8b3898770b711490d803018ae9bec2d60674ba0e5b2058a874f80" +checksum = "f2ddd4ca6963f6e94d00e8935986411953581ac893587ab1f0eb4f0b5a40ae65" dependencies = [ "cranelift-codegen", "cranelift-entity", @@ -398,7 +398,7 @@ dependencies = [ "itertools", "log", "smallvec", - "wasmparser 0.81.0", + "wasmparser 0.82.0", "wasmtime-types", ] @@ -652,12 +652,12 @@ dependencies = [ [[package]] name = "fs-set-times" -version = "0.14.2" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40c496df0e588acbc672c912b4eb48ca7912164e89498ffad89969492f8e958f" +checksum = "7df62ee66ee2d532ea8d567b5a3f0d03ecd64636b98bad5be1e93dcc918b92aa" dependencies = [ - "io-lifetimes 0.4.4", - "rustix 0.32.1", + "io-lifetimes 0.5.3", + "rustix 0.33.2", "winapi", ] @@ -735,6 +735,15 @@ dependencies = [ "libc", ] +[[package]] +name = "hermit-abi" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ab7905ea95c6d9af62940f9d7dd9596d54c334ae2c15300c482051292d5637f" +dependencies = [ + "libc", +] + [[package]] name = "humantime" version = "1.3.0" @@ -774,11 +783,11 @@ dependencies = [ [[package]] name = "io-extras" -version = "0.12.2" +version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c9132d2d6504f4e348b8e16787f01613b4d0e587458641a40e727304416ac8d" +checksum = "d0c937cc9891c12eaa8c63ad347e4a288364b1328b924886970b47a14ab8f8f8" dependencies = [ - "io-lifetimes 0.4.4", + "io-lifetimes 0.5.3", "winapi", ] @@ -794,10 +803,11 @@ dependencies = [ [[package]] name = "io-lifetimes" -version = "0.4.4" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6ef6787e7f0faedc040f95716bdd0e62bcfcf4ba93da053b62dea2691c13864" +checksum = "ec58677acfea8a15352d42fc87d11d63596ade9239e0a7c9352914417515dbe6" dependencies = [ + "libc", "winapi", ] @@ -807,6 +817,18 @@ version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68f2d64f2edebec4ce84ad108148e67e1064789bee435edc5b60ad398714a3a9" +[[package]] +name = "is-terminal" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c89a757e762896bdbdfadf2860d0f8b0cea5e363d8cf3e7bdfeb63d1d976352" +dependencies = [ + "hermit-abi 0.2.0", + "io-lifetimes 0.5.3", + "rustix 0.33.2", + "winapi", +] + [[package]] name = "itertools" version = "0.10.1" @@ -889,9 +911,9 @@ checksum = "a261afc61b7a5e323933b402ca6a1765183687c614789b1e4db7762ed4230bca" [[package]] name = "linux-raw-sys" -version = "0.0.37" +version = "0.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95f5690fef754d905294c56f7ac815836f2513af966aa47f2e07ac79be07827f" +checksum = "5bdc16c6ce4c85d9b46b4e66f2a814be5b3f034dbd5131c268a24ca26d970db8" [[package]] name = "log" @@ -963,7 +985,7 @@ version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3" dependencies = [ - "hermit-abi", + "hermit-abi 0.1.19", "libc", ] @@ -989,9 +1011,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.8.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "692fcb63b64b1758029e0a96ee63e049ce8c5948587f2f7208df04625e5f6b56" +checksum = "da32515d9f6e6e489d7bc9d84c71b060db7247dc035bbe44eac88cf87486d8d5" [[package]] name = "oorandom" @@ -1194,9 +1216,9 @@ dependencies = [ [[package]] name = "regalloc" -version = "0.0.33" +version = "0.0.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d808cff91dfca7b239d40b972ba628add94892b1d9e19a842aedc5cfae8ab1a" +checksum = "62446b1d3ebf980bdc68837700af1d77b37bc430e524bf95319c6eada2a4cc02" dependencies = [ "log", "rustc-hash", @@ -1292,34 +1314,20 @@ dependencies = [ [[package]] name = "rustix" -version = "0.31.3" +version = "0.33.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2dcfc2778a90e38f56a708bfc90572422e11d6c7ee233d053d1f782cf9df6d2" +checksum = "db890a96e64911e67fa84e58ce061a40a6a65c231e5fad20b190933f8991a27c" dependencies = [ "bitflags", "errno", - "io-lifetimes 0.4.4", + "io-lifetimes 0.5.3", "itoa 1.0.1", "libc", - "linux-raw-sys 0.0.36", + "linux-raw-sys 0.0.40", "once_cell", "winapi", ] -[[package]] -name = "rustix" -version = "0.32.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cee647393af53c750e15dcbf7781cdd2e550b246bde76e46c326e7ea3c73773" -dependencies = [ - "bitflags", - "errno", - "io-lifetimes 0.4.4", - "libc", - "linux-raw-sys 0.0.37", - "winapi", -] - [[package]] name = "ryu" version = "1.0.5" @@ -1477,18 +1485,18 @@ dependencies = [ [[package]] name = "system-interface" -version = "0.17.1" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56154c0a9e540ca0e204475913b1fccee114865b647d2019191fade73a8e4b56" +checksum = "1e09bb3fb4e02ec4b87e182ea9718fadbc0fa3e50085b40a9af9690572b67f9e" dependencies = [ "atty", "bitflags", "cap-fs-ext", - "cap-std 0.22.1", - "io-lifetimes 0.4.4", - "rustix 0.31.3", + "cap-std 0.24.1", + "io-lifetimes 0.5.3", + "rustix 0.33.2", "winapi", - "winx 0.30.0", + "winx 0.31.0", ] [[package]] @@ -1651,20 +1659,22 @@ checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" [[package]] name = "wasi-cap-std-sync" -version = "0.33.0" +version = "0.34.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11be3f8de85a747166e53b0bec8ae65945df476ba1048bbfca35292ad398b161" +checksum = "1c8a21d19ad46499a6611da6d74636f19a6bebaaaa85254b2bec4392493abe2c" dependencies = [ "anyhow", "async-trait", "cap-fs-ext", "cap-rand", - "cap-std 0.22.1", + "cap-std 0.24.1", "cap-time-ext", - "fs-set-times 0.14.2", - "io-lifetimes 0.4.4", + "fs-set-times 0.15.0", + "io-extras 0.13.2", + "io-lifetimes 0.5.3", + "is-terminal", "lazy_static", - "rustix 0.31.3", + "rustix 0.33.2", "system-interface", "tracing", "wasi-common", @@ -1673,15 +1683,15 @@ dependencies = [ [[package]] name = "wasi-common" -version = "0.33.0" +version = "0.34.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8e3aed634c018892c52a25239f3f23b97d5a70c9790e6a9299cb32d30fc5542" +checksum = "73ee711ef917d4250d1b6d430d6b7f3a4820f52940fb59beb761297998ff7528" dependencies = [ "anyhow", "bitflags", "cap-rand", - "cap-std 0.22.1", - "rustix 0.31.3", + "cap-std 0.24.1", + "rustix 0.33.2", "thiserror", "tracing", "wiggle", @@ -1786,9 +1796,9 @@ checksum = "be92b6dcaa5af4b2a176b29be3bf1402fab9e69d313141185099c7d1684f2dca" [[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" @@ -1802,29 +1812,28 @@ dependencies = [ [[package]] name = "wasmtime" -version = "0.33.0" +version = "0.34.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "414be1bc5ca12e755ffd3ff7acc3a6d1979922f8237fc34068b2156cebcc3270" +checksum = "4882e78d9daceeaff656d82869f298fd472ea8d8ccf96fbd310da5c1687773ac" dependencies = [ "anyhow", "async-trait", "backtrace", "bincode", "cfg-if", - "cpp_demangle", "indexmap", "lazy_static", "libc", "log", "object 0.27.1", + "once_cell", "paste", "psm", "rayon", "region", - "rustc-demangle", "serde", "target-lexicon", - "wasmparser 0.81.0", + "wasmparser 0.82.0", "wasmtime-cache", "wasmtime-cranelift", "wasmtime-environ", @@ -1837,9 +1846,9 @@ dependencies = [ [[package]] name = "wasmtime-cache" -version = "0.33.0" +version = "0.34.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b9b4cd1949206fda9241faf8c460a7d797aa1692594d3dd6bc1cbfa57ee20d0" +checksum = "cf5b9af2d970624455f9ea109acc60cc477afe097f86c190eb519a8b7d6646cd" dependencies = [ "anyhow", "base64", @@ -1847,7 +1856,7 @@ dependencies = [ "directories-next", "file-per-thread-logger", "log", - "rustix 0.31.3", + "rustix 0.33.2", "serde", "sha2", "toml", @@ -1857,9 +1866,9 @@ dependencies = [ [[package]] name = "wasmtime-cranelift" -version = "0.33.0" +version = "0.34.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4693d33725773615a4c9957e4aa731af57b27dca579702d1d8ed5750760f1a9" +checksum = "1ed6ff21d2dbfe568af483f0c508e049fc6a497c73635e2c50c9b1baf3a93ed8" dependencies = [ "anyhow", "cranelift-codegen", @@ -1873,15 +1882,15 @@ dependencies = [ "object 0.27.1", "target-lexicon", "thiserror", - "wasmparser 0.81.0", + "wasmparser 0.82.0", "wasmtime-environ", ] [[package]] name = "wasmtime-environ" -version = "0.33.0" +version = "0.34.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b17e47116a078b9770e6fb86cff8b9a660826623cebcfff251b047c8d8993ef" +checksum = "860936d38df423b4291b3e31bc28d4895e2208f9daba351c2397d18a0a10e0bf" dependencies = [ "anyhow", "cranelift-entity", @@ -1893,35 +1902,38 @@ dependencies = [ "serde", "target-lexicon", "thiserror", - "wasmparser 0.81.0", + "wasmparser 0.82.0", "wasmtime-types", ] [[package]] name = "wasmtime-fiber" -version = "0.33.0" +version = "0.34.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "044d9108ee9851547d8bc4e700be4479fde51efff3a81b1bc43219fc7e3310b0" +checksum = "67e285306aa274d85a22753bef826226e1cc473bac0b541523f46dccf80751cc" dependencies = [ "cc", - "rustix 0.31.3", + "rustix 0.33.2", "winapi", ] [[package]] name = "wasmtime-jit" -version = "0.33.0" +version = "0.34.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60ea5b380bdf92e32911400375aeefb900ac9d3f8e350bb6ba555a39315f2ee7" +checksum = "e794310a0df5266c7ac73e8211a024a49e3860ac0ca2af5db8527be942ad063e" dependencies = [ "addr2line 0.17.0", "anyhow", "bincode", "cfg-if", + "cpp_demangle", "gimli 0.26.1", + "log", "object 0.27.1", "region", - "rustix 0.31.3", + "rustc-demangle", + "rustix 0.33.2", "serde", "target-lexicon", "thiserror", @@ -1932,9 +1944,9 @@ dependencies = [ [[package]] name = "wasmtime-runtime" -version = "0.33.0" +version = "0.34.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abc7cd79937edd6e238b337608ebbcaf9c086a8457f01dfd598324f7fa56d81a" +checksum = "90ffe5cb3db705ea43fcf37475a79891a3ada754c1cbe333540879649de943d5" dependencies = [ "anyhow", "backtrace", @@ -1949,7 +1961,7 @@ dependencies = [ "more-asserts", "rand", "region", - "rustix 0.31.3", + "rustix 0.33.2", "thiserror", "wasmtime-environ", "wasmtime-fiber", @@ -1958,21 +1970,21 @@ dependencies = [ [[package]] name = "wasmtime-types" -version = "0.33.0" +version = "0.34.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9e5e51a461a2cf2b69e1fc48f325b17d78a8582816e18479e8ead58844b23f8" +checksum = "70a5b60d70c1927c5a403f7c751de179414b6b91da75b2312c3ae78196cf9dc3" dependencies = [ "cranelift-entity", "serde", "thiserror", - "wasmparser 0.81.0", + "wasmparser 0.82.0", ] [[package]] name = "wasmtime-wasi" -version = "0.33.0" +version = "0.34.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33235c2f566f307802eefde34366660d81a6c159da4e96e92be168c019bf2685" +checksum = "23fa6fbbad7e6f7dfe5fc0127ecd4bca409e3dcb51596b10ccf4949ac450d4c9" dependencies = [ "anyhow", "wasi-cap-std-sync", @@ -2020,9 +2032,9 @@ dependencies = [ [[package]] name = "wiggle" -version = "0.33.0" +version = "0.34.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c8d701567bd2e7f303248d4f92f5a22145b282234a28bd82d62fd9ef6dc215c" +checksum = "11fb3417e7e14c88f2d9ee6c3746ba6b71f4000f7f4d1450b219a278f39d31e8" dependencies = [ "anyhow", "async-trait", @@ -2035,9 +2047,9 @@ dependencies = [ [[package]] name = "wiggle-generate" -version = "0.33.0" +version = "0.34.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c87f4a07fca63f501eda1bb964ed1350195e02e340bc54ee53ee0d3fdef1f1bf" +checksum = "d0c36b9602eda8612e2338c4f39728046819b3bc2ed71a474c5c108f5b54e1f9" dependencies = [ "anyhow", "heck", @@ -2050,9 +2062,9 @@ dependencies = [ [[package]] name = "wiggle-macro" -version = "0.33.0" +version = "0.34.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d93dd9ccf857924ed83c5d6365ea77cda1ed15bbf352dce54912432708091663" +checksum = "abd843bbf81370dba59cb869cb50d8e369e82b809f84b6a8db23d6b2394e50e8" dependencies = [ "proc-macro2", "quote", @@ -2104,12 +2116,12 @@ dependencies = [ [[package]] name = "winx" -version = "0.30.0" +version = "0.31.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c54de2ce52a3e5839e129c7859e2b1f581769bbef57c0a2a09a12a5a3a5b3c2a" +checksum = "08d5973cb8cd94a77d03ad7e23bbe14889cb29805da1cec0e4aff75e21aebded" dependencies = [ "bitflags", - "io-lifetimes 0.4.4", + "io-lifetimes 0.5.3", "winapi", ] @@ -2169,18 +2181,18 @@ dependencies = [ [[package]] name = "zstd" -version = "0.9.0+zstd.1.5.0" +version = "0.10.0+zstd.1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07749a5dc2cb6b36661290245e350f15ec3bbb304e493db54a1d354480522ccd" +checksum = "3b1365becbe415f3f0fcd024e2f7b45bacfb5bdd055f0dc113571394114e7bdd" dependencies = [ "zstd-safe", ] [[package]] name = "zstd-safe" -version = "4.1.1+zstd.1.5.0" +version = "4.1.4+zstd.1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c91c90f2c593b003603e5e0493c837088df4469da25aafff8bce42ba48caf079" +checksum = "2f7cd17c9af1a4d6c24beb1cc54b17e2ef7b593dc92f19e9d9acad8b182bbaee" dependencies = [ "libc", "zstd-sys", @@ -2188,9 +2200,9 @@ dependencies = [ [[package]] name = "zstd-sys" -version = "1.6.1+zstd.1.5.0" +version = "1.6.3+zstd.1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "615120c7a2431d16cf1cf979e7fc31ba7a5b5e5707b29c8a99e5dbf8a8392a33" +checksum = "fc49afa5c8d634e75761feda8c592051e7eeb4683ba827211eb0d731d3402ea8" dependencies = [ "cc", "libc", diff --git a/crates/wizer/Cargo.toml b/crates/wizer/Cargo.toml index b529e5d88e39..e6fbcd8cf9ea 100644 --- a/crates/wizer/Cargo.toml +++ b/crates/wizer/Cargo.toml @@ -32,11 +32,11 @@ env_logger = { version = "0.8.2", optional = true } log = "0.4.14" rayon = "1.5.0" structopt = { version = "0.3.21", optional = true } -wasi-cap-std-sync = "0.33.0" +wasi-cap-std-sync = "0.34.1" wasm-encoder = "0.6.0" wasmparser = "0.78.2" -wasmtime = "0.33.0" -wasmtime-wasi = "0.33.0" +wasmtime = "0.34.1" +wasmtime-wasi = "0.34.1" # Enable this dependency to get messages with WAT disassemblies when certain # internal panics occur. diff --git a/crates/wizer/fuzz/Cargo.toml b/crates/wizer/fuzz/Cargo.toml index d1820217a495..c561f660e28b 100644 --- a/crates/wizer/fuzz/Cargo.toml +++ b/crates/wizer/fuzz/Cargo.toml @@ -15,7 +15,7 @@ libfuzzer-sys = "0.4" log = "0.4.14" wasm-smith = "0.4.0" wasmprinter = "0.2.26" -wasmtime = "0.33.0" +wasmtime = "0.34.1" [dependencies.wizer] path = ".." From bf5dd8885a0f9fef408fc729d1f96be90210ef68 Mon Sep 17 00:00:00 2001 From: Conrad Grobler Date: Fri, 25 Mar 2022 12:25:03 +0000 Subject: [PATCH 096/212] Update cap-std to v0.24.2 --- crates/wizer/Cargo.lock | 182 +++++++++------------------------------- crates/wizer/Cargo.toml | 2 +- 2 files changed, 42 insertions(+), 142 deletions(-) diff --git a/crates/wizer/Cargo.lock b/crates/wizer/Cargo.lock index 4f20e756ca90..58e93cb494ce 100644 --- a/crates/wizer/Cargo.lock +++ b/crates/wizer/Cargo.lock @@ -162,32 +162,12 @@ version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "71f5b22f0dc04ed3404bfae102654978bfd425c5568851a89eb4d4b8f58e9590" dependencies = [ - "cap-primitives 0.24.1", - "cap-std 0.24.1", - "io-lifetimes 0.5.3", + "cap-primitives", + "cap-std", + "io-lifetimes", "winapi", ] -[[package]] -name = "cap-primitives" -version = "0.21.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5998b8b3a49736500aec3c123fa3f6f605a125b41a6df725e6b7c924a612ab4" -dependencies = [ - "ambient-authority", - "errno", - "fs-set-times 0.13.1", - "io-extras 0.11.2", - "io-lifetimes 0.3.3", - "ipnet", - "maybe-owned", - "rustc_version", - "rustix 0.26.2", - "winapi", - "winapi-util", - "winx 0.29.1", -] - [[package]] name = "cap-primitives" version = "0.24.1" @@ -196,15 +176,15 @@ checksum = "defd283f080043a702c362203c2646a4e0a2fff99baede1eea1416239f0af220" dependencies = [ "ambient-authority", "errno", - "fs-set-times 0.15.0", - "io-extras 0.13.2", - "io-lifetimes 0.5.3", + "fs-set-times", + "io-extras", + "io-lifetimes", "ipnet", "maybe-owned", - "rustix 0.33.2", + "rustix", "winapi", "winapi-util", - "winx 0.31.0", + "winx", ] [[package]] @@ -219,29 +199,15 @@ dependencies = [ [[package]] name = "cap-std" -version = "0.21.1" +version = "0.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "811de89a7ede4ba32f2b75fe5c668a534da24942d81c081248a9d2843ebd517d" +checksum = "3430d1b5ba78fa381eb227525578d2b85d77b42ff49be85d1e72a94f305e603c" dependencies = [ - "cap-primitives 0.21.1", - "io-extras 0.11.2", - "io-lifetimes 0.3.3", + "cap-primitives", + "io-extras", + "io-lifetimes", "ipnet", - "rustc_version", - "rustix 0.26.2", -] - -[[package]] -name = "cap-std" -version = "0.24.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cbe56c8ed4cdf8360deb80dcced538968d3bac45e71befee65e95a0e262caf2" -dependencies = [ - "cap-primitives 0.24.1", - "io-extras 0.13.2", - "io-lifetimes 0.5.3", - "ipnet", - "rustix 0.33.2", + "rustix", ] [[package]] @@ -250,10 +216,10 @@ version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a34e5a4375b768b3acaec25dd7b53bcc15c801258c43a0ef2da2027f2028e46" dependencies = [ - "cap-primitives 0.24.1", + "cap-primitives", "once_cell", - "rustix 0.33.2", - "winx 0.31.0", + "rustix", + "winx", ] [[package]] @@ -639,25 +605,14 @@ dependencies = [ "log", ] -[[package]] -name = "fs-set-times" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa838950e8e36a567ce96a945c303e88d9916ff97df27c315a0d263a72bd816f" -dependencies = [ - "io-lifetimes 0.3.3", - "rustix 0.26.2", - "winapi", -] - [[package]] name = "fs-set-times" version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7df62ee66ee2d532ea8d567b5a3f0d03ecd64636b98bad5be1e93dcc918b92aa" dependencies = [ - "io-lifetimes 0.5.3", - "rustix 0.33.2", + "io-lifetimes", + "rustix", "winapi", ] @@ -770,34 +725,13 @@ dependencies = [ "serde", ] -[[package]] -name = "io-extras" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a1d9a66d8b0312e3601a04a2dcf8f0ddd873319560ddeabe2110fa1e5af781a" -dependencies = [ - "io-lifetimes 0.3.3", - "rustc_version", - "winapi", -] - [[package]] name = "io-extras" version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d0c937cc9891c12eaa8c63ad347e4a288364b1328b924886970b47a14ab8f8f8" dependencies = [ - "io-lifetimes 0.5.3", - "winapi", -] - -[[package]] -name = "io-lifetimes" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "278e90d6f8a6c76a8334b336e306efa3c5f2b604048cbfd486d6f49878e3af14" -dependencies = [ - "rustc_version", + "io-lifetimes", "winapi", ] @@ -824,8 +758,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7c89a757e762896bdbdfadf2860d0f8b0cea5e363d8cf3e7bdfeb63d1d976352" dependencies = [ "hermit-abi 0.2.0", - "io-lifetimes 0.5.3", - "rustix 0.33.2", + "io-lifetimes", + "rustix", "winapi", ] @@ -903,12 +837,6 @@ version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7fb9b38af92608140b86b693604b9ffcc5824240a484d1ecd4795bacb2fe88f3" -[[package]] -name = "linux-raw-sys" -version = "0.0.36" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a261afc61b7a5e323933b402ca6a1765183687c614789b1e4db7762ed4230bca" - [[package]] name = "linux-raw-sys" version = "0.0.40" @@ -1295,23 +1223,6 @@ dependencies = [ "semver", ] -[[package]] -name = "rustix" -version = "0.26.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18c44018277ec7195538f5631b90def7ad975bb46370cb0f4eff4012de9333f8" -dependencies = [ - "bitflags", - "errno", - "io-lifetimes 0.3.3", - "itoa 0.4.8", - "libc", - "linux-raw-sys 0.0.36", - "once_cell", - "rustc_version", - "winapi", -] - [[package]] name = "rustix" version = "0.33.2" @@ -1320,10 +1231,10 @@ checksum = "db890a96e64911e67fa84e58ce061a40a6a65c231e5fad20b190933f8991a27c" dependencies = [ "bitflags", "errno", - "io-lifetimes 0.5.3", + "io-lifetimes", "itoa 1.0.1", "libc", - "linux-raw-sys 0.0.40", + "linux-raw-sys", "once_cell", "winapi", ] @@ -1492,11 +1403,11 @@ dependencies = [ "atty", "bitflags", "cap-fs-ext", - "cap-std 0.24.1", - "io-lifetimes 0.5.3", - "rustix 0.33.2", + "cap-std", + "io-lifetimes", + "rustix", "winapi", - "winx 0.31.0", + "winx", ] [[package]] @@ -1667,14 +1578,14 @@ dependencies = [ "async-trait", "cap-fs-ext", "cap-rand", - "cap-std 0.24.1", + "cap-std", "cap-time-ext", - "fs-set-times 0.15.0", - "io-extras 0.13.2", - "io-lifetimes 0.5.3", + "fs-set-times", + "io-extras", + "io-lifetimes", "is-terminal", "lazy_static", - "rustix 0.33.2", + "rustix", "system-interface", "tracing", "wasi-common", @@ -1690,8 +1601,8 @@ dependencies = [ "anyhow", "bitflags", "cap-rand", - "cap-std 0.24.1", - "rustix 0.33.2", + "cap-std", + "rustix", "thiserror", "tracing", "wiggle", @@ -1856,7 +1767,7 @@ dependencies = [ "directories-next", "file-per-thread-logger", "log", - "rustix 0.33.2", + "rustix", "serde", "sha2", "toml", @@ -1913,7 +1824,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "67e285306aa274d85a22753bef826226e1cc473bac0b541523f46dccf80751cc" dependencies = [ "cc", - "rustix 0.33.2", + "rustix", "winapi", ] @@ -1933,7 +1844,7 @@ dependencies = [ "object 0.27.1", "region", "rustc-demangle", - "rustix 0.33.2", + "rustix", "serde", "target-lexicon", "thiserror", @@ -1961,7 +1872,7 @@ dependencies = [ "more-asserts", "rand", "region", - "rustix 0.33.2", + "rustix", "thiserror", "wasmtime-environ", "wasmtime-fiber", @@ -2103,17 +2014,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -[[package]] -name = "winx" -version = "0.29.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ecd175b4077107a91bb6bbb34aa9a691d8b45314791776f78b63a1cb8a08928" -dependencies = [ - "bitflags", - "io-lifetimes 0.3.3", - "winapi", -] - [[package]] name = "winx" version = "0.31.0" @@ -2121,7 +2021,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08d5973cb8cd94a77d03ad7e23bbe14889cb29805da1cec0e4aff75e21aebded" dependencies = [ "bitflags", - "io-lifetimes 0.5.3", + "io-lifetimes", "winapi", ] @@ -2142,7 +2042,7 @@ name = "wizer" version = "1.3.5" dependencies = [ "anyhow", - "cap-std 0.21.1", + "cap-std", "criterion", "env_logger 0.8.4", "log", diff --git a/crates/wizer/Cargo.toml b/crates/wizer/Cargo.toml index e6fbcd8cf9ea..c5f82a61bad6 100644 --- a/crates/wizer/Cargo.toml +++ b/crates/wizer/Cargo.toml @@ -27,7 +27,7 @@ harness = false [dependencies] anyhow = "1.0.38" -cap-std = "0.21.1" +cap-std = "0.24.2" env_logger = { version = "0.8.2", optional = true } log = "0.4.14" rayon = "1.5.0" From a6454de44c56c14626ddcc1196e40c18989e8852 Mon Sep 17 00:00:00 2001 From: Rainy Sinclair <844493+itsrainy@users.noreply.github.com> Date: Tue, 31 May 2022 14:27:29 -0400 Subject: [PATCH 097/212] Add support for specifying a custom linker to be used during wizening Co-authored-by: Nick Fitzgerald --- crates/wizer/README.md | 22 +++++- crates/wizer/src/lib.rs | 81 ++++++++++++++++++-- crates/wizer/tests/make_linker.rs | 122 ++++++++++++++++++++++++++++++ crates/wizer/tests/tests.rs | 6 +- 4 files changed, 220 insertions(+), 11 deletions(-) create mode 100644 crates/wizer/tests/make_linker.rs diff --git a/crates/wizer/README.md b/crates/wizer/README.md index 0af45fd5c15d..6ba4478cbc9a 100644 --- a/crates/wizer/README.md +++ b/crates/wizer/README.md @@ -131,10 +131,30 @@ use wizer::Wizer; let input_wasm = get_input_wasm_bytes(); let initialized_wasm_bytes = Wizer::new() - .allow_wasi(true) + .allow_wasi(true)? .run(&input_wasm)?; ``` +## Using Wizer with a custom Linker + +If you want your module to be able to import other modules during instantiation, you can +use the `.make_linker(...)` builder method to provide your own Linker, for example: + +```rust +use wizer::Wizer; + +let input_wasm = get_input_wasm_bytes(); +let initialized_wasm_bytes = Wizer::new() + .make_linker(Some(Rc::new(|e: &wasmtime::Engine| { + let mut linker = wasmtime::Linker::new(e); + linker.func_wrap("foo", "bar", |x: i32| x + 1)?; + Ok(linker) + }))) + .run(&input_wasm)?; +``` + +Note that `allow_wasi(true)` and a custom linker are currently mutually exclusive + ## How Does it Work? First we instantiate the input Wasm module with Wasmtime and run the diff --git a/crates/wizer/src/lib.rs b/crates/wizer/src/lib.rs index 98939a6c8fba..322260e3368f 100644 --- a/crates/wizer/src/lib.rs +++ b/crates/wizer/src/lib.rs @@ -22,6 +22,7 @@ use dummy::dummy_imports; use std::collections::{HashMap, HashSet}; use std::fmt::Display; use std::path::PathBuf; +use std::rc::Rc; #[cfg(feature = "structopt")] use structopt::StructOpt; use wasmtime::Extern; @@ -38,9 +39,8 @@ const DEFAULT_WASM_MODULE_LINKING: bool = false; /// context. pub(crate) type Store = wasmtime::Store>; -/// We only ever use `Linker` with a fixed `T` that is our optional WASI -/// context. -pub(crate) type Linker = wasmtime::Linker>; +/// The type of linker that Wizer uses when evaluating the initialization function. +pub type Linker = wasmtime::Linker>; #[cfg(feature = "structopt")] fn parse_map_dirs(s: &str) -> anyhow::Result<(PathBuf, PathBuf)> { @@ -73,7 +73,7 @@ fn parse_map_dirs(s: &str) -> anyhow::Result<(PathBuf, PathBuf)> { /// identity and aren't comparable in the Wasm spec, which makes snapshotting /// difficult. #[cfg_attr(feature = "structopt", derive(StructOpt))] -#[derive(Clone, Debug)] +#[derive(Clone)] pub struct Wizer { /// The Wasm export name of the function that should be executed to /// initialize the Wasm module. @@ -123,6 +123,9 @@ pub struct Wizer { #[cfg_attr(feature = "structopt", structopt(long = "allow-wasi"))] allow_wasi: bool, + #[cfg_attr(feature = "structopt", structopt(skip))] + make_linker: Option anyhow::Result>>, + /// When using WASI during initialization, should `stdin`, `stderr`, and /// `stdout` be inherited? /// @@ -197,6 +200,39 @@ pub struct Wizer { wasm_module_linking: Option, } +impl std::fmt::Debug for Wizer { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + let Wizer { + init_func, + func_renames, + allow_wasi, + make_linker: _, + inherit_stdio, + inherit_env, + keep_init_func, + dirs, + map_dirs, + wasm_multi_memory, + wasm_multi_value, + wasm_module_linking, + } = self; + f.debug_struct("Wizer") + .field("init_func", &init_func) + .field("func_renames", &func_renames) + .field("allow_wasi", &allow_wasi) + .field("make_linker", &"..") + .field("inherit_stdio", &inherit_stdio) + .field("inherit_env", &inherit_env) + .field("keep_init_func", &keep_init_func) + .field("dirs", &dirs) + .field("map_dirs", &map_dirs) + .field("wasm_multi_memory", &wasm_multi_memory) + .field("wasm_multi_value", &wasm_multi_value) + .field("wasm_module_linking", &wasm_module_linking) + .finish() + } +} + struct FuncRenames { /// For a given export name that we encounter in the original module, a map /// to a new name, if any, to emit in the output module. @@ -245,6 +281,7 @@ impl Wizer { init_func: "wizer.initialize".into(), func_renames: vec![], allow_wasi: false, + make_linker: None, inherit_stdio: None, inherit_env: None, keep_init_func: None, @@ -284,9 +321,35 @@ impl Wizer { /// rather than per-instance. /// /// Defaults to `false`. - pub fn allow_wasi(&mut self, allow: bool) -> &mut Self { + pub fn allow_wasi(&mut self, allow: bool) -> anyhow::Result<&mut Self> { + anyhow::ensure!( + self.make_linker.is_none(), + "Cannot use 'allow_wasi' with a custom linker" + ); self.allow_wasi = allow; - self + Ok(self) + } + + /// The linker to use during initialization rather than the default + /// `wasmtime::Linker`. + /// + /// If you want your Wasm module to be able to import non-WASI functionality + /// (or a subset of WASI) during initialization, you can provide a closure + /// that returns a `Linker` result. Note, this has the same non-determinism + /// concerns that `.allow_wasi(true)` does: if the allowed imports interact + /// with the world in some way, the outcome of that interaction will be + /// snapshotted by Wizer during initialization and will yield the same result + /// in every instance of the wizened module. + pub fn make_linker( + &mut self, + make_linker: Option anyhow::Result>>, + ) -> anyhow::Result<&mut Self> { + anyhow::ensure!( + !self.allow_wasi, + "Cannot use 'allow_wasi' with a custom linker" + ); + self.make_linker = make_linker; + Ok(self) } /// When using WASI during initialization, should `stdin`, `stdout`, and @@ -632,7 +695,11 @@ impl Wizer { ) -> anyhow::Result<(wasmtime::Instance, bool)> { log::debug!("Calling the initialization function"); - let mut linker = wasmtime::Linker::new(store.engine()); + let mut linker = if let Some(make_linker) = self.make_linker.as_deref() { + make_linker(store.engine()).context("failed to make custom linker")? + } else { + wasmtime::Linker::new(store.engine()) + }; if self.allow_wasi { wasmtime_wasi::add_to_linker(&mut linker, |ctx: &mut Option| { diff --git a/crates/wizer/tests/make_linker.rs b/crates/wizer/tests/make_linker.rs new file mode 100644 index 000000000000..6cb44c8d269f --- /dev/null +++ b/crates/wizer/tests/make_linker.rs @@ -0,0 +1,122 @@ +use anyhow::{Context, Result}; +use std::rc::Rc; +use wat::parse_str as wat_to_wasm; +use wizer::Wizer; + +fn get_wizer() -> Wizer { + let mut wizer = Wizer::new(); + wizer + .make_linker(Some(Rc::new(|e: &wasmtime::Engine| { + let mut linker = wasmtime::Linker::new(e); + linker.func_wrap("foo", "bar", |x: i32| x + 1)?; + Ok(linker) + }))) + .unwrap(); + wizer +} + +fn run_wasm(args: &[wasmtime::Val], expected: i32, wasm: &[u8]) -> Result<()> { + let _ = env_logger::try_init(); + + let wasm = get_wizer().run(&wasm)?; + log::debug!( + "=== Wizened Wasm ==========================================================\n\ + {}\n\ + ===========================================================================", + wasmprinter::print_bytes(&wasm).unwrap() + ); + if log::log_enabled!(log::Level::Debug) { + std::fs::write("test.wasm", &wasm).unwrap(); + } + + let mut config = wasmtime::Config::new(); + config.cache_config_load_default().unwrap(); + config.wasm_multi_memory(true); + config.wasm_multi_value(true); + config.wasm_module_linking(true); + + let engine = wasmtime::Engine::new(&config)?; + let wasi_ctx = wasi_cap_std_sync::WasiCtxBuilder::new().build(); + let mut store = wasmtime::Store::new(&engine, wasi_ctx); + let module = + wasmtime::Module::new(store.engine(), wasm).context("Wasm test case failed to compile")?; + + let mut linker = wasmtime::Linker::new(&engine); + linker.func_wrap("foo", "bar", |_: i32| -> Result { + Err(wasmtime::Trap::new("shouldn't be called")) + })?; + + let instance = linker.instantiate(&mut store, &module)?; + + let run = instance + .get_func(&mut store, "run") + .ok_or_else(|| anyhow::anyhow!("the test Wasm module does not export a `run` function"))?; + + let mut actual = vec![wasmtime::Val::I32(0)]; + run.call(&mut store, args, &mut actual)?; + anyhow::ensure!(actual.len() == 1, "expected one result"); + let actual = match actual[0] { + wasmtime::Val::I32(x) => x, + _ => anyhow::bail!("expected an i32 result"), + }; + anyhow::ensure!( + expected == actual, + "expected `{}`, found `{}`", + expected, + actual, + ); + + Ok(()) +} + +fn run_wat(args: &[wasmtime::Val], expected: i32, wat: &str) -> Result<()> { + let _ = env_logger::try_init(); + let wasm = wat_to_wasm(wat)?; + run_wasm(args, expected, &wasm) +} + +#[test] +fn custom_linker() -> Result<()> { + run_wat( + &[], + 1, + r#" +(module + (type (func (param i32) (result i32))) + (import "foo" "bar" (func (type 0))) + (global $g (mut i32) (i32.const 0)) + (func (export "wizer.initialize") + global.get $g + call 0 + global.set $g + ) + (func (export "run") (result i32) + (global.get $g) + ) +)"#, + ) +} + +#[test] +#[should_panic] +fn linker_and_wasi() { + Wizer::new() + .make_linker(Some(Rc::new(|e: &wasmtime::Engine| { + Ok(wasmtime::Linker::new(e)) + }))) + .unwrap() + .allow_wasi(true) + .unwrap(); +} + +#[test] +#[should_panic] +fn wasi_and_linker() { + Wizer::new() + .allow_wasi(true) + .unwrap() + .make_linker(Some(Rc::new(|e: &wasmtime::Engine| { + Ok(wasmtime::Linker::new(e)) + }))) + .unwrap(); +} diff --git a/crates/wizer/tests/tests.rs b/crates/wizer/tests/tests.rs index c747cd074d37..198c18667855 100644 --- a/crates/wizer/tests/tests.rs +++ b/crates/wizer/tests/tests.rs @@ -10,7 +10,7 @@ fn run_wat(args: &[wasmtime::Val], expected: i32, wat: &str) -> Result<()> { fn get_wizer() -> Wizer { let mut wizer = Wizer::new(); - wizer.allow_wasi(true); + wizer.allow_wasi(true).unwrap(); wizer.wasm_multi_memory(true); wizer.wasm_module_linking(true); wizer @@ -818,7 +818,7 @@ fn rename_functions() -> Result<()> { let wasm = wat_to_wasm(wat)?; let mut wizer = Wizer::new(); - wizer.allow_wasi(true); + wizer.allow_wasi(true).unwrap(); wizer.func_rename("func_a", "func_b"); wizer.func_rename("func_b", "func_c"); let wasm = wizer.run(&wasm)?; @@ -874,7 +874,7 @@ fn renames_and_module_linking() -> Result<()> { let wasm = wat_to_wasm(wat)?; let mut wizer = Wizer::new(); wizer.wasm_module_linking(true); - wizer.allow_wasi(true); + wizer.allow_wasi(true).unwrap(); wizer.func_rename("a", "b"); wizer.func_rename("b", "c"); let wasm = wizer.run(&wasm)?; From 24ced0896e4a2937a77218e8cbf2c21a593f1409 Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Mon, 6 Jun 2022 15:43:32 -0700 Subject: [PATCH 098/212] Bump to version 1.4.0 --- crates/wizer/Cargo.lock | 2 +- crates/wizer/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/wizer/Cargo.lock b/crates/wizer/Cargo.lock index 58e93cb494ce..e9db39afc5ad 100644 --- a/crates/wizer/Cargo.lock +++ b/crates/wizer/Cargo.lock @@ -2039,7 +2039,7 @@ dependencies = [ [[package]] name = "wizer" -version = "1.3.5" +version = "1.4.0" dependencies = [ "anyhow", "cap-std", diff --git a/crates/wizer/Cargo.toml b/crates/wizer/Cargo.toml index c5f82a61bad6..5574ade02754 100644 --- a/crates/wizer/Cargo.toml +++ b/crates/wizer/Cargo.toml @@ -9,7 +9,7 @@ license = "Apache-2.0 WITH LLVM-exception" name = "wizer" readme = "./README.md" repository = "https://github.com/bytecodealliance/wizer" -version = "1.3.5" +version = "1.4.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html From 737450da54842bb56ea1d8b37074398d96196bef Mon Sep 17 00:00:00 2001 From: Jake Champion Date: Tue, 5 Jul 2022 11:10:22 +0100 Subject: [PATCH 099/212] Add release workflow which builds for multiple operating systems and architectures These can be used by people who want to install wizer without having to compile it themselves. One such use-case would be the fastly compute runtimes which install wizer in their CI environments. --- crates/wizer/.github/workflows/release.yml | 91 ++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 crates/wizer/.github/workflows/release.yml diff --git a/crates/wizer/.github/workflows/release.yml b/crates/wizer/.github/workflows/release.yml new file mode 100644 index 000000000000..00cad17b4bc6 --- /dev/null +++ b/crates/wizer/.github/workflows/release.yml @@ -0,0 +1,91 @@ +# This is nearly entirely copied from +# https://github.com/fastly/Viceroy/blob/b37b89fc07ecd5845f1103380c5e4fae9cc13b30/.github/workflows/release.yml#L1 +# The changes made are to add the `--bin wizer` flag and change the filesystem paths to use wizer instead of viceroy +name: Release + +on: + push: + tags: + - "v*.*.*" + +jobs: + build: + strategy: + matrix: + rust-toolchain: [stable] + os: [ubuntu-latest, macos-11, windows-latest] + arch: [amd64, arm64] + exclude: + - os: windows-latest + arch: arm64 + include: + - os: ubuntu-latest + name: linux + rust_abi: unknown-linux-gnu + - os: macos-11 + name: darwin + rust_abi: apple-darwin + - os: windows-latest + name: windows + rust_abi: pc-windows-msvc + extension: .exe + - arch: arm64 + rust_arch: aarch64 + - arch: amd64 + rust_arch: x86_64 + + runs-on: ${{ matrix.os }} + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + submodules: true + + - name: Install latest Rust toolchain + uses: actions-rs/toolchain@v1 + with: + toolchain: ${{ matrix.rust-toolchain }} + target: ${{ matrix.rust_arch }}-${{ matrix.rust_abi }} + default: true + override: true + + - name: Install C cross-compilation toolchain + if: ${{ matrix.name == 'linux' && matrix.arch != 'amd64' }} + run: | + sudo apt-get update + sudo apt install -f -y gcc-${{ matrix.rust_arch }}-linux-gnu + echo CC=${{ matrix.rust_arch }}-linux-gnu-gcc >> $GITHUB_ENV + echo RUSTFLAGS='-C linker=${{ matrix.rust_arch }}-linux-gnu-gcc' >> $GITHUB_ENV + + - name: Extract tag name + uses: olegtarasov/get-tag@v2.1 + id: tagName + + - name: Build + uses: actions-rs/cargo@v1 + with: + command: build + args: --release --locked --bin wizer --target=${{ matrix.rust_arch }}-${{ matrix.rust_abi }} --all-features + + - name: Strip symbols (linux) + if: ${{ matrix.name == 'linux' }} + run: | + ${{ matrix.rust_arch }}-linux-gnu-strip target/${{ matrix.rust_arch }}-${{ matrix.rust_abi }}/release/wizer${{ matrix.extension }} + + - name: Strip symbols (non-linux) + if: ${{ matrix.name != 'linux' }} + run: | + strip target/${{ matrix.rust_arch }}-${{ matrix.rust_abi }}/release/wizer${{ matrix.extension }} + + - name: Package + run: | + cd target/${{ matrix.rust_arch }}-${{ matrix.rust_abi }}/release + tar czf wizer_${{ steps.tagName.outputs.tag }}_${{ matrix.name }}-${{ matrix.arch }}.tar.gz wizer${{ matrix.extension }} + + - name: Release + uses: softprops/action-gh-release@v1 + with: + files: | + target/${{ matrix.rust_arch }}-${{ matrix.rust_abi }}/release/wizer_${{ steps.tagName.outputs.tag }}_${{ matrix.name }}-${{ matrix.arch }}.tar.gz + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From c1819a5d35526c250d8e623d2f023009cde7f193 Mon Sep 17 00:00:00 2001 From: Jake Champion Date: Tue, 5 Jul 2022 18:35:24 +0100 Subject: [PATCH 100/212] Update installation section to mention the pre-built binaries --- crates/wizer/README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/wizer/README.md b/crates/wizer/README.md index 6ba4478cbc9a..0712baeace90 100644 --- a/crates/wizer/README.md +++ b/crates/wizer/README.md @@ -66,7 +66,9 @@ which `wasm-opt` can remove. ## Install -Install via `cargo`: +Download the a pre-built release from the [releases](https://github.com/bytecodealliance/wizer/releases) page. Unarchive the binary and place it in your $PATH. + +Alternatively you can install via `cargo`: ```shell-session $ cargo install wizer --all-features From 04a68a9d0d95250cd6e56d45cf192c7def91e575 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Thu, 1 Sep 2022 09:27:15 -0600 Subject: [PATCH 101/212] implement partial bulk memory support This is an expanded version of #37 which explicitly supports `memory.copy`, `memory.fill`, and `memory.init` but still rejects modules which use any other bulk memory operations. Signed-off-by: Joel Dice --- crates/wizer/src/lib.rs | 42 ++++++++++++++++------ crates/wizer/src/parse.rs | 7 +++- crates/wizer/tests/tests.rs | 71 +++++++++++++++++++++++++++++++++++++ 3 files changed, 108 insertions(+), 12 deletions(-) diff --git a/crates/wizer/src/lib.rs b/crates/wizer/src/lib.rs index 322260e3368f..c629f33866a1 100644 --- a/crates/wizer/src/lib.rs +++ b/crates/wizer/src/lib.rs @@ -34,6 +34,7 @@ const DEFAULT_KEEP_INIT_FUNC: bool = false; const DEFAULT_WASM_MULTI_VALUE: bool = true; const DEFAULT_WASM_MULTI_MEMORY: bool = true; const DEFAULT_WASM_MODULE_LINKING: bool = false; +const DEFAULT_WASM_BULK_MEMORY: bool = false; /// We only ever use `Store` with a fixed `T` that is our optional WASI /// context. @@ -198,6 +199,16 @@ pub struct Wizer { /// Disabled by default. #[cfg_attr(feature = "structopt", structopt(long, value_name = "true|false"))] wasm_module_linking: Option, + + /// Enable or disable Wasm bulk memory operations. + /// + /// Note that only `memory.copy`, `memory.fill`, and `memory.init` operations + /// are currently supported. Modules which use other instructions, such as + /// `table.copy` will be rejected. + /// + /// Disabled by default. + #[cfg_attr(feature = "structopt", structopt(long, value_name = "true|false"))] + wasm_bulk_memory: Option, } impl std::fmt::Debug for Wizer { @@ -215,6 +226,7 @@ impl std::fmt::Debug for Wizer { wasm_multi_memory, wasm_multi_value, wasm_module_linking, + wasm_bulk_memory, } = self; f.debug_struct("Wizer") .field("init_func", &init_func) @@ -229,6 +241,7 @@ impl std::fmt::Debug for Wizer { .field("wasm_multi_memory", &wasm_multi_memory) .field("wasm_multi_value", &wasm_multi_value) .field("wasm_module_linking", &wasm_module_linking) + .field("wasm_bulk_memory", &wasm_bulk_memory) .finish() } } @@ -290,6 +303,7 @@ impl Wizer { wasm_multi_memory: None, wasm_multi_value: None, wasm_module_linking: None, + wasm_bulk_memory: None, } } @@ -429,6 +443,18 @@ impl Wizer { self } + /// Enable or disable Wasm bulk memory operations. + /// + /// Note that only `memory.copy`, `memory.fill`, and `memory.init` + /// operations are currently supported. Modules which use other + /// instructions, such as `table.copy` will be rejected. + /// + /// Defaults to `false`. + pub fn wasm_bulk_memory(&mut self, enable: bool) -> &mut Self { + self.wasm_bulk_memory = Some(enable); + self + } + /// Initialize the given Wasm, snapshot it, and return the serialized /// snapshot as a new, pre-initialized Wasm module. pub fn run(&self, wasm: &[u8]) -> anyhow::Result> { @@ -503,12 +529,14 @@ impl Wizer { self.wasm_module_linking .unwrap_or(DEFAULT_WASM_MODULE_LINKING), ); + // Note that we only support `memory.copy`, `memory.fill`, and + // `memory.init` for the time being: + config.wasm_bulk_memory(self.wasm_bulk_memory.unwrap_or(DEFAULT_WASM_BULK_MEMORY)); - // Proposoals that we should add support for. + // Proposals that we should add support for. config.wasm_reference_types(false); config.wasm_simd(false); config.wasm_threads(false); - config.wasm_bulk_memory(false); Ok(config) } @@ -531,7 +559,7 @@ impl Wizer { memory64: false, exceptions: false, - // XXX: Though we don't actually support bulk memory yet, we + // XXX: Though we don't fully support bulk memory yet, we // unconditionally turn it on. // // Many parsers, notably our own `wasmparser`, assume that which @@ -607,14 +635,6 @@ impl Wizer { wasmparser::Payload::ModuleSectionEntry { parser, .. } => { parsers.push(parser); } - wasmparser::Payload::DataSection(mut data) => { - let count = data.get_count(); - for _ in 0..count { - if let wasmparser::DataKind::Passive = data.read().unwrap().kind { - anyhow::bail!("unsupported passive data segment"); - } - } - } wasmparser::Payload::End => { parsers.pop(); } diff --git a/crates/wizer/src/parse.rs b/crates/wizer/src/parse.rs index bbdce060baba..474dcf64be3d 100644 --- a/crates/wizer/src/parse.rs +++ b/crates/wizer/src/parse.rs @@ -84,7 +84,12 @@ pub(crate) fn parse<'a>(full_wasm: &'a [u8]) -> anyhow::Result elems.range(), full_wasm, ), - DataCountSection { .. } => unreachable!("validation rejects bulk memory"), + DataCountSection { range, .. } => stack.top_mut().module.add_raw_section( + &mut cx, + SectionId::DataCount, + range, + full_wasm, + ), DataSection(data) => stack.top_mut().module.add_raw_section( &mut cx, SectionId::Data, diff --git a/crates/wizer/tests/tests.rs b/crates/wizer/tests/tests.rs index 198c18667855..65b04856e552 100644 --- a/crates/wizer/tests/tests.rs +++ b/crates/wizer/tests/tests.rs @@ -13,6 +13,7 @@ fn get_wizer() -> Wizer { wizer.allow_wasi(true).unwrap(); wizer.wasm_multi_memory(true); wizer.wasm_module_linking(true); + wizer.wasm_bulk_memory(true); wizer } @@ -1014,3 +1015,73 @@ fn reject_import_instance_memory() -> Result<()> { "#, ) } + +#[test] +fn accept_bulk_memory_copy() -> Result<()> { + run_wat( + &[], + ('h' as i32) + ('w' as i32), + r#" + (module + (memory $memory (data "hello, wizer!")) + (func (export "wizer.initialize") + i32.const 42 ;; dst + i32.const 0 ;; src + i32.const 13 ;; size + memory.copy) + (func (export "run") (result i32) + i32.const 42 + i32.load8_u + i32.const 42 + i32.load8_u offset=7 + i32.add)) + "#, + ) +} + +#[test] +fn accept_bulk_memory_fill() -> Result<()> { + run_wat( + &[], + 77 + 77, + r#" + (module + (memory 1) + (func (export "wizer.initialize") + i32.const 42 ;; dst + i32.const 77 ;; value + i32.const 13 ;; size + memory.fill) + (func (export "run") (result i32) + i32.const 42 + i32.load8_u + i32.const 42 + i32.load8_u offset=7 + i32.add)) + "#, + ) +} + +#[test] +fn accept_bulk_memory_init() -> Result<()> { + run_wat( + &[], + ('h' as i32) + ('w' as i32), + r#" + (module + (memory 1) + (data $data "hello, wizer!") + (func (export "wizer.initialize") + i32.const 42 ;; dst + i32.const 0 ;; offset + i32.const 13 ;; size + memory.init $data) + (func (export "run") (result i32) + i32.const 42 + i32.load8_u + i32.const 42 + i32.load8_u offset=7 + i32.add)) + "#, + ) +} From 808dd8825fccea725f83ce9e651eb1344adacb0b Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Thu, 1 Sep 2022 15:26:43 -0600 Subject: [PATCH 102/212] add tests for rejecting additional reference types ops Signed-off-by: Joel Dice --- crates/wizer/tests/tests.rs | 123 +++++++++++++++++++++++++++++++++++- 1 file changed, 122 insertions(+), 1 deletion(-) diff --git a/crates/wizer/tests/tests.rs b/crates/wizer/tests/tests.rs index 65b04856e552..f3a8c84833aa 100644 --- a/crates/wizer/tests/tests.rs +++ b/crates/wizer/tests/tests.rs @@ -194,7 +194,7 @@ fn reject_imported_table() -> Result<()> { } #[test] -fn reject_bulk_memory() -> Result<()> { +fn reject_table_copy() -> Result<()> { let result = run_wat( &[], 42, @@ -226,6 +226,127 @@ fn reject_bulk_memory() -> Result<()> { Ok(()) } +#[test] +fn reject_table_get_set() -> Result<()> { + let result = run_wat( + &[], + 42, + r#" +(module + (table 3 funcref) + + (func $f (result i32) (i32.const 0)) + (func $g (result i32) (i32.const 0)) + (func $h (result i32) (i32.const 0)) + + (func (export "main") + i32.const 0 + i32.const 1 + table.get + table.set) + + (elem (i32.const 0) $f $g $h) +) +"#, + ); + assert!(result.is_err()); + + let err = result.unwrap_err(); + assert!(err + .to_string() + .contains("reference types support is not enabled"),); + + Ok(()) +} + +#[test] +fn reject_table_init() -> Result<()> { + let result = run_wat( + &[], + 42, + r#" +(module + (table 3 funcref) + + (func $f (result i32) (i32.const 0)) + (func $g (result i32) (i32.const 0)) + (func $h (result i32) (i32.const 0)) + + (elem $elem $f $g $h) + + (func (export "main") + i32.const 0 + i32.const 0 + i32.const 3 + table.init $elem) +) +"#, + ); + assert!(result.is_err()); + + let err = result.unwrap_err(); + assert!(err + .to_string() + .contains("unsupported `table.init` instruction")); + + Ok(()) +} + +#[test] +fn reject_elem_drop() -> Result<()> { + let result = run_wat( + &[], + 42, + r#" +(module + (table 3 funcref) + + (func $f (result i32) (i32.const 0)) + (func $g (result i32) (i32.const 0)) + (func $h (result i32) (i32.const 0)) + + (elem $elem $f $g $h) + + (func (export "main") + elem.drop $elem) +) +"#, + ); + assert!(result.is_err()); + + let err = result.unwrap_err(); + assert!(err + .to_string() + .contains("unsupported `elem.drop` instruction")); + + Ok(()) +} + +#[test] +fn reject_data_drop() -> Result<()> { + let result = run_wat( + &[], + 42, + r#" +(module + (memory 1) + (data $data "hello, wizer!") + + (func (export "main") + data.drop $data) +) +"#, + ); + assert!(result.is_err()); + + let err = result.unwrap_err(); + assert!(err + .to_string() + .contains("unsupported `data.drop` instruction")); + + Ok(()) +} + #[test] fn accept_module_linking_import_memory() -> Result<()> { run_wat( From 1bc058ad983ec06ec2357c22fc81990ea0a6436a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C3=BAl=20Cabrera?= Date: Tue, 7 Jun 2022 09:53:11 -0400 Subject: [PATCH 103/212] chore: Update wasmtime to v0.35.3 --- crates/wizer/Cargo.lock | 140 +++++++++++++++++++++-------------- crates/wizer/Cargo.toml | 6 +- crates/wizer/fuzz/Cargo.toml | 2 +- 3 files changed, 90 insertions(+), 58 deletions(-) diff --git a/crates/wizer/Cargo.lock b/crates/wizer/Cargo.lock index e9db39afc5ad..1b44413b1bfe 100644 --- a/crates/wizer/Cargo.lock +++ b/crates/wizer/Cargo.lock @@ -233,9 +233,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.70" +version = "1.0.73" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d26a6ce4b6a484fa3edb70f7efa6fc430fd2b87285fe8b84304fd0936faa0dc0" +checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" dependencies = [ "jobserver", ] @@ -281,18 +281,18 @@ dependencies = [ [[package]] name = "cranelift-bforest" -version = "0.81.1" +version = "0.82.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32f027f29ace03752bb83c112eb4f53744bc4baadf19955e67fcde1d71d2f39d" +checksum = "38faa2a16616c8e78a18d37b4726b98bfd2de192f2fdc8a39ddf568a408a0f75" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-codegen" -version = "0.81.1" +version = "0.82.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c10af69cbf4e228c11bdc26d8f9d5276773909152a769649a160571b282f92f" +checksum = "26f192472a3ba23860afd07d2b0217dc628f21fcc72617aa1336d98e1671f33b" dependencies = [ "cranelift-bforest", "cranelift-codegen-meta", @@ -307,33 +307,33 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.81.1" +version = "0.82.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290ac14d2cef43cbf1b53ad5c1b34216c9e32e00fa9b6ac57b5e5a2064369e02" +checksum = "0f32ddb89e9b89d3d9b36a5b7d7ea3261c98235a76ac95ba46826b8ec40b1a24" dependencies = [ "cranelift-codegen-shared", ] [[package]] name = "cranelift-codegen-shared" -version = "0.81.1" +version = "0.82.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "beb9142d134a03d01e3995e6d8dd3aecf16312261d0cb0c5dcd73d5be2528c1c" +checksum = "01fd0d9f288cc1b42d9333b7a776b17e278fc888c28e6a0f09b5573d45a150bc" [[package]] name = "cranelift-entity" -version = "0.81.1" +version = "0.82.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1268a50b7cbbfee8514d417fc031cedd9965b15fa9e5ed1d4bc16de86f76765e" +checksum = "9e3bfe172b83167604601faf9dc60453e0d0a93415b57a9c4d1a7ae6849185cf" dependencies = [ "serde", ] [[package]] name = "cranelift-frontend" -version = "0.81.1" +version = "0.82.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97ac0d440469e19ab12183e31a9e41b4efd8a4ca5fbde2a10c78c7bb857cc2a4" +checksum = "a006e3e32d80ce0e4ba7f1f9ddf66066d052a8c884a110b91d05404d6ce26dce" dependencies = [ "cranelift-codegen", "log", @@ -343,9 +343,9 @@ dependencies = [ [[package]] name = "cranelift-native" -version = "0.81.1" +version = "0.82.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "794cd1a5694a01c68957f9cfdc5ac092cf8b4e9c2d1697c4a5100f90103e9e9e" +checksum = "501241b0cdf903412ec9075385ac9f2b1eb18a89044d1538e97fab603231f70c" dependencies = [ "cranelift-codegen", "libc", @@ -354,9 +354,9 @@ dependencies = [ [[package]] name = "cranelift-wasm" -version = "0.81.1" +version = "0.82.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2ddd4ca6963f6e94d00e8935986411953581ac893587ab1f0eb4f0b5a40ae65" +checksum = "16d9e4211bbc3268042a96dd4de5bd979cda22434991d035f5f8eacba987fad2" dependencies = [ "cranelift-codegen", "cranelift-entity", @@ -364,7 +364,7 @@ dependencies = [ "itertools", "log", "smallvec", - "wasmparser 0.82.0", + "wasmparser 0.83.0", "wasmtime-types", ] @@ -784,6 +784,15 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1aab8fc367588b89dcee83ab0fd66b72b50b72fa1904d7095045ace2b0c81c35" +[[package]] +name = "ittapi-rs" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f712648a1ad72fbfb7adc2772c331e8d90f022f8cf30cbabefba2878dd3172b0" +dependencies = [ + "cc", +] + [[package]] name = "jobserver" version = "0.1.24" @@ -873,6 +882,15 @@ version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" +[[package]] +name = "memfd" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6627dc657574b49d6ad27105ed671822be56e0d2547d413bfbf3e8d8fa92e7a" +dependencies = [ + "libc", +] + [[package]] name = "memoffset" version = "0.6.4" @@ -1570,9 +1588,9 @@ checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" [[package]] name = "wasi-cap-std-sync" -version = "0.34.1" +version = "0.35.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c8a21d19ad46499a6611da6d74636f19a6bebaaaa85254b2bec4392493abe2c" +checksum = "9120fdc492d9d95cd7278b34f46fe9122962e4b2476c040f058971ccc00fc4d2" dependencies = [ "anyhow", "async-trait", @@ -1594,9 +1612,9 @@ dependencies = [ [[package]] name = "wasi-common" -version = "0.34.1" +version = "0.35.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73ee711ef917d4250d1b6d430d6b7f3a4820f52940fb59beb761297998ff7528" +checksum = "ab6097a5c8e9a791227a50945b6a891da6d93f518ebfa8716f231dc03f119585" dependencies = [ "anyhow", "bitflags", @@ -1707,9 +1725,9 @@ checksum = "be92b6dcaa5af4b2a176b29be3bf1402fab9e69d313141185099c7d1684f2dca" [[package]] name = "wasmparser" -version = "0.82.0" +version = "0.83.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0559cc0f1779240d6f894933498877ea94f693d84f3ee39c9a9932c6c312bd70" +checksum = "718ed7c55c2add6548cca3ddd6383d738cd73b892df400e96b9aa876f0141d7a" [[package]] name = "wasmprinter" @@ -1723,9 +1741,9 @@ dependencies = [ [[package]] name = "wasmtime" -version = "0.34.1" +version = "0.35.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4882e78d9daceeaff656d82869f298fd472ea8d8ccf96fbd310da5c1687773ac" +checksum = "21ffb4705016d5ca91e18a72ed6822dab50e6d5ddd7045461b17ef19071cdef1" dependencies = [ "anyhow", "async-trait", @@ -1744,7 +1762,7 @@ dependencies = [ "region", "serde", "target-lexicon", - "wasmparser 0.82.0", + "wasmparser 0.83.0", "wasmtime-cache", "wasmtime-cranelift", "wasmtime-environ", @@ -1757,9 +1775,9 @@ dependencies = [ [[package]] name = "wasmtime-cache" -version = "0.34.1" +version = "0.35.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf5b9af2d970624455f9ea109acc60cc477afe097f86c190eb519a8b7d6646cd" +checksum = "85c6ab24291fa7cb3a181f5669f6c72599b7ef781669759b45c7828c5999d0c0" dependencies = [ "anyhow", "base64", @@ -1777,9 +1795,9 @@ dependencies = [ [[package]] name = "wasmtime-cranelift" -version = "0.34.1" +version = "0.35.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ed6ff21d2dbfe568af483f0c508e049fc6a497c73635e2c50c9b1baf3a93ed8" +checksum = "f04c810078a491b7bc4866ebe045f714d2b95e6b539e1f64009a4a7606be11de" dependencies = [ "anyhow", "cranelift-codegen", @@ -1793,15 +1811,15 @@ dependencies = [ "object 0.27.1", "target-lexicon", "thiserror", - "wasmparser 0.82.0", + "wasmparser 0.83.0", "wasmtime-environ", ] [[package]] name = "wasmtime-environ" -version = "0.34.1" +version = "0.35.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "860936d38df423b4291b3e31bc28d4895e2208f9daba351c2397d18a0a10e0bf" +checksum = "61448266ea164b1ac406363cdcfac81c7c44db4d94c7a81c8620ac6c5c6cdf59" dependencies = [ "anyhow", "cranelift-entity", @@ -1813,15 +1831,15 @@ dependencies = [ "serde", "target-lexicon", "thiserror", - "wasmparser 0.82.0", + "wasmparser 0.83.0", "wasmtime-types", ] [[package]] name = "wasmtime-fiber" -version = "0.34.1" +version = "0.35.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67e285306aa274d85a22753bef826226e1cc473bac0b541523f46dccf80751cc" +checksum = "bbaaa38c3b48822ab27044e1d4a25a1052157de4c8f27574cb00167e127e320f" dependencies = [ "cc", "rustix", @@ -1830,9 +1848,9 @@ dependencies = [ [[package]] name = "wasmtime-jit" -version = "0.34.1" +version = "0.35.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e794310a0df5266c7ac73e8211a024a49e3860ac0ca2af5db8527be942ad063e" +checksum = "156b4623c6b0d4b8c24afb846c20525922f538ef464cc024abab7ea8de2109a2" dependencies = [ "addr2line 0.17.0", "anyhow", @@ -1840,6 +1858,7 @@ dependencies = [ "cfg-if", "cpp_demangle", "gimli 0.26.1", + "ittapi-rs", "log", "object 0.27.1", "region", @@ -1849,25 +1868,37 @@ dependencies = [ "target-lexicon", "thiserror", "wasmtime-environ", + "wasmtime-jit-debug", "wasmtime-runtime", "winapi", ] +[[package]] +name = "wasmtime-jit-debug" +version = "0.35.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5dc31f811760a6c76b2672c404866fd19b75e5fb3b0075a3e377a6846490654" +dependencies = [ + "lazy_static", + "object 0.27.1", + "rustix", +] + [[package]] name = "wasmtime-runtime" -version = "0.34.1" +version = "0.35.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90ffe5cb3db705ea43fcf37475a79891a3ada754c1cbe333540879649de943d5" +checksum = "f907beaff69d4d920fa4688411ee4cc75c0f01859e424677f9e426e2ef749864" dependencies = [ "anyhow", "backtrace", "cc", "cfg-if", "indexmap", - "lazy_static", "libc", "log", "mach", + "memfd", "memoffset", "more-asserts", "rand", @@ -1876,26 +1907,27 @@ dependencies = [ "thiserror", "wasmtime-environ", "wasmtime-fiber", + "wasmtime-jit-debug", "winapi", ] [[package]] name = "wasmtime-types" -version = "0.34.1" +version = "0.35.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70a5b60d70c1927c5a403f7c751de179414b6b91da75b2312c3ae78196cf9dc3" +checksum = "514ef0e5fd197b9609dc9eb74beba0c84d5a12b2417cbae55534633329ba4852" dependencies = [ "cranelift-entity", "serde", "thiserror", - "wasmparser 0.82.0", + "wasmparser 0.83.0", ] [[package]] name = "wasmtime-wasi" -version = "0.34.1" +version = "0.35.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23fa6fbbad7e6f7dfe5fc0127ecd4bca409e3dcb51596b10ccf4949ac450d4c9" +checksum = "3f0633261ad13d93ae84c758ce195c659a0ee57fcdbe724c8976f4b1872cdcde" dependencies = [ "anyhow", "wasi-cap-std-sync", @@ -1943,9 +1975,9 @@ dependencies = [ [[package]] name = "wiggle" -version = "0.34.1" +version = "0.35.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11fb3417e7e14c88f2d9ee6c3746ba6b71f4000f7f4d1450b219a278f39d31e8" +checksum = "36fb71c833bf174b1b34979942ff33f525b97311232ef6a0a18bcdf540ae9c91" dependencies = [ "anyhow", "async-trait", @@ -1958,9 +1990,9 @@ dependencies = [ [[package]] name = "wiggle-generate" -version = "0.34.1" +version = "0.35.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0c36b9602eda8612e2338c4f39728046819b3bc2ed71a474c5c108f5b54e1f9" +checksum = "52d684c4454e953df20b5a1c3e0a8d208ef4d5a768e013f64bebfc9f74a3f739" dependencies = [ "anyhow", "heck", @@ -1973,9 +2005,9 @@ dependencies = [ [[package]] name = "wiggle-macro" -version = "0.34.1" +version = "0.35.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abd843bbf81370dba59cb869cb50d8e369e82b809f84b6a8db23d6b2394e50e8" +checksum = "1da6c96c93eced4bf71e59ca1f06f933b84f37544a354646e37c0e5c6d5a262d" dependencies = [ "proc-macro2", "quote", diff --git a/crates/wizer/Cargo.toml b/crates/wizer/Cargo.toml index 5574ade02754..6259c19accd9 100644 --- a/crates/wizer/Cargo.toml +++ b/crates/wizer/Cargo.toml @@ -32,11 +32,11 @@ env_logger = { version = "0.8.2", optional = true } log = "0.4.14" rayon = "1.5.0" structopt = { version = "0.3.21", optional = true } -wasi-cap-std-sync = "0.34.1" +wasi-cap-std-sync = "0.35.3" wasm-encoder = "0.6.0" wasmparser = "0.78.2" -wasmtime = "0.34.1" -wasmtime-wasi = "0.34.1" +wasmtime = "0.35.3" +wasmtime-wasi = "0.35.3" # Enable this dependency to get messages with WAT disassemblies when certain # internal panics occur. diff --git a/crates/wizer/fuzz/Cargo.toml b/crates/wizer/fuzz/Cargo.toml index c561f660e28b..4f8b36adee97 100644 --- a/crates/wizer/fuzz/Cargo.toml +++ b/crates/wizer/fuzz/Cargo.toml @@ -15,7 +15,7 @@ libfuzzer-sys = "0.4" log = "0.4.14" wasm-smith = "0.4.0" wasmprinter = "0.2.26" -wasmtime = "0.34.1" +wasmtime = "0.35.3" [dependencies.wizer] path = ".." From 0e16565d6e60880a879a63d62f187bd7bd04ff9d Mon Sep 17 00:00:00 2001 From: Jake Champion Date: Fri, 26 Aug 2022 15:59:29 +0100 Subject: [PATCH 104/212] Move to using the same cross-compiling workflow as wasmtime which enables binary compatible builds and compiles for more platforms These prebuilt binaries will eventually be used within a wizer npm package (which itself will be used within the `@fastly/js-compute` npm package). I've tested both the macos builds and they are working I don't have a windows machine to test on and I don't have an x86_64 linux machine to test on unfortunately aarch64-linux and s390x-linux are commented out due to build errors these errors are solved in a newer version of wasmtime, when wizer updates to the newer wasmtime then we should uncomment these builds --- .../binary-compatible-builds/README.md | 9 + .../binary-compatible-builds/action.yml | 10 + .../actions/binary-compatible-builds/main.js | 56 ++++++ .../.github/actions/install-rust/README.md | 18 ++ .../.github/actions/install-rust/action.yml | 12 ++ .../.github/actions/install-rust/main.js | 36 ++++ crates/wizer/.github/workflows/ci.yml | 91 +-------- crates/wizer/.github/workflows/release.yml | 187 +++++++++++------- crates/wizer/ci/build-tarballs.sh | 63 +++--- .../wizer/ci/docker/aarch64-linux/Dockerfile | 7 + crates/wizer/ci/docker/s390x-linux/Dockerfile | 7 + .../wizer/ci/docker/x86_64-linux/Dockerfile | 5 + 12 files changed, 322 insertions(+), 179 deletions(-) create mode 100644 crates/wizer/.github/actions/binary-compatible-builds/README.md create mode 100644 crates/wizer/.github/actions/binary-compatible-builds/action.yml create mode 100755 crates/wizer/.github/actions/binary-compatible-builds/main.js create mode 100644 crates/wizer/.github/actions/install-rust/README.md create mode 100644 crates/wizer/.github/actions/install-rust/action.yml create mode 100644 crates/wizer/.github/actions/install-rust/main.js create mode 100644 crates/wizer/ci/docker/aarch64-linux/Dockerfile create mode 100644 crates/wizer/ci/docker/s390x-linux/Dockerfile create mode 100644 crates/wizer/ci/docker/x86_64-linux/Dockerfile diff --git a/crates/wizer/.github/actions/binary-compatible-builds/README.md b/crates/wizer/.github/actions/binary-compatible-builds/README.md new file mode 100644 index 000000000000..8368fd4f1a9e --- /dev/null +++ b/crates/wizer/.github/actions/binary-compatible-builds/README.md @@ -0,0 +1,9 @@ +# binary-compatible-builds + +A small (ish) action which is intended to be used and will configure builds of +Rust projects to be "more binary compatible". On Windows and macOS this +involves setting a few env vars, and on Linux this involves spinning up a CentOS +6 container which is running in the background. + +All subsequent build commands need to be wrapped in `$CENTOS` to optionally run +on `$CENTOS` on Linux to ensure builds happen inside the container. diff --git a/crates/wizer/.github/actions/binary-compatible-builds/action.yml b/crates/wizer/.github/actions/binary-compatible-builds/action.yml new file mode 100644 index 000000000000..c2950d99b02b --- /dev/null +++ b/crates/wizer/.github/actions/binary-compatible-builds/action.yml @@ -0,0 +1,10 @@ +name: 'Set up a CentOS 6 container to build releases in' +description: 'Set up a CentOS 6 container to build releases in' + +runs: + using: node12 + main: 'main.js' +inputs: + name: + required: true + description: "Name of the build" diff --git a/crates/wizer/.github/actions/binary-compatible-builds/main.js b/crates/wizer/.github/actions/binary-compatible-builds/main.js new file mode 100755 index 000000000000..378c5c202c9c --- /dev/null +++ b/crates/wizer/.github/actions/binary-compatible-builds/main.js @@ -0,0 +1,56 @@ +#!/usr/bin/env node + +const child_process = require('child_process'); +const stdio = { stdio: 'inherit' }; +const fs = require('fs'); + +function set_env(name, val) { + fs.appendFileSync(process.env['GITHUB_ENV'], `${name}=${val}\n`) +} + +// On OSX all we need to do is configure our deployment target as old as +// possible. For now 10.9 is the limit. +if (process.platform == 'darwin') { + set_env("MACOSX_DEPLOYMENT_TARGET", "10.9"); + return; +} + +// On Windows we build against the static CRT to reduce dll dependencies +if (process.platform == 'win32') { + set_env("RUSTFLAGS", "-Ctarget-feature=+crt-static"); + return; +} + +// ... and on Linux we do fancy things with containers. We'll spawn an old +// CentOS container in the background with a super old glibc, and then we'll run +// commands in there with the `$CENTOS` env var. + +if (process.env.CENTOS !== undefined) { + const args = ['exec', '-w', process.cwd(), '-i', 'build-container']; + for (const arg of process.argv.slice(2)) { + args.push(arg); + } + child_process.execFileSync('docker', args, stdio); + return; +} + +const name = process.env.INPUT_NAME; + +child_process.execFileSync('docker', [ + 'build', + '--tag', 'build-image', + `${process.cwd()}/ci/docker/${name}` +], stdio); + +child_process.execFileSync('docker', [ + 'run', + '--detach', + '--interactive', + '--name', 'build-container', + '-v', `${process.cwd()}:${process.cwd()}`, + '-v', `${child_process.execSync('rustc --print sysroot').toString().trim()}:/rust:ro`, + 'build-image', +], stdio); + +// Use ourselves to run future commands +set_env("CENTOS", __filename); diff --git a/crates/wizer/.github/actions/install-rust/README.md b/crates/wizer/.github/actions/install-rust/README.md new file mode 100644 index 000000000000..df8e94dcccbf --- /dev/null +++ b/crates/wizer/.github/actions/install-rust/README.md @@ -0,0 +1,18 @@ +# install-rust + +A small github action to install `rustup` and a Rust toolchain. This is +generally expressed inline, but it was repeated enough in this repository it +seemed worthwhile to extract. + +Some gotchas: + +* Can't `--self-update` on Windows due to permission errors (a bug in Github + Actions) +* `rustup` isn't installed on macOS (a bug in Github Actions) + +When the above are fixed we should delete this action and just use this inline: + +```yml +- run: rustup update $toolchain && rustup default $toolchain + shell: bash +``` diff --git a/crates/wizer/.github/actions/install-rust/action.yml b/crates/wizer/.github/actions/install-rust/action.yml new file mode 100644 index 000000000000..7a196591840d --- /dev/null +++ b/crates/wizer/.github/actions/install-rust/action.yml @@ -0,0 +1,12 @@ +name: 'Install Rust toolchain' +description: 'Install both `rustup` and a Rust toolchain' + +inputs: + toolchain: + description: 'Default toolchan to install' + required: false + default: 'stable' + +runs: + using: node12 + main: 'main.js' diff --git a/crates/wizer/.github/actions/install-rust/main.js b/crates/wizer/.github/actions/install-rust/main.js new file mode 100644 index 000000000000..b144d70aea43 --- /dev/null +++ b/crates/wizer/.github/actions/install-rust/main.js @@ -0,0 +1,36 @@ +const child_process = require('child_process'); +const toolchain = process.env.INPUT_TOOLCHAIN; +const fs = require('fs'); + +function set_env(name, val) { + fs.appendFileSync(process.env['GITHUB_ENV'], `${name}=${val}\n`) +} + +// Needed for now to get 1.24.2 which fixes a bug in 1.24.1 that causes issues +// on Windows. +if (process.platform === 'win32') { + child_process.execFileSync('rustup', ['self', 'update']); +} + +child_process.execFileSync('rustup', ['set', 'profile', 'minimal']); +child_process.execFileSync('rustup', ['update', toolchain, '--no-self-update']); +child_process.execFileSync('rustup', ['default', toolchain]); + +// Deny warnings on CI to keep our code warning-free as it lands in-tree. Don't +// do this on nightly though since there's a fair amount of warning churn there. +if (!toolchain.startsWith('nightly')) { + set_env("RUSTFLAGS", "-D warnings"); +} + +// Save disk space by avoiding incremental compilation, and also we don't use +// any caching so incremental wouldn't help anyway. +set_env("CARGO_INCREMENTAL", "0"); + +// Turn down debuginfo from 2 to 1 to help save disk space +set_env("CARGO_PROFILE_DEV_DEBUG", "1"); +set_env("CARGO_PROFILE_TEST_DEBUG", "1"); + +if (process.platform === 'darwin') { + set_env("CARGO_PROFILE_DEV_SPLIT_DEBUGINFO", "unpacked"); + set_env("CARGO_PROFILE_TEST_SPLIT_DEBUGINFO", "unpacked"); +} diff --git a/crates/wizer/.github/workflows/ci.yml b/crates/wizer/.github/workflows/ci.yml index 194bba16a0a9..bb5bd4312d2c 100644 --- a/crates/wizer/.github/workflows/ci.yml +++ b/crates/wizer/.github/workflows/ci.yml @@ -1,10 +1,6 @@ name: CI -on: - push: - branches: [ main ] - pull_request: - branches: [ main ] +on: pull_request env: CARGO_TERM_COLOR: always @@ -19,8 +15,14 @@ jobs: os: ubuntu-latest - build: x86_64-macos os: macos-latest + - build: aarch64-macos + os: macos-latest + target: aarch64-apple-darwin - build: x86_64-windows os: windows-latest + - build: x86_64-mingw + os: windows-latest + target: x86_64-pc-windows-gnu steps: - uses: actions/checkout@v2 - name: Build @@ -29,22 +31,6 @@ jobs: run: cargo test --verbose - name: Checking benches run : cargo check --benches - - name: Build release binary - run: cargo build --release --bin wizer --features="env_logger structopt" - - - name: Create dist - run: mkdir dist - - # Move binaries to dist folder - - run: cp target/release/wizer dist - if: matrix.os != 'windows-latest' && matrix.target == '' - - run: cp target/release/wizer.exe dist - if: matrix.build == 'x86_64-windows' - - - uses: actions/upload-artifact@v1 - with: - name: bins-${{ matrix.build }} - path: dist check_fuzz: runs-on: ubuntu-latest @@ -61,66 +47,3 @@ jobs: - run: rustup default stable - run: rustup component add rustfmt - run: cargo fmt --all -- --check - - - # Consumes all published artifacts from all the previous build steps, creates - # a bunch of tarballs for all of them, and then publishes the tarballs - # themselves as an artifact (for inspection) and then optionally creates - # github releases and/or tags for pushes. - publish: - name: Publish - needs: [build, rustfmt] - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - # Download all the artifacts that we'll be publishing. Should keep an eye on - # the `download-artifact` repository to see if we can ever get something - # like "download all artifacts" or "download this list of artifacts" - - name: Download x86_64 macOS binaries - uses: actions/download-artifact@v1 - with: - name: bins-x86_64-macos - - name: Download x86_64 Linux binaries - uses: actions/download-artifact@v1 - with: - name: bins-x86_64-linux - - name: Download x86_64 Windows binaries - uses: actions/download-artifact@v1 - with: - name: bins-x86_64-windows - - - name: Calculate tag name - run: | - name=dev - if [[ $GITHUB_REF == refs/tags/v* ]]; then - name=${GITHUB_REF:10} - fi - echo ::set-output name=val::$name - echo TAG=$name >> $GITHUB_ENV - id: tagname - - # Assemble all the build artifacts into tarballs and zip archives. - - name: Assemble tarballs - run: | - ./ci/build-tarballs.sh x86_64-linux - ./ci/build-tarballs.sh x86_64-macos - ./ci/build-tarballs.sh x86_64-windows .exe - - # Upload all assembled tarballs as an artifact of the github action run, so - # that way even PRs can inspect the output. - - uses: actions/upload-artifact@v1 - with: - name: tarballs - path: dist - - # ... and if this was an actual push (tag or `main`) then we publish a - # new release. This'll automatically publish a tag release or update `dev` - # with this `sha` - - name: Publish Release - uses: ./.github/actions/github-release - if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')) - with: - files: "dist/*" - name: ${{ steps.tagname.outputs.val }} - token: ${{ secrets.GITHUB_TOKEN }} diff --git a/crates/wizer/.github/workflows/release.yml b/crates/wizer/.github/workflows/release.yml index 00cad17b4bc6..01121e77f932 100644 --- a/crates/wizer/.github/workflows/release.yml +++ b/crates/wizer/.github/workflows/release.yml @@ -1,91 +1,132 @@ -# This is nearly entirely copied from -# https://github.com/fastly/Viceroy/blob/b37b89fc07ecd5845f1103380c5e4fae9cc13b30/.github/workflows/release.yml#L1 -# The changes made are to add the `--bin wizer` flag and change the filesystem paths to use wizer instead of viceroy name: Release - on: push: - tags: - - "v*.*.*" + branches: [main] + tags-ignore: [dev] + pull_request: +defaults: + run: + shell: bash + +# Cancel any in-flight jobs for the same PR/branch so there's only one active +# at a time +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true jobs: build: + runs-on: ${{ matrix.os }} strategy: matrix: - rust-toolchain: [stable] - os: [ubuntu-latest, macos-11, windows-latest] - arch: [amd64, arm64] - exclude: - - os: windows-latest - arch: arm64 include: - - os: ubuntu-latest - name: linux - rust_abi: unknown-linux-gnu - - os: macos-11 - name: darwin - rust_abi: apple-darwin - - os: windows-latest - name: windows - rust_abi: pc-windows-msvc - extension: .exe - - arch: arm64 - rust_arch: aarch64 - - arch: amd64 - rust_arch: x86_64 + - build: x86_64-linux + os: ubuntu-latest + - build: x86_64-macos + os: macos-latest + - build: aarch64-macos + os: macos-latest + target: aarch64-apple-darwin + - build: x86_64-windows + os: windows-latest + - build: x86_64-mingw + os: windows-latest + target: x86_64-pc-windows-gnu + + # TODO: aarch64-linux and s390x-linux are commented out due to build errors + # these errors are solved in a newer version of wasmtime, when wizer + # updates to the newer wasmtime then we should uncomment these builds + + #src/arch/aarch64.S: Assembler messages: + #src/arch/aarch64.S:21: Error: operand 1 should be a floating-point register -- `stp lr,fp,[sp,-16]!' + #src/arch/aarch64.S:50: Error: operand 1 should be a floating-point register -- `ldp lr,fp,[sp],16' + #src/arch/aarch64.S:90: Error: bad register expression + #exit status: 1 + #- build: aarch64-linux + #os: ubuntu-latest + #target: aarch64-unknown-linux-gnu + + #/rust/lib/rustlib/s390x-unknown-linux-gnu/lib/libstd-f6c951af7877beaf.rlib(std-f6c951af7877beaf.std.e2801c51-cgu.0.rcgu.o): In function `std::sys::unix::rand::imp::getrandom_fill_bytes::hb641b796bca799e8': + #/rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/sys/unix/rand.rs:(.text._ZN3std3sys4unix4rand19hashmap_random_keys17h949023c83f75d545E+0x30): undefined reference to `getrandom' + #/rust/lib/rustlib/s390x-unknown-linux-gnu/lib/libstd-f6c951af7877beaf.rlib(std-f6c951af7877beaf.std.e2801c51-cgu.0.rcgu.o): In function `std::sys::unix::rand::imp::getrandom::getrandom::h09b00f3fdb24c5b7': + #/rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/sys/unix/weak.rs:176: undefined reference to `getrandom' + #/rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/sys/unix/weak.rs:176: undefined reference to `getrandom' + #collect2: error: ld returned 1 exit status + #- build: s390x-linux + #os: ubuntu-latest + #target: s390x-unknown-linux-gnu + steps: + - uses: actions/checkout@v2 + with: + submodules: true + - uses: ./.github/actions/install-rust + - uses: ./.github/actions/binary-compatible-builds + with: + name: ${{ matrix.build }} + - run: | + echo CARGO_BUILD_TARGET=${{ matrix.target }} >> $GITHUB_ENV + rustup target add ${{ matrix.target }} + if: matrix.target != '' - runs-on: ${{ matrix.os }} + # Build `wizer` and executables + - run: $CENTOS cargo build --release --locked --bin wizer --all-features + + # Assemble release artifats appropriate for this platform, then upload them + # unconditionally to this workflow's files so we have a copy of them. + - run: ./ci/build-tarballs.sh "${{ matrix.build }}" "${{ matrix.target }}" + - uses: actions/upload-artifact@v1 + with: + name: bins-${{ matrix.build }} + path: dist + publish: + needs: [build] + runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v2 + - uses: actions/checkout@v2 + # Download all the artifacts that we'll be publishing. Should keep an eye on + # the `download-artifact` repository to see if we can ever get something + # like "download all artifacts" or "download this list of artifacts" + - uses: actions/download-artifact@v1 with: - submodules: true - - - name: Install latest Rust toolchain - uses: actions-rs/toolchain@v1 + name: bins-x86_64-macos + path: dist + - uses: actions/download-artifact@v1 with: - toolchain: ${{ matrix.rust-toolchain }} - target: ${{ matrix.rust_arch }}-${{ matrix.rust_abi }} - default: true - override: true - - - name: Install C cross-compilation toolchain - if: ${{ matrix.name == 'linux' && matrix.arch != 'amd64' }} - run: | - sudo apt-get update - sudo apt install -f -y gcc-${{ matrix.rust_arch }}-linux-gnu - echo CC=${{ matrix.rust_arch }}-linux-gnu-gcc >> $GITHUB_ENV - echo RUSTFLAGS='-C linker=${{ matrix.rust_arch }}-linux-gnu-gcc' >> $GITHUB_ENV - - - name: Extract tag name - uses: olegtarasov/get-tag@v2.1 - id: tagName - - - name: Build - uses: actions-rs/cargo@v1 + name: bins-aarch64-macos + path: dist + - uses: actions/download-artifact@v1 with: - command: build - args: --release --locked --bin wizer --target=${{ matrix.rust_arch }}-${{ matrix.rust_abi }} --all-features - - - name: Strip symbols (linux) - if: ${{ matrix.name == 'linux' }} - run: | - ${{ matrix.rust_arch }}-linux-gnu-strip target/${{ matrix.rust_arch }}-${{ matrix.rust_abi }}/release/wizer${{ matrix.extension }} - - - name: Strip symbols (non-linux) - if: ${{ matrix.name != 'linux' }} - run: | - strip target/${{ matrix.rust_arch }}-${{ matrix.rust_abi }}/release/wizer${{ matrix.extension }} + name: bins-x86_64-windows + path: dist + - uses: actions/download-artifact@v1 + with: + name: bins-x86_64-mingw + path: dist + - uses: actions/download-artifact@v1 + with: + name: bins-x86_64-linux + path: dist - - name: Package + - name: Calculate tag name run: | - cd target/${{ matrix.rust_arch }}-${{ matrix.rust_abi }}/release - tar czf wizer_${{ steps.tagName.outputs.tag }}_${{ matrix.name }}-${{ matrix.arch }}.tar.gz wizer${{ matrix.extension }} + name=dev + if [[ $GITHUB_REF == refs/tags/v* ]]; then + name=${GITHUB_REF:10} + fi + echo ::set-output name=val::$name + echo TAG=$name >> $GITHUB_ENV + id: tagname - - name: Release - uses: softprops/action-gh-release@v1 + # ... and if this was an actual push (tag or `main`) then we publish a + # new release. This'll automatically publish a tag release or update `dev` + # with this `sha`. Note that `continue-on-error` is set here so if this hits + # a bug we can go back and fetch and upload the release ourselves. + - run: cd .github/actions/github-release && npm install --production + - name: Publish Release + uses: ./.github/actions/github-release + if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')) with: - files: | - target/${{ matrix.rust_arch }}-${{ matrix.rust_abi }}/release/wizer_${{ steps.tagName.outputs.tag }}_${{ matrix.name }}-${{ matrix.arch }}.tar.gz - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + files: "dist/*" + token: ${{ secrets.GITHUB_TOKEN }} + name: ${{ steps.tagname.outputs.val }} + continue-on-error: true diff --git a/crates/wizer/ci/build-tarballs.sh b/crates/wizer/ci/build-tarballs.sh index 530d70473729..4e316407f4c8 100755 --- a/crates/wizer/ci/build-tarballs.sh +++ b/crates/wizer/ci/build-tarballs.sh @@ -1,41 +1,60 @@ #!/bin/bash -# A small shell script invoked from CI on the final Linux builder which actually -# assembles the release artifacts for a particular platform. This will take the -# binary artifacts of previous builders and create associated tarballs to -# publish to GitHub. +# A small script used for assembling release tarballs for the `wizer` +# binary. This is executed with two arguments, mostly coming from +# the CI matrix. # -# The first argument of this is the "platform" name to put into the tarball, and -# the second argument is the name of the github actions platform which is where -# we source binaries from. The final third argument is ".exe" on Windows to -# handle executable extensions right. +# The first argument is the name of the platform, used to name the release +# The second argument is the "target", if present, currently only for +# cross-compiles # -# Usage: build-tarballs.sh PLATFORM [.exe] - -# where PLATFORM is e.g. x86_64-linux, aarch64-linux, ... +# This expects the build to already be done and will assemble release artifacts +# in `dist/` set -ex platform=$1 -exe=$2 +target=$2 rm -rf tmp mkdir tmp mkdir -p dist +tag=dev +if [[ $GITHUB_REF == refs/tags/v* ]]; then + tag=${GITHUB_REF:10} +fi + +bin_pkgname=wizer-$tag-$platform + +mkdir tmp/$bin_pkgname +cp LICENSE README.md tmp/$bin_pkgname + +fmt=tar +if [ "$platform" = "x86_64-windows" ]; then + cp target/release/wizer.exe tmp/$bin_pkgname + fmt=zip +elif [ "$platform" = "x86_64-mingw" ]; then + cp target/x86_64-pc-windows-gnu/release/wizer.exe tmp/$bin_pkgname + fmt=zip +elif [ "$target" = "" ]; then + cp target/release/wizer tmp/$bin_pkgname +else + cp target/$target/release/wizer tmp/$bin_pkgname +fi + + mktarball() { dir=$1 - if [ "$exe" = "" ]; then - tar cJf dist/$dir.tar.xz -C tmp $dir + if [ "$fmt" = "tar" ]; then + # this is a bit wonky, but the goal is to use `xz` with threaded compression + # to ideally get better performance with the `-T0` flag. + tar -cvf - -C tmp $dir | xz -9 -T0 > dist/$dir.tar.xz else - (cd tmp && zip -r ../dist/$dir.zip $dir) + # Note that this runs on Windows, and it looks like GitHub Actions doesn't + # have a `zip` tool there, so we use something else + (cd tmp && 7z a ../dist/$dir.zip $dir/) fi } -# Create the main tarball of binaries -bin_pkgname=wizer-$TAG-$platform -mkdir tmp/$bin_pkgname -cp README.md tmp/$bin_pkgname -mv bins-$platform/wizer$exe tmp/$bin_pkgname -chmod +x tmp/$bin_pkgname/wizer$exe -mktarball $bin_pkgname +mktarball $bin_pkgname \ No newline at end of file diff --git a/crates/wizer/ci/docker/aarch64-linux/Dockerfile b/crates/wizer/ci/docker/aarch64-linux/Dockerfile new file mode 100644 index 000000000000..738688bedcdb --- /dev/null +++ b/crates/wizer/ci/docker/aarch64-linux/Dockerfile @@ -0,0 +1,7 @@ +FROM ubuntu:16.04 + +RUN apt-get update -y && apt-get install -y gcc gcc-aarch64-linux-gnu ca-certificates + +ENV PATH=$PATH:/rust/bin +ENV CARGO_BUILD_TARGET=aarch64-unknown-linux-gnu +ENV CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc \ No newline at end of file diff --git a/crates/wizer/ci/docker/s390x-linux/Dockerfile b/crates/wizer/ci/docker/s390x-linux/Dockerfile new file mode 100644 index 000000000000..f25df1b5d6bb --- /dev/null +++ b/crates/wizer/ci/docker/s390x-linux/Dockerfile @@ -0,0 +1,7 @@ +FROM ubuntu:16.04 + +RUN apt-get update -y && apt-get install -y gcc gcc-s390x-linux-gnu ca-certificates + +ENV PATH=$PATH:/rust/bin +ENV CARGO_BUILD_TARGET=s390x-unknown-linux-gnu +ENV CARGO_TARGET_S390X_UNKNOWN_LINUX_GNU_LINKER=s390x-linux-gnu-gcc \ No newline at end of file diff --git a/crates/wizer/ci/docker/x86_64-linux/Dockerfile b/crates/wizer/ci/docker/x86_64-linux/Dockerfile new file mode 100644 index 000000000000..388eddf9f786 --- /dev/null +++ b/crates/wizer/ci/docker/x86_64-linux/Dockerfile @@ -0,0 +1,5 @@ +FROM centos:7 + +RUN yum install -y git gcc + +ENV PATH=$PATH:/rust/bin \ No newline at end of file From 22e7fc4bb92477276fb47a9df689e61c764fc993 Mon Sep 17 00:00:00 2001 From: Jake Champion Date: Fri, 5 Aug 2022 17:53:00 +0100 Subject: [PATCH 105/212] Add npm packages for each platform+architecture combination that we supply prebuilt binaries for --- crates/wizer/.gitignore | 5 + crates/wizer/npm/wizer/LICENSE.md | 220 +++++++++++++++++++++++++ crates/wizer/npm/wizer/README.md | 18 ++ crates/wizer/npm/wizer/index.js | 18 ++ crates/wizer/npm/wizer/package.json | 38 +++++ crates/wizer/npm/wizer/post-install.js | 24 +++ crates/wizer/npm/wizer/update.js | 97 +++++++++++ crates/wizer/npm/wizer/wizer | 1 + 8 files changed, 421 insertions(+) create mode 100644 crates/wizer/npm/wizer/LICENSE.md create mode 100644 crates/wizer/npm/wizer/README.md create mode 100644 crates/wizer/npm/wizer/index.js create mode 100644 crates/wizer/npm/wizer/package.json create mode 100644 crates/wizer/npm/wizer/post-install.js create mode 100644 crates/wizer/npm/wizer/update.js create mode 100755 crates/wizer/npm/wizer/wizer diff --git a/crates/wizer/.gitignore b/crates/wizer/.gitignore index ea8c4bf7f35f..80730c7232fe 100644 --- a/crates/wizer/.gitignore +++ b/crates/wizer/.gitignore @@ -1 +1,6 @@ /target +node_modules +npm/wizer-darwin-arm64/ +npm/wizer-darwin-x64/ +npm/wizer-linux-x64/ +npm/wizer-win32-x64/ diff --git a/crates/wizer/npm/wizer/LICENSE.md b/crates/wizer/npm/wizer/LICENSE.md new file mode 100644 index 000000000000..f9d81955f4bc --- /dev/null +++ b/crates/wizer/npm/wizer/LICENSE.md @@ -0,0 +1,220 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + +--- LLVM Exceptions to the Apache 2.0 License ---- + +As an exception, if, as a result of your compiling your source code, portions +of this Software are embedded into an Object form of such source code, you +may redistribute such embedded portions in such Object form without complying +with the conditions of Sections 4(a), 4(b) and 4(d) of the License. + +In addition, if you combine or link compiled forms of this Software with +software that is licensed under the GPLv2 ("Combined Software") and if a +court of competent jurisdiction determines that the patent provision (Section +3), the indemnity provision (Section 9) or other Section of the License +conflicts with the conditions of the GPLv2, you may retroactively and +prospectively choose to deem waived or otherwise exclude such Section(s) of +the License, but only in their entirety and only with respect to the Combined +Software. + diff --git a/crates/wizer/npm/wizer/README.md b/crates/wizer/npm/wizer/README.md new file mode 100644 index 000000000000..fff50d06c1f1 --- /dev/null +++ b/crates/wizer/npm/wizer/README.md @@ -0,0 +1,18 @@ +# wizer + +> Prebuilt wizer binaries available via npm + +## API + +``` +$ npm install --save @bytecode-alliance/wizer +``` + +```js +const execFile = require('child_process').execFile; +const wizer = require('@bytecode-alliance/wizer'); + +execFile(wizer, ['input.wasm', '-o', 'initialized.wasm'], (err, stdout) => { + console.log(stdout); +}); +``` diff --git a/crates/wizer/npm/wizer/index.js b/crates/wizer/npm/wizer/index.js new file mode 100644 index 000000000000..66b0b76de7fb --- /dev/null +++ b/crates/wizer/npm/wizer/index.js @@ -0,0 +1,18 @@ +const platformPackages = [ + "@bytecode-alliance/wizer-win32-x64", + "@bytecode-alliance/wizer-linux-x64", + "@bytecode-alliance/wizer-darwin-x64", + "@bytecode-alliance/wizer-darwin-arm64", +] + +let location; +for (const pkg of platformPackages) { + try { + location = await import(pkg); + } catch {} +} +throw new Error( + "@bytecode-alliance/wizer does not have a precompiled binary for the platform/architecture you are using. You can open an issue on https://github.com/bytecodealliance/wizer/issues to request for your platform/architecture to be included." +); + +export default location; \ No newline at end of file diff --git a/crates/wizer/npm/wizer/package.json b/crates/wizer/npm/wizer/package.json new file mode 100644 index 000000000000..43a318885a34 --- /dev/null +++ b/crates/wizer/npm/wizer/package.json @@ -0,0 +1,38 @@ +{ + "name": "@bytecode-alliance/wizer", + "version": "1.4.6777777", + "description": "The WebAssembly Pre-Initializer", + "type": "module", + "scripts": { + "update": "node ./update.js", + "postinstall": "node ./post-install.js" + }, + "devDependencies": { + "@felipecrs/decompress-tarxz": "^4.0.0", + "decompress": "^4.2.1", + "decompress-unzip": "^4.0.1", + "zx": "^7.0.8" + }, + "main": "index.js", + "engines": { + "node": ">=16" + }, + "bin": { + "wizer": "wizer" + }, + "optionalDependencies": { + "@bytecode-alliance/wizer-darwin-arm64": "1.4.6777777", + "@bytecode-alliance/wizer-darwin-x64": "1.4.6777777", + "@bytecode-alliance/wizer-linux-x64": "1.4.6777777", + "@bytecode-alliance/wizer-win32-x64": "1.4.6777777" + }, + "license": "Apache-2.0", + "repository": { + "type": "git", + "url": "git+https://github.com/bytecodealliance/wizer.git" + }, + "bugs": { + "url": "https://github.com/bytecodealliance/wizer/issues" + }, + "homepage": "https://github.com/bytecodealliance/wizer#readme" +} diff --git a/crates/wizer/npm/wizer/post-install.js b/crates/wizer/npm/wizer/post-install.js new file mode 100644 index 000000000000..03f3aa71cf1b --- /dev/null +++ b/crates/wizer/npm/wizer/post-install.js @@ -0,0 +1,24 @@ +import { fileURLToPath } from 'node:url'; +import { dirname, join } from 'node:path'; +import { copyFile } from "node:fs/promises"; + +const __dirname = dirname(fileURLToPath(import.meta.url)); + +const platformPackages = [ + "@bytecode-alliance/wizer-win32-x64", + "@bytecode-alliance/wizer-linux-x64", + "@bytecode-alliance/wizer-darwin-x64", + "@bytecode-alliance/wizer-darwin-arm64", +] + + +for (const pkg of platformPackages) { + try { + const location = await import(pkg); + await copyFile(location, join(__dirname, 'wizer')) + process.exit() + } catch {} +} +throw new Error( + "@bytecode-alliance/wizer does not have a precompiled binary for the platform/architecture you are using. You can open an issue on https://github.com/bytecodealliance/wizer/issues to request for your platform/architecture to be included." +); \ No newline at end of file diff --git a/crates/wizer/npm/wizer/update.js b/crates/wizer/npm/wizer/update.js new file mode 100644 index 000000000000..408360217290 --- /dev/null +++ b/crates/wizer/npm/wizer/update.js @@ -0,0 +1,97 @@ +#!/usr/bin/env node + +import { fileURLToPath } from 'node:url'; +import { dirname, join, parse } from 'node:path'; +import { fetch } from 'zx' +import { mkdir, writeFile } from "node:fs/promises"; +import decompress from 'decompress'; +import decompressUnzip from 'decompress-unzip'; +import decompressTarxz from '@felipecrs/decompress-tarxz'; + +const __dirname = dirname(fileURLToPath(import.meta.url)); +const tag = 'dev'; +let response = await fetch(`https://api.github.com/repos/bytecodealliance/wizer/releases/tags/${tag}`) +response = await response.json() +const id = response.id +let packages = { + 'wizer-darwin-arm64': { + releaseAsset: `wizer-${tag}-x86_64-macos.tar.xz`, + binaryAsset: 'wizer', + description: 'The macOS 64-bit binary for Wizer, the WebAssembly Pre-Initializer', + os: 'darwin', + cpu: 'arm64', + }, + 'wizer-darwin-x64': { + releaseAsset: `wizer-${tag}-x86_64-macos.tar.xz`, + binaryAsset: 'wizer', + description: 'The macOS 64-bit binary for Wizer, the WebAssembly Pre-Initializer', + os: 'darwin', + cpu: 'x64', + }, + 'wizer-linux-x64': { + releaseAsset: `wizer-${tag}-x86_64-linux.tar.xz`, + binaryAsset: 'wizer', + description: 'The Linux 64-bit binary for Wizer, the WebAssembly Pre-Initializer', + os: 'darwin', + cpu: 'x64', + }, + 'wizer-win32-x64': { + releaseAsset: `wizer-${tag}-x86_64-windows.zip`, + binaryAsset: 'wizer.exe', + description: 'The Windows 64-bit binary for Wizer, the WebAssembly Pre-Initializer', + os: 'win32', + cpu: 'x64', + }, +} +let assets = await fetch(`https://api.github.com/repos/bytecodealliance/wizer/releases/${id}/assets`) +assets = await assets.json() + +// console.log({id,assets}) +// 'arm', 'arm64', 'ia32', 'mips','mipsel', 'ppc', 'ppc64', 's390', 's390x', and 'x64' +// 'aix', 'android', 'darwin', 'freebsd','linux', 'openbsd', 'sunos', and 'win32'. +for (const [packageName, info] of Object.entries(packages)) { + const asset = assets.find(asset => asset.name === info.releaseAsset) + if (!asset) { + throw new Error(`Can't find an asset named ${info.releaseAsset} for the release https://github.com/bytecodealliance/wizer/releases/tag/${tag}`) + } + const packageDirectory = join(__dirname, '../', packageName.split('/').pop()) + await mkdir(packageDirectory, { recursive: true }) + await writeFile(join(packageDirectory, 'package.json'), packageJson(packageName, tag, info.description, info.os, info.cpu)) + await writeFile(join(packageDirectory, 'index.js'), indexJs(info.binaryAsset)) + const browser_download_url = asset.browser_download_url; + let archive = await fetch(browser_download_url) + await decompress(Buffer.from(await archive.arrayBuffer()), packageDirectory, { + strip:1, + plugins: [ + decompressTarxz(), + decompressUnzip() + ], + filter: file => parse(file.path).base === info.binaryAsset + }) +} + +function indexJs(binaryAsset) { + return ` +import { fileURLToPath } from 'node:url' +import { dirname, join } from 'node:path' +const __dirname = dirname(fileURLToPath(import.meta.url)) +let location = join(__dirname, '${binaryAsset}') +export default location +` +} +function packageJson(name, version, description, os, cpu) { + return JSON.stringify({ + name: `@bytecode-alliance/${name}`, + bin: { + [name]: "wizer" + }, + type: "module", + version, + description, + repository: "https://github.com/evanw/esbuild", + license: "Apache-2.0", + preferUnplugged: false, + os: [os], + cpu: [cpu], + }, null, 4); +} diff --git a/crates/wizer/npm/wizer/wizer b/crates/wizer/npm/wizer/wizer new file mode 100755 index 000000000000..9be35e010725 --- /dev/null +++ b/crates/wizer/npm/wizer/wizer @@ -0,0 +1 @@ +placeholder file for the wizer binary to be copied to \ No newline at end of file From 1f0b8bb563c2daa20ad4fa24dd02bd7a84bd404b Mon Sep 17 00:00:00 2001 From: Jake Champion Date: Fri, 26 Aug 2022 15:46:45 +0100 Subject: [PATCH 106/212] ok --- crates/wizer/npm/wizer/package.json | 10 ++--- crates/wizer/npm/wizer/post-install.js | 53 +++++++++++++++++--------- crates/wizer/npm/wizer/update.js | 2 +- 3 files changed, 42 insertions(+), 23 deletions(-) diff --git a/crates/wizer/npm/wizer/package.json b/crates/wizer/npm/wizer/package.json index 43a318885a34..cfd6e551a851 100644 --- a/crates/wizer/npm/wizer/package.json +++ b/crates/wizer/npm/wizer/package.json @@ -1,6 +1,6 @@ { "name": "@bytecode-alliance/wizer", - "version": "1.4.6777777", + "version": "1.5.56", "description": "The WebAssembly Pre-Initializer", "type": "module", "scripts": { @@ -21,10 +21,10 @@ "wizer": "wizer" }, "optionalDependencies": { - "@bytecode-alliance/wizer-darwin-arm64": "1.4.6777777", - "@bytecode-alliance/wizer-darwin-x64": "1.4.6777777", - "@bytecode-alliance/wizer-linux-x64": "1.4.6777777", - "@bytecode-alliance/wizer-win32-x64": "1.4.6777777" + "@bytecode-alliance/wizer-darwin-arm64": "1.5.56", + "@bytecode-alliance/wizer-darwin-x64": "1.5.56", + "@bytecode-alliance/wizer-linux-x64": "1.5.56", + "@bytecode-alliance/wizer-win32-x64": "1.5.56" }, "license": "Apache-2.0", "repository": { diff --git a/crates/wizer/npm/wizer/post-install.js b/crates/wizer/npm/wizer/post-install.js index 03f3aa71cf1b..22512772d473 100644 --- a/crates/wizer/npm/wizer/post-install.js +++ b/crates/wizer/npm/wizer/post-install.js @@ -1,24 +1,43 @@ +import { execFileSync } from "child_process"; import { fileURLToPath } from 'node:url'; import { dirname, join } from 'node:path'; -import { copyFile } from "node:fs/promises"; - +import { copyFile, writeFile } from "node:fs/promises"; +import { endianness } from "node:os"; +import { platform, arch } from "node:process"; const __dirname = dirname(fileURLToPath(import.meta.url)); -const platformPackages = [ - "@bytecode-alliance/wizer-win32-x64", - "@bytecode-alliance/wizer-linux-x64", - "@bytecode-alliance/wizer-darwin-x64", - "@bytecode-alliance/wizer-darwin-arm64", -] +const knownPackages = { + "win32 x64 LE": "@bytecode-alliance/wizer-win32-x64", + "darwin arm64 LE": "@bytecode-alliance/wizer-darwin-arm64", + "darwin x64 LE": "@bytecode-alliance/wizer-darwin-x64", + "linux x64 LE": "@bytecode-alliance/wizer-linux-x64", +}; + +function pkgForCurrentPlatform() { + let platformKey = `${platform} ${arch} ${endianness()}`; + + if (platformKey in knownPackages) { + return knownPackages[platformKey]; + } + throw new Error(`Unsupported platform: "${platformKey}". "@bytecode-alliance/wizer does not have a precompiled binary for the platform/architecture you are using. You can open an issue on https://github.com/bytecodealliance/wizer/issues to request for your platform/architecture to be included."`); +} +const pkg = pkgForCurrentPlatform(); -for (const pkg of platformPackages) { - try { - const location = await import(pkg); - await copyFile(location, join(__dirname, 'wizer')) - process.exit() - } catch {} +try { + // First check for the binary package from our "optionalDependencies". This + // package should have been installed alongside this package at install time. + console.log({ pkg }) + const location = await import(pkg); + console.log({ location: location.default }) + await copyFile(location.default, join(__dirname, 'wizer')) + const contents = `export default "${location.default}";` + console.log({ contents }) + await writeFile(join(__dirname, 'index.js'), contents, { encoding: 'utf-8' }) +} catch (e) { + console.error(e); + throw new Error(`The package "${pkg}" could not be found, and is needed by @bytecode-alliance/wizer. +If you are installing @bytecode-alliance/wizer with npm, make sure that you don't specify the +"--no-optional" flag. The "optionalDependencies" package.json feature is used +by @bytecode-alliance/wizer to install the correct binary executable for your current platform.`); } -throw new Error( - "@bytecode-alliance/wizer does not have a precompiled binary for the platform/architecture you are using. You can open an issue on https://github.com/bytecodealliance/wizer/issues to request for your platform/architecture to be included." -); \ No newline at end of file diff --git a/crates/wizer/npm/wizer/update.js b/crates/wizer/npm/wizer/update.js index 408360217290..eb15b635bf1b 100644 --- a/crates/wizer/npm/wizer/update.js +++ b/crates/wizer/npm/wizer/update.js @@ -87,8 +87,8 @@ function packageJson(name, version, description, os, cpu) { }, type: "module", version, + main: "index.js", description, - repository: "https://github.com/evanw/esbuild", license: "Apache-2.0", preferUnplugged: false, os: [os], From d0bc3c436defa59a550c53b7cbce2718d4ebe57e Mon Sep 17 00:00:00 2001 From: Jake Champion Date: Fri, 4 Nov 2022 15:24:24 +0000 Subject: [PATCH 107/212] remove the post-install command and rely on detection at runtime to figure out which prebuilt binary to use --- crates/wizer/npm/wizer/index.js | 42 +- crates/wizer/npm/wizer/package-lock.json | 1146 ++++++++++++++++++++++ crates/wizer/npm/wizer/package.json | 8 +- crates/wizer/npm/wizer/post-install.js | 43 - crates/wizer/npm/wizer/update.js | 35 +- crates/wizer/npm/wizer/wizer | 1 - crates/wizer/npm/wizer/wizer.js | 35 + 7 files changed, 1240 insertions(+), 70 deletions(-) create mode 100644 crates/wizer/npm/wizer/package-lock.json delete mode 100644 crates/wizer/npm/wizer/post-install.js delete mode 100755 crates/wizer/npm/wizer/wizer create mode 100755 crates/wizer/npm/wizer/wizer.js diff --git a/crates/wizer/npm/wizer/index.js b/crates/wizer/npm/wizer/index.js index 66b0b76de7fb..78ba4b701f3b 100644 --- a/crates/wizer/npm/wizer/index.js +++ b/crates/wizer/npm/wizer/index.js @@ -1,18 +1,34 @@ -const platformPackages = [ - "@bytecode-alliance/wizer-win32-x64", - "@bytecode-alliance/wizer-linux-x64", - "@bytecode-alliance/wizer-darwin-x64", - "@bytecode-alliance/wizer-darwin-arm64", -] +import { endianness } from "node:os"; +import { platform, arch } from "node:process"; + +const knownPackages = { + "win32 x64 LE": "@bytecode-alliance/wizer-win32-x64", + "darwin arm64 LE": "@bytecode-alliance/wizer-darwin-arm64", + "darwin x64 LE": "@bytecode-alliance/wizer-darwin-x64", + "linux x64 LE": "@bytecode-alliance/wizer-linux-x64", +}; + +function pkgForCurrentPlatform() { + let platformKey = `${platform} ${arch} ${endianness()}`; + + if (platformKey in knownPackages) { + return knownPackages[platformKey]; + } + throw new Error(`Unsupported platform: "${platformKey}". "@bytecode-alliance/wizer does not have a precompiled binary for the platform/architecture you are using. You can open an issue on https://github.com/bytecodealliance/wizer/issues to request for your platform/architecture to be included."`); +} + +const pkg = pkgForCurrentPlatform(); let location; -for (const pkg of platformPackages) { - try { - location = await import(pkg); - } catch {} +try { + // Check for the binary package from our "optionalDependencies". This + // package should have been installed alongside this package at install time. + location = await import(pkg); +} catch (e) { + throw new Error(`The package "${pkg}" could not be found, and is needed by @bytecode-alliance/wizer. +If you are installing @bytecode-alliance/wizer with npm, make sure that you don't specify the +"--no-optional" flag. The "optionalDependencies" package.json feature is used +by @bytecode-alliance/wizer to install the correct binary executable for your current platform.`); } -throw new Error( - "@bytecode-alliance/wizer does not have a precompiled binary for the platform/architecture you are using. You can open an issue on https://github.com/bytecodealliance/wizer/issues to request for your platform/architecture to be included." -); export default location; \ No newline at end of file diff --git a/crates/wizer/npm/wizer/package-lock.json b/crates/wizer/npm/wizer/package-lock.json new file mode 100644 index 000000000000..7a21c1b3f127 --- /dev/null +++ b/crates/wizer/npm/wizer/package-lock.json @@ -0,0 +1,1146 @@ +{ + "name": "@bytecode-alliance/wizer", + "version": "1.5.56", + "lockfileVersion": 2, + "requires": true, + "packages": { + "": { + "name": "@bytecode-alliance/wizer", + "version": "1.5.56", + "license": "Apache-2.0", + "bin": { + "wizer": "wizer.js" + }, + "devDependencies": { + "decompress": "^4.2.1", + "decompress-tar": "^4.1.1", + "decompress-unzip": "^4.0.1", + "plzmasdk": "^1.2.5" + }, + "engines": { + "node": ">=16" + }, + "optionalDependencies": { + "@bytecode-alliance/wizer-darwin-arm64": "1.5.56", + "@bytecode-alliance/wizer-darwin-x64": "1.5.56", + "@bytecode-alliance/wizer-linux-x64": "1.5.56", + "@bytecode-alliance/wizer-win32-x64": "1.5.56" + } + }, + "node_modules/@bytecode-alliance/wizer-darwin-arm64": { + "version": "1.5.56", + "resolved": "http://localhost:4873/@bytecode-alliance%2fwizer-darwin-arm64/-/wizer-darwin-arm64-1.5.56.tgz", + "integrity": "sha512-0R7m3E+/0KiCn3vxgmQgmZUfjWIjSGjtc0Ps2I2ZkNBZ5LrymrTbM/0jSyBqotDvcjVLXaqCuyxkqzqEPmie8g==", + "cpu": [ + "arm64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "darwin" + ], + "bin": { + "wizer-darwin-arm64": "wizer" + } + }, + "node_modules/@bytecode-alliance/wizer-darwin-x64": { + "version": "1.5.56", + "resolved": "http://localhost:4873/@bytecode-alliance%2fwizer-darwin-x64/-/wizer-darwin-x64-1.5.56.tgz", + "integrity": "sha512-AQxaGgolMGrjRM55AICmJgU9ffPJ3PgdlJD2NnegEyaVJbmwuTd8XVnLnEyF1rH/5TxTfGh6yhK8MTtb2Z8U7Q==", + "cpu": [ + "x64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "darwin" + ], + "bin": { + "wizer-darwin-x64": "wizer" + } + }, + "node_modules/@bytecode-alliance/wizer-linux-x64": { + "version": "1.5.56", + "resolved": "http://localhost:4873/@bytecode-alliance%2fwizer-linux-x64/-/wizer-linux-x64-1.5.56.tgz", + "integrity": "sha512-wUcX3JUY9jIEdMSNtAXwKbUf1DtNMxtnpFfWklop8pZHNDSprtxdRzf8TyuPvEIuDKfEFuUkNBU6P8x63G3Rpw==", + "cpu": [ + "x64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "darwin" + ], + "bin": { + "wizer-linux-x64": "wizer" + } + }, + "node_modules/@bytecode-alliance/wizer-win32-x64": { + "version": "1.5.56", + "resolved": "http://localhost:4873/@bytecode-alliance%2fwizer-win32-x64/-/wizer-win32-x64-1.5.56.tgz", + "integrity": "sha512-E7OaPk5JvWCqCzCFG0QbBMuFUFdiMyK3hzbRZNlDOrliRKtsBc/vB7x82jH0RIvMpMdsWgq8nhaA1UnJGhH3jQ==", + "cpu": [ + "x64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "win32" + ], + "bin": { + "wizer-win32-x64": "wizer" + } + }, + "node_modules/base64-js": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", + "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/bl": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/bl/-/bl-1.2.3.tgz", + "integrity": "sha512-pvcNpa0UU69UT341rO6AYy4FVAIkUHuZXRIWbq+zHnsVcRzDDjIAhGuuYoi0d//cwIwtt4pkpKycWEfjdV+vww==", + "dev": true, + "dependencies": { + "readable-stream": "^2.3.5", + "safe-buffer": "^5.1.1" + } + }, + "node_modules/bl/node_modules/readable-stream": { + "version": "2.3.7", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", + "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", + "dev": true, + "dependencies": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "node_modules/bl/node_modules/safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "dev": true + }, + "node_modules/bl/node_modules/string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "dev": true, + "dependencies": { + "safe-buffer": "~5.1.0" + } + }, + "node_modules/buffer": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz", + "integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "dependencies": { + "base64-js": "^1.3.1", + "ieee754": "^1.1.13" + } + }, + "node_modules/buffer-alloc": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/buffer-alloc/-/buffer-alloc-1.2.0.tgz", + "integrity": "sha512-CFsHQgjtW1UChdXgbyJGtnm+O/uLQeZdtbDo8mfUgYXCHSM1wgrVxXm6bSyrUuErEb+4sYVGCzASBRot7zyrow==", + "dev": true, + "dependencies": { + "buffer-alloc-unsafe": "^1.1.0", + "buffer-fill": "^1.0.0" + } + }, + "node_modules/buffer-alloc-unsafe": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/buffer-alloc-unsafe/-/buffer-alloc-unsafe-1.1.0.tgz", + "integrity": "sha512-TEM2iMIEQdJ2yjPJoSIsldnleVaAk1oW3DBVUykyOLsEsFmEc9kn+SFFPz+gl54KQNxlDnAwCXosOS9Okx2xAg==", + "dev": true + }, + "node_modules/buffer-crc32": { + "version": "0.2.13", + "resolved": "https://registry.npmjs.org/buffer-crc32/-/buffer-crc32-0.2.13.tgz", + "integrity": "sha512-VO9Ht/+p3SN7SKWqcrgEzjGbRSJYTx+Q1pTQC0wrWqHx0vpJraQ6GtHx8tvcg1rlK1byhU5gccxgOgj7B0TDkQ==", + "dev": true, + "engines": { + "node": "*" + } + }, + "node_modules/buffer-fill": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/buffer-fill/-/buffer-fill-1.0.0.tgz", + "integrity": "sha512-T7zexNBwiiaCOGDg9xNX9PBmjrubblRkENuptryuI64URkXDFum9il/JGL8Lm8wYfAXpredVXXZz7eMHilimiQ==", + "dev": true + }, + "node_modules/commander": { + "version": "2.20.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", + "dev": true + }, + "node_modules/core-util-is": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", + "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==", + "dev": true + }, + "node_modules/decompress": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/decompress/-/decompress-4.2.1.tgz", + "integrity": "sha512-e48kc2IjU+2Zw8cTb6VZcJQ3lgVbS4uuB1TfCHbiZIP/haNXm+SVyhu+87jts5/3ROpd82GSVCoNs/z8l4ZOaQ==", + "dev": true, + "dependencies": { + "decompress-tar": "^4.0.0", + "decompress-tarbz2": "^4.0.0", + "decompress-targz": "^4.0.0", + "decompress-unzip": "^4.0.1", + "graceful-fs": "^4.1.10", + "make-dir": "^1.0.0", + "pify": "^2.3.0", + "strip-dirs": "^2.0.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/decompress-tar": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/decompress-tar/-/decompress-tar-4.1.1.tgz", + "integrity": "sha512-JdJMaCrGpB5fESVyxwpCx4Jdj2AagLmv3y58Qy4GE6HMVjWz1FeVQk1Ct4Kye7PftcdOo/7U7UKzYBJgqnGeUQ==", + "dev": true, + "dependencies": { + "file-type": "^5.2.0", + "is-stream": "^1.1.0", + "tar-stream": "^1.5.2" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/decompress-tar/node_modules/file-type": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/file-type/-/file-type-5.2.0.tgz", + "integrity": "sha512-Iq1nJ6D2+yIO4c8HHg4fyVb8mAJieo1Oloy1mLLaB2PvezNedhBVm+QU7g0qM42aiMbRXTxKKwGD17rjKNJYVQ==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/decompress-tar/node_modules/is-stream": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", + "integrity": "sha512-uQPm8kcs47jx38atAcWTVxyltQYoPT68y9aWYdV6yWXSyW8mzSat0TL6CiWdZeCdF3KrAvpVtnHbTv4RN+rqdQ==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/decompress-tarbz2": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/decompress-tarbz2/-/decompress-tarbz2-4.1.1.tgz", + "integrity": "sha512-s88xLzf1r81ICXLAVQVzaN6ZmX4A6U4z2nMbOwobxkLoIIfjVMBg7TeguTUXkKeXni795B6y5rnvDw7rxhAq9A==", + "dev": true, + "dependencies": { + "decompress-tar": "^4.1.0", + "file-type": "^6.1.0", + "is-stream": "^1.1.0", + "seek-bzip": "^1.0.5", + "unbzip2-stream": "^1.0.9" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/decompress-tarbz2/node_modules/file-type": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/file-type/-/file-type-6.2.0.tgz", + "integrity": "sha512-YPcTBDV+2Tm0VqjybVd32MHdlEGAtuxS3VAYsumFokDSMG+ROT5wawGlnHDoz7bfMcMDt9hxuXvXwoKUx2fkOg==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/decompress-tarbz2/node_modules/is-stream": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", + "integrity": "sha512-uQPm8kcs47jx38atAcWTVxyltQYoPT68y9aWYdV6yWXSyW8mzSat0TL6CiWdZeCdF3KrAvpVtnHbTv4RN+rqdQ==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/decompress-targz": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/decompress-targz/-/decompress-targz-4.1.1.tgz", + "integrity": "sha512-4z81Znfr6chWnRDNfFNqLwPvm4db3WuZkqV+UgXQzSngG3CEKdBkw5jrv3axjjL96glyiiKjsxJG3X6WBZwX3w==", + "dev": true, + "dependencies": { + "decompress-tar": "^4.1.1", + "file-type": "^5.2.0", + "is-stream": "^1.1.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/decompress-targz/node_modules/file-type": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/file-type/-/file-type-5.2.0.tgz", + "integrity": "sha512-Iq1nJ6D2+yIO4c8HHg4fyVb8mAJieo1Oloy1mLLaB2PvezNedhBVm+QU7g0qM42aiMbRXTxKKwGD17rjKNJYVQ==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/decompress-targz/node_modules/is-stream": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", + "integrity": "sha512-uQPm8kcs47jx38atAcWTVxyltQYoPT68y9aWYdV6yWXSyW8mzSat0TL6CiWdZeCdF3KrAvpVtnHbTv4RN+rqdQ==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/decompress-unzip": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/decompress-unzip/-/decompress-unzip-4.0.1.tgz", + "integrity": "sha512-1fqeluvxgnn86MOh66u8FjbtJpAFv5wgCT9Iw8rcBqQcCo5tO8eiJw7NNTrvt9n4CRBVq7CstiS922oPgyGLrw==", + "dev": true, + "dependencies": { + "file-type": "^3.8.0", + "get-stream": "^2.2.0", + "pify": "^2.3.0", + "yauzl": "^2.4.2" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/decompress-unzip/node_modules/file-type": { + "version": "3.9.0", + "resolved": "https://registry.npmjs.org/file-type/-/file-type-3.9.0.tgz", + "integrity": "sha512-RLoqTXE8/vPmMuTI88DAzhMYC99I8BWv7zYP4A1puo5HIjEJ5EX48ighy4ZyKMG9EDXxBgW6e++cn7d1xuFghA==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/end-of-stream": { + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz", + "integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==", + "dev": true, + "dependencies": { + "once": "^1.4.0" + } + }, + "node_modules/fd-slicer": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/fd-slicer/-/fd-slicer-1.1.0.tgz", + "integrity": "sha512-cE1qsB/VwyQozZ+q1dGxR8LBYNZeofhEdUNGSMbQD3Gw2lAzX9Zb3uIU6Ebc/Fmyjo9AWWfnn0AUCHqtevs/8g==", + "dev": true, + "dependencies": { + "pend": "~1.2.0" + } + }, + "node_modules/fs-constants": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz", + "integrity": "sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==", + "dev": true + }, + "node_modules/get-stream": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-2.3.1.tgz", + "integrity": "sha512-AUGhbbemXxrZJRD5cDvKtQxLuYaIbNtDTK8YqupCI393Q2KSTreEsLUN3ZxAWFGiKTzL6nKuzfcIvieflUX9qA==", + "dev": true, + "dependencies": { + "object-assign": "^4.0.1", + "pinkie-promise": "^2.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/graceful-fs": { + "version": "4.2.10", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.10.tgz", + "integrity": "sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==", + "dev": true + }, + "node_modules/ieee754": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", + "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true + }, + "node_modules/is-natural-number": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/is-natural-number/-/is-natural-number-4.0.1.tgz", + "integrity": "sha512-Y4LTamMe0DDQIIAlaer9eKebAlDSV6huy+TWhJVPlzZh2o4tRP5SQWFlLn5N0To4mDD22/qdOq+veo1cSISLgQ==", + "dev": true + }, + "node_modules/isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==", + "dev": true + }, + "node_modules/make-dir": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-1.3.0.tgz", + "integrity": "sha512-2w31R7SJtieJJnQtGc7RVL2StM2vGYVfqUOvUDxH6bC6aJTxPxTF0GnIgCyu7tjockiUWAYQRbxa7vKn34s5sQ==", + "dev": true, + "dependencies": { + "pify": "^3.0.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/make-dir/node_modules/pify": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", + "integrity": "sha512-C3FsVNH1udSEX48gGX1xfvwTWfsYWj5U+8/uK15BGzIGrKoUpghX8hWZwa/OFnakBiiVNmBvemTJR5mcy7iPcg==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "dev": true, + "dependencies": { + "wrappy": "1" + } + }, + "node_modules/pend": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz", + "integrity": "sha512-F3asv42UuXchdzt+xXqfW1OGlVBe+mxa2mqI0pg5yAHZPvFmY3Y6drSf/GQ1A86WgWEN9Kzh/WrgKa6iGcHXLg==", + "dev": true + }, + "node_modules/pify": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "integrity": "sha512-udgsAY+fTnvv7kI7aaxbqwWNb0AHiB0qBO89PZKPkoTmGOgdbrHDKD+0B2X4uTfJ/FT1R09r9gTsjUjNJotuog==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/pinkie": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/pinkie/-/pinkie-2.0.4.tgz", + "integrity": "sha512-MnUuEycAemtSaeFSjXKW/aroV7akBbY+Sv+RkyqFjgAe73F+MR0TBWKBRDkmfWq/HiFmdavfZ1G7h4SPZXaCSg==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/pinkie-promise": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz", + "integrity": "sha512-0Gni6D4UcLTbv9c57DfxDGdr41XfgUjqWZu492f0cIGr16zDU06BWP/RAEvOuo7CQ0CNjHaLlM59YJJFm3NWlw==", + "dev": true, + "dependencies": { + "pinkie": "^2.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/plzmasdk": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/plzmasdk/-/plzmasdk-1.2.5.tgz", + "integrity": "sha512-Z0SzRoroOI6yIKhBz3Qvoo6ExYLxOA/+2bj67u8RkNTEuMS1ZDgH0Uj7aZoN2+8+tJlVwhHBvtTBi0mxfhq5Cw==", + "dev": true, + "hasInstallScript": true, + "engines": { + "node": ">=13.0.0", + "npm": ">=6.0.0" + } + }, + "node_modules/process-nextick-args": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", + "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==", + "dev": true + }, + "node_modules/seek-bzip": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/seek-bzip/-/seek-bzip-1.0.6.tgz", + "integrity": "sha512-e1QtP3YL5tWww8uKaOCQ18UxIT2laNBXHjV/S2WYCiK4udiv8lkG89KRIoCjUagnAmCBurjF4zEVX2ByBbnCjQ==", + "dev": true, + "dependencies": { + "commander": "^2.8.1" + }, + "bin": { + "seek-bunzip": "bin/seek-bunzip", + "seek-table": "bin/seek-bzip-table" + } + }, + "node_modules/strip-dirs": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/strip-dirs/-/strip-dirs-2.1.0.tgz", + "integrity": "sha512-JOCxOeKLm2CAS73y/U4ZeZPTkE+gNVCzKt7Eox84Iej1LT/2pTWYpZKJuxwQpvX1LiZb1xokNR7RLfuBAa7T3g==", + "dev": true, + "dependencies": { + "is-natural-number": "^4.0.1" + } + }, + "node_modules/tar-stream": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-1.6.2.tgz", + "integrity": "sha512-rzS0heiNf8Xn7/mpdSVVSMAWAoy9bfb1WOTYC78Z0UQKeKa/CWS8FOq0lKGNa8DWKAn9gxjCvMLYc5PGXYlK2A==", + "dev": true, + "dependencies": { + "bl": "^1.0.0", + "buffer-alloc": "^1.2.0", + "end-of-stream": "^1.0.0", + "fs-constants": "^1.0.0", + "readable-stream": "^2.3.0", + "to-buffer": "^1.1.1", + "xtend": "^4.0.0" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/tar-stream/node_modules/readable-stream": { + "version": "2.3.7", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", + "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", + "dev": true, + "dependencies": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "node_modules/tar-stream/node_modules/safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "dev": true + }, + "node_modules/tar-stream/node_modules/string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "dev": true, + "dependencies": { + "safe-buffer": "~5.1.0" + } + }, + "node_modules/through": { + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", + "integrity": "sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg==", + "dev": true + }, + "node_modules/to-buffer": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/to-buffer/-/to-buffer-1.1.1.tgz", + "integrity": "sha512-lx9B5iv7msuFYE3dytT+KE5tap+rNYw+K4jVkb9R/asAb+pbBSM17jtunHplhBe6RRJdZx3Pn2Jph24O32mOVg==", + "dev": true + }, + "node_modules/unbzip2-stream": { + "version": "1.4.3", + "resolved": "https://registry.npmjs.org/unbzip2-stream/-/unbzip2-stream-1.4.3.tgz", + "integrity": "sha512-mlExGW4w71ebDJviH16lQLtZS32VKqsSfk80GCfUlwT/4/hNRFsoscrF/c++9xinkMzECL1uL9DDwXqFWkruPg==", + "dev": true, + "dependencies": { + "buffer": "^5.2.1", + "through": "^2.3.8" + } + }, + "node_modules/util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", + "dev": true + }, + "node_modules/wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", + "dev": true + }, + "node_modules/xtend": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", + "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==", + "dev": true, + "engines": { + "node": ">=0.4" + } + }, + "node_modules/yauzl": { + "version": "2.10.0", + "resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.10.0.tgz", + "integrity": "sha512-p4a9I6X6nu6IhoGmBqAcbJy1mlC4j27vEPZX9F4L4/vZT3Lyq1VkFHw/V/PUcB9Buo+DG3iHkT0x3Qya58zc3g==", + "dev": true, + "dependencies": { + "buffer-crc32": "~0.2.3", + "fd-slicer": "~1.1.0" + } + } + }, + "dependencies": { + "@bytecode-alliance/wizer-darwin-arm64": { + "version": "1.5.56", + "resolved": "http://localhost:4873/@bytecode-alliance%2fwizer-darwin-arm64/-/wizer-darwin-arm64-1.5.56.tgz", + "integrity": "sha512-0R7m3E+/0KiCn3vxgmQgmZUfjWIjSGjtc0Ps2I2ZkNBZ5LrymrTbM/0jSyBqotDvcjVLXaqCuyxkqzqEPmie8g==", + "optional": true + }, + "@bytecode-alliance/wizer-darwin-x64": { + "version": "1.5.56", + "resolved": "http://localhost:4873/@bytecode-alliance%2fwizer-darwin-x64/-/wizer-darwin-x64-1.5.56.tgz", + "integrity": "sha512-AQxaGgolMGrjRM55AICmJgU9ffPJ3PgdlJD2NnegEyaVJbmwuTd8XVnLnEyF1rH/5TxTfGh6yhK8MTtb2Z8U7Q==", + "optional": true + }, + "@bytecode-alliance/wizer-linux-x64": { + "version": "1.5.56", + "resolved": "http://localhost:4873/@bytecode-alliance%2fwizer-linux-x64/-/wizer-linux-x64-1.5.56.tgz", + "integrity": "sha512-wUcX3JUY9jIEdMSNtAXwKbUf1DtNMxtnpFfWklop8pZHNDSprtxdRzf8TyuPvEIuDKfEFuUkNBU6P8x63G3Rpw==", + "optional": true + }, + "@bytecode-alliance/wizer-win32-x64": { + "version": "1.5.56", + "resolved": "http://localhost:4873/@bytecode-alliance%2fwizer-win32-x64/-/wizer-win32-x64-1.5.56.tgz", + "integrity": "sha512-E7OaPk5JvWCqCzCFG0QbBMuFUFdiMyK3hzbRZNlDOrliRKtsBc/vB7x82jH0RIvMpMdsWgq8nhaA1UnJGhH3jQ==", + "optional": true + }, + "base64-js": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", + "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", + "dev": true + }, + "bl": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/bl/-/bl-1.2.3.tgz", + "integrity": "sha512-pvcNpa0UU69UT341rO6AYy4FVAIkUHuZXRIWbq+zHnsVcRzDDjIAhGuuYoi0d//cwIwtt4pkpKycWEfjdV+vww==", + "dev": true, + "requires": { + "readable-stream": "^2.3.5", + "safe-buffer": "^5.1.1" + }, + "dependencies": { + "readable-stream": { + "version": "2.3.7", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", + "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", + "dev": true, + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "dev": true + }, + "string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "dev": true, + "requires": { + "safe-buffer": "~5.1.0" + } + } + } + }, + "buffer": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz", + "integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==", + "dev": true, + "requires": { + "base64-js": "^1.3.1", + "ieee754": "^1.1.13" + } + }, + "buffer-alloc": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/buffer-alloc/-/buffer-alloc-1.2.0.tgz", + "integrity": "sha512-CFsHQgjtW1UChdXgbyJGtnm+O/uLQeZdtbDo8mfUgYXCHSM1wgrVxXm6bSyrUuErEb+4sYVGCzASBRot7zyrow==", + "dev": true, + "requires": { + "buffer-alloc-unsafe": "^1.1.0", + "buffer-fill": "^1.0.0" + } + }, + "buffer-alloc-unsafe": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/buffer-alloc-unsafe/-/buffer-alloc-unsafe-1.1.0.tgz", + "integrity": "sha512-TEM2iMIEQdJ2yjPJoSIsldnleVaAk1oW3DBVUykyOLsEsFmEc9kn+SFFPz+gl54KQNxlDnAwCXosOS9Okx2xAg==", + "dev": true + }, + "buffer-crc32": { + "version": "0.2.13", + "resolved": "https://registry.npmjs.org/buffer-crc32/-/buffer-crc32-0.2.13.tgz", + "integrity": "sha512-VO9Ht/+p3SN7SKWqcrgEzjGbRSJYTx+Q1pTQC0wrWqHx0vpJraQ6GtHx8tvcg1rlK1byhU5gccxgOgj7B0TDkQ==", + "dev": true + }, + "buffer-fill": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/buffer-fill/-/buffer-fill-1.0.0.tgz", + "integrity": "sha512-T7zexNBwiiaCOGDg9xNX9PBmjrubblRkENuptryuI64URkXDFum9il/JGL8Lm8wYfAXpredVXXZz7eMHilimiQ==", + "dev": true + }, + "commander": { + "version": "2.20.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", + "dev": true + }, + "core-util-is": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", + "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==", + "dev": true + }, + "decompress": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/decompress/-/decompress-4.2.1.tgz", + "integrity": "sha512-e48kc2IjU+2Zw8cTb6VZcJQ3lgVbS4uuB1TfCHbiZIP/haNXm+SVyhu+87jts5/3ROpd82GSVCoNs/z8l4ZOaQ==", + "dev": true, + "requires": { + "decompress-tar": "^4.0.0", + "decompress-tarbz2": "^4.0.0", + "decompress-targz": "^4.0.0", + "decompress-unzip": "^4.0.1", + "graceful-fs": "^4.1.10", + "make-dir": "^1.0.0", + "pify": "^2.3.0", + "strip-dirs": "^2.0.0" + } + }, + "decompress-tar": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/decompress-tar/-/decompress-tar-4.1.1.tgz", + "integrity": "sha512-JdJMaCrGpB5fESVyxwpCx4Jdj2AagLmv3y58Qy4GE6HMVjWz1FeVQk1Ct4Kye7PftcdOo/7U7UKzYBJgqnGeUQ==", + "dev": true, + "requires": { + "file-type": "^5.2.0", + "is-stream": "^1.1.0", + "tar-stream": "^1.5.2" + }, + "dependencies": { + "file-type": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/file-type/-/file-type-5.2.0.tgz", + "integrity": "sha512-Iq1nJ6D2+yIO4c8HHg4fyVb8mAJieo1Oloy1mLLaB2PvezNedhBVm+QU7g0qM42aiMbRXTxKKwGD17rjKNJYVQ==", + "dev": true + }, + "is-stream": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", + "integrity": "sha512-uQPm8kcs47jx38atAcWTVxyltQYoPT68y9aWYdV6yWXSyW8mzSat0TL6CiWdZeCdF3KrAvpVtnHbTv4RN+rqdQ==", + "dev": true + } + } + }, + "decompress-tarbz2": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/decompress-tarbz2/-/decompress-tarbz2-4.1.1.tgz", + "integrity": "sha512-s88xLzf1r81ICXLAVQVzaN6ZmX4A6U4z2nMbOwobxkLoIIfjVMBg7TeguTUXkKeXni795B6y5rnvDw7rxhAq9A==", + "dev": true, + "requires": { + "decompress-tar": "^4.1.0", + "file-type": "^6.1.0", + "is-stream": "^1.1.0", + "seek-bzip": "^1.0.5", + "unbzip2-stream": "^1.0.9" + }, + "dependencies": { + "file-type": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/file-type/-/file-type-6.2.0.tgz", + "integrity": "sha512-YPcTBDV+2Tm0VqjybVd32MHdlEGAtuxS3VAYsumFokDSMG+ROT5wawGlnHDoz7bfMcMDt9hxuXvXwoKUx2fkOg==", + "dev": true + }, + "is-stream": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", + "integrity": "sha512-uQPm8kcs47jx38atAcWTVxyltQYoPT68y9aWYdV6yWXSyW8mzSat0TL6CiWdZeCdF3KrAvpVtnHbTv4RN+rqdQ==", + "dev": true + } + } + }, + "decompress-targz": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/decompress-targz/-/decompress-targz-4.1.1.tgz", + "integrity": "sha512-4z81Znfr6chWnRDNfFNqLwPvm4db3WuZkqV+UgXQzSngG3CEKdBkw5jrv3axjjL96glyiiKjsxJG3X6WBZwX3w==", + "dev": true, + "requires": { + "decompress-tar": "^4.1.1", + "file-type": "^5.2.0", + "is-stream": "^1.1.0" + }, + "dependencies": { + "file-type": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/file-type/-/file-type-5.2.0.tgz", + "integrity": "sha512-Iq1nJ6D2+yIO4c8HHg4fyVb8mAJieo1Oloy1mLLaB2PvezNedhBVm+QU7g0qM42aiMbRXTxKKwGD17rjKNJYVQ==", + "dev": true + }, + "is-stream": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", + "integrity": "sha512-uQPm8kcs47jx38atAcWTVxyltQYoPT68y9aWYdV6yWXSyW8mzSat0TL6CiWdZeCdF3KrAvpVtnHbTv4RN+rqdQ==", + "dev": true + } + } + }, + "decompress-unzip": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/decompress-unzip/-/decompress-unzip-4.0.1.tgz", + "integrity": "sha512-1fqeluvxgnn86MOh66u8FjbtJpAFv5wgCT9Iw8rcBqQcCo5tO8eiJw7NNTrvt9n4CRBVq7CstiS922oPgyGLrw==", + "dev": true, + "requires": { + "file-type": "^3.8.0", + "get-stream": "^2.2.0", + "pify": "^2.3.0", + "yauzl": "^2.4.2" + }, + "dependencies": { + "file-type": { + "version": "3.9.0", + "resolved": "https://registry.npmjs.org/file-type/-/file-type-3.9.0.tgz", + "integrity": "sha512-RLoqTXE8/vPmMuTI88DAzhMYC99I8BWv7zYP4A1puo5HIjEJ5EX48ighy4ZyKMG9EDXxBgW6e++cn7d1xuFghA==", + "dev": true + } + } + }, + "end-of-stream": { + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz", + "integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==", + "dev": true, + "requires": { + "once": "^1.4.0" + } + }, + "fd-slicer": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/fd-slicer/-/fd-slicer-1.1.0.tgz", + "integrity": "sha512-cE1qsB/VwyQozZ+q1dGxR8LBYNZeofhEdUNGSMbQD3Gw2lAzX9Zb3uIU6Ebc/Fmyjo9AWWfnn0AUCHqtevs/8g==", + "dev": true, + "requires": { + "pend": "~1.2.0" + } + }, + "fs-constants": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz", + "integrity": "sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==", + "dev": true + }, + "get-stream": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-2.3.1.tgz", + "integrity": "sha512-AUGhbbemXxrZJRD5cDvKtQxLuYaIbNtDTK8YqupCI393Q2KSTreEsLUN3ZxAWFGiKTzL6nKuzfcIvieflUX9qA==", + "dev": true, + "requires": { + "object-assign": "^4.0.1", + "pinkie-promise": "^2.0.0" + } + }, + "graceful-fs": { + "version": "4.2.10", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.10.tgz", + "integrity": "sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==", + "dev": true + }, + "ieee754": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", + "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", + "dev": true + }, + "inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true + }, + "is-natural-number": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/is-natural-number/-/is-natural-number-4.0.1.tgz", + "integrity": "sha512-Y4LTamMe0DDQIIAlaer9eKebAlDSV6huy+TWhJVPlzZh2o4tRP5SQWFlLn5N0To4mDD22/qdOq+veo1cSISLgQ==", + "dev": true + }, + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==", + "dev": true + }, + "make-dir": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-1.3.0.tgz", + "integrity": "sha512-2w31R7SJtieJJnQtGc7RVL2StM2vGYVfqUOvUDxH6bC6aJTxPxTF0GnIgCyu7tjockiUWAYQRbxa7vKn34s5sQ==", + "dev": true, + "requires": { + "pify": "^3.0.0" + }, + "dependencies": { + "pify": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", + "integrity": "sha512-C3FsVNH1udSEX48gGX1xfvwTWfsYWj5U+8/uK15BGzIGrKoUpghX8hWZwa/OFnakBiiVNmBvemTJR5mcy7iPcg==", + "dev": true + } + } + }, + "object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", + "dev": true + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "dev": true, + "requires": { + "wrappy": "1" + } + }, + "pend": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz", + "integrity": "sha512-F3asv42UuXchdzt+xXqfW1OGlVBe+mxa2mqI0pg5yAHZPvFmY3Y6drSf/GQ1A86WgWEN9Kzh/WrgKa6iGcHXLg==", + "dev": true + }, + "pify": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "integrity": "sha512-udgsAY+fTnvv7kI7aaxbqwWNb0AHiB0qBO89PZKPkoTmGOgdbrHDKD+0B2X4uTfJ/FT1R09r9gTsjUjNJotuog==", + "dev": true + }, + "pinkie": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/pinkie/-/pinkie-2.0.4.tgz", + "integrity": "sha512-MnUuEycAemtSaeFSjXKW/aroV7akBbY+Sv+RkyqFjgAe73F+MR0TBWKBRDkmfWq/HiFmdavfZ1G7h4SPZXaCSg==", + "dev": true + }, + "pinkie-promise": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz", + "integrity": "sha512-0Gni6D4UcLTbv9c57DfxDGdr41XfgUjqWZu492f0cIGr16zDU06BWP/RAEvOuo7CQ0CNjHaLlM59YJJFm3NWlw==", + "dev": true, + "requires": { + "pinkie": "^2.0.0" + } + }, + "plzmasdk": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/plzmasdk/-/plzmasdk-1.2.5.tgz", + "integrity": "sha512-Z0SzRoroOI6yIKhBz3Qvoo6ExYLxOA/+2bj67u8RkNTEuMS1ZDgH0Uj7aZoN2+8+tJlVwhHBvtTBi0mxfhq5Cw==", + "dev": true + }, + "process-nextick-args": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", + "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==", + "dev": true + }, + "seek-bzip": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/seek-bzip/-/seek-bzip-1.0.6.tgz", + "integrity": "sha512-e1QtP3YL5tWww8uKaOCQ18UxIT2laNBXHjV/S2WYCiK4udiv8lkG89KRIoCjUagnAmCBurjF4zEVX2ByBbnCjQ==", + "dev": true, + "requires": { + "commander": "^2.8.1" + } + }, + "strip-dirs": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/strip-dirs/-/strip-dirs-2.1.0.tgz", + "integrity": "sha512-JOCxOeKLm2CAS73y/U4ZeZPTkE+gNVCzKt7Eox84Iej1LT/2pTWYpZKJuxwQpvX1LiZb1xokNR7RLfuBAa7T3g==", + "dev": true, + "requires": { + "is-natural-number": "^4.0.1" + } + }, + "tar-stream": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-1.6.2.tgz", + "integrity": "sha512-rzS0heiNf8Xn7/mpdSVVSMAWAoy9bfb1WOTYC78Z0UQKeKa/CWS8FOq0lKGNa8DWKAn9gxjCvMLYc5PGXYlK2A==", + "dev": true, + "requires": { + "bl": "^1.0.0", + "buffer-alloc": "^1.2.0", + "end-of-stream": "^1.0.0", + "fs-constants": "^1.0.0", + "readable-stream": "^2.3.0", + "to-buffer": "^1.1.1", + "xtend": "^4.0.0" + }, + "dependencies": { + "readable-stream": { + "version": "2.3.7", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", + "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", + "dev": true, + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "dev": true + }, + "string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "dev": true, + "requires": { + "safe-buffer": "~5.1.0" + } + } + } + }, + "through": { + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", + "integrity": "sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg==", + "dev": true + }, + "to-buffer": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/to-buffer/-/to-buffer-1.1.1.tgz", + "integrity": "sha512-lx9B5iv7msuFYE3dytT+KE5tap+rNYw+K4jVkb9R/asAb+pbBSM17jtunHplhBe6RRJdZx3Pn2Jph24O32mOVg==", + "dev": true + }, + "unbzip2-stream": { + "version": "1.4.3", + "resolved": "https://registry.npmjs.org/unbzip2-stream/-/unbzip2-stream-1.4.3.tgz", + "integrity": "sha512-mlExGW4w71ebDJviH16lQLtZS32VKqsSfk80GCfUlwT/4/hNRFsoscrF/c++9xinkMzECL1uL9DDwXqFWkruPg==", + "dev": true, + "requires": { + "buffer": "^5.2.1", + "through": "^2.3.8" + } + }, + "util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", + "dev": true + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", + "dev": true + }, + "xtend": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", + "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==", + "dev": true + }, + "yauzl": { + "version": "2.10.0", + "resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.10.0.tgz", + "integrity": "sha512-p4a9I6X6nu6IhoGmBqAcbJy1mlC4j27vEPZX9F4L4/vZT3Lyq1VkFHw/V/PUcB9Buo+DG3iHkT0x3Qya58zc3g==", + "dev": true, + "requires": { + "buffer-crc32": "~0.2.3", + "fd-slicer": "~1.1.0" + } + } + } +} diff --git a/crates/wizer/npm/wizer/package.json b/crates/wizer/npm/wizer/package.json index cfd6e551a851..2227a43fc477 100644 --- a/crates/wizer/npm/wizer/package.json +++ b/crates/wizer/npm/wizer/package.json @@ -5,20 +5,20 @@ "type": "module", "scripts": { "update": "node ./update.js", - "postinstall": "node ./post-install.js" + "version": "node ./update.js $npm_package_version" }, "devDependencies": { - "@felipecrs/decompress-tarxz": "^4.0.0", "decompress": "^4.2.1", "decompress-unzip": "^4.0.1", - "zx": "^7.0.8" + "decompress-tar": "^4.1.1", + "plzmasdk": "^1.2.5" }, "main": "index.js", "engines": { "node": ">=16" }, "bin": { - "wizer": "wizer" + "wizer": "./wizer.js" }, "optionalDependencies": { "@bytecode-alliance/wizer-darwin-arm64": "1.5.56", diff --git a/crates/wizer/npm/wizer/post-install.js b/crates/wizer/npm/wizer/post-install.js deleted file mode 100644 index 22512772d473..000000000000 --- a/crates/wizer/npm/wizer/post-install.js +++ /dev/null @@ -1,43 +0,0 @@ -import { execFileSync } from "child_process"; -import { fileURLToPath } from 'node:url'; -import { dirname, join } from 'node:path'; -import { copyFile, writeFile } from "node:fs/promises"; -import { endianness } from "node:os"; -import { platform, arch } from "node:process"; -const __dirname = dirname(fileURLToPath(import.meta.url)); - -const knownPackages = { - "win32 x64 LE": "@bytecode-alliance/wizer-win32-x64", - "darwin arm64 LE": "@bytecode-alliance/wizer-darwin-arm64", - "darwin x64 LE": "@bytecode-alliance/wizer-darwin-x64", - "linux x64 LE": "@bytecode-alliance/wizer-linux-x64", -}; - -function pkgForCurrentPlatform() { - let platformKey = `${platform} ${arch} ${endianness()}`; - - if (platformKey in knownPackages) { - return knownPackages[platformKey]; - } - throw new Error(`Unsupported platform: "${platformKey}". "@bytecode-alliance/wizer does not have a precompiled binary for the platform/architecture you are using. You can open an issue on https://github.com/bytecodealliance/wizer/issues to request for your platform/architecture to be included."`); -} - -const pkg = pkgForCurrentPlatform(); - -try { - // First check for the binary package from our "optionalDependencies". This - // package should have been installed alongside this package at install time. - console.log({ pkg }) - const location = await import(pkg); - console.log({ location: location.default }) - await copyFile(location.default, join(__dirname, 'wizer')) - const contents = `export default "${location.default}";` - console.log({ contents }) - await writeFile(join(__dirname, 'index.js'), contents, { encoding: 'utf-8' }) -} catch (e) { - console.error(e); - throw new Error(`The package "${pkg}" could not be found, and is needed by @bytecode-alliance/wizer. -If you are installing @bytecode-alliance/wizer with npm, make sure that you don't specify the -"--no-optional" flag. The "optionalDependencies" package.json feature is used -by @bytecode-alliance/wizer to install the correct binary executable for your current platform.`); -} diff --git a/crates/wizer/npm/wizer/update.js b/crates/wizer/npm/wizer/update.js index eb15b635bf1b..566e33933f13 100644 --- a/crates/wizer/npm/wizer/update.js +++ b/crates/wizer/npm/wizer/update.js @@ -2,11 +2,11 @@ import { fileURLToPath } from 'node:url'; import { dirname, join, parse } from 'node:path'; -import { fetch } from 'zx' import { mkdir, writeFile } from "node:fs/promises"; import decompress from 'decompress'; import decompressUnzip from 'decompress-unzip'; -import decompressTarxz from '@felipecrs/decompress-tarxz'; +import decompressTar from 'decompress-tar'; +import plzma from 'plzmasdk'; const __dirname = dirname(fileURLToPath(import.meta.url)); const tag = 'dev'; @@ -15,7 +15,7 @@ response = await response.json() const id = response.id let packages = { 'wizer-darwin-arm64': { - releaseAsset: `wizer-${tag}-x86_64-macos.tar.xz`, + releaseAsset: `wizer-${tag}-aarch64-macos.tar.xz`, binaryAsset: 'wizer', description: 'The macOS 64-bit binary for Wizer, the WebAssembly Pre-Initializer', os: 'darwin', @@ -46,9 +46,6 @@ let packages = { let assets = await fetch(`https://api.github.com/repos/bytecodealliance/wizer/releases/${id}/assets`) assets = await assets.json() -// console.log({id,assets}) -// 'arm', 'arm64', 'ia32', 'mips','mipsel', 'ppc', 'ppc64', 's390', 's390x', and 'x64' -// 'aix', 'android', 'darwin', 'freebsd','linux', 'openbsd', 'sunos', and 'win32'. for (const [packageName, info] of Object.entries(packages)) { const asset = assets.find(asset => asset.name === info.releaseAsset) if (!asset) { @@ -60,12 +57,32 @@ for (const [packageName, info] of Object.entries(packages)) { await writeFile(join(packageDirectory, 'index.js'), indexJs(info.binaryAsset)) const browser_download_url = asset.browser_download_url; let archive = await fetch(browser_download_url) - await decompress(Buffer.from(await archive.arrayBuffer()), packageDirectory, { + let buf = await archive.arrayBuffer() + + // Need to decompress into the original tarball format for later use in the `decompress` function + if (info.releaseAsset.endsWith('.xz')) { + const archiveDataInStream = new plzma.InStream(buf); + const decoder = new plzma.Decoder(archiveDataInStream, plzma.FileType.xz); + decoder.open(); + + // We know the xz archive only contains 1 file, the tarball + // We extract the tarball in-memory, for later use in the `decompress` function + const selectedItemsToStreams = new Map(); + selectedItemsToStreams.set(decoder.itemAt(0), plzma.OutStream()); + + decoder.extract(selectedItemsToStreams); + for (const value of selectedItemsToStreams.values()) { + buf = value.copyContent() + } + } + await decompress(Buffer.from(buf), packageDirectory, { + // Remove the leading directory from the extracted file. strip:1, plugins: [ - decompressTarxz(), - decompressUnzip() + decompressUnzip(), + decompressTar() ], + // Only extract the binary file and nothing else filter: file => parse(file.path).base === info.binaryAsset }) } diff --git a/crates/wizer/npm/wizer/wizer b/crates/wizer/npm/wizer/wizer deleted file mode 100755 index 9be35e010725..000000000000 --- a/crates/wizer/npm/wizer/wizer +++ /dev/null @@ -1 +0,0 @@ -placeholder file for the wizer binary to be copied to \ No newline at end of file diff --git a/crates/wizer/npm/wizer/wizer.js b/crates/wizer/npm/wizer/wizer.js new file mode 100755 index 000000000000..c791a8c870bc --- /dev/null +++ b/crates/wizer/npm/wizer/wizer.js @@ -0,0 +1,35 @@ +#!/usr/bin/env node +import { endianness } from "node:os"; +import { platform, arch } from "node:process"; +import { execFileSync } from "node:child_process"; +const knownPackages = { + "win32 x64 LE": "@bytecode-alliance/wizer-win32-x64", + "darwin arm64 LE": "@bytecode-alliance/wizer-darwin-arm64", + "darwin x64 LE": "@bytecode-alliance/wizer-darwin-x64", + "linux x64 LE": "@bytecode-alliance/wizer-linux-x64", +}; + +function pkgForCurrentPlatform() { + let platformKey = `${platform} ${arch} ${endianness()}`; + + if (platformKey in knownPackages) { + return knownPackages[platformKey]; + } + throw new Error(`Unsupported platform: "${platformKey}". "@bytecode-alliance/wizer does not have a precompiled binary for the platform/architecture you are using. You can open an issue on https://github.com/bytecodealliance/wizer/issues to request for your platform/architecture to be included."`); +} + +const pkg = pkgForCurrentPlatform(); + +let location; +try { + // Check for the binary package from our "optionalDependencies". This + // package should have been installed alongside this package at install time. + location = (await import(pkg)).default; +} catch (e) { + throw new Error(`The package "${pkg}" could not be found, and is needed by @bytecode-alliance/wizer. +If you are installing @bytecode-alliance/wizer with npm, make sure that you don't specify the +"--no-optional" flag. The "optionalDependencies" package.json feature is used +by @bytecode-alliance/wizer to install the correct binary executable for your current platform.`); +} + +execFileSync(location, process.argv.slice(2), { stdio: "inherit" }); From f115287f0e5a86abf52db275bb768a8fcd1943f0 Mon Sep 17 00:00:00 2001 From: Jake Champion Date: Fri, 4 Nov 2022 15:41:56 +0000 Subject: [PATCH 108/212] update all packages when running `npm version x.x.x` --- crates/wizer/npm/wizer/package.json | 1 - crates/wizer/npm/wizer/update.js | 33 ++++++++++++++++++++++------- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/crates/wizer/npm/wizer/package.json b/crates/wizer/npm/wizer/package.json index 2227a43fc477..fb7773e9f4ea 100644 --- a/crates/wizer/npm/wizer/package.json +++ b/crates/wizer/npm/wizer/package.json @@ -4,7 +4,6 @@ "description": "The WebAssembly Pre-Initializer", "type": "module", "scripts": { - "update": "node ./update.js", "version": "node ./update.js $npm_package_version" }, "devDependencies": { diff --git a/crates/wizer/npm/wizer/update.js b/crates/wizer/npm/wizer/update.js index 566e33933f13..01d8981be0ce 100644 --- a/crates/wizer/npm/wizer/update.js +++ b/crates/wizer/npm/wizer/update.js @@ -7,12 +7,9 @@ import decompress from 'decompress'; import decompressUnzip from 'decompress-unzip'; import decompressTar from 'decompress-tar'; import plzma from 'plzmasdk'; - const __dirname = dirname(fileURLToPath(import.meta.url)); -const tag = 'dev'; -let response = await fetch(`https://api.github.com/repos/bytecodealliance/wizer/releases/tags/${tag}`) -response = await response.json() -const id = response.id +const tag = process.argv.slice(2).at(0) || 'dev'; + let packages = { 'wizer-darwin-arm64': { releaseAsset: `wizer-${tag}-aarch64-macos.tar.xz`, @@ -43,20 +40,40 @@ let packages = { cpu: 'x64', }, } -let assets = await fetch(`https://api.github.com/repos/bytecodealliance/wizer/releases/${id}/assets`) + +const response = await fetch(`https://api.github.com/repos/bytecodealliance/wizer/releases/tags/${tag}`) +if (!response.ok) { + console.error(`Response from https://api.github.com/repos/bytecodealliance/wizer/releases/tags/${tag} was not ok`, response) + console.error(await response.text()) + process.exit(1) +} +response = await response.json() +const id = response.id +const assets = await fetch(`https://api.github.com/repos/bytecodealliance/wizer/releases/${id}/assets`) +if (!assets.ok) { + console.error(`Response from https://api.github.com/repos/bytecodealliance/wizer/releases/${id}/assets was not ok`, assets) + console.error(await response.text()) + process.exit(1) +} assets = await assets.json() for (const [packageName, info] of Object.entries(packages)) { const asset = assets.find(asset => asset.name === info.releaseAsset) if (!asset) { - throw new Error(`Can't find an asset named ${info.releaseAsset} for the release https://github.com/bytecodealliance/wizer/releases/tag/${tag}`) + console.error(`Can't find an asset named ${info.releaseAsset} for the release https://github.com/bytecodealliance/wizer/releases/tag/${tag}`) + process.exit(1) } const packageDirectory = join(__dirname, '../', packageName.split('/').pop()) await mkdir(packageDirectory, { recursive: true }) await writeFile(join(packageDirectory, 'package.json'), packageJson(packageName, tag, info.description, info.os, info.cpu)) await writeFile(join(packageDirectory, 'index.js'), indexJs(info.binaryAsset)) const browser_download_url = asset.browser_download_url; - let archive = await fetch(browser_download_url) + const archive = await fetch(browser_download_url) + if (!archive.ok) { + console.error(`Response from ${browser_download_url} was not ok`, archive) + console.error(await response.text()) + process.exit(1) + } let buf = await archive.arrayBuffer() // Need to decompress into the original tarball format for later use in the `decompress` function From 1c3e1c605a1b5b99e79d6761d722bc1998ef1d55 Mon Sep 17 00:00:00 2001 From: Jake Champion Date: Mon, 7 Nov 2022 12:13:44 +0000 Subject: [PATCH 109/212] append v to tag name before making github api requests -- the npm_package_version env var looks to not include the `v` even if supplied in the `npm version` command that was executed --- crates/wizer/npm/wizer/update.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/wizer/npm/wizer/update.js b/crates/wizer/npm/wizer/update.js index 01d8981be0ce..87d4eaafeba4 100644 --- a/crates/wizer/npm/wizer/update.js +++ b/crates/wizer/npm/wizer/update.js @@ -8,7 +8,8 @@ import decompressUnzip from 'decompress-unzip'; import decompressTar from 'decompress-tar'; import plzma from 'plzmasdk'; const __dirname = dirname(fileURLToPath(import.meta.url)); -const tag = process.argv.slice(2).at(0) || 'dev'; +const input = process.argv.slice(2).at(0); +const tag = input ? `v${input}` : 'dev'; let packages = { 'wizer-darwin-arm64': { From c10d321ad8cdd5b5daf226bc0f3aebf6692c386c Mon Sep 17 00:00:00 2001 From: Jake Champion Date: Mon, 7 Nov 2022 12:14:12 +0000 Subject: [PATCH 110/212] fix bug where we are attempting to reassign to a const declared value --- crates/wizer/npm/wizer/update.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/wizer/npm/wizer/update.js b/crates/wizer/npm/wizer/update.js index 87d4eaafeba4..8c1bec12c170 100644 --- a/crates/wizer/npm/wizer/update.js +++ b/crates/wizer/npm/wizer/update.js @@ -42,7 +42,7 @@ let packages = { }, } -const response = await fetch(`https://api.github.com/repos/bytecodealliance/wizer/releases/tags/${tag}`) +let response = await fetch(`https://api.github.com/repos/bytecodealliance/wizer/releases/tags/${tag}`) if (!response.ok) { console.error(`Response from https://api.github.com/repos/bytecodealliance/wizer/releases/tags/${tag} was not ok`, response) console.error(await response.text()) @@ -50,7 +50,7 @@ if (!response.ok) { } response = await response.json() const id = response.id -const assets = await fetch(`https://api.github.com/repos/bytecodealliance/wizer/releases/${id}/assets`) +let assets = await fetch(`https://api.github.com/repos/bytecodealliance/wizer/releases/${id}/assets`) if (!assets.ok) { console.error(`Response from https://api.github.com/repos/bytecodealliance/wizer/releases/${id}/assets was not ok`, assets) console.error(await response.text()) @@ -95,7 +95,7 @@ for (const [packageName, info] of Object.entries(packages)) { } await decompress(Buffer.from(buf), packageDirectory, { // Remove the leading directory from the extracted file. - strip:1, + strip: 1, plugins: [ decompressUnzip(), decompressTar() From 89325f17be334776ba3992eb26fd1f77b0790dfa Mon Sep 17 00:00:00 2001 From: Jake Champion Date: Mon, 7 Nov 2022 12:25:56 +0000 Subject: [PATCH 111/212] Bump to version 1.5.0 --- crates/wizer/Cargo.lock | 2 +- crates/wizer/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/wizer/Cargo.lock b/crates/wizer/Cargo.lock index 1b44413b1bfe..fb2408303dd7 100644 --- a/crates/wizer/Cargo.lock +++ b/crates/wizer/Cargo.lock @@ -2071,7 +2071,7 @@ dependencies = [ [[package]] name = "wizer" -version = "1.4.0" +version = "1.5.0" dependencies = [ "anyhow", "cap-std", diff --git a/crates/wizer/Cargo.toml b/crates/wizer/Cargo.toml index 6259c19accd9..8f165e1e07e6 100644 --- a/crates/wizer/Cargo.toml +++ b/crates/wizer/Cargo.toml @@ -9,7 +9,7 @@ license = "Apache-2.0 WITH LLVM-exception" name = "wizer" readme = "./README.md" repository = "https://github.com/bytecodealliance/wizer" -version = "1.4.0" +version = "1.5.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html From 88e23155a5970d90fd936043c6c5bb175235d4d6 Mon Sep 17 00:00:00 2001 From: Jake Champion Date: Mon, 7 Nov 2022 14:17:19 +0000 Subject: [PATCH 112/212] correct the version for @bytecode-alliance/wizer packageto match the cargo.toml version --- crates/wizer/npm/wizer/package-lock.json | 4 ++-- crates/wizer/npm/wizer/package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/wizer/npm/wizer/package-lock.json b/crates/wizer/npm/wizer/package-lock.json index 7a21c1b3f127..56bcfc679d13 100644 --- a/crates/wizer/npm/wizer/package-lock.json +++ b/crates/wizer/npm/wizer/package-lock.json @@ -1,12 +1,12 @@ { "name": "@bytecode-alliance/wizer", - "version": "1.5.56", + "version": "1.5.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@bytecode-alliance/wizer", - "version": "1.5.56", + "version": "1.5.0", "license": "Apache-2.0", "bin": { "wizer": "wizer.js" diff --git a/crates/wizer/npm/wizer/package.json b/crates/wizer/npm/wizer/package.json index fb7773e9f4ea..b952c8b1e26e 100644 --- a/crates/wizer/npm/wizer/package.json +++ b/crates/wizer/npm/wizer/package.json @@ -1,6 +1,6 @@ { "name": "@bytecode-alliance/wizer", - "version": "1.5.56", + "version": "1.5.0", "description": "The WebAssembly Pre-Initializer", "type": "module", "scripts": { From 7b37e3b770722565c254207618e2d32b84450379 Mon Sep 17 00:00:00 2001 From: Jake Champion Date: Thu, 10 Nov 2022 11:53:42 +0000 Subject: [PATCH 113/212] make sure the location export is a string and not an export object containing a default property --- crates/wizer/npm/wizer/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/wizer/npm/wizer/index.js b/crates/wizer/npm/wizer/index.js index 78ba4b701f3b..cde395e90a16 100644 --- a/crates/wizer/npm/wizer/index.js +++ b/crates/wizer/npm/wizer/index.js @@ -23,7 +23,7 @@ let location; try { // Check for the binary package from our "optionalDependencies". This // package should have been installed alongside this package at install time. - location = await import(pkg); + location = (await import(pkg)).default; } catch (e) { throw new Error(`The package "${pkg}" could not be found, and is needed by @bytecode-alliance/wizer. If you are installing @bytecode-alliance/wizer with npm, make sure that you don't specify the From ad4e09f97f179d9587e705217120deb44a64f517 Mon Sep 17 00:00:00 2001 From: Trevor Elliott Date: Thu, 8 Dec 2022 11:54:23 -0800 Subject: [PATCH 114/212] Emit the DataCount section during rewriting --- crates/wizer/src/rewrite.rs | 6 +++++ crates/wizer/tests/tests.rs | 51 +++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) diff --git a/crates/wizer/src/rewrite.rs b/crates/wizer/src/rewrite.rs index 2a25b9ad4496..9c60ce6ee973 100644 --- a/crates/wizer/src/rewrite.rs +++ b/crates/wizer/src/rewrite.rs @@ -168,6 +168,12 @@ impl Wizer { continue; } + s if s.id == SectionId::DataCount.into() => { + encoder.section(&wasm_encoder::DataCountSection { + count: u32::try_from(snapshot.data_segments.len()).unwrap(), + }); + } + s if s.id == SectionId::Data.into() => { // TODO: supporting bulk memory will require copying over // any passive and declared segments. diff --git a/crates/wizer/tests/tests.rs b/crates/wizer/tests/tests.rs index f3a8c84833aa..86dc97a08bc9 100644 --- a/crates/wizer/tests/tests.rs +++ b/crates/wizer/tests/tests.rs @@ -1160,6 +1160,57 @@ fn accept_bulk_memory_copy() -> Result<()> { ) } +#[test] +fn accept_bulk_memory_data_count() -> Result<()> { + let mut module = wasm_encoder::Module::new(); + let mut types = wasm_encoder::TypeSection::new(); + types.function(vec![], vec![wasm_encoder::ValType::I32]); + types.function(vec![], vec![]); + module.section(&types); + + let mut functions = wasm_encoder::FunctionSection::new(); + functions.function(0); + functions.function(1); + module.section(&functions); + + let mut memory = wasm_encoder::MemorySection::new(); + memory.memory(wasm_encoder::MemoryType { + minimum: 1, + maximum: Some(1), + memory64: false, + }); + module.section(&memory); + + let mut exports = wasm_encoder::ExportSection::new(); + exports.export("run", wasm_encoder::Export::Function(0)); + exports.export("wizer.initialize", wasm_encoder::Export::Function(1)); + module.section(&exports); + + module.section(&wasm_encoder::DataCountSection { count: 2 }); + + let mut code = wasm_encoder::CodeSection::new(); + let mut func = wasm_encoder::Function::new(vec![]); + func.instruction(wasm_encoder::Instruction::I32Const(42)); + func.instruction(wasm_encoder::Instruction::End); + code.function(&func); + + let mut func = wasm_encoder::Function::new(vec![]); + func.instruction(wasm_encoder::Instruction::End); + code.function(&func); + + module.section(&code); + + // We're expecting these two data segments to be merge into one, which will exercise wizer's + // ability to output the correct data count (1 instead of 2 above). + let mut data = wasm_encoder::DataSection::new(); + data.active(0, wasm_encoder::Instruction::I32Const(0), vec![0, 1, 2, 3]); + data.active(0, wasm_encoder::Instruction::I32Const(4), vec![5, 6, 7, 8]); + module.section(&data); + + run_wasm(&[], 42, &module.finish()).unwrap(); + Ok(()) +} + #[test] fn accept_bulk_memory_fill() -> Result<()> { run_wat( From 656d509160181676d169919c00ee4ff394e6faf2 Mon Sep 17 00:00:00 2001 From: Jake Champion Date: Fri, 9 Dec 2022 16:56:01 +0000 Subject: [PATCH 115/212] release 1.6.0 to npm --- crates/wizer/npm/wizer/package-lock.json | 435 +++++++---------------- crates/wizer/npm/wizer/package.json | 13 +- crates/wizer/npm/wizer/update.js | 5 +- 3 files changed, 150 insertions(+), 303 deletions(-) diff --git a/crates/wizer/npm/wizer/package-lock.json b/crates/wizer/npm/wizer/package-lock.json index 56bcfc679d13..bde0ae225ff4 100644 --- a/crates/wizer/npm/wizer/package-lock.json +++ b/crates/wizer/npm/wizer/package-lock.json @@ -1,12 +1,12 @@ { "name": "@bytecode-alliance/wizer", - "version": "1.5.0", + "version": "1.6.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@bytecode-alliance/wizer", - "version": "1.5.0", + "version": "1.6.0", "license": "Apache-2.0", "bin": { "wizer": "wizer.js" @@ -21,74 +21,10 @@ "node": ">=16" }, "optionalDependencies": { - "@bytecode-alliance/wizer-darwin-arm64": "1.5.56", - "@bytecode-alliance/wizer-darwin-x64": "1.5.56", - "@bytecode-alliance/wizer-linux-x64": "1.5.56", - "@bytecode-alliance/wizer-win32-x64": "1.5.56" - } - }, - "node_modules/@bytecode-alliance/wizer-darwin-arm64": { - "version": "1.5.56", - "resolved": "http://localhost:4873/@bytecode-alliance%2fwizer-darwin-arm64/-/wizer-darwin-arm64-1.5.56.tgz", - "integrity": "sha512-0R7m3E+/0KiCn3vxgmQgmZUfjWIjSGjtc0Ps2I2ZkNBZ5LrymrTbM/0jSyBqotDvcjVLXaqCuyxkqzqEPmie8g==", - "cpu": [ - "arm64" - ], - "license": "Apache-2.0", - "optional": true, - "os": [ - "darwin" - ], - "bin": { - "wizer-darwin-arm64": "wizer" - } - }, - "node_modules/@bytecode-alliance/wizer-darwin-x64": { - "version": "1.5.56", - "resolved": "http://localhost:4873/@bytecode-alliance%2fwizer-darwin-x64/-/wizer-darwin-x64-1.5.56.tgz", - "integrity": "sha512-AQxaGgolMGrjRM55AICmJgU9ffPJ3PgdlJD2NnegEyaVJbmwuTd8XVnLnEyF1rH/5TxTfGh6yhK8MTtb2Z8U7Q==", - "cpu": [ - "x64" - ], - "license": "Apache-2.0", - "optional": true, - "os": [ - "darwin" - ], - "bin": { - "wizer-darwin-x64": "wizer" - } - }, - "node_modules/@bytecode-alliance/wizer-linux-x64": { - "version": "1.5.56", - "resolved": "http://localhost:4873/@bytecode-alliance%2fwizer-linux-x64/-/wizer-linux-x64-1.5.56.tgz", - "integrity": "sha512-wUcX3JUY9jIEdMSNtAXwKbUf1DtNMxtnpFfWklop8pZHNDSprtxdRzf8TyuPvEIuDKfEFuUkNBU6P8x63G3Rpw==", - "cpu": [ - "x64" - ], - "license": "Apache-2.0", - "optional": true, - "os": [ - "darwin" - ], - "bin": { - "wizer-linux-x64": "wizer" - } - }, - "node_modules/@bytecode-alliance/wizer-win32-x64": { - "version": "1.5.56", - "resolved": "http://localhost:4873/@bytecode-alliance%2fwizer-win32-x64/-/wizer-win32-x64-1.5.56.tgz", - "integrity": "sha512-E7OaPk5JvWCqCzCFG0QbBMuFUFdiMyK3hzbRZNlDOrliRKtsBc/vB7x82jH0RIvMpMdsWgq8nhaA1UnJGhH3jQ==", - "cpu": [ - "x64" - ], - "license": "Apache-2.0", - "optional": true, - "os": [ - "win32" - ], - "bin": { - "wizer-win32-x64": "wizer" + "@bytecode-alliance/wizer-darwin-arm64": "1.6.0", + "@bytecode-alliance/wizer-darwin-x64": "1.6.0", + "@bytecode-alliance/wizer-linux-x64": "1.6.0", + "@bytecode-alliance/wizer-win32-x64": "1.6.0" } }, "node_modules/base64-js": { @@ -121,36 +57,6 @@ "safe-buffer": "^5.1.1" } }, - "node_modules/bl/node_modules/readable-stream": { - "version": "2.3.7", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", - "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", - "dev": true, - "dependencies": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" - } - }, - "node_modules/bl/node_modules/safe-buffer": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", - "dev": true - }, - "node_modules/bl/node_modules/string_decoder": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", - "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "dev": true, - "dependencies": { - "safe-buffer": "~5.1.0" - } - }, "node_modules/buffer": { "version": "5.7.1", "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz", @@ -251,24 +157,6 @@ "node": ">=4" } }, - "node_modules/decompress-tar/node_modules/file-type": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/file-type/-/file-type-5.2.0.tgz", - "integrity": "sha512-Iq1nJ6D2+yIO4c8HHg4fyVb8mAJieo1Oloy1mLLaB2PvezNedhBVm+QU7g0qM42aiMbRXTxKKwGD17rjKNJYVQ==", - "dev": true, - "engines": { - "node": ">=4" - } - }, - "node_modules/decompress-tar/node_modules/is-stream": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", - "integrity": "sha512-uQPm8kcs47jx38atAcWTVxyltQYoPT68y9aWYdV6yWXSyW8mzSat0TL6CiWdZeCdF3KrAvpVtnHbTv4RN+rqdQ==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/decompress-tarbz2": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/decompress-tarbz2/-/decompress-tarbz2-4.1.1.tgz", @@ -294,15 +182,6 @@ "node": ">=4" } }, - "node_modules/decompress-tarbz2/node_modules/is-stream": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", - "integrity": "sha512-uQPm8kcs47jx38atAcWTVxyltQYoPT68y9aWYdV6yWXSyW8mzSat0TL6CiWdZeCdF3KrAvpVtnHbTv4RN+rqdQ==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/decompress-targz": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/decompress-targz/-/decompress-targz-4.1.1.tgz", @@ -317,24 +196,6 @@ "node": ">=4" } }, - "node_modules/decompress-targz/node_modules/file-type": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/file-type/-/file-type-5.2.0.tgz", - "integrity": "sha512-Iq1nJ6D2+yIO4c8HHg4fyVb8mAJieo1Oloy1mLLaB2PvezNedhBVm+QU7g0qM42aiMbRXTxKKwGD17rjKNJYVQ==", - "dev": true, - "engines": { - "node": ">=4" - } - }, - "node_modules/decompress-targz/node_modules/is-stream": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", - "integrity": "sha512-uQPm8kcs47jx38atAcWTVxyltQYoPT68y9aWYdV6yWXSyW8mzSat0TL6CiWdZeCdF3KrAvpVtnHbTv4RN+rqdQ==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/decompress-unzip": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/decompress-unzip/-/decompress-unzip-4.0.1.tgz", @@ -377,6 +238,15 @@ "pend": "~1.2.0" } }, + "node_modules/file-type": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/file-type/-/file-type-5.2.0.tgz", + "integrity": "sha512-Iq1nJ6D2+yIO4c8HHg4fyVb8mAJieo1Oloy1mLLaB2PvezNedhBVm+QU7g0qM42aiMbRXTxKKwGD17rjKNJYVQ==", + "dev": true, + "engines": { + "node": ">=4" + } + }, "node_modules/fs-constants": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz", @@ -434,6 +304,15 @@ "integrity": "sha512-Y4LTamMe0DDQIIAlaer9eKebAlDSV6huy+TWhJVPlzZh2o4tRP5SQWFlLn5N0To4mDD22/qdOq+veo1cSISLgQ==", "dev": true }, + "node_modules/is-stream": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", + "integrity": "sha512-uQPm8kcs47jx38atAcWTVxyltQYoPT68y9aWYdV6yWXSyW8mzSat0TL6CiWdZeCdF3KrAvpVtnHbTv4RN+rqdQ==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/isarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", @@ -532,6 +411,47 @@ "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==", "dev": true }, + "node_modules/readable-stream": { + "version": "2.3.7", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", + "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", + "dev": true, + "dependencies": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "node_modules/readable-stream/node_modules/safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "dev": true + }, + "node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, "node_modules/seek-bzip": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/seek-bzip/-/seek-bzip-1.0.6.tgz", @@ -545,6 +465,21 @@ "seek-table": "bin/seek-bzip-table" } }, + "node_modules/string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "dev": true, + "dependencies": { + "safe-buffer": "~5.1.0" + } + }, + "node_modules/string_decoder/node_modules/safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "dev": true + }, "node_modules/strip-dirs": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/strip-dirs/-/strip-dirs-2.1.0.tgz", @@ -572,36 +507,6 @@ "node": ">= 0.8.0" } }, - "node_modules/tar-stream/node_modules/readable-stream": { - "version": "2.3.7", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", - "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", - "dev": true, - "dependencies": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" - } - }, - "node_modules/tar-stream/node_modules/safe-buffer": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", - "dev": true - }, - "node_modules/tar-stream/node_modules/string_decoder": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", - "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "dev": true, - "dependencies": { - "safe-buffer": "~5.1.0" - } - }, "node_modules/through": { "version": "2.3.8", "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", @@ -657,30 +562,6 @@ } }, "dependencies": { - "@bytecode-alliance/wizer-darwin-arm64": { - "version": "1.5.56", - "resolved": "http://localhost:4873/@bytecode-alliance%2fwizer-darwin-arm64/-/wizer-darwin-arm64-1.5.56.tgz", - "integrity": "sha512-0R7m3E+/0KiCn3vxgmQgmZUfjWIjSGjtc0Ps2I2ZkNBZ5LrymrTbM/0jSyBqotDvcjVLXaqCuyxkqzqEPmie8g==", - "optional": true - }, - "@bytecode-alliance/wizer-darwin-x64": { - "version": "1.5.56", - "resolved": "http://localhost:4873/@bytecode-alliance%2fwizer-darwin-x64/-/wizer-darwin-x64-1.5.56.tgz", - "integrity": "sha512-AQxaGgolMGrjRM55AICmJgU9ffPJ3PgdlJD2NnegEyaVJbmwuTd8XVnLnEyF1rH/5TxTfGh6yhK8MTtb2Z8U7Q==", - "optional": true - }, - "@bytecode-alliance/wizer-linux-x64": { - "version": "1.5.56", - "resolved": "http://localhost:4873/@bytecode-alliance%2fwizer-linux-x64/-/wizer-linux-x64-1.5.56.tgz", - "integrity": "sha512-wUcX3JUY9jIEdMSNtAXwKbUf1DtNMxtnpFfWklop8pZHNDSprtxdRzf8TyuPvEIuDKfEFuUkNBU6P8x63G3Rpw==", - "optional": true - }, - "@bytecode-alliance/wizer-win32-x64": { - "version": "1.5.56", - "resolved": "http://localhost:4873/@bytecode-alliance%2fwizer-win32-x64/-/wizer-win32-x64-1.5.56.tgz", - "integrity": "sha512-E7OaPk5JvWCqCzCFG0QbBMuFUFdiMyK3hzbRZNlDOrliRKtsBc/vB7x82jH0RIvMpMdsWgq8nhaA1UnJGhH3jQ==", - "optional": true - }, "base64-js": { "version": "1.5.1", "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", @@ -695,38 +576,6 @@ "requires": { "readable-stream": "^2.3.5", "safe-buffer": "^5.1.1" - }, - "dependencies": { - "readable-stream": { - "version": "2.3.7", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", - "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", - "dev": true, - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" - } - }, - "safe-buffer": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", - "dev": true - }, - "string_decoder": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", - "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "dev": true, - "requires": { - "safe-buffer": "~5.1.0" - } - } } }, "buffer": { @@ -804,20 +653,6 @@ "file-type": "^5.2.0", "is-stream": "^1.1.0", "tar-stream": "^1.5.2" - }, - "dependencies": { - "file-type": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/file-type/-/file-type-5.2.0.tgz", - "integrity": "sha512-Iq1nJ6D2+yIO4c8HHg4fyVb8mAJieo1Oloy1mLLaB2PvezNedhBVm+QU7g0qM42aiMbRXTxKKwGD17rjKNJYVQ==", - "dev": true - }, - "is-stream": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", - "integrity": "sha512-uQPm8kcs47jx38atAcWTVxyltQYoPT68y9aWYdV6yWXSyW8mzSat0TL6CiWdZeCdF3KrAvpVtnHbTv4RN+rqdQ==", - "dev": true - } } }, "decompress-tarbz2": { @@ -838,12 +673,6 @@ "resolved": "https://registry.npmjs.org/file-type/-/file-type-6.2.0.tgz", "integrity": "sha512-YPcTBDV+2Tm0VqjybVd32MHdlEGAtuxS3VAYsumFokDSMG+ROT5wawGlnHDoz7bfMcMDt9hxuXvXwoKUx2fkOg==", "dev": true - }, - "is-stream": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", - "integrity": "sha512-uQPm8kcs47jx38atAcWTVxyltQYoPT68y9aWYdV6yWXSyW8mzSat0TL6CiWdZeCdF3KrAvpVtnHbTv4RN+rqdQ==", - "dev": true } } }, @@ -856,20 +685,6 @@ "decompress-tar": "^4.1.1", "file-type": "^5.2.0", "is-stream": "^1.1.0" - }, - "dependencies": { - "file-type": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/file-type/-/file-type-5.2.0.tgz", - "integrity": "sha512-Iq1nJ6D2+yIO4c8HHg4fyVb8mAJieo1Oloy1mLLaB2PvezNedhBVm+QU7g0qM42aiMbRXTxKKwGD17rjKNJYVQ==", - "dev": true - }, - "is-stream": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", - "integrity": "sha512-uQPm8kcs47jx38atAcWTVxyltQYoPT68y9aWYdV6yWXSyW8mzSat0TL6CiWdZeCdF3KrAvpVtnHbTv4RN+rqdQ==", - "dev": true - } } }, "decompress-unzip": { @@ -910,6 +725,12 @@ "pend": "~1.2.0" } }, + "file-type": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/file-type/-/file-type-5.2.0.tgz", + "integrity": "sha512-Iq1nJ6D2+yIO4c8HHg4fyVb8mAJieo1Oloy1mLLaB2PvezNedhBVm+QU7g0qM42aiMbRXTxKKwGD17rjKNJYVQ==", + "dev": true + }, "fs-constants": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz", @@ -950,6 +771,12 @@ "integrity": "sha512-Y4LTamMe0DDQIIAlaer9eKebAlDSV6huy+TWhJVPlzZh2o4tRP5SQWFlLn5N0To4mDD22/qdOq+veo1cSISLgQ==", "dev": true }, + "is-stream": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", + "integrity": "sha512-uQPm8kcs47jx38atAcWTVxyltQYoPT68y9aWYdV6yWXSyW8mzSat0TL6CiWdZeCdF3KrAvpVtnHbTv4RN+rqdQ==", + "dev": true + }, "isarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", @@ -1027,6 +854,35 @@ "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==", "dev": true }, + "readable-stream": { + "version": "2.3.7", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", + "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", + "dev": true, + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + }, + "dependencies": { + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "dev": true + } + } + }, + "safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "dev": true + }, "seek-bzip": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/seek-bzip/-/seek-bzip-1.0.6.tgz", @@ -1036,6 +892,23 @@ "commander": "^2.8.1" } }, + "string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "dev": true, + "requires": { + "safe-buffer": "~5.1.0" + }, + "dependencies": { + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "dev": true + } + } + }, "strip-dirs": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/strip-dirs/-/strip-dirs-2.1.0.tgz", @@ -1058,38 +931,6 @@ "readable-stream": "^2.3.0", "to-buffer": "^1.1.1", "xtend": "^4.0.0" - }, - "dependencies": { - "readable-stream": { - "version": "2.3.7", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", - "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", - "dev": true, - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" - } - }, - "safe-buffer": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", - "dev": true - }, - "string_decoder": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", - "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "dev": true, - "requires": { - "safe-buffer": "~5.1.0" - } - } } }, "through": { diff --git a/crates/wizer/npm/wizer/package.json b/crates/wizer/npm/wizer/package.json index b952c8b1e26e..266e8d7e7e06 100644 --- a/crates/wizer/npm/wizer/package.json +++ b/crates/wizer/npm/wizer/package.json @@ -1,8 +1,11 @@ { "name": "@bytecode-alliance/wizer", - "version": "1.5.0", + "version": "1.6.0", "description": "The WebAssembly Pre-Initializer", "type": "module", + "publishConfig": { + "access": "public" + }, "scripts": { "version": "node ./update.js $npm_package_version" }, @@ -20,10 +23,10 @@ "wizer": "./wizer.js" }, "optionalDependencies": { - "@bytecode-alliance/wizer-darwin-arm64": "1.5.56", - "@bytecode-alliance/wizer-darwin-x64": "1.5.56", - "@bytecode-alliance/wizer-linux-x64": "1.5.56", - "@bytecode-alliance/wizer-win32-x64": "1.5.56" + "@bytecode-alliance/wizer-darwin-arm64": "1.6.0", + "@bytecode-alliance/wizer-darwin-x64": "1.6.0", + "@bytecode-alliance/wizer-linux-x64": "1.6.0", + "@bytecode-alliance/wizer-win32-x64": "1.6.0" }, "license": "Apache-2.0", "repository": { diff --git a/crates/wizer/npm/wizer/update.js b/crates/wizer/npm/wizer/update.js index 8c1bec12c170..c4758c2d1f13 100644 --- a/crates/wizer/npm/wizer/update.js +++ b/crates/wizer/npm/wizer/update.js @@ -30,7 +30,7 @@ let packages = { releaseAsset: `wizer-${tag}-x86_64-linux.tar.xz`, binaryAsset: 'wizer', description: 'The Linux 64-bit binary for Wizer, the WebAssembly Pre-Initializer', - os: 'darwin', + os: 'linux', cpu: 'x64', }, 'wizer-win32-x64': { @@ -128,5 +128,8 @@ function packageJson(name, version, description, os, cpu) { preferUnplugged: false, os: [os], cpu: [cpu], + publishConfig: { + access: "public" + }, }, null, 4); } From 4ead91fec046b727ded8d27bd7586852affa3f8b Mon Sep 17 00:00:00 2001 From: Jake Champion Date: Fri, 9 Dec 2022 16:59:35 +0000 Subject: [PATCH 116/212] strip v from start of tag --- crates/wizer/npm/wizer/update.js | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/wizer/npm/wizer/update.js b/crates/wizer/npm/wizer/update.js index c4758c2d1f13..25adef7c840b 100644 --- a/crates/wizer/npm/wizer/update.js +++ b/crates/wizer/npm/wizer/update.js @@ -115,6 +115,7 @@ export default location ` } function packageJson(name, version, description, os, cpu) { + version = version.startsWith('v') ? version.replace('v','') : version return JSON.stringify({ name: `@bytecode-alliance/${name}`, bin: { From 7a0b7f64bee48ddb111a2f48b23102d1c3399415 Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Fri, 9 Dec 2022 11:15:32 -0800 Subject: [PATCH 117/212] Bump crate version to 1.6.0 --- crates/wizer/Cargo.lock | 2 +- crates/wizer/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/wizer/Cargo.lock b/crates/wizer/Cargo.lock index fb2408303dd7..3dfe3393ad54 100644 --- a/crates/wizer/Cargo.lock +++ b/crates/wizer/Cargo.lock @@ -2071,7 +2071,7 @@ dependencies = [ [[package]] name = "wizer" -version = "1.5.0" +version = "1.6.0" dependencies = [ "anyhow", "cap-std", diff --git a/crates/wizer/Cargo.toml b/crates/wizer/Cargo.toml index 8f165e1e07e6..82d97afc3f2b 100644 --- a/crates/wizer/Cargo.toml +++ b/crates/wizer/Cargo.toml @@ -9,7 +9,7 @@ license = "Apache-2.0 WITH LLVM-exception" name = "wizer" readme = "./README.md" repository = "https://github.com/bytecodealliance/wizer" -version = "1.5.0" +version = "1.6.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html From 5a0bf89f068b708b245f382ee4a705003b120998 Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Fri, 9 Dec 2022 12:56:55 -0800 Subject: [PATCH 118/212] Exclude `.wasm` files from the published package --- crates/wizer/Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/wizer/Cargo.toml b/crates/wizer/Cargo.toml index 82d97afc3f2b..3b77abd871ae 100644 --- a/crates/wizer/Cargo.toml +++ b/crates/wizer/Cargo.toml @@ -4,6 +4,7 @@ categories = ["command-line-utilities", "development-tools", "wasm"] description = "The WebAssembly Pre-Initializer" documentation = "https://docs.rs/wizer" edition = "2018" +exclude = ["**.wasm"] homepage = "https://github.com/bytecodealliance/wizer" license = "Apache-2.0 WITH LLVM-exception" name = "wizer" From 0464f6eafda3d31815a7382ce057d2c641175655 Mon Sep 17 00:00:00 2001 From: Trevor Elliott Date: Wed, 14 Dec 2022 16:14:18 -0800 Subject: [PATCH 119/212] Update wizer.h to reference __main_void or __original_main as needed --- crates/wizer/include/wizer.h | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/crates/wizer/include/wizer.h b/crates/wizer/include/wizer.h index 3fcf169aa3e7..e374a5c96062 100644 --- a/crates/wizer/include/wizer.h +++ b/crates/wizer/include/wizer.h @@ -15,6 +15,27 @@ #define __WIZER_EXTERN_C extern #endif +#ifdef __clang_major__ +// wasi-sdk-16 was the first wasi-sdk version that shipped with a version of +// wasi-libc that did not include __original_main. However, wasi-sdk-15 shipped +// with clang-14.0.0. To correctly identify the boundary where __original_main +// no longer exists, we check for either clang-15+ or specifically clang-14.0.4. +// +// wasi-sdk-17 ships with clang-15.0.6 +// wasi-sdk-16 ships with clang-14.0.4 +#if __clang_major__ >= 15 || (__clang_major__ == 14 && __clang_patchlevel__ == 4) +#define WIZER_MAIN_VOID __main_void +#else +#define WIZER_MAIN_VOID __original_main +#endif +#endif + +// We default to assuming that the compiler is new enough to provide +// __main_void. +#ifndef WIZER_MAIN_VOID +#define WIZER_MAIN_VOID __main_void +#endif + /* * This macro inserts the exported functions necessary to allow Wizer to * pre-initialize a Wasm module. @@ -63,7 +84,7 @@ #define WIZER_INIT(init_func) \ __WIZER_EXTERN_C void __wasm_call_ctors(); \ __WIZER_EXTERN_C void __wasm_call_dtors(); \ - __WIZER_EXTERN_C int __original_main(); \ + __WIZER_EXTERN_C int WIZER_MAIN_VOID(); \ /* This function's export name `wizer.initialize` is specially */ \ /* recognized by Wizer. It is the direct entry point for pre-init. */ \ __attribute__((export_name("wizer.initialize"))) void \ @@ -80,14 +101,14 @@ /* This function replaces `_start` (the WASI-specified entry point) in */ \ /* the pre-initialized Wasm module. */ \ __attribute__((export_name("wizer.resume"))) void __wizer_resume() { \ - /* `__original_main()` is defined by the WASI SDK toolchain due to */ \ + /* `__main_void()` is defined by the WASI SDK toolchain due to */ \ /* special semantics in C/C++ for the `main()` function, i.e., ito */ \ /* can either take argc/argv or not. It collects arguments using */ \ /* the appropriate WASI calls and then invokes the user program's */ \ /* `main()`. This may change in the future; when it does, we will */ \ /* coordinate with the WASI-SDK toolchain to implement this entry */ \ /* point in an alternate way. */ \ - __original_main(); \ + WIZER_MAIN_VOID(); \ /* Because we are replacing `_start()`, we need to manually invoke */ \ /* destructors as well. */ \ __wasm_call_dtors(); \ From 1dc5bf022e19da539573ec1eef49cfa5b6037c41 Mon Sep 17 00:00:00 2001 From: Trevor Elliott Date: Wed, 14 Dec 2022 16:21:48 -0800 Subject: [PATCH 120/212] Makefile changes for newer clang --- crates/wizer/examples/cpp/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/wizer/examples/cpp/Makefile b/crates/wizer/examples/cpp/Makefile index 90d7e884b2f9..41f5df1a9d10 100644 --- a/crates/wizer/examples/cpp/Makefile +++ b/crates/wizer/examples/cpp/Makefile @@ -1,7 +1,7 @@ CXX := /opt/wasi-sdk/bin/clang++ CXXFLAGS := -O2 -I ../../include/ WIZER := ../../target/release/wizer -WASMTIME := wasmtime +WASMTIME ?= wasmtime .PHONY: all all: main_initialized.wasm @@ -10,7 +10,7 @@ main.wasm: main.cpp $(CXX) $(CXXFLAGS) -o $@ $^ main_initialized.wasm: main.wasm - $(WIZER) --allow-wasi -r _start=wizer.resume -o $@ $^ + $(WIZER) --allow-wasi --wasm-bulk-memory=true -r _start=wizer.resume -o $@ $^ .PHONY: test test: main_initialized.wasm From c1aa6b256ad54c7a5531ed38b0561c893c3c7983 Mon Sep 17 00:00:00 2001 From: Chris Fallin Date: Tue, 28 Feb 2023 11:56:08 -0800 Subject: [PATCH 121/212] Reduce the maximum number of data segments. --- crates/wizer/src/snapshot.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/wizer/src/snapshot.rs b/crates/wizer/src/snapshot.rs index d2bc3b014824..9e75497ecbb0 100644 --- a/crates/wizer/src/snapshot.rs +++ b/crates/wizer/src/snapshot.rs @@ -4,8 +4,10 @@ use wasmtime::{AsContext, AsContextMut}; const WASM_PAGE_SIZE: u64 = 65_536; -/// The maximum number of data segments that most engines support. -const MAX_DATA_SEGMENTS: usize = 100_000; +/// The maximum number of data segments that we will emit. Most +/// engines support more than this, but we want to leave some +/// headroom. +const MAX_DATA_SEGMENTS: usize = 10_000; /// A "snapshot" of Wasm state from its default value after having been initialized. pub struct Snapshot { From b65eb4c9016e3641840a4ec1c8c4403a84d2e251 Mon Sep 17 00:00:00 2001 From: Guy Bedford Date: Tue, 28 Feb 2023 16:51:22 -0800 Subject: [PATCH 122/212] 1.6.1-beta --- crates/wizer/npm/wizer/package.json | 7 ++----- crates/wizer/npm/wizer/update.js | 5 +---- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/crates/wizer/npm/wizer/package.json b/crates/wizer/npm/wizer/package.json index 266e8d7e7e06..ae9eaaeb658a 100644 --- a/crates/wizer/npm/wizer/package.json +++ b/crates/wizer/npm/wizer/package.json @@ -1,11 +1,8 @@ { - "name": "@bytecode-alliance/wizer", - "version": "1.6.0", + "name": "@bytecodealliance/wizer", + "version": "1.6.1-beta", "description": "The WebAssembly Pre-Initializer", "type": "module", - "publishConfig": { - "access": "public" - }, "scripts": { "version": "node ./update.js $npm_package_version" }, diff --git a/crates/wizer/npm/wizer/update.js b/crates/wizer/npm/wizer/update.js index 25adef7c840b..2ea31936f5c8 100644 --- a/crates/wizer/npm/wizer/update.js +++ b/crates/wizer/npm/wizer/update.js @@ -117,7 +117,7 @@ export default location function packageJson(name, version, description, os, cpu) { version = version.startsWith('v') ? version.replace('v','') : version return JSON.stringify({ - name: `@bytecode-alliance/${name}`, + name: `@bytecodealliance/${name}`, bin: { [name]: "wizer" }, @@ -129,8 +129,5 @@ function packageJson(name, version, description, os, cpu) { preferUnplugged: false, os: [os], cpu: [cpu], - publishConfig: { - access: "public" - }, }, null, 4); } From a5b81f969d3145024a37f7e9affa6c7a8601872d Mon Sep 17 00:00:00 2001 From: Guy Bedford Date: Tue, 28 Feb 2023 17:37:52 -0800 Subject: [PATCH 123/212] fixup: release changes --- crates/wizer/npm/wizer/README.md | 4 ++-- crates/wizer/npm/wizer/package.json | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/crates/wizer/npm/wizer/README.md b/crates/wizer/npm/wizer/README.md index fff50d06c1f1..1a501256ab08 100644 --- a/crates/wizer/npm/wizer/README.md +++ b/crates/wizer/npm/wizer/README.md @@ -5,12 +5,12 @@ ## API ``` -$ npm install --save @bytecode-alliance/wizer +$ npm install --save @bytecodealliance/wizer ``` ```js const execFile = require('child_process').execFile; -const wizer = require('@bytecode-alliance/wizer'); +const wizer = require('@bytecodealliance/wizer'); execFile(wizer, ['input.wasm', '-o', 'initialized.wasm'], (err, stdout) => { console.log(stdout); diff --git a/crates/wizer/npm/wizer/package.json b/crates/wizer/npm/wizer/package.json index ae9eaaeb658a..1d1bf967a8ba 100644 --- a/crates/wizer/npm/wizer/package.json +++ b/crates/wizer/npm/wizer/package.json @@ -20,10 +20,10 @@ "wizer": "./wizer.js" }, "optionalDependencies": { - "@bytecode-alliance/wizer-darwin-arm64": "1.6.0", - "@bytecode-alliance/wizer-darwin-x64": "1.6.0", - "@bytecode-alliance/wizer-linux-x64": "1.6.0", - "@bytecode-alliance/wizer-win32-x64": "1.6.0" + "@bytecode-alliance/wizer-darwin-arm64": "1.6.1-beta", + "@bytecode-alliance/wizer-darwin-x64": "1.6.1-beta", + "@bytecode-alliance/wizer-linux-x64": "1.6.1-beta", + "@bytecode-alliance/wizer-win32-x64": "1.6.1-beta" }, "license": "Apache-2.0", "repository": { From 13e1a8dc35ba5eff7648e5ab74b8975402cad3cc Mon Sep 17 00:00:00 2001 From: Guy Bedford Date: Tue, 28 Feb 2023 17:39:51 -0800 Subject: [PATCH 124/212] fixup --- crates/wizer/npm/wizer/package.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/crates/wizer/npm/wizer/package.json b/crates/wizer/npm/wizer/package.json index 1d1bf967a8ba..4829cb655971 100644 --- a/crates/wizer/npm/wizer/package.json +++ b/crates/wizer/npm/wizer/package.json @@ -1,6 +1,6 @@ { "name": "@bytecodealliance/wizer", - "version": "1.6.1-beta", + "version": "1.6.1-beta.2", "description": "The WebAssembly Pre-Initializer", "type": "module", "scripts": { @@ -20,10 +20,10 @@ "wizer": "./wizer.js" }, "optionalDependencies": { - "@bytecode-alliance/wizer-darwin-arm64": "1.6.1-beta", - "@bytecode-alliance/wizer-darwin-x64": "1.6.1-beta", - "@bytecode-alliance/wizer-linux-x64": "1.6.1-beta", - "@bytecode-alliance/wizer-win32-x64": "1.6.1-beta" + "@bytecodealliance/wizer-darwin-arm64": "1.6.1-beta", + "@bytecodealliance/wizer-darwin-x64": "1.6.1-beta", + "@bytecodealliance/wizer-linux-x64": "1.6.1-beta", + "@bytecodealliance/wizer-win32-x64": "1.6.1-beta" }, "license": "Apache-2.0", "repository": { From 3b982f045bc225f24b0b1457b394173cf98d374c Mon Sep 17 00:00:00 2001 From: Jake Champion Date: Wed, 1 Mar 2023 11:57:49 +0000 Subject: [PATCH 125/212] match cargo and npm versions --- crates/wizer/Cargo.lock | 2 +- crates/wizer/Cargo.toml | 2 +- crates/wizer/npm/wizer/package-lock.json | 16 ++++++++-------- crates/wizer/npm/wizer/package.json | 10 +++++----- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/crates/wizer/Cargo.lock b/crates/wizer/Cargo.lock index 3dfe3393ad54..8796c52dd0ee 100644 --- a/crates/wizer/Cargo.lock +++ b/crates/wizer/Cargo.lock @@ -2071,7 +2071,7 @@ dependencies = [ [[package]] name = "wizer" -version = "1.6.0" +version = "1.6.1-beta.3" dependencies = [ "anyhow", "cap-std", diff --git a/crates/wizer/Cargo.toml b/crates/wizer/Cargo.toml index 3b77abd871ae..844d8c33dd5d 100644 --- a/crates/wizer/Cargo.toml +++ b/crates/wizer/Cargo.toml @@ -10,7 +10,7 @@ license = "Apache-2.0 WITH LLVM-exception" name = "wizer" readme = "./README.md" repository = "https://github.com/bytecodealliance/wizer" -version = "1.6.0" +version = "1.6.1-beta.3" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/crates/wizer/npm/wizer/package-lock.json b/crates/wizer/npm/wizer/package-lock.json index bde0ae225ff4..db1506357e82 100644 --- a/crates/wizer/npm/wizer/package-lock.json +++ b/crates/wizer/npm/wizer/package-lock.json @@ -1,12 +1,12 @@ { - "name": "@bytecode-alliance/wizer", - "version": "1.6.0", + "name": "@bytecodealliance/wizer", + "version": "1.6.1-beta.3", "lockfileVersion": 2, "requires": true, "packages": { "": { - "name": "@bytecode-alliance/wizer", - "version": "1.6.0", + "name": "@bytecodealliance/wizer", + "version": "1.6.1-beta.3", "license": "Apache-2.0", "bin": { "wizer": "wizer.js" @@ -21,10 +21,10 @@ "node": ">=16" }, "optionalDependencies": { - "@bytecode-alliance/wizer-darwin-arm64": "1.6.0", - "@bytecode-alliance/wizer-darwin-x64": "1.6.0", - "@bytecode-alliance/wizer-linux-x64": "1.6.0", - "@bytecode-alliance/wizer-win32-x64": "1.6.0" + "@bytecodealliance/wizer-darwin-arm64": "1.6.1-beta.3", + "@bytecodealliance/wizer-darwin-x64": "1.6.1-beta.3", + "@bytecodealliance/wizer-linux-x64": "1.6.1-beta.3", + "@bytecodealliance/wizer-win32-x64": "1.6.1-beta.3" } }, "node_modules/base64-js": { diff --git a/crates/wizer/npm/wizer/package.json b/crates/wizer/npm/wizer/package.json index 4829cb655971..f75603519642 100644 --- a/crates/wizer/npm/wizer/package.json +++ b/crates/wizer/npm/wizer/package.json @@ -1,6 +1,6 @@ { "name": "@bytecodealliance/wizer", - "version": "1.6.1-beta.2", + "version": "1.6.1-beta.3", "description": "The WebAssembly Pre-Initializer", "type": "module", "scripts": { @@ -20,10 +20,10 @@ "wizer": "./wizer.js" }, "optionalDependencies": { - "@bytecodealliance/wizer-darwin-arm64": "1.6.1-beta", - "@bytecodealliance/wizer-darwin-x64": "1.6.1-beta", - "@bytecodealliance/wizer-linux-x64": "1.6.1-beta", - "@bytecodealliance/wizer-win32-x64": "1.6.1-beta" + "@bytecodealliance/wizer-darwin-arm64": "1.6.1-beta.3", + "@bytecodealliance/wizer-darwin-x64": "1.6.1-beta.3", + "@bytecodealliance/wizer-linux-x64": "1.6.1-beta.3", + "@bytecodealliance/wizer-win32-x64": "1.6.1-beta.3" }, "license": "Apache-2.0", "repository": { From ec59ed9daf535fec08bfe717e6defa786e84a6ee Mon Sep 17 00:00:00 2001 From: Jake Champion Date: Wed, 1 Mar 2023 13:36:22 +0000 Subject: [PATCH 126/212] correct npm organisation name within the npm packages --- crates/wizer/npm/wizer/index.js | 16 ++++++++-------- crates/wizer/npm/wizer/wizer.js | 16 ++++++++-------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/crates/wizer/npm/wizer/index.js b/crates/wizer/npm/wizer/index.js index cde395e90a16..65917efe93f2 100644 --- a/crates/wizer/npm/wizer/index.js +++ b/crates/wizer/npm/wizer/index.js @@ -2,10 +2,10 @@ import { endianness } from "node:os"; import { platform, arch } from "node:process"; const knownPackages = { - "win32 x64 LE": "@bytecode-alliance/wizer-win32-x64", - "darwin arm64 LE": "@bytecode-alliance/wizer-darwin-arm64", - "darwin x64 LE": "@bytecode-alliance/wizer-darwin-x64", - "linux x64 LE": "@bytecode-alliance/wizer-linux-x64", + "win32 x64 LE": "@bytecodealliance/wizer-win32-x64", + "darwin arm64 LE": "@bytecodealliance/wizer-darwin-arm64", + "darwin x64 LE": "@bytecodealliance/wizer-darwin-x64", + "linux x64 LE": "@bytecodealliance/wizer-linux-x64", }; function pkgForCurrentPlatform() { @@ -14,7 +14,7 @@ function pkgForCurrentPlatform() { if (platformKey in knownPackages) { return knownPackages[platformKey]; } - throw new Error(`Unsupported platform: "${platformKey}". "@bytecode-alliance/wizer does not have a precompiled binary for the platform/architecture you are using. You can open an issue on https://github.com/bytecodealliance/wizer/issues to request for your platform/architecture to be included."`); + throw new Error(`Unsupported platform: "${platformKey}". "@bytecodealliance/wizer does not have a precompiled binary for the platform/architecture you are using. You can open an issue on https://github.com/bytecodealliance/wizer/issues to request for your platform/architecture to be included."`); } const pkg = pkgForCurrentPlatform(); @@ -25,10 +25,10 @@ try { // package should have been installed alongside this package at install time. location = (await import(pkg)).default; } catch (e) { - throw new Error(`The package "${pkg}" could not be found, and is needed by @bytecode-alliance/wizer. -If you are installing @bytecode-alliance/wizer with npm, make sure that you don't specify the + throw new Error(`The package "${pkg}" could not be found, and is needed by @bytecodealliance/wizer. +If you are installing @bytecodealliance/wizer with npm, make sure that you don't specify the "--no-optional" flag. The "optionalDependencies" package.json feature is used -by @bytecode-alliance/wizer to install the correct binary executable for your current platform.`); +by @bytecodealliance/wizer to install the correct binary executable for your current platform.`); } export default location; \ No newline at end of file diff --git a/crates/wizer/npm/wizer/wizer.js b/crates/wizer/npm/wizer/wizer.js index c791a8c870bc..46b9a9394cd8 100755 --- a/crates/wizer/npm/wizer/wizer.js +++ b/crates/wizer/npm/wizer/wizer.js @@ -3,10 +3,10 @@ import { endianness } from "node:os"; import { platform, arch } from "node:process"; import { execFileSync } from "node:child_process"; const knownPackages = { - "win32 x64 LE": "@bytecode-alliance/wizer-win32-x64", - "darwin arm64 LE": "@bytecode-alliance/wizer-darwin-arm64", - "darwin x64 LE": "@bytecode-alliance/wizer-darwin-x64", - "linux x64 LE": "@bytecode-alliance/wizer-linux-x64", + "win32 x64 LE": "@bytecodealliance/wizer-win32-x64", + "darwin arm64 LE": "@bytecodealliance/wizer-darwin-arm64", + "darwin x64 LE": "@bytecodealliance/wizer-darwin-x64", + "linux x64 LE": "@bytecodealliance/wizer-linux-x64", }; function pkgForCurrentPlatform() { @@ -15,7 +15,7 @@ function pkgForCurrentPlatform() { if (platformKey in knownPackages) { return knownPackages[platformKey]; } - throw new Error(`Unsupported platform: "${platformKey}". "@bytecode-alliance/wizer does not have a precompiled binary for the platform/architecture you are using. You can open an issue on https://github.com/bytecodealliance/wizer/issues to request for your platform/architecture to be included."`); + throw new Error(`Unsupported platform: "${platformKey}". "@bytecodealliance/wizer does not have a precompiled binary for the platform/architecture you are using. You can open an issue on https://github.com/bytecodealliance/wizer/issues to request for your platform/architecture to be included."`); } const pkg = pkgForCurrentPlatform(); @@ -26,10 +26,10 @@ try { // package should have been installed alongside this package at install time. location = (await import(pkg)).default; } catch (e) { - throw new Error(`The package "${pkg}" could not be found, and is needed by @bytecode-alliance/wizer. -If you are installing @bytecode-alliance/wizer with npm, make sure that you don't specify the + throw new Error(`The package "${pkg}" could not be found, and is needed by @bytecodealliance/wizer. +If you are installing @bytecodealliance/wizer with npm, make sure that you don't specify the "--no-optional" flag. The "optionalDependencies" package.json feature is used -by @bytecode-alliance/wizer to install the correct binary executable for your current platform.`); +by @bytecodealliance/wizer to install the correct binary executable for your current platform.`); } execFileSync(location, process.argv.slice(2), { stdio: "inherit" }); From 279a759246666daf6344af9c1d53a77b1a9f4b8e Mon Sep 17 00:00:00 2001 From: Jake Champion Date: Wed, 1 Mar 2023 13:37:02 +0000 Subject: [PATCH 127/212] 1.6.1-beta.4 --- crates/wizer/Cargo.lock | 2 +- crates/wizer/Cargo.toml | 2 +- crates/wizer/npm/wizer/package-lock.json | 12 ++++++------ crates/wizer/npm/wizer/package.json | 10 +++++----- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/crates/wizer/Cargo.lock b/crates/wizer/Cargo.lock index 8796c52dd0ee..25aec03b4a29 100644 --- a/crates/wizer/Cargo.lock +++ b/crates/wizer/Cargo.lock @@ -2071,7 +2071,7 @@ dependencies = [ [[package]] name = "wizer" -version = "1.6.1-beta.3" +version = "1.6.1-beta.4" dependencies = [ "anyhow", "cap-std", diff --git a/crates/wizer/Cargo.toml b/crates/wizer/Cargo.toml index 844d8c33dd5d..0322a553acee 100644 --- a/crates/wizer/Cargo.toml +++ b/crates/wizer/Cargo.toml @@ -10,7 +10,7 @@ license = "Apache-2.0 WITH LLVM-exception" name = "wizer" readme = "./README.md" repository = "https://github.com/bytecodealliance/wizer" -version = "1.6.1-beta.3" +version = "1.6.1-beta.4" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/crates/wizer/npm/wizer/package-lock.json b/crates/wizer/npm/wizer/package-lock.json index db1506357e82..43ae84be7d74 100644 --- a/crates/wizer/npm/wizer/package-lock.json +++ b/crates/wizer/npm/wizer/package-lock.json @@ -1,12 +1,12 @@ { "name": "@bytecodealliance/wizer", - "version": "1.6.1-beta.3", + "version": "1.6.1-beta.4", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@bytecodealliance/wizer", - "version": "1.6.1-beta.3", + "version": "1.6.1-beta.4", "license": "Apache-2.0", "bin": { "wizer": "wizer.js" @@ -21,10 +21,10 @@ "node": ">=16" }, "optionalDependencies": { - "@bytecodealliance/wizer-darwin-arm64": "1.6.1-beta.3", - "@bytecodealliance/wizer-darwin-x64": "1.6.1-beta.3", - "@bytecodealliance/wizer-linux-x64": "1.6.1-beta.3", - "@bytecodealliance/wizer-win32-x64": "1.6.1-beta.3" + "@bytecodealliance/wizer-darwin-arm64": "1.6.1-beta.4", + "@bytecodealliance/wizer-darwin-x64": "1.6.1-beta.4", + "@bytecodealliance/wizer-linux-x64": "1.6.1-beta.4", + "@bytecodealliance/wizer-win32-x64": "1.6.1-beta.4" } }, "node_modules/base64-js": { diff --git a/crates/wizer/npm/wizer/package.json b/crates/wizer/npm/wizer/package.json index f75603519642..0180b799f793 100644 --- a/crates/wizer/npm/wizer/package.json +++ b/crates/wizer/npm/wizer/package.json @@ -1,6 +1,6 @@ { "name": "@bytecodealliance/wizer", - "version": "1.6.1-beta.3", + "version": "1.6.1-beta.4", "description": "The WebAssembly Pre-Initializer", "type": "module", "scripts": { @@ -20,10 +20,10 @@ "wizer": "./wizer.js" }, "optionalDependencies": { - "@bytecodealliance/wizer-darwin-arm64": "1.6.1-beta.3", - "@bytecodealliance/wizer-darwin-x64": "1.6.1-beta.3", - "@bytecodealliance/wizer-linux-x64": "1.6.1-beta.3", - "@bytecodealliance/wizer-win32-x64": "1.6.1-beta.3" + "@bytecodealliance/wizer-darwin-arm64": "1.6.1-beta.4", + "@bytecodealliance/wizer-darwin-x64": "1.6.1-beta.4", + "@bytecodealliance/wizer-linux-x64": "1.6.1-beta.4", + "@bytecodealliance/wizer-win32-x64": "1.6.1-beta.4" }, "license": "Apache-2.0", "repository": { From d3d14e5f0e972d51e05a3203897959a93eb0a671 Mon Sep 17 00:00:00 2001 From: Cheng Shao Date: Tue, 28 Mar 2023 16:11:16 +0000 Subject: [PATCH 128/212] feat: Add option to enable the Wasm SIMD128 feature This commit adds a --wasm-simd option to enable the Wasm SIMD128 feature. It's on by default. --- crates/wizer/src/lib.rs | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/crates/wizer/src/lib.rs b/crates/wizer/src/lib.rs index c629f33866a1..5423fd5f63e7 100644 --- a/crates/wizer/src/lib.rs +++ b/crates/wizer/src/lib.rs @@ -35,6 +35,7 @@ const DEFAULT_WASM_MULTI_VALUE: bool = true; const DEFAULT_WASM_MULTI_MEMORY: bool = true; const DEFAULT_WASM_MODULE_LINKING: bool = false; const DEFAULT_WASM_BULK_MEMORY: bool = false; +const DEFAULT_WASM_SIMD: bool = true; /// We only ever use `Store` with a fixed `T` that is our optional WASI /// context. @@ -209,6 +210,12 @@ pub struct Wizer { /// Disabled by default. #[cfg_attr(feature = "structopt", structopt(long, value_name = "true|false"))] wasm_bulk_memory: Option, + + /// Enable or disable the Wasm SIMD128 proposal. + /// + /// Enabled by default. + #[cfg_attr(feature = "structopt", structopt(long, value_name = "true|false"))] + wasm_simd: Option, } impl std::fmt::Debug for Wizer { @@ -227,6 +234,7 @@ impl std::fmt::Debug for Wizer { wasm_multi_value, wasm_module_linking, wasm_bulk_memory, + wasm_simd, } = self; f.debug_struct("Wizer") .field("init_func", &init_func) @@ -242,6 +250,7 @@ impl std::fmt::Debug for Wizer { .field("wasm_multi_value", &wasm_multi_value) .field("wasm_module_linking", &wasm_module_linking) .field("wasm_bulk_memory", &wasm_bulk_memory) + .field("wasm_simd", &wasm_simd) .finish() } } @@ -304,6 +313,7 @@ impl Wizer { wasm_multi_value: None, wasm_module_linking: None, wasm_bulk_memory: None, + wasm_simd: None, } } @@ -455,6 +465,14 @@ impl Wizer { self } + /// Enable or disable the Wasm SIMD128 proposal. + /// + /// Defaults to `true`. + pub fn wasm_simd(&mut self, enable: bool) -> &mut Self { + self.wasm_simd = Some(enable); + self + } + /// Initialize the given Wasm, snapshot it, and return the serialized /// snapshot as a new, pre-initialized Wasm module. pub fn run(&self, wasm: &[u8]) -> anyhow::Result> { @@ -533,9 +551,10 @@ impl Wizer { // `memory.init` for the time being: config.wasm_bulk_memory(self.wasm_bulk_memory.unwrap_or(DEFAULT_WASM_BULK_MEMORY)); + config.wasm_simd(self.wasm_simd.unwrap_or(DEFAULT_WASM_SIMD)); + // Proposals that we should add support for. config.wasm_reference_types(false); - config.wasm_simd(false); config.wasm_threads(false); Ok(config) @@ -553,7 +572,7 @@ impl Wizer { // Proposals that we should add support for. reference_types: false, - simd: false, + simd: self.wasm_simd.unwrap_or(DEFAULT_WASM_SIMD), threads: false, tail_call: false, memory64: false, From 6764a79f57b648bd38ac8cccf4eced4866f4900f Mon Sep 17 00:00:00 2001 From: Cheng Shao Date: Tue, 28 Mar 2023 17:31:17 +0000 Subject: [PATCH 129/212] feat: SIMD128 support This patch actually implements SIMD128 support, and also adds a test case. --- crates/wizer/fuzz/fuzz_targets/same_result.rs | 1 + crates/wizer/src/rewrite.rs | 4 ++++ crates/wizer/src/translate.rs | 3 ++- crates/wizer/tests/tests.rs | 20 +++++++++++++++++++ 4 files changed, 27 insertions(+), 1 deletion(-) diff --git a/crates/wizer/fuzz/fuzz_targets/same_result.rs b/crates/wizer/fuzz/fuzz_targets/same_result.rs index f943136764b0..2b7feeb85bb8 100644 --- a/crates/wizer/fuzz/fuzz_targets/same_result.rs +++ b/crates/wizer/fuzz/fuzz_targets/same_result.rs @@ -186,6 +186,7 @@ fn assert_val_eq(a: &Val, b: &Val) { let b = f64::from_bits(*b); a == b || (a.is_nan() && b.is_nan()) }), + (Val::V128(a), Val::V128(b)) => assert_eq!(a, b), _ => panic!("{:?} != {:?}", a, b), } } diff --git a/crates/wizer/src/rewrite.rs b/crates/wizer/src/rewrite.rs index 9c60ce6ee973..7b9dd1cfb34f 100644 --- a/crates/wizer/src/rewrite.rs +++ b/crates/wizer/src/rewrite.rs @@ -124,6 +124,9 @@ impl Wizer { wasmtime::Val::F64(x) => { wasm_encoder::Instruction::F64Const(f64::from_bits(*x)) } + wasmtime::Val::V128(x) => { + wasm_encoder::Instruction::V128Const(*x as i128) + } _ => unreachable!(), }, ); @@ -1095,6 +1098,7 @@ fn rewrite_state_module( wasmtime::Val::F64(x) => { wasm_encoder::Instruction::F64Const(f64::from_bits(*x)) } + wasmtime::Val::V128(x) => wasm_encoder::Instruction::V128Const(*x as i128), _ => unreachable!(), }, ); diff --git a/crates/wizer/src/translate.rs b/crates/wizer/src/translate.rs index 2e17ee2f22b6..7ff9b837a588 100644 --- a/crates/wizer/src/translate.rs +++ b/crates/wizer/src/translate.rs @@ -16,8 +16,9 @@ pub(crate) fn val_type(ty: wasmparser::Type) -> wasm_encoder::ValType { I64 => ValType::I64, F32 => ValType::F32, F64 => ValType::F64, + V128 => ValType::V128, FuncRef => ValType::FuncRef, - V128 | ExternRef | ExnRef => panic!("not supported"), + ExternRef | ExnRef => panic!("not supported"), Func | EmptyBlockType => unreachable!(), } } diff --git a/crates/wizer/tests/tests.rs b/crates/wizer/tests/tests.rs index 86dc97a08bc9..7e172de5173c 100644 --- a/crates/wizer/tests/tests.rs +++ b/crates/wizer/tests/tests.rs @@ -1257,3 +1257,23 @@ fn accept_bulk_memory_init() -> Result<()> { "#, ) } + +#[test] +fn accept_simd128() -> Result<()> { + run_wat( + &[], + 49, + r#" + (module + (global $g (mut v128) (v128.const i32x4 2 3 5 7)) + (func (export "wizer.initialize") + global.get $g + global.get $g + i32x4.mul + global.set $g) + (func (export "run") (result i32) + global.get $g + i32x4.extract_lane 3)) + "#, + ) +} From e1c1161d31f7473a3fa6a88e141926f35e5b1816 Mon Sep 17 00:00:00 2001 From: Jake Champion Date: Wed, 4 Jan 2023 17:35:19 +0000 Subject: [PATCH 130/212] update to wasmtime 0.38.0 wasmtime 0.36.0 removed it's module linking implementation to make room for the upcoming support for the component model. https://github.com/bytecodealliance/wasmtime/pull/3958 This commit removes all the module linking functionality from wizer and updates to wasmtime 0.38.0 --- crates/wizer/Cargo.lock | 272 +++++--- crates/wizer/Cargo.toml | 6 +- crates/wizer/fuzz/Cargo.toml | 2 +- crates/wizer/fuzz/fuzz_targets/same_result.rs | 6 +- crates/wizer/src/dummy.rs | 307 +-------- crates/wizer/src/lib.rs | 4 - crates/wizer/src/snapshot.rs | 5 +- crates/wizer/tests/make_linker.rs | 1 - crates/wizer/tests/tests.rs | 645 +----------------- 9 files changed, 192 insertions(+), 1056 deletions(-) diff --git a/crates/wizer/Cargo.lock b/crates/wizer/Cargo.lock index 25aec03b4a29..d0f95043451e 100644 --- a/crates/wizer/Cargo.lock +++ b/crates/wizer/Cargo.lock @@ -26,6 +26,17 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +[[package]] +name = "ahash" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" +dependencies = [ + "getrandom", + "once_cell", + "version_check", +] + [[package]] name = "aho-corasick" version = "0.7.18" @@ -52,9 +63,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.44" +version = "1.0.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61604a8f862e1d5c3229fdd78f8b02c68dcf73a4c4b05fd636d12240aaa242c1" +checksum = "2cb2f989d18dd141ab8ae82f64d1a8cdd37e0840f73a406896cf5e99502fab61" [[package]] name = "arbitrary" @@ -156,6 +167,12 @@ version = "3.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9df67f7bf9ef8498769f994239c45613ef0c5899415fb58e9add412d2c1a538" +[[package]] +name = "byteorder" +version = "1.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" + [[package]] name = "cap-fs-ext" version = "0.24.1" @@ -281,59 +298,60 @@ dependencies = [ [[package]] name = "cranelift-bforest" -version = "0.82.3" +version = "0.85.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38faa2a16616c8e78a18d37b4726b98bfd2de192f2fdc8a39ddf568a408a0f75" +checksum = "749d0d6022c9038dccf480bdde2a38d435937335bf2bb0f14e815d94517cdce8" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-codegen" -version = "0.82.3" +version = "0.85.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26f192472a3ba23860afd07d2b0217dc628f21fcc72617aa1336d98e1671f33b" +checksum = "e94370cc7b37bf652ccd8bb8f09bd900997f7ccf97520edfc75554bb5c4abbea" dependencies = [ "cranelift-bforest", "cranelift-codegen-meta", "cranelift-codegen-shared", "cranelift-entity", + "cranelift-isle", "gimli 0.26.1", "log", - "regalloc", + "regalloc2", "smallvec", "target-lexicon", ] [[package]] name = "cranelift-codegen-meta" -version = "0.82.3" +version = "0.85.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f32ddb89e9b89d3d9b36a5b7d7ea3261c98235a76ac95ba46826b8ec40b1a24" +checksum = "e0a3cea8fdab90e44018c5b9a1dfd460d8ee265ac354337150222a354628bdb6" dependencies = [ "cranelift-codegen-shared", ] [[package]] name = "cranelift-codegen-shared" -version = "0.82.3" +version = "0.85.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01fd0d9f288cc1b42d9333b7a776b17e278fc888c28e6a0f09b5573d45a150bc" +checksum = "5ac72f76f2698598951ab26d8c96eaa854810e693e7dd52523958b5909fde6b2" [[package]] name = "cranelift-entity" -version = "0.82.3" +version = "0.85.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e3bfe172b83167604601faf9dc60453e0d0a93415b57a9c4d1a7ae6849185cf" +checksum = "09eaeacfcd2356fe0e66b295e8f9d59fdd1ac3ace53ba50de14d628ec902f72d" dependencies = [ "serde", ] [[package]] name = "cranelift-frontend" -version = "0.82.3" +version = "0.85.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a006e3e32d80ce0e4ba7f1f9ddf66066d052a8c884a110b91d05404d6ce26dce" +checksum = "dba69c9980d5ffd62c18a2bde927855fcd7c8dc92f29feaf8636052662cbd99c" dependencies = [ "cranelift-codegen", "log", @@ -341,11 +359,17 @@ dependencies = [ "target-lexicon", ] +[[package]] +name = "cranelift-isle" +version = "0.85.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2920dc1e05cac40304456ed3301fde2c09bd6a9b0210bcfa2f101398d628d5b" + [[package]] name = "cranelift-native" -version = "0.82.3" +version = "0.85.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "501241b0cdf903412ec9075385ac9f2b1eb18a89044d1538e97fab603231f70c" +checksum = "f04dfa45f9b2a6f587c564d6b63388e00cd6589d2df6ea2758cf79e1a13285e6" dependencies = [ "cranelift-codegen", "libc", @@ -354,9 +378,9 @@ dependencies = [ [[package]] name = "cranelift-wasm" -version = "0.82.3" +version = "0.85.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16d9e4211bbc3268042a96dd4de5bd979cda22434991d035f5f8eacba987fad2" +checksum = "31a46513ae6f26f3f267d8d75b5373d555fbbd1e68681f348d99df43f747ec54" dependencies = [ "cranelift-codegen", "cranelift-entity", @@ -364,7 +388,7 @@ dependencies = [ "itertools", "log", "smallvec", - "wasmparser 0.83.0", + "wasmparser 0.85.0", "wasmtime-types", ] @@ -616,6 +640,15 @@ dependencies = [ "winapi", ] +[[package]] +name = "fxhash" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c" +dependencies = [ + "byteorder", +] + [[package]] name = "gcc" version = "0.3.55" @@ -671,6 +704,15 @@ name = "hashbrown" version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" +dependencies = [ + "ahash", +] + +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" [[package]] name = "heck" @@ -681,6 +723,12 @@ dependencies = [ "unicode-segmentation", ] +[[package]] +name = "heck" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9" + [[package]] name = "hermit-abi" version = "0.1.19" @@ -716,12 +764,12 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "indexmap" -version = "1.7.0" +version = "1.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc633605454125dec4b66843673f01c7df2b89479b32e0ed634e43a91cff62a5" +checksum = "1885e79c1fc4b10f0e172c475f458b7f7b93061064d98c3293e98c5ba0c8b399" dependencies = [ "autocfg", - "hashbrown", + "hashbrown 0.12.3", "serde", ] @@ -825,9 +873,9 @@ checksum = "3576a87f2ba00f6f106fdfcd16db1d698d648a26ad8e0573cad8537c3c362d2a" [[package]] name = "libc" -version = "0.2.115" +version = "0.2.139" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a8d982fa7a96a000f6ec4cfe966de9703eccde29750df2bb8949da91b0e818d" +checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" [[package]] name = "libfuzzer-sys" @@ -848,15 +896,15 @@ checksum = "7fb9b38af92608140b86b693604b9ffcc5824240a484d1ecd4795bacb2fe88f3" [[package]] name = "linux-raw-sys" -version = "0.0.40" +version = "0.0.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bdc16c6ce4c85d9b46b4e66f2a814be5b3f034dbd5131c268a24ca26d970db8" +checksum = "5284f00d480e1c39af34e72f8ad60b94f47007e3481cd3b731c1d67190ddc7b7" [[package]] name = "log" -version = "0.4.14" +version = "0.4.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" +checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" dependencies = [ "cfg-if", ] @@ -946,20 +994,21 @@ dependencies = [ [[package]] name = "object" -version = "0.27.1" +version = "0.28.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67ac1d3f9a1d3616fd9a60c8d74296f22406a238b6a72f5cc1e6f314df4ffbf9" +checksum = "e42c982f2d955fac81dd7e1d0e1426a7d702acd9c98d19ab01083a6a0328c424" dependencies = [ "crc32fast", + "hashbrown 0.11.2", "indexmap", "memchr", ] [[package]] name = "once_cell" -version = "1.9.0" +version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da32515d9f6e6e489d7bc9d84c71b060db7247dc035bbe44eac88cf87486d8d5" +checksum = "6f61fba1741ea2b3d6a1e3178721804bb716a68a6aeba1149b5d52e3d464ea66" [[package]] name = "oorandom" @@ -1161,13 +1210,14 @@ dependencies = [ ] [[package]] -name = "regalloc" -version = "0.0.34" +name = "regalloc2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62446b1d3ebf980bdc68837700af1d77b37bc430e524bf95319c6eada2a4cc02" +checksum = "4a8d23b35d7177df3b9d31ed8a9ab4bf625c668be77a319d4f5efd4a5257701c" dependencies = [ + "fxhash", "log", - "rustc-hash", + "slice-group-by", "smallvec", ] @@ -1226,12 +1276,6 @@ version = "0.1.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342" -[[package]] -name = "rustc-hash" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" - [[package]] name = "rustc_version" version = "0.4.0" @@ -1243,9 +1287,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.33.2" +version = "0.33.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db890a96e64911e67fa84e58ce061a40a6a65c231e5fad20b190933f8991a27c" +checksum = "938a344304321a9da4973b9ff4f9f8db9caf4597dfd9dda6a60b523340a0fff0" dependencies = [ "bitflags", "errno", @@ -1339,9 +1383,9 @@ dependencies = [ [[package]] name = "sha2" -version = "0.9.8" +version = "0.9.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b69f9a4c9740d74c5baa3fd2e547f9525fa8088a8a958e0ca2409a514e33f5fa" +checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" dependencies = [ "block-buffer", "cfg-if", @@ -1359,6 +1403,12 @@ dependencies = [ "dirs-next", ] +[[package]] +name = "slice-group-by" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03b634d87b960ab1a38c4fe143b508576f075e7c978bfad18217645ebfdfa2ec" + [[package]] name = "smallvec" version = "1.6.1" @@ -1394,7 +1444,7 @@ version = "0.4.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "134d838a2c9943ac3125cf6df165eda53493451b719f3255b2a26b85f772d0ba" dependencies = [ - "heck", + "heck 0.3.3", "proc-macro-error", "proc-macro2", "quote", @@ -1430,9 +1480,9 @@ dependencies = [ [[package]] name = "target-lexicon" -version = "0.12.2" +version = "0.12.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9bffcddbc2458fa3e6058414599e3c838a022abae82e5c67b4f7f80298d5bff" +checksum = "9410d0f6853b1d94f0e519fb95df60f29d2c1eff2d921ffdf01a4c8a3b54f12d" [[package]] name = "termcolor" @@ -1588,9 +1638,9 @@ checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" [[package]] name = "wasi-cap-std-sync" -version = "0.35.3" +version = "0.38.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9120fdc492d9d95cd7278b34f46fe9122962e4b2476c040f058971ccc00fc4d2" +checksum = "f086c5026d2fc3b268d138e65373f46422cc810f46d6e0776859c5027cb18728" dependencies = [ "anyhow", "async-trait", @@ -1612,14 +1662,15 @@ dependencies = [ [[package]] name = "wasi-common" -version = "0.35.3" +version = "0.38.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab6097a5c8e9a791227a50945b6a891da6d93f518ebfa8716f231dc03f119585" +checksum = "4e8844fede1c3787cc08853872f47e8bd91f6c939c7406bc7a5dba496b260c08" dependencies = [ "anyhow", "bitflags", "cap-rand", "cap-std", + "io-extras", "rustix", "thiserror", "tracing", @@ -1699,6 +1750,15 @@ dependencies = [ "leb128", ] +[[package]] +name = "wasm-encoder" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05632e0a66a6ed8cca593c24223aabd6262f256c3693ad9822c315285f010614" +dependencies = [ + "leb128", +] + [[package]] name = "wasm-smith" version = "0.4.5" @@ -1725,9 +1785,12 @@ checksum = "be92b6dcaa5af4b2a176b29be3bf1402fab9e69d313141185099c7d1684f2dca" [[package]] name = "wasmparser" -version = "0.83.0" +version = "0.85.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "718ed7c55c2add6548cca3ddd6383d738cd73b892df400e96b9aa876f0141d7a" +checksum = "570460c58b21e9150d2df0eaaedbb7816c34bcec009ae0dcc976e40ba81463e7" +dependencies = [ + "indexmap", +] [[package]] name = "wasmprinter" @@ -1741,9 +1804,9 @@ dependencies = [ [[package]] name = "wasmtime" -version = "0.35.3" +version = "0.38.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21ffb4705016d5ca91e18a72ed6822dab50e6d5ddd7045461b17ef19071cdef1" +checksum = "1f50eadf868ab6a04b7b511460233377d0bfbb92e417b2f6a98b98fef2e098f5" dependencies = [ "anyhow", "async-trait", @@ -1754,7 +1817,7 @@ dependencies = [ "lazy_static", "libc", "log", - "object 0.27.1", + "object 0.28.4", "once_cell", "paste", "psm", @@ -1762,7 +1825,7 @@ dependencies = [ "region", "serde", "target-lexicon", - "wasmparser 0.83.0", + "wasmparser 0.85.0", "wasmtime-cache", "wasmtime-cranelift", "wasmtime-environ", @@ -1775,9 +1838,9 @@ dependencies = [ [[package]] name = "wasmtime-cache" -version = "0.35.3" +version = "0.38.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85c6ab24291fa7cb3a181f5669f6c72599b7ef781669759b45c7828c5999d0c0" +checksum = "d1df23c642e1376892f3b72f311596976979cbf8b85469680cdd3a8a063d12a2" dependencies = [ "anyhow", "base64", @@ -1795,9 +1858,9 @@ dependencies = [ [[package]] name = "wasmtime-cranelift" -version = "0.35.3" +version = "0.38.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f04c810078a491b7bc4866ebe045f714d2b95e6b539e1f64009a4a7606be11de" +checksum = "f264ff6b4df247d15584f2f53d009fbc90032cfdc2605b52b961bffc71b6eccd" dependencies = [ "anyhow", "cranelift-codegen", @@ -1808,18 +1871,18 @@ dependencies = [ "gimli 0.26.1", "log", "more-asserts", - "object 0.27.1", + "object 0.28.4", "target-lexicon", "thiserror", - "wasmparser 0.83.0", + "wasmparser 0.85.0", "wasmtime-environ", ] [[package]] name = "wasmtime-environ" -version = "0.35.3" +version = "0.38.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61448266ea164b1ac406363cdcfac81c7c44db4d94c7a81c8620ac6c5c6cdf59" +checksum = "839d2820e4b830f4b9e7aa08d4c0acabf4a5036105d639f6dfa1c6891c73bdc6" dependencies = [ "anyhow", "cranelift-entity", @@ -1827,19 +1890,19 @@ dependencies = [ "indexmap", "log", "more-asserts", - "object 0.27.1", + "object 0.28.4", "serde", "target-lexicon", "thiserror", - "wasmparser 0.83.0", + "wasmparser 0.85.0", "wasmtime-types", ] [[package]] name = "wasmtime-fiber" -version = "0.35.3" +version = "0.38.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbaaa38c3b48822ab27044e1d4a25a1052157de4c8f27574cb00167e127e320f" +checksum = "3248be3c4911233535356025f6562193614a40155ee9094bb6a2b43f0dc82803" dependencies = [ "cc", "rustix", @@ -1848,9 +1911,9 @@ dependencies = [ [[package]] name = "wasmtime-jit" -version = "0.35.3" +version = "0.38.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "156b4623c6b0d4b8c24afb846c20525922f538ef464cc024abab7ea8de2109a2" +checksum = "ef0a0bcbfa18b946d890078ba0e1bc76bcc53eccfb40806c0020ec29dcd1bd49" dependencies = [ "addr2line 0.17.0", "anyhow", @@ -1860,7 +1923,7 @@ dependencies = [ "gimli 0.26.1", "ittapi-rs", "log", - "object 0.27.1", + "object 0.28.4", "region", "rustc-demangle", "rustix", @@ -1875,20 +1938,20 @@ dependencies = [ [[package]] name = "wasmtime-jit-debug" -version = "0.35.3" +version = "0.38.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5dc31f811760a6c76b2672c404866fd19b75e5fb3b0075a3e377a6846490654" +checksum = "4f4779d976206c458edd643d1ac622b6c37e4a0800a8b1d25dfbf245ac2f2cac" dependencies = [ "lazy_static", - "object 0.27.1", + "object 0.28.4", "rustix", ] [[package]] name = "wasmtime-runtime" -version = "0.35.3" +version = "0.38.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f907beaff69d4d920fa4688411ee4cc75c0f01859e424677f9e426e2ef749864" +checksum = "b7eb6ffa169eb5dcd18ac9473c817358cd57bc62c244622210566d473397954a" dependencies = [ "anyhow", "backtrace", @@ -1913,21 +1976,21 @@ dependencies = [ [[package]] name = "wasmtime-types" -version = "0.35.3" +version = "0.38.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "514ef0e5fd197b9609dc9eb74beba0c84d5a12b2417cbae55534633329ba4852" +checksum = "8d932b0ac5336f7308d869703dd225610a6a3aeaa8e968c52b43eed96cefb1c2" dependencies = [ "cranelift-entity", "serde", "thiserror", - "wasmparser 0.83.0", + "wasmparser 0.85.0", ] [[package]] name = "wasmtime-wasi" -version = "0.35.3" +version = "0.38.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f0633261ad13d93ae84c758ce195c659a0ee57fcdbe724c8976f4b1872cdcde" +checksum = "b68b7d77fb6f2975a6fe6cc4d0015d6b0cebb65c39fce1dd4cc00880dbf7789c" dependencies = [ "anyhow", "wasi-cap-std-sync", @@ -1947,20 +2010,23 @@ dependencies = [ [[package]] name = "wast" -version = "38.0.0" +version = "50.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ebc29df4629f497e0893aacd40f13a4a56b85ef6eb4ab6d603f07244f1a7bf2" +checksum = "a2cbb59d4ac799842791fe7e806fa5dbbf6b5554d538e51cc8e176db6ff0ae34" dependencies = [ "leb128", + "memchr", + "unicode-width", + "wasm-encoder 0.20.0", ] [[package]] name = "wat" -version = "1.0.40" +version = "1.0.52" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adcfaeb27e2578d2c6271a45609f4a055e6d7ba3a12eff35b1fd5ba147bdf046" +checksum = "584aaf7a1ecf4d383bbe1a25eeab0cbb8ff96acc6796707ff65cde48f4632f15" dependencies = [ - "wast 38.0.0", + "wast 50.0.0", ] [[package]] @@ -1975,9 +2041,9 @@ dependencies = [ [[package]] name = "wiggle" -version = "0.35.3" +version = "0.38.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36fb71c833bf174b1b34979942ff33f525b97311232ef6a0a18bcdf540ae9c91" +checksum = "67dadac11343d2aabc8a906a0db0aaf7cb5046ec3d6fffccdaf2847dccdef8d6" dependencies = [ "anyhow", "async-trait", @@ -1990,12 +2056,12 @@ dependencies = [ [[package]] name = "wiggle-generate" -version = "0.35.3" +version = "0.38.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52d684c4454e953df20b5a1c3e0a8d208ef4d5a768e013f64bebfc9f74a3f739" +checksum = "63a1dccd6b3fbd9a27417f5d30ce9aa3ee9cf529aad453abbf88a49c5d605b79" dependencies = [ "anyhow", - "heck", + "heck 0.4.0", "proc-macro2", "quote", "shellexpand", @@ -2005,9 +2071,9 @@ dependencies = [ [[package]] name = "wiggle-macro" -version = "0.35.3" +version = "0.38.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1da6c96c93eced4bf71e59ca1f06f933b84f37544a354646e37c0e5c6d5a262d" +checksum = "f1c368d57d9560c34deaa67e06b0953ccf65edb906c525e5a2c866c849b48ec2" dependencies = [ "proc-macro2", "quote", @@ -2113,18 +2179,18 @@ dependencies = [ [[package]] name = "zstd" -version = "0.10.0+zstd.1.5.2" +version = "0.11.2+zstd.1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b1365becbe415f3f0fcd024e2f7b45bacfb5bdd055f0dc113571394114e7bdd" +checksum = "20cc960326ece64f010d2d2107537f26dc589a6573a316bd5b1dba685fa5fde4" dependencies = [ "zstd-safe", ] [[package]] name = "zstd-safe" -version = "4.1.4+zstd.1.5.2" +version = "5.0.2+zstd.1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f7cd17c9af1a4d6c24beb1cc54b17e2ef7b593dc92f19e9d9acad8b182bbaee" +checksum = "1d2a5585e04f9eea4b2a3d1eca508c4dee9592a89ef6f450c11719da0726f4db" dependencies = [ "libc", "zstd-sys", @@ -2132,9 +2198,9 @@ dependencies = [ [[package]] name = "zstd-sys" -version = "1.6.3+zstd.1.5.2" +version = "2.0.4+zstd.1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc49afa5c8d634e75761feda8c592051e7eeb4683ba827211eb0d731d3402ea8" +checksum = "4fa202f2ef00074143e219d15b62ffc317d17cc33909feac471c044087cad7b0" dependencies = [ "cc", "libc", diff --git a/crates/wizer/Cargo.toml b/crates/wizer/Cargo.toml index 0322a553acee..e4c58e3f9b20 100644 --- a/crates/wizer/Cargo.toml +++ b/crates/wizer/Cargo.toml @@ -33,11 +33,11 @@ env_logger = { version = "0.8.2", optional = true } log = "0.4.14" rayon = "1.5.0" structopt = { version = "0.3.21", optional = true } -wasi-cap-std-sync = "0.35.3" +wasi-cap-std-sync = "0.38.0" wasm-encoder = "0.6.0" wasmparser = "0.78.2" -wasmtime = "0.35.3" -wasmtime-wasi = "0.35.3" +wasmtime = "0.38.0" +wasmtime-wasi = "0.38.0" # Enable this dependency to get messages with WAT disassemblies when certain # internal panics occur. diff --git a/crates/wizer/fuzz/Cargo.toml b/crates/wizer/fuzz/Cargo.toml index 4f8b36adee97..a6d280ce7b8c 100644 --- a/crates/wizer/fuzz/Cargo.toml +++ b/crates/wizer/fuzz/Cargo.toml @@ -15,7 +15,7 @@ libfuzzer-sys = "0.4" log = "0.4.14" wasm-smith = "0.4.0" wasmprinter = "0.2.26" -wasmtime = "0.35.3" +wasmtime = "0.38.0" [dependencies.wizer] path = ".." diff --git a/crates/wizer/fuzz/fuzz_targets/same_result.rs b/crates/wizer/fuzz/fuzz_targets/same_result.rs index 2b7feeb85bb8..b069bdb7fb91 100644 --- a/crates/wizer/fuzz/fuzz_targets/same_result.rs +++ b/crates/wizer/fuzz/fuzz_targets/same_result.rs @@ -38,7 +38,6 @@ fuzz_target!(|module: wasm_smith::ConfiguredModule| { let mut config = Config::new(); config.cache_config_load_default().unwrap(); - config.wasm_module_linking(true); config.wasm_multi_memory(true); config.wasm_multi_value(true); @@ -162,10 +161,7 @@ fuzz_target!(|module: wasm_smith::ConfiguredModule| { panic!("divergence between snapshot and non-snapshot memories"); } } - Extern::Instance(_) - | Extern::Func(_) - | Extern::Table(_) - | Extern::Module(_) => continue, + Extern::SharedMemory(_) | Extern::Func(_) | Extern::Table(_) => continue, } } } diff --git a/crates/wizer/src/dummy.rs b/crates/wizer/src/dummy.rs index 0ccc1c73d0cb..0a6500a878e4 100644 --- a/crates/wizer/src/dummy.rs +++ b/crates/wizer/src/dummy.rs @@ -3,7 +3,6 @@ //! Forked from `wasmtime/crates/fuzzing/src/oracles/dummy.rs`. use anyhow::Result; -use std::fmt::Write; use wasmtime::*; /// Create dummy imports for instantiating the module. @@ -15,60 +14,23 @@ pub fn dummy_imports( log::debug!("Creating dummy imports"); for imp in module.imports() { - match imp.name() { - Some(name) => { - if linker.get(&mut *store, imp.module(), Some(name)).is_some() { - // Already defined, must be part of WASI. - continue; - } - - linker - .define( - imp.module(), - name, - dummy_extern( - &mut *store, - imp.ty(), - &format!("'{}' '{}'", imp.module(), name), - )?, - ) - .unwrap(); - } - None => match imp.ty() { - wasmtime::ExternType::Instance(ty) => { - for ty in ty.exports() { - if linker - .get(&mut *store, imp.module(), Some(ty.name())) - .is_some() - { - // Already defined, must be part of WASI. - continue; - } - - linker - .define( - imp.module(), - ty.name(), - dummy_extern(&mut *store, ty.ty(), &format!("'{}'", imp.module()))?, - ) - .unwrap(); - } - } - other => { - if linker.get(&mut *store, imp.module(), None).is_some() { - // Already defined, must be part of WASI. - continue; - } - - linker - .define_name( - imp.module(), - dummy_extern(&mut *store, other, &format!("'{}'", imp.module()))?, - ) - .unwrap(); - } - }, + let name = imp.name(); + if linker.get(&mut *store, imp.module(), name).is_some() { + // Already defined, must be part of WASI. + continue; } + + linker + .define( + imp.module(), + name, + dummy_extern( + &mut *store, + imp.ty(), + &format!("'{}' '{}'", imp.module(), name), + )?, + ) + .unwrap(); } Ok(()) @@ -78,9 +40,6 @@ pub fn dummy_imports( pub fn dummy_extern(store: &mut crate::Store, ty: ExternType, name: &str) -> Result { Ok(match ty { ExternType::Func(func_ty) => Extern::Func(dummy_func(store, func_ty, name)), - ExternType::Instance(instance_ty) => { - Extern::Instance(dummy_instance(store, instance_ty, name)?) - } ExternType::Global(_) => { anyhow::bail!("Error: attempted to import unknown global: {}", name) } @@ -88,9 +47,6 @@ pub fn dummy_extern(store: &mut crate::Store, ty: ExternType, name: &str) -> Res ExternType::Memory(_) => { anyhow::bail!("Error: attempted to import unknown memory: {}", name) } - ExternType::Module(_) => { - anyhow::bail!("Error: attempted to import unknown module: {}", name) - } }) } @@ -126,234 +82,3 @@ pub fn dummy_value(val_ty: ValType) -> Val { pub fn dummy_values(val_tys: impl IntoIterator) -> Vec { val_tys.into_iter().map(dummy_value).collect() } - -/// Construct a dummy instance for the given instance type. -/// -/// This is done by using the expected type to generate a module on-the-fly -/// which we the instantiate. -pub fn dummy_instance(store: &mut crate::Store, ty: InstanceType, name: &str) -> Result { - let mut wat = WatGenerator::new(); - for ty in ty.exports() { - wat.export(&ty, name)?; - } - let module = Module::new(store.engine(), &wat.finish()).unwrap(); - Ok(Instance::new(store, &module, &[])?) -} - -struct WatGenerator { - tmp: usize, - dst: String, -} - -impl WatGenerator { - fn new() -> WatGenerator { - WatGenerator { - tmp: 0, - dst: String::from("(module\n"), - } - } - - fn finish(mut self) -> String { - self.dst.push_str(")\n"); - self.dst - } - - fn export(&mut self, ty: &ExportType<'_>, instance_name: &str) -> Result<()> { - let wat_name = format!("item{}", self.tmp); - self.tmp += 1; - let item_ty = ty.ty(); - self.item(&wat_name, &item_ty, instance_name, ty.name())?; - - write!(self.dst, "(export ").unwrap(); - self.str(ty.name()); - write!(self.dst, " (").unwrap(); - match item_ty { - ExternType::Func(_) => write!(self.dst, "func").unwrap(), - ExternType::Instance(_) => write!(self.dst, "instance").unwrap(), - ExternType::Memory(_) => anyhow::bail!( - "Error: attempted to import unknown memory: '{}' '{}'", - instance_name, - ty.name() - ), - ExternType::Global(_) => anyhow::bail!( - "Error: attempted to import unknown global: '{}' '{}'", - instance_name, - ty.name() - ), - ExternType::Table(_) => anyhow::bail!( - "Error: attempted to import unknown table: '{}' '{}'", - instance_name, - ty.name() - ), - ExternType::Module(_) => anyhow::bail!( - "Error: attempted to import unknown module: '{}' '{}'", - instance_name, - ty.name() - ), - } - writeln!(self.dst, " ${}))", wat_name).unwrap(); - Ok(()) - } - - fn item( - &mut self, - name: &str, - ty: &ExternType, - instance_name: &str, - item_name: &str, - ) -> Result<()> { - match ty { - ExternType::Func(ty) => { - write!(self.dst, "(func ${} ", name).unwrap(); - self.func_sig(ty); - for ty in ty.results() { - writeln!(self.dst, "").unwrap(); - self.value(&ty); - } - writeln!(self.dst, ")").unwrap(); - } - ExternType::Instance(ty) => { - writeln!(self.dst, "(module ${}_module", name).unwrap(); - for ty in ty.exports() { - self.export(&ty, instance_name)?; - } - self.dst.push_str(")\n"); - writeln!(self.dst, "(instance ${} (instantiate ${0}_module))", name).unwrap(); - } - ExternType::Memory(_) => anyhow::bail!( - "Error: attempted to import unknown memory: '{}' '{}'", - instance_name, - item_name - ), - ExternType::Global(_) => anyhow::bail!( - "Error: attempted to import unknown global: '{}' '{}'", - instance_name, - item_name - ), - ExternType::Table(_) => anyhow::bail!( - "Error: attempted to import unknown table: '{}' '{}'", - instance_name, - item_name - ), - ExternType::Module(_) => anyhow::bail!( - "Error: attempted to import unknown module: '{}' '{}'", - instance_name, - item_name - ), - } - Ok(()) - } - - fn func_sig(&mut self, ty: &FuncType) { - write!(self.dst, "(param ").unwrap(); - for ty in ty.params() { - write!(self.dst, "{} ", wat_ty(&ty)).unwrap(); - } - write!(self.dst, ") (result ").unwrap(); - for ty in ty.results() { - write!(self.dst, "{} ", wat_ty(&ty)).unwrap(); - } - write!(self.dst, ")").unwrap(); - } - - fn value(&mut self, ty: &ValType) { - match ty { - ValType::I32 => write!(self.dst, "i32.const 0").unwrap(), - ValType::I64 => write!(self.dst, "i64.const 0").unwrap(), - ValType::F32 => write!(self.dst, "f32.const 0").unwrap(), - ValType::F64 => write!(self.dst, "f64.const 0").unwrap(), - ValType::V128 => write!(self.dst, "v128.const i32x4 0 0 0 0").unwrap(), - ValType::ExternRef => write!(self.dst, "ref.null extern").unwrap(), - ValType::FuncRef => write!(self.dst, "ref.null func").unwrap(), - } - } - - fn str(&mut self, name: &str) { - let mut bytes = [0; 4]; - self.dst.push_str("\""); - for c in name.chars() { - let v = c as u32; - if v >= 0x20 && v < 0x7f && c != '"' && c != '\\' && v < 0xff { - self.dst.push(c); - } else { - for byte in c.encode_utf8(&mut bytes).as_bytes() { - self.hex_byte(*byte); - } - } - } - self.dst.push_str("\""); - } - - fn hex_byte(&mut self, byte: u8) { - fn to_hex(b: u8) -> char { - if b < 10 { - (b'0' + b) as char - } else { - (b'a' + b - 10) as char - } - } - self.dst.push('\\'); - self.dst.push(to_hex((byte >> 4) & 0xf)); - self.dst.push(to_hex(byte & 0xf)); - } -} - -fn wat_ty(ty: &ValType) -> &'static str { - match ty { - ValType::I32 => "i32", - ValType::I64 => "i64", - ValType::F32 => "f32", - ValType::F64 => "f64", - ValType::V128 => "v128", - ValType::ExternRef => "externref", - ValType::FuncRef => "funcref", - } -} - -#[cfg(test)] -mod tests { - use super::*; - use std::collections::HashSet; - - fn store() -> crate::Store { - let mut config = Config::default(); - config.wasm_module_linking(true); - config.wasm_multi_memory(true); - let engine = wasmtime::Engine::new(&config).unwrap(); - Store::new(&engine, None) - } - - #[test] - fn dummy_function_import() { - let mut store = store(); - let func_ty = FuncType::new(vec![ValType::I32], vec![ValType::I64]); - let func = dummy_func(&mut store, func_ty.clone(), "f"); - assert_eq!(func.ty(&store), func_ty); - } - - #[test] - fn dummy_instance_import() { - let mut store = store(); - - let mut instance_ty = InstanceType::new(); - - // Functions. - instance_ty.add_named_export("func0", FuncType::new(vec![ValType::I32], vec![]).into()); - instance_ty.add_named_export("func1", FuncType::new(vec![], vec![ValType::I64]).into()); - - // Instances. - instance_ty.add_named_export("instance0", InstanceType::new().into()); - instance_ty.add_named_export("instance1", InstanceType::new().into()); - - let instance = dummy_instance(&mut store, instance_ty.clone(), "instance").unwrap(); - - let mut expected_exports = vec!["func0", "func1", "instance0", "instance1"] - .into_iter() - .collect::>(); - for exp in instance.ty(&store).exports() { - let was_expected = expected_exports.remove(exp.name()); - assert!(was_expected); - } - assert!(expected_exports.is_empty()); - } -} diff --git a/crates/wizer/src/lib.rs b/crates/wizer/src/lib.rs index 5423fd5f63e7..884fec5880c4 100644 --- a/crates/wizer/src/lib.rs +++ b/crates/wizer/src/lib.rs @@ -543,10 +543,6 @@ impl Wizer { // Proposals we support. config.wasm_multi_memory(self.wasm_multi_memory.unwrap_or(DEFAULT_WASM_MULTI_MEMORY)); config.wasm_multi_value(self.wasm_multi_value.unwrap_or(DEFAULT_WASM_MULTI_VALUE)); - config.wasm_module_linking( - self.wasm_module_linking - .unwrap_or(DEFAULT_WASM_MODULE_LINKING), - ); // Note that we only support `memory.copy`, `memory.fill`, and // `memory.init` for the time being: config.wasm_bulk_memory(self.wasm_bulk_memory.unwrap_or(DEFAULT_WASM_BULK_MEMORY)); diff --git a/crates/wizer/src/snapshot.rs b/crates/wizer/src/snapshot.rs index 9e75497ecbb0..9d69b6f26f42 100644 --- a/crates/wizer/src/snapshot.rs +++ b/crates/wizer/src/snapshot.rs @@ -279,14 +279,11 @@ fn snapshot_instantiations( instance: &wasmtime::Instance, ) -> Vec { log::debug!("Snapshotting nested instantiations"); - let mut instantiations = vec![]; + let instantiations = vec![]; loop { let name = format!("__wizer_instance_{}", instantiations.len()); match instance.get_export(&mut *ctx, &name) { None => break, - Some(wasmtime::Extern::Instance(instance)) => { - instantiations.push(snapshot(&mut *ctx, &instance)); - } Some(_) => unreachable!(), } } diff --git a/crates/wizer/tests/make_linker.rs b/crates/wizer/tests/make_linker.rs index 6cb44c8d269f..ebde070e9a7e 100644 --- a/crates/wizer/tests/make_linker.rs +++ b/crates/wizer/tests/make_linker.rs @@ -33,7 +33,6 @@ fn run_wasm(args: &[wasmtime::Val], expected: i32, wasm: &[u8]) -> Result<()> { config.cache_config_load_default().unwrap(); config.wasm_multi_memory(true); config.wasm_multi_value(true); - config.wasm_module_linking(true); let engine = wasmtime::Engine::new(&config)?; let wasi_ctx = wasi_cap_std_sync::WasiCtxBuilder::new().build(); diff --git a/crates/wizer/tests/tests.rs b/crates/wizer/tests/tests.rs index 7e172de5173c..cb56f718f18c 100644 --- a/crates/wizer/tests/tests.rs +++ b/crates/wizer/tests/tests.rs @@ -35,7 +35,6 @@ fn run_wasm(args: &[wasmtime::Val], expected: i32, wasm: &[u8]) -> Result<()> { config.cache_config_load_default().unwrap(); config.wasm_multi_memory(true); config.wasm_multi_value(true); - config.wasm_module_linking(true); let engine = wasmtime::Engine::new(&config)?; let wasi_ctx = wasi_cap_std_sync::WasiCtxBuilder::new().build(); @@ -51,8 +50,7 @@ fn run_wasm(args: &[wasmtime::Val], expected: i32, wasm: &[u8]) -> Result<()> { .define_name("dummy_func", wasmtime::Func::wrap(&mut store, || {}))? .define("env", "f", wasmtime::Func::wrap(&mut store, || {}))? .define_name("f", wasmtime::Func::wrap(&mut store, || {}))? - .define("x", "f", wasmtime::Func::wrap(&mut store, || {}))? - .define_name("dummy_instance", dummy_instance)?; + .define("x", "f", wasmtime::Func::wrap(&mut store, || {}))?; wasmtime_wasi::add_to_linker(&mut linker, |wasi| wasi)?; @@ -137,32 +135,6 @@ fn basic_memory() -> Result<()> { ) } -#[test] -fn multi_memory() -> Result<()> { - run_wat( - &[], - 42, - r#" -(module - (memory $m1 1) - (memory $m2 1) - (func (export "wizer.initialize") - i32.const 0 - i32.const 41 - i32.store (memory $m1) offset=1337 - i32.const 0 - i32.const 1 - i32.store (memory $m2) offset=1337) - (func (export "run") (result i32) - i32.const 0 - i32.load (memory $m1) offset=1337 - i32.const 0 - i32.load (memory $m2) offset=1337 - i32.add)) -"#, - ) -} - #[test] fn reject_imported_memory() -> Result<()> { fails_wizening( @@ -347,505 +319,6 @@ fn reject_data_drop() -> Result<()> { Ok(()) } -#[test] -fn accept_module_linking_import_memory() -> Result<()> { - run_wat( - &[], - 42, - r#" -(module - (module $A - (memory (export "memory") 1)) - (instance $a (instantiate $A)) - - (module $B - (import "x" (instance $x (export "memory" (memory 1))))) - (instance $b (instantiate $B (import "x" (instance $a)))) - - (func (export "wizer.initialize") - nop) - - (func (export "run") (result i32) - i32.const 42) -) -"#, - ) -} - -#[test] -fn accept_module_linking_import_global() -> Result<()> { - run_wat( - &[], - 42, - r#" -(module - (module $A - (global (export "global") i32 (i32.const 1337))) - (instance $a (instantiate $A)) - - (module $B - (import "x" (instance $x (export "global" (global i32))))) - (instance $b (instantiate $B (import "x" (instance $a)))) - - (func (export "wizer.initialize") - nop) - - (func (export "run") (result i32) - i32.const 42) -) -"#, - ) -} - -#[test] -fn accept_module_linking_import_table() -> Result<()> { - run_wat( - &[], - 42, - r#" -(module - (module $A - (table (export "table") 0 funcref)) - (instance $a (instantiate $A)) - - (module $B - (import "x" (instance $x (export "table" (table 0 funcref))))) - (instance $b (instantiate $B (import "x" (instance $a)))) - - (func (export "wizer.initialize") - nop) - - (func (export "run") (result i32) - i32.const 42) -) -"#, - ) -} - -#[test] -fn module_linking_actually_works() -> Result<()> { - run_wat( - &[], - 42, - r#" -(module - (module $memory-module - (memory (export "memory") 1)) - (instance $memory-instance (instantiate $memory-module)) - - (module $use-memory - (import "x" (instance $m (export "memory" (memory 1)))) - (func (export "init") - i32.const 0 - i32.const 42 - i32.store (memory $m "memory") offset=1337)) - (instance $use-memory-instance - (instantiate $use-memory - (import "x" (instance $memory-instance)))) - - (func (export "wizer.initialize") - (call (func $use-memory-instance "init"))) - - (func (export "run") (result i32) - i32.const 0 - i32.load (memory $memory-instance "memory") offset=1337) -) -"#, - ) -} - -#[test] -fn module_linking_nested_instantiations_1() -> Result<()> { - run_wat( - &[], - 8, - r#" -(module - (module $A - (import "global" (global (mut i32))) - - (module $B - (import "global" (global (mut i32))) - - (module $C - (import "global" (global (mut i32))) - - (func (export "f") - i32.const 1 - global.get 0 - i32.add - global.set 0 - ) - ) - - (instance $c1 (instantiate $C (import "global" (global 0)))) - (instance $c2 (instantiate $C (import "global" (global 0)))) - - (func (export "f") - call (func $c1 "f") - call (func $c2 "f") - ) - ) - - (instance $b1 (instantiate $B (import "global" (global 0)))) - (instance $b2 (instantiate $B (import "global" (global 0)))) - - (func (export "f") - call (func $b1 "f") - call (func $b2 "f") - ) - ) - - (module $DefinesGlobal - (global (export "global") (mut i32) (i32.const 0))) - (instance $global_instance (instantiate $DefinesGlobal)) - - (instance $a1 (instantiate $A (import "global" (global $global_instance "global")))) - (instance $a2 (instantiate $A (import "global" (global $global_instance "global")))) - - (func (export "wizer.initialize") - call (func $a1 "f") - call (func $a2 "f")) - - (func (export "run") (result i32) - global.get (global $global_instance "global")) -) -"#, - ) -} - -#[test] -fn module_linking_nested_instantiations_0() -> Result<()> { - run_wat( - &[], - 42, - r#" -(module - (module $A - (import "global" (global (mut i32))) - - (module $B - (import "global" (global (mut i32))) - - (func (export "f") - i32.const 42 - global.set 0 - ) - ) - - (instance $b (instantiate $B (import "global" (global 0)))) - - (func (export "f") - call (func $b "f") - ) - ) - - (module $G - (global (export "global") (mut i32) (i32.const 0))) - - (instance $g (instantiate $G)) - - (instance $a (instantiate $A (import "global" (global $g "global")))) - - (func (export "wizer.initialize") - call (func $a "f") - ) - - (func (export "run") (result i32) - global.get (global $g "global") - ) -) -"#, - ) -} - -// Test that we handle repeated and interleaved initial sections. -#[test] -fn multiple_initial_sections() -> Result<()> { - run_wat( - &[], - 42, - r#" -(module - ;; Module section. - (module $A - (memory (export "memory") 1) - ) - - ;; Instance section. - (instance $a (instantiate $A)) - - ;; Alias section. - (alias $a "memory" (memory $memory)) - - ;; Module section. - (module $B - (import "memory" (memory 1)) - (func (export "init") - i32.const 0 - i32.const 42 - i32.store offset=1337 - ) - ) - - ;; Instance section. - (instance $b (instantiate $B (import "memory" (memory $memory)))) - - ;; Alias section. - (alias $b "init" (func $b-init)) - - ;; Module section. - (module $C - (import "memory" (memory 1)) - (func (export "run") (result i32) - i32.const 0 - i32.load offset=1337 - ) - ) - - ;; Instance section. - (instance $c (instantiate $C (import "memory" (memory $memory)))) - - ;; Alias section. - (alias $c "run" (func $c-run)) - - ;; Done with initial sections. - - (func (export "wizer.initialize") - call $b-init - ) - - (func (export "run") (result i32) - call $c-run - ) -) -"#, - ) -} - -#[test] -fn start_sections_in_nested_modules() -> Result<()> { - run_wat( - &[], - 42, - r#" -(module - (module $A - (import "global" (global $g (mut i32))) - (func $init - i32.const 41 - global.set $g) - (start $init) - ) - - (module $B - (global (export "global") (mut i32) (i32.const 0)) - ) - - (instance $b (instantiate $B)) - (alias $b "global" (global $g)) - (instance $a (instantiate $A (import "global" (global $g)))) - - (func (export "wizer.initialize") - global.get $g - i32.const 1 - i32.add - global.set $g - ) - (func (export "run") (result i32) - global.get $g - ) -) -"#, - ) -} - -#[test] -fn allow_function_imports_module_linking() -> Result<()> { - // Make sure that the umbrella module passes imports through to its - // instantiation of the root, and that the root can pass them along to its - // nested instantiations as well. - run_wat( - &[], - 42, - r#" -(module - (import "dummy_func" (func $dummy)) - (module $A - (import "dummy_func" (func))) - (instance (instantiate $A (import "dummy_func" (func $dummy)))) - (func (export "wizer.initialize") - nop - ) - (func (export "run") (result i32) - i32.const 42 - ) -) -"#, - ) -} - -#[test] -fn outer_module_alias() -> Result<()> { - run_wat( - &[], - 42, - r#" -(module - (module $A - (global (export "g") (mut i32) (i32.const 0)) - ) - - (module $B - (alias outer 0 0 (module $A)) - (instance $a (instantiate $A)) - (func (export "init") - i32.const 42 - global.set (global $a "g") - ) - (func (export "run") (result i32) - global.get (global $a "g") - ) - ) - (instance $b (instantiate $B)) - - (func (export "wizer.initialize") - call (func $b "init") - ) - (func (export "run") (result i32) - call (func $b "run") - ) -) -"#, - ) -} - -#[test] -fn instance_alias_without_entry_in_type_section() -> Result<()> { - run_wat( - &[], - 42, - r#" -(module - (module $CHILD - (module $a) - (instance $a (instantiate $a)) - (export "a" (instance $a))) - (instance $child (instantiate $CHILD)) - - ;; This root module doesn't ever declare an instance type for this alias. - (alias $child "a" (instance $no_type_for_this_instance)) - - (func (export "wizer.initialize") - nop - ) - (func (export "run") (result i32) - i32.const 42 - ) -) -"#, - ) -} - -#[test] -fn two_level_imports_and_implicit_instance_imports() -> Result<()> { - run_wat( - &[], - 42, - r#" -(module - ;; First, import an instance to make sure that we are accounting for already - ;; imported instances when forwarding implicit instances and are getting the - ;; index space correct. - (import "dummy_instance" (instance)) - - ;; This implicitly creates an instance import like: - ;; - ;; (import (env (instance (export "f" (func $f))))) - ;; - ;; We will have to forward this implicit instance from the umbrella to the - ;; root instantiation. - (import "env" "f" (func $f)) - - (module $A - (import "env" "f" (func))) - - ;; Pass that implicit instance through when instantiating `$A`. - (instance $a (instantiate $A (import "env" (instance 1)))) - - (func (export "wizer.initialize") - nop - ) - (func (export "run") (result i32) - i32.const 42 - ) -) -"#, - ) -} - -#[test] -fn implicit_instance_imports_and_other_instances() -> Result<()> { - // Test how implicit instance import injection interacts with explicit - // instance imports and explicit instantiations. - run_wat( - &[], - 42, - r#" -(module - (module $A - ;; This implicitly creates an instance import like: - ;; - ;; (import (env (instance (export "f" (func $f (result i32)))))) - (import "env" "f" (func $f (result i32))) - - (import "env2" (instance $env2 (export "g" (func (result i32))))) - - (module $B - (func (export "h") (result i32) - i32.const 1 - ) - ) - (instance $b (instantiate $B)) - - (func (export "run") (result i32) - call $f - call (func $env2 "g") - call (func $b "h") - i32.add - i32.add - ) - ) - - (module $Env - (func (export "f") (result i32) - i32.const 2 - ) - ) - (instance $env (instantiate $Env)) - - (module $Env2 - (func (export "g") (result i32) - i32.const 39 - ) - ) - (instance $env2 (instantiate $Env2)) - - (instance $a (instantiate $A - (import "env" (instance $env)) - (import "env2" (instance $env2)))) - - (func (export "wizer.initialize") - nop - ) - (func (export "run") (result i32) - call (func $a "run") - ) -) -"#, - ) -} - #[test] fn rust_regex() -> Result<()> { run_wasm( @@ -965,54 +438,6 @@ fn rename_functions() -> Result<()> { Ok(()) } -#[test] -fn renames_and_module_linking() -> Result<()> { - let wat = r#" -(module - (module $A - (func (export "a") (result i32) - i32.const 1) - (func (export "b") (result i32) - i32.const 2) - (func (export "c") (result i32) - i32.const 3) - ) - (instance $a (instantiate $A)) - (func (export "wizer.initialize") - nop - ) - (func (export "a") (result i32) - call (func $a "a") - ) - (func (export "b") (result i32) - call (func $a "b") - ) - (func (export "c") (result i32) - call (func $a "c") - ) -) - "#; - - let wasm = wat_to_wasm(wat)?; - let mut wizer = Wizer::new(); - wizer.wasm_module_linking(true); - wizer.allow_wasi(true).unwrap(); - wizer.func_rename("a", "b"); - wizer.func_rename("b", "c"); - let wasm = wizer.run(&wasm)?; - let wat = wasmprinter::print_bytes(&wasm)?; - - let expected_wat = r#" - (alias 1 "b" (func (;0;))) - (alias 1 "c" (func (;1;))) - (export "a" (func 0)) - (export "b" (func 1))) - "#; - - assert!(wat.trim().ends_with(expected_wat.trim())); - Ok(()) -} - #[test] fn wasi_reactor() -> anyhow::Result<()> { run_wat( @@ -1069,74 +494,6 @@ fn allow_undefined_import_function() -> Result<()> { ) } -#[test] -fn call_undefined_instance_import_function_during_init() -> Result<()> { - fails_wizening( - r#" - (module - (import "x" (instance (export "f" (func)))) - (alias 0 "f" (func $import)) - (func (export "wizer.initialize") - (call $import) - ) - ) - "#, - ) -} - -#[test] -fn allow_undefined_instance_import_function() -> Result<()> { - run_wat( - &[], - 42, - r#" - (module - (import "x" (instance (export "f" (func)))) - (func (export "wizer.initialize")) - (func (export "run") (result i32) - i32.const 42 - ) - ) - "#, - ) -} - -#[test] -fn reject_import_instance_global() -> Result<()> { - fails_wizening( - r#" - (module - (import "x" (instance (export "g" (global i32)))) - (func (export "wizer.initialize")) - ) - "#, - ) -} - -#[test] -fn reject_import_instance_table() -> Result<()> { - fails_wizening( - r#" - (module - (import "x" (instance (export "t" (table 0 externref)))) - (func (export "wizer.initialize")) - ) - "#, - ) -} - -#[test] -fn reject_import_instance_memory() -> Result<()> { - fails_wizening( - r#" - (module - (import "x" (instance (export "m" (memory 0)))) - (func (export "wizer.initialize")) - ) - "#, - ) -} - #[test] fn accept_bulk_memory_copy() -> Result<()> { run_wat( From 3c5f5bde148e7cb3e0928c427f6fb99cbd6c4ad3 Mon Sep 17 00:00:00 2001 From: Jake Champion Date: Sun, 8 Jan 2023 16:50:41 +0000 Subject: [PATCH 131/212] update to wasmtime 3.0.0 this update required changes from the removed `Trap::new` to anyhow! macro, Trap::new was removed in https://github.com/bytecodealliance/wasmtime/pull/5149/ --- crates/wizer/Cargo.lock | 691 +++++++++++++++++++----------- crates/wizer/Cargo.toml | 6 +- crates/wizer/fuzz/Cargo.toml | 2 +- crates/wizer/src/dummy.rs | 6 +- crates/wizer/tests/make_linker.rs | 6 +- crates/wizer/tests/tests.rs | 28 +- 6 files changed, 478 insertions(+), 261 deletions(-) diff --git a/crates/wizer/Cargo.lock b/crates/wizer/Cargo.lock index d0f95043451e..69753d41cb4a 100644 --- a/crates/wizer/Cargo.lock +++ b/crates/wizer/Cargo.lock @@ -2,30 +2,15 @@ # It is not intended for manual editing. version = 3 -[[package]] -name = "addr2line" -version = "0.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e61f2b7f93d2c7d2b08263acaa4a363b3e276806c68af6134c44f523bf1aacd" -dependencies = [ - "gimli 0.25.0", -] - [[package]] name = "addr2line" version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b9ecd88a8c8378ca913a680cd98f0f13ac67383d35993f86c90a70e3f137816b" dependencies = [ - "gimli 0.26.1", + "gimli", ] -[[package]] -name = "adler" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" - [[package]] name = "ahash" version = "0.7.6" @@ -76,6 +61,12 @@ dependencies = [ "derive_arbitrary", ] +[[package]] +name = "arrayvec" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6" + [[package]] name = "async-trait" version = "0.1.51" @@ -104,21 +95,6 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" -[[package]] -name = "backtrace" -version = "0.3.61" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7a905d892734eea339e896738c14b9afce22b5318f64b951e70bf3844419b01" -dependencies = [ - "addr2line 0.16.0", - "cc", - "cfg-if", - "libc", - "miniz_oxide", - "object 0.26.2", - "rustc-demangle", -] - [[package]] name = "base64" version = "0.13.0" @@ -142,9 +118,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "block-buffer" -version = "0.9.0" +version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" +checksum = "69cce20737498f97b993470a6e536b8523f0af7892a4f928cceb1ac5e52ebe7e" dependencies = [ "generic-array", ] @@ -175,14 +151,14 @@ checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" [[package]] name = "cap-fs-ext" -version = "0.24.1" +version = "0.26.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71f5b22f0dc04ed3404bfae102654978bfd425c5568851a89eb4d4b8f58e9590" +checksum = "0b0e103ce36d217d568903ad27b14ec2238ecb5d65bad2e756a8f3c0d651506e" dependencies = [ - "cap-primitives", - "cap-std", - "io-lifetimes", - "winapi", + "cap-primitives 0.26.1", + "cap-std 0.26.1", + "io-lifetimes 0.7.5", + "windows-sys 0.36.1", ] [[package]] @@ -193,22 +169,40 @@ checksum = "defd283f080043a702c362203c2646a4e0a2fff99baede1eea1416239f0af220" dependencies = [ "ambient-authority", "errno", - "fs-set-times", - "io-extras", - "io-lifetimes", + "fs-set-times 0.15.0", + "io-extras 0.13.2", + "io-lifetimes 0.5.3", "ipnet", "maybe-owned", - "rustix", + "rustix 0.33.7", "winapi", "winapi-util", - "winx", + "winx 0.31.0", +] + +[[package]] +name = "cap-primitives" +version = "0.26.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af3f336aa91cce16033ed3c94ac91d98956c49b420e6d6cd0dd7d0e386a57085" +dependencies = [ + "ambient-authority", + "fs-set-times 0.17.1", + "io-extras 0.15.0", + "io-lifetimes 0.7.5", + "ipnet", + "maybe-owned", + "rustix 0.35.13", + "winapi-util", + "windows-sys 0.36.1", + "winx 0.33.0", ] [[package]] name = "cap-rand" -version = "0.24.1" +version = "0.26.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12627a93bdbbe4fb32c1ea2b2c2665ba54c49eb48f1139440ce4c6a279701461" +checksum = "d14b9606aa9550d34651bc481443203bc014237bdb992d201d2afa62d2ec6dea" dependencies = [ "ambient-authority", "rand", @@ -220,23 +214,36 @@ version = "0.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3430d1b5ba78fa381eb227525578d2b85d77b42ff49be85d1e72a94f305e603c" dependencies = [ - "cap-primitives", - "io-extras", - "io-lifetimes", + "cap-primitives 0.24.1", + "io-extras 0.13.2", + "io-lifetimes 0.5.3", "ipnet", - "rustix", + "rustix 0.33.7", +] + +[[package]] +name = "cap-std" +version = "0.26.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9d6e70b626eceac9d6fc790fe2d72cc3f2f7bc3c35f467690c54a526b0f56db" +dependencies = [ + "cap-primitives 0.26.1", + "io-extras 0.15.0", + "io-lifetimes 0.7.5", + "ipnet", + "rustix 0.35.13", ] [[package]] name = "cap-time-ext" -version = "0.24.1" +version = "0.26.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a34e5a4375b768b3acaec25dd7b53bcc15c801258c43a0ef2da2027f2028e46" +checksum = "c3a0524f7c4cff2ea547ae2b652bf7a348fd3e48f76556dc928d8b45ab2f1d50" dependencies = [ - "cap-primitives", + "cap-primitives 0.26.1", "once_cell", - "rustix", - "winx", + "rustix 0.35.13", + "winx 0.33.0", ] [[package]] @@ -298,25 +305,28 @@ dependencies = [ [[package]] name = "cranelift-bforest" -version = "0.85.3" +version = "0.90.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "749d0d6022c9038dccf480bdde2a38d435937335bf2bb0f14e815d94517cdce8" +checksum = "b62c772976416112fa4484cbd688cb6fb35fd430005c1c586224fc014018abad" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-codegen" -version = "0.85.3" +version = "0.90.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e94370cc7b37bf652ccd8bb8f09bd900997f7ccf97520edfc75554bb5c4abbea" +checksum = "9b40ed2dd13c2ac7e24f88a3090c68ad3414eb1d066a95f8f1f7b3b819cb4e46" dependencies = [ + "arrayvec", + "bumpalo", "cranelift-bforest", "cranelift-codegen-meta", "cranelift-codegen-shared", + "cranelift-egraph", "cranelift-entity", "cranelift-isle", - "gimli 0.26.1", + "gimli", "log", "regalloc2", "smallvec", @@ -325,33 +335,47 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.85.3" +version = "0.90.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0a3cea8fdab90e44018c5b9a1dfd460d8ee265ac354337150222a354628bdb6" +checksum = "bb927a8f1c27c34ee3759b6b0ffa528d2330405d5cc4511f0cab33fe2279f4b5" dependencies = [ "cranelift-codegen-shared", ] [[package]] name = "cranelift-codegen-shared" -version = "0.85.3" +version = "0.90.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ac72f76f2698598951ab26d8c96eaa854810e693e7dd52523958b5909fde6b2" +checksum = "43dfa417b884a9ab488d95fd6b93b25e959321fe7bfd7a0a960ba5d7fb7ab927" + +[[package]] +name = "cranelift-egraph" +version = "0.90.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0a66b39785efd8513d2cca967ede56d6cc57c8d7986a595c7c47d0c78de8dce" +dependencies = [ + "cranelift-entity", + "fxhash", + "hashbrown", + "indexmap", + "log", + "smallvec", +] [[package]] name = "cranelift-entity" -version = "0.85.3" +version = "0.90.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09eaeacfcd2356fe0e66b295e8f9d59fdd1ac3ace53ba50de14d628ec902f72d" +checksum = "0637ffde963cb5d759bc4d454cfa364b6509e6c74cdaa21298add0ed9276f346" dependencies = [ "serde", ] [[package]] name = "cranelift-frontend" -version = "0.85.3" +version = "0.90.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dba69c9980d5ffd62c18a2bde927855fcd7c8dc92f29feaf8636052662cbd99c" +checksum = "fb72b8342685e850cb037350418f62cc4fc55d6c2eb9c7ca01b82f9f1a6f3d56" dependencies = [ "cranelift-codegen", "log", @@ -361,15 +385,15 @@ dependencies = [ [[package]] name = "cranelift-isle" -version = "0.85.3" +version = "0.90.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2920dc1e05cac40304456ed3301fde2c09bd6a9b0210bcfa2f101398d628d5b" +checksum = "850579cb9e4b448f7c301f1e6e6cbad99abe3f1f1d878a4994cb66e33c6db8cd" [[package]] name = "cranelift-native" -version = "0.85.3" +version = "0.90.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f04dfa45f9b2a6f587c564d6b63388e00cd6589d2df6ea2758cf79e1a13285e6" +checksum = "2d0a279e5bcba3e0466c734d8d8eb6bfc1ad29e95c37f3e4955b492b5616335e" dependencies = [ "cranelift-codegen", "libc", @@ -378,9 +402,9 @@ dependencies = [ [[package]] name = "cranelift-wasm" -version = "0.85.3" +version = "0.90.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31a46513ae6f26f3f267d8d75b5373d555fbbd1e68681f348d99df43f747ec54" +checksum = "e6b8c5e7ffb754093fb89ec4bd4f9dbb9f1c955427299e334917d284745835c2" dependencies = [ "cranelift-codegen", "cranelift-entity", @@ -388,7 +412,7 @@ dependencies = [ "itertools", "log", "smallvec", - "wasmparser 0.85.0", + "wasmparser 0.93.0", "wasmtime-types", ] @@ -481,6 +505,16 @@ dependencies = [ "lazy_static", ] +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "typenum", +] + [[package]] name = "csv" version = "1.1.6" @@ -516,11 +550,12 @@ dependencies = [ [[package]] name = "digest" -version = "0.9.0" +version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" +checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f" dependencies = [ - "generic-array", + "block-buffer", + "crypto-common", ] [[package]] @@ -635,11 +670,22 @@ version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7df62ee66ee2d532ea8d567b5a3f0d03ecd64636b98bad5be1e93dcc918b92aa" dependencies = [ - "io-lifetimes", - "rustix", + "io-lifetimes 0.5.3", + "rustix 0.33.7", "winapi", ] +[[package]] +name = "fs-set-times" +version = "0.17.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a267b6a9304912e018610d53fe07115d8b530b160e85db4d2d3a59f3ddde1aec" +dependencies = [ + "io-lifetimes 0.7.5", + "rustix 0.35.13", + "windows-sys 0.36.1", +] + [[package]] name = "fxhash" version = "0.2.1" @@ -676,12 +722,6 @@ dependencies = [ "wasi", ] -[[package]] -name = "gimli" -version = "0.25.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0a01e0497841a3b2db4f8afa483cce65f7e96a3498bd6c541734792aeac8fe7" - [[package]] name = "gimli" version = "0.26.1" @@ -701,19 +741,13 @@ checksum = "62aca2aba2d62b4a7f5b33f3712cb1b0692779a56fb510499d5c0aa594daeaf3" [[package]] name = "hashbrown" -version = "0.11.2" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" dependencies = [ "ahash", ] -[[package]] -name = "hashbrown" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" - [[package]] name = "heck" version = "0.3.3" @@ -769,7 +803,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1885e79c1fc4b10f0e172c475f458b7f7b93061064d98c3293e98c5ba0c8b399" dependencies = [ "autocfg", - "hashbrown 0.12.3", + "hashbrown", "serde", ] @@ -779,18 +813,44 @@ version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d0c937cc9891c12eaa8c63ad347e4a288364b1328b924886970b47a14ab8f8f8" dependencies = [ - "io-lifetimes", + "io-lifetimes 0.5.3", "winapi", ] +[[package]] +name = "io-extras" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a5d8c2ab5becd8720e30fd25f8fa5500d8dc3fceadd8378f05859bd7b46fc49" +dependencies = [ + "io-lifetimes 0.7.5", + "windows-sys 0.36.1", +] + [[package]] name = "io-lifetimes" version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec58677acfea8a15352d42fc87d11d63596ade9239e0a7c9352914417515dbe6" + +[[package]] +name = "io-lifetimes" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59ce5ef949d49ee85593fc4d3f3f95ad61657076395cbbce23e2121fc5542074" dependencies = [ "libc", - "winapi", + "windows-sys 0.42.0", +] + +[[package]] +name = "io-lifetimes" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46112a93252b123d31a119a8d1a1ac19deac4fac6e0e8b0df58f0d4e5870e63c" +dependencies = [ + "libc", + "windows-sys 0.42.0", ] [[package]] @@ -801,14 +861,14 @@ checksum = "68f2d64f2edebec4ce84ad108148e67e1064789bee435edc5b60ad398714a3a9" [[package]] name = "is-terminal" -version = "0.1.0" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c89a757e762896bdbdfadf2860d0f8b0cea5e363d8cf3e7bdfeb63d1d976352" +checksum = "0d508111813f9af3afd2f92758f77e4ed2cc9371b642112c6a48d22eb73105c5" dependencies = [ "hermit-abi 0.2.0", - "io-lifetimes", - "rustix", - "winapi", + "io-lifetimes 0.7.5", + "rustix 0.35.13", + "windows-sys 0.36.1", ] [[package]] @@ -833,10 +893,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1aab8fc367588b89dcee83ab0fd66b72b50b72fa1904d7095045ace2b0c81c35" [[package]] -name = "ittapi-rs" -version = "0.2.0" +name = "ittapi" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f712648a1ad72fbfb7adc2772c331e8d90f022f8cf30cbabefba2878dd3172b0" +checksum = "e8c4f6ff06169ce7048dac5150b1501c7e3716a929721aeb06b87e51a43e42f4" +dependencies = [ + "anyhow", + "ittapi-sys", + "log", +] + +[[package]] +name = "ittapi-sys" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87e078cce01485f418bae3beb34dd604aaedf2065502853c7da17fbce8e64eda" dependencies = [ "cc", ] @@ -900,6 +971,18 @@ version = "0.0.42" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5284f00d480e1c39af34e72f8ad60b94f47007e3481cd3b731c1d67190ddc7b7" +[[package]] +name = "linux-raw-sys" +version = "0.0.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4d2456c373231a208ad294c33dc5bff30051eafd954cd4caae83a712b12854d" + +[[package]] +name = "linux-raw-sys" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4" + [[package]] name = "log" version = "0.4.17" @@ -932,11 +1015,11 @@ checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" [[package]] name = "memfd" -version = "0.4.1" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6627dc657574b49d6ad27105ed671822be56e0d2547d413bfbf3e8d8fa92e7a" +checksum = "b20a59d985586e4a5aef64564ac77299f8586d8be6cf9106a5a40207e8908efb" dependencies = [ - "libc", + "rustix 0.36.6", ] [[package]] @@ -948,22 +1031,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "miniz_oxide" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a92518e98c078586bc6c934028adcca4c92a53d6a958196de835170a01d84e4b" -dependencies = [ - "adler", - "autocfg", -] - -[[package]] -name = "more-asserts" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0debeb9fcf88823ea64d64e4a815ab1643f33127d995978e099942ce38f25238" - [[package]] name = "num-traits" version = "0.2.14" @@ -985,21 +1052,12 @@ dependencies = [ [[package]] name = "object" -version = "0.26.2" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39f37e50073ccad23b6d09bcb5b263f4e76d3bb6038e4a3c08e52162ffa8abc2" -dependencies = [ - "memchr", -] - -[[package]] -name = "object" -version = "0.28.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e42c982f2d955fac81dd7e1d0e1426a7d702acd9c98d19ab01083a6a0328c424" +checksum = "21158b2c33aa6d4561f1c0a6ea283ca92bc54802a93b263e910746d679a7eb53" dependencies = [ "crc32fast", - "hashbrown 0.11.2", + "hashbrown", "indexmap", "memchr", ] @@ -1016,12 +1074,6 @@ version = "11.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575" -[[package]] -name = "opaque-debug" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" - [[package]] name = "paste" version = "1.0.5" @@ -1211,9 +1263,9 @@ dependencies = [ [[package]] name = "regalloc2" -version = "0.2.3" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a8d23b35d7177df3b9d31ed8a9ab4bf625c668be77a319d4f5efd4a5257701c" +checksum = "91b2eab54204ea0117fe9a060537e0b07a4e72f7c7d182361ecc346cab2240e5" dependencies = [ "fxhash", "log", @@ -1258,18 +1310,6 @@ dependencies = [ "regex", ] -[[package]] -name = "region" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "877e54ea2adcd70d80e9179344c97f93ef0dffd6b03e1f4529e6e83ab2fa9ae0" -dependencies = [ - "bitflags", - "libc", - "mach", - "winapi", -] - [[package]] name = "rustc-demangle" version = "0.1.21" @@ -1293,14 +1333,44 @@ checksum = "938a344304321a9da4973b9ff4f9f8db9caf4597dfd9dda6a60b523340a0fff0" dependencies = [ "bitflags", "errno", - "io-lifetimes", + "io-lifetimes 0.5.3", "itoa 1.0.1", "libc", - "linux-raw-sys", + "linux-raw-sys 0.0.42", "once_cell", "winapi", ] +[[package]] +name = "rustix" +version = "0.35.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "727a1a6d65f786ec22df8a81ca3121107f235970dc1705ed681d3e6e8b9cd5f9" +dependencies = [ + "bitflags", + "errno", + "io-lifetimes 0.7.5", + "itoa 1.0.1", + "libc", + "linux-raw-sys 0.0.46", + "once_cell", + "windows-sys 0.42.0", +] + +[[package]] +name = "rustix" +version = "0.36.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4feacf7db682c6c329c4ede12649cd36ecab0f3be5b7d74e6a20304725db4549" +dependencies = [ + "bitflags", + "errno", + "io-lifetimes 1.0.3", + "libc", + "linux-raw-sys 0.1.4", + "windows-sys 0.42.0", +] + [[package]] name = "ryu" version = "1.0.5" @@ -1383,15 +1453,13 @@ dependencies = [ [[package]] name = "sha2" -version = "0.9.9" +version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" +checksum = "82e6b795fe2e3b1e845bafcb27aa35405c4d47cdfc92af5fc8d3002f76cebdc0" dependencies = [ - "block-buffer", "cfg-if", "cpufeatures", "digest", - "opaque-debug", ] [[package]] @@ -1464,18 +1532,18 @@ dependencies = [ [[package]] name = "system-interface" -version = "0.20.0" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e09bb3fb4e02ec4b87e182ea9718fadbc0fa3e50085b40a9af9690572b67f9e" +checksum = "92adbaf536f5aff6986e1e62ba36cee72b1718c5153eee08b9e728ddde3f6029" dependencies = [ "atty", "bitflags", "cap-fs-ext", - "cap-std", - "io-lifetimes", - "rustix", - "winapi", - "winx", + "cap-std 0.26.1", + "io-lifetimes 0.7.5", + "rustix 0.35.13", + "windows-sys 0.36.1", + "winx 0.33.0", ] [[package]] @@ -1638,44 +1706,45 @@ checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" [[package]] name = "wasi-cap-std-sync" -version = "0.38.3" +version = "3.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f086c5026d2fc3b268d138e65373f46422cc810f46d6e0776859c5027cb18728" +checksum = "ecbeebb8985a5423f36f976b2f4a0b3c6ce38d7d9a7247e1ce07aa2880e4f29b" dependencies = [ "anyhow", "async-trait", "cap-fs-ext", "cap-rand", - "cap-std", + "cap-std 0.26.1", "cap-time-ext", - "fs-set-times", - "io-extras", - "io-lifetimes", + "fs-set-times 0.17.1", + "io-extras 0.15.0", + "io-lifetimes 0.7.5", "is-terminal", - "lazy_static", - "rustix", + "once_cell", + "rustix 0.35.13", "system-interface", "tracing", "wasi-common", - "winapi", + "windows-sys 0.36.1", ] [[package]] name = "wasi-common" -version = "0.38.3" +version = "3.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e8844fede1c3787cc08853872f47e8bd91f6c939c7406bc7a5dba496b260c08" +checksum = "81e2171f3783fe6600ee24ff6c58ca1b329c55e458cc1622ecc1fd0427648607" dependencies = [ "anyhow", "bitflags", "cap-rand", - "cap-std", - "io-extras", - "rustix", + "cap-std 0.26.1", + "io-extras 0.15.0", + "rustix 0.35.13", "thiserror", "tracing", + "wasmtime", "wiggle", - "winapi", + "windows-sys 0.36.1", ] [[package]] @@ -1785,9 +1854,9 @@ checksum = "be92b6dcaa5af4b2a176b29be3bf1402fab9e69d313141185099c7d1684f2dca" [[package]] name = "wasmparser" -version = "0.85.0" +version = "0.93.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "570460c58b21e9150d2df0eaaedbb7816c34bcec009ae0dcc976e40ba81463e7" +checksum = "c5a4460aa3e271fa180b6a5d003e728f3963fb30e3ba0fa7c9634caa06049328" dependencies = [ "indexmap", ] @@ -1804,28 +1873,25 @@ dependencies = [ [[package]] name = "wasmtime" -version = "0.38.3" +version = "3.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f50eadf868ab6a04b7b511460233377d0bfbb92e417b2f6a98b98fef2e098f5" +checksum = "d18265705b1c49218776577d9f301d79ab06888c7f4a32e2ed24e68a55738ce7" dependencies = [ "anyhow", "async-trait", - "backtrace", "bincode", "cfg-if", "indexmap", - "lazy_static", "libc", "log", - "object 0.28.4", + "object", "once_cell", "paste", "psm", "rayon", - "region", "serde", "target-lexicon", - "wasmparser 0.85.0", + "wasmparser 0.93.0", "wasmtime-cache", "wasmtime-cranelift", "wasmtime-environ", @@ -1833,14 +1899,23 @@ dependencies = [ "wasmtime-jit", "wasmtime-runtime", "wat", - "winapi", + "windows-sys 0.36.1", +] + +[[package]] +name = "wasmtime-asm-macros" +version = "3.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a201583f6c79b96e74dcce748fa44fb2958f474ef13c93f880ea4d3bed31ae4f" +dependencies = [ + "cfg-if", ] [[package]] name = "wasmtime-cache" -version = "0.38.3" +version = "3.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1df23c642e1376892f3b72f311596976979cbf8b85469680cdd3a8a063d12a2" +checksum = "3f37efc6945b08fcb634cffafc438dd299bac55a27c836954656c634d3e63c31" dependencies = [ "anyhow", "base64", @@ -1848,19 +1923,19 @@ dependencies = [ "directories-next", "file-per-thread-logger", "log", - "rustix", + "rustix 0.35.13", "serde", "sha2", "toml", - "winapi", + "windows-sys 0.36.1", "zstd", ] [[package]] name = "wasmtime-cranelift" -version = "0.38.3" +version = "3.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f264ff6b4df247d15584f2f53d009fbc90032cfdc2605b52b961bffc71b6eccd" +checksum = "fe208297e045ea0ee6702be88772ea40f918d55fbd4163981a4699aff034b634" dependencies = [ "anyhow", "cranelift-codegen", @@ -1868,93 +1943,102 @@ dependencies = [ "cranelift-frontend", "cranelift-native", "cranelift-wasm", - "gimli 0.26.1", + "gimli", "log", - "more-asserts", - "object 0.28.4", + "object", "target-lexicon", "thiserror", - "wasmparser 0.85.0", + "wasmparser 0.93.0", "wasmtime-environ", ] [[package]] name = "wasmtime-environ" -version = "0.38.3" +version = "3.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "839d2820e4b830f4b9e7aa08d4c0acabf4a5036105d639f6dfa1c6891c73bdc6" +checksum = "754b97f7441ac780a7fa738db5b9c23c1b70ef4abccd8ad205ada5669d196ba2" dependencies = [ "anyhow", "cranelift-entity", - "gimli 0.26.1", + "gimli", "indexmap", "log", - "more-asserts", - "object 0.28.4", + "object", "serde", "target-lexicon", "thiserror", - "wasmparser 0.85.0", + "wasmparser 0.93.0", "wasmtime-types", ] [[package]] name = "wasmtime-fiber" -version = "0.38.3" +version = "3.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3248be3c4911233535356025f6562193614a40155ee9094bb6a2b43f0dc82803" +checksum = "e5f54abc960b4a055ba16b942cbbd1da641e0ad44cc97a7608f3d43c069b120e" dependencies = [ "cc", - "rustix", - "winapi", + "cfg-if", + "rustix 0.35.13", + "wasmtime-asm-macros", + "windows-sys 0.36.1", ] [[package]] name = "wasmtime-jit" -version = "0.38.3" +version = "3.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef0a0bcbfa18b946d890078ba0e1bc76bcc53eccfb40806c0020ec29dcd1bd49" +checksum = "32800cb6e29faabab7056593f70a4c00c65c75c365aaf05406933f2169d0c22f" dependencies = [ - "addr2line 0.17.0", + "addr2line", "anyhow", "bincode", "cfg-if", "cpp_demangle", - "gimli 0.26.1", - "ittapi-rs", + "gimli", + "ittapi", "log", - "object 0.28.4", - "region", + "object", "rustc-demangle", - "rustix", "serde", "target-lexicon", "thiserror", "wasmtime-environ", "wasmtime-jit-debug", + "wasmtime-jit-icache-coherence", "wasmtime-runtime", - "winapi", + "windows-sys 0.36.1", ] [[package]] name = "wasmtime-jit-debug" -version = "0.38.3" +version = "3.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f4779d976206c458edd643d1ac622b6c37e4a0800a8b1d25dfbf245ac2f2cac" +checksum = "fe057012a0ba6cee3685af1e923d6e0a6cb9baf15fb3ffa4be3d7f712c7dec42" dependencies = [ - "lazy_static", - "object 0.28.4", - "rustix", + "object", + "once_cell", + "rustix 0.35.13", +] + +[[package]] +name = "wasmtime-jit-icache-coherence" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6bbabb309c06cc238ee91b1455b748c45f0bdcab0dda2c2db85b0a1e69fcb66" +dependencies = [ + "cfg-if", + "libc", + "windows-sys 0.36.1", ] [[package]] name = "wasmtime-runtime" -version = "0.38.3" +version = "3.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7eb6ffa169eb5dcd18ac9473c817358cd57bc62c244622210566d473397954a" +checksum = "09a23b6e138e89594c0189162e524a29e217aec8f9a4e1959a34f74c64e8d17d" dependencies = [ "anyhow", - "backtrace", "cc", "cfg-if", "indexmap", @@ -1963,34 +2047,34 @@ dependencies = [ "mach", "memfd", "memoffset", - "more-asserts", + "paste", "rand", - "region", - "rustix", + "rustix 0.35.13", "thiserror", + "wasmtime-asm-macros", "wasmtime-environ", "wasmtime-fiber", "wasmtime-jit-debug", - "winapi", + "windows-sys 0.36.1", ] [[package]] name = "wasmtime-types" -version = "0.38.3" +version = "3.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d932b0ac5336f7308d869703dd225610a6a3aeaa8e968c52b43eed96cefb1c2" +checksum = "68ec7615fde8c79737f1345d81f0b18da83b3db929a87b4604f27c932246d1e2" dependencies = [ "cranelift-entity", "serde", "thiserror", - "wasmparser 0.85.0", + "wasmparser 0.93.0", ] [[package]] name = "wasmtime-wasi" -version = "0.38.3" +version = "3.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b68b7d77fb6f2975a6fe6cc4d0015d6b0cebb65c39fce1dd4cc00880dbf7789c" +checksum = "ca539adf155dca1407aa3656e5661bf2364b1f3ebabc7f0a8bd62629d876acfa" dependencies = [ "anyhow", "wasi-cap-std-sync", @@ -2041,9 +2125,9 @@ dependencies = [ [[package]] name = "wiggle" -version = "0.38.3" +version = "3.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67dadac11343d2aabc8a906a0db0aaf7cb5046ec3d6fffccdaf2847dccdef8d6" +checksum = "2da09ca5b8bb9278a2123e8c36342166b9aaa55a0dbab18b231f46d6f6ab85bc" dependencies = [ "anyhow", "async-trait", @@ -2056,9 +2140,9 @@ dependencies = [ [[package]] name = "wiggle-generate" -version = "0.38.3" +version = "3.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63a1dccd6b3fbd9a27417f5d30ce9aa3ee9cf529aad453abbf88a49c5d605b79" +checksum = "ba5796f53b429df7d44cfdaae8f6d9cd981d82aec3516561352ca9c5e73ee185" dependencies = [ "anyhow", "heck 0.4.0", @@ -2071,9 +2155,9 @@ dependencies = [ [[package]] name = "wiggle-macro" -version = "0.38.3" +version = "3.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1c368d57d9560c34deaa67e06b0953ccf65edb906c525e5a2c866c849b48ec2" +checksum = "8b830eb7203d48942fb8bc8bb105f76e7d09c33a082d638e990e02143bb2facd" dependencies = [ "proc-macro2", "quote", @@ -2112,6 +2196,106 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "windows-sys" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea04155a16a59f9eab786fe12a4a450e75cdb175f9e0d80da1e17db09f55b8d2" +dependencies = [ + "windows_aarch64_msvc 0.36.1", + "windows_i686_gnu 0.36.1", + "windows_i686_msvc 0.36.1", + "windows_x86_64_gnu 0.36.1", + "windows_x86_64_msvc 0.36.1", +] + +[[package]] +name = "windows-sys" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc 0.42.0", + "windows_i686_gnu 0.42.0", + "windows_i686_msvc 0.42.0", + "windows_x86_64_gnu 0.42.0", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc 0.42.0", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d2aa71f6f0cbe00ae5167d90ef3cfe66527d6f613ca78ac8024c3ccab9a19e" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd0f252f5a35cac83d6311b2e795981f5ee6e67eb1f9a7f64eb4500fbc4dcdb4" + +[[package]] +name = "windows_i686_gnu" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6" + +[[package]] +name = "windows_i686_gnu" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbeae19f6716841636c28d695375df17562ca208b2b7d0dc47635a50ae6c5de7" + +[[package]] +name = "windows_i686_msvc" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024" + +[[package]] +name = "windows_i686_msvc" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84c12f65daa39dd2babe6e442988fc329d6243fdce47d7d2d155b8d874862246" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf7b1b21b5362cbc318f686150e5bcea75ecedc74dd157d874d754a2ca44b0ed" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09d525d2ba30eeb3297665bd434a54297e4170c7f1a44cad4ef58095b4cd2028" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f40009d85759725a34da6d89a94e63d7bdc50a862acf0dbc7c8e488f1edcb6f5" + [[package]] name = "winx" version = "0.31.0" @@ -2119,10 +2303,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08d5973cb8cd94a77d03ad7e23bbe14889cb29805da1cec0e4aff75e21aebded" dependencies = [ "bitflags", - "io-lifetimes", + "io-lifetimes 0.5.3", "winapi", ] +[[package]] +name = "winx" +version = "0.33.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7b01e010390eb263a4518c8cebf86cb67469d1511c00b749a47b64c39e8054d" +dependencies = [ + "bitflags", + "io-lifetimes 0.7.5", + "windows-sys 0.36.1", +] + [[package]] name = "witx" version = "0.9.1" @@ -2140,7 +2335,7 @@ name = "wizer" version = "1.6.1-beta.4" dependencies = [ "anyhow", - "cap-std", + "cap-std 0.24.2", "criterion", "env_logger 0.8.4", "log", diff --git a/crates/wizer/Cargo.toml b/crates/wizer/Cargo.toml index e4c58e3f9b20..e6de990a8fa1 100644 --- a/crates/wizer/Cargo.toml +++ b/crates/wizer/Cargo.toml @@ -33,11 +33,11 @@ env_logger = { version = "0.8.2", optional = true } log = "0.4.14" rayon = "1.5.0" structopt = { version = "0.3.21", optional = true } -wasi-cap-std-sync = "0.38.0" +wasi-cap-std-sync = "3.0.0" wasm-encoder = "0.6.0" wasmparser = "0.78.2" -wasmtime = "0.38.0" -wasmtime-wasi = "0.38.0" +wasmtime = "3.0.0" +wasmtime-wasi = "3.0.0" # Enable this dependency to get messages with WAT disassemblies when certain # internal panics occur. diff --git a/crates/wizer/fuzz/Cargo.toml b/crates/wizer/fuzz/Cargo.toml index a6d280ce7b8c..ced21360f21c 100644 --- a/crates/wizer/fuzz/Cargo.toml +++ b/crates/wizer/fuzz/Cargo.toml @@ -15,7 +15,7 @@ libfuzzer-sys = "0.4" log = "0.4.14" wasm-smith = "0.4.0" wasmprinter = "0.2.26" -wasmtime = "0.38.0" +wasmtime = "3.0.0" [dependencies.wizer] path = ".." diff --git a/crates/wizer/src/dummy.rs b/crates/wizer/src/dummy.rs index 0a6500a878e4..030888124833 100644 --- a/crates/wizer/src/dummy.rs +++ b/crates/wizer/src/dummy.rs @@ -2,7 +2,7 @@ //! //! Forked from `wasmtime/crates/fuzzing/src/oracles/dummy.rs`. -use anyhow::Result; +use anyhow::{anyhow, Result}; use wasmtime::*; /// Create dummy imports for instantiating the module. @@ -54,12 +54,12 @@ pub fn dummy_extern(store: &mut crate::Store, ty: ExternType, name: &str) -> Res pub fn dummy_func(store: &mut crate::Store, ty: FuncType, name: &str) -> Func { let name = name.to_string(); Func::new(store, ty.clone(), move |_caller, _params, _results| { - Err(Trap::new(format!( + Err(anyhow!( "Error: attempted to call an unknown imported function: {}\n\ \n\ You cannot call arbitrary imported functions during Wizer initialization.", name, - ))) + )) }) } diff --git a/crates/wizer/tests/make_linker.rs b/crates/wizer/tests/make_linker.rs index ebde070e9a7e..2a43c91d394b 100644 --- a/crates/wizer/tests/make_linker.rs +++ b/crates/wizer/tests/make_linker.rs @@ -1,4 +1,4 @@ -use anyhow::{Context, Result}; +use anyhow::{anyhow, Context, Result}; use std::rc::Rc; use wat::parse_str as wat_to_wasm; use wizer::Wizer; @@ -41,8 +41,8 @@ fn run_wasm(args: &[wasmtime::Val], expected: i32, wasm: &[u8]) -> Result<()> { wasmtime::Module::new(store.engine(), wasm).context("Wasm test case failed to compile")?; let mut linker = wasmtime::Linker::new(&engine); - linker.func_wrap("foo", "bar", |_: i32| -> Result { - Err(wasmtime::Trap::new("shouldn't be called")) + linker.func_wrap("foo", "bar", |_: i32| -> Result { + Err(anyhow!("shouldn't be called")) })?; let instance = linker.instantiate(&mut store, &module)?; diff --git a/crates/wizer/tests/tests.rs b/crates/wizer/tests/tests.rs index cb56f718f18c..dbd9182f1203 100644 --- a/crates/wizer/tests/tests.rs +++ b/crates/wizer/tests/tests.rs @@ -42,9 +42,6 @@ fn run_wasm(args: &[wasmtime::Val], expected: i32, wasm: &[u8]) -> Result<()> { let module = wasmtime::Module::new(store.engine(), wasm).context("Wasm test case failed to compile")?; - let dummy_module = wasmtime::Module::new(store.engine(), &wat::parse_str("(module)")?)?; - let dummy_instance = wasmtime::Instance::new(&mut store, &dummy_module, &[])?; - let mut linker = wasmtime::Linker::new(&engine); linker .define_name("dummy_func", wasmtime::Func::wrap(&mut store, || {}))? @@ -135,6 +132,31 @@ fn basic_memory() -> Result<()> { ) } +#[test] +fn multi_memory() -> Result<()> { + run_wat( + &[], + 42, + r#" +(module + (memory $m1 1) + (memory $m2 1) + (func (export "wizer.initialize") + i32.const 0 + i32.const 41 + i32.store $m1 offset=1337 + i32.const 0 + i32.const 1 + i32.store $m2 offset=1) + (func (export "run") (result i32) + i32.const 0 + i32.load $m1 offset=1337 + i32.const 0 + i32.load $m2 offset=1 + i32.add)) +"#, + ) +} #[test] fn reject_imported_memory() -> Result<()> { fails_wizening( From bd4157cdf45db103f88936f93e0581521fa3ce09 Mon Sep 17 00:00:00 2001 From: Jake Champion Date: Mon, 9 Jan 2023 17:30:16 +0000 Subject: [PATCH 132/212] Update tests.rs --- crates/wizer/tests/tests.rs | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/crates/wizer/tests/tests.rs b/crates/wizer/tests/tests.rs index dbd9182f1203..48b17a7c9daa 100644 --- a/crates/wizer/tests/tests.rs +++ b/crates/wizer/tests/tests.rs @@ -139,21 +139,21 @@ fn multi_memory() -> Result<()> { 42, r#" (module - (memory $m1 1) - (memory $m2 1) - (func (export "wizer.initialize") - i32.const 0 - i32.const 41 - i32.store $m1 offset=1337 - i32.const 0 - i32.const 1 - i32.store $m2 offset=1) - (func (export "run") (result i32) - i32.const 0 - i32.load $m1 offset=1337 - i32.const 0 - i32.load $m2 offset=1 - i32.add)) + (memory $m1 1) + (memory $m2 1) + (func (export "wizer.initialize") + i32.const 0 + i32.const 41 + i32.store $m1 offset=1337 + i32.const 0 + i32.const 1 + i32.store $m2 offset=1337) + (func (export "run") (result i32) + i32.const 0 + i32.load $m1 offset=1337 + i32.const 0 + i32.load $m2 offset=1337 + i32.add)) "#, ) } From aa37665bec72ed6074891ed4d996f687b52e2764 Mon Sep 17 00:00:00 2001 From: Jake Champion Date: Tue, 10 Jan 2023 00:05:48 +0000 Subject: [PATCH 133/212] print out the pre-wizened wasm when debugging --- crates/wizer/tests/tests.rs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/crates/wizer/tests/tests.rs b/crates/wizer/tests/tests.rs index 48b17a7c9daa..95e15157f7d6 100644 --- a/crates/wizer/tests/tests.rs +++ b/crates/wizer/tests/tests.rs @@ -20,15 +20,21 @@ fn get_wizer() -> Wizer { fn run_wasm(args: &[wasmtime::Val], expected: i32, wasm: &[u8]) -> Result<()> { let _ = env_logger::try_init(); + log::debug!( + "=== PreWizened Wasm ==========================================================\n\ + {}\n\ + ===========================================================================", + wasmprinter::print_bytes(&wasm).unwrap() + ); let wasm = get_wizer().run(&wasm)?; log::debug!( - "=== Wizened Wasm ==========================================================\n\ - {}\n\ - ===========================================================================", - wasmprinter::print_bytes(&wasm).unwrap() + "=== Wizened Wasm ==========================================================\n\ + {}\n\ + ===========================================================================", + wasmprinter::print_bytes(&wasm).unwrap() ); if log::log_enabled!(log::Level::Debug) { - std::fs::write("test.wasm", &wasm).unwrap(); + std::fs::write("test.wasm", &wasm).unwrap(); } let mut config = wasmtime::Config::new(); From 56c98278ec1112e73baac2d0d07d28ac0004b4af Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 14 Apr 2023 13:32:40 -0700 Subject: [PATCH 134/212] Update wat/wasmprinter deps Bring these up-to-date with the latest. --- crates/wizer/Cargo.lock | 100 ++++++++++++++++++++++++++++++------ crates/wizer/Cargo.toml | 4 +- crates/wizer/tests/tests.rs | 22 ++++---- 3 files changed, 100 insertions(+), 26 deletions(-) diff --git a/crates/wizer/Cargo.lock b/crates/wizer/Cargo.lock index 69753d41cb4a..d154e8b4f5a8 100644 --- a/crates/wizer/Cargo.lock +++ b/crates/wizer/Cargo.lock @@ -664,6 +664,15 @@ dependencies = [ "log", ] +[[package]] +name = "form_urlencoded" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9c384f161156f5260c24a097c56119f9be8c798586aecc13afbcbe7b7e26bf8" +dependencies = [ + "percent-encoding", +] + [[package]] name = "fs-set-times" version = "0.15.0" @@ -796,6 +805,16 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" +[[package]] +name = "idna" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] + [[package]] name = "indexmap" version = "1.9.2" @@ -1080,6 +1099,12 @@ version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "acbf547ad0c65e31259204bd90935776d1c693cec2f4ff7abb7a1bbbd40dfe58" +[[package]] +name = "percent-encoding" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" + [[package]] name = "pin-project-lite" version = "0.2.7" @@ -1600,6 +1625,21 @@ dependencies = [ "serde_json", ] +[[package]] +name = "tinyvec" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + [[package]] name = "toml" version = "0.5.8" @@ -1657,6 +1697,21 @@ dependencies = [ "serde_yaml", ] +[[package]] +name = "unicode-bidi" +version = "0.3.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" + +[[package]] +name = "unicode-normalization" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +dependencies = [ + "tinyvec", +] + [[package]] name = "unicode-segmentation" version = "1.8.0" @@ -1675,6 +1730,17 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" +[[package]] +name = "url" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d68c799ae75762b8c3fe375feb6600ef5602c883c5d21eb51c09f22b83c4643" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", +] + [[package]] name = "vec_map" version = "0.8.2" @@ -1821,9 +1887,9 @@ dependencies = [ [[package]] name = "wasm-encoder" -version = "0.20.0" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05632e0a66a6ed8cca593c24223aabd6262f256c3693ad9822c315285f010614" +checksum = "4eff853c4f09eec94d76af527eddad4e9de13b11d6286a1ef7134bc30135a2b7" dependencies = [ "leb128", ] @@ -1848,27 +1914,31 @@ checksum = "52144d4c78e5cf8b055ceab8e5fa22814ce4315d6002ad32cfd914f37c12fd65" [[package]] name = "wasmparser" -version = "0.80.1" +version = "0.93.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be92b6dcaa5af4b2a176b29be3bf1402fab9e69d313141185099c7d1684f2dca" +checksum = "c5a4460aa3e271fa180b6a5d003e728f3963fb30e3ba0fa7c9634caa06049328" +dependencies = [ + "indexmap", +] [[package]] name = "wasmparser" -version = "0.93.0" +version = "0.103.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5a4460aa3e271fa180b6a5d003e728f3963fb30e3ba0fa7c9634caa06049328" +checksum = "2c437373cac5ea84f1113d648d51f71751ffbe3d90c00ae67618cf20d0b5ee7b" dependencies = [ "indexmap", + "url", ] [[package]] name = "wasmprinter" -version = "0.2.29" +version = "0.2.55" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f62f18810edc34db799bcb3d555835b2eecc9b6b221f8ee74fdb5aae0bffa176" +checksum = "51befda9d7eefac615a2ef75f42d2f2bd243cdabaa141a8ea0f9ffa3fc79ccf4" dependencies = [ "anyhow", - "wasmparser 0.80.1", + "wasmparser 0.103.0", ] [[package]] @@ -2094,23 +2164,23 @@ dependencies = [ [[package]] name = "wast" -version = "50.0.0" +version = "56.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2cbb59d4ac799842791fe7e806fa5dbbf6b5554d538e51cc8e176db6ff0ae34" +checksum = "6b54185c051d7bbe23757d50fe575880a2426a2f06d2e9f6a10fd9a4a42920c0" dependencies = [ "leb128", "memchr", "unicode-width", - "wasm-encoder 0.20.0", + "wasm-encoder 0.25.0", ] [[package]] name = "wat" -version = "1.0.52" +version = "1.0.62" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "584aaf7a1ecf4d383bbe1a25eeab0cbb8ff96acc6796707ff65cde48f4632f15" +checksum = "56681922808216ab86d96bb750f70d500b5a7800e41564290fd46bb773581299" dependencies = [ - "wast 50.0.0", + "wast 56.0.0", ] [[package]] diff --git a/crates/wizer/Cargo.toml b/crates/wizer/Cargo.toml index e6de990a8fa1..4d46480e1814 100644 --- a/crates/wizer/Cargo.toml +++ b/crates/wizer/Cargo.toml @@ -49,8 +49,8 @@ optional = true [dev-dependencies] criterion = "0.3.4" env_logger = "0.8.2" -wasmprinter = "0.2.26" -wat = "1.0.36" +wasmprinter = "0.2.55" +wat = "1.0.62" [workspace] members = [ diff --git a/crates/wizer/tests/tests.rs b/crates/wizer/tests/tests.rs index 95e15157f7d6..f56ab4c10cef 100644 --- a/crates/wizer/tests/tests.rs +++ b/crates/wizer/tests/tests.rs @@ -21,20 +21,20 @@ fn run_wasm(args: &[wasmtime::Val], expected: i32, wasm: &[u8]) -> Result<()> { let _ = env_logger::try_init(); log::debug!( - "=== PreWizened Wasm ==========================================================\n\ + "=== PreWizened Wasm ==========================================================\n\ {}\n\ ===========================================================================", - wasmprinter::print_bytes(&wasm).unwrap() + wasmprinter::print_bytes(&wasm).unwrap() ); let wasm = get_wizer().run(&wasm)?; log::debug!( - "=== Wizened Wasm ==========================================================\n\ + "=== Wizened Wasm ==========================================================\n\ {}\n\ ===========================================================================", - wasmprinter::print_bytes(&wasm).unwrap() + wasmprinter::print_bytes(&wasm).unwrap() ); if log::log_enabled!(log::Level::Debug) { - std::fs::write("test.wasm", &wasm).unwrap(); + std::fs::write("test.wasm", &wasm).unwrap(); } let mut config = wasmtime::Config::new(); @@ -453,13 +453,17 @@ fn rename_functions() -> Result<()> { (type (;1;) (func (result i32))) (func (;0;) (type 0)) (func (;1;) (type 1) (result i32) - i32.const 1) + i32.const 1 + ) (func (;2;) (type 1) (result i32) - i32.const 2) + i32.const 2 + ) (func (;3;) (type 1) (result i32) - i32.const 3) + i32.const 3 + ) (export "func_a" (func 2)) - (export "func_b" (func 3))) + (export "func_b" (func 3)) +) "#; assert_eq!(wat.trim(), expected_wat.trim()); From edd561f7cb537f59aa36249af34af0b723da3c9f Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 14 Apr 2023 14:31:36 -0700 Subject: [PATCH 135/212] Update wasmparser/wasm-encoder deps incrementally These dependencies are far behind the latest versions so this fast-forwards them up to versions where larger changes are required. This updates them enough to perform some minor rewrites here and there but nothing major is changing. --- crates/wizer/Cargo.lock | 12 ++++----- crates/wizer/Cargo.toml | 4 +-- crates/wizer/src/info.rs | 4 +-- crates/wizer/src/info/types_interner.rs | 2 +- crates/wizer/src/instrument.rs | 2 +- crates/wizer/src/lib.rs | 6 +++++ crates/wizer/src/parse.rs | 34 +++++++++++++------------ crates/wizer/src/rewrite.rs | 9 ++++--- crates/wizer/src/translate.rs | 25 ++++++++---------- crates/wizer/tests/tests.rs | 10 ++++---- 10 files changed, 56 insertions(+), 52 deletions(-) diff --git a/crates/wizer/Cargo.lock b/crates/wizer/Cargo.lock index d154e8b4f5a8..2bbb74e5ffb1 100644 --- a/crates/wizer/Cargo.lock +++ b/crates/wizer/Cargo.lock @@ -1878,9 +1878,9 @@ dependencies = [ [[package]] name = "wasm-encoder" -version = "0.6.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2caacc74c68c74f0008c4055cdf509c43e623775eaf73323bb818dcf666ed9bd" +checksum = "aa9d9bf45fc46f71c407837c9b30b1e874197f2dc357588430b21e5017d290ab" dependencies = [ "leb128", ] @@ -1908,9 +1908,9 @@ dependencies = [ [[package]] name = "wasmparser" -version = "0.78.2" +version = "0.83.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52144d4c78e5cf8b055ceab8e5fa22814ce4315d6002ad32cfd914f37c12fd65" +checksum = "718ed7c55c2add6548cca3ddd6383d738cd73b892df400e96b9aa876f0141d7a" [[package]] name = "wasmparser" @@ -2412,8 +2412,8 @@ dependencies = [ "rayon", "structopt", "wasi-cap-std-sync", - "wasm-encoder 0.6.0", - "wasmparser 0.78.2", + "wasm-encoder 0.10.0", + "wasmparser 0.83.0", "wasmprinter", "wasmtime", "wasmtime-wasi", diff --git a/crates/wizer/Cargo.toml b/crates/wizer/Cargo.toml index 4d46480e1814..d833da3b3c37 100644 --- a/crates/wizer/Cargo.toml +++ b/crates/wizer/Cargo.toml @@ -34,8 +34,8 @@ log = "0.4.14" rayon = "1.5.0" structopt = { version = "0.3.21", optional = true } wasi-cap-std-sync = "3.0.0" -wasm-encoder = "0.6.0" -wasmparser = "0.78.2" +wasm-encoder = "0.10.0" +wasmparser = "0.83.0" wasmtime = "3.0.0" wasmtime-wasi = "3.0.0" diff --git a/crates/wizer/src/info.rs b/crates/wizer/src/info.rs index 738157a353c8..a5fbc4165bd8 100644 --- a/crates/wizer/src/info.rs +++ b/crates/wizer/src/info.rs @@ -355,7 +355,7 @@ impl Module { wasmparser::ImportSectionEntryType::Module(_) => { unreachable!("we disallow module imports; checked in validation") } - wasmparser::ImportSectionEntryType::Event(_) => { + wasmparser::ImportSectionEntryType::Tag(_) => { unreachable!("exceptions are unsupported; checked in validation") } } @@ -439,7 +439,7 @@ impl Module { } wasmparser::ExternalKind::Module | wasmparser::ExternalKind::Type - | wasmparser::ExternalKind::Event => unreachable!(), + | wasmparser::ExternalKind::Tag => unreachable!(), }; (name, entity) }) diff --git a/crates/wizer/src/info/types_interner.rs b/crates/wizer/src/info/types_interner.rs index b6179b718b16..4b1df0882083 100644 --- a/crates/wizer/src/info/types_interner.rs +++ b/crates/wizer/src/info/types_interner.rs @@ -161,7 +161,7 @@ impl<'a> TypesInterner<'a> { wasmparser::ImportSectionEntryType::Instance(idx) => { EntityType::Instance(types_space[usize::try_from(idx).unwrap()]) } - wasmparser::ImportSectionEntryType::Event(_) => unreachable!(), + wasmparser::ImportSectionEntryType::Tag(_) => unreachable!(), } } diff --git a/crates/wizer/src/instrument.rs b/crates/wizer/src/instrument.rs index 377cbabac99a..5f959c592e97 100644 --- a/crates/wizer/src/instrument.rs +++ b/crates/wizer/src/instrument.rs @@ -135,7 +135,7 @@ pub(crate) fn instrument(cx: &ModuleContext<'_>) -> Vec { } wasmparser::ExternalKind::Module | wasmparser::ExternalKind::Type - | wasmparser::ExternalKind::Event => { + | wasmparser::ExternalKind::Tag => { unreachable!("should have been rejected in validation/parsing") } }, diff --git a/crates/wizer/src/lib.rs b/crates/wizer/src/lib.rs index 884fec5880c4..3afa289f18e4 100644 --- a/crates/wizer/src/lib.rs +++ b/crates/wizer/src/lib.rs @@ -559,6 +559,10 @@ impl Wizer { // NB: keep this in sync with the Wasmtime config. fn wasm_features(&self) -> wasmparser::WasmFeatures { wasmparser::WasmFeatures { + mutable_global: true, + saturating_float_to_int: true, + sign_extension: true, + // Proposals that we support. multi_memory: self.wasm_multi_memory.unwrap_or(DEFAULT_WASM_MULTI_MEMORY), multi_value: self.wasm_multi_value.unwrap_or(DEFAULT_WASM_MULTI_VALUE), @@ -573,6 +577,8 @@ impl Wizer { tail_call: false, memory64: false, exceptions: false, + extended_const: false, + relaxed_simd: false, // XXX: Though we don't fully support bulk memory yet, we // unconditionally turn it on. diff --git a/crates/wizer/src/parse.rs b/crates/wizer/src/parse.rs index 474dcf64be3d..567907671532 100644 --- a/crates/wizer/src/parse.rs +++ b/crates/wizer/src/parse.rs @@ -116,7 +116,7 @@ pub(crate) fn parse<'a>(full_wasm: &'a [u8]) -> anyhow::Result } CodeSectionEntry(_) => unreachable!(), UnknownSection { .. } => anyhow::bail!("unknown section"), - EventSection(_) => anyhow::bail!("exceptions are not supported yet"), + TagSection(_) => anyhow::bail!("exceptions are not supported yet"), End => { let entry = stack.pop().unwrap(); @@ -329,19 +329,21 @@ fn check_import_type( _ => unreachable!(), } } - EntityType::Memory(mem_ty) => match mem_ty { - wasmparser::MemoryType::M32 { limits: _, shared } => { - anyhow::ensure!(!shared, "shared memories are not supported by Wizer yet"); - anyhow::ensure!( - !is_root, - "memory imports are not allowed in the root Wasm module" - ); - Ok(()) - } - wasmparser::MemoryType::M64 { .. } => { - anyhow::bail!("the memory64 proposal is not supported by Wizer yet") - } - }, + EntityType::Memory(mem_ty) => { + anyhow::ensure!( + !mem_ty.shared, + "shared memories are not supported by Wizer yet" + ); + anyhow::ensure!( + !mem_ty.memory64, + "the memory64 proposal is not supported by Wizer yet" + ); + anyhow::ensure!( + !is_root, + "memory imports are not allowed in the root Wasm module" + ); + Ok(()) + } EntityType::Table(_) | EntityType::Global(_) => { anyhow::ensure!( !is_root, @@ -436,7 +438,7 @@ fn alias_section<'a>( }; module.push_imported_global(cx, ty); } - wasmparser::ExternalKind::Event => { + wasmparser::ExternalKind::Tag => { unreachable!("validation should reject the exceptions proposal") } wasmparser::ExternalKind::Type => unreachable!("can't export types"), @@ -568,7 +570,7 @@ fn export_section<'a>( wasmparser::ExternalKind::Module => { anyhow::bail!("Wizer does not support importing and exporting modules") } - wasmparser::ExternalKind::Type | wasmparser::ExternalKind::Event => { + wasmparser::ExternalKind::Type | wasmparser::ExternalKind::Tag => { unreachable!("checked in validation") } wasmparser::ExternalKind::Function diff --git a/crates/wizer/src/rewrite.rs b/crates/wizer/src/rewrite.rs index 7b9dd1cfb34f..09a0d34bcbe6 100644 --- a/crates/wizer/src/rewrite.rs +++ b/crates/wizer/src/rewrite.rs @@ -59,7 +59,7 @@ impl Wizer { for seg in &snapshot.data_segments { data_section.active( seg.memory_index, - wasm_encoder::Instruction::I32Const(seg.offset as i32), + &wasm_encoder::Instruction::I32Const(seg.offset as i32), seg.data(store).iter().copied(), ); } @@ -115,7 +115,7 @@ impl Wizer { let glob_ty = translate::global_type(glob_ty); globals.global( glob_ty, - match val { + &match val { wasmtime::Val::I32(x) => wasm_encoder::Instruction::I32Const(*x), wasmtime::Val::I64(x) => wasm_encoder::Instruction::I64Const(*x), wasmtime::Val::F32(x) => { @@ -477,6 +477,7 @@ impl Wizer { wasm_encoder::Export::Instance(umbrella_instances - 1) } wasm_encoder::ItemKind::Module => unreachable!(), + wasm_encoder::ItemKind::Tag => unreachable!(), }, ); } @@ -1089,7 +1090,7 @@ fn rewrite_state_module( let glob_ty = translate::global_type(glob_ty); globals.global( glob_ty, - match val { + &match val { wasmtime::Val::I32(x) => wasm_encoder::Instruction::I32Const(*x), wasmtime::Val::I64(x) => wasm_encoder::Instruction::I64Const(*x), wasmtime::Val::F32(x) => { @@ -1120,7 +1121,7 @@ fn rewrite_state_module( for seg in &snapshot.data_segments { data.active( seg.memory_index, - wasm_encoder::Instruction::I32Const(seg.offset as i32), + &wasm_encoder::Instruction::I32Const(seg.offset as i32), seg.data(store).iter().copied(), ); } diff --git a/crates/wizer/src/translate.rs b/crates/wizer/src/translate.rs index 7ff9b837a588..b205e1567409 100644 --- a/crates/wizer/src/translate.rs +++ b/crates/wizer/src/translate.rs @@ -3,8 +3,8 @@ pub(crate) fn table_type(table_ty: wasmparser::TableType) -> wasm_encoder::TableType { wasm_encoder::TableType { element_type: val_type(table_ty.element_type), - minimum: table_ty.limits.initial, - maximum: table_ty.limits.maximum, + minimum: table_ty.initial, + maximum: table_ty.maximum, } } @@ -31,16 +31,11 @@ pub(crate) fn global_type(ty: wasmparser::GlobalType) -> wasm_encoder::GlobalTyp } pub(crate) fn memory_type(ty: wasmparser::MemoryType) -> wasm_encoder::MemoryType { - match ty { - wasmparser::MemoryType::M32 { - shared: false, - limits: lims, - } => wasm_encoder::MemoryType { - minimum: lims.initial.into(), - maximum: lims.maximum.map(|val| val.into()), - memory64: false, - }, - _ => unreachable!("handled in validation"), + assert!(!ty.shared); + wasm_encoder::MemoryType { + minimum: ty.initial.into(), + maximum: ty.maximum.map(|val| val.into()), + memory64: ty.memory64, } } @@ -65,7 +60,7 @@ pub(crate) fn entity_type(ty: wasmparser::ImportSectionEntryType) -> wasm_encode have module types" ) } - wasmparser::ImportSectionEntryType::Event(_) => unreachable!(), + wasmparser::ImportSectionEntryType::Tag(_) => unreachable!(), } } @@ -77,7 +72,7 @@ pub(crate) fn item_kind(kind: wasmparser::ExternalKind) -> wasm_encoder::ItemKin wasmparser::ExternalKind::Global => wasm_encoder::ItemKind::Global, wasmparser::ExternalKind::Module => wasm_encoder::ItemKind::Module, wasmparser::ExternalKind::Instance => wasm_encoder::ItemKind::Instance, - wasmparser::ExternalKind::Type | wasmparser::ExternalKind::Event => unreachable!(), + wasmparser::ExternalKind::Type | wasmparser::ExternalKind::Tag => unreachable!(), } } @@ -88,7 +83,7 @@ pub(crate) fn export(kind: wasmparser::ExternalKind, index: u32) -> wasm_encoder wasmparser::ExternalKind::Table => wasm_encoder::Export::Table(index), wasmparser::ExternalKind::Memory => wasm_encoder::Export::Memory(index), wasmparser::ExternalKind::Instance => wasm_encoder::Export::Instance(index), - wasmparser::ExternalKind::Event + wasmparser::ExternalKind::Tag | wasmparser::ExternalKind::Type | wasmparser::ExternalKind::Module => unreachable!(), } diff --git a/crates/wizer/tests/tests.rs b/crates/wizer/tests/tests.rs index f56ab4c10cef..ad62b4ef9edd 100644 --- a/crates/wizer/tests/tests.rs +++ b/crates/wizer/tests/tests.rs @@ -579,12 +579,12 @@ fn accept_bulk_memory_data_count() -> Result<()> { let mut code = wasm_encoder::CodeSection::new(); let mut func = wasm_encoder::Function::new(vec![]); - func.instruction(wasm_encoder::Instruction::I32Const(42)); - func.instruction(wasm_encoder::Instruction::End); + func.instruction(&wasm_encoder::Instruction::I32Const(42)); + func.instruction(&wasm_encoder::Instruction::End); code.function(&func); let mut func = wasm_encoder::Function::new(vec![]); - func.instruction(wasm_encoder::Instruction::End); + func.instruction(&wasm_encoder::Instruction::End); code.function(&func); module.section(&code); @@ -592,8 +592,8 @@ fn accept_bulk_memory_data_count() -> Result<()> { // We're expecting these two data segments to be merge into one, which will exercise wizer's // ability to output the correct data count (1 instead of 2 above). let mut data = wasm_encoder::DataSection::new(); - data.active(0, wasm_encoder::Instruction::I32Const(0), vec![0, 1, 2, 3]); - data.active(0, wasm_encoder::Instruction::I32Const(4), vec![5, 6, 7, 8]); + data.active(0, &wasm_encoder::Instruction::I32Const(0), vec![0, 1, 2, 3]); + data.active(0, &wasm_encoder::Instruction::I32Const(4), vec![5, 6, 7, 8]); module.section(&data); run_wasm(&[], 42, &module.finish()).unwrap(); From 05cbefa06757fc3c22ba396c878f778f8a99072b Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 14 Apr 2023 15:18:54 -0700 Subject: [PATCH 136/212] Update to wasmparser without module linking This involved deleting quite a bit more module-linking related code in `wizer`. --- crates/wizer/Cargo.lock | 9 +- crates/wizer/Cargo.toml | 2 +- crates/wizer/src/info.rs | 407 +--------- crates/wizer/src/info/types_interner.rs | 137 +--- crates/wizer/src/instrument.rs | 103 +-- crates/wizer/src/lib.rs | 30 +- crates/wizer/src/parse.rs | 324 +------- crates/wizer/src/rewrite.rs | 972 +----------------------- crates/wizer/src/rewrite/renumbering.rs | 57 -- crates/wizer/src/translate.rs | 61 +- crates/wizer/tests/tests.rs | 5 +- 11 files changed, 80 insertions(+), 2027 deletions(-) delete mode 100644 crates/wizer/src/rewrite/renumbering.rs diff --git a/crates/wizer/Cargo.lock b/crates/wizer/Cargo.lock index 2bbb74e5ffb1..ee2103e2b0bd 100644 --- a/crates/wizer/Cargo.lock +++ b/crates/wizer/Cargo.lock @@ -1908,9 +1908,12 @@ dependencies = [ [[package]] name = "wasmparser" -version = "0.83.0" +version = "0.84.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "718ed7c55c2add6548cca3ddd6383d738cd73b892df400e96b9aa876f0141d7a" +checksum = "77dc97c22bb5ce49a47b745bed8812d30206eff5ef3af31424f2c1820c0974b2" +dependencies = [ + "indexmap", +] [[package]] name = "wasmparser" @@ -2413,7 +2416,7 @@ dependencies = [ "structopt", "wasi-cap-std-sync", "wasm-encoder 0.10.0", - "wasmparser 0.83.0", + "wasmparser 0.84.0", "wasmprinter", "wasmtime", "wasmtime-wasi", diff --git a/crates/wizer/Cargo.toml b/crates/wizer/Cargo.toml index d833da3b3c37..56d7d78fd2dc 100644 --- a/crates/wizer/Cargo.toml +++ b/crates/wizer/Cargo.toml @@ -35,7 +35,7 @@ rayon = "1.5.0" structopt = { version = "0.3.21", optional = true } wasi-cap-std-sync = "3.0.0" wasm-encoder = "0.10.0" -wasmparser = "0.83.0" +wasmparser = "0.84.0" wasmtime = "3.0.0" wasmtime-wasi = "3.0.0" diff --git a/crates/wizer/src/info.rs b/crates/wizer/src/info.rs index a5fbc4165bd8..13cb362a7af1 100644 --- a/crates/wizer/src/info.rs +++ b/crates/wizer/src/info.rs @@ -2,14 +2,13 @@ use wasm_encoder::SectionId; pub mod types_interner; -use std::collections::BTreeMap; use std::convert::TryFrom; -use types_interner::{EntityType, InstanceType, Type, TypeId, TypesInterner}; +use types_interner::{EntityType, TypeId, TypesInterner}; /// A collection of info about modules within a module linking bundle. pub(crate) struct ModuleContext<'a> { arena: Vec>, - types: TypesInterner<'a>, + types: TypesInterner, } impl<'a> ModuleContext<'a> { @@ -28,33 +27,15 @@ impl<'a> ModuleContext<'a> { } /// Get the interned types set for this module context. - pub fn types(&self) -> &TypesInterner<'a> { + pub fn types(&self) -> &TypesInterner { &self.types } - /// Does this context represent a single Wasm module that doesn't use module - /// linking, or does it represent a bundle of one or more Wasm modules that - /// use module linking? - pub fn uses_module_linking(&self) -> bool { - self.arena.len() > 1 - || self.root().initial_sections(self).any(|s| { - s.id == SectionId::Alias.into() - || s.id == SectionId::Module.into() - || s.id == SectionId::Instance.into() - }) - } - /// Get a shared reference to the `DefinedModuleInfo` for this module, /// following through aliases. fn defined(&self, module: Module) -> &DefinedModuleInfo<'a> { - let mut id = module.id; - loop { - match &self.arena[id] { - ModuleInfo::Aliased(AliasedModuleInfo { alias_of, .. }) => { - id = *alias_of; - } - ModuleInfo::Defined(d) => return d, - } + match &self.arena[module.id] { + ModuleInfo::Defined(d) => return d, } } @@ -64,22 +45,15 @@ impl<'a> ModuleContext<'a> { /// aliased modules. fn defined_mut(&mut self, module: Module) -> &mut DefinedModuleInfo<'a> { match &mut self.arena[module.id] { - ModuleInfo::Aliased(_) => panic!("not a defined module"), ModuleInfo::Defined(d) => d, } } } enum ModuleInfo<'a> { - Aliased(AliasedModuleInfo), Defined(DefinedModuleInfo<'a>), } -struct AliasedModuleInfo { - /// The id of the other module that this is an alias of. - pub alias_of: usize, -} - /// Info that we keep track of on a per module-within-a-module-linking-bundle /// basis. /// @@ -90,11 +64,6 @@ struct DefinedModuleInfo<'a> { /// The raw sections from the original Wasm input. raw_sections: Vec>, - /// This vector has `n` entries when the module has `n` import sections. The - /// `i`th entry is a count of how many instance imports are in the `i`th - /// import section. - instance_import_counts: Vec, - /// Types available in this module. /// /// We keep track of these for determining how many things we need to @@ -104,24 +73,6 @@ struct DefinedModuleInfo<'a> { /// Imports made by this module. imports: Vec>, - /// Aliases that this module defines. - aliases: Vec>, - - /// Directly nested inner modules of this module. - /// - /// These entries are populated as we finish instrumenting the inner - /// modules. - modules: Vec, - - /// A map from instance indices to each instance's type for all defined, - /// imported, and aliased instances. - instances: Vec, - - /// A map from indices of defined instantiations (as opposed to imported or - /// aliased instantiations) to the id of the module that was instantiated - /// and the import arguments. - instantiations: BTreeMap>)>, - /// A map from global indices to each global's type for all defined, /// imported, and aliased globals. globals: Vec, @@ -172,54 +123,9 @@ pub(crate) struct Module { } impl Module { - /// Construct a new, defined module. - pub fn new_defined(cx: &mut ModuleContext) -> Self { - let id = cx.arena.len(); - cx.arena.push(ModuleInfo::Defined(Default::default())); - Module { id } - } - - /// Construct a new module that is an alias of the given module. - pub fn new_aliased(cx: &mut ModuleContext, alias_of: Module) -> Self { - let id = cx.arena.len(); - cx.arena.push(ModuleInfo::Aliased(AliasedModuleInfo { - alias_of: alias_of.id, - })); - Module { id } - } - - /// Get the pre-order traversal index of this module in its associated - /// module linking bundle. - pub fn pre_order_index(self) -> u32 { - u32::try_from(self.id).unwrap() - } - - /// Get the defined module that this module is an alias of, if any. - /// - /// This will see through all aliases. - pub fn get_aliased(self, cx: &ModuleContext<'_>) -> Option { - if matches!(cx.arena[self.id], ModuleInfo::Defined(_)) { - return None; - } - - let mut id = self.id; - loop { - match &cx.arena[id] { - ModuleInfo::Aliased(AliasedModuleInfo { alias_of, .. }) => { - id = *alias_of; - } - ModuleInfo::Defined(_) => return Some(Module { id }), - } - } - } - /// Translate the given `wasmparser` entity type into its interned /// representation using this module's types space. - pub fn entity_type( - self, - cx: &ModuleContext<'_>, - ty: wasmparser::ImportSectionEntryType, - ) -> EntityType { + pub fn entity_type(self, cx: &ModuleContext<'_>, ty: wasmparser::TypeRef) -> EntityType { cx.types().entity_type(ty, &cx.defined(self).types) } @@ -240,52 +146,14 @@ impl Module { } /// Push a new type into this module's types space. - pub fn push_type<'a>(self, cx: &mut ModuleContext<'a>, ty: wasmparser::TypeDef<'a>) { + pub fn push_type<'a>(self, cx: &mut ModuleContext<'a>, ty: wasmparser::TypeDef) { let types_space = match &cx.arena[self.id] { - ModuleInfo::Aliased(_) => panic!("not a defined module"), ModuleInfo::Defined(d) => &d.types, }; let ty = cx.types.insert_wasmparser(ty, types_space); cx.defined_mut(self).types.push(ty); } - /// Push an aliased type into this module's types space. - pub fn push_aliased_type(self, cx: &mut ModuleContext<'_>, ty: TypeId) { - cx.defined_mut(self).types.push(ty); - } - - /// Push a new module onto this module's list of nested child modules. - pub fn push_child_module(self, cx: &mut ModuleContext<'_>, child: Module) { - cx.defined_mut(self).modules.push(child); - } - - /// Push a new, aliased instance into this module's instance index space. - pub fn push_aliased_instance<'a>(self, cx: &mut ModuleContext<'a>, instance_type: TypeId) { - assert!(cx.types.get(instance_type).is_instance()); - cx.defined_mut(self).instances.push(instance_type); - } - - /// Push a new, imported instance into this module's instance index space. - pub fn push_imported_instance<'a>(self, cx: &mut ModuleContext<'a>, instance_type: TypeId) { - assert!(cx.types.get(instance_type).is_instance()); - cx.defined_mut(self).instances.push(instance_type); - } - - /// Push a new, imported instance into this module's instance index space. - pub fn push_defined_instance<'a>( - self, - cx: &mut ModuleContext<'a>, - instance_type: TypeId, - module: Module, - args: Vec>, - ) { - assert!(cx.types.get(instance_type).is_instance()); - let info = cx.defined_mut(self); - let index = u32::try_from(info.instances.len()).unwrap(); - info.instances.push(instance_type); - info.instantiations.insert(index, (module, args)); - } - /// Push a new imported memory into this module's memory index space. pub fn push_imported_memory(self, cx: &mut ModuleContext, memory_type: wasmparser::MemoryType) { let info = cx.defined_mut(self); @@ -335,53 +203,25 @@ impl Module { // Add the import to the appropriate index space for our current module. match import.ty { - wasmparser::ImportSectionEntryType::Memory(ty) => { + wasmparser::TypeRef::Memory(ty) => { self.push_imported_memory(cx, ty); } - wasmparser::ImportSectionEntryType::Global(ty) => { + wasmparser::TypeRef::Global(ty) => { self.push_imported_global(cx, ty); } - wasmparser::ImportSectionEntryType::Instance(ty_idx) => { - let ty = self.instance_type_at(cx, ty_idx).clone(); - self.push_imported_instance(cx, ty); - } - wasmparser::ImportSectionEntryType::Function(ty_idx) => { + wasmparser::TypeRef::Func(ty_idx) => { let ty = self.type_id_at(cx, ty_idx); self.push_function(cx, ty); } - wasmparser::ImportSectionEntryType::Table(ty) => { + wasmparser::TypeRef::Table(ty) => { self.push_table(cx, ty); } - wasmparser::ImportSectionEntryType::Module(_) => { - unreachable!("we disallow module imports; checked in validation") - } - wasmparser::ImportSectionEntryType::Tag(_) => { + wasmparser::TypeRef::Tag(_) => { unreachable!("exceptions are unsupported; checked in validation") } } } - /// Push a count of how many instance imports an import section had. - pub fn push_instance_import_count(self, cx: &mut ModuleContext<'_>, count: u32) { - cx.defined_mut(self).instance_import_counts.push(count); - } - - /// Push an instance implicitly created by a two-level import into this - /// module. - pub fn push_implicit_instance<'a>( - self, - cx: &mut ModuleContext<'a>, - instance_type: InstanceType<'a>, - ) { - let ty = cx.types.insert(Type::Instance(instance_type)); - cx.defined_mut(self).instances.push(ty); - } - - /// Push an alias into this module. - pub fn push_alias<'a>(self, cx: &mut ModuleContext<'a>, alias: wasmparser::Alias<'a>) { - cx.defined_mut(self).aliases.push(alias); - } - /// Push an export into this module. pub fn push_export<'a>(self, cx: &mut ModuleContext<'a>, export: wasmparser::Export<'a>) { cx.defined_mut(self).exports.push(export); @@ -392,147 +232,6 @@ impl Module { self.id == 0 } - /// Define an instance type for this module's exports. - /// - /// Returns the index of the type and updates the total count of types in - /// `num_types`. - pub fn define_instance_type(self, cx: &mut ModuleContext<'_>) -> TypeId { - // Inline `cx.defined(self)` to avoid borrowck errors. - let info = { - let mut id = self.id; - loop { - match &cx.arena[id] { - ModuleInfo::Aliased(AliasedModuleInfo { alias_of, .. }) => { - id = *alias_of; - } - ModuleInfo::Defined(d) => break d, - } - } - }; - - cx.types.insert(Type::Instance(InstanceType { - exports: info - .exports - .iter() - .map(|e| { - let name = e.field.into(); - let index = usize::try_from(e.index).unwrap(); - let entity = match e.kind { - wasmparser::ExternalKind::Function => { - let func_ty = info.functions[index]; - EntityType::Function(func_ty) - } - wasmparser::ExternalKind::Table => { - let ty = info.tables[index]; - EntityType::Table(ty) - } - wasmparser::ExternalKind::Memory => { - let ty = info.memories[index]; - EntityType::Memory(ty) - } - wasmparser::ExternalKind::Global => { - let ty = info.globals[index]; - EntityType::Global(ty) - } - wasmparser::ExternalKind::Instance => { - EntityType::Instance(info.instances[index]) - } - wasmparser::ExternalKind::Module - | wasmparser::ExternalKind::Type - | wasmparser::ExternalKind::Tag => unreachable!(), - }; - (name, entity) - }) - .collect(), - })) - } - - /// Define an instance type for this module's state. - pub fn define_state_instance_type(self, cx: &mut ModuleContext<'_>) -> TypeId { - // Define instance types for each of the instances that we instantiate - // locally so that we can refer to these types in the state instance's - // type. - let instantiated_modules: Vec<_> = - self.instantiations(cx).values().map(|(m, _)| *m).collect(); - let instance_types = instantiated_modules - .into_iter() - .map(|m| m.define_instance_type(cx)) - .collect::>(); - - // Define the state instance type. - cx.types.insert(Type::Instance(InstanceType { - exports: self - .defined_globals(cx) - .enumerate() - .map(|(i, (_, g))| { - ( - format!("__wizer_global_{}", i).into(), - EntityType::Global(g), - ) - }) - .chain(self.defined_memories(cx).enumerate().map(|(i, (_, m))| { - ( - format!("__wizer_memory_{}", i).into(), - EntityType::Memory(m), - ) - })) - .chain(instance_types.iter().enumerate().map(|(i, ty)| { - ( - format!("__wizer_instance_{}", i).into(), - EntityType::Instance(*ty), - ) - })) - .collect(), - })) - } - - /// Get the count of how many instance imports are in each import section in - /// this module. - pub fn instance_import_counts<'b>(self, cx: &'b ModuleContext<'_>) -> &'b [u32] { - &cx.defined(self).instance_import_counts - } - - /// Get the aliases defined in this module. - pub fn aliases<'a, 'b>(self, cx: &'b ModuleContext<'a>) -> &'b [wasmparser::Alias<'a>] { - &cx.defined(self).aliases - } - - /// Get an export from the `n`th instance by name. - pub fn instance_export<'b>( - self, - cx: &'b ModuleContext<'_>, - instance: u32, - name: &str, - ) -> Option<&'b EntityType> { - let instance = usize::try_from(instance).unwrap(); - let info = cx.defined(self); - let type_id = info.instances[instance]; - let instance = match cx.types.get(type_id) { - Type::Instance(i) => i, - _ => unreachable!(), - }; - instance.exports.get(name) - } - - /// Do a pre-order traversal over this module tree. - pub fn pre_order<'a, F>(self, cx: &mut ModuleContext<'a>, mut f: F) - where - F: FnMut(&mut ModuleContext<'a>, Module), - { - let mut stack = vec![self]; - while let Some(module) = stack.pop() { - f(cx, module); - let info = cx.defined(module); - stack.extend(info.modules.iter().copied().rev()); - } - } - - /// Get the first index in the memory space where a memory is defined rather - /// than aliased or imported. - pub fn defined_memories_index(self, cx: &ModuleContext) -> Option { - cx.defined(self).defined_memories_index - } - /// The number of defined memories in this module. pub fn defined_memories_len(self, cx: &ModuleContext) -> usize { let info = cx.defined(self); @@ -560,22 +259,6 @@ impl Module { .map(|(i, m)| (u32::try_from(i).unwrap(), m)) } - /// Get the first index in the global space where a global is defined rather - /// than aliased or imported. - pub fn defined_globals_index(self, cx: &ModuleContext) -> Option { - cx.defined(self).defined_globals_index - } - - /// The number of defined globals in this module. - pub fn defined_globals_len(self, cx: &ModuleContext<'_>) -> usize { - let info = cx.defined(self); - info.defined_globals_index.map_or(0, |n| { - let n = usize::try_from(n).unwrap(); - assert!(info.globals.len() > n); - info.globals.len() - n - }) - } - /// Iterate over the defined globals in this module. pub fn defined_globals<'b>( self, @@ -593,25 +276,6 @@ impl Module { .map(|(i, g)| (u32::try_from(i).unwrap(), g)) } - /// Iterate over the initial sections in this Wasm module. - pub fn initial_sections<'a, 'b>( - self, - cx: &'b ModuleContext<'a>, - ) -> impl Iterator> + 'b { - let info = cx.defined(self); - info.raw_sections - .iter() - .filter(|s| s.id != SectionId::Custom.into()) - .take_while(|s| match s.id { - x if x == SectionId::Type.into() => true, - x if x == SectionId::Import.into() => true, - x if x == SectionId::Alias.into() => true, - x if x == SectionId::Module.into() => true, - x if x == SectionId::Instance.into() => true, - _ => false, - }) - } - /// Get a slice of this module's original raw sections. pub fn raw_sections<'a, 'b>( self, @@ -620,67 +284,20 @@ impl Module { &cx.defined(self).raw_sections } - /// Get a slice of this module's nested child modules. - pub fn child_modules<'b>(self, cx: &'b ModuleContext<'_>) -> &'b [Module] { - &cx.defined(self).modules - } - /// Get a slice of this module's exports. pub fn exports<'a, 'b>(self, cx: &'b ModuleContext<'a>) -> &'b [wasmparser::Export<'a>] { &cx.defined(self).exports } - /// Get a slice of this module's imports. - pub fn imports<'a, 'b>(self, cx: &'b ModuleContext<'a>) -> &'b [wasmparser::Import<'a>] { - &cx.defined(self).imports - } - - /// Get this module's defined (as opposed to imported or aliased) - /// instantiations. - /// - /// The return value maps an instance index to the module that was - /// instantiated and the associated instantiation arguments. - pub fn instantiations<'a, 'b>( - self, - cx: &'b ModuleContext<'a>, - ) -> &'b BTreeMap>)> { - &cx.defined(self).instantiations - } - - /// Get this module's `n`th nested child module. - pub fn child_module_at(self, cx: &ModuleContext<'_>, n: u32) -> Module { - cx.defined(self).modules[usize::try_from(n).unwrap()] - } - /// Get the full types index space for this module. pub fn types<'a, 'b>(self, cx: &'b ModuleContext<'a>) -> &'b [TypeId] { &cx.defined(self).types } - /// Get the type at the given index. - /// - /// Panics if the types index space does not contain the given index. - pub fn type_at<'a, 'b>(self, cx: &'b ModuleContext<'a>, type_index: u32) -> &'b Type<'a> { - let id = self.type_id_at(cx, type_index); - cx.types.get(id) - } - /// Get the type at the given index. /// /// Panics if the types index space does not contain the given index. pub fn type_id_at(self, cx: &ModuleContext<'_>, type_index: u32) -> TypeId { cx.defined(self).types[usize::try_from(type_index).unwrap()] } - - /// Get the id for instance type at the given type index. - /// - /// Panics if the types index space does not contain the given index or the - /// type at the index is not an instance type. - pub fn instance_type_at<'a, 'b>(self, cx: &'b ModuleContext<'a>, type_index: u32) -> TypeId { - if let Type::Instance(_) = self.type_at(cx, type_index) { - self.types(cx)[usize::try_from(type_index).unwrap()] - } else { - panic!("not an instance type") - } - } } diff --git a/crates/wizer/src/info/types_interner.rs b/crates/wizer/src/info/types_interner.rs index 4b1df0882083..91cade06ef9c 100644 --- a/crates/wizer/src/info/types_interner.rs +++ b/crates/wizer/src/info/types_interner.rs @@ -1,9 +1,4 @@ -use std::{ - borrow::Cow, - collections::{BTreeMap, HashMap}, - convert::TryFrom, - rc::Rc, -}; +use std::{collections::HashMap, convert::TryFrom, rc::Rc}; /// A de-duplicated set of type definitions. /// @@ -16,38 +11,26 @@ use std::{ /// refer to these types, and pull them into their nested types index space, via /// outer type aliases. #[derive(Default)] -pub struct TypesInterner<'a> { +pub struct TypesInterner { /// The interned types. - types: Vec>>, + types: Vec>, /// An map from a type to its index in `self.types`. - type_to_index: HashMap>, u32>, + type_to_index: HashMap, u32>, } /// An interned Wasm type definition. #[derive(PartialEq, Eq, Hash)] -pub enum Type<'a> { +pub enum Type { Func(wasmparser::FuncType), - Instance(InstanceType<'a>), - Module(ModuleType<'a>), } -impl Type<'_> { - pub fn is_instance(&self) -> bool { - matches!(self, Type::Instance(_)) - } - +impl Type { pub fn is_func(&self) -> bool { matches!(self, Type::Func(_)) } } -/// An interned Wasm instance type. -#[derive(PartialEq, Eq, Hash)] -pub struct InstanceType<'a> { - pub exports: BTreeMap, EntityType>, -} - /// An interned type for some kind of Wasm entity. #[derive(PartialEq, Eq, Hash)] pub enum EntityType { @@ -55,15 +38,6 @@ pub enum EntityType { Table(wasmparser::TableType), Memory(wasmparser::MemoryType), Global(wasmparser::GlobalType), - Module(TypeId), - Instance(TypeId), -} - -/// An interned Wasm module type. -#[derive(PartialEq, Eq, Hash)] -pub struct ModuleType<'a> { - pub imports: BTreeMap<(Cow<'a, str>, Option>), EntityType>, - pub exports: BTreeMap, EntityType>, } /// An id of a type in a `TypesInterner` type set. @@ -72,30 +46,9 @@ pub struct TypeId { index: u32, } -impl TypeId { - /// Get the index of this type inside its `TypesInterner`. - /// - /// This index is *not* the same as the index within a particular module's - /// index space, it is within the `TypesInterner`'s index space (except for - /// the eventual umbrella module, whose types index space matches the - /// interner's index space). - pub fn index(self) -> u32 { - self.index - } -} - -impl<'a> TypesInterner<'a> { - /// Iterate over the types defined in this type set and their index. - pub fn iter<'b>(&'b self) -> impl Iterator)> + 'b { - assert!((self.types.len() as u64) < (u32::MAX as u64)); - self.types - .iter() - .enumerate() - .map(|(idx, ty)| (u32::try_from(idx).unwrap(), &**ty)) - } - +impl TypesInterner { /// Get a type by id. - pub fn get(&self, id: TypeId) -> &Type<'a> { + pub fn get(&self, id: TypeId) -> &Type { &*self.types[usize::try_from(id.index).unwrap()] } @@ -108,17 +61,11 @@ impl<'a> TypesInterner<'a> { /// that entry and its id are reused. pub fn insert_wasmparser( &mut self, - ty: wasmparser::TypeDef<'a>, - types_space: &[TypeId], + ty: wasmparser::TypeDef, + _types_space: &[TypeId], ) -> TypeId { match ty { wasmparser::TypeDef::Func(func_ty) => self.insert(Type::Func(func_ty)), - wasmparser::TypeDef::Instance(inst_ty) => { - self.insert_wasmparser_instance_type(inst_ty, types_space) - } - wasmparser::TypeDef::Module(module_ty) => { - self.insert_wasmparser_module_type(module_ty, types_space) - } } } @@ -126,7 +73,7 @@ impl<'a> TypesInterner<'a> { /// /// If the type has already been inserted and assigned an id before, then /// that entry and its id are reused. - pub fn insert(&mut self, ty: Type<'a>) -> TypeId { + pub fn insert(&mut self, ty: Type) -> TypeId { if let Some(index) = self.type_to_index.get(&ty).copied() { return TypeId { index }; } @@ -138,68 +85,20 @@ impl<'a> TypesInterner<'a> { TypeId { index } } - /// Convert a `wasmparser::ImportSectionEntryType` into an interned + /// Convert a `wasmparser::EntityType` into an interned /// `EntityType`. /// /// The provided `types_space` must be a slice of the defining module's /// types index space. - pub fn entity_type( - &self, - ty: wasmparser::ImportSectionEntryType, - types_space: &[TypeId], - ) -> EntityType { + pub fn entity_type(&self, ty: wasmparser::TypeRef, types_space: &[TypeId]) -> EntityType { match ty { - wasmparser::ImportSectionEntryType::Function(idx) => { + wasmparser::TypeRef::Func(idx) => { EntityType::Function(types_space[usize::try_from(idx).unwrap()]) } - wasmparser::ImportSectionEntryType::Table(ty) => EntityType::Table(ty), - wasmparser::ImportSectionEntryType::Memory(ty) => EntityType::Memory(ty), - wasmparser::ImportSectionEntryType::Global(ty) => EntityType::Global(ty), - wasmparser::ImportSectionEntryType::Module(idx) => { - EntityType::Module(types_space[usize::try_from(idx).unwrap()]) - } - wasmparser::ImportSectionEntryType::Instance(idx) => { - EntityType::Instance(types_space[usize::try_from(idx).unwrap()]) - } - wasmparser::ImportSectionEntryType::Tag(_) => unreachable!(), + wasmparser::TypeRef::Table(ty) => EntityType::Table(ty), + wasmparser::TypeRef::Memory(ty) => EntityType::Memory(ty), + wasmparser::TypeRef::Global(ty) => EntityType::Global(ty), + wasmparser::TypeRef::Tag(_) => unreachable!(), } } - - fn insert_wasmparser_instance_type( - &mut self, - inst_ty: wasmparser::InstanceType<'a>, - types_space: &[TypeId], - ) -> TypeId { - self.insert(Type::Instance(InstanceType { - exports: inst_ty - .exports - .iter() - .map(|exp| (exp.name.into(), self.entity_type(exp.ty, types_space))) - .collect(), - })) - } - - fn insert_wasmparser_module_type( - &mut self, - module_ty: wasmparser::ModuleType<'a>, - types_space: &[TypeId], - ) -> TypeId { - self.insert(Type::Module(ModuleType { - imports: module_ty - .imports - .iter() - .map(|imp| { - ( - (imp.module.into(), imp.field.map(Cow::from)), - self.entity_type(imp.ty, types_space), - ) - }) - .collect(), - exports: module_ty - .exports - .iter() - .map(|exp| (exp.name.into(), self.entity_type(exp.ty, types_space))) - .collect(), - })) - } } diff --git a/crates/wizer/src/instrument.rs b/crates/wizer/src/instrument.rs index 5f959c592e97..6ed69ad88a7c 100644 --- a/crates/wizer/src/instrument.rs +++ b/crates/wizer/src/instrument.rs @@ -2,7 +2,6 @@ use crate::info::{Module, ModuleContext}; use crate::stack_ext::StackExt; -use std::convert::TryFrom; use wasm_encoder::SectionId; /// Instrument the input Wasm so that it exports its memories and globals, @@ -71,24 +70,6 @@ pub(crate) fn instrument(cx: &ModuleContext<'_>) -> Vec { /// Sections in this module info that we are iterating over. sections: std::slice::Iter<'a, wasm_encoder::RawSection<'a>>, - - /// The index of this entry's parent module on the stack. `None` if this - /// is the root module. - parent_index: Option, - - /// Nested child modules that still need to be instrumented and added to - /// one of this entry's module's module sections. - children: std::slice::Iter<'a, Module>, - - /// The current module section we are building for this entry's - /// module. Only `Some` if we are currently processing this module's - /// (transitive) children, i.e. this is not the module on the top of the - /// stack. - module_section: Option, - - /// The number of children still remaining to be interested for the - /// current module section. - children_remaining: usize, } let root = cx.root(); @@ -96,10 +77,6 @@ pub(crate) fn instrument(cx: &ModuleContext<'_>) -> Vec { module: root, encoder: wasm_encoder::Module::new(), sections: root.raw_sections(cx).iter(), - parent_index: None, - children: root.child_modules(cx).iter(), - module_section: None, - children_remaining: 0, }]; loop { @@ -116,9 +93,9 @@ pub(crate) fn instrument(cx: &ModuleContext<'_>) -> Vec { // First, copy over all the original exports. for export in entry.module.exports(cx) { exports.export( - export.field, + export.name, match export.kind { - wasmparser::ExternalKind::Function => { + wasmparser::ExternalKind::Func => { wasm_encoder::Export::Function(export.index) } wasmparser::ExternalKind::Table => { @@ -130,12 +107,7 @@ pub(crate) fn instrument(cx: &ModuleContext<'_>) -> Vec { wasmparser::ExternalKind::Global => { wasm_encoder::Export::Global(export.index) } - wasmparser::ExternalKind::Instance => { - wasm_encoder::Export::Instance(export.index) - } - wasmparser::ExternalKind::Module - | wasmparser::ExternalKind::Type - | wasmparser::ExternalKind::Tag => { + wasmparser::ExternalKind::Tag => { unreachable!("should have been rejected in validation/parsing") } }, @@ -153,89 +125,20 @@ pub(crate) fn instrument(cx: &ModuleContext<'_>) -> Vec { let name = format!("__wizer_memory_{}", i); exports.export(&name, wasm_encoder::Export::Memory(j)); } - for (i, j) in entry.module.instantiations(cx).keys().enumerate() { - let name = format!("__wizer_instance_{}", i); - exports.export(&name, wasm_encoder::Export::Instance(*j)); - } entry.encoder.section(&exports); } - // Nested module sections need to recursively instrument each child - // module. - Some(section) if section.id == SectionId::Module.into() => { - let reader = wasmparser::ModuleSectionReader::new(section.data, 0).unwrap(); - let count = usize::try_from(reader.get_count()).unwrap(); - - assert!(stack.top().module_section.is_none()); - if count == 0 { - continue; - } - - stack.top_mut().module_section = Some(wasm_encoder::ModuleSection::new()); - - assert_eq!(stack.top().children_remaining, 0); - stack.top_mut().children_remaining = count; - - let children = stack - .top_mut() - .children - .by_ref() - .copied() - .take(count) - .collect::>(); - - assert_eq!( - children.len(), - count, - "shouldn't ever have fewer children than expected" - ); - - let parent_index = Some(stack.len() - 1); - stack.extend( - children - .into_iter() - // Reverse so that we pop them off the stack in order. - .rev() - .map(|c| StackEntry { - module: c, - encoder: wasm_encoder::Module::new(), - sections: c.raw_sections(cx).iter(), - parent_index, - children: c.child_modules(cx).iter(), - module_section: None, - children_remaining: 0, - }), - ); - } - // End of the current module: if this is the root, return the // instrumented module, otherwise add it as an entry in its parent's // module section. None => { let entry = stack.pop().unwrap(); - assert!(entry.module_section.is_none()); - assert_eq!(entry.children_remaining, 0); if entry.module.is_root() { assert!(stack.is_empty()); return entry.encoder.finish(); } - - let parent = &mut stack[entry.parent_index.unwrap()]; - parent - .module_section - .as_mut() - .unwrap() - .module(&entry.encoder); - - assert!(parent.children_remaining > 0); - parent.children_remaining -= 1; - - if parent.children_remaining == 0 { - let module_section = parent.module_section.take().unwrap(); - parent.encoder.section(&module_section); - } } // All other sections don't need instrumentation and can be copied diff --git a/crates/wizer/src/lib.rs b/crates/wizer/src/lib.rs index 3afa289f18e4..6b86c0deb722 100644 --- a/crates/wizer/src/lib.rs +++ b/crates/wizer/src/lib.rs @@ -33,7 +33,6 @@ const DEFAULT_INHERIT_ENV: bool = false; const DEFAULT_KEEP_INIT_FUNC: bool = false; const DEFAULT_WASM_MULTI_VALUE: bool = true; const DEFAULT_WASM_MULTI_MEMORY: bool = true; -const DEFAULT_WASM_MODULE_LINKING: bool = false; const DEFAULT_WASM_BULK_MEMORY: bool = false; const DEFAULT_WASM_SIMD: bool = true; @@ -195,12 +194,6 @@ pub struct Wizer { #[cfg_attr(feature = "structopt", structopt(long, value_name = "true|false"))] wasm_multi_value: Option, - /// Enable or disable the Wasm module-linking proposal. - /// - /// Disabled by default. - #[cfg_attr(feature = "structopt", structopt(long, value_name = "true|false"))] - wasm_module_linking: Option, - /// Enable or disable Wasm bulk memory operations. /// /// Note that only `memory.copy`, `memory.fill`, and `memory.init` operations @@ -232,7 +225,6 @@ impl std::fmt::Debug for Wizer { map_dirs, wasm_multi_memory, wasm_multi_value, - wasm_module_linking, wasm_bulk_memory, wasm_simd, } = self; @@ -248,7 +240,6 @@ impl std::fmt::Debug for Wizer { .field("map_dirs", &map_dirs) .field("wasm_multi_memory", &wasm_multi_memory) .field("wasm_multi_value", &wasm_multi_value) - .field("wasm_module_linking", &wasm_module_linking) .field("wasm_bulk_memory", &wasm_bulk_memory) .field("wasm_simd", &wasm_simd) .finish() @@ -311,7 +302,6 @@ impl Wizer { map_dirs: vec![], wasm_multi_memory: None, wasm_multi_value: None, - wasm_module_linking: None, wasm_bulk_memory: None, wasm_simd: None, } @@ -445,14 +435,6 @@ impl Wizer { self } - /// Enable or disable the Wasm module-linking proposal. - /// - /// Defaults to `false`. - pub fn wasm_module_linking(&mut self, enable: bool) -> &mut Self { - self.wasm_module_linking = Some(enable); - self - } - /// Enable or disable Wasm bulk memory operations. /// /// Note that only `memory.copy`, `memory.fill`, and `memory.init` @@ -566,9 +548,6 @@ impl Wizer { // Proposals that we support. multi_memory: self.wasm_multi_memory.unwrap_or(DEFAULT_WASM_MULTI_MEMORY), multi_value: self.wasm_multi_value.unwrap_or(DEFAULT_WASM_MULTI_VALUE), - module_linking: self - .wasm_module_linking - .unwrap_or(DEFAULT_WASM_MODULE_LINKING), // Proposals that we should add support for. reference_types: false, @@ -579,6 +558,7 @@ impl Wizer { exceptions: false, extended_const: false, relaxed_simd: false, + component_model: false, // XXX: Though we don't fully support bulk memory yet, we // unconditionally turn it on. @@ -613,8 +593,7 @@ impl Wizer { fn wasm_validate(&self, wasm: &[u8]) -> anyhow::Result<()> { log::debug!("Validating input Wasm"); - let mut validator = wasmparser::Validator::new(); - validator.wasm_features(self.wasm_features()); + let mut validator = wasmparser::Validator::new_with_features(self.wasm_features()); validator.validate_all(wasm)?; // Reject bulk memory stuff that manipulates state we don't @@ -653,10 +632,7 @@ impl Wizer { } } } - wasmparser::Payload::ModuleSectionEntry { parser, .. } => { - parsers.push(parser); - } - wasmparser::Payload::End => { + wasmparser::Payload::End(_) => { parsers.pop(); } _ => continue, diff --git a/crates/wizer/src/parse.rs b/crates/wizer/src/parse.rs index 567907671532..63be01ed69ca 100644 --- a/crates/wizer/src/parse.rs +++ b/crates/wizer/src/parse.rs @@ -1,12 +1,12 @@ use crate::info::{ - types_interner::{EntityType, InstanceType, Type, TypeId}, + types_interner::{EntityType, TypeId}, Module, ModuleContext, }; use crate::stack_ext::StackExt; use anyhow::{Context, Result}; use std::convert::TryFrom; use wasm_encoder::SectionId; -use wasmparser::{SectionReader, SectionWithLimitedItems}; +use wasmparser::SectionReader; struct StackEntry { parser: wasmparser::Parser, @@ -45,28 +45,6 @@ pub(crate) fn parse<'a>(full_wasm: &'a [u8]) -> anyhow::Result Version { .. } => {} TypeSection(types) => type_section(&mut cx, &mut stack, full_wasm, types)?, ImportSection(imports) => import_section(&mut cx, &mut stack, full_wasm, imports)?, - AliasSection(aliases) => alias_section(&mut cx, &mut stack, full_wasm, aliases)?, - InstanceSection(instances) => { - instance_section(&mut cx, &mut stack, full_wasm, instances)? - } - ModuleSectionStart { - range, - size: _, - count: _, - } => { - stack.top_mut().module.add_raw_section( - &mut cx, - SectionId::Module, - range, - full_wasm, - ); - } - ModuleSectionEntry { parser, range: _ } => { - stack.push(StackEntry { - parser, - module: Module::new_defined(&mut cx), - }); - } FunctionSection(funcs) => function_section(&mut cx, &mut stack, full_wasm, funcs)?, TableSection(tables) => table_section(&mut cx, &mut stack, full_wasm, tables)?, MemorySection(mems) => memory_section(&mut cx, &mut stack, full_wasm, mems)?, @@ -117,19 +95,25 @@ pub(crate) fn parse<'a>(full_wasm: &'a [u8]) -> anyhow::Result CodeSectionEntry(_) => unreachable!(), UnknownSection { .. } => anyhow::bail!("unknown section"), TagSection(_) => anyhow::bail!("exceptions are not supported yet"), - End => { + End(_) => { let entry = stack.pop().unwrap(); // If we finished parsing the root Wasm module, then we're done. - if entry.module.is_root() { - assert!(stack.is_empty()); - return Ok(cx); - } + assert!(entry.module.is_root()); + assert!(stack.is_empty()); + return Ok(cx); + } - // Otherwise, we need to add this module to its parent's module - // section. - let parent = stack.top_mut(); - parent.module.push_child_module(&mut cx, entry.module); + ComponentTypeSection(_) + | ComponentImportSection(_) + | ComponentFunctionSection(_) + | ComponentExportSection(_) + | ComponentStartSection(_) + | AliasSection(_) + | ModuleSection { .. } + | ComponentSection { .. } + | InstanceSection(_) => { + unreachable!() } } } @@ -150,65 +134,9 @@ fn type_section<'a>( for _ in 0..count { let ty = types.read()?; match ty { - wasmparser::TypeDef::Func(_) | wasmparser::TypeDef::Instance(_) => { + wasmparser::TypeDef::Func(_) => { module.push_type(cx, ty); } - - // We need to disallow module imports, even within nested modules - // that only ever have other nested modules supplied as - // arguments. Two different modules could be supplied for two - // different instantiations of the module-importing module, but then - // after we export all modules' globals in our instrumentation - // phase, those two different module arguments could become - // type-incompatible with each other: - // - // ``` - // (module - // - // ;; Module A exports and `f` function. Internally it has - // ;; one global. - // (module $A - // (global $g ...) - // (func (export "f") ...)) - // - // ;; Module B has an identical interface as A. Internally - // ;; it has two globals. - // (module $B - // (global $g ...) - // (global $h ...) - // (func (export "f") ...)) - // - // ;; Module C imports any module that exports an `f` - // ;; function. It instantiates this imported module. - // (module $C - // (import "env" "module" - // (module (export "f" (func))) - // (instance 0))) - // - // ;; C is instantiated with both A and B. - // (instance $C (import "env" "module" $A)) - // (instance $C (import "env" "module" $B)) - // ) - // ``` - // - // After this instrumentation pass, we need to make module C - // transitively export all of the globals from its inner - // instances. Which means that the module type used in the module - // import needs to specify how many modules are in the imported - // module, but in our two instantiations, we have two different - // numbers of globals defined in each module! The only way to - // resolve this would be to duplicate and specialize module C for - // each instantiation, which we don't want to do for complexity and - // code size reasons. - // - // Since module types are only used with importing and exporting - // modules, which we don't intend to support as described above, we - // can disallow module types to reject all of them in one fell - // swoop. - wasmparser::TypeDef::Module(_) => Err(anyhow::anyhow!( - "wizer does not support importing or exporting modules" - ) - .context("module types are not supported"))?, } } @@ -227,108 +155,36 @@ fn import_section<'a>( .module .add_raw_section(cx, SectionId::Import, imports.range(), full_wasm); - let mut instance_import_count = 0; - - // Two-level imports implicitly create an instance import. That is, this - // - // (import "env" "f" (func)) - // (import "env" "g" (func)) - // - // is implicitly translated into roughly - // - // (import "env" (instance (export "f" (func)) - // (export "g" (func)))) - // (alias 0 "f") - // (alias 0 "g") - // - // However not that this is _not_ a WAT-level desugaring where we only have - // to deal with the expanded form! We have to perform this translation - // ourselves as we parse the imports. - // - // This variable keeps track of the implicit instance import that we are - // currently building. Whenever we see a consecutive run of two-level - // imports for the same module, we coalesce them into an implicit instance - // import. - let mut implicit_instance_import: Option<(&str, InstanceType)> = None; - // Check that we can properly handle all imports. let count = imports.get_count(); for _ in 0..count { let imp = imports.read()?; - if imp.module.starts_with("__wizer_") - || imp.field.map_or(false, |f| f.starts_with("__wizer_")) - { + if imp.module.starts_with("__wizer_") || imp.name.starts_with("__wizer_") { anyhow::bail!( "input Wasm module already imports entities named with the `__wizer_*` prefix" ); } - match (implicit_instance_import.as_mut(), imp.field) { - (Some((implicit_module, instance_ty)), Some(field)) - if *implicit_module == imp.module => - { - let ty = module.entity_type(cx, imp.ty); - let old = instance_ty.exports.insert(field.into(), ty); - debug_assert!(old.is_none(), "checked by validation"); - } - _ => { - if let Some((_, instance_ty)) = implicit_instance_import.take() { - module.push_implicit_instance(cx, instance_ty); - instance_import_count += 1; - } - if let Some(field) = imp.field { - let field_ty = module.entity_type(cx, imp.ty); - let instance_ty = InstanceType { - exports: Some((field.into(), field_ty)).into_iter().collect(), - }; - implicit_instance_import = Some((imp.module, instance_ty)); - } - } - } - check_import_type( cx, stack.top().module.types(cx), stack.top().module.is_root(), &module.entity_type(cx, imp.ty), )?; - if let wasmparser::ImportSectionEntryType::Instance(_) = imp.ty { - instance_import_count += 1; - } module.push_import(cx, imp); } - - if let Some((_, instance_ty)) = implicit_instance_import.take() { - module.push_implicit_instance(cx, instance_ty); - instance_import_count += 1; - } - - module.push_instance_import_count(cx, instance_import_count); Ok(()) } fn check_import_type( - cx: &ModuleContext, - types: &[TypeId], + _cx: &ModuleContext, + _types: &[TypeId], is_root: bool, ty: &EntityType, ) -> Result<()> { match ty { EntityType::Function(_) => Ok(()), - EntityType::Instance(inst_ty) => { - // We allow importing instances that only export things that are - // acceptable imports. This is equivalent to a two-layer import. - match cx.types().get(*inst_ty) { - Type::Instance(inst_ty) => { - for ty in inst_ty.exports.values() { - check_import_type(cx, types, is_root, ty)?; - } - Ok(()) - } - _ => unreachable!(), - } - } EntityType::Memory(mem_ty) => { anyhow::ensure!( !mem_ty.shared, @@ -351,135 +207,9 @@ fn check_import_type( ); Ok(()) } - EntityType::Module(_) => { - unreachable!(); - } } } -fn alias_section<'a>( - cx: &mut ModuleContext<'a>, - stack: &mut Vec, - full_wasm: &'a [u8], - mut aliases: wasmparser::AliasSectionReader<'a>, -) -> anyhow::Result<()> { - let module = stack.top().module; - module.add_raw_section(cx, SectionId::Alias, aliases.range(), full_wasm); - - // Clone any aliases over into this module's index spaces. - for _ in 0..aliases.get_count() { - let alias = aliases.read()?; - match &alias { - wasmparser::Alias::OuterType { - relative_depth, - index, - } => { - let relative_depth = usize::try_from(*relative_depth).unwrap(); - // NB: `- 2` rather than `- 1` because - // `relative_depth=0` means this module's immediate - // parent, not this module itself. - let ty = stack[stack.len() - 2 - relative_depth] - .module - .type_id_at(cx, *index); - module.push_aliased_type(cx, ty); - } - wasmparser::Alias::OuterModule { - relative_depth, - index, - } => { - let relative_depth = usize::try_from(*relative_depth).unwrap(); - // Ditto regarding `- 2`. - let alias_of = stack[stack.len() - 2 - relative_depth] - .module - .child_module_at(cx, *index); - let aliased = Module::new_aliased(cx, alias_of); - module.push_child_module(cx, aliased); - } - wasmparser::Alias::InstanceExport { - instance, - kind, - export, - } => match kind { - wasmparser::ExternalKind::Module => { - anyhow::bail!("exported modules are not supported yet") - } - wasmparser::ExternalKind::Instance => { - let inst_ty = match module.instance_export(cx, *instance, export) { - Some(EntityType::Instance(i)) => *i, - _ => unreachable!(), - }; - module.push_aliased_instance(cx, inst_ty); - } - wasmparser::ExternalKind::Function => { - let func_ty = match module.instance_export(cx, *instance, export) { - Some(EntityType::Function(ty)) => *ty, - _ => unreachable!(), - }; - module.push_function(cx, func_ty); - } - wasmparser::ExternalKind::Table => { - let table_ty = match module.instance_export(cx, *instance, export) { - Some(EntityType::Table(ty)) => *ty, - _ => unreachable!(), - }; - module.push_table(cx, table_ty); - } - wasmparser::ExternalKind::Memory => { - let ty = match module.instance_export(cx, *instance, export) { - Some(EntityType::Memory(ty)) => *ty, - _ => unreachable!(), - }; - module.push_imported_memory(cx, ty); - } - wasmparser::ExternalKind::Global => { - let ty = match module.instance_export(cx, *instance, export) { - Some(EntityType::Global(ty)) => *ty, - _ => unreachable!(), - }; - module.push_imported_global(cx, ty); - } - wasmparser::ExternalKind::Tag => { - unreachable!("validation should reject the exceptions proposal") - } - wasmparser::ExternalKind::Type => unreachable!("can't export types"), - }, - } - module.push_alias(cx, alias); - } - - Ok(()) -} - -fn instance_section<'a>( - cx: &mut ModuleContext<'a>, - stack: &mut Vec, - full_wasm: &'a [u8], - mut instances: wasmparser::InstanceSectionReader<'a>, -) -> anyhow::Result<()> { - let module = stack.top().module; - module.add_raw_section(cx, SectionId::Instance, instances.range(), full_wasm); - - // Record the instantiations made in this module, and which modules were - // instantiated. - for _ in 0..instances.get_count() { - let inst = instances.read()?; - let module_index = inst.module(); - let child_module = module.child_module_at(cx, module_index); - let inst_ty = child_module.define_instance_type(cx); - - let mut instance_args_reader = inst.args()?; - let instance_args_count = usize::try_from(instance_args_reader.get_count()).unwrap(); - let mut instance_args = Vec::with_capacity(instance_args_count); - for _ in 0..instance_args_count { - instance_args.push(instance_args_reader.read()?); - } - - module.push_defined_instance(cx, inst_ty, child_module, instance_args); - } - - Ok(()) -} - fn function_section<'a>( cx: &mut ModuleContext<'a>, stack: &mut Vec, @@ -560,24 +290,20 @@ fn export_section<'a>( for _ in 0..exports.get_count() { let export = exports.read()?; - if export.field.starts_with("__wizer_") { + if export.name.starts_with("__wizer_") { anyhow::bail!( "input Wasm module already exports entities named with the `__wizer_*` prefix" ); } match export.kind { - wasmparser::ExternalKind::Module => { - anyhow::bail!("Wizer does not support importing and exporting modules") - } - wasmparser::ExternalKind::Type | wasmparser::ExternalKind::Tag => { + wasmparser::ExternalKind::Tag => { unreachable!("checked in validation") } - wasmparser::ExternalKind::Function + wasmparser::ExternalKind::Func | wasmparser::ExternalKind::Table | wasmparser::ExternalKind::Memory - | wasmparser::ExternalKind::Global - | wasmparser::ExternalKind::Instance => { + | wasmparser::ExternalKind::Global => { module.push_export(cx, export); } } diff --git a/crates/wizer/src/rewrite.rs b/crates/wizer/src/rewrite.rs index 09a0d34bcbe6..183daf80a4d5 100644 --- a/crates/wizer/src/rewrite.rs +++ b/crates/wizer/src/rewrite.rs @@ -1,17 +1,9 @@ //! Final rewrite pass. -mod renumbering; - use crate::{ - info::{ - types_interner::{EntityType, Type}, - Module, ModuleContext, - }, - snapshot::Snapshot, - translate, FuncRenames, Wizer, DEFAULT_KEEP_INIT_FUNC, + info::ModuleContext, snapshot::Snapshot, translate, FuncRenames, Wizer, DEFAULT_KEEP_INIT_FUNC, }; -use renumbering::Renumbering; -use std::{convert::TryFrom, iter}; +use std::convert::TryFrom; use wasm_encoder::SectionId; impl Wizer { @@ -28,25 +20,6 @@ impl Wizer { ) -> Vec { log::debug!("Rewriting input Wasm to pre-initialized state"); - if cx.uses_module_linking() { - self.rewrite_with_module_linking(cx, store, snapshot, renames, has_wasi_initialize) - } else { - self.rewrite_without_module_linking(cx, store, snapshot, renames, has_wasi_initialize) - } - } - - /// Rewrite a root Wasm module that has no children and doesn't use module - /// linking at all. - fn rewrite_without_module_linking( - &self, - cx: &ModuleContext<'_>, - store: &crate::Store, - snapshot: &Snapshot, - renames: &FuncRenames, - has_wasi_initialize: bool, - ) -> Vec { - assert!(snapshot.instantiations.is_empty()); - let mut encoder = wasm_encoder::Module::new(); let module = cx.root(); @@ -141,14 +114,14 @@ impl Wizer { let mut exports = wasm_encoder::ExportSection::new(); for export in module.exports(cx) { if !self.keep_init_func.unwrap_or(DEFAULT_KEEP_INIT_FUNC) - && (export.field == self.init_func - || (has_wasi_initialize && export.field == "_initialize")) + && (export.name == self.init_func + || (has_wasi_initialize && export.name == "_initialize")) { continue; } - if !renames.rename_src_to_dst.contains_key(export.field) - && renames.rename_dsts.contains(export.field) + if !renames.rename_src_to_dst.contains_key(export.name) + && renames.rename_dsts.contains(export.name) { // A rename overwrites this export, and it is not // renamed to another export, so skip it. @@ -157,8 +130,8 @@ impl Wizer { let field = renames .rename_src_to_dst - .get(export.field) - .map_or(export.field, |f| f.as_str()); + .get(export.name) + .map_or(export.name, |f| f.as_str()); let export = translate::export(export.kind, export.index); exports.export(field, export); @@ -183,10 +156,6 @@ impl Wizer { add_data_section(&mut encoder); } - s if s.id == SectionId::Module.into() => unreachable!(), - s if s.id == SectionId::Instance.into() => unreachable!(), - s if s.id == SectionId::Alias.into() => unreachable!(), - s => { encoder.section(s); } @@ -197,352 +166,6 @@ impl Wizer { add_data_section(&mut encoder); encoder.finish() } - - /// Rewrite a module linking bundle. - /// - /// ## Code Shape - /// - /// With module linking, we rewrite each module in the original bundle into - /// a *code module* that doesn't define any internal state (i.e. memories, - /// globals, and nested instances) and instead imports a *state instance* - /// that exports all of these things. For each instantiation, we have a - /// *state module* that defines the already-initialized state for that - /// instantiation, we instantiate that state module to create one such state - /// instance, and then use this as an import argument in the instantiation - /// of the original code module. This way, we do not duplicate shared code - /// bodies across multiple instantiations of the same module. - /// - /// Note that the root module is also split out into a code module and state - /// module, even though it is never explicitly instantiated inside the - /// bundle. - /// - /// The new root is an "umbrella" module that defines all the types used - /// within the whole bundle. Each nested module then aliases its types from - /// the umbrella module. The umbrella module aliases all exports of the - /// original root and re-exports them. - /// - /// For example, given this input Wasm module: - /// - /// ```wat - /// (module $A - /// (module $B - /// (memory $B_mem) - /// (global $B_glob (mut i32)) - /// (func (export "f") ...) - /// ) - /// - /// (instance $x (instantiate $B)) - /// (instance $y (instantiate $B)) - /// - /// (memory $A_mem) - /// (global $A_glob (mut i32)) - /// - /// (func (export "g") ...) - /// ) - /// ``` - /// - /// and some post-initialization state, this rewrite pass will produce the - /// following pre-initialized module: - /// - /// ```wat - /// (module $Umbrella - /// (module $A - /// ;; Locally defined state is replaced by a state instance import. - /// (import "__wizer_state" - /// (instance - /// (export "__wizer_memory_0" (memory $A_mem)) - /// (export "__wizer_global_0" (global $A_glob (mut i32))) - /// (export "__wizer_instance_0" (instance $x (export "f" (func)))) - /// (export "__wizer_instance_1" (instance $y (export "f" (func)))) - /// ) - /// ) - /// (func (export "g") ...) - /// ) - /// - /// (module $B - /// ;; Locally defined state is replaced by a state instance import. - /// (import "__wizer_state" - /// (instance - /// (export "__wizer_memory_0" (memory $B_mem)) - /// (export "__wizer_global_0" (global $B_glob (mut i32))) - /// ) - /// ) - /// (func (export "f") ...) - /// ) - /// - /// ;; Instantiations are replaced with specialized state modules that get - /// ;; instantiated exactly once to produce state instances, and finally - /// ;; the original instantiations are rewritten into instantiations of - /// ;; the corresponding code module with the state instance as an import - /// ;; argument. - /// - /// ;; State module for `$A`. - /// (module $A_state_module - /// ;; State module for `$x`. - /// (module $x_state_module - /// (memory (export "__wizer_memory_0") (memory)) - /// ;; Data segments to initialize the memory based on our snapshot - /// ;; would go here... - /// - /// (global (export "__wizer_global_0") - /// (global (mut i32) (i32.const (; ...snapshot's initialized value goes here... ;))) - /// ) - /// ) - /// - /// ;; State instance for `$x`. - /// (instance $x_state (instantiate $x_state_module)) - /// - /// ;; The instantiation of `$x` is now rewritten to use our state - /// ;; instance. - /// (instance $x (instantiate $B (import "__wizer_state" $x_state))) - /// - /// ;; Same goes for the `$y` instantiation. - /// (module $y_state_module - /// (memory (export "__wizer_memory_0") (memory)) - /// ;; Data segments... - /// (global (export "__wizer_global_0") - /// (global (mut i32) (i32.const (; ...snapshot's initialized value goes here... ;))) - /// ) - /// ) - /// (instance $y_state (instantiate $y_state_module)) - /// (instance $y (instantiate $B (import "__wizer_state" $y_state))) - /// - /// (memory $A_mem) - /// (global $A_glob (mut i32)) - /// ) - /// - /// ;; State instance for `$A`. - /// (instance $a_state (instantiate $A_state_module)) - /// - /// ;; The state is now joined with the code. - /// (instance $a_instance (instantiate $A (import "__wizer_state" $a_state))) - /// - /// ;; And finally we re-export all of our old root's exports. - /// (export "g" (func $a_instance "g")) - /// ) - /// ``` - /// - /// ## Implementation - /// - /// To implement this transformation, we first do a pre-order walk of the - /// module tree and emit the code modules as a flat sequence. Why a flat - /// sequence? The code modules cannot contain nested instantiations, because - /// nested instantiations are state that is not necessarily shared across - /// all instantiations of the outer module. And if we are already lifting - /// out nested instantiations, we need to also make nested modules available - /// for those lifted instantiations, and the easiest way to do that is to - /// flatten the code module tree (as opposed to re-exporting the nested - /// modules under well-known symbols). The pre-order traversal ensures that - /// the `Module::id` we assigned during the instrumentation phase matches - /// the module's place in the index space. - /// - /// The state modules, however, remain a nested tree, and we emit them in a - /// traversal of the `Snapshot` instance tree. We can do this because, - /// unlike code modules, each state module is only instantiated exactly - /// once. The instantiations' references to nested modules become outer - /// aliases pointing to the module's position in the parent's flat sequence - /// of nested modules. - fn rewrite_with_module_linking( - &self, - cx: &mut ModuleContext<'_>, - store: &crate::Store, - snapshot: &Snapshot, - renames: &FuncRenames, - has_wasi_initialize: bool, - ) -> Vec { - let mut umbrella = wasm_encoder::Module::new(); - - // Counts of various entities defined inside the umbrella module thus - // far. - let mut umbrella_funcs = 0; - let mut umbrella_tables = 0; - let mut umbrella_memories = 0; - let mut umbrella_globals = 0; - let mut umbrella_instances = 0; - - let (code_modules, num_code_modules) = rewrite_code_modules(cx); - - let root_state_module = rewrite_state_module(cx, store, cx.root(), &snapshot, 0); - let mut modules = wasm_encoder::ModuleSection::new(); - modules.module(&root_state_module); - let root_state_module_index = num_code_modules; - - // Imports that we will need to pass through from the umbrella to the - // root instance. - let import_sections: Vec<_> = cx - .root() - .initial_sections(cx) - .filter(|s| s.id == SectionId::Import.into()) - .collect(); - - // Instantiate the root state module by forwarding imports from the - // umbrella to the root instantiation. - // - // There is some trickery for implicit instance imports. We forward the - // implicit instance as an instantiation argument, since we can't - // provide two-level instantiation arguments, which means we need to - // determine when implicit imports are injected again. - let mut instances = wasm_encoder::InstanceSection::new(); - let mut args = vec![]; - let mut imports = cx.root().imports(cx).iter().peekable(); - loop { - let (module, is_two_level) = match imports.peek() { - Some(imp) => (imp.module, imp.field.is_some()), - None => break, - }; - - if is_two_level { - args.push((module, wasm_encoder::Export::Instance(umbrella_instances))); - umbrella_instances += 1; - } - while imports.peek().map_or(false, |imp| imp.module == module) { - let imp = imports.next().unwrap(); - let export = match imp.ty { - wasmparser::ImportSectionEntryType::Function(_) => { - umbrella_funcs += 1; - wasm_encoder::Export::Function(umbrella_funcs - 1) - } - wasmparser::ImportSectionEntryType::Instance(_) => { - umbrella_instances += 1; - wasm_encoder::Export::Instance(umbrella_instances - 1) - } - _ => unreachable!(), - }; - if !is_two_level { - args.push((module, export)); - } - } - } - instances.instantiate(root_state_module_index, args.iter().cloned()); - let root_state_instance_index = umbrella_instances; - umbrella_instances += 1; - - // Instantiate the root code module with the root state module. - let root_module_index = cx.root().pre_order_index(); - args.push(( - "__wizer_state", - wasm_encoder::Export::Instance(root_state_instance_index), - )); - instances.instantiate(root_module_index, args); - let root_instance_index = umbrella_instances; - umbrella_instances += 1; - - // Alias the root instance's exports and then re-export them. - let mut aliases = wasm_encoder::AliasSection::new(); - let mut exports = wasm_encoder::ExportSection::new(); - for exp in cx.root().exports(cx) { - if !self.keep_init_func.unwrap_or(DEFAULT_KEEP_INIT_FUNC) - && (exp.field == self.init_func - || (has_wasi_initialize && exp.field == "_initialize")) - { - continue; - } - - if !renames.rename_src_to_dst.contains_key(exp.field) - && renames.rename_dsts.contains(exp.field) - { - // A rename overwrites this export, and it is not renamed to - // another export, so skip it. - continue; - } - - let kind = translate::item_kind(exp.kind); - aliases.instance_export(root_instance_index, kind, exp.field); - - let field = renames - .rename_src_to_dst - .get(exp.field) - .map_or(exp.field, |f| f.as_str()); - exports.export( - field, - match kind { - wasm_encoder::ItemKind::Function => { - umbrella_funcs += 1; - wasm_encoder::Export::Function(umbrella_funcs - 1) - } - wasm_encoder::ItemKind::Table => { - umbrella_tables += 1; - wasm_encoder::Export::Table(umbrella_tables - 1) - } - wasm_encoder::ItemKind::Memory => { - umbrella_memories += 1; - wasm_encoder::Export::Memory(umbrella_memories - 1) - } - wasm_encoder::ItemKind::Global => { - umbrella_globals += 1; - wasm_encoder::Export::Global(umbrella_globals - 1) - } - wasm_encoder::ItemKind::Instance => { - umbrella_instances += 1; - wasm_encoder::Export::Instance(umbrella_instances - 1) - } - wasm_encoder::ItemKind::Module => unreachable!(), - wasm_encoder::ItemKind::Tag => unreachable!(), - }, - ); - } - - // NB: We encode the types last, even though it is the first section we - // place in the umbrella module, since adding state imports may need to - // define new instance types. - let types = umbrella_type_section(cx); - - // Now combine all our sections together in the umbrella module. - umbrella.section(&types); - umbrella.section(&code_modules); - umbrella.section(&modules); - for s in import_sections { - umbrella.section(s); - } - umbrella.section(&instances); - umbrella.section(&aliases); - umbrella.section(&exports); - - umbrella.finish() - } -} - -/// Create a type section with everything in the whole interned types set. -fn umbrella_type_section(cx: &ModuleContext<'_>) -> wasm_encoder::TypeSection { - let mut types = wasm_encoder::TypeSection::new(); - - let interned_entity_to_encoder_entity = |ty: &EntityType| match ty { - EntityType::Function(ty) => wasm_encoder::EntityType::Function(ty.index()), - EntityType::Table(ty) => wasm_encoder::EntityType::Table(translate::table_type(*ty)), - EntityType::Memory(ty) => wasm_encoder::EntityType::Memory(translate::memory_type(*ty)), - EntityType::Global(ty) => wasm_encoder::EntityType::Global(translate::global_type(*ty)), - EntityType::Module(ty) => wasm_encoder::EntityType::Module(ty.index()), - EntityType::Instance(ty) => wasm_encoder::EntityType::Instance(ty.index()), - }; - - for (_index, ty) in cx.types().iter() { - match ty { - Type::Func(f) => types.function( - f.params.iter().copied().map(translate::val_type), - f.returns.iter().copied().map(translate::val_type), - ), - Type::Instance(inst) => types.instance( - inst.exports - .iter() - .map(|(name, ty)| (name.as_ref(), interned_entity_to_encoder_entity(ty))), - ), - Type::Module(module) => types.module( - module.imports.iter().map(|((module, name), ty)| { - ( - module.as_ref(), - name.as_ref().map(|n| n.as_ref()), - interned_entity_to_encoder_entity(ty), - ) - }), - module - .exports - .iter() - .map(|(name, ty)| (name.as_ref(), interned_entity_to_encoder_entity(ty))), - ), - }; - } - - types } fn is_name_section(s: &wasm_encoder::RawSection) -> bool { @@ -551,582 +174,3 @@ fn is_name_section(s: &wasm_encoder::RawSection) -> bool { matches!(reader.read_string(), Ok("name")) } } - -/// Rewrite nested modules into a flat sequence, and where they import their -/// state, rather than define it locally. -/// -/// Returns the modules encoded in a module section and total number of code -/// modules defined. -fn rewrite_code_modules(cx: &mut ModuleContext) -> (wasm_encoder::ModuleSection, u32) { - let mut code_modules = wasm_encoder::ModuleSection::new(); - let mut num_code_modules = 0; - - cx.root().pre_order(cx, |cx, info| { - if info.get_aliased(cx).is_some() { - // Add a dummy module. This isn't ever actually used, since we will - // instead resolve the alias at the use sites and then use the - // aliased referent instead. If we had an alias kind like "alias a - // module from this index space" we would use that here. But we have - // to add an entry to the module index space to preserve our - // invariant that a code module is at its pre-order index in the - // umbrella's module index space. - code_modules.module(&wasm_encoder::Module::new()); - num_code_modules += 1; - return; - } - - let mut module = wasm_encoder::Module::new(); - - // We generally try to avoid renumbering entities in Wizer -- - // particularly any entities referenced from the code section, where - // renumbering could change the size of a LEB128 index and break DWARF - // debug info offsets -- because it means we can't copy whole sections - // from the original, input Wasm module. But we run into a conflicting - // constraints here with regards to instances: - // - // 1. Ideally we would import our state instance last, so that we don't - // perturb with our instance index space. - // - // 2. Locally-defined instances are state, and therefore must be pulled - // out of these code modules into our imported state instance, and - // then referenced via alias. - // - // (1) and (2) are in conflict because we can't create aliases of - // instances on the imported state instance until *after* the state - // instance is imported, which means we need to import our state - // instance first, which means we are forced to perturb the instance - // index space. - // - // Therefore, the first thing we add to each code module is an import - // section that imports the state instance. We need to explicitly - // rewrite all references to these instances (e.g. instance export - // aliases) to add one to their index so that they refer to the correct - // instance again. Luckily instances are never referenced from the code - // section, so DWARF debug info doesn't get invalidated. - // - // Finally, importing the state instance requires that we define the - // state instance's type. We really don't want to renumber types because - // those *are* referenced from the code section via `call_indirect`. To - // avoid renumbering types, we do a first pass over this module's types - // and build out a full type section with the same numbering as the - // original module, and then append the state import's type at the end. - let type_aliases = make_aliased_type_section(cx, info, 0); - module.section(&type_aliases); - let sections = make_state_import(cx, info); - for s in sections { - module.section(&s); - } - - // Now rewrite the initial sections one at a time. - // - // Note that the initial sections can occur repeatedly and in any - // order. This means that we only ever add, for example, `n` imports to - // the rewritten module when a particular import section defines `n` - // imports. We do *not* add all imports all at once. This is because - // imports and aliases might be interleaved, and adding all imports all - // at once could perturb entity numbering. - let mut sections = info.raw_sections(cx).iter(); - let mut imports = info.imports(cx).iter(); - let mut instantiations = 0..info.instantiations(cx).len(); - let mut aliases = info.aliases(cx).iter(); - let mut first_non_initial_section = None; - for section in sections.by_ref() { - match section { - // We handled this above. - s if s.id == SectionId::Type.into() => continue, - - // These are handled in subsequent steps of this pre-order - // traversal. - s if s.id == SectionId::Module.into() => continue, - - s if s.id == SectionId::Import.into() => { - let count = wasmparser::ImportSectionReader::new(s.data, 0) - .unwrap() - .get_count(); - let mut section = wasm_encoder::ImportSection::new(); - for imp in imports.by_ref().take(usize::try_from(count).unwrap()) { - section.import(imp.module, imp.field, translate::entity_type(imp.ty)); - } - module.section(§ion); - } - - // The actual instantiations are pulled out and handled in - // `rewrite_instantiations` and then we get them here via the - // state import. We need to bring them into scope via instance - // export aliases, however. - s if s.id == SectionId::Instance.into() => { - let count = wasmparser::InstanceSectionReader::new(s.data, 0) - .unwrap() - .get_count(); - let mut section = wasm_encoder::AliasSection::new(); - for idx in instantiations - .by_ref() - .take(usize::try_from(count).unwrap()) - { - // Our imported state instance is always instance 0. - let from_instance = 0; - let name = format!("__wizer_instance_{}", idx); - section.instance_export( - from_instance, - wasm_encoder::ItemKind::Instance, - &name, - ); - } - module.section(§ion); - } - - s if s.id == SectionId::Alias.into() => { - let count = wasmparser::AliasSectionReader::new(s.data, 0) - .unwrap() - .get_count(); - let mut section = wasm_encoder::AliasSection::new(); - for alias in aliases.by_ref().take(usize::try_from(count).unwrap()) { - match alias { - // We don't make any instantiations so we don't need - // modules here anymore. - wasmparser::Alias::OuterModule { .. } => continue, - // We already created a complete type section, - // including any aliases, above. - wasmparser::Alias::OuterType { .. } => continue, - // Copy over instance export aliases. - // however. - wasmparser::Alias::InstanceExport { - instance, - kind, - export, - } => { - // We need to add one to the instance's index - // because our state instance import shifted - // everything off by one. - let from_instance = instance + 1; - section.instance_export( - from_instance, - translate::item_kind(*kind), - export, - ); - } - } - } - module.section(§ion); - } - - s => { - assert!(first_non_initial_section.is_none()); - first_non_initial_section = Some(s); - break; - } - } - } - - // We don't define the memories from the original memory section, but we - // do add instance export aliases for each of them from our imported - // state instance. These aliases need to be in an alias section, which - // is an initial section and must come before the rest of the - // non-initial sections. But it must also come *after* any memories that - // might have been imported, so that we don't mess up the - // numbering. Therefore we add these aliases here, after we've processed - // the initial sections, but before we start with the rest of the - // sections. - if info.defined_memories_index(cx).is_some() { - let mut section = wasm_encoder::AliasSection::new(); - for (i, _) in info.defined_memories(cx).enumerate() { - // Our state instance is always instance 0. - let from_instance = 0; - let name = format!("__wizer_memory_{}", i); - section.instance_export(from_instance, wasm_encoder::ItemKind::Memory, &name); - } - module.section(§ion); - } - - // Globals are handled the same way as memories. - if info.defined_globals_index(cx).is_some() { - let mut section = wasm_encoder::AliasSection::new(); - for (i, _) in info.defined_globals(cx).enumerate() { - let from_instance = 0; - let name = format!("__wizer_global_{}", i); - section.instance_export(from_instance, wasm_encoder::ItemKind::Global, &name); - } - module.section(§ion); - } - - // Process the rest of the non-initial sections. - for section in first_non_initial_section.into_iter().chain(sections) { - match section { - // We replaced these with instance export aliases from our state - // instance above. - s if s.id == SectionId::Memory.into() => continue, - s if s.id == SectionId::Global.into() => continue, - - // We ignore the original data segments. We don't define - // memories anymore and state instances will define their own - // data segments based on the snapshot. - s if s.id == SectionId::Data.into() => continue, - s if s.id == SectionId::DataCount.into() => continue, - - // The start function has already been run! - s if s.id == SectionId::Start.into() => continue, - - // Finally, everything else is copied over as-is! - s => { - module.section(s); - } - } - } - - code_modules.module(&module); - num_code_modules += 1; - }); - - (code_modules, num_code_modules) -} - -/// Make the equivalent of the given module's type section from outer type -/// aliases that bring types from the umbrella module's types space into this -/// code module's types space. -fn make_aliased_type_section( - cx: &ModuleContext<'_>, - module: Module, - depth: u32, -) -> wasm_encoder::AliasSection { - let mut aliases = wasm_encoder::AliasSection::new(); - for ty in module.types(cx) { - aliases.outer_type(depth, ty.index()); - } - aliases -} - -/// Make an import section that imports a code module's state instance import. -fn make_state_import( - cx: &mut ModuleContext<'_>, - module: Module, -) -> Vec { - let mut sections = vec![]; - - // Define the state instance's type. - let state_instance_ty = module.define_state_instance_type(cx); - - // Alias the state instance type from the umbrella. - let mut alias = wasm_encoder::AliasSection::new(); - alias.outer_type(0, state_instance_ty.index()); - sections.push(StateImportSection::Alias(alias)); - - let state_instance_type_index = u32::try_from(module.types(cx).len()).unwrap(); - module.push_aliased_type(cx, state_instance_ty); - - // Define the import of the state instance, using the type - // we just defined. - let mut imports = wasm_encoder::ImportSection::new(); - imports.import( - "__wizer_state", - None, - wasm_encoder::EntityType::Instance(state_instance_type_index), - ); - sections.push(StateImportSection::Import(imports)); - - return sections; - - enum StateImportSection { - Alias(wasm_encoder::AliasSection), - Import(wasm_encoder::ImportSection), - } - - impl wasm_encoder::Section for StateImportSection { - fn id(&self) -> u8 { - match self { - StateImportSection::Alias(s) => s.id(), - StateImportSection::Import(s) => s.id(), - } - } - - fn encode(&self, sink: &mut S) - where - S: Extend, - { - match self { - StateImportSection::Alias(s) => s.encode(sink), - StateImportSection::Import(s) => s.encode(sink), - } - } - } -} - -/// Create the state module the given module instantiation and recursively do -/// the same for its nested instantiations. -fn rewrite_state_module( - cx: &ModuleContext<'_>, - store: &crate::Store, - info: Module, - snapshot: &Snapshot, - depth: u32, -) -> wasm_encoder::Module { - let mut state_module = wasm_encoder::Module::new(); - let mut exports = wasm_encoder::ExportSection::new(); - - // If there are nested instantiations, then define the nested state - // modules and then instantiate them. - assert_eq!(info.instantiations(cx).len(), snapshot.instantiations.len()); - if !snapshot.instantiations.is_empty() { - // We create nested instantiations such that each state module has - // the following module index space: - // - // [ - // alias instantiation[0]'s code module, - // alias instantiation[1]'s code module, - // ... - // alias instantiation[N]'s code module, - // define instantiation[0]'s state module, - // define instantiation[1]'s state module, - // ... - // define instantiation[N]'s state module, - // ] - // - // That is, the `i`th nested instantiation's code module is the `i`th - // module in the index space, and its state module is at index `N+i`. - // - // We define all the code module aliases up front. Nested instantiations - // may require aliasing instance exports from earlier instantiations, so - // we interleave those in the same order that they appeared in the - // original Wasm binary below. - let mut alias_section = wasm_encoder::AliasSection::new(); - for (module, _) in info.instantiations(cx).values() { - let module = module.get_aliased(cx).unwrap_or(*module); - - // Because we flatten the code modules into the umbrella module with - // a pre-order traversal, this instantiation's code module is the - // `module.pre_order_index()`th module in the root module's module - // index space. - let code_module_index_in_root = module.pre_order_index(); - alias_section.outer_module(depth, code_module_index_in_root); - } - state_module.section(&alias_section); - - // The instance index space is more complicated than the module index - // space because of potential instance imports and aliasing imported - // instance's exported nested instances. These imported/aliased - // instances can then be used as arguments to a nested instantiation, - // and then the resulting instance can also be used as an argument to - // further nested instantiations. To handle all this, we use a - // `Renumbering` map for tracking instance indices. - let mut instance_renumbering = Renumbering::default(); - - let aliased_types = make_aliased_type_section(cx, info, depth); - state_module.section(&aliased_types); - - let mut instance_import_counts = info.instance_import_counts(cx).iter().copied(); - let mut aliases = info.aliases(cx).iter(); - let mut instantiations = info.instantiations(cx).values().enumerate(); - - for section in info.initial_sections(cx) { - match section { - // Handled above. - s if s.id == SectionId::Type.into() => continue, - - // Copy the imports over and update our renumbering for any - // imported instances. - s if s.id == SectionId::Import.into() => { - state_module.section(s); - let instance_import_count = instance_import_counts.next().unwrap(); - for _ in 0..instance_import_count { - instance_renumbering.add_import(); - } - } - - // Update instance export aliases to use the numbered instance - // indices. Also update the renumbering for any aliased - // instances brought into scope. - s if s.id == SectionId::Alias.into() => { - let count = wasmparser::AliasSectionReader::new(s.data, 0) - .unwrap() - .get_count(); - let mut section = wasm_encoder::AliasSection::new(); - for alias in aliases.by_ref().take(usize::try_from(count).unwrap()) { - match alias { - wasmparser::Alias::InstanceExport { - instance, - kind, - export, - } => { - section.instance_export( - instance_renumbering.lookup(*instance), - translate::item_kind(*kind), - export, - ); - // If this brought a new instance into our - // instance index space, update our renumbering - // map. - if let wasmparser::ExternalKind::Instance = kind { - instance_renumbering.add_alias(); - } - } - // Handled by `make_complete_type_section`. - wasmparser::Alias::OuterType { .. } => continue, - // Ignore these because we alias only the modules we - // need for nested instantiations below. - wasmparser::Alias::OuterModule { .. } => continue, - } - } - state_module.section(§ion); - } - - // We alias only the modules we need for nested instantiations - // below. - s if s.id == SectionId::Module.into() => continue, - - // For each nested instantiation in this section, alias its code - // module, define its state module, instantiate the state module - // to create the state instance, instantiate the code module - // with the state instance, and finally export the code+state - // instance. - s if s.id == SectionId::Instance.into() => { - let count = wasmparser::InstanceSectionReader::new(s.data, 0) - .unwrap() - .get_count(); - let mut instance_section = wasm_encoder::InstanceSection::new(); - let mut module_section = wasm_encoder::ModuleSection::new(); - for (i, (module, instance_args)) in instantiations - .by_ref() - .take(usize::try_from(count).unwrap()) - { - // Define the state module for this instantiation. - let state_module = rewrite_state_module( - cx, - store, - *module, - &snapshot.instantiations[i], - depth + 1, - ); - module_section.module(&state_module); - - // Instantiate the state module to create the state - // instance. - let args: Vec<_> = instance_args - .iter() - .map(|arg| { - let mut arg = translate::instance_arg(arg); - if let (_name, wasm_encoder::Export::Instance(ref mut index)) = arg - { - *index = instance_renumbering.lookup(*index); - } - arg - }) - .collect(); - instance_section.instantiate( - u32::try_from(snapshot.instantiations.len() + i).unwrap(), - args, - ); - let state_instance_index = instance_renumbering.define_new(); - - // Then instantiate the associated code module, passing it this - // state instance and whatever other arguments it expects. - let args: Vec<_> = iter::once(( - "__wizer_state", - wasm_encoder::Export::Instance(state_instance_index), - )) - .chain(instance_args.iter().map(|arg| { - let mut arg = translate::instance_arg(arg); - if let (_name, wasm_encoder::Export::Instance(ref mut index)) = arg { - *index = instance_renumbering.lookup(*index); - } - arg - })) - .collect(); - instance_section.instantiate(u32::try_from(i).unwrap(), args); - let (_, code_and_state_instance_index) = instance_renumbering.define_both(); - - // Add the export for this nested instance. - let name = format!("__wizer_instance_{}", i); - exports.export( - &name, - wasm_encoder::Export::Instance( - u32::try_from(code_and_state_instance_index).unwrap(), - ), - ); - } - state_module.section(&module_section); - state_module.section(&instance_section); - } - - _ => unreachable!(), - } - } - } - - // Add defined memories. - assert_eq!(info.defined_memories_len(cx), snapshot.memory_mins.len()); - if info.defined_memories_index(cx).is_some() { - let mut memories = wasm_encoder::MemorySection::new(); - for (i, (new_min, (_, mem))) in snapshot - .memory_mins - .iter() - .copied() - .zip(info.defined_memories(cx)) - .enumerate() - { - let mut mem = translate::memory_type(mem); - assert!(new_min >= mem.minimum); - assert!(new_min <= mem.maximum.unwrap_or(u64::MAX)); - mem.minimum = new_min; - memories.memory(mem); - - let name = format!("__wizer_memory_{}", i); - exports.export( - &name, - wasm_encoder::Export::Memory(u32::try_from(i).unwrap()), - ); - } - state_module.section(&memories); - } - - // Add defined globals. - assert_eq!(info.defined_globals_len(cx), snapshot.globals.len()); - if info.defined_globals_index(cx).is_some() { - let mut globals = wasm_encoder::GlobalSection::new(); - for (i, (val, (_, glob_ty))) in snapshot - .globals - .iter() - .zip(info.defined_globals(cx)) - .enumerate() - { - let glob_ty = translate::global_type(glob_ty); - globals.global( - glob_ty, - &match val { - wasmtime::Val::I32(x) => wasm_encoder::Instruction::I32Const(*x), - wasmtime::Val::I64(x) => wasm_encoder::Instruction::I64Const(*x), - wasmtime::Val::F32(x) => { - wasm_encoder::Instruction::F32Const(f32::from_bits(*x)) - } - wasmtime::Val::F64(x) => { - wasm_encoder::Instruction::F64Const(f64::from_bits(*x)) - } - wasmtime::Val::V128(x) => wasm_encoder::Instruction::V128Const(*x as i128), - _ => unreachable!(), - }, - ); - - let name = format!("__wizer_global_{}", i); - exports.export( - &name, - wasm_encoder::Export::Global(u32::try_from(i).unwrap()), - ); - } - state_module.section(&globals); - } - - state_module.section(&exports); - - // Add data segments. - if !snapshot.data_segments.is_empty() { - let mut data = wasm_encoder::DataSection::new(); - for seg in &snapshot.data_segments { - data.active( - seg.memory_index, - &wasm_encoder::Instruction::I32Const(seg.offset as i32), - seg.data(store).iter().copied(), - ); - } - state_module.section(&data); - } - - state_module -} diff --git a/crates/wizer/src/rewrite/renumbering.rs b/crates/wizer/src/rewrite/renumbering.rs deleted file mode 100644 index 1d17017f0636..000000000000 --- a/crates/wizer/src/rewrite/renumbering.rs +++ /dev/null @@ -1,57 +0,0 @@ -use std::convert::TryFrom; - -/// A renumbering of indices. -/// -/// Keeps track of which indices in the original Wasm map to which indices in -/// the rewritten Wasm. -/// -/// Only supports injective renumberings: every old index has a corresponding -/// unique new index, but each new index does not need to have a corresponding -/// old index. -#[derive(Default, Debug)] -pub struct Renumbering { - old_count: u32, - new_count: u32, - old_to_new: Vec, -} - -impl Renumbering { - /// Define an entry in both the old and new index spaces. Returns a tuple of - /// the old and new indices. - pub fn define_both(&mut self) -> (u32, u32) { - debug_assert_eq!( - self.old_to_new.len(), - usize::try_from(self.old_count).unwrap() - ); - self.old_to_new.push(self.new_count); - self.old_count += 1; - self.new_count += 1; - (self.old_count - 1, self.new_count - 1) - } - - /// Add an import to both the old and new index spaces. Returns a tuple of - /// the old and new indices. - pub fn add_import(&mut self) -> (u32, u32) { - self.define_both() - } - - /// Add an alias to both the old and new index spaces. Returns a tuple of - /// the old and new indices. - pub fn add_alias(&mut self) -> (u32, u32) { - self.define_both() - } - - /// Add an entry to the new index space. Returns the entry's index in the - /// new index space. - pub fn define_new(&mut self) -> u32 { - self.new_count += 1; - self.new_count - 1 - } - - /// Get the new index for the given old index. - /// - /// Panics when `old` is not in the old index space. - pub fn lookup(&self, old: u32) -> u32 { - self.old_to_new[usize::try_from(old).unwrap()] - } -} diff --git a/crates/wizer/src/translate.rs b/crates/wizer/src/translate.rs index b205e1567409..9be934ebf5f9 100644 --- a/crates/wizer/src/translate.rs +++ b/crates/wizer/src/translate.rs @@ -1,13 +1,5 @@ //! Type translator functions from `wasmparser` to `wasm_encoder`. -pub(crate) fn table_type(table_ty: wasmparser::TableType) -> wasm_encoder::TableType { - wasm_encoder::TableType { - element_type: val_type(table_ty.element_type), - minimum: table_ty.initial, - maximum: table_ty.maximum, - } -} - pub(crate) fn val_type(ty: wasmparser::Type) -> wasm_encoder::ValType { use wasm_encoder::ValType; use wasmparser::Type::*; @@ -18,8 +10,7 @@ pub(crate) fn val_type(ty: wasmparser::Type) -> wasm_encoder::ValType { F64 => ValType::F64, V128 => ValType::V128, FuncRef => ValType::FuncRef, - ExternRef | ExnRef => panic!("not supported"), - Func | EmptyBlockType => unreachable!(), + ExternRef => panic!("not supported"), } } @@ -39,58 +30,12 @@ pub(crate) fn memory_type(ty: wasmparser::MemoryType) -> wasm_encoder::MemoryTyp } } -pub(crate) fn entity_type(ty: wasmparser::ImportSectionEntryType) -> wasm_encoder::EntityType { - match ty { - wasmparser::ImportSectionEntryType::Function(f) => wasm_encoder::EntityType::Function(f), - wasmparser::ImportSectionEntryType::Table(tty) => { - wasm_encoder::EntityType::Table(table_type(tty)) - } - wasmparser::ImportSectionEntryType::Memory(mty) => { - wasm_encoder::EntityType::Memory(memory_type(mty)) - } - wasmparser::ImportSectionEntryType::Global(gty) => { - wasm_encoder::EntityType::Global(global_type(gty)) - } - wasmparser::ImportSectionEntryType::Instance(ity) => { - wasm_encoder::EntityType::Instance(ity) - } - wasmparser::ImportSectionEntryType::Module(_) => { - unreachable!( - "we disallow importing/exporting modules so we shouldn't \ - have module types" - ) - } - wasmparser::ImportSectionEntryType::Tag(_) => unreachable!(), - } -} - -pub(crate) fn item_kind(kind: wasmparser::ExternalKind) -> wasm_encoder::ItemKind { - match kind { - wasmparser::ExternalKind::Function => wasm_encoder::ItemKind::Function, - wasmparser::ExternalKind::Table => wasm_encoder::ItemKind::Table, - wasmparser::ExternalKind::Memory => wasm_encoder::ItemKind::Memory, - wasmparser::ExternalKind::Global => wasm_encoder::ItemKind::Global, - wasmparser::ExternalKind::Module => wasm_encoder::ItemKind::Module, - wasmparser::ExternalKind::Instance => wasm_encoder::ItemKind::Instance, - wasmparser::ExternalKind::Type | wasmparser::ExternalKind::Tag => unreachable!(), - } -} - pub(crate) fn export(kind: wasmparser::ExternalKind, index: u32) -> wasm_encoder::Export { match kind { - wasmparser::ExternalKind::Function => wasm_encoder::Export::Function(index), + wasmparser::ExternalKind::Func => wasm_encoder::Export::Function(index), wasmparser::ExternalKind::Global => wasm_encoder::Export::Global(index), wasmparser::ExternalKind::Table => wasm_encoder::Export::Table(index), wasmparser::ExternalKind::Memory => wasm_encoder::Export::Memory(index), - wasmparser::ExternalKind::Instance => wasm_encoder::Export::Instance(index), - wasmparser::ExternalKind::Tag - | wasmparser::ExternalKind::Type - | wasmparser::ExternalKind::Module => unreachable!(), + wasmparser::ExternalKind::Tag => unreachable!(), } } - -pub(crate) fn instance_arg<'a>( - arg: &wasmparser::InstanceArg<'a>, -) -> (&'a str, wasm_encoder::Export) { - (arg.name, export(arg.kind, arg.index)) -} diff --git a/crates/wizer/tests/tests.rs b/crates/wizer/tests/tests.rs index ad62b4ef9edd..63ca5f3e1579 100644 --- a/crates/wizer/tests/tests.rs +++ b/crates/wizer/tests/tests.rs @@ -12,7 +12,6 @@ fn get_wizer() -> Wizer { let mut wizer = Wizer::new(); wizer.allow_wasi(true).unwrap(); wizer.wasm_multi_memory(true); - wizer.wasm_module_linking(true); wizer.wasm_bulk_memory(true); wizer } @@ -85,9 +84,7 @@ fn fails_wizening(wat: &str) -> Result<()> { let wasm = wat_to_wasm(wat)?; - let mut validator = wasmparser::Validator::new(); - validator.wasm_features(wasmparser::WasmFeatures { - module_linking: true, + let mut validator = wasmparser::Validator::new_with_features(wasmparser::WasmFeatures { multi_memory: true, ..Default::default() }); From cb7b3d579f9cef10830b0f191ea6b0c09a8555f8 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 14 Apr 2023 15:20:35 -0700 Subject: [PATCH 137/212] Update `wasmparser` to a version with the latest encoding of multi-memory This commit further updates the `wasmparser` dependency across some versions with minor renamings and structuring of the API. This pulls in enough support to get the `multi_memory` test passing. --- crates/wizer/Cargo.lock | 6 +++--- crates/wizer/Cargo.toml | 2 +- crates/wizer/src/info.rs | 10 +++++----- crates/wizer/src/info/types_interner.rs | 8 ++------ crates/wizer/src/parse.rs | 23 +++++++++++++---------- crates/wizer/src/translate.rs | 4 ++-- 6 files changed, 26 insertions(+), 27 deletions(-) diff --git a/crates/wizer/Cargo.lock b/crates/wizer/Cargo.lock index ee2103e2b0bd..f29453c14979 100644 --- a/crates/wizer/Cargo.lock +++ b/crates/wizer/Cargo.lock @@ -1908,9 +1908,9 @@ dependencies = [ [[package]] name = "wasmparser" -version = "0.84.0" +version = "0.87.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77dc97c22bb5ce49a47b745bed8812d30206eff5ef3af31424f2c1820c0974b2" +checksum = "5c04e207cd2e8ecb6f9bd28a2cf3119b4c6bfeee6fe3a25cc1daf8041d00a875" dependencies = [ "indexmap", ] @@ -2416,7 +2416,7 @@ dependencies = [ "structopt", "wasi-cap-std-sync", "wasm-encoder 0.10.0", - "wasmparser 0.84.0", + "wasmparser 0.87.0", "wasmprinter", "wasmtime", "wasmtime-wasi", diff --git a/crates/wizer/Cargo.toml b/crates/wizer/Cargo.toml index 56d7d78fd2dc..8ce0071c8bd1 100644 --- a/crates/wizer/Cargo.toml +++ b/crates/wizer/Cargo.toml @@ -35,7 +35,7 @@ rayon = "1.5.0" structopt = { version = "0.3.21", optional = true } wasi-cap-std-sync = "3.0.0" wasm-encoder = "0.10.0" -wasmparser = "0.84.0" +wasmparser = "0.87.0" wasmtime = "3.0.0" wasmtime-wasi = "3.0.0" diff --git a/crates/wizer/src/info.rs b/crates/wizer/src/info.rs index 13cb362a7af1..75de9e824d00 100644 --- a/crates/wizer/src/info.rs +++ b/crates/wizer/src/info.rs @@ -1,10 +1,10 @@ +use std::convert::TryFrom; +use std::ops::Range; +use types_interner::{EntityType, TypeId, TypesInterner}; use wasm_encoder::SectionId; pub mod types_interner; -use std::convert::TryFrom; -use types_interner::{EntityType, TypeId, TypesInterner}; - /// A collection of info about modules within a module linking bundle. pub(crate) struct ModuleContext<'a> { arena: Vec>, @@ -134,7 +134,7 @@ impl Module { self, cx: &mut ModuleContext<'a>, id: SectionId, - range: wasmparser::Range, + range: Range, full_wasm: &'a [u8], ) { cx.defined_mut(self) @@ -146,7 +146,7 @@ impl Module { } /// Push a new type into this module's types space. - pub fn push_type<'a>(self, cx: &mut ModuleContext<'a>, ty: wasmparser::TypeDef) { + pub fn push_type<'a>(self, cx: &mut ModuleContext<'a>, ty: wasmparser::Type) { let types_space = match &cx.arena[self.id] { ModuleInfo::Defined(d) => &d.types, }; diff --git a/crates/wizer/src/info/types_interner.rs b/crates/wizer/src/info/types_interner.rs index 91cade06ef9c..98d8fac634c9 100644 --- a/crates/wizer/src/info/types_interner.rs +++ b/crates/wizer/src/info/types_interner.rs @@ -59,13 +59,9 @@ impl TypesInterner { /// /// If the type has already been inserted and assigned an id before, then /// that entry and its id are reused. - pub fn insert_wasmparser( - &mut self, - ty: wasmparser::TypeDef, - _types_space: &[TypeId], - ) -> TypeId { + pub fn insert_wasmparser(&mut self, ty: wasmparser::Type, _types_space: &[TypeId]) -> TypeId { match ty { - wasmparser::TypeDef::Func(func_ty) => self.insert(Type::Func(func_ty)), + wasmparser::Type::Func(func_ty) => self.insert(Type::Func(func_ty)), } } diff --git a/crates/wizer/src/parse.rs b/crates/wizer/src/parse.rs index 63be01ed69ca..349da6e31cda 100644 --- a/crates/wizer/src/parse.rs +++ b/crates/wizer/src/parse.rs @@ -74,12 +74,12 @@ pub(crate) fn parse<'a>(full_wasm: &'a [u8]) -> anyhow::Result data.range(), full_wasm, ), - CustomSection { range, .. } => { - stack - .top_mut() - .module - .add_raw_section(&mut cx, SectionId::Custom, range, full_wasm) - } + CustomSection(c) => stack.top_mut().module.add_raw_section( + &mut cx, + SectionId::Custom, + c.range(), + full_wasm, + ), CodeSectionStart { range, count: _, @@ -106,13 +106,16 @@ pub(crate) fn parse<'a>(full_wasm: &'a [u8]) -> anyhow::Result ComponentTypeSection(_) | ComponentImportSection(_) - | ComponentFunctionSection(_) | ComponentExportSection(_) | ComponentStartSection(_) + | ComponentAliasSection(_) + | CoreTypeSection(_) + | InstanceSection(_) + | ComponentInstanceSection(_) + | ComponentCanonicalSection(_) | AliasSection(_) | ModuleSection { .. } - | ComponentSection { .. } - | InstanceSection(_) => { + | ComponentSection { .. } => { unreachable!() } } @@ -134,7 +137,7 @@ fn type_section<'a>( for _ in 0..count { let ty = types.read()?; match ty { - wasmparser::TypeDef::Func(_) => { + wasmparser::Type::Func(_) => { module.push_type(cx, ty); } } diff --git a/crates/wizer/src/translate.rs b/crates/wizer/src/translate.rs index 9be934ebf5f9..80bde493712f 100644 --- a/crates/wizer/src/translate.rs +++ b/crates/wizer/src/translate.rs @@ -1,8 +1,8 @@ //! Type translator functions from `wasmparser` to `wasm_encoder`. -pub(crate) fn val_type(ty: wasmparser::Type) -> wasm_encoder::ValType { +pub(crate) fn val_type(ty: wasmparser::ValType) -> wasm_encoder::ValType { use wasm_encoder::ValType; - use wasmparser::Type::*; + use wasmparser::ValType::*; match ty { I32 => ValType::I32, I64 => ValType::I64, From 86d9f66b009aee4bdaaeaa0b5c5852eab8f77b50 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 14 Apr 2023 15:33:22 -0700 Subject: [PATCH 138/212] Remove module linking support from fuzzer --- crates/wizer/fuzz/fuzz_targets/same_result.rs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/crates/wizer/fuzz/fuzz_targets/same_result.rs b/crates/wizer/fuzz/fuzz_targets/same_result.rs index b069bdb7fb91..43fbd454b8c9 100644 --- a/crates/wizer/fuzz/fuzz_targets/same_result.rs +++ b/crates/wizer/fuzz/fuzz_targets/same_result.rs @@ -68,7 +68,6 @@ fuzz_target!(|module: wasm_smith::ConfiguredModule| { // initialization routine. let mut wizer = wizer::Wizer::new(); wizer - .wasm_module_linking(true) .wasm_multi_memory(true) .wasm_multi_value(true) .init_func(init_func); @@ -197,10 +196,6 @@ impl<'a> arbitrary::Arbitrary<'a> for WasmConfig { } impl wasm_smith::Config for WasmConfig { - fn module_linking_enabled(&self) -> bool { - true - } - fn max_memories(&self) -> usize { 10 } From 1995ac49ffb6f755faacdba429919162ad166ccd Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 14 Apr 2023 17:30:57 -0700 Subject: [PATCH 139/212] Update wasmparser to the latest version Mostly just shuffling some bits around, shouldn't have any major impact on wizer. --- crates/wizer/Cargo.lock | 11 +------ crates/wizer/Cargo.toml | 2 +- crates/wizer/src/lib.rs | 6 ++-- crates/wizer/src/parse.rs | 58 ++++++++++++++--------------------- crates/wizer/src/translate.rs | 4 +-- 5 files changed, 30 insertions(+), 51 deletions(-) diff --git a/crates/wizer/Cargo.lock b/crates/wizer/Cargo.lock index f29453c14979..54dcba3147bf 100644 --- a/crates/wizer/Cargo.lock +++ b/crates/wizer/Cargo.lock @@ -1906,15 +1906,6 @@ dependencies = [ "wasm-encoder 0.4.1", ] -[[package]] -name = "wasmparser" -version = "0.87.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c04e207cd2e8ecb6f9bd28a2cf3119b4c6bfeee6fe3a25cc1daf8041d00a875" -dependencies = [ - "indexmap", -] - [[package]] name = "wasmparser" version = "0.93.0" @@ -2416,7 +2407,7 @@ dependencies = [ "structopt", "wasi-cap-std-sync", "wasm-encoder 0.10.0", - "wasmparser 0.87.0", + "wasmparser 0.103.0", "wasmprinter", "wasmtime", "wasmtime-wasi", diff --git a/crates/wizer/Cargo.toml b/crates/wizer/Cargo.toml index 8ce0071c8bd1..6179ad61d83e 100644 --- a/crates/wizer/Cargo.toml +++ b/crates/wizer/Cargo.toml @@ -35,7 +35,7 @@ rayon = "1.5.0" structopt = { version = "0.3.21", optional = true } wasi-cap-std-sync = "3.0.0" wasm-encoder = "0.10.0" -wasmparser = "0.87.0" +wasmparser = "0.103.0" wasmtime = "3.0.0" wasmtime-wasi = "3.0.0" diff --git a/crates/wizer/src/lib.rs b/crates/wizer/src/lib.rs index 6b86c0deb722..04d991774302 100644 --- a/crates/wizer/src/lib.rs +++ b/crates/wizer/src/lib.rs @@ -544,6 +544,7 @@ impl Wizer { mutable_global: true, saturating_float_to_int: true, sign_extension: true, + floats: true, // Proposals that we support. multi_memory: self.wasm_multi_memory.unwrap_or(DEFAULT_WASM_MULTI_MEMORY), @@ -559,6 +560,8 @@ impl Wizer { extended_const: false, relaxed_simd: false, component_model: false, + memory_control: false, + function_references: false, // XXX: Though we don't fully support bulk memory yet, we // unconditionally turn it on. @@ -584,9 +587,6 @@ impl Wizer { // that no table-mutating instructions exist in our input modules // until we *actually* support bulk memory. bulk_memory: true, - - // We will never want to enable this. - deterministic_only: false, } } diff --git a/crates/wizer/src/parse.rs b/crates/wizer/src/parse.rs index 349da6e31cda..10ec2d028a0a 100644 --- a/crates/wizer/src/parse.rs +++ b/crates/wizer/src/parse.rs @@ -6,7 +6,6 @@ use crate::stack_ext::StackExt; use anyhow::{Context, Result}; use std::convert::TryFrom; use wasm_encoder::SectionId; -use wasmparser::SectionReader; struct StackEntry { parser: wasmparser::Parser, @@ -107,13 +106,12 @@ pub(crate) fn parse<'a>(full_wasm: &'a [u8]) -> anyhow::Result ComponentTypeSection(_) | ComponentImportSection(_) | ComponentExportSection(_) - | ComponentStartSection(_) + | ComponentStartSection { .. } | ComponentAliasSection(_) | CoreTypeSection(_) | InstanceSection(_) | ComponentInstanceSection(_) | ComponentCanonicalSection(_) - | AliasSection(_) | ModuleSection { .. } | ComponentSection { .. } => { unreachable!() @@ -126,18 +124,16 @@ fn type_section<'a>( cx: &mut ModuleContext<'a>, stack: &mut Vec, full_wasm: &'a [u8], - mut types: wasmparser::TypeSectionReader<'a>, + types: wasmparser::TypeSectionReader<'a>, ) -> anyhow::Result<()> { let module = stack.top().module; module.add_raw_section(cx, SectionId::Type, types.range(), full_wasm); // Parse out types, as we will need them later when processing // instance imports. - let count = usize::try_from(types.get_count()).unwrap(); - for _ in 0..count { - let ty = types.read()?; - match ty { - wasmparser::Type::Func(_) => { + for ty in types { + match ty? { + ty @ wasmparser::Type::Func(_) => { module.push_type(cx, ty); } } @@ -150,7 +146,7 @@ fn import_section<'a>( cx: &mut ModuleContext<'a>, stack: &mut Vec, full_wasm: &'a [u8], - mut imports: wasmparser::ImportSectionReader<'a>, + imports: wasmparser::ImportSectionReader<'a>, ) -> anyhow::Result<()> { let module = stack.top().module; stack @@ -159,9 +155,8 @@ fn import_section<'a>( .add_raw_section(cx, SectionId::Import, imports.range(), full_wasm); // Check that we can properly handle all imports. - let count = imports.get_count(); - for _ in 0..count { - let imp = imports.read()?; + for imp in imports { + let imp = imp?; if imp.module.starts_with("__wizer_") || imp.name.starts_with("__wizer_") { anyhow::bail!( @@ -217,15 +212,13 @@ fn function_section<'a>( cx: &mut ModuleContext<'a>, stack: &mut Vec, full_wasm: &'a [u8], - mut funcs: wasmparser::FunctionSectionReader<'a>, + funcs: wasmparser::FunctionSectionReader<'a>, ) -> anyhow::Result<()> { let module = stack.top().module; module.add_raw_section(cx, SectionId::Function, funcs.range(), full_wasm); - let count = usize::try_from(funcs.get_count()).unwrap(); - for _ in 0..count { - let ty_idx = funcs.read()?; - let ty = module.type_id_at(cx, ty_idx); + for ty_idx in funcs { + let ty = module.type_id_at(cx, ty_idx?); module.push_function(cx, ty); } Ok(()) @@ -235,14 +228,13 @@ fn table_section<'a>( cx: &mut ModuleContext<'a>, stack: &mut Vec, full_wasm: &'a [u8], - mut tables: wasmparser::TableSectionReader<'a>, + tables: wasmparser::TableSectionReader<'a>, ) -> anyhow::Result<()> { let module = stack.top().module; module.add_raw_section(cx, SectionId::Table, tables.range(), full_wasm); - let count = usize::try_from(tables.get_count()).unwrap(); - for _ in 0..count { - module.push_table(cx, tables.read()?); + for table in tables { + module.push_table(cx, table?.ty); } Ok(()) } @@ -251,15 +243,13 @@ fn memory_section<'a>( cx: &mut ModuleContext<'a>, stack: &mut Vec, full_wasm: &'a [u8], - mut mems: wasmparser::MemorySectionReader<'a>, + mems: wasmparser::MemorySectionReader<'a>, ) -> anyhow::Result<()> { let module = stack.top().module; module.add_raw_section(cx, SectionId::Memory, mems.range(), full_wasm); - let count = usize::try_from(mems.get_count()).unwrap(); - for _ in 0..count { - let m = mems.read()?; - module.push_defined_memory(cx, m); + for m in mems { + module.push_defined_memory(cx, m?); } Ok(()) } @@ -268,15 +258,13 @@ fn global_section<'a>( cx: &mut ModuleContext<'a>, stack: &mut Vec, full_wasm: &'a [u8], - mut globals: wasmparser::GlobalSectionReader<'a>, + globals: wasmparser::GlobalSectionReader<'a>, ) -> anyhow::Result<()> { let module = stack.top().module; module.add_raw_section(cx, SectionId::Global, globals.range(), full_wasm); - let count = usize::try_from(globals.get_count()).unwrap(); - for _ in 0..count { - let g = globals.read()?; - module.push_defined_global(cx, g.ty); + for g in globals { + module.push_defined_global(cx, g?.ty); } Ok(()) } @@ -285,13 +273,13 @@ fn export_section<'a>( cx: &mut ModuleContext<'a>, stack: &mut Vec, full_wasm: &'a [u8], - mut exports: wasmparser::ExportSectionReader<'a>, + exports: wasmparser::ExportSectionReader<'a>, ) -> anyhow::Result<()> { let module = stack.top().module; module.add_raw_section(cx, SectionId::Export, exports.range(), full_wasm); - for _ in 0..exports.get_count() { - let export = exports.read()?; + for export in exports { + let export = export?; if export.name.starts_with("__wizer_") { anyhow::bail!( diff --git a/crates/wizer/src/translate.rs b/crates/wizer/src/translate.rs index 80bde493712f..1ee4a8d2e871 100644 --- a/crates/wizer/src/translate.rs +++ b/crates/wizer/src/translate.rs @@ -9,8 +9,8 @@ pub(crate) fn val_type(ty: wasmparser::ValType) -> wasm_encoder::ValType { F32 => ValType::F32, F64 => ValType::F64, V128 => ValType::V128, - FuncRef => ValType::FuncRef, - ExternRef => panic!("not supported"), + wasmparser::ValType::FUNCREF => ValType::FuncRef, + Ref(_) => panic!("not supported"), } } From 348b47e474a6f5bd468ac3af915dbeb2dd97a46f Mon Sep 17 00:00:00 2001 From: Jake Champion Date: Thu, 5 Jan 2023 11:28:06 +0000 Subject: [PATCH 140/212] update to wasmtime 4 --- crates/wizer/Cargo.lock | 1131 +++++++++-------- crates/wizer/Cargo.toml | 6 +- crates/wizer/benches/regex.rs | 2 +- crates/wizer/benches/uap.rs | 6 +- crates/wizer/fuzz/Cargo.toml | 2 +- crates/wizer/fuzz/fuzz_targets/same_result.rs | 2 +- crates/wizer/src/lib.rs | 4 +- 7 files changed, 593 insertions(+), 560 deletions(-) diff --git a/crates/wizer/Cargo.lock b/crates/wizer/Cargo.lock index 54dcba3147bf..494cd8a7e514 100644 --- a/crates/wizer/Cargo.lock +++ b/crates/wizer/Cargo.lock @@ -24,9 +24,9 @@ dependencies = [ [[package]] name = "aho-corasick" -version = "0.7.18" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f" +checksum = "67fc08ce920c31afb70f013dcce1bfc3a3195de6a228474e45e1f145b36f8d04" dependencies = [ "memchr", ] @@ -37,26 +37,32 @@ version = "0.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec8ad6edb4840b78c5c3d88de606b22252d552b55f3a4699fbb10fc070ec3049" +[[package]] +name = "ambient-authority" +version = "0.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9d4ee0d472d1cd2e28c97dfa124b3d8d992e10eb0a035f33f5d12e3a177ba3b" + [[package]] name = "ansi_term" -version = "0.11.0" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" +checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" dependencies = [ "winapi", ] [[package]] name = "anyhow" -version = "1.0.68" +version = "1.0.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2cb2f989d18dd141ab8ae82f64d1a8cdd37e0840f73a406896cf5e99502fab61" +checksum = "7de8ce5e0f9f8d88245311066a578d72b7af3e7088f32783804676302df237e4" [[package]] name = "arbitrary" -version = "1.0.2" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "577b08a4acd7b99869f863c50011b01eb73424ccc798ecd996f2e24817adfca7" +checksum = "e2d098ff73c1ca148721f37baad5ea6a465a13f9573aba8641fbbbae8164a54e" dependencies = [ "derive_arbitrary", ] @@ -69,13 +75,13 @@ checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6" [[package]] name = "async-trait" -version = "0.1.51" +version = "0.1.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44318e776df68115a881de9a8fd1b9e53368d7a4a5ce4cc48517da3393233a5e" +checksum = "b9ccdd8f2a161be9bd5c023df56f1b2a0bd1d83872ae53b71a84a12c9bf6e842" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.15", ] [[package]] @@ -91,15 +97,15 @@ dependencies = [ [[package]] name = "autocfg" -version = "1.0.1" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "base64" -version = "0.13.0" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" +checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" [[package]] name = "bincode" @@ -118,30 +124,18 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "block-buffer" -version = "0.10.3" +version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69cce20737498f97b993470a6e536b8523f0af7892a4f928cceb1ac5e52ebe7e" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" dependencies = [ "generic-array", ] -[[package]] -name = "bstr" -version = "0.2.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90682c8d613ad3373e66de8c6411e0ae2ab2571e879d2efbf73558cc66f21279" -dependencies = [ - "lazy_static", - "memchr", - "regex-automata", - "serde", -] - [[package]] name = "bumpalo" -version = "3.7.1" +version = "3.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9df67f7bf9ef8498769f994239c45613ef0c5899415fb58e9add412d2c1a538" +checksum = "9b1ce199063694f33ffb7dd4e0ee620741495c32833cde5aa08f02a0bf96f0c8" [[package]] name = "byteorder" @@ -151,24 +145,24 @@ checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" [[package]] name = "cap-fs-ext" -version = "0.26.1" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b0e103ce36d217d568903ad27b14ec2238ecb5d65bad2e756a8f3c0d651506e" +checksum = "e1742f5106155d46a41eac5f730ee189bf92fde6ae109fbf2cdb67176726ca5d" dependencies = [ - "cap-primitives 0.26.1", - "cap-std 0.26.1", - "io-lifetimes 0.7.5", - "windows-sys 0.36.1", + "cap-primitives 1.0.14", + "cap-std 1.0.14", + "io-lifetimes 1.0.10", + "windows-sys 0.48.0", ] [[package]] name = "cap-primitives" -version = "0.24.1" +version = "0.24.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "defd283f080043a702c362203c2646a4e0a2fff99baede1eea1416239f0af220" +checksum = "fb8fca3e81fae1d91a36e9784ca22a39ef623702b5f7904d89dc31f10184a178" dependencies = [ - "ambient-authority", - "errno", + "ambient-authority 0.0.1", + "errno 0.2.8", "fs-set-times 0.15.0", "io-extras 0.13.2", "io-lifetimes 0.5.3", @@ -182,39 +176,38 @@ dependencies = [ [[package]] name = "cap-primitives" -version = "0.26.1" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af3f336aa91cce16033ed3c94ac91d98956c49b420e6d6cd0dd7d0e386a57085" +checksum = "42068f579028e856717d61423645c85d2d216dde8eff62c9b30140e725c79177" dependencies = [ - "ambient-authority", - "fs-set-times 0.17.1", - "io-extras 0.15.0", - "io-lifetimes 0.7.5", + "ambient-authority 0.0.2", + "fs-set-times 0.19.1", + "io-extras 0.17.4", + "io-lifetimes 1.0.10", "ipnet", "maybe-owned", - "rustix 0.35.13", - "winapi-util", - "windows-sys 0.36.1", - "winx 0.33.0", + "rustix 0.37.14", + "windows-sys 0.48.0", + "winx 0.35.1", ] [[package]] name = "cap-rand" -version = "0.26.1" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d14b9606aa9550d34651bc481443203bc014237bdb992d201d2afa62d2ec6dea" +checksum = "d3be2ededc13f42a5921c08e565b854cb5ff9b88753e2c6ec12c58a24e7e8d4e" dependencies = [ - "ambient-authority", + "ambient-authority 0.0.2", "rand", ] [[package]] name = "cap-std" -version = "0.24.2" +version = "0.24.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3430d1b5ba78fa381eb227525578d2b85d77b42ff49be85d1e72a94f305e603c" +checksum = "2247568946095c7765ad2b441a56caffc08027734c634a6d5edda648f04e32eb" dependencies = [ - "cap-primitives 0.24.1", + "cap-primitives 0.24.4", "io-extras 0.13.2", "io-lifetimes 0.5.3", "ipnet", @@ -223,43 +216,39 @@ dependencies = [ [[package]] name = "cap-std" -version = "0.26.1" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9d6e70b626eceac9d6fc790fe2d72cc3f2f7bc3c35f467690c54a526b0f56db" +checksum = "559ad6fab5fedcc9bd5877160e1433fcd481f8af615068d6ca49472b1201cc6c" dependencies = [ - "cap-primitives 0.26.1", - "io-extras 0.15.0", - "io-lifetimes 0.7.5", - "ipnet", - "rustix 0.35.13", + "cap-primitives 1.0.14", + "io-extras 0.17.4", + "io-lifetimes 1.0.10", + "rustix 0.37.14", ] [[package]] name = "cap-time-ext" -version = "0.26.1" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3a0524f7c4cff2ea547ae2b652bf7a348fd3e48f76556dc928d8b45ab2f1d50" +checksum = "2a74e04cd32787bfa3a911af745b0fd5d99d4c3fc16c64449e1622c06fa27c8e" dependencies = [ - "cap-primitives 0.26.1", + "cap-primitives 1.0.14", "once_cell", - "rustix 0.35.13", - "winx 0.33.0", + "rustix 0.37.14", + "winx 0.35.1", ] [[package]] name = "cast" -version = "0.2.7" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c24dab4283a142afa2fdca129b80ad2c6284e073930f964c3a1293c225ee39a" -dependencies = [ - "rustc_version", -] +checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" [[package]] name = "cc" -version = "1.0.73" +version = "1.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" +checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" dependencies = [ "jobserver", ] @@ -272,9 +261,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "clap" -version = "2.33.3" +version = "2.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002" +checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" dependencies = [ "ansi_term", "atty", @@ -287,36 +276,36 @@ dependencies = [ [[package]] name = "cpp_demangle" -version = "0.3.3" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ea47428dc9d2237f3c6bc134472edfd63ebba0af932e783506dcfd66f10d18a" +checksum = "eeaa953eaad386a53111e47172c2fedba671e5684c8dd601a5f474f4f118710f" dependencies = [ "cfg-if", ] [[package]] name = "cpufeatures" -version = "0.2.1" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95059428f66df56b63431fdb4e1947ed2190586af5c5a8a8b71122bdf5a7f469" +checksum = "3e4c1eaa2012c47becbbad2ab175484c2a84d1185b566fb2cc5b8707343dfe58" dependencies = [ "libc", ] [[package]] name = "cranelift-bforest" -version = "0.90.1" +version = "0.91.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b62c772976416112fa4484cbd688cb6fb35fd430005c1c586224fc014018abad" +checksum = "2a2ab4512dfd3a6f4be184403a195f76e81a8a9f9e6c898e19d2dc3ce20e0115" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-codegen" -version = "0.90.1" +version = "0.91.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b40ed2dd13c2ac7e24f88a3090c68ad3414eb1d066a95f8f1f7b3b819cb4e46" +checksum = "98b022ed2a5913a38839dfbafe6cf135342661293b08049843362df4301261dc" dependencies = [ "arrayvec", "bumpalo", @@ -335,24 +324,24 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.90.1" +version = "0.91.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb927a8f1c27c34ee3759b6b0ffa528d2330405d5cc4511f0cab33fe2279f4b5" +checksum = "639307b45434ad112a98f8300c0f0ab085cbefcd767efcdef9ef19d4c0756e74" dependencies = [ "cranelift-codegen-shared", ] [[package]] name = "cranelift-codegen-shared" -version = "0.90.1" +version = "0.91.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43dfa417b884a9ab488d95fd6b93b25e959321fe7bfd7a0a960ba5d7fb7ab927" +checksum = "278e52e29c53fcf32431ef08406c295699a70306d05a0715c5b1bf50e33a9ab7" [[package]] name = "cranelift-egraph" -version = "0.90.1" +version = "0.91.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0a66b39785efd8513d2cca967ede56d6cc57c8d7986a595c7c47d0c78de8dce" +checksum = "624b54323b06e675293939311943ba82d323bb340468ce1889be5da7932c8d73" dependencies = [ "cranelift-entity", "fxhash", @@ -364,18 +353,18 @@ dependencies = [ [[package]] name = "cranelift-entity" -version = "0.90.1" +version = "0.91.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0637ffde963cb5d759bc4d454cfa364b6509e6c74cdaa21298add0ed9276f346" +checksum = "9a59bcbca89c3f1b70b93ab3cbba5e5e0cbf3e63dadb23c7525cb142e21a9d4c" dependencies = [ "serde", ] [[package]] name = "cranelift-frontend" -version = "0.90.1" +version = "0.91.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb72b8342685e850cb037350418f62cc4fc55d6c2eb9c7ca01b82f9f1a6f3d56" +checksum = "0d70abacb8cfef3dc8ff7e8836e9c1d70f7967dfdac824a4cd5e30223415aca6" dependencies = [ "cranelift-codegen", "log", @@ -385,15 +374,15 @@ dependencies = [ [[package]] name = "cranelift-isle" -version = "0.90.1" +version = "0.91.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "850579cb9e4b448f7c301f1e6e6cbad99abe3f1f1d878a4994cb66e33c6db8cd" +checksum = "393bc73c451830ff8dbb3a07f61843d6cb41a084f9996319917c0b291ed785bb" [[package]] name = "cranelift-native" -version = "0.90.1" +version = "0.91.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d0a279e5bcba3e0466c734d8d8eb6bfc1ad29e95c37f3e4955b492b5616335e" +checksum = "ba392fd53b1bf6d45bf1d97f7e13bb8ba8424f19d66d80e60a0d594c2bb2636e" dependencies = [ "cranelift-codegen", "libc", @@ -402,9 +391,9 @@ dependencies = [ [[package]] name = "cranelift-wasm" -version = "0.90.1" +version = "0.91.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6b8c5e7ffb754093fb89ec4bd4f9dbb9f1c955427299e334917d284745835c2" +checksum = "016abecc42cc114b924fa3fc306267f566076cefd3e43b891c510c8085c0811e" dependencies = [ "cranelift-codegen", "cranelift-entity", @@ -412,24 +401,24 @@ dependencies = [ "itertools", "log", "smallvec", - "wasmparser 0.93.0", + "wasmparser 0.95.0", "wasmtime-types", ] [[package]] name = "crc32fast" -version = "1.2.1" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81156fece84ab6a9f2afdb109ce3ae577e42b1228441eded99bd77f627953b1a" +checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" dependencies = [ "cfg-if", ] [[package]] name = "criterion" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1604dafd25fba2fe2d5895a9da139f8dc9b319a5fe5354ca137cbbce4e178d10" +checksum = "b01d6de93b2b6c65e17c634a26653a29d107b3c98c607c765bf38d041531cd8f" dependencies = [ "atty", "cast", @@ -453,9 +442,9 @@ dependencies = [ [[package]] name = "criterion-plot" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d00996de9f2f7559f7f4dc286073197f83e92256a59ed395f9aac01fe717da57" +checksum = "2673cc8207403546f45f5fd319a974b1e6983ad1a3ee7e6041650013be041876" dependencies = [ "cast", "itertools", @@ -463,9 +452,9 @@ dependencies = [ [[package]] name = "crossbeam-channel" -version = "0.5.1" +version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06ed27e177f16d65f0f0c22a213e17c696ace5dd64b14258b52f9417ccb52db4" +checksum = "a33c2bf77f2df06183c3aa30d1e96c0695a313d4f9c453cc3762a6db39f99200" dependencies = [ "cfg-if", "crossbeam-utils", @@ -473,9 +462,9 @@ dependencies = [ [[package]] name = "crossbeam-deque" -version = "0.8.1" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6455c0ca19f0d2fbf751b908d5c55c1f5cbc65e03c4225427254b46890bdde1e" +checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef" dependencies = [ "cfg-if", "crossbeam-epoch", @@ -484,25 +473,24 @@ dependencies = [ [[package]] name = "crossbeam-epoch" -version = "0.9.5" +version = "0.9.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ec02e091aa634e2c3ada4a392989e7c3116673ef0ac5b72232439094d73b7fd" +checksum = "46bd5f3f85273295a9d14aedfb86f6aadbff6d8f5295c4a9edb08e819dcf5695" dependencies = [ + "autocfg", "cfg-if", "crossbeam-utils", - "lazy_static", - "memoffset", + "memoffset 0.8.0", "scopeguard", ] [[package]] name = "crossbeam-utils" -version = "0.8.5" +version = "0.8.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d82cfc11ce7f2c3faef78d8a684447b40d503d9681acebed6cb728d45940c4db" +checksum = "3c063cd8cc95f5c377ed0d4b49a4b21f632396ff690e8470c29b3359b346984b" dependencies = [ "cfg-if", - "lazy_static", ] [[package]] @@ -517,13 +505,12 @@ dependencies = [ [[package]] name = "csv" -version = "1.1.6" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22813a6dc45b335f9bade10bf7271dc477e81113e89eb251a0bc2a8a81c536e1" +checksum = "0b015497079b9a9d69c02ad25de6c0a6edef051ea6360a327d0bd05802ef64ad" dependencies = [ - "bstr", "csv-core", - "itoa 0.4.8", + "itoa", "ryu", "serde", ] @@ -539,13 +526,13 @@ dependencies = [ [[package]] name = "derive_arbitrary" -version = "1.0.2" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b24629208e87a2d8b396ff43b15c4afb0a69cea3fbbaa9ed9b92b7c02f0aed73" +checksum = "f3cdeb9ec472d588e539a818b2dee436825730da08ad0017c4b1a17676bdc8b7" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -569,20 +556,19 @@ dependencies = [ ] [[package]] -name = "dirs-next" -version = "2.0.0" +name = "dirs" +version = "4.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b98cf8ebf19c3d1b223e151f99a4f9f0690dca41414773390fc824184ac833e1" +checksum = "ca3aa72a6f96ea37bbc5aa912f6788242832f75369bdfdadcb0e38423f100059" dependencies = [ - "cfg-if", - "dirs-sys-next", + "dirs-sys", ] [[package]] -name = "dirs-sys-next" -version = "0.1.2" +name = "dirs-sys" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d" +checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6" dependencies = [ "libc", "redox_users", @@ -590,25 +576,30 @@ dependencies = [ ] [[package]] -name = "dtoa" -version = "0.4.8" +name = "dirs-sys-next" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56899898ce76aaf4a0f24d914c97ea6ed976d42fec6ad33fcbb0a1103e07b2b0" +checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d" +dependencies = [ + "libc", + "redox_users", + "winapi", +] [[package]] name = "either" -version = "1.6.1" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" +checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" [[package]] name = "env_logger" -version = "0.7.1" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36" +checksum = "a19187fea3ac7e84da7dacf48de0c45d63c6a76f9490dae389aead16c243fce3" dependencies = [ "atty", - "humantime 1.3.0", + "humantime", "log", "regex", "termcolor", @@ -616,12 +607,12 @@ dependencies = [ [[package]] name = "env_logger" -version = "0.8.4" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a19187fea3ac7e84da7dacf48de0c45d63c6a76f9490dae389aead16c243fce3" +checksum = "85cdab6a89accf66733ad5a1693a4dcced6aeff64602b634530dd73c1f3ee9f0" dependencies = [ - "atty", - "humantime 2.1.0", + "humantime", + "is-terminal", "log", "regex", "termcolor", @@ -638,13 +629,24 @@ dependencies = [ "winapi", ] +[[package]] +name = "errno" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a" +dependencies = [ + "errno-dragonfly", + "libc", + "windows-sys 0.48.0", +] + [[package]] name = "errno-dragonfly" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14ca354e36190500e1e1fb267c647932382b54053c50b14970856c0b00a35067" +checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" dependencies = [ - "gcc", + "cc", "libc", ] @@ -654,13 +656,24 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" +[[package]] +name = "fd-lock" +version = "3.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39ae6b3d9530211fb3b12a95374b8b0823be812f53d09e18c5675c0146b09642" +dependencies = [ + "cfg-if", + "rustix 0.37.14", + "windows-sys 0.48.0", +] + [[package]] name = "file-per-thread-logger" -version = "0.1.4" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fdbe0d94371f9ce939b555dd342d0686cc4c0cadbcd4b61d70af5ff97eb4126" +checksum = "84f2e425d9790201ba4af4630191feac6dcc98765b118d4d18e91d23c2353866" dependencies = [ - "env_logger 0.7.1", + "env_logger 0.10.0", "log", ] @@ -686,13 +699,24 @@ dependencies = [ [[package]] name = "fs-set-times" -version = "0.17.1" +version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a267b6a9304912e018610d53fe07115d8b530b160e85db4d2d3a59f3ddde1aec" +checksum = "857cf27edcb26c2a36d84b2954019573d335bb289876113aceacacdca47a4fd4" dependencies = [ - "io-lifetimes 0.7.5", - "rustix 0.35.13", - "windows-sys 0.36.1", + "io-lifetimes 1.0.10", + "rustix 0.36.13", + "windows-sys 0.45.0", +] + +[[package]] +name = "fs-set-times" +version = "0.19.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7833d0f115a013d51c55950a3b09d30e4b057be9961b709acb9b5b17a1108861" +dependencies = [ + "io-lifetimes 1.0.10", + "rustix 0.37.14", + "windows-sys 0.48.0", ] [[package]] @@ -704,17 +728,11 @@ dependencies = [ "byteorder", ] -[[package]] -name = "gcc" -version = "0.3.55" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" - [[package]] name = "generic-array" -version = "0.14.4" +version = "0.14.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "501466ecc8a30d1d3b7fc9229b122b2ce8ed6e9d9223f1138d4babb253e51817" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", @@ -722,9 +740,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.3" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753" +checksum = "c85e1d9ab2eadba7e5040d4e09cbd6d072b76a557ad64e797c2cb9d4da21d7e4" dependencies = [ "cfg-if", "libc", @@ -733,9 +751,9 @@ dependencies = [ [[package]] name = "gimli" -version = "0.26.1" +version = "0.26.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78cc372d058dcf6d5ecd98510e7fbc9e5aec4d21de70f65fea8fecebcd881bd4" +checksum = "22030e2c5a68ec659fde1e949a745124b48e6fa8b045b7ed5bd1fe4ccc5c4e5d" dependencies = [ "fallible-iterator", "indexmap", @@ -744,9 +762,9 @@ dependencies = [ [[package]] name = "half" -version = "1.7.1" +version = "1.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62aca2aba2d62b4a7f5b33f3712cb1b0692779a56fb510499d5c0aa594daeaf3" +checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7" [[package]] name = "hashbrown" @@ -768,9 +786,9 @@ dependencies = [ [[package]] name = "heck" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" [[package]] name = "hermit-abi" @@ -783,21 +801,18 @@ dependencies = [ [[package]] name = "hermit-abi" -version = "0.2.0" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ab7905ea95c6d9af62940f9d7dd9596d54c334ae2c15300c482051292d5637f" +checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" dependencies = [ "libc", ] [[package]] -name = "humantime" -version = "1.3.0" +name = "hermit-abi" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f" -dependencies = [ - "quick-error", -] +checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" [[package]] name = "humantime" @@ -817,9 +832,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "1.9.2" +version = "1.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1885e79c1fc4b10f0e172c475f458b7f7b93061064d98c3293e98c5ba0c8b399" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" dependencies = [ "autocfg", "hashbrown", @@ -838,12 +853,12 @@ dependencies = [ [[package]] name = "io-extras" -version = "0.15.0" +version = "0.17.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a5d8c2ab5becd8720e30fd25f8fa5500d8dc3fceadd8378f05859bd7b46fc49" +checksum = "fde93d48f0d9277f977a333eca8313695ddd5301dc96f7e02aeddcb0dd99096f" dependencies = [ - "io-lifetimes 0.7.5", - "windows-sys 0.36.1", + "io-lifetimes 1.0.10", + "windows-sys 0.48.0", ] [[package]] @@ -854,68 +869,53 @@ checksum = "ec58677acfea8a15352d42fc87d11d63596ade9239e0a7c9352914417515dbe6" [[package]] name = "io-lifetimes" -version = "0.7.5" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59ce5ef949d49ee85593fc4d3f3f95ad61657076395cbbce23e2121fc5542074" +checksum = "9c66c74d2ae7e79a5a8f7ac924adbe38ee42a859c6539ad869eb51f0b52dc220" dependencies = [ + "hermit-abi 0.3.1", "libc", - "windows-sys 0.42.0", -] - -[[package]] -name = "io-lifetimes" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46112a93252b123d31a119a8d1a1ac19deac4fac6e0e8b0df58f0d4e5870e63c" -dependencies = [ - "libc", - "windows-sys 0.42.0", + "windows-sys 0.48.0", ] [[package]] name = "ipnet" -version = "2.3.1" +version = "2.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68f2d64f2edebec4ce84ad108148e67e1064789bee435edc5b60ad398714a3a9" +checksum = "12b6ee2129af8d4fb011108c73d99a1b83a85977f23b82460c0ae2e25bb4b57f" [[package]] name = "is-terminal" -version = "0.3.0" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d508111813f9af3afd2f92758f77e4ed2cc9371b642112c6a48d22eb73105c5" +checksum = "adcf93614601c8129ddf72e2d5633df827ba6551541c6d8c59520a371475be1f" dependencies = [ - "hermit-abi 0.2.0", - "io-lifetimes 0.7.5", - "rustix 0.35.13", - "windows-sys 0.36.1", + "hermit-abi 0.3.1", + "io-lifetimes 1.0.10", + "rustix 0.37.14", + "windows-sys 0.48.0", ] [[package]] name = "itertools" -version = "0.10.1" +version = "0.10.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69ddb889f9d0d08a67338271fa9b62996bc788c7796a5c18cf057420aaed5eaf" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" dependencies = [ "either", ] [[package]] name = "itoa" -version = "0.4.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4" - -[[package]] -name = "itoa" -version = "1.0.1" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1aab8fc367588b89dcee83ab0fd66b72b50b72fa1904d7095045ace2b0c81c35" +checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" [[package]] name = "ittapi" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8c4f6ff06169ce7048dac5150b1501c7e3716a929721aeb06b87e51a43e42f4" +checksum = "2e648c437172ce7d3ac35ca11a068755072054826fa455a916b43524fa4a62a7" dependencies = [ "anyhow", "ittapi-sys", @@ -924,27 +924,27 @@ dependencies = [ [[package]] name = "ittapi-sys" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87e078cce01485f418bae3beb34dd604aaedf2065502853c7da17fbce8e64eda" +checksum = "a9b32a4d23f72548178dde54f3c12c6b6a08598e25575c0d0fa5bd861e0dc1a5" dependencies = [ "cc", ] [[package]] name = "jobserver" -version = "0.1.24" +version = "0.1.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af25a77299a7f711a01975c35a6a424eb6862092cc2d6c72c4ed6cbc56dfc1fa" +checksum = "936cfd212a0155903bcbc060e316fb6cc7cbf2e1907329391ebadc1fe0ce77c2" dependencies = [ "libc", ] [[package]] name = "js-sys" -version = "0.3.55" +version = "0.3.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cc9ffccd38c451a86bf13657df244e9c3f37493cce8e5e21e940963777acc84" +checksum = "445dde2150c55e483f3d8416706b97ec8e8237c307e5b7b4b8dd15e6af2a0730" dependencies = [ "wasm-bindgen", ] @@ -957,21 +957,21 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "leb128" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3576a87f2ba00f6f106fdfcd16db1d698d648a26ad8e0573cad8537c3c362d2a" +checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" [[package]] name = "libc" -version = "0.2.139" +version = "0.2.142" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" +checksum = "6a987beff54b60ffa6d51982e1aa1146bc42f19bd26be28b0586f252fccf5317" [[package]] name = "libfuzzer-sys" -version = "0.4.2" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36a9a84a6e8b55dfefb04235e55edb2b9a2a18488fcae777a6bdaa6f06f1deb3" +checksum = "beb09950ae85a0a94b27676cccf37da5ff13f27076aa1adbc6545dd0d0e1bd4e" dependencies = [ "arbitrary", "cc", @@ -980,9 +980,9 @@ dependencies = [ [[package]] name = "linked-hash-map" -version = "0.5.4" +version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fb9b38af92608140b86b693604b9ffcc5824240a484d1ecd4795bacb2fe88f3" +checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" [[package]] name = "linux-raw-sys" @@ -992,15 +992,15 @@ checksum = "5284f00d480e1c39af34e72f8ad60b94f47007e3481cd3b731c1d67190ddc7b7" [[package]] name = "linux-raw-sys" -version = "0.0.46" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4d2456c373231a208ad294c33dc5bff30051eafd954cd4caae83a712b12854d" +checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4" [[package]] name = "linux-raw-sys" -version = "0.1.4" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4" +checksum = "36eb31c1778188ae1e64398743890d0877fef36d11521ac60406b42016e8c2cf" [[package]] name = "log" @@ -1028,44 +1028,53 @@ checksum = "4facc753ae494aeb6e3c22f839b158aebd4f9270f55cd3c79906c45476c47ab4" [[package]] name = "memchr" -version = "2.4.1" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" +checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" [[package]] name = "memfd" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b20a59d985586e4a5aef64564ac77299f8586d8be6cf9106a5a40207e8908efb" +checksum = "ffc89ccdc6e10d6907450f753537ebc5c5d3460d2e4e62ea74bd571db62c0f9e" dependencies = [ - "rustix 0.36.6", + "rustix 0.37.14", ] [[package]] name = "memoffset" -version = "0.6.4" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59accc507f1338036a0477ef61afdae33cde60840f4dfe481319ce3ad116ddf9" +checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" +dependencies = [ + "autocfg", +] + +[[package]] +name = "memoffset" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d61c719bcfbcf5d62b3a09efa6088de8c54bc0bfcd3ea7ae39fcc186108b8de1" dependencies = [ "autocfg", ] [[package]] name = "num-traits" -version = "0.2.14" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" +checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" dependencies = [ "autocfg", ] [[package]] name = "num_cpus" -version = "1.13.0" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3" +checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b" dependencies = [ - "hermit-abi 0.1.19", + "hermit-abi 0.2.6", "libc", ] @@ -1083,9 +1092,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.17.0" +version = "1.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f61fba1741ea2b3d6a1e3178721804bb716a68a6aeba1149b5d52e3d464ea66" +checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" [[package]] name = "oorandom" @@ -1095,9 +1104,9 @@ checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575" [[package]] name = "paste" -version = "1.0.5" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acbf547ad0c65e31259204bd90935776d1c693cec2f4ff7abb7a1bbbd40dfe58" +checksum = "9f746c4065a8fa3fe23974dd82f15431cc8d40779821001404d10d2e79ca7d79" [[package]] name = "percent-encoding" @@ -1107,15 +1116,21 @@ checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" [[package]] name = "pin-project-lite" -version = "0.2.7" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d31d11c69a6b52a174b42bdc0c30e5e11670f90788b2c471c31c1d17d449443" +checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" + +[[package]] +name = "pkg-config" +version = "0.3.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160" [[package]] name = "plotters" -version = "0.3.1" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32a3fd9ec30b9749ce28cd91f255d569591cdf937fe280c312143e3c4bad6f2a" +checksum = "2538b639e642295546c50fcd545198c9d64ee2a38620a628724a3b266d5fbf97" dependencies = [ "num-traits", "plotters-backend", @@ -1126,24 +1141,24 @@ dependencies = [ [[package]] name = "plotters-backend" -version = "0.3.2" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d88417318da0eaf0fdcdb51a0ee6c3bed624333bff8f946733049380be67ac1c" +checksum = "193228616381fecdc1224c62e96946dfbc73ff4384fba576e052ff8c1bea8142" [[package]] name = "plotters-svg" -version = "0.3.1" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "521fa9638fa597e1dc53e9412a4f9cefb01187ee1f7413076f9e6749e2885ba9" +checksum = "f9a81d2759aae1dae668f783c308bc5c8ebd191ff4184aaa1b37f65a6ae5a56f" dependencies = [ "plotters-backend", ] [[package]] name = "ppv-lite86" -version = "0.2.10" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "proc-macro-error" @@ -1154,7 +1169,7 @@ dependencies = [ "proc-macro-error-attr", "proc-macro2", "quote", - "syn", + "syn 1.0.109", "version_check", ] @@ -1171,47 +1186,40 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.29" +version = "1.0.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9f5105d4fdaab20335ca9565e106a5d9b82b6219b5ba735731124ac6711d23d" +checksum = "2b63bdb0cd06f1f4dedf69b254734f9b45af66e4a031e42a7480257d9898b435" dependencies = [ - "unicode-xid", + "unicode-ident", ] [[package]] name = "psm" -version = "0.1.16" +version = "0.1.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd136ff4382c4753fc061cb9e4712ab2af263376b95bbd5bd8cd50c020b78e69" +checksum = "5787f7cda34e3033a72192c018bc5883100330f362ef279a8cbccfce8bb4e874" dependencies = [ "cc", ] -[[package]] -name = "quick-error" -version = "1.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" - [[package]] name = "quote" -version = "1.0.9" +version = "1.0.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7" +checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc" dependencies = [ "proc-macro2", ] [[package]] name = "rand" -version = "0.8.4" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e7573632e6454cf6b99d7aac4ccca54be06da05aca2ef7423d22d27d4d4bcd8" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ "libc", "rand_chacha", "rand_core", - "rand_hc", ] [[package]] @@ -1226,71 +1234,60 @@ dependencies = [ [[package]] name = "rand_core" -version = "0.6.3" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ "getrandom", ] -[[package]] -name = "rand_hc" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d51e9f596de227fda2ea6c84607f5558e196eeaf43c986b724ba4fb8fdf497e7" -dependencies = [ - "rand_core", -] - [[package]] name = "rayon" -version = "1.5.1" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c06aca804d41dbc8ba42dfd964f0d01334eceb64314b9ecf7c5fad5188a06d90" +checksum = "1d2df5196e37bcc87abebc0053e20787d73847bb33134a69841207dd0a47f03b" dependencies = [ - "autocfg", - "crossbeam-deque", "either", "rayon-core", ] [[package]] name = "rayon-core" -version = "1.9.1" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d78120e2c850279833f1dd3582f730c4ab53ed95aeaaaa862a2a5c71b1656d8e" +checksum = "4b8f95bd6966f5c87776639160a66bd8ab9895d9d4ab01ddba9fc60661aebe8d" dependencies = [ "crossbeam-channel", "crossbeam-deque", "crossbeam-utils", - "lazy_static", "num_cpus", ] [[package]] name = "redox_syscall" -version = "0.2.10" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8383f39639269cde97d255a32bdb68c047337295414940c68bdd30c2e13203ff" +checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" dependencies = [ "bitflags", ] [[package]] name = "redox_users" -version = "0.4.0" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "528532f3d801c87aec9def2add9ca802fe569e44a544afe633765267840abe64" +checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" dependencies = [ "getrandom", "redox_syscall", + "thiserror", ] [[package]] name = "regalloc2" -version = "0.4.2" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91b2eab54204ea0117fe9a060537e0b07a4e72f7c7d182361ecc346cab2240e5" +checksum = "300d4fbfb40c1c66a78ba3ddd41c1110247cf52f97b87d0f2fc9209bd49b030c" dependencies = [ "fxhash", "log", @@ -1300,21 +1297,15 @@ dependencies = [ [[package]] name = "regex" -version = "1.5.4" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d07a8629359eb56f1e2fb1652bb04212c072a87ba68546a04065d525673ac461" +checksum = "af83e617f331cc6ae2da5443c602dfa5af81e517212d9d611a5b3ba1777b5370" dependencies = [ "aho-corasick", "memchr", "regex-syntax", ] -[[package]] -name = "regex-automata" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" - [[package]] name = "regex-bench" version = "0.1.0" @@ -1324,9 +1315,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.6.25" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b" +checksum = "a5996294f19bd3aae0453a862ad728f60e6600695733dd5df01da90c54363a3c" [[package]] name = "regex-test" @@ -1337,18 +1328,9 @@ dependencies = [ [[package]] name = "rustc-demangle" -version = "0.1.21" +version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342" - -[[package]] -name = "rustc_version" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" -dependencies = [ - "semver", -] +checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" [[package]] name = "rustix" @@ -1357,9 +1339,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "938a344304321a9da4973b9ff4f9f8db9caf4597dfd9dda6a60b523340a0fff0" dependencies = [ "bitflags", - "errno", + "errno 0.2.8", "io-lifetimes 0.5.3", - "itoa 1.0.1", + "itoa", "libc", "linux-raw-sys 0.0.42", "once_cell", @@ -1368,39 +1350,39 @@ dependencies = [ [[package]] name = "rustix" -version = "0.35.13" +version = "0.36.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "727a1a6d65f786ec22df8a81ca3121107f235970dc1705ed681d3e6e8b9cd5f9" +checksum = "3a38f9520be93aba504e8ca974197f46158de5dcaa9fa04b57c57cd6a679d658" dependencies = [ "bitflags", - "errno", - "io-lifetimes 0.7.5", - "itoa 1.0.1", + "errno 0.3.1", + "io-lifetimes 1.0.10", "libc", - "linux-raw-sys 0.0.46", - "once_cell", - "windows-sys 0.42.0", + "linux-raw-sys 0.1.4", + "windows-sys 0.45.0", ] [[package]] name = "rustix" -version = "0.36.6" +version = "0.37.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4feacf7db682c6c329c4ede12649cd36ecab0f3be5b7d74e6a20304725db4549" +checksum = "d9b864d3c18a5785a05953adeed93e2dca37ed30f18e69bba9f30079d51f363f" dependencies = [ "bitflags", - "errno", - "io-lifetimes 1.0.3", + "errno 0.3.1", + "io-lifetimes 1.0.10", + "itoa", "libc", - "linux-raw-sys 0.1.4", - "windows-sys 0.42.0", + "linux-raw-sys 0.3.4", + "once_cell", + "windows-sys 0.48.0", ] [[package]] name = "ryu" -version = "1.0.5" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" +checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" [[package]] name = "same-file" @@ -1417,17 +1399,11 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" -[[package]] -name = "semver" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "568a8e6258aa33c13358f81fd834adb854c6f7c9468520910a9b1e8fac068012" - [[package]] name = "serde" -version = "1.0.130" +version = "1.0.160" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f12d06de37cf59146fbdecab66aa99f9fe4f78722e3607577a5375d66bd0c913" +checksum = "bb2f3770c8bce3bcda7e149193a069a0f4365bda1fa5cd88e03bca26afc1216c" dependencies = [ "serde_derive", ] @@ -1444,34 +1420,34 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.130" +version = "1.0.160" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7bc1a1ab1961464eae040d96713baa5a724a8152c1222492465b54322ec508b" +checksum = "291a097c63d8497e00160b166a967a4a79c64f3facdd01cbd7502231688d77df" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.15", ] [[package]] name = "serde_json" -version = "1.0.68" +version = "1.0.96" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f690853975602e1bfe1ccbf50504d67174e3bcf340f23b5ea9992e0587a52d8" +checksum = "057d394a50403bcac12672b2b18fb387ab6d289d957dab67dd201875391e52f1" dependencies = [ - "itoa 0.4.8", + "itoa", "ryu", "serde", ] [[package]] name = "serde_yaml" -version = "0.8.21" +version = "0.8.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8c608a35705a5d3cdc9fbe403147647ff34b921f8e833e49306df898f9b20af" +checksum = "578a7433b776b56a35785ed5ce9a7e777ac0598aac5a6dd1b4b18a307c7fc71b" dependencies = [ - "dtoa", "indexmap", + "ryu", "serde", "yaml-rust", ] @@ -1489,11 +1465,11 @@ dependencies = [ [[package]] name = "shellexpand" -version = "2.1.0" +version = "2.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83bdb7831b2d85ddf4a7b148aa19d0587eddbe8671a436b7bd1182eaad0f2829" +checksum = "7ccc8076840c4da029af4f87e4e8daeb0fca6b87bbb02e10cb60b791450e11e4" dependencies = [ - "dirs-next", + "dirs", ] [[package]] @@ -1504,9 +1480,9 @@ checksum = "03b634d87b960ab1a38c4fe143b508576f075e7c978bfad18217645ebfdfa2ec" [[package]] name = "smallvec" -version = "1.6.1" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e" +checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" [[package]] name = "stable_deref_trait" @@ -1522,9 +1498,9 @@ checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" [[package]] name = "structopt" -version = "0.3.23" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf9d950ef167e25e0bdb073cf1d68e9ad2795ac826f2f3f59647817cf23c0bfa" +checksum = "0c6b5c64445ba8094a6ab0c3cd2ad323e07171012d9c98b0b15651daf1787a10" dependencies = [ "clap", "lazy_static", @@ -1533,55 +1509,66 @@ dependencies = [ [[package]] name = "structopt-derive" -version = "0.4.16" +version = "0.4.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "134d838a2c9943ac3125cf6df165eda53493451b719f3255b2a26b85f772d0ba" +checksum = "dcb5ae327f9cc13b68763b5749770cb9e048a99bd9dfdfa58d0cf05d5f64afe0" dependencies = [ "heck 0.3.3", "proc-macro-error", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] name = "syn" -version = "1.0.76" +version = "1.0.109" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6f107db402c2c2055242dbf4d2af0e69197202e9faacbef9571bbe47f5a1b84" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" dependencies = [ "proc-macro2", "quote", - "unicode-xid", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a34fcf3e8b60f57e6a14301a2e916d323af98b0ea63c599441eec8558660c822" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", ] [[package]] name = "system-interface" -version = "0.23.0" +version = "0.25.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92adbaf536f5aff6986e1e62ba36cee72b1718c5153eee08b9e728ddde3f6029" +checksum = "928ebd55ab758962e230f51ca63735c5b283f26292297c81404289cda5d78631" dependencies = [ - "atty", "bitflags", "cap-fs-ext", - "cap-std 0.26.1", - "io-lifetimes 0.7.5", - "rustix 0.35.13", - "windows-sys 0.36.1", - "winx 0.33.0", + "cap-std 1.0.14", + "fd-lock", + "io-lifetimes 1.0.10", + "rustix 0.37.14", + "windows-sys 0.48.0", + "winx 0.35.1", ] [[package]] name = "target-lexicon" -version = "0.12.5" +version = "0.12.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9410d0f6853b1d94f0e519fb95df60f29d2c1eff2d921ffdf01a4c8a3b54f12d" +checksum = "fd1ba337640d60c3e96bc6f0638a939b9c9a7f2c316a1598c279828b3d1dc8c5" [[package]] name = "termcolor" -version = "1.1.2" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dfed899f0eb03f32ee8c6a0aabdb8a7949659e3466561fc0adf54e26d88c5f4" +checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6" dependencies = [ "winapi-util", ] @@ -1597,22 +1584,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.29" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "602eca064b2d83369e2b2f34b09c70b605402801927c65c11071ac911d299b88" +checksum = "978c9a314bd8dc99be594bc3c175faaa9794be04a5a5e153caba6915336cebac" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.29" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bad553cc2c78e8de258400763a647e80e6d1b31ee237275d756f6836d204494c" +checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.15", ] [[package]] @@ -1642,18 +1629,18 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "toml" -version = "0.5.8" +version = "0.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a31142970826733df8241ef35dc040ef98c679ab14d7c3e54d827099b3acecaa" +checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" dependencies = [ "serde", ] [[package]] name = "tracing" -version = "0.1.28" +version = "0.1.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84f96e095c0c82419687c20ddf5cb3eadb61f4e1405923c9dc8e53a1adacbda8" +checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" dependencies = [ "cfg-if", "log", @@ -1664,29 +1651,29 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.16" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98863d0dd09fa59a1b79c6750ad80dbda6b75f4e71c437a6a1a8cb91a8bcbd77" +checksum = "0f57e3ca2a01450b1a921183a9c9cbfda207fd822cef4ccb00a65402cbba7a74" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.15", ] [[package]] name = "tracing-core" -version = "0.1.20" +version = "0.1.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46125608c26121c81b0c6d693eab5a420e416da7e43c426d2e8f7df8da8a3acf" +checksum = "24eb03ba0eab1fd845050058ce5e616558e8f8d8fca633e6b163fe25c797213a" dependencies = [ - "lazy_static", + "once_cell", ] [[package]] name = "typenum" -version = "1.14.0" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b63708a265f51345575b27fe43f9500ad611579e764c79edbc2037b1121959ec" +checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" [[package]] name = "uap-bench" @@ -1703,6 +1690,12 @@ version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" +[[package]] +name = "unicode-ident" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" + [[package]] name = "unicode-normalization" version = "0.1.22" @@ -1714,21 +1707,15 @@ dependencies = [ [[package]] name = "unicode-segmentation" -version = "1.8.0" +version = "1.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8895849a949e7845e06bd6dc1aa51731a103c42707010a5b591c0038fb73385b" +checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" [[package]] name = "unicode-width" -version = "0.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973" - -[[package]] -name = "unicode-xid" -version = "0.2.2" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" +checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" [[package]] name = "url" @@ -1749,75 +1736,74 @@ checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" [[package]] name = "version_check" -version = "0.9.3" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "walkdir" -version = "2.3.2" +version = "2.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56" +checksum = "36df944cda56c7d8d8b7496af378e6b16de9284591917d307c9b4d313c44e698" dependencies = [ "same-file", - "winapi", "winapi-util", ] [[package]] name = "wasi" -version = "0.10.2+wasi-snapshot-preview1" +version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasi-cap-std-sync" -version = "3.0.1" +version = "4.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecbeebb8985a5423f36f976b2f4a0b3c6ce38d7d9a7247e1ce07aa2880e4f29b" +checksum = "e60acd83cd80a87d255e4c6b7ae70fed9187ecd2a1485d2dddc3906f0ba729b1" dependencies = [ "anyhow", "async-trait", "cap-fs-ext", "cap-rand", - "cap-std 0.26.1", + "cap-std 1.0.14", "cap-time-ext", - "fs-set-times 0.17.1", - "io-extras 0.15.0", - "io-lifetimes 0.7.5", + "fs-set-times 0.18.1", + "io-extras 0.17.4", + "io-lifetimes 1.0.10", "is-terminal", "once_cell", - "rustix 0.35.13", + "rustix 0.36.13", "system-interface", "tracing", "wasi-common", - "windows-sys 0.36.1", + "windows-sys 0.42.0", ] [[package]] name = "wasi-common" -version = "3.0.1" +version = "4.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81e2171f3783fe6600ee24ff6c58ca1b329c55e458cc1622ecc1fd0427648607" +checksum = "9facbac46d77bbc4a2f090f590992871fc253963ae14cc19b12e7f6c44920ff2" dependencies = [ "anyhow", "bitflags", "cap-rand", - "cap-std 0.26.1", - "io-extras 0.15.0", - "rustix 0.35.13", + "cap-std 1.0.14", + "io-extras 0.17.4", + "rustix 0.36.13", "thiserror", "tracing", "wasmtime", "wiggle", - "windows-sys 0.36.1", + "windows-sys 0.42.0", ] [[package]] name = "wasm-bindgen" -version = "0.2.78" +version = "0.2.84" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "632f73e236b219150ea279196e54e610f5dbafa5d61786303d4da54f84e47fce" +checksum = "31f8dcbc21f30d9b8f2ea926ecb58f6b91192c17e9d33594b3df58b2007ca53b" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -1825,24 +1811,24 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.78" +version = "0.2.84" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a317bf8f9fba2476b4b2c85ef4c4af8ff39c3c7f0cdfeed4f82c34a880aa837b" +checksum = "95ce90fd5bcc06af55a641a86428ee4229e44e07033963a2290a8e241607ccb9" dependencies = [ "bumpalo", - "lazy_static", "log", + "once_cell", "proc-macro2", "quote", - "syn", + "syn 1.0.109", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.78" +version = "0.2.84" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d56146e7c495528bf6587663bea13a8eb588d39b36b679d83972e1a2dbbdacf9" +checksum = "4c21f77c0bedc37fd5dc21f897894a5ca01e7bb159884559461862ae90c0b4c5" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -1850,22 +1836,22 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.78" +version = "0.2.84" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7803e0eea25835f8abdc585cd3021b3deb11543c6fe226dcd30b228857c5c5ab" +checksum = "2aff81306fcac3c7515ad4e177f521b5c9a15f2b08f4e32d823066102f35a5f6" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.78" +version = "0.2.84" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0237232789cf037d5480773fe568aac745bfe2afbc11a863e97901780a6b47cc" +checksum = "0046fef7e28c3804e5e38bfa31ea2a0f73905319b677e57ebe37e49358989b5d" [[package]] name = "wasm-encoder" @@ -1908,11 +1894,12 @@ dependencies = [ [[package]] name = "wasmparser" -version = "0.93.0" +version = "0.95.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5a4460aa3e271fa180b6a5d003e728f3963fb30e3ba0fa7c9634caa06049328" +checksum = "f2ea896273ea99b15132414be1da01ab0d8836415083298ecaffbe308eaac87a" dependencies = [ "indexmap", + "url", ] [[package]] @@ -1937,9 +1924,9 @@ dependencies = [ [[package]] name = "wasmtime" -version = "3.0.1" +version = "4.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d18265705b1c49218776577d9f301d79ab06888c7f4a32e2ed24e68a55738ce7" +checksum = "a556932766120e2969c94a2d26ce47005451ac27236d418a11118c3ad5459905" dependencies = [ "anyhow", "async-trait", @@ -1955,7 +1942,7 @@ dependencies = [ "rayon", "serde", "target-lexicon", - "wasmparser 0.93.0", + "wasmparser 0.95.0", "wasmtime-cache", "wasmtime-cranelift", "wasmtime-environ", @@ -1963,23 +1950,23 @@ dependencies = [ "wasmtime-jit", "wasmtime-runtime", "wat", - "windows-sys 0.36.1", + "windows-sys 0.42.0", ] [[package]] name = "wasmtime-asm-macros" -version = "3.0.1" +version = "4.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a201583f6c79b96e74dcce748fa44fb2958f474ef13c93f880ea4d3bed31ae4f" +checksum = "0aa5d2ec8e75db6907b46bfdd4980aefc6666854c4693a20f89b8417fe9c80d8" dependencies = [ "cfg-if", ] [[package]] name = "wasmtime-cache" -version = "3.0.1" +version = "4.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f37efc6945b08fcb634cffafc438dd299bac55a27c836954656c634d3e63c31" +checksum = "45499ab75af0576ccf87b3f9130941245cc5cb086f63f0a323febeba3c077433" dependencies = [ "anyhow", "base64", @@ -1987,19 +1974,19 @@ dependencies = [ "directories-next", "file-per-thread-logger", "log", - "rustix 0.35.13", + "rustix 0.36.13", "serde", "sha2", "toml", - "windows-sys 0.36.1", + "windows-sys 0.42.0", "zstd", ] [[package]] name = "wasmtime-cranelift" -version = "3.0.1" +version = "4.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe208297e045ea0ee6702be88772ea40f918d55fbd4163981a4699aff034b634" +checksum = "b7a9ec65dec790ec8602c263a1da12de073cc46cb07ffa3fc28295d2238365b6" dependencies = [ "anyhow", "cranelift-codegen", @@ -2012,15 +1999,15 @@ dependencies = [ "object", "target-lexicon", "thiserror", - "wasmparser 0.93.0", + "wasmparser 0.95.0", "wasmtime-environ", ] [[package]] name = "wasmtime-environ" -version = "3.0.1" +version = "4.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "754b97f7441ac780a7fa738db5b9c23c1b70ef4abccd8ad205ada5669d196ba2" +checksum = "2137f0cdc6eed2f734c0d6f6a024af0e7a7208fa95e88501b72ca3c957bd0ba1" dependencies = [ "anyhow", "cranelift-entity", @@ -2031,28 +2018,28 @@ dependencies = [ "serde", "target-lexicon", "thiserror", - "wasmparser 0.93.0", + "wasmparser 0.95.0", "wasmtime-types", ] [[package]] name = "wasmtime-fiber" -version = "3.0.1" +version = "4.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5f54abc960b4a055ba16b942cbbd1da641e0ad44cc97a7608f3d43c069b120e" +checksum = "9b169876fae7ad2183166a919b01e2eabd28ccb96761cf322e936d1b0ff23aa9" dependencies = [ "cc", "cfg-if", - "rustix 0.35.13", + "rustix 0.36.13", "wasmtime-asm-macros", - "windows-sys 0.36.1", + "windows-sys 0.42.0", ] [[package]] name = "wasmtime-jit" -version = "3.0.1" +version = "4.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32800cb6e29faabab7056593f70a4c00c65c75c365aaf05406933f2169d0c22f" +checksum = "a5fbaffeaba705c0bfd681402e7629c9b611451e4c6ca3373a06293e846bb062" dependencies = [ "addr2line", "anyhow", @@ -2066,41 +2053,40 @@ dependencies = [ "rustc-demangle", "serde", "target-lexicon", - "thiserror", "wasmtime-environ", "wasmtime-jit-debug", "wasmtime-jit-icache-coherence", "wasmtime-runtime", - "windows-sys 0.36.1", + "windows-sys 0.42.0", ] [[package]] name = "wasmtime-jit-debug" -version = "3.0.1" +version = "4.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe057012a0ba6cee3685af1e923d6e0a6cb9baf15fb3ffa4be3d7f712c7dec42" +checksum = "17981d189925fcb3a449a18b330141865df3aa025c030c4572962e10daa9707f" dependencies = [ "object", "once_cell", - "rustix 0.35.13", + "rustix 0.36.13", ] [[package]] name = "wasmtime-jit-icache-coherence" -version = "2.0.1" +version = "3.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6bbabb309c06cc238ee91b1455b748c45f0bdcab0dda2c2db85b0a1e69fcb66" +checksum = "1f32b3f9e2b3b65fc9551240c81d69db8636b267ea5750ffc75e8a16d01680b0" dependencies = [ "cfg-if", "libc", - "windows-sys 0.36.1", + "windows-sys 0.42.0", ] [[package]] name = "wasmtime-runtime" -version = "3.0.1" +version = "4.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09a23b6e138e89594c0189162e524a29e217aec8f9a4e1959a34f74c64e8d17d" +checksum = "b1a777df20249db2c4c54a4a709b5620c9021fda238f4c9b03fe7f77feac9cff" dependencies = [ "anyhow", "cc", @@ -2110,35 +2096,34 @@ dependencies = [ "log", "mach", "memfd", - "memoffset", + "memoffset 0.6.5", "paste", "rand", - "rustix 0.35.13", - "thiserror", + "rustix 0.36.13", "wasmtime-asm-macros", "wasmtime-environ", "wasmtime-fiber", "wasmtime-jit-debug", - "windows-sys 0.36.1", + "windows-sys 0.42.0", ] [[package]] name = "wasmtime-types" -version = "3.0.1" +version = "4.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68ec7615fde8c79737f1345d81f0b18da83b3db929a87b4604f27c932246d1e2" +checksum = "6410892daeb7e69d5af6055c9c07d9f5d1e159539a6e3f649e932fe0d9008a5b" dependencies = [ "cranelift-entity", "serde", "thiserror", - "wasmparser 0.93.0", + "wasmparser 0.95.0", ] [[package]] name = "wasmtime-wasi" -version = "3.0.1" +version = "4.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca539adf155dca1407aa3656e5661bf2364b1f3ebabc7f0a8bd62629d876acfa" +checksum = "e6de942c58fa60248e4096ef3f8dabd498402a1d3ee2c4b1938902435a267d4b" dependencies = [ "anyhow", "wasi-cap-std-sync", @@ -2179,9 +2164,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.55" +version = "0.3.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38eb105f1c59d9eaa6b5cdc92b859d85b926e82cb2e0945cd0c9259faa6fe9fb" +checksum = "e33b99f4b23ba3eec1a53ac264e35a755f00e966e0065077d6027c0f575b0b97" dependencies = [ "js-sys", "wasm-bindgen", @@ -2189,9 +2174,9 @@ dependencies = [ [[package]] name = "wiggle" -version = "3.0.1" +version = "4.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2da09ca5b8bb9278a2123e8c36342166b9aaa55a0dbab18b231f46d6f6ab85bc" +checksum = "2b2beeb5443dddf5d896028b46fb0931bae6768a046042e56c66c276853e2cf9" dependencies = [ "anyhow", "async-trait", @@ -2204,28 +2189,28 @@ dependencies = [ [[package]] name = "wiggle-generate" -version = "3.0.1" +version = "4.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba5796f53b429df7d44cfdaae8f6d9cd981d82aec3516561352ca9c5e73ee185" +checksum = "bbf9dfdabe5cb75ca1075ec26599e91f20e61067a69dafaef265db81d3b67c67" dependencies = [ "anyhow", - "heck 0.4.0", + "heck 0.4.1", "proc-macro2", "quote", "shellexpand", - "syn", + "syn 1.0.109", "witx", ] [[package]] name = "wiggle-macro" -version = "3.0.1" +version = "4.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b830eb7203d48942fb8bc8bb105f76e7d09c33a082d638e990e02143bb2facd" +checksum = "196cfc4501ef83483b6833ec1e38db12b95a20773df2065779544cbe50b8c167" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", "wiggle-generate", ] @@ -2262,103 +2247,150 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "windows-sys" -version = "0.36.1" +version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea04155a16a59f9eab786fe12a4a450e75cdb175f9e0d80da1e17db09f55b8d2" +checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" dependencies = [ - "windows_aarch64_msvc 0.36.1", - "windows_i686_gnu 0.36.1", - "windows_i686_msvc 0.36.1", - "windows_x86_64_gnu 0.36.1", - "windows_x86_64_msvc 0.36.1", + "windows_aarch64_gnullvm 0.42.2", + "windows_aarch64_msvc 0.42.2", + "windows_i686_gnu 0.42.2", + "windows_i686_msvc 0.42.2", + "windows_x86_64_gnu 0.42.2", + "windows_x86_64_gnullvm 0.42.2", + "windows_x86_64_msvc 0.42.2", ] [[package]] name = "windows-sys" -version = "0.42.0" +version = "0.45.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" +checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" +dependencies = [ + "windows-targets 0.42.2", +] + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc 0.42.0", - "windows_i686_gnu 0.42.0", - "windows_i686_msvc 0.42.0", - "windows_x86_64_gnu 0.42.0", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc 0.42.0", + "windows-targets 0.48.0", +] + +[[package]] +name = "windows-targets" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" +dependencies = [ + "windows_aarch64_gnullvm 0.42.2", + "windows_aarch64_msvc 0.42.2", + "windows_i686_gnu 0.42.2", + "windows_i686_msvc 0.42.2", + "windows_x86_64_gnu 0.42.2", + "windows_x86_64_gnullvm 0.42.2", + "windows_x86_64_msvc 0.42.2", +] + +[[package]] +name = "windows-targets" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5" +dependencies = [ + "windows_aarch64_gnullvm 0.48.0", + "windows_aarch64_msvc 0.48.0", + "windows_i686_gnu 0.48.0", + "windows_i686_msvc 0.48.0", + "windows_x86_64_gnu 0.48.0", + "windows_x86_64_gnullvm 0.48.0", + "windows_x86_64_msvc 0.48.0", ] [[package]] name = "windows_aarch64_gnullvm" -version = "0.42.0" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41d2aa71f6f0cbe00ae5167d90ef3cfe66527d6f613ca78ac8024c3ccab9a19e" +checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" [[package]] name = "windows_aarch64_msvc" -version = "0.36.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47" +checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" [[package]] name = "windows_aarch64_msvc" -version = "0.42.0" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd0f252f5a35cac83d6311b2e795981f5ee6e67eb1f9a7f64eb4500fbc4dcdb4" +checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" [[package]] name = "windows_i686_gnu" -version = "0.36.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6" +checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" [[package]] name = "windows_i686_gnu" -version = "0.42.0" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbeae19f6716841636c28d695375df17562ca208b2b7d0dc47635a50ae6c5de7" +checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" [[package]] name = "windows_i686_msvc" -version = "0.36.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024" +checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" [[package]] name = "windows_i686_msvc" -version = "0.42.0" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84c12f65daa39dd2babe6e442988fc329d6243fdce47d7d2d155b8d874862246" +checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" [[package]] name = "windows_x86_64_gnu" -version = "0.36.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1" +checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" [[package]] name = "windows_x86_64_gnu" -version = "0.42.0" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf7b1b21b5362cbc318f686150e5bcea75ecedc74dd157d874d754a2ca44b0ed" +checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" [[package]] name = "windows_x86_64_gnullvm" -version = "0.42.0" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09d525d2ba30eeb3297665bd434a54297e4170c7f1a44cad4ef58095b4cd2028" +checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" [[package]] name = "windows_x86_64_msvc" -version = "0.36.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680" +checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" [[package]] name = "windows_x86_64_msvc" -version = "0.42.0" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f40009d85759725a34da6d89a94e63d7bdc50a862acf0dbc7c8e488f1edcb6f5" +checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" [[package]] name = "winx" @@ -2373,13 +2405,13 @@ dependencies = [ [[package]] name = "winx" -version = "0.33.0" +version = "0.35.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7b01e010390eb263a4518c8cebf86cb67469d1511c00b749a47b64c39e8054d" +checksum = "1c52a121f0fbf9320d5f2a9a5d82f6cb7557eda5e8b47fc3e7f359ec866ae960" dependencies = [ "bitflags", - "io-lifetimes 0.7.5", - "windows-sys 0.36.1", + "io-lifetimes 1.0.10", + "windows-sys 0.48.0", ] [[package]] @@ -2399,7 +2431,7 @@ name = "wizer" version = "1.6.1-beta.4" dependencies = [ "anyhow", - "cap-std 0.24.2", + "cap-std 0.24.4", "criterion", "env_logger 0.8.4", "log", @@ -2457,10 +2489,11 @@ dependencies = [ [[package]] name = "zstd-sys" -version = "2.0.4+zstd.1.5.2" +version = "2.0.8+zstd.1.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fa202f2ef00074143e219d15b62ffc317d17cc33909feac471c044087cad7b0" +checksum = "5556e6ee25d32df2586c098bbfa278803692a20d0ab9565e049480d52707ec8c" dependencies = [ "cc", "libc", + "pkg-config", ] diff --git a/crates/wizer/Cargo.toml b/crates/wizer/Cargo.toml index 6179ad61d83e..eb0a89fadd50 100644 --- a/crates/wizer/Cargo.toml +++ b/crates/wizer/Cargo.toml @@ -33,11 +33,11 @@ env_logger = { version = "0.8.2", optional = true } log = "0.4.14" rayon = "1.5.0" structopt = { version = "0.3.21", optional = true } -wasi-cap-std-sync = "3.0.0" +wasi-cap-std-sync = "4.0.0" wasm-encoder = "0.10.0" wasmparser = "0.103.0" -wasmtime = "3.0.0" -wasmtime-wasi = "3.0.0" +wasmtime = "4.0.0" +wasmtime-wasi = "4.0.0" # Enable this dependency to get messages with WAT disassemblies when certain # internal panics occur. diff --git a/crates/wizer/benches/regex.rs b/crates/wizer/benches/regex.rs index c7fc2a983abf..74505b5fad26 100644 --- a/crates/wizer/benches/regex.rs +++ b/crates/wizer/benches/regex.rs @@ -14,7 +14,7 @@ fn run_iter( data[ptr..].copy_from_slice(b"hello"); let run = instance - .get_typed_func::<(i32, i32), i32, _>(&mut store, "run") + .get_typed_func::<(i32, i32), i32>(&mut store, "run") .unwrap(); let result = run .call(&mut store, (i32::try_from(ptr).unwrap(), 5)) diff --git a/crates/wizer/benches/uap.rs b/crates/wizer/benches/uap.rs index a92a1e506700..66f051b30c0e 100644 --- a/crates/wizer/benches/uap.rs +++ b/crates/wizer/benches/uap.rs @@ -11,7 +11,7 @@ fn run_iter( let ua = "Mozilla/5.0 (X11; Linux x86_64; rv:85.0) Gecko/20100101 Firefox/85.0"; let alloc = instance - .get_typed_func::<(u32, u32), u32, _>(&mut store, "alloc") + .get_typed_func::<(u32, u32), u32>(&mut store, "alloc") .unwrap(); let ptr = alloc.call(&mut store, (ua.len() as u32, 1)).unwrap() as usize; @@ -20,7 +20,7 @@ fn run_iter( data[ptr..ptr + ua.len()].copy_from_slice(ua.as_bytes()); let run = instance - .get_typed_func::<(i32, i32), i32, _>(&mut store, "run") + .get_typed_func::<(i32, i32), i32>(&mut store, "run") .unwrap(); let result = run .call(&mut store, (i32::try_from(ptr).unwrap(), 5)) @@ -28,7 +28,7 @@ fn run_iter( assert_eq!(result, 0); let dealloc = instance - .get_typed_func::<(u32, u32, u32), (), _>(&mut store, "dealloc") + .get_typed_func::<(u32, u32, u32), ()>(&mut store, "dealloc") .unwrap(); dealloc .call(&mut store, (ptr as u32, ua.len() as u32, 1)) diff --git a/crates/wizer/fuzz/Cargo.toml b/crates/wizer/fuzz/Cargo.toml index ced21360f21c..42d32099a9ed 100644 --- a/crates/wizer/fuzz/Cargo.toml +++ b/crates/wizer/fuzz/Cargo.toml @@ -15,7 +15,7 @@ libfuzzer-sys = "0.4" log = "0.4.14" wasm-smith = "0.4.0" wasmprinter = "0.2.26" -wasmtime = "3.0.0" +wasmtime = "4.0.0" [dependencies.wizer] path = ".." diff --git a/crates/wizer/fuzz/fuzz_targets/same_result.rs b/crates/wizer/fuzz/fuzz_targets/same_result.rs index 43fbd454b8c9..03be40550005 100644 --- a/crates/wizer/fuzz/fuzz_targets/same_result.rs +++ b/crates/wizer/fuzz/fuzz_targets/same_result.rs @@ -105,7 +105,7 @@ fuzz_target!(|module: wasm_smith::ConfiguredModule| { // and main functions back to back. let instance = Instance::new(&mut store, &module, &[]).unwrap(); let init_func = instance - .get_typed_func::<(), (), _>(&mut store, init_func) + .get_typed_func::<(), ()>(&mut store, init_func) .unwrap(); init_func.call(&mut store, ()).unwrap(); let main_func = instance.get_func(&mut store, main_func).unwrap(); diff --git a/crates/wizer/src/lib.rs b/crates/wizer/src/lib.rs index 04d991774302..cb4eca514bcb 100644 --- a/crates/wizer/src/lib.rs +++ b/crates/wizer/src/lib.rs @@ -734,7 +734,7 @@ impl Wizer { if let Some(export) = instance.get_export(&mut *store, "_initialize") { if let Extern::Func(func) = export { - func.typed::<(), (), _>(&store) + func.typed::<(), ()>(&store) .and_then(|f| { has_wasi_initialize = true; f.call(&mut *store, ()).map_err(Into::into) @@ -744,7 +744,7 @@ impl Wizer { } let init_func = instance - .get_typed_func::<(), (), _>(&mut *store, &self.init_func) + .get_typed_func::<(), ()>(&mut *store, &self.init_func) .expect("checked by `validate_init_func`"); init_func .call(&mut *store, ()) From f78513898b2bfbefd361de87d5bc64345f75f58d Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 20 Apr 2023 08:23:25 -0700 Subject: [PATCH 141/212] Update to the latest wasm-encoder Mostly just minor changes, nothing ground-shaking. --- crates/wizer/Cargo.lock | 11 +---------- crates/wizer/Cargo.toml | 2 +- crates/wizer/src/instrument.rs | 21 +++++++-------------- crates/wizer/src/rewrite.rs | 24 +++++++++--------------- crates/wizer/src/translate.rs | 14 +++++++------- crates/wizer/tests/tests.rs | 10 ++++++---- 6 files changed, 31 insertions(+), 51 deletions(-) diff --git a/crates/wizer/Cargo.lock b/crates/wizer/Cargo.lock index 494cd8a7e514..95582dafcc6d 100644 --- a/crates/wizer/Cargo.lock +++ b/crates/wizer/Cargo.lock @@ -1862,15 +1862,6 @@ dependencies = [ "leb128", ] -[[package]] -name = "wasm-encoder" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa9d9bf45fc46f71c407837c9b30b1e874197f2dc357588430b21e5017d290ab" -dependencies = [ - "leb128", -] - [[package]] name = "wasm-encoder" version = "0.25.0" @@ -2438,7 +2429,7 @@ dependencies = [ "rayon", "structopt", "wasi-cap-std-sync", - "wasm-encoder 0.10.0", + "wasm-encoder 0.25.0", "wasmparser 0.103.0", "wasmprinter", "wasmtime", diff --git a/crates/wizer/Cargo.toml b/crates/wizer/Cargo.toml index eb0a89fadd50..a3570ba67c1f 100644 --- a/crates/wizer/Cargo.toml +++ b/crates/wizer/Cargo.toml @@ -34,7 +34,7 @@ log = "0.4.14" rayon = "1.5.0" structopt = { version = "0.3.21", optional = true } wasi-cap-std-sync = "4.0.0" -wasm-encoder = "0.10.0" +wasm-encoder = "0.25.0" wasmparser = "0.103.0" wasmtime = "4.0.0" wasmtime-wasi = "4.0.0" diff --git a/crates/wizer/src/instrument.rs b/crates/wizer/src/instrument.rs index 6ed69ad88a7c..eaff78927424 100644 --- a/crates/wizer/src/instrument.rs +++ b/crates/wizer/src/instrument.rs @@ -95,22 +95,15 @@ pub(crate) fn instrument(cx: &ModuleContext<'_>) -> Vec { exports.export( export.name, match export.kind { - wasmparser::ExternalKind::Func => { - wasm_encoder::Export::Function(export.index) - } - wasmparser::ExternalKind::Table => { - wasm_encoder::Export::Table(export.index) - } - wasmparser::ExternalKind::Memory => { - wasm_encoder::Export::Memory(export.index) - } - wasmparser::ExternalKind::Global => { - wasm_encoder::Export::Global(export.index) - } + wasmparser::ExternalKind::Func => wasm_encoder::ExportKind::Func, + wasmparser::ExternalKind::Table => wasm_encoder::ExportKind::Table, + wasmparser::ExternalKind::Memory => wasm_encoder::ExportKind::Memory, + wasmparser::ExternalKind::Global => wasm_encoder::ExportKind::Global, wasmparser::ExternalKind::Tag => { unreachable!("should have been rejected in validation/parsing") } }, + export.index, ); } @@ -119,11 +112,11 @@ pub(crate) fn instrument(cx: &ModuleContext<'_>) -> Vec { // them after initialization. for (i, (j, _)) in entry.module.defined_globals(cx).enumerate() { let name = format!("__wizer_global_{}", i); - exports.export(&name, wasm_encoder::Export::Global(j)); + exports.export(&name, wasm_encoder::ExportKind::Global, j); } for (i, (j, _)) in entry.module.defined_memories(cx).enumerate() { let name = format!("__wizer_memory_{}", i); - exports.export(&name, wasm_encoder::Export::Memory(j)); + exports.export(&name, wasm_encoder::ExportKind::Memory, j); } entry.encoder.section(&exports); diff --git a/crates/wizer/src/rewrite.rs b/crates/wizer/src/rewrite.rs index 183daf80a4d5..efc55c6c7ef7 100644 --- a/crates/wizer/src/rewrite.rs +++ b/crates/wizer/src/rewrite.rs @@ -4,7 +4,7 @@ use crate::{ info::ModuleContext, snapshot::Snapshot, translate, FuncRenames, Wizer, DEFAULT_KEEP_INIT_FUNC, }; use std::convert::TryFrom; -use wasm_encoder::SectionId; +use wasm_encoder::{ConstExpr, SectionId}; impl Wizer { /// Given the initialized snapshot, rewrite the Wasm so that it is already @@ -32,7 +32,7 @@ impl Wizer { for seg in &snapshot.data_segments { data_section.active( seg.memory_index, - &wasm_encoder::Instruction::I32Const(seg.offset as i32), + &ConstExpr::i32_const(seg.offset as i32), seg.data(store).iter().copied(), ); } @@ -89,17 +89,11 @@ impl Wizer { globals.global( glob_ty, &match val { - wasmtime::Val::I32(x) => wasm_encoder::Instruction::I32Const(*x), - wasmtime::Val::I64(x) => wasm_encoder::Instruction::I64Const(*x), - wasmtime::Val::F32(x) => { - wasm_encoder::Instruction::F32Const(f32::from_bits(*x)) - } - wasmtime::Val::F64(x) => { - wasm_encoder::Instruction::F64Const(f64::from_bits(*x)) - } - wasmtime::Val::V128(x) => { - wasm_encoder::Instruction::V128Const(*x as i128) - } + wasmtime::Val::I32(x) => ConstExpr::i32_const(*x), + wasmtime::Val::I64(x) => ConstExpr::i64_const(*x), + wasmtime::Val::F32(x) => ConstExpr::f32_const(f32::from_bits(*x)), + wasmtime::Val::F64(x) => ConstExpr::f64_const(f64::from_bits(*x)), + wasmtime::Val::V128(x) => ConstExpr::v128_const(*x as i128), _ => unreachable!(), }, ); @@ -133,8 +127,8 @@ impl Wizer { .get(export.name) .map_or(export.name, |f| f.as_str()); - let export = translate::export(export.kind, export.index); - exports.export(field, export); + let kind = translate::export(export.kind); + exports.export(field, kind, export.index); } encoder.section(&exports); } diff --git a/crates/wizer/src/translate.rs b/crates/wizer/src/translate.rs index 1ee4a8d2e871..c57ad094227b 100644 --- a/crates/wizer/src/translate.rs +++ b/crates/wizer/src/translate.rs @@ -9,7 +9,7 @@ pub(crate) fn val_type(ty: wasmparser::ValType) -> wasm_encoder::ValType { F32 => ValType::F32, F64 => ValType::F64, V128 => ValType::V128, - wasmparser::ValType::FUNCREF => ValType::FuncRef, + wasmparser::ValType::FUNCREF => ValType::FUNCREF, Ref(_) => panic!("not supported"), } } @@ -22,20 +22,20 @@ pub(crate) fn global_type(ty: wasmparser::GlobalType) -> wasm_encoder::GlobalTyp } pub(crate) fn memory_type(ty: wasmparser::MemoryType) -> wasm_encoder::MemoryType { - assert!(!ty.shared); wasm_encoder::MemoryType { minimum: ty.initial.into(), maximum: ty.maximum.map(|val| val.into()), memory64: ty.memory64, + shared: ty.shared, } } -pub(crate) fn export(kind: wasmparser::ExternalKind, index: u32) -> wasm_encoder::Export { +pub(crate) fn export(kind: wasmparser::ExternalKind) -> wasm_encoder::ExportKind { match kind { - wasmparser::ExternalKind::Func => wasm_encoder::Export::Function(index), - wasmparser::ExternalKind::Global => wasm_encoder::Export::Global(index), - wasmparser::ExternalKind::Table => wasm_encoder::Export::Table(index), - wasmparser::ExternalKind::Memory => wasm_encoder::Export::Memory(index), + wasmparser::ExternalKind::Func => wasm_encoder::ExportKind::Func, + wasmparser::ExternalKind::Global => wasm_encoder::ExportKind::Global, + wasmparser::ExternalKind::Table => wasm_encoder::ExportKind::Table, + wasmparser::ExternalKind::Memory => wasm_encoder::ExportKind::Memory, wasmparser::ExternalKind::Tag => unreachable!(), } } diff --git a/crates/wizer/tests/tests.rs b/crates/wizer/tests/tests.rs index 63ca5f3e1579..44727e9d2253 100644 --- a/crates/wizer/tests/tests.rs +++ b/crates/wizer/tests/tests.rs @@ -1,4 +1,5 @@ use anyhow::{Context, Result}; +use wasm_encoder::ConstExpr; use wat::parse_str as wat_to_wasm; use wizer::Wizer; @@ -564,12 +565,13 @@ fn accept_bulk_memory_data_count() -> Result<()> { minimum: 1, maximum: Some(1), memory64: false, + shared: false, }); module.section(&memory); let mut exports = wasm_encoder::ExportSection::new(); - exports.export("run", wasm_encoder::Export::Function(0)); - exports.export("wizer.initialize", wasm_encoder::Export::Function(1)); + exports.export("run", wasm_encoder::ExportKind::Func, 0); + exports.export("wizer.initialize", wasm_encoder::ExportKind::Func, 1); module.section(&exports); module.section(&wasm_encoder::DataCountSection { count: 2 }); @@ -589,8 +591,8 @@ fn accept_bulk_memory_data_count() -> Result<()> { // We're expecting these two data segments to be merge into one, which will exercise wizer's // ability to output the correct data count (1 instead of 2 above). let mut data = wasm_encoder::DataSection::new(); - data.active(0, &wasm_encoder::Instruction::I32Const(0), vec![0, 1, 2, 3]); - data.active(0, &wasm_encoder::Instruction::I32Const(4), vec![5, 6, 7, 8]); + data.active(0, &ConstExpr::i32_const(0), vec![0, 1, 2, 3]); + data.active(0, &ConstExpr::i32_const(4), vec![5, 6, 7, 8]); module.section(&data); run_wasm(&[], 42, &module.finish()).unwrap(); From 26897336cbfa0ab63b3a74afd932bc668b8eacc2 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 25 Apr 2023 11:17:46 -0700 Subject: [PATCH 142/212] Update Wasmtime to 8.0.0 --- crates/wizer/Cargo.lock | 319 +++++++++++++++++++++-------------- crates/wizer/Cargo.toml | 16 +- crates/wizer/fuzz/Cargo.toml | 4 +- crates/wizer/src/dummy.rs | 18 +- 4 files changed, 208 insertions(+), 149 deletions(-) diff --git a/crates/wizer/Cargo.lock b/crates/wizer/Cargo.lock index 95582dafcc6d..39aa63a4e163 100644 --- a/crates/wizer/Cargo.lock +++ b/crates/wizer/Cargo.lock @@ -4,20 +4,20 @@ version = 3 [[package]] name = "addr2line" -version = "0.17.0" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9ecd88a8c8378ca913a680cd98f0f13ac67383d35993f86c90a70e3f137816b" +checksum = "a76fd60b23679b7d19bd066031410fb7e458ccc5e958eb5c325888ce4baedc97" dependencies = [ "gimli", ] [[package]] name = "ahash" -version = "0.7.6" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" +checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" dependencies = [ - "getrandom", + "cfg-if", "once_cell", "version_check", ] @@ -67,12 +67,6 @@ dependencies = [ "derive_arbitrary", ] -[[package]] -name = "arrayvec" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6" - [[package]] name = "async-trait" version = "0.1.68" @@ -103,9 +97,9 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "base64" -version = "0.13.1" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" +checksum = "a4a4ddaa51a5bc52a6948f74c06d20aaaddb71924eab79b8c97a8c556e942d6a" [[package]] name = "bincode" @@ -294,28 +288,27 @@ dependencies = [ [[package]] name = "cranelift-bforest" -version = "0.91.1" +version = "0.95.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a2ab4512dfd3a6f4be184403a195f76e81a8a9f9e6c898e19d2dc3ce20e0115" +checksum = "2e9fb5af44f8cb4685d425a5101f562800618cfe7a454e23f87710ebfb22af50" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-codegen" -version = "0.91.1" +version = "0.95.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98b022ed2a5913a38839dfbafe6cf135342661293b08049843362df4301261dc" +checksum = "8b50041c01a29ab8c2dd93188a024d67c30a099067aa45bcb0f2bb0f6701b003" dependencies = [ - "arrayvec", "bumpalo", "cranelift-bforest", "cranelift-codegen-meta", "cranelift-codegen-shared", - "cranelift-egraph", "cranelift-entity", "cranelift-isle", "gimli", + "hashbrown 0.13.2", "log", "regalloc2", "smallvec", @@ -324,47 +317,33 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.91.1" +version = "0.95.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "639307b45434ad112a98f8300c0f0ab085cbefcd767efcdef9ef19d4c0756e74" +checksum = "3cdc8a18f16dff6690dc1a0ff5e3319b84904e6e9af06056e4712c3dca4ee63b" dependencies = [ "cranelift-codegen-shared", ] [[package]] name = "cranelift-codegen-shared" -version = "0.91.1" +version = "0.95.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "278e52e29c53fcf32431ef08406c295699a70306d05a0715c5b1bf50e33a9ab7" - -[[package]] -name = "cranelift-egraph" -version = "0.91.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "624b54323b06e675293939311943ba82d323bb340468ce1889be5da7932c8d73" -dependencies = [ - "cranelift-entity", - "fxhash", - "hashbrown", - "indexmap", - "log", - "smallvec", -] +checksum = "420bc3bed85c6879e0383318c0a614c00f2a74df67c37b7ab4cfd0c19fe11794" [[package]] name = "cranelift-entity" -version = "0.91.1" +version = "0.95.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a59bcbca89c3f1b70b93ab3cbba5e5e0cbf3e63dadb23c7525cb142e21a9d4c" +checksum = "0a6319b1918ca95faef80f17a44b5394bb63facd899f5369a54fbcc23e67971a" dependencies = [ "serde", ] [[package]] name = "cranelift-frontend" -version = "0.91.1" +version = "0.95.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d70abacb8cfef3dc8ff7e8836e9c1d70f7967dfdac824a4cd5e30223415aca6" +checksum = "a626e2d07bec4d029ba0393547433bc1cd6f1335581dd833f06e3feb3cbaf72a" dependencies = [ "cranelift-codegen", "log", @@ -374,15 +353,15 @@ dependencies = [ [[package]] name = "cranelift-isle" -version = "0.91.1" +version = "0.95.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "393bc73c451830ff8dbb3a07f61843d6cb41a084f9996319917c0b291ed785bb" +checksum = "2af8d1e5435264cac8208e34cc550abf6797ad6c7b4f6c874dc93a8249aa7d35" [[package]] name = "cranelift-native" -version = "0.91.1" +version = "0.95.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba392fd53b1bf6d45bf1d97f7e13bb8ba8424f19d66d80e60a0d594c2bb2636e" +checksum = "789bc52610128a42bbbba8e9b309eb73f8622bf10f55eb632ef552162a723ca7" dependencies = [ "cranelift-codegen", "libc", @@ -391,9 +370,9 @@ dependencies = [ [[package]] name = "cranelift-wasm" -version = "0.91.1" +version = "0.95.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "016abecc42cc114b924fa3fc306267f566076cefd3e43b891c510c8085c0811e" +checksum = "d3dbb9a85d3e0371fc65085dfde86211305a562c70bae9ea0a57155f58750983" dependencies = [ "cranelift-codegen", "cranelift-entity", @@ -401,7 +380,7 @@ dependencies = [ "itertools", "log", "smallvec", - "wasmparser 0.95.0", + "wasmparser 0.102.0", "wasmtime-types", ] @@ -480,7 +459,7 @@ dependencies = [ "autocfg", "cfg-if", "crossbeam-utils", - "memoffset 0.8.0", + "memoffset", "scopeguard", ] @@ -751,9 +730,9 @@ dependencies = [ [[package]] name = "gimli" -version = "0.26.2" +version = "0.27.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22030e2c5a68ec659fde1e949a745124b48e6fa8b045b7ed5bd1fe4ccc5c4e5d" +checksum = "ad0a93d233ebf96623465aad4046a8d3aa4da22d4f4beba5388838c8a434bbb4" dependencies = [ "fallible-iterator", "indexmap", @@ -771,6 +750,12 @@ name = "hashbrown" version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" + +[[package]] +name = "hashbrown" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" dependencies = [ "ahash", ] @@ -820,6 +805,12 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" +[[package]] +name = "id-arena" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25a2bc672d1148e28034f176e01fffebb08b35768468cc954630da77a1449005" + [[package]] name = "idna" version = "0.3.0" @@ -837,7 +828,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" dependencies = [ "autocfg", - "hashbrown", + "hashbrown 0.12.3", "serde", ] @@ -1041,15 +1032,6 @@ dependencies = [ "rustix 0.37.14", ] -[[package]] -name = "memoffset" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" -dependencies = [ - "autocfg", -] - [[package]] name = "memoffset" version = "0.8.0" @@ -1080,12 +1062,12 @@ dependencies = [ [[package]] name = "object" -version = "0.29.0" +version = "0.30.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21158b2c33aa6d4561f1c0a6ea283ca92bc54802a93b263e910746d679a7eb53" +checksum = "ea86265d3d3dcb6a27fc51bd29a4bf387fae9d2986b823079d4986af253eb439" dependencies = [ "crc32fast", - "hashbrown", + "hashbrown 0.13.2", "indexmap", "memchr", ] @@ -1202,6 +1184,17 @@ dependencies = [ "cc", ] +[[package]] +name = "pulldown-cmark" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffade02495f22453cd593159ea2f59827aae7f53fa8323f756799b670881dcf8" +dependencies = [ + "bitflags", + "memchr", + "unicase", +] + [[package]] name = "quote" version = "1.0.26" @@ -1285,9 +1278,9 @@ dependencies = [ [[package]] name = "regalloc2" -version = "0.5.1" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "300d4fbfb40c1c66a78ba3ddd41c1110247cf52f97b87d0f2fc9209bd49b030c" +checksum = "80535183cae11b149d618fbd3c37e38d7cda589d82d7769e196ca9a9042d7621" dependencies = [ "fxhash", "log", @@ -1684,6 +1677,15 @@ dependencies = [ "serde_yaml", ] +[[package]] +name = "unicase" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6" +dependencies = [ + "version_check", +] + [[package]] name = "unicode-bidi" version = "0.3.13" @@ -1717,6 +1719,12 @@ version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" +[[package]] +name = "unicode-xid" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" + [[package]] name = "url" version = "2.3.1" @@ -1758,9 +1766,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasi-cap-std-sync" -version = "4.0.1" +version = "8.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e60acd83cd80a87d255e4c6b7ae70fed9187ecd2a1485d2dddc3906f0ba729b1" +checksum = "8306bc71532b8a78f31e35d88e43506dfc5fc26bf30c7f0673cbf6beeb28bb6a" dependencies = [ "anyhow", "async-trait", @@ -1777,26 +1785,27 @@ dependencies = [ "system-interface", "tracing", "wasi-common", - "windows-sys 0.42.0", + "windows-sys 0.45.0", ] [[package]] name = "wasi-common" -version = "4.0.1" +version = "8.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9facbac46d77bbc4a2f090f590992871fc253963ae14cc19b12e7f6c44920ff2" +checksum = "58c4bd23d8aeec5da68339e121dccf21e2b2f7b9028c39413bfd2fe94eb7a535" dependencies = [ "anyhow", "bitflags", "cap-rand", "cap-std 1.0.14", "io-extras 0.17.4", + "log", "rustix 0.36.13", "thiserror", "tracing", "wasmtime", "wiggle", - "windows-sys 0.42.0", + "windows-sys 0.45.0", ] [[package]] @@ -1885,9 +1894,9 @@ dependencies = [ [[package]] name = "wasmparser" -version = "0.95.0" +version = "0.102.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2ea896273ea99b15132414be1da01ab0d8836415083298ecaffbe308eaac87a" +checksum = "48134de3d7598219ab9eaf6b91b15d8e50d31da76b8519fe4ecfcec2cf35104b" dependencies = [ "indexmap", "url", @@ -1915,9 +1924,9 @@ dependencies = [ [[package]] name = "wasmtime" -version = "4.0.1" +version = "8.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a556932766120e2969c94a2d26ce47005451ac27236d418a11118c3ad5459905" +checksum = "a65e578b6d35f3e808b21b00c652b4c3ded90249f642d504a67700d7a02cac1c" dependencies = [ "anyhow", "async-trait", @@ -1933,31 +1942,32 @@ dependencies = [ "rayon", "serde", "target-lexicon", - "wasmparser 0.95.0", + "wasmparser 0.102.0", "wasmtime-cache", + "wasmtime-component-macro", "wasmtime-cranelift", "wasmtime-environ", "wasmtime-fiber", "wasmtime-jit", "wasmtime-runtime", "wat", - "windows-sys 0.42.0", + "windows-sys 0.45.0", ] [[package]] name = "wasmtime-asm-macros" -version = "4.0.1" +version = "8.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0aa5d2ec8e75db6907b46bfdd4980aefc6666854c4693a20f89b8417fe9c80d8" +checksum = "cdaba4716347d5936234f17d1c75a3a92f21edaefc96dbdc64b36ef53504c1e1" dependencies = [ "cfg-if", ] [[package]] name = "wasmtime-cache" -version = "4.0.1" +version = "8.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45499ab75af0576ccf87b3f9130941245cc5cb086f63f0a323febeba3c077433" +checksum = "673200e1afd89735b9e641ec63218e9b7edf2860257db1968507c0538511d612" dependencies = [ "anyhow", "base64", @@ -1969,15 +1979,36 @@ dependencies = [ "serde", "sha2", "toml", - "windows-sys 0.42.0", + "windows-sys 0.45.0", "zstd", ] +[[package]] +name = "wasmtime-component-macro" +version = "8.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e83eb45f3bab16800cb9da977b04cd427f3e2b1e6668b6c2dcbc8baec8a6b6d" +dependencies = [ + "anyhow", + "proc-macro2", + "quote", + "syn 1.0.109", + "wasmtime-component-util", + "wasmtime-wit-bindgen", + "wit-parser", +] + +[[package]] +name = "wasmtime-component-util" +version = "8.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e9c89418c99fed44b9081e09ec4a9c5a3843ad663c4b0beceb16cac7a70c31d" + [[package]] name = "wasmtime-cranelift" -version = "4.0.1" +version = "8.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7a9ec65dec790ec8602c263a1da12de073cc46cb07ffa3fc28295d2238365b6" +checksum = "ed4490e68a86a8515071c19bd54a679b5c239c43badd24c18c764a63117ba119" dependencies = [ "anyhow", "cranelift-codegen", @@ -1990,15 +2021,31 @@ dependencies = [ "object", "target-lexicon", "thiserror", - "wasmparser 0.95.0", + "wasmparser 0.102.0", + "wasmtime-cranelift-shared", + "wasmtime-environ", +] + +[[package]] +name = "wasmtime-cranelift-shared" +version = "8.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73493000ea57cc755b4ab48df9194740c00ea6dcd2714b660b7859a451c1b925" +dependencies = [ + "anyhow", + "cranelift-codegen", + "cranelift-native", + "gimli", + "object", + "target-lexicon", "wasmtime-environ", ] [[package]] name = "wasmtime-environ" -version = "4.0.1" +version = "8.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2137f0cdc6eed2f734c0d6f6a024af0e7a7208fa95e88501b72ca3c957bd0ba1" +checksum = "5c2a2c8dcf2c4bacaa5bd29fbbc744769804377747940c6d5fe12b15bdfafe2c" dependencies = [ "anyhow", "cranelift-entity", @@ -2009,28 +2056,28 @@ dependencies = [ "serde", "target-lexicon", "thiserror", - "wasmparser 0.95.0", + "wasmparser 0.102.0", "wasmtime-types", ] [[package]] name = "wasmtime-fiber" -version = "4.0.1" +version = "8.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b169876fae7ad2183166a919b01e2eabd28ccb96761cf322e936d1b0ff23aa9" +checksum = "f2bcc711e6ccb9314b4d90112912060539ce98ac43b4d4408680609414de004f" dependencies = [ "cc", "cfg-if", "rustix 0.36.13", "wasmtime-asm-macros", - "windows-sys 0.42.0", + "windows-sys 0.45.0", ] [[package]] name = "wasmtime-jit" -version = "4.0.1" +version = "8.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5fbaffeaba705c0bfd681402e7629c9b611451e4c6ca3373a06293e846bb062" +checksum = "3b75238696641fb46dcf3cd6aaf09ac4c48040c5e2391d5c5a9883c35b09a627" dependencies = [ "addr2line", "anyhow", @@ -2048,14 +2095,14 @@ dependencies = [ "wasmtime-jit-debug", "wasmtime-jit-icache-coherence", "wasmtime-runtime", - "windows-sys 0.42.0", + "windows-sys 0.45.0", ] [[package]] name = "wasmtime-jit-debug" -version = "4.0.1" +version = "8.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17981d189925fcb3a449a18b330141865df3aa025c030c4572962e10daa9707f" +checksum = "f47cc7e383300218d338fcbe95f2d7343e125b6b0d284d0d9b7e6acc7dd112a1" dependencies = [ "object", "once_cell", @@ -2064,20 +2111,20 @@ dependencies = [ [[package]] name = "wasmtime-jit-icache-coherence" -version = "3.0.1" +version = "8.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f32b3f9e2b3b65fc9551240c81d69db8636b267ea5750ffc75e8a16d01680b0" +checksum = "b0c1b25e736692815a53f669e774e230b80ec063f21596f006f8310b9f2dd910" dependencies = [ "cfg-if", "libc", - "windows-sys 0.42.0", + "windows-sys 0.45.0", ] [[package]] name = "wasmtime-runtime" -version = "4.0.1" +version = "8.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1a777df20249db2c4c54a4a709b5620c9021fda238f4c9b03fe7f77feac9cff" +checksum = "9a305b2e4e62dfc67c8d25b2db1c2ac6ba44c7bcf0ccefb7fd9205338bed3f6a" dependencies = [ "anyhow", "cc", @@ -2087,7 +2134,7 @@ dependencies = [ "log", "mach", "memfd", - "memoffset 0.6.5", + "memoffset", "paste", "rand", "rustix 0.36.13", @@ -2095,34 +2142,46 @@ dependencies = [ "wasmtime-environ", "wasmtime-fiber", "wasmtime-jit-debug", - "windows-sys 0.42.0", + "windows-sys 0.45.0", ] [[package]] name = "wasmtime-types" -version = "4.0.1" +version = "8.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6410892daeb7e69d5af6055c9c07d9f5d1e159539a6e3f649e932fe0d9008a5b" +checksum = "efecff824b08f5c1da332a776ce01a928b200b27dbbb3ffd9374d7f2718671ea" dependencies = [ "cranelift-entity", "serde", "thiserror", - "wasmparser 0.95.0", + "wasmparser 0.102.0", ] [[package]] name = "wasmtime-wasi" -version = "4.0.1" +version = "8.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6de942c58fa60248e4096ef3f8dabd498402a1d3ee2c4b1938902435a267d4b" +checksum = "8ee49d3a53fd66187ac35f49f1cb5a28b3a104e066117d7194a0df7faf02658e" dependencies = [ "anyhow", + "libc", "wasi-cap-std-sync", "wasi-common", "wasmtime", "wiggle", ] +[[package]] +name = "wasmtime-wit-bindgen" +version = "8.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "796fdb0983ac1b3da4509169f49eea5e902b5641324466dc6f158c6e4ea693f5" +dependencies = [ + "anyhow", + "heck 0.4.1", + "wit-parser", +] + [[package]] name = "wast" version = "35.0.2" @@ -2165,9 +2224,9 @@ dependencies = [ [[package]] name = "wiggle" -version = "4.0.1" +version = "8.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b2beeb5443dddf5d896028b46fb0931bae6768a046042e56c66c276853e2cf9" +checksum = "883e99f57044e457243de44477104db73e90d892130e11da4cf7d1d9df3333e6" dependencies = [ "anyhow", "async-trait", @@ -2180,9 +2239,9 @@ dependencies = [ [[package]] name = "wiggle-generate" -version = "4.0.1" +version = "8.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbf9dfdabe5cb75ca1075ec26599e91f20e61067a69dafaef265db81d3b67c67" +checksum = "0743743724253da8c775c1668bfdb0e14f47b0666b6b41f997fb21a33e8768df" dependencies = [ "anyhow", "heck 0.4.1", @@ -2195,9 +2254,9 @@ dependencies = [ [[package]] name = "wiggle-macro" -version = "4.0.1" +version = "8.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "196cfc4501ef83483b6833ec1e38db12b95a20773df2065779544cbe50b8c167" +checksum = "6a21994785b4bbc8cf3811e1422feb3c6b613b9da51c8bacf35cc29ca2f356a0" dependencies = [ "proc-macro2", "quote", @@ -2236,21 +2295,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -[[package]] -name = "windows-sys" -version = "0.42.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" -dependencies = [ - "windows_aarch64_gnullvm 0.42.2", - "windows_aarch64_msvc 0.42.2", - "windows_i686_gnu 0.42.2", - "windows_i686_msvc 0.42.2", - "windows_x86_64_gnu 0.42.2", - "windows_x86_64_gnullvm 0.42.2", - "windows_x86_64_msvc 0.42.2", -] - [[package]] name = "windows-sys" version = "0.45.0" @@ -2405,6 +2449,21 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "wit-parser" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f887c3da527a51b321076ebe6a7513026a4757b6d4d144259946552d6fc728b3" +dependencies = [ + "anyhow", + "id-arena", + "indexmap", + "log", + "pulldown-cmark", + "unicode-xid", + "url", +] + [[package]] name = "witx" version = "0.9.1" diff --git a/crates/wizer/Cargo.toml b/crates/wizer/Cargo.toml index a3570ba67c1f..5fcb58f06d72 100644 --- a/crates/wizer/Cargo.toml +++ b/crates/wizer/Cargo.toml @@ -33,23 +33,29 @@ env_logger = { version = "0.8.2", optional = true } log = "0.4.14" rayon = "1.5.0" structopt = { version = "0.3.21", optional = true } -wasi-cap-std-sync = "4.0.0" +wasi-cap-std-sync = { workspace = true } wasm-encoder = "0.25.0" wasmparser = "0.103.0" -wasmtime = "4.0.0" -wasmtime-wasi = "4.0.0" +wasmtime = { workspace = true } +wasmtime-wasi = { workspace = true } # Enable this dependency to get messages with WAT disassemblies when certain # internal panics occur. [dependencies.wasmprinter] -version = "0.2.26" +workspace = true optional = true +[workspace.dependencies] +wasmprinter = "0.2.26" +wasmtime = "8.0.0" +wasmtime-wasi = "8.0.0" +wasi-cap-std-sync = "8.0.0" + [dev-dependencies] criterion = "0.3.4" env_logger = "0.8.2" -wasmprinter = "0.2.55" +wasmprinter = { workspace = true } wat = "1.0.62" [workspace] diff --git a/crates/wizer/fuzz/Cargo.toml b/crates/wizer/fuzz/Cargo.toml index 42d32099a9ed..854e3e267e8b 100644 --- a/crates/wizer/fuzz/Cargo.toml +++ b/crates/wizer/fuzz/Cargo.toml @@ -14,8 +14,8 @@ env_logger = "0.8.3" libfuzzer-sys = "0.4" log = "0.4.14" wasm-smith = "0.4.0" -wasmprinter = "0.2.26" -wasmtime = "4.0.0" +wasmprinter = { workspace = true } +wasmtime = { workspace = true } [dependencies.wizer] path = ".." diff --git a/crates/wizer/src/dummy.rs b/crates/wizer/src/dummy.rs index 030888124833..b5c7a90de91c 100644 --- a/crates/wizer/src/dummy.rs +++ b/crates/wizer/src/dummy.rs @@ -19,18 +19,12 @@ pub fn dummy_imports( // Already defined, must be part of WASI. continue; } - - linker - .define( - imp.module(), - name, - dummy_extern( - &mut *store, - imp.ty(), - &format!("'{}' '{}'", imp.module(), name), - )?, - ) - .unwrap(); + let val = dummy_extern( + &mut *store, + imp.ty(), + &format!("'{}' '{}'", imp.module(), name), + )?; + linker.define(&mut *store, imp.module(), name, val).unwrap(); } Ok(()) From 8f04436011d5779057f6e474e0ca62753fbf3cd8 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 25 Apr 2023 11:26:59 -0700 Subject: [PATCH 143/212] Fix compile of tests --- crates/wizer/tests/tests.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/crates/wizer/tests/tests.rs b/crates/wizer/tests/tests.rs index 44727e9d2253..4be44965fb16 100644 --- a/crates/wizer/tests/tests.rs +++ b/crates/wizer/tests/tests.rs @@ -49,11 +49,12 @@ fn run_wasm(args: &[wasmtime::Val], expected: i32, wasm: &[u8]) -> Result<()> { wasmtime::Module::new(store.engine(), wasm).context("Wasm test case failed to compile")?; let mut linker = wasmtime::Linker::new(&engine); + let thunk = wasmtime::Func::wrap(&mut store, || {}); linker - .define_name("dummy_func", wasmtime::Func::wrap(&mut store, || {}))? - .define("env", "f", wasmtime::Func::wrap(&mut store, || {}))? - .define_name("f", wasmtime::Func::wrap(&mut store, || {}))? - .define("x", "f", wasmtime::Func::wrap(&mut store, || {}))?; + .define_name(&mut store, "dummy_func", thunk)? + .define(&mut store, "env", "f", thunk)? + .define_name(&mut store, "f", thunk)? + .define(&mut store, "x", "f", thunk)?; wasmtime_wasi::add_to_linker(&mut linker, |wasi| wasi)?; From 4a453ef71de5a795bec700fcf1ecb9347e6ce312 Mon Sep 17 00:00:00 2001 From: Cheng Shao Date: Mon, 8 May 2023 11:11:43 +0000 Subject: [PATCH 144/212] wizer.h: handle the case when wasi command main function returns non-zero code When a wasi command's main function returns non-zero code, we should invoke __wasi_proc_exit for it. Closes #68. --- crates/wizer/include/wizer.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/crates/wizer/include/wizer.h b/crates/wizer/include/wizer.h index e374a5c96062..5492c0ec379c 100644 --- a/crates/wizer/include/wizer.h +++ b/crates/wizer/include/wizer.h @@ -84,6 +84,7 @@ #define WIZER_INIT(init_func) \ __WIZER_EXTERN_C void __wasm_call_ctors(); \ __WIZER_EXTERN_C void __wasm_call_dtors(); \ + __WIZER_EXTERN_C void __wasi_proc_exit(int); \ __WIZER_EXTERN_C int WIZER_MAIN_VOID(); \ /* This function's export name `wizer.initialize` is specially */ \ /* recognized by Wizer. It is the direct entry point for pre-init. */ \ @@ -108,10 +109,14 @@ /* `main()`. This may change in the future; when it does, we will */ \ /* coordinate with the WASI-SDK toolchain to implement this entry */ \ /* point in an alternate way. */ \ - WIZER_MAIN_VOID(); \ + int r = WIZER_MAIN_VOID(); \ /* Because we are replacing `_start()`, we need to manually invoke */ \ /* destructors as well. */ \ __wasm_call_dtors(); \ + /* If main returned non-zero code, call `__wasi_proc_exit`. */ \ + if (r != 0) { \ + __wasi_proc_exit(r); \ + } \ } /* From 0615f3647f8e4a0edc030d51d97699b062173668 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 9 May 2023 07:23:29 -0700 Subject: [PATCH 145/212] Enable binary releases for AArch64 and s390x Now that Wasmtime has been updated these should theoretically work according to the prior comments. --- crates/wizer/.github/workflows/release.yml | 29 +++++----------------- 1 file changed, 6 insertions(+), 23 deletions(-) diff --git a/crates/wizer/.github/workflows/release.yml b/crates/wizer/.github/workflows/release.yml index 01121e77f932..d3b053689800 100644 --- a/crates/wizer/.github/workflows/release.yml +++ b/crates/wizer/.github/workflows/release.yml @@ -32,29 +32,12 @@ jobs: - build: x86_64-mingw os: windows-latest target: x86_64-pc-windows-gnu - - # TODO: aarch64-linux and s390x-linux are commented out due to build errors - # these errors are solved in a newer version of wasmtime, when wizer - # updates to the newer wasmtime then we should uncomment these builds - - #src/arch/aarch64.S: Assembler messages: - #src/arch/aarch64.S:21: Error: operand 1 should be a floating-point register -- `stp lr,fp,[sp,-16]!' - #src/arch/aarch64.S:50: Error: operand 1 should be a floating-point register -- `ldp lr,fp,[sp],16' - #src/arch/aarch64.S:90: Error: bad register expression - #exit status: 1 - #- build: aarch64-linux - #os: ubuntu-latest - #target: aarch64-unknown-linux-gnu - - #/rust/lib/rustlib/s390x-unknown-linux-gnu/lib/libstd-f6c951af7877beaf.rlib(std-f6c951af7877beaf.std.e2801c51-cgu.0.rcgu.o): In function `std::sys::unix::rand::imp::getrandom_fill_bytes::hb641b796bca799e8': - #/rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/sys/unix/rand.rs:(.text._ZN3std3sys4unix4rand19hashmap_random_keys17h949023c83f75d545E+0x30): undefined reference to `getrandom' - #/rust/lib/rustlib/s390x-unknown-linux-gnu/lib/libstd-f6c951af7877beaf.rlib(std-f6c951af7877beaf.std.e2801c51-cgu.0.rcgu.o): In function `std::sys::unix::rand::imp::getrandom::getrandom::h09b00f3fdb24c5b7': - #/rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/sys/unix/weak.rs:176: undefined reference to `getrandom' - #/rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/sys/unix/weak.rs:176: undefined reference to `getrandom' - #collect2: error: ld returned 1 exit status - #- build: s390x-linux - #os: ubuntu-latest - #target: s390x-unknown-linux-gnu + - build: aarch64-linux + os: ubuntu-latest + target: aarch64-unknown-linux-gnu + - build: s390x-linux + os: ubuntu-latest + target: s390x-unknown-linux-gnu steps: - uses: actions/checkout@v2 with: From 3549ae32b94f45abf24569d44896b59c75d7615f Mon Sep 17 00:00:00 2001 From: Chris Fallin Date: Thu, 11 May 2023 14:30:25 -0700 Subject: [PATCH 146/212] Allow a preloaded module to be used by the wizened module. This PR adds a `--preload` option to Wizer that allows the user to provide a second module (in addition to the module being snapshotted) whose exprts are available for import by the snapshotted module. The preloaded module is not snapshotted, and is not linked or included in any way into the snapshot. Rather, it is assumed to contain intrinsics, stubs, helpers, or other stateless functions that are needed by the snapshotted module and that will also be available in its post-snapshot execution environment. This option is useful for, e.g., implementing "intrinsics" for other Wasm-transform tools that are implemented as magic imports. These imports can be stubbed out during snapshotting, but preserved as calls to imports in the snapshot, to enable further processing. --- crates/wizer/src/lib.rs | 45 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/crates/wizer/src/lib.rs b/crates/wizer/src/lib.rs index cb4eca514bcb..b8e38e8ef893 100644 --- a/crates/wizer/src/lib.rs +++ b/crates/wizer/src/lib.rs @@ -25,7 +25,7 @@ use std::path::PathBuf; use std::rc::Rc; #[cfg(feature = "structopt")] use structopt::StructOpt; -use wasmtime::Extern; +use wasmtime::{Engine, Extern}; use wasmtime_wasi::WasiCtx; const DEFAULT_INHERIT_STDIO: bool = true; @@ -124,6 +124,25 @@ pub struct Wizer { #[cfg_attr(feature = "structopt", structopt(long = "allow-wasi"))] allow_wasi: bool, + /// Provide an additional preloaded module that is available to the + /// main module. + /// + /// This allows running a module that depends on imports from + /// another module. Note that the additional module's state is *not* + /// snapshotted, nor is its code included in the Wasm snapshot; + /// rather, it is assumed that the resulting snapshot Wasm will also + /// be executed with the same imports available. + /// + /// The main purpose of this option is to allow "stubs" for certain + /// intrinsics to be included, when these will be provided with + /// different implementations when running or further processing the + /// snapshot. + /// + /// The format of this option is `name=file.{wasm,wat}`; e.g., + /// `intrinsics=stubs.wat`. + #[cfg_attr(feature = "structopt", structopt(long = "preload"))] + preload: Option, + #[cfg_attr(feature = "structopt", structopt(skip))] make_linker: Option anyhow::Result>>, @@ -217,6 +236,7 @@ impl std::fmt::Debug for Wizer { init_func, func_renames, allow_wasi, + preload, make_linker: _, inherit_stdio, inherit_env, @@ -232,6 +252,7 @@ impl std::fmt::Debug for Wizer { .field("init_func", &init_func) .field("func_renames", &func_renames) .field("allow_wasi", &allow_wasi) + .field("preload", &preload) .field("make_linker", &"..") .field("inherit_stdio", &inherit_stdio) .field("inherit_env", &inherit_env) @@ -294,6 +315,7 @@ impl Wizer { init_func: "wizer.initialize".into(), func_renames: vec![], allow_wasi: false, + preload: None, make_linker: None, inherit_stdio: None, inherit_env: None, @@ -489,7 +511,7 @@ impl Wizer { .context("failed to compile the Wasm module")?; self.validate_init_func(&module)?; - let (instance, has_wasi_initialize) = self.initialize(&mut store, &module)?; + let (instance, has_wasi_initialize) = self.initialize(&engine, &mut store, &module)?; let snapshot = snapshot::snapshot(&mut store, &instance); let rewritten_wasm = self.rewrite( &mut cx, @@ -707,6 +729,7 @@ impl Wizer { /// Instantiate the module and call its initialization function. fn initialize( &self, + engine: &Engine, store: &mut Store, module: &wasmtime::Module, ) -> anyhow::Result<(wasmtime::Instance, bool)> { @@ -724,6 +747,24 @@ impl Wizer { })?; } + if let Some(preload) = &self.preload { + if let Some((name, value)) = preload.split_once('=') { + let content = std::fs::read(value).context("failed to read preload module")?; + let module = wasmtime::Module::new(engine, content) + .context("failed to parse preload module")?; + let instance = wasmtime::Instance::new(&mut *store, &module, &[]) + .context("failed to instantiate preload module")?; + linker + .instance(&mut *store, name, instance) + .context("failed to add preload's exports to linker")?; + } else { + anyhow::bail!( + "Bad preload option: {} (must be of form `name=file`)", + preload + ); + } + } + dummy_imports(&mut *store, &module, &mut linker)?; let instance = linker From 7c5e4fcb78951cd9f5abf54b91ba0b827501debd Mon Sep 17 00:00:00 2001 From: Chris Fallin Date: Thu, 11 May 2023 14:48:44 -0700 Subject: [PATCH 147/212] Re-export Wasmtime crate to allow easier use with Wizer API. The Wizer API exposes several Wasmtime types, especially when using the functionality to provide a custom linker. It is thus useful to have a re-exported `wasmtime` to refer use when driving Wizer as a library, so versions do not need to be manually synchronized. --- crates/wizer/src/lib.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/crates/wizer/src/lib.rs b/crates/wizer/src/lib.rs index cb4eca514bcb..a867f3483f16 100644 --- a/crates/wizer/src/lib.rs +++ b/crates/wizer/src/lib.rs @@ -17,6 +17,10 @@ mod snapshot; mod stack_ext; mod translate; +/// Re-export wasmtime so users can align with our version. This is +/// especially useful when providing a custom Linker. +pub use wasmtime; + use anyhow::Context; use dummy::dummy_imports; use std::collections::{HashMap, HashSet}; From dd73c119756791085e17e9dc9d96084d5ef2376b Mon Sep 17 00:00:00 2001 From: Chris Fallin Date: Thu, 11 May 2023 15:04:40 -0700 Subject: [PATCH 148/212] Allow specifying preload programmatically as well. --- crates/wizer/src/lib.rs | 100 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 93 insertions(+), 7 deletions(-) diff --git a/crates/wizer/src/lib.rs b/crates/wizer/src/lib.rs index b8e38e8ef893..93530fc229d6 100644 --- a/crates/wizer/src/lib.rs +++ b/crates/wizer/src/lib.rs @@ -143,6 +143,12 @@ pub struct Wizer { #[cfg_attr(feature = "structopt", structopt(long = "preload"))] preload: Option, + /// Like `preload` above, but with the module contents provided, + /// rather than a filename. This is more useful for programmatic + /// use-cases where the embedding tool may also embed a Wasm module. + #[cfg_attr(feature = "structopt", structopt(skip))] + preload_bytes: Option<(String, Vec)>, + #[cfg_attr(feature = "structopt", structopt(skip))] make_linker: Option anyhow::Result>>, @@ -237,6 +243,7 @@ impl std::fmt::Debug for Wizer { func_renames, allow_wasi, preload, + preload_bytes, make_linker: _, inherit_stdio, inherit_env, @@ -253,6 +260,7 @@ impl std::fmt::Debug for Wizer { .field("func_renames", &func_renames) .field("allow_wasi", &allow_wasi) .field("preload", &preload) + .field("preload_bytes", &preload_bytes) .field("make_linker", &"..") .field("inherit_stdio", &inherit_stdio) .field("inherit_env", &inherit_env) @@ -316,6 +324,7 @@ impl Wizer { func_renames: vec![], allow_wasi: false, preload: None, + preload_bytes: None, make_linker: None, inherit_stdio: None, inherit_env: None, @@ -366,6 +375,67 @@ impl Wizer { Ok(self) } + /// Provide an additional preloaded module that is available to the + /// main module. + /// + /// This allows running a module that depends on imports from + /// another module. Note that the additional module's state is *not* + /// snapshotted, nor is its code included in the Wasm snapshot; + /// rather, it is assumed that the resulting snapshot Wasm will also + /// be executed with the same imports available. + /// + /// The main purpose of this option is to allow "stubs" for certain + /// intrinsics to be included, when these will be provided with + /// different implementations when running or further processing the + /// snapshot. + pub fn preload( + &mut self, + name_and_filename: Option<(&str, &str)>, + ) -> anyhow::Result<&mut Self> { + anyhow::ensure!( + self.make_linker.is_none(), + "Cannot use 'preload' with a custom linker" + ); + if let Some((name, _)) = name_and_filename { + anyhow::ensure!( + !name.contains("="), + "Module name cannot contain an `=` character" + ); + } + self.preload = name_and_filename.map(|(name, filename)| format!("{}={}", name, filename)); + Ok(self) + } + + /// Provide an additional preloaded module that is available to the + /// main module. Unlike `preload()`, this method takes an owned + /// vector of bytes as the module's actual content, rather than a + /// filename. As with `preload()`, the module may be in Wasm binary + /// format or in WAT text format. + /// + /// This allows running a module that depends on imports from + /// another module. Note that the additional module's state is *not* + /// snapshotted, nor is its code included in the Wasm snapshot; + /// rather, it is assumed that the resulting snapshot Wasm will also + /// be executed with the same imports available. + /// + /// The main purpose of this option is to allow "stubs" for certain + /// intrinsics to be included, when these will be provided with + /// different implementations when running or further processing the + /// snapshot. + /// + /// The argument is either `Some((module_name, bytes))` or `None`. + pub fn preload_bytes( + &mut self, + name_and_bytes: Option<(&str, Vec)>, + ) -> anyhow::Result<&mut Self> { + anyhow::ensure!( + self.make_linker.is_none(), + "Cannot use 'preload_bytes' with a custom linker" + ); + self.preload_bytes = name_and_bytes.map(|(name, bytes)| (name.to_owned(), bytes)); + Ok(self) + } + /// The linker to use during initialization rather than the default /// `wasmtime::Linker`. /// @@ -726,6 +796,25 @@ impl Wizer { Ok(Some(ctx.build())) } + /// Preload a module. + fn do_preload( + &self, + engine: &Engine, + store: &mut Store, + linker: &mut Linker, + name: &str, + content: &[u8], + ) -> anyhow::Result<()> { + let module = + wasmtime::Module::new(engine, content).context("failed to parse preload module")?; + let instance = wasmtime::Instance::new(&mut *store, &module, &[]) + .context("failed to instantiate preload module")?; + linker + .instance(&mut *store, name, instance) + .context("failed to add preload's exports to linker")?; + Ok(()) + } + /// Instantiate the module and call its initialization function. fn initialize( &self, @@ -750,13 +839,7 @@ impl Wizer { if let Some(preload) = &self.preload { if let Some((name, value)) = preload.split_once('=') { let content = std::fs::read(value).context("failed to read preload module")?; - let module = wasmtime::Module::new(engine, content) - .context("failed to parse preload module")?; - let instance = wasmtime::Instance::new(&mut *store, &module, &[]) - .context("failed to instantiate preload module")?; - linker - .instance(&mut *store, name, instance) - .context("failed to add preload's exports to linker")?; + self.do_preload(engine, &mut *store, &mut linker, &name[..], &content[..])?; } else { anyhow::bail!( "Bad preload option: {} (must be of form `name=file`)", @@ -764,6 +847,9 @@ impl Wizer { ); } } + if let Some((name, bytes)) = &self.preload_bytes { + self.do_preload(engine, &mut *store, &mut linker, &name[..], &bytes[..])?; + } dummy_imports(&mut *store, &module, &mut linker)?; From 458ac1d2531adadc25afe9dc4d917c4f9f71aef3 Mon Sep 17 00:00:00 2001 From: Chris Fallin Date: Fri, 12 May 2023 09:14:48 -0700 Subject: [PATCH 149/212] Allow for multiple preloads. --- crates/wizer/src/lib.rs | 39 +++++++++++++++++---------------------- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/crates/wizer/src/lib.rs b/crates/wizer/src/lib.rs index 93530fc229d6..2f90ec013397 100644 --- a/crates/wizer/src/lib.rs +++ b/crates/wizer/src/lib.rs @@ -139,15 +139,16 @@ pub struct Wizer { /// snapshot. /// /// The format of this option is `name=file.{wasm,wat}`; e.g., - /// `intrinsics=stubs.wat`. + /// `intrinsics=stubs.wat`. Multiple instances of the option may + /// appear. #[cfg_attr(feature = "structopt", structopt(long = "preload"))] - preload: Option, + preload: Vec, /// Like `preload` above, but with the module contents provided, /// rather than a filename. This is more useful for programmatic /// use-cases where the embedding tool may also embed a Wasm module. #[cfg_attr(feature = "structopt", structopt(skip))] - preload_bytes: Option<(String, Vec)>, + preload_bytes: Vec<(String, Vec)>, #[cfg_attr(feature = "structopt", structopt(skip))] make_linker: Option anyhow::Result>>, @@ -323,8 +324,8 @@ impl Wizer { init_func: "wizer.initialize".into(), func_renames: vec![], allow_wasi: false, - preload: None, - preload_bytes: None, + preload: vec![], + preload_bytes: vec![], make_linker: None, inherit_stdio: None, inherit_env: None, @@ -388,21 +389,16 @@ impl Wizer { /// intrinsics to be included, when these will be provided with /// different implementations when running or further processing the /// snapshot. - pub fn preload( - &mut self, - name_and_filename: Option<(&str, &str)>, - ) -> anyhow::Result<&mut Self> { + pub fn preload(&mut self, name: &str, filename: &str) -> anyhow::Result<&mut Self> { anyhow::ensure!( self.make_linker.is_none(), "Cannot use 'preload' with a custom linker" ); - if let Some((name, _)) = name_and_filename { - anyhow::ensure!( - !name.contains("="), - "Module name cannot contain an `=` character" - ); - } - self.preload = name_and_filename.map(|(name, filename)| format!("{}={}", name, filename)); + anyhow::ensure!( + !name.contains("="), + "Module name cannot contain an `=` character" + ); + self.preload.push(format!("{}={}", name, filename)); Ok(self) } @@ -422,17 +418,16 @@ impl Wizer { /// intrinsics to be included, when these will be provided with /// different implementations when running or further processing the /// snapshot. - /// - /// The argument is either `Some((module_name, bytes))` or `None`. pub fn preload_bytes( &mut self, - name_and_bytes: Option<(&str, Vec)>, + name: &str, + module_bytes: Vec, ) -> anyhow::Result<&mut Self> { anyhow::ensure!( self.make_linker.is_none(), "Cannot use 'preload_bytes' with a custom linker" ); - self.preload_bytes = name_and_bytes.map(|(name, bytes)| (name.to_owned(), bytes)); + self.preload_bytes.push((name.to_owned(), module_bytes)); Ok(self) } @@ -836,7 +831,7 @@ impl Wizer { })?; } - if let Some(preload) = &self.preload { + for preload in &self.preload { if let Some((name, value)) = preload.split_once('=') { let content = std::fs::read(value).context("failed to read preload module")?; self.do_preload(engine, &mut *store, &mut linker, &name[..], &content[..])?; @@ -847,7 +842,7 @@ impl Wizer { ); } } - if let Some((name, bytes)) = &self.preload_bytes { + for (name, bytes) in &self.preload_bytes { self.do_preload(engine, &mut *store, &mut linker, &name[..], &bytes[..])?; } From 254ebfb5defcd8db5fa8a8c56e309d26378f3d16 Mon Sep 17 00:00:00 2001 From: Chris Fallin Date: Fri, 12 May 2023 09:39:56 -0700 Subject: [PATCH 150/212] Add smoke-test for preloads. --- crates/wizer/tests/preloads.rs | 80 ++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 crates/wizer/tests/preloads.rs diff --git a/crates/wizer/tests/preloads.rs b/crates/wizer/tests/preloads.rs new file mode 100644 index 000000000000..74d5deff3d3b --- /dev/null +++ b/crates/wizer/tests/preloads.rs @@ -0,0 +1,80 @@ +use anyhow::Result; +use wat::parse_str as wat_to_wasm; +use wizer::Wizer; + +const PRELOAD1: &'static str = r#" +(module + (func (export "f") (param i32) (result i32) + local.get 0 + i32.const 1 + i32.add)) + "#; + +const PRELOAD2: &'static str = r#" +(module + (func (export "f") (param i32) (result i32) + local.get 0 + i32.const 2 + i32.add)) + "#; + +fn run_with_preloads(args: &[wasmtime::Val], wat: &str) -> Result { + let wasm = wat_to_wasm(wat)?; + let mut w = Wizer::new(); + w.preload_bytes("mod1", PRELOAD1.as_bytes().to_vec())?; + w.preload_bytes("mod2", PRELOAD2.as_bytes().to_vec())?; + let processed = w.run(&wasm)?; + + let engine = wasmtime::Engine::default(); + let mut store = wasmtime::Store::new(&engine, ()); + + let mod1 = wasmtime::Module::new(&engine, PRELOAD1.as_bytes())?; + let mod2 = wasmtime::Module::new(&engine, PRELOAD2.as_bytes())?; + let testmod = wasmtime::Module::new(&engine, &processed[..])?; + + let mod1_inst = wasmtime::Instance::new(&mut store, &mod1, &[])?; + let mod2_inst = wasmtime::Instance::new(&mut store, &mod2, &[])?; + let mut linker = wasmtime::Linker::new(&engine); + linker.instance(&mut store, "mod1", mod1_inst)?; + linker.instance(&mut store, "mod2", mod2_inst)?; + + let inst = linker.instantiate(&mut store, &testmod)?; + let run = inst + .get_func(&mut store, "run") + .ok_or_else(|| anyhow::anyhow!("no `run` function on test module"))?; + let mut returned = vec![wasmtime::Val::I32(0)]; + run.call(&mut store, args, &mut returned)?; + Ok(returned[0].clone()) +} + +#[test] +fn test_preloads() { + const WAT: &'static str = r#" + (module + (import "mod1" "f" (func $mod1f (param i32) (result i32))) + (import "mod2" "f" (func $mod2f (param i32) (result i32))) + (global $g1 (mut i32) (i32.const 0)) + (global $g2 (mut i32) (i32.const 0)) + (func (export "wizer.initialize") + i32.const 100 + call $mod1f + global.set $g1 + i32.const 100 + call $mod2f + global.set $g2) + (func (export "run") (param i32 i32) (result i32) + local.get 0 + call $mod1f + local.get 1 + call $mod2f + i32.add + global.get $g1 + global.get $g2 + i32.add + i32.add)) + "#; + + let result = + run_with_preloads(&[wasmtime::Val::I32(200), wasmtime::Val::I32(201)], WAT).unwrap(); + assert!(matches!(result, wasmtime::Val::I32(607))); +} From 51bc1a1384780edc1d3ddbd697cbed8ae20a468c Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Fri, 12 May 2023 10:45:25 -0700 Subject: [PATCH 151/212] Bump to version 2.0.0 --- crates/wizer/Cargo.lock | 2 +- crates/wizer/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/wizer/Cargo.lock b/crates/wizer/Cargo.lock index 39aa63a4e163..c4725ac5992d 100644 --- a/crates/wizer/Cargo.lock +++ b/crates/wizer/Cargo.lock @@ -2478,7 +2478,7 @@ dependencies = [ [[package]] name = "wizer" -version = "1.6.1-beta.4" +version = "2.0.0" dependencies = [ "anyhow", "cap-std 0.24.4", diff --git a/crates/wizer/Cargo.toml b/crates/wizer/Cargo.toml index 5fcb58f06d72..e333281541a3 100644 --- a/crates/wizer/Cargo.toml +++ b/crates/wizer/Cargo.toml @@ -10,7 +10,7 @@ license = "Apache-2.0 WITH LLVM-exception" name = "wizer" readme = "./README.md" repository = "https://github.com/bytecodealliance/wizer" -version = "1.6.1-beta.4" +version = "2.0.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html From 823392c87f1213f1fb19057bff903e4e625299a3 Mon Sep 17 00:00:00 2001 From: Mrmaxmeier Date: Tue, 16 May 2023 21:06:54 +0200 Subject: [PATCH 152/212] Avoid duplicate call to `_initialize` We call the reactor init function automatically before running the user's init function. Let's not call it twice if the user explicitly requests `_initialize`. --- crates/wizer/src/lib.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/crates/wizer/src/lib.rs b/crates/wizer/src/lib.rs index 2b70b11b9a66..3e188e62633f 100644 --- a/crates/wizer/src/lib.rs +++ b/crates/wizer/src/lib.rs @@ -866,6 +866,12 @@ impl Wizer { f.call(&mut *store, ()).map_err(Into::into) }) .context("calling the Reactor initialization function")?; + + if self.init_func == "_initialize" && has_wasi_initialize { + // Don't run `_initialize` twice if the it was explicitly + // requested as the init function. + return Ok((instance, has_wasi_initialize)); + } } } From 7ebc1e7701e9e87d7ad516cd1716239a836f58f3 Mon Sep 17 00:00:00 2001 From: Mrmaxmeier Date: Wed, 17 May 2023 21:09:54 +0200 Subject: [PATCH 153/212] Add test for `--init-func=_initialize` --- crates/wizer/tests/tests.rs | 40 ++++++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git a/crates/wizer/tests/tests.rs b/crates/wizer/tests/tests.rs index 4be44965fb16..8b8f28d1c42a 100644 --- a/crates/wizer/tests/tests.rs +++ b/crates/wizer/tests/tests.rs @@ -6,7 +6,7 @@ use wizer::Wizer; fn run_wat(args: &[wasmtime::Val], expected: i32, wat: &str) -> Result<()> { let _ = env_logger::try_init(); let wasm = wat_to_wasm(wat)?; - run_wasm(args, expected, &wasm) + wiz_and_run_wasm(args, expected, &wasm, get_wizer()) } fn get_wizer() -> Wizer { @@ -17,7 +17,12 @@ fn get_wizer() -> Wizer { wizer } -fn run_wasm(args: &[wasmtime::Val], expected: i32, wasm: &[u8]) -> Result<()> { +fn wiz_and_run_wasm( + args: &[wasmtime::Val], + expected: i32, + wasm: &[u8], + wizer: Wizer, +) -> Result<()> { let _ = env_logger::try_init(); log::debug!( @@ -26,7 +31,7 @@ fn run_wasm(args: &[wasmtime::Val], expected: i32, wasm: &[u8]) -> Result<()> { ===========================================================================", wasmprinter::print_bytes(&wasm).unwrap() ); - let wasm = get_wizer().run(&wasm)?; + let wasm = wizer.run(&wasm)?; log::debug!( "=== Wizened Wasm ==========================================================\n\ {}\n\ @@ -348,10 +353,11 @@ fn reject_data_drop() -> Result<()> { #[test] fn rust_regex() -> Result<()> { - run_wasm( + wiz_and_run_wasm( &[wasmtime::Val::I32(13)], 42, &include_bytes!("./regex_test.wasm")[..], + get_wizer(), ) } @@ -494,6 +500,30 @@ fn wasi_reactor() -> anyhow::Result<()> { ) } +#[test] +fn wasi_reactor_initializer_as_init_func() -> anyhow::Result<()> { + let wat = r#" + (module + (global $g (mut i32) i32.const 0) + (func (export "_initialize") + global.get $g + i32.const 1 + i32.add + global.set $g + ) + (func (export "run") (result i32) + global.get $g + ) + )"#; + + let _ = env_logger::try_init(); + let mut wizer = Wizer::new(); + wizer.init_func("_initialize"); + let wasm = wat_to_wasm(wat)?; + // we expect `_initialize` to be called _exactly_ once + wiz_and_run_wasm(&[], 1, &wasm, wizer) +} + #[test] fn call_undefined_import_function_during_init() -> Result<()> { fails_wizening( @@ -596,7 +626,7 @@ fn accept_bulk_memory_data_count() -> Result<()> { data.active(0, &ConstExpr::i32_const(4), vec![5, 6, 7, 8]); module.section(&data); - run_wasm(&[], 42, &module.finish()).unwrap(); + wiz_and_run_wasm(&[], 42, &module.finish(), get_wizer()).unwrap(); Ok(()) } From ff1a6555752f2d0431a835301ceb1a38e27761a3 Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Thu, 18 May 2023 09:00:43 -0700 Subject: [PATCH 154/212] Expand "wiz" to "wizen" in test function name --- crates/wizer/tests/tests.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/crates/wizer/tests/tests.rs b/crates/wizer/tests/tests.rs index 8b8f28d1c42a..5f598170878d 100644 --- a/crates/wizer/tests/tests.rs +++ b/crates/wizer/tests/tests.rs @@ -6,7 +6,7 @@ use wizer::Wizer; fn run_wat(args: &[wasmtime::Val], expected: i32, wat: &str) -> Result<()> { let _ = env_logger::try_init(); let wasm = wat_to_wasm(wat)?; - wiz_and_run_wasm(args, expected, &wasm, get_wizer()) + wizen_and_run_wasm(args, expected, &wasm, get_wizer()) } fn get_wizer() -> Wizer { @@ -17,7 +17,7 @@ fn get_wizer() -> Wizer { wizer } -fn wiz_and_run_wasm( +fn wizen_and_run_wasm( args: &[wasmtime::Val], expected: i32, wasm: &[u8], @@ -353,7 +353,7 @@ fn reject_data_drop() -> Result<()> { #[test] fn rust_regex() -> Result<()> { - wiz_and_run_wasm( + wizen_and_run_wasm( &[wasmtime::Val::I32(13)], 42, &include_bytes!("./regex_test.wasm")[..], @@ -521,7 +521,7 @@ fn wasi_reactor_initializer_as_init_func() -> anyhow::Result<()> { wizer.init_func("_initialize"); let wasm = wat_to_wasm(wat)?; // we expect `_initialize` to be called _exactly_ once - wiz_and_run_wasm(&[], 1, &wasm, wizer) + wizen_and_run_wasm(&[], 1, &wasm, wizer) } #[test] @@ -626,7 +626,7 @@ fn accept_bulk_memory_data_count() -> Result<()> { data.active(0, &ConstExpr::i32_const(4), vec![5, 6, 7, 8]); module.section(&data); - wiz_and_run_wasm(&[], 42, &module.finish(), get_wizer()).unwrap(); + wizen_and_run_wasm(&[], 42, &module.finish(), get_wizer()).unwrap(); Ok(()) } From 13478ebbd435efa5f15cb3294639beaebd862ce2 Mon Sep 17 00:00:00 2001 From: Jake Champion Date: Thu, 25 May 2023 10:47:27 +0100 Subject: [PATCH 155/212] ci: add aarch64-unknown-linux-gnu and s390x-unknown-linux-gnu as new test targets --- crates/wizer/.github/workflows/ci.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/crates/wizer/.github/workflows/ci.yml b/crates/wizer/.github/workflows/ci.yml index bb5bd4312d2c..2c2bbfba4a74 100644 --- a/crates/wizer/.github/workflows/ci.yml +++ b/crates/wizer/.github/workflows/ci.yml @@ -23,6 +23,12 @@ jobs: - build: x86_64-mingw os: windows-latest target: x86_64-pc-windows-gnu + - build: aarch64-linux + os: ubuntu-latest + target: aarch64-unknown-linux-gnu + - build: s390x-linux + os: ubuntu-latest + target: s390x-unknown-linux-gnu steps: - uses: actions/checkout@v2 - name: Build From cb13cf7611f73f841b8e9bcfc785fc7b0876c3d6 Mon Sep 17 00:00:00 2001 From: Jake Champion Date: Thu, 25 May 2023 10:47:59 +0100 Subject: [PATCH 156/212] ci: add aarch64-unknown-linux-gnu and s390x-unknown-linux-gnu as new precompiled artifact targets --- crates/wizer/.github/workflows/release.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/crates/wizer/.github/workflows/release.yml b/crates/wizer/.github/workflows/release.yml index d3b053689800..7b53ee1addca 100644 --- a/crates/wizer/.github/workflows/release.yml +++ b/crates/wizer/.github/workflows/release.yml @@ -89,6 +89,14 @@ jobs: with: name: bins-x86_64-linux path: dist + - uses: actions/download-artifact@v1 + with: + name: bins-aarch64-linux + path: dist + - uses: actions/download-artifact@v1 + with: + name: bins-s390x-linux + path: dist - name: Calculate tag name run: | From 3a960a3f878ba36a6c361e119f06f555afc3a714 Mon Sep 17 00:00:00 2001 From: Jake Champion Date: Thu, 25 May 2023 10:48:42 +0100 Subject: [PATCH 157/212] ci: publish the npm packages when a new tag is pushed --- crates/wizer/.github/workflows/release.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/crates/wizer/.github/workflows/release.yml b/crates/wizer/.github/workflows/release.yml index 7b53ee1addca..4874c6b37694 100644 --- a/crates/wizer/.github/workflows/release.yml +++ b/crates/wizer/.github/workflows/release.yml @@ -121,3 +121,13 @@ jobs: token: ${{ secrets.GITHUB_TOKEN }} name: ${{ steps.tagname.outputs.val }} continue-on-error: true + - name: Update npm packages to latest version + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') + working-directory: ./npm/wizer + run: npm install && npm version "${{ steps.tagname.outputs.val }}" + - name: Publish npm packages + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') + working-directory: ./npm + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + run: for n in *; do (echo $n && cd $n && npm publish); done \ No newline at end of file From a3ad1be0fb26f037e882d3822b5fdb5c59e30f76 Mon Sep 17 00:00:00 2001 From: Jake Champion Date: Thu, 25 May 2023 15:05:13 +0100 Subject: [PATCH 158/212] add npm packages for linux arm64 and s390x --- crates/wizer/.gitignore | 2 ++ crates/wizer/npm/wizer/wizer.js | 2 ++ 2 files changed, 4 insertions(+) diff --git a/crates/wizer/.gitignore b/crates/wizer/.gitignore index 80730c7232fe..196c957bbba6 100644 --- a/crates/wizer/.gitignore +++ b/crates/wizer/.gitignore @@ -4,3 +4,5 @@ npm/wizer-darwin-arm64/ npm/wizer-darwin-x64/ npm/wizer-linux-x64/ npm/wizer-win32-x64/ +npm/wizer-linux-s390x/ +npm/wizer-linux-arm64/ \ No newline at end of file diff --git a/crates/wizer/npm/wizer/wizer.js b/crates/wizer/npm/wizer/wizer.js index 46b9a9394cd8..77ac533b690c 100755 --- a/crates/wizer/npm/wizer/wizer.js +++ b/crates/wizer/npm/wizer/wizer.js @@ -6,7 +6,9 @@ const knownPackages = { "win32 x64 LE": "@bytecodealliance/wizer-win32-x64", "darwin arm64 LE": "@bytecodealliance/wizer-darwin-arm64", "darwin x64 LE": "@bytecodealliance/wizer-darwin-x64", + "linux arm64 LE": "@bytecodealliance/wizer-linux-arm64", "linux x64 LE": "@bytecodealliance/wizer-linux-x64", + "linux s390x BE": "@bytecodealliance/wizer-linux-s390x", }; function pkgForCurrentPlatform() { From dfd294af821c76ee4df6de72bf8623327d453720 Mon Sep 17 00:00:00 2001 From: Jake Champion Date: Thu, 25 May 2023 15:06:02 +0100 Subject: [PATCH 159/212] Update release.yml --- crates/wizer/.github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/wizer/.github/workflows/release.yml b/crates/wizer/.github/workflows/release.yml index 4874c6b37694..bcf1193d5aa9 100644 --- a/crates/wizer/.github/workflows/release.yml +++ b/crates/wizer/.github/workflows/release.yml @@ -130,4 +130,4 @@ jobs: working-directory: ./npm env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - run: for n in *; do (echo $n && cd $n && npm publish); done \ No newline at end of file + run: for dir in *; do (echo $dir && cd $dir && npm publish); done From 8e353eeaee5b76c37fa641ae9fd8a2361316c0f2 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 24 May 2023 11:25:45 -0700 Subject: [PATCH 160/212] Update wasmtime/wasm-tools dependencies This updates all the various deps to their latest versions. --- crates/wizer/Cargo.lock | 415 +++++++++++------------- crates/wizer/Cargo.toml | 14 +- crates/wizer/src/info/types_interner.rs | 1 + crates/wizer/src/instrument.rs | 2 +- crates/wizer/src/lib.rs | 1 + crates/wizer/src/parse.rs | 1 + crates/wizer/src/rewrite.rs | 14 +- 7 files changed, 205 insertions(+), 243 deletions(-) diff --git a/crates/wizer/Cargo.lock b/crates/wizer/Cargo.lock index c4725ac5992d..4a6569469f3b 100644 --- a/crates/wizer/Cargo.lock +++ b/crates/wizer/Cargo.lock @@ -116,6 +116,12 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "bitflags" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6776fc96284a0bb647b615056fc496d1fe1644a7ab01829818a6d91cae888b84" + [[package]] name = "block-buffer" version = "0.10.4" @@ -146,7 +152,7 @@ dependencies = [ "cap-primitives 1.0.14", "cap-std 1.0.14", "io-lifetimes 1.0.10", - "windows-sys 0.48.0", + "windows-sys", ] [[package]] @@ -181,7 +187,7 @@ dependencies = [ "ipnet", "maybe-owned", "rustix 0.37.14", - "windows-sys 0.48.0", + "windows-sys", "winx 0.35.1", ] @@ -261,7 +267,7 @@ checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" dependencies = [ "ansi_term", "atty", - "bitflags", + "bitflags 1.3.2", "strsim", "textwrap", "unicode-width", @@ -288,23 +294,24 @@ dependencies = [ [[package]] name = "cranelift-bforest" -version = "0.95.0" +version = "0.96.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e9fb5af44f8cb4685d425a5101f562800618cfe7a454e23f87710ebfb22af50" +checksum = "9b6160c0a96253993b79fb7e0983534a4515ecf666120ddf8f92068114997ebc" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-codegen" -version = "0.95.0" +version = "0.96.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b50041c01a29ab8c2dd93188a024d67c30a099067aa45bcb0f2bb0f6701b003" +checksum = "7b38da5f63562e42f3c929d7c76871098e5ad12c8ab44b0659ffc529f22a5b3a" dependencies = [ "bumpalo", "cranelift-bforest", "cranelift-codegen-meta", "cranelift-codegen-shared", + "cranelift-control", "cranelift-entity", "cranelift-isle", "gimli", @@ -317,33 +324,42 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.95.0" +version = "0.96.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3cdc8a18f16dff6690dc1a0ff5e3319b84904e6e9af06056e4712c3dca4ee63b" +checksum = "011371e213e163b55dd9e8404b3f2d9fa52cd14dc2f3dc5b83e61ffceff126db" dependencies = [ "cranelift-codegen-shared", ] [[package]] name = "cranelift-codegen-shared" -version = "0.95.0" +version = "0.96.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "420bc3bed85c6879e0383318c0a614c00f2a74df67c37b7ab4cfd0c19fe11794" +checksum = "1bf97dde7f5ad571161cdd203a2c9c88682ef669830aea3c14ea5d164ef8bb43" + +[[package]] +name = "cranelift-control" +version = "0.96.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd9a9254aee733b0f2b68e5eaaf0337ad53cb23252a056c10a35370551be8d40" +dependencies = [ + "arbitrary", +] [[package]] name = "cranelift-entity" -version = "0.95.0" +version = "0.96.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a6319b1918ca95faef80f17a44b5394bb63facd899f5369a54fbcc23e67971a" +checksum = "baf39a33ee39479d1337cd9333f3c09786c5a0ca1ec509edcaf9d1346d5de0e5" dependencies = [ "serde", ] [[package]] name = "cranelift-frontend" -version = "0.95.0" +version = "0.96.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a626e2d07bec4d029ba0393547433bc1cd6f1335581dd833f06e3feb3cbaf72a" +checksum = "65e260b92a193a0a2dccc3938f133d9532e7dcfe8d03e36bf8b7d3518c1c1793" dependencies = [ "cranelift-codegen", "log", @@ -353,15 +369,15 @@ dependencies = [ [[package]] name = "cranelift-isle" -version = "0.95.0" +version = "0.96.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2af8d1e5435264cac8208e34cc550abf6797ad6c7b4f6c874dc93a8249aa7d35" +checksum = "9446c8e1aadfcdacee1a49592bc2c25d1d9bf5484782c163e7f5485c92cd3c1c" [[package]] name = "cranelift-native" -version = "0.95.0" +version = "0.96.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "789bc52610128a42bbbba8e9b309eb73f8622bf10f55eb632ef552162a723ca7" +checksum = "eac916f3c5aff4b817e42fc2e682292b931495b3fe2603d5e3c3cf602d74e344" dependencies = [ "cranelift-codegen", "libc", @@ -370,9 +386,9 @@ dependencies = [ [[package]] name = "cranelift-wasm" -version = "0.95.0" +version = "0.96.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3dbb9a85d3e0371fc65085dfde86211305a562c70bae9ea0a57155f58750983" +checksum = "00bac57700cdb5c37996164d12f9fe62997d9d1762b38b6ba88f5e82538a9cbc" dependencies = [ "cranelift-codegen", "cranelift-entity", @@ -380,7 +396,7 @@ dependencies = [ "itertools", "log", "smallvec", - "wasmparser 0.102.0", + "wasmparser 0.103.0", "wasmtime-types", ] @@ -503,6 +519,15 @@ dependencies = [ "memchr", ] +[[package]] +name = "debugid" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef552e6f588e446098f6ba40d89ac146c8c7b64aade83c051ee00bb5d2bc18d" +dependencies = [ + "uuid", +] + [[package]] name = "derive_arbitrary" version = "1.3.0" @@ -616,7 +641,7 @@ checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a" dependencies = [ "errno-dragonfly", "libc", - "windows-sys 0.48.0", + "windows-sys", ] [[package]] @@ -643,7 +668,7 @@ checksum = "39ae6b3d9530211fb3b12a95374b8b0823be812f53d09e18c5675c0146b09642" dependencies = [ "cfg-if", "rustix 0.37.14", - "windows-sys 0.48.0", + "windows-sys", ] [[package]] @@ -676,17 +701,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "fs-set-times" -version = "0.18.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "857cf27edcb26c2a36d84b2954019573d335bb289876113aceacacdca47a4fd4" -dependencies = [ - "io-lifetimes 1.0.10", - "rustix 0.36.13", - "windows-sys 0.45.0", -] - [[package]] name = "fs-set-times" version = "0.19.1" @@ -695,7 +709,7 @@ checksum = "7833d0f115a013d51c55950a3b09d30e4b057be9961b709acb9b5b17a1108861" dependencies = [ "io-lifetimes 1.0.10", "rustix 0.37.14", - "windows-sys 0.48.0", + "windows-sys", ] [[package]] @@ -707,6 +721,19 @@ dependencies = [ "byteorder", ] +[[package]] +name = "fxprof-processed-profile" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27d12c0aed7f1e24276a241aadc4cb8ea9f83000f34bc062b7cc2d51e3b0fabd" +dependencies = [ + "bitflags 2.3.1", + "debugid", + "fxhash", + "serde", + "serde_json", +] + [[package]] name = "generic-array" version = "0.14.7" @@ -849,7 +876,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fde93d48f0d9277f977a333eca8313695ddd5301dc96f7e02aeddcb0dd99096f" dependencies = [ "io-lifetimes 1.0.10", - "windows-sys 0.48.0", + "windows-sys", ] [[package]] @@ -866,7 +893,7 @@ checksum = "9c66c74d2ae7e79a5a8f7ac924adbe38ee42a859c6539ad869eb51f0b52dc220" dependencies = [ "hermit-abi 0.3.1", "libc", - "windows-sys 0.48.0", + "windows-sys", ] [[package]] @@ -884,7 +911,7 @@ dependencies = [ "hermit-abi 0.3.1", "io-lifetimes 1.0.10", "rustix 0.37.14", - "windows-sys 0.48.0", + "windows-sys", ] [[package]] @@ -981,12 +1008,6 @@ version = "0.0.42" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5284f00d480e1c39af34e72f8ad60b94f47007e3481cd3b731c1d67190ddc7b7" -[[package]] -name = "linux-raw-sys" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4" - [[package]] name = "linux-raw-sys" version = "0.3.4" @@ -1190,7 +1211,7 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ffade02495f22453cd593159ea2f59827aae7f53fa8323f756799b670881dcf8" dependencies = [ - "bitflags", + "bitflags 1.3.2", "memchr", "unicase", ] @@ -1262,7 +1283,7 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" dependencies = [ - "bitflags", + "bitflags 1.3.2", ] [[package]] @@ -1278,12 +1299,13 @@ dependencies = [ [[package]] name = "regalloc2" -version = "0.6.1" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80535183cae11b149d618fbd3c37e38d7cda589d82d7769e196ca9a9042d7621" +checksum = "d4a52e724646c6c0800fc456ec43b4165d2f91fba88ceaca06d9e0b400023478" dependencies = [ - "fxhash", + "hashbrown 0.13.2", "log", + "rustc-hash", "slice-group-by", "smallvec", ] @@ -1325,13 +1347,19 @@ version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + [[package]] name = "rustix" version = "0.33.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "938a344304321a9da4973b9ff4f9f8db9caf4597dfd9dda6a60b523340a0fff0" dependencies = [ - "bitflags", + "bitflags 1.3.2", "errno 0.2.8", "io-lifetimes 0.5.3", "itoa", @@ -1341,34 +1369,20 @@ dependencies = [ "winapi", ] -[[package]] -name = "rustix" -version = "0.36.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a38f9520be93aba504e8ca974197f46158de5dcaa9fa04b57c57cd6a679d658" -dependencies = [ - "bitflags", - "errno 0.3.1", - "io-lifetimes 1.0.10", - "libc", - "linux-raw-sys 0.1.4", - "windows-sys 0.45.0", -] - [[package]] name = "rustix" version = "0.37.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9b864d3c18a5785a05953adeed93e2dca37ed30f18e69bba9f30079d51f363f" dependencies = [ - "bitflags", + "bitflags 1.3.2", "errno 0.3.1", "io-lifetimes 1.0.10", "itoa", "libc", "linux-raw-sys 0.3.4", "once_cell", - "windows-sys 0.48.0", + "windows-sys", ] [[package]] @@ -1541,13 +1555,13 @@ version = "0.25.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "928ebd55ab758962e230f51ca63735c5b283f26292297c81404289cda5d78631" dependencies = [ - "bitflags", + "bitflags 1.3.2", "cap-fs-ext", "cap-std 1.0.14", "fd-lock", "io-lifetimes 1.0.10", "rustix 0.37.14", - "windows-sys 0.48.0", + "windows-sys", "winx 0.35.1", ] @@ -1736,6 +1750,12 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "uuid" +version = "1.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "345444e32442451b267fc254ae85a209c64be56d2890e601a0c37ff0c3c5ecd2" + [[package]] name = "vec_map" version = "0.8.2" @@ -1766,9 +1786,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasi-cap-std-sync" -version = "8.0.0" +version = "9.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8306bc71532b8a78f31e35d88e43506dfc5fc26bf30c7f0673cbf6beeb28bb6a" +checksum = "4096c4ef7e44b1a74463464153469b87826e29309db80167a67cbdfdc16240a6" dependencies = [ "anyhow", "async-trait", @@ -1776,36 +1796,36 @@ dependencies = [ "cap-rand", "cap-std 1.0.14", "cap-time-ext", - "fs-set-times 0.18.1", + "fs-set-times 0.19.1", "io-extras 0.17.4", "io-lifetimes 1.0.10", "is-terminal", "once_cell", - "rustix 0.36.13", + "rustix 0.37.14", "system-interface", "tracing", "wasi-common", - "windows-sys 0.45.0", + "windows-sys", ] [[package]] name = "wasi-common" -version = "8.0.0" +version = "9.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58c4bd23d8aeec5da68339e121dccf21e2b2f7b9028c39413bfd2fe94eb7a535" +checksum = "f2ff11918dcda936b8f32ed6c73162317b2a467be1875d29b90980183acc34d1" dependencies = [ "anyhow", - "bitflags", + "bitflags 1.3.2", "cap-rand", "cap-std 1.0.14", "io-extras 0.17.4", "log", - "rustix 0.36.13", + "rustix 0.37.14", "thiserror", "tracing", "wasmtime", "wiggle", - "windows-sys 0.45.0", + "windows-sys", ] [[package]] @@ -1873,9 +1893,9 @@ dependencies = [ [[package]] name = "wasm-encoder" -version = "0.25.0" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4eff853c4f09eec94d76af527eddad4e9de13b11d6286a1ef7134bc30135a2b7" +checksum = "83c94f464d50e31da425794a02da1a82d4b96a657dcb152a6664e8aa915be517" dependencies = [ "leb128", ] @@ -1894,9 +1914,9 @@ dependencies = [ [[package]] name = "wasmparser" -version = "0.102.0" +version = "0.103.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48134de3d7598219ab9eaf6b91b15d8e50d31da76b8519fe4ecfcec2cf35104b" +checksum = "2c437373cac5ea84f1113d648d51f71751ffbe3d90c00ae67618cf20d0b5ee7b" dependencies = [ "indexmap", "url", @@ -1904,9 +1924,9 @@ dependencies = [ [[package]] name = "wasmparser" -version = "0.103.0" +version = "0.106.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c437373cac5ea84f1113d648d51f71751ffbe3d90c00ae67618cf20d0b5ee7b" +checksum = "d014e33793cab91655fa6349b0bc974984de106b2e0f6b0dfe6f6594b260624d" dependencies = [ "indexmap", "url", @@ -1914,24 +1934,26 @@ dependencies = [ [[package]] name = "wasmprinter" -version = "0.2.55" +version = "0.2.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51befda9d7eefac615a2ef75f42d2f2bd243cdabaa141a8ea0f9ffa3fc79ccf4" +checksum = "3c520299a0b5999adef4f063add9689e4559b3e4eb2688dbd63cc36ebb595841" dependencies = [ "anyhow", - "wasmparser 0.103.0", + "wasmparser 0.106.0", ] [[package]] name = "wasmtime" -version = "8.0.0" +version = "9.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a65e578b6d35f3e808b21b00c652b4c3ded90249f642d504a67700d7a02cac1c" +checksum = "24ca2e0d4e4806428980cd4439f2c4b24029da522d191f142da0135d07bb33c9" dependencies = [ "anyhow", "async-trait", "bincode", + "bumpalo", "cfg-if", + "fxprof-processed-profile", "indexmap", "libc", "log", @@ -1941,8 +1963,9 @@ dependencies = [ "psm", "rayon", "serde", + "serde_json", "target-lexicon", - "wasmparser 0.102.0", + "wasmparser 0.103.0", "wasmtime-cache", "wasmtime-component-macro", "wasmtime-cranelift", @@ -1951,23 +1974,23 @@ dependencies = [ "wasmtime-jit", "wasmtime-runtime", "wat", - "windows-sys 0.45.0", + "windows-sys", ] [[package]] name = "wasmtime-asm-macros" -version = "8.0.0" +version = "9.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdaba4716347d5936234f17d1c75a3a92f21edaefc96dbdc64b36ef53504c1e1" +checksum = "ac4a67ef4a478818d5234f24a9f94296edd3aa7448b0811c11cb30065f08388d" dependencies = [ "cfg-if", ] [[package]] name = "wasmtime-cache" -version = "8.0.0" +version = "9.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "673200e1afd89735b9e641ec63218e9b7edf2860257db1968507c0538511d612" +checksum = "19523f9aa866ab27d1730e0ac131411e84ca64ae737f53af32a565f929a739b5" dependencies = [ "anyhow", "base64", @@ -1975,19 +1998,19 @@ dependencies = [ "directories-next", "file-per-thread-logger", "log", - "rustix 0.36.13", + "rustix 0.37.14", "serde", "sha2", "toml", - "windows-sys 0.45.0", + "windows-sys", "zstd", ] [[package]] name = "wasmtime-component-macro" -version = "8.0.0" +version = "9.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e83eb45f3bab16800cb9da977b04cd427f3e2b1e6668b6c2dcbc8baec8a6b6d" +checksum = "dc0498a91533cdbe1642275649f5a7925477749aed5a44f79f5819b9cc481b20" dependencies = [ "anyhow", "proc-macro2", @@ -2000,18 +2023,19 @@ dependencies = [ [[package]] name = "wasmtime-component-util" -version = "8.0.0" +version = "9.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e9c89418c99fed44b9081e09ec4a9c5a3843ad663c4b0beceb16cac7a70c31d" +checksum = "6abc3b9b476d57bc69fab206454f1f85d51d6b8965ff0ecb04f1ddfe94254e59" [[package]] name = "wasmtime-cranelift" -version = "8.0.0" +version = "9.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed4490e68a86a8515071c19bd54a679b5c239c43badd24c18c764a63117ba119" +checksum = "e0fd6fc3481ba8a71a37f5d089db62e55d738d0930bd665c1bb9afcfae6f7f61" dependencies = [ "anyhow", "cranelift-codegen", + "cranelift-control", "cranelift-entity", "cranelift-frontend", "cranelift-native", @@ -2021,19 +2045,20 @@ dependencies = [ "object", "target-lexicon", "thiserror", - "wasmparser 0.102.0", + "wasmparser 0.103.0", "wasmtime-cranelift-shared", "wasmtime-environ", ] [[package]] name = "wasmtime-cranelift-shared" -version = "8.0.0" +version = "9.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73493000ea57cc755b4ab48df9194740c00ea6dcd2714b660b7859a451c1b925" +checksum = "509c8e577052bbd956200cc9e610b984140dd84842629423a854891da86eebea" dependencies = [ "anyhow", "cranelift-codegen", + "cranelift-control", "cranelift-native", "gimli", "object", @@ -2043,9 +2068,9 @@ dependencies = [ [[package]] name = "wasmtime-environ" -version = "8.0.0" +version = "9.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c2a2c8dcf2c4bacaa5bd29fbbc744769804377747940c6d5fe12b15bdfafe2c" +checksum = "fc05fad4839add17abf839656f677a4965b12639d919b5a346eb1efed5efbb18" dependencies = [ "anyhow", "cranelift-entity", @@ -2056,28 +2081,28 @@ dependencies = [ "serde", "target-lexicon", "thiserror", - "wasmparser 0.102.0", + "wasmparser 0.103.0", "wasmtime-types", ] [[package]] name = "wasmtime-fiber" -version = "8.0.0" +version = "9.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2bcc711e6ccb9314b4d90112912060539ce98ac43b4d4408680609414de004f" +checksum = "56db2e5979096f8931f1ed0413bc06344c077edaf84afd827f1faeb779a53722" dependencies = [ "cc", "cfg-if", - "rustix 0.36.13", + "rustix 0.37.14", "wasmtime-asm-macros", - "windows-sys 0.45.0", + "windows-sys", ] [[package]] name = "wasmtime-jit" -version = "8.0.0" +version = "9.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b75238696641fb46dcf3cd6aaf09ac4c48040c5e2391d5c5a9883c35b09a627" +checksum = "512d86bb17a864e289670515db7ad4d6aa3e2169715af607b21db0b032050d35" dependencies = [ "addr2line", "anyhow", @@ -2095,36 +2120,36 @@ dependencies = [ "wasmtime-jit-debug", "wasmtime-jit-icache-coherence", "wasmtime-runtime", - "windows-sys 0.45.0", + "windows-sys", ] [[package]] name = "wasmtime-jit-debug" -version = "8.0.0" +version = "9.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f47cc7e383300218d338fcbe95f2d7343e125b6b0d284d0d9b7e6acc7dd112a1" +checksum = "95b3e287fbaac91c56cb3c911219123dc4e85d4c79573e7506aedd5ae4ce06dd" dependencies = [ "object", "once_cell", - "rustix 0.36.13", + "rustix 0.37.14", ] [[package]] name = "wasmtime-jit-icache-coherence" -version = "8.0.0" +version = "9.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0c1b25e736692815a53f669e774e230b80ec063f21596f006f8310b9f2dd910" +checksum = "7d90933b781e1cef7656baed671c7a90bdba0c1c694e04fdd4124419308f5cbb" dependencies = [ "cfg-if", "libc", - "windows-sys 0.45.0", + "windows-sys", ] [[package]] name = "wasmtime-runtime" -version = "8.0.0" +version = "9.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a305b2e4e62dfc67c8d25b2db1c2ac6ba44c7bcf0ccefb7fd9205338bed3f6a" +checksum = "63b6c4bfd59e21bcd90c97f41ab721371efa720b4b007ac2840e74eb3a98a8a0" dependencies = [ "anyhow", "cc", @@ -2137,31 +2162,31 @@ dependencies = [ "memoffset", "paste", "rand", - "rustix 0.36.13", + "rustix 0.37.14", "wasmtime-asm-macros", "wasmtime-environ", "wasmtime-fiber", "wasmtime-jit-debug", - "windows-sys 0.45.0", + "windows-sys", ] [[package]] name = "wasmtime-types" -version = "8.0.0" +version = "9.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efecff824b08f5c1da332a776ce01a928b200b27dbbb3ffd9374d7f2718671ea" +checksum = "1cdd448786db95aa496b06e74ffe5be0780018ce8b2a9e3db6d5e117dc2e84fc" dependencies = [ "cranelift-entity", "serde", "thiserror", - "wasmparser 0.102.0", + "wasmparser 0.103.0", ] [[package]] name = "wasmtime-wasi" -version = "8.0.0" +version = "9.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ee49d3a53fd66187ac35f49f1cb5a28b3a104e066117d7194a0df7faf02658e" +checksum = "cda4af8d1de5e20fa7d59d732f0722791243c08e2886b38656d5d416e9a135c2" dependencies = [ "anyhow", "libc", @@ -2173,9 +2198,9 @@ dependencies = [ [[package]] name = "wasmtime-wit-bindgen" -version = "8.0.0" +version = "9.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "796fdb0983ac1b3da4509169f49eea5e902b5641324466dc6f158c6e4ea693f5" +checksum = "3f6b41780f19535abecab0b14c31a759bcf655cea79204958fb480b1586e9002" dependencies = [ "anyhow", "heck 0.4.1", @@ -2193,23 +2218,23 @@ dependencies = [ [[package]] name = "wast" -version = "56.0.0" +version = "59.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b54185c051d7bbe23757d50fe575880a2426a2f06d2e9f6a10fd9a4a42920c0" +checksum = "38462178c91e3f990df95f12bf48abe36018e03550a58a65c53975f4e704fc35" dependencies = [ "leb128", "memchr", "unicode-width", - "wasm-encoder 0.25.0", + "wasm-encoder 0.28.0", ] [[package]] name = "wat" -version = "1.0.62" +version = "1.0.65" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56681922808216ab86d96bb750f70d500b5a7800e41564290fd46bb773581299" +checksum = "c936a025be0417a94d6e9bf92bfdf9e06dbf63debf187b650d9c73a5add701f1" dependencies = [ - "wast 56.0.0", + "wast 59.0.0", ] [[package]] @@ -2224,13 +2249,13 @@ dependencies = [ [[package]] name = "wiggle" -version = "8.0.0" +version = "9.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "883e99f57044e457243de44477104db73e90d892130e11da4cf7d1d9df3333e6" +checksum = "21b7f1da4335006b30072d0e859e905a905b3c6a6a58c170159ce921283563ce" dependencies = [ "anyhow", "async-trait", - "bitflags", + "bitflags 1.3.2", "thiserror", "tracing", "wasmtime", @@ -2239,9 +2264,9 @@ dependencies = [ [[package]] name = "wiggle-generate" -version = "8.0.0" +version = "9.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0743743724253da8c775c1668bfdb0e14f47b0666b6b41f997fb21a33e8768df" +checksum = "5cff10f65663348b5503900777da6cc5a186902a4b9974c898abaec249f5257c" dependencies = [ "anyhow", "heck 0.4.1", @@ -2254,9 +2279,9 @@ dependencies = [ [[package]] name = "wiggle-macro" -version = "8.0.0" +version = "9.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a21994785b4bbc8cf3811e1422feb3c6b613b9da51c8bacf35cc29ca2f356a0" +checksum = "d7e71b4c5994191e29d29571df0ab7b4768e0deb01dba3bbad5981fe096a4b77" dependencies = [ "proc-macro2", "quote", @@ -2295,37 +2320,13 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -[[package]] -name = "windows-sys" -version = "0.45.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" -dependencies = [ - "windows-targets 0.42.2", -] - [[package]] name = "windows-sys" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ - "windows-targets 0.48.0", -] - -[[package]] -name = "windows-targets" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" -dependencies = [ - "windows_aarch64_gnullvm 0.42.2", - "windows_aarch64_msvc 0.42.2", - "windows_i686_gnu 0.42.2", - "windows_i686_msvc 0.42.2", - "windows_x86_64_gnu 0.42.2", - "windows_x86_64_gnullvm 0.42.2", - "windows_x86_64_msvc 0.42.2", + "windows-targets", ] [[package]] @@ -2334,93 +2335,51 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5" dependencies = [ - "windows_aarch64_gnullvm 0.48.0", - "windows_aarch64_msvc 0.48.0", - "windows_i686_gnu 0.48.0", - "windows_i686_msvc 0.48.0", - "windows_x86_64_gnu 0.48.0", - "windows_x86_64_gnullvm 0.48.0", - "windows_x86_64_msvc 0.48.0", + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", ] -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" - [[package]] name = "windows_aarch64_gnullvm" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" -[[package]] -name = "windows_aarch64_msvc" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" - [[package]] name = "windows_aarch64_msvc" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" -[[package]] -name = "windows_i686_gnu" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" - [[package]] name = "windows_i686_gnu" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" -[[package]] -name = "windows_i686_msvc" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" - [[package]] name = "windows_i686_msvc" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" -[[package]] -name = "windows_x86_64_gnu" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" - [[package]] name = "windows_x86_64_gnu" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" - [[package]] name = "windows_x86_64_gnullvm" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" -[[package]] -name = "windows_x86_64_msvc" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" - [[package]] name = "windows_x86_64_msvc" version = "0.48.0" @@ -2433,7 +2392,7 @@ version = "0.31.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08d5973cb8cd94a77d03ad7e23bbe14889cb29805da1cec0e4aff75e21aebded" dependencies = [ - "bitflags", + "bitflags 1.3.2", "io-lifetimes 0.5.3", "winapi", ] @@ -2444,16 +2403,16 @@ version = "0.35.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1c52a121f0fbf9320d5f2a9a5d82f6cb7557eda5e8b47fc3e7f359ec866ae960" dependencies = [ - "bitflags", + "bitflags 1.3.2", "io-lifetimes 1.0.10", - "windows-sys 0.48.0", + "windows-sys", ] [[package]] name = "wit-parser" -version = "0.6.4" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f887c3da527a51b321076ebe6a7513026a4757b6d4d144259946552d6fc728b3" +checksum = "5ca2581061573ef6d1754983d7a9b3ed5871ef859d52708ea9a0f5af32919172" dependencies = [ "anyhow", "id-arena", @@ -2488,8 +2447,8 @@ dependencies = [ "rayon", "structopt", "wasi-cap-std-sync", - "wasm-encoder 0.25.0", - "wasmparser 0.103.0", + "wasm-encoder 0.28.0", + "wasmparser 0.106.0", "wasmprinter", "wasmtime", "wasmtime-wasi", diff --git a/crates/wizer/Cargo.toml b/crates/wizer/Cargo.toml index e333281541a3..647160237384 100644 --- a/crates/wizer/Cargo.toml +++ b/crates/wizer/Cargo.toml @@ -34,8 +34,8 @@ log = "0.4.14" rayon = "1.5.0" structopt = { version = "0.3.21", optional = true } wasi-cap-std-sync = { workspace = true } -wasm-encoder = "0.25.0" -wasmparser = "0.103.0" +wasm-encoder = "0.28.0" +wasmparser = "0.106.0" wasmtime = { workspace = true } wasmtime-wasi = { workspace = true } @@ -46,17 +46,17 @@ workspace = true optional = true [workspace.dependencies] -wasmprinter = "0.2.26" -wasmtime = "8.0.0" -wasmtime-wasi = "8.0.0" -wasi-cap-std-sync = "8.0.0" +wasmprinter = "0.2.58" +wasmtime = "9.0.0" +wasmtime-wasi = "9.0.0" +wasi-cap-std-sync = "9.0.0" [dev-dependencies] criterion = "0.3.4" env_logger = "0.8.2" wasmprinter = { workspace = true } -wat = "1.0.62" +wat = "1.0.65" [workspace] members = [ diff --git a/crates/wizer/src/info/types_interner.rs b/crates/wizer/src/info/types_interner.rs index 98d8fac634c9..8d444370492b 100644 --- a/crates/wizer/src/info/types_interner.rs +++ b/crates/wizer/src/info/types_interner.rs @@ -62,6 +62,7 @@ impl TypesInterner { pub fn insert_wasmparser(&mut self, ty: wasmparser::Type, _types_space: &[TypeId]) -> TypeId { match ty { wasmparser::Type::Func(func_ty) => self.insert(Type::Func(func_ty)), + wasmparser::Type::Array(_) => todo!(), } } diff --git a/crates/wizer/src/instrument.rs b/crates/wizer/src/instrument.rs index eaff78927424..f6fb9c7e57e2 100644 --- a/crates/wizer/src/instrument.rs +++ b/crates/wizer/src/instrument.rs @@ -86,7 +86,7 @@ pub(crate) fn instrument(cx: &ModuleContext<'_>) -> Vec { // For the exports section, we need to transitively export internal // state so that we can read the initialized state after we call the // initialization function. - Some(section) if section.id == SectionId::Export.into() => { + Some(section) if section.id == u8::from(SectionId::Export) => { let entry = stack.top_mut(); let mut exports = wasm_encoder::ExportSection::new(); diff --git a/crates/wizer/src/lib.rs b/crates/wizer/src/lib.rs index 3e188e62633f..25810583fc4b 100644 --- a/crates/wizer/src/lib.rs +++ b/crates/wizer/src/lib.rs @@ -653,6 +653,7 @@ impl Wizer { component_model: false, memory_control: false, function_references: false, + gc: false, // XXX: Though we don't fully support bulk memory yet, we // unconditionally turn it on. diff --git a/crates/wizer/src/parse.rs b/crates/wizer/src/parse.rs index 10ec2d028a0a..566b837b9760 100644 --- a/crates/wizer/src/parse.rs +++ b/crates/wizer/src/parse.rs @@ -136,6 +136,7 @@ fn type_section<'a>( ty @ wasmparser::Type::Func(_) => { module.push_type(cx, ty); } + wasmparser::Type::Array(_) => todo!(), } } diff --git a/crates/wizer/src/rewrite.rs b/crates/wizer/src/rewrite.rs index efc55c6c7ef7..d992bd776ee7 100644 --- a/crates/wizer/src/rewrite.rs +++ b/crates/wizer/src/rewrite.rs @@ -64,7 +64,7 @@ impl Wizer { // For the memory section, we update the minimum size of each // defined memory to the snapshot's initialized size for that // memory. - s if s.id == SectionId::Memory.into() => { + s if s.id == u8::from(SectionId::Memory) => { let mut memories = wasm_encoder::MemorySection::new(); assert_eq!(module.defined_memories_len(cx), snapshot.memory_mins.len()); for ((_, mem), new_min) in module @@ -80,7 +80,7 @@ impl Wizer { // Encode the initialized global values from the snapshot, // rather than the original values. - s if s.id == SectionId::Global.into() => { + s if s.id == u8::from(SectionId::Global) => { let mut globals = wasm_encoder::GlobalSection::new(); for ((_, glob_ty), val) in module.defined_globals(cx).zip(snapshot.globals.iter()) @@ -104,7 +104,7 @@ impl Wizer { // Remove exports for the wizer initialization // function and WASI reactor _initialize function, // then perform any requested renames. - s if s.id == SectionId::Export.into() => { + s if s.id == u8::from(SectionId::Export) => { let mut exports = wasm_encoder::ExportSection::new(); for export in module.exports(cx) { if !self.keep_init_func.unwrap_or(DEFAULT_KEEP_INIT_FUNC) @@ -134,17 +134,17 @@ impl Wizer { } // Skip the `start` function -- it's already been run! - s if s.id == SectionId::Start.into() => { + s if s.id == u8::from(SectionId::Start) => { continue; } - s if s.id == SectionId::DataCount.into() => { + s if s.id == u8::from(SectionId::DataCount) => { encoder.section(&wasm_encoder::DataCountSection { count: u32::try_from(snapshot.data_segments.len()).unwrap(), }); } - s if s.id == SectionId::Data.into() => { + s if s.id == u8::from(SectionId::Data) => { // TODO: supporting bulk memory will require copying over // any passive and declared segments. add_data_section(&mut encoder); @@ -163,7 +163,7 @@ impl Wizer { } fn is_name_section(s: &wasm_encoder::RawSection) -> bool { - s.id == SectionId::Custom.into() && { + s.id == u8::from(SectionId::Custom) && { let mut reader = wasmparser::BinaryReader::new(s.data); matches!(reader.read_string(), Ok("name")) } From 2dc14e6b1b7b8ea924d4c4b74c16c7f08d90c23c Mon Sep 17 00:00:00 2001 From: Jake Champion Date: Fri, 26 May 2023 11:58:22 +0100 Subject: [PATCH 161/212] Bump version to 2.0.1 The changes included in 2.0.1 are: - Update wasmtime/wasm-tools dependencies ([#86](https://github.com/bytecodealliance/wizer/pull/86)) - Add prebuilt packages for aarch64-unknown-linux-gnu and s390x-unknown-linux-gnu ([#87 ](https://github.com/bytecodealliance/wizer/pull/87)) --- crates/wizer/Cargo.lock | 2 +- crates/wizer/Cargo.toml | 2 +- crates/wizer/npm/wizer/package-lock.json | 12 ++++++------ crates/wizer/npm/wizer/package.json | 10 +++++----- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/crates/wizer/Cargo.lock b/crates/wizer/Cargo.lock index 4a6569469f3b..b1297f9bb25f 100644 --- a/crates/wizer/Cargo.lock +++ b/crates/wizer/Cargo.lock @@ -2437,7 +2437,7 @@ dependencies = [ [[package]] name = "wizer" -version = "2.0.0" +version = "2.0.1" dependencies = [ "anyhow", "cap-std 0.24.4", diff --git a/crates/wizer/Cargo.toml b/crates/wizer/Cargo.toml index 647160237384..f4b63948691b 100644 --- a/crates/wizer/Cargo.toml +++ b/crates/wizer/Cargo.toml @@ -10,7 +10,7 @@ license = "Apache-2.0 WITH LLVM-exception" name = "wizer" readme = "./README.md" repository = "https://github.com/bytecodealliance/wizer" -version = "2.0.0" +version = "2.0.1" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/crates/wizer/npm/wizer/package-lock.json b/crates/wizer/npm/wizer/package-lock.json index 43ae84be7d74..09bea84aecf8 100644 --- a/crates/wizer/npm/wizer/package-lock.json +++ b/crates/wizer/npm/wizer/package-lock.json @@ -1,12 +1,12 @@ { "name": "@bytecodealliance/wizer", - "version": "1.6.1-beta.4", + "version": "2.0.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@bytecodealliance/wizer", - "version": "1.6.1-beta.4", + "version": "2.0.1", "license": "Apache-2.0", "bin": { "wizer": "wizer.js" @@ -21,10 +21,10 @@ "node": ">=16" }, "optionalDependencies": { - "@bytecodealliance/wizer-darwin-arm64": "1.6.1-beta.4", - "@bytecodealliance/wizer-darwin-x64": "1.6.1-beta.4", - "@bytecodealliance/wizer-linux-x64": "1.6.1-beta.4", - "@bytecodealliance/wizer-win32-x64": "1.6.1-beta.4" + "@bytecodealliance/wizer-darwin-arm64": "2.0.1", + "@bytecodealliance/wizer-darwin-x64": "2.0.1", + "@bytecodealliance/wizer-linux-x64": "2.0.1", + "@bytecodealliance/wizer-win32-x64": "2.0.1" } }, "node_modules/base64-js": { diff --git a/crates/wizer/npm/wizer/package.json b/crates/wizer/npm/wizer/package.json index 0180b799f793..cc80063a66eb 100644 --- a/crates/wizer/npm/wizer/package.json +++ b/crates/wizer/npm/wizer/package.json @@ -1,6 +1,6 @@ { "name": "@bytecodealliance/wizer", - "version": "1.6.1-beta.4", + "version": "2.0.1", "description": "The WebAssembly Pre-Initializer", "type": "module", "scripts": { @@ -20,10 +20,10 @@ "wizer": "./wizer.js" }, "optionalDependencies": { - "@bytecodealliance/wizer-darwin-arm64": "1.6.1-beta.4", - "@bytecodealliance/wizer-darwin-x64": "1.6.1-beta.4", - "@bytecodealliance/wizer-linux-x64": "1.6.1-beta.4", - "@bytecodealliance/wizer-win32-x64": "1.6.1-beta.4" + "@bytecodealliance/wizer-darwin-arm64": "2.0.1", + "@bytecodealliance/wizer-darwin-x64": "2.0.1", + "@bytecodealliance/wizer-linux-x64": "2.0.1", + "@bytecodealliance/wizer-win32-x64": "2.0.1" }, "license": "Apache-2.0", "repository": { From 5f12b41e62d204e7199aace738269b3063a8a88f Mon Sep 17 00:00:00 2001 From: Jake Champion Date: Fri, 26 May 2023 20:52:24 +0100 Subject: [PATCH 162/212] Apply suggestions from code review --- crates/wizer/Cargo.lock | 2 +- crates/wizer/Cargo.toml | 2 +- crates/wizer/npm/wizer/package-lock.json | 12 ++++++------ crates/wizer/npm/wizer/package.json | 10 +++++----- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/crates/wizer/Cargo.lock b/crates/wizer/Cargo.lock index b1297f9bb25f..5d0bee64d7e8 100644 --- a/crates/wizer/Cargo.lock +++ b/crates/wizer/Cargo.lock @@ -2437,7 +2437,7 @@ dependencies = [ [[package]] name = "wizer" -version = "2.0.1" +version = "3.0.0" dependencies = [ "anyhow", "cap-std 0.24.4", diff --git a/crates/wizer/Cargo.toml b/crates/wizer/Cargo.toml index f4b63948691b..efe0a1894e95 100644 --- a/crates/wizer/Cargo.toml +++ b/crates/wizer/Cargo.toml @@ -10,7 +10,7 @@ license = "Apache-2.0 WITH LLVM-exception" name = "wizer" readme = "./README.md" repository = "https://github.com/bytecodealliance/wizer" -version = "2.0.1" +version = "3.0.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/crates/wizer/npm/wizer/package-lock.json b/crates/wizer/npm/wizer/package-lock.json index 09bea84aecf8..b150a09a84d6 100644 --- a/crates/wizer/npm/wizer/package-lock.json +++ b/crates/wizer/npm/wizer/package-lock.json @@ -1,12 +1,12 @@ { "name": "@bytecodealliance/wizer", - "version": "2.0.1", + "version": "3.0.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@bytecodealliance/wizer", - "version": "2.0.1", + "version": "3.0.0", "license": "Apache-2.0", "bin": { "wizer": "wizer.js" @@ -21,10 +21,10 @@ "node": ">=16" }, "optionalDependencies": { - "@bytecodealliance/wizer-darwin-arm64": "2.0.1", - "@bytecodealliance/wizer-darwin-x64": "2.0.1", - "@bytecodealliance/wizer-linux-x64": "2.0.1", - "@bytecodealliance/wizer-win32-x64": "2.0.1" + "@bytecodealliance/wizer-darwin-arm64": "3.0.0", + "@bytecodealliance/wizer-darwin-x64": "3.0.0", + "@bytecodealliance/wizer-linux-x64": "3.0.0", + "@bytecodealliance/wizer-win32-x64": "3.0.0" } }, "node_modules/base64-js": { diff --git a/crates/wizer/npm/wizer/package.json b/crates/wizer/npm/wizer/package.json index cc80063a66eb..0c710780038d 100644 --- a/crates/wizer/npm/wizer/package.json +++ b/crates/wizer/npm/wizer/package.json @@ -1,6 +1,6 @@ { "name": "@bytecodealliance/wizer", - "version": "2.0.1", + "version": "3.0.0", "description": "The WebAssembly Pre-Initializer", "type": "module", "scripts": { @@ -20,10 +20,10 @@ "wizer": "./wizer.js" }, "optionalDependencies": { - "@bytecodealliance/wizer-darwin-arm64": "2.0.1", - "@bytecodealliance/wizer-darwin-x64": "2.0.1", - "@bytecodealliance/wizer-linux-x64": "2.0.1", - "@bytecodealliance/wizer-win32-x64": "2.0.1" + "@bytecodealliance/wizer-darwin-arm64": "3.0.0", + "@bytecodealliance/wizer-darwin-x64": "3.0.0", + "@bytecodealliance/wizer-linux-x64": "3.0.0", + "@bytecodealliance/wizer-win32-x64": "3.0.0" }, "license": "Apache-2.0", "repository": { From a55ccb80f5b13f6e8e670014d52ab2347a60f395 Mon Sep 17 00:00:00 2001 From: Jake Champion Date: Fri, 26 May 2023 20:53:44 +0100 Subject: [PATCH 163/212] Apply suggestions from code review --- crates/wizer/npm/wizer/package.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/wizer/npm/wizer/package.json b/crates/wizer/npm/wizer/package.json index 0c710780038d..d125c2819aa1 100644 --- a/crates/wizer/npm/wizer/package.json +++ b/crates/wizer/npm/wizer/package.json @@ -23,6 +23,8 @@ "@bytecodealliance/wizer-darwin-arm64": "3.0.0", "@bytecodealliance/wizer-darwin-x64": "3.0.0", "@bytecodealliance/wizer-linux-x64": "3.0.0", + "@bytecodealliance/wizer-linux-arm64": "3.0.0", + "@bytecodealliance/wizer-linux-s390x": "3.0.0", "@bytecodealliance/wizer-win32-x64": "3.0.0" }, "license": "Apache-2.0", From 013a5efbcfc2ab89dcd6552aa39ac240737811b1 Mon Sep 17 00:00:00 2001 From: Jake Champion Date: Fri, 26 May 2023 21:09:19 +0100 Subject: [PATCH 164/212] Update update.js --- crates/wizer/npm/wizer/update.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/crates/wizer/npm/wizer/update.js b/crates/wizer/npm/wizer/update.js index 2ea31936f5c8..451b03970bbe 100644 --- a/crates/wizer/npm/wizer/update.js +++ b/crates/wizer/npm/wizer/update.js @@ -33,6 +33,20 @@ let packages = { os: 'linux', cpu: 'x64', }, + 'wizer-linux-arm64': { + releaseAsset: `wizer-${tag}-arm64-linux.tar.xz`, + binaryAsset: 'wizer', + description : 'The Linux 64-bit binary for Wizer, the WebAssembly Pre-Initializer', + os: 'linux', + cpu: 'arm64', + }, + 'wizer-linux-s390x': { + releaseAsset: `wizer-${tag}-s390x-linux.tar.xz`, + binaryAsset: 'wizer', + description: 'The Linux S390X binary for Wizer, the WebAssembly Pre-Initializer', + os: 'linux', + cpu: 's390x', + }, 'wizer-win32-x64': { releaseAsset: `wizer-${tag}-x86_64-windows.zip`, binaryAsset: 'wizer.exe', From 0b99f4b0162550d4fd5337ad4262308991daab7c Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Sun, 28 May 2023 20:02:06 +0000 Subject: [PATCH 165/212] Un-export `_initialize` even with keep-init because calling `_initialize` multiple times is undefined behavior and recent wasi-libc explicitly rejects it: https://github.com/WebAssembly/wasi-libc/commit/9bec2d3aff198770e98544cb6f13add60e1f5fe6 --- crates/wizer/src/rewrite.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/wizer/src/rewrite.rs b/crates/wizer/src/rewrite.rs index d992bd776ee7..f87b48539786 100644 --- a/crates/wizer/src/rewrite.rs +++ b/crates/wizer/src/rewrite.rs @@ -107,9 +107,9 @@ impl Wizer { s if s.id == u8::from(SectionId::Export) => { let mut exports = wasm_encoder::ExportSection::new(); for export in module.exports(cx) { - if !self.keep_init_func.unwrap_or(DEFAULT_KEEP_INIT_FUNC) - && (export.name == self.init_func - || (has_wasi_initialize && export.name == "_initialize")) + if (export.name == self.init_func + && !self.keep_init_func.unwrap_or(DEFAULT_KEEP_INIT_FUNC)) + || (has_wasi_initialize && export.name == "_initialize") { continue; } From 3dc5837192d51d46cfa27434affeef81ff81fd53 Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Sun, 28 May 2023 20:14:56 +0000 Subject: [PATCH 166/212] Add test for reactor with `--keep-init-func=true` --- crates/wizer/tests/tests.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/crates/wizer/tests/tests.rs b/crates/wizer/tests/tests.rs index 5f598170878d..cb776265c030 100644 --- a/crates/wizer/tests/tests.rs +++ b/crates/wizer/tests/tests.rs @@ -524,6 +524,31 @@ fn wasi_reactor_initializer_as_init_func() -> anyhow::Result<()> { wizen_and_run_wasm(&[], 1, &wasm, wizer) } +#[test] +fn wasi_reactor_initializer_with_keep_init() -> anyhow::Result<()> { + let wat = r#" + (module + (global $g (mut i32) i32.const 0) + (func (export "_initialize") + i32.const 1 + global.set $g + ) + (func (export "wizer.initialize") + i32.const 2 + global.set $g) + (func (export "run") (result i32) + global.get $g + ) + )"#; + + let _ = env_logger::try_init(); + let mut wizer = Wizer::new(); + wizer.keep_init_func(true); + let wasm = wat_to_wasm(wat)?; + // we expect `_initialize` to be un-exported and not called at run + wizen_and_run_wasm(&[], 2, &wasm, wizer) +} + #[test] fn call_undefined_import_function_during_init() -> Result<()> { fails_wizening( From 8ff7765693b754b401c25e164229f38c5777c11b Mon Sep 17 00:00:00 2001 From: Jake Champion Date: Wed, 31 May 2023 10:42:59 +0100 Subject: [PATCH 167/212] correct the release asset location for 'wizer-linux-arm64' The filename contains aarch64 and not arm64 --- crates/wizer/npm/wizer/update.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/wizer/npm/wizer/update.js b/crates/wizer/npm/wizer/update.js index 451b03970bbe..60652496eb4c 100644 --- a/crates/wizer/npm/wizer/update.js +++ b/crates/wizer/npm/wizer/update.js @@ -34,7 +34,7 @@ let packages = { cpu: 'x64', }, 'wizer-linux-arm64': { - releaseAsset: `wizer-${tag}-arm64-linux.tar.xz`, + releaseAsset: `wizer-${tag}-aarch64-linux.tar.xz`, binaryAsset: 'wizer', description : 'The Linux 64-bit binary for Wizer, the WebAssembly Pre-Initializer', os: 'linux', From 38deac63054332253bc1fc3a2f48a83235c1c689 Mon Sep 17 00:00:00 2001 From: Jake Champion Date: Wed, 31 May 2023 10:44:06 +0100 Subject: [PATCH 168/212] use the same knownPackage definition to avoid drift between the two places which use the definion --- crates/wizer/npm/wizer/index.js | 19 +------------------ crates/wizer/npm/wizer/package-helpers.js | 19 +++++++++++++++++++ crates/wizer/npm/wizer/wizer.js | 19 +------------------ 3 files changed, 21 insertions(+), 36 deletions(-) create mode 100644 crates/wizer/npm/wizer/package-helpers.js diff --git a/crates/wizer/npm/wizer/index.js b/crates/wizer/npm/wizer/index.js index 65917efe93f2..c7c3e9065116 100644 --- a/crates/wizer/npm/wizer/index.js +++ b/crates/wizer/npm/wizer/index.js @@ -1,21 +1,4 @@ -import { endianness } from "node:os"; -import { platform, arch } from "node:process"; - -const knownPackages = { - "win32 x64 LE": "@bytecodealliance/wizer-win32-x64", - "darwin arm64 LE": "@bytecodealliance/wizer-darwin-arm64", - "darwin x64 LE": "@bytecodealliance/wizer-darwin-x64", - "linux x64 LE": "@bytecodealliance/wizer-linux-x64", -}; - -function pkgForCurrentPlatform() { - let platformKey = `${platform} ${arch} ${endianness()}`; - - if (platformKey in knownPackages) { - return knownPackages[platformKey]; - } - throw new Error(`Unsupported platform: "${platformKey}". "@bytecodealliance/wizer does not have a precompiled binary for the platform/architecture you are using. You can open an issue on https://github.com/bytecodealliance/wizer/issues to request for your platform/architecture to be included."`); -} +import { pkgForCurrentPlatform } from "./package-helpers.js"; const pkg = pkgForCurrentPlatform(); diff --git a/crates/wizer/npm/wizer/package-helpers.js b/crates/wizer/npm/wizer/package-helpers.js new file mode 100644 index 000000000000..72d85aa605b0 --- /dev/null +++ b/crates/wizer/npm/wizer/package-helpers.js @@ -0,0 +1,19 @@ +import { endianness } from "node:os"; +import { platform, arch } from "node:process"; + +const knownPackages = { + "win32 x64 LE": "@bytecodealliance/wizer-win32-x64", + "darwin arm64 LE": "@bytecodealliance/wizer-darwin-arm64", + "darwin x64 LE": "@bytecodealliance/wizer-darwin-x64", + "linux arm64 LE": "@bytecodealliance/wizer-linux-arm64", + "linux s390x BE": "@bytecodealliance/wizer-linux-s390x", + "linux x64 LE": "@bytecodealliance/wizer-linux-x64", +}; + +export function pkgForCurrentPlatform() { + let platformKey = `${platform} ${arch} ${endianness()}`; + if (platformKey in knownPackages) { + return knownPackages[platformKey]; + } + throw new Error(`Unsupported platform: "${platformKey}". "@bytecodealliance/wizer does not have a precompiled binary for the platform/architecture you are using. You can open an issue on https://github.com/bytecodealliance/wizer/issues to request for your platform/architecture to be included."`); +} diff --git a/crates/wizer/npm/wizer/wizer.js b/crates/wizer/npm/wizer/wizer.js index 77ac533b690c..72cbb0479650 100755 --- a/crates/wizer/npm/wizer/wizer.js +++ b/crates/wizer/npm/wizer/wizer.js @@ -1,24 +1,7 @@ #!/usr/bin/env node -import { endianness } from "node:os"; -import { platform, arch } from "node:process"; import { execFileSync } from "node:child_process"; -const knownPackages = { - "win32 x64 LE": "@bytecodealliance/wizer-win32-x64", - "darwin arm64 LE": "@bytecodealliance/wizer-darwin-arm64", - "darwin x64 LE": "@bytecodealliance/wizer-darwin-x64", - "linux arm64 LE": "@bytecodealliance/wizer-linux-arm64", - "linux x64 LE": "@bytecodealliance/wizer-linux-x64", - "linux s390x BE": "@bytecodealliance/wizer-linux-s390x", -}; -function pkgForCurrentPlatform() { - let platformKey = `${platform} ${arch} ${endianness()}`; - - if (platformKey in knownPackages) { - return knownPackages[platformKey]; - } - throw new Error(`Unsupported platform: "${platformKey}". "@bytecodealliance/wizer does not have a precompiled binary for the platform/architecture you are using. You can open an issue on https://github.com/bytecodealliance/wizer/issues to request for your platform/architecture to be included."`); -} +import { pkgForCurrentPlatform } from "./package-helpers.js"; const pkg = pkgForCurrentPlatform(); From 06015fd31bca66fc10fdfd24daad3b48bfb9894d Mon Sep 17 00:00:00 2001 From: Jake Champion Date: Wed, 31 May 2023 17:01:58 +0100 Subject: [PATCH 169/212] create version 3.0.1 --- crates/wizer/Cargo.lock | 2 +- crates/wizer/Cargo.toml | 2 +- crates/wizer/npm/wizer/package-lock.json | 14 ++++++++------ crates/wizer/npm/wizer/package.json | 14 +++++++------- 4 files changed, 17 insertions(+), 15 deletions(-) diff --git a/crates/wizer/Cargo.lock b/crates/wizer/Cargo.lock index 5d0bee64d7e8..6bc70ce314d3 100644 --- a/crates/wizer/Cargo.lock +++ b/crates/wizer/Cargo.lock @@ -2437,7 +2437,7 @@ dependencies = [ [[package]] name = "wizer" -version = "3.0.0" +version = "3.0.1" dependencies = [ "anyhow", "cap-std 0.24.4", diff --git a/crates/wizer/Cargo.toml b/crates/wizer/Cargo.toml index efe0a1894e95..aca5519c5866 100644 --- a/crates/wizer/Cargo.toml +++ b/crates/wizer/Cargo.toml @@ -10,7 +10,7 @@ license = "Apache-2.0 WITH LLVM-exception" name = "wizer" readme = "./README.md" repository = "https://github.com/bytecodealliance/wizer" -version = "3.0.0" +version = "3.0.1" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/crates/wizer/npm/wizer/package-lock.json b/crates/wizer/npm/wizer/package-lock.json index b150a09a84d6..b8ec28e08c21 100644 --- a/crates/wizer/npm/wizer/package-lock.json +++ b/crates/wizer/npm/wizer/package-lock.json @@ -1,12 +1,12 @@ { "name": "@bytecodealliance/wizer", - "version": "3.0.0", + "version": "3.0.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@bytecodealliance/wizer", - "version": "3.0.0", + "version": "3.0.1", "license": "Apache-2.0", "bin": { "wizer": "wizer.js" @@ -21,10 +21,12 @@ "node": ">=16" }, "optionalDependencies": { - "@bytecodealliance/wizer-darwin-arm64": "3.0.0", - "@bytecodealliance/wizer-darwin-x64": "3.0.0", - "@bytecodealliance/wizer-linux-x64": "3.0.0", - "@bytecodealliance/wizer-win32-x64": "3.0.0" + "@bytecodealliance/wizer-darwin-arm64": "3.0.1", + "@bytecodealliance/wizer-darwin-x64": "3.0.1", + "@bytecodealliance/wizer-linux-arm64": "3.0.1", + "@bytecodealliance/wizer-linux-s390x": "3.0.1", + "@bytecodealliance/wizer-linux-x64": "3.0.1", + "@bytecodealliance/wizer-win32-x64": "3.0.1" } }, "node_modules/base64-js": { diff --git a/crates/wizer/npm/wizer/package.json b/crates/wizer/npm/wizer/package.json index d125c2819aa1..2bcbb289d066 100644 --- a/crates/wizer/npm/wizer/package.json +++ b/crates/wizer/npm/wizer/package.json @@ -1,6 +1,6 @@ { "name": "@bytecodealliance/wizer", - "version": "3.0.0", + "version": "3.0.1", "description": "The WebAssembly Pre-Initializer", "type": "module", "scripts": { @@ -20,12 +20,12 @@ "wizer": "./wizer.js" }, "optionalDependencies": { - "@bytecodealliance/wizer-darwin-arm64": "3.0.0", - "@bytecodealliance/wizer-darwin-x64": "3.0.0", - "@bytecodealliance/wizer-linux-x64": "3.0.0", - "@bytecodealliance/wizer-linux-arm64": "3.0.0", - "@bytecodealliance/wizer-linux-s390x": "3.0.0", - "@bytecodealliance/wizer-win32-x64": "3.0.0" + "@bytecodealliance/wizer-darwin-arm64": "3.0.1", + "@bytecodealliance/wizer-darwin-x64": "3.0.1", + "@bytecodealliance/wizer-linux-x64": "3.0.1", + "@bytecodealliance/wizer-linux-arm64": "3.0.1", + "@bytecodealliance/wizer-linux-s390x": "3.0.1", + "@bytecodealliance/wizer-win32-x64": "3.0.1" }, "license": "Apache-2.0", "repository": { From 0c4fce02ed903c6e93935cd6ccd9ced287eecb1e Mon Sep 17 00:00:00 2001 From: "Jiaxiao Zhou (Mossaka)" Date: Sat, 15 Jul 2023 10:49:14 -0700 Subject: [PATCH 170/212] chore: bump deps and especially wasmtime to 10.0 Signed-off-by: Jiaxiao Zhou (Mossaka) --- crates/wizer/Cargo.lock | 599 ++++++++++++++++++++++++---------------- crates/wizer/Cargo.toml | 20 +- 2 files changed, 374 insertions(+), 245 deletions(-) diff --git a/crates/wizer/Cargo.lock b/crates/wizer/Cargo.lock index 6bc70ce314d3..fe8b5f944d45 100644 --- a/crates/wizer/Cargo.lock +++ b/crates/wizer/Cargo.lock @@ -33,15 +33,15 @@ dependencies = [ [[package]] name = "ambient-authority" -version = "0.0.1" +version = "0.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec8ad6edb4840b78c5c3d88de606b22252d552b55f3a4699fbb10fc070ec3049" +checksum = "e9d4ee0d472d1cd2e28c97dfa124b3d8d992e10eb0a035f33f5d12e3a177ba3b" [[package]] -name = "ambient-authority" -version = "0.0.2" +name = "anes" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9d4ee0d472d1cd2e28c97dfa124b3d8d992e10eb0a035f33f5d12e3a177ba3b" +checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" [[package]] name = "ansi_term" @@ -52,6 +52,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "anstyle" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a30da5c5f2d5e72842e00bcb57657162cdabef0931f40e2deb9b4140440cecd" + [[package]] name = "anyhow" version = "1.0.70" @@ -118,9 +124,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.3.1" +version = "2.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6776fc96284a0bb647b615056fc496d1fe1644a7ab01829818a6d91cae888b84" +checksum = "630be753d4e58660abd17930c71b647fe46c27ea6b63cc59e1e3851406972e42" [[package]] name = "block-buffer" @@ -155,32 +161,13 @@ dependencies = [ "windows-sys", ] -[[package]] -name = "cap-primitives" -version = "0.24.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb8fca3e81fae1d91a36e9784ca22a39ef623702b5f7904d89dc31f10184a178" -dependencies = [ - "ambient-authority 0.0.1", - "errno 0.2.8", - "fs-set-times 0.15.0", - "io-extras 0.13.2", - "io-lifetimes 0.5.3", - "ipnet", - "maybe-owned", - "rustix 0.33.7", - "winapi", - "winapi-util", - "winx 0.31.0", -] - [[package]] name = "cap-primitives" version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42068f579028e856717d61423645c85d2d216dde8eff62c9b30140e725c79177" dependencies = [ - "ambient-authority 0.0.2", + "ambient-authority", "fs-set-times 0.19.1", "io-extras 0.17.4", "io-lifetimes 1.0.10", @@ -192,26 +179,30 @@ dependencies = [ ] [[package]] -name = "cap-rand" -version = "1.0.14" +name = "cap-primitives" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3be2ededc13f42a5921c08e565b854cb5ff9b88753e2c6ec12c58a24e7e8d4e" +checksum = "2bf30c373a3bee22c292b1b6a7a26736a38376840f1af3d2d806455edf8c3899" dependencies = [ - "ambient-authority 0.0.2", - "rand", + "ambient-authority", + "fs-set-times 0.20.0", + "io-extras 0.18.0", + "io-lifetimes 2.0.2", + "ipnet", + "maybe-owned", + "rustix 0.38.4", + "windows-sys", + "winx 0.36.1", ] [[package]] -name = "cap-std" -version = "0.24.4" +name = "cap-rand" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2247568946095c7765ad2b441a56caffc08027734c634a6d5edda648f04e32eb" +checksum = "d3be2ededc13f42a5921c08e565b854cb5ff9b88753e2c6ec12c58a24e7e8d4e" dependencies = [ - "cap-primitives 0.24.4", - "io-extras 0.13.2", - "io-lifetimes 0.5.3", - "ipnet", - "rustix 0.33.7", + "ambient-authority", + "rand", ] [[package]] @@ -226,6 +217,18 @@ dependencies = [ "rustix 0.37.14", ] +[[package]] +name = "cap-std" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84bade423fa6403efeebeafe568fdb230e8c590a275fba2ba978dd112efcf6e9" +dependencies = [ + "cap-primitives 2.0.0", + "io-extras 0.18.0", + "io-lifetimes 2.0.2", + "rustix 0.38.4", +] + [[package]] name = "cap-time-ext" version = "1.0.14" @@ -259,6 +262,33 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "ciborium" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "effd91f6c78e5a4ace8a5d3c0b6bfaec9e2baaef55f3efc00e45fb2e477ee926" +dependencies = [ + "ciborium-io", + "ciborium-ll", + "serde", +] + +[[package]] +name = "ciborium-io" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdf919175532b369853f5d5e20b26b43112613fd6fe7aee757e35f7a44642656" + +[[package]] +name = "ciborium-ll" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "defaa24ecc093c77630e6c15e17c51f5e187bf35ee514f4e2d67baaa96dae22b" +dependencies = [ + "ciborium-io", + "half", +] + [[package]] name = "clap" version = "2.34.0" @@ -274,6 +304,31 @@ dependencies = [ "vec_map", ] +[[package]] +name = "clap" +version = "4.3.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3eab9e8ceb9afdade1ab3f0fd8dbce5b1b2f468ad653baf10e771781b2b67b73" +dependencies = [ + "clap_builder", +] + +[[package]] +name = "clap_builder" +version = "4.3.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f2763db829349bf00cfc06251268865ed4363b93a943174f638daf3ecdba2cd" +dependencies = [ + "anstyle", + "clap_lex", +] + +[[package]] +name = "clap_lex" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2da6da31387c7e4ef160ffab6d5e7f00c42626fe39aea70a7b0f1773f7dd6c1b" + [[package]] name = "cpp_demangle" version = "0.3.5" @@ -294,18 +349,18 @@ dependencies = [ [[package]] name = "cranelift-bforest" -version = "0.96.1" +version = "0.97.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b6160c0a96253993b79fb7e0983534a4515ecf666120ddf8f92068114997ebc" +checksum = "5c289b8eac3a97329a524e953b5fd68a8416ca629e1a37287f12d9e0760aadbc" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-codegen" -version = "0.96.1" +version = "0.97.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b38da5f63562e42f3c929d7c76871098e5ad12c8ab44b0659ffc529f22a5b3a" +checksum = "7bf07ba80f53fa7f7dc97b11087ea867f7ae4621cfca21a909eca92c0b96c7d9" dependencies = [ "bumpalo", "cranelift-bforest", @@ -324,42 +379,42 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.96.1" +version = "0.97.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "011371e213e163b55dd9e8404b3f2d9fa52cd14dc2f3dc5b83e61ffceff126db" +checksum = "40a7ca088173130c5c033e944756e3e441fbf3f637f32b4f6eb70252580c6dd4" dependencies = [ "cranelift-codegen-shared", ] [[package]] name = "cranelift-codegen-shared" -version = "0.96.1" +version = "0.97.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bf97dde7f5ad571161cdd203a2c9c88682ef669830aea3c14ea5d164ef8bb43" +checksum = "0114095ec7d2fbd658ed100bd007006360bc2530f57c6eee3d3838869140dbf9" [[package]] name = "cranelift-control" -version = "0.96.1" +version = "0.97.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd9a9254aee733b0f2b68e5eaaf0337ad53cb23252a056c10a35370551be8d40" +checksum = "1d56031683a55a949977e756d21826eb17a1f346143a1badc0e120a15615cd38" dependencies = [ "arbitrary", ] [[package]] name = "cranelift-entity" -version = "0.96.1" +version = "0.97.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf39a33ee39479d1337cd9333f3c09786c5a0ca1ec509edcaf9d1346d5de0e5" +checksum = "d6565198b5684367371e2b946ceca721eb36965e75e3592fad12fc2e15f65d7b" dependencies = [ "serde", ] [[package]] name = "cranelift-frontend" -version = "0.96.1" +version = "0.97.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65e260b92a193a0a2dccc3938f133d9532e7dcfe8d03e36bf8b7d3518c1c1793" +checksum = "25f28cc44847c8b98cb921e6bfc0f7b228f4d27519376fea724d181da91709a6" dependencies = [ "cranelift-codegen", "log", @@ -369,15 +424,15 @@ dependencies = [ [[package]] name = "cranelift-isle" -version = "0.96.1" +version = "0.97.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9446c8e1aadfcdacee1a49592bc2c25d1d9bf5484782c163e7f5485c92cd3c1c" +checksum = "80b658177e72178c438f7de5d6645c56d97af38e17fcb0b500459007b4e05cc5" [[package]] name = "cranelift-native" -version = "0.96.1" +version = "0.97.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eac916f3c5aff4b817e42fc2e682292b931495b3fe2603d5e3c3cf602d74e344" +checksum = "bf1c7de7221e6afcc5e13ced3b218faab3bc65b47eac67400046a05418aecd6a" dependencies = [ "cranelift-codegen", "libc", @@ -386,9 +441,9 @@ dependencies = [ [[package]] name = "cranelift-wasm" -version = "0.96.1" +version = "0.97.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00bac57700cdb5c37996164d12f9fe62997d9d1762b38b6ba88f5e82538a9cbc" +checksum = "76b0d28ebe8edb6b503630c489aa4669f1e2d13b97bec7271a0fcb0e159be3ad" dependencies = [ "cranelift-codegen", "cranelift-entity", @@ -396,7 +451,7 @@ dependencies = [ "itertools", "log", "smallvec", - "wasmparser 0.103.0", + "wasmparser 0.107.0", "wasmtime-types", ] @@ -411,24 +466,24 @@ dependencies = [ [[package]] name = "criterion" -version = "0.3.6" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b01d6de93b2b6c65e17c634a26653a29d107b3c98c607c765bf38d041531cd8f" +checksum = "f2b12d017a929603d80db1831cd3a24082f8137ce19c69e6447f54f5fc8d692f" dependencies = [ - "atty", + "anes", "cast", - "clap", + "ciborium", + "clap 4.3.12", "criterion-plot", - "csv", + "is-terminal", "itertools", - "lazy_static", "num-traits", + "once_cell", "oorandom", "plotters", "rayon", "regex", "serde", - "serde_cbor", "serde_derive", "serde_json", "tinytemplate", @@ -437,9 +492,9 @@ dependencies = [ [[package]] name = "criterion-plot" -version = "0.4.5" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2673cc8207403546f45f5fd319a974b1e6983ad1a3ee7e6041650013be041876" +checksum = "6b50826342786a51a89e2da3a28f1c32b06e387201bc2d19791f622c673706b1" dependencies = [ "cast", "itertools", @@ -498,27 +553,6 @@ dependencies = [ "typenum", ] -[[package]] -name = "csv" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b015497079b9a9d69c02ad25de6c0a6edef051ea6360a327d0bd05802ef64ad" -dependencies = [ - "csv-core", - "itoa", - "ryu", - "serde", -] - -[[package]] -name = "csv-core" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b2466559f260f48ad25fe6317b3c8dac77b5bdb5763ac7d9d6103530663bc90" -dependencies = [ - "memchr", -] - [[package]] name = "debugid" version = "0.8.0" @@ -596,6 +630,15 @@ version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" +[[package]] +name = "encoding_rs" +version = "0.8.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071a31f4ee85403370b58aca746f01041ede6f0da2730960ad001edc2b71b394" +dependencies = [ + "cfg-if", +] + [[package]] name = "env_logger" version = "0.8.4" @@ -623,15 +666,10 @@ dependencies = [ ] [[package]] -name = "errno" -version = "0.2.8" +name = "equivalent" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1" -dependencies = [ - "errno-dragonfly", - "libc", - "winapi", -] +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" @@ -673,9 +711,9 @@ dependencies = [ [[package]] name = "file-per-thread-logger" -version = "0.1.6" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84f2e425d9790201ba4af4630191feac6dcc98765b118d4d18e91d23c2353866" +checksum = "8a3cc21c33af89af0930c8cae4ade5e6fdc17b5d2c97b3d2e2edb67a1cf683f3" dependencies = [ "env_logger 0.10.0", "log", @@ -692,23 +730,23 @@ dependencies = [ [[package]] name = "fs-set-times" -version = "0.15.0" +version = "0.19.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7df62ee66ee2d532ea8d567b5a3f0d03ecd64636b98bad5be1e93dcc918b92aa" +checksum = "7833d0f115a013d51c55950a3b09d30e4b057be9961b709acb9b5b17a1108861" dependencies = [ - "io-lifetimes 0.5.3", - "rustix 0.33.7", - "winapi", + "io-lifetimes 1.0.10", + "rustix 0.37.14", + "windows-sys", ] [[package]] name = "fs-set-times" -version = "0.19.1" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7833d0f115a013d51c55950a3b09d30e4b057be9961b709acb9b5b17a1108861" +checksum = "dd738b84894214045e8414eaded76359b4a5773f0a0a56b16575110739cdcf39" dependencies = [ - "io-lifetimes 1.0.10", - "rustix 0.37.14", + "io-lifetimes 2.0.2", + "rustix 0.38.4", "windows-sys", ] @@ -727,7 +765,7 @@ version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "27d12c0aed7f1e24276a241aadc4cb8ea9f83000f34bc062b7cc2d51e3b0fabd" dependencies = [ - "bitflags 2.3.1", + "bitflags 2.3.3", "debugid", "fxhash", "serde", @@ -762,7 +800,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ad0a93d233ebf96623465aad4046a8d3aa4da22d4f4beba5388838c8a434bbb4" dependencies = [ "fallible-iterator", - "indexmap", + "indexmap 1.9.3", "stable_deref_trait", ] @@ -787,6 +825,12 @@ dependencies = [ "ahash", ] +[[package]] +name = "hashbrown" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a" + [[package]] name = "heck" version = "0.3.3" @@ -860,13 +904,13 @@ dependencies = [ ] [[package]] -name = "io-extras" -version = "0.13.2" +name = "indexmap" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0c937cc9891c12eaa8c63ad347e4a288364b1328b924886970b47a14ab8f8f8" +checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d" dependencies = [ - "io-lifetimes 0.5.3", - "winapi", + "equivalent", + "hashbrown 0.14.0", ] [[package]] @@ -880,10 +924,14 @@ dependencies = [ ] [[package]] -name = "io-lifetimes" -version = "0.5.3" +name = "io-extras" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec58677acfea8a15352d42fc87d11d63596ade9239e0a7c9352914417515dbe6" +checksum = "9d3c230ee517ee76b1cc593b52939ff68deda3fae9e41eca426c6b4993df51c4" +dependencies = [ + "io-lifetimes 2.0.2", + "windows-sys", +] [[package]] name = "io-lifetimes" @@ -896,6 +944,12 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "io-lifetimes" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bffb4def18c48926ccac55c1223e02865ce1a821751a95920448662696e7472c" + [[package]] name = "ipnet" version = "2.7.2" @@ -981,9 +1035,9 @@ checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" [[package]] name = "libc" -version = "0.2.142" +version = "0.2.147" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a987beff54b60ffa6d51982e1aa1146bc42f19bd26be28b0586f252fccf5317" +checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" [[package]] name = "libfuzzer-sys" @@ -1004,15 +1058,15 @@ checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" [[package]] name = "linux-raw-sys" -version = "0.0.42" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5284f00d480e1c39af34e72f8ad60b94f47007e3481cd3b731c1d67190ddc7b7" +checksum = "36eb31c1778188ae1e64398743890d0877fef36d11521ac60406b42016e8c2cf" [[package]] name = "linux-raw-sys" -version = "0.3.4" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36eb31c1778188ae1e64398743890d0877fef36d11521ac60406b42016e8c2cf" +checksum = "09fc20d2ca12cb9f044c93e3bd6d32d523e6e2ec3db4f7b2939cd99026ecd3f0" [[package]] name = "log" @@ -1089,7 +1143,7 @@ checksum = "ea86265d3d3dcb6a27fc51bd29a4bf387fae9d2986b823079d4986af253eb439" dependencies = [ "crc32fast", "hashbrown 0.13.2", - "indexmap", + "indexmap 1.9.3", "memchr", ] @@ -1299,9 +1353,9 @@ dependencies = [ [[package]] name = "regalloc2" -version = "0.8.1" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4a52e724646c6c0800fc456ec43b4165d2f91fba88ceaca06d9e0b400023478" +checksum = "5b4dcbd3a2ae7fb94b5813fa0e957c6ab51bf5d0a8ee1b69e0c2d0f1e6eb8485" dependencies = [ "hashbrown 0.13.2", "log", @@ -1355,32 +1409,31 @@ checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" [[package]] name = "rustix" -version = "0.33.7" +version = "0.37.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "938a344304321a9da4973b9ff4f9f8db9caf4597dfd9dda6a60b523340a0fff0" +checksum = "d9b864d3c18a5785a05953adeed93e2dca37ed30f18e69bba9f30079d51f363f" dependencies = [ "bitflags 1.3.2", - "errno 0.2.8", - "io-lifetimes 0.5.3", + "errno", + "io-lifetimes 1.0.10", "itoa", "libc", - "linux-raw-sys 0.0.42", + "linux-raw-sys 0.3.4", "once_cell", - "winapi", + "windows-sys", ] [[package]] name = "rustix" -version = "0.37.14" +version = "0.38.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b864d3c18a5785a05953adeed93e2dca37ed30f18e69bba9f30079d51f363f" +checksum = "0a962918ea88d644592894bc6dc55acc6c0956488adcebbfb6e273506b7fd6e5" dependencies = [ - "bitflags 1.3.2", - "errno 0.3.1", - "io-lifetimes 1.0.10", + "bitflags 2.3.3", + "errno", "itoa", "libc", - "linux-raw-sys 0.3.4", + "linux-raw-sys 0.4.3", "once_cell", "windows-sys", ] @@ -1406,6 +1459,12 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" +[[package]] +name = "semver" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bebd363326d05ec3e2f532ab7660680f3b02130d780c299bca73469d521bc0ed" + [[package]] name = "serde" version = "1.0.160" @@ -1415,16 +1474,6 @@ dependencies = [ "serde_derive", ] -[[package]] -name = "serde_cbor" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bef2ebfde456fb76bbcf9f59315333decc4fda0b2b44b420243c11e0f5ec1f5" -dependencies = [ - "half", - "serde", -] - [[package]] name = "serde_derive" version = "1.0.160" @@ -1453,7 +1502,7 @@ version = "0.8.26" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "578a7433b776b56a35785ed5ce9a7e777ac0598aac5a6dd1b4b18a307c7fc71b" dependencies = [ - "indexmap", + "indexmap 1.9.3", "ryu", "serde", "yaml-rust", @@ -1491,6 +1540,12 @@ version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" +[[package]] +name = "sptr" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b9b39299b249ad65f3b7e96443bad61c02ca5cd3589f46cb6d610a0fd6c0d6a" + [[package]] name = "stable_deref_trait" version = "1.2.0" @@ -1509,7 +1564,7 @@ version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c6b5c64445ba8094a6ab0c3cd2ad323e07171012d9c98b0b15651daf1787a10" dependencies = [ - "clap", + "clap 2.34.0", "lazy_static", "structopt-derive", ] @@ -1786,9 +1841,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasi-cap-std-sync" -version = "9.0.1" +version = "10.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4096c4ef7e44b1a74463464153469b87826e29309db80167a67cbdfdc16240a6" +checksum = "291862f1014dd7e674f93b263d57399de4dd1907ea37e74cf7d36454536ba2f0" dependencies = [ "anyhow", "async-trait", @@ -1810,9 +1865,9 @@ dependencies = [ [[package]] name = "wasi-common" -version = "9.0.1" +version = "10.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2ff11918dcda936b8f32ed6c73162317b2a467be1875d29b90980183acc34d1" +checksum = "3b422ae2403cae9ca603864272a402cf5001dd6fef8632e090e00c4fb475741b" dependencies = [ "anyhow", "bitflags 1.3.2", @@ -1893,9 +1948,18 @@ dependencies = [ [[package]] name = "wasm-encoder" -version = "0.28.0" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83c94f464d50e31da425794a02da1a82d4b96a657dcb152a6664e8aa915be517" +checksum = "18c41dbd92eaebf3612a39be316540b8377c871cb9bde6b064af962984912881" +dependencies = [ + "leb128", +] + +[[package]] +name = "wasm-encoder" +version = "0.30.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2f8e9778e04cbf44f58acc301372577375a666b966c50b03ef46144f80436a8" dependencies = [ "leb128", ] @@ -1907,54 +1971,65 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f7e95fdeed16adeffed44efdc7ccf27d4f57ff2e99de417c75bcee7dee09049b" dependencies = [ "arbitrary", - "indexmap", + "indexmap 1.9.3", "leb128", "wasm-encoder 0.4.1", ] [[package]] name = "wasmparser" -version = "0.103.0" +version = "0.106.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c437373cac5ea84f1113d648d51f71751ffbe3d90c00ae67618cf20d0b5ee7b" +checksum = "d014e33793cab91655fa6349b0bc974984de106b2e0f6b0dfe6f6594b260624d" dependencies = [ - "indexmap", + "indexmap 1.9.3", "url", ] [[package]] name = "wasmparser" -version = "0.106.0" +version = "0.107.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d014e33793cab91655fa6349b0bc974984de106b2e0f6b0dfe6f6594b260624d" +checksum = "29e3ac9b780c7dda0cac7a52a5d6d2d6707cc6e3451c9db209b6c758f40d7acb" dependencies = [ - "indexmap", - "url", + "indexmap 1.9.3", + "semver", +] + +[[package]] +name = "wasmparser" +version = "0.108.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76c956109dcb41436a39391139d9b6e2d0a5e0b158e1293ef352ec977e5e36c5" +dependencies = [ + "indexmap 2.0.0", + "semver", ] [[package]] name = "wasmprinter" -version = "0.2.58" +version = "0.2.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c520299a0b5999adef4f063add9689e4559b3e4eb2688dbd63cc36ebb595841" +checksum = "b76cb909fe3d9b0de58cee1f4072247e680ff5cc1558ccad2790a9de14a23993" dependencies = [ "anyhow", - "wasmparser 0.106.0", + "wasmparser 0.108.0", ] [[package]] name = "wasmtime" -version = "9.0.1" +version = "10.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24ca2e0d4e4806428980cd4439f2c4b24029da522d191f142da0135d07bb33c9" +checksum = "cd02b992d828b91efaf2a7499b21205fe4ab3002e401e3fe0f227aaeb4001d93" dependencies = [ "anyhow", "async-trait", "bincode", "bumpalo", "cfg-if", + "encoding_rs", "fxprof-processed-profile", - "indexmap", + "indexmap 1.9.3", "libc", "log", "object", @@ -1965,32 +2040,34 @@ dependencies = [ "serde", "serde_json", "target-lexicon", - "wasmparser 0.103.0", + "wasmparser 0.107.0", "wasmtime-cache", "wasmtime-component-macro", + "wasmtime-component-util", "wasmtime-cranelift", "wasmtime-environ", "wasmtime-fiber", "wasmtime-jit", "wasmtime-runtime", + "wasmtime-winch", "wat", "windows-sys", ] [[package]] name = "wasmtime-asm-macros" -version = "9.0.1" +version = "10.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac4a67ef4a478818d5234f24a9f94296edd3aa7448b0811c11cb30065f08388d" +checksum = "284466ef356ce2d909bc0ad470b60c4d0df5df2de9084457e118131b3c779b92" dependencies = [ "cfg-if", ] [[package]] name = "wasmtime-cache" -version = "9.0.1" +version = "10.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19523f9aa866ab27d1730e0ac131411e84ca64ae737f53af32a565f929a739b5" +checksum = "efc78cfe1a758d1336f447a47af6ec05e0df2c03c93440d70faf80e17fbb001e" dependencies = [ "anyhow", "base64", @@ -2008,9 +2085,9 @@ dependencies = [ [[package]] name = "wasmtime-component-macro" -version = "9.0.1" +version = "10.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc0498a91533cdbe1642275649f5a7925477749aed5a44f79f5819b9cc481b20" +checksum = "b8e916103436a6d84faa4c2083e2e98612a323c2cc6147ec419124f67c764c9c" dependencies = [ "anyhow", "proc-macro2", @@ -2023,15 +2100,15 @@ dependencies = [ [[package]] name = "wasmtime-component-util" -version = "9.0.1" +version = "10.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6abc3b9b476d57bc69fab206454f1f85d51d6b8965ff0ecb04f1ddfe94254e59" +checksum = "f20a5135ec5ef01080e674979b02d6fa5eebaa2b0c2d6660513ee9956a1bf624" [[package]] name = "wasmtime-cranelift" -version = "9.0.1" +version = "10.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0fd6fc3481ba8a71a37f5d089db62e55d738d0930bd665c1bb9afcfae6f7f61" +checksum = "8e1aa99cbf3f8edb5ad8408ba380f5ab481528ecd8a5053acf758e006d6727fd" dependencies = [ "anyhow", "cranelift-codegen", @@ -2045,16 +2122,16 @@ dependencies = [ "object", "target-lexicon", "thiserror", - "wasmparser 0.103.0", + "wasmparser 0.107.0", "wasmtime-cranelift-shared", "wasmtime-environ", ] [[package]] name = "wasmtime-cranelift-shared" -version = "9.0.1" +version = "10.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "509c8e577052bbd956200cc9e610b984140dd84842629423a854891da86eebea" +checksum = "cce31fd55978601acc103acbb8a26f81c89a6eae12d3a1c59f34151dfa609484" dependencies = [ "anyhow", "cranelift-codegen", @@ -2068,28 +2145,31 @@ dependencies = [ [[package]] name = "wasmtime-environ" -version = "9.0.1" +version = "10.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc05fad4839add17abf839656f677a4965b12639d919b5a346eb1efed5efbb18" +checksum = "41f9e58e0ee7d43ff13e75375c726b16bce022db798d3a099a65eeaa7d7a544b" dependencies = [ "anyhow", "cranelift-entity", "gimli", - "indexmap", + "indexmap 1.9.3", "log", "object", "serde", "target-lexicon", "thiserror", - "wasmparser 0.103.0", + "wasm-encoder 0.29.0", + "wasmparser 0.107.0", + "wasmprinter", + "wasmtime-component-util", "wasmtime-types", ] [[package]] name = "wasmtime-fiber" -version = "9.0.1" +version = "10.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56db2e5979096f8931f1ed0413bc06344c077edaf84afd827f1faeb779a53722" +checksum = "14309cbdf2c395258b124a24757c727403070c0465a28bcc780c4f82f4bca5ff" dependencies = [ "cc", "cfg-if", @@ -2100,9 +2180,9 @@ dependencies = [ [[package]] name = "wasmtime-jit" -version = "9.0.1" +version = "10.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "512d86bb17a864e289670515db7ad4d6aa3e2169715af607b21db0b032050d35" +checksum = "5f0f2eaeb01bb67266416507829bd8e0bb60278444e4cbd048e280833ebeaa02" dependencies = [ "addr2line", "anyhow", @@ -2114,6 +2194,7 @@ dependencies = [ "log", "object", "rustc-demangle", + "rustix 0.37.14", "serde", "target-lexicon", "wasmtime-environ", @@ -2125,9 +2206,9 @@ dependencies = [ [[package]] name = "wasmtime-jit-debug" -version = "9.0.1" +version = "10.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95b3e287fbaac91c56cb3c911219123dc4e85d4c79573e7506aedd5ae4ce06dd" +checksum = "f42e59d62542bfb73ce30672db7eaf4084a60b434b688ac4f05b287d497de082" dependencies = [ "object", "once_cell", @@ -2136,9 +2217,9 @@ dependencies = [ [[package]] name = "wasmtime-jit-icache-coherence" -version = "9.0.1" +version = "10.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d90933b781e1cef7656baed671c7a90bdba0c1c694e04fdd4124419308f5cbb" +checksum = "2b49ceb7e2105a8ebe5614d7bbab6f6ef137a284e371633af60b34925493081f" dependencies = [ "cfg-if", "libc", @@ -2147,14 +2228,15 @@ dependencies = [ [[package]] name = "wasmtime-runtime" -version = "9.0.1" +version = "10.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63b6c4bfd59e21bcd90c97f41ab721371efa720b4b007ac2840e74eb3a98a8a0" +checksum = "3a5de4762421b0b2b19e02111ca403632852b53e506e03b4b227ffb0fbfa63c2" dependencies = [ "anyhow", "cc", "cfg-if", - "indexmap", + "encoding_rs", + "indexmap 1.9.3", "libc", "log", "mach", @@ -2163,6 +2245,7 @@ dependencies = [ "paste", "rand", "rustix 0.37.14", + "sptr", "wasmtime-asm-macros", "wasmtime-environ", "wasmtime-fiber", @@ -2172,35 +2255,65 @@ dependencies = [ [[package]] name = "wasmtime-types" -version = "9.0.1" +version = "10.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cdd448786db95aa496b06e74ffe5be0780018ce8b2a9e3db6d5e117dc2e84fc" +checksum = "dcbb7c138f797192f46afdd3ec16f85ef007c3bb45fa8e5174031f17b0be4c4a" dependencies = [ "cranelift-entity", "serde", "thiserror", - "wasmparser 0.103.0", + "wasmparser 0.107.0", ] [[package]] name = "wasmtime-wasi" -version = "9.0.1" +version = "10.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cda4af8d1de5e20fa7d59d732f0722791243c08e2886b38656d5d416e9a135c2" +checksum = "01686e859249d4dffe3d7ce9957ae35bcf4161709dfafd165ee136bd54d179f1" dependencies = [ "anyhow", + "async-trait", + "bitflags 1.3.2", + "cap-fs-ext", + "cap-rand", + "cap-std 1.0.14", + "cap-time-ext", + "fs-set-times 0.19.1", + "io-extras 0.17.4", "libc", + "rustix 0.37.14", + "system-interface", + "thiserror", + "tracing", "wasi-cap-std-sync", "wasi-common", "wasmtime", "wiggle", + "windows-sys", +] + +[[package]] +name = "wasmtime-winch" +version = "10.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60160d8f7d2b301790730dac8ff25156c61d4fed79481e7074c21dd1283cfe2f" +dependencies = [ + "anyhow", + "cranelift-codegen", + "gimli", + "object", + "target-lexicon", + "wasmparser 0.107.0", + "wasmtime-cranelift-shared", + "wasmtime-environ", + "winch-codegen", ] [[package]] name = "wasmtime-wit-bindgen" -version = "9.0.1" +version = "10.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f6b41780f19535abecab0b14c31a759bcf655cea79204958fb480b1586e9002" +checksum = "d3334b0466a4d340de345cda83474d1d2c429770c3d667877971407672bc618a" dependencies = [ "anyhow", "heck 0.4.1", @@ -2218,23 +2331,23 @@ dependencies = [ [[package]] name = "wast" -version = "59.0.0" +version = "61.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38462178c91e3f990df95f12bf48abe36018e03550a58a65c53975f4e704fc35" +checksum = "dc6b347851b52fd500657d301155c79e8c67595501d179cef87b6f04ebd25ac4" dependencies = [ "leb128", "memchr", "unicode-width", - "wasm-encoder 0.28.0", + "wasm-encoder 0.30.0", ] [[package]] name = "wat" -version = "1.0.65" +version = "1.0.67" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c936a025be0417a94d6e9bf92bfdf9e06dbf63debf187b650d9c73a5add701f1" +checksum = "459e764d27c3ab7beba1ebd617cc025c7e76dea6e7c5ce3189989a970aea3491" dependencies = [ - "wast 59.0.0", + "wast 61.0.0", ] [[package]] @@ -2249,9 +2362,9 @@ dependencies = [ [[package]] name = "wiggle" -version = "9.0.1" +version = "10.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21b7f1da4335006b30072d0e859e905a905b3c6a6a58c170159ce921283563ce" +checksum = "ea93d31f59f2b2fa4196990b684771500072d385eaac12587c63db2bc185d705" dependencies = [ "anyhow", "async-trait", @@ -2264,9 +2377,9 @@ dependencies = [ [[package]] name = "wiggle-generate" -version = "9.0.1" +version = "10.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cff10f65663348b5503900777da6cc5a186902a4b9974c898abaec249f5257c" +checksum = "7df96ee6bea595fabf0346c08c553f684b08e88fad6fdb125e6efde047024f7b" dependencies = [ "anyhow", "heck 0.4.1", @@ -2279,9 +2392,9 @@ dependencies = [ [[package]] name = "wiggle-macro" -version = "9.0.1" +version = "10.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7e71b4c5994191e29d29571df0ab7b4768e0deb01dba3bbad5981fe096a4b77" +checksum = "8649011a011ecca6197c4db6ee630735062ba20595ea56ce58529b3b1c20aa2f" dependencies = [ "proc-macro2", "quote", @@ -2320,6 +2433,22 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "winch-codegen" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "525fdd0d4e82d1bd3083bd87e8ca8014abfbdc5bf290d1d5371dac440d351e89" +dependencies = [ + "anyhow", + "cranelift-codegen", + "gimli", + "regalloc2", + "smallvec", + "target-lexicon", + "wasmparser 0.107.0", + "wasmtime-environ", +] + [[package]] name = "windows-sys" version = "0.48.0" @@ -2388,37 +2517,37 @@ checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" [[package]] name = "winx" -version = "0.31.0" +version = "0.35.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08d5973cb8cd94a77d03ad7e23bbe14889cb29805da1cec0e4aff75e21aebded" +checksum = "1c52a121f0fbf9320d5f2a9a5d82f6cb7557eda5e8b47fc3e7f359ec866ae960" dependencies = [ "bitflags 1.3.2", - "io-lifetimes 0.5.3", - "winapi", + "io-lifetimes 1.0.10", + "windows-sys", ] [[package]] name = "winx" -version = "0.35.1" +version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c52a121f0fbf9320d5f2a9a5d82f6cb7557eda5e8b47fc3e7f359ec866ae960" +checksum = "4857cedf8371f690bb6782a3e2b065c54d1b6661be068aaf3eac8b45e813fdf8" dependencies = [ - "bitflags 1.3.2", - "io-lifetimes 1.0.10", + "bitflags 2.3.3", "windows-sys", ] [[package]] name = "wit-parser" -version = "0.7.1" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ca2581061573ef6d1754983d7a9b3ed5871ef859d52708ea9a0f5af32919172" +checksum = "6daec9f093dbaea0e94043eeb92ece327bbbe70c86b1f41aca9bbfefd7f050f0" dependencies = [ "anyhow", "id-arena", - "indexmap", + "indexmap 1.9.3", "log", "pulldown-cmark", + "semver", "unicode-xid", "url", ] @@ -2440,14 +2569,14 @@ name = "wizer" version = "3.0.1" dependencies = [ "anyhow", - "cap-std 0.24.4", + "cap-std 2.0.0", "criterion", - "env_logger 0.8.4", + "env_logger 0.10.0", "log", "rayon", "structopt", "wasi-cap-std-sync", - "wasm-encoder 0.28.0", + "wasm-encoder 0.30.0", "wasmparser 0.106.0", "wasmprinter", "wasmtime", diff --git a/crates/wizer/Cargo.toml b/crates/wizer/Cargo.toml index aca5519c5866..430fbb9d76ea 100644 --- a/crates/wizer/Cargo.toml +++ b/crates/wizer/Cargo.toml @@ -28,13 +28,13 @@ harness = false [dependencies] anyhow = "1.0.38" -cap-std = "0.24.2" -env_logger = { version = "0.8.2", optional = true } +cap-std = "2.0.0" +env_logger = { version = "0.10", optional = true } log = "0.4.14" rayon = "1.5.0" structopt = { version = "0.3.21", optional = true } wasi-cap-std-sync = { workspace = true } -wasm-encoder = "0.28.0" +wasm-encoder = "0.30.0" wasmparser = "0.106.0" wasmtime = { workspace = true } wasmtime-wasi = { workspace = true } @@ -46,17 +46,17 @@ workspace = true optional = true [workspace.dependencies] -wasmprinter = "0.2.58" -wasmtime = "9.0.0" -wasmtime-wasi = "9.0.0" -wasi-cap-std-sync = "9.0.0" +wasmprinter = "0.2.60" +wasmtime = "10.0" +wasmtime-wasi = "10.0" +wasi-cap-std-sync = "10.0" [dev-dependencies] -criterion = "0.3.4" -env_logger = "0.8.2" +criterion = "0.5.1" +env_logger = "0.10.0" wasmprinter = { workspace = true } -wat = "1.0.65" +wat = "1.0.67" [workspace] members = [ From c6d3926d4d9b77ce9447a331fe10165d4fd17712 Mon Sep 17 00:00:00 2001 From: Daniel Vigovszky Date: Mon, 7 Aug 2023 18:52:43 +0200 Subject: [PATCH 171/212] Updated to wasmtime 11.0.1 --- crates/wizer/Cargo.lock | 132 ++++++++++++++++++++-------------------- crates/wizer/Cargo.toml | 6 +- 2 files changed, 69 insertions(+), 69 deletions(-) diff --git a/crates/wizer/Cargo.lock b/crates/wizer/Cargo.lock index fe8b5f944d45..b01a7b867378 100644 --- a/crates/wizer/Cargo.lock +++ b/crates/wizer/Cargo.lock @@ -349,18 +349,18 @@ dependencies = [ [[package]] name = "cranelift-bforest" -version = "0.97.1" +version = "0.98.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c289b8eac3a97329a524e953b5fd68a8416ca629e1a37287f12d9e0760aadbc" +checksum = "1380172556902242d32f78ed08c98aac4f5952aef22d3684aed5c66a5db0a6fc" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-codegen" -version = "0.97.1" +version = "0.98.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7bf07ba80f53fa7f7dc97b11087ea867f7ae4621cfca21a909eca92c0b96c7d9" +checksum = "037cca234e1ad0766fdfe43b527ec14e100414b4ccf4bb614977aa9754958f57" dependencies = [ "bumpalo", "cranelift-bforest", @@ -379,42 +379,42 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.97.1" +version = "0.98.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40a7ca088173130c5c033e944756e3e441fbf3f637f32b4f6eb70252580c6dd4" +checksum = "d375e6afa8b9a304999ea8cf58424414b8e55e004571265a4f0826eba8b74f18" dependencies = [ "cranelift-codegen-shared", ] [[package]] name = "cranelift-codegen-shared" -version = "0.97.1" +version = "0.98.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0114095ec7d2fbd658ed100bd007006360bc2530f57c6eee3d3838869140dbf9" +checksum = "ca590e72ccb8da963def6e36460cce4412032b1f03c31d1a601838d305abdc39" [[package]] name = "cranelift-control" -version = "0.97.1" +version = "0.98.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d56031683a55a949977e756d21826eb17a1f346143a1badc0e120a15615cd38" +checksum = "9d2d38eea4373639f4b6236a40f69820fed16c5511093cd3783bf8491a93d9cf" dependencies = [ "arbitrary", ] [[package]] name = "cranelift-entity" -version = "0.97.1" +version = "0.98.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6565198b5684367371e2b946ceca721eb36965e75e3592fad12fc2e15f65d7b" +checksum = "5e3173c1434af23c00e4964722cf93ca8f0e6287289bf5d52110597c3ba2ea09" dependencies = [ "serde", ] [[package]] name = "cranelift-frontend" -version = "0.97.1" +version = "0.98.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25f28cc44847c8b98cb921e6bfc0f7b228f4d27519376fea724d181da91709a6" +checksum = "aec4a3a33825062eccf6eec73e852c8773220f6e4798925e19696562948beb1f" dependencies = [ "cranelift-codegen", "log", @@ -424,15 +424,15 @@ dependencies = [ [[package]] name = "cranelift-isle" -version = "0.97.1" +version = "0.98.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80b658177e72178c438f7de5d6645c56d97af38e17fcb0b500459007b4e05cc5" +checksum = "5146b5cea4b21095a021d964b0174cf6ff5530f83e8d0a822683c7559e360b66" [[package]] name = "cranelift-native" -version = "0.97.1" +version = "0.98.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf1c7de7221e6afcc5e13ced3b218faab3bc65b47eac67400046a05418aecd6a" +checksum = "21cec3717ce554d3936b2101aa8eae1a2a410bd6da0f4df698a4b008fe9cf1e9" dependencies = [ "cranelift-codegen", "libc", @@ -441,9 +441,9 @@ dependencies = [ [[package]] name = "cranelift-wasm" -version = "0.97.1" +version = "0.98.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76b0d28ebe8edb6b503630c489aa4669f1e2d13b97bec7271a0fcb0e159be3ad" +checksum = "d7fd2f9f1bf29ce6639ae2f477a2fe20bad0bd09289df13efeb890e8e4b9f807" dependencies = [ "cranelift-codegen", "cranelift-entity", @@ -1841,9 +1841,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasi-cap-std-sync" -version = "10.0.1" +version = "11.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "291862f1014dd7e674f93b263d57399de4dd1907ea37e74cf7d36454536ba2f0" +checksum = "dc0fb9a3b1143c8f549b64d707aef869d134fb681f17fb316f0d796537b670ef" dependencies = [ "anyhow", "async-trait", @@ -1865,9 +1865,9 @@ dependencies = [ [[package]] name = "wasi-common" -version = "10.0.1" +version = "11.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b422ae2403cae9ca603864272a402cf5001dd6fef8632e090e00c4fb475741b" +checksum = "41512a0523d86be06d7cf606e1bafd0238948b237ce832179f85dfdbce217e1a" dependencies = [ "anyhow", "bitflags 1.3.2", @@ -2018,9 +2018,9 @@ dependencies = [ [[package]] name = "wasmtime" -version = "10.0.1" +version = "11.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd02b992d828b91efaf2a7499b21205fe4ab3002e401e3fe0f227aaeb4001d93" +checksum = "0b1f817f2ca5070983c71f1205fbab5848c9073df7f4e1af9fdceb4cc4a1b8e5" dependencies = [ "anyhow", "async-trait", @@ -2056,18 +2056,18 @@ dependencies = [ [[package]] name = "wasmtime-asm-macros" -version = "10.0.1" +version = "11.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "284466ef356ce2d909bc0ad470b60c4d0df5df2de9084457e118131b3c779b92" +checksum = "0f82fbfda4610e9225238c62574ecded8e9d6ad3a12f387ac45819ecad5c3f9b" dependencies = [ "cfg-if", ] [[package]] name = "wasmtime-cache" -version = "10.0.1" +version = "11.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efc78cfe1a758d1336f447a47af6ec05e0df2c03c93440d70faf80e17fbb001e" +checksum = "b4f5b87f1ed383d6c219c04467ab6ae87990d6c2815d5a990138990a7fcbab95" dependencies = [ "anyhow", "base64", @@ -2085,9 +2085,9 @@ dependencies = [ [[package]] name = "wasmtime-component-macro" -version = "10.0.1" +version = "11.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8e916103436a6d84faa4c2083e2e98612a323c2cc6147ec419124f67c764c9c" +checksum = "e27b96c540c78e12b60025fcbc0ba8a55bff1b32885a5e8eae2df765a6bc97ac" dependencies = [ "anyhow", "proc-macro2", @@ -2100,15 +2100,15 @@ dependencies = [ [[package]] name = "wasmtime-component-util" -version = "10.0.1" +version = "11.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f20a5135ec5ef01080e674979b02d6fa5eebaa2b0c2d6660513ee9956a1bf624" +checksum = "0928fe66c22bf8887e2fb524b7647308b8ce836a333af8504e4f1d80b8ea849f" [[package]] name = "wasmtime-cranelift" -version = "10.0.1" +version = "11.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e1aa99cbf3f8edb5ad8408ba380f5ab481528ecd8a5053acf758e006d6727fd" +checksum = "b659f6e58662d1131f250339acd03aa49377f9351474282699985b79ca4d4a7c" dependencies = [ "anyhow", "cranelift-codegen", @@ -2129,9 +2129,9 @@ dependencies = [ [[package]] name = "wasmtime-cranelift-shared" -version = "10.0.1" +version = "11.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cce31fd55978601acc103acbb8a26f81c89a6eae12d3a1c59f34151dfa609484" +checksum = "74171de083bf2ecb716c507900f825e2b858346c714fbf48f4763ea760f998a8" dependencies = [ "anyhow", "cranelift-codegen", @@ -2145,9 +2145,9 @@ dependencies = [ [[package]] name = "wasmtime-environ" -version = "10.0.1" +version = "11.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41f9e58e0ee7d43ff13e75375c726b16bce022db798d3a099a65eeaa7d7a544b" +checksum = "b124cbac1a3e04a744c76b3f77919343ef16dc4c818a2406dd7b689b16a54639" dependencies = [ "anyhow", "cranelift-entity", @@ -2167,9 +2167,9 @@ dependencies = [ [[package]] name = "wasmtime-fiber" -version = "10.0.1" +version = "11.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14309cbdf2c395258b124a24757c727403070c0465a28bcc780c4f82f4bca5ff" +checksum = "f92ffb8869395c63100ffefbd71cf9489e7e9218e63a3798dcfe93fa8945f9cf" dependencies = [ "cc", "cfg-if", @@ -2180,9 +2180,9 @@ dependencies = [ [[package]] name = "wasmtime-jit" -version = "10.0.1" +version = "11.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f0f2eaeb01bb67266416507829bd8e0bb60278444e4cbd048e280833ebeaa02" +checksum = "90ff15f426c2378f32ffb6d9b4370e3504231492e93f6968e8b5102c3256bbc4" dependencies = [ "addr2line", "anyhow", @@ -2206,9 +2206,9 @@ dependencies = [ [[package]] name = "wasmtime-jit-debug" -version = "10.0.1" +version = "11.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f42e59d62542bfb73ce30672db7eaf4084a60b434b688ac4f05b287d497de082" +checksum = "c549e219102426aa1f90bd18e56a3195ed1e696c318abb3f501c1f4924b530ac" dependencies = [ "object", "once_cell", @@ -2217,9 +2217,9 @@ dependencies = [ [[package]] name = "wasmtime-jit-icache-coherence" -version = "10.0.1" +version = "11.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b49ceb7e2105a8ebe5614d7bbab6f6ef137a284e371633af60b34925493081f" +checksum = "1cf02fedda287a409cff80ad40a7c6c0f0771e99b0cd5e2b79d9cb7ecdc1b2f4" dependencies = [ "cfg-if", "libc", @@ -2228,9 +2228,9 @@ dependencies = [ [[package]] name = "wasmtime-runtime" -version = "10.0.1" +version = "11.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a5de4762421b0b2b19e02111ca403632852b53e506e03b4b227ffb0fbfa63c2" +checksum = "fc38c6229a5d3b8a2528eb33eb11d3e7ebf570259c7cd2f01e8668fe783ea443" dependencies = [ "anyhow", "cc", @@ -2255,9 +2255,9 @@ dependencies = [ [[package]] name = "wasmtime-types" -version = "10.0.1" +version = "11.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcbb7c138f797192f46afdd3ec16f85ef007c3bb45fa8e5174031f17b0be4c4a" +checksum = "768f6c5e7afc3a02eff2753196741db8e5ac5faf26a1e2204d7341b30a637c6f" dependencies = [ "cranelift-entity", "serde", @@ -2267,9 +2267,9 @@ dependencies = [ [[package]] name = "wasmtime-wasi" -version = "10.0.1" +version = "11.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01686e859249d4dffe3d7ce9957ae35bcf4161709dfafd165ee136bd54d179f1" +checksum = "ff7bb52cc5f9f3878cb012c5e42296e2fbb96e5407301b1e8e7007deec8dca9c" dependencies = [ "anyhow", "async-trait", @@ -2294,9 +2294,9 @@ dependencies = [ [[package]] name = "wasmtime-winch" -version = "10.0.1" +version = "11.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60160d8f7d2b301790730dac8ff25156c61d4fed79481e7074c21dd1283cfe2f" +checksum = "b2249faeb887b8b7e7b1797c460ac76160654aea3b8d5842093a771d77fc3819" dependencies = [ "anyhow", "cranelift-codegen", @@ -2311,9 +2311,9 @@ dependencies = [ [[package]] name = "wasmtime-wit-bindgen" -version = "10.0.1" +version = "11.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3334b0466a4d340de345cda83474d1d2c429770c3d667877971407672bc618a" +checksum = "84a4a005a6a2d5faa7cd953d389da8ae979cb571fe40edec7769649d8c98d874" dependencies = [ "anyhow", "heck 0.4.1", @@ -2362,9 +2362,9 @@ dependencies = [ [[package]] name = "wiggle" -version = "10.0.1" +version = "11.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea93d31f59f2b2fa4196990b684771500072d385eaac12587c63db2bc185d705" +checksum = "a89f0d9c91096db5e250cb803500bddfdd65ae3268a9e09283b75d3b513ede7a" dependencies = [ "anyhow", "async-trait", @@ -2377,9 +2377,9 @@ dependencies = [ [[package]] name = "wiggle-generate" -version = "10.0.1" +version = "11.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7df96ee6bea595fabf0346c08c553f684b08e88fad6fdb125e6efde047024f7b" +checksum = "12b5552356799612587de885e02b7e7e7d39e41657af1ddb985d18fbe5ac1642" dependencies = [ "anyhow", "heck 0.4.1", @@ -2392,9 +2392,9 @@ dependencies = [ [[package]] name = "wiggle-macro" -version = "10.0.1" +version = "11.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8649011a011ecca6197c4db6ee630735062ba20595ea56ce58529b3b1c20aa2f" +checksum = "2ca58f5cfecefaec28b09bfb6197a52dbd24df4656154bd377a166f1031d9b17" dependencies = [ "proc-macro2", "quote", @@ -2435,9 +2435,9 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "winch-codegen" -version = "0.8.1" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "525fdd0d4e82d1bd3083bd87e8ca8014abfbdc5bf290d1d5371dac440d351e89" +checksum = "21de111a36e8f367416862fdf6f10caa411cc07a6e21b614eedbf9388c2a3dc9" dependencies = [ "anyhow", "cranelift-codegen", diff --git a/crates/wizer/Cargo.toml b/crates/wizer/Cargo.toml index 430fbb9d76ea..c8ed246e9691 100644 --- a/crates/wizer/Cargo.toml +++ b/crates/wizer/Cargo.toml @@ -47,9 +47,9 @@ optional = true [workspace.dependencies] wasmprinter = "0.2.60" -wasmtime = "10.0" -wasmtime-wasi = "10.0" -wasi-cap-std-sync = "10.0" +wasmtime = "11.0.1" +wasmtime-wasi = "11.0.1" +wasi-cap-std-sync = "11.0.1" [dev-dependencies] From 916d1d457db23079c892a49d0682e50a7b96e6d0 Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Wed, 3 Jan 2024 08:52:53 -0800 Subject: [PATCH 172/212] Update to Wasmtime 16 --- crates/wizer/Cargo.lock | 913 ++++++++++++++++++++++-------------- crates/wizer/Cargo.toml | 6 +- crates/wizer/src/lib.rs | 8 +- crates/wizer/src/rewrite.rs | 4 +- crates/wizer/tests/tests.rs | 4 +- 5 files changed, 571 insertions(+), 364 deletions(-) diff --git a/crates/wizer/Cargo.lock b/crates/wizer/Cargo.lock index b01a7b867378..dc5e4f312d38 100644 --- a/crates/wizer/Cargo.lock +++ b/crates/wizer/Cargo.lock @@ -4,13 +4,19 @@ version = 3 [[package]] name = "addr2line" -version = "0.19.0" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a76fd60b23679b7d19bd066031410fb7e458ccc5e958eb5c325888ce4baedc97" +checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" dependencies = [ "gimli", ] +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + [[package]] name = "ahash" version = "0.8.3" @@ -37,6 +43,15 @@ version = "0.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e9d4ee0d472d1cd2e28c97dfa124b3d8d992e10eb0a035f33f5d12e3a177ba3b" +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + [[package]] name = "anes" version = "0.1.6" @@ -66,22 +81,22 @@ checksum = "7de8ce5e0f9f8d88245311066a578d72b7af3e7088f32783804676302df237e4" [[package]] name = "arbitrary" -version = "1.3.0" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2d098ff73c1ca148721f37baad5ea6a465a13f9573aba8641fbbbae8164a54e" +checksum = "7d5a26814d8dcb93b0e5a0ff3c6d80a8843bafb21b39e8e18a6f05471870e110" dependencies = [ "derive_arbitrary", ] [[package]] name = "async-trait" -version = "0.1.68" +version = "0.1.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9ccdd8f2a161be9bd5c023df56f1b2a0bd1d83872ae53b71a84a12c9bf6e842" +checksum = "c980ee35e870bd1a4d2c8294d4c04d0499e67bca1e4b5cefcc693c2fa00caea9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.46", ] [[package]] @@ -101,6 +116,21 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +[[package]] +name = "backtrace" +version = "0.3.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" +dependencies = [ + "addr2line", + "cc", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", +] + [[package]] name = "base64" version = "0.21.0" @@ -124,9 +154,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.3.3" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "630be753d4e58660abd17930c71b647fe46c27ea6b63cc59e1e3851406972e42" +checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" [[package]] name = "block-buffer" @@ -149,96 +179,87 @@ version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" +[[package]] +name = "bytes" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" + [[package]] name = "cap-fs-ext" -version = "1.0.14" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1742f5106155d46a41eac5f730ee189bf92fde6ae109fbf2cdb67176726ca5d" +checksum = "b779b2d0a001c125b4584ad586268fb4b92d957bff8d26d7fe0dd78283faa814" dependencies = [ - "cap-primitives 1.0.14", - "cap-std 1.0.14", - "io-lifetimes 1.0.10", - "windows-sys", + "cap-primitives", + "cap-std", + "io-lifetimes 2.0.2", + "windows-sys 0.48.0", ] [[package]] -name = "cap-primitives" -version = "1.0.14" +name = "cap-net-ext" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42068f579028e856717d61423645c85d2d216dde8eff62c9b30140e725c79177" +checksum = "6ffc30dee200c20b4dcb80572226f42658e1d9c4b668656d7cc59c33d50e396e" dependencies = [ - "ambient-authority", - "fs-set-times 0.19.1", - "io-extras 0.17.4", - "io-lifetimes 1.0.10", - "ipnet", - "maybe-owned", - "rustix 0.37.14", - "windows-sys", - "winx 0.35.1", + "cap-primitives", + "cap-std", + "rustix 0.38.28", + "smallvec", ] [[package]] name = "cap-primitives" -version = "2.0.0" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bf30c373a3bee22c292b1b6a7a26736a38376840f1af3d2d806455edf8c3899" +checksum = "fe16767ed8eee6d3f1f00d6a7576b81c226ab917eb54b96e5f77a5216ef67abb" dependencies = [ "ambient-authority", - "fs-set-times 0.20.0", - "io-extras 0.18.0", + "fs-set-times", + "io-extras", "io-lifetimes 2.0.2", "ipnet", "maybe-owned", - "rustix 0.38.4", - "windows-sys", - "winx 0.36.1", + "rustix 0.38.28", + "windows-sys 0.52.0", + "winx", ] [[package]] name = "cap-rand" -version = "1.0.14" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3be2ededc13f42a5921c08e565b854cb5ff9b88753e2c6ec12c58a24e7e8d4e" +checksum = "20e5695565f0cd7106bc3c7170323597540e772bb73e0be2cd2c662a0f8fa4ca" dependencies = [ "ambient-authority", "rand", ] -[[package]] -name = "cap-std" -version = "1.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "559ad6fab5fedcc9bd5877160e1433fcd481f8af615068d6ca49472b1201cc6c" -dependencies = [ - "cap-primitives 1.0.14", - "io-extras 0.17.4", - "io-lifetimes 1.0.10", - "rustix 0.37.14", -] - [[package]] name = "cap-std" version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "84bade423fa6403efeebeafe568fdb230e8c590a275fba2ba978dd112efcf6e9" dependencies = [ - "cap-primitives 2.0.0", - "io-extras 0.18.0", + "cap-primitives", + "io-extras", "io-lifetimes 2.0.2", - "rustix 0.38.4", + "rustix 0.38.28", ] [[package]] name = "cap-time-ext" -version = "1.0.14" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a74e04cd32787bfa3a911af745b0fd5d99d4c3fc16c64449e1622c06fa27c8e" +checksum = "03261630f291f425430a36f38c847828265bc928f517cdd2004c56f4b02f002b" dependencies = [ - "cap-primitives 1.0.14", + "ambient-authority", + "cap-primitives", + "iana-time-zone", "once_cell", - "rustix 0.37.14", - "winx 0.35.1", + "rustix 0.38.28", + "winx", ] [[package]] @@ -329,6 +350,12 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2da6da31387c7e4ef160ffab6d5e7f00c42626fe39aea70a7b0f1773f7dd6c1b" +[[package]] +name = "core-foundation-sys" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" + [[package]] name = "cpp_demangle" version = "0.3.5" @@ -349,18 +376,18 @@ dependencies = [ [[package]] name = "cranelift-bforest" -version = "0.98.1" +version = "0.103.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1380172556902242d32f78ed08c98aac4f5952aef22d3684aed5c66a5db0a6fc" +checksum = "7c22542c0b95bd3302f7ed6839869c561f2324bac2fd5e7e99f5cfa65fdc8b92" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-codegen" -version = "0.98.1" +version = "0.103.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "037cca234e1ad0766fdfe43b527ec14e100414b4ccf4bb614977aa9754958f57" +checksum = "6b3db903ef2e9c8a4de2ea6db5db052c7857282952f9df604aa55d169e6000d8" dependencies = [ "bumpalo", "cranelift-bforest", @@ -370,7 +397,7 @@ dependencies = [ "cranelift-entity", "cranelift-isle", "gimli", - "hashbrown 0.13.2", + "hashbrown 0.14.0", "log", "regalloc2", "smallvec", @@ -379,42 +406,43 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.98.1" +version = "0.103.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d375e6afa8b9a304999ea8cf58424414b8e55e004571265a4f0826eba8b74f18" +checksum = "6590feb5a1d6438f974bf6a5ac4dddf69fca14e1f07f3265d880f69e61a94463" dependencies = [ "cranelift-codegen-shared", ] [[package]] name = "cranelift-codegen-shared" -version = "0.98.1" +version = "0.103.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca590e72ccb8da963def6e36460cce4412032b1f03c31d1a601838d305abdc39" +checksum = "7239038c56fafe77fddc8788fc8533dd6c474dc5bdc5637216404f41ba807330" [[package]] name = "cranelift-control" -version = "0.98.1" +version = "0.103.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d2d38eea4373639f4b6236a40f69820fed16c5511093cd3783bf8491a93d9cf" +checksum = "f7dc9c595341404d381d27a3d950160856b35b402275f0c3990cd1ad683c8053" dependencies = [ "arbitrary", ] [[package]] name = "cranelift-entity" -version = "0.98.1" +version = "0.103.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e3173c1434af23c00e4964722cf93ca8f0e6287289bf5d52110597c3ba2ea09" +checksum = "44e3ee532fc4776c69bcedf7e62f9632cbb3f35776fa9a525cdade3195baa3f7" dependencies = [ "serde", + "serde_derive", ] [[package]] name = "cranelift-frontend" -version = "0.98.1" +version = "0.103.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aec4a3a33825062eccf6eec73e852c8773220f6e4798925e19696562948beb1f" +checksum = "a612c94d09e653662ec37681dc2d6fd2b9856e6df7147be0afc9aabb0abf19df" dependencies = [ "cranelift-codegen", "log", @@ -424,15 +452,15 @@ dependencies = [ [[package]] name = "cranelift-isle" -version = "0.98.1" +version = "0.103.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5146b5cea4b21095a021d964b0174cf6ff5530f83e8d0a822683c7559e360b66" +checksum = "85db9830abeb1170b7d29b536ffd55af1d4d26ac8a77570b5d1aca003bf225cc" [[package]] name = "cranelift-native" -version = "0.98.1" +version = "0.103.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21cec3717ce554d3936b2101aa8eae1a2a410bd6da0f4df698a4b008fe9cf1e9" +checksum = "301ef0edafeaeda5771a5d2db64ac53e1818ae3111220a185677025fe91db4a1" dependencies = [ "cranelift-codegen", "libc", @@ -441,9 +469,9 @@ dependencies = [ [[package]] name = "cranelift-wasm" -version = "0.98.1" +version = "0.103.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7fd2f9f1bf29ce6639ae2f477a2fe20bad0bd09289df13efeb890e8e4b9f807" +checksum = "380f0abe8264e4570ac615fc31cef32a3b90a77f7eb97b08331f9dd357b1f500" dependencies = [ "cranelift-codegen", "cranelift-entity", @@ -451,7 +479,7 @@ dependencies = [ "itertools", "log", "smallvec", - "wasmparser 0.107.0", + "wasmparser 0.118.1", "wasmtime-types", ] @@ -530,7 +558,7 @@ dependencies = [ "autocfg", "cfg-if", "crossbeam-utils", - "memoffset", + "memoffset 0.8.0", "scopeguard", ] @@ -564,13 +592,13 @@ dependencies = [ [[package]] name = "derive_arbitrary" -version = "1.3.0" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3cdeb9ec472d588e539a818b2dee436825730da08ad0017c4b1a17676bdc8b7" +checksum = "67e77553c4162a157adbf834ebae5b415acbecbeafc7a74b0e886657506a7611" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.46", ] [[package]] @@ -673,50 +701,29 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a" -dependencies = [ - "errno-dragonfly", - "libc", - "windows-sys", -] - -[[package]] -name = "errno-dragonfly" -version = "0.1.2" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" +checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" dependencies = [ - "cc", "libc", + "windows-sys 0.52.0", ] [[package]] name = "fallible-iterator" -version = "0.2.0" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" +checksum = "2acce4a10f12dc2fb14a218589d4f1f62ef011b2d0cc4b3cb1bba8e94da14649" [[package]] name = "fd-lock" -version = "3.0.12" +version = "4.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39ae6b3d9530211fb3b12a95374b8b0823be812f53d09e18c5675c0146b09642" +checksum = "7e5768da2206272c81ef0b5e951a41862938a6070da63bcea197899942d3b947" dependencies = [ "cfg-if", - "rustix 0.37.14", - "windows-sys", -] - -[[package]] -name = "file-per-thread-logger" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a3cc21c33af89af0930c8cae4ade5e6fdc17b5d2c97b3d2e2edb67a1cf683f3" -dependencies = [ - "env_logger 0.10.0", - "log", + "rustix 0.38.28", + "windows-sys 0.52.0", ] [[package]] @@ -730,24 +737,74 @@ dependencies = [ [[package]] name = "fs-set-times" -version = "0.19.1" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7833d0f115a013d51c55950a3b09d30e4b057be9961b709acb9b5b17a1108861" +checksum = "dd738b84894214045e8414eaded76359b4a5773f0a0a56b16575110739cdcf39" dependencies = [ - "io-lifetimes 1.0.10", - "rustix 0.37.14", - "windows-sys", + "io-lifetimes 2.0.2", + "rustix 0.38.28", + "windows-sys 0.48.0", ] [[package]] -name = "fs-set-times" -version = "0.20.0" +name = "futures" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd738b84894214045e8414eaded76359b4a5773f0a0a56b16575110739cdcf39" +checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" dependencies = [ - "io-lifetimes 2.0.2", - "rustix 0.38.4", - "windows-sys", + "futures-channel", + "futures-core", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" + +[[package]] +name = "futures-io" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" + +[[package]] +name = "futures-sink" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" + +[[package]] +name = "futures-task" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" + +[[package]] +name = "futures-util" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" +dependencies = [ + "futures-core", + "futures-sink", + "futures-task", + "pin-project-lite", + "pin-utils", ] [[package]] @@ -765,7 +822,7 @@ version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "27d12c0aed7f1e24276a241aadc4cb8ea9f83000f34bc062b7cc2d51e3b0fabd" dependencies = [ - "bitflags 2.3.3", + "bitflags 2.4.1", "debugid", "fxhash", "serde", @@ -795,12 +852,12 @@ dependencies = [ [[package]] name = "gimli" -version = "0.27.2" +version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad0a93d233ebf96623465aad4046a8d3aa4da22d4f4beba5388838c8a434bbb4" +checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" dependencies = [ "fallible-iterator", - "indexmap 1.9.3", + "indexmap 2.0.0", "stable_deref_trait", ] @@ -830,6 +887,9 @@ name = "hashbrown" version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a" +dependencies = [ + "ahash", +] [[package]] name = "heck" @@ -876,6 +936,29 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" +[[package]] +name = "iana-time-zone" +version = "0.1.59" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6a67363e2aa4443928ce15e57ebae94fd8949958fd1223c4cfc0cd473ad7539" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + [[package]] name = "id-arena" version = "2.2.1" @@ -900,7 +983,6 @@ checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" dependencies = [ "autocfg", "hashbrown 0.12.3", - "serde", ] [[package]] @@ -911,16 +993,7 @@ checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d" dependencies = [ "equivalent", "hashbrown 0.14.0", -] - -[[package]] -name = "io-extras" -version = "0.17.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fde93d48f0d9277f977a333eca8313695ddd5301dc96f7e02aeddcb0dd99096f" -dependencies = [ - "io-lifetimes 1.0.10", - "windows-sys", + "serde", ] [[package]] @@ -930,7 +1003,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d3c230ee517ee76b1cc593b52939ff68deda3fae9e41eca426c6b4993df51c4" dependencies = [ "io-lifetimes 2.0.2", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -941,7 +1014,7 @@ checksum = "9c66c74d2ae7e79a5a8f7ac924adbe38ee42a859c6539ad869eb51f0b52dc220" dependencies = [ "hermit-abi 0.3.1", "libc", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -965,7 +1038,7 @@ dependencies = [ "hermit-abi 0.3.1", "io-lifetimes 1.0.10", "rustix 0.37.14", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -985,9 +1058,9 @@ checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" [[package]] name = "ittapi" -version = "0.3.3" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e648c437172ce7d3ac35ca11a068755072054826fa455a916b43524fa4a62a7" +checksum = "6b996fe614c41395cdaedf3cf408a9534851090959d90d54a535f675550b64b1" dependencies = [ "anyhow", "ittapi-sys", @@ -996,9 +1069,9 @@ dependencies = [ [[package]] name = "ittapi-sys" -version = "0.3.3" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9b32a4d23f72548178dde54f3c12c6b6a08598e25575c0d0fa5bd861e0dc1a5" +checksum = "52f5385394064fa2c886205dba02598013ce83d3e92d33dbdc0c52fe0e7bf4fc" dependencies = [ "cc", ] @@ -1035,9 +1108,9 @@ checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" [[package]] name = "libc" -version = "0.2.147" +version = "0.2.151" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" +checksum = "302d7ab3130588088d277783b1e2d2e10c9e9e4a16dd9050e6ec93fb3e7048f4" [[package]] name = "libfuzzer-sys" @@ -1064,9 +1137,9 @@ checksum = "36eb31c1778188ae1e64398743890d0877fef36d11521ac60406b42016e8c2cf" [[package]] name = "linux-raw-sys" -version = "0.4.3" +version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09fc20d2ca12cb9f044c93e3bd6d32d523e6e2ec3db4f7b2939cd99026ecd3f0" +checksum = "c4cd1a83af159aa67994778be9070f0ae1bd732942279cabb14f86f986a21456" [[package]] name = "log" @@ -1116,6 +1189,35 @@ dependencies = [ "autocfg", ] +[[package]] +name = "memoffset" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c" +dependencies = [ + "autocfg", +] + +[[package]] +name = "miniz_oxide" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" +dependencies = [ + "adler", +] + +[[package]] +name = "mio" +version = "0.8.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f3d0b296e374a4e6f3c7b0a1f5a51d748a0d34c85e7dc48fc3fa9a87657fe09" +dependencies = [ + "libc", + "wasi", + "windows-sys 0.48.0", +] + [[package]] name = "num-traits" version = "0.2.15" @@ -1137,13 +1239,13 @@ dependencies = [ [[package]] name = "object" -version = "0.30.3" +version = "0.32.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea86265d3d3dcb6a27fc51bd29a4bf387fae9d2986b823079d4986af253eb439" +checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" dependencies = [ "crc32fast", - "hashbrown 0.13.2", - "indexmap 1.9.3", + "hashbrown 0.14.0", + "indexmap 2.0.0", "memchr", ] @@ -1177,6 +1279,12 @@ version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + [[package]] name = "pkg-config" version = "0.3.26" @@ -1243,9 +1351,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.56" +version = "1.0.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b63bdb0cd06f1f4dedf69b254734f9b45af66e4a031e42a7480257d9898b435" +checksum = "2de98502f212cfcea8d0bb305bd0f49d7ebdd75b64ba0a68f937d888f4e0d6db" dependencies = [ "unicode-ident", ] @@ -1259,22 +1367,11 @@ dependencies = [ "cc", ] -[[package]] -name = "pulldown-cmark" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffade02495f22453cd593159ea2f59827aae7f53fa8323f756799b670881dcf8" -dependencies = [ - "bitflags 1.3.2", - "memchr", - "unicase", -] - [[package]] name = "quote" -version = "1.0.26" +version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc" +checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" dependencies = [ "proc-macro2", ] @@ -1353,9 +1450,9 @@ dependencies = [ [[package]] name = "regalloc2" -version = "0.9.2" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b4dcbd3a2ae7fb94b5813fa0e957c6ab51bf5d0a8ee1b69e0c2d0f1e6eb8485" +checksum = "ad156d539c879b7a24a363a2016d77961786e71f48f2e2fc8302a92abd2429a6" dependencies = [ "hashbrown 0.13.2", "log", @@ -1416,26 +1513,24 @@ dependencies = [ "bitflags 1.3.2", "errno", "io-lifetimes 1.0.10", - "itoa", "libc", "linux-raw-sys 0.3.4", - "once_cell", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] name = "rustix" -version = "0.38.4" +version = "0.38.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a962918ea88d644592894bc6dc55acc6c0956488adcebbfb6e273506b7fd6e5" +checksum = "72e572a5e8ca657d7366229cdde4bd14c4eb5499a9573d4d366fe1b599daa316" dependencies = [ - "bitflags 2.3.3", + "bitflags 2.4.1", "errno", "itoa", "libc", - "linux-raw-sys 0.4.3", + "linux-raw-sys 0.4.12", "once_cell", - "windows-sys", + "windows-sys 0.52.0", ] [[package]] @@ -1467,29 +1562,29 @@ checksum = "bebd363326d05ec3e2f532ab7660680f3b02130d780c299bca73469d521bc0ed" [[package]] name = "serde" -version = "1.0.160" +version = "1.0.194" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb2f3770c8bce3bcda7e149193a069a0f4365bda1fa5cd88e03bca26afc1216c" +checksum = "0b114498256798c94a0689e1a15fec6005dee8ac1f41de56404b67afc2a4b773" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.160" +version = "1.0.194" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "291a097c63d8497e00160b166a967a4a79c64f3facdd01cbd7502231688d77df" +checksum = "a3385e45322e8f9931410f01b3031ec534c3947d0e94c18049af4d9f9907d4e0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.46", ] [[package]] name = "serde_json" -version = "1.0.96" +version = "1.0.110" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "057d394a50403bcac12672b2b18fb387ab6d289d957dab67dd201875391e52f1" +checksum = "6fbd975230bada99c8bb618e0c365c2eefa219158d5c6c29610fd09ff1833257" dependencies = [ "itoa", "ryu", @@ -1540,6 +1635,16 @@ version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" +[[package]] +name = "socket2" +version = "0.4.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f7916fc008ca5542385b89a3d3ce689953c143e9304a9bf8beec1de48994c0d" +dependencies = [ + "libc", + "winapi", +] + [[package]] name = "sptr" version = "0.3.2" @@ -1595,9 +1700,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.15" +version = "2.0.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a34fcf3e8b60f57e6a14301a2e916d323af98b0ea63c599441eec8558660c822" +checksum = "89456b690ff72fddcecf231caedbe615c59480c93358a93dfae7fc29e3ebbf0e" dependencies = [ "proc-macro2", "quote", @@ -1606,25 +1711,25 @@ dependencies = [ [[package]] name = "system-interface" -version = "0.25.7" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "928ebd55ab758962e230f51ca63735c5b283f26292297c81404289cda5d78631" +checksum = "27ce32341b2c0b70c144bbf35627fdc1ef18c76ced5e5e7b3ee8b5ba6b2ab6a0" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.4.1", "cap-fs-ext", - "cap-std 1.0.14", + "cap-std", "fd-lock", - "io-lifetimes 1.0.10", - "rustix 0.37.14", - "windows-sys", - "winx 0.35.1", + "io-lifetimes 2.0.2", + "rustix 0.38.28", + "windows-sys 0.48.0", + "winx", ] [[package]] name = "target-lexicon" -version = "0.12.7" +version = "0.12.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd1ba337640d60c3e96bc6f0638a939b9c9a7f2c316a1598c279828b3d1dc8c5" +checksum = "69758bda2e78f098e4ccb393021a0963bb3442eac05f135c30f61b7370bbafae" [[package]] name = "termcolor" @@ -1646,22 +1751,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.40" +version = "1.0.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "978c9a314bd8dc99be594bc3c175faaa9794be04a5a5e153caba6915336cebac" +checksum = "d54378c645627613241d077a3a79db965db602882668f9136ac42af9ecb730ad" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.40" +version = "1.0.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" +checksum = "fa0faa943b50f3db30a20aa7e265dbc66076993efed8463e8de414e5d06d3471" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.46", ] [[package]] @@ -1689,6 +1794,23 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" +[[package]] +name = "tokio" +version = "1.29.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "532826ff75199d5833b9d2c5fe410f29235e25704ee5f0ef599fb51c21f4a4da" +dependencies = [ + "autocfg", + "backtrace", + "bytes", + "libc", + "mio", + "num_cpus", + "pin-project-lite", + "socket2", + "windows-sys 0.48.0", +] + [[package]] name = "toml" version = "0.5.11" @@ -1719,7 +1841,7 @@ checksum = "0f57e3ca2a01450b1a921183a9c9cbfda207fd822cef4ccb00a65402cbba7a74" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.46", ] [[package]] @@ -1746,15 +1868,6 @@ dependencies = [ "serde_yaml", ] -[[package]] -name = "unicase" -version = "2.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6" -dependencies = [ - "version_check", -] - [[package]] name = "unicode-bidi" version = "0.3.13" @@ -1841,46 +1954,45 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasi-cap-std-sync" -version = "11.0.1" +version = "16.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc0fb9a3b1143c8f549b64d707aef869d134fb681f17fb316f0d796537b670ef" +checksum = "154528979a211aa28d969846e883df75705809ed9bcc70aba61460683ea7355b" dependencies = [ "anyhow", "async-trait", "cap-fs-ext", "cap-rand", - "cap-std 1.0.14", + "cap-std", "cap-time-ext", - "fs-set-times 0.19.1", - "io-extras 0.17.4", - "io-lifetimes 1.0.10", - "is-terminal", + "fs-set-times", + "io-extras", + "io-lifetimes 2.0.2", "once_cell", - "rustix 0.37.14", + "rustix 0.38.28", "system-interface", "tracing", "wasi-common", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] name = "wasi-common" -version = "11.0.1" +version = "16.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41512a0523d86be06d7cf606e1bafd0238948b237ce832179f85dfdbce217e1a" +checksum = "3d888b611fee7d273dd057dc009d2dd3132736f36710ffd65657ac83628d1e3b" dependencies = [ "anyhow", - "bitflags 1.3.2", + "bitflags 2.4.1", "cap-rand", - "cap-std 1.0.14", - "io-extras 0.17.4", + "cap-std", + "io-extras", "log", - "rustix 0.37.14", + "rustix 0.38.28", "thiserror", "tracing", "wasmtime", "wiggle", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -1948,18 +2060,18 @@ dependencies = [ [[package]] name = "wasm-encoder" -version = "0.29.0" +version = "0.30.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18c41dbd92eaebf3612a39be316540b8377c871cb9bde6b064af962984912881" +checksum = "b2f8e9778e04cbf44f58acc301372577375a666b966c50b03ef46144f80436a8" dependencies = [ "leb128", ] [[package]] name = "wasm-encoder" -version = "0.30.0" +version = "0.38.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2f8e9778e04cbf44f58acc301372577375a666b966c50b03ef46144f80436a8" +checksum = "0ad2b51884de9c7f4fe2fd1043fccb8dcad4b1e29558146ee57a144d15779f3f" dependencies = [ "leb128", ] @@ -1988,19 +2100,9 @@ dependencies = [ [[package]] name = "wasmparser" -version = "0.107.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29e3ac9b780c7dda0cac7a52a5d6d2d6707cc6e3451c9db209b6c758f40d7acb" -dependencies = [ - "indexmap 1.9.3", - "semver", -] - -[[package]] -name = "wasmparser" -version = "0.108.0" +version = "0.118.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76c956109dcb41436a39391139d9b6e2d0a5e0b158e1293ef352ec977e5e36c5" +checksum = "95ee9723b928e735d53000dec9eae7b07a60e490c85ab54abb66659fc61bfcd9" dependencies = [ "indexmap 2.0.0", "semver", @@ -2008,19 +2110,19 @@ dependencies = [ [[package]] name = "wasmprinter" -version = "0.2.60" +version = "0.2.75" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b76cb909fe3d9b0de58cee1f4072247e680ff5cc1558ccad2790a9de14a23993" +checksum = "3d027eb8294904fc715ac0870cebe6b0271e96b90605ee21511e7565c4ce568c" dependencies = [ "anyhow", - "wasmparser 0.108.0", + "wasmparser 0.118.1", ] [[package]] name = "wasmtime" -version = "11.0.1" +version = "16.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b1f817f2ca5070983c71f1205fbab5848c9073df7f4e1af9fdceb4cc4a1b8e5" +checksum = "a8e539fded2495422ea3c4dfa7beeddba45904eece182cf315294009e1a323bf" dependencies = [ "anyhow", "async-trait", @@ -2029,18 +2131,19 @@ dependencies = [ "cfg-if", "encoding_rs", "fxprof-processed-profile", - "indexmap 1.9.3", + "indexmap 2.0.0", "libc", "log", "object", "once_cell", "paste", - "psm", "rayon", "serde", + "serde_derive", "serde_json", "target-lexicon", - "wasmparser 0.107.0", + "wasm-encoder 0.38.1", + "wasmparser 0.118.1", "wasmtime-cache", "wasmtime-component-macro", "wasmtime-component-util", @@ -2051,48 +2154,48 @@ dependencies = [ "wasmtime-runtime", "wasmtime-winch", "wat", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] name = "wasmtime-asm-macros" -version = "11.0.1" +version = "16.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f82fbfda4610e9225238c62574ecded8e9d6ad3a12f387ac45819ecad5c3f9b" +checksum = "660ba9143e15a2acd921820df221b73aee256bd3ca2d208d73d8adc9587ccbb9" dependencies = [ "cfg-if", ] [[package]] name = "wasmtime-cache" -version = "11.0.1" +version = "16.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4f5b87f1ed383d6c219c04467ab6ae87990d6c2815d5a990138990a7fcbab95" +checksum = "a3ce373743892002f9391c6741ef0cb0335b55ec899d874f311222b7e36f4594" dependencies = [ "anyhow", "base64", "bincode", "directories-next", - "file-per-thread-logger", "log", - "rustix 0.37.14", + "rustix 0.38.28", "serde", + "serde_derive", "sha2", "toml", - "windows-sys", + "windows-sys 0.48.0", "zstd", ] [[package]] name = "wasmtime-component-macro" -version = "11.0.1" +version = "16.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e27b96c540c78e12b60025fcbc0ba8a55bff1b32885a5e8eae2df765a6bc97ac" +checksum = "12ef32643324e564e1c359e9044daa06cbf90d7e2d6c99a738d17a12959f01a5" dependencies = [ "anyhow", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.46", "wasmtime-component-util", "wasmtime-wit-bindgen", "wit-parser", @@ -2100,17 +2203,18 @@ dependencies = [ [[package]] name = "wasmtime-component-util" -version = "11.0.1" +version = "16.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0928fe66c22bf8887e2fb524b7647308b8ce836a333af8504e4f1d80b8ea849f" +checksum = "8c87d06c18d21a4818f354c00a85f4ebc62b2270961cd022968452b0e4dbed9d" [[package]] name = "wasmtime-cranelift" -version = "11.0.1" +version = "16.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b659f6e58662d1131f250339acd03aa49377f9351474282699985b79ca4d4a7c" +checksum = "2d648c8b4064a7911093b02237cd5569f71ca171d3a0a486bf80600b19e1cba2" dependencies = [ "anyhow", + "cfg-if", "cranelift-codegen", "cranelift-control", "cranelift-entity", @@ -2122,16 +2226,17 @@ dependencies = [ "object", "target-lexicon", "thiserror", - "wasmparser 0.107.0", + "wasmparser 0.118.1", "wasmtime-cranelift-shared", "wasmtime-environ", + "wasmtime-versioned-export-macros", ] [[package]] name = "wasmtime-cranelift-shared" -version = "11.0.1" +version = "16.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74171de083bf2ecb716c507900f825e2b858346c714fbf48f4763ea760f998a8" +checksum = "290a89027688782da8ff60b12bb95695494b1874e0d0ba2ba387d23dace6d70c" dependencies = [ "anyhow", "cranelift-codegen", @@ -2145,21 +2250,22 @@ dependencies = [ [[package]] name = "wasmtime-environ" -version = "11.0.1" +version = "16.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b124cbac1a3e04a744c76b3f77919343ef16dc4c818a2406dd7b689b16a54639" +checksum = "61eb64fb3e0da883e2df4a13a81d6282e072336e6cb6295021d0f7ab2e352754" dependencies = [ "anyhow", "cranelift-entity", "gimli", - "indexmap 1.9.3", + "indexmap 2.0.0", "log", "object", "serde", + "serde_derive", "target-lexicon", "thiserror", - "wasm-encoder 0.29.0", - "wasmparser 0.107.0", + "wasm-encoder 0.38.1", + "wasmparser 0.118.1", "wasmprinter", "wasmtime-component-util", "wasmtime-types", @@ -2167,22 +2273,24 @@ dependencies = [ [[package]] name = "wasmtime-fiber" -version = "11.0.1" +version = "16.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f92ffb8869395c63100ffefbd71cf9489e7e9218e63a3798dcfe93fa8945f9cf" +checksum = "40ecf1d3a838b0956b71ad3f8cb80069a228339775bf02dd35d86a5a68bbe443" dependencies = [ + "anyhow", "cc", "cfg-if", - "rustix 0.37.14", + "rustix 0.38.28", "wasmtime-asm-macros", - "windows-sys", + "wasmtime-versioned-export-macros", + "windows-sys 0.48.0", ] [[package]] name = "wasmtime-jit" -version = "11.0.1" +version = "16.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90ff15f426c2378f32ffb6d9b4370e3504231492e93f6968e8b5102c3256bbc4" +checksum = "f485336add49267d8859e8f8084d2d4b9a4b1564496b6f30ba5b168d50c10ceb" dependencies = [ "addr2line", "anyhow", @@ -2194,116 +2302,141 @@ dependencies = [ "log", "object", "rustc-demangle", - "rustix 0.37.14", + "rustix 0.38.28", "serde", + "serde_derive", "target-lexicon", "wasmtime-environ", "wasmtime-jit-debug", "wasmtime-jit-icache-coherence", "wasmtime-runtime", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] name = "wasmtime-jit-debug" -version = "11.0.1" +version = "16.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c549e219102426aa1f90bd18e56a3195ed1e696c318abb3f501c1f4924b530ac" +checksum = "65e119affec40edb2fab9044f188759a00c2df9c3017278d047012a2de1efb4f" dependencies = [ "object", "once_cell", - "rustix 0.37.14", + "rustix 0.38.28", + "wasmtime-versioned-export-macros", ] [[package]] name = "wasmtime-jit-icache-coherence" -version = "11.0.1" +version = "16.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cf02fedda287a409cff80ad40a7c6c0f0771e99b0cd5e2b79d9cb7ecdc1b2f4" +checksum = "6b6d197fcc34ad32ed440e1f9552fd57d1f377d9699d31dee1b5b457322c1f8a" dependencies = [ "cfg-if", "libc", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] name = "wasmtime-runtime" -version = "11.0.1" +version = "16.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc38c6229a5d3b8a2528eb33eb11d3e7ebf570259c7cd2f01e8668fe783ea443" +checksum = "794b2bb19b99ef8322ff0dd9fe1ba7e19c41036dfb260b3f99ecce128c42ff92" dependencies = [ "anyhow", "cc", "cfg-if", "encoding_rs", - "indexmap 1.9.3", + "indexmap 2.0.0", "libc", "log", "mach", "memfd", - "memoffset", + "memoffset 0.9.0", "paste", - "rand", - "rustix 0.37.14", + "psm", + "rustix 0.38.28", "sptr", + "wasm-encoder 0.38.1", "wasmtime-asm-macros", "wasmtime-environ", "wasmtime-fiber", "wasmtime-jit-debug", - "windows-sys", + "wasmtime-versioned-export-macros", + "wasmtime-wmemcheck", + "windows-sys 0.48.0", ] [[package]] name = "wasmtime-types" -version = "11.0.1" +version = "16.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "768f6c5e7afc3a02eff2753196741db8e5ac5faf26a1e2204d7341b30a637c6f" +checksum = "d995db8bb56f2cd8d2dc0ed5ffab94ffb435283b0fe6747f80f7aab40b2d06a1" dependencies = [ "cranelift-entity", "serde", + "serde_derive", "thiserror", - "wasmparser 0.107.0", + "wasmparser 0.118.1", +] + +[[package]] +name = "wasmtime-versioned-export-macros" +version = "16.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f55c5565959287c21dd0f4277ae3518dd2ae62679f655ee2dbc4396e19d210db" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.46", ] [[package]] name = "wasmtime-wasi" -version = "11.0.1" +version = "16.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff7bb52cc5f9f3878cb012c5e42296e2fbb96e5407301b1e8e7007deec8dca9c" +checksum = "ccd8370078149d49a3a47e93741553fd79b700421464b6a27ca32718192ab130" dependencies = [ "anyhow", "async-trait", - "bitflags 1.3.2", + "bitflags 2.4.1", + "bytes", "cap-fs-ext", + "cap-net-ext", "cap-rand", - "cap-std 1.0.14", + "cap-std", "cap-time-ext", - "fs-set-times 0.19.1", - "io-extras 0.17.4", + "fs-set-times", + "futures", + "io-extras", + "io-lifetimes 2.0.2", "libc", - "rustix 0.37.14", + "log", + "once_cell", + "rustix 0.38.28", "system-interface", "thiserror", + "tokio", "tracing", + "url", "wasi-cap-std-sync", "wasi-common", "wasmtime", "wiggle", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] name = "wasmtime-winch" -version = "11.0.1" +version = "16.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2249faeb887b8b7e7b1797c460ac76160654aea3b8d5842093a771d77fc3819" +checksum = "2c6f945ff9bad96e0a69973d74f193c19f627c8adbf250e7cb73ae7564b6cc8a" dependencies = [ "anyhow", "cranelift-codegen", "gimli", "object", "target-lexicon", - "wasmparser 0.107.0", + "wasmparser 0.118.1", "wasmtime-cranelift-shared", "wasmtime-environ", "winch-codegen", @@ -2311,15 +2444,22 @@ dependencies = [ [[package]] name = "wasmtime-wit-bindgen" -version = "11.0.1" +version = "16.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84a4a005a6a2d5faa7cd953d389da8ae979cb571fe40edec7769649d8c98d874" +checksum = "f328b2d4a690270324756e886ed5be3a4da4c00be0eea48253f4595ad068062b" dependencies = [ "anyhow", "heck 0.4.1", + "indexmap 2.0.0", "wit-parser", ] +[[package]] +name = "wasmtime-wmemcheck" +version = "16.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67761d8f8c0b3c13a5d34356274b10a40baba67fe9cfabbfc379a8b414e45de2" + [[package]] name = "wast" version = "35.0.2" @@ -2331,23 +2471,23 @@ dependencies = [ [[package]] name = "wast" -version = "61.0.0" +version = "69.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc6b347851b52fd500657d301155c79e8c67595501d179cef87b6f04ebd25ac4" +checksum = "c1ee37317321afde358e4d7593745942c48d6d17e0e6e943704de9bbee121e7a" dependencies = [ "leb128", "memchr", "unicode-width", - "wasm-encoder 0.30.0", + "wasm-encoder 0.38.1", ] [[package]] name = "wat" -version = "1.0.67" +version = "1.0.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "459e764d27c3ab7beba1ebd617cc025c7e76dea6e7c5ce3189989a970aea3491" +checksum = "aeb338ee8dee4d4cd05e6426683f21c5087dc7cfc8903e839ccf48d43332da3c" dependencies = [ - "wast 61.0.0", + "wast 69.0.1", ] [[package]] @@ -2362,13 +2502,13 @@ dependencies = [ [[package]] name = "wiggle" -version = "11.0.1" +version = "16.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a89f0d9c91096db5e250cb803500bddfdd65ae3268a9e09283b75d3b513ede7a" +checksum = "0afb26cd3269289bb314a361ff0a6685e5ce793b62181a9fe3f81ace15051697" dependencies = [ "anyhow", "async-trait", - "bitflags 1.3.2", + "bitflags 2.4.1", "thiserror", "tracing", "wasmtime", @@ -2377,28 +2517,28 @@ dependencies = [ [[package]] name = "wiggle-generate" -version = "11.0.1" +version = "16.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12b5552356799612587de885e02b7e7e7d39e41657af1ddb985d18fbe5ac1642" +checksum = "cef2868fed7584d2b552fa317104858ded80021d23b073b2d682d3c932a027bd" dependencies = [ "anyhow", "heck 0.4.1", "proc-macro2", "quote", "shellexpand", - "syn 1.0.109", + "syn 2.0.46", "witx", ] [[package]] name = "wiggle-macro" -version = "11.0.1" +version = "16.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ca58f5cfecefaec28b09bfb6197a52dbd24df4656154bd377a166f1031d9b17" +checksum = "31ae1ec11a17ea481539ee9a5719a278c9790d974060fbf71db4b2c05378780b" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.46", "wiggle-generate", ] @@ -2435,9 +2575,9 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "winch-codegen" -version = "0.9.1" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21de111a36e8f367416862fdf6f10caa411cc07a6e21b614eedbf9388c2a3dc9" +checksum = "58e58c236a6abdd9ab454552b4f29e16cfa837a86897c1503313b2e62e7609ec" dependencies = [ "anyhow", "cranelift-codegen", @@ -2445,17 +2585,35 @@ dependencies = [ "regalloc2", "smallvec", "target-lexicon", - "wasmparser 0.107.0", + "wasmparser 0.118.1", "wasmtime-environ", ] +[[package]] +name = "windows-core" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" +dependencies = [ + "windows-targets 0.52.0", +] + [[package]] name = "windows-sys" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ - "windows-targets", + "windows-targets 0.48.0", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.0", ] [[package]] @@ -2464,13 +2622,28 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_aarch64_gnullvm 0.48.0", + "windows_aarch64_msvc 0.48.0", + "windows_i686_gnu 0.48.0", + "windows_i686_msvc 0.48.0", + "windows_x86_64_gnu 0.48.0", + "windows_x86_64_gnullvm 0.48.0", + "windows_x86_64_msvc 0.48.0", +] + +[[package]] +name = "windows-targets" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" +dependencies = [ + "windows_aarch64_gnullvm 0.52.0", + "windows_aarch64_msvc 0.52.0", + "windows_i686_gnu 0.52.0", + "windows_i686_msvc 0.52.0", + "windows_x86_64_gnu 0.52.0", + "windows_x86_64_gnullvm 0.52.0", + "windows_x86_64_msvc 0.52.0", ] [[package]] @@ -2479,36 +2652,72 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" + [[package]] name = "windows_aarch64_msvc" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" + [[package]] name = "windows_i686_gnu" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" +[[package]] +name = "windows_i686_gnu" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" + [[package]] name = "windows_i686_msvc" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" +[[package]] +name = "windows_i686_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" + [[package]] name = "windows_x86_64_gnu" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" + [[package]] name = "windows_x86_64_gnullvm" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" + [[package]] name = "windows_x86_64_msvc" version = "0.48.0" @@ -2516,15 +2725,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" [[package]] -name = "winx" -version = "0.35.1" +name = "windows_x86_64_msvc" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c52a121f0fbf9320d5f2a9a5d82f6cb7557eda5e8b47fc3e7f359ec866ae960" -dependencies = [ - "bitflags 1.3.2", - "io-lifetimes 1.0.10", - "windows-sys", -] +checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" [[package]] name = "winx" @@ -2532,24 +2736,25 @@ version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4857cedf8371f690bb6782a3e2b065c54d1b6661be068aaf3eac8b45e813fdf8" dependencies = [ - "bitflags 2.3.3", - "windows-sys", + "bitflags 2.4.1", + "windows-sys 0.48.0", ] [[package]] name = "wit-parser" -version = "0.8.0" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6daec9f093dbaea0e94043eeb92ece327bbbe70c86b1f41aca9bbfefd7f050f0" +checksum = "15df6b7b28ce94b8be39d8df5cb21a08a4f3b9f33b631aedb4aa5776f785ead3" dependencies = [ "anyhow", "id-arena", - "indexmap 1.9.3", + "indexmap 2.0.0", "log", - "pulldown-cmark", "semver", + "serde", + "serde_derive", + "serde_json", "unicode-xid", - "url", ] [[package]] @@ -2569,7 +2774,7 @@ name = "wizer" version = "3.0.1" dependencies = [ "anyhow", - "cap-std 2.0.0", + "cap-std", "criterion", "env_logger 0.10.0", "log", diff --git a/crates/wizer/Cargo.toml b/crates/wizer/Cargo.toml index c8ed246e9691..ac9867dcd15c 100644 --- a/crates/wizer/Cargo.toml +++ b/crates/wizer/Cargo.toml @@ -47,9 +47,9 @@ optional = true [workspace.dependencies] wasmprinter = "0.2.60" -wasmtime = "11.0.1" -wasmtime-wasi = "11.0.1" -wasi-cap-std-sync = "11.0.1" +wasmtime = "16" +wasmtime-wasi = "16" +wasi-cap-std-sync = "16" [dev-dependencies] diff --git a/crates/wizer/src/lib.rs b/crates/wizer/src/lib.rs index 25810583fc4b..f2ceb9467fac 100644 --- a/crates/wizer/src/lib.rs +++ b/crates/wizer/src/lib.rs @@ -766,10 +766,10 @@ impl Wizer { let mut ctx = wasi_cap_std_sync::WasiCtxBuilder::new(); if self.inherit_stdio.unwrap_or(DEFAULT_INHERIT_STDIO) { - ctx = ctx.inherit_stdio(); + ctx.inherit_stdio(); } if self.inherit_env.unwrap_or(DEFAULT_INHERIT_ENV) { - ctx = ctx.inherit_env()?; + ctx.inherit_env()?; } for dir in &self.dirs { log::debug!("Preopening directory: {}", dir.display()); @@ -778,7 +778,7 @@ impl Wizer { wasmtime_wasi::sync::ambient_authority(), ) .with_context(|| format!("failed to open directory: {}", dir.display()))?; - ctx = ctx.preopened_dir(preopened, dir)?; + ctx.preopened_dir(preopened, dir)?; } for (guest_dir, host_dir) in &self.map_dirs { log::debug!( @@ -791,7 +791,7 @@ impl Wizer { wasmtime_wasi::sync::ambient_authority(), ) .with_context(|| format!("failed to open directory: {}", host_dir.display()))?; - ctx = ctx.preopened_dir(preopened, guest_dir)?; + ctx.preopened_dir(preopened, guest_dir)?; } Ok(Some(ctx.build())) } diff --git a/crates/wizer/src/rewrite.rs b/crates/wizer/src/rewrite.rs index f87b48539786..01742ec3c2ae 100644 --- a/crates/wizer/src/rewrite.rs +++ b/crates/wizer/src/rewrite.rs @@ -93,7 +93,9 @@ impl Wizer { wasmtime::Val::I64(x) => ConstExpr::i64_const(*x), wasmtime::Val::F32(x) => ConstExpr::f32_const(f32::from_bits(*x)), wasmtime::Val::F64(x) => ConstExpr::f64_const(f64::from_bits(*x)), - wasmtime::Val::V128(x) => ConstExpr::v128_const(*x as i128), + wasmtime::Val::V128(x) => { + ConstExpr::v128_const(x.as_u128() as i128) + } _ => unreachable!(), }, ); diff --git a/crates/wizer/tests/tests.rs b/crates/wizer/tests/tests.rs index cb776265c030..386c5c83a14a 100644 --- a/crates/wizer/tests/tests.rs +++ b/crates/wizer/tests/tests.rs @@ -276,7 +276,7 @@ fn reject_table_init() -> Result<()> { (func $g (result i32) (i32.const 0)) (func $h (result i32) (i32.const 0)) - (elem $elem $f $g $h) + (elem $elem func $f $g $h) (func (export "main") i32.const 0 @@ -309,7 +309,7 @@ fn reject_elem_drop() -> Result<()> { (func $g (result i32) (i32.const 0)) (func $h (result i32) (i32.const 0)) - (elem $elem $f $g $h) + (elem $elem func $f $g $h) (func (export "main") elem.drop $elem) From 36df5c1cb2472c121759527454ad701b15018d12 Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Wed, 3 Jan 2024 08:53:51 -0800 Subject: [PATCH 173/212] Bump to version 4 --- crates/wizer/Cargo.lock | 2 +- crates/wizer/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/wizer/Cargo.lock b/crates/wizer/Cargo.lock index dc5e4f312d38..713697ceccd7 100644 --- a/crates/wizer/Cargo.lock +++ b/crates/wizer/Cargo.lock @@ -2771,7 +2771,7 @@ dependencies = [ [[package]] name = "wizer" -version = "3.0.1" +version = "4.0.0" dependencies = [ "anyhow", "cap-std", diff --git a/crates/wizer/Cargo.toml b/crates/wizer/Cargo.toml index ac9867dcd15c..9ef0b1aa2a1b 100644 --- a/crates/wizer/Cargo.toml +++ b/crates/wizer/Cargo.toml @@ -10,7 +10,7 @@ license = "Apache-2.0 WITH LLVM-exception" name = "wizer" readme = "./README.md" repository = "https://github.com/bytecodealliance/wizer" -version = "3.0.1" +version = "4.0.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html From 6f77c8c96396437e47d6db06369dafd027952bfc Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Wed, 3 Jan 2024 09:01:05 -0800 Subject: [PATCH 174/212] Update npm package versions too --- crates/wizer/npm/wizer/package.json | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/crates/wizer/npm/wizer/package.json b/crates/wizer/npm/wizer/package.json index 2bcbb289d066..836759f47509 100644 --- a/crates/wizer/npm/wizer/package.json +++ b/crates/wizer/npm/wizer/package.json @@ -1,6 +1,6 @@ { "name": "@bytecodealliance/wizer", - "version": "3.0.1", + "version": "4.0.0", "description": "The WebAssembly Pre-Initializer", "type": "module", "scripts": { @@ -20,12 +20,12 @@ "wizer": "./wizer.js" }, "optionalDependencies": { - "@bytecodealliance/wizer-darwin-arm64": "3.0.1", - "@bytecodealliance/wizer-darwin-x64": "3.0.1", - "@bytecodealliance/wizer-linux-x64": "3.0.1", - "@bytecodealliance/wizer-linux-arm64": "3.0.1", - "@bytecodealliance/wizer-linux-s390x": "3.0.1", - "@bytecodealliance/wizer-win32-x64": "3.0.1" + "@bytecodealliance/wizer-darwin-arm64": "4.0.0", + "@bytecodealliance/wizer-darwin-x64": "4.0.0", + "@bytecodealliance/wizer-linux-x64": "4.0.0", + "@bytecodealliance/wizer-linux-arm64": "4.0.0", + "@bytecodealliance/wizer-linux-s390x": "4.0.0", + "@bytecodealliance/wizer-win32-x64": "4.0.0" }, "license": "Apache-2.0", "repository": { From ddf3c5e034bd8c36d74e0c247d7723788d5d5980 Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Wed, 3 Jan 2024 09:12:37 -0800 Subject: [PATCH 175/212] Fix fuzz target build --- crates/wizer/src/dummy.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/wizer/src/dummy.rs b/crates/wizer/src/dummy.rs index b5c7a90de91c..7f5ce936f206 100644 --- a/crates/wizer/src/dummy.rs +++ b/crates/wizer/src/dummy.rs @@ -65,7 +65,7 @@ pub fn dummy_value(val_ty: ValType) -> Val { ValType::I64 => Val::I64(0), ValType::F32 => Val::F32(0), ValType::F64 => Val::F64(0), - ValType::V128 => Val::V128(0), + ValType::V128 => Val::V128(0.into()), ValType::ExternRef => Val::ExternRef(None), ValType::FuncRef => Val::FuncRef(None), } From 2f72d62a7d99d024bfd5fc2f335a6d2ac537a79a Mon Sep 17 00:00:00 2001 From: Gentle Date: Fri, 8 Mar 2024 16:21:09 +0100 Subject: [PATCH 176/212] Update wasmtime --- crates/wizer/Cargo.lock | 1062 ++++++++++++++--------------- crates/wizer/Cargo.toml | 8 +- crates/wizer/benches/regex.rs | 4 +- crates/wizer/benches/uap.rs | 4 +- crates/wizer/src/lib.rs | 5 +- crates/wizer/tests/make_linker.rs | 2 +- crates/wizer/tests/tests.rs | 2 +- 7 files changed, 512 insertions(+), 575 deletions(-) diff --git a/crates/wizer/Cargo.lock b/crates/wizer/Cargo.lock index 713697ceccd7..7fc60aac61a6 100644 --- a/crates/wizer/Cargo.lock +++ b/crates/wizer/Cargo.lock @@ -19,20 +19,21 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "ahash" -version = "0.8.3" +version = "0.8.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" +checksum = "8b79b82693f705137f8fb9b37871d99e4f9a7df12b917eed79c3d3954830a60b" dependencies = [ "cfg-if", "once_cell", "version_check", + "zerocopy", ] [[package]] name = "aho-corasick" -version = "1.0.1" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67fc08ce920c31afb70f013dcce1bfc3a3195de6a228474e45e1f145b36f8d04" +checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" dependencies = [ "memchr", ] @@ -69,15 +70,15 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.1" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a30da5c5f2d5e72842e00bcb57657162cdabef0931f40e2deb9b4140440cecd" +checksum = "8901269c6307e8d93993578286ac0edf7f195079ffff5ebdeea6a59ffb7e36bc" [[package]] name = "anyhow" -version = "1.0.70" +version = "1.0.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7de8ce5e0f9f8d88245311066a578d72b7af3e7088f32783804676302df237e4" +checksum = "5ad32ce52e4161730f7098c077cd2ed6229b5804ccf99e5366be1ab72a98b4e1" [[package]] name = "arbitrary" @@ -96,7 +97,7 @@ checksum = "c980ee35e870bd1a4d2c8294d4c04d0499e67bca1e4b5cefcc693c2fa00caea9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.46", + "syn 2.0.52", ] [[package]] @@ -133,9 +134,9 @@ dependencies = [ [[package]] name = "base64" -version = "0.21.0" +version = "0.21.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4a4ddaa51a5bc52a6948f74c06d20aaaddb71924eab79b8c97a8c556e942d6a" +checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" [[package]] name = "bincode" @@ -154,9 +155,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.4.1" +version = "2.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" +checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" [[package]] name = "block-buffer" @@ -169,15 +170,15 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.12.1" +version = "3.15.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b1ce199063694f33ffb7dd4e0ee620741495c32833cde5aa08f02a0bf96f0c8" +checksum = "8ea184aa71bb362a1157c896979544cc23974e08fd265f29ea96b59f0b4a555b" [[package]] name = "byteorder" -version = "1.4.3" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" @@ -187,25 +188,25 @@ checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" [[package]] name = "cap-fs-ext" -version = "2.0.0" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b779b2d0a001c125b4584ad586268fb4b92d957bff8d26d7fe0dd78283faa814" +checksum = "88e341d15ac1029aadce600be764a1a1edafe40e03cde23285bc1d261b3a4866" dependencies = [ "cap-primitives", "cap-std", - "io-lifetimes 2.0.2", - "windows-sys 0.48.0", + "io-lifetimes", + "windows-sys 0.52.0", ] [[package]] name = "cap-net-ext" -version = "2.0.0" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ffc30dee200c20b4dcb80572226f42658e1d9c4b668656d7cc59c33d50e396e" +checksum = "434168fe6533055f0f4204039abe3ff6d7db338ef46872a5fa39e9d5ad5ab7a9" dependencies = [ "cap-primitives", "cap-std", - "rustix 0.38.28", + "rustix", "smallvec", ] @@ -218,10 +219,10 @@ dependencies = [ "ambient-authority", "fs-set-times", "io-extras", - "io-lifetimes 2.0.2", + "io-lifetimes", "ipnet", "maybe-owned", - "rustix 0.38.28", + "rustix", "windows-sys 0.52.0", "winx", ] @@ -238,14 +239,14 @@ dependencies = [ [[package]] name = "cap-std" -version = "2.0.0" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84bade423fa6403efeebeafe568fdb230e8c590a275fba2ba978dd112efcf6e9" +checksum = "593db20e4c51f62d3284bae7ee718849c3214f93a3b94ea1899ad85ba119d330" dependencies = [ "cap-primitives", "io-extras", - "io-lifetimes 2.0.2", - "rustix 0.38.28", + "io-lifetimes", + "rustix", ] [[package]] @@ -258,7 +259,7 @@ dependencies = [ "cap-primitives", "iana-time-zone", "once_cell", - "rustix 0.38.28", + "rustix", "winx", ] @@ -270,11 +271,11 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" [[package]] name = "cc" -version = "1.0.79" +version = "1.0.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" +checksum = "02f341c093d19155a6e41631ce5971aac4e9a868262212153124c15fa22d1cdc" dependencies = [ - "jobserver", + "libc", ] [[package]] @@ -285,9 +286,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "ciborium" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "effd91f6c78e5a4ace8a5d3c0b6bfaec9e2baaef55f3efc00e45fb2e477ee926" +checksum = "42e69ffd6f0917f5c029256a24d0161db17cea3997d185db0d35926308770f0e" dependencies = [ "ciborium-io", "ciborium-ll", @@ -296,15 +297,15 @@ dependencies = [ [[package]] name = "ciborium-io" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdf919175532b369853f5d5e20b26b43112613fd6fe7aee757e35f7a44642656" +checksum = "05afea1e0a06c9be33d539b876f1ce3692f4afea2cb41f740e7743225ed1c757" [[package]] name = "ciborium-ll" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "defaa24ecc093c77630e6c15e17c51f5e187bf35ee514f4e2d67baaa96dae22b" +checksum = "57663b653d948a338bfb3eeba9bb2fd5fcfaecb9e199e87e1eda4d9e8b240fd9" dependencies = [ "ciborium-io", "half", @@ -327,18 +328,18 @@ dependencies = [ [[package]] name = "clap" -version = "4.3.12" +version = "4.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3eab9e8ceb9afdade1ab3f0fd8dbce5b1b2f468ad653baf10e771781b2b67b73" +checksum = "c918d541ef2913577a0f9566e9ce27cb35b6df072075769e0b26cb5a554520da" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.3.12" +version = "4.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f2763db829349bf00cfc06251268865ed4363b93a943174f638daf3ecdba2cd" +checksum = "9f3e7391dad68afb0c2ede1bf619f579a3dc9c2ec67f089baa397123a2f3d1eb" dependencies = [ "anstyle", "clap_lex", @@ -346,9 +347,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.5.0" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2da6da31387c7e4ef160ffab6d5e7f00c42626fe39aea70a7b0f1773f7dd6c1b" +checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce" [[package]] name = "core-foundation-sys" @@ -367,27 +368,27 @@ dependencies = [ [[package]] name = "cpufeatures" -version = "0.2.7" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e4c1eaa2012c47becbbad2ab175484c2a84d1185b566fb2cc5b8707343dfe58" +checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" dependencies = [ "libc", ] [[package]] name = "cranelift-bforest" -version = "0.103.0" +version = "0.105.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c22542c0b95bd3302f7ed6839869c561f2324bac2fd5e7e99f5cfa65fdc8b92" +checksum = "9515fcc42b6cb5137f76b84c1a6f819782d0cf12473d145d3bc5cd67eedc8bc2" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-codegen" -version = "0.103.0" +version = "0.105.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b3db903ef2e9c8a4de2ea6db5db052c7857282952f9df604aa55d169e6000d8" +checksum = "1ad827c6071bfe6d22de1bc331296a29f9ddc506ff926d8415b435ec6a6efce0" dependencies = [ "bumpalo", "cranelift-bforest", @@ -397,7 +398,7 @@ dependencies = [ "cranelift-entity", "cranelift-isle", "gimli", - "hashbrown 0.14.0", + "hashbrown 0.14.3", "log", "regalloc2", "smallvec", @@ -406,33 +407,33 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.103.0" +version = "0.105.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6590feb5a1d6438f974bf6a5ac4dddf69fca14e1f07f3265d880f69e61a94463" +checksum = "10e6b36237a9ca2ce2fb4cc7741d418a080afa1327402138412ef85d5367bef1" dependencies = [ "cranelift-codegen-shared", ] [[package]] name = "cranelift-codegen-shared" -version = "0.103.0" +version = "0.105.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7239038c56fafe77fddc8788fc8533dd6c474dc5bdc5637216404f41ba807330" +checksum = "c36bf4bfb86898a94ccfa773a1f86e8a5346b1983ff72059bdd2db4600325251" [[package]] name = "cranelift-control" -version = "0.103.0" +version = "0.105.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7dc9c595341404d381d27a3d950160856b35b402275f0c3990cd1ad683c8053" +checksum = "7cbf36560e7a6bd1409ca91e7b43b2cc7ed8429f343d7605eadf9046e8fac0d0" dependencies = [ "arbitrary", ] [[package]] name = "cranelift-entity" -version = "0.103.0" +version = "0.105.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44e3ee532fc4776c69bcedf7e62f9632cbb3f35776fa9a525cdade3195baa3f7" +checksum = "a71e11061a75b1184c09bea97c026a88f08b59ade96a7bb1f259d4ea0df2e942" dependencies = [ "serde", "serde_derive", @@ -440,9 +441,9 @@ dependencies = [ [[package]] name = "cranelift-frontend" -version = "0.103.0" +version = "0.105.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a612c94d09e653662ec37681dc2d6fd2b9856e6df7147be0afc9aabb0abf19df" +checksum = "af5d4da63143ee3485c7bcedde0a818727d737d1083484a0ceedb8950c89e495" dependencies = [ "cranelift-codegen", "log", @@ -452,15 +453,15 @@ dependencies = [ [[package]] name = "cranelift-isle" -version = "0.103.0" +version = "0.105.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85db9830abeb1170b7d29b536ffd55af1d4d26ac8a77570b5d1aca003bf225cc" +checksum = "457a9832b089e26f5eea70dcf49bed8ec6edafed630ce7c83161f24d46ab8085" [[package]] name = "cranelift-native" -version = "0.103.0" +version = "0.105.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "301ef0edafeaeda5771a5d2db64ac53e1818ae3111220a185677025fe91db4a1" +checksum = "9b490d579df1ce365e1ea359e24ed86d82289fa785153327c2f6a69a59a731e4" dependencies = [ "cranelift-codegen", "libc", @@ -469,9 +470,9 @@ dependencies = [ [[package]] name = "cranelift-wasm" -version = "0.103.0" +version = "0.105.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "380f0abe8264e4570ac615fc31cef32a3b90a77f7eb97b08331f9dd357b1f500" +checksum = "8cd747ed7f9a461dda9c388415392f6bb95d1a6ef3b7694d17e0817eb74b7798" dependencies = [ "cranelift-codegen", "cranelift-entity", @@ -479,15 +480,15 @@ dependencies = [ "itertools", "log", "smallvec", - "wasmparser 0.118.1", + "wasmparser 0.121.2", "wasmtime-types", ] [[package]] name = "crc32fast" -version = "1.3.2" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" +checksum = "b3855a8a784b474f333699ef2bbca9db2c4a1f6d9088a90a2d25b1eb53111eaa" dependencies = [ "cfg-if", ] @@ -501,7 +502,7 @@ dependencies = [ "anes", "cast", "ciborium", - "clap 4.3.12", + "clap 4.5.1", "criterion-plot", "is-terminal", "itertools", @@ -528,48 +529,36 @@ dependencies = [ "itertools", ] -[[package]] -name = "crossbeam-channel" -version = "0.5.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a33c2bf77f2df06183c3aa30d1e96c0695a313d4f9c453cc3762a6db39f99200" -dependencies = [ - "cfg-if", - "crossbeam-utils", -] - [[package]] name = "crossbeam-deque" -version = "0.8.3" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef" +checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d" dependencies = [ - "cfg-if", "crossbeam-epoch", "crossbeam-utils", ] [[package]] name = "crossbeam-epoch" -version = "0.9.14" +version = "0.9.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46bd5f3f85273295a9d14aedfb86f6aadbff6d8f5295c4a9edb08e819dcf5695" +checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" dependencies = [ - "autocfg", - "cfg-if", "crossbeam-utils", - "memoffset 0.8.0", - "scopeguard", ] [[package]] name = "crossbeam-utils" -version = "0.8.15" +version = "0.8.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c063cd8cc95f5c377ed0d4b49a4b21f632396ff690e8470c29b3359b346984b" -dependencies = [ - "cfg-if", -] +checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345" + +[[package]] +name = "crunchy" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" [[package]] name = "crypto-common" @@ -598,14 +587,14 @@ checksum = "67e77553c4162a157adbf834ebae5b415acbecbeafc7a74b0e886657506a7611" dependencies = [ "proc-macro2", "quote", - "syn 2.0.46", + "syn 2.0.52", ] [[package]] name = "digest" -version = "0.10.6" +version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer", "crypto-common", @@ -654,15 +643,15 @@ dependencies = [ [[package]] name = "either" -version = "1.8.1" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" +checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a" [[package]] name = "encoding_rs" -version = "0.8.32" +version = "0.8.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "071a31f4ee85403370b58aca746f01041ede6f0da2730960ad001edc2b71b394" +checksum = "7268b386296a025e474d5140678f75d6de9493ae55a5d709eeb9dd08149945e1" dependencies = [ "cfg-if", ] @@ -682,9 +671,9 @@ dependencies = [ [[package]] name = "env_logger" -version = "0.10.0" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85cdab6a89accf66733ad5a1693a4dcced6aeff64602b634530dd73c1f3ee9f0" +checksum = "4cd405aab171cb85d6735e5c8d9db038c17d3ca007a4d2c25f337935c3d90580" dependencies = [ "humantime", "is-terminal", @@ -722,28 +711,28 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7e5768da2206272c81ef0b5e951a41862938a6070da63bcea197899942d3b947" dependencies = [ "cfg-if", - "rustix 0.38.28", + "rustix", "windows-sys 0.52.0", ] [[package]] name = "form_urlencoded" -version = "1.1.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9c384f161156f5260c24a097c56119f9be8c798586aecc13afbcbe7b7e26bf8" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" dependencies = [ "percent-encoding", ] [[package]] name = "fs-set-times" -version = "0.20.0" +version = "0.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd738b84894214045e8414eaded76359b4a5773f0a0a56b16575110739cdcf39" +checksum = "033b337d725b97690d86893f9de22b67b80dcc4e9ad815f348254c38119db8fb" dependencies = [ - "io-lifetimes 2.0.2", - "rustix 0.38.28", - "windows-sys 0.48.0", + "io-lifetimes", + "rustix", + "windows-sys 0.52.0", ] [[package]] @@ -822,7 +811,7 @@ version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "27d12c0aed7f1e24276a241aadc4cb8ea9f83000f34bc062b7cc2d51e3b0fabd" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "debugid", "fxhash", "serde", @@ -841,9 +830,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.9" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c85e1d9ab2eadba7e5040d4e09cbd6d072b76a557ad64e797c2cb9d4da21d7e4" +checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" dependencies = [ "cfg-if", "libc", @@ -857,15 +846,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" dependencies = [ "fallible-iterator", - "indexmap 2.0.0", + "indexmap 2.2.5", "stable_deref_trait", ] [[package]] name = "half" -version = "1.8.2" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7" +checksum = "b5eceaaeec696539ddaf7b333340f1af35a5aa87ae3e4f3ead0532f72affab2e" +dependencies = [ + "cfg-if", + "crunchy", +] [[package]] name = "hashbrown" @@ -884,9 +877,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.14.0" +version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a" +checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" dependencies = [ "ahash", ] @@ -917,18 +910,9 @@ dependencies = [ [[package]] name = "hermit-abi" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" -dependencies = [ - "libc", -] - -[[package]] -name = "hermit-abi" -version = "0.3.1" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" +checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" [[package]] name = "humantime" @@ -938,9 +922,9 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "iana-time-zone" -version = "0.1.59" +version = "0.1.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6a67363e2aa4443928ce15e57ebae94fd8949958fd1223c4cfc0cd473ad7539" +checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141" dependencies = [ "android_system_properties", "core-foundation-sys", @@ -967,9 +951,9 @@ checksum = "25a2bc672d1148e28034f176e01fffebb08b35768468cc954630da77a1449005" [[package]] name = "idna" -version = "0.3.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6" +checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" dependencies = [ "unicode-bidi", "unicode-normalization", @@ -987,58 +971,46 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.0.0" +version = "2.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d" +checksum = "7b0b929d511467233429c45a44ac1dcaa21ba0f5ba11e4879e6ed28ddb4f9df4" dependencies = [ "equivalent", - "hashbrown 0.14.0", + "hashbrown 0.14.3", "serde", ] [[package]] name = "io-extras" -version = "0.18.0" +version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d3c230ee517ee76b1cc593b52939ff68deda3fae9e41eca426c6b4993df51c4" +checksum = "c301e73fb90e8a29e600a9f402d095765f74310d582916a952f618836a1bd1ed" dependencies = [ - "io-lifetimes 2.0.2", - "windows-sys 0.48.0", -] - -[[package]] -name = "io-lifetimes" -version = "1.0.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c66c74d2ae7e79a5a8f7ac924adbe38ee42a859c6539ad869eb51f0b52dc220" -dependencies = [ - "hermit-abi 0.3.1", - "libc", - "windows-sys 0.48.0", + "io-lifetimes", + "windows-sys 0.52.0", ] [[package]] name = "io-lifetimes" -version = "2.0.2" +version = "2.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bffb4def18c48926ccac55c1223e02865ce1a821751a95920448662696e7472c" +checksum = "5a611371471e98973dbcab4e0ec66c31a10bc356eeb4d54a0e05eac8158fe38c" [[package]] name = "ipnet" -version = "2.7.2" +version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12b6ee2129af8d4fb011108c73d99a1b83a85977f23b82460c0ae2e25bb4b57f" +checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" [[package]] name = "is-terminal" -version = "0.4.7" +version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adcf93614601c8129ddf72e2d5633df827ba6551541c6d8c59520a371475be1f" +checksum = "f23ff5ef2b80d608d61efee834934d862cd92461afc0560dedf493e4c033738b" dependencies = [ - "hermit-abi 0.3.1", - "io-lifetimes 1.0.10", - "rustix 0.37.14", - "windows-sys 0.48.0", + "hermit-abi 0.3.9", + "libc", + "windows-sys 0.52.0", ] [[package]] @@ -1052,9 +1024,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.6" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" +checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" [[package]] name = "ittapi" @@ -1076,20 +1048,11 @@ dependencies = [ "cc", ] -[[package]] -name = "jobserver" -version = "0.1.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "936cfd212a0155903bcbc060e316fb6cc7cbf2e1907329391ebadc1fe0ce77c2" -dependencies = [ - "libc", -] - [[package]] name = "js-sys" -version = "0.3.61" +version = "0.3.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "445dde2150c55e483f3d8416706b97ec8e8237c307e5b7b4b8dd15e6af2a0730" +checksum = "406cda4b368d531c842222cf9d2600a9a4acce8d29423695379c6868a143a9ee" dependencies = [ "wasm-bindgen", ] @@ -1108,15 +1071,15 @@ checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" [[package]] name = "libc" -version = "0.2.151" +version = "0.2.153" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "302d7ab3130588088d277783b1e2d2e10c9e9e4a16dd9050e6ec93fb3e7048f4" +checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" [[package]] name = "libfuzzer-sys" -version = "0.4.6" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "beb09950ae85a0a94b27676cccf37da5ff13f27076aa1adbc6545dd0d0e1bd4e" +checksum = "a96cfd5557eb82f2b83fed4955246c988d331975a002961b07c81584d107e7f7" dependencies = [ "arbitrary", "cc", @@ -1124,31 +1087,33 @@ dependencies = [ ] [[package]] -name = "linked-hash-map" -version = "0.5.6" +name = "libredox" +version = "0.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" +checksum = "85c833ca1e66078851dba29046874e38f08b2c883700aa29a03ddd3b23814ee8" +dependencies = [ + "bitflags 2.4.2", + "libc", + "redox_syscall", +] [[package]] -name = "linux-raw-sys" -version = "0.3.4" +name = "linked-hash-map" +version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36eb31c1778188ae1e64398743890d0877fef36d11521ac60406b42016e8c2cf" +checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" [[package]] name = "linux-raw-sys" -version = "0.4.12" +version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4cd1a83af159aa67994778be9070f0ae1bd732942279cabb14f86f986a21456" +checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" [[package]] name = "log" -version = "0.4.17" +version = "0.4.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" -dependencies = [ - "cfg-if", -] +checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" [[package]] name = "mach" @@ -1167,26 +1132,17 @@ checksum = "4facc753ae494aeb6e3c22f839b158aebd4f9270f55cd3c79906c45476c47ab4" [[package]] name = "memchr" -version = "2.5.0" +version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" +checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" [[package]] name = "memfd" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffc89ccdc6e10d6907450f753537ebc5c5d3460d2e4e62ea74bd571db62c0f9e" -dependencies = [ - "rustix 0.37.14", -] - -[[package]] -name = "memoffset" -version = "0.8.0" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d61c719bcfbcf5d62b3a09efa6088de8c54bc0bfcd3ea7ae39fcc186108b8de1" +checksum = "b2cffa4ad52c6f791f4f8b15f0c05f9824b2ced1160e88cc393d64fff9a8ac64" dependencies = [ - "autocfg", + "rustix", ] [[package]] @@ -1200,9 +1156,9 @@ dependencies = [ [[package]] name = "miniz_oxide" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" +checksum = "9d811f3e15f28568be3407c8e7fdb6514c1cda3cb30683f15b6a1a1dc4ea14a7" dependencies = [ "adler", ] @@ -1220,20 +1176,20 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.15" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +checksum = "da0df0e5185db44f69b44f26786fe401b6c293d1907744beaa7fa62b2e5a517a" dependencies = [ "autocfg", ] [[package]] name = "num_cpus" -version = "1.15.0" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b" +checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" dependencies = [ - "hermit-abi 0.2.6", + "hermit-abi 0.3.9", "libc", ] @@ -1244,16 +1200,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" dependencies = [ "crc32fast", - "hashbrown 0.14.0", - "indexmap 2.0.0", + "hashbrown 0.14.3", + "indexmap 2.2.5", "memchr", ] [[package]] name = "once_cell" -version = "1.17.1" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "oorandom" @@ -1263,21 +1219,21 @@ checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575" [[package]] name = "paste" -version = "1.0.12" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f746c4065a8fa3fe23974dd82f15431cc8d40779821001404d10d2e79ca7d79" +checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" [[package]] name = "percent-encoding" -version = "2.2.0" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pin-project-lite" -version = "0.2.9" +version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" +checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" [[package]] name = "pin-utils" @@ -1287,15 +1243,15 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "pkg-config" -version = "0.3.26" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160" +checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" [[package]] name = "plotters" -version = "0.3.4" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2538b639e642295546c50fcd545198c9d64ee2a38620a628724a3b266d5fbf97" +checksum = "d2c224ba00d7cadd4d5c660deaf2098e5e80e07846537c51f9cfa4be50c1fd45" dependencies = [ "num-traits", "plotters-backend", @@ -1306,15 +1262,15 @@ dependencies = [ [[package]] name = "plotters-backend" -version = "0.3.4" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "193228616381fecdc1224c62e96946dfbc73ff4384fba576e052ff8c1bea8142" +checksum = "9e76628b4d3a7581389a35d5b6e2139607ad7c75b17aed325f210aa91f4a9609" [[package]] name = "plotters-svg" -version = "0.3.3" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9a81d2759aae1dae668f783c308bc5c8ebd191ff4184aaa1b37f65a6ae5a56f" +checksum = "38f6d39893cca0701371e3c27294f09797214b86f1fb951b89ade8ec04e2abab" dependencies = [ "plotters-backend", ] @@ -1351,9 +1307,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.74" +version = "1.0.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2de98502f212cfcea8d0bb305bd0f49d7ebdd75b64ba0a68f937d888f4e0d6db" +checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" dependencies = [ "unicode-ident", ] @@ -1408,9 +1364,9 @@ dependencies = [ [[package]] name = "rayon" -version = "1.7.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d2df5196e37bcc87abebc0053e20787d73847bb33134a69841207dd0a47f03b" +checksum = "e4963ed1bc86e4f3ee217022bd855b297cef07fb9eac5dfa1f788b220b49b3bd" dependencies = [ "either", "rayon-core", @@ -1418,33 +1374,31 @@ dependencies = [ [[package]] name = "rayon-core" -version = "1.11.0" +version = "1.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b8f95bd6966f5c87776639160a66bd8ab9895d9d4ab01ddba9fc60661aebe8d" +checksum = "1465873a3dfdaa8ae7cb14b4383657caab0b3e8a0aa9ae8e04b044854c8dfce2" dependencies = [ - "crossbeam-channel", "crossbeam-deque", "crossbeam-utils", - "num_cpus", ] [[package]] name = "redox_syscall" -version = "0.2.16" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" +checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" dependencies = [ "bitflags 1.3.2", ] [[package]] name = "redox_users" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" +checksum = "a18479200779601e498ada4e8c1e1f50e3ee19deb0259c25825a98b5603b2cb4" dependencies = [ "getrandom", - "redox_syscall", + "libredox", "thiserror", ] @@ -1463,9 +1417,21 @@ dependencies = [ [[package]] name = "regex" -version = "1.8.1" +version = "1.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af83e617f331cc6ae2da5443c602dfa5af81e517212d9d611a5b3ba1777b5370" +checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5bb987efffd3c6d0d8f5f89510bb458559eab11e4f869acb20bf845e016259cd" dependencies = [ "aho-corasick", "memchr", @@ -1481,9 +1447,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.7.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5996294f19bd3aae0453a862ad728f60e6600695733dd5df01da90c54363a3c" +checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" [[package]] name = "regex-test" @@ -1506,38 +1472,24 @@ checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" [[package]] name = "rustix" -version = "0.37.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b864d3c18a5785a05953adeed93e2dca37ed30f18e69bba9f30079d51f363f" -dependencies = [ - "bitflags 1.3.2", - "errno", - "io-lifetimes 1.0.10", - "libc", - "linux-raw-sys 0.3.4", - "windows-sys 0.48.0", -] - -[[package]] -name = "rustix" -version = "0.38.28" +version = "0.38.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72e572a5e8ca657d7366229cdde4bd14c4eb5499a9573d4d366fe1b599daa316" +checksum = "6ea3e1a662af26cd7a3ba09c0297a31af215563ecf42817c98df621387f4e949" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "errno", "itoa", "libc", - "linux-raw-sys 0.4.12", + "linux-raw-sys", "once_cell", "windows-sys 0.52.0", ] [[package]] name = "ryu" -version = "1.0.13" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" +checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" [[package]] name = "same-file" @@ -1548,43 +1500,37 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "scopeguard" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" - [[package]] name = "semver" -version = "1.0.17" +version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bebd363326d05ec3e2f532ab7660680f3b02130d780c299bca73469d521bc0ed" +checksum = "92d43fe69e652f3df9bdc2b85b2854a0825b86e4fb76bc44d945137d053639ca" [[package]] name = "serde" -version = "1.0.194" +version = "1.0.197" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b114498256798c94a0689e1a15fec6005dee8ac1f41de56404b67afc2a4b773" +checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.194" +version = "1.0.197" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3385e45322e8f9931410f01b3031ec534c3947d0e94c18049af4d9f9907d4e0" +checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.46", + "syn 2.0.52", ] [[package]] name = "serde_json" -version = "1.0.110" +version = "1.0.114" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fbd975230bada99c8bb618e0c365c2eefa219158d5c6c29610fd09ff1833257" +checksum = "c5f09b1bd632ef549eaa9f60a1f8de742bdbc698e6cee2095fc84dde5f549ae0" dependencies = [ "itoa", "ryu", @@ -1605,9 +1551,9 @@ dependencies = [ [[package]] name = "sha2" -version = "0.10.6" +version = "0.10.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82e6b795fe2e3b1e845bafcb27aa35405c4d47cdfc92af5fc8d3002f76cebdc0" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" dependencies = [ "cfg-if", "cpufeatures", @@ -1625,24 +1571,24 @@ dependencies = [ [[package]] name = "slice-group-by" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03b634d87b960ab1a38c4fe143b508576f075e7c978bfad18217645ebfdfa2ec" +checksum = "826167069c09b99d56f31e9ae5c99049e932a98c9dc2dac47645b08dbbf76ba7" [[package]] name = "smallvec" -version = "1.10.0" +version = "1.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" +checksum = "e6ecd384b10a64542d77071bd64bd7b231f4ed5940fba55e98c3de13824cf3d7" [[package]] name = "socket2" -version = "0.4.10" +version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f7916fc008ca5542385b89a3d3ce689953c143e9304a9bf8beec1de48994c0d" +checksum = "05ffd9c0a93b7543e062e759284fcf5f5e3b098501104bfbdde4d404db792871" dependencies = [ "libc", - "winapi", + "windows-sys 0.52.0", ] [[package]] @@ -1700,9 +1646,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.46" +version = "2.0.52" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89456b690ff72fddcecf231caedbe615c59480c93358a93dfae7fc29e3ebbf0e" +checksum = "b699d15b36d1f02c3e7c69f8ffef53de37aefae075d8488d4ba1a7788d574a07" dependencies = [ "proc-macro2", "quote", @@ -1711,31 +1657,31 @@ dependencies = [ [[package]] name = "system-interface" -version = "0.26.0" +version = "0.26.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27ce32341b2c0b70c144bbf35627fdc1ef18c76ced5e5e7b3ee8b5ba6b2ab6a0" +checksum = "0682e006dd35771e392a6623ac180999a9a854b1d4a6c12fb2e804941c2b1f58" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "cap-fs-ext", "cap-std", "fd-lock", - "io-lifetimes 2.0.2", - "rustix 0.38.28", - "windows-sys 0.48.0", + "io-lifetimes", + "rustix", + "windows-sys 0.52.0", "winx", ] [[package]] name = "target-lexicon" -version = "0.12.13" +version = "0.12.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69758bda2e78f098e4ccb393021a0963bb3442eac05f135c30f61b7370bbafae" +checksum = "e1fc403891a21bcfb7c37834ba66a547a8f402146eba7265b5a6d88059c9ff2f" [[package]] name = "termcolor" -version = "1.2.0" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6" +checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" dependencies = [ "winapi-util", ] @@ -1751,22 +1697,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.56" +version = "1.0.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d54378c645627613241d077a3a79db965db602882668f9136ac42af9ecb730ad" +checksum = "1e45bcbe8ed29775f228095caf2cd67af7a4ccf756ebff23a306bf3e8b47b24b" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.56" +version = "1.0.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa0faa943b50f3db30a20aa7e265dbc66076993efed8463e8de414e5d06d3471" +checksum = "a953cb265bef375dae3de6663da4d3804eee9682ea80d8e2542529b73c531c81" dependencies = [ "proc-macro2", "quote", - "syn 2.0.46", + "syn 2.0.52", ] [[package]] @@ -1796,11 +1742,10 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.29.1" +version = "1.36.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "532826ff75199d5833b9d2c5fe410f29235e25704ee5f0ef599fb51c21f4a4da" +checksum = "61285f6515fa018fb2d1e46eb21223fff441ee8db5d0f1435e8ab4f5cdb80931" dependencies = [ - "autocfg", "backtrace", "bytes", "libc", @@ -1822,11 +1767,10 @@ dependencies = [ [[package]] name = "tracing" -version = "0.1.37" +version = "0.1.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" +checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" dependencies = [ - "cfg-if", "log", "pin-project-lite", "tracing-attributes", @@ -1835,29 +1779,29 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.24" +version = "0.1.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f57e3ca2a01450b1a921183a9c9cbfda207fd822cef4ccb00a65402cbba7a74" +checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.46", + "syn 2.0.52", ] [[package]] name = "tracing-core" -version = "0.1.30" +version = "0.1.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24eb03ba0eab1fd845050058ce5e616558e8f8d8fca633e6b163fe25c797213a" +checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" dependencies = [ "once_cell", ] [[package]] name = "typenum" -version = "1.16.0" +version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] name = "uap-bench" @@ -1870,36 +1814,36 @@ dependencies = [ [[package]] name = "unicode-bidi" -version = "0.3.13" +version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" +checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" [[package]] name = "unicode-ident" -version = "1.0.8" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "unicode-normalization" -version = "0.1.22" +version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5" dependencies = [ "tinyvec", ] [[package]] name = "unicode-segmentation" -version = "1.10.1" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" +checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" [[package]] name = "unicode-width" -version = "0.1.10" +version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" +checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" [[package]] name = "unicode-xid" @@ -1909,9 +1853,9 @@ checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" [[package]] name = "url" -version = "2.3.1" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d68c799ae75762b8c3fe375feb6600ef5602c883c5d21eb51c09f22b83c4643" +checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" dependencies = [ "form_urlencoded", "idna", @@ -1920,9 +1864,9 @@ dependencies = [ [[package]] name = "uuid" -version = "1.3.3" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "345444e32442451b267fc254ae85a209c64be56d2890e601a0c37ff0c3c5ecd2" +checksum = "f00cc9702ca12d3c81455259621e676d0f7251cec66a21e98fe2e9a37db93b2a" [[package]] name = "vec_map" @@ -1938,9 +1882,9 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "walkdir" -version = "2.3.3" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36df944cda56c7d8d8b7496af378e6b16de9284591917d307c9b4d313c44e698" +checksum = "d71d857dc86794ca4c280d616f7da00d2dbfd8cd788846559a6813e6aa4b54ee" dependencies = [ "same-file", "winapi-util", @@ -1953,53 +1897,36 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] -name = "wasi-cap-std-sync" -version = "16.0.0" +name = "wasi-common" +version = "18.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "154528979a211aa28d969846e883df75705809ed9bcc70aba61460683ea7355b" +checksum = "880c1461417b2bf90262591bf8a5f04358fb86dac8a585a49b87024971296763" dependencies = [ "anyhow", - "async-trait", + "bitflags 2.4.2", "cap-fs-ext", "cap-rand", "cap-std", "cap-time-ext", "fs-set-times", "io-extras", - "io-lifetimes 2.0.2", + "io-lifetimes", + "log", "once_cell", - "rustix 0.38.28", + "rustix", "system-interface", - "tracing", - "wasi-common", - "windows-sys 0.48.0", -] - -[[package]] -name = "wasi-common" -version = "16.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d888b611fee7d273dd057dc009d2dd3132736f36710ffd65657ac83628d1e3b" -dependencies = [ - "anyhow", - "bitflags 2.4.1", - "cap-rand", - "cap-std", - "io-extras", - "log", - "rustix 0.38.28", "thiserror", "tracing", "wasmtime", "wiggle", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] name = "wasm-bindgen" -version = "0.2.84" +version = "0.2.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31f8dcbc21f30d9b8f2ea926ecb58f6b91192c17e9d33594b3df58b2007ca53b" +checksum = "c1e124130aee3fb58c5bdd6b639a0509486b0338acaaae0c84a5124b0f588b7f" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -2007,24 +1934,24 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.84" +version = "0.2.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95ce90fd5bcc06af55a641a86428ee4229e44e07033963a2290a8e241607ccb9" +checksum = "c9e7e1900c352b609c8488ad12639a311045f40a35491fb69ba8c12f758af70b" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.52", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.84" +version = "0.2.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c21f77c0bedc37fd5dc21f897894a5ca01e7bb159884559461862ae90c0b4c5" +checksum = "b30af9e2d358182b5c7449424f017eba305ed32a7010509ede96cdc4696c46ed" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -2032,22 +1959,22 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.84" +version = "0.2.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2aff81306fcac3c7515ad4e177f521b5c9a15f2b08f4e32d823066102f35a5f6" +checksum = "642f325be6301eb8107a83d12a8ac6c1e1c54345a7ef1a9261962dfefda09e66" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.52", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.84" +version = "0.2.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0046fef7e28c3804e5e38bfa31ea2a0f73905319b677e57ebe37e49358989b5d" +checksum = "4f186bd2dcf04330886ce82d6f33dd75a7bfcf69ecf5763b89fcde53b6ac9838" [[package]] name = "wasm-encoder" @@ -2069,9 +1996,18 @@ dependencies = [ [[package]] name = "wasm-encoder" -version = "0.38.1" +version = "0.41.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ad2b51884de9c7f4fe2fd1043fccb8dcad4b1e29558146ee57a144d15779f3f" +checksum = "972f97a5d8318f908dded23594188a90bcd09365986b1163e66d70170e5287ae" +dependencies = [ + "leb128", +] + +[[package]] +name = "wasm-encoder" +version = "0.201.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9c7d2731df60006819b013f64ccc2019691deccf6e11a1804bc850cd6748f1a" dependencies = [ "leb128", ] @@ -2100,30 +2036,32 @@ dependencies = [ [[package]] name = "wasmparser" -version = "0.118.1" +version = "0.121.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95ee9723b928e735d53000dec9eae7b07a60e490c85ab54abb66659fc61bfcd9" +checksum = "9dbe55c8f9d0dbd25d9447a5a889ff90c0cc3feaa7395310d3d826b2c703eaab" dependencies = [ - "indexmap 2.0.0", + "bitflags 2.4.2", + "indexmap 2.2.5", "semver", ] [[package]] name = "wasmprinter" -version = "0.2.75" +version = "0.2.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d027eb8294904fc715ac0870cebe6b0271e96b90605ee21511e7565c4ce568c" +checksum = "60e73986a6b7fdfedb7c5bf9e7eb71135486507c8fbc4c0c42cffcb6532988b7" dependencies = [ "anyhow", - "wasmparser 0.118.1", + "wasmparser 0.121.2", ] [[package]] name = "wasmtime" -version = "16.0.0" +version = "18.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8e539fded2495422ea3c4dfa7beeddba45904eece182cf315294009e1a323bf" +checksum = "4c843b8bc4dd4f3a76173ba93405c71111d570af0d90ea5f6299c705d0c2add2" dependencies = [ + "addr2line", "anyhow", "async-trait", "bincode", @@ -2131,71 +2069,75 @@ dependencies = [ "cfg-if", "encoding_rs", "fxprof-processed-profile", - "indexmap 2.0.0", + "gimli", + "indexmap 2.2.5", + "ittapi", "libc", "log", "object", "once_cell", "paste", "rayon", + "rustix", "serde", "serde_derive", "serde_json", "target-lexicon", - "wasm-encoder 0.38.1", - "wasmparser 0.118.1", + "wasm-encoder 0.41.2", + "wasmparser 0.121.2", "wasmtime-cache", "wasmtime-component-macro", "wasmtime-component-util", "wasmtime-cranelift", "wasmtime-environ", "wasmtime-fiber", - "wasmtime-jit", + "wasmtime-jit-debug", + "wasmtime-jit-icache-coherence", "wasmtime-runtime", "wasmtime-winch", "wat", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] name = "wasmtime-asm-macros" -version = "16.0.0" +version = "18.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "660ba9143e15a2acd921820df221b73aee256bd3ca2d208d73d8adc9587ccbb9" +checksum = "86b9d329c718b3a18412a6a017c912b539baa8fe1210d21b651f6b4dbafed743" dependencies = [ "cfg-if", ] [[package]] name = "wasmtime-cache" -version = "16.0.0" +version = "18.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3ce373743892002f9391c6741ef0cb0335b55ec899d874f311222b7e36f4594" +checksum = "6fb4fc2bbf9c790a57875eba65588fa97acf57a7d784dc86d057e648d9a1ed91" dependencies = [ "anyhow", "base64", "bincode", "directories-next", "log", - "rustix 0.38.28", + "rustix", "serde", "serde_derive", "sha2", "toml", - "windows-sys 0.48.0", + "windows-sys 0.52.0", "zstd", ] [[package]] name = "wasmtime-component-macro" -version = "16.0.0" +version = "18.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12ef32643324e564e1c359e9044daa06cbf90d7e2d6c99a738d17a12959f01a5" +checksum = "d8d55ddfd02898885c39638eae9631cd430c83a368f5996ed0f7bfb181d02157" dependencies = [ "anyhow", "proc-macro2", "quote", - "syn 2.0.46", + "syn 2.0.52", "wasmtime-component-util", "wasmtime-wit-bindgen", "wit-parser", @@ -2203,15 +2145,15 @@ dependencies = [ [[package]] name = "wasmtime-component-util" -version = "16.0.0" +version = "18.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c87d06c18d21a4818f354c00a85f4ebc62b2270961cd022968452b0e4dbed9d" +checksum = "1d6d69c430cddc70ec42159506962c66983ce0192ebde4eb125b7aabc49cff88" [[package]] name = "wasmtime-cranelift" -version = "16.0.0" +version = "18.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d648c8b4064a7911093b02237cd5569f71ca171d3a0a486bf80600b19e1cba2" +checksum = "31ca62f519225492bd555d0ec85a2dacb0c10315db3418c8b9aeb3824bf54a24" dependencies = [ "anyhow", "cfg-if", @@ -2226,7 +2168,7 @@ dependencies = [ "object", "target-lexicon", "thiserror", - "wasmparser 0.118.1", + "wasmparser 0.121.2", "wasmtime-cranelift-shared", "wasmtime-environ", "wasmtime-versioned-export-macros", @@ -2234,9 +2176,9 @@ dependencies = [ [[package]] name = "wasmtime-cranelift-shared" -version = "16.0.0" +version = "18.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290a89027688782da8ff60b12bb95695494b1874e0d0ba2ba387d23dace6d70c" +checksum = "fd5f2071f42e61490bf7cb95b9acdbe6a29dd577a398019304a960585f28b844" dependencies = [ "anyhow", "cranelift-codegen", @@ -2250,22 +2192,25 @@ dependencies = [ [[package]] name = "wasmtime-environ" -version = "16.0.0" +version = "18.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61eb64fb3e0da883e2df4a13a81d6282e072336e6cb6295021d0f7ab2e352754" +checksum = "82bf1a47f384610da19f58b0fd392ca6a3b720974315c08afb0392c0f3951fed" dependencies = [ "anyhow", + "bincode", + "cpp_demangle", "cranelift-entity", "gimli", - "indexmap 2.0.0", + "indexmap 2.2.5", "log", "object", + "rustc-demangle", "serde", "serde_derive", "target-lexicon", "thiserror", - "wasm-encoder 0.38.1", - "wasmparser 0.118.1", + "wasm-encoder 0.41.2", + "wasmparser 0.121.2", "wasmprinter", "wasmtime-component-util", "wasmtime-types", @@ -2273,132 +2218,105 @@ dependencies = [ [[package]] name = "wasmtime-fiber" -version = "16.0.0" +version = "18.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40ecf1d3a838b0956b71ad3f8cb80069a228339775bf02dd35d86a5a68bbe443" +checksum = "0e31aecada2831e067ebfe93faa3001cc153d506f8af40bbea58aa1d20fe4820" dependencies = [ "anyhow", "cc", "cfg-if", - "rustix 0.38.28", + "rustix", "wasmtime-asm-macros", "wasmtime-versioned-export-macros", - "windows-sys 0.48.0", -] - -[[package]] -name = "wasmtime-jit" -version = "16.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f485336add49267d8859e8f8084d2d4b9a4b1564496b6f30ba5b168d50c10ceb" -dependencies = [ - "addr2line", - "anyhow", - "bincode", - "cfg-if", - "cpp_demangle", - "gimli", - "ittapi", - "log", - "object", - "rustc-demangle", - "rustix 0.38.28", - "serde", - "serde_derive", - "target-lexicon", - "wasmtime-environ", - "wasmtime-jit-debug", - "wasmtime-jit-icache-coherence", - "wasmtime-runtime", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] name = "wasmtime-jit-debug" -version = "16.0.0" +version = "18.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65e119affec40edb2fab9044f188759a00c2df9c3017278d047012a2de1efb4f" +checksum = "833dae95bc7a4f9177bf93f9497419763535b74e37eb8c37be53937d3281e287" dependencies = [ "object", "once_cell", - "rustix 0.38.28", + "rustix", "wasmtime-versioned-export-macros", ] [[package]] name = "wasmtime-jit-icache-coherence" -version = "16.0.0" +version = "18.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b6d197fcc34ad32ed440e1f9552fd57d1f377d9699d31dee1b5b457322c1f8a" +checksum = "33f4121cb29dda08139b2824a734dd095d83ce843f2d613a84eb580b9cfc17ac" dependencies = [ "cfg-if", "libc", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] name = "wasmtime-runtime" -version = "16.0.0" +version = "18.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "794b2bb19b99ef8322ff0dd9fe1ba7e19c41036dfb260b3f99ecce128c42ff92" +checksum = "4e517f2b996bb3b0e34a82a2bce194f850d9bcfc25c08328ef5fb71b071066b8" dependencies = [ "anyhow", "cc", "cfg-if", "encoding_rs", - "indexmap 2.0.0", + "indexmap 2.2.5", "libc", "log", "mach", "memfd", - "memoffset 0.9.0", + "memoffset", "paste", "psm", - "rustix 0.38.28", + "rustix", "sptr", - "wasm-encoder 0.38.1", + "wasm-encoder 0.41.2", "wasmtime-asm-macros", "wasmtime-environ", "wasmtime-fiber", "wasmtime-jit-debug", "wasmtime-versioned-export-macros", "wasmtime-wmemcheck", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] name = "wasmtime-types" -version = "16.0.0" +version = "18.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d995db8bb56f2cd8d2dc0ed5ffab94ffb435283b0fe6747f80f7aab40b2d06a1" +checksum = "54a327d7a0ef57bd52a507d28b4561a74126c7a8535a2fc6f2025716bc6a52e8" dependencies = [ "cranelift-entity", "serde", "serde_derive", "thiserror", - "wasmparser 0.118.1", + "wasmparser 0.121.2", ] [[package]] name = "wasmtime-versioned-export-macros" -version = "16.0.0" +version = "18.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f55c5565959287c21dd0f4277ae3518dd2ae62679f655ee2dbc4396e19d210db" +checksum = "8ef32eea9fc7035a55159a679d1e89b43ece5ae45d24eed4808e6a92c99a0da4" dependencies = [ "proc-macro2", "quote", - "syn 2.0.46", + "syn 2.0.52", ] [[package]] name = "wasmtime-wasi" -version = "16.0.0" +version = "18.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccd8370078149d49a3a47e93741553fd79b700421464b6a27ca32718192ab130" +checksum = "d04d2fb2257245aa05ff799ded40520ae4d8cd31b0d14972afac89061f12fe12" dependencies = [ "anyhow", "async-trait", - "bitflags 2.4.1", + "bitflags 2.4.2", "bytes", "cap-fs-ext", "cap-net-ext", @@ -2408,35 +2326,33 @@ dependencies = [ "fs-set-times", "futures", "io-extras", - "io-lifetimes 2.0.2", - "libc", + "io-lifetimes", "log", "once_cell", - "rustix 0.38.28", + "rustix", "system-interface", "thiserror", "tokio", "tracing", "url", - "wasi-cap-std-sync", "wasi-common", "wasmtime", "wiggle", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] name = "wasmtime-winch" -version = "16.0.0" +version = "18.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c6f945ff9bad96e0a69973d74f193c19f627c8adbf250e7cb73ae7564b6cc8a" +checksum = "db3378c0e808a744b5d4df2a9a9d2746a53b151811926731f04fc401707f7d54" dependencies = [ "anyhow", "cranelift-codegen", "gimli", "object", "target-lexicon", - "wasmparser 0.118.1", + "wasmparser 0.121.2", "wasmtime-cranelift-shared", "wasmtime-environ", "winch-codegen", @@ -2444,21 +2360,21 @@ dependencies = [ [[package]] name = "wasmtime-wit-bindgen" -version = "16.0.0" +version = "18.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f328b2d4a690270324756e886ed5be3a4da4c00be0eea48253f4595ad068062b" +checksum = "ca677c36869e45602617b25a9968ec0d895ad9a0aee3756d9dee1ddd89456f91" dependencies = [ "anyhow", "heck 0.4.1", - "indexmap 2.0.0", + "indexmap 2.2.5", "wit-parser", ] [[package]] name = "wasmtime-wmemcheck" -version = "16.0.0" +version = "18.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67761d8f8c0b3c13a5d34356274b10a40baba67fe9cfabbfc379a8b414e45de2" +checksum = "7f4cbfb052d66f03603a9b77f18171ea245c7805714caad370a549a6344bf86b" [[package]] name = "wast" @@ -2471,30 +2387,31 @@ dependencies = [ [[package]] name = "wast" -version = "69.0.1" +version = "201.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1ee37317321afde358e4d7593745942c48d6d17e0e6e943704de9bbee121e7a" +checksum = "1ef6e1ef34d7da3e2b374fd2b1a9c0227aff6cad596e1b24df9b58d0f6222faa" dependencies = [ + "bumpalo", "leb128", "memchr", "unicode-width", - "wasm-encoder 0.38.1", + "wasm-encoder 0.201.0", ] [[package]] name = "wat" -version = "1.0.82" +version = "1.201.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aeb338ee8dee4d4cd05e6426683f21c5087dc7cfc8903e839ccf48d43332da3c" +checksum = "453d5b37a45b98dee4f4cb68015fc73634d7883bbef1c65e6e9c78d454cf3f32" dependencies = [ - "wast 69.0.1", + "wast 201.0.0", ] [[package]] name = "web-sys" -version = "0.3.61" +version = "0.3.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e33b99f4b23ba3eec1a53ac264e35a755f00e966e0065077d6027c0f575b0b97" +checksum = "96565907687f7aceb35bc5fc03770a8a0471d82e479f25832f54a0e3f4b28446" dependencies = [ "js-sys", "wasm-bindgen", @@ -2502,13 +2419,13 @@ dependencies = [ [[package]] name = "wiggle" -version = "16.0.0" +version = "18.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0afb26cd3269289bb314a361ff0a6685e5ce793b62181a9fe3f81ace15051697" +checksum = "b69812e493f8a43d8551abfaaf9539e1aff0cf56a58cdd276845fc4af035d0cd" dependencies = [ "anyhow", "async-trait", - "bitflags 2.4.1", + "bitflags 2.4.2", "thiserror", "tracing", "wasmtime", @@ -2517,28 +2434,28 @@ dependencies = [ [[package]] name = "wiggle-generate" -version = "16.0.0" +version = "18.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cef2868fed7584d2b552fa317104858ded80021d23b073b2d682d3c932a027bd" +checksum = "0446357a5a7af0172848b6eca7b2aa1ab7d90065cd2ab02b633a322e1a52f636" dependencies = [ "anyhow", "heck 0.4.1", "proc-macro2", "quote", "shellexpand", - "syn 2.0.46", + "syn 2.0.52", "witx", ] [[package]] name = "wiggle-macro" -version = "16.0.0" +version = "18.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31ae1ec11a17ea481539ee9a5719a278c9790d974060fbf71db4b2c05378780b" +checksum = "9498ef53a12cf25dc6de9baef6ccd8b58d159202c412a19f4d72b218393086c5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.46", + "syn 2.0.52", "wiggle-generate", ] @@ -2560,9 +2477,9 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" dependencies = [ "winapi", ] @@ -2575,9 +2492,9 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "winch-codegen" -version = "0.14.0" +version = "0.16.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58e58c236a6abdd9ab454552b4f29e16cfa837a86897c1503313b2e62e7609ec" +checksum = "8197ed4a2ebf612f0624ddda10de71f8cd2d3a4ecf8ffac0586a264599708d63" dependencies = [ "anyhow", "cranelift-codegen", @@ -2585,7 +2502,7 @@ dependencies = [ "regalloc2", "smallvec", "target-lexicon", - "wasmparser 0.118.1", + "wasmparser 0.121.2", "wasmtime-environ", ] @@ -2595,7 +2512,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" dependencies = [ - "windows-targets 0.52.0", + "windows-targets 0.52.4", ] [[package]] @@ -2604,7 +2521,7 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ - "windows-targets 0.48.0", + "windows-targets 0.48.5", ] [[package]] @@ -2613,142 +2530,142 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.0", + "windows-targets 0.52.4", ] [[package]] name = "windows-targets" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" dependencies = [ - "windows_aarch64_gnullvm 0.48.0", - "windows_aarch64_msvc 0.48.0", - "windows_i686_gnu 0.48.0", - "windows_i686_msvc 0.48.0", - "windows_x86_64_gnu 0.48.0", - "windows_x86_64_gnullvm 0.48.0", - "windows_x86_64_msvc 0.48.0", + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", ] [[package]] name = "windows-targets" -version = "0.52.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" +checksum = "7dd37b7e5ab9018759f893a1952c9420d060016fc19a472b4bb20d1bdd694d1b" dependencies = [ - "windows_aarch64_gnullvm 0.52.0", - "windows_aarch64_msvc 0.52.0", - "windows_i686_gnu 0.52.0", - "windows_i686_msvc 0.52.0", - "windows_x86_64_gnu 0.52.0", - "windows_x86_64_gnullvm 0.52.0", - "windows_x86_64_msvc 0.52.0", + "windows_aarch64_gnullvm 0.52.4", + "windows_aarch64_msvc 0.52.4", + "windows_i686_gnu 0.52.4", + "windows_i686_msvc 0.52.4", + "windows_x86_64_gnu 0.52.4", + "windows_x86_64_gnullvm 0.52.4", + "windows_x86_64_msvc 0.52.4", ] [[package]] name = "windows_aarch64_gnullvm" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" +checksum = "bcf46cf4c365c6f2d1cc93ce535f2c8b244591df96ceee75d8e83deb70a9cac9" [[package]] name = "windows_aarch64_msvc" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_aarch64_msvc" -version = "0.52.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" +checksum = "da9f259dd3bcf6990b55bffd094c4f7235817ba4ceebde8e6d11cd0c5633b675" [[package]] name = "windows_i686_gnu" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_gnu" -version = "0.52.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" +checksum = "b474d8268f99e0995f25b9f095bc7434632601028cf86590aea5c8a5cb7801d3" [[package]] name = "windows_i686_msvc" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_i686_msvc" -version = "0.52.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" +checksum = "1515e9a29e5bed743cb4415a9ecf5dfca648ce85ee42e15873c3cd8610ff8e02" [[package]] name = "windows_x86_64_gnu" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnu" -version = "0.52.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" +checksum = "5eee091590e89cc02ad514ffe3ead9eb6b660aedca2183455434b93546371a03" [[package]] name = "windows_x86_64_gnullvm" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" +checksum = "77ca79f2451b49fa9e2af39f0747fe999fcda4f5e241b2898624dca97a1f2177" [[package]] name = "windows_x86_64_msvc" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "windows_x86_64_msvc" -version = "0.52.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" +checksum = "32b752e52a2da0ddfbdbcc6fceadfeede4c939ed16d13e648833a61dfb611ed8" [[package]] name = "winx" -version = "0.36.1" +version = "0.36.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4857cedf8371f690bb6782a3e2b065c54d1b6661be068aaf3eac8b45e813fdf8" +checksum = "f9643b83820c0cd246ecabe5fa454dd04ba4fa67996369466d0747472d337346" dependencies = [ - "bitflags 2.4.1", - "windows-sys 0.48.0", + "bitflags 2.4.2", + "windows-sys 0.52.0", ] [[package]] name = "wit-parser" -version = "0.13.0" +version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15df6b7b28ce94b8be39d8df5cb21a08a4f3b9f33b631aedb4aa5776f785ead3" +checksum = "316b36a9f0005f5aa4b03c39bc3728d045df136f8c13a73b7db4510dec725e08" dependencies = [ "anyhow", "id-arena", - "indexmap 2.0.0", + "indexmap 2.2.5", "log", "semver", "serde", @@ -2776,11 +2693,11 @@ dependencies = [ "anyhow", "cap-std", "criterion", - "env_logger 0.10.0", + "env_logger 0.10.2", "log", "rayon", "structopt", - "wasi-cap-std-sync", + "wasi-common", "wasm-encoder 0.30.0", "wasmparser 0.106.0", "wasmprinter", @@ -2811,6 +2728,26 @@ dependencies = [ "linked-hash-map", ] +[[package]] +name = "zerocopy" +version = "0.7.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.52", +] + [[package]] name = "zstd" version = "0.11.2+zstd.1.5.2" @@ -2832,11 +2769,10 @@ dependencies = [ [[package]] name = "zstd-sys" -version = "2.0.8+zstd.1.5.5" +version = "2.0.9+zstd.1.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5556e6ee25d32df2586c098bbfa278803692a20d0ab9565e049480d52707ec8c" +checksum = "9e16efa8a874a0481a574084d34cc26fdb3b99627480f785888deb6386506656" dependencies = [ "cc", - "libc", "pkg-config", ] diff --git a/crates/wizer/Cargo.toml b/crates/wizer/Cargo.toml index 9ef0b1aa2a1b..dbdf4fd0adcf 100644 --- a/crates/wizer/Cargo.toml +++ b/crates/wizer/Cargo.toml @@ -33,11 +33,11 @@ env_logger = { version = "0.10", optional = true } log = "0.4.14" rayon = "1.5.0" structopt = { version = "0.3.21", optional = true } -wasi-cap-std-sync = { workspace = true } wasm-encoder = "0.30.0" wasmparser = "0.106.0" wasmtime = { workspace = true } wasmtime-wasi = { workspace = true } +wasi-common = { workspace = true } # Enable this dependency to get messages with WAT disassemblies when certain # internal panics occur. @@ -47,9 +47,9 @@ optional = true [workspace.dependencies] wasmprinter = "0.2.60" -wasmtime = "16" -wasmtime-wasi = "16" -wasi-cap-std-sync = "16" +wasmtime = "18" +wasmtime-wasi = "18" +wasi-common = "18" [dev-dependencies] diff --git a/crates/wizer/benches/regex.rs b/crates/wizer/benches/regex.rs index 74505b5fad26..b385a1373850 100644 --- a/crates/wizer/benches/regex.rs +++ b/crates/wizer/benches/regex.rs @@ -2,9 +2,9 @@ use criterion::{criterion_group, criterion_main, Criterion}; use std::convert::TryFrom; fn run_iter( - linker: &wasmtime::Linker, + linker: &wasmtime::Linker, module: &wasmtime::Module, - mut store: &mut wasmtime::Store, + mut store: &mut wasmtime::Store, ) { let instance = linker.instantiate(&mut store, module).unwrap(); diff --git a/crates/wizer/benches/uap.rs b/crates/wizer/benches/uap.rs index 66f051b30c0e..d5fdd8ae86a6 100644 --- a/crates/wizer/benches/uap.rs +++ b/crates/wizer/benches/uap.rs @@ -2,9 +2,9 @@ use criterion::{criterion_group, criterion_main, Criterion}; use std::convert::TryFrom; fn run_iter( - linker: &wasmtime::Linker, + linker: &wasmtime::Linker, module: &wasmtime::Module, - mut store: &mut wasmtime::Store, + mut store: &mut wasmtime::Store, ) { let instance = linker.instantiate(&mut store, module).unwrap(); diff --git a/crates/wizer/src/lib.rs b/crates/wizer/src/lib.rs index f2ceb9467fac..f6a30293d797 100644 --- a/crates/wizer/src/lib.rs +++ b/crates/wizer/src/lib.rs @@ -29,8 +29,9 @@ use std::path::PathBuf; use std::rc::Rc; #[cfg(feature = "structopt")] use structopt::StructOpt; +use wasi_common::WasiCtx; use wasmtime::{Engine, Extern}; -use wasmtime_wasi::WasiCtx; +use wasmtime_wasi::WasiCtxBuilder; const DEFAULT_INHERIT_STDIO: bool = true; const DEFAULT_INHERIT_ENV: bool = false; @@ -764,7 +765,7 @@ impl Wizer { return Ok(None); } - let mut ctx = wasi_cap_std_sync::WasiCtxBuilder::new(); + let mut ctx = WasiCtxBuilder::new(); if self.inherit_stdio.unwrap_or(DEFAULT_INHERIT_STDIO) { ctx.inherit_stdio(); } diff --git a/crates/wizer/tests/make_linker.rs b/crates/wizer/tests/make_linker.rs index 2a43c91d394b..a6531f495c04 100644 --- a/crates/wizer/tests/make_linker.rs +++ b/crates/wizer/tests/make_linker.rs @@ -35,7 +35,7 @@ fn run_wasm(args: &[wasmtime::Val], expected: i32, wasm: &[u8]) -> Result<()> { config.wasm_multi_value(true); let engine = wasmtime::Engine::new(&config)?; - let wasi_ctx = wasi_cap_std_sync::WasiCtxBuilder::new().build(); + let wasi_ctx = wasmtime_wasi::WasiCtxBuilder::new().build(); let mut store = wasmtime::Store::new(&engine, wasi_ctx); let module = wasmtime::Module::new(store.engine(), wasm).context("Wasm test case failed to compile")?; diff --git a/crates/wizer/tests/tests.rs b/crates/wizer/tests/tests.rs index 386c5c83a14a..057733f1fd57 100644 --- a/crates/wizer/tests/tests.rs +++ b/crates/wizer/tests/tests.rs @@ -48,7 +48,7 @@ fn wizen_and_run_wasm( config.wasm_multi_value(true); let engine = wasmtime::Engine::new(&config)?; - let wasi_ctx = wasi_cap_std_sync::WasiCtxBuilder::new().build(); + let wasi_ctx = wasmtime_wasi::WasiCtxBuilder::new().build(); let mut store = wasmtime::Store::new(&engine, wasi_ctx); let module = wasmtime::Module::new(store.engine(), wasm).context("Wasm test case failed to compile")?; From e559b955365105af470b025d4dced008cd4c7cc8 Mon Sep 17 00:00:00 2001 From: Gentle Date: Sat, 9 Mar 2024 02:30:55 +0100 Subject: [PATCH 177/212] updates, replace wasi-cap-std-sync with wasi-common --- crates/wizer/Cargo.lock | 276 ++++++++++++-------- crates/wizer/Cargo.toml | 22 +- crates/wizer/benches/regex-bench/Cargo.toml | 2 +- crates/wizer/benches/uap-bench/Cargo.toml | 6 +- crates/wizer/fuzz/Cargo.toml | 6 +- crates/wizer/src/info.rs | 2 +- crates/wizer/src/info/types_interner.rs | 11 +- crates/wizer/src/lib.rs | 2 + crates/wizer/src/parse.rs | 13 +- crates/wizer/tests/regex-test/Cargo.toml | 2 +- 10 files changed, 200 insertions(+), 142 deletions(-) diff --git a/crates/wizer/Cargo.lock b/crates/wizer/Cargo.lock index 7fc60aac61a6..5cb8e05638ed 100644 --- a/crates/wizer/Cargo.lock +++ b/crates/wizer/Cargo.lock @@ -19,9 +19,9 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "ahash" -version = "0.8.10" +version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b79b82693f705137f8fb9b37871d99e4f9a7df12b917eed79c3d3954830a60b" +checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" dependencies = [ "cfg-if", "once_cell", @@ -68,12 +68,54 @@ dependencies = [ "winapi", ] +[[package]] +name = "anstream" +version = "0.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d96bd03f33fe50a863e394ee9718a706f988b9079b20c3784fb726e7678b62fb" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "utf8parse", +] + [[package]] name = "anstyle" version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8901269c6307e8d93993578286ac0edf7f195079ffff5ebdeea6a59ffb7e36bc" +[[package]] +name = "anstyle-parse" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c75ac65da39e5fe5ab759307499ddad880d724eed2f6ce5b5e8a26f4f387928c" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e28923312444cdd728e4738b3f9c9cac739500909bb3d3c94b43551b16517648" +dependencies = [ + "windows-sys 0.52.0", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7" +dependencies = [ + "anstyle", + "windows-sys 0.52.0", +] + [[package]] name = "anyhow" version = "1.0.80" @@ -170,9 +212,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.15.3" +version = "3.15.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ea184aa71bb362a1157c896979544cc23974e08fd265f29ea96b59f0b4a555b" +checksum = "7ff69b9dd49fd426c69a0db9fc04dd934cdb6645ff000864d98f7e2af8830eaa" [[package]] name = "byteorder" @@ -192,8 +234,8 @@ version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "88e341d15ac1029aadce600be764a1a1edafe40e03cde23285bc1d261b3a4866" dependencies = [ - "cap-primitives", - "cap-std", + "cap-primitives 2.0.1", + "cap-std 2.0.1", "io-lifetimes", "windows-sys 0.52.0", ] @@ -204,8 +246,8 @@ version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "434168fe6533055f0f4204039abe3ff6d7db338ef46872a5fa39e9d5ad5ab7a9" dependencies = [ - "cap-primitives", - "cap-std", + "cap-primitives 2.0.1", + "cap-std 2.0.1", "rustix", "smallvec", ] @@ -227,6 +269,23 @@ dependencies = [ "winx", ] +[[package]] +name = "cap-primitives" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90a0b44fc796b1a84535a63753d50ba3972c4db55c7255c186f79140e63d56d0" +dependencies = [ + "ambient-authority", + "fs-set-times", + "io-extras", + "io-lifetimes", + "ipnet", + "maybe-owned", + "rustix", + "windows-sys 0.52.0", + "winx", +] + [[package]] name = "cap-rand" version = "2.0.1" @@ -243,7 +302,19 @@ version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "593db20e4c51f62d3284bae7ee718849c3214f93a3b94ea1899ad85ba119d330" dependencies = [ - "cap-primitives", + "cap-primitives 2.0.1", + "io-extras", + "io-lifetimes", + "rustix", +] + +[[package]] +name = "cap-std" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "266626ce180cf9709f317d0bf9754e3a5006359d87f4bf792f06c9c5f1b63c0f" +dependencies = [ + "cap-primitives 3.0.0", "io-extras", "io-lifetimes", "rustix", @@ -256,7 +327,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "03261630f291f425430a36f38c847828265bc928f517cdd2004c56f4b02f002b" dependencies = [ "ambient-authority", - "cap-primitives", + "cap-primitives 2.0.1", "iana-time-zone", "once_cell", "rustix", @@ -351,6 +422,12 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce" +[[package]] +name = "colorchoice" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" + [[package]] name = "core-foundation-sys" version = "0.8.6" @@ -657,29 +734,26 @@ dependencies = [ ] [[package]] -name = "env_logger" -version = "0.8.4" +name = "env_filter" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a19187fea3ac7e84da7dacf48de0c45d63c6a76f9490dae389aead16c243fce3" +checksum = "a009aa4810eb158359dda09d0c87378e4bbb89b5a801f016885a4707ba24f7ea" dependencies = [ - "atty", - "humantime", "log", "regex", - "termcolor", ] [[package]] name = "env_logger" -version = "0.10.2" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cd405aab171cb85d6735e5c8d9db038c17d3ca007a4d2c25f337935c3d90580" +checksum = "38b35839ba51819680ba087cd351788c9a3c476841207e0b8cee0b04722343b9" dependencies = [ + "anstream", + "anstyle", + "env_filter", "humantime", - "is-terminal", "log", - "regex", - "termcolor", ] [[package]] @@ -715,6 +789,12 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "flagset" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdeb3aa5e95cf9aabc17f060cfa0ced7b83f042390760ca53bf09df9968acaa1" + [[package]] name = "form_urlencoded" version = "1.2.1" @@ -846,7 +926,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" dependencies = [ "fallible-iterator", - "indexmap 2.2.5", + "indexmap", "stable_deref_trait", ] @@ -860,12 +940,6 @@ dependencies = [ "crunchy", ] -[[package]] -name = "hashbrown" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" - [[package]] name = "hashbrown" version = "0.13.2" @@ -959,16 +1033,6 @@ dependencies = [ "unicode-normalization", ] -[[package]] -name = "indexmap" -version = "1.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" -dependencies = [ - "autocfg", - "hashbrown 0.12.3", -] - [[package]] name = "indexmap" version = "2.2.5" @@ -1097,12 +1161,6 @@ dependencies = [ "redox_syscall", ] -[[package]] -name = "linked-hash-map" -version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" - [[package]] name = "linux-raw-sys" version = "0.4.13" @@ -1201,7 +1259,7 @@ checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" dependencies = [ "crc32fast", "hashbrown 0.14.3", - "indexmap 2.2.5", + "indexmap", "memchr", ] @@ -1429,9 +1487,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bb987efffd3c6d0d8f5f89510bb458559eab11e4f869acb20bf845e016259cd" +checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea" dependencies = [ "aho-corasick", "memchr", @@ -1539,14 +1597,15 @@ dependencies = [ [[package]] name = "serde_yaml" -version = "0.8.26" +version = "0.9.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "578a7433b776b56a35785ed5ce9a7e777ac0598aac5a6dd1b4b18a307c7fc71b" +checksum = "8fd075d994154d4a774f95b51fb96bdc2832b0ea48425c92546073816cda1f2f" dependencies = [ - "indexmap 1.9.3", + "indexmap", + "itoa", "ryu", "serde", - "yaml-rust", + "unsafe-libyaml", ] [[package]] @@ -1663,7 +1722,7 @@ checksum = "0682e006dd35771e392a6623ac180999a9a854b1d4a6c12fb2e804941c2b1f58" dependencies = [ "bitflags 2.4.2", "cap-fs-ext", - "cap-std", + "cap-std 2.0.1", "fd-lock", "io-lifetimes", "rustix", @@ -1677,15 +1736,6 @@ version = "0.12.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e1fc403891a21bcfb7c37834ba66a547a8f402146eba7265b5a6d88059c9ff2f" -[[package]] -name = "termcolor" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" -dependencies = [ - "winapi-util", -] - [[package]] name = "textwrap" version = "0.11.0" @@ -1851,6 +1901,12 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" +[[package]] +name = "unsafe-libyaml" +version = "0.2.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab4c90930b95a82d00dc9e9ac071b4991924390d46cbd0dfe566148667605e4b" + [[package]] name = "url" version = "2.5.0" @@ -1862,6 +1918,12 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "utf8parse" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" + [[package]] name = "uuid" version = "1.7.0" @@ -1906,7 +1968,7 @@ dependencies = [ "bitflags 2.4.2", "cap-fs-ext", "cap-rand", - "cap-std", + "cap-std 2.0.1", "cap-time-ext", "fs-set-times", "io-extras", @@ -1976,24 +2038,6 @@ version = "0.2.91" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4f186bd2dcf04330886ce82d6f33dd75a7bfcf69ecf5763b89fcde53b6ac9838" -[[package]] -name = "wasm-encoder" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51b4949d4f2b25a4b208317dcf86aacef9e7a5884e48dfc45d4aeb91808d6f86" -dependencies = [ - "leb128", -] - -[[package]] -name = "wasm-encoder" -version = "0.30.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2f8e9778e04cbf44f58acc301372577375a666b966c50b03ef46144f80436a8" -dependencies = [ - "leb128", -] - [[package]] name = "wasm-encoder" version = "0.41.2" @@ -2014,34 +2058,37 @@ dependencies = [ [[package]] name = "wasm-smith" -version = "0.4.5" +version = "0.201.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7e95fdeed16adeffed44efdc7ccf27d4f57ff2e99de417c75bcee7dee09049b" +checksum = "61ff53a54a853f174b0df74cdb1553f1451e7bcdc23b26b1379f664ee1913d1a" dependencies = [ + "anyhow", "arbitrary", - "indexmap 1.9.3", + "flagset", + "indexmap", "leb128", - "wasm-encoder 0.4.1", + "wasm-encoder 0.201.0", ] [[package]] name = "wasmparser" -version = "0.106.0" +version = "0.121.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d014e33793cab91655fa6349b0bc974984de106b2e0f6b0dfe6f6594b260624d" +checksum = "9dbe55c8f9d0dbd25d9447a5a889ff90c0cc3feaa7395310d3d826b2c703eaab" dependencies = [ - "indexmap 1.9.3", - "url", + "bitflags 2.4.2", + "indexmap", + "semver", ] [[package]] name = "wasmparser" -version = "0.121.2" +version = "0.201.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9dbe55c8f9d0dbd25d9447a5a889ff90c0cc3feaa7395310d3d826b2c703eaab" +checksum = "84e5df6dba6c0d7fafc63a450f1738451ed7a0b52295d83e868218fa286bf708" dependencies = [ "bitflags 2.4.2", - "indexmap 2.2.5", + "indexmap", "semver", ] @@ -2055,6 +2102,16 @@ dependencies = [ "wasmparser 0.121.2", ] +[[package]] +name = "wasmprinter" +version = "0.201.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a67e66da702706ba08729a78e3c0079085f6bfcb1a62e4799e97bbf728c2c265" +dependencies = [ + "anyhow", + "wasmparser 0.201.0", +] + [[package]] name = "wasmtime" version = "18.0.2" @@ -2070,7 +2127,7 @@ dependencies = [ "encoding_rs", "fxprof-processed-profile", "gimli", - "indexmap 2.2.5", + "indexmap", "ittapi", "libc", "log", @@ -2201,7 +2258,7 @@ dependencies = [ "cpp_demangle", "cranelift-entity", "gimli", - "indexmap 2.2.5", + "indexmap", "log", "object", "rustc-demangle", @@ -2211,7 +2268,7 @@ dependencies = [ "thiserror", "wasm-encoder 0.41.2", "wasmparser 0.121.2", - "wasmprinter", + "wasmprinter 0.2.80", "wasmtime-component-util", "wasmtime-types", ] @@ -2264,7 +2321,7 @@ dependencies = [ "cc", "cfg-if", "encoding_rs", - "indexmap 2.2.5", + "indexmap", "libc", "log", "mach", @@ -2321,7 +2378,7 @@ dependencies = [ "cap-fs-ext", "cap-net-ext", "cap-rand", - "cap-std", + "cap-std 2.0.1", "cap-time-ext", "fs-set-times", "futures", @@ -2366,7 +2423,7 @@ checksum = "ca677c36869e45602617b25a9968ec0d895ad9a0aee3756d9dee1ddd89456f91" dependencies = [ "anyhow", "heck 0.4.1", - "indexmap 2.2.5", + "indexmap", "wit-parser", ] @@ -2665,7 +2722,7 @@ checksum = "316b36a9f0005f5aa4b03c39bc3728d045df136f8c13a73b7db4510dec725e08" dependencies = [ "anyhow", "id-arena", - "indexmap 2.2.5", + "indexmap", "log", "semver", "serde", @@ -2691,16 +2748,16 @@ name = "wizer" version = "4.0.0" dependencies = [ "anyhow", - "cap-std", + "cap-std 3.0.0", "criterion", - "env_logger 0.10.2", + "env_logger", "log", "rayon", "structopt", "wasi-common", - "wasm-encoder 0.30.0", - "wasmparser 0.106.0", - "wasmprinter", + "wasm-encoder 0.201.0", + "wasmparser 0.201.0", + "wasmprinter 0.201.0", "wasmtime", "wasmtime-wasi", "wat", @@ -2710,24 +2767,15 @@ dependencies = [ name = "wizer-fuzz" version = "0.0.0" dependencies = [ - "env_logger 0.8.4", + "env_logger", "libfuzzer-sys", "log", "wasm-smith", - "wasmprinter", + "wasmprinter 0.201.0", "wasmtime", "wizer", ] -[[package]] -name = "yaml-rust" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56c1936c4cc7a1c9ab21a1ebb602eb942ba868cbd44a99cb7cdc5892335e1c85" -dependencies = [ - "linked-hash-map", -] - [[package]] name = "zerocopy" version = "0.7.32" diff --git a/crates/wizer/Cargo.toml b/crates/wizer/Cargo.toml index dbdf4fd0adcf..6a5efbe51f42 100644 --- a/crates/wizer/Cargo.toml +++ b/crates/wizer/Cargo.toml @@ -27,14 +27,14 @@ name = "uap" harness = false [dependencies] -anyhow = "1.0.38" -cap-std = "2.0.0" -env_logger = { version = "0.10", optional = true } -log = "0.4.14" -rayon = "1.5.0" -structopt = { version = "0.3.21", optional = true } -wasm-encoder = "0.30.0" -wasmparser = "0.106.0" +anyhow = "1.0.80" +cap-std = "3.0.0" +env_logger = { version = "0.11", optional = true } +log = "0.4.21" +rayon = "1.9.0" +structopt = { version = "0.3.26", optional = true } +wasm-encoder = "0.201.0" +wasmparser = "0.201.0" wasmtime = { workspace = true } wasmtime-wasi = { workspace = true } wasi-common = { workspace = true } @@ -46,7 +46,7 @@ workspace = true optional = true [workspace.dependencies] -wasmprinter = "0.2.60" +wasmprinter = "0.201.0" wasmtime = "18" wasmtime-wasi = "18" wasi-common = "18" @@ -54,9 +54,9 @@ wasi-common = "18" [dev-dependencies] criterion = "0.5.1" -env_logger = "0.10.0" +env_logger = "0.11.3" wasmprinter = { workspace = true } -wat = "1.0.67" +wat = "1.201.0" [workspace] members = [ diff --git a/crates/wizer/benches/regex-bench/Cargo.toml b/crates/wizer/benches/regex-bench/Cargo.toml index 36d53cc164cb..9b1c0d7dc9b1 100644 --- a/crates/wizer/benches/regex-bench/Cargo.toml +++ b/crates/wizer/benches/regex-bench/Cargo.toml @@ -10,7 +10,7 @@ crate-type = ["cdylib"] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -regex = "1.4.2" +regex = "1.10.3" [features] wizer = [] diff --git a/crates/wizer/benches/uap-bench/Cargo.toml b/crates/wizer/benches/uap-bench/Cargo.toml index f4d87bff9f45..1d468e4552a0 100644 --- a/crates/wizer/benches/uap-bench/Cargo.toml +++ b/crates/wizer/benches/uap-bench/Cargo.toml @@ -10,9 +10,9 @@ crate-type = ["cdylib"] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -serde = { version = "1.0.117", features = ["derive"] } -regex = "1.4.2" -serde_yaml = "0.8.14" +serde = { version = "1.0.197", features = ["derive"] } +regex = "1.10.3" +serde_yaml = "0.9.32" [features] wizer = [] diff --git a/crates/wizer/fuzz/Cargo.toml b/crates/wizer/fuzz/Cargo.toml index 854e3e267e8b..2e3d3e12db6a 100644 --- a/crates/wizer/fuzz/Cargo.toml +++ b/crates/wizer/fuzz/Cargo.toml @@ -10,10 +10,10 @@ edition = "2018" cargo-fuzz = true [dependencies] -env_logger = "0.8.3" +env_logger = "0.11.3" libfuzzer-sys = "0.4" -log = "0.4.14" -wasm-smith = "0.4.0" +log = "0.4.21" +wasm-smith = "0.201.0" wasmprinter = { workspace = true } wasmtime = { workspace = true } diff --git a/crates/wizer/src/info.rs b/crates/wizer/src/info.rs index 75de9e824d00..82acbbbde5ec 100644 --- a/crates/wizer/src/info.rs +++ b/crates/wizer/src/info.rs @@ -146,7 +146,7 @@ impl Module { } /// Push a new type into this module's types space. - pub fn push_type<'a>(self, cx: &mut ModuleContext<'a>, ty: wasmparser::Type) { + pub fn push_type<'a>(self, cx: &mut ModuleContext<'a>, ty: wasmparser::CompositeType) { let types_space = match &cx.arena[self.id] { ModuleInfo::Defined(d) => &d.types, }; diff --git a/crates/wizer/src/info/types_interner.rs b/crates/wizer/src/info/types_interner.rs index 8d444370492b..2196955708dd 100644 --- a/crates/wizer/src/info/types_interner.rs +++ b/crates/wizer/src/info/types_interner.rs @@ -59,10 +59,15 @@ impl TypesInterner { /// /// If the type has already been inserted and assigned an id before, then /// that entry and its id are reused. - pub fn insert_wasmparser(&mut self, ty: wasmparser::Type, _types_space: &[TypeId]) -> TypeId { + pub fn insert_wasmparser( + &mut self, + ty: wasmparser::CompositeType, + _types_space: &[TypeId], + ) -> TypeId { match ty { - wasmparser::Type::Func(func_ty) => self.insert(Type::Func(func_ty)), - wasmparser::Type::Array(_) => todo!(), + wasmparser::CompositeType::Func(func_ty) => self.insert(Type::Func(func_ty)), + wasmparser::CompositeType::Array(_) => todo!(), + wasmparser::CompositeType::Struct(_) => todo!(), } } diff --git a/crates/wizer/src/lib.rs b/crates/wizer/src/lib.rs index f6a30293d797..306795ff8c91 100644 --- a/crates/wizer/src/lib.rs +++ b/crates/wizer/src/lib.rs @@ -637,6 +637,8 @@ impl Wizer { saturating_float_to_int: true, sign_extension: true, floats: true, + component_model_values: false, + component_model_nested_names: false, // Proposals that we support. multi_memory: self.wasm_multi_memory.unwrap_or(DEFAULT_WASM_MULTI_MEMORY), diff --git a/crates/wizer/src/parse.rs b/crates/wizer/src/parse.rs index 566b837b9760..10ceb20a637e 100644 --- a/crates/wizer/src/parse.rs +++ b/crates/wizer/src/parse.rs @@ -131,12 +131,15 @@ fn type_section<'a>( // Parse out types, as we will need them later when processing // instance imports. - for ty in types { - match ty? { - ty @ wasmparser::Type::Func(_) => { - module.push_type(cx, ty); + for group in types { + for ty in group?.into_types() { + match ty.composite_type { + ty @ wasmparser::CompositeType::Func(_) => { + module.push_type(cx, ty); + } + wasmparser::CompositeType::Array(_) => todo!(), + wasmparser::CompositeType::Struct(_) => todo!(), } - wasmparser::Type::Array(_) => todo!(), } } diff --git a/crates/wizer/tests/regex-test/Cargo.toml b/crates/wizer/tests/regex-test/Cargo.toml index 60c1e9827891..083a9ad09da2 100644 --- a/crates/wizer/tests/regex-test/Cargo.toml +++ b/crates/wizer/tests/regex-test/Cargo.toml @@ -10,4 +10,4 @@ crate-type = ["cdylib"] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -regex = "1.4.2" +regex = "1.10.3" From 020327bc249b8f6f818dd9907f5c4dacd3657458 Mon Sep 17 00:00:00 2001 From: Gentle Date: Mon, 11 Mar 2024 00:03:49 +0100 Subject: [PATCH 178/212] update fuzzing code --- crates/wizer/fuzz/fuzz_targets/same_result.rs | 47 ++----------------- 1 file changed, 3 insertions(+), 44 deletions(-) diff --git a/crates/wizer/fuzz/fuzz_targets/same_result.rs b/crates/wizer/fuzz/fuzz_targets/same_result.rs index 03be40550005..8bf519028044 100644 --- a/crates/wizer/fuzz/fuzz_targets/same_result.rs +++ b/crates/wizer/fuzz/fuzz_targets/same_result.rs @@ -15,16 +15,16 @@ #![no_main] -use libfuzzer_sys::{arbitrary, fuzz_target}; +use libfuzzer_sys::fuzz_target; use wasmtime::*; const FUEL: u32 = 1_000; -fuzz_target!(|module: wasm_smith::ConfiguredModule| { +fuzz_target!(|module: wasm_smith::Module| { let _ = env_logger::try_init(); let mut module = module; - module.ensure_termination(FUEL); + module.ensure_termination(FUEL).unwrap(); let wasm = module.to_bytes(); if log::log_enabled!(log::Level::Debug) { @@ -185,44 +185,3 @@ fn assert_val_eq(a: &Val, b: &Val) { _ => panic!("{:?} != {:?}", a, b), } } - -#[derive(Clone, Default, Debug)] -struct WasmConfig; - -impl<'a> arbitrary::Arbitrary<'a> for WasmConfig { - fn arbitrary(_: &mut arbitrary::Unstructured<'a>) -> arbitrary::Result { - Ok(WasmConfig) - } -} - -impl wasm_smith::Config for WasmConfig { - fn max_memories(&self) -> usize { - 10 - } - - fn max_memory_pages(&self) -> u32 { - // We want small memories that are quick to compare, but we also want to - // allow memories to grow so we can shake out any memory-growth-related - // bugs, so we choose `2` instead of `1`. - 2 - } - - fn min_funcs(&self) -> usize { - // Always generate at least one function that we can hopefully use as an - // initialization function. - 1 - } - - fn min_exports(&self) -> usize { - // Always at least one export, hopefully a function we can use as an - // initialization routine. - 1 - } - - fn memory_offset_choices(&self) -> (u32, u32, u32) { - // Always use an offset immediate that is within the memory's minimum - // size. This should make trapping on loads/stores a little less - // frequent. - (1, 0, 0) - } -} From 2cbdafc6a249b407deee3340b34978a41fc002ac Mon Sep 17 00:00:00 2001 From: Gentle Date: Mon, 11 Mar 2024 17:57:16 +0100 Subject: [PATCH 179/212] add wasm_smith config again --- crates/wizer/fuzz/fuzz_targets/same_result.rs | 34 +++++++++++++++++-- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/crates/wizer/fuzz/fuzz_targets/same_result.rs b/crates/wizer/fuzz/fuzz_targets/same_result.rs index 8bf519028044..324900f72cf4 100644 --- a/crates/wizer/fuzz/fuzz_targets/same_result.rs +++ b/crates/wizer/fuzz/fuzz_targets/same_result.rs @@ -15,15 +15,43 @@ #![no_main] -use libfuzzer_sys::fuzz_target; +use libfuzzer_sys::{ + arbitrary::{Arbitrary, Unstructured}, + fuzz_target, +}; +use wasm_smith::MemoryOffsetChoices; use wasmtime::*; const FUEL: u32 = 1_000; -fuzz_target!(|module: wasm_smith::Module| { +fuzz_target!(|data: &[u8]| { let _ = env_logger::try_init(); - let mut module = module; + let mut u = Unstructured::new(data); + + let mut config = wasm_smith::Config::arbitrary(&mut u).unwrap(); + config.max_memories = 10; + + // We want small memories that are quick to compare, but we also want to + // allow memories to grow so we can shake out any memory-growth-related + // bugs, so we choose `2` instead of `1`. + config.max_memory32_pages = 2; + config.max_memory64_pages = 2; + + // Always generate at least one function that we can hopefully use as an + // initialization function. + config.min_funcs = 1; + + // Always at least one export, hopefully a function we can use as an + // initialization routine. + config.min_exports = 1; + + // Always use an offset immediate that is within the memory's minimum + // size. This should make trapping on loads/stores a little less + // frequent. + config.memory_offset_choices = MemoryOffsetChoices(1, 0, 0); + + let mut module = wasm_smith::Module::new(config, &mut u).unwrap(); module.ensure_termination(FUEL).unwrap(); let wasm = module.to_bytes(); From 97a5e49330bff1add865c153bc0bb38563e81a8e Mon Sep 17 00:00:00 2001 From: Gentle Date: Mon, 11 Mar 2024 23:01:09 +0100 Subject: [PATCH 180/212] fuzzer goes further now --- crates/wizer/fuzz/fuzz_targets/same_result.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/crates/wizer/fuzz/fuzz_targets/same_result.rs b/crates/wizer/fuzz/fuzz_targets/same_result.rs index 324900f72cf4..700a97caf506 100644 --- a/crates/wizer/fuzz/fuzz_targets/same_result.rs +++ b/crates/wizer/fuzz/fuzz_targets/same_result.rs @@ -42,16 +42,22 @@ fuzz_target!(|data: &[u8]| { // initialization function. config.min_funcs = 1; + config.max_funcs = 10; + // Always at least one export, hopefully a function we can use as an // initialization routine. config.min_exports = 1; + config.max_exports = 10; + // Always use an offset immediate that is within the memory's minimum // size. This should make trapping on loads/stores a little less // frequent. config.memory_offset_choices = MemoryOffsetChoices(1, 0, 0); - let mut module = wasm_smith::Module::new(config, &mut u).unwrap(); + let Ok(mut module) = wasm_smith::Module::new(config, &mut u) else { + return; + }; module.ensure_termination(FUEL).unwrap(); let wasm = module.to_bytes(); From 077e6a6b945788662ff23d994f153b19015c1cb5 Mon Sep 17 00:00:00 2001 From: Gentle Date: Mon, 11 Mar 2024 23:50:58 +0100 Subject: [PATCH 181/212] disable wasm features that were added since last update --- crates/wizer/fuzz/fuzz_targets/same_result.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/crates/wizer/fuzz/fuzz_targets/same_result.rs b/crates/wizer/fuzz/fuzz_targets/same_result.rs index 700a97caf506..270e804d38bd 100644 --- a/crates/wizer/fuzz/fuzz_targets/same_result.rs +++ b/crates/wizer/fuzz/fuzz_targets/same_result.rs @@ -55,6 +55,9 @@ fuzz_target!(|data: &[u8]| { // frequent. config.memory_offset_choices = MemoryOffsetChoices(1, 0, 0); + config.reference_types_enabled = false; + config.bulk_memory_enabled = false; + let Ok(mut module) = wasm_smith::Module::new(config, &mut u) else { return; }; From 07d10ad037c76208d8a31f224c1f8e56303d1560 Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Tue, 12 Mar 2024 05:26:02 -0600 Subject: [PATCH 182/212] Bump to version 5.0.0 --- crates/wizer/Cargo.lock | 2 +- crates/wizer/Cargo.toml | 2 +- crates/wizer/npm/wizer/package.json | 14 +++++++------- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/crates/wizer/Cargo.lock b/crates/wizer/Cargo.lock index 5cb8e05638ed..0deef838c989 100644 --- a/crates/wizer/Cargo.lock +++ b/crates/wizer/Cargo.lock @@ -2745,7 +2745,7 @@ dependencies = [ [[package]] name = "wizer" -version = "4.0.0" +version = "5.0.0" dependencies = [ "anyhow", "cap-std 3.0.0", diff --git a/crates/wizer/Cargo.toml b/crates/wizer/Cargo.toml index 6a5efbe51f42..3b7c67f97848 100644 --- a/crates/wizer/Cargo.toml +++ b/crates/wizer/Cargo.toml @@ -10,7 +10,7 @@ license = "Apache-2.0 WITH LLVM-exception" name = "wizer" readme = "./README.md" repository = "https://github.com/bytecodealliance/wizer" -version = "4.0.0" +version = "5.0.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/crates/wizer/npm/wizer/package.json b/crates/wizer/npm/wizer/package.json index 836759f47509..925338fc0e91 100644 --- a/crates/wizer/npm/wizer/package.json +++ b/crates/wizer/npm/wizer/package.json @@ -1,6 +1,6 @@ { "name": "@bytecodealliance/wizer", - "version": "4.0.0", + "version": "5.0.0", "description": "The WebAssembly Pre-Initializer", "type": "module", "scripts": { @@ -20,12 +20,12 @@ "wizer": "./wizer.js" }, "optionalDependencies": { - "@bytecodealliance/wizer-darwin-arm64": "4.0.0", - "@bytecodealliance/wizer-darwin-x64": "4.0.0", - "@bytecodealliance/wizer-linux-x64": "4.0.0", - "@bytecodealliance/wizer-linux-arm64": "4.0.0", - "@bytecodealliance/wizer-linux-s390x": "4.0.0", - "@bytecodealliance/wizer-win32-x64": "4.0.0" + "@bytecodealliance/wizer-darwin-arm64": "5.0.0", + "@bytecodealliance/wizer-darwin-x64": "5.0.0", + "@bytecodealliance/wizer-linux-x64": "5.0.0", + "@bytecodealliance/wizer-linux-arm64": "5.0.0", + "@bytecodealliance/wizer-linux-s390x": "5.0.0", + "@bytecodealliance/wizer-win32-x64": "5.0.0" }, "license": "Apache-2.0", "repository": { From a631e57092a365fb64755020498600cb03287369 Mon Sep 17 00:00:00 2001 From: Gentle Date: Wed, 27 Mar 2024 19:50:24 +0100 Subject: [PATCH 183/212] Update dependencies, wasmtime-19 --- crates/wizer/Cargo.lock | 899 +++++++------------- crates/wizer/Cargo.toml | 18 +- crates/wizer/benches/regex-bench/Cargo.toml | 2 +- crates/wizer/benches/regex.rs | 8 +- crates/wizer/benches/uap-bench/Cargo.toml | 4 +- crates/wizer/benches/uap.rs | 8 +- crates/wizer/fuzz/Cargo.toml | 2 +- crates/wizer/src/dummy.rs | 13 +- crates/wizer/src/lib.rs | 12 +- crates/wizer/tests/make_linker.rs | 2 +- crates/wizer/tests/regex-test/Cargo.toml | 2 +- crates/wizer/tests/tests.rs | 4 +- 12 files changed, 347 insertions(+), 627 deletions(-) diff --git a/crates/wizer/Cargo.lock b/crates/wizer/Cargo.lock index 0deef838c989..93ee5796f0b5 100644 --- a/crates/wizer/Cargo.lock +++ b/crates/wizer/Cargo.lock @@ -11,12 +11,6 @@ dependencies = [ "gimli", ] -[[package]] -name = "adler" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" - [[package]] name = "ahash" version = "0.8.11" @@ -31,9 +25,9 @@ dependencies = [ [[package]] name = "aho-corasick" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" dependencies = [ "memchr", ] @@ -103,7 +97,7 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e28923312444cdd728e4738b3f9c9cac739500909bb3d3c94b43551b16517648" dependencies = [ - "windows-sys 0.52.0", + "windows-sys", ] [[package]] @@ -113,14 +107,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7" dependencies = [ "anstyle", - "windows-sys 0.52.0", + "windows-sys", ] [[package]] name = "anyhow" -version = "1.0.80" +version = "1.0.81" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ad32ce52e4161730f7098c077cd2ed6229b5804ccf99e5366be1ab72a98b4e1" +checksum = "0952808a6c2afd1aa8947271f3a60f1a6763c7b912d210184c5149b5cf147247" [[package]] name = "arbitrary" @@ -133,13 +127,13 @@ dependencies = [ [[package]] name = "async-trait" -version = "0.1.77" +version = "0.1.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c980ee35e870bd1a4d2c8294d4c04d0499e67bca1e4b5cefcc693c2fa00caea9" +checksum = "a507401cad91ec6a857ed5513a2073c82a9b9048762b885bb98655b306964681" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.55", ] [[package]] @@ -155,24 +149,9 @@ dependencies = [ [[package]] name = "autocfg" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" - -[[package]] -name = "backtrace" -version = "0.3.69" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" -dependencies = [ - "addr2line", - "cc", - "cfg-if", - "libc", - "miniz_oxide", - "object", - "rustc-demangle", -] +checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" [[package]] name = "base64" @@ -197,9 +176,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.4.2" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" +checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" [[package]] name = "block-buffer" @@ -222,51 +201,16 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" -[[package]] -name = "bytes" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" - [[package]] name = "cap-fs-ext" -version = "2.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88e341d15ac1029aadce600be764a1a1edafe40e03cde23285bc1d261b3a4866" -dependencies = [ - "cap-primitives 2.0.1", - "cap-std 2.0.1", - "io-lifetimes", - "windows-sys 0.52.0", -] - -[[package]] -name = "cap-net-ext" -version = "2.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "434168fe6533055f0f4204039abe3ff6d7db338ef46872a5fa39e9d5ad5ab7a9" -dependencies = [ - "cap-primitives 2.0.1", - "cap-std 2.0.1", - "rustix", - "smallvec", -] - -[[package]] -name = "cap-primitives" -version = "2.0.1" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe16767ed8eee6d3f1f00d6a7576b81c226ab917eb54b96e5f77a5216ef67abb" +checksum = "769f8cd02eb04d57f14e2e371ebb533f96817f9b2525d73a5c72b61ca7973747" dependencies = [ - "ambient-authority", - "fs-set-times", - "io-extras", + "cap-primitives", + "cap-std", "io-lifetimes", - "ipnet", - "maybe-owned", - "rustix", - "windows-sys 0.52.0", - "winx", + "windows-sys", ] [[package]] @@ -282,39 +226,27 @@ dependencies = [ "ipnet", "maybe-owned", "rustix", - "windows-sys 0.52.0", + "windows-sys", "winx", ] [[package]] name = "cap-rand" -version = "2.0.1" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20e5695565f0cd7106bc3c7170323597540e772bb73e0be2cd2c662a0f8fa4ca" +checksum = "4327f08daac33a99bb03c54ae18c8f32c3ba31c728a33ddf683c6c6a5043de68" dependencies = [ "ambient-authority", "rand", ] -[[package]] -name = "cap-std" -version = "2.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "593db20e4c51f62d3284bae7ee718849c3214f93a3b94ea1899ad85ba119d330" -dependencies = [ - "cap-primitives 2.0.1", - "io-extras", - "io-lifetimes", - "rustix", -] - [[package]] name = "cap-std" version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "266626ce180cf9709f317d0bf9754e3a5006359d87f4bf792f06c9c5f1b63c0f" dependencies = [ - "cap-primitives 3.0.0", + "cap-primitives", "io-extras", "io-lifetimes", "rustix", @@ -322,12 +254,12 @@ dependencies = [ [[package]] name = "cap-time-ext" -version = "2.0.1" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03261630f291f425430a36f38c847828265bc928f517cdd2004c56f4b02f002b" +checksum = "e1353421ba83c19da60726e35db0a89abef984b3be183ff6f58c5b8084fcd0c5" dependencies = [ "ambient-authority", - "cap-primitives 2.0.1", + "cap-primitives", "iana-time-zone", "once_cell", "rustix", @@ -342,10 +274,11 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" [[package]] name = "cc" -version = "1.0.88" +version = "1.0.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02f341c093d19155a6e41631ce5971aac4e9a868262212153124c15fa22d1cdc" +checksum = "8cd6604a82acf3039f1144f54b8eb34e91ffba622051189e71b781822d5ee1f5" dependencies = [ + "jobserver", "libc", ] @@ -399,18 +332,18 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.1" +version = "4.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c918d541ef2913577a0f9566e9ce27cb35b6df072075769e0b26cb5a554520da" +checksum = "90bc066a67923782aa8515dbaea16946c5bcc5addbd668bb80af688e53e548a0" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.5.1" +version = "4.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f3e7391dad68afb0c2ede1bf619f579a3dc9c2ec67f089baa397123a2f3d1eb" +checksum = "ae129e2e766ae0ec03484e609954119f123cc1fe650337e155d03b022f24f7b4" dependencies = [ "anstyle", "clap_lex", @@ -436,9 +369,9 @@ checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" [[package]] name = "cpp_demangle" -version = "0.3.5" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eeaa953eaad386a53111e47172c2fedba671e5684c8dd601a5f474f4f118710f" +checksum = "7e8227005286ec39567949b33df9896bcadfa6051bccca2488129f108ca23119" dependencies = [ "cfg-if", ] @@ -454,18 +387,18 @@ dependencies = [ [[package]] name = "cranelift-bforest" -version = "0.105.2" +version = "0.106.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9515fcc42b6cb5137f76b84c1a6f819782d0cf12473d145d3bc5cd67eedc8bc2" +checksum = "6a535eb1cf5a6003197dc569320c40c1cb2d2f97ef5d5348eebf067f20957381" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-codegen" -version = "0.105.2" +version = "0.106.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ad827c6071bfe6d22de1bc331296a29f9ddc506ff926d8415b435ec6a6efce0" +checksum = "11b5066db32cec1492573827183af2142d2d88fe85a83cfc9e73f0f63d3788d4" dependencies = [ "bumpalo", "cranelift-bforest", @@ -484,33 +417,33 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.105.2" +version = "0.106.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10e6b36237a9ca2ce2fb4cc7741d418a080afa1327402138412ef85d5367bef1" +checksum = "64942e5774308e835fbad4dd25f253105412c90324631910e1ec27963147bddb" dependencies = [ "cranelift-codegen-shared", ] [[package]] name = "cranelift-codegen-shared" -version = "0.105.2" +version = "0.106.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c36bf4bfb86898a94ccfa773a1f86e8a5346b1983ff72059bdd2db4600325251" +checksum = "c39c33db9a86dd6d8d04166a10c53deb477aeea3500eaaefca682e4eda9bb986" [[package]] name = "cranelift-control" -version = "0.105.2" +version = "0.106.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cbf36560e7a6bd1409ca91e7b43b2cc7ed8429f343d7605eadf9046e8fac0d0" +checksum = "4b7fc4937613aea3156a0538800a17bf56f345a5da2e79ae3df58488c93d867f" dependencies = [ "arbitrary", ] [[package]] name = "cranelift-entity" -version = "0.105.2" +version = "0.106.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a71e11061a75b1184c09bea97c026a88f08b59ade96a7bb1f259d4ea0df2e942" +checksum = "f85575e79a153ce1ddbfb7fe1813519b4bfe1eb200cc9c8353b45ad123ae4d36" dependencies = [ "serde", "serde_derive", @@ -518,9 +451,9 @@ dependencies = [ [[package]] name = "cranelift-frontend" -version = "0.105.2" +version = "0.106.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af5d4da63143ee3485c7bcedde0a818727d737d1083484a0ceedb8950c89e495" +checksum = "bbc31d6c0ab2249fe0c21e988256b42f5f401ab2673b4fc40076c82a698bdfb9" dependencies = [ "cranelift-codegen", "log", @@ -530,15 +463,15 @@ dependencies = [ [[package]] name = "cranelift-isle" -version = "0.105.2" +version = "0.106.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "457a9832b089e26f5eea70dcf49bed8ec6edafed630ce7c83161f24d46ab8085" +checksum = "dc14f37e3314c0e4c53779c2f46753bf242efff76ee9473757a1fff3b495ad37" [[package]] name = "cranelift-native" -version = "0.105.2" +version = "0.106.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b490d579df1ce365e1ea359e24ed86d82289fa785153327c2f6a69a59a731e4" +checksum = "2ea5375f76ab31f9800a23fb2b440810286a6f669a3eb467cdd7ff255ea64268" dependencies = [ "cranelift-codegen", "libc", @@ -547,17 +480,17 @@ dependencies = [ [[package]] name = "cranelift-wasm" -version = "0.105.2" +version = "0.106.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cd747ed7f9a461dda9c388415392f6bb95d1a6ef3b7694d17e0817eb74b7798" +checksum = "79851dba01b1fa83fad95134aa27beca88dc4b027121d92ab19788582389dc5f" dependencies = [ "cranelift-codegen", "cranelift-entity", "cranelift-frontend", - "itertools", + "itertools 0.12.1", "log", "smallvec", - "wasmparser 0.121.2", + "wasmparser 0.201.0", "wasmtime-types", ] @@ -579,10 +512,10 @@ dependencies = [ "anes", "cast", "ciborium", - "clap 4.5.1", + "clap 4.5.4", "criterion-plot", "is-terminal", - "itertools", + "itertools 0.10.5", "num-traits", "once_cell", "oorandom", @@ -603,7 +536,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6b50826342786a51a89e2da3a28f1c32b06e387201bc2d19791f622c673706b1" dependencies = [ "cast", - "itertools", + "itertools 0.10.5", ] [[package]] @@ -664,7 +597,7 @@ checksum = "67e77553c4162a157adbf834ebae5b415acbecbeafc7a74b0e886657506a7611" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.55", ] [[package]] @@ -769,7 +702,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" dependencies = [ "libc", - "windows-sys 0.52.0", + "windows-sys", ] [[package]] @@ -786,7 +719,7 @@ checksum = "7e5768da2206272c81ef0b5e951a41862938a6070da63bcea197899942d3b947" dependencies = [ "cfg-if", "rustix", - "windows-sys 0.52.0", + "windows-sys", ] [[package]] @@ -795,15 +728,6 @@ version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cdeb3aa5e95cf9aabc17f060cfa0ced7b83f042390760ca53bf09df9968acaa1" -[[package]] -name = "form_urlencoded" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" -dependencies = [ - "percent-encoding", -] - [[package]] name = "fs-set-times" version = "0.20.1" @@ -812,68 +736,7 @@ checksum = "033b337d725b97690d86893f9de22b67b80dcc4e9ad815f348254c38119db8fb" dependencies = [ "io-lifetimes", "rustix", - "windows-sys 0.52.0", -] - -[[package]] -name = "futures" -version = "0.3.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" -dependencies = [ - "futures-channel", - "futures-core", - "futures-io", - "futures-sink", - "futures-task", - "futures-util", -] - -[[package]] -name = "futures-channel" -version = "0.3.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" -dependencies = [ - "futures-core", - "futures-sink", -] - -[[package]] -name = "futures-core" -version = "0.3.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" - -[[package]] -name = "futures-io" -version = "0.3.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" - -[[package]] -name = "futures-sink" -version = "0.3.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" - -[[package]] -name = "futures-task" -version = "0.3.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" - -[[package]] -name = "futures-util" -version = "0.3.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" -dependencies = [ - "futures-core", - "futures-sink", - "futures-task", - "pin-project-lite", - "pin-utils", + "windows-sys", ] [[package]] @@ -891,7 +754,7 @@ version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "27d12c0aed7f1e24276a241aadc4cb8ea9f83000f34bc062b7cc2d51e3b0fabd" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "debugid", "fxhash", "serde", @@ -1023,21 +886,11 @@ version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "25a2bc672d1148e28034f176e01fffebb08b35768468cc954630da77a1449005" -[[package]] -name = "idna" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" -dependencies = [ - "unicode-bidi", - "unicode-normalization", -] - [[package]] name = "indexmap" -version = "2.2.5" +version = "2.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b0b929d511467233429c45a44ac1dcaa21ba0f5ba11e4879e6ed28ddb4f9df4" +checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" dependencies = [ "equivalent", "hashbrown 0.14.3", @@ -1051,7 +904,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c301e73fb90e8a29e600a9f402d095765f74310d582916a952f618836a1bd1ed" dependencies = [ "io-lifetimes", - "windows-sys 0.52.0", + "windows-sys", ] [[package]] @@ -1074,7 +927,7 @@ checksum = "f23ff5ef2b80d608d61efee834934d862cd92461afc0560dedf493e4c033738b" dependencies = [ "hermit-abi 0.3.9", "libc", - "windows-sys 0.52.0", + "windows-sys", ] [[package]] @@ -1086,11 +939,20 @@ dependencies = [ "either", ] +[[package]] +name = "itertools" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" +dependencies = [ + "either", +] + [[package]] name = "itoa" -version = "1.0.10" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "ittapi" @@ -1112,11 +974,20 @@ dependencies = [ "cc", ] +[[package]] +name = "jobserver" +version = "0.1.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab46a6e9526ddef3ae7f787c06f0f2600639ba80ea3eade3d8e670a2230f51d6" +dependencies = [ + "libc", +] + [[package]] name = "js-sys" -version = "0.3.68" +version = "0.3.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "406cda4b368d531c842222cf9d2600a9a4acce8d29423695379c6868a143a9ee" +checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d" dependencies = [ "wasm-bindgen", ] @@ -1156,7 +1027,7 @@ version = "0.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "85c833ca1e66078851dba29046874e38f08b2c883700aa29a03ddd3b23814ee8" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "libc", "redox_syscall", ] @@ -1205,33 +1076,13 @@ dependencies = [ [[package]] name = "memoffset" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c" +checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a" dependencies = [ "autocfg", ] -[[package]] -name = "miniz_oxide" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d811f3e15f28568be3407c8e7fdb6514c1cda3cb30683f15b6a1a1dc4ea14a7" -dependencies = [ - "adler", -] - -[[package]] -name = "mio" -version = "0.8.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f3d0b296e374a4e6f3c7b0a1f5a51d748a0d34c85e7dc48fc3fa9a87657fe09" -dependencies = [ - "libc", - "wasi", - "windows-sys 0.48.0", -] - [[package]] name = "num-traits" version = "0.2.18" @@ -1241,16 +1092,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "num_cpus" -version = "1.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" -dependencies = [ - "hermit-abi 0.3.9", - "libc", -] - [[package]] name = "object" version = "0.32.2" @@ -1281,24 +1122,12 @@ version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" -[[package]] -name = "percent-encoding" -version = "2.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" - [[package]] name = "pin-project-lite" version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" -[[package]] -name = "pin-utils" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" - [[package]] name = "pkg-config" version = "0.3.30" @@ -1365,9 +1194,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.78" +version = "1.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" +checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e" dependencies = [ "unicode-ident", ] @@ -1422,9 +1251,9 @@ dependencies = [ [[package]] name = "rayon" -version = "1.9.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4963ed1bc86e4f3ee217022bd855b297cef07fb9eac5dfa1f788b220b49b3bd" +checksum = "b418a60154510ca1a002a752ca9714984e21e4241e804d32555251faf8b78ffa" dependencies = [ "either", "rayon-core", @@ -1475,9 +1304,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.3" +version = "1.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15" +checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c" dependencies = [ "aho-corasick", "memchr", @@ -1505,9 +1334,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" +checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" [[package]] name = "regex-test" @@ -1530,17 +1359,17 @@ checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" [[package]] name = "rustix" -version = "0.38.31" +version = "0.38.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ea3e1a662af26cd7a3ba09c0297a31af215563ecf42817c98df621387f4e949" +checksum = "65e04861e65f21776e67888bfbea442b3642beaa0138fdb1dd7a84a52dffdb89" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "errno", "itoa", "libc", "linux-raw-sys", "once_cell", - "windows-sys 0.52.0", + "windows-sys", ] [[package]] @@ -1581,25 +1410,34 @@ checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.55", ] [[package]] name = "serde_json" -version = "1.0.114" +version = "1.0.115" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5f09b1bd632ef549eaa9f60a1f8de742bdbc698e6cee2095fc84dde5f549ae0" +checksum = "12dc5c46daa8e9fdf4f5e71b6cf9a53f2487da0e86e55808e2d35539666497dd" dependencies = [ "itoa", "ryu", "serde", ] +[[package]] +name = "serde_spanned" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb3622f419d1296904700073ea6cc23ad690adbd66f13ea683df73298736f0c1" +dependencies = [ + "serde", +] + [[package]] name = "serde_yaml" -version = "0.9.32" +version = "0.9.34+deprecated" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fd075d994154d4a774f95b51fb96bdc2832b0ea48425c92546073816cda1f2f" +checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47" dependencies = [ "indexmap", "itoa", @@ -1636,19 +1474,9 @@ checksum = "826167069c09b99d56f31e9ae5c99049e932a98c9dc2dac47645b08dbbf76ba7" [[package]] name = "smallvec" -version = "1.13.1" +version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6ecd384b10a64542d77071bd64bd7b231f4ed5940fba55e98c3de13824cf3d7" - -[[package]] -name = "socket2" -version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05ffd9c0a93b7543e062e759284fcf5f5e3b098501104bfbdde4d404db792871" -dependencies = [ - "libc", - "windows-sys 0.52.0", -] +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] name = "sptr" @@ -1705,9 +1533,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.52" +version = "2.0.55" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b699d15b36d1f02c3e7c69f8ffef53de37aefae075d8488d4ba1a7788d574a07" +checksum = "002a1b3dbf967edfafc32655d0f377ab0bb7b994aa1d32c8cc7e9b8bf3ebb8f0" dependencies = [ "proc-macro2", "quote", @@ -1716,17 +1544,17 @@ dependencies = [ [[package]] name = "system-interface" -version = "0.26.1" +version = "0.27.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0682e006dd35771e392a6623ac180999a9a854b1d4a6c12fb2e804941c2b1f58" +checksum = "9aef1f9d4c1dbdd1cb3a63be9efd2f04d8ddbc919d46112982c76818ffc2f1a7" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "cap-fs-ext", - "cap-std 2.0.1", + "cap-std", "fd-lock", "io-lifetimes", "rustix", - "windows-sys 0.52.0", + "windows-sys", "winx", ] @@ -1747,22 +1575,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.57" +version = "1.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e45bcbe8ed29775f228095caf2cd67af7a4ccf756ebff23a306bf3e8b47b24b" +checksum = "03468839009160513471e86a034bb2c5c0e4baae3b43f79ffc55c4a5427b3297" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.57" +version = "1.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a953cb265bef375dae3de6663da4d3804eee9682ea80d8e2542529b73c531c81" +checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.55", ] [[package]] @@ -1776,43 +1604,37 @@ dependencies = [ ] [[package]] -name = "tinyvec" -version = "1.6.0" +name = "toml" +version = "0.8.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +checksum = "e9dd1545e8208b4a5af1aa9bbd0b4cf7e9ea08fabc5d0a5c67fcaafa17433aa3" dependencies = [ - "tinyvec_macros", + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit", ] [[package]] -name = "tinyvec_macros" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" - -[[package]] -name = "tokio" -version = "1.36.0" +name = "toml_datetime" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61285f6515fa018fb2d1e46eb21223fff441ee8db5d0f1435e8ab4f5cdb80931" +checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" dependencies = [ - "backtrace", - "bytes", - "libc", - "mio", - "num_cpus", - "pin-project-lite", - "socket2", - "windows-sys 0.48.0", + "serde", ] [[package]] -name = "toml" -version = "0.5.11" +name = "toml_edit" +version = "0.22.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" +checksum = "8e40bb779c5187258fd7aad0eb68cb8706a0a81fa712fbea808ab43c4b8374c4" dependencies = [ + "indexmap", "serde", + "serde_spanned", + "toml_datetime", + "winnow", ] [[package]] @@ -1835,7 +1657,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.55", ] [[package]] @@ -1862,27 +1684,12 @@ dependencies = [ "serde_yaml", ] -[[package]] -name = "unicode-bidi" -version = "0.3.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" - [[package]] name = "unicode-ident" version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" -[[package]] -name = "unicode-normalization" -version = "0.1.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5" -dependencies = [ - "tinyvec", -] - [[package]] name = "unicode-segmentation" version = "1.11.0" @@ -1903,20 +1710,9 @@ checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" [[package]] name = "unsafe-libyaml" -version = "0.2.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab4c90930b95a82d00dc9e9ac071b4991924390d46cbd0dfe566148667605e4b" - -[[package]] -name = "url" -version = "2.5.0" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" -dependencies = [ - "form_urlencoded", - "idna", - "percent-encoding", -] +checksum = "673aac59facbab8a9007c7f6108d11f63b603f7cabff99fabf650fea5c32b861" [[package]] name = "utf8parse" @@ -1926,9 +1722,9 @@ checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" [[package]] name = "uuid" -version = "1.7.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f00cc9702ca12d3c81455259621e676d0f7251cec66a21e98fe2e9a37db93b2a" +checksum = "a183cf7feeba97b4dd1c0d46788634f6221d87fa961b305bed08c851829efcc0" [[package]] name = "vec_map" @@ -1944,9 +1740,9 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "walkdir" -version = "2.4.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d71d857dc86794ca4c280d616f7da00d2dbfd8cd788846559a6813e6aa4b54ee" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" dependencies = [ "same-file", "winapi-util", @@ -1960,15 +1756,15 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasi-common" -version = "18.0.2" +version = "19.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "880c1461417b2bf90262591bf8a5f04358fb86dac8a585a49b87024971296763" +checksum = "1df07660d36c7e6bceccb546b58d0901319db633549ae56124cbc5c7285d1ee0" dependencies = [ "anyhow", - "bitflags 2.4.2", + "bitflags 2.5.0", "cap-fs-ext", "cap-rand", - "cap-std 2.0.1", + "cap-std", "cap-time-ext", "fs-set-times", "io-extras", @@ -1981,14 +1777,14 @@ dependencies = [ "tracing", "wasmtime", "wiggle", - "windows-sys 0.52.0", + "windows-sys", ] [[package]] name = "wasm-bindgen" -version = "0.2.91" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1e124130aee3fb58c5bdd6b639a0509486b0338acaaae0c84a5124b0f588b7f" +checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -1996,24 +1792,24 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.91" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9e7e1900c352b609c8488ad12639a311045f40a35491fb69ba8c12f758af70b" +checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.55", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.91" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b30af9e2d358182b5c7449424f017eba305ed32a7010509ede96cdc4696c46ed" +checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -2021,102 +1817,102 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.91" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "642f325be6301eb8107a83d12a8ac6c1e1c54345a7ef1a9261962dfefda09e66" +checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.55", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.91" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f186bd2dcf04330886ce82d6f33dd75a7bfcf69ecf5763b89fcde53b6ac9838" +checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" [[package]] name = "wasm-encoder" -version = "0.41.2" +version = "0.201.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "972f97a5d8318f908dded23594188a90bcd09365986b1163e66d70170e5287ae" +checksum = "b9c7d2731df60006819b013f64ccc2019691deccf6e11a1804bc850cd6748f1a" dependencies = [ "leb128", ] [[package]] name = "wasm-encoder" -version = "0.201.0" +version = "0.202.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9c7d2731df60006819b013f64ccc2019691deccf6e11a1804bc850cd6748f1a" +checksum = "bfd106365a7f5f7aa3c1916a98cbb3ad477f5ff96ddb130285a91c6e7429e67a" dependencies = [ "leb128", ] [[package]] name = "wasm-smith" -version = "0.201.0" +version = "0.202.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61ff53a54a853f174b0df74cdb1553f1451e7bcdc23b26b1379f664ee1913d1a" +checksum = "4cf58fe4c46def4c0cdab0818cf0e663db7a018473795349996c48335d5d1163" dependencies = [ "anyhow", "arbitrary", "flagset", "indexmap", "leb128", - "wasm-encoder 0.201.0", + "wasm-encoder 0.202.0", ] [[package]] name = "wasmparser" -version = "0.121.2" +version = "0.201.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9dbe55c8f9d0dbd25d9447a5a889ff90c0cc3feaa7395310d3d826b2c703eaab" +checksum = "84e5df6dba6c0d7fafc63a450f1738451ed7a0b52295d83e868218fa286bf708" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "indexmap", "semver", ] [[package]] name = "wasmparser" -version = "0.201.0" +version = "0.202.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84e5df6dba6c0d7fafc63a450f1738451ed7a0b52295d83e868218fa286bf708" +checksum = "d6998515d3cf3f8b980ef7c11b29a9b1017d4cf86b99ae93b546992df9931413" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "indexmap", "semver", ] [[package]] name = "wasmprinter" -version = "0.2.80" +version = "0.201.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60e73986a6b7fdfedb7c5bf9e7eb71135486507c8fbc4c0c42cffcb6532988b7" +checksum = "a67e66da702706ba08729a78e3c0079085f6bfcb1a62e4799e97bbf728c2c265" dependencies = [ "anyhow", - "wasmparser 0.121.2", + "wasmparser 0.201.0", ] [[package]] name = "wasmprinter" -version = "0.201.0" +version = "0.202.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a67e66da702706ba08729a78e3c0079085f6bfcb1a62e4799e97bbf728c2c265" +checksum = "ab1cc9508685eef9502e787f4d4123745f5651a1e29aec047645d3cac1e2da7a" dependencies = [ "anyhow", - "wasmparser 0.201.0", + "wasmparser 0.202.0", ] [[package]] name = "wasmtime" -version = "18.0.2" +version = "19.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c843b8bc4dd4f3a76173ba93405c71111d570af0d90ea5f6299c705d0c2add2" +checksum = "6a08af88fa3d324cc5cf6d388d90ef396a787b3fb4bbd51ba185f8645dc0f02c" dependencies = [ "addr2line", "anyhow", @@ -2136,12 +1932,13 @@ dependencies = [ "paste", "rayon", "rustix", + "semver", "serde", "serde_derive", "serde_json", "target-lexicon", - "wasm-encoder 0.41.2", - "wasmparser 0.121.2", + "wasm-encoder 0.201.0", + "wasmparser 0.201.0", "wasmtime-cache", "wasmtime-component-macro", "wasmtime-component-util", @@ -2151,25 +1948,26 @@ dependencies = [ "wasmtime-jit-debug", "wasmtime-jit-icache-coherence", "wasmtime-runtime", + "wasmtime-slab", "wasmtime-winch", "wat", - "windows-sys 0.52.0", + "windows-sys", ] [[package]] name = "wasmtime-asm-macros" -version = "18.0.2" +version = "19.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86b9d329c718b3a18412a6a017c912b539baa8fe1210d21b651f6b4dbafed743" +checksum = "16cdbfcf28542bcda0b5fd68d44603e53e5ad126cbe7b9f25c130e1249fd8211" dependencies = [ "cfg-if", ] [[package]] name = "wasmtime-cache" -version = "18.0.2" +version = "19.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fb4fc2bbf9c790a57875eba65588fa97acf57a7d784dc86d057e648d9a1ed91" +checksum = "546b85be1a1d380ba821aeb0252b656359d0ce027b16fef8fc0e2f2b9159e193" dependencies = [ "anyhow", "base64", @@ -2181,20 +1979,20 @@ dependencies = [ "serde_derive", "sha2", "toml", - "windows-sys 0.52.0", + "windows-sys", "zstd", ] [[package]] name = "wasmtime-component-macro" -version = "18.0.2" +version = "19.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8d55ddfd02898885c39638eae9631cd430c83a368f5996ed0f7bfb181d02157" +checksum = "0cdcf690257c623506eeec3a502864b282aab0fdfd6981c1ebb63c7e98f4a23a" dependencies = [ "anyhow", "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.55", "wasmtime-component-util", "wasmtime-wit-bindgen", "wit-parser", @@ -2202,15 +2000,15 @@ dependencies = [ [[package]] name = "wasmtime-component-util" -version = "18.0.2" +version = "19.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d6d69c430cddc70ec42159506962c66983ce0192ebde4eb125b7aabc49cff88" +checksum = "ab3ae7bf66e2fae1e332ab3634f332d7422e878a6eecc47c8f8f78cc1f24e501" [[package]] name = "wasmtime-cranelift" -version = "18.0.2" +version = "19.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31ca62f519225492bd555d0ec85a2dacb0c10315db3418c8b9aeb3824bf54a24" +checksum = "67ea025c969a09117818732fa6f96848e858a7953d4659dab8081a6eea3c0523" dependencies = [ "anyhow", "cfg-if", @@ -2225,7 +2023,7 @@ dependencies = [ "object", "target-lexicon", "thiserror", - "wasmparser 0.121.2", + "wasmparser 0.201.0", "wasmtime-cranelift-shared", "wasmtime-environ", "wasmtime-versioned-export-macros", @@ -2233,9 +2031,9 @@ dependencies = [ [[package]] name = "wasmtime-cranelift-shared" -version = "18.0.2" +version = "19.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd5f2071f42e61490bf7cb95b9acdbe6a29dd577a398019304a960585f28b844" +checksum = "dcd6dd2f8d8d4860b384f61f89b597633a5b5f0943c546210e5084c5d321fe20" dependencies = [ "anyhow", "cranelift-codegen", @@ -2249,9 +2047,9 @@ dependencies = [ [[package]] name = "wasmtime-environ" -version = "18.0.2" +version = "19.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82bf1a47f384610da19f58b0fd392ca6a3b720974315c08afb0392c0f3951fed" +checksum = "7f60f3f717658dd77745de03b750d5852126e9be6dad465848c77f90387c44c9" dependencies = [ "anyhow", "bincode", @@ -2266,18 +2064,18 @@ dependencies = [ "serde_derive", "target-lexicon", "thiserror", - "wasm-encoder 0.41.2", - "wasmparser 0.121.2", - "wasmprinter 0.2.80", + "wasm-encoder 0.201.0", + "wasmparser 0.201.0", + "wasmprinter 0.201.0", "wasmtime-component-util", "wasmtime-types", ] [[package]] name = "wasmtime-fiber" -version = "18.0.2" +version = "19.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e31aecada2831e067ebfe93faa3001cc153d506f8af40bbea58aa1d20fe4820" +checksum = "bf8cd22ab1041bf0e54b6283e57824557902e4fed8b1f3a7eef29cbaba89eebf" dependencies = [ "anyhow", "cc", @@ -2285,14 +2083,14 @@ dependencies = [ "rustix", "wasmtime-asm-macros", "wasmtime-versioned-export-macros", - "windows-sys 0.52.0", + "windows-sys", ] [[package]] name = "wasmtime-jit-debug" -version = "18.0.2" +version = "19.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "833dae95bc7a4f9177bf93f9497419763535b74e37eb8c37be53937d3281e287" +checksum = "8753654f698354950a557d0d0cbdecf356c973659920091cf3d5fada74183e02" dependencies = [ "object", "once_cell", @@ -2302,20 +2100,20 @@ dependencies = [ [[package]] name = "wasmtime-jit-icache-coherence" -version = "18.0.2" +version = "19.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33f4121cb29dda08139b2824a734dd095d83ce843f2d613a84eb580b9cfc17ac" +checksum = "2796e4b4989db62899d2117e1e0258b839d088c044591b14e3a0396e7b3ae53a" dependencies = [ "cfg-if", "libc", - "windows-sys 0.52.0", + "windows-sys", ] [[package]] name = "wasmtime-runtime" -version = "18.0.2" +version = "19.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e517f2b996bb3b0e34a82a2bce194f850d9bcfc25c08328ef5fb71b071066b8" +checksum = "4bf2b7745df452a4f41b9aab21d3f7ba1347b12da2fdc5241e59306127884a68" dependencies = [ "anyhow", "cc", @@ -2331,85 +2129,58 @@ dependencies = [ "psm", "rustix", "sptr", - "wasm-encoder 0.41.2", + "wasm-encoder 0.201.0", "wasmtime-asm-macros", "wasmtime-environ", "wasmtime-fiber", "wasmtime-jit-debug", "wasmtime-versioned-export-macros", "wasmtime-wmemcheck", - "windows-sys 0.52.0", + "windows-sys", ] +[[package]] +name = "wasmtime-slab" +version = "19.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83448ef600ad95977019ebaea84a5516fdbc9561d0a8e26b1e099351f993b527" + [[package]] name = "wasmtime-types" -version = "18.0.2" +version = "19.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54a327d7a0ef57bd52a507d28b4561a74126c7a8535a2fc6f2025716bc6a52e8" +checksum = "cf6fe7ed3fd18ed4b1e4465fe5c8674acc9f03523fca5b1b9f975b2560cd741b" dependencies = [ "cranelift-entity", "serde", "serde_derive", "thiserror", - "wasmparser 0.121.2", + "wasmparser 0.201.0", ] [[package]] name = "wasmtime-versioned-export-macros" -version = "18.0.2" +version = "19.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ef32eea9fc7035a55159a679d1e89b43ece5ae45d24eed4808e6a92c99a0da4" +checksum = "6d6d967f01032da7d4c6303da32f6a00d5efe1bac124b156e7342d8ace6ffdfc" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", -] - -[[package]] -name = "wasmtime-wasi" -version = "18.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d04d2fb2257245aa05ff799ded40520ae4d8cd31b0d14972afac89061f12fe12" -dependencies = [ - "anyhow", - "async-trait", - "bitflags 2.4.2", - "bytes", - "cap-fs-ext", - "cap-net-ext", - "cap-rand", - "cap-std 2.0.1", - "cap-time-ext", - "fs-set-times", - "futures", - "io-extras", - "io-lifetimes", - "log", - "once_cell", - "rustix", - "system-interface", - "thiserror", - "tokio", - "tracing", - "url", - "wasi-common", - "wasmtime", - "wiggle", - "windows-sys 0.52.0", + "syn 2.0.55", ] [[package]] name = "wasmtime-winch" -version = "18.0.2" +version = "19.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db3378c0e808a744b5d4df2a9a9d2746a53b151811926731f04fc401707f7d54" +checksum = "eb8b3fcbc455105760e4a2aa8ee3f39b8357183a62201383b3f72d4836ca2be8" dependencies = [ "anyhow", "cranelift-codegen", "gimli", "object", "target-lexicon", - "wasmparser 0.121.2", + "wasmparser 0.201.0", "wasmtime-cranelift-shared", "wasmtime-environ", "winch-codegen", @@ -2417,9 +2188,9 @@ dependencies = [ [[package]] name = "wasmtime-wit-bindgen" -version = "18.0.2" +version = "19.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca677c36869e45602617b25a9968ec0d895ad9a0aee3756d9dee1ddd89456f91" +checksum = "96326c9800fb6c099f50d1bd2126d636fc2f96950e1675acf358c0f52516cd38" dependencies = [ "anyhow", "heck 0.4.1", @@ -2429,9 +2200,9 @@ dependencies = [ [[package]] name = "wasmtime-wmemcheck" -version = "18.0.2" +version = "19.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f4cbfb052d66f03603a9b77f18171ea245c7805714caad370a549a6344bf86b" +checksum = "36bd91a4dc55af0bf55e9e2ab0ea13724cfb5c5a1acdf8873039769208f59490" [[package]] name = "wast" @@ -2444,31 +2215,31 @@ dependencies = [ [[package]] name = "wast" -version = "201.0.0" +version = "202.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ef6e1ef34d7da3e2b374fd2b1a9c0227aff6cad596e1b24df9b58d0f6222faa" +checksum = "1fbcb11204515c953c9b42ede0a46a1c5e17f82af05c4fae201a8efff1b0f4fe" dependencies = [ "bumpalo", "leb128", "memchr", "unicode-width", - "wasm-encoder 0.201.0", + "wasm-encoder 0.202.0", ] [[package]] name = "wat" -version = "1.201.0" +version = "1.202.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "453d5b37a45b98dee4f4cb68015fc73634d7883bbef1c65e6e9c78d454cf3f32" +checksum = "4de4b15a47135c56a3573406e9977b9518787a6154459b4842a9b9d3d1684848" dependencies = [ - "wast 201.0.0", + "wast 202.0.0", ] [[package]] name = "web-sys" -version = "0.3.68" +version = "0.3.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96565907687f7aceb35bc5fc03770a8a0471d82e479f25832f54a0e3f4b28446" +checksum = "77afa9a11836342370f4817622a2f0f418b134426d91a82dfb48f532d2ec13ef" dependencies = [ "js-sys", "wasm-bindgen", @@ -2476,13 +2247,13 @@ dependencies = [ [[package]] name = "wiggle" -version = "18.0.2" +version = "19.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b69812e493f8a43d8551abfaaf9539e1aff0cf56a58cdd276845fc4af035d0cd" +checksum = "ae1136a209614ace00b0c11f04dc7cf42540773be3b22eff6ad165110aba29c1" dependencies = [ "anyhow", "async-trait", - "bitflags 2.4.2", + "bitflags 2.5.0", "thiserror", "tracing", "wasmtime", @@ -2491,28 +2262,28 @@ dependencies = [ [[package]] name = "wiggle-generate" -version = "18.0.2" +version = "19.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0446357a5a7af0172848b6eca7b2aa1ab7d90065cd2ab02b633a322e1a52f636" +checksum = "4c2bd99ce26046f4246d720a4198f6a8fc95bc5da82ae4ef62263e24641c3076" dependencies = [ "anyhow", "heck 0.4.1", "proc-macro2", "quote", "shellexpand", - "syn 2.0.52", + "syn 2.0.55", "witx", ] [[package]] name = "wiggle-macro" -version = "18.0.2" +version = "19.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9498ef53a12cf25dc6de9baef6ccd8b58d159202c412a19f4d72b218393086c5" +checksum = "512d816dbcd0113103b2eb2402ec9018e7f0755202a5b3e67db726f229d8dcae" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.55", "wiggle-generate", ] @@ -2549,9 +2320,9 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "winch-codegen" -version = "0.16.2" +version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8197ed4a2ebf612f0624ddda10de71f8cd2d3a4ecf8ffac0586a264599708d63" +checksum = "d285c833af9453c037cd220765f86c5c9961e8906a815829107c8801d535b8e4" dependencies = [ "anyhow", "cranelift-codegen", @@ -2559,7 +2330,7 @@ dependencies = [ "regalloc2", "smallvec", "target-lexicon", - "wasmparser 0.121.2", + "wasmparser 0.201.0", "wasmtime-environ", ] @@ -2569,16 +2340,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" dependencies = [ - "windows-targets 0.52.4", -] - -[[package]] -name = "windows-sys" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" -dependencies = [ - "windows-targets 0.48.5", + "windows-targets", ] [[package]] @@ -2587,22 +2349,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.4", -] - -[[package]] -name = "windows-targets" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" -dependencies = [ - "windows_aarch64_gnullvm 0.48.5", - "windows_aarch64_msvc 0.48.5", - "windows_i686_gnu 0.48.5", - "windows_i686_msvc 0.48.5", - "windows_x86_64_gnu 0.48.5", - "windows_x86_64_gnullvm 0.48.5", - "windows_x86_64_msvc 0.48.5", + "windows-targets", ] [[package]] @@ -2611,81 +2358,45 @@ version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7dd37b7e5ab9018759f893a1952c9420d060016fc19a472b4bb20d1bdd694d1b" dependencies = [ - "windows_aarch64_gnullvm 0.52.4", - "windows_aarch64_msvc 0.52.4", - "windows_i686_gnu 0.52.4", - "windows_i686_msvc 0.52.4", - "windows_x86_64_gnu 0.52.4", - "windows_x86_64_gnullvm 0.52.4", - "windows_x86_64_msvc 0.52.4", + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", ] -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" - [[package]] name = "windows_aarch64_gnullvm" version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bcf46cf4c365c6f2d1cc93ce535f2c8b244591df96ceee75d8e83deb70a9cac9" -[[package]] -name = "windows_aarch64_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" - [[package]] name = "windows_aarch64_msvc" version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "da9f259dd3bcf6990b55bffd094c4f7235817ba4ceebde8e6d11cd0c5633b675" -[[package]] -name = "windows_i686_gnu" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" - [[package]] name = "windows_i686_gnu" version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b474d8268f99e0995f25b9f095bc7434632601028cf86590aea5c8a5cb7801d3" -[[package]] -name = "windows_i686_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" - [[package]] name = "windows_i686_msvc" version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1515e9a29e5bed743cb4415a9ecf5dfca648ce85ee42e15873c3cd8610ff8e02" -[[package]] -name = "windows_x86_64_gnu" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" - [[package]] name = "windows_x86_64_gnu" version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5eee091590e89cc02ad514ffe3ead9eb6b660aedca2183455434b93546371a03" -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" - [[package]] name = "windows_x86_64_gnullvm" version = "0.52.4" @@ -2694,15 +2405,18 @@ checksum = "77ca79f2451b49fa9e2af39f0747fe999fcda4f5e241b2898624dca97a1f2177" [[package]] name = "windows_x86_64_msvc" -version = "0.48.5" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" +checksum = "32b752e52a2da0ddfbdbcc6fceadfeede4c939ed16d13e648833a61dfb611ed8" [[package]] -name = "windows_x86_64_msvc" -version = "0.52.4" +name = "winnow" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32b752e52a2da0ddfbdbcc6fceadfeede4c939ed16d13e648833a61dfb611ed8" +checksum = "dffa400e67ed5a4dd237983829e66475f0a4a26938c4b04c21baede6262215b8" +dependencies = [ + "memchr", +] [[package]] name = "winx" @@ -2710,15 +2424,15 @@ version = "0.36.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f9643b83820c0cd246ecabe5fa454dd04ba4fa67996369466d0747472d337346" dependencies = [ - "bitflags 2.4.2", - "windows-sys 0.52.0", + "bitflags 2.5.0", + "windows-sys", ] [[package]] name = "wit-parser" -version = "0.13.2" +version = "0.201.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "316b36a9f0005f5aa4b03c39bc3728d045df136f8c13a73b7db4510dec725e08" +checksum = "196d3ecfc4b759a8573bf86a9b3f8996b304b3732e4c7de81655f875f6efdca6" dependencies = [ "anyhow", "id-arena", @@ -2729,6 +2443,7 @@ dependencies = [ "serde_derive", "serde_json", "unicode-xid", + "wasmparser 0.201.0", ] [[package]] @@ -2748,18 +2463,17 @@ name = "wizer" version = "5.0.0" dependencies = [ "anyhow", - "cap-std 3.0.0", + "cap-std", "criterion", "env_logger", "log", "rayon", "structopt", "wasi-common", - "wasm-encoder 0.201.0", - "wasmparser 0.201.0", - "wasmprinter 0.201.0", + "wasm-encoder 0.202.0", + "wasmparser 0.202.0", + "wasmprinter 0.202.0", "wasmtime", - "wasmtime-wasi", "wat", ] @@ -2771,7 +2485,7 @@ dependencies = [ "libfuzzer-sys", "log", "wasm-smith", - "wasmprinter 0.201.0", + "wasmprinter 0.202.0", "wasmtime", "wizer", ] @@ -2793,33 +2507,32 @@ checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.55", ] [[package]] name = "zstd" -version = "0.11.2+zstd.1.5.2" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20cc960326ece64f010d2d2107537f26dc589a6573a316bd5b1dba685fa5fde4" +checksum = "2d789b1514203a1120ad2429eae43a7bd32b90976a7bb8a05f7ec02fa88cc23a" dependencies = [ "zstd-safe", ] [[package]] name = "zstd-safe" -version = "5.0.2+zstd.1.5.2" +version = "7.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d2a5585e04f9eea4b2a3d1eca508c4dee9592a89ef6f450c11719da0726f4db" +checksum = "1cd99b45c6bc03a018c8b8a86025678c87e55526064e38f9df301989dce7ec0a" dependencies = [ - "libc", "zstd-sys", ] [[package]] name = "zstd-sys" -version = "2.0.9+zstd.1.5.5" +version = "2.0.10+zstd.1.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e16efa8a874a0481a574084d34cc26fdb3b99627480f785888deb6386506656" +checksum = "c253a4914af5bafc8fa8c86ee400827e83cf6ec01195ec1f1ed8441bf00d65aa" dependencies = [ "cc", "pkg-config", diff --git a/crates/wizer/Cargo.toml b/crates/wizer/Cargo.toml index 3b7c67f97848..15d1abbfa3f5 100644 --- a/crates/wizer/Cargo.toml +++ b/crates/wizer/Cargo.toml @@ -27,16 +27,15 @@ name = "uap" harness = false [dependencies] -anyhow = "1.0.80" +anyhow = "1.0.81" cap-std = "3.0.0" env_logger = { version = "0.11", optional = true } log = "0.4.21" -rayon = "1.9.0" +rayon = "1.10.0" structopt = { version = "0.3.26", optional = true } -wasm-encoder = "0.201.0" -wasmparser = "0.201.0" +wasm-encoder = "0.202.0" +wasmparser = "0.202.0" wasmtime = { workspace = true } -wasmtime-wasi = { workspace = true } wasi-common = { workspace = true } # Enable this dependency to get messages with WAT disassemblies when certain @@ -46,17 +45,16 @@ workspace = true optional = true [workspace.dependencies] -wasmprinter = "0.201.0" -wasmtime = "18" -wasmtime-wasi = "18" -wasi-common = "18" +wasmprinter = "0.202.0" +wasmtime = "19" +wasi-common = "19" [dev-dependencies] criterion = "0.5.1" env_logger = "0.11.3" wasmprinter = { workspace = true } -wat = "1.201.0" +wat = "1.202.0" [workspace] members = [ diff --git a/crates/wizer/benches/regex-bench/Cargo.toml b/crates/wizer/benches/regex-bench/Cargo.toml index 9b1c0d7dc9b1..784d98f573c2 100644 --- a/crates/wizer/benches/regex-bench/Cargo.toml +++ b/crates/wizer/benches/regex-bench/Cargo.toml @@ -10,7 +10,7 @@ crate-type = ["cdylib"] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -regex = "1.10.3" +regex = "1.10.4" [features] wizer = [] diff --git a/crates/wizer/benches/regex.rs b/crates/wizer/benches/regex.rs index b385a1373850..83251aaca0aa 100644 --- a/crates/wizer/benches/regex.rs +++ b/crates/wizer/benches/regex.rs @@ -26,25 +26,25 @@ fn bench_regex(c: &mut Criterion) { let mut group = c.benchmark_group("regex"); group.bench_function("control", |b| { let engine = wasmtime::Engine::default(); - let wasi = wasmtime_wasi::WasiCtxBuilder::new().build(); + let wasi = wasi_common::sync::WasiCtxBuilder::new().build(); let mut store = wasmtime::Store::new(&engine, wasi); let module = wasmtime::Module::new(store.engine(), &include_bytes!("regex_bench.control.wasm")) .unwrap(); let mut linker = wasmtime::Linker::new(&engine); - wasmtime_wasi::sync::add_to_linker(&mut linker, |s| s).unwrap(); + wasi_common::sync::add_to_linker(&mut linker, |s| s).unwrap(); b.iter(|| run_iter(&linker, &module, &mut store)); }); group.bench_function("wizer", |b| { let engine = wasmtime::Engine::default(); - let wasi = wasmtime_wasi::WasiCtxBuilder::new().build(); + let wasi = wasi_common::sync::WasiCtxBuilder::new().build(); let mut store = wasmtime::Store::new(&engine, wasi); let module = wasmtime::Module::new(store.engine(), &include_bytes!("regex_bench.control.wasm")) .unwrap(); let mut linker = wasmtime::Linker::new(&engine); - wasmtime_wasi::sync::add_to_linker(&mut linker, |s| s).unwrap(); + wasi_common::sync::add_to_linker(&mut linker, |s| s).unwrap(); b.iter(|| run_iter(&linker, &module, &mut store)); }); diff --git a/crates/wizer/benches/uap-bench/Cargo.toml b/crates/wizer/benches/uap-bench/Cargo.toml index 1d468e4552a0..b57373bf1a9f 100644 --- a/crates/wizer/benches/uap-bench/Cargo.toml +++ b/crates/wizer/benches/uap-bench/Cargo.toml @@ -11,8 +11,8 @@ crate-type = ["cdylib"] [dependencies] serde = { version = "1.0.197", features = ["derive"] } -regex = "1.10.3" -serde_yaml = "0.9.32" +regex = "1.10.4" +serde_yaml = "0.9.34" [features] wizer = [] diff --git a/crates/wizer/benches/uap.rs b/crates/wizer/benches/uap.rs index d5fdd8ae86a6..d5cdaa4343ad 100644 --- a/crates/wizer/benches/uap.rs +++ b/crates/wizer/benches/uap.rs @@ -39,24 +39,24 @@ fn bench_uap(c: &mut Criterion) { let mut group = c.benchmark_group("uap"); group.bench_function("control", |b| { let engine = wasmtime::Engine::default(); - let wasi = wasmtime_wasi::WasiCtxBuilder::new().build(); + let wasi = wasi_common::sync::WasiCtxBuilder::new().build(); let mut store = wasmtime::Store::new(&engine, wasi); let module = wasmtime::Module::new(store.engine(), &include_bytes!("uap_bench.control.wasm")) .unwrap(); let mut linker = wasmtime::Linker::new(&engine); - wasmtime_wasi::sync::add_to_linker(&mut linker, |s| s).unwrap(); + wasi_common::sync::add_to_linker(&mut linker, |s| s).unwrap(); b.iter(|| run_iter(&linker, &module, &mut store)); }); group.bench_function("wizer", |b| { let engine = wasmtime::Engine::default(); - let wasi = wasmtime_wasi::WasiCtxBuilder::new().build(); + let wasi = wasi_common::sync::WasiCtxBuilder::new().build(); let mut store = wasmtime::Store::new(&engine, wasi); let module = wasmtime::Module::new(store.engine(), &include_bytes!("uap_bench.wizer.wasm")).unwrap(); let mut linker = wasmtime::Linker::new(&engine); - wasmtime_wasi::sync::add_to_linker(&mut linker, |s| s).unwrap(); + wasi_common::sync::add_to_linker(&mut linker, |s| s).unwrap(); b.iter(|| run_iter(&linker, &module, &mut store)); }); diff --git a/crates/wizer/fuzz/Cargo.toml b/crates/wizer/fuzz/Cargo.toml index 2e3d3e12db6a..537f7428cd6e 100644 --- a/crates/wizer/fuzz/Cargo.toml +++ b/crates/wizer/fuzz/Cargo.toml @@ -13,7 +13,7 @@ cargo-fuzz = true env_logger = "0.11.3" libfuzzer-sys = "0.4" log = "0.4.21" -wasm-smith = "0.201.0" +wasm-smith = "0.202.0" wasmprinter = { workspace = true } wasmtime = { workspace = true } diff --git a/crates/wizer/src/dummy.rs b/crates/wizer/src/dummy.rs index 7f5ce936f206..e89fadab2e81 100644 --- a/crates/wizer/src/dummy.rs +++ b/crates/wizer/src/dummy.rs @@ -66,8 +66,17 @@ pub fn dummy_value(val_ty: ValType) -> Val { ValType::F32 => Val::F32(0), ValType::F64 => Val::F64(0), ValType::V128 => Val::V128(0.into()), - ValType::ExternRef => Val::ExternRef(None), - ValType::FuncRef => Val::FuncRef(None), + ValType::Ref(ref_type) => { + if ref_type.matches(&RefType::EXTERNREF) { + Val::ExternRef(None) + } else if ref_type.matches(&RefType::FUNCREF) { + Val::FuncRef(None) + } else if ref_type.matches(&RefType::NULLFUNCREF) { + Val::FuncRef(None) + } else { + panic!("Unknown RefType {:?}", ref_type); + } + } } } diff --git a/crates/wizer/src/lib.rs b/crates/wizer/src/lib.rs index 306795ff8c91..c50a150378a2 100644 --- a/crates/wizer/src/lib.rs +++ b/crates/wizer/src/lib.rs @@ -17,6 +17,7 @@ mod snapshot; mod stack_ext; mod translate; +use wasi_common::sync::WasiCtxBuilder; /// Re-export wasmtime so users can align with our version. This is /// especially useful when providing a custom Linker. pub use wasmtime; @@ -31,7 +32,6 @@ use std::rc::Rc; use structopt::StructOpt; use wasi_common::WasiCtx; use wasmtime::{Engine, Extern}; -use wasmtime_wasi::WasiCtxBuilder; const DEFAULT_INHERIT_STDIO: bool = true; const DEFAULT_INHERIT_ENV: bool = false; @@ -776,9 +776,9 @@ impl Wizer { } for dir in &self.dirs { log::debug!("Preopening directory: {}", dir.display()); - let preopened = wasmtime_wasi::sync::Dir::open_ambient_dir( + let preopened = wasi_common::sync::Dir::open_ambient_dir( dir, - wasmtime_wasi::sync::ambient_authority(), + wasi_common::sync::ambient_authority(), ) .with_context(|| format!("failed to open directory: {}", dir.display()))?; ctx.preopened_dir(preopened, dir)?; @@ -789,9 +789,9 @@ impl Wizer { guest_dir.display(), host_dir.display() ); - let preopened = wasmtime_wasi::sync::Dir::open_ambient_dir( + let preopened = wasi_common::sync::Dir::open_ambient_dir( host_dir, - wasmtime_wasi::sync::ambient_authority(), + wasi_common::sync::ambient_authority(), ) .with_context(|| format!("failed to open directory: {}", host_dir.display()))?; ctx.preopened_dir(preopened, guest_dir)?; @@ -834,7 +834,7 @@ impl Wizer { }; if self.allow_wasi { - wasmtime_wasi::add_to_linker(&mut linker, |ctx: &mut Option| { + wasi_common::sync::add_to_linker(&mut linker, |ctx: &mut Option| { ctx.as_mut().unwrap() })?; } diff --git a/crates/wizer/tests/make_linker.rs b/crates/wizer/tests/make_linker.rs index a6531f495c04..5e43822f82f1 100644 --- a/crates/wizer/tests/make_linker.rs +++ b/crates/wizer/tests/make_linker.rs @@ -35,7 +35,7 @@ fn run_wasm(args: &[wasmtime::Val], expected: i32, wasm: &[u8]) -> Result<()> { config.wasm_multi_value(true); let engine = wasmtime::Engine::new(&config)?; - let wasi_ctx = wasmtime_wasi::WasiCtxBuilder::new().build(); + let wasi_ctx = wasi_common::sync::WasiCtxBuilder::new().build(); let mut store = wasmtime::Store::new(&engine, wasi_ctx); let module = wasmtime::Module::new(store.engine(), wasm).context("Wasm test case failed to compile")?; diff --git a/crates/wizer/tests/regex-test/Cargo.toml b/crates/wizer/tests/regex-test/Cargo.toml index 083a9ad09da2..43b7575aa1d2 100644 --- a/crates/wizer/tests/regex-test/Cargo.toml +++ b/crates/wizer/tests/regex-test/Cargo.toml @@ -10,4 +10,4 @@ crate-type = ["cdylib"] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -regex = "1.10.3" +regex = "1.10.4" diff --git a/crates/wizer/tests/tests.rs b/crates/wizer/tests/tests.rs index 057733f1fd57..197df13f1d44 100644 --- a/crates/wizer/tests/tests.rs +++ b/crates/wizer/tests/tests.rs @@ -48,7 +48,7 @@ fn wizen_and_run_wasm( config.wasm_multi_value(true); let engine = wasmtime::Engine::new(&config)?; - let wasi_ctx = wasmtime_wasi::WasiCtxBuilder::new().build(); + let wasi_ctx = wasi_common::sync::WasiCtxBuilder::new().build(); let mut store = wasmtime::Store::new(&engine, wasi_ctx); let module = wasmtime::Module::new(store.engine(), wasm).context("Wasm test case failed to compile")?; @@ -61,7 +61,7 @@ fn wizen_and_run_wasm( .define_name(&mut store, "f", thunk)? .define(&mut store, "x", "f", thunk)?; - wasmtime_wasi::add_to_linker(&mut linker, |wasi| wasi)?; + wasi_common::sync::add_to_linker(&mut linker, |wasi| wasi)?; let instance = linker.instantiate(&mut store, &module)?; From 4a27c8e6cd7cb6357f9371f00e1aee631879fea2 Mon Sep 17 00:00:00 2001 From: Gentle Date: Wed, 3 Apr 2024 15:43:16 +0200 Subject: [PATCH 184/212] wasmtime 19.0.1 --- crates/wizer/Cargo.lock | 194 +++++++++++++++++++--------------------- 1 file changed, 92 insertions(+), 102 deletions(-) diff --git a/crates/wizer/Cargo.lock b/crates/wizer/Cargo.lock index 93ee5796f0b5..e60f2f0859ac 100644 --- a/crates/wizer/Cargo.lock +++ b/crates/wizer/Cargo.lock @@ -133,7 +133,7 @@ checksum = "a507401cad91ec6a857ed5513a2073c82a9b9048762b885bb98655b306964681" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -387,18 +387,18 @@ dependencies = [ [[package]] name = "cranelift-bforest" -version = "0.106.0" +version = "0.106.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a535eb1cf5a6003197dc569320c40c1cb2d2f97ef5d5348eebf067f20957381" +checksum = "5b3775cc6cc00c90d29eebea55feedb2b0168e23f5415bab7859c4004d7323d1" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-codegen" -version = "0.106.0" +version = "0.106.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11b5066db32cec1492573827183af2142d2d88fe85a83cfc9e73f0f63d3788d4" +checksum = "637f3184ba5bfa48d425bad1d2e4faf5fcf619f5e0ca107edc6dc02f589d4d74" dependencies = [ "bumpalo", "cranelift-bforest", @@ -417,33 +417,33 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.106.0" +version = "0.106.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64942e5774308e835fbad4dd25f253105412c90324631910e1ec27963147bddb" +checksum = "e4b35b8240462341d94d31aab807cad704683988708261aecae3d57db48b7212" dependencies = [ "cranelift-codegen-shared", ] [[package]] name = "cranelift-codegen-shared" -version = "0.106.0" +version = "0.106.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c39c33db9a86dd6d8d04166a10c53deb477aeea3500eaaefca682e4eda9bb986" +checksum = "8f3cd1555aa9df1d6d8375732de41b4cb0d787006948d55b6d004d521e9efeb0" [[package]] name = "cranelift-control" -version = "0.106.0" +version = "0.106.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b7fc4937613aea3156a0538800a17bf56f345a5da2e79ae3df58488c93d867f" +checksum = "14b31a562a10e98ab148fa146801e20665c5f9eda4fce9b2c5a3836575887d74" dependencies = [ "arbitrary", ] [[package]] name = "cranelift-entity" -version = "0.106.0" +version = "0.106.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f85575e79a153ce1ddbfb7fe1813519b4bfe1eb200cc9c8353b45ad123ae4d36" +checksum = "af1e0467700a3f4fccf5feddbaebdf8b0eb82535b06a9600c4bc5df40872e75d" dependencies = [ "serde", "serde_derive", @@ -451,9 +451,9 @@ dependencies = [ [[package]] name = "cranelift-frontend" -version = "0.106.0" +version = "0.106.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbc31d6c0ab2249fe0c21e988256b42f5f401ab2673b4fc40076c82a698bdfb9" +checksum = "6cb918ee2c23939262efd1b99d76a21212ac7bd35129582133e21a22a6ff0467" dependencies = [ "cranelift-codegen", "log", @@ -463,15 +463,15 @@ dependencies = [ [[package]] name = "cranelift-isle" -version = "0.106.0" +version = "0.106.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc14f37e3314c0e4c53779c2f46753bf242efff76ee9473757a1fff3b495ad37" +checksum = "966e4cfb23cf6d7f1d285d53a912baaffc5f06bcd9c9b0a2d8c66a184fae534b" [[package]] name = "cranelift-native" -version = "0.106.0" +version = "0.106.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ea5375f76ab31f9800a23fb2b440810286a6f669a3eb467cdd7ff255ea64268" +checksum = "bea803aadfc4aabdfae7c3870f1b1f6dd4332f4091859e9758ef5fca6bf8cc87" dependencies = [ "cranelift-codegen", "libc", @@ -480,9 +480,9 @@ dependencies = [ [[package]] name = "cranelift-wasm" -version = "0.106.0" +version = "0.106.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79851dba01b1fa83fad95134aa27beca88dc4b027121d92ab19788582389dc5f" +checksum = "11d18a3572cd897555bba3621e568029417d8f5cc26aeede2d7cb0bad6afd916" dependencies = [ "cranelift-codegen", "cranelift-entity", @@ -597,7 +597,7 @@ checksum = "67e77553c4162a157adbf834ebae5b415acbecbeafc7a74b0e886657506a7611" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -899,9 +899,9 @@ dependencies = [ [[package]] name = "io-extras" -version = "0.18.1" +version = "0.18.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c301e73fb90e8a29e600a9f402d095765f74310d582916a952f618836a1bd1ed" +checksum = "c9f046b9af244f13b3bd939f55d16830ac3a201e8a9ba9661bfcb03e2be72b9b" dependencies = [ "io-lifetimes", "windows-sys", @@ -1023,13 +1023,12 @@ dependencies = [ [[package]] name = "libredox" -version = "0.0.1" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85c833ca1e66078851dba29046874e38f08b2c883700aa29a03ddd3b23814ee8" +checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" dependencies = [ "bitflags 2.5.0", "libc", - "redox_syscall", ] [[package]] @@ -1061,9 +1060,9 @@ checksum = "4facc753ae494aeb6e3c22f839b158aebd4f9270f55cd3c79906c45476c47ab4" [[package]] name = "memchr" -version = "2.7.1" +version = "2.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" +checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" [[package]] name = "memfd" @@ -1124,9 +1123,9 @@ checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" [[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 = "pkg-config" @@ -1269,20 +1268,11 @@ dependencies = [ "crossbeam-utils", ] -[[package]] -name = "redox_syscall" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" -dependencies = [ - "bitflags 1.3.2", -] - [[package]] name = "redox_users" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a18479200779601e498ada4e8c1e1f50e3ee19deb0259c25825a98b5603b2cb4" +checksum = "bd283d9651eeda4b2a83a43c1c91b266c40fd76ecd39a50a8c630ae69dc72891" dependencies = [ "getrandom", "libredox", @@ -1410,7 +1400,7 @@ checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -1533,9 +1523,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.55" +version = "2.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "002a1b3dbf967edfafc32655d0f377ab0bb7b994aa1d32c8cc7e9b8bf3ebb8f0" +checksum = "44cfb93f38070beee36b3fef7d4f5a16f27751d94b187b666a5cc5e9b0d30687" dependencies = [ "proc-macro2", "quote", @@ -1544,9 +1534,9 @@ dependencies = [ [[package]] name = "system-interface" -version = "0.27.1" +version = "0.27.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9aef1f9d4c1dbdd1cb3a63be9efd2f04d8ddbc919d46112982c76818ffc2f1a7" +checksum = "b858526d22750088a9b3cf2e3c2aacebd5377f13adeec02860c30d09113010a6" dependencies = [ "bitflags 2.5.0", "cap-fs-ext", @@ -1590,7 +1580,7 @@ checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -1657,7 +1647,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -1756,9 +1746,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasi-common" -version = "19.0.0" +version = "19.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1df07660d36c7e6bceccb546b58d0901319db633549ae56124cbc5c7285d1ee0" +checksum = "6b53dfacdeacca15ee2a48a4aa0ec6a6d0da737676e465770c0585f79c04e638" dependencies = [ "anyhow", "bitflags 2.5.0", @@ -1801,7 +1791,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", "wasm-bindgen-shared", ] @@ -1823,7 +1813,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -1910,9 +1900,9 @@ dependencies = [ [[package]] name = "wasmtime" -version = "19.0.0" +version = "19.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a08af88fa3d324cc5cf6d388d90ef396a787b3fb4bbd51ba185f8645dc0f02c" +checksum = "516be5b58a8f75d39b01378516dcb0ff7b9bc39c7f1f10eec5b338d4916cf988" dependencies = [ "addr2line", "anyhow", @@ -1956,18 +1946,18 @@ dependencies = [ [[package]] name = "wasmtime-asm-macros" -version = "19.0.0" +version = "19.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16cdbfcf28542bcda0b5fd68d44603e53e5ad126cbe7b9f25c130e1249fd8211" +checksum = "e8d22d88a92d69385f18143c946884bf6aaa9ec206ce54c85a2d320c1362b009" dependencies = [ "cfg-if", ] [[package]] name = "wasmtime-cache" -version = "19.0.0" +version = "19.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "546b85be1a1d380ba821aeb0252b656359d0ce027b16fef8fc0e2f2b9159e193" +checksum = "068728a840223b56c964507550da671372e7e5c2f3a7856012b57482e3e979a7" dependencies = [ "anyhow", "base64", @@ -1985,14 +1975,14 @@ dependencies = [ [[package]] name = "wasmtime-component-macro" -version = "19.0.0" +version = "19.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0cdcf690257c623506eeec3a502864b282aab0fdfd6981c1ebb63c7e98f4a23a" +checksum = "631244bac89c57ebe7283209d86fe175ad5929328e75f61bf9141895cafbf52d" dependencies = [ "anyhow", "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", "wasmtime-component-util", "wasmtime-wit-bindgen", "wit-parser", @@ -2000,15 +1990,15 @@ dependencies = [ [[package]] name = "wasmtime-component-util" -version = "19.0.0" +version = "19.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab3ae7bf66e2fae1e332ab3634f332d7422e878a6eecc47c8f8f78cc1f24e501" +checksum = "82ad496ba0558f7602da5e9d4c201f35f7aefcca70f973ec916f3f0d0787ef74" [[package]] name = "wasmtime-cranelift" -version = "19.0.0" +version = "19.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67ea025c969a09117818732fa6f96848e858a7953d4659dab8081a6eea3c0523" +checksum = "961ab5ee4b17e627001b18069ee89ef906edbbd3f84955515f6aad5ab6d82299" dependencies = [ "anyhow", "cfg-if", @@ -2031,9 +2021,9 @@ dependencies = [ [[package]] name = "wasmtime-cranelift-shared" -version = "19.0.0" +version = "19.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcd6dd2f8d8d4860b384f61f89b597633a5b5f0943c546210e5084c5d321fe20" +checksum = "bc4db94596be14cd1f85844ce85470bf68acf235143098b9d9bf72b49e47b917" dependencies = [ "anyhow", "cranelift-codegen", @@ -2047,9 +2037,9 @@ dependencies = [ [[package]] name = "wasmtime-environ" -version = "19.0.0" +version = "19.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f60f3f717658dd77745de03b750d5852126e9be6dad465848c77f90387c44c9" +checksum = "420b13858ef27dfd116f1fdb0513e9593a307a632ade2ea58334b639a3d8d24e" dependencies = [ "anyhow", "bincode", @@ -2073,9 +2063,9 @@ dependencies = [ [[package]] name = "wasmtime-fiber" -version = "19.0.0" +version = "19.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf8cd22ab1041bf0e54b6283e57824557902e4fed8b1f3a7eef29cbaba89eebf" +checksum = "5d37ff0e11a023019e34fe839c74a1c00880b989f4446176b6cc6da3b58e3ef2" dependencies = [ "anyhow", "cc", @@ -2088,9 +2078,9 @@ dependencies = [ [[package]] name = "wasmtime-jit-debug" -version = "19.0.0" +version = "19.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8753654f698354950a557d0d0cbdecf356c973659920091cf3d5fada74183e02" +checksum = "7b849f19ad1d4a8133ff05b82c438144f17fb49b08e5f7995f8c1e25cf35f390" dependencies = [ "object", "once_cell", @@ -2100,9 +2090,9 @@ dependencies = [ [[package]] name = "wasmtime-jit-icache-coherence" -version = "19.0.0" +version = "19.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2796e4b4989db62899d2117e1e0258b839d088c044591b14e3a0396e7b3ae53a" +checksum = "59c48eb4223d6556ffbf3decb146d0da124f1fd043f41c98b705252cb6a5c186" dependencies = [ "cfg-if", "libc", @@ -2111,9 +2101,9 @@ dependencies = [ [[package]] name = "wasmtime-runtime" -version = "19.0.0" +version = "19.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bf2b7745df452a4f41b9aab21d3f7ba1347b12da2fdc5241e59306127884a68" +checksum = "7fefac2cb5f5a6f365234a3584bf40bd2e45e7f6cd90a689d9b2afbb9881978f" dependencies = [ "anyhow", "cc", @@ -2141,15 +2131,15 @@ dependencies = [ [[package]] name = "wasmtime-slab" -version = "19.0.0" +version = "19.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83448ef600ad95977019ebaea84a5516fdbc9561d0a8e26b1e099351f993b527" +checksum = "52d7b97b92df126fdbe994a53d2215828ec5ed5087535e6d4703b1fbd299f0e3" [[package]] name = "wasmtime-types" -version = "19.0.0" +version = "19.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf6fe7ed3fd18ed4b1e4465fe5c8674acc9f03523fca5b1b9f975b2560cd741b" +checksum = "509c88abb830819b259c49e2d4e4f22b555db066ba08ded0b76b071a2aa53ddf" dependencies = [ "cranelift-entity", "serde", @@ -2160,20 +2150,20 @@ dependencies = [ [[package]] name = "wasmtime-versioned-export-macros" -version = "19.0.0" +version = "19.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d6d967f01032da7d4c6303da32f6a00d5efe1bac124b156e7342d8ace6ffdfc" +checksum = "f1d81c092a61ca1667013e2eb08fed7c6c53e496dbbaa32d5685dc5152b0a772" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] name = "wasmtime-winch" -version = "19.0.0" +version = "19.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb8b3fcbc455105760e4a2aa8ee3f39b8357183a62201383b3f72d4836ca2be8" +checksum = "a0958907880e37a2d3974f5b3574c23bf70aaf1fc6c1f716625bb50dac776f1a" dependencies = [ "anyhow", "cranelift-codegen", @@ -2188,9 +2178,9 @@ dependencies = [ [[package]] name = "wasmtime-wit-bindgen" -version = "19.0.0" +version = "19.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96326c9800fb6c099f50d1bd2126d636fc2f96950e1675acf358c0f52516cd38" +checksum = "a593ddefd2f80617df6bea084b2e422d8969e924bc209642a794d57518f59587" dependencies = [ "anyhow", "heck 0.4.1", @@ -2200,9 +2190,9 @@ dependencies = [ [[package]] name = "wasmtime-wmemcheck" -version = "19.0.0" +version = "19.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36bd91a4dc55af0bf55e9e2ab0ea13724cfb5c5a1acdf8873039769208f59490" +checksum = "b77212b6874bbc86d220bb1d28632d0c11c6afe996c3e1ddcf746b1a6b4919b9" [[package]] name = "wast" @@ -2247,9 +2237,9 @@ dependencies = [ [[package]] name = "wiggle" -version = "19.0.0" +version = "19.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae1136a209614ace00b0c11f04dc7cf42540773be3b22eff6ad165110aba29c1" +checksum = "f093d8afdb09efaf2ed1037468bd4614308a762d215b6cafd60a7712993a8ffa" dependencies = [ "anyhow", "async-trait", @@ -2262,28 +2252,28 @@ dependencies = [ [[package]] name = "wiggle-generate" -version = "19.0.0" +version = "19.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c2bd99ce26046f4246d720a4198f6a8fc95bc5da82ae4ef62263e24641c3076" +checksum = "47c7bccd5172ce8d853242f723e42c84b8c131b24fb07a1570f9045d99258616" dependencies = [ "anyhow", "heck 0.4.1", "proc-macro2", "quote", "shellexpand", - "syn 2.0.55", + "syn 2.0.58", "witx", ] [[package]] name = "wiggle-macro" -version = "19.0.0" +version = "19.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "512d816dbcd0113103b2eb2402ec9018e7f0755202a5b3e67db726f229d8dcae" +checksum = "a69d087dee85991096fc0c6eaf4dcf4e17cd16a0594c33b8ab9e2d345234ef75" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", "wiggle-generate", ] @@ -2320,9 +2310,9 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "winch-codegen" -version = "0.17.0" +version = "0.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d285c833af9453c037cd220765f86c5c9961e8906a815829107c8801d535b8e4" +checksum = "e72a6a7034793b874b85e428fd6d7b3ccccb98c326e33af3aa40cdf50d0c33da" dependencies = [ "anyhow", "cranelift-codegen", @@ -2507,7 +2497,7 @@ checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] From 5ea1b5a5184d4eba63db75b7b4f79369a26d81ed Mon Sep 17 00:00:00 2001 From: Gentle Date: Fri, 5 Apr 2024 19:25:24 +0200 Subject: [PATCH 185/212] dummy_value now returns error for non-nullable reference types --- crates/wizer/src/dummy.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/crates/wizer/src/dummy.rs b/crates/wizer/src/dummy.rs index e89fadab2e81..57100cfd05fd 100644 --- a/crates/wizer/src/dummy.rs +++ b/crates/wizer/src/dummy.rs @@ -59,14 +59,17 @@ pub fn dummy_func(store: &mut crate::Store, ty: FuncType, name: &str) -> Func { /// Construct a dummy value for the given value type. #[cfg(fuzzing)] -pub fn dummy_value(val_ty: ValType) -> Val { - match val_ty { +pub fn dummy_value(val_ty: ValType) -> Result { + Ok(match val_ty { ValType::I32 => Val::I32(0), ValType::I64 => Val::I64(0), ValType::F32 => Val::F32(0), ValType::F64 => Val::F64(0), ValType::V128 => Val::V128(0.into()), ValType::Ref(ref_type) => { + if !ref_type.is_nullable() { + anyhow::bail!("cannot create a dummy value for a non-nullable reference type"); + } if ref_type.matches(&RefType::EXTERNREF) { Val::ExternRef(None) } else if ref_type.matches(&RefType::FUNCREF) { @@ -77,11 +80,14 @@ pub fn dummy_value(val_ty: ValType) -> Val { panic!("Unknown RefType {:?}", ref_type); } } - } + }) } /// Construct a sequence of dummy values for the given types. #[cfg(fuzzing)] pub fn dummy_values(val_tys: impl IntoIterator) -> Vec { - val_tys.into_iter().map(dummy_value).collect() + val_tys + .into_iter() + .filter_map(|ty| dummy_value(ty).ok()) + .collect() } From 5d13bb1d70d4bd95d2b84e00e9ee457c22c2aee8 Mon Sep 17 00:00:00 2001 From: Guy Bedford Date: Wed, 10 Apr 2024 18:08:11 -0700 Subject: [PATCH 186/212] fix release workflow --- crates/wizer/.github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/wizer/.github/workflows/release.yml b/crates/wizer/.github/workflows/release.yml index bcf1193d5aa9..c070d60a1422 100644 --- a/crates/wizer/.github/workflows/release.yml +++ b/crates/wizer/.github/workflows/release.yml @@ -124,7 +124,7 @@ jobs: - name: Update npm packages to latest version if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') working-directory: ./npm/wizer - run: npm install && npm version "${{ steps.tagname.outputs.val }}" + run: npm install && npm version "${{ steps.tagname.outputs.val }}" --allow-same-version - name: Publish npm packages if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') working-directory: ./npm From 57cf98eb9418da9082a0d55dabfb3d1e68fbd9b6 Mon Sep 17 00:00:00 2001 From: Gentle Date: Fri, 12 Apr 2024 23:40:57 +0200 Subject: [PATCH 187/212] error out instead of swallowing error values in fuzzer --- crates/wizer/fuzz/fuzz_targets/same_result.rs | 3 ++- crates/wizer/src/dummy.rs | 7 ++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/crates/wizer/fuzz/fuzz_targets/same_result.rs b/crates/wizer/fuzz/fuzz_targets/same_result.rs index 270e804d38bd..8b84d8ebf881 100644 --- a/crates/wizer/fuzz/fuzz_targets/same_result.rs +++ b/crates/wizer/fuzz/fuzz_targets/same_result.rs @@ -132,7 +132,8 @@ fuzz_target!(|data: &[u8]| { // Instantiate the snapshot and call the main function. let snapshot_instance = Instance::new(&mut store, &snapshot_module, &[]).unwrap(); let snapshot_main_func = snapshot_instance.get_func(&mut store, main_func).unwrap(); - let main_args = wizer::dummy::dummy_values(snapshot_main_func.ty(&store).params()); + let main_args = + wizer::dummy::dummy_values(snapshot_main_func.ty(&store).params()).unwrap(); let mut snapshot_result = vec![wasmtime::Val::I32(0); snapshot_main_func.ty(&store).results().len()]; let snapshot_call_result = diff --git a/crates/wizer/src/dummy.rs b/crates/wizer/src/dummy.rs index 57100cfd05fd..6248662e1138 100644 --- a/crates/wizer/src/dummy.rs +++ b/crates/wizer/src/dummy.rs @@ -85,9 +85,6 @@ pub fn dummy_value(val_ty: ValType) -> Result { /// Construct a sequence of dummy values for the given types. #[cfg(fuzzing)] -pub fn dummy_values(val_tys: impl IntoIterator) -> Vec { - val_tys - .into_iter() - .filter_map(|ty| dummy_value(ty).ok()) - .collect() +pub fn dummy_values(val_tys: impl IntoIterator) -> Result> { + val_tys.into_iter().map(|ty| dummy_value(ty)).collect() } From 309c2ab212ee584928ac79846a69fe0eaa13393f Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Mon, 15 Apr 2024 14:48:41 -0700 Subject: [PATCH 188/212] Bump to version 6.0.0 --- crates/wizer/Cargo.lock | 2 +- crates/wizer/Cargo.toml | 2 +- crates/wizer/npm/wizer/package.json | 14 +++++++------- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/crates/wizer/Cargo.lock b/crates/wizer/Cargo.lock index e60f2f0859ac..97b03eb6c8a1 100644 --- a/crates/wizer/Cargo.lock +++ b/crates/wizer/Cargo.lock @@ -2450,7 +2450,7 @@ dependencies = [ [[package]] name = "wizer" -version = "5.0.0" +version = "6.0.0" dependencies = [ "anyhow", "cap-std", diff --git a/crates/wizer/Cargo.toml b/crates/wizer/Cargo.toml index 15d1abbfa3f5..0327e60b2e9f 100644 --- a/crates/wizer/Cargo.toml +++ b/crates/wizer/Cargo.toml @@ -10,7 +10,7 @@ license = "Apache-2.0 WITH LLVM-exception" name = "wizer" readme = "./README.md" repository = "https://github.com/bytecodealliance/wizer" -version = "5.0.0" +version = "6.0.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/crates/wizer/npm/wizer/package.json b/crates/wizer/npm/wizer/package.json index 925338fc0e91..d8a0ad6864a0 100644 --- a/crates/wizer/npm/wizer/package.json +++ b/crates/wizer/npm/wizer/package.json @@ -1,6 +1,6 @@ { "name": "@bytecodealliance/wizer", - "version": "5.0.0", + "version": "6.0.0", "description": "The WebAssembly Pre-Initializer", "type": "module", "scripts": { @@ -20,12 +20,12 @@ "wizer": "./wizer.js" }, "optionalDependencies": { - "@bytecodealliance/wizer-darwin-arm64": "5.0.0", - "@bytecodealliance/wizer-darwin-x64": "5.0.0", - "@bytecodealliance/wizer-linux-x64": "5.0.0", - "@bytecodealliance/wizer-linux-arm64": "5.0.0", - "@bytecodealliance/wizer-linux-s390x": "5.0.0", - "@bytecodealliance/wizer-win32-x64": "5.0.0" + "@bytecodealliance/wizer-darwin-arm64": "6.0.0", + "@bytecodealliance/wizer-darwin-x64": "6.0.0", + "@bytecodealliance/wizer-linux-x64": "6.0.0", + "@bytecodealliance/wizer-linux-arm64": "6.0.0", + "@bytecodealliance/wizer-linux-s390x": "6.0.0", + "@bytecodealliance/wizer-win32-x64": "6.0.0" }, "license": "Apache-2.0", "repository": { From ee1d97b563fd4882af9192e6d277d6f9bcd4f30b Mon Sep 17 00:00:00 2001 From: Guy Bedford Date: Mon, 19 Aug 2024 17:52:44 +0200 Subject: [PATCH 189/212] release: add npmrc to ensure publish permissions (#107) * release: add npmrc to ensure publish permissions * use configuration instead * use global config --- crates/wizer/.github/workflows/release.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/wizer/.github/workflows/release.yml b/crates/wizer/.github/workflows/release.yml index c070d60a1422..ac1707ba9333 100644 --- a/crates/wizer/.github/workflows/release.yml +++ b/crates/wizer/.github/workflows/release.yml @@ -125,6 +125,8 @@ jobs: if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') working-directory: ./npm/wizer run: npm install && npm version "${{ steps.tagname.outputs.val }}" --allow-same-version + - name: Setup npm auth + run: npm config --global set '//registry.npmjs.org/:_authToken'='$NODE_AUTH_TOKEN' - name: Publish npm packages if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') working-directory: ./npm From 0bc5624914441ced4e8b1b8b02a9fa795b55ccce Mon Sep 17 00:00:00 2001 From: Eduard Voiculescu Date: Mon, 19 Aug 2024 11:52:55 -0400 Subject: [PATCH 190/212] Remove $ signs from the bash script to allow for copy pasting (#106) --- crates/wizer/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/wizer/README.md b/crates/wizer/README.md index 0712baeace90..b229f59ac0f6 100644 --- a/crates/wizer/README.md +++ b/crates/wizer/README.md @@ -71,7 +71,7 @@ Download the a pre-built release from the [releases](https://github.com/bytecode Alternatively you can install via `cargo`: ```shell-session -$ cargo install wizer --all-features +cargo install wizer --all-features ``` ## Example Usage @@ -91,7 +91,7 @@ For a complete C++ example, see [this](https://github.com/bytecodealliance/wizer Then, if your Wasm module is named `input.wasm`, run the `wizer` CLI: ```shell-session -$ wizer input.wasm -o initialized.wasm +wizer input.wasm -o initialized.wasm ``` Now you have a pre-initialized version of your Wasm module at @@ -100,7 +100,7 @@ Now you have a pre-initialized version of your Wasm module at More details, flags, and options can be found via `--help`: ```shell-session -$ wizer --help +wizer --help ``` ## Caveats From c145a8fec6ece17cfcb06bcca58a9983394c8a85 Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Mon, 19 Aug 2024 09:46:03 -0700 Subject: [PATCH 191/212] Use `almalinux:8` instead of `centos:7` docker image for release builds (#108) * Update the binary-compatible-builds action from Wasmtime * Use `almalinux:8` as base image for x86_64-linux CI docker image The `centos:7` image hit end of life, so we need something new. Similar to https://github.com/bytecodealliance/wasmtime/pull/8892 in Wasmtime. * Allos `cfg(fuzzing)` * Remove dead code ever since module-linking support was removed * set global npm config with sudo in ci --- .../binary-compatible-builds/action.yml | 2 +- .../actions/binary-compatible-builds/main.js | 8 ++++++- crates/wizer/.github/workflows/release.yml | 2 +- crates/wizer/Cargo.toml | 3 +++ .../wizer/ci/docker/x86_64-linux/Dockerfile | 6 +++--- crates/wizer/src/snapshot.rs | 21 ------------------- 6 files changed, 15 insertions(+), 27 deletions(-) diff --git a/crates/wizer/.github/actions/binary-compatible-builds/action.yml b/crates/wizer/.github/actions/binary-compatible-builds/action.yml index c2950d99b02b..8abc72d63742 100644 --- a/crates/wizer/.github/actions/binary-compatible-builds/action.yml +++ b/crates/wizer/.github/actions/binary-compatible-builds/action.yml @@ -2,7 +2,7 @@ name: 'Set up a CentOS 6 container to build releases in' description: 'Set up a CentOS 6 container to build releases in' runs: - using: node12 + using: node20 main: 'main.js' inputs: name: diff --git a/crates/wizer/.github/actions/binary-compatible-builds/main.js b/crates/wizer/.github/actions/binary-compatible-builds/main.js index 378c5c202c9c..6b72ebe2b4cc 100755 --- a/crates/wizer/.github/actions/binary-compatible-builds/main.js +++ b/crates/wizer/.github/actions/binary-compatible-builds/main.js @@ -21,6 +21,12 @@ if (process.platform == 'win32') { return; } +// Android doesn't use a container as it's controlled by the installation of the +// SDK/NDK. +if (process.env.INPUT_NAME && process.env.INPUT_NAME.indexOf("android") >= 0) { + return; +} + // ... and on Linux we do fancy things with containers. We'll spawn an old // CentOS container in the background with a super old glibc, and then we'll run // commands in there with the `$CENTOS` env var. @@ -34,7 +40,7 @@ if (process.env.CENTOS !== undefined) { return; } -const name = process.env.INPUT_NAME; +const name = process.env.INPUT_NAME.replace(/-min$/, ''); child_process.execFileSync('docker', [ 'build', diff --git a/crates/wizer/.github/workflows/release.yml b/crates/wizer/.github/workflows/release.yml index ac1707ba9333..d3adbbbc0094 100644 --- a/crates/wizer/.github/workflows/release.yml +++ b/crates/wizer/.github/workflows/release.yml @@ -126,7 +126,7 @@ jobs: working-directory: ./npm/wizer run: npm install && npm version "${{ steps.tagname.outputs.val }}" --allow-same-version - name: Setup npm auth - run: npm config --global set '//registry.npmjs.org/:_authToken'='$NODE_AUTH_TOKEN' + run: sudo npm config --global set '//registry.npmjs.org/:_authToken'='$NODE_AUTH_TOKEN' - name: Publish npm packages if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') working-directory: ./npm diff --git a/crates/wizer/Cargo.toml b/crates/wizer/Cargo.toml index 0327e60b2e9f..2bc0ae69bdea 100644 --- a/crates/wizer/Cargo.toml +++ b/crates/wizer/Cargo.toml @@ -66,3 +66,6 @@ members = [ [profile.bench] debug = true + +[lints.rust] +unexpected_cfgs = { level = "allow", check-cfg = ['cfg(fuzzing)'] } diff --git a/crates/wizer/ci/docker/x86_64-linux/Dockerfile b/crates/wizer/ci/docker/x86_64-linux/Dockerfile index 388eddf9f786..b88812c79602 100644 --- a/crates/wizer/ci/docker/x86_64-linux/Dockerfile +++ b/crates/wizer/ci/docker/x86_64-linux/Dockerfile @@ -1,5 +1,5 @@ -FROM centos:7 +FROM almalinux:8 -RUN yum install -y git gcc +RUN dnf install -y git gcc make -ENV PATH=$PATH:/rust/bin \ No newline at end of file +ENV PATH=$PATH:/rust/bin diff --git a/crates/wizer/src/snapshot.rs b/crates/wizer/src/snapshot.rs index 9d69b6f26f42..d3c5fcd36ea0 100644 --- a/crates/wizer/src/snapshot.rs +++ b/crates/wizer/src/snapshot.rs @@ -19,9 +19,6 @@ pub struct Snapshot { /// Segments of non-zero memory. pub data_segments: Vec, - - /// Snapshots for each nested instantiation. - pub instantiations: Vec, } /// A data segment initializer for a memory. @@ -83,13 +80,11 @@ pub fn snapshot(ctx: &mut impl AsContextMut, instance: &wasmtime::Instance) -> S let globals = snapshot_globals(&mut *ctx, instance); let (memory_mins, data_segments) = snapshot_memories(&mut *ctx, instance); - let instantiations = snapshot_instantiations(&mut *ctx, instance); Snapshot { globals, memory_mins, data_segments, - instantiations, } } @@ -273,19 +268,3 @@ fn remove_excess_segments(merged_data_segments: &mut Vec) { // deterministic. merged_data_segments.sort_by_key(|s| (s.memory_index, s.offset)); } - -fn snapshot_instantiations( - ctx: &mut impl AsContextMut, - instance: &wasmtime::Instance, -) -> Vec { - log::debug!("Snapshotting nested instantiations"); - let instantiations = vec![]; - loop { - let name = format!("__wizer_instance_{}", instantiations.len()); - match instance.get_export(&mut *ctx, &name) { - None => break, - Some(_) => unreachable!(), - } - } - instantiations -} From 738714879f6e0241e2ea27ff43dc3bfcd528cd3e Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Tue, 20 Aug 2024 08:00:13 -0700 Subject: [PATCH 192/212] Update Wasmtime and the WASI implementation to v23 (#109) * Update wasmtime and the wasi implementation to v23 * Fix benchmark compilation --- crates/wizer/Cargo.lock | 659 ++++++++++++++++++++---------- crates/wizer/Cargo.toml | 7 +- crates/wizer/benches/regex.rs | 33 +- crates/wizer/benches/uap.rs | 33 +- crates/wizer/src/lib.rs | 56 +-- crates/wizer/tests/make_linker.rs | 3 +- crates/wizer/tests/tests.rs | 14 +- 7 files changed, 551 insertions(+), 254 deletions(-) diff --git a/crates/wizer/Cargo.lock b/crates/wizer/Cargo.lock index 97b03eb6c8a1..cb1a664bfc46 100644 --- a/crates/wizer/Cargo.lock +++ b/crates/wizer/Cargo.lock @@ -11,6 +11,12 @@ dependencies = [ "gimli", ] +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + [[package]] name = "ahash" version = "0.8.11" @@ -154,19 +160,25 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" [[package]] -name = "base64" -version = "0.21.7" +name = "backtrace" +version = "0.3.71" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" +checksum = "26b05800d2e817c8b3b4b54abd461726265fa9789ae34330622f2db9ee696f9d" +dependencies = [ + "addr2line", + "cc", + "cfg-if", + "libc", + "miniz_oxide", + "object 0.32.2", + "rustc-demangle", +] [[package]] -name = "bincode" -version = "1.3.3" +name = "base64" +version = "0.21.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" -dependencies = [ - "serde", -] +checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" [[package]] name = "bitflags" @@ -201,6 +213,12 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" +[[package]] +name = "bytes" +version = "1.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8318a53db07bb3f8dca91a600466bdb3f2eaadeedfdbcf02e1accbad9271ba50" + [[package]] name = "cap-fs-ext" version = "3.0.0" @@ -213,6 +231,18 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "cap-net-ext" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59ff6d3fb274292a9af283417e383afe6ded1fe66f6472d2c781216d3d80c218" +dependencies = [ + "cap-primitives", + "cap-std", + "rustix", + "smallvec", +] + [[package]] name = "cap-primitives" version = "3.0.0" @@ -232,9 +262,9 @@ dependencies = [ [[package]] name = "cap-rand" -version = "3.0.0" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4327f08daac33a99bb03c54ae18c8f32c3ba31c728a33ddf683c6c6a5043de68" +checksum = "dbcb16a619d8b8211ed61f42bd290d2a1ac71277a69cf8417ec0996fa92f5211" dependencies = [ "ambient-authority", "rand", @@ -355,6 +385,12 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce" +[[package]] +name = "cobs" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67ba02a97a2bd10f4b59b25c7973101c79642302776489e030cd13cdab09ed15" + [[package]] name = "colorchoice" version = "1.0.0" @@ -363,9 +399,9 @@ checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" [[package]] name = "core-foundation-sys" -version = "0.8.6" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" [[package]] name = "cpp_demangle" @@ -387,21 +423,32 @@ dependencies = [ [[package]] name = "cranelift-bforest" -version = "0.106.1" +version = "0.110.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b3775cc6cc00c90d29eebea55feedb2b0168e23f5415bab7859c4004d7323d1" +checksum = "305d51c180ebdc46ef61bc60c54ae6512db3bc9a05842a1f1e762e45977019ab" dependencies = [ "cranelift-entity", ] +[[package]] +name = "cranelift-bitset" +version = "0.110.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3247afacd9b13d620033f3190d9e49d1beefc1acb33d5604a249956c9c13709" +dependencies = [ + "serde", + "serde_derive", +] + [[package]] name = "cranelift-codegen" -version = "0.106.1" +version = "0.110.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "637f3184ba5bfa48d425bad1d2e4faf5fcf619f5e0ca107edc6dc02f589d4d74" +checksum = "bd7ca95e831c18d1356da783765c344207cbdffea91e13e47fa9327dbb2e0719" dependencies = [ "bumpalo", "cranelift-bforest", + "cranelift-bitset", "cranelift-codegen-meta", "cranelift-codegen-shared", "cranelift-control", @@ -411,49 +458,51 @@ dependencies = [ "hashbrown 0.14.3", "log", "regalloc2", + "rustc-hash", "smallvec", "target-lexicon", ] [[package]] name = "cranelift-codegen-meta" -version = "0.106.1" +version = "0.110.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4b35b8240462341d94d31aab807cad704683988708261aecae3d57db48b7212" +checksum = "450c105fa1e51bfba4e95a86e926504a867ad5639d63f31d43fe3b7ec1f1c9ef" dependencies = [ "cranelift-codegen-shared", ] [[package]] name = "cranelift-codegen-shared" -version = "0.106.1" +version = "0.110.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f3cd1555aa9df1d6d8375732de41b4cb0d787006948d55b6d004d521e9efeb0" +checksum = "5479117cd1266881479908d383086561cee37e49affbea9b1e6b594cc21cc220" [[package]] name = "cranelift-control" -version = "0.106.1" +version = "0.110.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14b31a562a10e98ab148fa146801e20665c5f9eda4fce9b2c5a3836575887d74" +checksum = "34378804f0abfdd22c068a741cfeed86938b92375b2a96fb0b42c878e0141bfb" dependencies = [ "arbitrary", ] [[package]] name = "cranelift-entity" -version = "0.106.1" +version = "0.110.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af1e0467700a3f4fccf5feddbaebdf8b0eb82535b06a9600c4bc5df40872e75d" +checksum = "a48cb0a194c9ba82fec35a1e492055388d89b2e3c03dee9dcf2488892be8004d" dependencies = [ + "cranelift-bitset", "serde", "serde_derive", ] [[package]] name = "cranelift-frontend" -version = "0.106.1" +version = "0.110.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6cb918ee2c23939262efd1b99d76a21212ac7bd35129582133e21a22a6ff0467" +checksum = "8327afc6c1c05f4be62fefce5b439fa83521c65363a322e86ea32c85e7ceaf64" dependencies = [ "cranelift-codegen", "log", @@ -463,15 +512,15 @@ dependencies = [ [[package]] name = "cranelift-isle" -version = "0.106.1" +version = "0.110.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "966e4cfb23cf6d7f1d285d53a912baaffc5f06bcd9c9b0a2d8c66a184fae534b" +checksum = "56b08621c00321efcfa3eee6a3179adc009e21ea8d24ca7adc3c326184bc3f48" [[package]] name = "cranelift-native" -version = "0.106.1" +version = "0.110.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bea803aadfc4aabdfae7c3870f1b1f6dd4332f4091859e9758ef5fca6bf8cc87" +checksum = "d51180b147c8557c1196c77b098f04140c91962e135ea152cd2fcabf40cf365c" dependencies = [ "cranelift-codegen", "libc", @@ -480,9 +529,9 @@ dependencies = [ [[package]] name = "cranelift-wasm" -version = "0.106.1" +version = "0.110.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11d18a3572cd897555bba3621e568029417d8f5cc26aeede2d7cb0bad6afd916" +checksum = "019e3dccb7f15e0bc14f0ddc034ec608a66df8e05c9e1e16f75a7716f8461799" dependencies = [ "cranelift-codegen", "cranelift-entity", @@ -490,7 +539,7 @@ dependencies = [ "itertools 0.12.1", "log", "smallvec", - "wasmparser 0.201.0", + "wasmparser 0.212.0", "wasmtime-types", ] @@ -657,6 +706,12 @@ version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a" +[[package]] +name = "embedded-io" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef1a6892d9eef45c8fa6b9e0086428a2cca8491aca8f787c534a3d6d0bcb3ced" + [[package]] name = "encoding_rs" version = "0.8.33" @@ -728,6 +783,15 @@ version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cdeb3aa5e95cf9aabc17f060cfa0ced7b83f042390760ca53bf09df9968acaa1" +[[package]] +name = "form_urlencoded" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" +dependencies = [ + "percent-encoding", +] + [[package]] name = "fs-set-times" version = "0.20.1" @@ -739,6 +803,67 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "futures" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" + +[[package]] +name = "futures-io" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" + +[[package]] +name = "futures-sink" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" + +[[package]] +name = "futures-task" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" + +[[package]] +name = "futures-util" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" +dependencies = [ + "futures-core", + "futures-sink", + "futures-task", + "pin-project-lite", + "pin-utils", +] + [[package]] name = "fxhash" version = "0.2.1" @@ -819,6 +944,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" dependencies = [ "ahash", + "serde", ] [[package]] @@ -886,6 +1012,16 @@ version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "25a2bc672d1148e28034f176e01fffebb08b35768468cc954630da77a1449005" +[[package]] +name = "idna" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] + [[package]] name = "indexmap" version = "2.2.6" @@ -1021,6 +1157,12 @@ dependencies = [ "once_cell", ] +[[package]] +name = "libm" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" + [[package]] name = "libredox" version = "0.1.3" @@ -1044,10 +1186,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" [[package]] -name = "mach" -version = "0.3.2" +name = "mach2" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b823e83b2affd8f40a9ee8c29dbc56404c1e34cd2710921f2801e2cf29527afa" +checksum = "19b955cdeb2a02b9117f121ce63aa52d08ade45de53e48fe6a38b39c10f6f709" dependencies = [ "libc", ] @@ -1074,12 +1216,24 @@ dependencies = [ ] [[package]] -name = "memoffset" -version = "0.9.1" +name = "miniz_oxide" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a" +checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08" dependencies = [ - "autocfg", + "adler", +] + +[[package]] +name = "mio" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80e04d1dcff3aae0704555fe5fee3bcfaf3d1fdf8a7e521d5b9d2b42acb52cec" +dependencies = [ + "hermit-abi 0.3.9", + "libc", + "wasi", + "windows-sys", ] [[package]] @@ -1096,6 +1250,15 @@ name = "object" version = "0.32.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" +dependencies = [ + "memchr", +] + +[[package]] +name = "object" +version = "0.36.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27b64972346851a39438c60b341ebc01bba47464ae329e55cf343eb93964efd9" dependencies = [ "crc32fast", "hashbrown 0.14.3", @@ -1121,12 +1284,24 @@ version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" +[[package]] +name = "percent-encoding" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" + [[package]] name = "pin-project-lite" version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + [[package]] name = "pkg-config" version = "0.3.30" @@ -1161,11 +1336,25 @@ dependencies = [ "plotters-backend", ] +[[package]] +name = "postcard" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a55c51ee6c0db07e68448e336cf8ea4131a620edefebf9893e759b2d793420f8" +dependencies = [ + "cobs", + "embedded-io", + "serde", +] + [[package]] name = "ppv-lite86" -version = "0.2.17" +version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" +checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" +dependencies = [ + "zerocopy", +] [[package]] name = "proc-macro-error" @@ -1382,6 +1571,9 @@ name = "semver" version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "92d43fe69e652f3df9bdc2b85b2854a0825b86e4fb76bc44d945137d053639ca" +dependencies = [ + "serde", +] [[package]] name = "serde" @@ -1467,6 +1659,19 @@ name = "smallvec" version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" +dependencies = [ + "serde", +] + +[[package]] +name = "socket2" +version = "0.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c" +dependencies = [ + "libc", + "windows-sys", +] [[package]] name = "sptr" @@ -1554,6 +1759,15 @@ version = "0.12.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e1fc403891a21bcfb7c37834ba66a547a8f402146eba7265b5a6d88059c9ff2f" +[[package]] +name = "termcolor" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" +dependencies = [ + "winapi-util", +] + [[package]] name = "textwrap" version = "0.11.0" @@ -1593,6 +1807,36 @@ dependencies = [ "serde_json", ] +[[package]] +name = "tinyvec" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "445e881f4f6d382d5f27c034e25eb92edd7c784ceab92a0937db7f2e9471b938" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + +[[package]] +name = "tokio" +version = "1.39.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9babc99b9923bfa4804bd74722ff02c0381021eafa4db9949217e3be8e84fff5" +dependencies = [ + "backtrace", + "bytes", + "libc", + "mio", + "pin-project-lite", + "socket2", + "windows-sys", +] + [[package]] name = "toml" version = "0.8.12" @@ -1633,7 +1877,6 @@ version = "0.1.40" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" dependencies = [ - "log", "pin-project-lite", "tracing-attributes", "tracing-core", @@ -1674,12 +1917,27 @@ dependencies = [ "serde_yaml", ] +[[package]] +name = "unicode-bidi" +version = "0.3.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" + [[package]] name = "unicode-ident" version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +[[package]] +name = "unicode-normalization" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5" +dependencies = [ + "tinyvec", +] + [[package]] name = "unicode-segmentation" version = "1.11.0" @@ -1704,6 +1962,17 @@ version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "673aac59facbab8a9007c7f6108d11f63b603f7cabff99fabf650fea5c32b861" +[[package]] +name = "url" +version = "2.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22784dbdf76fdde8af1aeda5622b546b422b6fc585325248a2bf9f5e41e94d6c" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", +] + [[package]] name = "utf8parse" version = "0.2.1" @@ -1744,32 +2013,6 @@ version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" -[[package]] -name = "wasi-common" -version = "19.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b53dfacdeacca15ee2a48a4aa0ec6a6d0da737676e465770c0585f79c04e638" -dependencies = [ - "anyhow", - "bitflags 2.5.0", - "cap-fs-ext", - "cap-rand", - "cap-std", - "cap-time-ext", - "fs-set-times", - "io-extras", - "io-lifetimes", - "log", - "once_cell", - "rustix", - "system-interface", - "thiserror", - "tracing", - "wasmtime", - "wiggle", - "windows-sys", -] - [[package]] name = "wasm-bindgen" version = "0.2.92" @@ -1826,18 +2069,27 @@ checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" [[package]] name = "wasm-encoder" -version = "0.201.0" +version = "0.202.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9c7d2731df60006819b013f64ccc2019691deccf6e11a1804bc850cd6748f1a" +checksum = "bfd106365a7f5f7aa3c1916a98cbb3ad477f5ff96ddb130285a91c6e7429e67a" dependencies = [ "leb128", ] [[package]] name = "wasm-encoder" -version = "0.202.0" +version = "0.212.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfd106365a7f5f7aa3c1916a98cbb3ad477f5ff96ddb130285a91c6e7429e67a" +checksum = "501940df4418b8929eb6d52f1aade1fdd15a5b86c92453cb696e3c906bd3fc33" +dependencies = [ + "leb128", +] + +[[package]] +name = "wasm-encoder" +version = "0.215.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fb56df3e06b8e6b77e37d2969a50ba51281029a9aeb3855e76b7f49b6418847" dependencies = [ "leb128", ] @@ -1858,9 +2110,9 @@ dependencies = [ [[package]] name = "wasmparser" -version = "0.201.0" +version = "0.202.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84e5df6dba6c0d7fafc63a450f1738451ed7a0b52295d83e868218fa286bf708" +checksum = "d6998515d3cf3f8b980ef7c11b29a9b1017d4cf86b99ae93b546992df9931413" dependencies = [ "bitflags 2.5.0", "indexmap", @@ -1869,66 +2121,80 @@ dependencies = [ [[package]] name = "wasmparser" -version = "0.202.0" +version = "0.212.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6998515d3cf3f8b980ef7c11b29a9b1017d4cf86b99ae93b546992df9931413" +checksum = "8d28bc49ba1e5c5b61ffa7a2eace10820443c4b7d1c0b144109261d14570fdf8" dependencies = [ + "ahash", "bitflags 2.5.0", + "hashbrown 0.14.3", "indexmap", "semver", + "serde", ] [[package]] name = "wasmprinter" -version = "0.201.0" +version = "0.202.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a67e66da702706ba08729a78e3c0079085f6bfcb1a62e4799e97bbf728c2c265" +checksum = "ab1cc9508685eef9502e787f4d4123745f5651a1e29aec047645d3cac1e2da7a" dependencies = [ "anyhow", - "wasmparser 0.201.0", + "wasmparser 0.202.0", ] [[package]] name = "wasmprinter" -version = "0.202.0" +version = "0.212.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab1cc9508685eef9502e787f4d4123745f5651a1e29aec047645d3cac1e2da7a" +checksum = "dfac65326cc561112af88c3028f6dfdb140acff67ede33a8e86be2dc6b8956f7" dependencies = [ "anyhow", - "wasmparser 0.202.0", + "termcolor", + "wasmparser 0.212.0", ] [[package]] name = "wasmtime" -version = "19.0.1" +version = "23.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "516be5b58a8f75d39b01378516dcb0ff7b9bc39c7f1f10eec5b338d4916cf988" +checksum = "07232e0b473af36112da7348f51e73fa8b11047a6cb546096da3812930b7c93a" dependencies = [ "addr2line", "anyhow", "async-trait", - "bincode", + "bitflags 2.5.0", "bumpalo", + "cc", "cfg-if", "encoding_rs", "fxprof-processed-profile", "gimli", + "hashbrown 0.14.3", "indexmap", "ittapi", "libc", + "libm", "log", - "object", + "mach2", + "memfd", + "object 0.36.3", "once_cell", "paste", + "postcard", + "psm", "rayon", "rustix", "semver", "serde", "serde_derive", "serde_json", + "smallvec", + "sptr", "target-lexicon", - "wasm-encoder 0.201.0", - "wasmparser 0.201.0", + "wasm-encoder 0.212.0", + "wasmparser 0.212.0", + "wasmtime-asm-macros", "wasmtime-cache", "wasmtime-component-macro", "wasmtime-component-util", @@ -1937,8 +2203,8 @@ dependencies = [ "wasmtime-fiber", "wasmtime-jit-debug", "wasmtime-jit-icache-coherence", - "wasmtime-runtime", "wasmtime-slab", + "wasmtime-versioned-export-macros", "wasmtime-winch", "wat", "windows-sys", @@ -1946,24 +2212,24 @@ dependencies = [ [[package]] name = "wasmtime-asm-macros" -version = "19.0.1" +version = "23.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8d22d88a92d69385f18143c946884bf6aaa9ec206ce54c85a2d320c1362b009" +checksum = "e5a9c42562d879c749288d9a26acc0d95d2ca069e30c2ec2efce84461c4d62b3" dependencies = [ "cfg-if", ] [[package]] name = "wasmtime-cache" -version = "19.0.1" +version = "23.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "068728a840223b56c964507550da671372e7e5c2f3a7856012b57482e3e979a7" +checksum = "38d5d5aac98c8ae87cf5244495da7722e3fa022aa6f3f4fcd5e3d6e5699ce422" dependencies = [ "anyhow", "base64", - "bincode", "directories-next", "log", + "postcard", "rustix", "serde", "serde_derive", @@ -1975,9 +2241,9 @@ dependencies = [ [[package]] name = "wasmtime-component-macro" -version = "19.0.1" +version = "23.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "631244bac89c57ebe7283209d86fe175ad5929328e75f61bf9141895cafbf52d" +checksum = "c0c3f57c4bc96f9b4a6ff4d6cb6e837913eff32e98d09e2b6d79b5c4647b415b" dependencies = [ "anyhow", "proc-macro2", @@ -1990,15 +2256,15 @@ dependencies = [ [[package]] name = "wasmtime-component-util" -version = "19.0.1" +version = "23.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82ad496ba0558f7602da5e9d4c201f35f7aefcca70f973ec916f3f0d0787ef74" +checksum = "1da707969bc31a565da9b32d087eb2370c95c6f2087c5539a15f2e3b27e77203" [[package]] name = "wasmtime-cranelift" -version = "19.0.1" +version = "23.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "961ab5ee4b17e627001b18069ee89ef906edbbd3f84955515f6aad5ab6d82299" +checksum = "62cb6135ec46994299be711b78b03acaa9480de3715f827d450f0c947a84977c" dependencies = [ "anyhow", "cfg-if", @@ -2010,62 +2276,46 @@ dependencies = [ "cranelift-wasm", "gimli", "log", - "object", + "object 0.36.3", "target-lexicon", "thiserror", - "wasmparser 0.201.0", - "wasmtime-cranelift-shared", + "wasmparser 0.212.0", "wasmtime-environ", "wasmtime-versioned-export-macros", ] -[[package]] -name = "wasmtime-cranelift-shared" -version = "19.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc4db94596be14cd1f85844ce85470bf68acf235143098b9d9bf72b49e47b917" -dependencies = [ - "anyhow", - "cranelift-codegen", - "cranelift-control", - "cranelift-native", - "gimli", - "object", - "target-lexicon", - "wasmtime-environ", -] - [[package]] name = "wasmtime-environ" -version = "19.0.1" +version = "23.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "420b13858ef27dfd116f1fdb0513e9593a307a632ade2ea58334b639a3d8d24e" +checksum = "9bcaa3b42a0718e9123da7fb75e8e13fc95df7db2a7e32e2f2f4f0d3333b7d6f" dependencies = [ "anyhow", - "bincode", "cpp_demangle", + "cranelift-bitset", "cranelift-entity", "gimli", "indexmap", "log", - "object", + "object 0.36.3", + "postcard", "rustc-demangle", + "semver", "serde", "serde_derive", "target-lexicon", - "thiserror", - "wasm-encoder 0.201.0", - "wasmparser 0.201.0", - "wasmprinter 0.201.0", + "wasm-encoder 0.212.0", + "wasmparser 0.212.0", + "wasmprinter 0.212.0", "wasmtime-component-util", "wasmtime-types", ] [[package]] name = "wasmtime-fiber" -version = "19.0.1" +version = "23.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d37ff0e11a023019e34fe839c74a1c00880b989f4446176b6cc6da3b58e3ef2" +checksum = "baf1c805515f4bc157f70f998038951009d21a19c1ef8c5fbb374a11b1d56672" dependencies = [ "anyhow", "cc", @@ -2078,11 +2328,11 @@ dependencies = [ [[package]] name = "wasmtime-jit-debug" -version = "19.0.1" +version = "23.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b849f19ad1d4a8133ff05b82c438144f17fb49b08e5f7995f8c1e25cf35f390" +checksum = "118e141e52f3898a531a612985bd09a5e05a1d646cad2f30a3020b675c21cd49" dependencies = [ - "object", + "object 0.36.3", "once_cell", "rustix", "wasmtime-versioned-export-macros", @@ -2090,97 +2340,100 @@ dependencies = [ [[package]] name = "wasmtime-jit-icache-coherence" -version = "19.0.1" +version = "23.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59c48eb4223d6556ffbf3decb146d0da124f1fd043f41c98b705252cb6a5c186" -dependencies = [ - "cfg-if", - "libc", - "windows-sys", -] - -[[package]] -name = "wasmtime-runtime" -version = "19.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fefac2cb5f5a6f365234a3584bf40bd2e45e7f6cd90a689d9b2afbb9881978f" +checksum = "2cfee42dac5148fc2664ab1f5cb8d7fa77a28d1a2cf1d9483abc2c3d751a58b9" dependencies = [ "anyhow", - "cc", "cfg-if", - "encoding_rs", - "indexmap", "libc", - "log", - "mach", - "memfd", - "memoffset", - "paste", - "psm", - "rustix", - "sptr", - "wasm-encoder 0.201.0", - "wasmtime-asm-macros", - "wasmtime-environ", - "wasmtime-fiber", - "wasmtime-jit-debug", - "wasmtime-versioned-export-macros", - "wasmtime-wmemcheck", "windows-sys", ] [[package]] name = "wasmtime-slab" -version = "19.0.1" +version = "23.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52d7b97b92df126fdbe994a53d2215828ec5ed5087535e6d4703b1fbd299f0e3" +checksum = "42eb8f6515708ec67974998c3e644101db4186308985f5ef7c2ef324ff33c948" [[package]] name = "wasmtime-types" -version = "19.0.1" +version = "23.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "509c88abb830819b259c49e2d4e4f22b555db066ba08ded0b76b071a2aa53ddf" +checksum = "046873fb8fb3e9652f3fd76fe99c8c8129007695c3d73b2e307fdae40f6e324c" dependencies = [ + "anyhow", "cranelift-entity", "serde", "serde_derive", - "thiserror", - "wasmparser 0.201.0", + "smallvec", + "wasmparser 0.212.0", ] [[package]] name = "wasmtime-versioned-export-macros" -version = "19.0.1" +version = "23.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1d81c092a61ca1667013e2eb08fed7c6c53e496dbbaa32d5685dc5152b0a772" +checksum = "99c02af2e9dbeb427304d1a08787d70ed0dbfec1af2236616f84c9f1f03e7969" dependencies = [ "proc-macro2", "quote", "syn 2.0.58", ] +[[package]] +name = "wasmtime-wasi" +version = "23.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2a1349f254d0b8f2ec8f996d0982f040abf22cd6ab19e3cf67afd033c552208" +dependencies = [ + "anyhow", + "async-trait", + "bitflags 2.5.0", + "bytes", + "cap-fs-ext", + "cap-net-ext", + "cap-rand", + "cap-std", + "cap-time-ext", + "fs-set-times", + "futures", + "io-extras", + "io-lifetimes", + "once_cell", + "rustix", + "system-interface", + "thiserror", + "tokio", + "tracing", + "url", + "wasmtime", + "wiggle", + "windows-sys", +] + [[package]] name = "wasmtime-winch" -version = "19.0.1" +version = "23.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0958907880e37a2d3974f5b3574c23bf70aaf1fc6c1f716625bb50dac776f1a" +checksum = "b2ceddc47a49af10908a288fdfdc296ab3932062cab62a785e3705bbb3709c59" dependencies = [ "anyhow", "cranelift-codegen", "gimli", - "object", + "object 0.36.3", "target-lexicon", - "wasmparser 0.201.0", - "wasmtime-cranelift-shared", + "wasmparser 0.212.0", + "wasmtime-cranelift", "wasmtime-environ", "winch-codegen", ] [[package]] name = "wasmtime-wit-bindgen" -version = "19.0.1" +version = "23.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a593ddefd2f80617df6bea084b2e422d8969e924bc209642a794d57518f59587" +checksum = "75f528f8b8a2376a3dacaf497d960216dd466d324425361e1e00e26de0a7705c" dependencies = [ "anyhow", "heck 0.4.1", @@ -2188,12 +2441,6 @@ dependencies = [ "wit-parser", ] -[[package]] -name = "wasmtime-wmemcheck" -version = "19.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b77212b6874bbc86d220bb1d28632d0c11c6afe996c3e1ddcf746b1a6b4919b9" - [[package]] name = "wast" version = "35.0.2" @@ -2205,24 +2452,24 @@ dependencies = [ [[package]] name = "wast" -version = "202.0.0" +version = "215.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fbcb11204515c953c9b42ede0a46a1c5e17f82af05c4fae201a8efff1b0f4fe" +checksum = "1ff1d00d893593249e60720be04a7c1f42f1c4dc3806a2869f4e66ab61eb54cb" dependencies = [ "bumpalo", "leb128", "memchr", "unicode-width", - "wasm-encoder 0.202.0", + "wasm-encoder 0.215.0", ] [[package]] name = "wat" -version = "1.202.0" +version = "1.215.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4de4b15a47135c56a3573406e9977b9518787a6154459b4842a9b9d3d1684848" +checksum = "670bf4d9c8cf76ae242d70ded47c546525b6dafaa6871f9bcb065344bf2b4e3d" dependencies = [ - "wast 202.0.0", + "wast 215.0.0", ] [[package]] @@ -2237,9 +2484,9 @@ dependencies = [ [[package]] name = "wiggle" -version = "19.0.1" +version = "23.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f093d8afdb09efaf2ed1037468bd4614308a762d215b6cafd60a7712993a8ffa" +checksum = "af4a61a764e5c4f0cb8c1796859d266e75828c244089e77c81c6158dd8c4fda4" dependencies = [ "anyhow", "async-trait", @@ -2252,9 +2499,9 @@ dependencies = [ [[package]] name = "wiggle-generate" -version = "19.0.1" +version = "23.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47c7bccd5172ce8d853242f723e42c84b8c131b24fb07a1570f9045d99258616" +checksum = "f2d45f4c50cfcbc222fb5221142fa65aa834d0a54b77b5760be0ea0a1ccad52d" dependencies = [ "anyhow", "heck 0.4.1", @@ -2267,9 +2514,9 @@ dependencies = [ [[package]] name = "wiggle-macro" -version = "19.0.1" +version = "23.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a69d087dee85991096fc0c6eaf4dcf4e17cd16a0594c33b8ab9e2d345234ef75" +checksum = "12e0fbccad12e5b406effb8676eb3713fdbe366975fb65d56f960ace6da118e4" dependencies = [ "proc-macro2", "quote", @@ -2310,9 +2557,9 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "winch-codegen" -version = "0.17.1" +version = "0.21.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e72a6a7034793b874b85e428fd6d7b3ccccb98c326e33af3aa40cdf50d0c33da" +checksum = "2a41b67a37ea74e83c38ef495cc213aba73385236b1deee883dc869e835003b9" dependencies = [ "anyhow", "cranelift-codegen", @@ -2320,7 +2567,8 @@ dependencies = [ "regalloc2", "smallvec", "target-lexicon", - "wasmparser 0.201.0", + "wasmparser 0.212.0", + "wasmtime-cranelift", "wasmtime-environ", ] @@ -2420,9 +2668,9 @@ dependencies = [ [[package]] name = "wit-parser" -version = "0.201.0" +version = "0.212.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "196d3ecfc4b759a8573bf86a9b3f8996b304b3732e4c7de81655f875f6efdca6" +checksum = "ceeb0424aa8679f3fcf2d6e3cfa381f3d6fa6179976a2c05a6249dd2bb426716" dependencies = [ "anyhow", "id-arena", @@ -2433,7 +2681,7 @@ dependencies = [ "serde_derive", "serde_json", "unicode-xid", - "wasmparser 0.201.0", + "wasmparser 0.212.0", ] [[package]] @@ -2459,11 +2707,11 @@ dependencies = [ "log", "rayon", "structopt", - "wasi-common", "wasm-encoder 0.202.0", "wasmparser 0.202.0", "wasmprinter 0.202.0", "wasmtime", + "wasmtime-wasi", "wat", ] @@ -2486,6 +2734,7 @@ version = "0.7.32" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be" dependencies = [ + "byteorder", "zerocopy-derive", ] diff --git a/crates/wizer/Cargo.toml b/crates/wizer/Cargo.toml index 2bc0ae69bdea..a11688703721 100644 --- a/crates/wizer/Cargo.toml +++ b/crates/wizer/Cargo.toml @@ -36,7 +36,7 @@ structopt = { version = "0.3.26", optional = true } wasm-encoder = "0.202.0" wasmparser = "0.202.0" wasmtime = { workspace = true } -wasi-common = { workspace = true } +wasmtime-wasi = { workspace = true, features = ["preview1"] } # Enable this dependency to get messages with WAT disassemblies when certain # internal panics occur. @@ -46,9 +46,8 @@ optional = true [workspace.dependencies] wasmprinter = "0.202.0" -wasmtime = "19" -wasi-common = "19" - +wasmtime = "23" +wasmtime-wasi = "23" [dev-dependencies] criterion = "0.5.1" diff --git a/crates/wizer/benches/regex.rs b/crates/wizer/benches/regex.rs index 83251aaca0aa..79ceb8350bfe 100644 --- a/crates/wizer/benches/regex.rs +++ b/crates/wizer/benches/regex.rs @@ -1,10 +1,11 @@ use criterion::{criterion_group, criterion_main, Criterion}; use std::convert::TryFrom; +use wizer::StoreData; fn run_iter( - linker: &wasmtime::Linker, + linker: &wasmtime::Linker, module: &wasmtime::Module, - mut store: &mut wasmtime::Store, + mut store: &mut wasmtime::Store, ) { let instance = linker.instantiate(&mut store, module).unwrap(); @@ -26,25 +27,41 @@ fn bench_regex(c: &mut Criterion) { let mut group = c.benchmark_group("regex"); group.bench_function("control", |b| { let engine = wasmtime::Engine::default(); - let wasi = wasi_common::sync::WasiCtxBuilder::new().build(); - let mut store = wasmtime::Store::new(&engine, wasi); + let wasi = wasmtime_wasi::WasiCtxBuilder::new().build_p1(); + let mut store = wasmtime::Store::new( + &engine, + StoreData { + wasi_ctx: Some(wasi), + }, + ); let module = wasmtime::Module::new(store.engine(), &include_bytes!("regex_bench.control.wasm")) .unwrap(); let mut linker = wasmtime::Linker::new(&engine); - wasi_common::sync::add_to_linker(&mut linker, |s| s).unwrap(); + wasmtime_wasi::preview1::add_to_linker_sync(&mut linker, |s: &mut StoreData| { + s.wasi_ctx.as_mut().unwrap() + }) + .unwrap(); b.iter(|| run_iter(&linker, &module, &mut store)); }); group.bench_function("wizer", |b| { let engine = wasmtime::Engine::default(); - let wasi = wasi_common::sync::WasiCtxBuilder::new().build(); - let mut store = wasmtime::Store::new(&engine, wasi); + let wasi = wasmtime_wasi::WasiCtxBuilder::new().build_p1(); + let mut store = wasmtime::Store::new( + &engine, + StoreData { + wasi_ctx: Some(wasi), + }, + ); let module = wasmtime::Module::new(store.engine(), &include_bytes!("regex_bench.control.wasm")) .unwrap(); let mut linker = wasmtime::Linker::new(&engine); - wasi_common::sync::add_to_linker(&mut linker, |s| s).unwrap(); + wasmtime_wasi::preview1::add_to_linker_sync(&mut linker, |s: &mut StoreData| { + s.wasi_ctx.as_mut().unwrap() + }) + .unwrap(); b.iter(|| run_iter(&linker, &module, &mut store)); }); diff --git a/crates/wizer/benches/uap.rs b/crates/wizer/benches/uap.rs index d5cdaa4343ad..beafc0d91eec 100644 --- a/crates/wizer/benches/uap.rs +++ b/crates/wizer/benches/uap.rs @@ -1,10 +1,11 @@ use criterion::{criterion_group, criterion_main, Criterion}; use std::convert::TryFrom; +use wizer::StoreData; fn run_iter( - linker: &wasmtime::Linker, + linker: &wasmtime::Linker, module: &wasmtime::Module, - mut store: &mut wasmtime::Store, + mut store: &mut wasmtime::Store, ) { let instance = linker.instantiate(&mut store, module).unwrap(); @@ -39,24 +40,40 @@ fn bench_uap(c: &mut Criterion) { let mut group = c.benchmark_group("uap"); group.bench_function("control", |b| { let engine = wasmtime::Engine::default(); - let wasi = wasi_common::sync::WasiCtxBuilder::new().build(); - let mut store = wasmtime::Store::new(&engine, wasi); + let wasi = wasmtime_wasi::WasiCtxBuilder::new().build_p1(); + let mut store = wasmtime::Store::new( + &engine, + StoreData { + wasi_ctx: Some(wasi), + }, + ); let module = wasmtime::Module::new(store.engine(), &include_bytes!("uap_bench.control.wasm")) .unwrap(); let mut linker = wasmtime::Linker::new(&engine); - wasi_common::sync::add_to_linker(&mut linker, |s| s).unwrap(); + wasmtime_wasi::preview1::add_to_linker_sync(&mut linker, |s: &mut StoreData| { + s.wasi_ctx.as_mut().unwrap() + }) + .unwrap(); b.iter(|| run_iter(&linker, &module, &mut store)); }); group.bench_function("wizer", |b| { let engine = wasmtime::Engine::default(); - let wasi = wasi_common::sync::WasiCtxBuilder::new().build(); - let mut store = wasmtime::Store::new(&engine, wasi); + let wasi = wasmtime_wasi::WasiCtxBuilder::new().build_p1(); + let mut store = wasmtime::Store::new( + &engine, + StoreData { + wasi_ctx: Some(wasi), + }, + ); let module = wasmtime::Module::new(store.engine(), &include_bytes!("uap_bench.wizer.wasm")).unwrap(); let mut linker = wasmtime::Linker::new(&engine); - wasi_common::sync::add_to_linker(&mut linker, |s| s).unwrap(); + wasmtime_wasi::preview1::add_to_linker_sync(&mut linker, |s: &mut StoreData| { + s.wasi_ctx.as_mut().unwrap() + }) + .unwrap(); b.iter(|| run_iter(&linker, &module, &mut store)); }); diff --git a/crates/wizer/src/lib.rs b/crates/wizer/src/lib.rs index c50a150378a2..f52b882fa117 100644 --- a/crates/wizer/src/lib.rs +++ b/crates/wizer/src/lib.rs @@ -17,7 +17,6 @@ mod snapshot; mod stack_ext; mod translate; -use wasi_common::sync::WasiCtxBuilder; /// Re-export wasmtime so users can align with our version. This is /// especially useful when providing a custom Linker. pub use wasmtime; @@ -30,8 +29,11 @@ use std::path::PathBuf; use std::rc::Rc; #[cfg(feature = "structopt")] use structopt::StructOpt; -use wasi_common::WasiCtx; use wasmtime::{Engine, Extern}; +use wasmtime_wasi::{ + preview1::{self, WasiP1Ctx}, + WasiCtxBuilder, +}; const DEFAULT_INHERIT_STDIO: bool = true; const DEFAULT_INHERIT_ENV: bool = false; @@ -41,15 +43,22 @@ const DEFAULT_WASM_MULTI_MEMORY: bool = true; const DEFAULT_WASM_BULK_MEMORY: bool = false; const DEFAULT_WASM_SIMD: bool = true; +/// The type of data that is stored in the `wasmtime::Store` during +/// initialization. +pub struct StoreData { + /// The WASI context that is optionally used during initialization. + pub wasi_ctx: Option, +} + /// We only ever use `Store` with a fixed `T` that is our optional WASI /// context. -pub(crate) type Store = wasmtime::Store>; +pub(crate) type Store = wasmtime::Store; /// The type of linker that Wizer uses when evaluating the initialization function. -pub type Linker = wasmtime::Linker>; +pub type Linker = wasmtime::Linker; #[cfg(feature = "structopt")] -fn parse_map_dirs(s: &str) -> anyhow::Result<(PathBuf, PathBuf)> { +fn parse_map_dirs(s: &str) -> anyhow::Result<(String, PathBuf)> { let parts: Vec<&str> = s.split("::").collect(); if parts.len() != 2 { anyhow::bail!("must contain exactly one double colon ('::')"); @@ -211,7 +220,7 @@ pub struct Wizer { feature = "structopt", structopt(long = "mapdir", value_name = "GUEST_DIR::HOST_DIR", parse(try_from_str = parse_map_dirs)) )] - map_dirs: Vec<(PathBuf, PathBuf)>, + map_dirs: Vec<(String, PathBuf)>, /// Enable or disable Wasm multi-memory proposal. /// @@ -504,7 +513,7 @@ impl Wizer { /// None are mapped by default. pub fn map_dir( &mut self, - guest_dir: impl Into, + guest_dir: impl Into, host_dir: impl Into, ) -> &mut Self { self.map_dirs.push((guest_dir.into(), host_dir.into())); @@ -576,7 +585,7 @@ impl Wizer { let config = self.wasmtime_config()?; let engine = wasmtime::Engine::new(&config)?; let wasi_ctx = self.wasi_context()?; - let mut store = wasmtime::Store::new(&engine, wasi_ctx); + let mut store = wasmtime::Store::new(&engine, StoreData { wasi_ctx }); let module = wasmtime::Module::new(&engine, &instrumented_wasm) .context("failed to compile the Wasm module")?; self.validate_init_func(&module)?; @@ -762,7 +771,7 @@ impl Wizer { Ok(()) } - fn wasi_context(&self) -> anyhow::Result> { + fn wasi_context(&self) -> anyhow::Result> { if !self.allow_wasi { return Ok(None); } @@ -772,31 +781,30 @@ impl Wizer { ctx.inherit_stdio(); } if self.inherit_env.unwrap_or(DEFAULT_INHERIT_ENV) { - ctx.inherit_env()?; + ctx.inherit_env(); } for dir in &self.dirs { log::debug!("Preopening directory: {}", dir.display()); - let preopened = wasi_common::sync::Dir::open_ambient_dir( + let guest = dir.display().to_string(); + ctx.preopened_dir( dir, - wasi_common::sync::ambient_authority(), + guest, + wasmtime_wasi::DirPerms::all(), + wasmtime_wasi::FilePerms::all(), ) .with_context(|| format!("failed to open directory: {}", dir.display()))?; - ctx.preopened_dir(preopened, dir)?; } for (guest_dir, host_dir) in &self.map_dirs { - log::debug!( - "Preopening directory: {}::{}", - guest_dir.display(), - host_dir.display() - ); - let preopened = wasi_common::sync::Dir::open_ambient_dir( + log::debug!("Preopening directory: {guest_dir}::{}", host_dir.display()); + ctx.preopened_dir( host_dir, - wasi_common::sync::ambient_authority(), + guest_dir, + wasmtime_wasi::DirPerms::all(), + wasmtime_wasi::FilePerms::all(), ) .with_context(|| format!("failed to open directory: {}", host_dir.display()))?; - ctx.preopened_dir(preopened, guest_dir)?; } - Ok(Some(ctx.build())) + Ok(Some(ctx.build_p1())) } /// Preload a module. @@ -834,8 +842,8 @@ impl Wizer { }; if self.allow_wasi { - wasi_common::sync::add_to_linker(&mut linker, |ctx: &mut Option| { - ctx.as_mut().unwrap() + preview1::add_to_linker_sync(&mut linker, |ctx: &mut StoreData| { + ctx.wasi_ctx.as_mut().unwrap() })?; } diff --git a/crates/wizer/tests/make_linker.rs b/crates/wizer/tests/make_linker.rs index 5e43822f82f1..195b6034721c 100644 --- a/crates/wizer/tests/make_linker.rs +++ b/crates/wizer/tests/make_linker.rs @@ -1,5 +1,6 @@ use anyhow::{anyhow, Context, Result}; use std::rc::Rc; +use wasmtime_wasi::WasiCtxBuilder; use wat::parse_str as wat_to_wasm; use wizer::Wizer; @@ -35,7 +36,7 @@ fn run_wasm(args: &[wasmtime::Val], expected: i32, wasm: &[u8]) -> Result<()> { config.wasm_multi_value(true); let engine = wasmtime::Engine::new(&config)?; - let wasi_ctx = wasi_common::sync::WasiCtxBuilder::new().build(); + let wasi_ctx = WasiCtxBuilder::new().build_p1(); let mut store = wasmtime::Store::new(&engine, wasi_ctx); let module = wasmtime::Module::new(store.engine(), wasm).context("Wasm test case failed to compile")?; diff --git a/crates/wizer/tests/tests.rs b/crates/wizer/tests/tests.rs index 197df13f1d44..66c2f3fdd980 100644 --- a/crates/wizer/tests/tests.rs +++ b/crates/wizer/tests/tests.rs @@ -1,7 +1,8 @@ use anyhow::{Context, Result}; use wasm_encoder::ConstExpr; +use wasmtime_wasi::{preview1, WasiCtxBuilder}; use wat::parse_str as wat_to_wasm; -use wizer::Wizer; +use wizer::{StoreData, Wizer}; fn run_wat(args: &[wasmtime::Val], expected: i32, wat: &str) -> Result<()> { let _ = env_logger::try_init(); @@ -48,8 +49,13 @@ fn wizen_and_run_wasm( config.wasm_multi_value(true); let engine = wasmtime::Engine::new(&config)?; - let wasi_ctx = wasi_common::sync::WasiCtxBuilder::new().build(); - let mut store = wasmtime::Store::new(&engine, wasi_ctx); + let wasi_ctx = WasiCtxBuilder::new().build_p1(); + let mut store = wasmtime::Store::new( + &engine, + StoreData { + wasi_ctx: Some(wasi_ctx), + }, + ); let module = wasmtime::Module::new(store.engine(), wasm).context("Wasm test case failed to compile")?; @@ -61,7 +67,7 @@ fn wizen_and_run_wasm( .define_name(&mut store, "f", thunk)? .define(&mut store, "x", "f", thunk)?; - wasi_common::sync::add_to_linker(&mut linker, |wasi| wasi)?; + preview1::add_to_linker_sync(&mut linker, |wasi| wasi.wasi_ctx.as_mut().unwrap())?; let instance = linker.instantiate(&mut store, &module)?; From a5291bcf2faf0283853b7ce8825e20ba68aff334 Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Tue, 20 Aug 2024 08:58:45 -0700 Subject: [PATCH 193/212] Bump to version 7.0.0 (#110) --- crates/wizer/Cargo.lock | 2 +- crates/wizer/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/wizer/Cargo.lock b/crates/wizer/Cargo.lock index cb1a664bfc46..17f7e2e69ec1 100644 --- a/crates/wizer/Cargo.lock +++ b/crates/wizer/Cargo.lock @@ -2698,7 +2698,7 @@ dependencies = [ [[package]] name = "wizer" -version = "6.0.0" +version = "7.0.0" dependencies = [ "anyhow", "cap-std", diff --git a/crates/wizer/Cargo.toml b/crates/wizer/Cargo.toml index a11688703721..9fa4aed00604 100644 --- a/crates/wizer/Cargo.toml +++ b/crates/wizer/Cargo.toml @@ -10,7 +10,7 @@ license = "Apache-2.0 WITH LLVM-exception" name = "wizer" readme = "./README.md" repository = "https://github.com/bytecodealliance/wizer" -version = "6.0.0" +version = "7.0.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html From b1c6c49d6b9e16c20fff2f98dc2540692769230a Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Tue, 20 Aug 2024 10:07:09 -0700 Subject: [PATCH 194/212] Bump to 7.0.1 (#111) --- crates/wizer/Cargo.lock | 2 +- crates/wizer/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/wizer/Cargo.lock b/crates/wizer/Cargo.lock index 17f7e2e69ec1..8c5189031735 100644 --- a/crates/wizer/Cargo.lock +++ b/crates/wizer/Cargo.lock @@ -2698,7 +2698,7 @@ dependencies = [ [[package]] name = "wizer" -version = "7.0.0" +version = "7.0.1" dependencies = [ "anyhow", "cap-std", diff --git a/crates/wizer/Cargo.toml b/crates/wizer/Cargo.toml index 9fa4aed00604..1b734bedeb04 100644 --- a/crates/wizer/Cargo.toml +++ b/crates/wizer/Cargo.toml @@ -10,7 +10,7 @@ license = "Apache-2.0 WITH LLVM-exception" name = "wizer" readme = "./README.md" repository = "https://github.com/bytecodealliance/wizer" -version = "7.0.0" +version = "7.0.1" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html From 8ffd07bf589f3c530fe9019bcc10f89f2fc5c0f0 Mon Sep 17 00:00:00 2001 From: Guy Bedford Date: Tue, 20 Aug 2024 22:20:14 +0200 Subject: [PATCH 195/212] fixup deploy workflow (#112) --- crates/wizer/.github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/wizer/.github/workflows/release.yml b/crates/wizer/.github/workflows/release.yml index d3adbbbc0094..303cd6c5f536 100644 --- a/crates/wizer/.github/workflows/release.yml +++ b/crates/wizer/.github/workflows/release.yml @@ -126,7 +126,7 @@ jobs: working-directory: ./npm/wizer run: npm install && npm version "${{ steps.tagname.outputs.val }}" --allow-same-version - name: Setup npm auth - run: sudo npm config --global set '//registry.npmjs.org/:_authToken'='$NODE_AUTH_TOKEN' + run: sudo npm config --global set '//registry.npmjs.org/:_authToken'='${NODE_AUTH_TOKEN}' - name: Publish npm packages if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') working-directory: ./npm From 6c75d82ca7e1d8081b68e446d60de9e91649fb8e Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Tue, 20 Aug 2024 13:31:27 -0700 Subject: [PATCH 196/212] Bump to 7.0.2 (#113) --- crates/wizer/Cargo.lock | 2 +- crates/wizer/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/wizer/Cargo.lock b/crates/wizer/Cargo.lock index 8c5189031735..382401b1ec1c 100644 --- a/crates/wizer/Cargo.lock +++ b/crates/wizer/Cargo.lock @@ -2698,7 +2698,7 @@ dependencies = [ [[package]] name = "wizer" -version = "7.0.1" +version = "7.0.2" dependencies = [ "anyhow", "cap-std", diff --git a/crates/wizer/Cargo.toml b/crates/wizer/Cargo.toml index 1b734bedeb04..7b2de6b66bd5 100644 --- a/crates/wizer/Cargo.toml +++ b/crates/wizer/Cargo.toml @@ -10,7 +10,7 @@ license = "Apache-2.0 WITH LLVM-exception" name = "wizer" readme = "./README.md" repository = "https://github.com/bytecodealliance/wizer" -version = "7.0.1" +version = "7.0.2" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html From fec92a061f842c419e7c00153fdd7c4fa44ca9e2 Mon Sep 17 00:00:00 2001 From: Guy Bedford Date: Wed, 21 Aug 2024 00:34:27 +0200 Subject: [PATCH 197/212] release: fix version updating (#114) --- crates/wizer/.github/workflows/release.yml | 2 +- crates/wizer/npm/wizer/package.json | 20 +++++++++----------- crates/wizer/npm/wizer/update.js | 14 +++++++++++--- 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/crates/wizer/.github/workflows/release.yml b/crates/wizer/.github/workflows/release.yml index 303cd6c5f536..009512240bb0 100644 --- a/crates/wizer/.github/workflows/release.yml +++ b/crates/wizer/.github/workflows/release.yml @@ -124,7 +124,7 @@ jobs: - name: Update npm packages to latest version if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') working-directory: ./npm/wizer - run: npm install && npm version "${{ steps.tagname.outputs.val }}" --allow-same-version + run: npm install && node update.js "${{ steps.tagname.outputs.val }}" - name: Setup npm auth run: sudo npm config --global set '//registry.npmjs.org/:_authToken'='${NODE_AUTH_TOKEN}' - name: Publish npm packages diff --git a/crates/wizer/npm/wizer/package.json b/crates/wizer/npm/wizer/package.json index d8a0ad6864a0..408684a0fd1b 100644 --- a/crates/wizer/npm/wizer/package.json +++ b/crates/wizer/npm/wizer/package.json @@ -1,11 +1,9 @@ { "name": "@bytecodealliance/wizer", - "version": "6.0.0", + "version": "VERSION", "description": "The WebAssembly Pre-Initializer", + "private": true, "type": "module", - "scripts": { - "version": "node ./update.js $npm_package_version" - }, "devDependencies": { "decompress": "^4.2.1", "decompress-unzip": "^4.0.1", @@ -20,12 +18,12 @@ "wizer": "./wizer.js" }, "optionalDependencies": { - "@bytecodealliance/wizer-darwin-arm64": "6.0.0", - "@bytecodealliance/wizer-darwin-x64": "6.0.0", - "@bytecodealliance/wizer-linux-x64": "6.0.0", - "@bytecodealliance/wizer-linux-arm64": "6.0.0", - "@bytecodealliance/wizer-linux-s390x": "6.0.0", - "@bytecodealliance/wizer-win32-x64": "6.0.0" + "@bytecodealliance/wizer-darwin-arm64": "VERSION", + "@bytecodealliance/wizer-darwin-x64": "VERSION", + "@bytecodealliance/wizer-linux-x64": "VERSION", + "@bytecodealliance/wizer-linux-arm64": "VERSION", + "@bytecodealliance/wizer-linux-s390x": "VERSION", + "@bytecodealliance/wizer-win32-x64": "VERSION" }, "license": "Apache-2.0", "repository": { @@ -36,4 +34,4 @@ "url": "https://github.com/bytecodealliance/wizer/issues" }, "homepage": "https://github.com/bytecodealliance/wizer#readme" -} +} \ No newline at end of file diff --git a/crates/wizer/npm/wizer/update.js b/crates/wizer/npm/wizer/update.js index 60652496eb4c..c88ab4abc60e 100644 --- a/crates/wizer/npm/wizer/update.js +++ b/crates/wizer/npm/wizer/update.js @@ -2,14 +2,22 @@ import { fileURLToPath } from 'node:url'; import { dirname, join, parse } from 'node:path'; -import { mkdir, writeFile } from "node:fs/promises"; +import { mkdir, writeFile, readFile } from "node:fs/promises"; import decompress from 'decompress'; import decompressUnzip from 'decompress-unzip'; import decompressTar from 'decompress-tar'; import plzma from 'plzmasdk'; const __dirname = dirname(fileURLToPath(import.meta.url)); -const input = process.argv.slice(2).at(0); -const tag = input ? `v${input}` : 'dev'; +const version = process.argv.slice(2).at(0).trim(); +const tag = version ? `v${version}` : 'dev'; + +const pjson = JSON.parse(await readFile('package.json')); +pjson.version = version; +delete pjson.private; +for (const dep of Object.keys(pjson.optionalDependencies)) { + pjson.optionalDependencies[dep] = version; +} +await writeFile('package.json', JSON.stringify(pjson, null, 2)); let packages = { 'wizer-darwin-arm64': { From be98f623c6d3ff81a0fe56f181d3551e0d20df65 Mon Sep 17 00:00:00 2001 From: Guy Bedford Date: Wed, 21 Aug 2024 00:54:21 +0200 Subject: [PATCH 198/212] 7.0.3 (#115) --- crates/wizer/Cargo.lock | 2 +- crates/wizer/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/wizer/Cargo.lock b/crates/wizer/Cargo.lock index 382401b1ec1c..8e84b573b25c 100644 --- a/crates/wizer/Cargo.lock +++ b/crates/wizer/Cargo.lock @@ -2698,7 +2698,7 @@ dependencies = [ [[package]] name = "wizer" -version = "7.0.2" +version = "7.0.3" dependencies = [ "anyhow", "cap-std", diff --git a/crates/wizer/Cargo.toml b/crates/wizer/Cargo.toml index 7b2de6b66bd5..ce980f2f3543 100644 --- a/crates/wizer/Cargo.toml +++ b/crates/wizer/Cargo.toml @@ -10,7 +10,7 @@ license = "Apache-2.0 WITH LLVM-exception" name = "wizer" readme = "./README.md" repository = "https://github.com/bytecodealliance/wizer" -version = "7.0.2" +version = "7.0.3" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html From 5b91ee38b65d7e6a587231ae323959dbe3c48c20 Mon Sep 17 00:00:00 2001 From: Guy Bedford Date: Wed, 21 Aug 2024 02:18:44 +0200 Subject: [PATCH 199/212] release: fix version tag reader (#116) --- crates/wizer/npm/wizer/update.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/wizer/npm/wizer/update.js b/crates/wizer/npm/wizer/update.js index c88ab4abc60e..288251452c71 100644 --- a/crates/wizer/npm/wizer/update.js +++ b/crates/wizer/npm/wizer/update.js @@ -8,8 +8,8 @@ import decompressUnzip from 'decompress-unzip'; import decompressTar from 'decompress-tar'; import plzma from 'plzmasdk'; const __dirname = dirname(fileURLToPath(import.meta.url)); -const version = process.argv.slice(2).at(0).trim(); -const tag = version ? `v${version}` : 'dev'; +const tag = process.argv.slice(2).at(0).trim() || 'dev'; +const version = tag.startsWith('v') ? tag.slice(1) : tag; const pjson = JSON.parse(await readFile('package.json')); pjson.version = version; From e843a3585db9ba7fc34d85a285514a1d22e2f254 Mon Sep 17 00:00:00 2001 From: Guy Bedford Date: Wed, 21 Aug 2024 02:26:12 +0200 Subject: [PATCH 200/212] 7.0.4 (#117) --- crates/wizer/Cargo.lock | 2 +- crates/wizer/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/wizer/Cargo.lock b/crates/wizer/Cargo.lock index 8e84b573b25c..c11ada341a59 100644 --- a/crates/wizer/Cargo.lock +++ b/crates/wizer/Cargo.lock @@ -2698,7 +2698,7 @@ dependencies = [ [[package]] name = "wizer" -version = "7.0.3" +version = "7.0.4" dependencies = [ "anyhow", "cap-std", diff --git a/crates/wizer/Cargo.toml b/crates/wizer/Cargo.toml index ce980f2f3543..ed4bd9c68ac6 100644 --- a/crates/wizer/Cargo.toml +++ b/crates/wizer/Cargo.toml @@ -10,7 +10,7 @@ license = "Apache-2.0 WITH LLVM-exception" name = "wizer" readme = "./README.md" repository = "https://github.com/bytecodealliance/wizer" -version = "7.0.3" +version = "7.0.4" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html From 094cb477bbdaa12d756ff02199c9f514d3eb7c37 Mon Sep 17 00:00:00 2001 From: Chris Fallin Date: Thu, 5 Sep 2024 14:23:38 -0700 Subject: [PATCH 201/212] Fix Intel Mac CI builds. (#118) * Fix Intel Mac CI builds. We build both x86-64 and aarch64 ("Intel Mac" and "Apple Silicon Mac") binaries for wizer in CI on the `macos-latest` CI runner. Historically, this runner was an x86-64 machine, so while we could do a direct compile for x86-64 binaries, we added a target override for `aarch64-darwin` for the aarch64 builds to force a cross-compile. When GitHub switched macOS CI runners to aarch64 (ARM64) machines somewhat recently, the `macos-latest` runner image began producing aarch64 binaries by default, and the target override for cross-compilation became meaningless (redundant). As a result, *both* of our x86-64 and aarch64 macOS binary artifacts contained aarch64 binaries. This is a problem for anyone running an Intel Mac. This PR switches the CI config to specify a cross-compilation of x86-64 binaries, so each target builds its proper architecture. * Use actions/upload-artifact v4 * Use v4 of actions/download-artifact too --- crates/wizer/.github/workflows/ci.yml | 1 + crates/wizer/.github/workflows/release.yml | 17 +++++++++-------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/crates/wizer/.github/workflows/ci.yml b/crates/wizer/.github/workflows/ci.yml index 2c2bbfba4a74..0c4ac924d011 100644 --- a/crates/wizer/.github/workflows/ci.yml +++ b/crates/wizer/.github/workflows/ci.yml @@ -15,6 +15,7 @@ jobs: os: ubuntu-latest - build: x86_64-macos os: macos-latest + target: x86_64-apple-darwin - build: aarch64-macos os: macos-latest target: aarch64-apple-darwin diff --git a/crates/wizer/.github/workflows/release.yml b/crates/wizer/.github/workflows/release.yml index 009512240bb0..f8c486fe24ea 100644 --- a/crates/wizer/.github/workflows/release.yml +++ b/crates/wizer/.github/workflows/release.yml @@ -24,6 +24,7 @@ jobs: os: ubuntu-latest - build: x86_64-macos os: macos-latest + target: x86_64-apple-darwin - build: aarch64-macos os: macos-latest target: aarch64-apple-darwin @@ -57,7 +58,7 @@ jobs: # Assemble release artifats appropriate for this platform, then upload them # unconditionally to this workflow's files so we have a copy of them. - run: ./ci/build-tarballs.sh "${{ matrix.build }}" "${{ matrix.target }}" - - uses: actions/upload-artifact@v1 + - uses: actions/upload-artifact@v4 with: name: bins-${{ matrix.build }} path: dist @@ -69,31 +70,31 @@ jobs: # Download all the artifacts that we'll be publishing. Should keep an eye on # the `download-artifact` repository to see if we can ever get something # like "download all artifacts" or "download this list of artifacts" - - uses: actions/download-artifact@v1 + - uses: actions/download-artifact@v4 with: name: bins-x86_64-macos path: dist - - uses: actions/download-artifact@v1 + - uses: actions/download-artifact@v4 with: name: bins-aarch64-macos path: dist - - uses: actions/download-artifact@v1 + - uses: actions/download-artifact@v4 with: name: bins-x86_64-windows path: dist - - uses: actions/download-artifact@v1 + - uses: actions/download-artifact@v4 with: name: bins-x86_64-mingw path: dist - - uses: actions/download-artifact@v1 + - uses: actions/download-artifact@v4 with: name: bins-x86_64-linux path: dist - - uses: actions/download-artifact@v1 + - uses: actions/download-artifact@v4 with: name: bins-aarch64-linux path: dist - - uses: actions/download-artifact@v1 + - uses: actions/download-artifact@v4 with: name: bins-s390x-linux path: dist From 16b97f0641869066b9c27db3f2542f96c8c142f6 Mon Sep 17 00:00:00 2001 From: Guy Bedford Date: Thu, 5 Sep 2024 23:32:43 +0200 Subject: [PATCH 202/212] 7.0.5 (#119) --- crates/wizer/Cargo.lock | 2 +- crates/wizer/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/wizer/Cargo.lock b/crates/wizer/Cargo.lock index c11ada341a59..16d0e5e24f73 100644 --- a/crates/wizer/Cargo.lock +++ b/crates/wizer/Cargo.lock @@ -2698,7 +2698,7 @@ dependencies = [ [[package]] name = "wizer" -version = "7.0.4" +version = "7.0.5" dependencies = [ "anyhow", "cap-std", diff --git a/crates/wizer/Cargo.toml b/crates/wizer/Cargo.toml index ed4bd9c68ac6..9f5bc58de28d 100644 --- a/crates/wizer/Cargo.toml +++ b/crates/wizer/Cargo.toml @@ -10,7 +10,7 @@ license = "Apache-2.0 WITH LLVM-exception" name = "wizer" readme = "./README.md" repository = "https://github.com/bytecodealliance/wizer" -version = "7.0.4" +version = "7.0.5" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html From e1f43b1bd669aec18f4f15e25d710a5516ed4544 Mon Sep 17 00:00:00 2001 From: Guy Bedford Date: Fri, 6 Sep 2024 00:19:31 +0200 Subject: [PATCH 203/212] update ci write permissions (#120) --- crates/wizer/.github/workflows/release.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/wizer/.github/workflows/release.yml b/crates/wizer/.github/workflows/release.yml index f8c486fe24ea..648eae191961 100644 --- a/crates/wizer/.github/workflows/release.yml +++ b/crates/wizer/.github/workflows/release.yml @@ -8,6 +8,8 @@ defaults: run: shell: bash +permissions: write-all + # Cancel any in-flight jobs for the same PR/branch so there's only one active # at a time concurrency: From 4818cbebb4fa3d4d716bbe73a0610be70b151109 Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Thu, 27 Feb 2025 02:22:02 +0900 Subject: [PATCH 204/212] Update wasmtime to v29 (#127) --- crates/wizer/Cargo.lock | 581 ++++++++++++++++++++++------------------ crates/wizer/Cargo.toml | 4 +- 2 files changed, 328 insertions(+), 257 deletions(-) diff --git a/crates/wizer/Cargo.lock b/crates/wizer/Cargo.lock index 16d0e5e24f73..35f29d5ac5f5 100644 --- a/crates/wizer/Cargo.lock +++ b/crates/wizer/Cargo.lock @@ -8,7 +8,16 @@ version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" dependencies = [ - "gimli", + "gimli 0.28.1", +] + +[[package]] +name = "addr2line" +version = "0.24.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1" +dependencies = [ + "gimli 0.31.1", ] [[package]] @@ -38,6 +47,12 @@ dependencies = [ "memchr", ] +[[package]] +name = "allocator-api2" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" + [[package]] name = "ambient-authority" version = "0.0.2" @@ -103,7 +118,7 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e28923312444cdd728e4738b3f9c9cac739500909bb3d3c94b43551b16517648" dependencies = [ - "windows-sys", + "windows-sys 0.52.0", ] [[package]] @@ -113,20 +128,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7" dependencies = [ "anstyle", - "windows-sys", + "windows-sys 0.52.0", ] [[package]] name = "anyhow" -version = "1.0.81" +version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0952808a6c2afd1aa8947271f3a60f1a6763c7b912d210184c5149b5cf147247" +checksum = "34ac096ce696dc2fcabef30516bb13c0a68a11d30131d3df6f04711467681b04" [[package]] name = "arbitrary" -version = "1.3.2" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d5a26814d8dcb93b0e5a0ff3c6d80a8843bafb21b39e8e18a6f05471870e110" +checksum = "dde20b3d026af13f561bdd0f15edf01fc734f0dafcedbaf42bba506a9517f223" dependencies = [ "derive_arbitrary", ] @@ -139,7 +154,7 @@ checksum = "a507401cad91ec6a857ed5513a2073c82a9b9048762b885bb98655b306964681" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.98", ] [[package]] @@ -165,7 +180,7 @@ version = "0.3.71" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "26b05800d2e817c8b3b4b54abd461726265fa9789ae34330622f2db9ee696f9d" dependencies = [ - "addr2line", + "addr2line 0.21.0", "cc", "cfg-if", "libc", @@ -203,9 +218,12 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.15.4" +version = "3.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ff69b9dd49fd426c69a0db9fc04dd934cdb6645ff000864d98f7e2af8830eaa" +checksum = "1628fb46dfa0b37568d12e5edd512553eccf6a22a78e8bde00bb4aed84d5bdbf" +dependencies = [ + "allocator-api2", +] [[package]] name = "byteorder" @@ -221,21 +239,21 @@ checksum = "8318a53db07bb3f8dca91a600466bdb3f2eaadeedfdbcf02e1accbad9271ba50" [[package]] name = "cap-fs-ext" -version = "3.0.0" +version = "3.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "769f8cd02eb04d57f14e2e371ebb533f96817f9b2525d73a5c72b61ca7973747" +checksum = "7f78efdd7378980d79c0f36b519e51191742d2c9f91ffa5e228fba9f3806d2e1" dependencies = [ "cap-primitives", "cap-std", "io-lifetimes", - "windows-sys", + "windows-sys 0.59.0", ] [[package]] name = "cap-net-ext" -version = "3.0.0" +version = "3.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59ff6d3fb274292a9af283417e383afe6ded1fe66f6472d2c781216d3d80c218" +checksum = "4ac68674a6042af2bcee1adad9f6abd432642cf03444ce3a5b36c3f39f23baf8" dependencies = [ "cap-primitives", "cap-std", @@ -245,9 +263,9 @@ dependencies = [ [[package]] name = "cap-primitives" -version = "3.0.0" +version = "3.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90a0b44fc796b1a84535a63753d50ba3972c4db55c7255c186f79140e63d56d0" +checksum = "8fc15faeed2223d8b8e8cc1857f5861935a06d06713c4ac106b722ae9ce3c369" dependencies = [ "ambient-authority", "fs-set-times", @@ -256,15 +274,15 @@ dependencies = [ "ipnet", "maybe-owned", "rustix", - "windows-sys", + "windows-sys 0.59.0", "winx", ] [[package]] name = "cap-rand" -version = "3.2.0" +version = "3.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbcb16a619d8b8211ed61f42bd290d2a1ac71277a69cf8417ec0996fa92f5211" +checksum = "dea13372b49df066d1ae654e5c6e41799c1efd9f6b36794b921e877ea4037977" dependencies = [ "ambient-authority", "rand", @@ -272,9 +290,9 @@ dependencies = [ [[package]] name = "cap-std" -version = "3.0.0" +version = "3.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "266626ce180cf9709f317d0bf9754e3a5006359d87f4bf792f06c9c5f1b63c0f" +checksum = "c3dbd3e8e8d093d6ccb4b512264869e1281cdb032f7940bd50b2894f96f25609" dependencies = [ "cap-primitives", "io-extras", @@ -284,9 +302,9 @@ dependencies = [ [[package]] name = "cap-time-ext" -version = "3.0.0" +version = "3.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1353421ba83c19da60726e35db0a89abef984b3be183ff6f58c5b8084fcd0c5" +checksum = "bd736b20fc033f564a1995fb82fc349146de43aabba19c7368b4cb17d8f9ea53" dependencies = [ "ambient-authority", "cap-primitives", @@ -356,7 +374,7 @@ dependencies = [ "bitflags 1.3.2", "strsim", "textwrap", - "unicode-width", + "unicode-width 0.1.11", "vec_map", ] @@ -423,18 +441,18 @@ dependencies = [ [[package]] name = "cranelift-bforest" -version = "0.110.2" +version = "0.116.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "305d51c180ebdc46ef61bc60c54ae6512db3bc9a05842a1f1e762e45977019ab" +checksum = "e15d04a0ce86cb36ead88ad68cf693ffd6cda47052b9e0ac114bc47fd9cd23c4" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-bitset" -version = "0.110.2" +version = "0.116.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3247afacd9b13d620033f3190d9e49d1beefc1acb33d5604a249956c9c13709" +checksum = "7c6e3969a7ce267259ce244b7867c5d3bc9e65b0a87e81039588dfdeaede9f34" dependencies = [ "serde", "serde_derive", @@ -442,9 +460,9 @@ dependencies = [ [[package]] name = "cranelift-codegen" -version = "0.110.2" +version = "0.116.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd7ca95e831c18d1356da783765c344207cbdffea91e13e47fa9327dbb2e0719" +checksum = "2c22032c4cb42558371cf516bb47f26cdad1819d3475c133e93c49f50ebf304e" dependencies = [ "bumpalo", "cranelift-bforest", @@ -454,44 +472,45 @@ dependencies = [ "cranelift-control", "cranelift-entity", "cranelift-isle", - "gimli", + "gimli 0.31.1", "hashbrown 0.14.3", "log", "regalloc2", "rustc-hash", + "serde", "smallvec", "target-lexicon", ] [[package]] name = "cranelift-codegen-meta" -version = "0.110.2" +version = "0.116.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "450c105fa1e51bfba4e95a86e926504a867ad5639d63f31d43fe3b7ec1f1c9ef" +checksum = "c904bc71c61b27fc57827f4a1379f29de64fe95653b620a3db77d59655eee0b8" dependencies = [ "cranelift-codegen-shared", ] [[package]] name = "cranelift-codegen-shared" -version = "0.110.2" +version = "0.116.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5479117cd1266881479908d383086561cee37e49affbea9b1e6b594cc21cc220" +checksum = "40180f5497572f644ce88c255480981ae2ec1d7bb4d8e0c0136a13b87a2f2ceb" [[package]] name = "cranelift-control" -version = "0.110.2" +version = "0.116.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34378804f0abfdd22c068a741cfeed86938b92375b2a96fb0b42c878e0141bfb" +checksum = "26d132c6d0bd8a489563472afc171759da0707804a65ece7ceb15a8c6d7dd5ef" dependencies = [ "arbitrary", ] [[package]] name = "cranelift-entity" -version = "0.110.2" +version = "0.116.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a48cb0a194c9ba82fec35a1e492055388d89b2e3c03dee9dcf2488892be8004d" +checksum = "4b2d0d9618275474fbf679dd018ac6e009acbd6ae6850f6a67be33fb3b00b323" dependencies = [ "cranelift-bitset", "serde", @@ -500,9 +519,9 @@ dependencies = [ [[package]] name = "cranelift-frontend" -version = "0.110.2" +version = "0.116.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8327afc6c1c05f4be62fefce5b439fa83521c65363a322e86ea32c85e7ceaf64" +checksum = "4fac41e16729107393174b0c9e3730fb072866100e1e64e80a1a963b2e484d57" dependencies = [ "cranelift-codegen", "log", @@ -512,37 +531,21 @@ dependencies = [ [[package]] name = "cranelift-isle" -version = "0.110.2" +version = "0.116.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56b08621c00321efcfa3eee6a3179adc009e21ea8d24ca7adc3c326184bc3f48" +checksum = "1ca20d576e5070044d0a72a9effc2deacf4d6aa650403189d8ea50126483944d" [[package]] name = "cranelift-native" -version = "0.110.2" +version = "0.116.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d51180b147c8557c1196c77b098f04140c91962e135ea152cd2fcabf40cf365c" +checksum = "b8dee82f3f1f2c4cba9177f1cc5e350fe98764379bcd29340caa7b01f85076c7" dependencies = [ "cranelift-codegen", "libc", "target-lexicon", ] -[[package]] -name = "cranelift-wasm" -version = "0.110.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "019e3dccb7f15e0bc14f0ddc034ec608a66df8e05c9e1e16f75a7716f8461799" -dependencies = [ - "cranelift-codegen", - "cranelift-entity", - "cranelift-frontend", - "itertools 0.12.1", - "log", - "smallvec", - "wasmparser 0.212.0", - "wasmtime-types", -] - [[package]] name = "crc32fast" version = "1.4.0" @@ -640,13 +643,13 @@ dependencies = [ [[package]] name = "derive_arbitrary" -version = "1.3.2" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67e77553c4162a157adbf834ebae5b415acbecbeafc7a74b0e886657506a7611" +checksum = "30542c1ad912e0e3d22a1935c290e12e8a29d704a420177a31faad4a601a0800" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.98", ] [[package]] @@ -752,12 +755,12 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.8" +version = "0.3.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" +checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d" dependencies = [ "libc", - "windows-sys", + "windows-sys 0.59.0", ] [[package]] @@ -774,7 +777,7 @@ checksum = "7e5768da2206272c81ef0b5e951a41862938a6070da63bcea197899942d3b947" dependencies = [ "cfg-if", "rustix", - "windows-sys", + "windows-sys 0.52.0", ] [[package]] @@ -783,6 +786,12 @@ version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cdeb3aa5e95cf9aabc17f060cfa0ced7b83f042390760ca53bf09df9968acaa1" +[[package]] +name = "foldhash" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0d2fde1f7b3d48b8395d5f2de76c18a528bd6a9cdde438df747bfcba3e05d6f" + [[package]] name = "form_urlencoded" version = "1.2.1" @@ -800,7 +809,7 @@ checksum = "033b337d725b97690d86893f9de22b67b80dcc4e9ad815f348254c38119db8fb" dependencies = [ "io-lifetimes", "rustix", - "windows-sys", + "windows-sys 0.52.0", ] [[package]] @@ -912,6 +921,12 @@ name = "gimli" version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" + +[[package]] +name = "gimli" +version = "0.31.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" dependencies = [ "fallible-iterator", "indexmap", @@ -930,20 +945,20 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.13.2" +version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" +checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" dependencies = [ "ahash", ] [[package]] name = "hashbrown" -version = "0.14.3" +version = "0.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" +checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" dependencies = [ - "ahash", + "foldhash", "serde", ] @@ -958,9 +973,9 @@ dependencies = [ [[package]] name = "heck" -version = "0.4.1" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" [[package]] name = "hermit-abi" @@ -1024,23 +1039,23 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.2.6" +version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" +checksum = "8c9c992b02b5b4c94ea26e32fe5bccb7aa7d9f390ab5c1221ff895bc7ea8b652" dependencies = [ "equivalent", - "hashbrown 0.14.3", + "hashbrown 0.15.2", "serde", ] [[package]] name = "io-extras" -version = "0.18.2" +version = "0.18.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9f046b9af244f13b3bd939f55d16830ac3a201e8a9ba9661bfcb03e2be72b9b" +checksum = "2285ddfe3054097ef4b2fe909ef8c3bcd1ea52a8f0d274416caebeef39f04a65" dependencies = [ "io-lifetimes", - "windows-sys", + "windows-sys 0.59.0", ] [[package]] @@ -1063,7 +1078,7 @@ checksum = "f23ff5ef2b80d608d61efee834934d862cd92461afc0560dedf493e4c033738b" dependencies = [ "hermit-abi 0.3.9", "libc", - "windows-sys", + "windows-sys 0.52.0", ] [[package]] @@ -1086,9 +1101,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.11" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" +checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674" [[package]] name = "ittapi" @@ -1140,11 +1155,17 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" +[[package]] +name = "leb128fmt" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09edd9e8b54e49e587e4f6295a7d29c3ea94d469cb40ab8ca70b288248a81db2" + [[package]] name = "libc" -version = "0.2.153" +version = "0.2.169" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" +checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a" [[package]] name = "libfuzzer-sys" @@ -1175,9 +1196,9 @@ dependencies = [ [[package]] name = "linux-raw-sys" -version = "0.4.13" +version = "0.4.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" +checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab" [[package]] name = "log" @@ -1233,7 +1254,7 @@ dependencies = [ "hermit-abi 0.3.9", "libc", "wasi", - "windows-sys", + "windows-sys 0.52.0", ] [[package]] @@ -1256,12 +1277,12 @@ dependencies = [ [[package]] name = "object" -version = "0.36.3" +version = "0.36.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27b64972346851a39438c60b341ebc01bba47464ae329e55cf343eb93964efd9" +checksum = "62948e14d923ea95ea2c7c86c71013138b66525b86bdc08d2dcc262bdb497b87" dependencies = [ "crc32fast", - "hashbrown 0.14.3", + "hashbrown 0.15.2", "indexmap", "memchr", ] @@ -1382,9 +1403,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.79" +version = "1.0.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e" +checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99" dependencies = [ "unicode-ident", ] @@ -1398,6 +1419,18 @@ dependencies = [ "cc", ] +[[package]] +name = "pulley-interpreter" +version = "29.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62d95f8575df49a2708398182f49a888cf9dc30210fb1fd2df87c889edcee75d" +dependencies = [ + "cranelift-bitset", + "log", + "sptr", + "wasmtime-math", +] + [[package]] name = "quote" version = "1.0.35" @@ -1470,14 +1503,15 @@ dependencies = [ [[package]] name = "regalloc2" -version = "0.9.3" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad156d539c879b7a24a363a2016d77961786e71f48f2e2fc8302a92abd2429a6" +checksum = "145c1c267e14f20fb0f88aa76a1c5ffec42d592c1d28b3cd9148ae35916158d3" dependencies = [ - "hashbrown 0.13.2", + "allocator-api2", + "bumpalo", + "hashbrown 0.15.2", "log", "rustc-hash", - "slice-group-by", "smallvec", ] @@ -1532,15 +1566,15 @@ checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" [[package]] name = "rustc-hash" -version = "1.1.0" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" +checksum = "357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d" [[package]] name = "rustix" -version = "0.38.32" +version = "0.38.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65e04861e65f21776e67888bfbea442b3642beaa0138fdb1dd7a84a52dffdb89" +checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154" dependencies = [ "bitflags 2.5.0", "errno", @@ -1548,7 +1582,7 @@ dependencies = [ "libc", "linux-raw-sys", "once_cell", - "windows-sys", + "windows-sys 0.59.0", ] [[package]] @@ -1577,22 +1611,22 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.197" +version = "1.0.217" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" +checksum = "02fc4265df13d6fa1d00ecff087228cc0a2b5f3c0e87e258d8b94a156e984c70" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.197" +version = "1.0.217" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" +checksum = "5a9bf7cf98d04a2b28aead066b7496853d4779c9cc183c440dbac457641e19a0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.98", ] [[package]] @@ -1648,12 +1682,6 @@ dependencies = [ "dirs", ] -[[package]] -name = "slice-group-by" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "826167069c09b99d56f31e9ae5c99049e932a98c9dc2dac47645b08dbbf76ba7" - [[package]] name = "smallvec" version = "1.13.2" @@ -1670,7 +1698,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c" dependencies = [ "libc", - "windows-sys", + "windows-sys 0.52.0", ] [[package]] @@ -1728,9 +1756,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.58" +version = "2.0.98" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44cfb93f38070beee36b3fef7d4f5a16f27751d94b187b666a5cc5e9b0d30687" +checksum = "36147f1a48ae0ec2b5b3bc5b537d267457555a10dc06f3dbc8cb11ba3006d3b1" dependencies = [ "proc-macro2", "quote", @@ -1749,15 +1777,15 @@ dependencies = [ "fd-lock", "io-lifetimes", "rustix", - "windows-sys", + "windows-sys 0.52.0", "winx", ] [[package]] name = "target-lexicon" -version = "0.12.14" +version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1fc403891a21bcfb7c37834ba66a547a8f402146eba7265b5a6d88059c9ff2f" +checksum = "e502f78cdbb8ba4718f566c418c52bc729126ffd16baee5baa718cf25dd5a69a" [[package]] name = "termcolor" @@ -1774,7 +1802,7 @@ version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" dependencies = [ - "unicode-width", + "unicode-width 0.1.11", ] [[package]] @@ -1794,7 +1822,7 @@ checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.98", ] [[package]] @@ -1834,7 +1862,7 @@ dependencies = [ "mio", "pin-project-lite", "socket2", - "windows-sys", + "windows-sys 0.52.0", ] [[package]] @@ -1890,7 +1918,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.98", ] [[package]] @@ -1902,6 +1930,17 @@ dependencies = [ "once_cell", ] +[[package]] +name = "trait-variant" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70977707304198400eb4835a78f6a9f928bf41bba420deb8fdb175cd965d77a7" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.98", +] + [[package]] name = "typenum" version = "1.17.0" @@ -1950,6 +1989,12 @@ version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" +[[package]] +name = "unicode-width" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fc81956842c57dac11422a97c3b8195a1ff727f06e85c84ed2e8aa277c9a0fd" + [[package]] name = "unicode-xid" version = "0.2.4" @@ -2034,7 +2079,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.98", "wasm-bindgen-shared", ] @@ -2056,7 +2101,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.98", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -2078,20 +2123,22 @@ dependencies = [ [[package]] name = "wasm-encoder" -version = "0.212.0" +version = "0.221.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "501940df4418b8929eb6d52f1aade1fdd15a5b86c92453cb696e3c906bd3fc33" +checksum = "dc8444fe4920de80a4fe5ab564fff2ae58b6b73166b89751f8c6c93509da32e5" dependencies = [ "leb128", + "wasmparser 0.221.3", ] [[package]] name = "wasm-encoder" -version = "0.215.0" +version = "0.225.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb56df3e06b8e6b77e37d2969a50ba51281029a9aeb3855e76b7f49b6418847" +checksum = "6f7eac0445cac73bcf09e6a97f83248d64356dccf9f2b100199769b6b42464e5" dependencies = [ - "leb128", + "leb128fmt", + "wasmparser 0.225.0", ] [[package]] @@ -2121,18 +2168,28 @@ dependencies = [ [[package]] name = "wasmparser" -version = "0.212.0" +version = "0.221.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d28bc49ba1e5c5b61ffa7a2eace10820443c4b7d1c0b144109261d14570fdf8" +checksum = "d06bfa36ab3ac2be0dee563380147a5b81ba10dd8885d7fbbc9eb574be67d185" dependencies = [ - "ahash", "bitflags 2.5.0", - "hashbrown 0.14.3", + "hashbrown 0.15.2", "indexmap", "semver", "serde", ] +[[package]] +name = "wasmparser" +version = "0.225.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36e5456165f81e64cb9908a0fe9b9d852c2c74582aa3fe2be3c2da57f937d3ae" +dependencies = [ + "bitflags 2.5.0", + "indexmap", + "semver", +] + [[package]] name = "wasmprinter" version = "0.202.0" @@ -2145,22 +2202,22 @@ dependencies = [ [[package]] name = "wasmprinter" -version = "0.212.0" +version = "0.221.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfac65326cc561112af88c3028f6dfdb140acff67ede33a8e86be2dc6b8956f7" +checksum = "7343c42a97f2926c7819ff81b64012092ae954c5d83ddd30c9fcdefd97d0b283" dependencies = [ "anyhow", "termcolor", - "wasmparser 0.212.0", + "wasmparser 0.221.3", ] [[package]] name = "wasmtime" -version = "23.0.2" +version = "29.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07232e0b473af36112da7348f51e73fa8b11047a6cb546096da3812930b7c93a" +checksum = "11976a250672556d1c4c04c6d5d7656ac9192ac9edc42a4587d6c21460010e69" dependencies = [ - "addr2line", + "addr2line 0.24.2", "anyhow", "async-trait", "bitflags 2.5.0", @@ -2169,20 +2226,20 @@ dependencies = [ "cfg-if", "encoding_rs", "fxprof-processed-profile", - "gimli", + "gimli 0.31.1", "hashbrown 0.14.3", "indexmap", "ittapi", "libc", - "libm", "log", "mach2", "memfd", - "object 0.36.3", + "object 0.36.7", "once_cell", "paste", "postcard", "psm", + "pulley-interpreter", "rayon", "rustix", "semver", @@ -2192,8 +2249,9 @@ dependencies = [ "smallvec", "sptr", "target-lexicon", - "wasm-encoder 0.212.0", - "wasmparser 0.212.0", + "trait-variant", + "wasm-encoder 0.221.3", + "wasmparser 0.221.3", "wasmtime-asm-macros", "wasmtime-cache", "wasmtime-component-macro", @@ -2203,27 +2261,28 @@ dependencies = [ "wasmtime-fiber", "wasmtime-jit-debug", "wasmtime-jit-icache-coherence", + "wasmtime-math", "wasmtime-slab", "wasmtime-versioned-export-macros", "wasmtime-winch", "wat", - "windows-sys", + "windows-sys 0.59.0", ] [[package]] name = "wasmtime-asm-macros" -version = "23.0.2" +version = "29.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5a9c42562d879c749288d9a26acc0d95d2ca069e30c2ec2efce84461c4d62b3" +checksum = "1f178b0d125201fbe9f75beaf849bd3e511891f9e45ba216a5b620802ccf64f2" dependencies = [ "cfg-if", ] [[package]] name = "wasmtime-cache" -version = "23.0.2" +version = "29.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38d5d5aac98c8ae87cf5244495da7722e3fa022aa6f3f4fcd5e3d6e5699ce422" +checksum = "8b1161c8f62880deea07358bc40cceddc019f1c81d46007bc390710b2fe24ffc" dependencies = [ "anyhow", "base64", @@ -2235,20 +2294,20 @@ dependencies = [ "serde_derive", "sha2", "toml", - "windows-sys", + "windows-sys 0.59.0", "zstd", ] [[package]] name = "wasmtime-component-macro" -version = "23.0.2" +version = "29.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0c3f57c4bc96f9b4a6ff4d6cb6e837913eff32e98d09e2b6d79b5c4647b415b" +checksum = "d74de6592ed945d0a602f71243982a304d5d02f1e501b638addf57f42d57dfaf" dependencies = [ "anyhow", "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.98", "wasmtime-component-util", "wasmtime-wit-bindgen", "wit-parser", @@ -2256,15 +2315,15 @@ dependencies = [ [[package]] name = "wasmtime-component-util" -version = "23.0.2" +version = "29.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1da707969bc31a565da9b32d087eb2370c95c6f2087c5539a15f2e3b27e77203" +checksum = "707dc7b3c112ab5a366b30cfe2fb5b2f8e6a0f682f16df96a5ec582bfe6f056e" [[package]] name = "wasmtime-cranelift" -version = "23.0.2" +version = "29.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62cb6135ec46994299be711b78b03acaa9480de3715f827d450f0c947a84977c" +checksum = "366be722674d4bf153290fbcbc4d7d16895cc82fb3e869f8d550ff768f9e9e87" dependencies = [ "anyhow", "cfg-if", @@ -2273,49 +2332,50 @@ dependencies = [ "cranelift-entity", "cranelift-frontend", "cranelift-native", - "cranelift-wasm", - "gimli", + "gimli 0.31.1", + "itertools 0.12.1", "log", - "object 0.36.3", + "object 0.36.7", + "smallvec", "target-lexicon", "thiserror", - "wasmparser 0.212.0", + "wasmparser 0.221.3", "wasmtime-environ", "wasmtime-versioned-export-macros", ] [[package]] name = "wasmtime-environ" -version = "23.0.2" +version = "29.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9bcaa3b42a0718e9123da7fb75e8e13fc95df7db2a7e32e2f2f4f0d3333b7d6f" +checksum = "cdadc1af7097347aa276a4f008929810f726b5b46946971c660b6d421e9994ad" dependencies = [ "anyhow", "cpp_demangle", "cranelift-bitset", "cranelift-entity", - "gimli", + "gimli 0.31.1", "indexmap", "log", - "object 0.36.3", + "object 0.36.7", "postcard", "rustc-demangle", "semver", "serde", "serde_derive", + "smallvec", "target-lexicon", - "wasm-encoder 0.212.0", - "wasmparser 0.212.0", - "wasmprinter 0.212.0", + "wasm-encoder 0.221.3", + "wasmparser 0.221.3", + "wasmprinter 0.221.3", "wasmtime-component-util", - "wasmtime-types", ] [[package]] name = "wasmtime-fiber" -version = "23.0.2" +version = "29.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1c805515f4bc157f70f998038951009d21a19c1ef8c5fbb374a11b1d56672" +checksum = "ccba90d4119f081bca91190485650730a617be1fff5228f8c4757ce133d21117" dependencies = [ "anyhow", "cc", @@ -2323,69 +2383,63 @@ dependencies = [ "rustix", "wasmtime-asm-macros", "wasmtime-versioned-export-macros", - "windows-sys", + "windows-sys 0.59.0", ] [[package]] name = "wasmtime-jit-debug" -version = "23.0.2" +version = "29.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "118e141e52f3898a531a612985bd09a5e05a1d646cad2f30a3020b675c21cd49" +checksum = "3e7b61488a5ee00c35c8c22de707c36c0aecacf419a3be803a6a2ba5e860f56a" dependencies = [ - "object 0.36.3", - "once_cell", + "object 0.36.7", "rustix", "wasmtime-versioned-export-macros", ] [[package]] name = "wasmtime-jit-icache-coherence" -version = "23.0.2" +version = "29.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2cfee42dac5148fc2664ab1f5cb8d7fa77a28d1a2cf1d9483abc2c3d751a58b9" +checksum = "ec5e8552e01692e6c2e5293171704fed8abdec79d1a6995a0870ab190e5747d1" dependencies = [ "anyhow", "cfg-if", "libc", - "windows-sys", + "windows-sys 0.59.0", ] [[package]] -name = "wasmtime-slab" -version = "23.0.2" +name = "wasmtime-math" +version = "29.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42eb8f6515708ec67974998c3e644101db4186308985f5ef7c2ef324ff33c948" +checksum = "29210ec2aa25e00f4d54605cedaf080f39ec01a872c5bd520ad04c67af1dde17" +dependencies = [ + "libm", +] [[package]] -name = "wasmtime-types" -version = "23.0.2" +name = "wasmtime-slab" +version = "29.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "046873fb8fb3e9652f3fd76fe99c8c8129007695c3d73b2e307fdae40f6e324c" -dependencies = [ - "anyhow", - "cranelift-entity", - "serde", - "serde_derive", - "smallvec", - "wasmparser 0.212.0", -] +checksum = "fcb5821a96fa04ac14bc7b158bb3d5cd7729a053db5a74dad396cd513a5e5ccf" [[package]] name = "wasmtime-versioned-export-macros" -version = "23.0.2" +version = "29.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99c02af2e9dbeb427304d1a08787d70ed0dbfec1af2236616f84c9f1f03e7969" +checksum = "86ff86db216dc0240462de40c8290887a613dddf9685508eb39479037ba97b5b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.98", ] [[package]] name = "wasmtime-wasi" -version = "23.0.2" +version = "29.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2a1349f254d0b8f2ec8f996d0982f040abf22cd6ab19e3cf67afd033c552208" +checksum = "8d1be69bfcab1bdac74daa7a1f9695ab992b9c8e21b9b061e7d66434097e0ca4" dependencies = [ "anyhow", "async-trait", @@ -2400,30 +2454,30 @@ dependencies = [ "futures", "io-extras", "io-lifetimes", - "once_cell", "rustix", "system-interface", "thiserror", "tokio", "tracing", + "trait-variant", "url", "wasmtime", "wiggle", - "windows-sys", + "windows-sys 0.59.0", ] [[package]] name = "wasmtime-winch" -version = "23.0.2" +version = "29.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2ceddc47a49af10908a288fdfdc296ab3932062cab62a785e3705bbb3709c59" +checksum = "fdbabfb8f20502d5e1d81092b9ead3682ae59988487aafcd7567387b7a43cf8f" dependencies = [ "anyhow", "cranelift-codegen", - "gimli", - "object 0.36.3", + "gimli 0.31.1", + "object 0.36.7", "target-lexicon", - "wasmparser 0.212.0", + "wasmparser 0.221.3", "wasmtime-cranelift", "wasmtime-environ", "winch-codegen", @@ -2431,12 +2485,12 @@ dependencies = [ [[package]] name = "wasmtime-wit-bindgen" -version = "23.0.2" +version = "29.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75f528f8b8a2376a3dacaf497d960216dd466d324425361e1e00e26de0a7705c" +checksum = "8358319c2dd1e4db79e3c1c5d3a5af84956615343f9f89f4e4996a36816e06e6" dependencies = [ "anyhow", - "heck 0.4.1", + "heck 0.5.0", "indexmap", "wit-parser", ] @@ -2452,24 +2506,24 @@ dependencies = [ [[package]] name = "wast" -version = "215.0.0" +version = "225.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ff1d00d893593249e60720be04a7c1f42f1c4dc3806a2869f4e66ab61eb54cb" +checksum = "c61496027ff707f9fa9e0b22c34ec163eb7adb1070df565e32a9180a76e4300b" dependencies = [ "bumpalo", - "leb128", + "leb128fmt", "memchr", - "unicode-width", - "wasm-encoder 0.215.0", + "unicode-width 0.2.0", + "wasm-encoder 0.225.0", ] [[package]] name = "wat" -version = "1.215.0" +version = "1.225.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "670bf4d9c8cf76ae242d70ded47c546525b6dafaa6871f9bcb065344bf2b4e3d" +checksum = "89e72a33942234fd0794bcdac30e43b448de3187512414267678e511c6755f11" dependencies = [ - "wast 215.0.0", + "wast 225.0.0", ] [[package]] @@ -2484,9 +2538,9 @@ dependencies = [ [[package]] name = "wiggle" -version = "23.0.2" +version = "29.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af4a61a764e5c4f0cb8c1796859d266e75828c244089e77c81c6158dd8c4fda4" +checksum = "4b9af35bc9629c52c261465320a9a07959164928b4241980ba1cf923b9e6751d" dependencies = [ "anyhow", "async-trait", @@ -2499,28 +2553,28 @@ dependencies = [ [[package]] name = "wiggle-generate" -version = "23.0.2" +version = "29.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2d45f4c50cfcbc222fb5221142fa65aa834d0a54b77b5760be0ea0a1ccad52d" +checksum = "2cf267dd05673912c8138f4b54acabe6bd53407d9d1536f0fadb6520dd16e101" dependencies = [ "anyhow", - "heck 0.4.1", + "heck 0.5.0", "proc-macro2", "quote", "shellexpand", - "syn 2.0.58", + "syn 2.0.98", "witx", ] [[package]] name = "wiggle-macro" -version = "23.0.2" +version = "29.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12e0fbccad12e5b406effb8676eb3713fdbe366975fb65d56f960ace6da118e4" +checksum = "08c5c473d4198e6c2d377f3809f713ff0c110cab88a0805ae099a82119ee250c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.98", "wiggle-generate", ] @@ -2557,17 +2611,18 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "winch-codegen" -version = "0.21.2" +version = "29.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a41b67a37ea74e83c38ef495cc213aba73385236b1deee883dc869e835003b9" +checksum = "2f849ef2c5f46cb0a20af4b4487aaa239846e52e2c03f13fa3c784684552859c" dependencies = [ "anyhow", "cranelift-codegen", - "gimli", + "gimli 0.31.1", "regalloc2", "smallvec", "target-lexicon", - "wasmparser 0.212.0", + "thiserror", + "wasmparser 0.221.3", "wasmtime-cranelift", "wasmtime-environ", ] @@ -2590,15 +2645,25 @@ dependencies = [ "windows-targets", ] +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets", +] + [[package]] name = "windows-targets" -version = "0.52.4" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7dd37b7e5ab9018759f893a1952c9420d060016fc19a472b4bb20d1bdd694d1b" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ "windows_aarch64_gnullvm", "windows_aarch64_msvc", "windows_i686_gnu", + "windows_i686_gnullvm", "windows_i686_msvc", "windows_x86_64_gnu", "windows_x86_64_gnullvm", @@ -2607,45 +2672,51 @@ dependencies = [ [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.4" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bcf46cf4c365c6f2d1cc93ce535f2c8b244591df96ceee75d8e83deb70a9cac9" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" [[package]] name = "windows_aarch64_msvc" -version = "0.52.4" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da9f259dd3bcf6990b55bffd094c4f7235817ba4ceebde8e6d11cd0c5633b675" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" [[package]] name = "windows_i686_gnu" -version = "0.52.4" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b474d8268f99e0995f25b9f095bc7434632601028cf86590aea5c8a5cb7801d3" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" [[package]] name = "windows_i686_msvc" -version = "0.52.4" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1515e9a29e5bed743cb4415a9ecf5dfca648ce85ee42e15873c3cd8610ff8e02" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" [[package]] name = "windows_x86_64_gnu" -version = "0.52.4" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5eee091590e89cc02ad514ffe3ead9eb6b660aedca2183455434b93546371a03" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.4" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77ca79f2451b49fa9e2af39f0747fe999fcda4f5e241b2898624dca97a1f2177" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] name = "windows_x86_64_msvc" -version = "0.52.4" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32b752e52a2da0ddfbdbcc6fceadfeede4c939ed16d13e648833a61dfb611ed8" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" @@ -2663,14 +2734,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f9643b83820c0cd246ecabe5fa454dd04ba4fa67996369466d0747472d337346" dependencies = [ "bitflags 2.5.0", - "windows-sys", + "windows-sys 0.52.0", ] [[package]] name = "wit-parser" -version = "0.212.0" +version = "0.221.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ceeb0424aa8679f3fcf2d6e3cfa381f3d6fa6179976a2c05a6249dd2bb426716" +checksum = "896112579ed56b4a538b07a3d16e562d101ff6265c46b515ce0c701eef16b2ac" dependencies = [ "anyhow", "id-arena", @@ -2681,7 +2752,7 @@ dependencies = [ "serde_derive", "serde_json", "unicode-xid", - "wasmparser 0.212.0", + "wasmparser 0.221.3", ] [[package]] @@ -2746,7 +2817,7 @@ checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.98", ] [[package]] diff --git a/crates/wizer/Cargo.toml b/crates/wizer/Cargo.toml index 9f5bc58de28d..1add9b285e7b 100644 --- a/crates/wizer/Cargo.toml +++ b/crates/wizer/Cargo.toml @@ -46,8 +46,8 @@ optional = true [workspace.dependencies] wasmprinter = "0.202.0" -wasmtime = "23" -wasmtime-wasi = "23" +wasmtime = "29" +wasmtime-wasi = "29" [dev-dependencies] criterion = "0.5.1" From 5f4583b8a7d1e3d73de83ae0a5db5676383679ce Mon Sep 17 00:00:00 2001 From: Gentle Date: Wed, 26 Feb 2025 20:57:16 +0100 Subject: [PATCH 205/212] add option for reference-types (#124) * add option for reference_types only enables the wasmtime feature, which allows initializing Modules that were compiled with newer llvm versions but don't actually use reference_types Disabled by default * Update src/lib.rs Co-authored-by: Nick Fitzgerald * reject reference-types related instructions * add setter for wasm_reference_types * bail instead of unreachable * tests for reference-types still rejecting tyble modifying instructions * better error messages * test indirect call with reference_types enabled * same docstring for library and cli * (hopefully) actually use the new call_indirect --------- Co-authored-by: Gentle Co-authored-by: Nick Fitzgerald --- crates/wizer/src/lib.rs | 64 +++++++++++++++++++++++-- crates/wizer/tests/tests.rs | 94 +++++++++++++++++++++++++++++++++++++ 2 files changed, 155 insertions(+), 3 deletions(-) diff --git a/crates/wizer/src/lib.rs b/crates/wizer/src/lib.rs index f52b882fa117..9194ce394cd7 100644 --- a/crates/wizer/src/lib.rs +++ b/crates/wizer/src/lib.rs @@ -42,6 +42,7 @@ const DEFAULT_WASM_MULTI_VALUE: bool = true; const DEFAULT_WASM_MULTI_MEMORY: bool = true; const DEFAULT_WASM_BULK_MEMORY: bool = false; const DEFAULT_WASM_SIMD: bool = true; +const DEFAULT_WASM_REFERENCE_TYPES: bool = false; /// The type of data that is stored in the `wasmtime::Store` during /// initialization. @@ -249,6 +250,16 @@ pub struct Wizer { /// Enabled by default. #[cfg_attr(feature = "structopt", structopt(long, value_name = "true|false"))] wasm_simd: Option, + + /// Enable or disable the Wasm reference-types proposal. + /// + /// Currently does not implement snapshotting or the use of references, + /// but enables initializing Wasm modules that use encodings introduced + /// in the reference-types proposal. + /// + /// Disabled by default. + #[cfg_attr(feature = "structopt", structopt(long, value_name = "true|false"))] + wasm_reference_types: Option, } impl std::fmt::Debug for Wizer { @@ -269,6 +280,7 @@ impl std::fmt::Debug for Wizer { wasm_multi_value, wasm_bulk_memory, wasm_simd, + wasm_reference_types, } = self; f.debug_struct("Wizer") .field("init_func", &init_func) @@ -286,6 +298,7 @@ impl std::fmt::Debug for Wizer { .field("wasm_multi_value", &wasm_multi_value) .field("wasm_bulk_memory", &wasm_bulk_memory) .field("wasm_simd", &wasm_simd) + .field("wasm_reference_types", &wasm_reference_types) .finish() } } @@ -350,6 +363,7 @@ impl Wizer { wasm_multi_value: None, wasm_bulk_memory: None, wasm_simd: None, + wasm_reference_types: None, } } @@ -556,6 +570,18 @@ impl Wizer { self } + /// Enable or disable the Wasm reference-types proposal. + /// + /// Currently does not implement snapshotting or the use of references, + /// but enables initializing Wasm modules that use encodings introduced + /// in the reference-types proposal. + /// + /// Defaults to `false`. + pub fn wasm_reference_types(&mut self, enable: bool) -> &mut Self { + self.wasm_reference_types = Some(enable); + self + } + /// Initialize the given Wasm, snapshot it, and return the serialized /// snapshot as a new, pre-initialized Wasm module. pub fn run(&self, wasm: &[u8]) -> anyhow::Result> { @@ -632,8 +658,14 @@ impl Wizer { config.wasm_simd(self.wasm_simd.unwrap_or(DEFAULT_WASM_SIMD)); + // Note that reference_types are not actually supported, + // but many compilers now enable them by default + config.wasm_reference_types( + self.wasm_reference_types + .unwrap_or(DEFAULT_WASM_REFERENCE_TYPES), + ); + // Proposals that we should add support for. - config.wasm_reference_types(false); config.wasm_threads(false); Ok(config) @@ -654,7 +686,9 @@ impl Wizer { multi_value: self.wasm_multi_value.unwrap_or(DEFAULT_WASM_MULTI_VALUE), // Proposals that we should add support for. - reference_types: false, + reference_types: self + .wasm_reference_types + .unwrap_or(DEFAULT_WASM_REFERENCE_TYPES), simd: self.wasm_simd.unwrap_or(DEFAULT_WASM_SIMD), threads: false, tail_call: false, @@ -730,7 +764,31 @@ impl Wizer { anyhow::bail!("unsupported `data.drop` instruction") } wasmparser::Operator::TableSet { .. } => { - unreachable!("part of reference types") + anyhow::bail!("unsupported `table.set` instruction") + } + wasmparser::Operator::TableGet { .. } => { + anyhow::bail!("unsupported `table.get` instruction") + } + wasmparser::Operator::RefNull { .. } => { + anyhow::bail!("unsupported `ref.null` instruction") + } + wasmparser::Operator::RefIsNull => { + anyhow::bail!("unsupported `ref.is_null` instruction") + } + wasmparser::Operator::TypedSelect { .. } => { + anyhow::bail!("unsupported typed `select` instruction") + } + wasmparser::Operator::RefFunc { .. } => { + anyhow::bail!("unsupported `ref.func` instruction") + } + wasmparser::Operator::TableSize { .. } => { + anyhow::bail!("unsupported `table.size` instruction") + } + wasmparser::Operator::TableGrow { .. } => { + anyhow::bail!("unsupported `table.grow` instruction") + } + wasmparser::Operator::TableFill { .. } => { + anyhow::bail!("unsupported `table.fill` instruction") } _ => continue, } diff --git a/crates/wizer/tests/tests.rs b/crates/wizer/tests/tests.rs index 66c2f3fdd980..e7d18733d474 100644 --- a/crates/wizer/tests/tests.rs +++ b/crates/wizer/tests/tests.rs @@ -269,6 +269,100 @@ fn reject_table_get_set() -> Result<()> { Ok(()) } +#[test] +fn reject_table_get_set_with_reference_types_enabled() -> Result<()> { + let wat = r#" + (module + (table 3 funcref) + + (func $f (result i32) (i32.const 0)) + (func $g (result i32) (i32.const 0)) + (func $h (result i32) (i32.const 0)) + + (func (export "main") + i32.const 0 + i32.const 1 + table.get + table.set) + + (elem (i32.const 0) $f $g $h) + )"#; + + let _ = env_logger::try_init(); + let mut wizer = Wizer::new(); + wizer.wasm_reference_types(true); + + let wasm = wat_to_wasm(wat)?; + let result = wizen_and_run_wasm(&[], 42, &wasm, wizer); + + assert!(result.is_err()); + + let err = result.unwrap_err(); + assert!(err + .to_string() + .contains("unsupported `table.get` instruction"),); + + Ok(()) +} + +#[test] +fn reject_table_grow_with_reference_types_enabled() -> anyhow::Result<()> { + let wat = r#" + (module + (elem declare func $f) + (func $f) + (table 0 funcref) + (func (export "_initialize") (result i32) + ref.func $f + i32.const 1 + table.grow + ) + )"#; + + let _ = env_logger::try_init(); + let mut wizer = Wizer::new(); + wizer.wasm_reference_types(true); + + let wasm = wat_to_wasm(wat)?; + let result = wizen_and_run_wasm(&[], 42, &wasm, wizer); + + assert!(result.is_err()); + + let err = result.unwrap_err(); + assert!(err + .to_string() + .contains("unsupported `ref.func` instruction")); + + Ok(()) +} + +#[test] +fn indirect_call_with_reference_types() -> anyhow::Result<()> { + let wat = r#" + (module + (type $sig (func (result i32))) + (table 0 funcref) + (table $table1 1 funcref) + (elem (table $table1) (i32.const 0) func $f) + (func $f (type $sig) + i32.const 42 + ) + (func (export "wizer.initialize")) + (func (export "run") (result i32) + i32.const 0 + call_indirect $table1 (type $sig) + ) + )"#; + + let _ = env_logger::try_init(); + let mut wizer = Wizer::new(); + wizer.wasm_reference_types(true); + wizer.wasm_bulk_memory(true); + + let wasm = wat_to_wasm(wat)?; + wizen_and_run_wasm(&[], 42, &wasm, wizer) +} + #[test] fn reject_table_init() -> Result<()> { let result = run_wat( From fc78a019e968a4db3e5e1b23b0f55f9596bdaeaf Mon Sep 17 00:00:00 2001 From: Gentle Date: Thu, 27 Feb 2025 20:47:23 +0100 Subject: [PATCH 206/212] enable reference types and bulk memory support by default (#129) * enable reference types and bulk memory support by default * update tests --------- Co-authored-by: Gentle --- crates/wizer/src/lib.rs | 12 ++++++------ crates/wizer/tests/tests.rs | 32 ++++++++++++++++---------------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/crates/wizer/src/lib.rs b/crates/wizer/src/lib.rs index 9194ce394cd7..5a0a31e7fc81 100644 --- a/crates/wizer/src/lib.rs +++ b/crates/wizer/src/lib.rs @@ -40,9 +40,9 @@ const DEFAULT_INHERIT_ENV: bool = false; const DEFAULT_KEEP_INIT_FUNC: bool = false; const DEFAULT_WASM_MULTI_VALUE: bool = true; const DEFAULT_WASM_MULTI_MEMORY: bool = true; -const DEFAULT_WASM_BULK_MEMORY: bool = false; +const DEFAULT_WASM_BULK_MEMORY: bool = true; const DEFAULT_WASM_SIMD: bool = true; -const DEFAULT_WASM_REFERENCE_TYPES: bool = false; +const DEFAULT_WASM_REFERENCE_TYPES: bool = true; /// The type of data that is stored in the `wasmtime::Store` during /// initialization. @@ -241,7 +241,7 @@ pub struct Wizer { /// are currently supported. Modules which use other instructions, such as /// `table.copy` will be rejected. /// - /// Disabled by default. + /// Enabled by default. #[cfg_attr(feature = "structopt", structopt(long, value_name = "true|false"))] wasm_bulk_memory: Option, @@ -257,7 +257,7 @@ pub struct Wizer { /// but enables initializing Wasm modules that use encodings introduced /// in the reference-types proposal. /// - /// Disabled by default. + /// Enabled by default. #[cfg_attr(feature = "structopt", structopt(long, value_name = "true|false"))] wasm_reference_types: Option, } @@ -556,7 +556,7 @@ impl Wizer { /// operations are currently supported. Modules which use other /// instructions, such as `table.copy` will be rejected. /// - /// Defaults to `false`. + /// Defaults to `true`. pub fn wasm_bulk_memory(&mut self, enable: bool) -> &mut Self { self.wasm_bulk_memory = Some(enable); self @@ -576,7 +576,7 @@ impl Wizer { /// but enables initializing Wasm modules that use encodings introduced /// in the reference-types proposal. /// - /// Defaults to `false`. + /// Defaults to `true`. pub fn wasm_reference_types(&mut self, enable: bool) -> &mut Self { self.wasm_reference_types = Some(enable); self diff --git a/crates/wizer/tests/tests.rs b/crates/wizer/tests/tests.rs index e7d18733d474..4005f414a1c5 100644 --- a/crates/wizer/tests/tests.rs +++ b/crates/wizer/tests/tests.rs @@ -238,10 +238,7 @@ fn reject_table_copy() -> Result<()> { #[test] fn reject_table_get_set() -> Result<()> { - let result = run_wat( - &[], - 42, - r#" + let wat = r#" (module (table 3 funcref) @@ -257,8 +254,15 @@ fn reject_table_get_set() -> Result<()> { (elem (i32.const 0) $f $g $h) ) -"#, - ); +"#; + + let _ = env_logger::try_init(); + let mut wizer = Wizer::new(); + wizer.wasm_reference_types(false); + + let wasm = wat_to_wasm(wat)?; + let result = wizen_and_run_wasm(&[], 42, &wasm, wizer); + assert!(result.is_err()); let err = result.unwrap_err(); @@ -271,7 +275,10 @@ fn reject_table_get_set() -> Result<()> { #[test] fn reject_table_get_set_with_reference_types_enabled() -> Result<()> { - let wat = r#" + let result = run_wat( + &[], + 42, + r#" (module (table 3 funcref) @@ -286,15 +293,8 @@ fn reject_table_get_set_with_reference_types_enabled() -> Result<()> { table.set) (elem (i32.const 0) $f $g $h) - )"#; - - let _ = env_logger::try_init(); - let mut wizer = Wizer::new(); - wizer.wasm_reference_types(true); - - let wasm = wat_to_wasm(wat)?; - let result = wizen_and_run_wasm(&[], 42, &wasm, wizer); - + )"#, + ); assert!(result.is_err()); let err = result.unwrap_err(); From 92f77df37da59acd3df7cb43d4a2b5ed667745c3 Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Fri, 28 Feb 2025 09:17:06 -0800 Subject: [PATCH 207/212] Bump to version 8 --- crates/wizer/Cargo.lock | 4 ++-- crates/wizer/Cargo.toml | 2 +- crates/wizer/README.md | 6 ++++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/crates/wizer/Cargo.lock b/crates/wizer/Cargo.lock index 35f29d5ac5f5..b9f7b180d25d 100644 --- a/crates/wizer/Cargo.lock +++ b/crates/wizer/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "addr2line" @@ -2769,7 +2769,7 @@ dependencies = [ [[package]] name = "wizer" -version = "7.0.5" +version = "8.0.0" dependencies = [ "anyhow", "cap-std", diff --git a/crates/wizer/Cargo.toml b/crates/wizer/Cargo.toml index 1add9b285e7b..4aa3cb55ef63 100644 --- a/crates/wizer/Cargo.toml +++ b/crates/wizer/Cargo.toml @@ -10,7 +10,7 @@ license = "Apache-2.0 WITH LLVM-exception" name = "wizer" readme = "./README.md" repository = "https://github.com/bytecodealliance/wizer" -version = "7.0.5" +version = "8.0.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/crates/wizer/README.md b/crates/wizer/README.md index b229f59ac0f6..d2ba90c845f3 100644 --- a/crates/wizer/README.md +++ b/crates/wizer/README.md @@ -66,7 +66,9 @@ which `wasm-opt` can remove. ## Install -Download the a pre-built release from the [releases](https://github.com/bytecodealliance/wizer/releases) page. Unarchive the binary and place it in your $PATH. +Download the a pre-built release from the +[releases](https://github.com/bytecodealliance/wizer/releases) page. Unarchive +the binary and place it in your `$PATH`. Alternatively you can install via `cargo`: @@ -122,7 +124,7 @@ Add a dependency in your `Cargo.toml`: # Cargo.toml [dependencies] -wizer = "1" +wizer = "8" ``` And then use the `wizer::Wizer` builder to configure and run Wizer: From 2f76c8535d7c86ea72a1fd81627c0e8bad5324cf Mon Sep 17 00:00:00 2001 From: Cheng Shao Date: Thu, 10 Apr 2025 19:20:43 +0200 Subject: [PATCH 208/212] chore: bump deps (#132) --- crates/wizer/Cargo.lock | 355 ++++++++++-------- crates/wizer/Cargo.toml | 22 +- crates/wizer/fuzz/fuzz_targets/same_result.rs | 5 +- crates/wizer/src/dummy.rs | 3 + crates/wizer/src/info/types_interner.rs | 9 +- crates/wizer/src/lib.rs | 83 ++-- crates/wizer/src/parse.rs | 13 +- crates/wizer/src/rewrite.rs | 2 +- crates/wizer/src/translate.rs | 2 + crates/wizer/tests/tests.rs | 22 +- 10 files changed, 274 insertions(+), 242 deletions(-) diff --git a/crates/wizer/Cargo.lock b/crates/wizer/Cargo.lock index b9f7b180d25d..f1bc61c4b779 100644 --- a/crates/wizer/Cargo.lock +++ b/crates/wizer/Cargo.lock @@ -26,18 +26,6 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" -[[package]] -name = "ahash" -version = "0.8.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" -dependencies = [ - "cfg-if", - "once_cell", - "version_check", - "zerocopy", -] - [[package]] name = "aho-corasick" version = "1.1.3" @@ -133,9 +121,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.95" +version = "1.0.97" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34ac096ce696dc2fcabef30516bb13c0a68a11d30131d3df6f04711467681b04" +checksum = "dcfed56ad506cb2c684a14971b8861fdc3baaaae314b9e5f9bb532cbe3ba7a4f" [[package]] name = "arbitrary" @@ -263,9 +251,9 @@ dependencies = [ [[package]] name = "cap-primitives" -version = "3.4.2" +version = "3.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fc15faeed2223d8b8e8cc1857f5861935a06d06713c4ac106b722ae9ce3c369" +checksum = "50ad0183a9659850877cefe8f5b87d564b2dd1fe78b18945813687f29c0a6878" dependencies = [ "ambient-authority", "fs-set-times", @@ -290,9 +278,9 @@ dependencies = [ [[package]] name = "cap-std" -version = "3.4.2" +version = "3.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3dbd3e8e8d093d6ccb4b512264869e1281cdb032f7940bd50b2894f96f25609" +checksum = "1c41814365b796ed12688026cb90a1e03236a84ccf009628f9c43c8aa3af250a" dependencies = [ "cap-primitives", "io-extras", @@ -439,20 +427,35 @@ dependencies = [ "libc", ] +[[package]] +name = "cranelift-assembler-x64" +version = "0.118.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e4b56ebe316895d3fa37775d0a87b0c889cc933f5c8b253dbcc7c7bcb7fe7e4" +dependencies = [ + "cranelift-assembler-x64-meta", +] + +[[package]] +name = "cranelift-assembler-x64-meta" +version = "0.118.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95cabbc01dfbd7dcd6c329ca44f0212910309c221797ac736a67a5bc8857fe1b" + [[package]] name = "cranelift-bforest" -version = "0.116.1" +version = "0.118.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e15d04a0ce86cb36ead88ad68cf693ffd6cda47052b9e0ac114bc47fd9cd23c4" +checksum = "76ffe46df300a45f1dc6f609dc808ce963f0e3a2e971682c479a2d13e3b9b8ef" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-bitset" -version = "0.116.1" +version = "0.118.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c6e3969a7ce267259ce244b7867c5d3bc9e65b0a87e81039588dfdeaede9f34" +checksum = "b265bed7c51e1921fdae6419791d31af77d33662ee56d7b0fa0704dc8d231cab" dependencies = [ "serde", "serde_derive", @@ -460,11 +463,12 @@ dependencies = [ [[package]] name = "cranelift-codegen" -version = "0.116.1" +version = "0.118.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c22032c4cb42558371cf516bb47f26cdad1819d3475c133e93c49f50ebf304e" +checksum = "e606230a7e3a6897d603761baee0d19f88d077f17b996bb5089488a29ae96e41" dependencies = [ "bumpalo", + "cranelift-assembler-x64", "cranelift-bforest", "cranelift-bitset", "cranelift-codegen-meta", @@ -473,8 +477,9 @@ dependencies = [ "cranelift-entity", "cranelift-isle", "gimli 0.31.1", - "hashbrown 0.14.3", + "hashbrown", "log", + "pulley-interpreter", "regalloc2", "rustc-hash", "serde", @@ -484,33 +489,35 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.116.1" +version = "0.118.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c904bc71c61b27fc57827f4a1379f29de64fe95653b620a3db77d59655eee0b8" +checksum = "8a63bffafc23bc60969ad528e138788495999d935f0adcfd6543cb151ca8637d" dependencies = [ + "cranelift-assembler-x64", "cranelift-codegen-shared", + "pulley-interpreter", ] [[package]] name = "cranelift-codegen-shared" -version = "0.116.1" +version = "0.118.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40180f5497572f644ce88c255480981ae2ec1d7bb4d8e0c0136a13b87a2f2ceb" +checksum = "af50281b67324b58e843170a6a5943cf6d387c06f7eeacc9f5696e4ab7ae7d7e" [[package]] name = "cranelift-control" -version = "0.116.1" +version = "0.118.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26d132c6d0bd8a489563472afc171759da0707804a65ece7ceb15a8c6d7dd5ef" +checksum = "8c20c1b38d1abfbcebb0032e497e71156c0e3b8dcb3f0a92b9863b7bcaec290c" dependencies = [ "arbitrary", ] [[package]] name = "cranelift-entity" -version = "0.116.1" +version = "0.118.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b2d0d9618275474fbf679dd018ac6e009acbd6ae6850f6a67be33fb3b00b323" +checksum = "0c2c67d95507c51b4a1ff3f3555fe4bfec36b9e13c1b684ccc602736f5d5f4a2" dependencies = [ "cranelift-bitset", "serde", @@ -519,9 +526,9 @@ dependencies = [ [[package]] name = "cranelift-frontend" -version = "0.116.1" +version = "0.118.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fac41e16729107393174b0c9e3730fb072866100e1e64e80a1a963b2e484d57" +checksum = "4e002691cc69c38b54fc7ec93e5be5b744f627d027031d991cc845d1d512d0ce" dependencies = [ "cranelift-codegen", "log", @@ -531,15 +538,15 @@ dependencies = [ [[package]] name = "cranelift-isle" -version = "0.116.1" +version = "0.118.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ca20d576e5070044d0a72a9effc2deacf4d6aa650403189d8ea50126483944d" +checksum = "e93588ed1796cbcb0e2ad160403509e2c5d330d80dd6e0014ac6774c7ebac496" [[package]] name = "cranelift-native" -version = "0.116.1" +version = "0.118.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8dee82f3f1f2c4cba9177f1cc5e350fe98764379bcd29340caa7b01f85076c7" +checksum = "e5b09bdd6407bf5d89661b80cf926ce731c9e8cc184bf49102267a2369a8358e" dependencies = [ "cranelift-codegen", "libc", @@ -736,14 +743,14 @@ dependencies = [ [[package]] name = "env_logger" -version = "0.11.3" +version = "0.11.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38b35839ba51819680ba087cd351788c9a3c476841207e0b8cee0b04722343b9" +checksum = "13c863f0904021b108aa8b2f55046443e6b1ebde8fd4a15c399893aae4fa069f" dependencies = [ "anstream", "anstyle", "env_filter", - "humantime", + "jiff", "log", ] @@ -943,15 +950,6 @@ dependencies = [ "crunchy", ] -[[package]] -name = "hashbrown" -version = "0.14.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" -dependencies = [ - "ahash", -] - [[package]] name = "hashbrown" version = "0.15.2" @@ -992,12 +990,6 @@ version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" -[[package]] -name = "humantime" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" - [[package]] name = "iana-time-zone" version = "0.1.60" @@ -1044,7 +1036,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8c9c992b02b5b4c94ea26e32fe5bccb7aa7d9f390ab5c1221ff895bc7ea8b652" dependencies = [ "equivalent", - "hashbrown 0.15.2", + "hashbrown", "serde", ] @@ -1125,6 +1117,30 @@ dependencies = [ "cc", ] +[[package]] +name = "jiff" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f33145a5cbea837164362c7bd596106eb7c5198f97d1ba6f6ebb3223952e488" +dependencies = [ + "jiff-static", + "log", + "portable-atomic", + "portable-atomic-util", + "serde", +] + +[[package]] +name = "jiff-static" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43ce13c40ec6956157a3635d97a1ee2df323b263f09ea14165131289cb0f5c19" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.98", +] + [[package]] name = "jobserver" version = "0.1.28" @@ -1202,9 +1218,9 @@ checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab" [[package]] name = "log" -version = "0.4.21" +version = "0.4.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" +checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94" [[package]] name = "mach2" @@ -1282,7 +1298,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "62948e14d923ea95ea2c7c86c71013138b66525b86bdc08d2dcc262bdb497b87" dependencies = [ "crc32fast", - "hashbrown 0.15.2", + "hashbrown", "indexmap", "memchr", ] @@ -1357,6 +1373,21 @@ dependencies = [ "plotters-backend", ] +[[package]] +name = "portable-atomic" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "350e9b48cbc6b0e028b0473b114454c6316e57336ee184ceab6e53f72c178b3e" + +[[package]] +name = "portable-atomic-util" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8a2f0d8d040d7848a709caf78912debcc3f33ee4b3cac47d73d1e1069e83507" +dependencies = [ + "portable-atomic", +] + [[package]] name = "postcard" version = "1.0.8" @@ -1421,21 +1452,20 @@ dependencies = [ [[package]] name = "pulley-interpreter" -version = "29.0.1" +version = "31.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62d95f8575df49a2708398182f49a888cf9dc30210fb1fd2df87c889edcee75d" +checksum = "0c3325791708ad50580aeacfcce06cb5e462c9ba7a2368e109cb2012b944b70e" dependencies = [ "cranelift-bitset", "log", - "sptr", "wasmtime-math", ] [[package]] name = "quote" -version = "1.0.35" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" +checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" dependencies = [ "proc-macro2", ] @@ -1509,7 +1539,7 @@ checksum = "145c1c267e14f20fb0f88aa76a1c5ffec42d592c1d28b3cd9148ae35916158d3" dependencies = [ "allocator-api2", "bumpalo", - "hashbrown 0.15.2", + "hashbrown", "log", "rustc-hash", "smallvec", @@ -2123,22 +2153,22 @@ dependencies = [ [[package]] name = "wasm-encoder" -version = "0.221.3" +version = "0.226.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc8444fe4920de80a4fe5ab564fff2ae58b6b73166b89751f8c6c93509da32e5" +checksum = "f7d81b727619aec227dce83e7f7420d4e56c79acd044642a356ea045b98d4e13" dependencies = [ - "leb128", - "wasmparser 0.221.3", + "leb128fmt", + "wasmparser 0.226.0", ] [[package]] name = "wasm-encoder" -version = "0.225.0" +version = "0.228.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f7eac0445cac73bcf09e6a97f83248d64356dccf9f2b100199769b6b42464e5" +checksum = "05d30290541f2d4242a162bbda76b8f2d8b1ac59eab3568ed6f2327d52c9b2c4" dependencies = [ "leb128fmt", - "wasmparser 0.225.0", + "wasmparser 0.228.0", ] [[package]] @@ -2157,23 +2187,12 @@ dependencies = [ [[package]] name = "wasmparser" -version = "0.202.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6998515d3cf3f8b980ef7c11b29a9b1017d4cf86b99ae93b546992df9931413" -dependencies = [ - "bitflags 2.5.0", - "indexmap", - "semver", -] - -[[package]] -name = "wasmparser" -version = "0.221.3" +version = "0.226.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d06bfa36ab3ac2be0dee563380147a5b81ba10dd8885d7fbbc9eb574be67d185" +checksum = "bc28600dcb2ba68d7e5f1c3ba4195c2bddc918c0243fd702d0b6dbd05689b681" dependencies = [ "bitflags 2.5.0", - "hashbrown 0.15.2", + "hashbrown", "indexmap", "semver", "serde", @@ -2181,41 +2200,44 @@ dependencies = [ [[package]] name = "wasmparser" -version = "0.225.0" +version = "0.228.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36e5456165f81e64cb9908a0fe9b9d852c2c74582aa3fe2be3c2da57f937d3ae" +checksum = "4abf1132c1fdf747d56bbc1bb52152400c70f336870f968b85e89ea422198ae3" dependencies = [ "bitflags 2.5.0", + "hashbrown", "indexmap", "semver", + "serde", ] [[package]] name = "wasmprinter" -version = "0.202.0" +version = "0.226.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab1cc9508685eef9502e787f4d4123745f5651a1e29aec047645d3cac1e2da7a" +checksum = "753a0516fa6c01756ee861f36878dfd9875f273aea9409d9ea390a333c5bcdc2" dependencies = [ "anyhow", - "wasmparser 0.202.0", + "termcolor", + "wasmparser 0.226.0", ] [[package]] name = "wasmprinter" -version = "0.221.3" +version = "0.228.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7343c42a97f2926c7819ff81b64012092ae954c5d83ddd30c9fcdefd97d0b283" +checksum = "0df64bd38c14db359d02ce2024c64eb161aa2618ccee5f3bc5acbbd65c9a875c" dependencies = [ "anyhow", "termcolor", - "wasmparser 0.221.3", + "wasmparser 0.228.0", ] [[package]] name = "wasmtime" -version = "29.0.1" +version = "31.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11976a250672556d1c4c04c6d5d7656ac9192ac9edc42a4587d6c21460010e69" +checksum = "b9fe78033c72da8741e724d763daf1375c93a38bfcea99c873ee4415f6098c3f" dependencies = [ "addr2line 0.24.2", "anyhow", @@ -2227,7 +2249,7 @@ dependencies = [ "encoding_rs", "fxprof-processed-profile", "gimli 0.31.1", - "hashbrown 0.14.3", + "hashbrown", "indexmap", "ittapi", "libc", @@ -2250,8 +2272,8 @@ dependencies = [ "sptr", "target-lexicon", "trait-variant", - "wasm-encoder 0.221.3", - "wasmparser 0.221.3", + "wasm-encoder 0.226.0", + "wasmparser 0.226.0", "wasmtime-asm-macros", "wasmtime-cache", "wasmtime-component-macro", @@ -2271,18 +2293,18 @@ dependencies = [ [[package]] name = "wasmtime-asm-macros" -version = "29.0.1" +version = "31.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f178b0d125201fbe9f75beaf849bd3e511891f9e45ba216a5b620802ccf64f2" +checksum = "47f3d44ae977d70ccf80938b371d5ec60b6adedf60800b9e8dd1223bb69f4cbc" dependencies = [ "cfg-if", ] [[package]] name = "wasmtime-cache" -version = "29.0.1" +version = "31.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b1161c8f62880deea07358bc40cceddc019f1c81d46007bc390710b2fe24ffc" +checksum = "e209505770c7f38725513dba37246265fa6f724c30969de1e9d2a9e6c8f55099" dependencies = [ "anyhow", "base64", @@ -2300,9 +2322,9 @@ dependencies = [ [[package]] name = "wasmtime-component-macro" -version = "29.0.1" +version = "31.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d74de6592ed945d0a602f71243982a304d5d02f1e501b638addf57f42d57dfaf" +checksum = "397e68ee29eb072d8d8741c9d2c971a284cd1bc960ebf2c1f6a33ea6ba16d6e1" dependencies = [ "anyhow", "proc-macro2", @@ -2315,15 +2337,15 @@ dependencies = [ [[package]] name = "wasmtime-component-util" -version = "29.0.1" +version = "31.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "707dc7b3c112ab5a366b30cfe2fb5b2f8e6a0f682f16df96a5ec582bfe6f056e" +checksum = "f292ef5eb2cf3d414c2bde59c7fa0feeba799c8db9a8c5a656ad1d1a1d05e10b" [[package]] name = "wasmtime-cranelift" -version = "29.0.1" +version = "31.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "366be722674d4bf153290fbcbc4d7d16895cc82fb3e869f8d550ff768f9e9e87" +checksum = "52fc12eb8ea695a30007a4849a5fd56209dd86a15579e92e0c27c27122818505" dependencies = [ "anyhow", "cfg-if", @@ -2336,19 +2358,20 @@ dependencies = [ "itertools 0.12.1", "log", "object 0.36.7", + "pulley-interpreter", "smallvec", "target-lexicon", "thiserror", - "wasmparser 0.221.3", + "wasmparser 0.226.0", "wasmtime-environ", "wasmtime-versioned-export-macros", ] [[package]] name = "wasmtime-environ" -version = "29.0.1" +version = "31.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdadc1af7097347aa276a4f008929810f726b5b46946971c660b6d421e9994ad" +checksum = "5b6b4bf08e371edf262cccb62de10e214bd4aaafaa069f1cd49c9c1c3a5ae8e4" dependencies = [ "anyhow", "cpp_demangle", @@ -2365,17 +2388,17 @@ dependencies = [ "serde_derive", "smallvec", "target-lexicon", - "wasm-encoder 0.221.3", - "wasmparser 0.221.3", - "wasmprinter 0.221.3", + "wasm-encoder 0.226.0", + "wasmparser 0.226.0", + "wasmprinter 0.226.0", "wasmtime-component-util", ] [[package]] name = "wasmtime-fiber" -version = "29.0.1" +version = "31.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccba90d4119f081bca91190485650730a617be1fff5228f8c4757ce133d21117" +checksum = "f4c8828d7d8fbe90d087a9edea9223315caf7eb434848896667e5d27889f1173" dependencies = [ "anyhow", "cc", @@ -2388,10 +2411,11 @@ dependencies = [ [[package]] name = "wasmtime-jit-debug" -version = "29.0.1" +version = "31.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e7b61488a5ee00c35c8c22de707c36c0aecacf419a3be803a6a2ba5e860f56a" +checksum = "ab9eff86dedd48b023199de2d266f5d3e37bc7c5bafdc1e3e3057214649ecf5a" dependencies = [ + "cc", "object 0.36.7", "rustix", "wasmtime-versioned-export-macros", @@ -2399,9 +2423,9 @@ dependencies = [ [[package]] name = "wasmtime-jit-icache-coherence" -version = "29.0.1" +version = "31.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec5e8552e01692e6c2e5293171704fed8abdec79d1a6995a0870ab190e5747d1" +checksum = "a54f6c6c7e9d7eeee32dfcc10db7f29d505ee7dd28d00593ea241d5f70698e64" dependencies = [ "anyhow", "cfg-if", @@ -2411,24 +2435,24 @@ dependencies = [ [[package]] name = "wasmtime-math" -version = "29.0.1" +version = "31.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29210ec2aa25e00f4d54605cedaf080f39ec01a872c5bd520ad04c67af1dde17" +checksum = "b1108aad2e6965698f9207ea79b80eda2b3dcc57dcb69f4258296d4664ae32cd" dependencies = [ "libm", ] [[package]] name = "wasmtime-slab" -version = "29.0.1" +version = "31.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcb5821a96fa04ac14bc7b158bb3d5cd7729a053db5a74dad396cd513a5e5ccf" +checksum = "84d6a321317281b721c5530ef733e8596ecc6065035f286ccd155b3fa8e0ab2f" [[package]] name = "wasmtime-versioned-export-macros" -version = "29.0.1" +version = "31.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86ff86db216dc0240462de40c8290887a613dddf9685508eb39479037ba97b5b" +checksum = "5732a5c86efce7bca121a61d8c07875f6b85c1607aa86753b40f7f8bd9d3a780" dependencies = [ "proc-macro2", "quote", @@ -2437,9 +2461,9 @@ dependencies = [ [[package]] name = "wasmtime-wasi" -version = "29.0.1" +version = "31.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d1be69bfcab1bdac74daa7a1f9695ab992b9c8e21b9b061e7d66434097e0ca4" +checksum = "9b425ede2633fade96bd624b6f35cea5f8be1995d149530882dbc35efbf1e31f" dependencies = [ "anyhow", "async-trait", @@ -2459,25 +2483,38 @@ dependencies = [ "thiserror", "tokio", "tracing", - "trait-variant", "url", "wasmtime", + "wasmtime-wasi-io", "wiggle", "windows-sys 0.59.0", ] +[[package]] +name = "wasmtime-wasi-io" +version = "31.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2ec650d8891ec5ff823bdcefe3b370278becd1f33125bcfdcf628943dcde676" +dependencies = [ + "anyhow", + "async-trait", + "bytes", + "futures", + "wasmtime", +] + [[package]] name = "wasmtime-winch" -version = "29.0.1" +version = "31.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fdbabfb8f20502d5e1d81092b9ead3682ae59988487aafcd7567387b7a43cf8f" +checksum = "3aa4741ee66a52e2f0ec5f79040017123ba47d2dff9d994b35879cc2b7f468d4" dependencies = [ "anyhow", "cranelift-codegen", "gimli 0.31.1", "object 0.36.7", "target-lexicon", - "wasmparser 0.221.3", + "wasmparser 0.226.0", "wasmtime-cranelift", "wasmtime-environ", "winch-codegen", @@ -2485,9 +2522,9 @@ dependencies = [ [[package]] name = "wasmtime-wit-bindgen" -version = "29.0.1" +version = "31.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8358319c2dd1e4db79e3c1c5d3a5af84956615343f9f89f4e4996a36816e06e6" +checksum = "505c13fa0cac6c43e805347acf1e916c8de54e3790f2c22873c5692964b09b62" dependencies = [ "anyhow", "heck 0.5.0", @@ -2506,24 +2543,24 @@ dependencies = [ [[package]] name = "wast" -version = "225.0.0" +version = "228.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c61496027ff707f9fa9e0b22c34ec163eb7adb1070df565e32a9180a76e4300b" +checksum = "9e5aae124478cb51439f6587f074a3a5e835afd22751c59a87b2e2a882727c97" dependencies = [ "bumpalo", "leb128fmt", "memchr", "unicode-width 0.2.0", - "wasm-encoder 0.225.0", + "wasm-encoder 0.228.0", ] [[package]] name = "wat" -version = "1.225.0" +version = "1.228.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89e72a33942234fd0794bcdac30e43b448de3187512414267678e511c6755f11" +checksum = "7ec29c89a8d055df988de7236483bf569988ac3d6905899f6af5ef920f9385ad" dependencies = [ - "wast 225.0.0", + "wast 228.0.0", ] [[package]] @@ -2538,9 +2575,9 @@ dependencies = [ [[package]] name = "wiggle" -version = "29.0.1" +version = "31.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b9af35bc9629c52c261465320a9a07959164928b4241980ba1cf923b9e6751d" +checksum = "1dc9a83fe01faa51423fc84941cdbe0ec33ba1e9a75524a560a27a4ad1ff2c3b" dependencies = [ "anyhow", "async-trait", @@ -2553,9 +2590,9 @@ dependencies = [ [[package]] name = "wiggle-generate" -version = "29.0.1" +version = "31.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2cf267dd05673912c8138f4b54acabe6bd53407d9d1536f0fadb6520dd16e101" +checksum = "d250c01cd52cfdb40aad167fad579af55acbeccb85a54827099d31dc1b90cbd7" dependencies = [ "anyhow", "heck 0.5.0", @@ -2568,9 +2605,9 @@ dependencies = [ [[package]] name = "wiggle-macro" -version = "29.0.1" +version = "31.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08c5c473d4198e6c2d377f3809f713ff0c110cab88a0805ae099a82119ee250c" +checksum = "35be0aee84be808a5e17f6b732e110eb75703d9d6e66e22c7464d841aa2600c5" dependencies = [ "proc-macro2", "quote", @@ -2611,9 +2648,9 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "winch-codegen" -version = "29.0.1" +version = "31.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f849ef2c5f46cb0a20af4b4487aaa239846e52e2c03f13fa3c784684552859c" +checksum = "e02f05457f74ec3c94d5c5caac06b84fd8d9d4d7fa21419189845ed245a53477" dependencies = [ "anyhow", "cranelift-codegen", @@ -2622,7 +2659,7 @@ dependencies = [ "smallvec", "target-lexicon", "thiserror", - "wasmparser 0.221.3", + "wasmparser 0.226.0", "wasmtime-cranelift", "wasmtime-environ", ] @@ -2739,9 +2776,9 @@ dependencies = [ [[package]] name = "wit-parser" -version = "0.221.3" +version = "0.226.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "896112579ed56b4a538b07a3d16e562d101ff6265c46b515ce0c701eef16b2ac" +checksum = "33f007722bfd43a2978c5b8b90f02c927dddf0f11c5f5b50929816b3358718cd" dependencies = [ "anyhow", "id-arena", @@ -2752,7 +2789,7 @@ dependencies = [ "serde_derive", "serde_json", "unicode-xid", - "wasmparser 0.221.3", + "wasmparser 0.226.0", ] [[package]] @@ -2778,9 +2815,9 @@ dependencies = [ "log", "rayon", "structopt", - "wasm-encoder 0.202.0", - "wasmparser 0.202.0", - "wasmprinter 0.202.0", + "wasm-encoder 0.228.0", + "wasmparser 0.228.0", + "wasmprinter 0.228.0", "wasmtime", "wasmtime-wasi", "wat", @@ -2794,7 +2831,7 @@ dependencies = [ "libfuzzer-sys", "log", "wasm-smith", - "wasmprinter 0.202.0", + "wasmprinter 0.228.0", "wasmtime", "wizer", ] diff --git a/crates/wizer/Cargo.toml b/crates/wizer/Cargo.toml index 4aa3cb55ef63..89b0db547522 100644 --- a/crates/wizer/Cargo.toml +++ b/crates/wizer/Cargo.toml @@ -27,14 +27,14 @@ name = "uap" harness = false [dependencies] -anyhow = "1.0.81" -cap-std = "3.0.0" -env_logger = { version = "0.11", optional = true } -log = "0.4.21" +anyhow = "1.0.97" +cap-std = "3.4.3" +env_logger = { version = "0.11.8", optional = true } +log = "0.4.27" rayon = "1.10.0" structopt = { version = "0.3.26", optional = true } -wasm-encoder = "0.202.0" -wasmparser = "0.202.0" +wasm-encoder = "0.228.0" +wasmparser = "0.228.0" wasmtime = { workspace = true } wasmtime-wasi = { workspace = true, features = ["preview1"] } @@ -45,15 +45,15 @@ workspace = true optional = true [workspace.dependencies] -wasmprinter = "0.202.0" -wasmtime = "29" -wasmtime-wasi = "29" +wasmprinter = "0.228.0" +wasmtime = "31" +wasmtime-wasi = "31" [dev-dependencies] criterion = "0.5.1" -env_logger = "0.11.3" +env_logger = "0.11.8" wasmprinter = { workspace = true } -wat = "1.202.0" +wat = "1.228.0" [workspace] members = [ diff --git a/crates/wizer/fuzz/fuzz_targets/same_result.rs b/crates/wizer/fuzz/fuzz_targets/same_result.rs index 8b84d8ebf881..76a58ce5492f 100644 --- a/crates/wizer/fuzz/fuzz_targets/same_result.rs +++ b/crates/wizer/fuzz/fuzz_targets/same_result.rs @@ -198,7 +198,10 @@ fuzz_target!(|data: &[u8]| { panic!("divergence between snapshot and non-snapshot memories"); } } - Extern::SharedMemory(_) | Extern::Func(_) | Extern::Table(_) => continue, + Extern::SharedMemory(_) + | Extern::Func(_) + | Extern::Table(_) + | Extern::Tag(_) => continue, } } } diff --git a/crates/wizer/src/dummy.rs b/crates/wizer/src/dummy.rs index 6248662e1138..949447a5c481 100644 --- a/crates/wizer/src/dummy.rs +++ b/crates/wizer/src/dummy.rs @@ -41,6 +41,9 @@ pub fn dummy_extern(store: &mut crate::Store, ty: ExternType, name: &str) -> Res ExternType::Memory(_) => { anyhow::bail!("Error: attempted to import unknown memory: {}", name) } + ExternType::Tag(_) => { + anyhow::bail!("Error: attempted to import unknown tag: {}", name) + } }) } diff --git a/crates/wizer/src/info/types_interner.rs b/crates/wizer/src/info/types_interner.rs index 2196955708dd..748a835bddc5 100644 --- a/crates/wizer/src/info/types_interner.rs +++ b/crates/wizer/src/info/types_interner.rs @@ -64,10 +64,11 @@ impl TypesInterner { ty: wasmparser::CompositeType, _types_space: &[TypeId], ) -> TypeId { - match ty { - wasmparser::CompositeType::Func(func_ty) => self.insert(Type::Func(func_ty)), - wasmparser::CompositeType::Array(_) => todo!(), - wasmparser::CompositeType::Struct(_) => todo!(), + match ty.inner { + wasmparser::CompositeInnerType::Func(func_ty) => self.insert(Type::Func(func_ty)), + wasmparser::CompositeInnerType::Array(_) => todo!(), + wasmparser::CompositeInnerType::Struct(_) => todo!(), + wasmparser::CompositeInnerType::Cont(_) => todo!(), } } diff --git a/crates/wizer/src/lib.rs b/crates/wizer/src/lib.rs index 5a0a31e7fc81..05898b71cd4e 100644 --- a/crates/wizer/src/lib.rs +++ b/crates/wizer/src/lib.rs @@ -17,6 +17,7 @@ mod snapshot; mod stack_ext; mod translate; +use wasmparser::WasmFeatures; /// Re-export wasmtime so users can align with our version. This is /// especially useful when providing a custom Linker. pub use wasmtime; @@ -665,6 +666,9 @@ impl Wizer { .unwrap_or(DEFAULT_WASM_REFERENCE_TYPES), ); + config.wasm_tail_call(true); + config.wasm_extended_const(true); + // Proposals that we should add support for. config.wasm_threads(false); @@ -673,59 +677,34 @@ impl Wizer { // NB: keep this in sync with the Wasmtime config. fn wasm_features(&self) -> wasmparser::WasmFeatures { - wasmparser::WasmFeatures { - mutable_global: true, - saturating_float_to_int: true, - sign_extension: true, - floats: true, - component_model_values: false, - component_model_nested_names: false, - - // Proposals that we support. - multi_memory: self.wasm_multi_memory.unwrap_or(DEFAULT_WASM_MULTI_MEMORY), - multi_value: self.wasm_multi_value.unwrap_or(DEFAULT_WASM_MULTI_VALUE), - - // Proposals that we should add support for. - reference_types: self - .wasm_reference_types + let mut features = WasmFeatures::WASM2; + + features.set( + WasmFeatures::MULTI_MEMORY, + self.wasm_multi_memory.unwrap_or(DEFAULT_WASM_MULTI_MEMORY), + ); + features.set( + WasmFeatures::MULTI_VALUE, + self.wasm_multi_value.unwrap_or(DEFAULT_WASM_MULTI_VALUE), + ); + features.set( + WasmFeatures::BULK_MEMORY, + self.wasm_bulk_memory.unwrap_or(DEFAULT_WASM_BULK_MEMORY), + ); + features.set( + WasmFeatures::SIMD, + self.wasm_simd.unwrap_or(DEFAULT_WASM_SIMD), + ); + features.set( + WasmFeatures::REFERENCE_TYPES, + self.wasm_reference_types .unwrap_or(DEFAULT_WASM_REFERENCE_TYPES), - simd: self.wasm_simd.unwrap_or(DEFAULT_WASM_SIMD), - threads: false, - tail_call: false, - memory64: false, - exceptions: false, - extended_const: false, - relaxed_simd: false, - component_model: false, - memory_control: false, - function_references: false, - gc: false, - - // XXX: Though we don't fully support bulk memory yet, we - // unconditionally turn it on. - // - // Many parsers, notably our own `wasmparser`, assume that which - // Wasm features are enabled or disabled cannot affect parsing, only - // validation. That assumption is incorrect when it comes to data - // segments, the multi-memory proposal, and the bulk memory - // proposal. A `0x01` prefix of a data segment can either mean "this - // is a passive segment" if bulk memory is enabled or "this segment - // is referring to memory index 1" if both bulk memory is disabled - // and multi-memory is enabled. `wasmparser` fails to handle this - // edge case, which means that everything built on top of it, like - // Wasmtime, also fail to handle this edge case. However, because - // bulk memory is merged into the spec proper and is no longer - // technically a "proposal", and because a fix would require - // significant refactoring and API changes to give a - // `wasmparser::Parser` a `wasmparser::WasmFeatures`, we won't ever - // resolve this discrepancy in `wasmparser`. - // - // So we enable bulk memory during parsing, validation, and - // execution, but we add our own custom validation pass to ensure - // that no table-mutating instructions exist in our input modules - // until we *actually* support bulk memory. - bulk_memory: true, - } + ); + + features.set(WasmFeatures::TAIL_CALL, true); + features.set(WasmFeatures::EXTENDED_CONST, true); + + return features; } fn wasm_validate(&self, wasm: &[u8]) -> anyhow::Result<()> { diff --git a/crates/wizer/src/parse.rs b/crates/wizer/src/parse.rs index 10ceb20a637e..2ef58c82e694 100644 --- a/crates/wizer/src/parse.rs +++ b/crates/wizer/src/parse.rs @@ -102,7 +102,6 @@ pub(crate) fn parse<'a>(full_wasm: &'a [u8]) -> anyhow::Result assert!(stack.is_empty()); return Ok(cx); } - ComponentTypeSection(_) | ComponentImportSection(_) | ComponentExportSection(_) @@ -116,6 +115,7 @@ pub(crate) fn parse<'a>(full_wasm: &'a [u8]) -> anyhow::Result | ComponentSection { .. } => { unreachable!() } + _ => anyhow::bail!("unsupported wasmparser payload"), } } } @@ -133,12 +133,13 @@ fn type_section<'a>( // instance imports. for group in types { for ty in group?.into_types() { - match ty.composite_type { - ty @ wasmparser::CompositeType::Func(_) => { - module.push_type(cx, ty); + match ty.composite_type.inner { + wasmparser::CompositeInnerType::Func(_) => { + module.push_type(cx, ty.composite_type); } - wasmparser::CompositeType::Array(_) => todo!(), - wasmparser::CompositeType::Struct(_) => todo!(), + wasmparser::CompositeInnerType::Array(_) => todo!(), + wasmparser::CompositeInnerType::Struct(_) => todo!(), + wasmparser::CompositeInnerType::Cont(_) => todo!(), } } } diff --git a/crates/wizer/src/rewrite.rs b/crates/wizer/src/rewrite.rs index 01742ec3c2ae..637913e67d7d 100644 --- a/crates/wizer/src/rewrite.rs +++ b/crates/wizer/src/rewrite.rs @@ -166,7 +166,7 @@ impl Wizer { fn is_name_section(s: &wasm_encoder::RawSection) -> bool { s.id == u8::from(SectionId::Custom) && { - let mut reader = wasmparser::BinaryReader::new(s.data); + let mut reader = wasmparser::BinaryReader::new(s.data, 0); matches!(reader.read_string(), Ok("name")) } } diff --git a/crates/wizer/src/translate.rs b/crates/wizer/src/translate.rs index c57ad094227b..6b0addc101c3 100644 --- a/crates/wizer/src/translate.rs +++ b/crates/wizer/src/translate.rs @@ -18,6 +18,7 @@ pub(crate) fn global_type(ty: wasmparser::GlobalType) -> wasm_encoder::GlobalTyp wasm_encoder::GlobalType { val_type: val_type(ty.content_type), mutable: ty.mutable, + shared: ty.shared, } } @@ -27,6 +28,7 @@ pub(crate) fn memory_type(ty: wasmparser::MemoryType) -> wasm_encoder::MemoryTyp maximum: ty.maximum.map(|val| val.into()), memory64: ty.memory64, shared: ty.shared, + page_size_log2: None, } } diff --git a/crates/wizer/tests/tests.rs b/crates/wizer/tests/tests.rs index 4005f414a1c5..7a9bbc51a765 100644 --- a/crates/wizer/tests/tests.rs +++ b/crates/wizer/tests/tests.rs @@ -97,10 +97,10 @@ fn fails_wizening(wat: &str) -> Result<()> { let wasm = wat_to_wasm(wat)?; - let mut validator = wasmparser::Validator::new_with_features(wasmparser::WasmFeatures { - multi_memory: true, - ..Default::default() - }); + let mut features = wasmparser::WasmFeatures::WASM2; + features.set(wasmparser::WasmFeatures::MULTI_MEMORY, true); + + let mut validator = wasmparser::Validator::new_with_features(features); validator .validate_all(&wasm) .context("initial Wasm should be valid")?; @@ -556,6 +556,8 @@ fn rename_functions() -> Result<()> { (module (type (;0;) (func)) (type (;1;) (func (result i32))) + (export "func_a" (func 2)) + (export "func_b" (func 3)) (func (;0;) (type 0)) (func (;1;) (type 1) (result i32) i32.const 1 @@ -566,8 +568,6 @@ fn rename_functions() -> Result<()> { (func (;3;) (type 1) (result i32) i32.const 3 ) - (export "func_a" (func 2)) - (export "func_b" (func 3)) ) "#; @@ -707,8 +707,13 @@ fn accept_bulk_memory_copy() -> Result<()> { fn accept_bulk_memory_data_count() -> Result<()> { let mut module = wasm_encoder::Module::new(); let mut types = wasm_encoder::TypeSection::new(); - types.function(vec![], vec![wasm_encoder::ValType::I32]); - types.function(vec![], vec![]); + types.ty().func_type(&wasm_encoder::FuncType::new( + vec![], + vec![wasm_encoder::ValType::I32], + )); + types + .ty() + .func_type(&wasm_encoder::FuncType::new(vec![], vec![])); module.section(&types); let mut functions = wasm_encoder::FunctionSection::new(); @@ -722,6 +727,7 @@ fn accept_bulk_memory_data_count() -> Result<()> { maximum: Some(1), memory64: false, shared: false, + page_size_log2: None, }); module.section(&memory); From 45c4b6ae3038b0530ffb31bf25365c0102816c02 Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Tue, 3 Jun 2025 23:09:12 +0200 Subject: [PATCH 209/212] Bump to version 9.0.0 (#135) --- crates/wizer/Cargo.lock | 2 +- crates/wizer/Cargo.toml | 2 +- crates/wizer/README.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/wizer/Cargo.lock b/crates/wizer/Cargo.lock index f1bc61c4b779..6922dbf17253 100644 --- a/crates/wizer/Cargo.lock +++ b/crates/wizer/Cargo.lock @@ -2806,7 +2806,7 @@ dependencies = [ [[package]] name = "wizer" -version = "8.0.0" +version = "9.0.0" dependencies = [ "anyhow", "cap-std", diff --git a/crates/wizer/Cargo.toml b/crates/wizer/Cargo.toml index 89b0db547522..1ac331813b06 100644 --- a/crates/wizer/Cargo.toml +++ b/crates/wizer/Cargo.toml @@ -10,7 +10,7 @@ license = "Apache-2.0 WITH LLVM-exception" name = "wizer" readme = "./README.md" repository = "https://github.com/bytecodealliance/wizer" -version = "8.0.0" +version = "9.0.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/crates/wizer/README.md b/crates/wizer/README.md index d2ba90c845f3..dfdcc7969e1f 100644 --- a/crates/wizer/README.md +++ b/crates/wizer/README.md @@ -124,7 +124,7 @@ Add a dependency in your `Cargo.toml`: # Cargo.toml [dependencies] -wizer = "8" +wizer = "9" ``` And then use the `wizer::Wizer` builder to configure and run Wizer: From 409a5d5a03cc8f1bbfc5f83f5acaa8da085079d8 Mon Sep 17 00:00:00 2001 From: Victor Adossi <123968127+vados-cosmonic@users.noreply.github.com> Date: Thu, 28 Aug 2025 00:27:09 +0900 Subject: [PATCH 210/212] chore(deps): update wasmtime & upstream deps (#136) * chore(deps): update wasmtime & upstream deps This commit updates wasmtime along with other deps: - wasmtime: v31 -> v36.0.2 - wasmparser et al: *.228 -> *.238 * fix(deps): use major version of wasmtime in dep Co-authored-by: Till Schneidereit --------- Co-authored-by: Till Schneidereit --- crates/wizer/Cargo.lock | 762 ++++++++++-------- crates/wizer/Cargo.toml | 12 +- crates/wizer/fuzz/fuzz_targets/same_result.rs | 4 +- crates/wizer/src/lib.rs | 2 +- crates/wizer/src/rewrite.rs | 8 +- crates/wizer/tests/make_linker.rs | 4 +- crates/wizer/tests/tests.rs | 4 +- 7 files changed, 465 insertions(+), 331 deletions(-) diff --git a/crates/wizer/Cargo.lock b/crates/wizer/Cargo.lock index 6922dbf17253..bce1de50a6ff 100644 --- a/crates/wizer/Cargo.lock +++ b/crates/wizer/Cargo.lock @@ -13,11 +13,11 @@ dependencies = [ [[package]] name = "addr2line" -version = "0.24.2" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1" +checksum = "9acbfca36652500c911ddb767ed433e3ed99b032b5d935be73c6923662db1d43" dependencies = [ - "gimli 0.31.1", + "gimli 0.32.2", ] [[package]] @@ -179,9 +179,9 @@ dependencies = [ [[package]] name = "base64" -version = "0.21.7" +version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" [[package]] name = "bitflags" @@ -227,9 +227,9 @@ checksum = "8318a53db07bb3f8dca91a600466bdb3f2eaadeedfdbcf02e1accbad9271ba50" [[package]] name = "cap-fs-ext" -version = "3.4.2" +version = "3.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f78efdd7378980d79c0f36b519e51191742d2c9f91ffa5e228fba9f3806d2e1" +checksum = "e41cc18551193fe8fa6f15c1e3c799bc5ec9e2cfbfaa8ed46f37013e3e6c173c" dependencies = [ "cap-primitives", "cap-std", @@ -239,21 +239,21 @@ dependencies = [ [[package]] name = "cap-net-ext" -version = "3.4.2" +version = "3.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ac68674a6042af2bcee1adad9f6abd432642cf03444ce3a5b36c3f39f23baf8" +checksum = "9f83833816c66c986e913b22ac887cec216ea09301802054316fc5301809702c" dependencies = [ "cap-primitives", "cap-std", - "rustix", + "rustix 1.0.8", "smallvec", ] [[package]] name = "cap-primitives" -version = "3.4.3" +version = "3.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50ad0183a9659850877cefe8f5b87d564b2dd1fe78b18945813687f29c0a6878" +checksum = "0a1e394ed14f39f8bc26f59d4c0c010dbe7f0a1b9bafff451b1f98b67c8af62a" dependencies = [ "ambient-authority", "fs-set-times", @@ -261,16 +261,17 @@ dependencies = [ "io-lifetimes", "ipnet", "maybe-owned", - "rustix", + "rustix 1.0.8", + "rustix-linux-procfs", "windows-sys 0.59.0", "winx", ] [[package]] name = "cap-rand" -version = "3.4.2" +version = "3.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dea13372b49df066d1ae654e5c6e41799c1efd9f6b36794b921e877ea4037977" +checksum = "0acb89ccf798a28683f00089d0630dfaceec087234eae0d308c05ddeaa941b40" dependencies = [ "ambient-authority", "rand", @@ -278,27 +279,27 @@ dependencies = [ [[package]] name = "cap-std" -version = "3.4.3" +version = "3.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c41814365b796ed12688026cb90a1e03236a84ccf009628f9c43c8aa3af250a" +checksum = "07c0355ca583dd58f176c3c12489d684163861ede3c9efa6fd8bba314c984189" dependencies = [ "cap-primitives", "io-extras", "io-lifetimes", - "rustix", + "rustix 1.0.8", ] [[package]] name = "cap-time-ext" -version = "3.4.2" +version = "3.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd736b20fc033f564a1995fb82fc349146de43aabba19c7368b4cb17d8f9ea53" +checksum = "491af520b8770085daa0466978c75db90368c71896523f2464214e38359b1a5b" dependencies = [ "ambient-authority", "cap-primitives", "iana-time-zone", "once_cell", - "rustix", + "rustix 1.0.8", "winx", ] @@ -429,33 +430,36 @@ dependencies = [ [[package]] name = "cranelift-assembler-x64" -version = "0.118.0" +version = "0.123.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e4b56ebe316895d3fa37775d0a87b0c889cc933f5c8b253dbcc7c7bcb7fe7e4" +checksum = "0920ef6863433fa28ece7e53925be4cd39a913adba2dc3738f4edd182f76d168" dependencies = [ "cranelift-assembler-x64-meta", ] [[package]] name = "cranelift-assembler-x64-meta" -version = "0.118.0" +version = "0.123.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95cabbc01dfbd7dcd6c329ca44f0212910309c221797ac736a67a5bc8857fe1b" +checksum = "8990a217e2529a378af1daf4f8afa889f928f07ebbde6ae2f058ae60e40e2c20" +dependencies = [ + "cranelift-srcgen", +] [[package]] name = "cranelift-bforest" -version = "0.118.0" +version = "0.123.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76ffe46df300a45f1dc6f609dc808ce963f0e3a2e971682c479a2d13e3b9b8ef" +checksum = "62225596b687f69a42c038485a28369badc186cb7c74bd9436eeec9f539011b1" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-bitset" -version = "0.118.0" +version = "0.123.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b265bed7c51e1921fdae6419791d31af77d33662ee56d7b0fa0704dc8d231cab" +checksum = "c23914fc4062558650a6f0d8c1846c97b541215a291fdeabc85f68bdc9bbcca3" dependencies = [ "serde", "serde_derive", @@ -463,9 +467,9 @@ dependencies = [ [[package]] name = "cranelift-codegen" -version = "0.118.0" +version = "0.123.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e606230a7e3a6897d603761baee0d19f88d077f17b996bb5089488a29ae96e41" +checksum = "41a238b2f7e7ec077eb170145fa15fd8b3d0f36cc83d8e354e29ca550f339ca7" dependencies = [ "bumpalo", "cranelift-assembler-x64", @@ -476,7 +480,7 @@ dependencies = [ "cranelift-control", "cranelift-entity", "cranelift-isle", - "gimli 0.31.1", + "gimli 0.32.2", "hashbrown", "log", "pulley-interpreter", @@ -485,39 +489,42 @@ dependencies = [ "serde", "smallvec", "target-lexicon", + "wasmtime-internal-math", ] [[package]] name = "cranelift-codegen-meta" -version = "0.118.0" +version = "0.123.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a63bffafc23bc60969ad528e138788495999d935f0adcfd6543cb151ca8637d" +checksum = "9315ddcc2512513a9d66455ec89bb70ae5498cb472f5ed990230536f4cd5c011" dependencies = [ - "cranelift-assembler-x64", + "cranelift-assembler-x64-meta", "cranelift-codegen-shared", + "cranelift-srcgen", + "heck 0.5.0", "pulley-interpreter", ] [[package]] name = "cranelift-codegen-shared" -version = "0.118.0" +version = "0.123.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af50281b67324b58e843170a6a5943cf6d387c06f7eeacc9f5696e4ab7ae7d7e" +checksum = "dc6acea40ef860f28cb36eaad479e26556c1e538b0a66fc44598cf1b1689393d" [[package]] name = "cranelift-control" -version = "0.118.0" +version = "0.123.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c20c1b38d1abfbcebb0032e497e71156c0e3b8dcb3f0a92b9863b7bcaec290c" +checksum = "6b2af895da90761cfda4a4445960554fcec971e637882eda5a87337d993fe1b9" dependencies = [ "arbitrary", ] [[package]] name = "cranelift-entity" -version = "0.118.0" +version = "0.123.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c2c67d95507c51b4a1ff3f3555fe4bfec36b9e13c1b684ccc602736f5d5f4a2" +checksum = "6e8c542c856feb50d504e4fc0526b3db3a514f882a9f68f956164531517828ab" dependencies = [ "cranelift-bitset", "serde", @@ -526,9 +533,9 @@ dependencies = [ [[package]] name = "cranelift-frontend" -version = "0.118.0" +version = "0.123.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e002691cc69c38b54fc7ec93e5be5b744f627d027031d991cc845d1d512d0ce" +checksum = "9996dd9c20929c03360fe0c4edf3594c0cbb94525bdbfa04b6bb639ec14573c7" dependencies = [ "cranelift-codegen", "log", @@ -538,21 +545,27 @@ dependencies = [ [[package]] name = "cranelift-isle" -version = "0.118.0" +version = "0.123.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e93588ed1796cbcb0e2ad160403509e2c5d330d80dd6e0014ac6774c7ebac496" +checksum = "928b8dccad51b9e0ffe54accbd617da900239439b13d48f0f122ab61105ca6ad" [[package]] name = "cranelift-native" -version = "0.118.0" +version = "0.123.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5b09bdd6407bf5d89661b80cf926ce731c9e8cc184bf49102267a2369a8358e" +checksum = "7f75ef0a6a2efed3a2a14812318e28dc82c214eab5399c13d70878e2f88947b5" dependencies = [ "cranelift-codegen", "libc", "target-lexicon", ] +[[package]] +name = "cranelift-srcgen" +version = "0.123.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "673bd6d1c83cb41d60afb140a1474ef6caf1a3e02f3820fc522aefbc93ac67d6" + [[package]] name = "crc32fast" version = "1.4.0" @@ -679,26 +692,6 @@ dependencies = [ "dirs-sys-next", ] -[[package]] -name = "dirs" -version = "4.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca3aa72a6f96ea37bbc5aa912f6788242832f75369bdfdadcb0e38423f100059" -dependencies = [ - "dirs-sys", -] - -[[package]] -name = "dirs-sys" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6" -dependencies = [ - "libc", - "redox_users", - "winapi", -] - [[package]] name = "dirs-sys-next" version = "0.1.2" @@ -783,7 +776,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7e5768da2206272c81ef0b5e951a41862938a6070da63bcea197899942d3b947" dependencies = [ "cfg-if", - "rustix", + "rustix 0.38.44", "windows-sys 0.52.0", ] @@ -815,7 +808,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "033b337d725b97690d86893f9de22b67b80dcc4e9ad815f348254c38119db8fb" dependencies = [ "io-lifetimes", - "rustix", + "rustix 0.38.44", "windows-sys 0.52.0", ] @@ -931,9 +924,9 @@ checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" [[package]] name = "gimli" -version = "0.31.1" +version = "0.32.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" +checksum = "cc6298e594375a7fead9efd5568f0a46e6a154fb6a9bdcbe3c06946ffd81a5f6" dependencies = [ "fallible-iterator", "indexmap", @@ -1056,6 +1049,17 @@ version = "2.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a611371471e98973dbcab4e0ec66c31a10bc356eeb4d54a0e05eac8158fe38c" +[[package]] +name = "io-uring" +version = "0.7.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "046fa2d4d00aea763528b4950358d0ead425372445dc8ff86312b3c69ff7727b" +dependencies = [ + "bitflags 2.5.0", + "cfg-if", + "libc", +] + [[package]] name = "ipnet" version = "2.9.0" @@ -1084,9 +1088,9 @@ dependencies = [ [[package]] name = "itertools" -version = "0.12.1" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" +checksum = "2b192c782037fadd9cfa75548310488aabdbf3d2da73885b31bd0abd03351285" dependencies = [ "either", ] @@ -1216,6 +1220,12 @@ version = "0.4.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab" +[[package]] +name = "linux-raw-sys" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd945864f07fe9f5371a27ad7b52a172b4b499999f1d97574c9fa68373937e12" + [[package]] name = "log" version = "0.4.27" @@ -1249,7 +1259,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b2cffa4ad52c6f791f4f8b15f0c05f9824b2ced1160e88cc393d64fff9a8ac64" dependencies = [ - "rustix", + "rustix 0.38.44", ] [[package]] @@ -1293,9 +1303,9 @@ dependencies = [ [[package]] name = "object" -version = "0.36.7" +version = "0.37.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62948e14d923ea95ea2c7c86c71013138b66525b86bdc08d2dcc262bdb497b87" +checksum = "ff76201f031d8863c38aa7f905eca4f53abbfa15f609db4277d44cd8938f33fe" dependencies = [ "crc32fast", "hashbrown", @@ -1315,12 +1325,6 @@ version = "11.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575" -[[package]] -name = "paste" -version = "1.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" - [[package]] name = "percent-encoding" version = "2.3.1" @@ -1442,23 +1446,26 @@ dependencies = [ ] [[package]] -name = "psm" -version = "0.1.21" +name = "pulley-interpreter" +version = "36.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5787f7cda34e3033a72192c018bc5883100330f362ef279a8cbccfce8bb4e874" +checksum = "e4e2d31146038fd9e62bfa331db057aca325d5ca10451a9fe341356cead7da53" dependencies = [ - "cc", + "cranelift-bitset", + "log", + "pulley-macros", + "wasmtime-internal-math", ] [[package]] -name = "pulley-interpreter" -version = "31.0.0" +name = "pulley-macros" +version = "36.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c3325791708ad50580aeacfcce06cb5e462c9ba7a2368e109cb2012b944b70e" +checksum = "efb9fdafaca625f9ea8cfa793364ea1bdd32d306cff18f166b00ddaa61ecbb27" dependencies = [ - "cranelift-bitset", - "log", - "wasmtime-math", + "proc-macro2", + "quote", + "syn 2.0.98", ] [[package]] @@ -1528,14 +1535,14 @@ checksum = "bd283d9651eeda4b2a83a43c1c91b266c40fd76ecd39a50a8c630ae69dc72891" dependencies = [ "getrandom", "libredox", - "thiserror", + "thiserror 1.0.58", ] [[package]] name = "regalloc2" -version = "0.11.1" +version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "145c1c267e14f20fb0f88aa76a1c5ffec42d592c1d28b3cd9148ae35916158d3" +checksum = "5216b1837de2149f8bc8e6d5f88a9326b63b8c836ed58ce4a0a29ec736a59734" dependencies = [ "allocator-api2", "bumpalo", @@ -1608,13 +1615,34 @@ checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154" dependencies = [ "bitflags 2.5.0", "errno", - "itoa", "libc", - "linux-raw-sys", - "once_cell", + "linux-raw-sys 0.4.15", + "windows-sys 0.59.0", +] + +[[package]] +name = "rustix" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11181fbabf243db407ef8df94a6ce0b2f9a733bd8be4ad02b4eda9602296cac8" +dependencies = [ + "bitflags 2.5.0", + "errno", + "libc", + "linux-raw-sys 0.9.4", "windows-sys 0.59.0", ] +[[package]] +name = "rustix-linux-procfs" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2fc84bf7e9aa16c4f2c758f27412dc9841341e16aa682d9c7ac308fe3ee12056" +dependencies = [ + "once_cell", + "rustix 1.0.8", +] + [[package]] name = "ryu" version = "1.0.17" @@ -1704,13 +1732,10 @@ dependencies = [ ] [[package]] -name = "shellexpand" -version = "2.1.2" +name = "slab" +version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ccc8076840c4da029af4f87e4e8daeb0fca6b87bbb02e10cb60b791450e11e4" -dependencies = [ - "dirs", -] +checksum = "7a2ae44ef20feb57a68b23d846850f861394c2e02dc425a50098ae8c90267589" [[package]] name = "smallvec" @@ -1731,12 +1756,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "sptr" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b9b39299b249ad65f3b7e96443bad61c02ca5cd3589f46cb6d610a0fd6c0d6a" - [[package]] name = "stable_deref_trait" version = "1.2.0" @@ -1806,7 +1825,7 @@ dependencies = [ "cap-std", "fd-lock", "io-lifetimes", - "rustix", + "rustix 0.38.44", "windows-sys 0.52.0", "winx", ] @@ -1841,7 +1860,16 @@ version = "1.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "03468839009160513471e86a034bb2c5c0e4baae3b43f79ffc55c4a5427b3297" dependencies = [ - "thiserror-impl", + "thiserror-impl 1.0.58", +] + +[[package]] +name = "thiserror" +version = "2.0.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3467d614147380f2e4e374161426ff399c91084acd2363eaf549172b3d5e60c0" +dependencies = [ + "thiserror-impl 2.0.16", ] [[package]] @@ -1855,6 +1883,17 @@ dependencies = [ "syn 2.0.98", ] +[[package]] +name = "thiserror-impl" +version = "2.0.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c5e1be1c48b9172ee610da68fd9cd2770e7a4056cb3fc98710ee6906f0c7960" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.98", +] + [[package]] name = "tinytemplate" version = "1.2.1" @@ -1882,15 +1921,17 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.39.3" +version = "1.46.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9babc99b9923bfa4804bd74722ff02c0381021eafa4db9949217e3be8e84fff5" +checksum = "0cc3a2344dafbe23a245241fe8b09735b521110d30fcefbbd5feb1797ca35d17" dependencies = [ "backtrace", "bytes", + "io-uring", "libc", "mio", "pin-project-lite", + "slab", "socket2", "windows-sys 0.52.0", ] @@ -1960,17 +2001,6 @@ dependencies = [ "once_cell", ] -[[package]] -name = "trait-variant" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70977707304198400eb4835a78f6a9f928bf41bba420deb8fdb175cd965d77a7" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.98", -] - [[package]] name = "typenum" version = "1.17.0" @@ -2153,22 +2183,22 @@ dependencies = [ [[package]] name = "wasm-encoder" -version = "0.226.0" +version = "0.236.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7d81b727619aec227dce83e7f7420d4e56c79acd044642a356ea045b98d4e13" +checksum = "724fccfd4f3c24b7e589d333fc0429c68042897a7e8a5f8694f31792471841e7" dependencies = [ "leb128fmt", - "wasmparser 0.226.0", + "wasmparser 0.236.1", ] [[package]] name = "wasm-encoder" -version = "0.228.0" +version = "0.238.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05d30290541f2d4242a162bbda76b8f2d8b1ac59eab3568ed6f2327d52c9b2c4" +checksum = "50143b010bdc3adbd16275710f9085cc80d9c12cb869309a51a98ce2ff96558e" dependencies = [ "leb128fmt", - "wasmparser 0.228.0", + "wasmparser 0.238.0", ] [[package]] @@ -2187,9 +2217,9 @@ dependencies = [ [[package]] name = "wasmparser" -version = "0.226.0" +version = "0.236.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc28600dcb2ba68d7e5f1c3ba4195c2bddc918c0243fd702d0b6dbd05689b681" +checksum = "a9b1e81f3eb254cf7404a82cee6926a4a3ccc5aad80cc3d43608a070c67aa1d7" dependencies = [ "bitflags 2.5.0", "hashbrown", @@ -2200,9 +2230,9 @@ dependencies = [ [[package]] name = "wasmparser" -version = "0.228.0" +version = "0.238.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4abf1132c1fdf747d56bbc1bb52152400c70f336870f968b85e89ea422198ae3" +checksum = "c0ad4ca2ecb86b79ea410cd970985665de1d05774b7107b214bc5852b1bcbad7" dependencies = [ "bitflags 2.5.0", "hashbrown", @@ -2213,33 +2243,33 @@ dependencies = [ [[package]] name = "wasmprinter" -version = "0.226.0" +version = "0.236.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "753a0516fa6c01756ee861f36878dfd9875f273aea9409d9ea390a333c5bcdc2" +checksum = "2df225df06a6df15b46e3f73ca066ff92c2e023670969f7d50ce7d5e695abbb1" dependencies = [ "anyhow", "termcolor", - "wasmparser 0.226.0", + "wasmparser 0.236.1", ] [[package]] name = "wasmprinter" -version = "0.228.0" +version = "0.238.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0df64bd38c14db359d02ce2024c64eb161aa2618ccee5f3bc5acbbd65c9a875c" +checksum = "5fec8a560f7288effd1a61fe8d7bfe9fc3efdc2173949d7a5ee38ea9e8eaa336" dependencies = [ "anyhow", "termcolor", - "wasmparser 0.228.0", + "wasmparser 0.238.0", ] [[package]] name = "wasmtime" -version = "31.0.0" +version = "36.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9fe78033c72da8741e724d763daf1375c93a38bfcea99c873ee4415f6098c3f" +checksum = "5b3e1fab634681494213138ea3a18e958e5ea99da13a4a01a4b870d51a41680b" dependencies = [ - "addr2line 0.24.2", + "addr2line 0.25.0", "anyhow", "async-trait", "bitflags 2.5.0", @@ -2248,7 +2278,7 @@ dependencies = [ "cfg-if", "encoding_rs", "fxprof-processed-profile", - "gimli 0.31.1", + "gimli 0.32.2", "hashbrown", "indexmap", "ittapi", @@ -2256,96 +2286,120 @@ dependencies = [ "log", "mach2", "memfd", - "object 0.36.7", + "object 0.37.3", "once_cell", - "paste", "postcard", - "psm", "pulley-interpreter", "rayon", - "rustix", + "rustix 1.0.8", "semver", "serde", "serde_derive", "serde_json", "smallvec", - "sptr", "target-lexicon", - "trait-variant", - "wasm-encoder 0.226.0", - "wasmparser 0.226.0", - "wasmtime-asm-macros", - "wasmtime-cache", - "wasmtime-component-macro", - "wasmtime-component-util", - "wasmtime-cranelift", + "wasm-encoder 0.236.1", + "wasmparser 0.236.1", "wasmtime-environ", - "wasmtime-fiber", - "wasmtime-jit-debug", - "wasmtime-jit-icache-coherence", - "wasmtime-math", - "wasmtime-slab", - "wasmtime-versioned-export-macros", - "wasmtime-winch", + "wasmtime-internal-asm-macros", + "wasmtime-internal-cache", + "wasmtime-internal-component-macro", + "wasmtime-internal-component-util", + "wasmtime-internal-cranelift", + "wasmtime-internal-fiber", + "wasmtime-internal-jit-debug", + "wasmtime-internal-jit-icache-coherence", + "wasmtime-internal-math", + "wasmtime-internal-slab", + "wasmtime-internal-unwinder", + "wasmtime-internal-versioned-export-macros", + "wasmtime-internal-winch", "wat", - "windows-sys 0.59.0", + "windows-sys 0.60.2", +] + +[[package]] +name = "wasmtime-environ" +version = "36.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6750e519977953a018fe994aada7e02510aea4babb03310aa5f5b4145b6e6577" +dependencies = [ + "anyhow", + "cpp_demangle", + "cranelift-bitset", + "cranelift-entity", + "gimli 0.32.2", + "indexmap", + "log", + "object 0.37.3", + "postcard", + "rustc-demangle", + "semver", + "serde", + "serde_derive", + "smallvec", + "target-lexicon", + "wasm-encoder 0.236.1", + "wasmparser 0.236.1", + "wasmprinter 0.236.1", + "wasmtime-internal-component-util", ] [[package]] -name = "wasmtime-asm-macros" -version = "31.0.0" +name = "wasmtime-internal-asm-macros" +version = "36.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47f3d44ae977d70ccf80938b371d5ec60b6adedf60800b9e8dd1223bb69f4cbc" +checksum = "bdbf38adac6e81d5c0326e8fd25f80450e3038f2fc103afd3c5cc8b83d5dd78b" dependencies = [ "cfg-if", ] [[package]] -name = "wasmtime-cache" -version = "31.0.0" +name = "wasmtime-internal-cache" +version = "36.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e209505770c7f38725513dba37246265fa6f724c30969de1e9d2a9e6c8f55099" +checksum = "c0c9085d8c04cc294612d743e2f355382b39250de4bd20bf4b0b0b7c0ae7067a" dependencies = [ "anyhow", "base64", "directories-next", "log", "postcard", - "rustix", + "rustix 1.0.8", "serde", "serde_derive", "sha2", "toml", - "windows-sys 0.59.0", + "windows-sys 0.60.2", "zstd", ] [[package]] -name = "wasmtime-component-macro" -version = "31.0.0" +name = "wasmtime-internal-component-macro" +version = "36.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "397e68ee29eb072d8d8741c9d2c971a284cd1bc960ebf2c1f6a33ea6ba16d6e1" +checksum = "26a578a474e3b7ddce063cd169ced292b5185013341457522891b10e989aa42a" dependencies = [ "anyhow", "proc-macro2", "quote", "syn 2.0.98", - "wasmtime-component-util", - "wasmtime-wit-bindgen", + "wasmtime-internal-component-util", + "wasmtime-internal-wit-bindgen", "wit-parser", ] [[package]] -name = "wasmtime-component-util" -version = "31.0.0" +name = "wasmtime-internal-component-util" +version = "36.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f292ef5eb2cf3d414c2bde59c7fa0feeba799c8db9a8c5a656ad1d1a1d05e10b" +checksum = "edc23d46ec1b1cd42b6f73205eb80498ed94b47098ec53456c0b18299405b158" [[package]] -name = "wasmtime-cranelift" -version = "31.0.0" +name = "wasmtime-internal-cranelift" +version = "36.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52fc12eb8ea695a30007a4849a5fd56209dd86a15579e92e0c27c27122818505" +checksum = "d85b8ba128525bff91b89ac8a97755136a4fb0fb59df5ffb7539dd646455d441" dependencies = [ "anyhow", "cfg-if", @@ -2354,116 +2408,134 @@ dependencies = [ "cranelift-entity", "cranelift-frontend", "cranelift-native", - "gimli 0.31.1", - "itertools 0.12.1", + "gimli 0.32.2", + "itertools 0.14.0", "log", - "object 0.36.7", + "object 0.37.3", "pulley-interpreter", "smallvec", "target-lexicon", - "thiserror", - "wasmparser 0.226.0", + "thiserror 2.0.16", + "wasmparser 0.236.1", "wasmtime-environ", - "wasmtime-versioned-export-macros", + "wasmtime-internal-math", + "wasmtime-internal-versioned-export-macros", ] [[package]] -name = "wasmtime-environ" -version = "31.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b6b4bf08e371edf262cccb62de10e214bd4aaafaa069f1cd49c9c1c3a5ae8e4" -dependencies = [ - "anyhow", - "cpp_demangle", - "cranelift-bitset", - "cranelift-entity", - "gimli 0.31.1", - "indexmap", - "log", - "object 0.36.7", - "postcard", - "rustc-demangle", - "semver", - "serde", - "serde_derive", - "smallvec", - "target-lexicon", - "wasm-encoder 0.226.0", - "wasmparser 0.226.0", - "wasmprinter 0.226.0", - "wasmtime-component-util", -] - -[[package]] -name = "wasmtime-fiber" -version = "31.0.0" +name = "wasmtime-internal-fiber" +version = "36.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4c8828d7d8fbe90d087a9edea9223315caf7eb434848896667e5d27889f1173" +checksum = "0c566f5137de1f55339df8a236a5ec89698b466a3d33f9cc07823a58a3f85e16" dependencies = [ "anyhow", "cc", "cfg-if", - "rustix", - "wasmtime-asm-macros", - "wasmtime-versioned-export-macros", - "windows-sys 0.59.0", + "libc", + "rustix 1.0.8", + "wasmtime-internal-asm-macros", + "wasmtime-internal-versioned-export-macros", + "windows-sys 0.60.2", ] [[package]] -name = "wasmtime-jit-debug" -version = "31.0.0" +name = "wasmtime-internal-jit-debug" +version = "36.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab9eff86dedd48b023199de2d266f5d3e37bc7c5bafdc1e3e3057214649ecf5a" +checksum = "e03f0b11f8fe4d456feac11e7e9dc6f02ddb34d4f6a1912775dbc63c5bdd5670" dependencies = [ "cc", - "object 0.36.7", - "rustix", - "wasmtime-versioned-export-macros", + "object 0.37.3", + "rustix 1.0.8", + "wasmtime-internal-versioned-export-macros", ] [[package]] -name = "wasmtime-jit-icache-coherence" -version = "31.0.0" +name = "wasmtime-internal-jit-icache-coherence" +version = "36.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a54f6c6c7e9d7eeee32dfcc10db7f29d505ee7dd28d00593ea241d5f70698e64" +checksum = "71aeb74f9b3fd9225319c723e59832a77a674b0c899ba9795f9b2130a6d1b167" dependencies = [ "anyhow", "cfg-if", "libc", - "windows-sys 0.59.0", + "windows-sys 0.60.2", ] [[package]] -name = "wasmtime-math" -version = "31.0.0" +name = "wasmtime-internal-math" +version = "36.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1108aad2e6965698f9207ea79b80eda2b3dcc57dcb69f4258296d4664ae32cd" +checksum = "31d5dad8a609c6cc47a5f265f13b52e347e893450a69641af082b8a276043fa7" dependencies = [ "libm", ] [[package]] -name = "wasmtime-slab" -version = "31.0.0" +name = "wasmtime-internal-slab" +version = "36.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84d6a321317281b721c5530ef733e8596ecc6065035f286ccd155b3fa8e0ab2f" +checksum = "6d152a7b875d62e395bfe0ae7d12e7b47cd332eb380353cce3eb831f9843731d" + +[[package]] +name = "wasmtime-internal-unwinder" +version = "36.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2aaacc0fea00293f7af7e6c25cef74b7d213ebbe7560c86305eec15fc318fab8" +dependencies = [ + "anyhow", + "cfg-if", + "cranelift-codegen", + "log", + "object 0.37.3", +] [[package]] -name = "wasmtime-versioned-export-macros" -version = "31.0.0" +name = "wasmtime-internal-versioned-export-macros" +version = "36.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5732a5c86efce7bca121a61d8c07875f6b85c1607aa86753b40f7f8bd9d3a780" +checksum = "c61c7f75326434944cc5f3b75409a063fa37e537f6247f00f0f733679f0be406" dependencies = [ "proc-macro2", "quote", "syn 2.0.98", ] +[[package]] +name = "wasmtime-internal-winch" +version = "36.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6cfbaa87e1ac4972bb096c9cb1800fedc113e36332cc4bc2c96a2ef1d7c5e750" +dependencies = [ + "anyhow", + "cranelift-codegen", + "gimli 0.32.2", + "object 0.37.3", + "target-lexicon", + "wasmparser 0.236.1", + "wasmtime-environ", + "wasmtime-internal-cranelift", + "winch-codegen", +] + +[[package]] +name = "wasmtime-internal-wit-bindgen" +version = "36.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "169042d58002f16da149ab7d608b71164411abd1fc5140f48f4c200b44bb5565" +dependencies = [ + "anyhow", + "bitflags 2.5.0", + "heck 0.5.0", + "indexmap", + "wit-parser", +] + [[package]] name = "wasmtime-wasi" -version = "31.0.0" +version = "36.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b425ede2633fade96bd624b6f35cea5f8be1995d149530882dbc35efbf1e31f" +checksum = "b9049a5fedcd24fa0f665ba7c17c4445c1a547536a9560d960e15bee2d8428d0" dependencies = [ "anyhow", "async-trait", @@ -2478,23 +2550,23 @@ dependencies = [ "futures", "io-extras", "io-lifetimes", - "rustix", + "rustix 1.0.8", "system-interface", - "thiserror", + "thiserror 2.0.16", "tokio", "tracing", "url", "wasmtime", "wasmtime-wasi-io", "wiggle", - "windows-sys 0.59.0", + "windows-sys 0.60.2", ] [[package]] name = "wasmtime-wasi-io" -version = "31.0.0" +version = "36.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2ec650d8891ec5ff823bdcefe3b370278becd1f33125bcfdcf628943dcde676" +checksum = "d62156d8695d80df8e85baeb56379b3ba6b6bf5996671594724c24d40b67825f" dependencies = [ "anyhow", "async-trait", @@ -2503,35 +2575,6 @@ dependencies = [ "wasmtime", ] -[[package]] -name = "wasmtime-winch" -version = "31.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3aa4741ee66a52e2f0ec5f79040017123ba47d2dff9d994b35879cc2b7f468d4" -dependencies = [ - "anyhow", - "cranelift-codegen", - "gimli 0.31.1", - "object 0.36.7", - "target-lexicon", - "wasmparser 0.226.0", - "wasmtime-cranelift", - "wasmtime-environ", - "winch-codegen", -] - -[[package]] -name = "wasmtime-wit-bindgen" -version = "31.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "505c13fa0cac6c43e805347acf1e916c8de54e3790f2c22873c5692964b09b62" -dependencies = [ - "anyhow", - "heck 0.5.0", - "indexmap", - "wit-parser", -] - [[package]] name = "wast" version = "35.0.2" @@ -2543,24 +2586,24 @@ dependencies = [ [[package]] name = "wast" -version = "228.0.0" +version = "238.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e5aae124478cb51439f6587f074a3a5e835afd22751c59a87b2e2a882727c97" +checksum = "8c671ea796336ebaa49b963adb14cf13cb98de4e64d69ed4a16ace8c7b4db87b" dependencies = [ "bumpalo", "leb128fmt", "memchr", "unicode-width 0.2.0", - "wasm-encoder 0.228.0", + "wasm-encoder 0.238.0", ] [[package]] name = "wat" -version = "1.228.0" +version = "1.238.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ec29c89a8d055df988de7236483bf569988ac3d6905899f6af5ef920f9385ad" +checksum = "8de04a6a9c93aaae4de7bec6323bf11f810457b479f9f877e80d212fd77ffdbc" dependencies = [ - "wast 228.0.0", + "wast 238.0.0", ] [[package]] @@ -2575,14 +2618,14 @@ dependencies = [ [[package]] name = "wiggle" -version = "31.0.0" +version = "36.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1dc9a83fe01faa51423fc84941cdbe0ec33ba1e9a75524a560a27a4ad1ff2c3b" +checksum = "e233166bc0ef02371ebe2c630aba51dd3f015bcaf616d32b4171efab84d09137" dependencies = [ "anyhow", "async-trait", "bitflags 2.5.0", - "thiserror", + "thiserror 2.0.16", "tracing", "wasmtime", "wiggle-macro", @@ -2590,24 +2633,23 @@ dependencies = [ [[package]] name = "wiggle-generate" -version = "31.0.0" +version = "36.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d250c01cd52cfdb40aad167fad579af55acbeccb85a54827099d31dc1b90cbd7" +checksum = "93048543902e61c65b75d8a9ea0e78d5a8723e5db6e11ff93870165807c4463d" dependencies = [ "anyhow", "heck 0.5.0", "proc-macro2", "quote", - "shellexpand", "syn 2.0.98", "witx", ] [[package]] name = "wiggle-macro" -version = "31.0.0" +version = "36.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35be0aee84be808a5e17f6b732e110eb75703d9d6e66e22c7464d841aa2600c5" +checksum = "fd7e511edbcaa045079dea564486c4ff7946ae491002227c41d74ea62a59d329" dependencies = [ "proc-macro2", "quote", @@ -2648,20 +2690,22 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "winch-codegen" -version = "31.0.0" +version = "36.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e02f05457f74ec3c94d5c5caac06b84fd8d9d4d7fa21419189845ed245a53477" +checksum = "6e615fe205d7d4c9aa62217862f2e0969d00b9b0843af0b1b8181adaea3cfef3" dependencies = [ "anyhow", + "cranelift-assembler-x64", "cranelift-codegen", - "gimli 0.31.1", + "gimli 0.32.2", "regalloc2", "smallvec", "target-lexicon", - "thiserror", - "wasmparser 0.226.0", - "wasmtime-cranelift", + "thiserror 2.0.16", + "wasmparser 0.236.1", "wasmtime-environ", + "wasmtime-internal-cranelift", + "wasmtime-internal-math", ] [[package]] @@ -2670,16 +2714,22 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" dependencies = [ - "windows-targets", + "windows-targets 0.52.6", ] +[[package]] +name = "windows-link" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e6ad25900d524eaabdbbb96d20b4311e1e7ae1699af4fb28c17ae66c80d798a" + [[package]] name = "windows-sys" version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets", + "windows-targets 0.52.6", ] [[package]] @@ -2688,7 +2738,16 @@ version = "0.59.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" dependencies = [ - "windows-targets", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-sys" +version = "0.60.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb" +dependencies = [ + "windows-targets 0.53.3", ] [[package]] @@ -2697,14 +2756,31 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_gnullvm", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", + "windows_i686_gnullvm 0.52.6", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", +] + +[[package]] +name = "windows-targets" +version = "0.53.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5fe6031c4041849d7c496a8ded650796e7b6ecc19df1a431c1a363342e5dc91" +dependencies = [ + "windows-link", + "windows_aarch64_gnullvm 0.53.0", + "windows_aarch64_msvc 0.53.0", + "windows_i686_gnu 0.53.0", + "windows_i686_gnullvm 0.53.0", + "windows_i686_msvc 0.53.0", + "windows_x86_64_gnu 0.53.0", + "windows_x86_64_gnullvm 0.53.0", + "windows_x86_64_msvc 0.53.0", ] [[package]] @@ -2713,48 +2789,96 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86b8d5f90ddd19cb4a147a5fa63ca848db3df085e25fee3cc10b39b6eebae764" + [[package]] name = "windows_aarch64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" +[[package]] +name = "windows_aarch64_msvc" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7651a1f62a11b8cbd5e0d42526e55f2c99886c77e007179efff86c2b137e66c" + [[package]] name = "windows_i686_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" +[[package]] +name = "windows_i686_gnu" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1dc67659d35f387f5f6c479dc4e28f1d4bb90ddd1a5d3da2e5d97b42d6272c3" + [[package]] name = "windows_i686_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" +[[package]] +name = "windows_i686_gnullvm" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ce6ccbdedbf6d6354471319e781c0dfef054c81fbc7cf83f338a4296c0cae11" + [[package]] name = "windows_i686_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" +[[package]] +name = "windows_i686_msvc" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "581fee95406bb13382d2f65cd4a908ca7b1e4c2f1917f143ba16efe98a589b5d" + [[package]] name = "windows_x86_64_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" +[[package]] +name = "windows_x86_64_gnu" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e55b5ac9ea33f2fc1716d1742db15574fd6fc8dadc51caab1c16a3d3b4190ba" + [[package]] name = "windows_x86_64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a6e035dd0599267ce1ee132e51c27dd29437f63325753051e71dd9e42406c57" + [[package]] name = "windows_x86_64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" +[[package]] +name = "windows_x86_64_msvc" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "271414315aff87387382ec3d271b52d7ae78726f5d44ac98b4f4030c91880486" + [[package]] name = "winnow" version = "0.6.5" @@ -2776,9 +2900,9 @@ dependencies = [ [[package]] name = "wit-parser" -version = "0.226.0" +version = "0.236.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33f007722bfd43a2978c5b8b90f02c927dddf0f11c5f5b50929816b3358718cd" +checksum = "16e4833a20cd6e85d6abfea0e63a399472d6f88c6262957c17f546879a80ba15" dependencies = [ "anyhow", "id-arena", @@ -2789,7 +2913,7 @@ dependencies = [ "serde_derive", "serde_json", "unicode-xid", - "wasmparser 0.226.0", + "wasmparser 0.236.1", ] [[package]] @@ -2800,7 +2924,7 @@ checksum = "e366f27a5cabcddb2706a78296a40b8fcc451e1a6aba2fc1d94b4a01bdaaef4b" dependencies = [ "anyhow", "log", - "thiserror", + "thiserror 1.0.58", "wast 35.0.2", ] @@ -2815,9 +2939,9 @@ dependencies = [ "log", "rayon", "structopt", - "wasm-encoder 0.228.0", - "wasmparser 0.228.0", - "wasmprinter 0.228.0", + "wasm-encoder 0.238.0", + "wasmparser 0.238.0", + "wasmprinter 0.238.0", "wasmtime", "wasmtime-wasi", "wat", @@ -2831,7 +2955,7 @@ dependencies = [ "libfuzzer-sys", "log", "wasm-smith", - "wasmprinter 0.228.0", + "wasmprinter 0.238.0", "wasmtime", "wizer", ] diff --git a/crates/wizer/Cargo.toml b/crates/wizer/Cargo.toml index 1ac331813b06..1670a25f89be 100644 --- a/crates/wizer/Cargo.toml +++ b/crates/wizer/Cargo.toml @@ -33,8 +33,8 @@ env_logger = { version = "0.11.8", optional = true } log = "0.4.27" rayon = "1.10.0" structopt = { version = "0.3.26", optional = true } -wasm-encoder = "0.228.0" -wasmparser = "0.228.0" +wasm-encoder = "0.238.0" +wasmparser = "0.238.0" wasmtime = { workspace = true } wasmtime-wasi = { workspace = true, features = ["preview1"] } @@ -45,15 +45,15 @@ workspace = true optional = true [workspace.dependencies] -wasmprinter = "0.228.0" -wasmtime = "31" -wasmtime-wasi = "31" +wasmprinter = "0.238.0" +wasmtime = "36" +wasmtime-wasi = "36" [dev-dependencies] criterion = "0.5.1" env_logger = "0.11.8" wasmprinter = { workspace = true } -wat = "1.228.0" +wat = "1.238.0" [workspace] members = [ diff --git a/crates/wizer/fuzz/fuzz_targets/same_result.rs b/crates/wizer/fuzz/fuzz_targets/same_result.rs index 76a58ce5492f..f4b9bb09f3e6 100644 --- a/crates/wizer/fuzz/fuzz_targets/same_result.rs +++ b/crates/wizer/fuzz/fuzz_targets/same_result.rs @@ -74,7 +74,9 @@ fuzz_target!(|data: &[u8]| { } let mut config = Config::new(); - config.cache_config_load_default().unwrap(); + wasmtime::Cache::from_file(None) + .map(|cache| config.cache(Some(cache))) + .unwrap(); config.wasm_multi_memory(true); config.wasm_multi_value(true); diff --git a/crates/wizer/src/lib.rs b/crates/wizer/src/lib.rs index 05898b71cd4e..61d4d814ae2d 100644 --- a/crates/wizer/src/lib.rs +++ b/crates/wizer/src/lib.rs @@ -648,7 +648,7 @@ impl Wizer { // Enable Wasmtime's code cache. This makes it so that repeated // wizenings of the same Wasm module (e.g. with different WASI inputs) // doesn't require re-compiling the Wasm to native code every time. - config.cache_config_load_default()?; + wasmtime::Cache::from_file(None).map(|cache| config.cache(Some(cache)))?; // Proposals we support. config.wasm_multi_memory(self.wasm_multi_memory.unwrap_or(DEFAULT_WASM_MULTI_MEMORY)); diff --git a/crates/wizer/src/rewrite.rs b/crates/wizer/src/rewrite.rs index 637913e67d7d..fbf39d7d7888 100644 --- a/crates/wizer/src/rewrite.rs +++ b/crates/wizer/src/rewrite.rs @@ -91,8 +91,12 @@ impl Wizer { &match val { wasmtime::Val::I32(x) => ConstExpr::i32_const(*x), wasmtime::Val::I64(x) => ConstExpr::i64_const(*x), - wasmtime::Val::F32(x) => ConstExpr::f32_const(f32::from_bits(*x)), - wasmtime::Val::F64(x) => ConstExpr::f64_const(f64::from_bits(*x)), + wasmtime::Val::F32(x) => { + ConstExpr::f32_const(wasm_encoder::Ieee32::new(*x)) + } + wasmtime::Val::F64(x) => { + ConstExpr::f64_const(wasm_encoder::Ieee64::new(*x)) + } wasmtime::Val::V128(x) => { ConstExpr::v128_const(x.as_u128() as i128) } diff --git a/crates/wizer/tests/make_linker.rs b/crates/wizer/tests/make_linker.rs index 195b6034721c..8147692a065b 100644 --- a/crates/wizer/tests/make_linker.rs +++ b/crates/wizer/tests/make_linker.rs @@ -31,7 +31,9 @@ fn run_wasm(args: &[wasmtime::Val], expected: i32, wasm: &[u8]) -> Result<()> { } let mut config = wasmtime::Config::new(); - config.cache_config_load_default().unwrap(); + wasmtime::Cache::from_file(None) + .map(|cache| config.cache(Some(cache))) + .unwrap(); config.wasm_multi_memory(true); config.wasm_multi_value(true); diff --git a/crates/wizer/tests/tests.rs b/crates/wizer/tests/tests.rs index 7a9bbc51a765..a6ea92e0611e 100644 --- a/crates/wizer/tests/tests.rs +++ b/crates/wizer/tests/tests.rs @@ -44,7 +44,9 @@ fn wizen_and_run_wasm( } let mut config = wasmtime::Config::new(); - config.cache_config_load_default().unwrap(); + wasmtime::Cache::from_file(None) + .map(|cache| config.cache(Some(cache))) + .unwrap(); config.wasm_multi_memory(true); config.wasm_multi_value(true); From a94726c93dcbf5120dd717e4bf93cf5a6983d858 Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Wed, 27 Aug 2025 11:28:31 -0700 Subject: [PATCH 211/212] Bump to version 10.0.0 (#137) --- crates/wizer/Cargo.lock | 2 +- crates/wizer/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/wizer/Cargo.lock b/crates/wizer/Cargo.lock index bce1de50a6ff..5414c76b34a1 100644 --- a/crates/wizer/Cargo.lock +++ b/crates/wizer/Cargo.lock @@ -2930,7 +2930,7 @@ dependencies = [ [[package]] name = "wizer" -version = "9.0.0" +version = "10.0.0" dependencies = [ "anyhow", "cap-std", diff --git a/crates/wizer/Cargo.toml b/crates/wizer/Cargo.toml index 1670a25f89be..2d0836b750b2 100644 --- a/crates/wizer/Cargo.toml +++ b/crates/wizer/Cargo.toml @@ -10,7 +10,7 @@ license = "Apache-2.0 WITH LLVM-exception" name = "wizer" readme = "./README.md" repository = "https://github.com/bytecodealliance/wizer" -version = "9.0.0" +version = "10.0.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html From 19c3380b988d9d57ad7a650fcf30a71e6f878ec7 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 8 Oct 2025 08:14:23 -0700 Subject: [PATCH 212/212] Ignore wizer subdirectory for now prtest:full --- Cargo.toml | 1 + crates/wizer/benches/uap-bench/uap-core | 1 - crates/wizer/examples/cpp/main.cpp | 34 +++++------ crates/wizer/include/wizer.h | 80 ++++++++++++------------- scripts/publish.rs | 6 ++ 5 files changed, 63 insertions(+), 59 deletions(-) delete mode 160000 crates/wizer/benches/uap-bench/uap-core diff --git a/Cargo.toml b/Cargo.toml index 4dddc77a3595..9129c2529602 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -172,6 +172,7 @@ members = [ ] exclude = [ 'docs/rust_wasi_markdown_parser', + 'crates/wizer', ] [workspace.package] diff --git a/crates/wizer/benches/uap-bench/uap-core b/crates/wizer/benches/uap-bench/uap-core deleted file mode 160000 index f21592418f63..000000000000 --- a/crates/wizer/benches/uap-bench/uap-core +++ /dev/null @@ -1 +0,0 @@ -Subproject commit f21592418f6323f9ce32f10e231841cf8e782b43 diff --git a/crates/wizer/examples/cpp/main.cpp b/crates/wizer/examples/cpp/main.cpp index 6bf27571311f..86d1c00072e3 100644 --- a/crates/wizer/examples/cpp/main.cpp +++ b/crates/wizer/examples/cpp/main.cpp @@ -2,15 +2,12 @@ #include class Test { - public: - Test() : value(1) { - printf( - "global constructor (should be the first printed line)\n"); - } - ~Test() { - printf("global destructor (should be the last printed line)\n"); - } - int value; +public: + Test() : value(1) { + printf("global constructor (should be the first printed line)\n"); + } + ~Test() { printf("global destructor (should be the last printed line)\n"); } + int value; }; bool initialized = false; @@ -18,17 +15,18 @@ int orig_value = 0; Test t; static void init_func() { - // This should run after the ctor for `t`, and before `main`. - orig_value = t.value; - t.value = 2; - initialized = true; + // This should run after the ctor for `t`, and before `main`. + orig_value = t.value; + t.value = 2; + initialized = true; } WIZER_INIT(init_func); -int main(int argc, char** argv) { - if (!initialized) init_func(); - printf("argc (should not be baked into snapshot): %d\n", argc); - printf("orig_value (should be 1): %d\n", orig_value); - printf("t.value (should be 2): %d\n", t.value); +int main(int argc, char **argv) { + if (!initialized) + init_func(); + printf("argc (should not be baked into snapshot): %d\n", argc); + printf("orig_value (should be 1): %d\n", orig_value); + printf("t.value (should be 2): %d\n", t.value); } diff --git a/crates/wizer/include/wizer.h b/crates/wizer/include/wizer.h index 5492c0ec379c..b138a5e27b4c 100644 --- a/crates/wizer/include/wizer.h +++ b/crates/wizer/include/wizer.h @@ -23,7 +23,8 @@ // // wasi-sdk-17 ships with clang-15.0.6 // wasi-sdk-16 ships with clang-14.0.4 -#if __clang_major__ >= 15 || (__clang_major__ == 14 && __clang_patchlevel__ == 4) +#if __clang_major__ >= 15 || \ + (__clang_major__ == 14 && __clang_patchlevel__ == 4) #define WIZER_MAIN_VOID __main_void #else #define WIZER_MAIN_VOID __original_main @@ -82,42 +83,41 @@ * should be run), use `WIZER_DEFAULT_INIT()` instead. */ #define WIZER_INIT(init_func) \ - __WIZER_EXTERN_C void __wasm_call_ctors(); \ - __WIZER_EXTERN_C void __wasm_call_dtors(); \ - __WIZER_EXTERN_C void __wasi_proc_exit(int); \ - __WIZER_EXTERN_C int WIZER_MAIN_VOID(); \ - /* This function's export name `wizer.initialize` is specially */ \ - /* recognized by Wizer. It is the direct entry point for pre-init. */ \ - __attribute__((export_name("wizer.initialize"))) void \ - __wizer_initialize() { \ - /* `__wasm_call_ctors()` is generated by `wasm-ld` and invokes all */ \ - /* of the global constructors. It is safe (and in fact necessary) */ \ - /* to manually invoke it here because `wizer.initialize` is the */ \ - /* direct entry point, and no libc startup (crt1.o or equivalent) */ \ - /* is executed before this code does. */ \ - __wasm_call_ctors(); \ - /* We now invoke the provided init function before returning. */ \ - init_func(); \ + __WIZER_EXTERN_C void __wasm_call_ctors(); \ + __WIZER_EXTERN_C void __wasm_call_dtors(); \ + __WIZER_EXTERN_C void __wasi_proc_exit(int); \ + __WIZER_EXTERN_C int WIZER_MAIN_VOID(); \ + /* This function's export name `wizer.initialize` is specially */ \ + /* recognized by Wizer. It is the direct entry point for pre-init. */ \ + __attribute__((export_name("wizer.initialize"))) void __wizer_initialize() { \ + /* `__wasm_call_ctors()` is generated by `wasm-ld` and invokes all */ \ + /* of the global constructors. It is safe (and in fact necessary) */ \ + /* to manually invoke it here because `wizer.initialize` is the */ \ + /* direct entry point, and no libc startup (crt1.o or equivalent) */ \ + /* is executed before this code does. */ \ + __wasm_call_ctors(); \ + /* We now invoke the provided init function before returning. */ \ + init_func(); \ + } \ + /* This function replaces `_start` (the WASI-specified entry point) in */ \ + /* the pre-initialized Wasm module. */ \ + __attribute__((export_name("wizer.resume"))) void __wizer_resume() { \ + /* `__main_void()` is defined by the WASI SDK toolchain due to */ \ + /* special semantics in C/C++ for the `main()` function, i.e., ito */ \ + /* can either take argc/argv or not. It collects arguments using */ \ + /* the appropriate WASI calls and then invokes the user program's */ \ + /* `main()`. This may change in the future; when it does, we will */ \ + /* coordinate with the WASI-SDK toolchain to implement this entry */ \ + /* point in an alternate way. */ \ + int r = WIZER_MAIN_VOID(); \ + /* Because we are replacing `_start()`, we need to manually invoke */ \ + /* destructors as well. */ \ + __wasm_call_dtors(); \ + /* If main returned non-zero code, call `__wasi_proc_exit`. */ \ + if (r != 0) { \ + __wasi_proc_exit(r); \ } \ - /* This function replaces `_start` (the WASI-specified entry point) in */ \ - /* the pre-initialized Wasm module. */ \ - __attribute__((export_name("wizer.resume"))) void __wizer_resume() { \ - /* `__main_void()` is defined by the WASI SDK toolchain due to */ \ - /* special semantics in C/C++ for the `main()` function, i.e., ito */ \ - /* can either take argc/argv or not. It collects arguments using */ \ - /* the appropriate WASI calls and then invokes the user program's */ \ - /* `main()`. This may change in the future; when it does, we will */ \ - /* coordinate with the WASI-SDK toolchain to implement this entry */ \ - /* point in an alternate way. */ \ - int r = WIZER_MAIN_VOID(); \ - /* Because we are replacing `_start()`, we need to manually invoke */ \ - /* destructors as well. */ \ - __wasm_call_dtors(); \ - /* If main returned non-zero code, call `__wasi_proc_exit`. */ \ - if (r != 0) { \ - __wasi_proc_exit(r); \ - } \ - } + } /* * This macro is like `WIZER_INIT()`, but takes no initialization function. @@ -126,8 +126,8 @@ * * See documentation for `WIZER_INIT()` for more details and usage instructions. */ -#define WIZER_DEFAULT_INIT() \ - static void __empty_init() {} \ - WIZER_INIT(__empty_init) +#define WIZER_DEFAULT_INIT() \ + static void __empty_init() {} \ + WIZER_INIT(__empty_init) -#endif // _WIZER_H_ +#endif // _WIZER_H_ diff --git a/scripts/publish.rs b/scripts/publish.rs index c9f8feea6404..0d410336a632 100644 --- a/scripts/publish.rs +++ b/scripts/publish.rs @@ -244,6 +244,12 @@ fn run_cmd(cmd: &mut Command) { } fn find_crates(dir: &Path, ws: &Workspace, dst: &mut Vec) { + // Temporary exclusion of Wizer to get reverted in #11805 with full Wizer + // integration. + if dir.ends_with("wizer") { + return; + } + if dir.join("Cargo.toml").exists() { let krate = read_crate(Some(ws), &dir.join("Cargo.toml")); if !krate.publish || CRATES_TO_PUBLISH.iter().any(|c| krate.name == *c) {