Running LuaJITLuaJIT has only a single stand-alone executable, called luajit on POSIX systems or luajit.exe on Windows. It can be used to run simple Lua statements or whole Lua applications from the command line. It has an interactive mode, too. Command Line OptionsThe luajit stand-alone executable is just a slightly modified version of the regular lua stand-alone executable. It supports the same basic options, too. luajit -h prints a short list of the available options. Please have a look at the Lua manual for details. LuaJIT has some additional options: -b[options] input outputThis option saves or lists bytecode. The following additional options are accepted:
The output file type is auto-detected from the extension of the output file name:
Notes:
Typical usage examples: luajit -b test.lua test.out # Save bytecode to test.out luajit -bg test.lua test.out # Keep debug info luajit -be "print('hello world')" test.out # Save cmdline script luajit -bl test.lua # List to stdout luajit -bl test.lua test.txt # List to test.txt luajit -ble "print('hello world')" # List cmdline script luajit -b test.lua test.obj # Generate object file # Link test.obj with your application and load it with require("test") -j cmd[=arg[,arg...]]This option performs a LuaJIT control command or activates one of the loadable extension modules. The command is first looked up in the jit.* library. If no matching function is found, a module named jit.<cmd> is loaded and the start() function of the module is called with the specified arguments (if any). The space between -j and cmd is optional. Here are the available LuaJIT control commands:
The -jv and -jdump commands are extension modules written in Lua. They are mainly used for debugging the JIT compiler itself. For a description of their options and output format, please read the comment block at the start of their source. They can be found in the lib directory of the source distribution or installed under the jit directory. By default this is /usr/local/share/luajit-2.0.2/jit on POSIX systems. -O[level]
|
Flag | -O1 | -O2 | -O3 | |
fold | ? | ? | ? | Constant Folding, Simplifications and Reassociation |
cse | ? | ? | ? | Common-Subexpression Elimination |
dce | ? | ? | ? | Dead-Code Elimination |
narrow | ? | ? | Narrowing of numbers to integers | |
loop | ? | ? | Loop Optimizations (code hoisting) | |
fwd | ? | Load Forwarding (L2L) and Store Forwarding (S2L) | ||
dse | ? | Dead-Store Elimination | ||
abc | ? | Array Bounds Check Elimination | ||
sink | ? | Allocation/Store Sinking | ||
fuse | ? | Fusion of operands into instructions |
Here are the parameters and their default settings:
Parameter | Default | |
maxtrace | 1000 | Max. number of traces in the cache |
maxrecord | 4000 | Max. number of recorded IR instructions |
maxirconst | 500 | Max. number of IR constants of a trace |
maxside | 100 | Max. number of side traces of a root trace |
maxsnap | 500 | Max. number of snapshots for a trace |
hotloop | 56 | Number of iterations to detect a hot loop or hot call |
hotexit | 10 | Number of taken exits to start a side trace |
tryside | 4 | Number of attempts to compile a side trace |
instunroll | 4 | Max. unroll factor for instable loops |
loopunroll | 15 | Max. unroll factor for loop ops in side traces |
callunroll | 3 | Max. unroll factor for pseudo-recursive calls |
recunroll | 2 | Min. unroll factor for true recursion |
sizemcode | 32 | Size of each machine code area in KBytes (Windows: 64K) |
maxmcode | 512 | Max. total size of all machine code areas in KBytes |
|