pub struct BasicInterpreterState<Regs, Env, Memory, IF> {
pub regs: Regs,
pub env: Env,
pub memory: Memory,
pub instruction_fetcher: IF,
}Expand description
Basic interpreter state.
This is a simple container, which is not required to be used, is helpful for storing the whole state related to the interpreter together.
Fields§
§regs: RegsGeneral purpose registers
env: EnvExecution environment.
Extensions might use this to place additional constraints on Env to require additional
registers, handlers (like SystemInstructionHandler) or other resources. If no such
extension is used, () can be used as a placeholder.
memory: MemoryMemory
instruction_fetcher: IFInstruction fetcher
Implementations§
Source§impl<Regs, Env, Memory, IF> BasicInterpreterState<Regs, Env, Memory, IF>
impl<Regs, Env, Memory, IF> BasicInterpreterState<Regs, Env, Memory, IF>
Sourcepub fn execute<I>(
&mut self,
) -> Result<(), ExecutionError<<<<I as Instruction>::Hart as HartConfig>::Reg as Register>::Type>>where
Regs: RegisterFile<<<I as Instruction>::Hart as HartConfig>::Reg>,
I: ExecutableInstruction<Regs, Env, Memory, IF>,
Memory: VirtualMemory,
IF: InstructionFetcher<I, Memory> + ProgramCounter<<<<I as Instruction>::Hart as HartConfig>::Reg as Register>::Type, Memory>,
pub fn execute<I>(
&mut self,
) -> Result<(), ExecutionError<<<<I as Instruction>::Hart as HartConfig>::Reg as Register>::Type>>where
Regs: RegisterFile<<<I as Instruction>::Hart as HartConfig>::Reg>,
I: ExecutableInstruction<Regs, Env, Memory, IF>,
Memory: VirtualMemory,
IF: InstructionFetcher<I, Memory> + ProgramCounter<<<<I as Instruction>::Hart as HartConfig>::Reg as Register>::Type, Memory>,
Execute the program with a given basic interpreter state.
The implementation is designed to be efficient with little left to optimize further. Though it is still possible to improve performance by applying additional constraints on the program.
When execution fails, the program counter stays where the failure left it:
- after a branch whose target was refused, at that target, so calling this again fails the same way
- after an instruction that failed, or a jump whose target
ProgramCounter::set_pc()refused, right after that instruction, so calling this again continues with the next one - after a failed fetch, wherever the instruction fetcher left it, which for
BasicInstructionFetcheris the address it couldn’t fetch from