Expand description
Function objects: compiled prototypes, Lua closures, upvalues.
Structs§
- Close
Cont - Per-iteration state for a chain of
__closehandlers driven through the interpreter loop. When a handler is pushed onto the call stack, this rides in aCont::Closeframe underneath it so acoroutine.yieldfrom the handler preserves the close iteration with the rest of the thread. - Frame
- An activation record on a thread’s call stack. Pure data (closure handle +
stack offsets), so it lives in
runtimewhere the GC can trace a suspended coroutine’s frames. - LocVar
- Debug record for a local variable: its name and the pc range over which it
occupies register
reg. Used to name registers in error messages and debug.getinfo (PUC LocVar). - LuaClosure
- A Lua closure: a
Protopaired with its captured upvalues. - Meta
Cont - How to complete a VM instruction once its metamethod returns.
- Native
Closure - A native (host) function with captured upvalues — the analogue of PUC C
closures. Builtins are allocated once at registration so identity is
stable; stateful iterators (gmatch) mutate their upvalues via
as_mut. - Native
Cont - A continuation frame for
pcall/xpcall: where its wrapped result lands and how to wrap it. Lives on the call stack below the protected call (seeCallFrame). - Proto
- A compiled function (PUC Proto). Immutable after compilation.
- Upval
Desc - Where a closure’s upvalue is captured from, relative to the enclosing function (PUC Upvaldesc).
- Upvalue
- An upvalue cell. Open: refers to a live VM stack slot (the stack is a GC root, so open cells trace nothing). Closed: owns the value inline.
Enums§
- After
Close - What to run once
begin_closehas drained every tbc slot. - Call
Frame - An entry on a thread’s call stack: either a Lua activation record or a continuation frame standing in for a yieldable native (pcall/xpcall).
- Cont
Kind - Continuation kind for yieldable native dispatch.
- JitProto
State - P11-S2 / S2c — per-Proto JIT cache state. Copy so it fits a plain
Cellon the dispatch hot path (noRefCellborrow check); the fn pointer’s mmap is kept alive byVm.jit_handles. - Meta
Action - Per-op finishing action for a yielded metamethod call.
- Upval
State - Open / closed state of an upvalue cell.
Constants§
- INLINE_
UPVALS_ N - P11-S5d.M — closures with
≤ INLINE_UPVALS_Nupvalues skip the per-closure upvals Box. TheOp::Closurehandler builds upvals into a stack array and callsHeap::new_closure_inline(&[Gc<…>]), which writes them straight intoinline_storage— no caller-side Vec/Box.closure_alloc-style benchmarks create 10k single-upval closures per iter; eliminating the 24-byte Vec alloc shaves ~300µs.