Skip to main content

Module mem

Module mem 

Source
Expand description

Flat-buffer memory model + the Memory trait that abstracts over different memory backends (software-copy here, hardware-paged in the bare-metal Hyperlight guest).

Matches v2 javm’s flat_mem layout for perf parity: a single contiguous Vec<u8> indexed by 32-bit address. Reads/writes are bounds-checked against flat_mem.len(); on out-of-range the caller gets false/None and translates to ExitReason::PageFault.

Per-page permissions are tracked separately in flat_perms (one byte per page) so the JIT signal handler can detect ro-write faults without involving the interpreter. The interpreter itself relies on the page-protected mmap mapping (Stage 3 / kernel integration) for read-only enforcement; this layer just bounds- checks.

The fast-path read/write helpers use read_unaligned / write_unaligned via raw pointers — single MOV on x86. Same shape as v2 javm/src/interpreter/mod.rs:198-309.

Modules§

perm
Per-page permission byte (matches v2’s flat_perms semantics).

Structs§

CopyingMemory
Address-space mapping for one execution context.

Enums§

Access
Mapping permission for Memory::map_region. RO regions back perm::RO pages; RW regions back perm::RW pages.
MapError
Setup-time error for Memory::map_region.
MemAccess
Outcome of a memory access (slow path; the fast inline helpers return raw Option / bool).

Constants§

PAGE_SIZE
PVM page size: 4 KiB.

Traits§

Memory
Memory backend abstraction.

Type Aliases§

Mem
Compatibility alias for the pre-trait name. Consumers can keep writing Mem; new code should prefer CopyingMemory (when the concrete impl is wanted) or be generic over M: Memory.