Expand description
Flat storage for the spaces a guest does not address.
Register, unique and temporary spaces are small, dense and hit constantly:
every operand of every p-code operation is a read or a write here. The
emulator’s general-purpose backing for them is FxHashMap<u64, u8>, which
costs one hash lookup per byte — reading RAX is eight lookups, and a
Vec allocation for the result.
These spaces are nothing like guest memory: their addresses are assigned by
the specification, start at zero, and span a few hundred bytes. A plain
Vec<u8> indexed by address is the right shape, turning each access into a
bounds check and a copy.
§This is not, by itself, faster
Measured against the hash-map backing on a hot loop, this is neutral to about 5% slower. Profiling says why: register access is roughly 4% of run time, so removing per-byte hashing from it cannot matter much. The cost is interpreter dispatch and allocation churn instead.
It is kept because a JIT needs it. Compiled code has to reach the register file by address, and it cannot call into a hash map per operand and stay worth compiling. This is groundwork for that, not a speedup in its own right.
Guest RAM deliberately does not live here — it is sparse across a 64-bit
space and needs permissions, which is what Mmu is for.
Structs§
- Flat
Space - One densely-addressed space.
- Flat
Spaces - The set of flat spaces for a module.