From dd6d8db49acda5d5353a0a9c42485d9b4bde419d Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Fri, 12 Jul 2019 16:47:02 -0300 Subject: [PATCH] Reordering of instructions in the main loop The instructions in the main interpreter loop were reordered to the same order of their enumeration in 'lopcodes.h'. --- lvm.c | 88 +++++++++++++++++++++++++++++------------------------------ 1 file changed, 44 insertions(+), 44 deletions(-) diff --git a/lvm.c b/lvm.c index 4011819d..ec65ea78 100644 --- a/lvm.c +++ b/lvm.c @@ -1097,11 +1097,6 @@ void luaV_execute (lua_State *L, CallInfo *ci) { setobjs2s(L, ra, RB(i)); vmbreak; } - vmcase(OP_LOADK) { - TValue *rb = k + GETARG_Bx(i); - setobj2s(L, ra, rb); - vmbreak; - } vmcase(OP_LOADI) { lua_Integer b = GETARG_sBx(i); setivalue(s2v(ra), b); @@ -1112,6 +1107,11 @@ void luaV_execute (lua_State *L, CallInfo *ci) { setfltvalue(s2v(ra), cast_num(b)); vmbreak; } + vmcase(OP_LOADK) { + TValue *rb = k + GETARG_Bx(i); + setobj2s(L, ra, rb); + vmbreak; + } vmcase(OP_LOADKX) { TValue *rb; rb = k + GETARG_Ax(*pc); pc++; @@ -1331,6 +1331,45 @@ void luaV_execute (lua_State *L, CallInfo *ci) { op_arithK(L, luaV_idiv, luai_numidiv, TM_IDIV, 0); vmbreak; } + vmcase(OP_BANDK) { + op_bitwiseK(L, l_band, TM_BAND); + vmbreak; + } + vmcase(OP_BORK) { + op_bitwiseK(L, l_bor, TM_BOR); + vmbreak; + } + vmcase(OP_BXORK) { + op_bitwiseK(L, l_bxor, TM_BXOR); + vmbreak; + } + vmcase(OP_SHRI) { + TValue *rb = vRB(i); + int ic = GETARG_sC(i); + lua_Integer ib; + if (tointegerns(rb, &ib)) { + setivalue(s2v(ra), luaV_shiftl(ib, -ic)); + } + else { + TMS ev = TM_SHR; + if (TESTARG_k(i)) { + ic = -ic; ev = TM_SHL; + } + Protect(luaT_trybiniTM(L, rb, ic, 0, ra, ev)); + } + vmbreak; + } + vmcase(OP_SHLI) { + TValue *rb = vRB(i); + int ic = GETARG_sC(i); + lua_Integer ib; + if (tointegerns(rb, &ib)) { + setivalue(s2v(ra), luaV_shiftl(ic, ib)); + } + else + Protect(luaT_trybiniTM(L, rb, ic, 1, ra, TM_SHL)); + vmbreak; + } vmcase(OP_ADD) { op_arith(L, l_addi, luai_numadd, TM_ADD); vmbreak; @@ -1359,18 +1398,6 @@ void luaV_execute (lua_State *L, CallInfo *ci) { op_arith(L, luaV_idiv, luai_numidiv, TM_IDIV); vmbreak; } - vmcase(OP_BANDK) { - op_bitwiseK(L, l_band, TM_BAND); - vmbreak; - } - vmcase(OP_BORK) { - op_bitwiseK(L, l_bor, TM_BOR); - vmbreak; - } - vmcase(OP_BXORK) { - op_bitwiseK(L, l_bxor, TM_BXOR); - vmbreak; - } vmcase(OP_BAND) { op_bitwise(L, l_band, TM_BAND); vmbreak; @@ -1383,33 +1410,6 @@ void luaV_execute (lua_State *L, CallInfo *ci) { op_bitwise(L, l_bxor, TM_BXOR); vmbreak; } - vmcase(OP_SHRI) { - TValue *rb = vRB(i); - int ic = GETARG_sC(i); - lua_Integer ib; - if (tointegerns(rb, &ib)) { - setivalue(s2v(ra), luaV_shiftl(ib, -ic)); - } - else { - TMS ev = TM_SHR; - if (TESTARG_k(i)) { - ic = -ic; ev = TM_SHL; - } - Protect(luaT_trybiniTM(L, rb, ic, 0, ra, ev)); - } - vmbreak; - } - vmcase(OP_SHLI) { - TValue *rb = vRB(i); - int ic = GETARG_sC(i); - lua_Integer ib; - if (tointegerns(rb, &ib)) { - setivalue(s2v(ra), luaV_shiftl(ic, ib)); - } - else - Protect(luaT_trybiniTM(L, rb, ic, 1, ra, TM_SHL)); - vmbreak; - } vmcase(OP_SHR) { TValue *rb = vRB(i); TValue *rc = vRC(i);