Skip to main content

Module function

Module function 

Source
Expand description

Function objects: compiled prototypes, Lua closures, upvalues.

Structs§

CloseCont
Per-iteration state for a chain of __close handlers driven through the interpreter loop. When a handler is pushed onto the call stack, this rides in a Cont::Close frame underneath it so a coroutine.yield from 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 runtime where 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 Proto paired with its captured upvalues.
MetaCont
How to complete a VM instruction once its metamethod returns.
NativeClosure
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.
NativeCont
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 (see CallFrame).
Proto
A compiled function (PUC Proto). Immutable after compilation.
UpvalDesc
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§

AfterClose
What to run once begin_close has drained every tbc slot.
CallFrame
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).
ContKind
Continuation kind for yieldable native dispatch.
JitProtoState
P11-S2 / S2c — per-Proto JIT cache state. Copy so it fits a plain Cell on the dispatch hot path (no RefCell borrow check); the fn pointer’s mmap is kept alive by Vm.jit_handles.
MetaAction
Per-op finishing action for a yielded metamethod call.
UpvalState
Open / closed state of an upvalue cell.

Constants§

INLINE_UPVALS_N
P11-S5d.M — closures with ≤ INLINE_UPVALS_N upvalues skip the per-closure upvals Box. The Op::Closure handler builds upvals into a stack array and calls Heap::new_closure_inline(&[Gc<…>]), which writes them straight into inline_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.