Skip to main content

Module fn_bytecode

Module fn_bytecode 

Source
Expand description

A relocatable, self-contained per-function bytecode unit (HOTSWAP §7).

A CompiledProgram holds every function body in ONE flat code vector with ABSOLUTE jump targets; entry_pc marks where each begins. slice_function lifts one function out of that vector into a FnBytecode whose jump targets are 0-relative to its own first op, carrying the frame/param/return metadata needed to run or compile it independently of the program it came from.

This is the producer the Axis-1 hot-swap consumes: the WASM-portable warm-bytecode side-table (P11) installs an FnBytecode per function, and the OPFS tier cache (P12) serializes it. The native path (P10) feeds the same body to forge (which rebases by entry_pc itself, so it takes the program slice directly).

Structs§

FnBytecode
One function lifted out of a CompiledProgram: a self-contained, relocatable body with 0-relative jump targets plus the metadata to execute or compile it.

Functions§

slice_function
Lift function fi out of program into a self-contained FnBytecode with 0-relative jumps. The body is program.code[entry_pc..end] (where end is the next function’s entry, or the end of code); its absolute jump targets are rebased by -entry_pc, so they index into the returned code directly.