dreamworkAPI
Ctrl K
GitHub
libraryDocs / jit

jit

librarysharedmenusource

The jit library is a standard Lua library which provides functions to manipulate the JIT compiler.

It's a wrapper for the native jit library from LuaJIT.

[SHARED AND MENU]

Sets the JIT compiler optimization flags and parameters.

It's an alias for jit.opt.start.

Flags: "-O0".."-O3", "+fold", "-dce", "+loop", "-abc", etc.

Parameters: "maxtrace=1000", "hotloop=56", "maxmcode=8192", etc.

View documents

Fields

NameTypeDescription
version_numberintegerThe version of the JIT compiler as a number, e.g. 20100 for 2.1.0, 0 if not available.
edgebooleantrue if the JIT compiler is an edge version (LuaJIT 2.1+), false otherwise. = false
version_byteintegerThe major version of the JIT compiler: 1 for LuaJIT 2.0, 2 for LuaJIT 2.1+, 0 if unknown. = 0
os"Windows" | "Linux" | "OSX" | "BSD" | "POSIX" | "Other" | "unknown" | stringThe target OS name, "unknown" if not available.
arch"x86" | "x64" | "arm" | "arm64" | "arm64be" | "ppc" | "ppc64" | "ppc64le" | "mips" | "mipsel" | "mips64" | "mips64el" | "unknown" | stringThe target architecture name, "unknown" if not available.
versionstring | "unknown"The full name of the JIT compiler version, e.g. "LuaJIT 2.1.0-beta3", "unknown" if not available.
optionsfun( ...: string )

Functions

jit.getfbcReturns the bytecode instruction at the given position of the given Lua function.
jit.getfconstReturns the constant at the given index of the given Lua function.
jit.getfinfoReturns the LuaJIT internal information about the given function.
jit.getfupvalueReturns the name of the upvalue at the given index of the given Lua function.
jit.isFFIChecks if the given function is a FFI function.
jit.options

#jit.getfbc

sharedmenunodiscardsource
function jit.getfbc(location: function | integer, position: integer): integer | nil, integer | nil

Returns the bytecode instruction at the given position of the given Lua function.

Returns nil if the position is out of range or the function is not a Lua function.

Parameters
NameTypeDescription
locationfunction | integerThe function or the stack level to get the main function from.
positionintegerThe bytecode position (program counter), starting from 0.
Returns
TypeNameDescription
integer | nilinsThe raw 32-bit bytecode instruction.
integer | nilmodeThe opcode mode flags of the instruction.

#jit.getfconst

sharedmenunodiscardsource
function jit.getfconst(location: function | integer, position: integer): any | nil

Returns the constant at the given index of the given Lua function.

Non-negative indices are for number constants, negative indices are for GC constants (strings, tables, child prototypes, etc.).

Returns nil if the index is out of range.

Parameters
NameTypeDescription
locationfunction | integerThe function or the stack level to get the main function from.
positionintegerThe index of the constant.
Returns
TypeNameDescription
any | nilvalueThe constant value.

#jit.getfinfo

sharedmenunodiscardsource
function jit.getfinfo(location: function | integer, position?: integer): jit.funcinfo.c | jit.funcinfo.lua

Returns the LuaJIT internal information about the given function.

For Lua functions returns jit.funcinfo.lua (lines, stack slots, params, bytecodes count, constants, source, etc.), if position is given, currentline and loc will be related to the bytecode at this position.

For C functions returns jit.funcinfo.c (address, upvalues count and ffid for builtin fast functions).

Parameters
NameTypeDescription
locationfunction | integerThe function or the stack level to get the main function from.
positionoptionalintegerThe bytecode position (program counter) inside the function.
Returns
TypeNameDescription
jit.funcinfo.c | jit.funcinfo.luainfoThe function information.

#jit.getfupvalue

sharedmenunodiscardsource
function jit.getfupvalue(location: function | integer, position: integer): string | nil

Returns the name of the upvalue at the given index of the given Lua function.

Returns nil if the index is out of range.

Parameters
NameTypeDescription
locationfunction | integerThe function or the stack level to get the main function from.
positionintegerThe index of the upvalue, starting from 0.
Returns
TypeNameDescription
string | nilnameThe name of the upvalue.

#jit.isFFI

sharedmenunodiscardsource
function jit.isFFI(fn: function): boolean

Checks if the given function is a FFI function.

Fallback, jit.util is not available, so any C function is treated as a fast function.

Parameters
NameTypeDescription
fnfunctionThe function to check.
Returns
TypeNameDescription
booleanis_ffitrue if the function is a FFI function, false otherwise.

#jit.options

function jit.options()

Alias of debug.fempty.

Generated from the dreamwork meta branch.