Skip to main content

Module buffer

Module buffer 

Source
Expand description

The copy-and-patch assembler: glue stencils into executable code.

JitBuffer collects stencil instances with their hole values, then finish() lays everything out — stencil code, an 8-byte-aligned literal pool for constant holes, and pointer slots for GOT-indirect sites — maps a page (learning the final base address), patches every relocation against that base, writes ONCE, and seals. No mutable window ever escapes; W^X toggling stays confined to the constructing thread.

Layout:

[piece 0][piece 1]…[piece N]  [pointer slots…]  [value slots…]
 ^code, 16-byte aligned        ^8-byte aligned GOT-style slots

Structs§

JitBuffer
The staged assembly.
JitChain
A finished, executable chain.
Label
A placed stencil instance, identifying a continuation target.

Enums§

BufferError
Assembly errors.
HoleValue
What to plug into a stencil’s holes, by hole id.

Functions§

jit_canary_enabled
Whether LOGOS_JIT_CANARY=1 armed the operand-stack / region-frame sentinel guards (read once; the per-chain path stays branch-cheap).