Skip to main content

Module asm

Module asm 

Source
Expand description

x86-64 assembler for PVM recompiler.

Emits native x86-64 machine code with label-based jump resolution. All jumps use 32-bit relative offsets (no short-jump optimization).

§Safety model

The assembler writes to a raw *mut u8 buffer (self.buf) for performance. The key invariant: self.buf points to a valid allocation of at least self.capacity bytes (either a Vec’s backing store or an mmap region). All emission functions have debug_assert!(self.write_pos + N <= self.capacity) guards. Callers must ensure capacity via ensure_capacity() before emitting. Vec length is synced via set_len(write_pos) only at finalization boundaries.

Structs§

Assembler
x86-64 assembler with label support.
InstBuf
Instruction buffer: accumulates x86 bytes in a u128 register, then flushes with a single bulk write. Avoids per-byte memory stores.
Label
Label identifier.

Enums§

Cc
Condition codes for Jcc/SETcc/CMOVcc.
Reg
x86-64 register encoding.