Remove all Sink traits
This commit is contained in:
@@ -5,13 +5,13 @@ use cranelift_codegen::isa::TargetIsa;
|
||||
use cranelift_codegen::settings::Configurable;
|
||||
use cranelift_codegen::{self, ir, settings, MachReloc};
|
||||
use cranelift_codegen::{
|
||||
binemit::{Addend, CodeInfo, CodeOffset, Reloc, RelocSink},
|
||||
binemit::{CodeInfo, Reloc},
|
||||
CodegenError,
|
||||
};
|
||||
use cranelift_entity::SecondaryMap;
|
||||
use cranelift_module::{
|
||||
DataContext, DataDescription, DataId, FuncId, Init, Linkage, Module, ModuleCompiledFunction,
|
||||
ModuleDeclarations, ModuleError, ModuleResult, RelocRecord,
|
||||
ModuleDeclarations, ModuleError, ModuleResult,
|
||||
};
|
||||
use log::info;
|
||||
use std::collections::HashMap;
|
||||
@@ -671,25 +671,17 @@ impl Module for JITModule {
|
||||
.allocate(size, EXECUTABLE_DATA_ALIGNMENT)
|
||||
.expect("TODO: handle OOM etc.");
|
||||
|
||||
let mut reloc_sink = JITRelocSink::default();
|
||||
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);
|
||||
}
|
||||
let relocs = ctx
|
||||
.mach_compile_result
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.buffer
|
||||
.relocs()
|
||||
.to_vec();
|
||||
|
||||
self.record_function_for_perf(ptr, size, &decl.name);
|
||||
self.compiled_functions[id] = Some(CompiledBlob {
|
||||
ptr,
|
||||
size,
|
||||
relocs: reloc_sink.relocs,
|
||||
});
|
||||
self.compiled_functions[id] = Some(CompiledBlob { ptr, size, relocs });
|
||||
|
||||
if self.isa.flags().is_pic() {
|
||||
self.pending_got_updates.push(GotUpdate {
|
||||
@@ -729,7 +721,7 @@ impl Module for JITModule {
|
||||
&mut self,
|
||||
id: FuncId,
|
||||
bytes: &[u8],
|
||||
relocs: &[RelocRecord],
|
||||
relocs: &[MachReloc],
|
||||
) -> ModuleResult<ModuleCompiledFunction> {
|
||||
info!("defining function {} with bytes", id);
|
||||
let total_size: u32 = match bytes.len().try_into() {
|
||||
@@ -896,26 +888,3 @@ fn lookup_with_dlsym(name: &str) -> Option<*const u8> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
struct JITRelocSink {
|
||||
relocs: Vec<RelocRecord>,
|
||||
}
|
||||
|
||||
impl RelocSink for JITRelocSink {
|
||||
fn reloc_external(
|
||||
&mut self,
|
||||
offset: CodeOffset,
|
||||
_srcloc: ir::SourceLoc,
|
||||
reloc: Reloc,
|
||||
name: &ir::ExternalName,
|
||||
addend: Addend,
|
||||
) {
|
||||
self.relocs.push(RelocRecord {
|
||||
offset,
|
||||
reloc,
|
||||
name: name.clone(),
|
||||
addend,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user