Skip to content

Commit

Permalink
Merge pull request #1250 from wasmerio/feature/update-wasmparser
Browse files Browse the repository at this point in the history
Update wasmparser to 0.51.3 and clif forks to 0.59
  • Loading branch information
syrusakbary authored Feb 26, 2020
2 parents 6059c04 + a8b4f2a commit 73370b9
Show file tree
Hide file tree
Showing 14 changed files with 254 additions and 159 deletions.
72 changes: 46 additions & 26 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions lib/clif-backend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ readme = "README.md"

[dependencies]
wasmer-runtime-core = { path = "../runtime-core", version = "0.14.1" }
cranelift-native = "0.52.0"
cranelift-codegen = "0.52.0"
cranelift-entity = "0.52.0"
cranelift-frontend = { package = "wasmer-clif-fork-frontend", version = "0.52.0" }
cranelift-wasm = { package = "wasmer-clif-fork-wasm", version = "0.52.0" }
target-lexicon = "0.9"
wasmparser = "0.45.0"
cranelift-native = "0.59.0"
cranelift-codegen = "0.59.0"
cranelift-entity = "0.59.0"
cranelift-frontend = { package = "wasmer-clif-fork-frontend", version = "0.59.0" }
cranelift-wasm = { package = "wasmer-clif-fork-wasm", version = "0.59.0" }
target-lexicon = "0.10"
wasmparser = "0.51.3"
byteorder = "1.3.2"
nix = "0.15.0"
libc = "0.2.60"
Expand Down
92 changes: 79 additions & 13 deletions lib/clif-backend/src/code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ use crate::{
};

use cranelift_codegen::entity::EntityRef;
use cranelift_codegen::ir::{self, Ebb, Function, InstBuilder};
use cranelift_codegen::ir::{self, Block, Function, InstBuilder};
use cranelift_codegen::isa::CallConv;
use cranelift_codegen::{cursor::FuncCursor, isa};
use cranelift_frontend::{FunctionBuilder, Position, Variable};
use cranelift_wasm::{self, FuncTranslator, ModuleTranslationState};
use cranelift_wasm::{get_vmctx_value_label, translate_operator};
use cranelift_wasm::{FuncEnvironment, ReturnMode, TargetEnvironment, WasmError};

use std::mem;
use std::sync::{Arc, RwLock};
use wasmer_runtime_core::error::CompileError;
Expand Down Expand Up @@ -103,7 +104,7 @@ impl ModuleCodeGenerator<CraneliftFunctionCodeGenerator, Caller, CodegenError>
},
};

debug_assert_eq!(func_env.func.dfg.num_ebbs(), 0, "Function must be empty");
debug_assert_eq!(func_env.func.dfg.num_blocks(), 0, "Function must be empty");
debug_assert_eq!(func_env.func.dfg.num_insts(), 0, "Function must be empty");

let mut builder = FunctionBuilder::new(
Expand All @@ -115,20 +116,20 @@ impl ModuleCodeGenerator<CraneliftFunctionCodeGenerator, Caller, CodegenError>
// TODO srcloc
//builder.set_srcloc(cur_srcloc(&reader));

let entry_block = builder.create_ebb();
builder.append_ebb_params_for_function_params(entry_block);
let entry_block = builder.create_block();
builder.append_block_params_for_function_params(entry_block);
builder.switch_to_block(entry_block); // This also creates values for the arguments.
builder.seal_block(entry_block);
// Make sure the entry block is inserted in the layout before we make any callbacks to
// `environ`. The callback functions may need to insert things in the entry block.
builder.ensure_inserted_ebb();
builder.ensure_inserted_block();

declare_wasm_parameters(&mut builder, entry_block);

// Set up the translation state with a single pushed control block representing the whole
// function and its return values.
let exit_block = builder.create_ebb();
builder.append_ebb_params_for_function_returns(exit_block);
let exit_block = builder.create_block();
builder.append_block_params_for_function_returns(exit_block);
func_env
.func_translator
.state
Expand Down Expand Up @@ -1005,7 +1006,7 @@ impl FuncEnvironment for FunctionEnvironment {
_src: ir::Value,
_len: ir::Value,
) -> cranelift_wasm::WasmResult<()> {
unimplemented!("table.copy yet implemented");
unimplemented!("table.copy not yet implemented");
}

fn translate_table_init(
Expand All @@ -1018,15 +1019,80 @@ impl FuncEnvironment for FunctionEnvironment {
_src: ir::Value,
_len: ir::Value,
) -> cranelift_wasm::WasmResult<()> {
unimplemented!("table.init yet implemented");
unimplemented!("table.init not yet implemented");
}

fn translate_elem_drop(
&mut self,
_pos: FuncCursor,
_seg_index: u32,
) -> cranelift_wasm::WasmResult<()> {
unimplemented!("elem.drop yet implemented");
unimplemented!("elem.drop not yet implemented");
}

fn translate_table_grow(
&mut self,
_pos: FuncCursor,
_table_index: u32,
_delta: ir::Value,
_init_value: ir::Value,
) -> cranelift_wasm::WasmResult<ir::Value> {
unimplemented!("table.grow not yet implemented");
}

fn translate_table_get(
&mut self,
_pos: FuncCursor,
_table_index: u32,
_index: ir::Value,
) -> cranelift_wasm::WasmResult<ir::Value> {
unimplemented!("table.get not yet implemented");
}

fn translate_table_set(
&mut self,
_pos: FuncCursor,
_table_index: u32,
_value: ir::Value,
_index: ir::Value,
) -> cranelift_wasm::WasmResult<()> {
unimplemented!("table.set not yet implemented");
}

fn translate_table_fill(
&mut self,
_pos: FuncCursor,
_table_index: u32,
_dst: ir::Value,
_val: ir::Value,
_len: ir::Value,
) -> cranelift_wasm::WasmResult<()> {
unimplemented!("table.fill not yet implemented");
}

fn translate_ref_func(
&mut self,
_pos: FuncCursor,
_func_index: u32,
) -> cranelift_wasm::WasmResult<ir::Value> {
unimplemented!("ref.func not yet implemented");
}

fn translate_custom_global_get(
&mut self,
_pos: FuncCursor,
_global_index: cranelift_wasm::GlobalIndex,
) -> cranelift_wasm::WasmResult<ir::Value> {
unimplemented!("custom global.get not yet implemented");
}

fn translate_custom_global_set(
&mut self,
_pos: FuncCursor,
_global_index: cranelift_wasm::GlobalIndex,
_val: ir::Value,
) -> cranelift_wasm::WasmResult<()> {
unimplemented!("custom global.set not yet implemented");
}
}

Expand Down Expand Up @@ -1215,7 +1281,7 @@ fn pointer_type(mcg: &CraneliftModuleCodeGenerator) -> ir::Type {
/// Declare local variables for the signature parameters that correspond to WebAssembly locals.
///
/// Return the number of local variables declared.
fn declare_wasm_parameters(builder: &mut FunctionBuilder, entry_block: Ebb) -> usize {
fn declare_wasm_parameters(builder: &mut FunctionBuilder, entry_block: Block) -> usize {
let sig_len = builder.func.signature.params.len();
let mut next_local = 0;
for i in 0..sig_len {
Expand All @@ -1228,11 +1294,11 @@ fn declare_wasm_parameters(builder: &mut FunctionBuilder, entry_block: Ebb) -> u
builder.declare_var(local, param_type.value_type);
next_local += 1;

let param_value = builder.ebb_params(entry_block)[i];
let param_value = builder.block_params(entry_block)[i];
builder.def_var(local, param_value);
}
if param_type.purpose == ir::ArgumentPurpose::VMContext {
let param_value = builder.ebb_params(entry_block)[i];
let param_value = builder.block_params(entry_block)[i];
builder.set_val_label(param_value, get_vmctx_value_label());
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/clif-backend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ fn get_isa() -> Box<dyn isa::TargetIsa> {
let flags = {
let mut builder = settings::builder();
builder.set("opt_level", "speed_and_size").unwrap();
builder.set("jump_tables_enabled", "false").unwrap();
builder.set("enable_jump_tables", "false").unwrap();

if cfg!(test) || cfg!(debug_assertions) {
builder.set("enable_verifier", "true").unwrap();
Expand Down
2 changes: 1 addition & 1 deletion lib/clif-backend/src/relocation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ pub struct RelocSink {
}

impl binemit::RelocSink for RelocSink {
fn reloc_ebb(
fn reloc_block(
&mut self,
_offset: binemit::CodeOffset,
_reloc: binemit::Reloc,
Expand Down
Loading

0 comments on commit 73370b9

Please sign in to comment.