summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2017-10-01 16:13:43 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2017-10-01 16:13:43 -0300
commitbc1b0733b808f02639ed79fff02f69f731636539 (patch)
treed90ae6263abb6fe1e6641e9a33981457418edea5
parent722bdbe17d0192baf72978f88069d12a921e9bfb (diff)
downloadlua-github-bc1b0733b808f02639ed79fff02f69f731636539.tar.gz
avoid the use of bit 'Bk' ('B' will lose this bit soon)
-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 @@
/*
-** $Id: lcode.c,v 2.125 2017/09/26 18:14:45 roberto Exp roberto $
+** $Id: lcode.c,v 2.126 2017/09/28 16:53:29 roberto Exp roberto $
** Code generator for Lua
** See Copyright Notice in lua.h
*/
@@ -1068,7 +1068,7 @@ static int isKstr (FuncState *fs, expdesc *e) {
*/
static int isKint (expdesc *e) {
return (e->k == VKINT && !hasjumps(e) &&
- l_castS2U(e->u.ival) <= l_castS2U(MAXARG_C));
+ l_castS2U(e->u.ival) <= l_castS2U(MAXARG_Cr));
}
@@ -1178,8 +1178,8 @@ static void codebinexpval (FuncState *fs, OpCode op,
v1 = luaK_exp2anyreg(fs, e1);
}
else { /* exchange operands to make 2nd one a constant */
- v2 = cast_int(e1->u.ival);
- v1 = luaK_exp2anyreg(fs, e2) | BITRK; /* K bit signal the exchange */
+ v2 = cast_int(e1->u.ival) | BITRK; /* K bit signal the exchange */
+ v1 = luaK_exp2anyreg(fs, e2);
}
op = OP_ADDI;
}
diff --git a/lopcodes.h b/lopcodes.h
index 6b9c3aeb..5aa75b16 100644
--- a/lopcodes.h
+++ b/lopcodes.h
@@ -1,5 +1,5 @@
/*
-** $Id: lopcodes.h,v 1.161 2017/09/26 18:14:45 roberto Exp roberto $
+** $Id: lopcodes.h,v 1.162 2017/09/28 16:53:29 roberto Exp roberto $
** Opcodes for Lua virtual machine
** See Copyright Notice in lua.h
*/
@@ -73,6 +73,7 @@ enum OpMode {iABC, iABx, iAsBx, iAx}; /* basic instruction format */
#define MAXARG_A ((1<<SIZE_A)-1)
#define MAXARG_B ((1<<SIZE_B)-1)
#define MAXARG_C ((1<<SIZE_C)-1)
+#define MAXARG_Cr ((1<<(SIZE_C - 1))-1)
/* creates a mask with 'n' 1 bits at position 'p' */
@@ -102,10 +103,6 @@ enum OpMode {iABC, iABx, iAsBx, iAx}; /* basic instruction format */
#define GETARG_B(i) check_exp(checkopm(i, iABC), getarg(i, POS_B, SIZE_B))
#define SETARG_B(i,v) setarg(i, v, POS_B, SIZE_B)
-#define GETARG_Br(i) \
- check_exp(checkopm(i, iABC), getarg(i, POS_B, SIZE_B - 1))
-#define GETARG_Bk(i) getarg(i, (POS_B + SIZE_B - 1), 1)
-
#define GETARG_C(i) check_exp(checkopm(i, iABC), getarg(i, POS_C, SIZE_C))
#define SETARG_C(i,v) setarg(i, v, POS_C, SIZE_C)
@@ -142,7 +139,7 @@ enum OpMode {iABC, iABx, iAsBx, iAx}; /* basic instruction format */
*/
/* this bit 1 means constant (0 means register) */
-#define BITRK (1 << (SIZE_B - 1))
+#define BITRK (1 << (SIZE_C - 1))
/* test whether value is a constant */
#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 @@
/*
-** $Id: lvm.c,v 2.295 2017/09/27 18:59:08 roberto Exp roberto $
+** $Id: lvm.c,v 2.296 2017/09/28 16:53:29 roberto Exp roberto $
** Lua virtual machine
** See Copyright Notice in lua.h
*/
@@ -733,7 +733,7 @@ void luaV_finishOp (lua_State *L) {
#define RA(i) (base+GETARG_A(i))
-#define RB(i) (base+GETARG_Br(i))
+#define RB(i) (base+GETARG_B(i))
#define vRB(i) s2v(RB(i))
#define KB(i) (k+GETARG_B(i))
#define RC(i) (base+GETARG_C(i))
@@ -989,7 +989,7 @@ void luaV_execute (lua_State *L) {
}
vmcase(OP_ADDI) {
TValue *rb = vRB(i);
- int ic = GETARG_C(i);
+ int ic = GETARG_Cr(i);
lua_Number nb;
if (ttisinteger(rb)) {
setivalue(s2v(ra), intop(+, ivalue(rb), ic));
@@ -998,7 +998,7 @@ void luaV_execute (lua_State *L) {
setfltvalue(s2v(ra), luai_numadd(L, nb, cast_num(ic)));
}
else
- Protect(luaT_trybiniTM(L, rb, ic, GETARG_Bk(i), ra, TM_ADD));
+ Protect(luaT_trybiniTM(L, rb, ic, GETARG_Ck(i), ra, TM_ADD));
vmbreak;
}
vmcase(OP_ADD) {