Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cranelift backend update to fork of clif version 0.43.1 #822

Merged
merged 5 commits into from
Sep 24, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
128 changes: 65 additions & 63 deletions Cargo.lock

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

18 changes: 9 additions & 9 deletions lib/clif-backend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ readme = "README.md"

[dependencies]
wasmer-runtime-core = { path = "../runtime-core", version = "0.7.0" }
cranelift-native = { version = "0.31" }
cranelift-codegen = { version = "0.31" }
cranelift-entity = { version = "0.31" }
cranelift-frontend = { package = "wasmer-clif-fork-frontend", version = "0.33" }
cranelift-wasm = { package = "wasmer-clif-fork-wasm", version = "0.33" }
target-lexicon = "0.4"
wasmparser = "0.35.1"
byteorder = "1.3"
nix = "0.15"
cranelift-native = { git = "https://github.com/wasmerio/cranelift", branch = "feature/merge-cranelift-0-43-1" }
cranelift-codegen = { git = "https://github.com/wasmerio/cranelift", branch = "feature/merge-cranelift-0-43-1" }
cranelift-entity = { git = "https://github.com/wasmerio/cranelift", branch = "feature/merge-cranelift-0-43-1" }
cranelift-frontend = { git = "https://github.com/wasmerio/cranelift", branch = "feature/merge-cranelift-0-43-1" }
cranelift-wasm = { git = "https://github.com/wasmerio/cranelift", branch = "feature/merge-cranelift-0-43-1" }
bjfish marked this conversation as resolved.
Show resolved Hide resolved
target-lexicon = "0.8.1"
wasmparser = "0.37.0"
byteorder = "1.3.2"
nix = "0.15.0"
libc = "0.2.60"
rayon = "1.1"

Expand Down
13 changes: 12 additions & 1 deletion lib/clif-backend/src/code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1117,7 +1117,18 @@ impl FunctionCodeGenerator<CodegenError> for CraneliftFunctionCodeGenerator {

fn feed_local(&mut self, ty: WpType, n: usize) -> Result<(), CodegenError> {
let mut next_local = self.next_local;
cranelift_wasm::declare_locals(&mut self.builder(), n as u32, ty, &mut next_local)?;
let mut builder = FunctionBuilder::new(
&mut self.func,
&mut self.func_translator.func_ctx,
&mut self.position,
);
cranelift_wasm::declare_locals(
&mut builder,
n as u32,
ty,
&mut next_local,
&mut self.func_env,
)?;
self.next_local = next_local;
Ok(())
}
Expand Down
4 changes: 2 additions & 2 deletions lib/clif-backend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ extern crate serde;
fn get_isa() -> Box<dyn isa::TargetIsa> {
let flags = {
let mut builder = settings::builder();
builder.set("opt_level", "best").unwrap();
builder.set("opt_level", "speed_and_size").unwrap();
builder.set("jump_tables_enabled", "false").unwrap();

if cfg!(not(test)) {
builder.set("enable_verifier", "false").unwrap();
}

let flags = settings::Flags::new(builder);
debug_assert_eq!(flags.opt_level(), settings::OptLevel::Best);
debug_assert_eq!(flags.opt_level(), settings::OptLevel::SpeedAndSize);
flags
};
isa::lookup(Triple::host()).unwrap().finish(flags)
Expand Down
5 changes: 5 additions & 0 deletions lib/clif-backend/src/relocation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,11 @@ impl binemit::RelocSink for RelocSink {
}
}
}

fn reloc_constant(&mut self, _: u32, _: cranelift_codegen::binemit::Reloc, _: u32) {
unimplemented!()
}

fn reloc_jt(
&mut self,
_offset: binemit::CodeOffset,
Expand Down
13 changes: 11 additions & 2 deletions lib/clif-backend/src/resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ use crate::{
use rayon::prelude::*;

use byteorder::{ByteOrder, LittleEndian};
use cranelift_codegen::{ir, isa, Context};
use cranelift_codegen::{
binemit::{Stackmap, StackmapSink},
ir, isa, Context,
};
use std::{
mem,
ptr::{write_unaligned, NonNull},
Expand Down Expand Up @@ -58,6 +61,11 @@ pub struct FuncResolverBuilder {
import_len: usize,
}

pub struct NoopStackmapSink {}
impl StackmapSink for NoopStackmapSink {
fn add_stackmap(&mut self, _: u32, _: Stackmap) {}
}

impl FuncResolverBuilder {
pub fn new_from_backend_cache(
backend_cache: BackendCache,
Expand Down Expand Up @@ -109,12 +117,13 @@ impl FuncResolverBuilder {
ctx.func = func.to_owned();
let mut reloc_sink = RelocSink::new();
let mut local_trap_sink = LocalTrapSink::new();

let mut stackmap_sink = NoopStackmapSink {};
ctx.compile_and_emit(
isa,
&mut code_buf,
&mut reloc_sink,
&mut local_trap_sink,
&mut stackmap_sink,
)
.map_err(|e| CompileError::InternalError { msg: e.to_string() })?;
ctx.clear();
Expand Down
Loading