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