Re: luajit-dump.el -- Emacs mode for reading jit.dump files

  • From: Mike Pall <mike-1412@xxxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Tue, 16 Dec 2014 03:08:37 +0100

Yichun Zhang (agentzh) wrote:
> This is essentially the debug information for the machine code
> generated by the JIT compiler

The IR already has that info. All snapshots of a trace carry a
bytecode PC plus the (partial) frame info relative to the base
frame of the trace. From that info you can pretty accurately
reconstruct the control flow of the whole trace ('connect the
dots'). (*)

You could expose that info via jit.util.tracesnap(). Look at
lj_snap_restore() on how to get at the PC and the frame links.

(*) There's an optimization which directs an exit to the other
side of a conditional (instead of retrying it). But this is always
followed by another snapshot that continues the control flow.

The individual basic blocks of the machine code can be mapped back
to the IR with a similar algorithm, by tracking the trace exit
stubs and mapping them back to the snapshots in the IR. The
jit.dump() module has the code to detect the branches to the trace
exit stubs and insert the exit numbers into the disassebly.

--Mike

Other related posts: