aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lcode.c8
-rw-r--r--lopcodes.h9
-rw-r--r--lvm.c8
3 files changed, 11 insertions, 14 deletions
diff --git a/lcode.c b/lcode.c
index 1f6e9c11..1331a54e 100644
--- a/lcode.c
+++ b/lcode.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lcode.c,v 2.125 2017/09/26 18:14:45 roberto Exp roberto $ 2** $Id: lcode.c,v 2.126 2017/09/28 16:53:29 roberto Exp roberto $
3** Code generator for Lua 3** Code generator for Lua
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -1068,7 +1068,7 @@ static int isKstr (FuncState *fs, expdesc *e) {
1068*/ 1068*/
1069static int isKint (expdesc *e) { 1069static int isKint (expdesc *e) {
1070 return (e->k == VKINT && !hasjumps(e) && 1070 return (e->k == VKINT && !hasjumps(e) &&
1071 l_castS2U(e->u.ival) <= l_castS2U(MAXARG_C)); 1071 l_castS2U(e->u.ival) <= l_castS2U(MAXARG_Cr));
1072} 1072}
1073 1073
1074 1074
@@ -1178,8 +1178,8 @@ static void codebinexpval (FuncState *fs, OpCode op,
1178 v1 = luaK_exp2anyreg(fs, e1); 1178 v1 = luaK_exp2anyreg(fs, e1);
1179 } 1179 }
1180 else { /* exchange operands to make 2nd one a constant */ 1180 else { /* exchange operands to make 2nd one a constant */
1181 v2 = cast_int(e1->u.ival); 1181 v2 = cast_int(e1->u.ival) | BITRK; /* K bit signal the exchange */
1182 v1 = luaK_exp2anyreg(fs, e2) | BITRK; /* K bit signal the exchange */ 1182 v1 = luaK_exp2anyreg(fs, e2);
1183 } 1183 }
1184 op = OP_ADDI; 1184 op = OP_ADDI;
1185 } 1185 }
diff --git a/lopcodes.h b/lopcodes.h
index 6b9c3aeb..5aa75b16 100644
--- a/lopcodes.h
+++ b/lopcodes.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lopcodes.h,v 1.161 2017/09/26 18:14:45 roberto Exp roberto $ 2** $Id: lopcodes.h,v 1.162 2017/09/28 16:53:29 roberto Exp roberto $
3** Opcodes for Lua virtual machine 3** Opcodes for Lua virtual machine
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -73,6 +73,7 @@ enum OpMode {iABC, iABx, iAsBx, iAx}; /* basic instruction format */
73#define MAXARG_A ((1<<SIZE_A)-1) 73#define MAXARG_A ((1<<SIZE_A)-1)
74#define MAXARG_B ((1<<SIZE_B)-1) 74#define MAXARG_B ((1<<SIZE_B)-1)
75#define MAXARG_C ((1<<SIZE_C)-1) 75#define MAXARG_C ((1<<SIZE_C)-1)
76#define MAXARG_Cr ((1<<(SIZE_C - 1))-1)
76 77
77 78
78/* creates a mask with 'n' 1 bits at position 'p' */ 79/* creates a mask with 'n' 1 bits at position 'p' */
@@ -102,10 +103,6 @@ enum OpMode {iABC, iABx, iAsBx, iAx}; /* basic instruction format */
102#define GETARG_B(i) check_exp(checkopm(i, iABC), getarg(i, POS_B, SIZE_B)) 103#define GETARG_B(i) check_exp(checkopm(i, iABC), getarg(i, POS_B, SIZE_B))
103#define SETARG_B(i,v) setarg(i, v, POS_B, SIZE_B) 104#define SETARG_B(i,v) setarg(i, v, POS_B, SIZE_B)
104 105
105#define GETARG_Br(i) \
106 check_exp(checkopm(i, iABC), getarg(i, POS_B, SIZE_B - 1))
107#define GETARG_Bk(i) getarg(i, (POS_B + SIZE_B - 1), 1)
108
109#define GETARG_C(i) check_exp(checkopm(i, iABC), getarg(i, POS_C, SIZE_C)) 106#define GETARG_C(i) check_exp(checkopm(i, iABC), getarg(i, POS_C, SIZE_C))
110#define SETARG_C(i,v) setarg(i, v, POS_C, SIZE_C) 107#define SETARG_C(i,v) setarg(i, v, POS_C, SIZE_C)
111 108
@@ -142,7 +139,7 @@ enum OpMode {iABC, iABx, iAsBx, iAx}; /* basic instruction format */
142*/ 139*/
143 140
144/* this bit 1 means constant (0 means register) */ 141/* this bit 1 means constant (0 means register) */
145#define BITRK (1 << (SIZE_B - 1)) 142#define BITRK (1 << (SIZE_C - 1))
146 143
147/* test whether value is a constant */ 144/* test whether value is a constant */
148#define ISK(x) ((x) & BITRK) 145#define ISK(x) ((x) & BITRK)
diff --git a/lvm.c b/lvm.c
index fd02ad5b..b534f0a0 100644
--- a/lvm.c
+++ b/lvm.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lvm.c,v 2.295 2017/09/27 18:59:08 roberto Exp roberto $ 2** $Id: lvm.c,v 2.296 2017/09/28 16:53:29 roberto Exp roberto $
3** Lua virtual machine 3** Lua virtual machine
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -733,7 +733,7 @@ void luaV_finishOp (lua_State *L) {
733 733
734 734
735#define RA(i) (base+GETARG_A(i)) 735#define RA(i) (base+GETARG_A(i))
736#define RB(i) (base+GETARG_Br(i)) 736#define RB(i) (base+GETARG_B(i))
737#define vRB(i) s2v(RB(i)) 737#define vRB(i) s2v(RB(i))
738#define KB(i) (k+GETARG_B(i)) 738#define KB(i) (k+GETARG_B(i))
739#define RC(i) (base+GETARG_C(i)) 739#define RC(i) (base+GETARG_C(i))
@@ -989,7 +989,7 @@ void luaV_execute (lua_State *L) {
989 } 989 }
990 vmcase(OP_ADDI) { 990 vmcase(OP_ADDI) {
991 TValue *rb = vRB(i); 991 TValue *rb = vRB(i);
992 int ic = GETARG_C(i); 992 int ic = GETARG_Cr(i);
993 lua_Number nb; 993 lua_Number nb;
994 if (ttisinteger(rb)) { 994 if (ttisinteger(rb)) {
995 setivalue(s2v(ra), intop(+, ivalue(rb), ic)); 995 setivalue(s2v(ra), intop(+, ivalue(rb), ic));
@@ -998,7 +998,7 @@ void luaV_execute (lua_State *L) {
998 setfltvalue(s2v(ra), luai_numadd(L, nb, cast_num(ic))); 998 setfltvalue(s2v(ra), luai_numadd(L, nb, cast_num(ic)));
999 } 999 }
1000 else 1000 else
1001 Protect(luaT_trybiniTM(L, rb, ic, GETARG_Bk(i), ra, TM_ADD)); 1001 Protect(luaT_trybiniTM(L, rb, ic, GETARG_Ck(i), ra, TM_ADD));
1002 vmbreak; 1002 vmbreak;
1003 } 1003 }
1004 vmcase(OP_ADD) { 1004 vmcase(OP_ADD) {