Library to work with the LuaJIT functionality of gmod.
jit.attach( function callback, string event )
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) This function isn't officially documented on LuJIT wiki,..
Flushes the whole cache of compiled code.
Disables LuaJIT Lua compilation.
Enables LuaJIT Lua compilation.
jit.opt.start( vararg args )
JIT compiler optimization control. The opt sub-module provides the backend for the -O command line LuaJIT option. You can also use it programmatically, e.g.: jit.opt.start(2) -- same as -O2 jit.opt.start("-dce") jit.opt.start("hotloop=10", "hotexit=2") A list of LuaJIT -O command line options can be found here(a table of various optimization levels are displayed towards the bottom of the page along with exactly which optimization options are enabled for each level): http://..
boolean, any jit.status()
Returns the status of the JIT compiler and the current optimizations enabled.
number, number jit.util.funcbc( function func, number pos )
Returns bytecode of a function at a position.
table jit.util.funcinfo( function func, number pos = 0 )
Retrieves LuaJIT information about a given function, similarly to debug.getinfo. Possible table fields: linedefined: as for debug.getinfo lastlinedefined: as for debug.getinfo params: the number of parameters the function takes stackslots: the number of stack slots the function's local variable use upvalues: the number of upvalues the function uses bytecodes: the number of bytecodes it the compiled function gcconsts: the number of garbage collectable constants nconsts: the number of lua_Number (double) c..
any jit.util.funck( function func, number index )
Gets a constant at a certain index in a function. This function isn't officially documented on LuJIT wiki, use it at your own risk.Numbers constants goes from 0 (included) to n-1, n being the value of nconsts in jit.util.funcinfo in other words, the consts goes from (nconsts-1) to -nThis function only works for Lua defined functions.
string jit.util.funcuvname( function func, number index )
Does the exact same thing as debug.getupvalue except it only returns the name, not the name and the object. The upvalue indexes also start at 0 rather than 1, so doing jit.util.funcuvname(func, 0) will get you the same name as debug.getupvalue(func, 1) This function isn't officially documented on LuJIT wiki, use it at your own risk.
number jit.util.ircalladdr( number index )
Gets the address of a function from a list of 20 functions, for the list see Ircalladdr Functions This function isn't officially documented on LuJIT wiki, use it at your own risk.
table jit.util.traceinfo( number trace )
Return table fields: link (number): the linked trace (0 for link types: none, return, interpreter) nk (number): the lowest IR constant (???) nins (number): the next IR instruction (???) linktype (string): the link type (none, root, loop, tail-recursion, up-recursion, down-recursion, interpreter, return) nexit (number): number of snapshots (for use with jit.util.tracesnap)
table jit.util.tracesnap( number tr, number sn )
Return table fields: 0 (ref) (number): first IR ref for the snapshot 1 (nslots) (number): the number of valid slots all indexes except first 2 and last (there might not be any of these): the snapshot map last index in table (number): -16777216 (255 << 24)