Skip to main content

Emitter

Struct Emitter 

Source
pub struct Emitter<'a> { /* private fields */ }
Expand description

Emits QCode before a site’s anchor, on the hook’s behalf.

Values are ValueIds: literals from constant, operands of the anchor from store_operands and friends, or the results of arithmetic emitted here. Everything emitted stays before the anchor, in emission order.

Implementations§

Source§

impl<'a> Emitter<'a>

Source

pub fn new(ctx: &'a mut Context<'static>, site: &Site) -> Self

Source

pub fn ctx(&self) -> &Context<'static>

Source

pub fn address(&self) -> Option<u64>

The guest address of the site.

Source

pub fn constant(&self, value: u64, size: usize) -> ValueId

An integer literal of size bytes.

Source

pub fn size_of(&self, value: ValueId) -> usize

The width in bytes of a value.

Source

pub fn store_operands(&self) -> Option<(ValueId, usize, ValueId)>

The anchor’s store operands: pointer, width and stored value, if the anchor is a store.

Source

pub fn load_operands(&self) -> Option<(ValueId, usize)>

The anchor’s load operands: pointer and width, if the anchor is a load.

Source

pub fn binop_operands(&self) -> Option<(Binop, ValueId, ValueId)>

The anchor’s binary operands, if the anchor is a binary operation.

Source

pub fn binop(&mut self, op: IntBinop, lhs: ValueId, rhs: ValueId) -> ValueId

Emits an integer binary operation before the anchor.

Emitted arithmetic carries no guest address: it is the hook’s, not the guest instruction’s, and stamping it would make it look like the start of that instruction to the next hook choosing sites.

Source

pub fn zext(&mut self, value: ValueId, size: usize) -> ValueId

Zero-extends (or truncates) value to size bytes.

Source

pub fn in_range(&mut self, value: ValueId, begin: u64, end: u64) -> ValueId

value - begin < end - begin + 1, as a one-byte condition: whether a 64-bit value lies in begin..=end.

Source

pub fn interrupt(&mut self, code: u64, args: &[ValueId]) -> InstructionId

Stops unconditionally before the anchor with vm.interrupt(code, args...).

Source

pub fn interrupt_if( &mut self, cond: ValueId, code: u64, args: &[ValueId], ) -> InstructionId

Stops before the anchor only when cond is non-zero, without leaving compiled code otherwise.

The block is split before the anchor; the code emitted so far stays in the first half, which ends in cbranch cond -> hook, rest, where hook holds the interrupt and falls through to rest, the second half. Later emissions go before the anchor in rest.

Auto Trait Implementations§

§

impl<'a> !UnwindSafe for Emitter<'a>

§

impl<'a> Freeze for Emitter<'a>

§

impl<'a> RefUnwindSafe for Emitter<'a>

§

impl<'a> Send for Emitter<'a>

§

impl<'a> Sync for Emitter<'a>

§

impl<'a> Unpin for Emitter<'a>

§

impl<'a> UnsafeUnpin for Emitter<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.