diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 074de2b47a..4c8193198d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -49,6 +49,8 @@ jobs: doc_api: name: Doc - build the API documentation runs-on: ubuntu-latest + env: + RUSTDOCFLAGS: -Dintra-doc-link-resolution-failure steps: - uses: actions/checkout@v2 with: diff --git a/Cargo.lock b/Cargo.lock index f3820ae53b..31c4c940d7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -595,7 +595,7 @@ dependencies = [ "serde", "target-lexicon", "thiserror", - "wasmparser 0.57.0", + "wasmparser 0.58.0", "wat", ] @@ -1123,7 +1123,7 @@ dependencies = [ "staticvec", "thiserror", "typemap", - "wasmparser 0.57.0", + "wasmparser 0.58.0", "wat", ] @@ -1338,6 +1338,7 @@ dependencies = [ "peepmatic-automata", "peepmatic-macro", "serde", + "serde_test", "thiserror", "wast 15.0.0", ] @@ -1881,6 +1882,15 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_test" +version = "1.0.114" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f58190d074af17bd48118303db08afadbd506bc2ba511b4582cebd8f882a9b8d" +dependencies = [ + "serde", +] + [[package]] name = "sha2" version = "0.8.2" @@ -2299,9 +2309,9 @@ checksum = "af931e2e1960c53f4a28b063fec4cacd036f35acbec8ff3a4739125b17382a87" [[package]] name = "wasmparser" -version = "0.57.0" +version = "0.58.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32fddd575d477c6e9702484139cf9f23dcd554b06d185ed0f56c857dd3a47aa6" +checksum = "721a8d79483738d7aef6397edcf8f04cd862640b1ad5973adf5bb50fc10e86db" [[package]] name = "wasmprinter" @@ -2327,7 +2337,7 @@ dependencies = [ "rustc-demangle", "target-lexicon", "tempfile", - "wasmparser 0.57.0", + "wasmparser 0.58.0", "wasmtime-environ", "wasmtime-jit", "wasmtime-profiling", @@ -2400,7 +2410,7 @@ dependencies = [ "object 0.19.0", "target-lexicon", "thiserror", - "wasmparser 0.57.0", + "wasmparser 0.58.0", "wasmtime-environ", ] @@ -2431,7 +2441,7 @@ dependencies = [ "tempfile", "thiserror", "toml", - "wasmparser 0.57.0", + "wasmparser 0.58.0", "winapi", "zstd", ] @@ -2460,7 +2470,7 @@ dependencies = [ "env_logger", "log", "rayon", - "wasmparser 0.57.0", + "wasmparser 0.58.0", "wasmprinter", "wasmtime", "wasmtime-wast", @@ -2484,7 +2494,7 @@ dependencies = [ "region", "target-lexicon", "thiserror", - "wasmparser 0.57.0", + "wasmparser 0.58.0", "wasmtime-debug", "wasmtime-environ", "wasmtime-profiling", @@ -2770,9 +2780,9 @@ dependencies = [ [[package]] name = "z3" -version = "0.5.1" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ded00cd90f8e3a7ea3155bddd72573f2b099ea201877542d924e47b58dd04e72" +checksum = "f0354c65dfe00e08c4ab30581732906874f97156f424bfb390cf0cca2cb6ac29" dependencies = [ "lazy_static", "log", @@ -2781,9 +2791,9 @@ dependencies = [ [[package]] name = "z3-sys" -version = "0.6.1" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4002d8a1facb54d02dbfb86151281e5450618ab330936bc2f3acaab31eae11ae" +checksum = "e1863cafae8eb86dd7d69c9218421b288594e8836346e93d4f36ade427195a21" dependencies = [ "cmake", ] diff --git a/build.rs b/build.rs index 5ea2345fdb..848420aaa8 100644 --- a/build.rs +++ b/build.rs @@ -205,11 +205,6 @@ fn ignore(testsuite: &str, testname: &str, strategy: &str) -> bool { ("simd", "simd_i16x8_arith2") => return true, ("simd", "simd_i8x16_arith2") => return true, - // waiting for the upstream spec to get updated with new binary - // encodings of operations and for that to propagate to the - // testsuite repo. - ("simd", "simd_const") => return true, - ("reference_types", "table_copy_on_imported_tables") | ("reference_types", "externref_id_function") | ("reference_types", "table_size") diff --git a/cranelift/codegen/src/ir/extfunc.rs b/cranelift/codegen/src/ir/extfunc.rs index e2f2bb984b..9bb089fd56 100644 --- a/cranelift/codegen/src/ir/extfunc.rs +++ b/cranelift/codegen/src/ir/extfunc.rs @@ -383,7 +383,7 @@ pub struct ExtFuncData { /// flag is best used when the target is known to be in the same unit of code generation, such /// as a Wasm module. /// - /// See the documentation for [`RelocDistance`](machinst::RelocDistance) for more details. A + /// See the documentation for [`RelocDistance`](crate::machinst::RelocDistance) for more details. A /// `colocated` flag value of `true` implies `RelocDistance::Near`. pub colocated: bool, } diff --git a/cranelift/codegen/src/ir/globalvalue.rs b/cranelift/codegen/src/ir/globalvalue.rs index dae869445c..6c9b2d7bcf 100644 --- a/cranelift/codegen/src/ir/globalvalue.rs +++ b/cranelift/codegen/src/ir/globalvalue.rs @@ -66,7 +66,7 @@ pub enum GlobalValueData { /// /// If `true`, some backends may use relocation forms that have limited range: for example, /// a +/- 2^27-byte range on AArch64. See the documentation for - /// [`RelocDistance`](machinst::RelocDistance) for more details. + /// [`RelocDistance`](crate::machinst::RelocDistance) for more details. colocated: bool, /// Does this symbol refer to a thread local storage value? diff --git a/cranelift/codegen/src/isa/aarch64/abi.rs b/cranelift/codegen/src/isa/aarch64/abi.rs index ed12ed0365..9a4f64896e 100644 --- a/cranelift/codegen/src/isa/aarch64/abi.rs +++ b/cranelift/codegen/src/isa/aarch64/abi.rs @@ -86,9 +86,9 @@ //! formal arguments, would: //! - Accept a pointer P to the struct return area in x0 on entry. //! - Return v3 in x0. -//! - Return v2 in memory at [P]. -//! - Return v1 in memory at [P+8]. -//! - Return v0 in memory at [P+16]. +//! - Return v2 in memory at `[P]`. +//! - Return v1 in memory at `[P+8]`. +//! - Return v0 in memory at `[P+16]`. use crate::ir; use crate::ir::types; diff --git a/cranelift/codegen/src/machinst/buffer.rs b/cranelift/codegen/src/machinst/buffer.rs index 4d9bc828f8..5f54b1ba77 100644 --- a/cranelift/codegen/src/machinst/buffer.rs +++ b/cranelift/codegen/src/machinst/buffer.rs @@ -12,13 +12,13 @@ //! from the branch itself. //! //! - The lowering of control flow from the CFG-with-edges produced by -//! [BlockLoweringOrder], combined with many empty edge blocks when the register -//! allocator does not need to insert any spills/reloads/moves in edge blocks, -//! results in many suboptimal branch patterns. The lowering also pays no -//! attention to block order, and so two-target conditional forms (cond-br -//! followed by uncond-br) can often by avoided because one of the targets is -//! the fallthrough. There are several cases here where we can simplify to use -//! fewer branches. +//! [BlockLoweringOrder](super::BlockLoweringOrder), combined with many empty +//! edge blocks when the register allocator does not need to insert any +//! spills/reloads/moves in edge blocks, results in many suboptimal branch +//! patterns. The lowering also pays no attention to block order, and so +//! two-target conditional forms (cond-br followed by uncond-br) can often by +//! avoided because one of the targets is the fallthrough. There are several +//! cases here where we can simplify to use fewer branches. //! //! This "buffer" implements a single-pass code emission strategy (with a later //! "fixup" pass, but only through recorded fixups, not all instructions). The @@ -41,7 +41,7 @@ //! by the emitter (e.g., vcode iterating over instruction structs). The emitter //! has some awareness of this: it either asks for an island between blocks, so //! it is not accidentally executed, or else it emits a branch around the island -//! when all other options fail (see [Inst::EmitIsland] meta-instruction). +//! when all other options fail (see `Inst::EmitIsland` meta-instruction). //! //! - A "veneer" is an instruction (or sequence of instructions) in an "island" //! that implements a longer-range reference to a label. The idea is that, for diff --git a/cranelift/codegen/src/preopt.serialized b/cranelift/codegen/src/preopt.serialized index f016c6d32d..bae915dab0 100644 Binary files a/cranelift/codegen/src/preopt.serialized and b/cranelift/codegen/src/preopt.serialized differ diff --git a/cranelift/filetests/src/function_runner.rs b/cranelift/filetests/src/function_runner.rs index 69ad26029b..d195697246 100644 --- a/cranelift/filetests/src/function_runner.rs +++ b/cranelift/filetests/src/function_runner.rs @@ -39,7 +39,8 @@ pub struct SingleFunctionCompiler { impl SingleFunctionCompiler { /// Build a [SingleFunctionCompiler] from a [TargetIsa]. For functions to be runnable on the - /// host machine, this [TargetISA] must match the host machine's ISA (see [with_host_isa]). + /// host machine, this [TargetIsa] must match the host machine's ISA (see + /// [SingleFunctionCompiler::with_host_isa]). pub fn new(isa: Box) -> Self { let trampolines = HashMap::new(); Self { isa, trampolines } diff --git a/cranelift/filetests/src/test_interpret.rs b/cranelift/filetests/src/test_interpret.rs index ccde4a0084..1545022375 100644 --- a/cranelift/filetests/src/test_interpret.rs +++ b/cranelift/filetests/src/test_interpret.rs @@ -1,6 +1,7 @@ //! Test command for interpreting CLIF files and verifying their results //! -//! The `interpret` test command interprets each function on the host machine using [RunCommand]s. +//! The `interpret` test command interprets each function on the host machine +//! using [RunCommand](cranelift_reader::RunCommand)s. use crate::subtest::{Context, SubTest, SubtestResult}; use cranelift_codegen::{self, ir}; diff --git a/cranelift/peepmatic/Cargo.toml b/cranelift/peepmatic/Cargo.toml index 3171153c74..084374951d 100644 --- a/cranelift/peepmatic/Cargo.toml +++ b/cranelift/peepmatic/Cargo.toml @@ -14,4 +14,4 @@ peepmatic-automata = { version = "0.2.0", path = "crates/automata", features = [ peepmatic-macro = { version = "0.2.0", path = "crates/macro" } peepmatic-runtime = { version = "0.2.0", path = "crates/runtime", features = ["construct"] } wast = "15.0.0" -z3 = { version = "0.5.1", features = ["static-link-z3"] } +z3 = { version = "0.6.0", features = ["static-link-z3"] } diff --git a/cranelift/peepmatic/crates/runtime/Cargo.toml b/cranelift/peepmatic/crates/runtime/Cargo.toml index 75b73388dd..fe21c3defd 100644 --- a/cranelift/peepmatic/crates/runtime/Cargo.toml +++ b/cranelift/peepmatic/crates/runtime/Cargo.toml @@ -18,6 +18,8 @@ serde = { version = "1.0.105", features = ["derive"] } thiserror = "1.0.15" wast = { version = "15.0.0", optional = true } +[dev-dependencies] +serde_test = "1.0.114" [features] # Enable support for a few extra methods that are required by the `peepmatic` diff --git a/cranelift/peepmatic/crates/runtime/src/integer_interner.rs b/cranelift/peepmatic/crates/runtime/src/integer_interner.rs index 996100a66d..035027c2a2 100644 --- a/cranelift/peepmatic/crates/runtime/src/integer_interner.rs +++ b/cranelift/peepmatic/crates/runtime/src/integer_interner.rs @@ -5,8 +5,12 @@ //! few compared to the full range of `u64`) integers we are matching against //! here and then reference them by `IntegerId`. +use serde::de::{Deserializer, SeqAccess, Visitor}; +use serde::ser::{SerializeSeq, Serializer}; use serde::{Deserialize, Serialize}; use std::collections::BTreeMap; +use std::fmt; +use std::marker::PhantomData; use std::num::{NonZeroU16, NonZeroU32}; /// An identifier for an interned integer. @@ -14,7 +18,7 @@ use std::num::{NonZeroU16, NonZeroU32}; pub struct IntegerId(#[doc(hidden)] pub NonZeroU16); /// An interner for integer values. -#[derive(Debug, Default, Serialize, Deserialize)] +#[derive(Debug, Default)] pub struct IntegerInterner { // Note: we use `BTreeMap`s for deterministic serialization. map: BTreeMap, @@ -71,3 +75,118 @@ impl From for NonZeroU32 { id.0.into() } } + +impl Serialize for IntegerInterner { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + let mut seq = serializer.serialize_seq(Some(self.values.len()))?; + for p in &self.values { + seq.serialize_element(&p)?; + } + seq.end() + } +} + +impl<'de> Deserialize<'de> for IntegerInterner { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + deserializer.deserialize_seq(IntegerInternerVisitor { + marker: PhantomData, + }) + } +} + +struct IntegerInternerVisitor { + marker: PhantomData IntegerInterner>, +} + +impl<'de> Visitor<'de> for IntegerInternerVisitor { + type Value = IntegerInterner; + + fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + write!( + formatter, + "a `peepmatic_runtime::integer_interner::IntegerInterner`" + ) + } + + fn visit_seq(self, mut access: M) -> Result + where + M: SeqAccess<'de>, + { + const DEFAULT_CAPACITY: usize = 16; + let capacity = access.size_hint().unwrap_or(DEFAULT_CAPACITY); + + let mut interner = IntegerInterner { + map: BTreeMap::new(), + values: Vec::with_capacity(capacity), + }; + + while let Some(path) = access.next_element::()? { + interner.intern(path); + } + + Ok(interner) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use serde_test::{assert_tokens, Token}; + use std::iter::successors; + + #[derive(Debug, Serialize, Deserialize)] + #[serde(transparent)] + pub struct OrderedIntegerInterner(IntegerInterner); + + impl PartialEq for OrderedIntegerInterner { + fn eq(&self, other: &OrderedIntegerInterner) -> bool { + self.0.values.iter().eq(other.0.values.iter()) + } + } + + fn intern_fib(interner: &mut IntegerInterner, skip: usize, take: usize) { + successors(Some((0, 1)), |(a, b): &(u64, u64)| { + a.checked_add(*b).map(|c| (*b, c)) + }) + .skip(skip) + .take(take) + .for_each(|(i, _)| { + interner.intern(i); + }) + } + + #[test] + fn test_ser_de_empty_interner() { + let interner = IntegerInterner::new(); + + assert_tokens( + &OrderedIntegerInterner(interner), + &[Token::Seq { len: Some(0) }, Token::SeqEnd], + ); + } + + #[test] + fn test_ser_de_fibonacci_interner() { + let mut interner = IntegerInterner::new(); + intern_fib(&mut interner, 10, 5); + + assert_tokens( + &OrderedIntegerInterner(interner), + &[ + Token::Seq { len: Some(5) }, + Token::U64(55), + Token::U64(89), + Token::U64(144), + Token::U64(233), + Token::U64(377), + Token::SeqEnd, + ], + ); + } +} diff --git a/cranelift/peepmatic/crates/runtime/src/optimizer.rs b/cranelift/peepmatic/crates/runtime/src/optimizer.rs index 3830a248bf..589c3f7761 100644 --- a/cranelift/peepmatic/crates/runtime/src/optimizer.rs +++ b/cranelift/peepmatic/crates/runtime/src/optimizer.rs @@ -16,7 +16,7 @@ use std::num::NonZeroU32; /// optimizations to instructions. /// /// These are created from a set of peephole optimizations with the -/// [`PeepholeOptimizer::instance`][crate::PeepholeOptimizer::instance] method. +/// [`PeepholeOptimizations::optimizer`] method. /// /// Reusing an instance when applying peephole optimizations to different /// instruction sequences means that you reuse internal allocations that are diff --git a/cranelift/peepmatic/src/verify.rs b/cranelift/peepmatic/src/verify.rs index 03865458ca..53970e9070 100644 --- a/cranelift/peepmatic/src/verify.rs +++ b/cranelift/peepmatic/src/verify.rs @@ -255,7 +255,7 @@ impl<'a> TypingContext<'a> { let is_void = self.is_void(&root_ty); let is_cpu_flags = self.is_cpu_flags(&root_ty); self.constraints.push(( - is_int.or(&[&is_bool, &is_void, &is_cpu_flags]), + z3::ast::Bool::or(&self.z3, &[&is_int, &is_bool, &is_void, &is_cpu_flags]), span, Some( "the root of an optimization must be an integer, a boolean, void, or CPU flags" @@ -719,7 +719,7 @@ impl<'a> TypingContextTrait<'a> for TypingContext<'a> { .as_bool() .unwrap(); self.constraints.push(( - is_int.or(&[&is_bool]), + z3::ast::Bool::or(&self.z3, &[&is_int, &is_bool]), span, Some("type error: must be either an int or a bool type".into()), )); diff --git a/cranelift/wasm/Cargo.toml b/cranelift/wasm/Cargo.toml index 2149d6f8b7..4e8034979f 100644 --- a/cranelift/wasm/Cargo.toml +++ b/cranelift/wasm/Cargo.toml @@ -12,7 +12,7 @@ keywords = ["webassembly", "wasm"] edition = "2018" [dependencies] -wasmparser = { version = "0.57.0", default-features = false } +wasmparser = { version = "0.58.0", default-features = false } cranelift-codegen = { path = "../codegen", version = "0.65.0", default-features = false } cranelift-entity = { path = "../entity", version = "0.65.0" } cranelift-frontend = { path = "../frontend", version = "0.65.0", default-features = false } diff --git a/cranelift/wasm/src/code_translator.rs b/cranelift/wasm/src/code_translator.rs index b2df7bb853..9a55e772f1 100644 --- a/cranelift/wasm/src/code_translator.rs +++ b/cranelift/wasm/src/code_translator.rs @@ -1575,7 +1575,10 @@ pub fn translate_operator( | Operator::I32x4WidenLowI16x8S { .. } | Operator::I32x4WidenHighI16x8S { .. } | Operator::I32x4WidenLowI16x8U { .. } - | Operator::I32x4WidenHighI16x8U { .. } => { + | Operator::I32x4WidenHighI16x8U { .. } + | Operator::I8x16Bitmask + | Operator::I16x8Bitmask + | Operator::I32x4Bitmask => { return Err(wasm_unsupported!("proposed SIMD operator {:?}", op)); } @@ -2007,7 +2010,8 @@ fn type_of(operator: &Operator) -> Type { | Operator::I8x16MinU | Operator::I8x16MaxS | Operator::I8x16MaxU - | Operator::I8x16RoundingAverageU => I8X16, + | Operator::I8x16RoundingAverageU + | Operator::I8x16Bitmask => I8X16, Operator::I16x8Splat | Operator::V16x8LoadSplat { .. } @@ -2041,7 +2045,8 @@ fn type_of(operator: &Operator) -> Type { | Operator::I16x8MaxS | Operator::I16x8MaxU | Operator::I16x8RoundingAverageU - | Operator::I16x8Mul => I16X8, + | Operator::I16x8Mul + | Operator::I16x8Bitmask => I16X8, Operator::I32x4Splat | Operator::V32x4LoadSplat { .. } @@ -2071,7 +2076,8 @@ fn type_of(operator: &Operator) -> Type { | Operator::I32x4MaxS | Operator::I32x4MaxU | Operator::F32x4ConvertI32x4S - | Operator::F32x4ConvertI32x4U => I32X4, + | Operator::F32x4ConvertI32x4U + | Operator::I32x4Bitmask => I32X4, Operator::I64x2Splat | Operator::V64x2LoadSplat { .. } diff --git a/cranelift/wasm/src/module_translator.rs b/cranelift/wasm/src/module_translator.rs index e31e6f09f8..d34a2c1557 100644 --- a/cranelift/wasm/src/module_translator.rs +++ b/cranelift/wasm/src/module_translator.rs @@ -71,6 +71,11 @@ pub fn translate_module<'data>( environ.reserve_passive_data(count)?; } + SectionContent::Module(_) + | SectionContent::ModuleCode(_) + | SectionContent::Instance(_) + | SectionContent::Alias(_) => unimplemented!("module linking not implemented yet"), + SectionContent::Custom { name, binary, diff --git a/cranelift/wasm/src/sections_translator.rs b/cranelift/wasm/src/sections_translator.rs index 3ae2be1b29..5eb7272662 100644 --- a/cranelift/wasm/src/sections_translator.rs +++ b/cranelift/wasm/src/sections_translator.rs @@ -26,7 +26,7 @@ use wasmparser::{ ElementKind, ElementSectionReader, Export, ExportSectionReader, ExternalKind, FunctionSectionReader, GlobalSectionReader, GlobalType, ImportSectionEntryType, ImportSectionReader, MemorySectionReader, MemoryType, NameSectionReader, Naming, NamingReader, - Operator, TableSectionReader, Type, TypeSectionReader, + Operator, TableSectionReader, Type, TypeDef, TypeSectionReader, }; /// Parses the Type section of the wasm module. @@ -40,22 +40,26 @@ pub fn parse_type_section( environ.reserve_signatures(count)?; for entry in types { - let wasm_func_ty = entry?; - let mut sig = Signature::new(ModuleEnvironment::target_config(environ).default_call_conv); - sig.params.extend(wasm_func_ty.params.iter().map(|ty| { - let cret_arg: ir::Type = type_to_type(*ty, environ) - .expect("only numeric types are supported in function signatures"); - AbiParam::new(cret_arg) - })); - sig.returns.extend(wasm_func_ty.returns.iter().map(|ty| { - let cret_arg: ir::Type = type_to_type(*ty, environ) - .expect("only numeric types are supported in function signatures"); - AbiParam::new(cret_arg) - })); - environ.declare_signature(&wasm_func_ty, sig)?; - module_translation_state - .wasm_types - .push((wasm_func_ty.params, wasm_func_ty.returns)); + if let Ok(TypeDef::Func(wasm_func_ty)) = entry { + let mut sig = + Signature::new(ModuleEnvironment::target_config(environ).default_call_conv); + sig.params.extend(wasm_func_ty.params.iter().map(|ty| { + let cret_arg: ir::Type = type_to_type(*ty, environ) + .expect("only numeric types are supported in function signatures"); + AbiParam::new(cret_arg) + })); + sig.returns.extend(wasm_func_ty.returns.iter().map(|ty| { + let cret_arg: ir::Type = type_to_type(*ty, environ) + .expect("only numeric types are supported in function signatures"); + AbiParam::new(cret_arg) + })); + environ.declare_signature(&wasm_func_ty, sig)?; + module_translation_state + .wasm_types + .push((wasm_func_ty.params, wasm_func_ty.returns)); + } else { + unimplemented!("module linking not implemented yet") + } } Ok(()) } @@ -70,7 +74,7 @@ pub fn parse_import_section<'data>( for entry in imports { let import = entry?; let module_name = import.module; - let field_name = import.field; + let field_name = import.field.unwrap(); // TODO Handle error when module linking is implemented. match import.ty { ImportSectionEntryType::Function(sig) => { @@ -80,6 +84,9 @@ pub fn parse_import_section<'data>( field_name, )?; } + ImportSectionEntryType::Module(_sig) | ImportSectionEntryType::Instance(_sig) => { + unimplemented!("module linking not implemented yet") + } ImportSectionEntryType::Memory(MemoryType { limits: ref memlimits, shared, @@ -268,6 +275,9 @@ pub fn parse_export_section<'data>( ExternalKind::Global => { environ.declare_global_export(GlobalIndex::new(index), field)? } + ExternalKind::Type | ExternalKind::Module | ExternalKind::Instance => { + unimplemented!("module linking not implemented yet") + } } } diff --git a/crates/debug/Cargo.toml b/crates/debug/Cargo.toml index e004256b2c..7a56147650 100644 --- a/crates/debug/Cargo.toml +++ b/crates/debug/Cargo.toml @@ -13,7 +13,7 @@ edition = "2018" [dependencies] gimli = "0.21.0" -wasmparser = "0.57.0" +wasmparser = "0.58.0" object = { version = "0.19", default-features = false, features = ["write"] } wasmtime-environ = { path = "../environ", version = "0.18.0" } target-lexicon = { version = "0.10.0", default-features = false } diff --git a/crates/debug/src/read_debuginfo.rs b/crates/debug/src/read_debuginfo.rs index f1a0f149d6..6751fdfd40 100644 --- a/crates/debug/src/read_debuginfo.rs +++ b/crates/debug/src/read_debuginfo.rs @@ -6,7 +6,7 @@ use gimli::{ }; use std::collections::HashMap; use std::path::PathBuf; -use wasmparser::{self, ModuleReader, SectionCode}; +use wasmparser::{self, ModuleReader, SectionCode, TypeDef}; trait Reader: gimli::Reader {} @@ -186,7 +186,13 @@ pub fn read_debuginfo(data: &[u8]) -> Result { signatures_params = section .get_type_section_reader()? .into_iter() - .map(|ft| Ok(ft?.params)) + .map(|ft| { + if let Ok(TypeDef::Func(ft)) = ft { + Ok(ft.params) + } else { + unimplemented!("module linking not implemented yet") + } + }) .collect::>>()?; } SectionCode::Import => { diff --git a/crates/environ/Cargo.toml b/crates/environ/Cargo.toml index d3cdc72a52..8d640ed1d2 100644 --- a/crates/environ/Cargo.toml +++ b/crates/environ/Cargo.toml @@ -16,7 +16,7 @@ anyhow = "1.0" cranelift-codegen = { path = "../../cranelift/codegen", version = "0.65.0", features = ["enable-serde"] } cranelift-entity = { path = "../../cranelift/entity", version = "0.65.0", features = ["enable-serde"] } cranelift-wasm = { path = "../../cranelift/wasm", version = "0.65.0", features = ["enable-serde"] } -wasmparser = "0.57.0" +wasmparser = "0.58.0" lightbeam = { path = "../lightbeam", optional = true, version = "0.18.0" } indexmap = "1.0.2" rayon = "1.2.1" diff --git a/crates/fuzzing/Cargo.toml b/crates/fuzzing/Cargo.toml index 01a505793a..24821f30d7 100644 --- a/crates/fuzzing/Cargo.toml +++ b/crates/fuzzing/Cargo.toml @@ -13,7 +13,7 @@ binaryen = { version = "0.10.0", optional = true } env_logger = "0.7.1" log = "0.4.8" rayon = "1.2.1" -wasmparser = "0.57.0" +wasmparser = "0.58.0" wasmprinter = "0.2.5" wasmtime = { path = "../wasmtime" } wasmtime-wast = { path = "../wast" } diff --git a/crates/jit/Cargo.toml b/crates/jit/Cargo.toml index 61ad92226f..fc1f178ebd 100644 --- a/crates/jit/Cargo.toml +++ b/crates/jit/Cargo.toml @@ -24,7 +24,7 @@ wasmtime-profiling = { path = "../profiling", version = "0.18.0" } region = "2.1.0" thiserror = "1.0.4" target-lexicon = { version = "0.10.0", default-features = false } -wasmparser = "0.57.0" +wasmparser = "0.58.0" more-asserts = "0.2.1" anyhow = "1.0" cfg-if = "0.1.9" diff --git a/crates/lightbeam/Cargo.toml b/crates/lightbeam/Cargo.toml index 5c25375a56..953fa023ca 100644 --- a/crates/lightbeam/Cargo.toml +++ b/crates/lightbeam/Cargo.toml @@ -24,7 +24,7 @@ smallvec = "1.0.0" staticvec = "0.10" thiserror = "1.0.9" typemap = "0.3" -wasmparser = "0.57.0" +wasmparser = "0.58.0" [dev-dependencies] lazy_static = "1.2" diff --git a/crates/lightbeam/src/translate_sections.rs b/crates/lightbeam/src/translate_sections.rs index 6730664dc8..ab769afca0 100644 --- a/crates/lightbeam/src/translate_sections.rs +++ b/crates/lightbeam/src/translate_sections.rs @@ -5,14 +5,18 @@ use cranelift_codegen::{binemit, ir}; use wasmparser::{ CodeSectionReader, DataSectionReader, ElementSectionReader, ExportSectionReader, FuncType, FunctionSectionReader, GlobalSectionReader, ImportSectionReader, MemorySectionReader, - MemoryType, TableSectionReader, TableType, TypeSectionReader, + MemoryType, TableSectionReader, TableType, TypeDef, TypeSectionReader, }; /// Parses the Type section of the wasm module. pub fn type_(types_reader: TypeSectionReader) -> Result, Error> { types_reader .into_iter() - .map(|r| r.map_err(Into::into)) + .map(|r| match r { + Ok(TypeDef::Func(ft)) => Ok(ft), + Ok(_) => unimplemented!("module linking is not implemented yet"), + Err(e) => Err(e.into()), + }) .collect() } diff --git a/crates/runtime/src/externref.rs b/crates/runtime/src/externref.rs index a7bf80b6b3..2272c3bcb8 100644 --- a/crates/runtime/src/externref.rs +++ b/crates/runtime/src/externref.rs @@ -21,7 +21,7 @@ //! The `VMExternData` struct is *preceded* by the dynamically-sized value boxed //! up and referenced by one or more `VMExternRef`s: //! -//! ```ignore +//! ```text //! ,-------------------------------------------------------. //! | | //! V | diff --git a/crates/wasmtime/Cargo.toml b/crates/wasmtime/Cargo.toml index 384a608426..7ddc2986a6 100644 --- a/crates/wasmtime/Cargo.toml +++ b/crates/wasmtime/Cargo.toml @@ -14,7 +14,7 @@ wasmtime-runtime = { path = "../runtime", version = "0.18.0" } wasmtime-environ = { path = "../environ", version = "0.18.0" } wasmtime-jit = { path = "../jit", version = "0.18.0" } wasmtime-profiling = { path = "../profiling", version = "0.18.0" } -wasmparser = "0.57.0" +wasmparser = "0.58.0" target-lexicon = { version = "0.10.0", default-features = false } anyhow = "1.0.19" region = "2.1.0" diff --git a/crates/wasmtime/src/runtime.rs b/crates/wasmtime/src/runtime.rs index a33254b1dd..ddec435af7 100644 --- a/crates/wasmtime/src/runtime.rs +++ b/crates/wasmtime/src/runtime.rs @@ -89,6 +89,7 @@ impl Config { enable_simd: false, enable_multi_value: true, enable_tail_call: false, + enable_module_linking: false, }, }, flags, diff --git a/crates/wiggle/src/lib.rs b/crates/wiggle/src/lib.rs index 1887b6cb4c..b7c646a09a 100644 --- a/crates/wiggle/src/lib.rs +++ b/crates/wiggle/src/lib.rs @@ -61,7 +61,7 @@ pub use region::Region; /// /// # Using References /// -/// The [`GuestMemory::as_slice`] or [`GuestPtr::as_str`] will return smart +/// The [`GuestPtr::as_slice`] or [`GuestPtr::as_str`] will return smart /// pointers [`GuestSlice`] and [`GuestStr`]. These types, which implement /// [`std::ops::Deref`] and [`std::ops::DerefMut`], provide mutable references /// into the memory region given by a `GuestMemory`. diff --git a/crates/wiggle/wasmtime/macro/src/lib.rs b/crates/wiggle/wasmtime/macro/src/lib.rs index b075e54d7d..160babeb12 100644 --- a/crates/wiggle/wasmtime/macro/src/lib.rs +++ b/crates/wiggle/wasmtime/macro/src/lib.rs @@ -21,7 +21,7 @@ use config::{MissingMemoryConf, ModuleConf, TargetConf}; /// where the macro is invoked. `witx_literal` takes a string of the witx document, e.g. /// `"(typename $foo u8)"`. /// * `ctx`: The context struct used for the Wiggle implementation. This must be the same -/// type as the [`wasmtime_wiggle::from_witx`] macro at `target` was invoked with. However, it +/// type as the `wasmtime_wiggle::from_witx` macro at `target` was invoked with. However, it /// must be imported to the current scope so that it is a bare identifier e.g. `CtxType`, not /// `path::to::CtxType`. /// * `modules`: Describes how any modules in the witx document will be implemented as Wasmtime