Low-overhead profiler, part 4: JIT compiler support.

This commit is contained in:
Mike Pall
2013-09-08 02:53:23 +02:00
parent d3d30d389b
commit d1194a82eb
12 changed files with 151 additions and 12 deletions

View File

@@ -14,6 +14,10 @@
#include "lj_frame.h"
#include "lj_debug.h"
#include "lj_dispatch.h"
#if LJ_HASJIT
#include "lj_jit.h"
#include "lj_trace.h"
#endif
#include "lj_profile.h"
#include "luajit.h"
@@ -218,13 +222,20 @@ LUA_API void luaJIT_profile_start(lua_State *L, const char *mode,
ProfileState *ps = &profile_state;
int interval = LJ_PROFILE_INTERVAL_DEFAULT;
while (*mode) {
switch (*mode++) {
int m = *mode++;
switch (m) {
case 'i':
interval = 0;
while (*mode >= '0' && *mode <= '9')
interval = interval * 10 + (*mode++ - '0');
if (interval <= 0) interval = 1;
break;
#if LJ_HASJIT
case 'l': case 'f':
L2J(L)->prof_mode = m;
lj_trace_flushall(L);
break;
#endif
default: /* Ignore unknown mode chars. */
break;
}
@@ -251,6 +262,10 @@ LUA_API void luaJIT_profile_stop(lua_State *L)
profile_timer_stop(ps);
g->hookmask &= ~HOOK_PROFILE;
lj_dispatch_update(g);
#if LJ_HASJIT
G2J(g)->prof_mode = 0;
lj_trace_flushall(L);
#endif
lj_buf_free(g, &ps->sb);
setmref(ps->sb.b, NULL);
setmref(ps->sb.e, NULL);