Update to wasmparser 0.31.0 and goblin 0.0.22.
This commit is contained in:
committed by
Benjamin Bouvier
parent
83715d638b
commit
ccd77c1d0b
@@ -13,7 +13,7 @@ edition = "2018"
|
|||||||
cranelift-codegen = { path = "../cranelift-codegen", version = "0.30.0" }
|
cranelift-codegen = { path = "../cranelift-codegen", version = "0.30.0" }
|
||||||
cranelift-module = { path = "../cranelift-module", version = "0.30.0" }
|
cranelift-module = { path = "../cranelift-module", version = "0.30.0" }
|
||||||
faerie = "0.10.0"
|
faerie = "0.10.0"
|
||||||
goblin = "0.0.21"
|
goblin = "0.0.22"
|
||||||
failure = "0.1.2"
|
failure = "0.1.2"
|
||||||
target-lexicon = "0.4.0"
|
target-lexicon = "0.4.0"
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ keywords = ["webassembly", "wasm"]
|
|||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
wasmparser = { version = "0.29.2", default-features = false }
|
wasmparser = { version = "0.31.0", default-features = false }
|
||||||
cranelift-codegen = { path = "../cranelift-codegen", version = "0.30.0", default-features = false }
|
cranelift-codegen = { path = "../cranelift-codegen", version = "0.30.0", default-features = false }
|
||||||
cranelift-entity = { path = "../cranelift-entity", version = "0.30.0", default-features = false }
|
cranelift-entity = { path = "../cranelift-entity", version = "0.30.0", default-features = false }
|
||||||
cranelift-frontend = { path = "../cranelift-frontend", version = "0.30.0", default-features = false }
|
cranelift-frontend = { path = "../cranelift-frontend", version = "0.30.0", default-features = false }
|
||||||
|
|||||||
@@ -25,7 +25,9 @@
|
|||||||
use super::{hash_map, HashMap};
|
use super::{hash_map, HashMap};
|
||||||
use crate::environ::{FuncEnvironment, GlobalVariable, ReturnMode, WasmError, WasmResult};
|
use crate::environ::{FuncEnvironment, GlobalVariable, ReturnMode, WasmError, WasmResult};
|
||||||
use crate::state::{ControlStackFrame, TranslationState};
|
use crate::state::{ControlStackFrame, TranslationState};
|
||||||
use crate::translation_utils::{f32_translation, f64_translation, num_return_values, type_to_type};
|
use crate::translation_utils::{
|
||||||
|
blocktype_to_type, f32_translation, f64_translation, num_return_values,
|
||||||
|
};
|
||||||
use crate::translation_utils::{FuncIndex, MemoryIndex, SignatureIndex, TableIndex};
|
use crate::translation_utils::{FuncIndex, MemoryIndex, SignatureIndex, TableIndex};
|
||||||
use core::{i32, u32};
|
use core::{i32, u32};
|
||||||
use cranelift_codegen::ir::condcodes::{FloatCC, IntCC};
|
use cranelift_codegen::ir::condcodes::{FloatCC, IntCC};
|
||||||
@@ -130,7 +132,7 @@ pub fn translate_operator<FE: FuncEnvironment + ?Sized>(
|
|||||||
***********************************************************************************/
|
***********************************************************************************/
|
||||||
Operator::Block { ty } => {
|
Operator::Block { ty } => {
|
||||||
let next = builder.create_ebb();
|
let next = builder.create_ebb();
|
||||||
if let Ok(ty_cre) = type_to_type(ty) {
|
if let Ok(ty_cre) = blocktype_to_type(ty) {
|
||||||
builder.append_ebb_param(next, ty_cre);
|
builder.append_ebb_param(next, ty_cre);
|
||||||
}
|
}
|
||||||
state.push_block(next, num_return_values(ty));
|
state.push_block(next, num_return_values(ty));
|
||||||
@@ -138,7 +140,7 @@ pub fn translate_operator<FE: FuncEnvironment + ?Sized>(
|
|||||||
Operator::Loop { ty } => {
|
Operator::Loop { ty } => {
|
||||||
let loop_body = builder.create_ebb();
|
let loop_body = builder.create_ebb();
|
||||||
let next = builder.create_ebb();
|
let next = builder.create_ebb();
|
||||||
if let Ok(ty_cre) = type_to_type(ty) {
|
if let Ok(ty_cre) = blocktype_to_type(ty) {
|
||||||
builder.append_ebb_param(next, ty_cre);
|
builder.append_ebb_param(next, ty_cre);
|
||||||
}
|
}
|
||||||
builder.ins().jump(loop_body, &[]);
|
builder.ins().jump(loop_body, &[]);
|
||||||
@@ -156,7 +158,7 @@ pub fn translate_operator<FE: FuncEnvironment + ?Sized>(
|
|||||||
// and we add nothing;
|
// and we add nothing;
|
||||||
// - either the If have an Else clause, in that case the destination of this jump
|
// - either the If have an Else clause, in that case the destination of this jump
|
||||||
// instruction will be changed later when we translate the Else operator.
|
// instruction will be changed later when we translate the Else operator.
|
||||||
if let Ok(ty_cre) = type_to_type(ty) {
|
if let Ok(ty_cre) = blocktype_to_type(ty) {
|
||||||
builder.append_ebb_param(if_not, ty_cre);
|
builder.append_ebb_param(if_not, ty_cre);
|
||||||
}
|
}
|
||||||
state.push_if(jump_inst, if_not, num_return_values(ty));
|
state.push_if(jump_inst, if_not, num_return_values(ty));
|
||||||
|
|||||||
@@ -119,6 +119,14 @@ pub fn type_to_type(ty: wasmparser::Type) -> Result<ir::Type, ()> {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Helper function translating wasmparser block signatures to Cranelift types when possible.
|
||||||
|
pub fn blocktype_to_type(ty: wasmparser::TypeOrFuncType) -> Result<ir::Type, ()> {
|
||||||
|
match ty {
|
||||||
|
wasmparser::TypeOrFuncType::Type(ty) => type_to_type(ty),
|
||||||
|
wasmparser::TypeOrFuncType::FuncType(_) => unimplemented!("multi-value block signatures"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Turns a `wasmparser` `f32` into a `Cranelift` one.
|
/// Turns a `wasmparser` `f32` into a `Cranelift` one.
|
||||||
pub fn f32_translation(x: wasmparser::Ieee32) -> ir::immediates::Ieee32 {
|
pub fn f32_translation(x: wasmparser::Ieee32) -> ir::immediates::Ieee32 {
|
||||||
ir::immediates::Ieee32::with_bits(x.bits())
|
ir::immediates::Ieee32::with_bits(x.bits())
|
||||||
@@ -130,14 +138,17 @@ pub fn f64_translation(x: wasmparser::Ieee64) -> ir::immediates::Ieee64 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Translate a `wasmparser` type into its `Cranelift` equivalent, when possible
|
/// Translate a `wasmparser` type into its `Cranelift` equivalent, when possible
|
||||||
pub fn num_return_values(ty: wasmparser::Type) -> usize {
|
pub fn num_return_values(ty: wasmparser::TypeOrFuncType) -> usize {
|
||||||
match ty {
|
match ty {
|
||||||
|
wasmparser::TypeOrFuncType::Type(ty) => match ty {
|
||||||
wasmparser::Type::EmptyBlockType => 0,
|
wasmparser::Type::EmptyBlockType => 0,
|
||||||
wasmparser::Type::I32
|
wasmparser::Type::I32
|
||||||
| wasmparser::Type::F32
|
| wasmparser::Type::F32
|
||||||
| wasmparser::Type::I64
|
| wasmparser::Type::I64
|
||||||
| wasmparser::Type::F64 => 1,
|
| wasmparser::Type::F64 => 1,
|
||||||
_ => panic!("unsupported return value type"),
|
_ => panic!("unsupported return value type"),
|
||||||
|
},
|
||||||
|
wasmparser::TypeOrFuncType::FuncType(_) => unimplemented!("multi-value block signatures"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user