From a33caec9be0a4e51858a6bcae5691fe5ca422833 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 4 Aug 2021 09:53:47 -0500 Subject: [PATCH] Bump the wasm-tools crates (#3139) * Bump the wasm-tools crates Pulls in some updates here and there, mostly for updating crates to the latest version to prepare for later memory64 work. * Update lightbeam --- Cargo.lock | 34 ++++---- Cargo.toml | 6 +- cranelift/codegen/Cargo.toml | 2 +- cranelift/peepmatic/Cargo.toml | 2 +- cranelift/peepmatic/crates/fuzzing/Cargo.toml | 2 +- cranelift/peepmatic/crates/runtime/Cargo.toml | 2 +- cranelift/peepmatic/crates/souper/Cargo.toml | 2 +- .../peepmatic/crates/test-operator/Cargo.toml | 2 +- cranelift/wasm/Cargo.toml | 2 +- cranelift/wasm/src/code_translator.rs | 20 +++-- cranelift/wasm/src/environ/spec.rs | 40 +++++----- cranelift/wasm/src/module_translator.rs | 14 ++-- cranelift/wasm/src/sections_translator.rs | 80 ++++++++++--------- cranelift/wasm/src/translation_utils.rs | 8 +- crates/cranelift/Cargo.toml | 2 +- crates/debug/Cargo.toml | 2 +- crates/environ/Cargo.toml | 2 +- crates/environ/src/module_environ.rs | 4 +- crates/fuzzing/Cargo.toml | 4 +- crates/fuzzing/src/generators/api.rs | 7 +- crates/jit/Cargo.toml | 2 +- crates/lightbeam/Cargo.toml | 2 +- crates/lightbeam/src/microwasm.rs | 2 +- crates/lightbeam/src/module.rs | 17 ++-- crates/lightbeam/wasmtime/Cargo.toml | 2 +- crates/wasmtime/Cargo.toml | 2 +- crates/wasmtime/src/types.rs | 2 +- crates/wasmtime/src/types/matching.rs | 8 +- crates/wast/Cargo.toml | 2 +- crates/wast/src/wast.rs | 9 ++- 30 files changed, 148 insertions(+), 137 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c27436d437..9f736c8c08 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -593,7 +593,7 @@ dependencies = [ "smallvec", "souper-ir", "target-lexicon", - "wast 36.0.0", + "wast 37.0.0", ] [[package]] @@ -2020,7 +2020,7 @@ dependencies = [ "peepmatic-test-operator", "peepmatic-traits", "serde", - "wast 36.0.0", + "wast 37.0.0", "z3", ] @@ -2048,7 +2048,7 @@ dependencies = [ "peepmatic-traits", "rand 0.8.3", "serde", - "wast 36.0.0", + "wast 37.0.0", ] [[package]] @@ -2073,7 +2073,7 @@ dependencies = [ "serde", "serde_test", "thiserror", - "wast 36.0.0", + "wast 37.0.0", ] [[package]] @@ -2085,7 +2085,7 @@ dependencies = [ "peepmatic", "peepmatic-test-operator", "souper-ir", - "wast 36.0.0", + "wast 37.0.0", ] [[package]] @@ -2106,7 +2106,7 @@ version = "0.76.0" dependencies = [ "peepmatic-traits", "serde", - "wast 36.0.0", + "wast 37.0.0", ] [[package]] @@ -3491,15 +3491,15 @@ dependencies = [ [[package]] name = "wasmparser" -version = "0.79.0" +version = "0.80.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b5894be15a559c85779254700e1d35f02f843b5a69152e5c82c626d9fd66c0e" +checksum = "a5f71b80b8193e50910919e7d1bc956d2b4f42b1cb1fad84bacb59332c16f2cf" [[package]] name = "wasmprinter" -version = "0.2.27" +version = "0.2.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe6f65000c9b653a87ba9b8bebe9230371337db2b7e70db724ee4b79d2b9936f" +checksum = "b48e4f2999b9930e9b037e328357d7d2367e0d8ea6e534be90aeff60976c0452" dependencies = [ "anyhow", "wasmparser", @@ -3639,7 +3639,7 @@ dependencies = [ "wasmtime-wasi-crypto", "wasmtime-wasi-nn", "wasmtime-wast", - "wast 36.0.0", + "wast 37.0.0", "wat", "winapi", ] @@ -3874,7 +3874,7 @@ version = "0.29.0" dependencies = [ "anyhow", "wasmtime", - "wast 36.0.0", + "wast 37.0.0", ] [[package]] @@ -3888,20 +3888,20 @@ dependencies = [ [[package]] name = "wast" -version = "36.0.0" +version = "37.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b5d7ba374a364571da1cb0a379a3dc302582a2d9937a183bfe35b68ad5bb9c4" +checksum = "9bc7b9a76845047ded00e031754ff410afee0d50fbdf62b55bdeecd245063d68" dependencies = [ "leb128", ] [[package]] name = "wat" -version = "1.0.38" +version = "1.0.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16383df7f0e3901484c2dda6294ed6895caa3627ce4f6584141dcf30a33a23e6" +checksum = "2ab2cc8d9a69d1ab28a41d9149bb06bb927aba8fc9d56625f8b597a564c83f50" dependencies = [ - "wast 36.0.0", + "wast 37.0.0", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index aa9ce92ce8..260bc4ed87 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -38,12 +38,12 @@ anyhow = "1.0.19" target-lexicon = { version = "0.12.0", default-features = false } pretty_env_logger = "0.4.0" file-per-thread-logger = "0.1.1" -wat = "1.0.38" +wat = "1.0.39" libc = "0.2.60" log = "0.4.8" rayon = "1.5.0" humantime = "2.0.0" -wasmparser = "0.79.0" +wasmparser = "0.80.0" lazy_static = "1.4.0" [dev-dependencies] @@ -56,7 +56,7 @@ wasmtime-fuzzing = { path = "crates/fuzzing" } wasmtime-runtime = { path = "crates/runtime" } tokio = { version = "1.8.0", features = ["rt", "time", "macros", "rt-multi-thread"] } tracing-subscriber = "0.2.16" -wast = "36.0.0" +wast = "37.0.0" criterion = "0.3.4" num_cpus = "1.13.0" winapi = { version = "0.3.9", features = ['memoryapi'] } diff --git a/cranelift/codegen/Cargo.toml b/cranelift/codegen/Cargo.toml index 2ad36e99a7..6b40fd04be 100644 --- a/cranelift/codegen/Cargo.toml +++ b/cranelift/codegen/Cargo.toml @@ -28,7 +28,7 @@ peepmatic-traits = { path = "../peepmatic/crates/traits", optional = true, versi peepmatic-runtime = { path = "../peepmatic/crates/runtime", optional = true, version = "0.76.0" } regalloc = { version = "0.0.31" } souper-ir = { version = "2.1.0", optional = true } -wast = { version = "36.0.0", optional = true } +wast = { version = "37.0.0", optional = true } # It is a goal of the cranelift-codegen crate to have minimal external dependencies. # Please don't add any unless they are essential to the task of creating binary # machine code. Integration tests that need external dependencies can be diff --git a/cranelift/peepmatic/Cargo.toml b/cranelift/peepmatic/Cargo.toml index 1dd33ad771..17c94fde11 100644 --- a/cranelift/peepmatic/Cargo.toml +++ b/cranelift/peepmatic/Cargo.toml @@ -15,7 +15,7 @@ peepmatic-macro = { version = "0.76.0", path = "crates/macro" } peepmatic-runtime = { version = "0.76.0", path = "crates/runtime", features = ["construct"] } peepmatic-traits = { version = "0.76.0", path = "crates/traits" } serde = { version = "1.0.105", features = ["derive"] } -wast = "36.0.0" +wast = "37.0.0" z3 = { version = "0.7.1", features = ["static-link-z3"] } [dev-dependencies] diff --git a/cranelift/peepmatic/crates/fuzzing/Cargo.toml b/cranelift/peepmatic/crates/fuzzing/Cargo.toml index 394408dd54..cc67c0b44d 100644 --- a/cranelift/peepmatic/crates/fuzzing/Cargo.toml +++ b/cranelift/peepmatic/crates/fuzzing/Cargo.toml @@ -21,4 +21,4 @@ peepmatic-test-operator = { path = "../test-operator" } peepmatic-traits = { path = "../traits" } rand = { version = "0.8.3", features = ["small_rng"] } serde = "1.0.106" -wast = "36.0.0" +wast = "37.0.0" diff --git a/cranelift/peepmatic/crates/runtime/Cargo.toml b/cranelift/peepmatic/crates/runtime/Cargo.toml index 7aeed8f83b..6fc44997d9 100644 --- a/cranelift/peepmatic/crates/runtime/Cargo.toml +++ b/cranelift/peepmatic/crates/runtime/Cargo.toml @@ -16,7 +16,7 @@ peepmatic-automata = { version = "0.76.0", path = "../automata", features = ["se peepmatic-traits = { version = "0.76.0", path = "../traits" } serde = { version = "1.0.105", features = ["derive"] } thiserror = "1.0.15" -wast = { version = "36.0.0", optional = true } +wast = { version = "37.0.0", optional = true } [dev-dependencies] peepmatic-test-operator = { version = "0.76.0", path = "../test-operator" } diff --git a/cranelift/peepmatic/crates/souper/Cargo.toml b/cranelift/peepmatic/crates/souper/Cargo.toml index f5b801d321..f6ea48aaa4 100644 --- a/cranelift/peepmatic/crates/souper/Cargo.toml +++ b/cranelift/peepmatic/crates/souper/Cargo.toml @@ -16,4 +16,4 @@ log = "0.4.8" [dev-dependencies] peepmatic = { path = "../..", version = "0.76.0" } peepmatic-test-operator = { version = "0.76.0", path = "../test-operator" } -wast = "36.0.0" +wast = "37.0.0" diff --git a/cranelift/peepmatic/crates/test-operator/Cargo.toml b/cranelift/peepmatic/crates/test-operator/Cargo.toml index e0a982e715..96ba760140 100644 --- a/cranelift/peepmatic/crates/test-operator/Cargo.toml +++ b/cranelift/peepmatic/crates/test-operator/Cargo.toml @@ -11,4 +11,4 @@ edition = "2018" [dependencies] peepmatic-traits = { version = "0.76.0", path = "../traits" } serde = { version = "1.0.105", features = ["derive"] } -wast = "36.0.0" +wast = "37.0.0" diff --git a/cranelift/wasm/Cargo.toml b/cranelift/wasm/Cargo.toml index c53b864558..f00187502d 100644 --- a/cranelift/wasm/Cargo.toml +++ b/cranelift/wasm/Cargo.toml @@ -12,7 +12,7 @@ keywords = ["webassembly", "wasm"] edition = "2018" [dependencies] -wasmparser = { version = "0.79", default-features = false } +wasmparser = { version = "0.80", default-features = false } cranelift-codegen = { path = "../codegen", version = "0.76.0", default-features = false } cranelift-entity = { path = "../entity", version = "0.76.0" } cranelift-frontend = { path = "../frontend", version = "0.76.0", default-features = false } diff --git a/cranelift/wasm/src/code_translator.rs b/cranelift/wasm/src/code_translator.rs index cc6866fc4d..da53a5dc48 100644 --- a/cranelift/wasm/src/code_translator.rs +++ b/cranelift/wasm/src/code_translator.rs @@ -2150,7 +2150,7 @@ fn translate_unreachable_operator( fn get_heap_addr( heap: ir::Heap, addr32: ir::Value, - offset: u32, + offset: u64, width: u32, addr_ty: Type, builder: &mut FunctionBuilder, @@ -2160,6 +2160,9 @@ fn get_heap_addr( let offset_guard_size: u64 = builder.func.heaps[heap].offset_guard_size.into(); + // Currently this function only supports 32-bit memories. + let offset = u32::try_from(offset).unwrap(); + // How exactly the bounds check is performed here and what it's performed // on is a bit tricky. Generally we want to rely on access violations (e.g. // segfaults) to generate traps since that means we don't have to bounds @@ -2239,12 +2242,12 @@ fn prepare_load( state: &mut FuncTranslationState, environ: &mut FE, ) -> WasmResult<(MemFlags, Value, Offset32)> { - let addr32 = state.pop1(); + let addr = state.pop1(); let heap = state.get_heap(builder.func, memarg.memory, environ)?; let (base, offset) = get_heap_addr( heap, - addr32, + addr, memarg.offset, loaded_bytes, environ.pointer_type(), @@ -2335,11 +2338,14 @@ fn fold_atomic_mem_addr( ) -> Value { let access_ty_bytes = access_ty.bytes(); let final_lma = if memarg.offset > 0 { + // Note that 32-bit memories are only supported here at this time, the + // logic here (e.g. the `iadd_imm` will need to check for overflow and + // other bits and pieces for 64-bit memories. assert!(builder.func.dfg.value_type(linear_mem_addr) == I32); let linear_mem_addr = builder.ins().uextend(I64, linear_mem_addr); let a = builder .ins() - .iadd_imm(linear_mem_addr, i64::from(memarg.offset)); + .iadd_imm(linear_mem_addr, i64::try_from(memarg.offset).unwrap()); let cflags = builder.ins().ifcmp_imm(a, 0x1_0000_0000i64); builder.ins().trapif( IntCC::UnsignedGreaterThanOrEqual, @@ -2374,10 +2380,14 @@ fn finalise_atomic_mem_addr( environ: &mut FE, ) -> WasmResult { // Check the alignment of `linear_mem_addr`. + // + // Note that the `iadd_imm` here and the `try_from` only works for 32-bit + // memories. let access_ty_bytes = access_ty.bytes(); + assert!(builder.func.dfg.value_type(linear_mem_addr) == I32); let final_lma = builder .ins() - .iadd_imm(linear_mem_addr, i64::from(memarg.offset)); + .iadd_imm(linear_mem_addr, i64::try_from(memarg.offset).unwrap()); if access_ty_bytes != 1 { assert!(access_ty_bytes == 2 || access_ty_bytes == 4 || access_ty_bytes == 8); let final_lma_misalignment = builder diff --git a/cranelift/wasm/src/environ/spec.rs b/cranelift/wasm/src/environ/spec.rs index 31c8d86a4e..474aa05901 100644 --- a/cranelift/wasm/src/environ/spec.rs +++ b/cranelift/wasm/src/environ/spec.rs @@ -8,9 +8,9 @@ use crate::state::FuncTranslationState; use crate::translation_utils::{ - DataIndex, ElemIndex, EntityIndex, EntityType, Event, EventIndex, FuncIndex, Global, - GlobalIndex, InstanceIndex, InstanceTypeIndex, Memory, MemoryIndex, ModuleIndex, - ModuleTypeIndex, SignatureIndex, Table, TableIndex, TypeIndex, + DataIndex, ElemIndex, EntityIndex, EntityType, FuncIndex, Global, GlobalIndex, InstanceIndex, + InstanceTypeIndex, Memory, MemoryIndex, ModuleIndex, ModuleTypeIndex, SignatureIndex, Table, + TableIndex, Tag, TagIndex, TypeIndex, }; use core::convert::From; use core::convert::TryFrom; @@ -771,15 +771,15 @@ pub trait ModuleEnvironment<'data>: TargetEnvironment { field: Option<&'data str>, ) -> WasmResult<()>; - /// Declares an event import to the environment. - fn declare_event_import( + /// Declares an tag import to the environment. + fn declare_tag_import( &mut self, - event: Event, + tag: Tag, module: &'data str, field: Option<&'data str>, ) -> WasmResult<()> { - drop((event, module, field)); - Err(WasmError::Unsupported("wasm events".to_string())) + drop((tag, module, field)); + Err(WasmError::Unsupported("wasm tags".to_string())) } /// Declares a global import to the environment. @@ -844,16 +844,16 @@ pub trait ModuleEnvironment<'data>: TargetEnvironment { /// Declares a memory to the environment fn declare_memory(&mut self, memory: Memory) -> WasmResult<()>; - /// Provides the number of defined events up front. By default this does nothing, but + /// Provides the number of defined tags up front. By default this does nothing, but /// implementations can use this to preallocate memory if desired. - fn reserve_events(&mut self, _num: u32) -> WasmResult<()> { + fn reserve_tags(&mut self, _num: u32) -> WasmResult<()> { Ok(()) } - /// Declares an event to the environment - fn declare_event(&mut self, event: Event) -> WasmResult<()> { - drop(event); - Err(WasmError::Unsupported("wasm events".to_string())) + /// Declares an tag to the environment + fn declare_tag(&mut self, tag: Tag) -> WasmResult<()> { + drop(tag); + Err(WasmError::Unsupported("wasm tags".to_string())) } /// Provides the number of defined globals up front. By default this does nothing, but @@ -885,14 +885,10 @@ pub trait ModuleEnvironment<'data>: TargetEnvironment { name: &'data str, ) -> WasmResult<()>; - /// Declares an event export to the environment. - fn declare_event_export( - &mut self, - event_index: EventIndex, - name: &'data str, - ) -> WasmResult<()> { - drop((event_index, name)); - Err(WasmError::Unsupported("wasm events".to_string())) + /// Declares an tag export to the environment. + fn declare_tag_export(&mut self, tag_index: TagIndex, name: &'data str) -> WasmResult<()> { + drop((tag_index, name)); + Err(WasmError::Unsupported("wasm tags".to_string())) } /// Declares a global export to the environment. diff --git a/cranelift/wasm/src/module_translator.rs b/cranelift/wasm/src/module_translator.rs index 0114a43c94..5d605d1e77 100644 --- a/cranelift/wasm/src/module_translator.rs +++ b/cranelift/wasm/src/module_translator.rs @@ -2,10 +2,10 @@ //! to deal with each part of it. use crate::environ::{ModuleEnvironment, WasmResult}; use crate::sections_translator::{ - parse_alias_section, parse_data_section, parse_element_section, parse_event_section, - parse_export_section, parse_function_section, parse_global_section, parse_import_section, - parse_instance_section, parse_memory_section, parse_name_section, parse_start_section, - parse_table_section, parse_type_section, + parse_alias_section, parse_data_section, parse_element_section, parse_export_section, + parse_function_section, parse_global_section, parse_import_section, parse_instance_section, + parse_memory_section, parse_name_section, parse_start_section, parse_table_section, + parse_tag_section, parse_type_section, }; use crate::state::ModuleTranslationState; use cranelift_codegen::timing; @@ -59,9 +59,9 @@ pub fn translate_module<'data>( parse_memory_section(memories, environ)?; } - Payload::EventSection(events) => { - validator.event_section(&events)?; - parse_event_section(events, environ)?; + Payload::TagSection(tags) => { + validator.tag_section(&tags)?; + parse_tag_section(tags, environ)?; } Payload::GlobalSection(globals) => { diff --git a/cranelift/wasm/src/sections_translator.rs b/cranelift/wasm/src/sections_translator.rs index 54bba7a344..28b6413390 100644 --- a/cranelift/wasm/src/sections_translator.rs +++ b/cranelift/wasm/src/sections_translator.rs @@ -10,9 +10,9 @@ use crate::environ::{Alias, ModuleEnvironment, WasmError, WasmResult}; use crate::state::ModuleTranslationState; use crate::translation_utils::{ - tabletype_to_type, type_to_type, DataIndex, ElemIndex, EntityIndex, EntityType, Event, - EventIndex, FuncIndex, Global, GlobalIndex, GlobalInit, InstanceIndex, Memory, MemoryIndex, - ModuleIndex, Table, TableElementType, TableIndex, TypeIndex, + tabletype_to_type, type_to_type, DataIndex, ElemIndex, EntityIndex, EntityType, FuncIndex, + Global, GlobalIndex, GlobalInit, InstanceIndex, Memory, MemoryIndex, ModuleIndex, Table, + TableElementType, TableIndex, Tag, TagIndex, TypeIndex, }; use crate::wasm_unsupported; use core::convert::TryFrom; @@ -24,10 +24,10 @@ use std::boxed::Box; use std::vec::Vec; use wasmparser::{ self, Data, DataKind, DataSectionReader, Element, ElementItem, ElementItems, ElementKind, - ElementSectionReader, EventSectionReader, EventType, Export, ExportSectionReader, ExternalKind, - FunctionSectionReader, GlobalSectionReader, GlobalType, ImportSectionEntryType, - ImportSectionReader, MemorySectionReader, MemoryType, NameSectionReader, Naming, Operator, - TableSectionReader, TableType, TypeDef, TypeSectionReader, + ElementSectionReader, Export, ExportSectionReader, ExternalKind, FunctionSectionReader, + GlobalSectionReader, GlobalType, ImportSectionEntryType, ImportSectionReader, + MemorySectionReader, MemoryType, NameSectionReader, Naming, Operator, TableSectionReader, + TableType, TagSectionReader, TagType, TypeDef, TypeSectionReader, }; fn entity_type( @@ -45,7 +45,7 @@ fn entity_type( EntityType::Instance(environ.type_to_instance_type(TypeIndex::from_u32(sig))?) } ImportSectionEntryType::Memory(ty) => EntityType::Memory(memory(ty)), - ImportSectionEntryType::Event(evt) => EntityType::Event(event(evt)), + ImportSectionEntryType::Tag(t) => EntityType::Tag(tag(t)), ImportSectionEntryType::Global(ty) => { EntityType::Global(global(ty, environ, GlobalInit::Import)?) } @@ -54,19 +54,16 @@ fn entity_type( } fn memory(ty: MemoryType) -> Memory { - match ty { - MemoryType::M32 { limits, shared } => Memory { - minimum: limits.initial, - maximum: limits.maximum, - shared: shared, - }, - // FIXME(#2361) - MemoryType::M64 { .. } => unimplemented!(), + assert!(!ty.memory64); + Memory { + minimum: ty.initial.try_into().unwrap(), + maximum: ty.maximum.map(|i| i.try_into().unwrap()), + shared: ty.shared, } } -fn event(e: EventType) -> Event { - Event { +fn tag(e: TagType) -> Tag { + Tag { ty: TypeIndex::from_u32(e.type_index), } } @@ -78,8 +75,8 @@ fn table(ty: TableType, environ: &mut dyn ModuleEnvironment<'_>) -> WasmResult TableElementType::Val(t), None => TableElementType::Func, }, - minimum: ty.limits.initial, - maximum: ty.limits.maximum, + minimum: ty.initial, + maximum: ty.maximum, }) } @@ -174,8 +171,8 @@ pub fn parse_import_section<'data>( ImportSectionEntryType::Memory(ty) => { environ.declare_memory_import(memory(ty), import.module, import.field)?; } - ImportSectionEntryType::Event(e) => { - environ.declare_event_import(event(e), import.module, import.field)?; + ImportSectionEntryType::Tag(e) => { + environ.declare_tag_import(tag(e), import.module, import.field)?; } ImportSectionEntryType::Global(ty) => { let ty = global(ty, environ, GlobalInit::Import)?; @@ -243,16 +240,16 @@ pub fn parse_memory_section( Ok(()) } -/// Parses the Event section of the wasm module. -pub fn parse_event_section( - events: EventSectionReader, +/// Parses the Tag section of the wasm module. +pub fn parse_tag_section( + tags: TagSectionReader, environ: &mut dyn ModuleEnvironment, ) -> WasmResult<()> { - environ.reserve_events(events.get_count())?; + environ.reserve_tags(tags.get_count())?; - for entry in events { - let event = event(entry?); - environ.declare_event(event)?; + for entry in tags { + let tag = tag(entry?); + environ.declare_tag(tag)?; } Ok(()) @@ -321,7 +318,7 @@ pub fn parse_export_section<'data>( ExternalKind::Memory => { environ.declare_memory_export(MemoryIndex::new(index), field)? } - ExternalKind::Event => environ.declare_event_export(EventIndex::new(index), field)?, + ExternalKind::Tag => environ.declare_tag_export(TagIndex::new(index), field)?, ExternalKind::Global => { environ.declare_global_export(GlobalIndex::new(index), field)? } @@ -473,20 +470,31 @@ pub fn parse_name_section<'data>( environ.declare_module_name(name); } wasmparser::Name::Local(l) => { - let mut reader = l.get_function_local_reader()?; - for _ in 0..reader.get_count() { + let mut reader = l.get_indirect_map()?; + for _ in 0..reader.get_indirect_count() { let f = reader.read()?; - if f.func_index == u32::max_value() { + if f.indirect_index == u32::max_value() { continue; } let mut map = f.get_map()?; for _ in 0..map.get_count() { let Naming { index, name } = map.read()?; - environ.declare_local_name(FuncIndex::from_u32(f.func_index), index, name) + environ.declare_local_name( + FuncIndex::from_u32(f.indirect_index), + index, + name, + ) } } } - wasmparser::Name::Unknown { .. } => {} + wasmparser::Name::Label(_) + | wasmparser::Name::Type(_) + | wasmparser::Name::Table(_) + | wasmparser::Name::Global(_) + | wasmparser::Name::Memory(_) + | wasmparser::Name::Element(_) + | wasmparser::Name::Data(_) + | wasmparser::Name::Unknown { .. } => {} } } Ok(()) @@ -516,7 +524,7 @@ pub fn parse_instance_section<'data>( ExternalKind::Instance => { EntityIndex::Instance(InstanceIndex::from_u32(arg.index)) } - ExternalKind::Event => unimplemented!(), + ExternalKind::Tag => unimplemented!(), // this won't pass validation ExternalKind::Type => unreachable!(), diff --git a/cranelift/wasm/src/translation_utils.rs b/cranelift/wasm/src/translation_utils.rs index fffb7b375e..018febbbb7 100644 --- a/cranelift/wasm/src/translation_utils.rs +++ b/cranelift/wasm/src/translation_utils.rs @@ -95,8 +95,8 @@ entity_impl!(InstanceIndex); /// Index type of an event inside the WebAssembly module. #[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Debug)] #[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))] -pub struct EventIndex(u32); -entity_impl!(EventIndex); +pub struct TagIndex(u32); +entity_impl!(TagIndex); /// Specialized index for just module types. #[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Debug)] @@ -139,7 +139,7 @@ pub enum EntityType { /// A linear memory with the specified limits Memory(Memory), /// An event definition. - Event(Event), + Tag(Tag), /// A table with the specified element type and limits Table(Table), /// A function type where the index points to the type section and records a @@ -236,7 +236,7 @@ pub struct Memory { /// WebAssembly event. #[derive(Debug, Clone, Copy, Hash, Eq, PartialEq)] #[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))] -pub struct Event { +pub struct Tag { /// The event signature type. pub ty: TypeIndex, } diff --git a/crates/cranelift/Cargo.toml b/crates/cranelift/Cargo.toml index 083de6e28a..4eabe5ec4b 100644 --- a/crates/cranelift/Cargo.toml +++ b/crates/cranelift/Cargo.toml @@ -16,5 +16,5 @@ cranelift-wasm = { path = "../../cranelift/wasm", version = "0.76.0" } cranelift-codegen = { path = "../../cranelift/codegen", version = "0.76.0" } cranelift-frontend = { path = "../../cranelift/frontend", version = "0.76.0" } cranelift-entity = { path = "../../cranelift/entity", version = "0.76.0" } -wasmparser = "0.79.0" +wasmparser = "0.80.0" target-lexicon = "0.12" diff --git a/crates/debug/Cargo.toml b/crates/debug/Cargo.toml index 84b230130d..4b058eb164 100644 --- a/crates/debug/Cargo.toml +++ b/crates/debug/Cargo.toml @@ -12,7 +12,7 @@ edition = "2018" [dependencies] gimli = "0.25.0" -wasmparser = "0.79" +wasmparser = "0.80" object = { version = "0.26.0", default-features = false, features = ["read_core", "elf", "write"] } wasmtime-environ = { path = "../environ", version = "0.29.0" } target-lexicon = { version = "0.12.0", default-features = false } diff --git a/crates/environ/Cargo.toml b/crates/environ/Cargo.toml index 79f16ebeb2..7aec79ce10 100644 --- a/crates/environ/Cargo.toml +++ b/crates/environ/Cargo.toml @@ -14,7 +14,7 @@ edition = "2018" cranelift-codegen = { path = "../../cranelift/codegen", version = "0.76.0", features = ["enable-serde"] } cranelift-entity = { path = "../../cranelift/entity", version = "0.76.0", features = ["enable-serde"] } cranelift-wasm = { path = "../../cranelift/wasm", version = "0.76.0", features = ["enable-serde"] } -wasmparser = "0.79" +wasmparser = "0.80" indexmap = { version = "1.0.2", features = ["serde-1"] } thiserror = "1.0.4" serde = { version = "1.0.94", features = ["derive"] } diff --git a/crates/environ/src/module_environ.rs b/crates/environ/src/module_environ.rs index 7cffaaf000..4b53388812 100644 --- a/crates/environ/src/module_environ.rs +++ b/crates/environ/src/module_environ.rs @@ -339,7 +339,7 @@ impl<'data> ModuleEnvironment<'data> { EntityIndex::Instance(self.result.module.instances.push(ty)) } EntityType::Module(ty) => EntityIndex::Module(self.result.module.modules.push(ty)), - EntityType::Event(_) => unimplemented!(), + EntityType::Tag(_) => unimplemented!(), } } @@ -1088,7 +1088,7 @@ and for re-adding support for interface types you can see this issue: EntityType::Module(sig) => { self.result.module.modules.push(*sig); } - EntityType::Event(_) => unimplemented!(), + EntityType::Tag(_) => unimplemented!(), } self.result .module diff --git a/crates/fuzzing/Cargo.toml b/crates/fuzzing/Cargo.toml index e8555fa618..7e6e5a014c 100644 --- a/crates/fuzzing/Cargo.toml +++ b/crates/fuzzing/Cargo.toml @@ -13,8 +13,8 @@ arbitrary = { version = "1.0.0", features = ["derive"] } env_logger = "0.8.1" log = "0.4.8" rayon = "1.2.1" -wasmparser = "0.79" -wasmprinter = "0.2.27" +wasmparser = "0.80" +wasmprinter = "0.2.28" wasmtime = { path = "../wasmtime" } wasmtime-wast = { path = "../wast" } wasm-encoder = "0.5.0" diff --git a/crates/fuzzing/src/generators/api.rs b/crates/fuzzing/src/generators/api.rs index bfcaccb0c9..1f47765dff 100644 --- a/crates/fuzzing/src/generators/api.rs +++ b/crates/fuzzing/src/generators/api.rs @@ -221,10 +221,7 @@ fn predict_rss(wasm: &[u8]) -> Result { // the minimum amount of memory to our predicted rss. Payload::MemorySection(s) => { for entry in s { - let initial = match entry? { - MemoryType::M32 { limits, .. } => limits.initial as usize, - MemoryType::M64 { limits, .. } => limits.initial as usize, - }; + let initial = entry?.initial as usize; prediction += initial * 64 * 1024; } } @@ -233,7 +230,7 @@ fn predict_rss(wasm: &[u8]) -> Result { // currently this is 3 pointers per table entry. Payload::TableSection(s) => { for entry in s { - let initial = entry?.limits.initial as usize; + let initial = entry?.initial as usize; prediction += initial * 3 * mem::size_of::(); } } diff --git a/crates/jit/Cargo.toml b/crates/jit/Cargo.toml index d18b6f3e20..d6bb5f613f 100644 --- a/crates/jit/Cargo.toml +++ b/crates/jit/Cargo.toml @@ -27,7 +27,7 @@ rayon = { version = "1.0", optional = true } region = "2.2.0" thiserror = "1.0.4" target-lexicon = { version = "0.12.0", default-features = false } -wasmparser = "0.79" +wasmparser = "0.80" more-asserts = "0.2.1" anyhow = "1.0" cfg-if = "1.0" diff --git a/crates/lightbeam/Cargo.toml b/crates/lightbeam/Cargo.toml index f5440ca672..39f955253d 100644 --- a/crates/lightbeam/Cargo.toml +++ b/crates/lightbeam/Cargo.toml @@ -24,7 +24,7 @@ more-asserts = "0.2.1" smallvec = "1.6.1" thiserror = "1.0.9" typemap = "0.3" -wasmparser = "0.79" +wasmparser = "0.80" [dev-dependencies] lazy_static = "1.2" diff --git a/crates/lightbeam/src/microwasm.rs b/crates/lightbeam/src/microwasm.rs index af20a1a3e1..c046bf6377 100644 --- a/crates/lightbeam/src/microwasm.rs +++ b/crates/lightbeam/src/microwasm.rs @@ -440,7 +440,7 @@ impl From for MemoryImmediate { assert_eq!(other.memory, 0); MemoryImmediate { flags: other.align.into(), - offset: other.offset, + offset: other.offset as u32, } } } diff --git a/crates/lightbeam/src/module.rs b/crates/lightbeam/src/module.rs index 3c8f31ee59..85612e64d6 100644 --- a/crates/lightbeam/src/module.rs +++ b/crates/lightbeam/src/module.rs @@ -10,7 +10,7 @@ use memoffset::offset_of; use std::{convert::TryInto, mem}; use thiserror::Error; -use wasmparser::{FuncType, MemoryType, Parser, Payload, ResizableLimits, Type}; +use wasmparser::{FuncType, Parser, Payload, Type}; pub trait AsValueType { const TYPE: Type; @@ -104,12 +104,12 @@ pub struct TranslatedModule { ctx: SimpleContext, // TODO: Should we wrap this in a `Mutex` so that calling functions from multiple // threads doesn't cause data races? - memory: Option, + memory: Option<(u64, Option)>, } impl TranslatedModule { pub fn instantiate(self) -> ExecutableModule { - let mem_size = self.memory.map(|limits| limits.initial).unwrap_or(0) as usize; + let mem_size = self.memory.map(|limits| limits.0 as u32).unwrap_or(0) as usize; let mem: BoxSlice<_> = vec![0u8; mem_size * WASM_PAGE_SIZE] .into_boxed_slice() .into(); @@ -535,19 +535,12 @@ pub fn translate_only(data: &[u8]) -> Result { if !mem.is_empty() { let mem = mem[0]; - let limits = match mem { - MemoryType::M32 { - limits, - shared: false, - } => limits, - _ => return Err(Error::Input("unsupported memory".to_string())), - }; - if Some(limits.initial) != limits.maximum { + if Some(mem.initial) != mem.maximum { return Err(Error::Input( "Custom memory limits not supported in lightbeam".to_string(), )); } - output.memory = Some(limits); + output.memory = Some((mem.initial, mem.maximum)); } } Payload::GlobalSection(s) => { diff --git a/crates/lightbeam/wasmtime/Cargo.toml b/crates/lightbeam/wasmtime/Cargo.toml index f71e3972ef..a2c2e48906 100644 --- a/crates/lightbeam/wasmtime/Cargo.toml +++ b/crates/lightbeam/wasmtime/Cargo.toml @@ -13,6 +13,6 @@ edition = "2018" [dependencies] lightbeam = { path = "..", version = "0.29.0" } -wasmparser = "0.79" +wasmparser = "0.80" cranelift-codegen = { path = "../../../cranelift/codegen", version = "0.76.0" } wasmtime-environ = { path = "../../environ", version = "0.29.0" } diff --git a/crates/wasmtime/Cargo.toml b/crates/wasmtime/Cargo.toml index 8543de3ab7..4c0ee28516 100644 --- a/crates/wasmtime/Cargo.toml +++ b/crates/wasmtime/Cargo.toml @@ -20,7 +20,7 @@ wasmtime-cache = { path = "../cache", version = "0.29.0", optional = true } wasmtime-profiling = { path = "../profiling", version = "0.29.0" } wasmtime-fiber = { path = "../fiber", version = "0.29.0", optional = true } target-lexicon = { version = "0.12.0", default-features = false } -wasmparser = "0.79" +wasmparser = "0.80" anyhow = "1.0.19" region = "2.2.0" libc = "0.2" diff --git a/crates/wasmtime/src/types.rs b/crates/wasmtime/src/types.rs index ff13665929..c50b8cd637 100644 --- a/crates/wasmtime/src/types.rs +++ b/crates/wasmtime/src/types.rs @@ -217,7 +217,7 @@ impl ExternType { let ty = &types.instance_signatures[*ty]; InstanceType::from_wasmtime(types, ty).into() } - EntityType::Event(_) => unimplemented!("wasm event support"), + EntityType::Tag(_) => unimplemented!("wasm tag support"), } } } diff --git a/crates/wasmtime/src/types/matching.rs b/crates/wasmtime/src/types/matching.rs index 9709288c4d..8485802149 100644 --- a/crates/wasmtime/src/types/matching.rs +++ b/crates/wasmtime/src/types/matching.rs @@ -236,7 +236,7 @@ impl MatchCx<'_> { EntityType::Global(_) => "global", EntityType::Module(_) => "module", EntityType::Memory(_) => "memory", - EntityType::Event(_) => "event", + EntityType::Tag(_) => "tag", EntityType::Instance(_) => "instance", EntityType::Table(_) => "table", EntityType::Function(_) => "function", @@ -301,7 +301,7 @@ impl MatchCx<'_> { } _ => bail!("expected module, but found {}", actual_desc), }, - EntityType::Event(_) => unimplemented!(), + EntityType::Tag(_) => unimplemented!(), } } @@ -332,7 +332,7 @@ impl MatchCx<'_> { Extern::Module(actual) => self.module(*expected, actual), _ => bail!("expected module, but found {}", actual.desc()), }, - EntityType::Event(_) => unimplemented!(), + EntityType::Tag(_) => unimplemented!(), } } @@ -373,6 +373,6 @@ fn entity_desc(ty: &EntityType) -> &'static str { EntityType::Function(_) => "func", EntityType::Instance(_) => "instance", EntityType::Module(_) => "module", - EntityType::Event(_) => "event", + EntityType::Tag(_) => "tag", } } diff --git a/crates/wast/Cargo.toml b/crates/wast/Cargo.toml index 22a3e08a0a..a010884a15 100644 --- a/crates/wast/Cargo.toml +++ b/crates/wast/Cargo.toml @@ -12,7 +12,7 @@ edition = "2018" [dependencies] anyhow = "1.0.19" wasmtime = { path = "../wasmtime", version = "0.29.0", default-features = false } -wast = "36.0.0" +wast = "37.0.0" [badges] maintenance = { status = "actively-developed" } diff --git a/crates/wast/src/wast.rs b/crates/wast/src/wast.rs index c0f39b7eca..a2fc29a3dd 100644 --- a/crates/wast/src/wast.rs +++ b/crates/wast/src/wast.rs @@ -302,9 +302,15 @@ impl WastContext { } AssertInvalid { span: _, - mut module, + module, message, } => { + let mut module = match module { + wast::QuoteModule::Module(m) => m, + // This is a `*.wat` parser test which we're not + // interested in. + wast::QuoteModule::Quote(_) => return Ok(()), + }; let bytes = module.encode()?; let err = match self.module(None, &bytes) { Ok(()) => bail!("expected module to fail to build"), @@ -354,6 +360,7 @@ impl WastContext { ) } } + AssertUncaughtException { .. } => bail!("unimplemented assert_uncaught_exception"), } Ok(())