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:
@@ -9,7 +9,7 @@
|
||||
//! contexts concurrently. Typically, you would have one context per compilation thread and only a
|
||||
//! single ISA instance.
|
||||
|
||||
use crate::binemit::{CodeInfo, RelocSink, StackMapSink, TrapSink};
|
||||
use crate::binemit::CodeInfo;
|
||||
use crate::dce::do_dce;
|
||||
use crate::dominator_tree::DominatorTree;
|
||||
use crate::flowgraph::ControlFlowGraph;
|
||||
@@ -18,7 +18,7 @@ use crate::isa::TargetIsa;
|
||||
use crate::legalizer::simple_legalize;
|
||||
use crate::licm::do_licm;
|
||||
use crate::loop_analysis::LoopAnalysis;
|
||||
use crate::machinst::{MachCompileResult, MachReloc, MachStackMap, MachTrap};
|
||||
use crate::machinst::MachCompileResult;
|
||||
use crate::nan_canonicalization::do_nan_canonicalization;
|
||||
use crate::remove_constant_phis::do_remove_constant_phis;
|
||||
use crate::result::CodegenResult;
|
||||
@@ -111,16 +111,11 @@ impl Context {
|
||||
&mut self,
|
||||
isa: &dyn TargetIsa,
|
||||
mem: &mut Vec<u8>,
|
||||
relocs: &mut dyn RelocSink,
|
||||
traps: &mut dyn TrapSink,
|
||||
stack_maps: &mut dyn StackMapSink,
|
||||
) -> CodegenResult<()> {
|
||||
let info = self.compile(isa)?;
|
||||
let old_len = mem.len();
|
||||
mem.resize(old_len + info.total_size as usize, 0);
|
||||
let new_info = unsafe {
|
||||
self.emit_to_memory(mem.as_mut_ptr().add(old_len), relocs, traps, stack_maps)
|
||||
};
|
||||
let new_info = unsafe { self.emit_to_memory(mem.as_mut_ptr().add(old_len)) };
|
||||
debug_assert!(new_info == info);
|
||||
Ok(())
|
||||
}
|
||||
@@ -187,13 +182,7 @@ impl Context {
|
||||
///
|
||||
/// Returns information about the emitted code and data.
|
||||
#[deny(unsafe_op_in_unsafe_fn)]
|
||||
pub unsafe fn emit_to_memory(
|
||||
&self,
|
||||
mem: *mut u8,
|
||||
relocs: &mut dyn RelocSink,
|
||||
traps: &mut dyn TrapSink,
|
||||
stack_maps: &mut dyn StackMapSink,
|
||||
) -> CodeInfo {
|
||||
pub unsafe fn emit_to_memory(&self, mem: *mut u8) -> CodeInfo {
|
||||
let _tt = timing::binemit();
|
||||
let result = self
|
||||
.mach_compile_result
|
||||
@@ -204,32 +193,6 @@ impl Context {
|
||||
let mem = unsafe { std::slice::from_raw_parts_mut(mem, info.total_size as usize) };
|
||||
mem.copy_from_slice(result.buffer.data());
|
||||
|
||||
for &MachReloc {
|
||||
offset,
|
||||
srcloc,
|
||||
kind,
|
||||
ref name,
|
||||
addend,
|
||||
} in result.buffer.relocs()
|
||||
{
|
||||
relocs.reloc_external(offset, srcloc, kind, name, addend);
|
||||
}
|
||||
for &MachTrap {
|
||||
offset,
|
||||
srcloc,
|
||||
code,
|
||||
} in result.buffer.traps()
|
||||
{
|
||||
traps.trap(offset, srcloc, code);
|
||||
}
|
||||
for &MachStackMap {
|
||||
offset_end,
|
||||
ref stack_map,
|
||||
..
|
||||
} in result.buffer.stack_maps()
|
||||
{
|
||||
stack_maps.add_stack_map(offset_end, stack_map.clone());
|
||||
}
|
||||
info
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user