From 2b650e4b6142b9facea3416f89bc7bf7d7c7ac31 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 15 May 2026 11:53:53 +0200 Subject: [PATCH] Revert "Blua: 'Protect' in table operations is not needed in the fast track" This reverts commit 537a50b9b3d7f33d95e142910ef5880cc8cc57cf. --- src/blua/lvm.c | 30 +++++++----------------------- 1 file changed, 7 insertions(+), 23 deletions(-) diff --git a/src/blua/lvm.c b/src/blua/lvm.c index 7540bcdec..484329825 100644 --- a/src/blua/lvm.c +++ b/src/blua/lvm.c @@ -393,21 +393,6 @@ static void Arith (lua_State *L, StkId ra, TValue *rb, } -/* -** copy of 'luaV_gettable', but protecting call to potential metamethod -** (which can reallocate the stack) -*/ -#define gettableProtected(L,t,k,v) { TValue *aux; \ - if (luaV_fastget(L,t,k,aux,luaH_get)) { setobj2s(L, v, aux); } \ - else Protect(luaV_finishget(L,t,k,v,aux)); } - - -/* same for 'luaV_settable' */ -#define settableProtected(L,t,k,v) { TValue *slot; \ - if (!luaV_fastset(L,t,k,slot,luaH_set,v)) \ - Protect(luaV_finishset(L,t,k,v,slot)); } - - void luaV_execute (lua_State *L, int nexeccalls) { LClosure *cl; @@ -417,9 +402,9 @@ void luaV_execute (lua_State *L, int nexeccalls) { reentry: /* entry point */ lua_assert(isLua(L->ci)); pc = L->savedpc; - cl = &clvalue(L->ci->func)->l; /* local reference to function's closure */ - k = cl->p->k; /* local reference to function's constant table */ - base = L->base; /* local copy of function's base */ + cl = &clvalue(L->ci->func)->l; + base = L->base; + k = cl->p->k; /* main loop of interpreter */ for (;;) { const Instruction i = *pc++; @@ -479,7 +464,7 @@ void luaV_execute (lua_State *L, int nexeccalls) { StkId ra = RA(i); StkId rb = RB(i); TValue *rc = RKC(i); - gettableProtected(L, rb, rc, ra); + Protect(luaV_gettable(L, rb, rc, ra)); continue; } case OP_SETGLOBAL: { @@ -501,7 +486,7 @@ void luaV_execute (lua_State *L, int nexeccalls) { StkId ra = RA(i); TValue *rb = RKB(i); TValue *rc = RKC(i); - settableProtected(L, ra, rb, rc); + Protect(luaV_settable(L, ra, rb, rc)); continue; } case OP_NEWTABLE: { @@ -515,9 +500,8 @@ void luaV_execute (lua_State *L, int nexeccalls) { case OP_SELF: { StkId ra = RA(i); StkId rb = RB(i); - TValue *rc = RKC(i); - setobjs2s(L, ra + 1, rb); - gettableProtected(L, rb, rc, ra); + setobjs2s(L, ra+1, rb); + Protect(luaV_gettable(L, rb, RKC(i), ra)); continue; } case OP_ADD: {