pub struct ProgramInstance { /* private fields */ }Expand description
A prepared address space plus predecoded code, ready to execute.
Splitting this out of run_program separates setup (build the
flat memory, map the read-only overlays, predecode the code) from
execution (interpret to an exit). Callers that measure execution
need that split: every other engine a benchmark might compare
against instantiates before the clock starts, so folding nub’s
setup into the timed region would understate it.
invoke continues from the current memory state, so
repeated calls observe the guest’s own mutations. Build a fresh
instance for a cold run.
Implementations§
Source§impl ProgramInstance
impl ProgramInstance
Sourcepub fn new(spec: &ProgramSpec<'_>) -> Self
pub fn new(spec: &ProgramSpec<'_>) -> Self
Build the address space and predecode the code.
Sourcepub fn invoke(
&mut self,
handler: &mut dyn EcallHandler,
initial_gas: u64,
) -> InvocationResult
pub fn invoke( &mut self, handler: &mut dyn EcallHandler, initial_gas: u64, ) -> InvocationResult
Interpret from regs until the program exits.
handler decides what ecall/ecalli mean;
ExitingEcallHandler surfaces them as exits, matching the JIT
trampoline.
Sourcepub fn set_entry_pc(&mut self, pc: u64)
pub fn set_entry_pc(&mut self, pc: u64)
Re-enter at a different PC on the next invoke.