Expand description
Centralized Lua VM limits and configuration constants.
Mirrors Lua 5.5’s luaconf.h / llimits.h design.
All magic numbers that control VM behavior are collected here
for easy tuning and configuration.
Constants§
- BASIC_
STACK_ SIZE - Initial stack capacity for new Lua states. Equivalent to 2 × LUA_MINSTACK (Lua 5.5: LUA_MINSTACK = 20).
- CONCAT_
STACK_ BUF_ SIZE - Stack-allocated buffer size for small concatenations.
- CSTACKERR
- Extra C-stack depth allowance granted during error-handler execution.
Allows error handlers and
__closemetamethods to run even after a C-stack overflow. - DEFAULT_
GC_ MAJORMINOR - Major-to-minor GC transition threshold (percentage).
- DEFAULT_
GC_ MINORMAJOR - Minor-to-major GC transition threshold (percentage).
- DEFAULT_
GC_ MINORMUL - Default minor GC collection multiplier (percentage). Matches C Lua 5.5’s LUAI_GENMINORMUL = 20. A young (minor) collection will run after creating GENMINORMUL% new bytes.
- DEFAULT_
GC_ PAUSE - Default GC pause (percentage). Controls how long GC waits before starting a new cycle. 250 = wait until memory is 2.5x the size after last collection.
- DEFAULT_
GC_ STEPMUL - Default GC step multiplier (percentage). Controls how much work GC does per step relative to memory allocation. 200 = collect 2x the allocated speed.
- EXTRA_
STACK - Extra stack slots above frame_top for C function calls, temporaries, etc. Matches Lua 5.5’s EXTRA_STACK (5).
- GC_
SWEEPMAX - Maximum number of objects swept per single GC step.
- LFIELDS_
PER_ FLUSH - Number of list items to flush per SETLIST instruction in table constructors. Matches Lua 5.5’s LFIELDS_PER_FLUSH.
- LUAI_
MAXCSTACK - Default maximum C-stack depth (Rust recursion depth).
Matches C Lua 5.5’s
LUAI_MAXCSTACK(200). Limits how many times we can recursively enterlua_execute, call metamethods, or call C functions. - LUAI_
MAXSHORTLEN - Maximum length for “short” strings (interned in hash table). Matches Lua 5.5’s LUAI_MAXSHORTLEN.
- LUAI_
MAXSTACK - Default maximum stack size (number of slots). Matches Lua 5.5’s LUAI_MAXSTACK.
- LUA_
MAXCAPTURES - Maximum number of captures in
string.find/string.gmatchpatterns. Matches Lua 5.5’s LUA_MAXCAPTURES. - LUA_
MINSTACK - Minimum guaranteed stack slots available to C functions. Matches Lua 5.5’s LUA_MINSTACK.
- MAXCCALLS
- Maximum parser recursion depth (prevents stack overflow in parser). Matches Lua 5.5’s MAXCCALLS for the parser.
- MAXCCALLS_
PATTERN - Maximum match recursion depth for pattern matching.
- MAXINDEXRK
- Maximum index for R/K operand in instructions.
- MAXTAGLOOP
- Maximum depth for __index / __newindex metamethod chains. Prevents infinite loops in metamethod resolution. Matches Lua 5.5’s MAXTAGLOOP.
- MAXUPVAL
- Maximum number of upvalues per function. Matches Lua 5.5’s MAXUPVAL.
- MAXVARS
- Maximum number of local variables per function. Matches Lua 5.5’s MAXVARS.
- MAX_
CALL_ DEPTH - Default maximum Lua call-stack depth (number of call frames).
This limits how deep pure-Lua calls can nest.
Set high by default — the real recursion guard is
LUAI_MAXCSTACK. - MAX_
SRC_ LEN - Maximum length of source name in error messages.
- MAX_
STRING_ SIZE - Maximum string size (1 GB).
- NO_REG
- “No register” sentinel value in the compiler.
- UNARY_
PRIORITY - Unary operator priority in expression parser.