mirror of
https://github.com/LuaJIT/LuaJIT.git
synced 2025-02-07 23:24:09 +00:00
Fix interaction between profiler hooks and finalizers.
Thanks to Julien Desgats.
This commit is contained in:
parent
9600e4318e
commit
92fa45f9eb
@ -466,6 +466,7 @@ static void gc_call_finalizer(global_State *g, lua_State *L,
|
||||
TValue *top;
|
||||
lj_trace_abort(g);
|
||||
hook_entergc(g); /* Disable hooks and new traces during __gc. */
|
||||
if (LJ_HASPROFILE && (oldh & HOOK_PROFILE)) lj_dispatch_update(g);
|
||||
g->gc.threshold = LJ_MAX_MEM; /* Prevent GC steps. */
|
||||
top = L->top;
|
||||
copyTV(L, top++, mo);
|
||||
@ -474,6 +475,7 @@ static void gc_call_finalizer(global_State *g, lua_State *L,
|
||||
L->top = top+1;
|
||||
errcode = lj_vm_pcall(L, top, 1+0, -1); /* Stack: |mo|o| -> | */
|
||||
hook_restore(g, oldh);
|
||||
if (LJ_HASPROFILE && (oldh & HOOK_PROFILE)) lj_dispatch_update(g);
|
||||
g->gc.threshold = oldt; /* Restore GC threshold. */
|
||||
if (errcode)
|
||||
lj_err_throw(L, errcode); /* Propagate errors. */
|
||||
|
@ -638,7 +638,8 @@ typedef struct global_State {
|
||||
#define HOOK_PROFILE 0x80
|
||||
#define hook_active(g) ((g)->hookmask & HOOK_ACTIVE)
|
||||
#define hook_enter(g) ((g)->hookmask |= HOOK_ACTIVE)
|
||||
#define hook_entergc(g) ((g)->hookmask |= (HOOK_ACTIVE|HOOK_GC))
|
||||
#define hook_entergc(g) \
|
||||
((g)->hookmask = ((g)->hookmask | (HOOK_ACTIVE|HOOK_GC)) & ~HOOK_PROFILE)
|
||||
#define hook_vmevent(g) ((g)->hookmask |= (HOOK_ACTIVE|HOOK_VMEVENT))
|
||||
#define hook_leave(g) ((g)->hookmask &= ~HOOK_ACTIVE)
|
||||
#define hook_save(g) ((g)->hookmask & ~HOOK_EVENTMASK)
|
||||
|
@ -153,7 +153,7 @@ static void profile_trigger(ProfileState *ps)
|
||||
profile_lock(ps);
|
||||
ps->samples++; /* Always increment number of samples. */
|
||||
mask = g->hookmask;
|
||||
if (!(mask & (HOOK_PROFILE|HOOK_VMEVENT))) { /* Set profile hook. */
|
||||
if (!(mask & (HOOK_PROFILE|HOOK_VMEVENT|HOOK_GC))) { /* Set profile hook. */
|
||||
int st = g->vmstate;
|
||||
ps->vmstate = st >= 0 ? 'N' :
|
||||
st == ~LJ_VMST_INTERP ? 'I' :
|
||||
|
Loading…
Reference in New Issue
Block a user