From 29078518c14a4f49224fc58c57053bda2e8284dc Mon Sep 17 00:00:00 2001 From: Mike Pall Date: Tue, 10 Sep 2013 00:02:20 +0200 Subject: [PATCH] Add -jp=fl mode and minor fixes. --- src/jit/p.lua | 17 ++++++++++++----- src/jit/zone.lua | 6 +++++- src/lib_jit.c | 4 ++-- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/jit/p.lua b/src/jit/p.lua index f3bec9f0..1fbf389a 100644 --- a/src/jit/p.lua +++ b/src/jit/p.lua @@ -21,7 +21,7 @@ -- -- The following dump features are available: -- --- f Stack dump: function name, Otherwise module:line. Default mode +-- f Stack dump: function name, otherwise module:line. Default mode. -- F Stack dump: ditto, but always prepend module. -- l Stack dump: module:line. -- stack dump depth (callee < caller). Default: 1. @@ -33,7 +33,7 @@ -- r Show raw sample counts. Default: show percentages. -- a Annotate excerpts from source code files. -- A Annotate complete source code files. --- G Produce output suitable for graphical tools (e.g. flame graphs). +-- G Produce raw output suitable for graphical tools (e.g. flame graphs). -- m Minimum sample percentage to be shown. Default: 3. -- i Sampling interval in milliseconds. Default: 10. -- @@ -87,6 +87,8 @@ local function prof_cb(th, samples, vmmode) if prof_split == 2 then local k1, k2 = key_stack:match("(.-) [<>] (.*)") if k2 then key_stack, key_stack2 = k1, k2 end + elseif prof_split == 3 then + key_stack2 = profile.dumpstack(th, "l", 1) end end -- Order keys. @@ -138,7 +140,8 @@ local function prof_top(count1, count2, samples, indent) if count2 then local r = count2[k] if r then - prof_top(r, nil, v, prof_depth < 0 and " -> " or " <- ") + prof_top(r, nil, v, (prof_split == 3 or prof_split == 1) and " -- " or + (prof_depth < 0 and " -> " or " <- ")) end end end @@ -221,7 +224,7 @@ local function prof_finish() profile.stop() local samples = prof_samples if samples == 0 then - if prof_raw ~= true then out:write("[no samples collected]\n") end + if prof_raw ~= true then out:write("[No samples collected]\n") end return end if prof_ann then @@ -254,6 +257,9 @@ local function prof_start(mode) prof_split = 2 if prof_depth == -1 or m["-"] then prof_depth = -2 elseif prof_depth == 1 then prof_depth = 2 end + elseif mode:find("[fF].*l") then + scope = "l" + prof_split = 3 else prof_split = (scope == "" or mode:find("[zv].*[lfF]")) and 1 or 0 end @@ -271,7 +277,8 @@ local function prof_start(mode) elseif scope == "" then prof_fmt = false else - prof_fmt = flags..scope..(prof_depth >= 0 and "Z < " or "Z > ") + local sc = prof_split == 3 and m.f or m.F or scope + prof_fmt = flags..sc..(prof_depth >= 0 and "Z < " or "Z > ") end prof_count1 = {} prof_count2 = {} diff --git a/src/jit/zone.lua b/src/jit/zone.lua index da2eccb0..7201d014 100644 --- a/src/jit/zone.lua +++ b/src/jit/zone.lua @@ -35,7 +35,11 @@ return setmetatable({ end }, { __call = function(t, zone) - if zone then t[#t+1] = zone else return assert(remove(t)) end + if zone then + t[#t+1] = zone + else + return (assert(remove(t), "empty zone stack")) + end end }) diff --git a/src/lib_jit.c b/src/lib_jit.c index 9e4fd3a8..e8acb55a 100644 --- a/src/lib_jit.c +++ b/src/lib_jit.c @@ -563,7 +563,7 @@ static void jit_profile_callback(lua_State *L2, lua_State *L, int samples, } } -/* profile.start(mode, func) */ +/* profile.start(mode, cb) */ LJLIB_CF(jit_profile_start) { GCtab *registry = tabV(registry(L)); @@ -597,7 +597,7 @@ LJLIB_CF(jit_profile_stop) return 0; } -/* profile.dumpstack([thread,] fmt, depth) */ +/* dump = profile.dumpstack([thread,] fmt, depth) */ LJLIB_CF(jit_profile_dumpstack) { lua_State *L2 = L;