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>
<tableclass="opt">
<trclass="opthead">
<tdclass="flag_name">Flag</td>
<tdclass="flag_level">-O1</td>
<tdclass="flag_level">-O2</td>
<tdclass="flag_level">-O3</td>
<tdclass="flag_desc"> </td>
</tr>
<trclass="odd separate">
<tdclass="flag_name">fold</td><tdclass="flag_level">•</td><tdclass="flag_level">•</td><tdclass="flag_level">•</td><tdclass="flag_desc">Constant Folding, Simplifications and Reassociation</td></tr>
<tdclass="flag_name">narrow</td><tdclass="flag_level"> </td><tdclass="flag_level">•</td><tdclass="flag_level">•</td><tdclass="flag_desc">Narrowing of numbers to integers</td></tr>
<tdclass="flag_name">fwd</td><tdclass="flag_level"> </td><tdclass="flag_level"> </td><tdclass="flag_level">•</td><tdclass="flag_desc">Load Forwarding (L2L) and Store Forwarding (S2L)</td></tr>
<tdclass="flag_name">fuse</td><tdclass="flag_level"> </td><tdclass="flag_level"> </td><tdclass="flag_level">•</td><tdclass="flag_desc">Fusion of operands into instructions</td></tr>
</table>
<p>
Here are the parameters and their default settings:
</p>
<tableclass="opt">
<trclass="opthead">
<tdclass="param_name">Parameter</td>
<tdclass="param_default">Default</td>
<tdclass="param_desc"> </td>
</tr>
<trclass="odd separate">
<tdclass="param_name">maxtrace</td><tdclass="param_default">1000</td><tdclass="param_desc">Max. number of traces in the cache</td></tr>
<trclass="even">
<tdclass="param_name">maxrecord</td><tdclass="param_default">4000</td><tdclass="param_desc">Max. number of recorded IR instructions</td></tr>
<trclass="odd">
<tdclass="param_name">maxirconst</td><tdclass="param_default">500</td><tdclass="param_desc">Max. number of IR constants of a trace</td></tr>
<trclass="even">
<tdclass="param_name">maxside</td><tdclass="param_default">100</td><tdclass="param_desc">Max. number of side traces of a root trace</td></tr>
<trclass="odd">
<tdclass="param_name">maxsnap</td><tdclass="param_default">500</td><tdclass="param_desc">Max. number of snapshots for a trace</td></tr>
<trclass="even separate">
<tdclass="param_name">hotloop</td><tdclass="param_default">56</td><tdclass="param_desc">Number of iterations to detect a hot loop or hot call</td></tr>
<trclass="odd">
<tdclass="param_name">hotexit</td><tdclass="param_default">10</td><tdclass="param_desc">Number of taken exits to start a side trace</td></tr>
<trclass="even">
<tdclass="param_name">tryside</td><tdclass="param_default">4</td><tdclass="param_desc">Number of attempts to compile a side trace</td></tr>
<trclass="odd separate">
<tdclass="param_name">instunroll</td><tdclass="param_default">4</td><tdclass="param_desc">Max. unroll factor for instable loops</td></tr>
<trclass="even">
<tdclass="param_name">loopunroll</td><tdclass="param_default">15</td><tdclass="param_desc">Max. unroll factor for loop ops in side traces</td></tr>
<trclass="odd">
<tdclass="param_name">callunroll</td><tdclass="param_default">3</td><tdclass="param_desc">Max. unroll factor for pseudo-recursive calls</td></tr>
<trclass="even">
<tdclass="param_name">recunroll</td><tdclass="param_default">2</td><tdclass="param_desc">Min. unroll factor for true recursion</td></tr>
<trclass="odd separate">
<tdclass="param_name">sizemcode</td><tdclass="param_default">32</td><tdclass="param_desc">Size of each machine code area in KBytes (Windows: 64K)</td></tr>
<trclass="even">
<tdclass="param_name">maxmcode</td><tdclass="param_default">512</td><tdclass="param_desc">Max. total size of all machine code areas in KBytes</td></tr>