mirror of
https://github.com/LuaJIT/LuaJIT.git
synced 2025-02-12 09:24:07 +00:00
Fix profiler/hook interaction.
This commit is contained in:
parent
a51b8bf6b4
commit
eec06a0e3b
@ -362,11 +362,19 @@ static void callhook(lua_State *L, int event, BCLine line)
|
||||
/* Top frame, nextframe = NULL. */
|
||||
ar.i_ci = (int)((L->base-1) - tvref(L->stack));
|
||||
lj_state_checkstack(L, 1+LUA_MINSTACK);
|
||||
#if LJ_HASPROFILE && !LJ_PROFILE_SIGPROF
|
||||
lj_profile_hook_enter(g);
|
||||
#else
|
||||
hook_enter(g);
|
||||
#endif
|
||||
hookf(L, &ar);
|
||||
lua_assert(hook_active(g));
|
||||
setgcref(g->cur_L, obj2gco(L));
|
||||
#if LJ_HASPROFILE && !LJ_PROFILE_SIGPROF
|
||||
lj_profile_hook_leave(g);
|
||||
#else
|
||||
hook_leave(g);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -87,6 +87,34 @@ static ProfileState profile_state;
|
||||
/* Default sample interval in milliseconds. */
|
||||
#define LJ_PROFILE_INTERVAL_DEFAULT 10
|
||||
|
||||
/* -- Profiler/hook interaction ------------------------------------------- */
|
||||
|
||||
#if !LJ_PROFILE_SIGPROF
|
||||
void LJ_FASTCALL lj_profile_hook_enter(global_State *g)
|
||||
{
|
||||
ProfileState *ps = &profile_state;
|
||||
if (ps->g) {
|
||||
profile_lock(ps);
|
||||
hook_enter(g);
|
||||
profile_unlock(ps);
|
||||
} else {
|
||||
hook_enter(g);
|
||||
}
|
||||
}
|
||||
|
||||
void LJ_FASTCALL lj_profile_hook_leave(global_State *g)
|
||||
{
|
||||
ProfileState *ps = &profile_state;
|
||||
if (ps->g) {
|
||||
profile_lock(ps);
|
||||
hook_leave(g);
|
||||
profile_unlock(ps);
|
||||
} else {
|
||||
hook_leave(g);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* -- Profile callbacks --------------------------------------------------- */
|
||||
|
||||
/* Callback from profile hook (HOOK_PROFILE already cleared). */
|
||||
|
@ -11,6 +11,10 @@
|
||||
#if LJ_HASPROFILE
|
||||
|
||||
LJ_FUNC void LJ_FASTCALL lj_profile_interpreter(lua_State *L);
|
||||
#if !LJ_PROFILE_SIGPROF
|
||||
LJ_FUNC void LJ_FASTCALL lj_profile_hook_enter(global_State *g);
|
||||
LJ_FUNC void LJ_FASTCALL lj_profile_hook_leave(global_State *g);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user