aboutsummaryrefslogtreecommitdiff
path: root/lib/dump.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lib/dump.lua')
-rw-r--r--lib/dump.lua31
1 files changed, 10 insertions, 21 deletions
diff --git a/lib/dump.lua b/lib/dump.lua
index a6b61f53..b049828f 100644
--- a/lib/dump.lua
+++ b/lib/dump.lua
@@ -69,7 +69,7 @@ local type, tostring = type, tostring
69local stdout, stderr = io.stdout, io.stderr 69local stdout, stderr = io.stdout, io.stderr
70 70
71-- Load other modules on-demand. 71-- Load other modules on-demand.
72local bcline, discreate 72local bcline, disass
73 73
74-- Active flag, output file handle and dump mode. 74-- Active flag, output file handle and dump mode.
75local active, out, dumpmode 75local active, out, dumpmode
@@ -87,7 +87,11 @@ local function fillsymtab(nexit)
87 for i=0,#ircall do t[ircalladdr(i)] = ircall[i] end 87 for i=0,#ircall do t[ircalladdr(i)] = ircall[i] end
88 end 88 end
89 if nexit > nexitsym then 89 if nexit > nexitsym then
90 for i=nexitsym,nexit-1 do t[traceexitstub(i)] = tostring(i) end 90 for i=nexitsym,nexit-1 do
91 local addr = traceexitstub(i)
92 if addr == nil then nexit = 1000000; break end
93 t[addr] = tostring(i)
94 end
91 nexitsym = nexit 95 nexitsym = nexit
92 end 96 end
93 return t 97 return t
@@ -103,11 +107,9 @@ local function dump_mcode(tr)
103 if not info then return end 107 if not info then return end
104 local mcode, addr, loop = tracemc(tr) 108 local mcode, addr, loop = tracemc(tr)
105 if not mcode then return end 109 if not mcode then return end
106 if not discreate then 110 if not disass then disass = require("jit.dis_"..jit.arch) end
107 discreate = require("jit.dis_"..jit.arch).create
108 end
109 out:write("---- TRACE ", tr, " mcode ", #mcode, "\n") 111 out:write("---- TRACE ", tr, " mcode ", #mcode, "\n")
110 local ctx = discreate(mcode, addr, dumpwrite) 112 local ctx = disass.create(mcode, addr, dumpwrite)
111 ctx.hexdump = 0 113 ctx.hexdump = 0
112 ctx.symtab = fillsymtab(info.nexit) 114 ctx.symtab = fillsymtab(info.nexit)
113 if loop ~= 0 then 115 if loop ~= 0 then
@@ -346,25 +348,12 @@ local function dump_snap(tr)
346 end 348 end
347end 349end
348 350
349-- NYI: should really get the register map from the disassembler.
350local reg_map = ({
351 x86 = {
352 [0] = "eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi",
353 "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7",
354 },
355 x64 = {
356 [0] = "rax", "rcx", "rdx", "rbx", "rsp", "rbp", "rsi", "rdi",
357 "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
358 "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7",
359 "xmm8", "xmm9", "xmm10", "xmm11", "xmm12", "xmm13", "xmm14", "xmm15",
360 }
361})[jit.arch]
362
363-- Return a register name or stack slot for a rid/sp location. 351-- Return a register name or stack slot for a rid/sp location.
364local function ridsp_name(ridsp) 352local function ridsp_name(ridsp)
353 if not disass then disass = require("jit.dis_"..jit.arch) end
365 local rid = band(ridsp, 0xff) 354 local rid = band(ridsp, 0xff)
366 if ridsp > 255 then return format("[%x]", shr(ridsp, 8)*4) end 355 if ridsp > 255 then return format("[%x]", shr(ridsp, 8)*4) end
367 if rid < 128 then return reg_map[rid] end 356 if rid < 128 then return disass.regname(rid) end
368 return "" 357 return ""
369end 358end
370 359