Update to cranelift 0.51.

This commit is contained in:
Nick Lewycky 2019-12-17 12:57:18 -08:00
parent 4018494f6e
commit c2f287e65b
3 changed files with 846 additions and 776 deletions

1495
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -12,13 +12,13 @@ readme = "README.md"
[dependencies]
wasmer-runtime-core = { path = "../runtime-core", version = "0.12.0" }
cranelift-native = "0.44.0"
cranelift-codegen = "0.44.0"
cranelift-entity = "0.44.0"
cranelift-frontend = { package = "wasmer-clif-fork-frontend", version = "0.44.0" }
cranelift-wasm = { package = "wasmer-clif-fork-wasm", version = "0.44.0" }
target-lexicon = "0.8.1"
wasmparser = "0.39.1"
cranelift-native = { git = "https://github.com/wasmerio/cranelift", branch = "wasmer" }
cranelift-codegen = { git = "https://github.com/wasmerio/cranelift", branch = "wasmer" }
cranelift-entity = { git = "https://github.com/wasmerio/cranelift", branch = "wasmer" }
cranelift-frontend = { git = "https://github.com/wasmerio/cranelift", branch = "wasmer" }
cranelift-wasm = { git = "https://github.com/wasmerio/cranelift", branch = "wasmer" }
target-lexicon = "0.9"
wasmparser = "0.39.2"
byteorder = "1.3.2"
nix = "0.15.0"
libc = "0.2.60"

View File

@ -11,9 +11,9 @@ use cranelift_codegen::ir::{self, Ebb, Function, InstBuilder};
use cranelift_codegen::isa::CallConv;
use cranelift_codegen::{cursor::FuncCursor, isa};
use cranelift_frontend::{FunctionBuilder, Position, Variable};
use cranelift_wasm::{self, FuncTranslator};
use cranelift_wasm::{self, FuncTranslator, ModuleTranslationState};
use cranelift_wasm::{get_vmctx_value_label, translate_operator};
use cranelift_wasm::{FuncEnvironment, ReturnMode, WasmError};
use cranelift_wasm::{FuncEnvironment, ReturnMode, TargetEnvironment, WasmError};
use std::mem;
use std::sync::{Arc, RwLock};
use wasmer_runtime_core::error::CompileError;
@ -247,7 +247,7 @@ pub struct FunctionEnvironment {
clif_signatures: Map<SigIndex, ir::Signature>,
}
impl FuncEnvironment for FunctionEnvironment {
impl TargetEnvironment for FunctionEnvironment {
/// Gets configuration information needed for compiling functions
fn target_config(&self) -> isa::TargetFrontendConfig {
self.target_config
@ -265,6 +265,13 @@ impl FuncEnvironment for FunctionEnvironment {
self.target_config().pointer_bytes()
}
/// Return Cranelift reference type.
fn reference_type(&self) -> ir::Type {
ir::types::R64
}
}
impl FuncEnvironment for FunctionEnvironment {
/// Sets up the necessary preamble definitions in `func` to access the global identified
/// by `index`.
///
@ -802,7 +809,6 @@ impl FuncEnvironment for FunctionEnvironment {
}
}
}
/// Generates code corresponding to wasm `memory.grow`.
///
/// `index` refers to the linear memory to query.
@ -931,6 +937,94 @@ impl FuncEnvironment for FunctionEnvironment {
Ok(*pos.func.dfg.inst_results(call_inst).first().unwrap())
}
fn translate_memory_copy(
&mut self,
_pos: FuncCursor,
_clif_mem_index: cranelift_wasm::MemoryIndex,
_heap: ir::Heap,
_dst: ir::Value,
_src: ir::Value,
_len: ir::Value,
) -> cranelift_wasm::WasmResult<()> {
unimplemented!("memory.copy not yet implemented");
}
fn translate_memory_fill(
&mut self,
_pos: FuncCursor,
_clif_mem_index: cranelift_wasm::MemoryIndex,
_heap: ir::Heap,
_dst: ir::Value,
_val: ir::Value,
_len: ir::Value,
) -> cranelift_wasm::WasmResult<()> {
unimplemented!("memory.fill not yet implemented");
}
fn translate_memory_init(
&mut self,
_pos: FuncCursor,
_clif_mem_index: cranelift_wasm::MemoryIndex,
_heap: ir::Heap,
_seg_index: u32,
_dst: ir::Value,
_src: ir::Value,
_len: ir::Value,
) -> cranelift_wasm::WasmResult<()> {
unimplemented!("memory.init not yet implemented");
}
fn translate_data_drop(
&mut self,
_pos: FuncCursor,
_seg_index: u32,
) -> cranelift_wasm::WasmResult<()> {
unimplemented!("data.drop not yet implemented");
}
fn translate_table_size(
&mut self,
_pos: FuncCursor,
_index: cranelift_wasm::TableIndex,
_table: ir::Table,
) -> cranelift_wasm::WasmResult<ir::Value> {
unimplemented!("table.size not yet implemented");
}
fn translate_table_copy(
&mut self,
_pos: FuncCursor,
_dst_table_index: cranelift_wasm::TableIndex,
_dst_table: ir::Table,
_src_table_index: cranelift_wasm::TableIndex,
_src_table: ir::Table,
_dst: ir::Value,
_src: ir::Value,
_len: ir::Value,
) -> cranelift_wasm::WasmResult<()> {
unimplemented!("table.copy yet implemented");
}
fn translate_table_init(
&mut self,
_pos: FuncCursor,
_seg_index: u32,
_table_index: cranelift_wasm::TableIndex,
_table: ir::Table,
_dst: ir::Value,
_src: ir::Value,
_len: ir::Value,
) -> cranelift_wasm::WasmResult<()> {
unimplemented!("table.init yet implemented");
}
fn translate_elem_drop(
&mut self,
_pos: FuncCursor,
_seg_index: u32,
) -> cranelift_wasm::WasmResult<()> {
unimplemented!("elem.drop yet implemented");
}
}
impl FunctionEnvironment {
@ -1016,8 +1110,15 @@ impl FunctionCodeGenerator<CodegenError> for CraneliftFunctionCodeGenerator {
&mut self.func_translator.func_ctx,
&mut self.position,
);
let state = &mut self.func_translator.state;
translate_operator(op, &mut builder, state, &mut self.func_env)?;
let module_state = ModuleTranslationState::new();
let func_state = &mut self.func_translator.state;
translate_operator(
&module_state,
op,
&mut builder,
func_state,
&mut self.func_env,
)?;
Ok(())
}