From cc30e88125822e167f770c78eb7e50699cf29fda Mon Sep 17 00:00:00 2001 From: Laurence Tratt Date: Thu, 24 Oct 2024 20:28:34 +0100 Subject: [PATCH] Promote immediates. This is a conservative use of `yk_promote` operating on Lua opcodes which themselves use immediates (e.g. OP_ADDI). It does have a small (just over 1% improvement) effect on big_loop.lua, but the main point of this is to show that we can start to move an interpreter in a yk-specific direction. --- src/lvm.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lvm.c b/src/lvm.c index de547a4..5a938f0 100644 --- a/src/lvm.c +++ b/src/lvm.c @@ -903,7 +903,7 @@ void luaV_finishOp (lua_State *L) { #define op_arithI(L,iop,fop) { \ StkId ra = RA(i); \ TValue *v1 = vRB(i); \ - int imm = GETARG_sC(i); \ + int imm = yk_promote(GETARG_sC(i)); \ if (ttisinteger(v1)) { \ lua_Integer iv1 = ivalue(v1); \ pc++; setivalue(s2v(ra), iop(L, iv1, imm)); \ @@ -1031,7 +1031,7 @@ void luaV_finishOp (lua_State *L) { #define op_orderI(L,opi,opf,inv,tm) { \ StkId ra = RA(i); \ int cond; \ - int im = GETARG_sB(i); \ + int im = yk_promote(GETARG_sB(i)); \ if (ttisinteger(s2v(ra))) \ cond = opi(ivalue(s2v(ra)), im); \ else if (ttisfloat(s2v(ra))) { \ @@ -1531,7 +1531,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) { vmcase(OP_MMBINI) { StkId ra = RA(i); Instruction pi = *(pc - 2); /* original arith. expression */ - int imm = GETARG_sB(i); + int imm = yk_promote(GETARG_sB(i)); TMS tm = (TMS)GETARG_C(i); int flip = GETARG_k(i); StkId result = RA(pi); @@ -1638,7 +1638,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) { vmcase(OP_EQI) { StkId ra = RA(i); int cond; - int im = GETARG_sB(i); + int im = yk_promote(GETARG_sB(i)); if (ttisinteger(s2v(ra))) cond = (ivalue(s2v(ra)) == im); else if (ttisfloat(s2v(ra)))