aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Pall <mike>2009-12-08 19:52:28 +0100
committerMike Pall <mike>2009-12-08 19:52:28 +0100
commit5287b9326479ea2b7dddd6f642673e58e5a7f354 (patch)
treef6f9fe375652f6cfc607d8c5f022ccbaff857c4d /src
parent2d0ef4522bebcc380e9aaf21b9bebcb62fcfc4fe (diff)
downloadluajit-5287b9326479ea2b7dddd6f642673e58e5a7f354.tar.gz
luajit-5287b9326479ea2b7dddd6f642673e58e5a7f354.tar.bz2
luajit-5287b9326479ea2b7dddd6f642673e58e5a7f354.zip
LuaJIT-2.0.0-beta2 hotfix #2v2.0.0-beta2-hotfix2
Fix lua_tocfunction(). Fix cutoff register in JMP bytecode for some conditional expressions. Fix PHI marking algorithm for references from variant slots.
Diffstat (limited to 'src')
-rw-r--r--src/lj_api.c8
-rw-r--r--src/lj_opt_loop.c17
-rw-r--r--src/lj_parse.c6
3 files changed, 20 insertions, 11 deletions
diff --git a/src/lj_api.c b/src/lj_api.c
index db48e3a6..7a759e5f 100644
--- a/src/lj_api.c
+++ b/src/lj_api.c
@@ -486,8 +486,12 @@ LUA_API size_t lua_objlen(lua_State *L, int idx)
486LUA_API lua_CFunction lua_tocfunction(lua_State *L, int idx) 486LUA_API lua_CFunction lua_tocfunction(lua_State *L, int idx)
487{ 487{
488 cTValue *o = index2adr(L, idx); 488 cTValue *o = index2adr(L, idx);
489 ASMFunction gate = funcV(o)->c.gate; 489 if (tvisfunc(o)) {
490 return (gate == lj_gate_c || gate == lj_gate_cwrap) ? funcV(o)->c.f : NULL; 490 ASMFunction gate = funcV(o)->c.gate;
491 if (gate == lj_gate_c || gate == lj_gate_cwrap)
492 return funcV(o)->c.f;
493 }
494 return NULL;
491} 495}
492 496
493LUA_API void *lua_touserdata(lua_State *L, int idx) 497LUA_API void *lua_touserdata(lua_State *L, int idx)
diff --git a/src/lj_opt_loop.c b/src/lj_opt_loop.c
index 05e9409e..f9a2a808 100644
--- a/src/lj_opt_loop.c
+++ b/src/lj_opt_loop.c
@@ -131,15 +131,18 @@ static void loop_emit_phi(jit_State *J, IRRef1 *subst, IRRef1 *phi, IRRef nphi)
131 nslots = J->baseslot+J->maxslot; 131 nslots = J->baseslot+J->maxslot;
132 for (i = 1; i < nslots; i++) { 132 for (i = 1; i < nslots; i++) {
133 IRRef ref = tref_ref(J->slot[i]); 133 IRRef ref = tref_ref(J->slot[i]);
134 if (!irref_isk(ref) && ref != subst[ref]) { 134 while (!irref_isk(ref) && ref != subst[ref]) {
135 IRIns *ir = IR(ref); 135 IRIns *ir = IR(ref);
136 irt_clearmark(ir->t); /* Unmark potential uses, too. */ 136 irt_clearmark(ir->t); /* Unmark potential uses, too. */
137 if (!irt_isphi(ir->t) && !irt_ispri(ir->t)) { 137 if (irt_isphi(ir->t) || irt_ispri(ir->t))
138 irt_setphi(ir->t); 138 break;
139 if (nphi >= LJ_MAX_PHI) 139 irt_setphi(ir->t);
140 lj_trace_err(J, LJ_TRERR_PHIOV); 140 if (nphi >= LJ_MAX_PHI)
141 phi[nphi++] = (IRRef1)ref; 141 lj_trace_err(J, LJ_TRERR_PHIOV);
142 } 142 phi[nphi++] = (IRRef1)ref;
143 ref = subst[ref];
144 if (ref > invar)
145 break;
143 } 146 }
144 } 147 }
145 /* Pass #4: emit PHI instructions or eliminate PHIs. */ 148 /* Pass #4: emit PHI instructions or eliminate PHIs. */
diff --git a/src/lj_parse.c b/src/lj_parse.c
index 663525ab..000772fe 100644
--- a/src/lj_parse.c
+++ b/src/lj_parse.c
@@ -636,6 +636,7 @@ static void invertjump(FuncState *fs, ExpDesc *e)
636 636
637static BCPos jumponcond(FuncState *fs, ExpDesc *e, int cond) 637static BCPos jumponcond(FuncState *fs, ExpDesc *e, int cond)
638{ 638{
639 BCPos pc;
639 if (e->k == VRELOCABLE) { 640 if (e->k == VRELOCABLE) {
640 BCIns *i = bcptr(fs, e); 641 BCIns *i = bcptr(fs, e);
641 if (bc_op(*i) == BC_NOT) { 642 if (bc_op(*i) == BC_NOT) {
@@ -648,9 +649,10 @@ static BCPos jumponcond(FuncState *fs, ExpDesc *e, int cond)
648 reserveregs(fs, 1); 649 reserveregs(fs, 1);
649 discharge2reg(fs, e, fs->freereg-1); 650 discharge2reg(fs, e, fs->freereg-1);
650 } 651 }
651 freeexp(fs, e);
652 emitAD(fs, cond ? BC_ISTC : BC_ISFC, NO_REG, e->u.s.info); 652 emitAD(fs, cond ? BC_ISTC : BC_ISFC, NO_REG, e->u.s.info);
653 return emit_jump(fs); 653 pc = emit_jump(fs);
654 freeexp(fs, e);
655 return pc;
654} 656}
655 657
656static void goiftrue(FuncState *fs, ExpDesc *e) 658static void goiftrue(FuncState *fs, ExpDesc *e)