Skip to content

Commit c6194d2

Browse files
committed
Try #518:
2 parents fada36a + adb257a commit c6194d2

File tree

10 files changed

+41
-24
lines changed

10 files changed

+41
-24
lines changed

lib/clif-backend/Cargo.toml

+6-6
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ edition = "2018"
99

1010
[dependencies]
1111
wasmer-runtime-core = { path = "../runtime-core", version = "0.5.1" }
12-
cranelift-native = { git = "https://github.com/wasmerio/cranelift.git", rev = "84ec31b0fdfc10db491ef950815ee2961db057cb" }
13-
cranelift-codegen = { git = "https://github.com/wasmerio/cranelift.git", rev = "84ec31b0fdfc10db491ef950815ee2961db057cb" }
14-
cranelift-entity = { git = "https://github.com/wasmerio/cranelift.git", rev = "84ec31b0fdfc10db491ef950815ee2961db057cb" }
15-
cranelift-frontend = { git = "https://github.com/wasmerio/cranelift.git", rev = "84ec31b0fdfc10db491ef950815ee2961db057cb" }
16-
cranelift-wasm = { git = "https://github.com/wasmerio/cranelift.git", rev = "84ec31b0fdfc10db491ef950815ee2961db057cb" }
12+
cranelift-native = { git = "https://github.com/wasmerio/cranelift.git", rev = "2af151541063384edeaa3f014d00597356f73901" }
13+
cranelift-codegen = { git = "https://github.com/wasmerio/cranelift.git", rev = "2af151541063384edeaa3f014d00597356f73901" }
14+
cranelift-entity = { git = "https://github.com/wasmerio/cranelift.git", rev = "2af151541063384edeaa3f014d00597356f73901" }
15+
cranelift-frontend = { git = "https://github.com/wasmerio/cranelift.git", rev = "2af151541063384edeaa3f014d00597356f73901" }
16+
cranelift-wasm = { git = "https://github.com/wasmerio/cranelift.git", rev = "2af151541063384edeaa3f014d00597356f73901" }
1717
hashbrown = "0.1"
1818
target-lexicon = "0.4.0"
19-
wasmparser = "0.29.2"
19+
wasmparser = "0.31.0"
2020
byteorder = "1"
2121
nix = "0.13.0"
2222
libc = "0.2.49"

lib/llvm-backend/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ edition = "2018"
77
[dependencies]
88
wasmer-runtime-core = { path = "../runtime-core", version = "0.5.1" }
99
inkwell = { git = "https://github.com/wasmerio/inkwell", branch = "llvm7-0" }
10-
wasmparser = "0.29.2"
10+
wasmparser = "0.31.0"
1111
hashbrown = "0.1.8"
1212
smallvec = "0.6.8"
1313
goblin = "0.0.20"

lib/llvm-backend/src/code.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use wasmparser::{BinaryReaderError, MemoryImmediate, Operator, Type as WpType};
2424

2525
use crate::backend::LLVMBackend;
2626
use crate::intrinsics::{CtxType, GlobalCache, Intrinsics, MemoryCache};
27-
use crate::read_info::type_to_type;
27+
use crate::read_info::{blocktype_to_type, type_to_type};
2828
use crate::state::{ControlFrame, IfElseState, State};
2929
use crate::trampolines::generate_trampolines;
3030

@@ -525,7 +525,7 @@ impl FunctionCodeGenerator<CodegenError> for LLVMFunctionCodeGenerator {
525525
let end_block = context.append_basic_block(&function, "end");
526526
builder.position_at_end(&end_block);
527527

528-
let phis = if let Ok(wasmer_ty) = type_to_type(ty) {
528+
let phis = if let Ok(wasmer_ty) = blocktype_to_type(ty) {
529529
let llvm_ty = type_to_llvm(intrinsics, wasmer_ty);
530530
[llvm_ty]
531531
.iter()
@@ -545,7 +545,7 @@ impl FunctionCodeGenerator<CodegenError> for LLVMFunctionCodeGenerator {
545545
builder.build_unconditional_branch(&loop_body);
546546

547547
builder.position_at_end(&loop_next);
548-
let phis = if let Ok(wasmer_ty) = type_to_type(ty) {
548+
let phis = if let Ok(wasmer_ty) = blocktype_to_type(ty) {
549549
let llvm_ty = type_to_llvm(intrinsics, wasmer_ty);
550550
[llvm_ty]
551551
.iter()
@@ -680,7 +680,7 @@ impl FunctionCodeGenerator<CodegenError> for LLVMFunctionCodeGenerator {
680680
let end_phis = {
681681
builder.position_at_end(&end_block);
682682

683-
let phis = if let Ok(wasmer_ty) = type_to_type(ty) {
683+
let phis = if let Ok(wasmer_ty) = blocktype_to_type(ty) {
684684
let llvm_ty = type_to_llvm(intrinsics, wasmer_ty);
685685
[llvm_ty]
686686
.iter()

lib/llvm-backend/src/read_info.rs

+14-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use wasmer_runtime_core::types::Type;
2-
use wasmparser::{BinaryReaderError, Type as WpType};
2+
use wasmparser::{BinaryReaderError, Type as WpType, TypeOrFuncType as WpTypeOrFuncType};
33

44
pub fn type_to_type(ty: WpType) -> Result<Type, BinaryReaderError> {
55
Ok(match ty {
@@ -21,3 +21,16 @@ pub fn type_to_type(ty: WpType) -> Result<Type, BinaryReaderError> {
2121
}
2222
})
2323
}
24+
25+
pub fn blocktype_to_type(ty: WpTypeOrFuncType) -> Result<Type, BinaryReaderError> {
26+
match ty {
27+
WpTypeOrFuncType::Type(inner_ty) => type_to_type(inner_ty),
28+
_ => {
29+
return Err(BinaryReaderError {
30+
message:
31+
"the wasmer llvm backend does not yet support the multi-value return extension",
32+
offset: -1isize as usize,
33+
});
34+
}
35+
}
36+
}

lib/middleware-common/src/metering.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use wasmer_runtime_core::{
22
codegen::{Event, EventSink, FunctionMiddleware, InternalEvent},
33
module::ModuleInfo,
44
vm::{Ctx, InternalField},
5-
wasmparser::{Operator, Type as WpType},
5+
wasmparser::{Operator, Type as WpType, TypeOrFuncType as WpTypeOrFuncType},
66
Instance,
77
};
88

@@ -92,7 +92,7 @@ impl FunctionMiddleware for Metering {
9292
}));
9393
sink.push(Event::WasmOwned(Operator::I64GeU));
9494
sink.push(Event::WasmOwned(Operator::If {
95-
ty: WpType::EmptyBlockType,
95+
ty: WpTypeOrFuncType::Type(WpType::EmptyBlockType),
9696
}));
9797
sink.push(Event::Internal(InternalEvent::Breakpoint(Box::new(
9898
move |ctx| unsafe {

lib/runtime-abi/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ wasmer-runtime-core = { path = "../runtime-core" }
1313
hashbrown = "0.1"
1414
failure = "0.1"
1515
tar = "0.4"
16-
wasmparser = "0.29.2"
16+
wasmparser = "0.31.0"
1717
zstd = "0.4"
1818

1919
# [target.'cfg(unix)'.dependencies.zbox]

lib/runtime-core/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ edition = "2018"
1010
[dependencies]
1111
nix = "0.12.0"
1212
page_size = "0.4.1"
13-
wasmparser = "0.29.2"
13+
wasmparser = "0.31.0"
1414
parking_lot = "0.7.1"
1515
lazy_static = "1.2.0"
1616
indexmap = "1.0.2"

lib/runtime-core/src/parse.rs

+1
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ pub fn read_module<
9393
enable_reference_types: false,
9494
enable_simd: false,
9595
enable_bulk_memory: false,
96+
enable_multi_value: false,
9697
},
9798
mutable_global_imports: false,
9899
}),

lib/singlepass-backend/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ edition = "2018"
99

1010
[dependencies]
1111
wasmer-runtime-core = { path = "../runtime-core", version = "0.5.1" }
12-
wasmparser = "0.29.2"
12+
wasmparser = "0.31.0"
1313
dynasm = "0.3.2"
1414
dynasmrt = "0.3.1"
1515
lazy_static = "1.2.0"

lib/singlepass-backend/src/codegen_x64.rs

+10-7
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ use wasmer_runtime_core::{
2929
},
3030
vm::{self, LocalGlobal, LocalTable, INTERNALS_SIZE},
3131
};
32-
use wasmparser::{Operator, Type as WpType};
32+
use wasmparser::{Operator, Type as WpType, TypeOrFuncType as WpTypeOrFuncType};
3333

3434
lazy_static! {
3535
/// 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<CodegenError> for X64FunctionCode {
33353335
loop_like: false,
33363336
if_else: IfElseState::If(label_else),
33373337
returns: match ty {
3338-
WpType::EmptyBlockType => smallvec![],
3339-
_ => smallvec![ty],
3338+
WpTypeOrFuncType::Type(WpType::EmptyBlockType) => smallvec![],
3339+
WpTypeOrFuncType::Type(inner_ty) => smallvec![inner_ty],
3340+
_ => panic!("multi-value returns not yet implemented"),
33403341
},
33413342
value_stack_depth: self.value_stack.len(),
33423343
});
@@ -3434,8 +3435,9 @@ impl FunctionCodeGenerator<CodegenError> for X64FunctionCode {
34343435
loop_like: false,
34353436
if_else: IfElseState::None,
34363437
returns: match ty {
3437-
WpType::EmptyBlockType => smallvec![],
3438-
_ => smallvec![ty],
3438+
WpTypeOrFuncType::Type(WpType::EmptyBlockType) => smallvec![],
3439+
WpTypeOrFuncType::Type(inner_ty) => smallvec![inner_ty],
3440+
_ => panic!("multi-value returns not yet implemented"),
34393441
},
34403442
value_stack_depth: self.value_stack.len(),
34413443
});
@@ -3447,8 +3449,9 @@ impl FunctionCodeGenerator<CodegenError> for X64FunctionCode {
34473449
loop_like: true,
34483450
if_else: IfElseState::None,
34493451
returns: match ty {
3450-
WpType::EmptyBlockType => smallvec![],
3451-
_ => smallvec![ty],
3452+
WpTypeOrFuncType::Type(WpType::EmptyBlockType) => smallvec![],
3453+
WpTypeOrFuncType::Type(inner_ty) => smallvec![inner_ty],
3454+
_ => panic!("multi-value returns not yet implemented"),
34523455
},
34533456
value_stack_depth: self.value_stack.len(),
34543457
});

0 commit comments

Comments
 (0)