浏览代码

Add more docs for bytecode load/save feature.

Mike Pall 14 年之前
父节点
当前提交
ecab831ebf
共有 2 个文件被更改,包括 24 次插入0 次删除
  1. 17 0
      doc/extensions.html
  2. 7 0
      doc/running.html

+ 17 - 0
doc/extensions.html

@@ -166,6 +166,23 @@ positive infinity results in <tt>"inf"</tt> and negative infinity results
 in <tt>"-inf"</tt>.
 </p>
 
+<h3 id="string_dump"><tt>string.dump(f [,strip])</tt> generates portable bytecode</h3>
+<p>
+An extra argument has been added to <tt>string.dump()</tt>. If set to
+<tt>true</tt>, 'stripped' bytecode without debug information is
+generated. This speeds up later bytecode loading and reduces memory
+usage. See also the
+<a href="running.html#opt_b"><tt>-b</tt> command line option</a>.
+</p>
+<p>
+The generated bytecode is portable and can be loaded on any architecture
+that LuaJIT supports, independent of word size or endianess. However the
+bytecode compatibility versions must match. Bytecode stays compatible
+for dot releases (x.y.0 &rarr; x.y.1), but may change with major or
+minor releases (2.0 &rarr; 2.1) or between any beta release. Foreign
+bytecode (e.g. from Lua 5.1) is incompatible and cannot be loaded.
+</p>
+
 <h3 id="math_random">Enhanced PRNG for <tt>math.random()</tt></h3>
 <p>
 LuaJIT uses a Tausworthe PRNG with period 2^223 to implement

+ 7 - 0
doc/running.html

@@ -133,6 +133,13 @@ luajit -bl test.lua                             # List to stdout
 luajit -bl test.lua test.txt                    # List to test.txt
 luajit -ble "print('hello world') end"          # List cmdline script
 </pre>
+<p>
+Note: A file in bytecode format is auto-detected and can be loaded like
+any Lua source file. E.g. directly from the command line or with
+<tt>loadfile()</tt>, <tt>dofile()</tt> etc. See also
+<a href="extensions.html#string_dump">string.dump()</a> for information
+on bytecode portability and compatibility.
+</p>
 
 <h3 id="opt_j"><tt>-j cmd[=arg[,arg...]]</tt></h3>
 <p>