aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Pall <mike>2012-04-09 14:48:27 +0200
committerMike Pall <mike>2012-04-09 14:48:27 +0200
commitd621a6ccc2638fcfea518b7b9f8c377ce93aad8b (patch)
treeec728889bd01f4af354fdb051773a7801d153524 /src
parentc3e1d727caf22c1d87b4f2ca4d7e628d2b4d7d9b (diff)
downloadluajit-d621a6ccc2638fcfea518b7b9f8c377ce93aad8b.tar.gz
luajit-d621a6ccc2638fcfea518b7b9f8c377ce93aad8b.tar.bz2
luajit-d621a6ccc2638fcfea518b7b9f8c377ce93aad8b.zip
Fix discharge order of comparisons in Lua parser.
Diffstat (limited to 'src')
-rw-r--r--src/lj_parse.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/lj_parse.c b/src/lj_parse.c
index aca719a3..0f32d121 100644
--- a/src/lj_parse.c
+++ b/src/lj_parse.c
@@ -833,13 +833,14 @@ static void bcemit_comp(FuncState *fs, BinOpr opr, ExpDesc *e1, ExpDesc *e2)
833 } 833 }
834 } else { 834 } else {
835 uint32_t op = opr-OPR_LT+BC_ISLT; 835 uint32_t op = opr-OPR_LT+BC_ISLT;
836 BCReg ra; 836 BCReg ra, rd;
837 if ((op-BC_ISLT) & 1) { /* GT -> LT, GE -> LE */ 837 if ((op-BC_ISLT) & 1) { /* GT -> LT, GE -> LE */
838 e1 = e2; e2 = eret; /* Swap operands. */ 838 e1 = e2; e2 = eret; /* Swap operands. */
839 op = ((op-BC_ISLT)^3)+BC_ISLT; 839 op = ((op-BC_ISLT)^3)+BC_ISLT;
840 } 840 }
841 rd = expr_toanyreg(fs, e2);
841 ra = expr_toanyreg(fs, e1); 842 ra = expr_toanyreg(fs, e1);
842 ins = BCINS_AD(op, ra, expr_toanyreg(fs, e2)); 843 ins = BCINS_AD(op, ra, rd);
843 } 844 }
844 /* Using expr_free might cause asserts if the order is wrong. */ 845 /* Using expr_free might cause asserts if the order is wrong. */
845 if (e1->k == VNONRELOC && e1->u.s.info >= fs->nactvar) fs->freereg--; 846 if (e1->k == VNONRELOC && e1->u.s.info >= fs->nactvar) fs->freereg--;