diff --git a/lib/clif-backend/Cargo.toml b/lib/clif-backend/Cargo.toml index 0cb1511f9c8..e6ce8f28560 100644 --- a/lib/clif-backend/Cargo.toml +++ b/lib/clif-backend/Cargo.toml @@ -9,14 +9,14 @@ edition = "2018" [dependencies] wasmer-runtime-core = { path = "../runtime-core", version = "0.5.1" } -cranelift-native = { git = "https://github.com/wasmerio/cranelift.git", rev = "84ec31b0fdfc10db491ef950815ee2961db057cb" } -cranelift-codegen = { git = "https://github.com/wasmerio/cranelift.git", rev = "84ec31b0fdfc10db491ef950815ee2961db057cb" } -cranelift-entity = { git = "https://github.com/wasmerio/cranelift.git", rev = "84ec31b0fdfc10db491ef950815ee2961db057cb" } -cranelift-frontend = { git = "https://github.com/wasmerio/cranelift.git", rev = "84ec31b0fdfc10db491ef950815ee2961db057cb" } -cranelift-wasm = { git = "https://github.com/wasmerio/cranelift.git", rev = "84ec31b0fdfc10db491ef950815ee2961db057cb" } +cranelift-native = { git = "https://github.com/wasmerio/cranelift.git", rev = "2ada531d79b34a9e6c94c81f2615677e22d68780" } +cranelift-codegen = { git = "https://github.com/wasmerio/cranelift.git", rev = "2ada531d79b34a9e6c94c81f2615677e22d68780" } +cranelift-entity = { git = "https://github.com/wasmerio/cranelift.git", rev = "2ada531d79b34a9e6c94c81f2615677e22d68780" } +cranelift-frontend = { git = "https://github.com/wasmerio/cranelift.git", rev = "2ada531d79b34a9e6c94c81f2615677e22d68780" } +cranelift-wasm = { git = "https://github.com/wasmerio/cranelift.git", rev = "2ada531d79b34a9e6c94c81f2615677e22d68780" } hashbrown = "0.1" target-lexicon = "0.4.0" -wasmparser = "0.29.2" +wasmparser = "0.32.1" byteorder = "1" nix = "0.13.0" libc = "0.2.49" diff --git a/lib/clif-backend/src/lib.rs b/lib/clif-backend/src/lib.rs index 074b0b670c4..4f11d6ea77d 100644 --- a/lib/clif-backend/src/lib.rs +++ b/lib/clif-backend/src/lib.rs @@ -25,6 +25,7 @@ fn get_isa() -> Box { let flags = { let mut builder = settings::builder(); builder.set("opt_level", "best").unwrap(); + builder.set("jump_tables_enabled", "false").unwrap(); if cfg!(not(test)) { builder.set("enable_verifier", "false").unwrap(); diff --git a/lib/llvm-backend/Cargo.toml b/lib/llvm-backend/Cargo.toml index b84273e625b..5b0cac2b142 100644 --- a/lib/llvm-backend/Cargo.toml +++ b/lib/llvm-backend/Cargo.toml @@ -7,7 +7,7 @@ edition = "2018" [dependencies] wasmer-runtime-core = { path = "../runtime-core", version = "0.5.1" } inkwell = { git = "https://github.com/wasmerio/inkwell", branch = "llvm7-0" } -wasmparser = "0.29.2" +wasmparser = "0.32.1" hashbrown = "0.1.8" smallvec = "0.6.8" goblin = "0.0.20" diff --git a/lib/llvm-backend/src/code.rs b/lib/llvm-backend/src/code.rs index 1a84a15c748..0359b3dd8b9 100644 --- a/lib/llvm-backend/src/code.rs +++ b/lib/llvm-backend/src/code.rs @@ -24,7 +24,7 @@ use wasmparser::{BinaryReaderError, MemoryImmediate, Operator, Type as WpType}; use crate::backend::LLVMBackend; use crate::intrinsics::{CtxType, GlobalCache, Intrinsics, MemoryCache}; -use crate::read_info::type_to_type; +use crate::read_info::{blocktype_to_type, type_to_type}; use crate::state::{ControlFrame, IfElseState, State}; use crate::trampolines::generate_trampolines; @@ -525,7 +525,7 @@ impl FunctionCodeGenerator for LLVMFunctionCodeGenerator { let end_block = context.append_basic_block(&function, "end"); builder.position_at_end(&end_block); - let phis = if let Ok(wasmer_ty) = type_to_type(ty) { + let phis = if let Ok(wasmer_ty) = blocktype_to_type(ty) { let llvm_ty = type_to_llvm(intrinsics, wasmer_ty); [llvm_ty] .iter() @@ -545,7 +545,7 @@ impl FunctionCodeGenerator for LLVMFunctionCodeGenerator { builder.build_unconditional_branch(&loop_body); builder.position_at_end(&loop_next); - let phis = if let Ok(wasmer_ty) = type_to_type(ty) { + let phis = if let Ok(wasmer_ty) = blocktype_to_type(ty) { let llvm_ty = type_to_llvm(intrinsics, wasmer_ty); [llvm_ty] .iter() @@ -680,7 +680,7 @@ impl FunctionCodeGenerator for LLVMFunctionCodeGenerator { let end_phis = { builder.position_at_end(&end_block); - let phis = if let Ok(wasmer_ty) = type_to_type(ty) { + let phis = if let Ok(wasmer_ty) = blocktype_to_type(ty) { let llvm_ty = type_to_llvm(intrinsics, wasmer_ty); [llvm_ty] .iter() diff --git a/lib/llvm-backend/src/read_info.rs b/lib/llvm-backend/src/read_info.rs index 572469ce2b2..fa5c017d30f 100644 --- a/lib/llvm-backend/src/read_info.rs +++ b/lib/llvm-backend/src/read_info.rs @@ -1,5 +1,5 @@ use wasmer_runtime_core::types::Type; -use wasmparser::{BinaryReaderError, Type as WpType}; +use wasmparser::{BinaryReaderError, Type as WpType, TypeOrFuncType as WpTypeOrFuncType}; pub fn type_to_type(ty: WpType) -> Result { Ok(match ty { @@ -21,3 +21,16 @@ pub fn type_to_type(ty: WpType) -> Result { } }) } + +pub fn blocktype_to_type(ty: WpTypeOrFuncType) -> Result { + match ty { + WpTypeOrFuncType::Type(inner_ty) => type_to_type(inner_ty), + _ => { + return Err(BinaryReaderError { + message: + "the wasmer llvm backend does not yet support the multi-value return extension", + offset: -1isize as usize, + }); + } + } +} diff --git a/lib/middleware-common/src/metering.rs b/lib/middleware-common/src/metering.rs index dd5b856b5dc..12d4ab24090 100644 --- a/lib/middleware-common/src/metering.rs +++ b/lib/middleware-common/src/metering.rs @@ -2,7 +2,7 @@ use wasmer_runtime_core::{ codegen::{Event, EventSink, FunctionMiddleware, InternalEvent}, module::ModuleInfo, vm::{Ctx, InternalField}, - wasmparser::{Operator, Type as WpType}, + wasmparser::{Operator, Type as WpType, TypeOrFuncType as WpTypeOrFuncType}, Instance, }; @@ -92,7 +92,7 @@ impl FunctionMiddleware for Metering { })); sink.push(Event::WasmOwned(Operator::I64GeU)); sink.push(Event::WasmOwned(Operator::If { - ty: WpType::EmptyBlockType, + ty: WpTypeOrFuncType::Type(WpType::EmptyBlockType), })); sink.push(Event::Internal(InternalEvent::Breakpoint(Box::new( move |ctx| unsafe { diff --git a/lib/runtime-abi/Cargo.toml b/lib/runtime-abi/Cargo.toml index 4deb4d7b3de..be15a3a2ccf 100644 --- a/lib/runtime-abi/Cargo.toml +++ b/lib/runtime-abi/Cargo.toml @@ -13,7 +13,7 @@ wasmer-runtime-core = { path = "../runtime-core" } hashbrown = "0.1" failure = "0.1" tar = "0.4" -wasmparser = "0.29.2" +wasmparser = "0.32.1" zstd = "0.4" # [target.'cfg(unix)'.dependencies.zbox] diff --git a/lib/runtime-core/Cargo.toml b/lib/runtime-core/Cargo.toml index 581dff7446f..7f716aea403 100644 --- a/lib/runtime-core/Cargo.toml +++ b/lib/runtime-core/Cargo.toml @@ -10,7 +10,7 @@ edition = "2018" [dependencies] nix = "0.12.0" page_size = "0.4.1" -wasmparser = "0.29.2" +wasmparser = "0.32.1" parking_lot = "0.7.1" lazy_static = "1.2.0" indexmap = "1.0.2" diff --git a/lib/runtime-core/src/parse.rs b/lib/runtime-core/src/parse.rs index 7a76a46ace3..b3bf141aed1 100644 --- a/lib/runtime-core/src/parse.rs +++ b/lib/runtime-core/src/parse.rs @@ -93,6 +93,7 @@ pub fn read_module< enable_reference_types: false, enable_simd: false, enable_bulk_memory: false, + enable_multi_value: false, }, mutable_global_imports: false, }), diff --git a/lib/singlepass-backend/Cargo.toml b/lib/singlepass-backend/Cargo.toml index e9de7088208..c9302fb0f25 100644 --- a/lib/singlepass-backend/Cargo.toml +++ b/lib/singlepass-backend/Cargo.toml @@ -9,7 +9,7 @@ edition = "2018" [dependencies] wasmer-runtime-core = { path = "../runtime-core", version = "0.5.1" } -wasmparser = "0.29.2" +wasmparser = "0.32.1" dynasm = "0.3.2" dynasmrt = "0.3.1" lazy_static = "1.2.0" diff --git a/lib/singlepass-backend/src/codegen_x64.rs b/lib/singlepass-backend/src/codegen_x64.rs index 636f596382b..23131b643b0 100644 --- a/lib/singlepass-backend/src/codegen_x64.rs +++ b/lib/singlepass-backend/src/codegen_x64.rs @@ -29,7 +29,7 @@ use wasmer_runtime_core::{ }, vm::{self, LocalGlobal, LocalTable, INTERNALS_SIZE}, }; -use wasmparser::{Operator, Type as WpType}; +use wasmparser::{Operator, Type as WpType, TypeOrFuncType as WpTypeOrFuncType}; lazy_static! { /// Performs a System V call to `target` with [stack_top..stack_base] as the argument list, from right to left. @@ -3335,8 +3335,9 @@ impl FunctionCodeGenerator for X64FunctionCode { loop_like: false, if_else: IfElseState::If(label_else), returns: match ty { - WpType::EmptyBlockType => smallvec![], - _ => smallvec![ty], + WpTypeOrFuncType::Type(WpType::EmptyBlockType) => smallvec![], + WpTypeOrFuncType::Type(inner_ty) => smallvec![inner_ty], + _ => panic!("multi-value returns not yet implemented"), }, value_stack_depth: self.value_stack.len(), }); @@ -3434,8 +3435,9 @@ impl FunctionCodeGenerator for X64FunctionCode { loop_like: false, if_else: IfElseState::None, returns: match ty { - WpType::EmptyBlockType => smallvec![], - _ => smallvec![ty], + WpTypeOrFuncType::Type(WpType::EmptyBlockType) => smallvec![], + WpTypeOrFuncType::Type(inner_ty) => smallvec![inner_ty], + _ => panic!("multi-value returns not yet implemented"), }, value_stack_depth: self.value_stack.len(), }); @@ -3447,8 +3449,9 @@ impl FunctionCodeGenerator for X64FunctionCode { loop_like: true, if_else: IfElseState::None, returns: match ty { - WpType::EmptyBlockType => smallvec![], - _ => smallvec![ty], + WpTypeOrFuncType::Type(WpType::EmptyBlockType) => smallvec![], + WpTypeOrFuncType::Type(inner_ty) => smallvec![inner_ty], + _ => panic!("multi-value returns not yet implemented"), }, value_stack_depth: self.value_stack.len(), });