Garry's Mod Wiki

Revision Difference

jit.attach#511494

<function name="attach" parent="jit" type="libraryfunc">⤶ <description>⤶ You can attach callbacks to a number of compiler events with jit.attach. The callback can be called:⤶ ⤶ * when a function has been compiled to bytecode ("bc");⤶ * when trace recording starts or stops ("trace");⤶ * as a trace is being recorded ("record");⤶ * or when a trace exits through a side exit ("texit").⤶ ⤶ Set a callback with jit.attach(callback, "event") and clear the same callback with jit.attach(callback)⤶ ⤶ <warning>This function isn't officially documented on LuJIT wiki, use it at your own risk.</warning>⤶ </description>⤶ <realm>Shared and Menu</realm>⤶ <args>⤶ <arg name="callback" type="function">The callback function.&#xA;&#xA;The arguments passed to the callback depend on the event being reported:&#xA;&#xA;* &quot;bc&quot;:&#xA;&lt;page&gt;function&lt;/page&gt; func - The function that&#x27;s just been recorded&#xA;&#xA;&#xA;&#xA;* &quot;trace&quot;:&#xA;&lt;page&gt;string&lt;/page&gt; what - description of the trace event: &quot;flush&quot;, &quot;start&quot;, &quot;stop&quot;, &quot;abort&quot;. Available for all events.&#xA;&#xA;&#xA;&lt;page&gt;number&lt;/page&gt; tr - The trace number. Not available for flush.&#xA;&#xA;&#xA;&lt;page&gt;function&lt;/page&gt; func - The function being traced. Available for start and abort.&#xA;&#xA;&#xA;&lt;page&gt;number&lt;/page&gt; pc - The program counter - the bytecode number of the function being recorded (if this a Lua function). Available for start and abort.&#xA;&#xA;&#xA;&lt;page&gt;number&lt;/page&gt; otr - start: the parent trace number if this is a side trace, abort: abort code&#xA;&#xA;&#xA;&lt;page&gt;string&lt;/page&gt; oex - start: the exit number for the parent trace, abort: abort reason (string)&#xA;&#xA;&#xA;&#xA;* &quot;record&quot;:&#xA;&lt;page&gt;number&lt;/page&gt; tr - The trace number. Not available for flush.&#xA;&#xA;&#xA;&lt;page&gt;function&lt;/page&gt; func - The function being traced. Available for start and abort.&#xA;&#xA;&#xA;&lt;page&gt;number&lt;/page&gt; pc - The program counter - the bytecode number of the function being recorded (if this a Lua function). Available for start and abort.&#xA;&#xA;&#xA;&lt;page&gt;number&lt;/page&gt; depth - The depth of the inlining of the current bytecode.&#xA;&#xA;&#xA;&#xA;* &quot;texit&quot;:&#xA;&lt;page&gt;number&lt;/page&gt; tr - The trace number. Not available for flush.&#xA;&#xA;&#xA;&lt;page&gt;number&lt;/page&gt; ex - The exit number&#xA;&#xA;&#xA;&lt;page&gt;number&lt;/page&gt; ngpr - The number of general-purpose and floating point registers that are active at the exit.&#xA;&#xA;&#xA;&lt;page&gt;number&lt;/page&gt; nfpr - The number of general-purpose and floating point registers that are active at the exit.</arg>⤶ <arg name="event" type="string">The event to hook into.</arg>⤶ </args>⤶ </function>⤶ ⤶