Expand description
PVM-to-x86-64 code generation.
Compiles PVM bytecode into native x86-64 machine code. Each PVM basic block becomes a native basic block with gas metering at entry. PVM registers are mapped to x86-64 registers for the duration of execution.
Register mapping (PVM φ[i] → x86-64):
φ[0] → RBP (callee-saved) — RA, rarely used as memory base
φ[1] → RBX (callee-saved) — SP, avoids RBP encoding penalty
φ[2] → R12 (callee-saved)
φ[3] → R13 (callee-saved)
φ[4] → R14 (callee-saved)
φ[5] → RSI (caller-saved)
φ[6] → RDI (caller-saved)
φ[7] → R8 (caller-saved)
φ[8] → R9 (caller-saved)
φ[9] → R10 (caller-saved)
φ[10] → R11 (caller-saved)
φ[11] → RAX (caller-saved)
φ[12] → RCX (caller-saved)
Reserved: R15 = gas meter, RDX = scratch, RSP = native stack.
Structs§
- Compile
Result - Result of compilation.
- Compiler
- PVM-to-x86-64 compiler.
- Helper
Fns - Helper function pointers passed to compiled code.
Constants§
- CTX_
BB_ LEN - CTX_
BB_ STARTS - CTX_
CODE_ BASE - CTX_
DISPATCH_ TABLE - CTX_
ENTRY_ PC - CTX_
EXIT_ ARG - CTX_
EXIT_ REASON - CTX_
FAST_ REENTRY - CTX_GAS
- CTX_
HEAP_ BASE - CTX_
HEAP_ TOP - CTX_
JT_ LEN - CTX_
JT_ PTR - CTX_PC
- CTX_
REGS - CTX_VA
- JitContext lives above the PVM u32 address space (no bounds check
on guest mem — the full low 4 GiB of native VA belongs to the
program). CTX is reached via RIP-relative
[rip+disp32], which gives ±2 GiB range from the JIT code, so CTX must be adjacent to the JIT region. - EXIT_
ECALL - EXIT_
HALT - Exit reason codes (matching ExitReason enum).
- EXIT_
HOST_ CALL - EXIT_
OOG - EXIT_
PAGE_ FAULT - EXIT_
PANIC - EXIT_
TRAP