javm_exec/predecoded.rs
1//! Pre-decoded PVM instruction representation, shared between the
2//! pure execution-engine gas accounting (here in `javm-exec`) and
3//! the recompiler crate that populates the slice via its
4//! `predecode` pass.
5//!
6//! The struct is a plain data tuple of opcode + decoded args + PC
7//! metadata. It carries no recompiler-internal state, so it lives
8//! here so that `gas_cost.rs` can reference it without javm-exec
9//! depending on the recompiler crate.
10
11use crate::args::Args;
12use crate::instruction::Opcode;
13
14/// Pre-decoded PVM instruction. Stores everything the codegen and
15/// the gas simulator need per instruction.
16#[derive(Clone, Copy, Debug)]
17pub struct PreDecodedInst {
18 /// PVM opcode (for compile_instruction match dispatch).
19 pub opcode: Opcode,
20 /// Decoded arguments (registers, immediates, offsets).
21 pub args: Args,
22 /// PVM byte offset of this instruction.
23 pub pc: u32,
24 /// PVM byte offset of the next instruction.
25 pub next_pc: u32,
26 /// Gas cost if this is a gas block start (>0), 0 otherwise.
27 /// Set by the recompiler's single-pass codegen via placeholder + patch.
28 pub gas_cost: u32,
29 /// Whether this instruction starts a gas metering block.
30 pub is_gas_block_start: bool,
31 /// Flat register fields for fast gas cost lookup (avoids Args enum match).
32 pub ra: u8,
33 pub rb: u8,
34 pub rd: u8,
35}