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:
bjorn3
2022-01-11 18:17:29 +01:00
parent 55d722db05
commit b803514d55
13 changed files with 155 additions and 138 deletions

View File

@@ -1,6 +1,5 @@
//! Provides functionality for compiling and running CLIF IR for `run` tests.
use core::mem;
use cranelift_codegen::binemit::{NullRelocSink, NullStackMapSink, NullTrapSink};
use cranelift_codegen::data_value::DataValue;
use cranelift_codegen::ir::{condcodes::IntCC, Function, InstBuilder, Signature};
use cranelift_codegen::isa::TargetIsa;
@@ -241,14 +240,11 @@ fn compile(function: Function, isa: &dyn TargetIsa) -> Result<Mmap, CompilationE
context.func = function;
// Compile and encode the result to machine code.
let relocs = &mut NullRelocSink {};
let traps = &mut NullTrapSink {};
let stack_maps = &mut NullStackMapSink {};
let code_info = context.compile(isa)?;
let mut code_page = MmapMut::map_anon(code_info.total_size as usize)?;
unsafe {
context.emit_to_memory(code_page.as_mut_ptr(), relocs, traps, stack_maps);
context.emit_to_memory(code_page.as_mut_ptr());
};
let code_page = code_page.make_exec()?;