Use function defined in wasmer-runtime-core instead of our own copy of it.

This commit is contained in:
Nick Lewycky
2019-12-17 15:12:54 -08:00
parent f9bb579c05
commit 6a0a4390c1
2 changed files with 6 additions and 20 deletions

View File

@ -1,7 +1,7 @@
use crate::{ use crate::{
backend::LLVMBackend, backend::LLVMBackend,
intrinsics::{tbaa_label, CtxType, GlobalCache, Intrinsics, MemoryCache}, intrinsics::{tbaa_label, CtxType, GlobalCache, Intrinsics, MemoryCache},
read_info::{blocktype_to_type, type_to_type}, read_info::blocktype_to_type,
stackmap::{StackmapEntry, StackmapEntryKind, StackmapRegistry, ValueSemantic}, stackmap::{StackmapEntry, StackmapEntryKind, StackmapRegistry, ValueSemantic},
state::{ControlFrame, ExtraInfo, IfElseState, State}, state::{ControlFrame, ExtraInfo, IfElseState, State},
trampolines::generate_trampolines, trampolines::generate_trampolines,
@ -34,6 +34,7 @@ use wasmer_runtime_core::{
codegen::*, codegen::*,
memory::MemoryType, memory::MemoryType,
module::{ModuleInfo, ModuleInner}, module::{ModuleInfo, ModuleInner},
parse::wp_type_to_type,
structures::{Map, TypedIndex}, structures::{Map, TypedIndex},
types::{ types::{
FuncIndex, FuncSig, GlobalIndex, LocalOrImport, MemoryIndex, SigIndex, TableIndex, Type, FuncIndex, FuncSig, GlobalIndex, LocalOrImport, MemoryIndex, SigIndex, TableIndex, Type,
@ -915,7 +916,7 @@ impl<'ctx> FunctionCodeGenerator<CodegenError> for LLVMFunctionCodeGenerator<'ct
fn feed_local(&mut self, ty: WpType, count: usize) -> Result<(), CodegenError> { fn feed_local(&mut self, ty: WpType, count: usize) -> Result<(), CodegenError> {
let param_len = self.num_params; let param_len = self.num_params;
let wasmer_ty = type_to_type(ty)?; let wasmer_ty = wp_type_to_type(ty)?;
let intrinsics = self.intrinsics.as_ref().unwrap(); let intrinsics = self.intrinsics.as_ref().unwrap();
let ty = type_to_llvm(intrinsics, wasmer_ty); let ty = type_to_llvm(intrinsics, wasmer_ty);

View File

@ -1,25 +1,10 @@
use wasmer_runtime_core::parse::wp_type_to_type;
use wasmer_runtime_core::types::Type; use wasmer_runtime_core::types::Type;
use wasmparser::{BinaryReaderError, Type as WpType, TypeOrFuncType as WpTypeOrFuncType}; use wasmparser::{BinaryReaderError, TypeOrFuncType as WpTypeOrFuncType};
pub fn type_to_type(ty: WpType) -> Result<Type, BinaryReaderError> {
Ok(match ty {
WpType::I32 => Type::I32,
WpType::I64 => Type::I64,
WpType::F32 => Type::F32,
WpType::F64 => Type::F64,
WpType::V128 => Type::V128,
_ => {
return Err(BinaryReaderError {
message: "that type is not supported as a wasmer type",
offset: -1isize as usize,
});
}
})
}
pub fn blocktype_to_type(ty: WpTypeOrFuncType) -> Result<Type, BinaryReaderError> { pub fn blocktype_to_type(ty: WpTypeOrFuncType) -> Result<Type, BinaryReaderError> {
match ty { match ty {
WpTypeOrFuncType::Type(inner_ty) => type_to_type(inner_ty), WpTypeOrFuncType::Type(inner_ty) => wp_type_to_type(inner_ty),
_ => { _ => {
return Err(BinaryReaderError { return Err(BinaryReaderError {
message: message: