Replace upvalue-based shell dispatch with OP_LUSH opcode

Add a dedicated OP_LUSH A B instruction that loads shell C functions
directly from the registry, eliminating the need for upvalue allocation
in mainfunc(), upvalue population in lua_load(), and the fragile
LUSH_NUM_UPVALS heuristic. Every chunk no longer carries 4 extra
upvalues.
This commit is contained in:
Cormac Shannon
2026-03-12 22:47:25 +00:00
parent f88b17959f
commit f09a033160
9 changed files with 46 additions and 78 deletions

13
lvm.c
View File

@@ -1939,6 +1939,19 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
Protect(luaT_getvarargs(L, ci, ra, n));
vmbreak;
}
vmcase(OP_LUSH) {
StkId ra = RA(i);
int idx = GETARG_B(i);
Table *regt = hvalue(&G(L)->l_registry);
TValue lushtv;
lu_byte tag = luaH_getint(regt, LUA_RIDX_LUSH, &lushtv);
if (novariant(tag) == LUA_TTABLE) {
TValue func;
luaH_getint(hvalue(&lushtv), idx + 1, &func); /* 1-based */
setobj2s(L, ra, &func);
}
vmbreak;
}
vmcase(OP_GETVARG) {
StkId ra = RA(i);
TValue *rc = vRC(i);