Remove add_call_site from CodeSink and RelocSink
And introduce MachBufferFinalized::call_sites() in the place.
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
//! `CodeSink::put*` methods, so the performance impact of the virtual callbacks is less severe.
|
||||
use super::{Addend, CodeInfo, CodeOffset, CodeSink, Reloc};
|
||||
use crate::binemit::stack_map::StackMap;
|
||||
use crate::ir::{ExternalName, Opcode, SourceLoc, TrapCode};
|
||||
use crate::ir::{ExternalName, SourceLoc, TrapCode};
|
||||
use core::ptr::write_unaligned;
|
||||
|
||||
/// A `CodeSink` that writes binary machine code directly into memory.
|
||||
@@ -77,10 +77,6 @@ pub trait RelocSink {
|
||||
_: &ExternalName,
|
||||
_: Addend,
|
||||
);
|
||||
|
||||
/// Track a call site whose return address is the given CodeOffset, for the given opcode. Does
|
||||
/// nothing in general, only useful for certain embedders (SpiderMonkey).
|
||||
fn add_call_site(&mut self, _: Opcode, _: CodeOffset, _: SourceLoc) {}
|
||||
}
|
||||
|
||||
/// A trait for receiving trap codes and offsets.
|
||||
@@ -115,15 +111,6 @@ impl<'a> CodeSink for MemoryCodeSink<'a> {
|
||||
let ofs = self.offset as CodeOffset;
|
||||
self.traps.trap(ofs, srcloc, code);
|
||||
}
|
||||
|
||||
fn add_call_site(&mut self, opcode: Opcode, loc: SourceLoc) {
|
||||
debug_assert!(
|
||||
opcode.is_call(),
|
||||
"adding call site info for a non-call instruction."
|
||||
);
|
||||
let ret_addr = self.offset as CodeOffset;
|
||||
self.relocs.add_call_site(opcode, ret_addr, loc);
|
||||
}
|
||||
}
|
||||
|
||||
/// A `RelocSink` implementation that does nothing, which is convenient when
|
||||
|
||||
@@ -11,7 +11,7 @@ pub use self::memorysink::{
|
||||
TrapSink,
|
||||
};
|
||||
pub use self::stack_map::StackMap;
|
||||
use crate::ir::{ExternalName, Opcode, SourceLoc, TrapCode};
|
||||
use crate::ir::{ExternalName, SourceLoc, TrapCode};
|
||||
use core::fmt;
|
||||
#[cfg(feature = "enable-serde")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
@@ -113,9 +113,4 @@ pub trait CodeSink {
|
||||
|
||||
/// Add trap information for the current offset.
|
||||
fn trap(&mut self, _: TrapCode, _: SourceLoc);
|
||||
|
||||
/// Add a call site for a call with the given opcode, returning at the current offset.
|
||||
fn add_call_site(&mut self, _: Opcode, _: SourceLoc) {
|
||||
// Default implementation doesn't need to do anything.
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user