aboutsummaryrefslogtreecommitdiff
path: root/src/lj_record.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lj_record.c')
-rw-r--r--src/lj_record.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/src/lj_record.c b/src/lj_record.c
index 01c09c58..539fd197 100644
--- a/src/lj_record.c
+++ b/src/lj_record.c
@@ -502,6 +502,7 @@ static LoopEvent rec_for(jit_State *J, const BCIns *fori, int isforl)
502static LoopEvent rec_iterl(jit_State *J, const BCIns iterins) 502static LoopEvent rec_iterl(jit_State *J, const BCIns iterins)
503{ 503{
504 BCReg ra = bc_a(iterins); 504 BCReg ra = bc_a(iterins);
505 lua_assert(!LJ_FR2); /* TODO_FR2: handle different frame setup. */
505 if (!tref_isnil(getslot(J, ra))) { /* Looping back? */ 506 if (!tref_isnil(getslot(J, ra))) { /* Looping back? */
506 J->base[ra-1] = J->base[ra]; /* Copy result of ITERC to control var. */ 507 J->base[ra-1] = J->base[ra]; /* Copy result of ITERC to control var. */
507 J->maxslot = ra-1+bc_b(J->pc[-1]); 508 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)
672 TValue *functv = &J->L->base[func]; 673 TValue *functv = &J->L->base[func];
673 TRef *fbase = &J->base[func]; 674 TRef *fbase = &J->base[func];
674 ptrdiff_t i; 675 ptrdiff_t i;
676 lua_assert(!LJ_FR2); /* TODO_FR2: handle different frame setup. */
675 for (i = 0; i <= nargs; i++) 677 for (i = 0; i <= nargs; i++)
676 (void)getslot(J, func+i); /* Ensure func and all args have a reference. */ 678 (void)getslot(J, func+i); /* Ensure func and all args have a reference. */
677 if (!tref_isfunc(fbase[0])) { /* Resolve __call metamethod. */ 679 if (!tref_isfunc(fbase[0])) { /* Resolve __call metamethod. */
@@ -788,7 +790,8 @@ void lj_record_ret(jit_State *J, BCReg rbase, ptrdiff_t gotresults)
788 BCIns callins = *(frame_pc(frame)-1); 790 BCIns callins = *(frame_pc(frame)-1);
789 ptrdiff_t nresults = bc_b(callins) ? (ptrdiff_t)bc_b(callins)-1 :gotresults; 791 ptrdiff_t nresults = bc_b(callins) ? (ptrdiff_t)bc_b(callins)-1 :gotresults;
790 BCReg cbase = bc_a(callins); 792 BCReg cbase = bc_a(callins);
791 GCproto *pt = funcproto(frame_func(frame - (cbase+1))); 793 GCproto *pt = funcproto(frame_func(frame - (cbase+1-LJ_FR2)));
794 lua_assert(!LJ_FR2); /* TODO_FR2: handle different frame teardown. */
792 if ((pt->flags & PROTO_NOJIT)) 795 if ((pt->flags & PROTO_NOJIT))
793 lj_trace_err(J, LJ_TRERR_CJITOFF); 796 lj_trace_err(J, LJ_TRERR_CJITOFF);
794 if (J->framedepth == 0 && J->pt && frame == J->L->base - 1) { 797 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)
973 lj_trace_err(J, LJ_TRERR_NOMM); 976 lj_trace_err(J, LJ_TRERR_NOMM);
974 } 977 }
975ok: 978ok:
979 lua_assert(!LJ_FR2); /* TODO_FR2: handle different frame setup. */
976 base[0] = ix->mobj; 980 base[0] = ix->mobj;
977 copyTV(J->L, basev+0, &ix->mobjv); 981 copyTV(J->L, basev+0, &ix->mobjv);
978 lj_record_call(J, func, 2); 982 lj_record_call(J, func, 2);
@@ -989,6 +993,7 @@ static TRef rec_mm_len(jit_State *J, TRef tr, TValue *tv)
989 BCReg func = rec_mm_prep(J, lj_cont_ra); 993 BCReg func = rec_mm_prep(J, lj_cont_ra);
990 TRef *base = J->base + func; 994 TRef *base = J->base + func;
991 TValue *basev = J->L->base + func; 995 TValue *basev = J->L->base + func;
996 lua_assert(!LJ_FR2); /* TODO_FR2: handle different frame setup. */
992 base[0] = ix.mobj; copyTV(J->L, basev+0, &ix.mobjv); 997 base[0] = ix.mobj; copyTV(J->L, basev+0, &ix.mobjv);
993 base[1] = tr; copyTV(J->L, basev+1, tv); 998 base[1] = tr; copyTV(J->L, basev+1, tv);
994#if LJ_52 999#if LJ_52
@@ -1011,6 +1016,7 @@ static void rec_mm_callcomp(jit_State *J, RecordIndex *ix, int op)
1011 BCReg func = rec_mm_prep(J, (op&1) ? lj_cont_condf : lj_cont_condt); 1016 BCReg func = rec_mm_prep(J, (op&1) ? lj_cont_condf : lj_cont_condt);
1012 TRef *base = J->base + func; 1017 TRef *base = J->base + func;
1013 TValue *tv = J->L->base + func; 1018 TValue *tv = J->L->base + func;
1019 lua_assert(!LJ_FR2); /* TODO_FR2: handle different frame setup. */
1014 base[0] = ix->mobj; base[1] = ix->val; base[2] = ix->key; 1020 base[0] = ix->mobj; base[1] = ix->val; base[2] = ix->key;
1015 copyTV(J->L, tv+0, &ix->mobjv); 1021 copyTV(J->L, tv+0, &ix->mobjv);
1016 copyTV(J->L, tv+1, &ix->valv); 1022 copyTV(J->L, tv+1, &ix->valv);
@@ -1261,6 +1267,7 @@ TRef lj_record_idx(jit_State *J, RecordIndex *ix)
1261 BCReg func = rec_mm_prep(J, ix->val ? lj_cont_nop : lj_cont_ra); 1267 BCReg func = rec_mm_prep(J, ix->val ? lj_cont_nop : lj_cont_ra);
1262 TRef *base = J->base + func; 1268 TRef *base = J->base + func;
1263 TValue *tv = J->L->base + func; 1269 TValue *tv = J->L->base + func;
1270 lua_assert(!LJ_FR2); /* TODO_FR2: handle different frame setup. */
1264 base[0] = ix->mobj; base[1] = ix->tab; base[2] = ix->key; 1271 base[0] = ix->mobj; base[1] = ix->tab; base[2] = ix->key;
1265 setfuncV(J->L, tv+0, funcV(&ix->mobjv)); 1272 setfuncV(J->L, tv+0, funcV(&ix->mobjv));
1266 copyTV(J->L, tv+1, &ix->tabv); 1273 copyTV(J->L, tv+1, &ix->tabv);
@@ -2135,28 +2142,28 @@ void lj_record_ins(jit_State *J)
2135 /* -- Calls and vararg handling ----------------------------------------- */ 2142 /* -- Calls and vararg handling ----------------------------------------- */
2136 2143
2137 case BC_ITERC: 2144 case BC_ITERC:
2138 J->base[ra] = getslot(J, ra-3); 2145 J->base[ra] = getslot(J, ra-3-LJ_FR2);
2139 J->base[ra+1] = getslot(J, ra-2); 2146 J->base[ra+1] = getslot(J, ra-2-LJ_FR2);
2140 J->base[ra+2] = getslot(J, ra-1); 2147 J->base[ra+2] = getslot(J, ra-1-LJ_FR2);
2141 { /* Do the actual copy now because lj_record_call needs the values. */ 2148 { /* Do the actual copy now because lj_record_call needs the values. */
2142 TValue *b = &J->L->base[ra]; 2149 TValue *b = &J->L->base[ra];
2143 copyTV(J->L, b, b-3); 2150 copyTV(J->L, b, b-3-LJ_FR2);
2144 copyTV(J->L, b+1, b-2); 2151 copyTV(J->L, b+1, b-2-LJ_FR2);
2145 copyTV(J->L, b+2, b-1); 2152 copyTV(J->L, b+2, b-1-LJ_FR2);
2146 } 2153 }
2147 lj_record_call(J, ra, (ptrdiff_t)rc-1); 2154 lj_record_call(J, ra, (ptrdiff_t)rc-1);
2148 break; 2155 break;
2149 2156
2150 /* L->top is set to L->base+ra+rc+NARGS-1+1. See lj_dispatch_ins(). */ 2157 /* L->top is set to L->base+ra+rc+NARGS-1+1. See lj_dispatch_ins(). */
2151 case BC_CALLM: 2158 case BC_CALLM:
2152 rc = (BCReg)(J->L->top - J->L->base) - ra; 2159 rc = (BCReg)(J->L->top - J->L->base) - ra - LJ_FR2;
2153 /* fallthrough */ 2160 /* fallthrough */
2154 case BC_CALL: 2161 case BC_CALL:
2155 lj_record_call(J, ra, (ptrdiff_t)rc-1); 2162 lj_record_call(J, ra, (ptrdiff_t)rc-1);
2156 break; 2163 break;
2157 2164
2158 case BC_CALLMT: 2165 case BC_CALLMT:
2159 rc = (BCReg)(J->L->top - J->L->base) - ra; 2166 rc = (BCReg)(J->L->top - J->L->base) - ra - LJ_FR2;
2160 /* fallthrough */ 2167 /* fallthrough */
2161 case BC_CALLT: 2168 case BC_CALLT:
2162 lj_record_tailcall(J, ra, (ptrdiff_t)rc-1); 2169 lj_record_tailcall(J, ra, (ptrdiff_t)rc-1);