pub struct Vm<S> {
pub stats: Stats,
pub optimize: bool,
/* private fields */
}Expand description
A machine: an owned module, a memory, and a position in the code.
Fields§
§stats: StatsCounters and phase timings for this run.
optimize: boolWhether freshly lifted blocks get a cleanup round.
Lifting one machine instruction emits every side effect the specification describes, including flag computations the surrounding code never reads. Removing the ones with no users at all is sound block-locally — an instruction with no users cannot be observed — and is paid once per block instead of on every execution of it.
Implementations§
Source§impl<S: CodeSource> Vm<S>
impl<S: CodeSource> Vm<S>
Sourcepub fn new(ctx: Context<'static>, entry: BlockId, source: S) -> Self
pub fn new(ctx: Context<'static>, entry: BlockId, source: S) -> Self
Builds a machine positioned at entry.
Sourcepub fn at_address(
ctx: Context<'static>,
addr: u64,
source: S,
memory: VmMemory,
) -> Result<Self, CodeError>
pub fn at_address( ctx: Context<'static>, addr: u64, source: S, memory: VmMemory, ) -> Result<Self, CodeError>
Builds a machine positioned at a guest address, lifting the entry block if the module does not already contain it.
Sourcepub fn set_block_executor(&mut self, executor: Box<dyn BlockExecutor>)
pub fn set_block_executor(&mut self, executor: Box<dyn BlockExecutor>)
Installs an alternative executor for block bodies, replacing any previous one. Purely an optimisation: removing it changes speed, not behaviour.
pub fn clear_block_executor(&mut self)
pub fn context(&self) -> &Context<'static>
pub fn memory(&self) -> &VmMemory
pub fn memory_mut(&mut self) -> &mut VmMemory
Sourcepub fn emulator(&mut self) -> &mut StandaloneEmulator<VmMemory>
pub fn emulator(&mut self) -> &mut StandaloneEmulator<VmMemory>
The emulator underneath, for register access and harness seeding.
Sourcepub fn pc(&self) -> Option<u64>
pub fn pc(&self) -> Option<u64>
The guest address of the block about to execute, if it has one.