diff options
Diffstat (limited to '')
-rw-r--r-- | src/jit/dump.lua | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/src/jit/dump.lua b/src/jit/dump.lua index 7441b74d..4b79ad6a 100644 --- a/src/jit/dump.lua +++ b/src/jit/dump.lua | |||
@@ -54,7 +54,7 @@ | |||
54 | 54 | ||
55 | -- Cache some library functions and objects. | 55 | -- Cache some library functions and objects. |
56 | local jit = require("jit") | 56 | local jit = require("jit") |
57 | assert(jit.version_num == 20002, "LuaJIT core/library version mismatch") | 57 | assert(jit.version_num == 20100, "LuaJIT core/library version mismatch") |
58 | local jutil = require("jit.util") | 58 | local jutil = require("jit.util") |
59 | local vmdef = require("jit.vmdef") | 59 | local vmdef = require("jit.vmdef") |
60 | local funcinfo, funcbc = jutil.funcinfo, jutil.funcbc | 60 | local funcinfo, funcbc = jutil.funcinfo, jutil.funcbc |
@@ -62,7 +62,7 @@ local traceinfo, traceir, tracek = jutil.traceinfo, jutil.traceir, jutil.tracek | |||
62 | local tracemc, tracesnap = jutil.tracemc, jutil.tracesnap | 62 | local tracemc, tracesnap = jutil.tracemc, jutil.tracesnap |
63 | local traceexitstub, ircalladdr = jutil.traceexitstub, jutil.ircalladdr | 63 | local traceexitstub, ircalladdr = jutil.traceexitstub, jutil.ircalladdr |
64 | local bit = require("bit") | 64 | local bit = require("bit") |
65 | local band, shl, shr = bit.band, bit.lshift, bit.rshift | 65 | local band, shl, shr, tohex = bit.band, bit.lshift, bit.rshift, bit.tohex |
66 | local sub, gsub, format = string.sub, string.gsub, string.format | 66 | local sub, gsub, format = string.sub, string.gsub, string.format |
67 | local byte, char, rep = string.byte, string.char, string.rep | 67 | local byte, char, rep = string.byte, string.char, string.rep |
68 | local type, tostring = type, tostring | 68 | local type, tostring = type, tostring |
@@ -90,6 +90,7 @@ local function fillsymtab_tr(tr, nexit) | |||
90 | end | 90 | end |
91 | for i=0,nexit-1 do | 91 | for i=0,nexit-1 do |
92 | local addr = traceexitstub(tr, i) | 92 | local addr = traceexitstub(tr, i) |
93 | if addr < 0 then addr = addr + 2^32 end | ||
93 | t[addr] = tostring(i) | 94 | t[addr] = tostring(i) |
94 | end | 95 | end |
95 | local addr = traceexitstub(tr, nexit) | 96 | local addr = traceexitstub(tr, nexit) |
@@ -103,7 +104,10 @@ local function fillsymtab(tr, nexit) | |||
103 | local ircall = vmdef.ircall | 104 | local ircall = vmdef.ircall |
104 | for i=0,#ircall do | 105 | for i=0,#ircall do |
105 | local addr = ircalladdr(i) | 106 | local addr = ircalladdr(i) |
106 | if addr ~= 0 then t[addr] = ircall[i] end | 107 | if addr ~= 0 then |
108 | if addr < 0 then addr = addr + 2^32 end | ||
109 | t[addr] = ircall[i] | ||
110 | end | ||
107 | end | 111 | end |
108 | end | 112 | end |
109 | if nexitsym == 1000000 then -- Per-trace exit stubs. | 113 | if nexitsym == 1000000 then -- Per-trace exit stubs. |
@@ -117,6 +121,7 @@ local function fillsymtab(tr, nexit) | |||
117 | nexit = 1000000 | 121 | nexit = 1000000 |
118 | break | 122 | break |
119 | end | 123 | end |
124 | if addr < 0 then addr = addr + 2^32 end | ||
120 | t[addr] = tostring(i) | 125 | t[addr] = tostring(i) |
121 | end | 126 | end |
122 | nexitsym = nexit | 127 | nexitsym = nexit |
@@ -135,6 +140,7 @@ local function dump_mcode(tr) | |||
135 | local mcode, addr, loop = tracemc(tr) | 140 | local mcode, addr, loop = tracemc(tr) |
136 | if not mcode then return end | 141 | if not mcode then return end |
137 | if not disass then disass = require("jit.dis_"..jit.arch) end | 142 | if not disass then disass = require("jit.dis_"..jit.arch) end |
143 | if addr < 0 then addr = addr + 2^32 end | ||
138 | out:write("---- TRACE ", tr, " mcode ", #mcode, "\n") | 144 | out:write("---- TRACE ", tr, " mcode ", #mcode, "\n") |
139 | local ctx = disass.create(mcode, addr, dumpwrite) | 145 | local ctx = disass.create(mcode, addr, dumpwrite) |
140 | ctx.hexdump = 0 | 146 | ctx.hexdump = 0 |
@@ -269,8 +275,7 @@ local litname = { | |||
269 | ["CONV "] = setmetatable({}, { __index = function(t, mode) | 275 | ["CONV "] = setmetatable({}, { __index = function(t, mode) |
270 | local s = irtype[band(mode, 31)] | 276 | local s = irtype[band(mode, 31)] |
271 | s = irtype[band(shr(mode, 5), 31)].."."..s | 277 | s = irtype[band(shr(mode, 5), 31)].."."..s |
272 | if band(mode, 0x400) ~= 0 then s = s.." trunc" | 278 | if band(mode, 0x800) ~= 0 then s = s.." sext" end |
273 | elseif band(mode, 0x800) ~= 0 then s = s.." sext" end | ||
274 | local c = shr(mode, 14) | 279 | local c = shr(mode, 14) |
275 | if c == 2 then s = s.." index" elseif c == 3 then s = s.." check" end | 280 | if c == 2 then s = s.." index" elseif c == 3 then s = s.." check" end |
276 | t[mode] = s | 281 | t[mode] = s |
@@ -279,6 +284,8 @@ local litname = { | |||
279 | ["FLOAD "] = vmdef.irfield, | 284 | ["FLOAD "] = vmdef.irfield, |
280 | ["FREF "] = vmdef.irfield, | 285 | ["FREF "] = vmdef.irfield, |
281 | ["FPMATH"] = vmdef.irfpm, | 286 | ["FPMATH"] = vmdef.irfpm, |
287 | ["BUFHDR"] = { [0] = "RESET", "APPEND" }, | ||
288 | ["TOSTR "] = { [0] = "INT", "NUM", "CHAR" }, | ||
282 | } | 289 | } |
283 | 290 | ||
284 | local function ctlsub(c) | 291 | local function ctlsub(c) |
@@ -608,7 +615,7 @@ local function dump_texit(tr, ex, ngpr, nfpr, ...) | |||
608 | end | 615 | end |
609 | else | 616 | else |
610 | for i=1,ngpr do | 617 | for i=1,ngpr do |
611 | out:write(format(" %08x", regs[i])) | 618 | out:write(" ", tohex(regs[i])) |
612 | if i % 8 == 0 then out:write("\n") end | 619 | if i % 8 == 0 then out:write("\n") end |
613 | end | 620 | end |
614 | end | 621 | end |
@@ -692,9 +699,9 @@ local function dumpon(opt, outfile) | |||
692 | end | 699 | end |
693 | 700 | ||
694 | -- Public module functions. | 701 | -- Public module functions. |
695 | module(...) | 702 | return { |
696 | 703 | on = dumpon, | |
697 | on = dumpon | 704 | off = dumpoff, |
698 | off = dumpoff | 705 | start = dumpon -- For -j command line option. |
699 | start = dumpon -- For -j command line option. | 706 | } |
700 | 707 | ||