jit
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.
Fields
| Name | Type | Description |
|---|---|---|
version_number | integer | The version of the JIT compiler as a number, e.g. 20100 for 2.1.0, 0 if not available. |
edge | boolean | true if the JIT compiler is an edge version (LuaJIT 2.1+), false otherwise. = false |
version_byte | integer | The 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" | string | The target OS name, "unknown" if not available. |
arch | "x86" | "x64" | "arm" | "arm64" | "arm64be" | "ppc" | "ppc64" | "ppc64le" | "mips" | "mipsel" | "mips64" | "mips64el" | "unknown" | string | The target architecture name, "unknown" if not available. |
version | string | "unknown" | The full name of the JIT compiler version, e.g. "LuaJIT 2.1.0-beta3", "unknown" if not available. |
options | fun( ...: string ) |
Functions
jit.getfbc | Returns the bytecode instruction at the given position of the given Lua function. |
jit.getfconst | Returns the constant at the given index of the given Lua function. |
jit.getfinfo | Returns the LuaJIT internal information about the given function. |
jit.getfupvalue | Returns the name of the upvalue at the given index of the given Lua function. |
jit.isFFI | Checks if the given function is a FFI function. |
jit.options |
#jit.getfbc
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.
| Name | Type | Description |
|---|---|---|
location | function | integer | The function or the stack level to get the main function from. |
position | integer | The bytecode position (program counter), starting from 0. |
| Type | Name | Description |
|---|---|---|
integer | nil | ins | The raw 32-bit bytecode instruction. |
integer | nil | mode | The opcode mode flags of the instruction. |
#jit.getfconst
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.
| Name | Type | Description |
|---|---|---|
location | function | integer | The function or the stack level to get the main function from. |
position | integer | The index of the constant. |
| Type | Name | Description |
|---|---|---|
any | nil | value | The constant value. |
#jit.getfinfo
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).
| Name | Type | Description |
|---|---|---|
location | function | integer | The function or the stack level to get the main function from. |
positionoptional | integer | The bytecode position (program counter) inside the function. |
| Type | Name | Description |
|---|---|---|
jit.funcinfo.c | jit.funcinfo.lua | info | The function information. |
#jit.getfupvalue
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.
| Name | Type | Description |
|---|---|---|
location | function | integer | The function or the stack level to get the main function from. |
position | integer | The index of the upvalue, starting from 0. |
| Type | Name | Description |
|---|---|---|
string | nil | name | The name of the upvalue. |
#jit.isFFI
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.
| Name | Type | Description |
|---|---|---|
fn | function | The function to check. |
| Type | Name | Description |
|---|---|---|
boolean | is_ffi | true if the function is a FFI function, false otherwise. |
#jit.options
function jit.options()
Alias of debug.fempty.