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:
13
lvm.c
13
lvm.c
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user