pub struct CallSite<'a> { /* private fields */ }Expand description
What a call instruction records besides its operands: the stack slots that hold its GC roots while it runs (its stack map), and the landing pad control reaches if the callee unwinds.
§Examples
use backend_lang::mir::{Function, SlotKind};
use backend_lang::x86_64::{op, SYSV};
let mut f = Function::new("f", &SYSV);
let b = f.block()?;
let root = f.stack_slot(SlotKind::Local { size: 8, align: 8 })?;
let g = f.symbol("g")?;
let call = f.push(b, op::CALL, &[g.into()])?;
f.push(b, op::RET, &[])?;
f.set_call_site(call, &[root], None)?;
let site = f.call_site(call).unwrap();
assert_eq!(site.gc_slots(), [root]);
assert_eq!(site.landing_pad(), None);Implementations§
Source§impl<'a> CallSite<'a>
impl<'a> CallSite<'a>
Sourcepub const fn inst(&self) -> Inst
pub const fn inst(&self) -> Inst
The call instruction.
§Examples
use backend_lang::mir::Function;
use backend_lang::x86_64::{op, SYSV};
let mut f = Function::new("f", &SYSV);
let b = f.block()?;
let g = f.symbol("g")?;
let call = f.push(b, op::CALL, &[g.into()])?;
f.set_call_site(call, &[], None)?;
assert_eq!(f.call_site(call).unwrap().inst(), call);Sourcepub const fn gc_slots(&self) -> &'a [StackSlot]
pub const fn gc_slots(&self) -> &'a [StackSlot]
The slots holding the GC references live across the call, which a collector reads and may rewrite while the callee runs.
§Examples
use backend_lang::mir::{Function, SlotKind};
use backend_lang::x86_64::{op, SYSV};
let mut f = Function::new("f", &SYSV);
let b = f.block()?;
let s = f.stack_slot(SlotKind::Local { size: 8, align: 8 })?;
let g = f.symbol("g")?;
let call = f.push(b, op::CALL, &[g.into()])?;
f.set_call_site(call, &[s], None)?;
assert_eq!(f.call_site(call).unwrap().gc_slots().len(), 1);Sourcepub const fn landing_pad(&self) -> Option<Block>
pub const fn landing_pad(&self) -> Option<Block>
The block control reaches when the callee unwinds, if any.
§Examples
use backend_lang::mir::Function;
use backend_lang::x86_64::{op, SYSV};
let mut f = Function::new("f", &SYSV);
let b = f.block()?;
let pad = f.block()?;
let g = f.symbol("g")?;
let call = f.push(b, op::CALL, &[g.into()])?;
f.set_call_site(call, &[], Some(pad))?;
assert_eq!(f.call_site(call).unwrap().landing_pad(), Some(pad));Trait Implementations§
impl<'a> Copy for CallSite<'a>
impl<'a> Eq for CallSite<'a>
impl<'a> StructuralPartialEq for CallSite<'a>
Auto Trait Implementations§
impl<'a> Freeze for CallSite<'a>
impl<'a> RefUnwindSafe for CallSite<'a>
impl<'a> Send for CallSite<'a>
impl<'a> Sync for CallSite<'a>
impl<'a> Unpin for CallSite<'a>
impl<'a> UnsafeUnpin for CallSite<'a>
impl<'a> UnwindSafe for CallSite<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more