Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Not quite what you're looking for, but I've managed some reverse-engineering of the jit.* tracing facilities. What follows is a bit rough, inaccurate, subject to change and very incomplete. I'll start making use of it in <a href="https://github.com/geoffleyland/luatrace" rel="noreferrer">luatrace</a> soon. These functions are used in several of the -j library files. <code>dump.lua</code> is probably a good place to start.</p> <p><strong>jit.attach</strong></p> <p>You can attach callbacks to a number of compiler events with <code>jit.attach</code>. The callback can be called:</p> <ul> <li>when a function has been compiled to bytecode ("bc");</li> <li>when trace recording starts or stops ("trace");</li> <li>as a trace is being recorded ("record");</li> <li>or when a trace exits through a side exit ("texit").</li> </ul> <p>Set a callback with <code>jit.attach(callback, "event")</code> and clear the same callback with <code>jit.attach(callback)</code></p> <p>The arguments passed to the callback depend on the event being reported:</p> <ul> <li>"bc": <code>callback(func)</code>. <code>func</code> is the function that's just been recorded.</li> <li>"trace": <code>callback(what, tr, func, pc, otr, oex)</code> <ul> <li><code>what</code> is a description of the trace event: "flush", "start", "stop", "abort". Available for all events.</li> <li><code>tr</code> is the trace number. Not available for flush.</li> <li><code>func</code> is the function being traced. Available for start and abort.</li> <li><code>pc</code> is the program counter - the bytecode number of the function being recorded (if this a Lua function). Available for start and abort.</li> <li><code>otr</code> start: the parent trace number if this is a side trace, abort: abort code (integer)?</li> <li><code>oex</code> start: the exit number for the parent trace, abort: abort reason (string) </li> </ul></li> <li>"record": <code>callback(tr, func, pc, depth)</code>. The first arguments are the same as for trace start. <code>depth</code> is the depth of the inlining of the current bytecode.</li> <li>"texit": <code>callback(tr, ex, ngpr, nfpr)</code>. <ul> <li><code>tr</code> is the trace number as before</li> <li><code>ex</code> is the exit number</li> <li><code>ngpr</code> and <code>nfpr</code> are the number of general-purpose and floating point registers that are active at the exit.</li> </ul></li> </ul> <p><strong>jit.util.funcinfo(func, pc)</strong></p> <p>When passed <code>func</code> and <code>pc</code> from a <code>jit.attach</code> callback, <code>jit.util.funcinfo</code> returns a table of information about the function, much like <code>debug.getinfo</code>.</p> <p>The fields of the table are:</p> <ul> <li><code>linedefined</code>: as for <code>debug.getinfo</code></li> <li><code>lastlinedefined</code>: as for <code>debug.getinfo</code></li> <li><code>params</code>: the number of parameters the function takes</li> <li><code>stackslots</code>: the number of stack slots the function's local variable use</li> <li><code>upvalues</code>: the number of upvalues the function uses</li> <li><code>bytecodes</code>: the number of bytecodes it the compiled function</li> <li><code>gcconsts</code>: ??</li> <li><code>nconsts</code>: ??</li> <li><code>currentline</code>: as for <code>debug.getinfo</code></li> <li><code>isvararg</code>: if the function is a vararg function`</li> <li><code>source</code>: as for <code>debug.getinfo</code></li> <li><code>loc</code>: a string describing the source and currentline, like "&lt;source&gt;:&lt;line&gt;"</li> <li><code>ffid</code>: the fast function id of the function (if it is one). In this case only <code>upvalues</code> above and <code>addr</code> below are valid</li> <li><code>addr</code>: the address of the function (if it is not a Lua function). If it's a C function rather than a fast function, only <code>upvalues</code> above is valid</li> </ul>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload