diff --git a/src/lj_trace.c b/src/lj_trace.c index afaeb300..5de43f23 100644 --- a/src/lj_trace.c +++ b/src/lj_trace.c @@ -574,11 +574,18 @@ static TValue *trace_state(lua_State *L, lua_CFunction dummy, void *ud) case LJ_TRACE_RECORD: trace_pendpatch(J, 0); 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); setfuncV(L, L->top++, J->fn); setintV(L->top++, J->pt ? (int32_t)proto_bcpos(J->pt, J->pc) : -1); setintV(L->top++, J->framedepth); + , + copyTV(L, &J2G(J)->tmptv, &savetv); + copyTV(L, &J2G(J)->tmptv2, &savetv2); ); lj_record_ins(J); break; diff --git a/src/lj_vmevent.h b/src/lj_vmevent.h index 857e5be5..8a0822f2 100644 --- a/src/lj_vmevent.h +++ b/src/lj_vmevent.h @@ -31,7 +31,8 @@ typedef enum { } 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 #define lj_vmevent_send(L, ev, args) \ if (G(L)->vmevmask & VMEVENT_MASK(LJ_VMEVENT_##ev)) { \ @@ -41,6 +42,15 @@ typedef enum { 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 void lj_vmevent_call(lua_State *L, ptrdiff_t argbase);