From a567f6119fb906c6b47bb1f197e030538b650493 Mon Sep 17 00:00:00 2001 From: Lukas Diekmann Date: Wed, 23 Apr 2025 11:08:01 +0100 Subject: [PATCH] Promote big constants for arithmetic operations. --- src/lvm.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/lvm.c b/src/lvm.c index 8ca2df9..df64cbc 100644 --- a/src/lvm.c +++ b/src/lvm.c @@ -985,10 +985,22 @@ void luaV_finishOp (lua_State *L) { /* ** Arithmetic operations with K operands. */ +#ifdef USE_YK +#define op_arithK(L,iop,fop) { \ + TValue *v1 = vRB(i); \ + TValue *v2 = KC(i); lua_assert(ttisnumber(v2)); \ + StkId ra = RA(i); \ + if (ttisinteger(v1) && ttisinteger(v2)) { \ + lua_Integer i1 = ivalue(v1); lua_Integer i2 = yk_promote(ivalue(v2)); \ + pc++; setivalue(s2v(ra), iop(L, i1, i2)); \ + } \ + else op_arithf_aux(L, v1, v2, fop); } +#else #define op_arithK(L,iop,fop) { \ TValue *v1 = vRB(i); \ TValue *v2 = KC(i); lua_assert(ttisnumber(v2)); \ op_arith_aux(L, v1, v2, iop, fop); } +#endif /*