Optionally return PC position in jit.util.tracesnap().
Suggested by Sergey Bronnikov. #1472
This commit is contained in:
parent
0bf26146d6
commit
8e6520a7ae
@ -340,11 +340,12 @@ LJLIB_CF(jit_util_tracek)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* local snap = jit.util.tracesnap(tr, sn) */
|
/* local snap = jit.util.tracesnap(tr, sn[, getpos]) */
|
||||||
LJLIB_CF(jit_util_tracesnap)
|
LJLIB_CF(jit_util_tracesnap)
|
||||||
{
|
{
|
||||||
GCtrace *T = jit_checktrace(L);
|
GCtrace *T = jit_checktrace(L);
|
||||||
SnapNo sn = (SnapNo)lj_lib_checkint(L, 2);
|
SnapNo sn = (SnapNo)lj_lib_checkint(L, 2);
|
||||||
|
int getpos = (L->base+2 < L->top && tvistruecond(L->base+2));
|
||||||
if (T && sn < T->nsnap) {
|
if (T && sn < T->nsnap) {
|
||||||
SnapShot *snap = &T->snap[sn];
|
SnapShot *snap = &T->snap[sn];
|
||||||
SnapEntry *map = &T->snapmap[snap->mapofs];
|
SnapEntry *map = &T->snapmap[snap->mapofs];
|
||||||
@ -357,6 +358,12 @@ LJLIB_CF(jit_util_tracesnap)
|
|||||||
for (n = 0; n < nent; n++)
|
for (n = 0; n < nent; n++)
|
||||||
setintV(lj_tab_setint(L, t, (int32_t)(n+2)), (int32_t)map[n]);
|
setintV(lj_tab_setint(L, t, (int32_t)(n+2)), (int32_t)map[n]);
|
||||||
setintV(lj_tab_setint(L, t, (int32_t)(nent+2)), (int32_t)SNAP(255, 0, 0));
|
setintV(lj_tab_setint(L, t, (int32_t)(nent+2)), (int32_t)SNAP(255, 0, 0));
|
||||||
|
if (getpos) {
|
||||||
|
const BCIns *pc = snap_pc(&map[nent]), *startpc = pc;
|
||||||
|
while (bc_op(*startpc) < BC_FUNCF) startpc--;
|
||||||
|
setintV(L->top++, (int)(pc - startpc));
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user