ljx

FORK: LuaJIT with native 5.2 and 5.3 support
git clone https://git.neptards.moe/neptards/ljx.git
Log | Files | Refs | README

ext_jit.html (5903B)


      1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
      2 <html>
      3 <head>
      4 <title>jit.* Library</title>
      5 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
      6 <meta name="Author" content="Mike Pall">
      7 <meta name="Copyright" content="Copyright (C) 2005-2016, Mike Pall">
      8 <meta name="Language" content="en">
      9 <link rel="stylesheet" type="text/css" href="bluequad.css" media="screen">
     10 <link rel="stylesheet" type="text/css" href="bluequad-print.css" media="print">
     11 </head>
     12 <body>
     13 <div id="site">
     14 <a href="http://luajit.org"><span>Lua<span id="logo">JIT</span></span></a>
     15 </div>
     16 <div id="head">
     17 <h1><tt>jit.*</tt> Library</h1>
     18 </div>
     19 <div id="nav">
     20 <ul><li>
     21 <a href="luajit.html">LuaJIT</a>
     22 <ul><li>
     23 <a href="http://luajit.org/download.html">Download <span class="ext">&raquo;</span></a>
     24 </li><li>
     25 <a href="install.html">Installation</a>
     26 </li><li>
     27 <a href="running.html">Running</a>
     28 </li></ul>
     29 </li><li>
     30 <a href="extensions.html">Extensions</a>
     31 <ul><li>
     32 <a href="ext_ffi.html">FFI Library</a>
     33 <ul><li>
     34 <a href="ext_ffi_tutorial.html">FFI Tutorial</a>
     35 </li><li>
     36 <a href="ext_ffi_api.html">ffi.* API</a>
     37 </li><li>
     38 <a href="ext_ffi_semantics.html">FFI Semantics</a>
     39 </li></ul>
     40 </li><li>
     41 <a class="current" href="ext_jit.html">jit.* Library</a>
     42 </li><li>
     43 <a href="ext_c_api.html">Lua/C API</a>
     44 </li><li>
     45 <a href="ext_profiler.html">Profiler</a>
     46 </li></ul>
     47 </li><li>
     48 <a href="status.html">Status</a>
     49 <ul><li>
     50 <a href="changes.html">Changes</a>
     51 </li></ul>
     52 </li><li>
     53 <a href="faq.html">FAQ</a>
     54 </li><li>
     55 <a href="http://luajit.org/performance.html">Performance <span class="ext">&raquo;</span></a>
     56 </li><li>
     57 <a href="http://wiki.luajit.org/">Wiki <span class="ext">&raquo;</span></a>
     58 </li><li>
     59 <a href="http://luajit.org/list.html">Mailing List <span class="ext">&raquo;</span></a>
     60 </li></ul>
     61 </div>
     62 <div id="main">
     63 <p>
     64 The functions in this built-in module control the behavior of the JIT
     65 compiler engine. Note that JIT-compilation is fully automatic &mdash;
     66 you probably won't need to use any of the following functions unless
     67 you have special needs.
     68 </p>
     69 
     70 <h3 id="jit_onoff"><tt>jit.on()<br>
     71 jit.off()</tt></h3>
     72 <p>
     73 Turns the whole JIT compiler on (default) or off.
     74 </p>
     75 <p>
     76 These functions are typically used with the command line options
     77 <tt>-j on</tt> or <tt>-j off</tt>.
     78 </p>
     79 
     80 <h3 id="jit_flush"><tt>jit.flush()</tt></h3>
     81 <p>
     82 Flushes the whole cache of compiled code.
     83 </p>
     84 
     85 <h3 id="jit_onoff_func"><tt>jit.on(func|true [,true|false])<br>
     86 jit.off(func|true [,true|false])<br>
     87 jit.flush(func|true [,true|false])</tt></h3>
     88 <p>
     89 <tt>jit.on</tt> enables JIT compilation for a Lua function (this is
     90 the default).
     91 </p>
     92 <p>
     93 <tt>jit.off</tt> disables JIT compilation for a Lua function and
     94 flushes any already compiled code from the code cache.
     95 </p>
     96 <p>
     97 <tt>jit.flush</tt> flushes the code, but doesn't affect the
     98 enable/disable status.
     99 </p>
    100 <p>
    101 The current function, i.e. the Lua function calling this library
    102 function, can also be specified by passing <tt>true</tt> as the first
    103 argument.
    104 </p>
    105 <p>
    106 If the second argument is <tt>true</tt>, JIT compilation is also
    107 enabled, disabled or flushed recursively for all sub-functions of a
    108 function. With <tt>false</tt> only the sub-functions are affected.
    109 </p>
    110 <p>
    111 The <tt>jit.on</tt> and <tt>jit.off</tt> functions only set a flag
    112 which is checked when the function is about to be compiled. They do
    113 not trigger immediate compilation.
    114 </p>
    115 <p>
    116 Typical usage is <tt>jit.off(true, true)</tt> in the main chunk
    117 of a module to turn off JIT compilation for the whole module for
    118 debugging purposes.
    119 </p>
    120 
    121 <h3 id="jit_flush_tr"><tt>jit.flush(tr)</tt></h3>
    122 <p>
    123 Flushes the root trace, specified by its number, and all of its side
    124 traces from the cache. The code for the trace will be retained as long
    125 as there are any other traces which link to it.
    126 </p>
    127 
    128 <h3 id="jit_status"><tt>status, ... = jit.status()</tt></h3>
    129 <p>
    130 Returns the current status of the JIT compiler. The first result is
    131 either <tt>true</tt> or <tt>false</tt> if the JIT compiler is turned
    132 on or off. The remaining results are strings for CPU-specific features
    133 and enabled optimizations.
    134 </p>
    135 
    136 <h3 id="jit_version"><tt>jit.version</tt></h3>
    137 <p>
    138 Contains the LuaJIT version string.
    139 </p>
    140 
    141 <h3 id="jit_version_num"><tt>jit.version_num</tt></h3>
    142 <p>
    143 Contains the version number of the LuaJIT core. Version xx.yy.zz
    144 is represented by the decimal number xxyyzz.
    145 </p>
    146 
    147 <h3 id="jit_os"><tt>jit.os</tt></h3>
    148 <p>
    149 Contains the target OS name:
    150 "Windows", "Linux", "OSX", "BSD", "POSIX" or "Other".
    151 </p>
    152 
    153 <h3 id="jit_arch"><tt>jit.arch</tt></h3>
    154 <p>
    155 Contains the target architecture name:
    156 "x86", "x64", "arm", "arm64", "ppc", "mips" or "mips64".
    157 </p>
    158 
    159 <h2 id="jit_opt"><tt>jit.opt.*</tt> &mdash; JIT compiler optimization control</h2>
    160 <p>
    161 This sub-module provides the backend for the <tt>-O</tt> command line
    162 option.
    163 </p>
    164 <p>
    165 You can also use it programmatically, e.g.:
    166 </p>
    167 <pre class="code">
    168 jit.opt.start(2) -- same as -O2
    169 jit.opt.start("-dce")
    170 jit.opt.start("hotloop=10", "hotexit=2")
    171 </pre>
    172 <p>
    173 Unlike in LuaJIT 1.x, the module is built-in and
    174 <b>optimization is turned on by default!</b>
    175 It's no longer necessary to run <tt>require("jit.opt").start()</tt>,
    176 which was one of the ways to enable optimization.
    177 </p>
    178 
    179 <h2 id="jit_util"><tt>jit.util.*</tt> &mdash; JIT compiler introspection</h2>
    180 <p>
    181 This sub-module holds functions to introspect the bytecode, generated
    182 traces, the IR and the generated machine code. The functionality
    183 provided by this module is still in flux and therefore undocumented.
    184 </p>
    185 <p>
    186 The debug modules <tt>-jbc</tt>, <tt>-jv</tt> and <tt>-jdump</tt> make
    187 extensive use of these functions. Please check out their source code,
    188 if you want to know more.
    189 </p>
    190 <br class="flush">
    191 </div>
    192 <div id="foot">
    193 <hr class="hide">
    194 Copyright &copy; 2005-2016 Mike Pall
    195 <span class="noprint">
    196 &middot;
    197 <a href="contact.html">Contact</a>
    198 </span>
    199 </div>
    200 </body>
    201 </html>