diff options
| author | Mike Pall <mike> | 2026-08-03 10:44:17 +0200 |
|---|---|---|
| committer | Mike Pall <mike> | 2026-08-03 10:44:17 +0200 |
| commit | f30aabe82f61dbd6901f6a75dadde0a64dc626d2 (patch) | |
| tree | 80eda65bf087e10b2a78d9b94bcec3a04ed4d2de /src/jit/dump.lua | |
| parent | 28084004ee68d576f3f0c9ea61ea448fe3e10f07 (diff) | |
| download | luajit-f30aabe82f61dbd6901f6a75dadde0a64dc626d2.tar.gz luajit-f30aabe82f61dbd6901f6a75dadde0a64dc626d2.tar.bz2 luajit-f30aabe82f61dbd6901f6a75dadde0a64dc626d2.zip | |
Modernize jit.* Lua modules.
Diffstat (limited to 'src/jit/dump.lua')
| -rw-r--r-- | src/jit/dump.lua | 132 |
1 files changed, 66 insertions, 66 deletions
diff --git a/src/jit/dump.lua b/src/jit/dump.lua index 6a700bbe4..3532e3c4e 100644 --- a/src/jit/dump.lua +++ b/src/jit/dump.lua | |||
| @@ -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, shr, tohex = bit.band, bit.rshift, bit.tohex | 65 | local tohex = 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, rep = string.byte, string.rep | 67 | local byte, rep = string.byte, string.rep |
| 68 | local type, tostring = type, tostring | 68 | local type, tostring = type, tostring |
| @@ -90,7 +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 | if addr < 0 then addr += 2^32 end |
| 94 | t[addr] = tostring(i) | 94 | t[addr] = tostring(i) |
| 95 | end | 95 | end |
| 96 | local addr = traceexitstub(tr, nexit) | 96 | local addr = traceexitstub(tr, nexit) |
| @@ -105,9 +105,9 @@ local function fillsymtab(tr, nexit) | |||
| 105 | local ircall = vmdef.ircall | 105 | local ircall = vmdef.ircall |
| 106 | for i=0,#ircall do | 106 | for i=0,#ircall do |
| 107 | local addr = ircalladdr(i) | 107 | local addr = ircalladdr(i) |
| 108 | if addr ~= 0 then | 108 | if addr != 0 then |
| 109 | if maskaddr then addr = band(addr, maskaddr) end | 109 | if maskaddr then addr &= maskaddr end |
| 110 | if addr < 0 then addr = addr + 2^32 end | 110 | if addr < 0 then addr += 2^32 end |
| 111 | t[addr] = ircall[i] | 111 | t[addr] = ircall[i] |
| 112 | end | 112 | end |
| 113 | end | 113 | end |
| @@ -123,7 +123,7 @@ local function fillsymtab(tr, nexit) | |||
| 123 | nexit = 1000000 | 123 | nexit = 1000000 |
| 124 | break | 124 | break |
| 125 | end | 125 | end |
| 126 | if addr < 0 then addr = addr + 2^32 end | 126 | if addr < 0 then addr += 2^32 end |
| 127 | t[addr] = tostring(i) | 127 | t[addr] = tostring(i) |
| 128 | end | 128 | end |
| 129 | nexitsym = nexit | 129 | nexitsym = nexit |
| @@ -142,12 +142,12 @@ local function dump_mcode(tr) | |||
| 142 | local mcode, addr, loop = tracemc(tr) | 142 | local mcode, addr, loop = tracemc(tr) |
| 143 | if not mcode then return end | 143 | if not mcode then return end |
| 144 | if not disass then disass = require("jit.dis_"..jit.arch) end | 144 | if not disass then disass = require("jit.dis_"..jit.arch) end |
| 145 | if addr < 0 then addr = addr + 2^32 end | 145 | if addr < 0 then addr += 2^32 end |
| 146 | out:write("---- TRACE ", tr, " mcode ", #mcode, "\n") | 146 | out:write("---- TRACE ", tr, " mcode ", #mcode, "\n") |
| 147 | local ctx = disass.create(mcode, addr, dumpwrite) | 147 | local ctx = disass.create(mcode, addr, dumpwrite) |
| 148 | ctx.hexdump = 0 | 148 | ctx.hexdump = 0 |
| 149 | ctx.symtab = fillsymtab(tr, info.nexit) | 149 | ctx.symtab = fillsymtab(tr, info.nexit) |
| 150 | if loop ~= 0 then | 150 | if loop != 0 then |
| 151 | symtab[addr+loop] = "LOOP" | 151 | symtab[addr+loop] = "LOOP" |
| 152 | ctx:disass(0, loop) | 152 | ctx:disass(0, loop) |
| 153 | out:write("->LOOP:\n") | 153 | out:write("->LOOP:\n") |
| @@ -233,7 +233,7 @@ local html_escape = { ["<"] = "<", [">"] = ">", ["&"] = "&", } | |||
| 233 | local function colorize_html(s, t, extra) | 233 | local function colorize_html(s, t, extra) |
| 234 | s = gsub(s, "[<>&]", html_escape) | 234 | s = gsub(s, "[<>&]", html_escape) |
| 235 | return format('<span class="irt_%s%s">%s</span>', | 235 | return format('<span class="irt_%s%s">%s</span>', |
| 236 | irtype_text[t], extra and " irt_extra" or "", s) | 236 | irtype_text[t], extra ? " irt_extra" : "", s) |
| 237 | end | 237 | end |
| 238 | 238 | ||
| 239 | local irtype_html = setmetatable({}, | 239 | local irtype_html = setmetatable({}, |
| @@ -268,25 +268,25 @@ local colorize, irtype | |||
| 268 | local litname = { | 268 | local litname = { |
| 269 | ["SLOAD "] = setmetatable({}, { __index = function(t, mode) | 269 | ["SLOAD "] = setmetatable({}, { __index = function(t, mode) |
| 270 | local s = "" | 270 | local s = "" |
| 271 | if band(mode, 1) ~= 0 then s = s.."P" end | 271 | if mode & 1 != 0 then s ..= "P" end |
| 272 | if band(mode, 2) ~= 0 then s = s.."F" end | 272 | if mode & 2 != 0 then s ..= "F" end |
| 273 | if band(mode, 4) ~= 0 then s = s.."T" end | 273 | if mode & 4 != 0 then s ..= "T" end |
| 274 | if band(mode, 8) ~= 0 then s = s.."C" end | 274 | if mode & 8 != 0 then s ..= "C" end |
| 275 | if band(mode, 16) ~= 0 then s = s.."R" end | 275 | if mode & 16 != 0 then s ..= "R" end |
| 276 | if band(mode, 32) ~= 0 then s = s.."I" end | 276 | if mode & 32 != 0 then s ..= "I" end |
| 277 | if band(mode, 64) ~= 0 then s = s.."K" end | 277 | if mode & 64 != 0 then s ..= "K" end |
| 278 | t[mode] = s | 278 | t[mode] = s |
| 279 | return s | 279 | return s |
| 280 | end}), | 280 | end}), |
| 281 | ["XLOAD "] = { [0] = "", "R", "V", "RV", "U", "RU", "VU", "RVU", }, | 281 | ["XLOAD "] = { [0] = "", "R", "V", "RV", "U", "RU", "VU", "RVU", }, |
| 282 | ["CONV "] = setmetatable({}, { __index = function(t, mode) | 282 | ["CONV "] = setmetatable({}, { __index = function(t, mode) |
| 283 | local s = irtype[band(mode, 31)] | 283 | local s = irtype[mode & 31] |
| 284 | s = irtype[band(shr(mode, 5), 31)].."."..s | 284 | s = irtype[(mode >> 5) & 31].."."..s |
| 285 | if band(mode, 0x800) ~= 0 then s = s.." sext" end | 285 | if mode & 0x800 != 0 then s ..= " sext" end |
| 286 | local c = shr(mode, 12) | 286 | local c = mode >> 12 |
| 287 | if c == 1 then s = s.." none" | 287 | if c == 1 then s ..= " none" |
| 288 | elseif c == 2 then s = s.." index" | 288 | elseif c == 2 then s ..= " index" |
| 289 | elseif c == 3 then s = s.." check" end | 289 | elseif c == 3 then s ..= " check" end |
| 290 | t[mode] = s | 290 | t[mode] = s |
| 291 | return s | 291 | return s |
| 292 | end}), | 292 | end}), |
| @@ -325,16 +325,16 @@ local function formatk(tr, idx, sn) | |||
| 325 | local s | 325 | local s |
| 326 | if tn == "number" then | 326 | if tn == "number" then |
| 327 | if t < 12 then | 327 | if t < 12 then |
| 328 | s = k == 0 and "NULL" or format("[0x%08x]", k) | 328 | s = k == 0 ? "NULL" : format("[0x%08x]", k) |
| 329 | elseif band(sn or 0, 0x30000) ~= 0 then | 329 | elseif (sn or 0) & 0x30000 != 0 then |
| 330 | s = band(sn, 0x20000) ~= 0 and "contpc" or "ftsz" | 330 | s = sn & 0x20000 != 0 ? "contpc" : "ftsz" |
| 331 | elseif k == 2^52+2^51 then | 331 | elseif k == 2^52+2^51 then |
| 332 | s = "bias" | 332 | s = "bias" |
| 333 | else | 333 | else |
| 334 | s = format(0 < k and k < 0x1p-1026 and "%+a" or "%+.14g", k) | 334 | s = format(0 < k and k < 0x1p-1026 ? "%+a" : "%+.14g", k) |
| 335 | end | 335 | end |
| 336 | elseif tn == "string" then | 336 | elseif tn == "string" then |
| 337 | s = format(#k > 20 and '"%.20s"~' or '"%s"', gsub(k, "%c", ctlsub)) | 337 | s = format(#k > 20 ? '"%.20s"~' : '"%s"', gsub(k, "%c", ctlsub)) |
| 338 | elseif tn == "function" then | 338 | elseif tn == "function" then |
| 339 | s = fmtfunc(k) | 339 | s = fmtfunc(k) |
| 340 | elseif tn == "table" then | 340 | elseif tn == "table" then |
| @@ -348,13 +348,13 @@ local function formatk(tr, idx, sn) | |||
| 348 | end | 348 | end |
| 349 | elseif t == 21 then -- int64_t | 349 | elseif t == 21 then -- int64_t |
| 350 | s = sub(tostring(k), 1, -3) | 350 | s = sub(tostring(k), 1, -3) |
| 351 | if sub(s, 1, 1) ~= "-" then s = "+"..s end | 351 | if sub(s, 1, 1) != "-" then s = "+"..s end |
| 352 | elseif sn == 0x1057fff then -- SNAP(1, SNAP_FRAME | SNAP_NORESTORE, REF_NIL) | 352 | elseif sn == 0x1057fff then -- SNAP(1, SNAP_FRAME | SNAP_NORESTORE, REF_NIL) |
| 353 | return "----" -- Special case for LJ_FR2 slot 1. | 353 | return "----" -- Special case for LJ_FR2 slot 1. |
| 354 | else | 354 | else |
| 355 | s = tostring(k) -- For primitives. | 355 | s = tostring(k) -- For primitives. |
| 356 | end | 356 | end |
| 357 | s = colorize(format("%-4s", s), t, band(sn or 0, 0x100000) ~= 0) | 357 | s = colorize(format("%-4s", s), t, (sn or 0) & 0x100000 != 0) |
| 358 | if slot then | 358 | if slot then |
| 359 | s = format("%s @%d", s, slot) | 359 | s = format("%s @%d", s, slot) |
| 360 | end | 360 | end |
| @@ -365,18 +365,18 @@ local function printsnap(tr, snap) | |||
| 365 | local n = 2 | 365 | local n = 2 |
| 366 | for s=0,snap[1]-1 do | 366 | for s=0,snap[1]-1 do |
| 367 | local sn = snap[n] | 367 | local sn = snap[n] |
| 368 | if shr(sn, 24) == s then | 368 | if sn >> 24 == s then |
| 369 | n = n + 1 | 369 | n += 1 |
| 370 | local ref = band(sn, 0xffff) - 0x8000 -- REF_BIAS | 370 | local ref = (sn & 0xffff) - 0x8000 -- REF_BIAS |
| 371 | if ref < 0 then | 371 | if ref < 0 then |
| 372 | out:write(formatk(tr, ref, sn)) | 372 | out:write(formatk(tr, ref, sn)) |
| 373 | elseif band(sn, 0x80000) ~= 0 then -- SNAP_SOFTFPNUM | 373 | elseif sn & 0x80000 != 0 then -- SNAP_SOFTFPNUM |
| 374 | out:write(colorize(format("%04d/%04d", ref, ref+1), 14)) | 374 | out:write(colorize(format("%04d/%04d", ref, ref+1), 14)) |
| 375 | else | 375 | else |
| 376 | local m, ot, op1, op2 = traceir(tr, ref) | 376 | local m, ot, op1, op2 = traceir(tr, ref) |
| 377 | out:write(colorize(format("%04d", ref), band(ot, 31), band(sn, 0x100000) ~= 0)) | 377 | out:write(colorize(format("%04d", ref), ot & 31, sn & 0x100000 != 0)) |
| 378 | end | 378 | end |
| 379 | out:write(band(sn, 0x10000) == 0 and " " or "|") -- SNAP_FRAME | 379 | out:write(sn & 0x10000 == 0 ? " " : "|") -- SNAP_FRAME |
| 380 | else | 380 | else |
| 381 | out:write("---- ") | 381 | out:write("---- ") |
| 382 | end | 382 | end |
| @@ -398,9 +398,9 @@ end | |||
| 398 | -- Return a register name or stack slot for a rid/sp location. | 398 | -- Return a register name or stack slot for a rid/sp location. |
| 399 | local function ridsp_name(ridsp, ins) | 399 | local function ridsp_name(ridsp, ins) |
| 400 | if not disass then disass = require("jit.dis_"..jit.arch) end | 400 | if not disass then disass = require("jit.dis_"..jit.arch) end |
| 401 | local rid, slot = band(ridsp, 0xff), shr(ridsp, 8) | 401 | local rid, slot = ridsp & 0xff, ridsp >> 8 |
| 402 | if rid == 253 or rid == 254 then | 402 | if rid == 253 or rid == 254 then |
| 403 | return (slot == 0 or slot == 255) and " {sink" or format(" {%04d", ins-slot) | 403 | return (slot == 0 or slot == 255) ? " {sink" : format(" {%04d", ins-slot) |
| 404 | end | 404 | end |
| 405 | if ridsp > 255 then return format("[%x]", slot*4) end | 405 | if ridsp > 255 then return format("[%x]", slot*4) end |
| 406 | if rid < 128 then return disass.regname(rid) end | 406 | if rid < 128 then return disass.regname(rid) end |
| @@ -412,7 +412,7 @@ local function dumpcallfunc(tr, ins) | |||
| 412 | local ctype | 412 | local ctype |
| 413 | if ins > 0 then | 413 | if ins > 0 then |
| 414 | local m, ot, op1, op2 = traceir(tr, ins) | 414 | local m, ot, op1, op2 = traceir(tr, ins) |
| 415 | if band(ot, 31) == 0 then -- nil type means CARG(func, ctype). | 415 | if ot & 31 == 0 then -- nil type means CARG(func, ctype). |
| 416 | ins = op1 | 416 | ins = op1 |
| 417 | ctype = formatk(tr, op2) | 417 | ctype = formatk(tr, op2) |
| 418 | end | 418 | end |
| @@ -431,7 +431,7 @@ local function dumpcallargs(tr, ins) | |||
| 431 | out:write(formatk(tr, ins)) | 431 | out:write(formatk(tr, ins)) |
| 432 | else | 432 | else |
| 433 | local m, ot, op1, op2 = traceir(tr, ins) | 433 | local m, ot, op1, op2 = traceir(tr, ins) |
| 434 | local oidx = 6*shr(ot, 8) | 434 | local oidx = 6 * (ot >> 8) |
| 435 | local op = sub(vmdef.irnames, oidx+1, oidx+6) | 435 | local op = sub(vmdef.irnames, oidx+1, oidx+6) |
| 436 | if op == "CARG " then | 436 | if op == "CARG " then |
| 437 | dumpcallargs(tr, op1) | 437 | dumpcallargs(tr, op1) |
| @@ -468,12 +468,12 @@ local function dump_ir(tr, dumpsnap, dumpreg) | |||
| 468 | out:write(format(".... SNAP #%-3d [ ", snapno)) | 468 | out:write(format(".... SNAP #%-3d [ ", snapno)) |
| 469 | end | 469 | end |
| 470 | printsnap(tr, snap) | 470 | printsnap(tr, snap) |
| 471 | snapno = snapno + 1 | 471 | snapno += 1 |
| 472 | snap = tracesnap(tr, snapno) | 472 | snap = tracesnap(tr, snapno) |
| 473 | snapref = snap and snap[0] or 65536 | 473 | snapref = snap ? snap[0] : 65536 |
| 474 | end | 474 | end |
| 475 | local m, ot, op1, op2, ridsp = traceir(tr, ins) | 475 | local m, ot, op1, op2, ridsp = traceir(tr, ins) |
| 476 | local oidx, t = 6*shr(ot, 8), band(ot, 31) | 476 | local oidx, t = 6 * (ot >> 8), ot & 31 |
| 477 | local op = sub(irnames, oidx+1, oidx+6) | 477 | local op = sub(irnames, oidx+1, oidx+6) |
| 478 | if op == "LOOP " then | 478 | if op == "LOOP " then |
| 479 | if dumpreg then | 479 | if dumpreg then |
| @@ -481,45 +481,45 @@ local function dump_ir(tr, dumpsnap, dumpreg) | |||
| 481 | else | 481 | else |
| 482 | out:write(format("%04d ------ LOOP ------------\n", ins)) | 482 | out:write(format("%04d ------ LOOP ------------\n", ins)) |
| 483 | end | 483 | end |
| 484 | elseif op ~= "NOP " and op ~= "CARG " and | 484 | elseif op != "NOP " and op != "CARG " and |
| 485 | (dumpreg or op ~= "RENAME") then | 485 | (dumpreg or op != "RENAME") then |
| 486 | local rid = band(ridsp, 255) | 486 | local rid = ridsp & 255 |
| 487 | if dumpreg then | 487 | if dumpreg then |
| 488 | out:write(format("%04d %-6s", ins, ridsp_name(ridsp, ins))) | 488 | out:write(format("%04d %-6s", ins, ridsp_name(ridsp, ins))) |
| 489 | else | 489 | else |
| 490 | out:write(format("%04d ", ins)) | 490 | out:write(format("%04d ", ins)) |
| 491 | end | 491 | end |
| 492 | out:write(format("%s%s %s %s ", | 492 | out:write(format("%s%s %s %s ", |
| 493 | (rid == 254 or rid == 253) and "}" or | 493 | rid == 254 or rid == 253 ? "}" : |
| 494 | (band(ot, 128) == 0 and " " or ">"), | 494 | ot & 128 == 0 ? " " : ">", |
| 495 | band(ot, 64) == 0 and " " or "+", | 495 | ot & 64 == 0 ? " " : "+", |
| 496 | irtype[t], op)) | 496 | irtype[t], op)) |
| 497 | local m1, m2 = band(m, 3), band(m, 3*4) | 497 | local m1, m2 = m & 3, m & (3 << 2) |
| 498 | if sub(op, 1, 4) == "CALL" then | 498 | if sub(op, 1, 4) == "CALL" then |
| 499 | local ctype | 499 | local ctype |
| 500 | if m2 == 1*4 then -- op2 == IRMlit | 500 | if m2 == 1 << 2 then -- op2 == IRMlit |
| 501 | out:write(format("%-10s (", vmdef.ircall[op2])) | 501 | out:write(format("%-10s (", vmdef.ircall[op2])) |
| 502 | else | 502 | else |
| 503 | ctype = dumpcallfunc(tr, op2) | 503 | ctype = dumpcallfunc(tr, op2) |
| 504 | end | 504 | end |
| 505 | if op1 ~= -1 then dumpcallargs(tr, op1) end | 505 | if op1 != -1 then dumpcallargs(tr, op1) end |
| 506 | out:write(")") | 506 | out:write(")") |
| 507 | if ctype then out:write(" ctype ", ctype) end | 507 | if ctype then out:write(" ctype ", ctype) end |
| 508 | elseif op == "CNEW " and op2 == -1 then | 508 | elseif op == "CNEW " and op2 == -1 then |
| 509 | out:write(formatk(tr, op1)) | 509 | out:write(formatk(tr, op1)) |
| 510 | elseif m1 ~= 3 then -- op1 != IRMnone | 510 | elseif m1 != 3 then -- op1 != IRMnone |
| 511 | if op1 < 0 then | 511 | if op1 < 0 then |
| 512 | out:write(formatk(tr, op1)) | 512 | out:write(formatk(tr, op1)) |
| 513 | else | 513 | else |
| 514 | out:write(format(m1 == 0 and "%04d" or "#%-3d", op1)) | 514 | out:write(format(m1 == 0 ? "%04d" : "#%-3d", op1)) |
| 515 | end | 515 | end |
| 516 | if m2 ~= 3*4 then -- op2 != IRMnone | 516 | if m2 != 3 << 2 then -- op2 != IRMnone |
| 517 | if m2 == 1*4 then -- op2 == IRMlit | 517 | if m2 == 1 << 2 then -- op2 == IRMlit |
| 518 | local litn = litname[op] | 518 | local litn = litname[op] |
| 519 | if litn and litn[op2] then | 519 | if litn and litn[op2] then |
| 520 | out:write(" ", litn[op2]) | 520 | out:write(" ", litn[op2]) |
| 521 | elseif op == "UREFO " or op == "UREFC " then | 521 | elseif op == "UREFO " or op == "UREFC " then |
| 522 | out:write(format(" #%-3d", shr(op2, 8))) | 522 | out:write(format(" #%-3d", op2 >> 8)) |
| 523 | else | 523 | else |
| 524 | out:write(format(" #%-3d", op2)) | 524 | out:write(format(" #%-3d", op2)) |
| 525 | end | 525 | end |
| @@ -572,7 +572,7 @@ local function dump_trace(what, tr, func, pc, otr, oex) | |||
| 572 | if what == "start" then | 572 | if what == "start" then |
| 573 | if dumpmode.H then out:write('<pre class="ljdump">\n') end | 573 | if dumpmode.H then out:write('<pre class="ljdump">\n') end |
| 574 | out:write("---- TRACE ", tr, " ", what) | 574 | out:write("---- TRACE ", tr, " ", what) |
| 575 | if otr then out:write(" ", otr, "/", oex == -1 and "stitch" or oex) end | 575 | if otr then out:write(" ", otr, "/", oex == -1 ? "stitch" : oex) end |
| 576 | out:write(" ", fmtfunc(func, pc), "\n") | 576 | out:write(" ", fmtfunc(func, pc), "\n") |
| 577 | elseif what == "stop" or what == "abort" then | 577 | elseif what == "stop" or what == "abort" then |
| 578 | out:write("---- TRACE ", tr, " ", what) | 578 | out:write("---- TRACE ", tr, " ", what) |
| @@ -599,7 +599,7 @@ end | |||
| 599 | 599 | ||
| 600 | -- Dump recorded bytecode. | 600 | -- Dump recorded bytecode. |
| 601 | local function dump_record(tr, func, pc, depth) | 601 | local function dump_record(tr, func, pc, depth) |
| 602 | if depth ~= recdepth then | 602 | if depth != recdepth then |
| 603 | recdepth = depth | 603 | recdepth = depth |
| 604 | recprefix = rep(" .", depth) | 604 | recprefix = rep(" .", depth) |
| 605 | end | 605 | end |
| @@ -615,7 +615,7 @@ local function dump_record(tr, func, pc, depth) | |||
| 615 | else | 615 | else |
| 616 | out:write(line) | 616 | out:write(line) |
| 617 | end | 617 | end |
| 618 | if pc >= 0 and band(funcbc(func, pc), 0xff) < 16 then -- ORDER BC | 618 | if pc >= 0 and funcbc(func, pc) & 0xff < 16 then -- ORDER BC |
| 619 | out:write(bcline(func, pc+1, recprefix)) -- Write JMP for cond. | 619 | out:write(bcline(func, pc+1, recprefix)) -- Write JMP for cond. |
| 620 | end | 620 | end |
| 621 | end | 621 | end |
| @@ -664,7 +664,7 @@ local function dumpoff() | |||
| 664 | jit.attach(dump_texit) | 664 | jit.attach(dump_texit) |
| 665 | jit.attach(dump_record) | 665 | jit.attach(dump_record) |
| 666 | jit.attach(dump_trace) | 666 | jit.attach(dump_trace) |
| 667 | if out and out ~= stdout and out ~= stderr then out:close() end | 667 | if out and out != stdout and out != stderr then out:close() end |
| 668 | out = nil | 668 | out = nil |
| 669 | end | 669 | end |
| 670 | end | 670 | end |
| @@ -674,16 +674,16 @@ local function dumpon(opt, outfile) | |||
| 674 | if active then dumpoff() end | 674 | if active then dumpoff() end |
| 675 | 675 | ||
| 676 | local term = os.getenv("TERM") | 676 | local term = os.getenv("TERM") |
| 677 | local colormode = (term and term:match("color") or os.getenv("COLORTERM")) and "A" or "T" | 677 | local colormode = (term ? (term:match("color")) : os.getenv("COLORTERM")) ? "A" : "T" |
| 678 | if opt then | 678 | if opt then |
| 679 | opt = gsub(opt, "[TAH]", function(mode) colormode = mode; return ""; end) | 679 | opt = gsub(opt, "[TAH]", function(mode) colormode = mode; return ""; end) |
| 680 | end | 680 | end |
| 681 | 681 | ||
| 682 | local m = { t=true, b=true, i=true, m=true, } | 682 | local m = { t=true, b=true, i=true, m=true, } |
| 683 | if opt and opt ~= "" then | 683 | if opt and opt != "" then |
| 684 | local o = sub(opt, 1, 1) | 684 | local o = sub(opt, 1, 1) |
| 685 | if o ~= "+" and o ~= "-" then m = {} end | 685 | if o != "+" and o != "-" then m = {} end |
| 686 | for i=1,#opt do m[sub(opt, i, i)] = (o ~= "-") end | 686 | for i=1,#opt do m[sub(opt, i, i)] = (o != "-") end |
| 687 | end | 687 | end |
| 688 | dumpmode = m | 688 | dumpmode = m |
| 689 | 689 | ||
| @@ -700,7 +700,7 @@ local function dumpon(opt, outfile) | |||
| 700 | 700 | ||
| 701 | if not outfile then outfile = os.getenv("LUAJIT_DUMPFILE") end | 701 | if not outfile then outfile = os.getenv("LUAJIT_DUMPFILE") end |
| 702 | if outfile then | 702 | if outfile then |
| 703 | out = outfile == "-" and stdout or assert(io.open(outfile, "w")) | 703 | out = outfile == "-" ? stdout : assert(io.open(outfile, "w")) |
| 704 | else | 704 | else |
| 705 | out = stdout | 705 | out = stdout |
| 706 | end | 706 | end |
