mirror of
https://github.com/fluencelabs/wasmer
synced 2025-06-20 12:16:30 +00:00
Update for new wasmparser.rs version.
This commit is contained in:
@ -24,7 +24,7 @@ use wasmparser::{BinaryReaderError, MemoryImmediate, Operator, Type as WpType};
|
|||||||
|
|
||||||
use crate::backend::LLVMBackend;
|
use crate::backend::LLVMBackend;
|
||||||
use crate::intrinsics::{CtxType, GlobalCache, Intrinsics, MemoryCache};
|
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::state::{ControlFrame, IfElseState, State};
|
||||||
use crate::trampolines::generate_trampolines;
|
use crate::trampolines::generate_trampolines;
|
||||||
|
|
||||||
@ -525,7 +525,7 @@ impl FunctionCodeGenerator<CodegenError> for LLVMFunctionCodeGenerator {
|
|||||||
let end_block = context.append_basic_block(&function, "end");
|
let end_block = context.append_basic_block(&function, "end");
|
||||||
builder.position_at_end(&end_block);
|
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);
|
let llvm_ty = type_to_llvm(intrinsics, wasmer_ty);
|
||||||
[llvm_ty]
|
[llvm_ty]
|
||||||
.iter()
|
.iter()
|
||||||
@ -545,7 +545,7 @@ impl FunctionCodeGenerator<CodegenError> for LLVMFunctionCodeGenerator {
|
|||||||
builder.build_unconditional_branch(&loop_body);
|
builder.build_unconditional_branch(&loop_body);
|
||||||
|
|
||||||
builder.position_at_end(&loop_next);
|
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);
|
let llvm_ty = type_to_llvm(intrinsics, wasmer_ty);
|
||||||
[llvm_ty]
|
[llvm_ty]
|
||||||
.iter()
|
.iter()
|
||||||
@ -680,7 +680,7 @@ impl FunctionCodeGenerator<CodegenError> for LLVMFunctionCodeGenerator {
|
|||||||
let end_phis = {
|
let end_phis = {
|
||||||
builder.position_at_end(&end_block);
|
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);
|
let llvm_ty = type_to_llvm(intrinsics, wasmer_ty);
|
||||||
[llvm_ty]
|
[llvm_ty]
|
||||||
.iter()
|
.iter()
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use wasmer_runtime_core::types::Type;
|
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<Type, BinaryReaderError> {
|
pub fn type_to_type(ty: WpType) -> Result<Type, BinaryReaderError> {
|
||||||
Ok(match ty {
|
Ok(match ty {
|
||||||
@ -21,3 +21,15 @@ pub fn type_to_type(ty: WpType) -> Result<Type, BinaryReaderError> {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn blocktype_to_type(ty: WpTypeOrFuncType) -> Result<Type, BinaryReaderError> {
|
||||||
|
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,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -29,7 +29,7 @@ use wasmer_runtime_core::{
|
|||||||
},
|
},
|
||||||
vm::{self, LocalGlobal, LocalTable, INTERNALS_SIZE},
|
vm::{self, LocalGlobal, LocalTable, INTERNALS_SIZE},
|
||||||
};
|
};
|
||||||
use wasmparser::{Operator, Type as WpType};
|
use wasmparser::{Operator, Type as WpType, TypeOrFuncType as WpTypeOrFuncType};
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
/// Performs a System V call to `target` with [stack_top..stack_base] as the argument list, from right to left.
|
/// 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 {
|
|||||||
loop_like: false,
|
loop_like: false,
|
||||||
if_else: IfElseState::If(label_else),
|
if_else: IfElseState::If(label_else),
|
||||||
returns: match ty {
|
returns: match ty {
|
||||||
WpType::EmptyBlockType => smallvec![],
|
WpTypeOrFuncType::Type(WpType::EmptyBlockType) => smallvec![],
|
||||||
_ => smallvec![ty],
|
WpTypeOrFuncType::Type(inner_ty) => smallvec![inner_ty],
|
||||||
|
_ => panic!("multi-value returns not yet implemented"),
|
||||||
},
|
},
|
||||||
value_stack_depth: self.value_stack.len(),
|
value_stack_depth: self.value_stack.len(),
|
||||||
});
|
});
|
||||||
@ -3434,8 +3435,9 @@ impl FunctionCodeGenerator<CodegenError> for X64FunctionCode {
|
|||||||
loop_like: false,
|
loop_like: false,
|
||||||
if_else: IfElseState::None,
|
if_else: IfElseState::None,
|
||||||
returns: match ty {
|
returns: match ty {
|
||||||
WpType::EmptyBlockType => smallvec![],
|
WpTypeOrFuncType::Type(WpType::EmptyBlockType) => smallvec![],
|
||||||
_ => smallvec![ty],
|
WpTypeOrFuncType::Type(inner_ty) => smallvec![inner_ty],
|
||||||
|
_ => panic!("multi-value returns not yet implemented"),
|
||||||
},
|
},
|
||||||
value_stack_depth: self.value_stack.len(),
|
value_stack_depth: self.value_stack.len(),
|
||||||
});
|
});
|
||||||
@ -3447,8 +3449,9 @@ impl FunctionCodeGenerator<CodegenError> for X64FunctionCode {
|
|||||||
loop_like: true,
|
loop_like: true,
|
||||||
if_else: IfElseState::None,
|
if_else: IfElseState::None,
|
||||||
returns: match ty {
|
returns: match ty {
|
||||||
WpType::EmptyBlockType => smallvec![],
|
WpTypeOrFuncType::Type(WpType::EmptyBlockType) => smallvec![],
|
||||||
_ => smallvec![ty],
|
WpTypeOrFuncType::Type(inner_ty) => smallvec![inner_ty],
|
||||||
|
_ => panic!("multi-value returns not yet implemented"),
|
||||||
},
|
},
|
||||||
value_stack_depth: self.value_stack.len(),
|
value_stack_depth: self.value_stack.len(),
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user