From bfce3c1127fd57fe0c935c92bcf45b4737041edd Mon Sep 17 00:00:00 2001 From: Mike Pall Date: Thu, 10 Mar 2011 01:57:24 +0100 Subject: DUALNUM: Handle integer type in JIT compiler. --- src/lj_opt_loop.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/lj_opt_loop.c') diff --git a/src/lj_opt_loop.c b/src/lj_opt_loop.c index 559e579e..6dd06636 100644 --- a/src/lj_opt_loop.c +++ b/src/lj_opt_loop.c @@ -300,8 +300,11 @@ static void loop_unroll(jit_State *J) } /* Check all loop-carried dependencies for type instability. */ if (!irt_sametype(t, irr->t)) { - if (irt_isnum(t) && irt_isinteger(irr->t)) /* Fix int->num case. */ + if (irt_isnum(t) && irt_isinteger(irr->t)) /* Fix int->num. */ subst[ins] = tref_ref(emitir(IRTN(IR_CONV), ref, IRCONV_NUM_INT)); + else if (irt_isnum(irr->t) && irt_isinteger(t)) /* Fix num->int. */ + subst[ins] = tref_ref(emitir(IRTGI(IR_CONV), ref, + IRCONV_INT_NUM|IRCONV_CHECK)); else if (!(irt_isinteger(t) && irt_isinteger(irr->t))) lj_trace_err(J, LJ_TRERR_TYPEINS); } @@ -355,8 +358,8 @@ int lj_opt_loop(jit_State *J) int errcode = lj_vm_cpcall(J->L, NULL, J, cploop_opt); if (LJ_UNLIKELY(errcode)) { lua_State *L = J->L; - if (errcode == LUA_ERRRUN && tvisnum(L->top-1)) { /* Trace error? */ - int32_t e = lj_num2int(numV(L->top-1)); + if (errcode == LUA_ERRRUN && tvisnumber(L->top-1)) { /* Trace error? */ + int32_t e = numberVint(L->top-1); switch ((TraceError)e) { case LJ_TRERR_TYPEINS: /* Type instability. */ case LJ_TRERR_GFAIL: /* Guard would always fail. */ -- cgit v1.2.3-55-g6feb