Expand description
Byte-PVM interpreter.
Predecodes a PvmProgram via crate::decode::predecode and
dispatches over the resulting DecodedInst array.
Cherry-picked from v2 javm/src/interpreter/mod.rs::run (~787
LOC). The opcode-dispatch arms are verbatim modulo two adaptations:
-
State as parameters. v2’s
Interpreterowns gas/regs/mem/ code/etc. v3’sInterpreter::runis a free function that takes&PvmProgram + &mut Regs + &mut Mem + &mut GasCounter + &mut dyn EcallHandler. The predecoded state is computed on entry (matching v2’sInterpreter::newflow, but inline rather than stored). -
Ecall routing. v2 returns
ExitReason::Ecall/HostCalldirectly to the kernel. v3 routes both through theEcallHandlertrait: onContinuethe loop resumes atinst.next_idx; onExit(reason)the run returns. The diagnosticregs.gpr[7]“unsupported opcode” recording from the MVP is dropped (full coverage means it can’t fire).
Preserved optimizations (vs v2):
- Predecoded
DecodedInstflat layout (40 bytes; noArgsenum matching in the hot loop). pc_to_idxhot-loop indexing for dynamic jumps.- Gas-block charging via
inst.bb_gas_cost(JAR v0.8.0). do_load!/do_store!macros (zero overhead).- Fast-path
mem.read_*/write_*helpers (single MOV on x86).
Structs§
- Interpreter
- Namespace for byte-PVM execution.