Don't return CodeInfo from Context::compile_and_emit
It is already available through ctx.mach_compile_result and rarely needed.
This commit is contained in:
@@ -5,7 +5,7 @@ use cranelift_codegen::entity::SecondaryMap;
|
||||
use cranelift_codegen::isa::TargetIsa;
|
||||
use cranelift_codegen::{self, ir};
|
||||
use cranelift_codegen::{
|
||||
binemit::{Addend, CodeInfo, CodeOffset, Reloc, RelocSink, StackMapSink, TrapSink},
|
||||
binemit::{Addend, CodeOffset, Reloc, RelocSink, StackMapSink, TrapSink},
|
||||
CodegenError,
|
||||
};
|
||||
use cranelift_module::{
|
||||
@@ -311,21 +311,16 @@ impl Module for ObjectModule {
|
||||
stack_map_sink: &mut dyn StackMapSink,
|
||||
) -> ModuleResult<ModuleCompiledFunction> {
|
||||
info!("defining function {}: {}", func_id, ctx.func.display());
|
||||
let CodeInfo {
|
||||
total_size: code_size,
|
||||
..
|
||||
} = ctx.compile(self.isa())?;
|
||||
let mut code: Vec<u8> = vec![0; code_size as usize];
|
||||
let mut code: Vec<u8> = Vec::new();
|
||||
let mut reloc_sink = ObjectRelocSink::default();
|
||||
|
||||
unsafe {
|
||||
ctx.emit_to_memory(
|
||||
code.as_mut_ptr(),
|
||||
&mut reloc_sink,
|
||||
trap_sink,
|
||||
stack_map_sink,
|
||||
)
|
||||
};
|
||||
ctx.compile_and_emit(
|
||||
self.isa(),
|
||||
&mut code,
|
||||
&mut reloc_sink,
|
||||
trap_sink,
|
||||
stack_map_sink,
|
||||
)?;
|
||||
|
||||
self.define_function_bytes(func_id, &code, &reloc_sink.relocs)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user