Remove sink arguments from compile_and_emit
The data can be accessed after the fact using context.mach_compile_result
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
use cranelift::prelude::*;
|
||||
use cranelift_codegen::binemit::{NullStackMapSink, NullTrapSink};
|
||||
use cranelift_codegen::settings::{self, Configurable};
|
||||
use cranelift_jit::{JITBuilder, JITModule};
|
||||
use cranelift_module::{default_libcall_names, Linkage, Module};
|
||||
@@ -48,11 +47,7 @@ fn main() {
|
||||
bcx.seal_all_blocks();
|
||||
bcx.finalize();
|
||||
}
|
||||
let mut trap_sink = NullTrapSink {};
|
||||
let mut stack_map_sink = NullStackMapSink {};
|
||||
module
|
||||
.define_function(func_a, &mut ctx, &mut trap_sink, &mut stack_map_sink)
|
||||
.unwrap();
|
||||
module.define_function(func_a, &mut ctx).unwrap();
|
||||
module.clear_context(&mut ctx);
|
||||
|
||||
ctx.func.signature = sig_b;
|
||||
@@ -74,9 +69,7 @@ fn main() {
|
||||
bcx.seal_all_blocks();
|
||||
bcx.finalize();
|
||||
}
|
||||
module
|
||||
.define_function(func_b, &mut ctx, &mut trap_sink, &mut stack_map_sink)
|
||||
.unwrap();
|
||||
module.define_function(func_b, &mut ctx).unwrap();
|
||||
module.clear_context(&mut ctx);
|
||||
|
||||
// Perform linking.
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
use crate::{compiled_blob::CompiledBlob, memory::Memory};
|
||||
use cranelift_codegen::isa::TargetIsa;
|
||||
use cranelift_codegen::settings::Configurable;
|
||||
use cranelift_codegen::{self, ir, settings};
|
||||
use cranelift_codegen::{self, ir, settings, MachReloc};
|
||||
use cranelift_codegen::{
|
||||
binemit::{Addend, CodeInfo, CodeOffset, Reloc, RelocSink, StackMapSink, TrapSink},
|
||||
binemit::{Addend, CodeInfo, CodeOffset, Reloc, RelocSink},
|
||||
CodegenError,
|
||||
};
|
||||
use cranelift_entity::SecondaryMap;
|
||||
@@ -648,8 +648,6 @@ impl Module for JITModule {
|
||||
&mut self,
|
||||
id: FuncId,
|
||||
ctx: &mut cranelift_codegen::Context,
|
||||
trap_sink: &mut dyn TrapSink,
|
||||
stack_map_sink: &mut dyn StackMapSink,
|
||||
) -> ModuleResult<ModuleCompiledFunction> {
|
||||
info!("defining function {}: {}", id, ctx.func.display());
|
||||
let decl = self.declarations.get_function_decl(id);
|
||||
@@ -674,7 +672,17 @@ impl Module for JITModule {
|
||||
.expect("TODO: handle OOM etc.");
|
||||
|
||||
let mut reloc_sink = JITRelocSink::default();
|
||||
unsafe { ctx.emit_to_memory(ptr, &mut reloc_sink, trap_sink, stack_map_sink) };
|
||||
unsafe { ctx.emit_to_memory(ptr) };
|
||||
for &MachReloc {
|
||||
offset,
|
||||
srcloc,
|
||||
kind,
|
||||
ref name,
|
||||
addend,
|
||||
} in ctx.mach_compile_result.as_ref().unwrap().buffer.relocs()
|
||||
{
|
||||
reloc_sink.reloc_external(offset, srcloc, kind, name, addend);
|
||||
}
|
||||
|
||||
self.record_function_for_perf(ptr, size, &decl.name);
|
||||
self.compiled_functions[id] = Some(CompiledBlob {
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
use cranelift_codegen::binemit::{NullStackMapSink, NullTrapSink};
|
||||
use cranelift_codegen::ir::*;
|
||||
use cranelift_codegen::isa::CallConv;
|
||||
use cranelift_codegen::settings::{self, Configurable};
|
||||
@@ -56,11 +55,7 @@ fn define_simple_function(module: &mut JITModule) -> FuncId {
|
||||
bcx.ins().return_(&[]);
|
||||
}
|
||||
|
||||
let mut trap_sink = NullTrapSink {};
|
||||
let mut stack_map_sink = NullStackMapSink {};
|
||||
module
|
||||
.define_function(func_id, &mut ctx, &mut trap_sink, &mut stack_map_sink)
|
||||
.unwrap();
|
||||
module.define_function(func_id, &mut ctx).unwrap();
|
||||
|
||||
func_id
|
||||
}
|
||||
@@ -205,11 +200,7 @@ fn libcall_function() {
|
||||
bcx.ins().return_(&[]);
|
||||
}
|
||||
|
||||
let mut trap_sink = NullTrapSink {};
|
||||
let mut stack_map_sink = NullStackMapSink {};
|
||||
module
|
||||
.define_function(func_id, &mut ctx, &mut trap_sink, &mut stack_map_sink)
|
||||
.unwrap();
|
||||
module.define_function(func_id, &mut ctx).unwrap();
|
||||
|
||||
module.finalize_definitions();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user