123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235 |
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
- <html>
- <head>
- <title>Running LuaJIT</title>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <meta name="Author" content="Mike Pall">
- <meta name="Copyright" content="Copyright (C) 2005-2010, Mike Pall">
- <meta name="Language" content="en">
- <link rel="stylesheet" type="text/css" href="bluequad.css" media="screen">
- <link rel="stylesheet" type="text/css" href="bluequad-print.css" media="print">
- <style type="text/css">
- table.opt {
- line-height: 1.2;
- }
- tr.opthead td {
- font-weight: bold;
- }
- td.flag_name {
- width: 4em;
- }
- td.flag_level {
- width: 2em;
- text-align: center;
- }
- td.param_name {
- width: 6em;
- }
- td.param_default {
- width: 4em;
- text-align: right;
- }
- </style>
- </head>
- <body>
- <div id="site">
- <a href="http://luajit.org"><span>Lua<span id="logo">JIT</span></span></a>
- </div>
- <div id="head">
- <h1>Running LuaJIT</h1>
- </div>
- <div id="nav">
- <ul><li>
- <a href="luajit.html">LuaJIT</a>
- <ul><li>
- <a href="install.html">Installation</a>
- </li><li>
- <a class="current" href="running.html">Running</a>
- </li><li>
- <a href="api.html">API Extensions</a>
- </li></ul>
- </li><li>
- <a href="status.html">Status</a>
- <ul><li>
- <a href="changes.html">Changes</a>
- </li></ul>
- </li><li>
- <a href="faq.html">FAQ</a>
- </li><li>
- <a href="http://luajit.org/download.html">Download <span class="ext">»</span></a>
- </li></ul>
- </div>
- <div id="main">
- <p>
- LuaJIT has only a single stand-alone executable, called <tt>luajit</tt> on
- POSIX systems or <tt>luajit.exe</tt> 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.
- </p>
- <p class="indent" style="color: #c00000;">
- Note: the beta test releases only install under the versioned name on
- POSIX systems (to avoid overwriting a previous version). You either need
- to type <tt>luajit-2.0.0-beta3</tt> to start it or create a symlink
- with a command like this:
- </p>
- <pre class="code" style="color: #c00000;">
- sudo ln -sf luajit-2.0.0-beta3 /usr/local/bin/luajit
- </pre>
- <p>
- Unlike previous versions <b>optimization is turned on by default</b> in
- LuaJIT 2.0!<br>It's no longer necessary to use <tt>luajit -O</tt>.
- </p>
- <h2 id="options">Command Line Options</h2>
- <p>
- The <tt>luajit</tt> stand-alone executable is just a slightly modified
- version of the regular <tt>lua</tt> stand-alone executable.
- It supports the same basic options, too. <tt>luajit -h</tt>
- prints a short list of the available options. Please have a look at the
- <a href="http://www.lua.org/manual/5.1/manual.html#6"><span class="ext">»</span> Lua manual</a>
- for details.
- </p>
- <p>
- Two additional options control the behavior of LuaJIT:
- </p>
- <h3 id="opt_j"><tt>-j cmd[=arg[,arg...]]</tt></h3>
- <p>
- This option performs a LuaJIT control command or activates one of the
- loadable extension modules. The command is first looked up in the
- <tt>jit.*</tt> library. If no matching function is found, a module
- named <tt>jit.<cmd></tt> is loaded and the <tt>start()</tt>
- function of the module is called with the specified arguments (if
- any). The space between <tt>-j</tt> and <tt>cmd</tt> is optional.
- </p>
- <p>
- Here are the available LuaJIT control commands:
- </p>
- <ul>
- <li id="j_on"><tt>-jon</tt> — Turns the JIT compiler on (default).</li>
- <li id="j_off"><tt>-joff</tt> — Turns the JIT compiler off (only use the interpreter).</li>
- <li id="j_flush"><tt>-jflush</tt> — Flushes the whole cache of compiled code.</li>
- <li id="j_v"><tt>-jv</tt> — Shows verbose information about the progress of the JIT compiler.</li>
- <li id="j_dump"><tt>-jdump</tt> — Dumps the code and structures used in various compiler stages.</li>
- </ul>
- <p>
- The <tt>-jv</tt> and <tt>-jdump</tt> 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 <tt>lib</tt> directory of the source
- distribution or installed under the <tt>jit</tt> directory. By default
- this is <tt>/usr/local/share/luajit-2.0.0-beta3/jit</tt> on POSIX
- systems.
- </p>
- <h3 id="opt_O"><tt>-O[level]</tt><br>
- <tt>-O[+]flag</tt> <tt>-O-flag</tt><br>
- <tt>-Oparam=value</tt></h3>
- <p>
- This options allows fine-tuned control of the optimizations used by
- the JIT compiler. This is mainly intended for debugging LuaJIT itself.
- Please note that the JIT compiler is extremely fast (we are talking
- about the microsecond to millisecond range). Disabling optimizations
- doesn't have any visible impact on its overhead, but usually generates
- code that runs slower.
- </p>
- <p>
- The first form sets an optimization level — this enables a
- specific mix of optimization flags. <tt>-O0</tt> turns off all
- optimizations and higher numbers enable more optimizations. Omitting
- the level (i.e. just <tt>-O</tt>) sets the default optimization level,
- which is <tt>-O3</tt> in the current version.
- </p>
- <p>
- The second form adds or removes individual optimization flags.
- The third form sets a parameter for the VM or the JIT compiler
- to a specific value.
- </p>
- <p>
- You can either use this option multiple times (like <tt>-Ocse
- -O-dce -Ohotloop=10</tt>) or separate several settings with a comma
- (like <tt>-O+cse,-dce,hotloop=10</tt>). The settings are applied from
- left to right and later settings override earlier ones. You can freely
- mix the three forms, but note that setting an optimization level
- overrides all earlier flags.
- </p>
- <p>
- Here are the available flags and at what optimization levels they
- are enabled:
- </p>
- <table class="opt">
- <tr class="opthead">
- <td class="flag_name">Flag</td>
- <td class="flag_level">-O1</td>
- <td class="flag_level">-O2</td>
- <td class="flag_level">-O3</td>
- <td class="flag_desc"> </td>
- </tr>
- <tr class="odd separate">
- <td class="flag_name">fold</td><td class="flag_level">•</td><td class="flag_level">•</td><td class="flag_level">•</td><td class="flag_desc">Constant Folding, Simplifications and Reassociation</td></tr>
- <tr class="even">
- <td class="flag_name">cse</td><td class="flag_level">•</td><td class="flag_level">•</td><td class="flag_level">•</td><td class="flag_desc">Common-Subexpression Elimination</td></tr>
- <tr class="odd">
- <td class="flag_name">dce</td><td class="flag_level">•</td><td class="flag_level">•</td><td class="flag_level">•</td><td class="flag_desc">Dead-Code Elimination</td></tr>
- <tr class="even">
- <td class="flag_name">narrow</td><td class="flag_level"> </td><td class="flag_level">•</td><td class="flag_level">•</td><td class="flag_desc">Narrowing of numbers to integers</td></tr>
- <tr class="odd">
- <td class="flag_name">loop</td><td class="flag_level"> </td><td class="flag_level">•</td><td class="flag_level">•</td><td class="flag_desc">Loop Optimizations (code hoisting)</td></tr>
- <tr class="even">
- <td class="flag_name">fwd</td><td class="flag_level"> </td><td class="flag_level"> </td><td class="flag_level">•</td><td class="flag_desc">Load Forwarding (L2L) and Store Forwarding (S2L)</td></tr>
- <tr class="odd">
- <td class="flag_name">dse</td><td class="flag_level"> </td><td class="flag_level"> </td><td class="flag_level">•</td><td class="flag_desc">Dead-Store Elimination</td></tr>
- <tr class="even">
- <td class="flag_name">fuse</td><td class="flag_level"> </td><td class="flag_level"> </td><td class="flag_level">•</td><td class="flag_desc">Fusion of operands into instructions</td></tr>
- </table>
- <p>
- Here are the parameters and their default settings:
- </p>
- <table class="opt">
- <tr class="opthead">
- <td class="param_name">Parameter</td>
- <td class="param_default">Default</td>
- <td class="param_desc"> </td>
- </tr>
- <tr class="odd separate">
- <td class="param_name">maxtrace</td><td class="param_default">1000</td><td class="param_desc">Max. number of traces in the cache</td></tr>
- <tr class="even">
- <td class="param_name">maxrecord</td><td class="param_default">2000</td><td class="param_desc">Max. number of recorded IR instructions</td></tr>
- <tr class="odd">
- <td class="param_name">maxirconst</td><td class="param_default">500</td><td class="param_desc">Max. number of IR constants of a trace</td></tr>
- <tr class="even">
- <td class="param_name">maxside</td><td class="param_default">100</td><td class="param_desc">Max. number of side traces of a root trace</td></tr>
- <tr class="odd">
- <td class="param_name">maxsnap</td><td class="param_default">100</td><td class="param_desc">Max. number of snapshots for a trace</td></tr>
- <tr class="even separate">
- <td class="param_name">hotloop</td><td class="param_default">56</td><td class="param_desc">Number of iterations to detect a hot loop or hot call</td></tr>
- <tr class="odd">
- <td class="param_name">hotexit</td><td class="param_default">10</td><td class="param_desc">Number of taken exits to start a side trace</td></tr>
- <tr class="even">
- <td class="param_name">tryside</td><td class="param_default">4</td><td class="param_desc">Number of attempts to compile a side trace</td></tr>
- <tr class="odd separate">
- <td class="param_name">instunroll</td><td class="param_default">4</td><td class="param_desc">Max. unroll factor for instable loops</td></tr>
- <tr class="even">
- <td class="param_name">loopunroll</td><td class="param_default">7</td><td class="param_desc">Max. unroll factor for loop ops in side traces</td></tr>
- <tr class="odd">
- <td class="param_name">callunroll</td><td class="param_default">3</td><td class="param_desc">Max. unroll factor for pseudo-recursive calls</td></tr>
- <tr class="even">
- <td class="param_name">recunroll</td><td class="param_default">2</td><td class="param_desc">Min. unroll factor for true recursion</td></tr>
- <tr class="odd separate">
- <td class="param_name">sizemcode</td><td class="param_default">32</td><td class="param_desc">Size of each machine code area in KBytes (Windows: 64K)</td></tr>
- <tr class="even">
- <td class="param_name">maxmcode</td><td class="param_default">512</td><td class="param_desc">Max. total size of all machine code areas in KBytes</td></tr>
- </table>
- <br class="flush">
- </div>
- <div id="foot">
- <hr class="hide">
- Copyright © 2005-2010 Mike Pall
- <span class="noprint">
- ·
- <a href="contact.html">Contact</a>
- </span>
- </div>
- </body>
- </html>
|