aboutsummaryrefslogtreecommitdiff
path: root/doc/ext_jit.html
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--doc/ext_jit.html177
1 files changed, 177 insertions, 0 deletions
diff --git a/doc/ext_jit.html b/doc/ext_jit.html
new file mode 100644
index 00000000..d621476b
--- /dev/null
+++ b/doc/ext_jit.html
@@ -0,0 +1,177 @@
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-2010, 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="install.html">Installation</a>
24</li><li>
25<a href="running.html">Running</a>
26</li></ul>
27</li><li>
28<a href="extensions.html">Extensions</a>
29<ul><li>
30<a class="current" href="ext_jit.html">jit.* Library</a>
31</li><li>
32<a href="ext_c_api.html">Lua/C API</a>
33</li></ul>
34</li><li>
35<a href="status.html">Status</a>
36<ul><li>
37<a href="changes.html">Changes</a>
38</li></ul>
39</li><li>
40<a href="faq.html">FAQ</a>
41</li><li>
42<a href="http://luajit.org/performance.html">Performance <span class="ext">&raquo;</span></a>
43</li><li>
44<a href="http://luajit.org/download.html">Download <span class="ext">&raquo;</span></a>
45</li></ul>
46</div>
47<div id="main">
48<p>
49The functions in this built-in module control the behavior
50of the JIT compiler engine.
51</p>
52
53<h3 id="jit_onoff"><tt>jit.on()<br>
54jit.off()</tt></h3>
55<p>
56Turns the whole JIT compiler on (default) or off.
57</p>
58<p>
59These functions are typically used with the command line options
60<tt>-j on</tt> or <tt>-j off</tt>.
61</p>
62
63<h3 id="jit_flush"><tt>jit.flush()</tt></h3>
64<p>
65Flushes the whole cache of compiled code.
66</p>
67
68<h3 id="jit_onoff_func"><tt>jit.on(func|true [,true|false])<br>
69jit.off(func|true [,true|false])<br>
70jit.flush(func|true [,true|false])</tt></h3>
71<p>
72<tt>jit.on</tt> enables JIT compilation for a Lua function (this is
73the default).
74</p>
75<p>
76<tt>jit.off</tt> disables JIT compilation for a Lua function and
77flushes any already compiled code from the code cache.
78</p>
79<p>
80<tt>jit.flush</tt> flushes the code, but doesn't affect the
81enable/disable status.
82</p>
83<p>
84The current function, i.e. the Lua function calling this library
85function, can also be specified by passing <tt>true</tt> as the first
86argument.
87</p>
88<p>
89If the second argument is <tt>true</tt>, JIT compilation is also
90enabled, disabled or flushed recursively for all sub-functions of a
91function. With <tt>false</tt> only the sub-functions are affected.
92</p>
93<p>
94The <tt>jit.on</tt> and <tt>jit.off</tt> functions only set a flag
95which is checked when the function is about to be compiled. They do
96not trigger immediate compilation.
97</p>
98<p>
99Typical usage is <tt>jit.off(true, true)</tt> in the main chunk
100of a module to turn off JIT compilation for the whole module for
101debugging purposes.
102</p>
103
104<h3 id="jit_flush_tr"><tt>jit.flush(tr)</tt></h3>
105<p>
106Flushes the specified root trace and all of its side traces from the cache.
107The code for the trace will be retained as long as there are any other
108traces which link to it.
109</p>
110
111<h3 id="jit_status"><tt>status, ... = jit.status()</tt></h3>
112<p>
113Returns the current status of the JIT compiler. The first result is
114either <tt>true</tt> or <tt>false</tt> if the JIT compiler is turned
115on or off. The remaining results are strings for CPU-specific features
116and enabled optimizations.
117</p>
118
119<h3 id="jit_version"><tt>jit.version</tt></h3>
120<p>
121Contains the LuaJIT version string.
122</p>
123
124<h3 id="jit_version_num"><tt>jit.version_num</tt></h3>
125<p>
126Contains the version number of the LuaJIT core. Version xx.yy.zz
127is represented by the decimal number xxyyzz.
128</p>
129
130<h3 id="jit_arch"><tt>jit.arch</tt></h3>
131<p>
132Contains the target architecture name (CPU and optional ABI).
133</p>
134
135<h2 id="jit_opt"><tt>jit.opt.*</tt> &mdash; JIT compiler optimization control</h2>
136<p>
137This sub-module provides the backend for the <tt>-O</tt> command line
138option.
139</p>
140<p>
141You can also use it programmatically, e.g.:
142</p>
143<pre class="code">
144jit.opt.start(2) -- same as -O2
145jit.opt.start("-dce")
146jit.opt.start("hotloop=10", "hotexit=2")
147</pre>
148<p>
149Unlike in LuaJIT 1.x, the module is built-in and
150<b>optimization is turned on by default!</b>
151It's no longer necessary to run <tt>require("jit.opt").start()</tt>,
152which was one of the ways to enable optimization.
153</p>
154
155<h2 id="jit_util"><tt>jit.util.*</tt> &mdash; JIT compiler introspection</h2>
156<p>
157This sub-module holds functions to introspect the bytecode, generated
158traces, the IR and the generated machine code. The functionality
159provided by this module is still in flux and therefore undocumented.
160</p>
161<p>
162The debug modules <tt>-jbc</tt>, <tt>-jv</tt> and <tt>-jdump</tt> make
163extensive use of these functions. Please check out their source code,
164if you want to know more.
165</p>
166<br class="flush">
167</div>
168<div id="foot">
169<hr class="hide">
170Copyright &copy; 2005-2010 Mike Pall
171<span class="noprint">
172&middot;
173<a href="contact.html">Contact</a>
174</span>
175</div>
176</body>
177</html>