Merge reloc_func and reloc_globalsym into reloc_external.

This commit is contained in:
Dan Gohman
2017-10-31 12:06:13 -07:00
parent b60b2ce135
commit 5d063eb8bc
12 changed files with 52 additions and 55 deletions

View File

@@ -14,7 +14,7 @@
//! relocations to a `RelocSink` trait object. Relocations are less frequent than the
//! `CodeSink::put*` methods, so the performance impact of the virtual callbacks is less severe.
use ir::{Ebb, FuncRef, GlobalVar, JumpTable};
use ir::{ExternalName, Ebb, JumpTable};
use super::{CodeSink, CodeOffset, Reloc};
use std::ptr::write_unaligned;
@@ -51,12 +51,8 @@ pub trait RelocSink {
/// Add a relocation referencing an EBB at the current offset.
fn reloc_ebb(&mut self, CodeOffset, Reloc, Ebb);
/// Add a relocation referencing an external function at the current offset.
fn reloc_func(&mut self, CodeOffset, Reloc, FuncRef);
/// Add a relocation referencing an external global variable symbol at the
/// current offset.
fn reloc_globalsym(&mut self, CodeOffset, Reloc, GlobalVar);
/// Add a relocation referencing an external symbol at the current offset.
fn reloc_external(&mut self, CodeOffset, Reloc, &ExternalName);
/// Add a relocation referencing a jump table.
fn reloc_jt(&mut self, CodeOffset, Reloc, JumpTable);
@@ -100,14 +96,9 @@ impl<'a> CodeSink for MemoryCodeSink<'a> {
self.relocs.reloc_ebb(ofs, rel, ebb);
}
fn reloc_func(&mut self, rel: Reloc, func: FuncRef) {
fn reloc_external(&mut self, rel: Reloc, name: &ExternalName) {
let ofs = self.offset();
self.relocs.reloc_func(ofs, rel, func);
}
fn reloc_globalsym(&mut self, rel: Reloc, global: GlobalVar) {
let ofs = self.offset();
self.relocs.reloc_globalsym(ofs, rel, global);
self.relocs.reloc_external(ofs, rel, name);
}
fn reloc_jt(&mut self, rel: Reloc, jt: JumpTable) {