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 ec5f8276..9a722f73 100644 --- a/src/jit/dump.lua +++ b/src/jit/dump.lua | |||
@@ -55,7 +55,7 @@ | |||
55 | 55 | ||
56 | -- Cache some library functions and objects. | 56 | -- Cache some library functions and objects. |
57 | local jit = require("jit") | 57 | local jit = require("jit") |
58 | assert(jit.version_num == 20004, "LuaJIT core/library version mismatch") | 58 | assert(jit.version_num == 20100, "LuaJIT core/library version mismatch") |
59 | local jutil = require("jit.util") | 59 | local jutil = require("jit.util") |
60 | local vmdef = require("jit.vmdef") | 60 | local vmdef = require("jit.vmdef") |
61 | local funcinfo, funcbc = jutil.funcinfo, jutil.funcbc | 61 | local funcinfo, funcbc = jutil.funcinfo, jutil.funcbc |
@@ -63,7 +63,7 @@ local traceinfo, traceir, tracek = jutil.traceinfo, jutil.traceir, jutil.tracek | |||
63 | local tracemc, tracesnap = jutil.tracemc, jutil.tracesnap | 63 | local tracemc, tracesnap = jutil.tracemc, jutil.tracesnap |
64 | local traceexitstub, ircalladdr = jutil.traceexitstub, jutil.ircalladdr | 64 | local traceexitstub, ircalladdr = jutil.traceexitstub, jutil.ircalladdr |
65 | local bit = require("bit") | 65 | local bit = require("bit") |
66 | local band, shl, shr = bit.band, bit.lshift, bit.rshift | 66 | local band, shl, shr, tohex = bit.band, bit.lshift, bit.rshift, bit.tohex |
67 | local sub, gsub, format = string.sub, string.gsub, string.format | 67 | local sub, gsub, format = string.sub, string.gsub, string.format |
68 | local byte, char, rep = string.byte, string.char, string.rep | 68 | local byte, char, rep = string.byte, string.char, string.rep |
69 | local type, tostring = type, tostring | 69 | local type, tostring = type, tostring |
@@ -91,6 +91,7 @@ local function fillsymtab_tr(tr, nexit) | |||
91 | end | 91 | end |
92 | for i=0,nexit-1 do | 92 | for i=0,nexit-1 do |
93 | local addr = traceexitstub(tr, i) | 93 | local addr = traceexitstub(tr, i) |
94 | if addr < 0 then addr = addr + 2^32 end | ||
94 | t[addr] = tostring(i) | 95 | t[addr] = tostring(i) |
95 | end | 96 | end |
96 | local addr = traceexitstub(tr, nexit) | 97 | local addr = traceexitstub(tr, nexit) |
@@ -104,7 +105,10 @@ local function fillsymtab(tr, nexit) | |||
104 | local ircall = vmdef.ircall | 105 | local ircall = vmdef.ircall |
105 | for i=0,#ircall do | 106 | for i=0,#ircall do |
106 | local addr = ircalladdr(i) | 107 | local addr = ircalladdr(i) |
107 | if addr ~= 0 then t[addr] = ircall[i] end | 108 | if addr ~= 0 then |
109 | if addr < 0 then addr = addr + 2^32 end | ||
110 | t[addr] = ircall[i] | ||
111 | end | ||
108 | end | 112 | end |
109 | end | 113 | end |
110 | if nexitsym == 1000000 then -- Per-trace exit stubs. | 114 | if nexitsym == 1000000 then -- Per-trace exit stubs. |
@@ -118,6 +122,7 @@ local function fillsymtab(tr, nexit) | |||
118 | nexit = 1000000 | 122 | nexit = 1000000 |
119 | break | 123 | break |
120 | end | 124 | end |
125 | if addr < 0 then addr = addr + 2^32 end | ||
121 | t[addr] = tostring(i) | 126 | t[addr] = tostring(i) |
122 | end | 127 | end |
123 | nexitsym = nexit | 128 | nexitsym = nexit |
@@ -136,6 +141,7 @@ local function dump_mcode(tr) | |||
136 | local mcode, addr, loop = tracemc(tr) | 141 | local mcode, addr, loop = tracemc(tr) |
137 | if not mcode then return end | 142 | if not mcode then return end |
138 | if not disass then disass = require("jit.dis_"..jit.arch) end | 143 | if not disass then disass = require("jit.dis_"..jit.arch) end |
144 | if addr < 0 then addr = addr + 2^32 end | ||
139 | out:write("---- TRACE ", tr, " mcode ", #mcode, "\n") | 145 | out:write("---- TRACE ", tr, " mcode ", #mcode, "\n") |
140 | local ctx = disass.create(mcode, addr, dumpwrite) | 146 | local ctx = disass.create(mcode, addr, dumpwrite) |
141 | ctx.hexdump = 0 | 147 | ctx.hexdump = 0 |
@@ -270,8 +276,7 @@ local litname = { | |||
270 | ["CONV "] = setmetatable({}, { __index = function(t, mode) | 276 | ["CONV "] = setmetatable({}, { __index = function(t, mode) |
271 | local s = irtype[band(mode, 31)] | 277 | local s = irtype[band(mode, 31)] |
272 | s = irtype[band(shr(mode, 5), 31)].."."..s | 278 | s = irtype[band(shr(mode, 5), 31)].."."..s |
273 | if band(mode, 0x400) ~= 0 then s = s.." trunc" | 279 | if band(mode, 0x800) ~= 0 then s = s.." sext" end |
274 | elseif band(mode, 0x800) ~= 0 then s = s.." sext" end | ||
275 | local c = shr(mode, 14) | 280 | local c = shr(mode, 14) |
276 | if c == 2 then s = s.." index" elseif c == 3 then s = s.." check" end | 281 | if c == 2 then s = s.." index" elseif c == 3 then s = s.." check" end |
277 | t[mode] = s | 282 | t[mode] = s |
@@ -280,6 +285,8 @@ local litname = { | |||
280 | ["FLOAD "] = vmdef.irfield, | 285 | ["FLOAD "] = vmdef.irfield, |
281 | ["FREF "] = vmdef.irfield, | 286 | ["FREF "] = vmdef.irfield, |
282 | ["FPMATH"] = vmdef.irfpm, | 287 | ["FPMATH"] = vmdef.irfpm, |
288 | ["BUFHDR"] = { [0] = "RESET", "APPEND" }, | ||
289 | ["TOSTR "] = { [0] = "INT", "NUM", "CHAR" }, | ||
283 | } | 290 | } |
284 | 291 | ||
285 | local function ctlsub(c) | 292 | 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 | ||