Save tmptv state for trace recorder across RECORD vmevent.

This commit is contained in:
Mike Pall 2011-10-14 00:43:17 +02:00
parent 882537a874
commit 4c9318792f
2 changed files with 19 additions and 2 deletions

View File

@ -574,11 +574,18 @@ static TValue *trace_state(lua_State *L, lua_CFunction dummy, void *ud)
case LJ_TRACE_RECORD: case LJ_TRACE_RECORD:
trace_pendpatch(J, 0); trace_pendpatch(J, 0);
setvmstate(J2G(J), RECORD); setvmstate(J2G(J), RECORD);
lj_vmevent_send(L, RECORD, lj_vmevent_send_(L, RECORD,
TValue savetv; /* Save tmptv state for trace recorder. */
TValue savetv2;
copyTV(L, &savetv, &J2G(J)->tmptv);
copyTV(L, &savetv2, &J2G(J)->tmptv2);
setintV(L->top++, J->cur.traceno); setintV(L->top++, J->cur.traceno);
setfuncV(L, L->top++, J->fn); setfuncV(L, L->top++, J->fn);
setintV(L->top++, J->pt ? (int32_t)proto_bcpos(J->pt, J->pc) : -1); setintV(L->top++, J->pt ? (int32_t)proto_bcpos(J->pt, J->pc) : -1);
setintV(L->top++, J->framedepth); setintV(L->top++, J->framedepth);
,
copyTV(L, &J2G(J)->tmptv, &savetv);
copyTV(L, &J2G(J)->tmptv2, &savetv2);
); );
lj_record_ins(J); lj_record_ins(J);
break; break;

View File

@ -31,7 +31,8 @@ typedef enum {
} VMEvent; } VMEvent;
#ifdef LUAJIT_DISABLE_VMEVENT #ifdef LUAJIT_DISABLE_VMEVENT
#define lj_vmevent_send(L, ev, args) UNUSED(L) #define lj_vmevent_send(L, ev, args) UNUSED(L)
#define lj_vmevent_send_(L, ev, args, post) UNUSED(L)
#else #else
#define lj_vmevent_send(L, ev, args) \ #define lj_vmevent_send(L, ev, args) \
if (G(L)->vmevmask & VMEVENT_MASK(LJ_VMEVENT_##ev)) { \ if (G(L)->vmevmask & VMEVENT_MASK(LJ_VMEVENT_##ev)) { \
@ -41,6 +42,15 @@ typedef enum {
lj_vmevent_call(L, argbase); \ lj_vmevent_call(L, argbase); \
} \ } \
} }
#define lj_vmevent_send_(L, ev, args, post) \
if (G(L)->vmevmask & VMEVENT_MASK(LJ_VMEVENT_##ev)) { \
ptrdiff_t argbase = lj_vmevent_prepare(L, LJ_VMEVENT_##ev); \
if (argbase) { \
args \
lj_vmevent_call(L, argbase); \
post \
} \
}
LJ_FUNC ptrdiff_t lj_vmevent_prepare(lua_State *L, VMEvent ev); LJ_FUNC ptrdiff_t lj_vmevent_prepare(lua_State *L, VMEvent ev);
LJ_FUNC void lj_vmevent_call(lua_State *L, ptrdiff_t argbase); LJ_FUNC void lj_vmevent_call(lua_State *L, ptrdiff_t argbase);