[iterate-4A] jit: cache MemEnv fast_mem + expose mmio_count (prep for block chaining)

Behavior-neutral prep on top of the inline-load parity milestone:

  * JitCache caches mem.fast_mem() (resolved once — the mapping is invariant for
    a run) so compiled blocks build their MemEnv without a virtual call per
    execution. MemEnv::from_fast(mem, Option<FastMem>) is the non-virtual
    constructor. Measured impact is within noise (96.5 -> 96.4 MIPS) but it
    removes redundant per-block work.
  * FastMem/MemEnv gain mmio_count: a pointer to GuestMemory's monotonic MMIO
    access counter. Unused for now; the upcoming superblock-chaining JIT will
    sample it across a block boundary to stop chaining on an MMIO touch
    (preserving the interpreter's fine-grained MMIO ordering).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
MechaCat02
2026-07-07 20:02:05 +02:00
parent da0509b4ac
commit 5d5dc5dd89
4 changed files with 41 additions and 4 deletions

View File

@@ -150,7 +150,7 @@ pub fn run_block(
) -> StepResult {
if let Some(f) = jit.get_or_compile(block) {
JIT_COMPILED_RUN.fetch_add(1, Ordering::Relaxed);
let env = MemEnv::new(mem);
let env = jit.mem_env(mem);
let raw = f(ctx as *mut PpcContext, &env as *const MemEnv);
// Covered blocks are straight-line (branch/sc/trap/db16cyc are all
// uncovered), so a compiled block always runs to completion and