Skip to content

Commit

Permalink
luajit: last updates from Mike Pall
Browse files Browse the repository at this point in the history
  • Loading branch information
andresy committed Nov 27, 2012
1 parent f396e96 commit 026129a
Show file tree
Hide file tree
Showing 24 changed files with 132 additions and 106 deletions.
15 changes: 4 additions & 11 deletions exe/luajit/Makefile
Expand Up @@ -16,8 +16,7 @@
MAJVER= 2
MINVER= 0
RELVER= 0
PREREL= -beta11
VERSION= $(MAJVER).$(MINVER).$(RELVER)$(PREREL)
VERSION= $(MAJVER).$(MINVER).$(RELVER)
ABIVER= 5.1

##############################################################################
Expand Down Expand Up @@ -108,7 +107,7 @@ install: $(INSTALL_DEP)
$(MKDIR) $(INSTALL_DIRS)
cd src && $(INSTALL_X) $(FILE_T) $(INSTALL_T)
cd src && test -f $(FILE_A) && $(INSTALL_F) $(FILE_A) $(INSTALL_STATIC) || :
$(RM) $(INSTALL_DYN) $(INSTALL_SHORT1) $(INSTALL_SHORT2)
$(RM) $(INSTALL_TSYM) $(INSTALL_DYN) $(INSTALL_SHORT1) $(INSTALL_SHORT2)
cd src && test -f $(FILE_SO) && \
$(INSTALL_X) $(FILE_SO) $(INSTALL_DYN) && \
$(LDCONFIG) $(INSTALL_LIB) && \
Expand All @@ -120,25 +119,19 @@ install: $(INSTALL_DEP)
$(RM) $(FILE_PC).tmp
cd src && $(INSTALL_F) $(FILES_INC) $(INSTALL_INC)
cd src/jit && $(INSTALL_F) $(FILES_JITLIB) $(INSTALL_JITLIB)
$(SYMLINK) $(INSTALL_TNAME) $(INSTALL_TSYM)
@echo "==== Successfully installed LuaJIT $(VERSION) to $(PREFIX) ===="
@echo ""
@echo "Note: the beta releases deliberately do NOT install a symlink for luajit"
@echo "You can do this now by running this command (with sudo):"
@echo ""
@echo " $(SYMLINK) $(INSTALL_TNAME) $(INSTALL_TSYM)"
@echo ""

uninstall:
@echo "==== Uninstalling LuaJIT $(VERSION) from $(PREFIX) ===="
$(UNINSTALL) $(INSTALL_T) $(INSTALL_STATIC) $(INSTALL_DYN) $(INSTALL_SHORT1) $(INSTALL_SHORT2) $(INSTALL_MAN)/$(FILE_MAN) $(INSTALL_PC)
$(UNINSTALL) $(INSTALL_TSYM) $(INSTALL_T) $(INSTALL_STATIC) $(INSTALL_DYN) $(INSTALL_SHORT1) $(INSTALL_SHORT2) $(INSTALL_MAN)/$(FILE_MAN) $(INSTALL_PC)
for file in $(FILES_JITLIB); do \
$(UNINSTALL) $(INSTALL_JITLIB)/$$file; \
done
for file in $(FILES_INC); do \
$(UNINSTALL) $(INSTALL_INC)/$$file; \
done
$(LDCONFIG) $(INSTALL_LIB)
test -f $(INSTALL_TSYM) || $(UNINSTALL) $(INSTALL_TSYM)
$(RMDIR) $(UNINSTALL_DIRS) || :
@echo "==== Successfully uninstalled LuaJIT $(VERSION) from $(PREFIX) ===="

Expand Down
4 changes: 2 additions & 2 deletions exe/luajit/README
@@ -1,5 +1,5 @@
README for LuaJIT 2.0.0-beta11
------------------------------
README for LuaJIT 2.0.0
-----------------------

LuaJIT is a Just-In-Time (JIT) compiler for the Lua programming language.

Expand Down
27 changes: 23 additions & 4 deletions exe/luajit/doc/changes.html
Expand Up @@ -63,16 +63,35 @@ <h1>LuaJIT Change History</h1>
<div id="main">
<p>
This is a list of changes between the released versions of LuaJIT.<br>
The current <span style="color: #c00000;">development version</span> is <strong>LuaJIT&nbsp;2.0.0-beta11</strong>.<br>
The current <span style="color: #0000c0;">stable version</span> is <strong>LuaJIT&nbsp;1.1.8</strong>.
The current <span style="color: #0000c0;">stable version</span> is <strong>LuaJIT&nbsp;2.0.0</strong>.<br>
</p>
<p>
Please check the
<a href="http://luajit.org/changes.html"><span class="ext">&raquo;</span>&nbsp;Online Change History</a>
to see whether newer versions are available.
</p>

<div class="major" style="background: #ffd0d0;">
<div class="major" style="background: #d0d0ff;">
<h2 id="LuaJIT-2.0.0">LuaJIT 2.0.0 &mdash; 2012-11-08</h2>
<ul>
<li>Correctness and completeness:
<ul>
<li>Fix Android/x86 build.</li>
<li>Fix recording of equality comparisons with <tt>__eq</tt> metamethods.</li>
<li>Fix detection of immutable upvalues.</li>
<li>Replace error with PANIC for callbacks from JIT-compiled code.</li>
<li>Fix builtin string to number conversion for <tt>INT_MIN</tt>.</li>
<li>Don't create unneeded array part for template tables.</li>
<li>Fix <tt>CONV.num.int</tt> sinking.</li>
<li>Don't propagate implicitly widened number to index metamethods.</li>
<li>ARM: Fix ordered comparisons of number vs. non-number.</li>
<li>FFI: Fix code generation for replay of sunk float fields.</li>
<li>FFI: Fix signedness of bool.</li>
<li>FFI: Fix recording of bool call result check on x86/x64.</li>
<li>FFI: Fix stack-adjustment for <tt>__thiscall</tt> callbacks.</li>
</ul></li>
</ul>

<h2 id="LuaJIT-2.0.0-beta11">LuaJIT 2.0.0-beta11 &mdash; 2012-10-16</h2>
<ul>
<li>New features:
Expand Down Expand Up @@ -580,7 +599,7 @@ <h2 id="LuaJIT-2.0.0-beta1">LuaJIT 2.0.0-beta1 &mdash; 2009-10-31</h2>
</ul>
</div>

<div class="major" style="background: #d0d0ff;">
<div class="major" style="background: #ffff80;">
<h2 id="LuaJIT-1.1.8">LuaJIT 1.1.8 &mdash; 2012-04-16</h2>
<ul>
<li>Merged with Lua 5.1.5. Also integrated fixes for all
Expand Down
33 changes: 17 additions & 16 deletions exe/luajit/doc/ext_ffi_semantics.html
Expand Up @@ -148,7 +148,7 @@ <h2 id="clang">C Language Support</h2>
<li>GCC <tt>__attribute__</tt> with the following attributes:
<tt>aligned</tt>, <tt>packed</tt>, <tt>mode</tt>,
<tt>vector_size</tt>, <tt>cdecl</tt>, <tt>fastcall</tt>,
<tt>stdcall</tt>.</li>
<tt>stdcall</tt>, <tt>thiscall</tt>.</li>

<li>The GCC <tt>__extension__</tt> keyword and the GCC
<tt>__alignof__</tt> operator.</li>
Expand All @@ -160,8 +160,8 @@ <h2 id="clang">C Language Support</h2>
<tt>__int16</tt>, <tt>__int32</tt> and <tt>__int64</tt>.</li>

<li>MSVC <tt>__cdecl</tt>, <tt>__fastcall</tt>, <tt>__stdcall</tt>,
<tt>__ptr32</tt>, <tt>__ptr64</tt>, <tt>__declspec(align(n))</tt>
and <tt>#pragma&nbsp;pack</tt>.</li>
<tt>__thiscall</tt>, <tt>__ptr32</tt>, <tt>__ptr64</tt>,
<tt>__declspec(align(n))</tt> and <tt>#pragma&nbsp;pack</tt>.</li>

<li>All other GCC/MSVC-specific attributes are ignored.</li>

Expand Down Expand Up @@ -517,17 +517,17 @@ <h2 id="init_table">Table Initializers</h2>
Depending on the use case, you may need to explicitly add a
<tt>NULL</tt> or <tt>0</tt> terminator to a VLA.</li>

<li>If the table has a non-empty hash part, a
<tt>struct</tt>/<tt>union</tt> is initialized by looking up each field
name (as a string key) in the table. Each non-<tt>nil</tt> value is
used to initialize the corresponding field.</li>

<li>Otherwise a <tt>struct</tt>/<tt>union</tt> is initialized in the
<li>A <tt>struct</tt>/<tt>union</tt> can be initialized in the
order of the declaration of its fields. Each field is initialized with
the consecutive table elements, starting at either index <tt>[0]</tt>
consecutive table elements, starting at either index <tt>[0]</tt>
or <tt>[1]</tt>. This process stops at the first <tt>nil</tt> table
element.</li>

<li>Otherwise, if neither index <tt>[0]</tt> nor <tt>[1]</tt> is present,
a <tt>struct</tt>/<tt>union</tt> is initialized by looking up each field
name (as a string key) in the table. Each non-<tt>nil</tt> value is
used to initialize the corresponding field.</li>

<li>Uninitialized fields of a <tt>struct</tt> are filled with zero
bytes, except for the trailing VLA of a VLS.</li>

Expand Down Expand Up @@ -943,9 +943,10 @@ <h2 id="callback">Callbacks</h2>
<p>
However, this heuristic may fail under specific circumstances: e.g. a
message polling function might not run Lua callbacks right away and the call
gets JIT-compiled. If it later happens to call back into Lua, you'll get a
VM PANIC with the message <tt>"bad callback"</tt>. Then you'll need to
manually turn off JIT-compilation with
gets JIT-compiled. If it later happens to call back into Lua (e.g. a rarely
invoked error callback), you'll get a VM PANIC with the message
<tt>"bad callback"</tt>. Then you'll need to manually turn off
JIT-compilation with
<a href="ext_jit.html#jit_onoff_func"><tt>jit.off()</tt></a> for the
surrounding Lua function that invokes such a message polling function (or
similar).
Expand Down Expand Up @@ -1038,9 +1039,9 @@ <h3 id="callback_performance">Callback performance</h3>
GUI application, which waits for user input most of the time, anyway.
</p>
<p>
For new designs <b>avoid push-style APIs</b> (C&nbsp;function repeatedly
calling a callback for each result). Instead <b>use pull-style APIs</b>
(call a C&nbsp;function repeatedly to get a new result). Calls from Lua
For new designs <b>avoid push-style APIs</b>: a C&nbsp;function repeatedly
calling a callback for each result. Instead <b>use pull-style APIs</b>:
call a C&nbsp;function repeatedly to get a new result. Calls from Lua
to C via the FFI are much faster than the other way round. Most well-designed
libraries already use pull-style APIs (read/write, get/put).
</p>
Expand Down
23 changes: 13 additions & 10 deletions exe/luajit/doc/extensions.html
Expand Up @@ -170,6 +170,17 @@ <h3 id="tostring"><tt>tostring()</tt> etc. canonicalize NaN and &plusmn;Inf</h3>
in <tt>"-inf"</tt>.
</p>

<h3 id="tonumber"><tt>tonumber()</tt> etc. use builtin string to number conversion</h3>
<p>
All string-to-number conversions consistently convert integer and
floating-point inputs in decimal and hexadecimal on all platforms.
<tt>strtod()</tt> is <em>not</em> used anymore, which avoids numerous
problems with poor C library implementations. The builtin conversion
function provides full precision according to the IEEE-754 standard, it
works independently of the current locale and it supports hex floating-point
numbers (e.g. <tt>0x1.5p-3</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
Expand Down Expand Up @@ -198,7 +209,7 @@ <h3 id="math_random">Enhanced PRNG for <tt>math.random()</tt></h3>
The PRNG generates the same sequences from the same seeds on all
platforms and makes use of all bits in the seed argument.
<tt>math.random()</tt> without arguments generates 52 pseudo-random bits
for every call. The result is uniformly distributed between 0 and 1.
for every call. The result is uniformly distributed between 0.0 and 1.0.
It's correctly scaled up and rounded for <tt>math.random(n&nbsp;[,m])</tt> to
preserve uniformity.
</p>
Expand All @@ -222,19 +233,11 @@ <h3 id="debug_meta"><tt>debug.*</tt> functions identify metamethods</h3>

<h2 id="resumable">Fully Resumable VM</h2>
<p>
The LuaJIT 2.x VM is fully resumable. This means you can yield from a
The LuaJIT VM is fully resumable. This means you can yield from a
coroutine even across contexts, where this would not possible with
the standard Lua&nbsp;5.1 VM: e.g. you can yield across <tt>pcall()</tt>
and <tt>xpcall()</tt>, across iterators and across metamethods.
</p>
<p>
Note however that LuaJIT 2.x doesn't use
<a href="http://coco.luajit.org/"><span class="ext">&raquo;</span>&nbsp;Coco</a> anymore. This means the
overhead for creating coroutines is much smaller and no extra
C&nbsp;stacks need to be allocated. OTOH you can no longer yield
across arbitrary C&nbsp;functions. Keep this in mind when
upgrading from LuaJIT 1.x.
</p>

<h2 id="lua52">Extensions from Lua 5.2</h2>
<p>
Expand Down
17 changes: 4 additions & 13 deletions exe/luajit/doc/install.html
Expand Up @@ -188,8 +188,8 @@ <h3>Prerequisites</h3>
and change to the newly created directory:
</p>
<pre class="code">
tar zxf LuaJIT-2.0.0-beta11.tar.gz
cd LuaJIT-2.0.0-beta11</pre>
tar zxf LuaJIT-2.0.0.tar.gz
cd LuaJIT-2.0.0</pre>
<h3>Building LuaJIT</h3>
<p>
The supplied Makefiles try to auto-detect the settings needed for your
Expand Down Expand Up @@ -236,15 +236,6 @@ <h3>Installing LuaJIT</h3>
<p>
Obviously the prefixes given during build and installation need to be the same.
</p>
<p style="color: #c00000;">
Note: to avoid overwriting a previous version, the beta test releases
only install the LuaJIT executable under the versioned name (i.e.
<tt>luajit-2.0.0-beta11</tt>). You probably want to create a symlink
for convenience, with a command like this:
</p>
<pre class="code" style="color: #c00000;">
sudo ln -sf luajit-2.0.0-beta11&nbsp;/usr/local/bin/luajit
</pre>

<h2 id="windows">Windows Systems</h2>
<h3>Prerequisites</h3>
Expand Down Expand Up @@ -461,8 +452,8 @@ <h2 id="cross">Cross-compiling LuaJIT</h2>
Or use Android. :-p
</p>
<pre class="code">
IXCODE=/Applications/Xcode45-DP4.app/Contents
ISDK=$IXCODE/Developer/Platforms/iPhoneOS.platform/Developer
IXCODE=`xcode-select -print-path`
ISDK=$IXCODE/Platforms/iPhoneOS.platform/Developer
ISDKVER=iPhoneOS6.0.sdk
ISDKP=$ISDK/usr/bin/
ISDKF="-arch armv7 -isysroot $ISDK/SDKs/$ISDKVER"
Expand Down
2 changes: 1 addition & 1 deletion exe/luajit/doc/luajit.html
Expand Up @@ -176,7 +176,7 @@ <h2>Overview</h2>
<td class="speed">3x<br>-&nbsp;&nbsp;100x</td>
<td class="kb">115&nbsp;<small>KB</small><br>VM</td>
<td class="kb">90&nbsp;<small>KB</small><br>JIT</td>
<td class="kloc">73&nbsp;<small>KLOC</small><br>C</td>
<td class="kloc">63&nbsp;<small>KLOC</small><br>C</td>
<td class="kloc">24&nbsp;<small>KLOC</small><br>ASM</td>
<td class="kloc">11&nbsp;<small>KLOC</small><br>Lua</td>
</tr>
Expand Down
17 changes: 3 additions & 14 deletions exe/luajit/doc/running.html
Expand Up @@ -86,15 +86,6 @@ <h1>Running LuaJIT</h1>
Lua statements or whole Lua applications from the command line. It has an
interactive mode, too.
</p>
<p class="indent" style="color: #c00000;">
Note: the beta test releases only install under the versioned name on
POSIX systems (to avoid overwriting a previous version). You either need
to type <tt>luajit-2.0.0-beta11</tt> to start it or create a symlink
with a command like this:
</p>
<pre class="code" style="color: #c00000;">
sudo ln -sf luajit-2.0.0-beta11&nbsp;/usr/local/bin/luajit
</pre>

<h2 id="options">Command Line Options</h2>
<p>
Expand Down Expand Up @@ -195,7 +186,7 @@ <h3 id="opt_j"><tt>-j cmd[=arg[,arg...]]</tt></h3>
read the comment block at the start of their source.
They can be found in the <tt>lib</tt> directory of the source
distribution or installed under the <tt>jit</tt> directory. By default
this is <tt>/usr/local/share/luajit-2.0.0-beta11/jit</tt> on POSIX
this is <tt>/usr/local/share/luajit-2.0.0/jit</tt> on POSIX
systems.
</p>

Expand All @@ -217,10 +208,6 @@ <h3 id="opt_O"><tt>-O[level]</tt><br>
the level (i.e. just <tt>-O</tt>) sets the default optimization level,
which is <tt>-O3</tt> in the current version.
</p>
<p style="font-size: 8pt;">
Note: Unlike previous versions, <b>optimization is turned on by default</b> in
LuaJIT 2.0!<br>It's no longer necessary to use <tt>luajit&nbsp;-O</tt>.
</p>
<p>
The second form adds or removes individual optimization flags.
The third form sets a parameter for the VM or the JIT compiler
Expand Down Expand Up @@ -263,6 +250,8 @@ <h3 id="opt_O"><tt>-O[level]</tt><br>
<tr class="even">
<td class="flag_name">abc</td><td class="flag_level">&nbsp;</td><td class="flag_level">&nbsp;</td><td class="flag_level">&bull;</td><td class="flag_desc">Array Bounds Check Elimination</td></tr>
<tr class="odd">
<td class="flag_name">sink</td><td class="flag_level">&nbsp;</td><td class="flag_level">&nbsp;</td><td class="flag_level">&bull;</td><td class="flag_desc">Allocation/Store Sinking</td></tr>
<tr class="even">
<td class="flag_name">fuse</td><td class="flag_level">&nbsp;</td><td class="flag_level">&nbsp;</td><td class="flag_level">&bull;</td><td class="flag_desc">Fusion of operands into instructions</td></tr>
</table>
<p>
Expand Down
8 changes: 3 additions & 5 deletions exe/luajit/doc/status.html
Expand Up @@ -62,11 +62,9 @@ <h1>Status &amp; Roadmap</h1>
</div>
<div id="main">
<p>
<span style="color: #c00000;">LuaJIT&nbsp;2.0</span> is the currently active
<span style="color: #c00000;">development branch</span> in beta test.
It has <a href="http://luajit.org/performance.html"><span class="ext">&raquo;</span>&nbsp;much better performance</a> than
LuaJIT&nbsp;1.x and runs on many more platforms and architectures.
The branch has already been frozen as it's nearing a stable release.
<span style="color: #0000c0;">LuaJIT&nbsp;2.0</span> is the current
<span style="color: #0000c0;">stable branch</span>. This branch is in
feature-freeze &mdash; new features will only be added to LuaJIT&nbsp;2.1.
</p>

<h2>Current Status</h2>
Expand Down
2 changes: 1 addition & 1 deletion exe/luajit/etc/luajit.pc
Expand Up @@ -2,7 +2,7 @@
majver=2
minver=0
relver=0
version=${majver}.${minver}.${relver}-beta11
version=${majver}.${minver}.${relver}
abiver=5.1

prefix=/usr/local
Expand Down
6 changes: 5 additions & 1 deletion exe/luajit/src/lj_arch.h
Expand Up @@ -300,7 +300,11 @@

/* Check target-specific constraints. */
#ifndef _BUILDVM_H
#if LJ_TARGET_ARM
#if LJ_TARGET_X64
#if __USING_SJLJ_EXCEPTIONS__
#error "Need a C compiler with native exception handling on x64"
#endif
#elif LJ_TARGET_ARM
#if defined(__ARMEB__)
#error "No support for big-endian ARM"
#endif
Expand Down
17 changes: 13 additions & 4 deletions exe/luajit/src/lj_asm.c
Expand Up @@ -826,10 +826,19 @@ static void asm_snap_alloc1(ASMState *as, IRRef ref)
asm_snap_alloc1(as, (irs+1)->op2);
}
}
} else if (ir->o == IR_CONV && ir->op2 == IRCONV_NUM_INT) {
asm_snap_alloc1(as, ir->op1);
} else {
RegSet allow = (!LJ_SOFTFP && irt_isfp(ir->t)) ? RSET_FPR : RSET_GPR;
RegSet allow;
if (ir->o == IR_CONV && ir->op2 == IRCONV_NUM_INT) {
IRIns *irc;
for (irc = IR(as->curins); irc > ir; irc--)
if ((irc->op1 == ref || irc->op2 == ref) &&
!(irc->r == RID_SINK || irc->r == RID_SUNK))
goto nosink; /* Don't sink conversion if result is used. */
asm_snap_alloc1(as, ir->op1);
return;
}
nosink:
allow = (!LJ_SOFTFP && irt_isfp(ir->t)) ? RSET_FPR : RSET_GPR;
if ((as->freeset & allow) ||
(allow == RSET_FPR && asm_snap_canremat(as))) {
/* Get a weak register if we have a free one or can rematerialize. */
Expand Down Expand Up @@ -1391,7 +1400,7 @@ static void asm_head_side(ASMState *as)
ra_sethint(ir->r, rs); /* Hint may be gone, set it again. */
else if (sps_scale(regsp_spill(rs))+spdelta == sps_scale(ir->s))
continue; /* Same spill slot, do nothing. */
mask = ((!LJ_SOFTFP && irt_isnum(ir->t)) ? RSET_FPR : RSET_GPR) & allow;
mask = ((!LJ_SOFTFP && irt_isfp(ir->t)) ? RSET_FPR : RSET_GPR) & allow;
if (mask == RSET_EMPTY)
lj_trace_err(as->J, LJ_TRERR_NYICOAL);
r = ra_allocref(as, i, mask);
Expand Down

0 comments on commit 026129a

Please sign in to comment.