Module jit
Module jit

Module jit

Module jit

Overview

The jit module has functions for tracing the LuaJIT Just-In-Time compiler’s progress, showing the byte-code or assembler output that the compiler produces, and in general providing information about what LuaJIT does with Lua code.

Index

Below is a list of all jit functions.

Name Use
jit.bc.dump() Print the byte code of a function
jit.dis_x86.disass() Print the i386 assembler code of a string of bytes
jit.dis_x64.disass() Print the x86-64 assembler code of a string of bytes
jit.dump.on(), jit.dump.off() Print the intermediate or machine code of the following Lua code
jit.v.on(), jit.v.off() Print a trace of LuaJIT’s progress compiling and interpreting code
jit.bc.dump(function)

Prints the byte code of a function.

Example:

function f()
  print("D")
end
jit.bc.dump(f)

For a list of available options, read the source code of bc.lua.

jit.dis_x86.disass(string)

Prints the i386 assembler code of a string of bytes.

Example:

-- Disassemble hexadecimal 97 which is the x86 code for xchg eax, edi
jit.dis_x86.disass('\x97')

For a list of available options, read the source code of dis_x86.lua.

jit.dis_x64.disass(string)

Prints the x86-64 assembler code of a string of bytes.

Example:

-- Disassemble hexadecimal 97 which is the x86-64 code for xchg eax, edi
jit.dis_x64.disass('\x97')

For a list of available options, read the source code of dis_x64.lua.

jit.dump.on(option[, output file])
jit.dump.off()

Prints the intermediate or machine code of the following Lua code.

Example:

-- Show the machine code of a Lua "for" loop
jit.dump.on('m')
local x = 0;
for i = 1, 1e6 do
  x = x + i
end
print(x)
jit.dump.off()

For a list of available options, read the source code of dump.lua.

jit.v.on(option[, output file])
jit.v.off()

Prints a trace of LuaJIT’s progress compiling and interpreting code.

Example:

-- Show what LuaJIT is doing for a Lua "for" loop
jit.v.on()
local x = 0
for i = 1, 1e6 do
    x = x + i
end
print(x)
jit.v.off()

For a list of available options, read the source code of v.lua.