Add LJ_FR2 mode: Two-slot frame info.
This commit is contained in:
@@ -502,6 +502,7 @@ static LoopEvent rec_for(jit_State *J, const BCIns *fori, int isforl)
|
||||
static LoopEvent rec_iterl(jit_State *J, const BCIns iterins)
|
||||
{
|
||||
BCReg ra = bc_a(iterins);
|
||||
lua_assert(!LJ_FR2); /* TODO_FR2: handle different frame setup. */
|
||||
if (!tref_isnil(getslot(J, ra))) { /* Looping back? */
|
||||
J->base[ra-1] = J->base[ra]; /* Copy result of ITERC to control var. */
|
||||
J->maxslot = ra-1+bc_b(J->pc[-1]);
|
||||
@@ -672,6 +673,7 @@ static void rec_call_setup(jit_State *J, BCReg func, ptrdiff_t nargs)
|
||||
TValue *functv = &J->L->base[func];
|
||||
TRef *fbase = &J->base[func];
|
||||
ptrdiff_t i;
|
||||
lua_assert(!LJ_FR2); /* TODO_FR2: handle different frame setup. */
|
||||
for (i = 0; i <= nargs; i++)
|
||||
(void)getslot(J, func+i); /* Ensure func and all args have a reference. */
|
||||
if (!tref_isfunc(fbase[0])) { /* Resolve __call metamethod. */
|
||||
@@ -788,7 +790,8 @@ void lj_record_ret(jit_State *J, BCReg rbase, ptrdiff_t gotresults)
|
||||
BCIns callins = *(frame_pc(frame)-1);
|
||||
ptrdiff_t nresults = bc_b(callins) ? (ptrdiff_t)bc_b(callins)-1 :gotresults;
|
||||
BCReg cbase = bc_a(callins);
|
||||
GCproto *pt = funcproto(frame_func(frame - (cbase+1)));
|
||||
GCproto *pt = funcproto(frame_func(frame - (cbase+1-LJ_FR2)));
|
||||
lua_assert(!LJ_FR2); /* TODO_FR2: handle different frame teardown. */
|
||||
if ((pt->flags & PROTO_NOJIT))
|
||||
lj_trace_err(J, LJ_TRERR_CJITOFF);
|
||||
if (J->framedepth == 0 && J->pt && frame == J->L->base - 1) {
|
||||
@@ -973,6 +976,7 @@ static TRef rec_mm_arith(jit_State *J, RecordIndex *ix, MMS mm)
|
||||
lj_trace_err(J, LJ_TRERR_NOMM);
|
||||
}
|
||||
ok:
|
||||
lua_assert(!LJ_FR2); /* TODO_FR2: handle different frame setup. */
|
||||
base[0] = ix->mobj;
|
||||
copyTV(J->L, basev+0, &ix->mobjv);
|
||||
lj_record_call(J, func, 2);
|
||||
@@ -989,6 +993,7 @@ static TRef rec_mm_len(jit_State *J, TRef tr, TValue *tv)
|
||||
BCReg func = rec_mm_prep(J, lj_cont_ra);
|
||||
TRef *base = J->base + func;
|
||||
TValue *basev = J->L->base + func;
|
||||
lua_assert(!LJ_FR2); /* TODO_FR2: handle different frame setup. */
|
||||
base[0] = ix.mobj; copyTV(J->L, basev+0, &ix.mobjv);
|
||||
base[1] = tr; copyTV(J->L, basev+1, tv);
|
||||
#if LJ_52
|
||||
@@ -1011,6 +1016,7 @@ static void rec_mm_callcomp(jit_State *J, RecordIndex *ix, int op)
|
||||
BCReg func = rec_mm_prep(J, (op&1) ? lj_cont_condf : lj_cont_condt);
|
||||
TRef *base = J->base + func;
|
||||
TValue *tv = J->L->base + func;
|
||||
lua_assert(!LJ_FR2); /* TODO_FR2: handle different frame setup. */
|
||||
base[0] = ix->mobj; base[1] = ix->val; base[2] = ix->key;
|
||||
copyTV(J->L, tv+0, &ix->mobjv);
|
||||
copyTV(J->L, tv+1, &ix->valv);
|
||||
@@ -1261,6 +1267,7 @@ TRef lj_record_idx(jit_State *J, RecordIndex *ix)
|
||||
BCReg func = rec_mm_prep(J, ix->val ? lj_cont_nop : lj_cont_ra);
|
||||
TRef *base = J->base + func;
|
||||
TValue *tv = J->L->base + func;
|
||||
lua_assert(!LJ_FR2); /* TODO_FR2: handle different frame setup. */
|
||||
base[0] = ix->mobj; base[1] = ix->tab; base[2] = ix->key;
|
||||
setfuncV(J->L, tv+0, funcV(&ix->mobjv));
|
||||
copyTV(J->L, tv+1, &ix->tabv);
|
||||
@@ -2135,28 +2142,28 @@ void lj_record_ins(jit_State *J)
|
||||
/* -- Calls and vararg handling ----------------------------------------- */
|
||||
|
||||
case BC_ITERC:
|
||||
J->base[ra] = getslot(J, ra-3);
|
||||
J->base[ra+1] = getslot(J, ra-2);
|
||||
J->base[ra+2] = getslot(J, ra-1);
|
||||
J->base[ra] = getslot(J, ra-3-LJ_FR2);
|
||||
J->base[ra+1] = getslot(J, ra-2-LJ_FR2);
|
||||
J->base[ra+2] = getslot(J, ra-1-LJ_FR2);
|
||||
{ /* Do the actual copy now because lj_record_call needs the values. */
|
||||
TValue *b = &J->L->base[ra];
|
||||
copyTV(J->L, b, b-3);
|
||||
copyTV(J->L, b+1, b-2);
|
||||
copyTV(J->L, b+2, b-1);
|
||||
copyTV(J->L, b, b-3-LJ_FR2);
|
||||
copyTV(J->L, b+1, b-2-LJ_FR2);
|
||||
copyTV(J->L, b+2, b-1-LJ_FR2);
|
||||
}
|
||||
lj_record_call(J, ra, (ptrdiff_t)rc-1);
|
||||
break;
|
||||
|
||||
/* L->top is set to L->base+ra+rc+NARGS-1+1. See lj_dispatch_ins(). */
|
||||
case BC_CALLM:
|
||||
rc = (BCReg)(J->L->top - J->L->base) - ra;
|
||||
rc = (BCReg)(J->L->top - J->L->base) - ra - LJ_FR2;
|
||||
/* fallthrough */
|
||||
case BC_CALL:
|
||||
lj_record_call(J, ra, (ptrdiff_t)rc-1);
|
||||
break;
|
||||
|
||||
case BC_CALLMT:
|
||||
rc = (BCReg)(J->L->top - J->L->base) - ra;
|
||||
rc = (BCReg)(J->L->top - J->L->base) - ra - LJ_FR2;
|
||||
/* fallthrough */
|
||||
case BC_CALLT:
|
||||
lj_record_tailcall(J, ra, (ptrdiff_t)rc-1);
|
||||
|
||||
Reference in New Issue
Block a user