summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2020-02-11 11:12:33 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2020-02-11 11:12:33 -0300
commit9b7987a9d1471ba94764286b28e0998f73deb46a (patch)
treeb24e2836a29621521d65e6dc77fb39bdc4b627ee
parent28ef7061bbcce39590c97a2ad662e0b60f7adab5 (diff)
downloadlua-9b7987a9d1471ba94764286b28e0998f73deb46a.tar.gz
lua-9b7987a9d1471ba94764286b28e0998f73deb46a.tar.bz2
lua-9b7987a9d1471ba94764286b28e0998f73deb46a.zip
OP_LOADFALSE broken in two instructions
-rw-r--r--lcode.c8
-rw-r--r--ljumptab.h1
-rw-r--r--lopcodes.c1
-rw-r--r--lopcodes.h3
-rw-r--r--lopnames.h1
-rw-r--r--lvm.c6
6 files changed, 14 insertions, 6 deletions
diff --git a/lcode.c b/lcode.c
index 332fdd00..35e0527f 100644
--- a/lcode.c
+++ b/lcode.c
@@ -872,9 +872,9 @@ static void discharge2anyreg (FuncState *fs, expdesc *e) {
872} 872}
873 873
874 874
875static int code_loadbool (FuncState *fs, int A, OpCode op, int jump) { 875static int code_loadbool (FuncState *fs, int A, OpCode op) {
876 luaK_getlabel(fs); /* those instructions may be jump targets */ 876 luaK_getlabel(fs); /* those instructions may be jump targets */
877 return luaK_codeABC(fs, op, A, jump, 0); 877 return luaK_codeABC(fs, op, A, 0, 0);
878} 878}
879 879
880 880
@@ -908,8 +908,8 @@ static void exp2reg (FuncState *fs, expdesc *e, int reg) {
908 int p_t = NO_JUMP; /* position of an eventual LOAD true */ 908 int p_t = NO_JUMP; /* position of an eventual LOAD true */
909 if (need_value(fs, e->t) || need_value(fs, e->f)) { 909 if (need_value(fs, e->t) || need_value(fs, e->f)) {
910 int fj = (e->k == VJMP) ? NO_JUMP : luaK_jump(fs); 910 int fj = (e->k == VJMP) ? NO_JUMP : luaK_jump(fs);
911 p_f = code_loadbool(fs, reg, OP_LOADFALSE, 1); /* skip next inst. */ 911 p_f = code_loadbool(fs, reg, OP_LFALSESKIP); /* skip next inst. */
912 p_t = code_loadbool(fs, reg, OP_LOADTRUE, 0); 912 p_t = code_loadbool(fs, reg, OP_LOADTRUE);
913 /* jump around these booleans if 'e' is not a test */ 913 /* jump around these booleans if 'e' is not a test */
914 luaK_patchtohere(fs, fj); 914 luaK_patchtohere(fs, fj);
915 } 915 }
diff --git a/ljumptab.h b/ljumptab.h
index 22e9575f..0edd79d5 100644
--- a/ljumptab.h
+++ b/ljumptab.h
@@ -31,6 +31,7 @@ static void *disptab[NUM_OPCODES] = {
31&&L_OP_LOADK, 31&&L_OP_LOADK,
32&&L_OP_LOADKX, 32&&L_OP_LOADKX,
33&&L_OP_LOADFALSE, 33&&L_OP_LOADFALSE,
34&&L_OP_LFALSESKIP,
34&&L_OP_LOADTRUE, 35&&L_OP_LOADTRUE,
35&&L_OP_LOADNIL, 36&&L_OP_LOADNIL,
36&&L_OP_GETUPVAL, 37&&L_OP_GETUPVAL,
diff --git a/lopcodes.c b/lopcodes.c
index f5347a3c..4e983e08 100644
--- a/lopcodes.c
+++ b/lopcodes.c
@@ -25,6 +25,7 @@ LUAI_DDEF const lu_byte luaP_opmodes[NUM_OPCODES] = {
25 ,opmode(0, 0, 0, 0, 1, iABx) /* OP_LOADK */ 25 ,opmode(0, 0, 0, 0, 1, iABx) /* OP_LOADK */
26 ,opmode(0, 0, 0, 0, 1, iABx) /* OP_LOADKX */ 26 ,opmode(0, 0, 0, 0, 1, iABx) /* OP_LOADKX */
27 ,opmode(0, 0, 0, 0, 1, iABC) /* OP_LOADFALSE */ 27 ,opmode(0, 0, 0, 0, 1, iABC) /* OP_LOADFALSE */
28 ,opmode(0, 0, 0, 0, 1, iABC) /* OP_LFALSESKIP */
28 ,opmode(0, 0, 0, 0, 1, iABC) /* OP_LOADTRUE */ 29 ,opmode(0, 0, 0, 0, 1, iABC) /* OP_LOADTRUE */
29 ,opmode(0, 0, 0, 0, 1, iABC) /* OP_LOADNIL */ 30 ,opmode(0, 0, 0, 0, 1, iABC) /* OP_LOADNIL */
30 ,opmode(0, 0, 0, 0, 1, iABC) /* OP_GETUPVAL */ 31 ,opmode(0, 0, 0, 0, 1, iABC) /* OP_GETUPVAL */
diff --git a/lopcodes.h b/lopcodes.h
index 8fd52d18..d755870f 100644
--- a/lopcodes.h
+++ b/lopcodes.h
@@ -202,7 +202,8 @@ OP_LOADI,/* A sBx R[A] := sBx */
202OP_LOADF,/* A sBx R[A] := (lua_Number)sBx */ 202OP_LOADF,/* A sBx R[A] := (lua_Number)sBx */
203OP_LOADK,/* A Bx R[A] := K[Bx] */ 203OP_LOADK,/* A Bx R[A] := K[Bx] */
204OP_LOADKX,/* A R[A] := K[extra arg] */ 204OP_LOADKX,/* A R[A] := K[extra arg] */
205OP_LOADFALSE,/* A B R[A] := false; if (B) pc++ */ 205OP_LOADFALSE,/* A R[A] := false */
206OP_LFALSESKIP,/*A R[A] := false; pc++ */
206OP_LOADTRUE,/* A R[A] := true */ 207OP_LOADTRUE,/* A R[A] := true */
207OP_LOADNIL,/* A B R[A], R[A+1], ..., R[A+B] := nil */ 208OP_LOADNIL,/* A B R[A], R[A+1], ..., R[A+B] := nil */
208OP_GETUPVAL,/* A B R[A] := UpValue[B] */ 209OP_GETUPVAL,/* A B R[A] := UpValue[B] */
diff --git a/lopnames.h b/lopnames.h
index a2097a74..f20147e3 100644
--- a/lopnames.h
+++ b/lopnames.h
@@ -16,6 +16,7 @@ static const char *const opnames[] = {
16 "LOADK", 16 "LOADK",
17 "LOADKX", 17 "LOADKX",
18 "LOADFALSE", 18 "LOADFALSE",
19 "LFALSESKIP",
19 "LOADTRUE", 20 "LOADTRUE",
20 "LOADNIL", 21 "LOADNIL",
21 "GETUPVAL", 22 "GETUPVAL",
diff --git a/lvm.c b/lvm.c
index 9c1ad47e..d802379c 100644
--- a/lvm.c
+++ b/lvm.c
@@ -1183,7 +1183,11 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
1183 } 1183 }
1184 vmcase(OP_LOADFALSE) { 1184 vmcase(OP_LOADFALSE) {
1185 setbfvalue(s2v(ra)); 1185 setbfvalue(s2v(ra));
1186 if (GETARG_B(i)) pc++; /* if B, skip next instruction */ 1186 vmbreak;
1187 }
1188 vmcase(OP_LFALSESKIP) {
1189 setbfvalue(s2v(ra));
1190 pc++; /* skip next instruction */
1187 vmbreak; 1191 vmbreak;
1188 } 1192 }
1189 vmcase(OP_LOADTRUE) { 1193 vmcase(OP_LOADTRUE) {