summaryrefslogtreecommitdiff
path: root/src/lj_record.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lj_record.c')
-rw-r--r--src/lj_record.c39
1 files changed, 4 insertions, 35 deletions
diff --git a/src/lj_record.c b/src/lj_record.c
index eaaafc51..e5a8b208 100644
--- a/src/lj_record.c
+++ b/src/lj_record.c
@@ -92,26 +92,6 @@ static void rec_check_ir(jit_State *J)
92 } 92 }
93} 93}
94 94
95/* Compare frame stack of the recorder and the VM. */
96static void rec_check_frames(jit_State *J)
97{
98 cTValue *frame = J->L->base - 1;
99 cTValue *lim = J->L->base - J->baseslot;
100 int32_t depth = J->framedepth;
101 while (frame > lim) {
102 depth--;
103 lua_assert(depth >= 0);
104 lua_assert((SnapEntry)frame_ftsz(frame) == J->frame[depth]);
105 if (frame_iscont(frame)) {
106 depth--;
107 lua_assert(depth >= 0);
108 lua_assert((SnapEntry)frame_ftsz(frame-1) == J->frame[depth]);
109 }
110 frame = frame_prev(frame);
111 }
112 lua_assert(depth == 0);
113}
114
115/* Compare stack slots and frames of the recorder and the VM. */ 95/* Compare stack slots and frames of the recorder and the VM. */
116static void rec_check_slots(jit_State *J) 96static void rec_check_slots(jit_State *J)
117{ 97{
@@ -157,7 +137,6 @@ static void rec_check_slots(jit_State *J)
157 } 137 }
158 } 138 }
159 lua_assert(J->framedepth == depth); 139 lua_assert(J->framedepth == depth);
160 rec_check_frames(J);
161} 140}
162#endif 141#endif
163 142
@@ -519,9 +498,7 @@ static void rec_call(jit_State *J, BCReg func, ptrdiff_t nargs)
519 fbase[0] = trfunc | TREF_FRAME; 498 fbase[0] = trfunc | TREF_FRAME;
520 499
521 /* Bump frame. */ 500 /* Bump frame. */
522 J->frame[J->framedepth++] = SNAP_MKPC(J->pc+1); 501 J->framedepth++;
523 if (J->framedepth > LJ_MAX_JFRAME)
524 lj_trace_err(J, LJ_TRERR_STACKOV);
525 J->base += func+1; 502 J->base += func+1;
526 J->baseslot += func+1; 503 J->baseslot += func+1;
527 J->maxslot = nargs; 504 J->maxslot = nargs;
@@ -626,6 +603,7 @@ static BCReg rec_mm_prep(jit_State *J, ASMFunction cont)
626 trcont = lj_ir_kptr(J, (void *)cont); 603 trcont = lj_ir_kptr(J, (void *)cont);
627#endif 604#endif
628 J->base[top] = trcont | TREF_CONT; 605 J->base[top] = trcont | TREF_CONT;
606 J->framedepth++;
629 for (s = J->maxslot; s < top; s++) 607 for (s = J->maxslot; s < top; s++)
630 J->base[s] = 0; /* Clear frame gap to avoid resurrecting previous refs. */ 608 J->base[s] = 0; /* Clear frame gap to avoid resurrecting previous refs. */
631 return top+1; 609 return top+1;
@@ -695,7 +673,6 @@ ok:
695 base[0] = ix->mobj; 673 base[0] = ix->mobj;
696 copyTV(J->L, basev+0, &ix->mobjv); 674 copyTV(J->L, basev+0, &ix->mobjv);
697 rec_call(J, func, 2); 675 rec_call(J, func, 2);
698 J->frame[J->framedepth++] = SNAP_MKFTSZ((func+1)*sizeof(TValue)+FRAME_CONT);
699 return 0; /* No result yet. */ 676 return 0; /* No result yet. */
700} 677}
701 678
@@ -710,7 +687,6 @@ static void rec_mm_callcomp(jit_State *J, RecordIndex *ix, int op)
710 copyTV(J->L, tv+1, &ix->valv); 687 copyTV(J->L, tv+1, &ix->valv);
711 copyTV(J->L, tv+2, &ix->keyv); 688 copyTV(J->L, tv+2, &ix->keyv);
712 rec_call(J, func, 2); 689 rec_call(J, func, 2);
713 J->frame[J->framedepth++] = SNAP_MKFTSZ((func+1)*sizeof(TValue)+FRAME_CONT);
714} 690}
715 691
716/* Record call to equality comparison metamethod (for tab and udata only). */ 692/* Record call to equality comparison metamethod (for tab and udata only). */
@@ -890,11 +866,9 @@ static TRef rec_idx(jit_State *J, RecordIndex *ix)
890 base[3] = ix->val; 866 base[3] = ix->val;
891 copyTV(J->L, tv+3, &ix->valv); 867 copyTV(J->L, tv+3, &ix->valv);
892 rec_call(J, func, 3); /* mobj(tab, key, val) */ 868 rec_call(J, func, 3); /* mobj(tab, key, val) */
893 J->frame[J->framedepth++] = SNAP_MKFTSZ((func+1)*sizeof(TValue)+FRAME_CONT);
894 return 0; 869 return 0;
895 } else { 870 } else {
896 rec_call(J, func, 2); /* res = mobj(tab, key) */ 871 rec_call(J, func, 2); /* res = mobj(tab, key) */
897 J->frame[J->framedepth++] = SNAP_MKFTSZ((func+1)*sizeof(TValue)+FRAME_CONT);
898 return 0; /* No result yet. */ 872 return 0; /* No result yet. */
899 } 873 }
900 } 874 }
@@ -1294,8 +1268,6 @@ static void LJ_FASTCALL recff_ipairs(jit_State *J, RecordFFData *rd)
1294static void LJ_FASTCALL recff_pcall(jit_State *J, RecordFFData *rd) 1268static void LJ_FASTCALL recff_pcall(jit_State *J, RecordFFData *rd)
1295{ 1269{
1296 if (J->maxslot >= 1) { 1270 if (J->maxslot >= 1) {
1297 J->pc = (const BCIns *)(sizeof(TValue) - 4 +
1298 (hook_active(J2G(J)) ? FRAME_PCALLH : FRAME_PCALL));
1299 rec_call(J, 0, J->maxslot - 1); 1271 rec_call(J, 0, J->maxslot - 1);
1300 rd->nres = -1; /* Pending call. */ 1272 rd->nres = -1; /* Pending call. */
1301 } /* else: Interpreter will throw. */ 1273 } /* else: Interpreter will throw. */
@@ -1321,8 +1293,6 @@ static void LJ_FASTCALL recff_xpcall(jit_State *J, RecordFFData *rd)
1321 copyTV(J->L, &argv1, &rd->argv[1]); 1293 copyTV(J->L, &argv1, &rd->argv[1]);
1322 copyTV(J->L, &rd->argv[0], &argv1); 1294 copyTV(J->L, &rd->argv[0], &argv1);
1323 copyTV(J->L, &rd->argv[1], &argv0); 1295 copyTV(J->L, &rd->argv[1], &argv0);
1324 J->pc = (const BCIns *)(2*sizeof(TValue) - 4 +
1325 (hook_active(J2G(J)) ? FRAME_PCALLH : FRAME_PCALL));
1326 /* Need to protect rec_call because it may throw. */ 1296 /* Need to protect rec_call because it may throw. */
1327 errcode = lj_vm_cpcall(J->L, NULL, J, recff_xpcall_cp); 1297 errcode = lj_vm_cpcall(J->L, NULL, J, recff_xpcall_cp);
1328 /* Always undo Lua stack swap to avoid confusing the interpreter. */ 1298 /* Always undo Lua stack swap to avoid confusing the interpreter. */
@@ -2329,13 +2299,12 @@ static void rec_setup_side(jit_State *J, Trace *T)
2329 } 2299 }
2330 setslot: 2300 setslot:
2331 J->slot[s] = tr | (sn&(SNAP_CONT|SNAP_FRAME)); /* Same as TREF_* flags. */ 2301 J->slot[s] = tr | (sn&(SNAP_CONT|SNAP_FRAME)); /* Same as TREF_* flags. */
2332 if ((sn & SNAP_FRAME) && s != 0) 2302 if ((sn & SNAP_FRAME))
2333 J->baseslot = s+1; 2303 J->baseslot = s+1;
2334 } 2304 }
2335 J->base = J->slot + J->baseslot; 2305 J->base = J->slot + J->baseslot;
2336 J->maxslot = snap->nslots - J->baseslot; 2306 J->maxslot = snap->nslots - J->baseslot;
2337 J->framedepth = snap->depth; /* Copy frames from snapshot. */ 2307 J->framedepth = snap->depth;
2338 memcpy(J->frame, &map[nent+1], sizeof(SnapEntry)*(size_t)snap->depth);
2339 lj_snap_add(J); 2308 lj_snap_add(J);
2340} 2309}
2341 2310