aboutsummaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
Diffstat (limited to 'doc')
-rw-r--r--doc/changes.html2
-rw-r--r--doc/contact.html2
-rw-r--r--doc/ext_c_api.html2
-rw-r--r--doc/ext_ffi.html2
-rw-r--r--doc/ext_ffi_api.html2
-rw-r--r--doc/ext_ffi_semantics.html24
-rw-r--r--doc/ext_ffi_tutorial.html2
-rw-r--r--doc/ext_jit.html2
-rw-r--r--doc/ext_profiler.html365
-rw-r--r--doc/extensions.html35
-rw-r--r--doc/faq.html2
-rw-r--r--doc/install.html2
-rw-r--r--doc/luajit.html2
-rw-r--r--doc/running.html3
-rw-r--r--doc/status.html2
15 files changed, 445 insertions, 4 deletions
diff --git a/doc/changes.html b/doc/changes.html
index 98412293..6dbf26ba 100644
--- a/doc/changes.html
+++ b/doc/changes.html
@@ -44,6 +44,8 @@ div.major { max-width: 600px; padding: 1em; margin: 1em 0 1em 0; }
44<a href="ext_jit.html">jit.* Library</a> 44<a href="ext_jit.html">jit.* Library</a>
45</li><li> 45</li><li>
46<a href="ext_c_api.html">Lua/C API</a> 46<a href="ext_c_api.html">Lua/C API</a>
47</li><li>
48<a href="ext_profiler.html">Profiler</a>
47</li></ul> 49</li></ul>
48</li><li> 50</li><li>
49<a href="status.html">Status</a> 51<a href="status.html">Status</a>
diff --git a/doc/contact.html b/doc/contact.html
index 0483a829..8d19e7fb 100644
--- a/doc/contact.html
+++ b/doc/contact.html
@@ -41,6 +41,8 @@
41<a href="ext_jit.html">jit.* Library</a> 41<a href="ext_jit.html">jit.* Library</a>
42</li><li> 42</li><li>
43<a href="ext_c_api.html">Lua/C API</a> 43<a href="ext_c_api.html">Lua/C API</a>
44</li><li>
45<a href="ext_profiler.html">Profiler</a>
44</li></ul> 46</li></ul>
45</li><li> 47</li><li>
46<a href="status.html">Status</a> 48<a href="status.html">Status</a>
diff --git a/doc/ext_c_api.html b/doc/ext_c_api.html
index 48503361..a768e9d4 100644
--- a/doc/ext_c_api.html
+++ b/doc/ext_c_api.html
@@ -41,6 +41,8 @@
41<a href="ext_jit.html">jit.* Library</a> 41<a href="ext_jit.html">jit.* Library</a>
42</li><li> 42</li><li>
43<a class="current" href="ext_c_api.html">Lua/C API</a> 43<a class="current" href="ext_c_api.html">Lua/C API</a>
44</li><li>
45<a href="ext_profiler.html">Profiler</a>
44</li></ul> 46</li></ul>
45</li><li> 47</li><li>
46<a href="status.html">Status</a> 48<a href="status.html">Status</a>
diff --git a/doc/ext_ffi.html b/doc/ext_ffi.html
index fa9ca971..c044d28d 100644
--- a/doc/ext_ffi.html
+++ b/doc/ext_ffi.html
@@ -41,6 +41,8 @@
41<a href="ext_jit.html">jit.* Library</a> 41<a href="ext_jit.html">jit.* Library</a>
42</li><li> 42</li><li>
43<a href="ext_c_api.html">Lua/C API</a> 43<a href="ext_c_api.html">Lua/C API</a>
44</li><li>
45<a href="ext_profiler.html">Profiler</a>
44</li></ul> 46</li></ul>
45</li><li> 47</li><li>
46<a href="status.html">Status</a> 48<a href="status.html">Status</a>
diff --git a/doc/ext_ffi_api.html b/doc/ext_ffi_api.html
index dcffcfa3..6e9b4a30 100644
--- a/doc/ext_ffi_api.html
+++ b/doc/ext_ffi_api.html
@@ -46,6 +46,8 @@ td.abiparam { font-weight: bold; width: 6em; }
46<a href="ext_jit.html">jit.* Library</a> 46<a href="ext_jit.html">jit.* Library</a>
47</li><li> 47</li><li>
48<a href="ext_c_api.html">Lua/C API</a> 48<a href="ext_c_api.html">Lua/C API</a>
49</li><li>
50<a href="ext_profiler.html">Profiler</a>
49</li></ul> 51</li></ul>
50</li><li> 52</li><li>
51<a href="status.html">Status</a> 53<a href="status.html">Status</a>
diff --git a/doc/ext_ffi_semantics.html b/doc/ext_ffi_semantics.html
index 7e5f7035..d7e8c869 100644
--- a/doc/ext_ffi_semantics.html
+++ b/doc/ext_ffi_semantics.html
@@ -46,6 +46,8 @@ td.convop { font-style: italic; width: 40%; }
46<a href="ext_jit.html">jit.* Library</a> 46<a href="ext_jit.html">jit.* Library</a>
47</li><li> 47</li><li>
48<a href="ext_c_api.html">Lua/C API</a> 48<a href="ext_c_api.html">Lua/C API</a>
49</li><li>
50<a href="ext_profiler.html">Profiler</a>
49</li></ul> 51</li></ul>
50</li><li> 52</li><li>
51<a href="status.html">Status</a> 53<a href="status.html">Status</a>
@@ -730,6 +732,22 @@ You'll have to explicitly convert a 64&nbsp;bit integer to a Lua
730number (e.g. for regular floating-point calculations) with 732number (e.g. for regular floating-point calculations) with
731<tt>tonumber()</tt>. But note this may incur a precision loss.</li> 733<tt>tonumber()</tt>. But note this may incur a precision loss.</li>
732 734
735<li><b>64&nbsp;bit bitwise operations</b>: the rules for 64&nbsp;bit
736arithmetic operators apply analogously.<br>
737
738Unlike the other <tt>bit.*</tt> operations, <tt>bit.tobit()</tt>
739converts a cdata number via <tt>int64_t</tt> to <tt>int32_t</tt> and
740returns a Lua number.<br>
741
742For <tt>bit.band()</tt>, <tt>bit.bor()</tt> and <tt>bit.bxor()</tt>, the
743conversion to <tt>int64_t</tt> or <tt>uint64_t</tt> applies to
744<em>all</em> arguments, if <em>any</em> argument is a cdata number.<br>
745
746For all other operations, only the first argument is used to determine
747the output type. This implies that a cdata number as a shift count for
748shifts and rotates is accepted, but that alone does <em>not</em> cause
749a cdata number output.
750
733</ul> 751</ul>
734 752
735<h3 id="cdata_comp">Comparisons of cdata objects</h3> 753<h3 id="cdata_comp">Comparisons of cdata objects</h3>
@@ -1205,9 +1223,8 @@ suboptimal performance, especially when used in inner loops:
1205<li>Vector operations.</li> 1223<li>Vector operations.</li>
1206<li>Table initializers.</li> 1224<li>Table initializers.</li>
1207<li>Initialization of nested <tt>struct</tt>/<tt>union</tt> types.</li> 1225<li>Initialization of nested <tt>struct</tt>/<tt>union</tt> types.</li>
1208<li>Allocations of variable-length arrays or structs.</li> 1226<li>Non-default initialization of VLA/VLS or large C&nbsp;types
1209<li>Allocations of C&nbsp;types with a size &gt; 128&nbsp;bytes or an 1227(&gt; 128&nbsp;bytes or &gt; 16 array elements.</li>
1210alignment &gt; 8&nbsp;bytes.</li>
1211<li>Conversions from lightuserdata to <tt>void&nbsp;*</tt>.</li> 1228<li>Conversions from lightuserdata to <tt>void&nbsp;*</tt>.</li>
1212<li>Pointer differences for element sizes that are not a power of 1229<li>Pointer differences for element sizes that are not a power of
1213two.</li> 1230two.</li>
@@ -1224,7 +1241,6 @@ value.</li>
1224Other missing features: 1241Other missing features:
1225</p> 1242</p>
1226<ul> 1243<ul>
1227<li>Bit operations for 64&nbsp;bit types.</li>
1228<li>Arithmetic for <tt>complex</tt> numbers.</li> 1244<li>Arithmetic for <tt>complex</tt> numbers.</li>
1229<li>Passing structs by value to vararg C&nbsp;functions.</li> 1245<li>Passing structs by value to vararg C&nbsp;functions.</li>
1230<li><a href="extensions.html#exceptions">C++ exception interoperability</a> 1246<li><a href="extensions.html#exceptions">C++ exception interoperability</a>
diff --git a/doc/ext_ffi_tutorial.html b/doc/ext_ffi_tutorial.html
index 01fb8992..f98c8de3 100644
--- a/doc/ext_ffi_tutorial.html
+++ b/doc/ext_ffi_tutorial.html
@@ -48,6 +48,8 @@ td.idiomlua b { font-weight: normal; color: #2142bf; }
48<a href="ext_jit.html">jit.* Library</a> 48<a href="ext_jit.html">jit.* Library</a>
49</li><li> 49</li><li>
50<a href="ext_c_api.html">Lua/C API</a> 50<a href="ext_c_api.html">Lua/C API</a>
51</li><li>
52<a href="ext_profiler.html">Profiler</a>
51</li></ul> 53</li></ul>
52</li><li> 54</li><li>
53<a href="status.html">Status</a> 55<a href="status.html">Status</a>
diff --git a/doc/ext_jit.html b/doc/ext_jit.html
index 098be5e0..fb4d434b 100644
--- a/doc/ext_jit.html
+++ b/doc/ext_jit.html
@@ -41,6 +41,8 @@
41<a class="current" href="ext_jit.html">jit.* Library</a> 41<a class="current" href="ext_jit.html">jit.* Library</a>
42</li><li> 42</li><li>
43<a href="ext_c_api.html">Lua/C API</a> 43<a href="ext_c_api.html">Lua/C API</a>
44</li><li>
45<a href="ext_profiler.html">Profiler</a>
44</li></ul> 46</li></ul>
45</li><li> 47</li><li>
46<a href="status.html">Status</a> 48<a href="status.html">Status</a>
diff --git a/doc/ext_profiler.html b/doc/ext_profiler.html
new file mode 100644
index 00000000..3b00fc53
--- /dev/null
+++ b/doc/ext_profiler.html
@@ -0,0 +1,365 @@
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2<html>
3<head>
4<title>Profiler</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-2014, 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>Profiler</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 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 class="current" 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>
64LuaJIT has an integrated statistical profiler with very low overhead. It
65allows sampling the currently executing stack and other parameters in
66regular intervals.
67</p>
68<p>
69The integrated profiler can be accessed from three levels:
70</p>
71<ul>
72<li>The <a href="#hl_profiler">bundled high-level profiler</a>, invoked by the
73<a href="#j_p"><tt>-jp</tt></a> command line option.</li>
74<li>A <a href="#ll_lua_api">low-level Lua API</a> to control the profiler.</li>
75<li>A <a href="#ll_c_api">low-level C API</a> to control the profiler.</li>
76</ul>
77
78<h2 id="hl_profiler">High-Level Profiler</h2>
79<p>
80The bundled high-level profiler offers basic profiling functionality. It
81generates simple textual summaries or source code annotations. It can be
82accessed with the <a href="#j_p"><tt>-jp</tt></a> command line option
83or from Lua code by loading the underlying <tt>jit.p</tt> module.
84</p>
85<p>
86To cut to the chase &mdash; run this to get a CPU usage profile by
87function name:
88</p>
89<pre class="code">
90luajit -jp myapp.lua
91</pre>
92<p>
93It's <em>not</em> a stated goal of the bundled profiler to add every
94possible option or to cater for special profiling needs. The low-level
95profiler APIs are documented below. They may be used by third-party
96authors to implement advanced functionality, e.g. IDE integration or
97graphical profilers.
98</p>
99<p>
100Note: Sampling works for both interpreted and JIT-compiled code. The
101results for JIT-compiled code may sometimes be surprising. LuaJIT
102heavily optimizes and inlines Lua code &mdash; there's no simple
103one-to-one correspondence between source code lines and the sampled
104machine code.
105</p>
106
107<h3 id="j_p"><tt>-jp=[options[,output]]</tt></h3>
108<p>
109The <tt>-jp</tt> command line option starts the high-level profiler.
110When the application run by the command line terminates, the profiler
111stops and writes the results to <tt>stdout</tt> or to the specified
112<tt>output</tt> file.
113</p>
114<p>
115The <tt>options</tt> argument specifies how the profiling is to be
116performed:
117</p>
118<ul>
119<li><tt>f</tt> &mdash; Stack dump: function name, otherwise module:line.
120This is the default mode.</li>
121<li><tt>F</tt> &mdash; Stack dump: ditto, but dump module:name.</li>
122<li><tt>l</tt> &mdash; Stack dump: module:line.</li>
123<li><tt>&lt;number&gt;</tt> &mdash; stack dump depth (callee &larr;
124caller). Default: 1.</li>
125<li><tt>-&lt;number&gt;</tt> &mdash; Inverse stack dump depth (caller
126&rarr; callee).</li>
127<li><tt>s</tt> &mdash; Split stack dump after first stack level. Implies
128depth&nbsp;&ge;&nbsp;2 or depth&nbsp;&le;&nbsp;-2.</li>
129<li><tt>p</tt> &mdash; Show full path for module names.</li>
130<li><tt>v</tt> &mdash; Show VM states.</li>
131<li><tt>z</tt> &mdash; Show <a href="#jit_zone">zones</a>.</li>
132<li><tt>r</tt> &mdash; Show raw sample counts. Default: show percentages.</li>
133<li><tt>a</tt> &mdash; Annotate excerpts from source code files.</li>
134<li><tt>A</tt> &mdash; Annotate complete source code files.</li>
135<li><tt>G</tt> &mdash; Produce raw output suitable for graphical tools.</li>
136<li><tt>m&lt;number&gt;</tt> &mdash; Minimum sample percentage to be shown.
137Default: 3%.</li>
138<li><tt>i&lt;number&gt;</tt> &mdash; Sampling interval in milliseconds.
139Default: 10ms.<br>
140Note: The actual sampling precision is OS-dependent.</li>
141</ul>
142<p>
143The default output for <tt>-jp</tt> is a list of the most CPU consuming
144spots in the application. Increasing the stack dump depth with (say)
145<tt>-jp=2</tt> may help to point out the main callers or callees of
146hotspots. But sample aggregation is still flat per unique stack dump.
147</p>
148<p>
149To get a two-level view (split view) of callers/callees, use
150<tt>-jp=s</tt> or <tt>-jp=-s</tt>. The percentages shown for the second
151level are relative to the first level.
152</p>
153<p>
154To see how much time is spent in each line relative to a function, use
155<tt>-jp=fl</tt>.
156</p>
157<p>
158To see how much time is spent in different VM states or
159<a href="#jit_zone">zones</a>, use <tt>-jp=v</tt> or <tt>-jp=z</tt>.
160</p>
161<p>
162Combinations of <tt>v/z</tt> with <tt>f/F/l</tt> produce two-level
163views, e.g. <tt>-jp=vf</tt> or <tt>-jp=fv</tt>. This shows the time
164spent in a VM state or zone vs. hotspots. This can be used to answer
165questions like "Which time consuming functions are only interpreted?" or
166"What's the garbage collector overhead for a specific function?".
167</p>
168<p>
169Multiple options can be combined &mdash; but not all combinations make
170sense, see above. E.g. <tt>-jp=3si4m1</tt> samples three stack levels
171deep in 4ms intervals and shows a split view of the CPU consuming
172functions and their callers with a 1% threshold.
173</p>
174<p>
175Source code annotations produced by <tt>-jp=a</tt> or <tt>-jp=A</tt> are
176always flat and at the line level. Obviously, the source code files need
177to be readable by the profiler script.
178</p>
179<p>
180The high-level profiler can also be started and stopped from Lua code with:
181</p>
182<pre class="code">
183require("jit.p").start(options, output)
184...
185require("jit.p").stop()
186</pre>
187
188<h3 id="jit_zone"><tt>jit.zone</tt> &mdash; Zones</h3>
189<p>
190Zones can be used to provide information about different parts of an
191application to the high-level profiler. E.g. a game could make use of an
192<tt>"AI"</tt> zone, a <tt>"PHYS"</tt> zone, etc. Zones are hierarchical,
193organized as a stack.
194</p>
195<p>
196The <tt>jit.zone</tt> module needs to be loaded explicitly:
197</p>
198<pre class="code">
199local zone = require("jit.zone")
200</pre>
201<ul>
202<li><tt>zone("name")</tt> pushes a named zone to the zone stack.</li>
203<li><tt>zone()</tt> pops the current zone from the zone stack and
204returns its name.</li>
205<li><tt>zone:get()</tt> returns the current zone name or <tt>nil</tt>.</li>
206<li><tt>zone:flush()</tt> flushes the zone stack.</li>
207</ul>
208<p>
209To show the time spent in each zone use <tt>-jp=z</tt>. To show the time
210spent relative to hotspots use e.g. <tt>-jp=zf</tt> or <tt>-jp=fz</tt>.
211</p>
212
213<h2 id="ll_lua_api">Low-level Lua API</h2>
214<p>
215The <tt>jit.profile</tt> module gives access to the low-level API of the
216profiler from Lua code. This module needs to be loaded explicitly:
217<pre class="code">
218local profile = require("jit.profile")
219</pre>
220<p>
221This module can be used to implement your own higher-level profiler.
222A typical profiling run starts the profiler, captures stack dumps in
223the profiler callback, adds them to a hash table to aggregate the number
224of samples, stops the profiler and then analyzes all of the captured
225stack dumps. Other parameters can be sampled in the profiler callback,
226too. But it's important not to spend too much time in the callback,
227since this may skew the statistics.
228</p>
229
230<h3 id="profile_start"><tt>profile.start(mode, cb)</tt>
231&mdash; Start profiler</h3>
232<p>
233This function starts the profiler. The <tt>mode</tt> argument is a
234string holding options:
235</p>
236<ul>
237<li><tt>f</tt> &mdash; Profile with precision down to the function level.</li>
238<li><tt>l</tt> &mdash; Profile with precision down to the line level.</li>
239<li><tt>i&lt;number&gt;</tt> &mdash; Sampling interval in milliseconds (default
24010ms).</br>
241Note: The actual sampling precision is OS-dependent.
242</li>
243</ul>
244<p>
245The <tt>cb</tt> argument is a callback function which is called with
246three arguments: <tt>(thread, samples, vmstate)</tt>. The callback is
247called on a separate coroutine, the <tt>thread</tt> argument is the
248state that holds the stack to sample for profiling. Note: do
249<em>not</em> modify the stack of that state or call functions on it.
250</p>
251<p>
252<tt>samples</tt> gives the number of accumulated samples since the last
253callback (usually 1).
254</p>
255<p>
256<tt>vmstate</tt> holds the VM state at the time the profiling timer
257triggered. This may or may not correspond to the state of the VM when
258the profiling callback is called. The state is either <tt>'N'</tt>
259native (compiled) code, <tt>'I'</tt> interpreted code, <tt>'C'</tt>
260C&nbsp;code, <tt>'G'</tt> the garbage collector, or <tt>'J'</tt> the JIT
261compiler.
262</p>
263
264<h3 id="profile_stop"><tt>profile.stop()</tt>
265&mdash; Stop profiler</h3>
266<p>
267This function stops the profiler.
268</p>
269
270<h3 id="profile_dump"><tt>dump = profile.dumpstack([thread,] fmt, depth)</tt>
271&mdash; Dump stack </h3>
272<p>
273This function allows taking stack dumps in an efficient manner. It
274returns a string with a stack dump for the <tt>thread</tt> (coroutine),
275formatted according to the <tt>fmt</tt> argument:
276</p>
277<ul>
278<li><tt>p</tt> &mdash; Preserve the full path for module names. Otherwise
279only the file name is used.</li>
280<li><tt>f</tt> &mdash; Dump the function name if it can be derived. Otherwise
281use module:line.</li>
282<li><tt>F</tt> &mdash; Ditto, but dump module:name.</li>
283<li><tt>l</tt> &mdash; Dump module:line.</li>
284<li><tt>Z</tt> &mdash; Zap the following characters for the last dumped
285frame.</li>
286<li>All other characters are added verbatim to the output string.</li>
287</ul>
288<p>
289The <tt>depth</tt> argument gives the number of frames to dump, starting
290at the topmost frame of the thread. A negative number dumps the frames in
291inverse order.
292</p>
293<p>
294The first example prints a list of the current module names and line
295numbers of up to 10 frames in separate lines. The second example prints
296semicolon-separated function names for all frames (up to 100) in inverse
297order:
298</p>
299<pre class="code">
300print(profile.dumpstack(thread, "l\n", 10))
301print(profile.dumpstack(thread, "lZ;", -100))
302</pre>
303
304<h2 id="ll_c_api">Low-level C API</h2>
305<p>
306The profiler can be controlled directly from C&nbsp;code, e.g. for
307use by IDEs. The declarations are in <tt>"luajit.h"</tt> (see
308<a href="ext_c_api.html">Lua/C API</a> extensions).
309</p>
310
311<h3 id="luaJIT_profile_start"><tt>luaJIT_profile_start(L, mode, cb, data)</tt>
312&mdash; Start profiler</h3>
313<p>
314This function starts the profiler. <a href="#profile_start">See
315above</a> for a description of the <tt>mode</tt> argument.
316</p>
317<p>
318The <tt>cb</tt> argument is a callback function with the following
319declaration:
320</p>
321<pre class="code">
322typedef void (*luaJIT_profile_callback)(void *data, lua_State *L,
323 int samples, int vmstate);
324</pre>
325<p>
326<tt>data</tt> is available for use by the callback. <tt>L</tt> is the
327state that holds the stack to sample for profiling. Note: do
328<em>not</em> modify this stack or call functions on this stack &mdash;
329use a separate coroutine for this purpose. <a href="#profile_start">See
330above</a> for a description of <tt>samples</tt> and <tt>vmstate</tt>.
331</p>
332
333<h3 id="luaJIT_profile_stop"><tt>luaJIT_profile_stop(L)</tt>
334&mdash; Stop profiler</h3>
335<p>
336This function stops the profiler.
337</p>
338
339<h3 id="luaJIT_profile_dumpstack"><tt>p = luaJIT_profile_dumpstack(L, fmt, depth, len)</tt>
340&mdash; Dump stack </h3>
341<p>
342This function allows taking stack dumps in an efficient manner.
343<a href="#profile_dump">See above</a> for a description of <tt>fmt</tt>
344and <tt>depth</tt>.
345</p>
346<p>
347This function returns a <tt>const&nbsp;char&nbsp;*</tt> pointing to a
348private string buffer of the profiler. The <tt>int&nbsp;*len</tt>
349argument returns the length of the output string. The buffer is
350overwritten on the next call and deallocated when the profiler stops.
351You either need to consume the content immediately or copy it for later
352use.
353</p>
354<br class="flush">
355</div>
356<div id="foot">
357<hr class="hide">
358Copyright &copy; 2005-2014 Mike Pall
359<span class="noprint">
360&middot;
361<a href="contact.html">Contact</a>
362</span>
363</div>
364</body>
365</html>
diff --git a/doc/extensions.html b/doc/extensions.html
index 20b597f1..172334ad 100644
--- a/doc/extensions.html
+++ b/doc/extensions.html
@@ -58,6 +58,8 @@ td.excinterop {
58<a href="ext_jit.html">jit.* Library</a> 58<a href="ext_jit.html">jit.* Library</a>
59</li><li> 59</li><li>
60<a href="ext_c_api.html">Lua/C API</a> 60<a href="ext_c_api.html">Lua/C API</a>
61</li><li>
62<a href="ext_profiler.html">Profiler</a>
61</li></ul> 63</li></ul>
62</li><li> 64</li><li>
63<a href="status.html">Status</a> 65<a href="status.html">Status</a>
@@ -113,6 +115,9 @@ bit.lshift bit.rshift bit.arshift bit.rol bit.ror bit.bswap
113This module is a LuaJIT built-in &mdash; you don't need to download or 115This module is a LuaJIT built-in &mdash; you don't need to download or
114install Lua BitOp. The Lua BitOp site has full documentation for all 116install Lua BitOp. The Lua BitOp site has full documentation for all
115<a href="http://bitop.luajit.org/api.html"><span class="ext">&raquo;</span>&nbsp;Lua BitOp API functions</a>. 117<a href="http://bitop.luajit.org/api.html"><span class="ext">&raquo;</span>&nbsp;Lua BitOp API functions</a>.
118The FFI adds support for
119<a href="ext_ffi_semantics.html#cdata_arith">64&nbsp;bit bitwise operations</a>,
120using the same API functions.
116</p> 121</p>
117<p> 122<p>
118Please make sure to <tt>require</tt> the module before using any of 123Please make sure to <tt>require</tt> the module before using any of
@@ -146,6 +151,11 @@ LuaJIT adds some
146<a href="ext_c_api.html">extra functions to the Lua/C API</a>. 151<a href="ext_c_api.html">extra functions to the Lua/C API</a>.
147</p> 152</p>
148 153
154<h3 id="profiler">Profiler</h3>
155<p>
156LuaJIT has an <a href="ext_profiler.html">integrated profiler</a>.
157</p>
158
149<h2 id="library">Enhanced Standard Library Functions</h2> 159<h2 id="library">Enhanced Standard Library Functions</h2>
150 160
151<h3 id="xpcall"><tt>xpcall(f, err [,args...])</tt> passes arguments</h3> 161<h3 id="xpcall"><tt>xpcall(f, err [,args...])</tt> passes arguments</h3>
@@ -198,6 +208,31 @@ minor releases (2.0 &rarr; 2.1) or between any beta release. Foreign
198bytecode (e.g. from Lua 5.1) is incompatible and cannot be loaded. 208bytecode (e.g. from Lua 5.1) is incompatible and cannot be loaded.
199</p> 209</p>
200 210
211<h3 id="table_new"><tt>table.new(narray, nhash)</tt> allocates a pre-sized table</h3>
212<p>
213An extra library function <tt>table.new()</tt> can be made available via
214<tt>require("table.new")</tt>. This creates a pre-sized table, just like
215the C API equivalent <tt>lua_createtable()</tt>. This is useful for big
216tables if the final table size is known and automatic table resizing is
217too expensive.
218</p>
219
220<h3 id="table_clear"><tt>table.clear(tab)</tt> clears a table</h3>
221<p>
222An extra library function <tt>table.clear()</tt> can be made available
223via <tt>require("table.clear")</tt>. This clears all keys and values
224from a table, but preserves the allocated array/hash sizes. This is
225useful when a table, which is linked from multiple places, needs to be
226cleared and/or when recycling a table for use by the same context. This
227avoids managing backlinks, saves an allocation and the overhead of
228incremental array/hash part growth.
229</p>
230<p>
231Please note this function is meant for very specific situations. In most
232cases it's better to replace the (usually single) link with a new table
233and let the GC do its work.
234</p>
235
201<h3 id="math_random">Enhanced PRNG for <tt>math.random()</tt></h3> 236<h3 id="math_random">Enhanced PRNG for <tt>math.random()</tt></h3>
202<p> 237<p>
203LuaJIT uses a Tausworthe PRNG with period 2^223 to implement 238LuaJIT uses a Tausworthe PRNG with period 2^223 to implement
diff --git a/doc/faq.html b/doc/faq.html
index ffc2ae89..a95d23d5 100644
--- a/doc/faq.html
+++ b/doc/faq.html
@@ -44,6 +44,8 @@ dd { margin-left: 1.5em; }
44<a href="ext_jit.html">jit.* Library</a> 44<a href="ext_jit.html">jit.* Library</a>
45</li><li> 45</li><li>
46<a href="ext_c_api.html">Lua/C API</a> 46<a href="ext_c_api.html">Lua/C API</a>
47</li><li>
48<a href="ext_profiler.html">Profiler</a>
47</li></ul> 49</li></ul>
48</li><li> 50</li><li>
49<a href="status.html">Status</a> 51<a href="status.html">Status</a>
diff --git a/doc/install.html b/doc/install.html
index 2388ff33..bff8d280 100644
--- a/doc/install.html
+++ b/doc/install.html
@@ -69,6 +69,8 @@ td.compatno {
69<a href="ext_jit.html">jit.* Library</a> 69<a href="ext_jit.html">jit.* Library</a>
70</li><li> 70</li><li>
71<a href="ext_c_api.html">Lua/C API</a> 71<a href="ext_c_api.html">Lua/C API</a>
72</li><li>
73<a href="ext_profiler.html">Profiler</a>
72</li></ul> 74</li></ul>
73</li><li> 75</li><li>
74<a href="status.html">Status</a> 76<a href="status.html">Status</a>
diff --git a/doc/luajit.html b/doc/luajit.html
index 43af69c9..15c5f12e 100644
--- a/doc/luajit.html
+++ b/doc/luajit.html
@@ -123,6 +123,8 @@ table.feature small {
123<a href="ext_jit.html">jit.* Library</a> 123<a href="ext_jit.html">jit.* Library</a>
124</li><li> 124</li><li>
125<a href="ext_c_api.html">Lua/C API</a> 125<a href="ext_c_api.html">Lua/C API</a>
126</li><li>
127<a href="ext_profiler.html">Profiler</a>
126</li></ul> 128</li></ul>
127</li><li> 129</li><li>
128<a href="status.html">Status</a> 130<a href="status.html">Status</a>
diff --git a/doc/running.html b/doc/running.html
index c01c52d5..08a8f079 100644
--- a/doc/running.html
+++ b/doc/running.html
@@ -63,6 +63,8 @@ td.param_default {
63<a href="ext_jit.html">jit.* Library</a> 63<a href="ext_jit.html">jit.* Library</a>
64</li><li> 64</li><li>
65<a href="ext_c_api.html">Lua/C API</a> 65<a href="ext_c_api.html">Lua/C API</a>
66</li><li>
67<a href="ext_profiler.html">Profiler</a>
66</li></ul> 68</li></ul>
67</li><li> 69</li><li>
68<a href="status.html">Status</a> 70<a href="status.html">Status</a>
@@ -178,6 +180,7 @@ Here are the available LuaJIT control commands:
178<li id="j_flush"><tt>-jflush</tt> &mdash; Flushes the whole cache of compiled code.</li> 180<li id="j_flush"><tt>-jflush</tt> &mdash; Flushes the whole cache of compiled code.</li>
179<li id="j_v"><tt>-jv</tt> &mdash; Shows verbose information about the progress of the JIT compiler.</li> 181<li id="j_v"><tt>-jv</tt> &mdash; Shows verbose information about the progress of the JIT compiler.</li>
180<li id="j_dump"><tt>-jdump</tt> &mdash; Dumps the code and structures used in various compiler stages.</li> 182<li id="j_dump"><tt>-jdump</tt> &mdash; Dumps the code and structures used in various compiler stages.</li>
183<li id="j_p"><tt>-jp</tt> &mdash; Start the <a href="ext_profiler.html">integrated profiler</a>.</li>
181</ul> 184</ul>
182<p> 185<p>
183The <tt>-jv</tt> and <tt>-jdump</tt> commands are extension modules 186The <tt>-jv</tt> and <tt>-jdump</tt> commands are extension modules
diff --git a/doc/status.html b/doc/status.html
index ddcaed33..50d217a7 100644
--- a/doc/status.html
+++ b/doc/status.html
@@ -44,6 +44,8 @@ ul li { padding-bottom: 0.3em; }
44<a href="ext_jit.html">jit.* Library</a> 44<a href="ext_jit.html">jit.* Library</a>
45</li><li> 45</li><li>
46<a href="ext_c_api.html">Lua/C API</a> 46<a href="ext_c_api.html">Lua/C API</a>
47</li><li>
48<a href="ext_profiler.html">Profiler</a>
47</li></ul> 49</li></ul>
48</li><li> 50</li><li>
49<a class="current" href="status.html">Status</a> 51<a class="current" href="status.html">Status</a>