Skip to main content

Module runtime

Module runtime 

Source
Expand description

Runtime core: values, GC heap, strings, tables, function objects.

Re-exports§

pub use coroutine::Coro;
pub use coroutine::CoroStatus;
pub use function::AfterClose;
pub use function::CallFrame;
pub use function::CloseCont;
pub use function::ContKind;
pub use function::Frame;
pub use function::LocVar;
pub use function::LuaClosure;
pub use function::MetaAction;
pub use function::MetaCont;
pub use function::NativeClosure;
pub use function::NativeCont;
pub use function::Proto;
pub use function::UpvalDesc;
pub use function::UpvalState;
pub use function::Upvalue;
pub use heap::ObjTag;
pub use heap::Gc;
pub use heap::Heap;
pub use string::LuaStr;
pub use table::Table;
pub use table::TableError;
pub use userdata::FileHandle;
pub use userdata::Userdata;
pub use userdata::UserdataPayload;
pub use value::Value;

Modules§

coroutine
Coroutine (thread) objects (P05). A coroutine owns a full execution context — value stack, call frames, open upvalues, to-be-closed slots and stack top — that is swapped into the running Vm while it is active and saved back here while it is suspended.
frame_marker
P17-D v2 Phase 1 — type foundation for LJ-style unified stack-frame memory.
function
Function objects: compiled prototypes, Lua closures, upvalues.
heap
GC heap v1: precise stop-the-world mark & sweep over an intrusive all-objects list (PUC allgc shape). All unsafe object plumbing is confined to this module and string/table internals.
string
Lua strings: immutable byte sequences allocated in one block (header + inline bytes). Short strings (≤ 40 bytes, PUC LUAI_MAXSHORTLEN) are interned in the heap’s string table: equality is pointer equality. Long strings hash lazily, seeded per-heap (hash-flooding defense for hostile script workloads (script host)).
table
Lua table: hybrid array + hash.
userdata
Userdata objects. In luna the only userdata are io file handles (there is no C API exposing arbitrary host objects), so a userdata wraps a file/stream handle plus an optional metatable — the shared FILE* metatable attached by the io library. Full io handle methods (read/write/seek/…) land with the io file model; this is the GC-level object + identity.
value
16-byte tagged value (PUC TValue equivalent). Chosen over 8-byte NaN-boxing on bench evidence — see benches/value_repr.rs and the P02 plan: Lua 5.5’s native i64 forces NaN-boxed integers into 47-bit smis plus range checks, losing 24% on the arithmetic dispatch path.