mirror of
https://github.com/fluencelabs/wasmer
synced 2025-06-24 22:21:32 +00:00
Cranelift backend update to fork of clif version 0.43.1
This commit is contained in:
@ -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(())
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ 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)) {
|
||||
@ -42,7 +42,7 @@ fn get_isa() -> Box<dyn isa::TargetIsa> {
|
||||
}
|
||||
|
||||
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)
|
||||
|
@ -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,
|
||||
|
@ -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},
|
||||
@ -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,
|
||||
@ -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();
|
||||
|
@ -1,4 +1,5 @@
|
||||
use crate::cache::TrampolineCache;
|
||||
use crate::resolver::NoopStackmapSink;
|
||||
use cranelift_codegen::{
|
||||
binemit::{NullTrapSink, Reloc, RelocSink},
|
||||
cursor::{Cursor, FuncCursor},
|
||||
@ -19,6 +20,11 @@ struct NullRelocSink {}
|
||||
impl RelocSink for NullRelocSink {
|
||||
fn reloc_ebb(&mut self, _: u32, _: Reloc, _: u32) {}
|
||||
fn reloc_external(&mut self, _: u32, _: Reloc, _: &ir::ExternalName, _: i64) {}
|
||||
|
||||
fn reloc_constant(&mut self, _: u32, _: Reloc, _: u32) {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn reloc_jt(&mut self, _: u32, _: Reloc, _: ir::JumpTable) {}
|
||||
}
|
||||
|
||||
@ -89,12 +95,13 @@ impl Trampolines {
|
||||
ctx.func = trampoline_func;
|
||||
|
||||
let mut code_buf = Vec::new();
|
||||
|
||||
let mut stackmap_sink = NoopStackmapSink {};
|
||||
ctx.compile_and_emit(
|
||||
isa,
|
||||
&mut code_buf,
|
||||
&mut NullRelocSink {},
|
||||
&mut NullTrapSink {},
|
||||
&mut stackmap_sink,
|
||||
)
|
||||
.expect("unable to compile trampolines");
|
||||
ctx.clear();
|
||||
|
Reference in New Issue
Block a user