diff options
author | Mike Pall <mike> | 2011-10-27 01:52:37 +0200 |
---|---|---|
committer | Mike Pall <mike> | 2011-10-27 01:57:30 +0200 |
commit | 2dc574d06bc6e828109a3bffa975592f9417434c (patch) | |
tree | 1239baece908e2390eb378e6d7d8063825926f9b /lib | |
parent | 1d190c99a2547b44deb8f5e483452d9f51925fb2 (diff) | |
download | luajit-2dc574d06bc6e828109a3bffa975592f9417434c.tar.gz luajit-2dc574d06bc6e828109a3bffa975592f9417434c.tar.bz2 luajit-2dc574d06bc6e828109a3bffa975592f9417434c.zip |
FFI: Compile calls to stdcall, fastcall and vararg functions.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/dump.lua | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/lib/dump.lua b/lib/dump.lua index 3a88ef45..0f0e9058 100644 --- a/lib/dump.lua +++ b/lib/dump.lua | |||
@@ -378,6 +378,24 @@ local function ridsp_name(ridsp) | |||
378 | return "" | 378 | return "" |
379 | end | 379 | end |
380 | 380 | ||
381 | -- Dump CALL* function ref and return optional ctype. | ||
382 | local function dumpcallfunc(tr, ins) | ||
383 | local ctype | ||
384 | if ins > 0 then | ||
385 | local m, ot, op1, op2 = traceir(tr, ins) | ||
386 | if band(ot, 31) == 0 then -- nil type means CARG(func, ctype). | ||
387 | ins = op1 | ||
388 | ctype = formatk(tr, op2) | ||
389 | end | ||
390 | end | ||
391 | if ins < 0 then | ||
392 | out:write(format("[0x%x](", tonumber((tracek(tr, ins))))) | ||
393 | else | ||
394 | out:write(format("%04d (", ins)) | ||
395 | end | ||
396 | return ctype | ||
397 | end | ||
398 | |||
381 | -- Recursively gather CALL* args and dump them. | 399 | -- Recursively gather CALL* args and dump them. |
382 | local function dumpcallargs(tr, ins) | 400 | local function dumpcallargs(tr, ins) |
383 | if ins < 0 then | 401 | if ins < 0 then |
@@ -447,15 +465,15 @@ local function dump_ir(tr, dumpsnap, dumpreg) | |||
447 | irtype[t], op)) | 465 | irtype[t], op)) |
448 | local m1, m2 = band(m, 3), band(m, 3*4) | 466 | local m1, m2 = band(m, 3), band(m, 3*4) |
449 | if sub(op, 1, 4) == "CALL" then | 467 | if sub(op, 1, 4) == "CALL" then |
468 | local ctype | ||
450 | if m2 == 1*4 then -- op2 == IRMlit | 469 | if m2 == 1*4 then -- op2 == IRMlit |
451 | out:write(format("%-10s (", vmdef.ircall[op2])) | 470 | out:write(format("%-10s (", vmdef.ircall[op2])) |
452 | elseif op2 < 0 then | ||
453 | out:write(format("[0x%x](", tonumber((tracek(tr, op2))))) | ||
454 | else | 471 | else |
455 | out:write(format("%04d (", op2)) | 472 | ctype = dumpcallfunc(tr, op2) |
456 | end | 473 | end |
457 | if op1 ~= -1 then dumpcallargs(tr, op1) end | 474 | if op1 ~= -1 then dumpcallargs(tr, op1) end |
458 | out:write(")") | 475 | out:write(")") |
476 | if ctype then out:write(" ctype ", ctype) end | ||
459 | elseif op == "CNEW " and op2 == -1 then | 477 | elseif op == "CNEW " and op2 == -1 then |
460 | out:write(formatk(tr, op1)) | 478 | out:write(formatk(tr, op1)) |
461 | elseif m1 ~= 3 then -- op1 != IRMnone | 479 | elseif m1 ~= 3 then -- op1 != IRMnone |