Skip to main content

Module interp

Module interp 

Source
Expand description

PVM2 (RV+C+Zbb+Zba+Zbs+Zicond+custom-0) interpreter.

Program bundles the constituents an interpreter run needs (code bytes, predecode output, code base) so the integration layer can cache the predecode alongside the bytecode and pass a single Arc to the executor.

Mirrors the recompiler’s semantics — same per-block gas charging at Predecode::block_costs, same RV-spec ALU/branch behaviour, same Ecalli/Jalr runtime contracts (jalr targets validated to be basic-block starts via the per-instruction block-start flag). Cross-checked against the recompiler in the smoke example: bit-identical gas_used and side-effects on every workload.

Dispatch is a match over Inst variants. Instructions come from Predecode::insts (one entry per static instruction); static branch / jal targets are resolved to instruction indices via binary search on the (sorted) insts array. Reused infrastructure: Regs, Memory trait, GasCounter, EcallHandler — identical to the PVM interpreter’s contract.

Structs§

Interpreter
PVM2 interpreter namespace.
Program
Predecoded PVM2 program: bytecode plus the per-instruction analysis the interpreter consumes. Cache-friendly — the integration layer builds one of these per Image and shares it across invocations.