Merge tag 'v2.1.0-beta3' into ppc64-port

RELEASE LuaJIT-2.1.0-beta3
This commit is contained in:
Gustavo Serra Scalet 2017-05-03 11:03:59 -03:00
commit bb23a152cb
205 changed files with 6134 additions and 727 deletions

View File

@ -1,7 +1,7 @@
=============================================================================== ===============================================================================
LuaJIT -- a Just-In-Time Compiler for Lua. http://luajit.org/ LuaJIT -- a Just-In-Time Compiler for Lua. http://luajit.org/
Copyright (C) 2005-2016 Mike Pall. All rights reserved. Copyright (C) 2005-2017 Mike Pall. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

View File

@ -10,13 +10,13 @@
# For MSVC, please follow the instructions given in src/msvcbuild.bat. # For MSVC, please follow the instructions given in src/msvcbuild.bat.
# For MinGW and Cygwin, cd to src and run make with the Makefile there. # For MinGW and Cygwin, cd to src and run make with the Makefile there.
# #
# Copyright (C) 2005-2016 Mike Pall. See Copyright Notice in luajit.h # Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h
############################################################################## ##############################################################################
MAJVER= 2 MAJVER= 2
MINVER= 1 MINVER= 1
RELVER= 0 RELVER= 0
PREREL= -beta2 PREREL= -beta3
VERSION= $(MAJVER).$(MINVER).$(RELVER)$(PREREL) VERSION= $(MAJVER).$(MINVER).$(RELVER)$(PREREL)
ABIVER= 5.1 ABIVER= 5.1
@ -86,8 +86,9 @@ FILE_MAN= luajit.1
FILE_PC= luajit.pc FILE_PC= luajit.pc
FILES_INC= lua.h lualib.h lauxlib.h luaconf.h lua.hpp luajit.h FILES_INC= lua.h lualib.h lauxlib.h luaconf.h lua.hpp luajit.h
FILES_JITLIB= bc.lua bcsave.lua dump.lua p.lua v.lua zone.lua \ FILES_JITLIB= bc.lua bcsave.lua dump.lua p.lua v.lua zone.lua \
dis_x86.lua dis_x64.lua dis_arm.lua dis_ppc.lua \ dis_x86.lua dis_x64.lua dis_arm.lua dis_arm64.lua \
dis_mips.lua dis_mipsel.lua vmdef.lua dis_arm64be.lua dis_ppc.lua dis_mips.lua dis_mipsel.lua \
dis_mips64.lua dis_mips64el.lua vmdef.lua
ifeq (,$(findstring Windows,$(OS))) ifeq (,$(findstring Windows,$(OS)))
HOST_SYS:= $(shell uname -s) HOST_SYS:= $(shell uname -s)

4
README
View File

@ -1,11 +1,11 @@
README for LuaJIT 2.1.0-beta2 README for LuaJIT 2.1.0-beta3
----------------------------- -----------------------------
LuaJIT is a Just-In-Time (JIT) compiler for the Lua programming language. LuaJIT is a Just-In-Time (JIT) compiler for the Lua programming language.
Project Homepage: http://luajit.org/ Project Homepage: http://luajit.org/
LuaJIT is Copyright (C) 2005-2016 Mike Pall. LuaJIT is Copyright (C) 2005-2017 Mike Pall.
LuaJIT is free software, released under the MIT license. LuaJIT is free software, released under the MIT license.
See full Copyright Notice in the COPYRIGHT file or in luajit.h. See full Copyright Notice in the COPYRIGHT file or in luajit.h.

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2004-2016 Mike Pall. /* Copyright (C) 2004-2017 Mike Pall.
* *
* You are welcome to use the general ideas of this design for your own sites. * You are welcome to use the general ideas of this design for your own sites.
* But please do not steal the stylesheet, the layout or the color scheme. * But please do not steal the stylesheet, the layout or the color scheme.

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2004-2016 Mike Pall. /* Copyright (C) 2004-2017 Mike Pall.
* *
* You are welcome to use the general ideas of this design for your own sites. * You are welcome to use the general ideas of this design for your own sites.
* But please do not steal the stylesheet, the layout or the color scheme. * But please do not steal the stylesheet, the layout or the color scheme.

View File

@ -4,7 +4,7 @@
<title>LuaJIT Change History</title> <title>LuaJIT Change History</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Author" content="Mike Pall"> <meta name="Author" content="Mike Pall">
<meta name="Copyright" content="Copyright (C) 2005-2016, Mike Pall"> <meta name="Copyright" content="Copyright (C) 2005-2017, Mike Pall">
<meta name="Language" content="en"> <meta name="Language" content="en">
<link rel="stylesheet" type="text/css" href="bluequad.css" media="screen"> <link rel="stylesheet" type="text/css" href="bluequad.css" media="screen">
<link rel="stylesheet" type="text/css" href="bluequad-print.css" media="print"> <link rel="stylesheet" type="text/css" href="bluequad-print.css" media="print">
@ -65,7 +65,7 @@ div.major { max-width: 600px; padding: 1em; margin: 1em 0 1em 0; }
<div id="main"> <div id="main">
<p> <p>
This is a list of changes between the released versions of LuaJIT.<br> This is a list of changes between the released versions of LuaJIT.<br>
The current <span style="color: #0000c0;">stable version</span> is <strong>LuaJIT&nbsp;2.0.4</strong>.<br> The current <span style="color: #0000c0;">stable version</span> is <strong>LuaJIT&nbsp;2.0.5</strong>.<br>
</p> </p>
<p> <p>
Please check the Please check the
@ -74,6 +74,30 @@ to see whether newer versions are available.
</p> </p>
<div class="major" style="background: #d0d0ff;"> <div class="major" style="background: #d0d0ff;">
<h2 id="LuaJIT-2.1.0-beta3">LuaJIT 2.1.0-beta3 &mdash; 2017-05-01</h2>
<ul>
<li>Rewrite memory block allocator.</li>
<li>Add various extension from Lua 5.2/5.3.</li>
<li>Remove old Lua 5.0 compatibility defines.</li>
<li>Set arg table before evaluating <tt>LUA_INIT</tt> and <tt>-e</tt> chunks.</li>
<li>Fix FOLD rules for <tt>math.abs()</tt> and FP negation.</li>
<li>Fix soft-float <tt>math.abs()</tt> and negation.</li>
<li>Fix formatting of some small denormals at low precision.</li>
<li>LJ_GC64: Add JIT compiler support.</li>
<li>x64/LJ_GC64: Add JIT compiler backend.</li>
<li>x86/x64: Generate BMI2 shifts and rotates, if available.</li>
<li>Windows/x86: Add full exception interoperability.</li>
<li>ARM64: Add big-endian support.</li>
<li>ARM64: Add JIT compiler backend.</li>
<li>MIPS: Fix <tt>TSETR</tt> barrier.</li>
<li>MIPS: Support MIPS16 interlinking.</li>
<li>MIPS soft-float: Fix code generation for <tt>HREF</tt>.</li>
<li>MIPS64: Add MIPS64 hard-float JIT compiler backend.</li>
<li>MIPS64: Add MIPS64 hard-float/soft-float support to interpreter.</li>
<li>FFI: Compile bitfield loads/stores.</li>
<li>Various fixes common with the 2.0 branch.</li>
</ul>
<h2 id="LuaJIT-2.1.0-beta2">LuaJIT 2.1.0-beta2 &mdash; 2016-03-03</h2> <h2 id="LuaJIT-2.1.0-beta2">LuaJIT 2.1.0-beta2 &mdash; 2016-03-03</h2>
<ul> <ul>
<li>Enable trace stitching.</li> <li>Enable trace stitching.</li>
@ -140,6 +164,48 @@ Please take a look at the commit history for more details.
</div> </div>
<div class="major" style="background: #ffffd0;"> <div class="major" style="background: #ffffd0;">
<h2 id="LuaJIT-2.0.5">LuaJIT 2.0.5 &mdash; 2017-05-01</h2>
<ul>
<li>Add workaround for MSVC 2015 stdio changes.</li>
<li>Limit mcode alloc probing, depending on the available pool size.</li>
<li>Fix overly restrictive range calculation in mcode allocation.</li>
<li>Fix out-of-scope goto handling in parser.</li>
<li>Remove internal <tt>__mode = "K"</tt> and replace with safe check.</li>
<li>Add "proto" field to <tt>jit.util.funcinfo()</tt>.</li>
<li>Fix GC step size calculation.</li>
<li>Initialize <tt>uv-&gt;immutable</tt> for upvalues of loaded chunks.</li>
<li>Fix for cdata vs. non-cdata arithmetics/comparisons.</li>
<li>Drop leftover regs in 'for' iterator assignment, too.</li>
<li>Fix PHI remarking in SINK pass.</li>
<li>Don't try to record outermost <tt>pcall()</tt> return to lower frame.</li>
<li>Add guard for obscure aliasing between open upvalues and SSA slots.</li>
<li>Remove assumption that <tt>lj_math_random_step()</tt> doesn't clobber FPRs.</li>
<li>Fix handling of non-numeric strings in arithmetic coercions.</li>
<li>Fix recording of <tt>select(n, ...)</tt> with off-trace varargs</li>
<li>Fix install for cross-builds.</li>
<li>Don't allocate unused 2nd result register in JIT compiler backend.</li>
<li>Drop marks from replayed instructions when sinking.</li>
<li>Fix unsinking check.</li>
<li>Properly handle OOM in <tt>trace_save()</tt>.</li>
<li>Limit number of arguments given to <tt>io.lines()</tt> and <tt>fp:lines()</tt>.</li>
<li>Fix narrowing of <tt>TOBIT</tt>.</li>
<li>OSX: Fix build with recent XCode.</li>
<li>x86/x64: Don't spill an explicit <tt>REF_BASE</tt> in the IR.</li>
<li>x86/x64: Fix instruction length decoder.</li>
<li>x86/x64: Search for exit jumps with instruction length decoder.</li>
<li>ARM: Fix <tt>BLX</tt> encoding for Thumb interworking calls.</li>
<li>MIPS: Don't use <tt>RID_GP</tt> as a scratch register.</li>
<li>MIPS: Fix emitted code for U32 to float conversion.</li>
<li>MIPS: Backport workaround for compact unwind tables.</li>
<li>MIPS: Fix cross-endian jit.bcsave.</li>
<li>MIPS: Fix <tt>BC_ISNEXT</tt> fallback path.</li>
<li>MIPS: Fix use of ffgccheck delay slots in interpreter.</li>
<li>FFI: Fix FOLD rules for <tt>int64_t</tt> comparisons.</li>
<li>FFI: Fix SPLIT pass for <tt>CONV i64.u64</tt>.</li>
<li>FFI: Fix <tt>ipairs()</tt> recording.</li>
<li>FFI: Don't propagate qualifiers into subtypes of complex.</li>
</ul>
<h2 id="LuaJIT-2.0.4">LuaJIT 2.0.4 &mdash; 2015-05-14</h2> <h2 id="LuaJIT-2.0.4">LuaJIT 2.0.4 &mdash; 2015-05-14</h2>
<ul> <ul>
<li>Fix stack check in narrowing optimization.</li> <li>Fix stack check in narrowing optimization.</li>
@ -807,7 +873,7 @@ no point in listing differences over earlier versions.</li>
</div> </div>
<div id="foot"> <div id="foot">
<hr class="hide"> <hr class="hide">
Copyright &copy; 2005-2016 Mike Pall Copyright &copy; 2005-2017 Mike Pall
<span class="noprint"> <span class="noprint">
&middot; &middot;
<a href="contact.html">Contact</a> <a href="contact.html">Contact</a>

View File

@ -4,7 +4,7 @@
<title>Contact</title> <title>Contact</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Author" content="Mike Pall"> <meta name="Author" content="Mike Pall">
<meta name="Copyright" content="Copyright (C) 2005-2016, Mike Pall"> <meta name="Copyright" content="Copyright (C) 2005-2017, Mike Pall">
<meta name="Language" content="en"> <meta name="Language" content="en">
<link rel="stylesheet" type="text/css" href="bluequad.css" media="screen"> <link rel="stylesheet" type="text/css" href="bluequad.css" media="screen">
<link rel="stylesheet" type="text/css" href="bluequad-print.css" media="print"> <link rel="stylesheet" type="text/css" href="bluequad-print.css" media="print">
@ -61,8 +61,15 @@
</div> </div>
<div id="main"> <div id="main">
<p> <p>
If you want to report bugs, propose fixes or suggest enhancements,
please use the
<a href="https://github.com/LuaJIT/LuaJIT/issues">GitHub issue tracker</a>.
</p>
<p>
Please send general questions to the Please send general questions to the
<a href="http://luajit.org/list.html"><span class="ext">&raquo;</span>&nbsp;LuaJIT mailing list</a>. <a href="http://luajit.org/list.html"><span class="ext">&raquo;</span>&nbsp;LuaJIT mailing list</a>.
</p>
<p>
You can also send any questions you have directly to me: You can also send any questions you have directly to me:
</p> </p>
@ -86,7 +93,7 @@ xD("fyZKB8xv\"FJytmz8.KAB0u52D")
<h2>Copyright</h2> <h2>Copyright</h2>
<p> <p>
All documentation is All documentation is
Copyright &copy; 2005-2016 Mike Pall. Copyright &copy; 2005-2017 Mike Pall.
</p> </p>
@ -94,7 +101,7 @@ Copyright &copy; 2005-2016 Mike Pall.
</div> </div>
<div id="foot"> <div id="foot">
<hr class="hide"> <hr class="hide">
Copyright &copy; 2005-2016 Mike Pall Copyright &copy; 2005-2017 Mike Pall
<span class="noprint"> <span class="noprint">
&middot; &middot;
<a href="contact.html">Contact</a> <a href="contact.html">Contact</a>

View File

@ -4,7 +4,7 @@
<title>Lua/C API Extensions</title> <title>Lua/C API Extensions</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Author" content="Mike Pall"> <meta name="Author" content="Mike Pall">
<meta name="Copyright" content="Copyright (C) 2005-2016, Mike Pall"> <meta name="Copyright" content="Copyright (C) 2005-2017, Mike Pall">
<meta name="Language" content="en"> <meta name="Language" content="en">
<link rel="stylesheet" type="text/css" href="bluequad.css" media="screen"> <link rel="stylesheet" type="text/css" href="bluequad.css" media="screen">
<link rel="stylesheet" type="text/css" href="bluequad-print.css" media="print"> <link rel="stylesheet" type="text/css" href="bluequad-print.css" media="print">
@ -179,7 +179,7 @@ Also note that this mechanism is not without overhead.
</div> </div>
<div id="foot"> <div id="foot">
<hr class="hide"> <hr class="hide">
Copyright &copy; 2005-2016 Mike Pall Copyright &copy; 2005-2017 Mike Pall
<span class="noprint"> <span class="noprint">
&middot; &middot;
<a href="contact.html">Contact</a> <a href="contact.html">Contact</a>

View File

@ -4,7 +4,7 @@
<title>FFI Library</title> <title>FFI Library</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Author" content="Mike Pall"> <meta name="Author" content="Mike Pall">
<meta name="Copyright" content="Copyright (C) 2005-2016, Mike Pall"> <meta name="Copyright" content="Copyright (C) 2005-2017, Mike Pall">
<meta name="Language" content="en"> <meta name="Language" content="en">
<link rel="stylesheet" type="text/css" href="bluequad.css" media="screen"> <link rel="stylesheet" type="text/css" href="bluequad.css" media="screen">
<link rel="stylesheet" type="text/css" href="bluequad-print.css" media="print"> <link rel="stylesheet" type="text/css" href="bluequad-print.css" media="print">
@ -322,7 +322,7 @@ without undue conversion penalties.
</div> </div>
<div id="foot"> <div id="foot">
<hr class="hide"> <hr class="hide">
Copyright &copy; 2005-2016 Mike Pall Copyright &copy; 2005-2017 Mike Pall
<span class="noprint"> <span class="noprint">
&middot; &middot;
<a href="contact.html">Contact</a> <a href="contact.html">Contact</a>

View File

@ -4,7 +4,7 @@
<title>ffi.* API Functions</title> <title>ffi.* API Functions</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Author" content="Mike Pall"> <meta name="Author" content="Mike Pall">
<meta name="Copyright" content="Copyright (C) 2005-2016, Mike Pall"> <meta name="Copyright" content="Copyright (C) 2005-2017, Mike Pall">
<meta name="Language" content="en"> <meta name="Language" content="en">
<link rel="stylesheet" type="text/css" href="bluequad.css" media="screen"> <link rel="stylesheet" type="text/css" href="bluequad.css" media="screen">
<link rel="stylesheet" type="text/css" href="bluequad-print.css" media="print"> <link rel="stylesheet" type="text/css" href="bluequad-print.css" media="print">
@ -560,7 +560,7 @@ named <tt>i</tt>.
</div> </div>
<div id="foot"> <div id="foot">
<hr class="hide"> <hr class="hide">
Copyright &copy; 2005-2016 Mike Pall Copyright &copy; 2005-2017 Mike Pall
<span class="noprint"> <span class="noprint">
&middot; &middot;
<a href="contact.html">Contact</a> <a href="contact.html">Contact</a>

View File

@ -4,7 +4,7 @@
<title>FFI Semantics</title> <title>FFI Semantics</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Author" content="Mike Pall"> <meta name="Author" content="Mike Pall">
<meta name="Copyright" content="Copyright (C) 2005-2016, Mike Pall"> <meta name="Copyright" content="Copyright (C) 2005-2017, Mike Pall">
<meta name="Language" content="en"> <meta name="Language" content="en">
<link rel="stylesheet" type="text/css" href="bluequad.css" media="screen"> <link rel="stylesheet" type="text/css" href="bluequad.css" media="screen">
<link rel="stylesheet" type="text/css" href="bluequad-print.css" media="print"> <link rel="stylesheet" type="text/css" href="bluequad-print.css" media="print">
@ -1221,13 +1221,12 @@ The following operations are currently not compiled and may exhibit
suboptimal performance, especially when used in inner loops: suboptimal performance, especially when used in inner loops:
</p> </p>
<ul> <ul>
<li>Bitfield accesses and initializations.</li>
<li>Vector operations.</li> <li>Vector operations.</li>
<li>Table initializers.</li> <li>Table initializers.</li>
<li>Initialization of nested <tt>struct</tt>/<tt>union</tt> types.</li> <li>Initialization of nested <tt>struct</tt>/<tt>union</tt> types.</li>
<li>Non-default initialization of VLA/VLS or large C&nbsp;types <li>Non-default initialization of VLA/VLS or large C&nbsp;types
(&gt; 128&nbsp;bytes or &gt; 16 array elements.</li> (&gt; 128&nbsp;bytes or &gt; 16 array elements.</li>
<li>Conversions from lightuserdata to <tt>void&nbsp;*</tt>.</li> <li>Bitfield initializations.</li>
<li>Pointer differences for element sizes that are not a power of <li>Pointer differences for element sizes that are not a power of
two.</li> two.</li>
<li>Calls to C&nbsp;functions with aggregates passed or returned by <li>Calls to C&nbsp;functions with aggregates passed or returned by
@ -1253,7 +1252,7 @@ compiled.</li>
</div> </div>
<div id="foot"> <div id="foot">
<hr class="hide"> <hr class="hide">
Copyright &copy; 2005-2016 Mike Pall Copyright &copy; 2005-2017 Mike Pall
<span class="noprint"> <span class="noprint">
&middot; &middot;
<a href="contact.html">Contact</a> <a href="contact.html">Contact</a>

View File

@ -4,7 +4,7 @@
<title>FFI Tutorial</title> <title>FFI Tutorial</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Author" content="Mike Pall"> <meta name="Author" content="Mike Pall">
<meta name="Copyright" content="Copyright (C) 2005-2016, Mike Pall"> <meta name="Copyright" content="Copyright (C) 2005-2017, Mike Pall">
<meta name="Language" content="en"> <meta name="Language" content="en">
<link rel="stylesheet" type="text/css" href="bluequad.css" media="screen"> <link rel="stylesheet" type="text/css" href="bluequad.css" media="screen">
<link rel="stylesheet" type="text/css" href="bluequad-print.css" media="print"> <link rel="stylesheet" type="text/css" href="bluequad-print.css" media="print">
@ -593,7 +593,7 @@ it to a local variable in the function scope is unnecessary.
</div> </div>
<div id="foot"> <div id="foot">
<hr class="hide"> <hr class="hide">
Copyright &copy; 2005-2016 Mike Pall Copyright &copy; 2005-2017 Mike Pall
<span class="noprint"> <span class="noprint">
&middot; &middot;
<a href="contact.html">Contact</a> <a href="contact.html">Contact</a>

View File

@ -4,7 +4,7 @@
<title>jit.* Library</title> <title>jit.* Library</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Author" content="Mike Pall"> <meta name="Author" content="Mike Pall">
<meta name="Copyright" content="Copyright (C) 2005-2016, Mike Pall"> <meta name="Copyright" content="Copyright (C) 2005-2017, Mike Pall">
<meta name="Language" content="en"> <meta name="Language" content="en">
<link rel="stylesheet" type="text/css" href="bluequad.css" media="screen"> <link rel="stylesheet" type="text/css" href="bluequad.css" media="screen">
<link rel="stylesheet" type="text/css" href="bluequad-print.css" media="print"> <link rel="stylesheet" type="text/css" href="bluequad-print.css" media="print">
@ -191,7 +191,7 @@ if you want to know more.
</div> </div>
<div id="foot"> <div id="foot">
<hr class="hide"> <hr class="hide">
Copyright &copy; 2005-2016 Mike Pall Copyright &copy; 2005-2017 Mike Pall
<span class="noprint"> <span class="noprint">
&middot; &middot;
<a href="contact.html">Contact</a> <a href="contact.html">Contact</a>

View File

@ -4,7 +4,7 @@
<title>Profiler</title> <title>Profiler</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Author" content="Mike Pall"> <meta name="Author" content="Mike Pall">
<meta name="Copyright" content="Copyright (C) 2005-2016, Mike Pall"> <meta name="Copyright" content="Copyright (C) 2005-2017, Mike Pall">
<meta name="Language" content="en"> <meta name="Language" content="en">
<link rel="stylesheet" type="text/css" href="bluequad.css" media="screen"> <link rel="stylesheet" type="text/css" href="bluequad.css" media="screen">
<link rel="stylesheet" type="text/css" href="bluequad-print.css" media="print"> <link rel="stylesheet" type="text/css" href="bluequad-print.css" media="print">
@ -355,7 +355,7 @@ use.
</div> </div>
<div id="foot"> <div id="foot">
<hr class="hide"> <hr class="hide">
Copyright &copy; 2005-2016 Mike Pall Copyright &copy; 2005-2017 Mike Pall
<span class="noprint"> <span class="noprint">
&middot; &middot;
<a href="contact.html">Contact</a> <a href="contact.html">Contact</a>

View File

@ -4,7 +4,7 @@
<title>Extensions</title> <title>Extensions</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Author" content="Mike Pall"> <meta name="Author" content="Mike Pall">
<meta name="Copyright" content="Copyright (C) 2005-2016, Mike Pall"> <meta name="Copyright" content="Copyright (C) 2005-2017, Mike Pall">
<meta name="Language" content="en"> <meta name="Language" content="en">
<link rel="stylesheet" type="text/css" href="bluequad.css" media="screen"> <link rel="stylesheet" type="text/css" href="bluequad.css" media="screen">
<link rel="stylesheet" type="text/css" href="bluequad-print.css" media="print"> <link rel="stylesheet" type="text/css" href="bluequad-print.css" media="print">
@ -210,7 +210,8 @@ bytecode (e.g. from Lua 5.1) is incompatible and cannot be loaded.
<p> <p>
Note: <tt>LJ_GC64</tt> mode requires a different frame layout, which implies Note: <tt>LJ_GC64</tt> mode requires a different frame layout, which implies
a different, incompatible bytecode format for ports that use this mode (e.g. a different, incompatible bytecode format for ports that use this mode (e.g.
ARM64). This may be rectified in the future. ARM64 or MIPS64) or when explicitly enabled for x64. This may be rectified
in the future.
</p> </p>
<h3 id="table_new"><tt>table.new(narray, nhash)</tt> allocates a pre-sized table</h3> <h3 id="table_new"><tt>table.new(narray, nhash)</tt> allocates a pre-sized table</h3>
@ -291,8 +292,8 @@ enabled:
<li><tt>load(string|reader [, chunkname [,mode [,env]]])</tt>.</li> <li><tt>load(string|reader [, chunkname [,mode [,env]]])</tt>.</li>
<li><tt>loadstring()</tt> is an alias for <tt>load()</tt>.</li> <li><tt>loadstring()</tt> is an alias for <tt>load()</tt>.</li>
<li><tt>loadfile(filename [,mode [,env]])</tt>.</li> <li><tt>loadfile(filename [,mode [,env]])</tt>.</li>
<li><tt>math.log(x [,base])</tt>. <li><tt>math.log(x [,base])</tt>.</li>
<li><tt>string.rep(s, n [,sep])</tt>. <li><tt>string.rep(s, n [,sep])</tt>.</li>
<li><tt>string.format()</tt>: <tt>%q</tt> reversible. <li><tt>string.format()</tt>: <tt>%q</tt> reversible.
<tt>%s</tt> checks <tt>__tostring</tt>. <tt>%s</tt> checks <tt>__tostring</tt>.
<tt>%a</tt> and <tt>"%A</tt> added.</li> <tt>%a</tt> and <tt>"%A</tt> added.</li>
@ -311,6 +312,26 @@ indexes for varargs.</li>
<li><tt>debug.getupvalue()</tt> and <tt>debug.setupvalue()</tt> handle <li><tt>debug.getupvalue()</tt> and <tt>debug.setupvalue()</tt> handle
C&nbsp;functions.</li> C&nbsp;functions.</li>
<li><tt>debug.upvalueid()</tt> and <tt>debug.upvaluejoin()</tt>.</li> <li><tt>debug.upvalueid()</tt> and <tt>debug.upvaluejoin()</tt>.</li>
<li>Lua/C API extensions:
<tt>lua_version()</tt>
<tt>lua_upvalueid()</tt>
<tt>lua_upvaluejoin()</tt>
<tt>lua_loadx()</tt>
<tt>lua_copy()</tt>
<tt>lua_tonumberx()</tt>
<tt>lua_tointegerx()</tt>
<tt>luaL_fileresult()</tt>
<tt>luaL_execresult()</tt>
<tt>luaL_loadfilex()</tt>
<tt>luaL_loadbufferx()</tt>
<tt>luaL_traceback()</tt>
<tt>luaL_setfuncs()</tt>
<tt>luaL_pushmodule()</tt>
<tt>luaL_newlibtable()</tt>
<tt>luaL_newlib()</tt>
<tt>luaL_testudata()</tt>
<tt>luaL_setmetatable()</tt>
</li>
<li>Command line option <tt>-E</tt>.</li> <li>Command line option <tt>-E</tt>.</li>
<li>Command line checks <tt>__tostring</tt> for errors.</li> <li>Command line checks <tt>__tostring</tt> for errors.</li>
</ul> </ul>
@ -335,7 +356,9 @@ instead of <tt>true</tt>.</li>
exit status.</li> exit status.</li>
<li><tt>debug.setmetatable()</tt> returns object.</li> <li><tt>debug.setmetatable()</tt> returns object.</li>
<li><tt>debug.getuservalue()</tt> and <tt>debug.setuservalue()</tt>.</li> <li><tt>debug.getuservalue()</tt> and <tt>debug.setuservalue()</tt>.</li>
<li>Remove <tt>math.mod()</tt>, <tt>string.gfind()</tt>. <li>Remove <tt>math.mod()</tt>, <tt>string.gfind()</tt>.</li>
<li><tt>package.searchers</tt>.</li>
<li><tt>module()</tt> returns the module table.</li>
</ul> </ul>
<p> <p>
Note: this provides only partial compatibility with Lua 5.2 at the Note: this provides only partial compatibility with Lua 5.2 at the
@ -350,6 +373,12 @@ LuaJIT supports some extensions from Lua&nbsp;5.3:
<ul> <ul>
<li>Unicode escape <tt>'\u{XX...}'</tt> embeds the UTF-8 encoding in string literals.</li> <li>Unicode escape <tt>'\u{XX...}'</tt> embeds the UTF-8 encoding in string literals.</li>
<li>The argument table <tt>arg</tt> can be read (and modified) by <tt>LUA_INIT</tt> and <tt>-e</tt> chunks.</li> <li>The argument table <tt>arg</tt> can be read (and modified) by <tt>LUA_INIT</tt> and <tt>-e</tt> chunks.</li>
<li><tt>io.read()</tt> and <tt>file:read()</tt> accept formats with or without a leading <tt>*</tt>.</li>
<li><tt>table.move(a1, f, e, t [,a2])</tt>.</li>
<li><tt>coroutine.isyieldable()</tt>.</li>
<li>Lua/C API extensions:
<tt>lua_isyieldable()</tt>
</li>
</ul> </ul>
<h2 id="exceptions">C++ Exception Interoperability</h2> <h2 id="exceptions">C++ Exception Interoperability</h2>
@ -443,7 +472,7 @@ C++ destructors.</li>
</div> </div>
<div id="foot"> <div id="foot">
<hr class="hide"> <hr class="hide">
Copyright &copy; 2005-2016 Mike Pall Copyright &copy; 2005-2017 Mike Pall
<span class="noprint"> <span class="noprint">
&middot; &middot;
<a href="contact.html">Contact</a> <a href="contact.html">Contact</a>

View File

@ -4,7 +4,7 @@
<title>Frequently Asked Questions (FAQ)</title> <title>Frequently Asked Questions (FAQ)</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Author" content="Mike Pall"> <meta name="Author" content="Mike Pall">
<meta name="Copyright" content="Copyright (C) 2005-2016, Mike Pall"> <meta name="Copyright" content="Copyright (C) 2005-2017, Mike Pall">
<meta name="Language" content="en"> <meta name="Language" content="en">
<link rel="stylesheet" type="text/css" href="bluequad.css" media="screen"> <link rel="stylesheet" type="text/css" href="bluequad.css" media="screen">
<link rel="stylesheet" type="text/css" href="bluequad-print.css" media="print"> <link rel="stylesheet" type="text/css" href="bluequad-print.css" media="print">
@ -176,7 +176,7 @@ the development of certain features, if they are important to you.
</div> </div>
<div id="foot"> <div id="foot">
<hr class="hide"> <hr class="hide">
Copyright &copy; 2005-2016 Mike Pall Copyright &copy; 2005-2017 Mike Pall
<span class="noprint"> <span class="noprint">
&middot; &middot;
<a href="contact.html">Contact</a> <a href="contact.html">Contact</a>

View File

@ -4,7 +4,7 @@
<title>Installation</title> <title>Installation</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Author" content="Mike Pall"> <meta name="Author" content="Mike Pall">
<meta name="Copyright" content="Copyright (C) 2005-2016, Mike Pall"> <meta name="Copyright" content="Copyright (C) 2005-2017, Mike Pall">
<meta name="Language" content="en"> <meta name="Language" content="en">
<link rel="stylesheet" type="text/css" href="bluequad.css" media="screen"> <link rel="stylesheet" type="text/css" href="bluequad.css" media="screen">
<link rel="stylesheet" type="text/css" href="bluequad-print.css" media="print"> <link rel="stylesheet" type="text/css" href="bluequad-print.css" media="print">
@ -175,6 +175,14 @@ MSVC or WinSDK.</li>
Please read the instructions given in these files, before changing Please read the instructions given in these files, before changing
any settings. any settings.
</p> </p>
<p>
LuaJIT on x64 currently uses 32 bit GC objects by default.
<tt>LJ_GC64</tt> mode may be explicitly enabled:
add <tt>XCFLAGS=-DLUAJIT_ENABLE_GC64</tt> to the make command or run
<tt>msvcbuild gc64</tt> for MSVC/WinSDK. Please check the note
about the <a href="extensions.html#string_dump">bytecode format</a>
differences, too.
</p>
<h2 id="posix">POSIX Systems (Linux, OSX, *BSD etc.)</h2> <h2 id="posix">POSIX Systems (Linux, OSX, *BSD etc.)</h2>
<h3>Prerequisites</h3> <h3>Prerequisites</h3>
@ -190,8 +198,8 @@ open a terminal window and change to this directory. Now unpack the archive
and change to the newly created directory: and change to the newly created directory:
</p> </p>
<pre class="code"> <pre class="code">
tar zxf LuaJIT-2.0.4.tar.gz tar zxf LuaJIT-2.0.5.tar.gz
cd LuaJIT-2.0.4</pre> cd LuaJIT-2.0.5</pre>
<h3>Building LuaJIT</h3> <h3>Building LuaJIT</h3>
<p> <p>
The supplied Makefiles try to auto-detect the settings needed for your The supplied Makefiles try to auto-detect the settings needed for your
@ -584,14 +592,11 @@ intend to load Lua/C modules at runtime.
</li> </li>
<li> <li>
If you're building a 64 bit application on OSX which links directly or If you're building a 64 bit application on OSX which links directly or
indirectly against LuaJIT, you need to link your main executable indirectly against LuaJIT which is not built for <tt>LJ_GC64</tt> mode,
with these flags: you need to link your main executable with these flags:
<pre class="code"> <pre class="code">
-pagezero_size 10000 -image_base 100000000 -pagezero_size 10000 -image_base 100000000
</pre> </pre>
Also, it's recommended to <tt>rebase</tt> all (self-compiled) shared libraries
which are loaded at runtime on OSX/x64 (e.g. C extension modules for Lua).
See: <tt>man rebase</tt>
</li> </li>
</ul> </ul>
<p>Additional hints for initializing LuaJIT using the C API functions:</p> <p>Additional hints for initializing LuaJIT using the C API functions:</p>
@ -677,7 +682,7 @@ to me (the upstream) and not you (the package maintainer), anyway.
</div> </div>
<div id="foot"> <div id="foot">
<hr class="hide"> <hr class="hide">
Copyright &copy; 2005-2016 Mike Pall Copyright &copy; 2005-2017 Mike Pall
<span class="noprint"> <span class="noprint">
&middot; &middot;
<a href="contact.html">Contact</a> <a href="contact.html">Contact</a>

View File

@ -4,7 +4,7 @@
<title>LuaJIT</title> <title>LuaJIT</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Author" content="Mike Pall"> <meta name="Author" content="Mike Pall">
<meta name="Copyright" content="Copyright (C) 2005-2016, Mike Pall"> <meta name="Copyright" content="Copyright (C) 2005-2017, Mike Pall">
<meta name="Language" content="en"> <meta name="Language" content="en">
<link rel="stylesheet" type="text/css" href="bluequad.css" media="screen"> <link rel="stylesheet" type="text/css" href="bluequad.css" media="screen">
<link rel="stylesheet" type="text/css" href="bluequad-print.css" media="print"> <link rel="stylesheet" type="text/css" href="bluequad-print.css" media="print">
@ -152,7 +152,7 @@ Lua is a powerful, dynamic and light-weight programming language.
It may be embedded or used as a general-purpose, stand-alone language. It may be embedded or used as a general-purpose, stand-alone language.
</p> </p>
<p> <p>
LuaJIT is Copyright &copy; 2005-2016 Mike Pall, released under the LuaJIT is Copyright &copy; 2005-2017 Mike Pall, released under the
<a href="http://www.opensource.org/licenses/mit-license.php"><span class="ext">&raquo;</span>&nbsp;MIT open source license</a>. <a href="http://www.opensource.org/licenses/mit-license.php"><span class="ext">&raquo;</span>&nbsp;MIT open source license</a>.
</p> </p>
<p> <p>
@ -226,7 +226,7 @@ Please select a sub-topic in the navigation bar to learn more about LuaJIT.
</div> </div>
<div id="foot"> <div id="foot">
<hr class="hide"> <hr class="hide">
Copyright &copy; 2005-2016 Mike Pall Copyright &copy; 2005-2017 Mike Pall
<span class="noprint"> <span class="noprint">
&middot; &middot;
<a href="contact.html">Contact</a> <a href="contact.html">Contact</a>

View File

@ -4,7 +4,7 @@
<title>Running LuaJIT</title> <title>Running LuaJIT</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Author" content="Mike Pall"> <meta name="Author" content="Mike Pall">
<meta name="Copyright" content="Copyright (C) 2005-2016, Mike Pall"> <meta name="Copyright" content="Copyright (C) 2005-2017, Mike Pall">
<meta name="Language" content="en"> <meta name="Language" content="en">
<link rel="stylesheet" type="text/css" href="bluequad.css" media="screen"> <link rel="stylesheet" type="text/css" href="bluequad.css" media="screen">
<link rel="stylesheet" type="text/css" href="bluequad-print.css" media="print"> <link rel="stylesheet" type="text/css" href="bluequad-print.css" media="print">
@ -189,7 +189,7 @@ itself. For a description of their options and output format, please
read the comment block at the start of their source. read the comment block at the start of their source.
They can be found in the <tt>lib</tt> directory of the 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 distribution or installed under the <tt>jit</tt> directory. By default
this is <tt>/usr/local/share/luajit-2.0.4/jit</tt> on POSIX this is <tt>/usr/local/share/luajit-2.0.5/jit</tt> on POSIX
systems. systems.
</p> </p>
@ -299,7 +299,7 @@ Here are the parameters and their default settings:
</div> </div>
<div id="foot"> <div id="foot">
<hr class="hide"> <hr class="hide">
Copyright &copy; 2005-2016 Mike Pall Copyright &copy; 2005-2017 Mike Pall
<span class="noprint"> <span class="noprint">
&middot; &middot;
<a href="contact.html">Contact</a> <a href="contact.html">Contact</a>

View File

@ -4,7 +4,7 @@
<title>Status</title> <title>Status</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Author" content="Mike Pall"> <meta name="Author" content="Mike Pall">
<meta name="Copyright" content="Copyright (C) 2005-2016, Mike Pall"> <meta name="Copyright" content="Copyright (C) 2005-2017, Mike Pall">
<meta name="Language" content="en"> <meta name="Language" content="en">
<link rel="stylesheet" type="text/css" href="bluequad.css" media="screen"> <link rel="stylesheet" type="text/css" href="bluequad.css" media="screen">
<link rel="stylesheet" type="text/css" href="bluequad-print.css" media="print"> <link rel="stylesheet" type="text/css" href="bluequad-print.css" media="print">
@ -97,12 +97,23 @@ handled correctly. The error may fall through an on-trace
<tt>lua_atpanic</tt> on x64. This issue will be fixed with the new <tt>lua_atpanic</tt> on x64. This issue will be fixed with the new
garbage collector. garbage collector.
</li> </li>
<li>
LuaJIT on 64 bit systems provides a <b>limited range</b> of 47 bits for the
<b>legacy <tt>lightuserdata</tt></b> data type.
This is only relevant on x64 systems which use the negative part of the
virtual address space in user mode, e.g. Solaris/x64, and on ARM64 systems
configured with a 48 bit or 52 bit VA.
Avoid using <tt>lightuserdata</tt> to hold pointers that may point outside
of that range, e.g. variables on the stack. In general, avoid this data
type for new code and replace it with (much more performant) FFI bindings.
FFI cdata pointers can address the full 64 bit range.
</li>
</ul> </ul>
<br class="flush"> <br class="flush">
</div> </div>
<div id="foot"> <div id="foot">
<hr class="hide"> <hr class="hide">
Copyright &copy; 2005-2016 Mike Pall Copyright &copy; 2005-2017 Mike Pall
<span class="noprint"> <span class="noprint">
&middot; &middot;
<a href="contact.html">Contact</a> <a href="contact.html">Contact</a>

View File

@ -1,6 +1,6 @@
/* /*
** DynASM ARM encoding engine. ** DynASM ARM encoding engine.
** Copyright (C) 2005-2016 Mike Pall. All rights reserved. ** Copyright (C) 2005-2017 Mike Pall. All rights reserved.
** Released under the MIT license. See dynasm.lua for full copyright notice. ** Released under the MIT license. See dynasm.lua for full copyright notice.
*/ */

View File

@ -1,7 +1,7 @@
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
-- DynASM ARM module. -- DynASM ARM module.
-- --
-- Copyright (C) 2005-2016 Mike Pall. All rights reserved. -- Copyright (C) 2005-2017 Mike Pall. All rights reserved.
-- See dynasm.lua for full copyright notice. -- See dynasm.lua for full copyright notice.
------------------------------------------------------------------------------ ------------------------------------------------------------------------------

View File

@ -1,6 +1,6 @@
/* /*
** DynASM ARM64 encoding engine. ** DynASM ARM64 encoding engine.
** Copyright (C) 2005-2016 Mike Pall. All rights reserved. ** Copyright (C) 2005-2017 Mike Pall. All rights reserved.
** Released under the MIT license. See dynasm.lua for full copyright notice. ** Released under the MIT license. See dynasm.lua for full copyright notice.
*/ */

View File

@ -1,7 +1,7 @@
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
-- DynASM ARM64 module. -- DynASM ARM64 module.
-- --
-- Copyright (C) 2005-2016 Mike Pall. All rights reserved. -- Copyright (C) 2005-2017 Mike Pall. All rights reserved.
-- See dynasm.lua for full copyright notice. -- See dynasm.lua for full copyright notice.
------------------------------------------------------------------------------ ------------------------------------------------------------------------------

View File

@ -1,6 +1,6 @@
/* /*
** DynASM MIPS encoding engine. ** DynASM MIPS encoding engine.
** Copyright (C) 2005-2016 Mike Pall. All rights reserved. ** Copyright (C) 2005-2017 Mike Pall. All rights reserved.
** Released under the MIT license. See dynasm.lua for full copyright notice. ** Released under the MIT license. See dynasm.lua for full copyright notice.
*/ */

View File

@ -1,7 +1,7 @@
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
-- DynASM MIPS32/MIPS64 module. -- DynASM MIPS32/MIPS64 module.
-- --
-- Copyright (C) 2005-2016 Mike Pall. All rights reserved. -- Copyright (C) 2005-2017 Mike Pall. All rights reserved.
-- See dynasm.lua for full copyright notice. -- See dynasm.lua for full copyright notice.
------------------------------------------------------------------------------ ------------------------------------------------------------------------------

View File

@ -1,7 +1,7 @@
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
-- DynASM MIPS64 module. -- DynASM MIPS64 module.
-- --
-- Copyright (C) 2005-2016 Mike Pall. All rights reserved. -- Copyright (C) 2005-2017 Mike Pall. All rights reserved.
-- See dynasm.lua for full copyright notice. -- See dynasm.lua for full copyright notice.
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
-- This module just sets 64 bit mode for the combined MIPS/MIPS64 module. -- This module just sets 64 bit mode for the combined MIPS/MIPS64 module.

View File

@ -1,6 +1,6 @@
/* /*
** DynASM PPC/PPC64 encoding engine. ** DynASM PPC/PPC64 encoding engine.
** Copyright (C) 2005-2016 Mike Pall. All rights reserved. ** Copyright (C) 2005-2017 Mike Pall. All rights reserved.
** Released under the MIT license. See dynasm.lua for full copyright notice. ** Released under the MIT license. See dynasm.lua for full copyright notice.
*/ */

View File

@ -1,7 +1,7 @@
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
-- DynASM PPC/PPC64 module. -- DynASM PPC/PPC64 module.
-- --
-- Copyright (C) 2005-2016 Mike Pall. All rights reserved. -- Copyright (C) 2005-2017 Mike Pall. All rights reserved.
-- See dynasm.lua for full copyright notice. -- See dynasm.lua for full copyright notice.
-- --
-- Support for various extensions contributed by Caio Souza Oliveira. -- Support for various extensions contributed by Caio Souza Oliveira.

View File

@ -1,6 +1,6 @@
/* /*
** DynASM encoding engine prototypes. ** DynASM encoding engine prototypes.
** Copyright (C) 2005-2016 Mike Pall. All rights reserved. ** Copyright (C) 2005-2017 Mike Pall. All rights reserved.
** Released under the MIT license. See dynasm.lua for full copyright notice. ** Released under the MIT license. See dynasm.lua for full copyright notice.
*/ */

View File

@ -1,7 +1,7 @@
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
-- DynASM x64 module. -- DynASM x64 module.
-- --
-- Copyright (C) 2005-2016 Mike Pall. All rights reserved. -- Copyright (C) 2005-2017 Mike Pall. All rights reserved.
-- See dynasm.lua for full copyright notice. -- See dynasm.lua for full copyright notice.
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
-- This module just sets 64 bit mode for the combined x86/x64 module. -- This module just sets 64 bit mode for the combined x86/x64 module.

View File

@ -1,6 +1,6 @@
/* /*
** DynASM x86 encoding engine. ** DynASM x86 encoding engine.
** Copyright (C) 2005-2016 Mike Pall. All rights reserved. ** Copyright (C) 2005-2017 Mike Pall. All rights reserved.
** Released under the MIT license. See dynasm.lua for full copyright notice. ** Released under the MIT license. See dynasm.lua for full copyright notice.
*/ */

View File

@ -1,7 +1,7 @@
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
-- DynASM x86/x64 module. -- DynASM x86/x64 module.
-- --
-- Copyright (C) 2005-2016 Mike Pall. All rights reserved. -- Copyright (C) 2005-2017 Mike Pall. All rights reserved.
-- See dynasm.lua for full copyright notice. -- See dynasm.lua for full copyright notice.
------------------------------------------------------------------------------ ------------------------------------------------------------------------------

View File

@ -2,7 +2,7 @@
-- DynASM. A dynamic assembler for code generation engines. -- DynASM. A dynamic assembler for code generation engines.
-- Originally designed and implemented for LuaJIT. -- Originally designed and implemented for LuaJIT.
-- --
-- Copyright (C) 2005-2016 Mike Pall. All rights reserved. -- Copyright (C) 2005-2017 Mike Pall. All rights reserved.
-- See below for full copyright notice. -- See below for full copyright notice.
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
@ -17,7 +17,7 @@ local _info = {
url = "http://luajit.org/dynasm.html", url = "http://luajit.org/dynasm.html",
license = "MIT", license = "MIT",
copyright = [[ copyright = [[
Copyright (C) 2005-2016 Mike Pall. All rights reserved. Copyright (C) 2005-2017 Mike Pall. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the a copy of this software and associated documentation files (the

View File

@ -74,7 +74,7 @@ luajit \-jv \-e "for i=1,10 do for j=1,10 do for k=1,100 do end end end"
Runs some nested loops and shows the resulting traces. Runs some nested loops and shows the resulting traces.
.SH COPYRIGHT .SH COPYRIGHT
.PP .PP
\fBLuaJIT\fR is Copyright \(co 2005-2016 Mike Pall. \fBLuaJIT\fR is Copyright \(co 2005-2017 Mike Pall.
.br .br
\fBLuaJIT\fR is open source software, released under the MIT license. \fBLuaJIT\fR is open source software, released under the MIT license.
.SH SEE ALSO .SH SEE ALSO

View File

@ -2,7 +2,7 @@
majver=2 majver=2
minver=1 minver=1
relver=0 relver=0
version=${majver}.${minver}.${relver}-beta2 version=${majver}.${minver}.${relver}-beta3
abiver=5.1 abiver=5.1
prefix=/usr/local prefix=/usr/local

View File

@ -7,7 +7,7 @@
# Also works with MinGW and Cygwin on Windows. # Also works with MinGW and Cygwin on Windows.
# Please check msvcbuild.bat for building with MSVC on Windows. # Please check msvcbuild.bat for building with MSVC on Windows.
# #
# Copyright (C) 2005-2016 Mike Pall. See Copyright Notice in luajit.h # Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h
############################################################################## ##############################################################################
MAJVER= 2 MAJVER= 2
@ -110,6 +110,9 @@ XCFLAGS=
#XCFLAGS+= -DLUAJIT_NUMMODE=1 #XCFLAGS+= -DLUAJIT_NUMMODE=1
#XCFLAGS+= -DLUAJIT_NUMMODE=2 #XCFLAGS+= -DLUAJIT_NUMMODE=2
# #
# Enable GC64 mode for x64.
#XCFLAGS+= -DLUAJIT_ENABLE_GC64
#
############################################################################## ##############################################################################
############################################################################## ##############################################################################
@ -206,7 +209,7 @@ TARGET_CC= $(STATIC_CC)
TARGET_STCC= $(STATIC_CC) TARGET_STCC= $(STATIC_CC)
TARGET_DYNCC= $(DYNAMIC_CC) TARGET_DYNCC= $(DYNAMIC_CC)
TARGET_LD= $(CROSS)$(CC) TARGET_LD= $(CROSS)$(CC)
TARGET_AR= $(CROSS)ar rcus TARGET_AR= $(CROSS)ar rcus 2>/dev/null
TARGET_STRIP= $(CROSS)strip TARGET_STRIP= $(CROSS)strip
TARGET_LIBPATH= $(or $(PREFIX),/usr/local)/$(or $(MULTILIB),lib) TARGET_LIBPATH= $(or $(PREFIX),/usr/local)/$(or $(MULTILIB),lib)
@ -239,6 +242,9 @@ ifneq (,$(findstring LJ_TARGET_ARM ,$(TARGET_TESTARCH)))
TARGET_LJARCH= arm TARGET_LJARCH= arm
else else
ifneq (,$(findstring LJ_TARGET_ARM64 ,$(TARGET_TESTARCH))) ifneq (,$(findstring LJ_TARGET_ARM64 ,$(TARGET_TESTARCH)))
ifneq (,$(findstring __AARCH64EB__ ,$(TARGET_TESTARCH)))
TARGET_ARCH= -D__AARCH64EB__=1
endif
TARGET_LJARCH= arm64 TARGET_LJARCH= arm64
else else
ifneq (,$(findstring LJ_TARGET_PPC ,$(TARGET_TESTARCH))) ifneq (,$(findstring LJ_TARGET_PPC ,$(TARGET_TESTARCH)))
@ -310,7 +316,6 @@ ifeq (Darwin,$(TARGET_SYS))
export MACOSX_DEPLOYMENT_TARGET=10.4 export MACOSX_DEPLOYMENT_TARGET=10.4
endif endif
TARGET_STRIP+= -x TARGET_STRIP+= -x
TARGET_AR+= 2>/dev/null
TARGET_XSHLDFLAGS= -dynamiclib -single_module -undefined dynamic_lookup -fPIC TARGET_XSHLDFLAGS= -dynamiclib -single_module -undefined dynamic_lookup -fPIC
TARGET_DYNXLDOPTS= TARGET_DYNXLDOPTS=
TARGET_XSHLDFLAGS+= -install_name $(TARGET_DYLIBPATH) -compatibility_version $(MAJVER).$(MINVER) -current_version $(MAJVER).$(MINVER).$(RELVER) TARGET_XSHLDFLAGS+= -install_name $(TARGET_DYLIBPATH) -compatibility_version $(MAJVER).$(MINVER) -current_version $(MAJVER).$(MINVER).$(RELVER)
@ -321,7 +326,6 @@ ifeq (Darwin,$(TARGET_SYS))
else else
ifeq (iOS,$(TARGET_SYS)) ifeq (iOS,$(TARGET_SYS))
TARGET_STRIP+= -x TARGET_STRIP+= -x
TARGET_AR+= 2>/dev/null
TARGET_XSHLDFLAGS= -dynamiclib -single_module -undefined dynamic_lookup -fPIC TARGET_XSHLDFLAGS= -dynamiclib -single_module -undefined dynamic_lookup -fPIC
TARGET_DYNXLDOPTS= TARGET_DYNXLDOPTS=
TARGET_XSHLDFLAGS+= -install_name $(TARGET_DYLIBPATH) -compatibility_version $(MAJVER).$(MINVER) -current_version $(MAJVER).$(MINVER).$(RELVER) TARGET_XSHLDFLAGS+= -install_name $(TARGET_DYLIBPATH) -compatibility_version $(MAJVER).$(MINVER) -current_version $(MAJVER).$(MINVER).$(RELVER)

View File

@ -3,8 +3,8 @@ lib_aux.o: lib_aux.c lua.h luaconf.h lauxlib.h lj_obj.h lj_def.h \
lj_dispatch.h lj_bc.h lj_traceerr.h lj_lib.h lj_alloc.h lj_dispatch.h lj_bc.h lj_traceerr.h lj_lib.h lj_alloc.h
lib_base.o: lib_base.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h \ lib_base.o: lib_base.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h \
lj_def.h lj_arch.h lj_gc.h lj_err.h lj_errmsg.h lj_debug.h lj_str.h \ lj_def.h lj_arch.h lj_gc.h lj_err.h lj_errmsg.h lj_debug.h lj_str.h \
lj_tab.h lj_meta.h lj_state.h lj_ctype.h lj_cconv.h lj_bc.h lj_ff.h \ lj_tab.h lj_meta.h lj_state.h lj_frame.h lj_bc.h lj_ctype.h lj_cconv.h \
lj_ffdef.h lj_dispatch.h lj_jit.h lj_ir.h lj_char.h lj_strscan.h \ lj_ff.h lj_ffdef.h lj_dispatch.h lj_jit.h lj_ir.h lj_char.h lj_strscan.h \
lj_strfmt.h lj_lib.h lj_libdef.h lj_strfmt.h lj_lib.h lj_libdef.h
lib_bit.o: lib_bit.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h lj_def.h \ lib_bit.o: lib_bit.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h lj_def.h \
lj_arch.h lj_err.h lj_errmsg.h lj_buf.h lj_gc.h lj_str.h lj_strscan.h \ lj_arch.h lj_err.h lj_errmsg.h lj_buf.h lj_gc.h lj_str.h lj_strscan.h \

View File

@ -1,6 +1,6 @@
/* /*
** LuaJIT VM builder. ** LuaJIT VM builder.
** Copyright (C) 2005-2016 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h
** **
** This is a tool to build the hand-tuned assembler code required for ** This is a tool to build the hand-tuned assembler code required for
** LuaJIT's bytecode interpreter. It supports a variety of output formats ** LuaJIT's bytecode interpreter. It supports a variety of output formats

View File

@ -1,6 +1,6 @@
/* /*
** LuaJIT VM builder. ** LuaJIT VM builder.
** Copyright (C) 2005-2016 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h
*/ */
#ifndef _BUILDVM_H #ifndef _BUILDVM_H

View File

@ -1,6 +1,6 @@
/* /*
** LuaJIT VM builder: Assembler source code emitter. ** LuaJIT VM builder: Assembler source code emitter.
** Copyright (C) 2005-2016 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h
*/ */
#include "buildvm.h" #include "buildvm.h"
@ -93,10 +93,14 @@ static void emit_asm_words(BuildCtx *ctx, uint8_t *p, int n)
{ {
int i; int i;
for (i = 0; i < n; i += 4) { for (i = 0; i < n; i += 4) {
uint32_t ins = *(uint32_t *)(p+i);
#if LJ_TARGET_ARM64 && LJ_BE
ins = lj_bswap(ins); /* ARM64 instructions are always little-endian. */
#endif
if ((i & 15) == 0) if ((i & 15) == 0)
fprintf(ctx->fp, "\t.long 0x%08x", *(uint32_t *)(p+i)); fprintf(ctx->fp, "\t.long 0x%08x", ins);
else else
fprintf(ctx->fp, ",0x%08x", *(uint32_t *)(p+i)); fprintf(ctx->fp, ",0x%08x", ins);
if ((i & 15) == 12) putc('\n', ctx->fp); if ((i & 15) == 12) putc('\n', ctx->fp);
} }
if ((n & 15) != 0) putc('\n', ctx->fp); if ((n & 15) != 0) putc('\n', ctx->fp);
@ -222,7 +226,8 @@ static void emit_asm_label(BuildCtx *ctx, const char *name, int size, int isfunc
case BUILD_machasm: case BUILD_machasm:
fprintf(ctx->fp, fprintf(ctx->fp,
"\n\t.private_extern %s\n" "\n\t.private_extern %s\n"
"%s:\n", name, name); "\t.no_dead_strip %s\n"
"%s:\n", name, name, name);
break; break;
default: default:
break; break;

View File

@ -1,6 +1,6 @@
/* /*
** LuaJIT VM builder: IR folding hash table generator. ** LuaJIT VM builder: IR folding hash table generator.
** Copyright (C) 2005-2016 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h
*/ */
#include "buildvm.h" #include "buildvm.h"

View File

@ -1,6 +1,6 @@
/* /*
** LuaJIT VM builder: library definition compiler. ** LuaJIT VM builder: library definition compiler.
** Copyright (C) 2005-2016 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h
*/ */
#include "buildvm.h" #include "buildvm.h"

View File

@ -15,7 +15,12 @@ static const uint8_t libbc_code[] = {
8,2,0,0,88,3,23,128,59,3,2,0,43,4,0,0,64,4,2,0,76,3,2,0,88,3,18,128,16,1,14, 8,2,0,0,88,3,23,128,59,3,2,0,43,4,0,0,64,4,2,0,76,3,2,0,88,3,18,128,16,1,14,
0,41,3,1,0,3,3,1,0,88,3,14,128,3,1,2,0,88,3,12,128,59,3,1,0,22,4,1,1,18,5,2, 0,41,3,1,0,3,3,1,0,88,3,14,128,3,1,2,0,88,3,12,128,59,3,1,0,22,4,1,1,18,5,2,
0,41,6,1,0,77,4,4,128,23,8,1,7,59,9,7,0,64,9,8,0,79,4,252,127,43,4,0,0,64,4, 0,41,6,1,0,77,4,4,128,23,8,1,7,59,9,7,0,64,9,8,0,79,4,252,127,43,4,0,0,64,4,
2,0,76,3,2,0,75,0,1,0,0,2,0 2,0,76,3,2,0,75,0,1,0,0,2,0,5,12,0,0,0,35,16,0,12,0,16,1,14,0,16,2,14,0,16,
3,14,0,11,4,0,0,88,5,1,128,18,4,0,0,16,4,12,0,3,1,2,0,88,5,24,128,33,5,1,3,
0,2,3,0,88,6,4,128,2,3,1,0,88,6,2,128,4,4,0,0,88,6,9,128,18,6,1,0,18,7,2,0,
41,8,1,0,77,6,4,128,32,10,5,9,59,11,9,0,64,11,10,4,79,6,252,127,88,6,8,128,
18,6,2,0,18,7,1,0,41,8,255,255,77,6,4,128,32,10,5,9,59,11,9,0,64,11,10,4,79,
6,252,127,76,4,2,0,0
#else #else
0,1,2,0,0,1,2,24,1,0,0,76,1,2,0,241,135,158,166,3,220,203,178,130,4,0,1,2,0, 0,1,2,0,0,1,2,24,1,0,0,76,1,2,0,241,135,158,166,3,220,203,178,130,4,0,1,2,0,
0,1,2,24,1,0,0,76,1,2,0,243,244,148,165,20,198,190,199,252,3,0,1,2,0,0,0,3, 0,1,2,24,1,0,0,76,1,2,0,243,244,148,165,20,198,190,199,252,3,0,1,2,0,0,0,3,
@ -28,7 +33,12 @@ static const uint8_t libbc_code[] = {
8,2,0,0,88,3,23,128,59,3,2,0,43,4,0,0,64,4,2,0,76,3,2,0,88,3,18,128,16,1,14, 8,2,0,0,88,3,23,128,59,3,2,0,43,4,0,0,64,4,2,0,76,3,2,0,88,3,18,128,16,1,14,
0,41,3,1,0,3,3,1,0,88,3,14,128,3,1,2,0,88,3,12,128,59,3,1,0,22,4,1,1,18,5,2, 0,41,3,1,0,3,3,1,0,88,3,14,128,3,1,2,0,88,3,12,128,59,3,1,0,22,4,1,1,18,5,2,
0,41,6,1,0,77,4,4,128,23,8,1,7,59,9,7,0,64,9,8,0,79,4,252,127,43,4,0,0,64,4, 0,41,6,1,0,77,4,4,128,23,8,1,7,59,9,7,0,64,9,8,0,79,4,252,127,43,4,0,0,64,4,
2,0,76,3,2,0,75,0,1,0,0,2,0 2,0,76,3,2,0,75,0,1,0,0,2,0,5,12,0,0,0,35,16,0,12,0,16,1,14,0,16,2,14,0,16,
3,14,0,11,4,0,0,88,5,1,128,18,4,0,0,16,4,12,0,3,1,2,0,88,5,24,128,33,5,1,3,
0,2,3,0,88,6,4,128,2,3,1,0,88,6,2,128,4,4,0,0,88,6,9,128,18,6,1,0,18,7,2,0,
41,8,1,0,77,6,4,128,32,10,5,9,59,11,9,0,64,11,10,4,79,6,252,127,88,6,8,128,
18,6,2,0,18,7,1,0,41,8,255,255,77,6,4,128,32,10,5,9,59,11,9,0,64,11,10,4,79,
6,252,127,76,4,2,0,0
#endif #endif
}; };
@ -40,6 +50,7 @@ static const struct { const char *name; int ofs; } libbc_map[] = {
{"table_foreach",136}, {"table_foreach",136},
{"table_getn",207}, {"table_getn",207},
{"table_remove",226}, {"table_remove",226},
{NULL,355} {"table_move",355},
{NULL,502}
}; };

View File

@ -1,6 +1,6 @@
/* /*
** LuaJIT VM builder: PE object emitter. ** LuaJIT VM builder: PE object emitter.
** Copyright (C) 2005-2016 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h
** **
** Only used for building on Windows, since we cannot assume the presence ** Only used for building on Windows, since we cannot assume the presence
** of a suitable assembler. The host and target byte order must match. ** of a suitable assembler. The host and target byte order must match.

View File

@ -2,7 +2,7 @@
-- Lua script to dump the bytecode of the library functions written in Lua. -- Lua script to dump the bytecode of the library functions written in Lua.
-- The resulting 'buildvm_libbc.h' is used for the build process of LuaJIT. -- The resulting 'buildvm_libbc.h' is used for the build process of LuaJIT.
---------------------------------------------------------------------------- ----------------------------------------------------------------------------
-- Copyright (C) 2005-2016 Mike Pall. All rights reserved. -- Copyright (C) 2005-2017 Mike Pall. All rights reserved.
-- Released under the MIT license. See Copyright Notice in luajit.h -- Released under the MIT license. See Copyright Notice in luajit.h
---------------------------------------------------------------------------- ----------------------------------------------------------------------------

View File

@ -2,7 +2,7 @@
-- Lua script to generate a customized, minified version of Lua. -- Lua script to generate a customized, minified version of Lua.
-- The resulting 'minilua' is used for the build process of LuaJIT. -- The resulting 'minilua' is used for the build process of LuaJIT.
---------------------------------------------------------------------------- ----------------------------------------------------------------------------
-- Copyright (C) 2005-2016 Mike Pall. All rights reserved. -- Copyright (C) 2005-2017 Mike Pall. All rights reserved.
-- Released under the MIT license. See Copyright Notice in luajit.h -- Released under the MIT license. See Copyright Notice in luajit.h
---------------------------------------------------------------------------- ----------------------------------------------------------------------------

View File

@ -1,7 +1,7 @@
---------------------------------------------------------------------------- ----------------------------------------------------------------------------
-- LuaJIT bytecode listing module. -- LuaJIT bytecode listing module.
-- --
-- Copyright (C) 2005-2016 Mike Pall. All rights reserved. -- Copyright (C) 2005-2017 Mike Pall. All rights reserved.
-- Released under the MIT license. See Copyright Notice in luajit.h -- Released under the MIT license. See Copyright Notice in luajit.h
---------------------------------------------------------------------------- ----------------------------------------------------------------------------
-- --

View File

@ -1,7 +1,7 @@
---------------------------------------------------------------------------- ----------------------------------------------------------------------------
-- LuaJIT module to save/list bytecode. -- LuaJIT module to save/list bytecode.
-- --
-- Copyright (C) 2005-2016 Mike Pall. All rights reserved. -- Copyright (C) 2005-2017 Mike Pall. All rights reserved.
-- Released under the MIT license. See Copyright Notice in luajit.h -- Released under the MIT license. See Copyright Notice in luajit.h
---------------------------------------------------------------------------- ----------------------------------------------------------------------------
-- --
@ -63,8 +63,8 @@ local map_type = {
} }
local map_arch = { local map_arch = {
x86 = true, x64 = true, arm = true, arm64 = true, ppc = true, x86 = true, x64 = true, arm = true, arm64 = true, arm64be = true,
mips = true, mipsel = true, ppc = true, mips = true, mipsel = true,
} }
local map_os = { local map_os = {
@ -200,7 +200,7 @@ typedef struct {
]] ]]
local symname = LJBC_PREFIX..ctx.modname local symname = LJBC_PREFIX..ctx.modname
local is64, isbe = false, false local is64, isbe = false, false
if ctx.arch == "x64" or ctx.arch == "arm64" then if ctx.arch == "x64" or ctx.arch == "arm64" or ctx.arch == "arm64be" then
is64 = true is64 = true
elseif ctx.arch == "ppc" or ctx.arch == "mips" then elseif ctx.arch == "ppc" or ctx.arch == "mips" then
isbe = true isbe = true
@ -237,9 +237,9 @@ typedef struct {
hdr.eendian = isbe and 2 or 1 hdr.eendian = isbe and 2 or 1
hdr.eversion = 1 hdr.eversion = 1
hdr.type = f16(1) hdr.type = f16(1)
hdr.machine = f16(({ x86=3, x64=62, arm=40, arm64=183, ppc=20, mips=8, mipsel=8 })[ctx.arch]) hdr.machine = f16(({ x86=3, x64=62, arm=40, arm64=183, arm64be=183, ppc=20, mips=8, mipsel=8 })[ctx.arch])
if ctx.arch == "mips" or ctx.arch == "mipsel" then if ctx.arch == "mips" or ctx.arch == "mipsel" then
hdr.flags = 0x50001006 hdr.flags = f32(0x50001006)
end end
hdr.version = f32(1) hdr.version = f32(1)
hdr.shofs = fofs(ffi.offsetof(o, "sect")) hdr.shofs = fofs(ffi.offsetof(o, "sect"))

View File

@ -1,7 +1,7 @@
---------------------------------------------------------------------------- ----------------------------------------------------------------------------
-- LuaJIT ARM disassembler module. -- LuaJIT ARM disassembler module.
-- --
-- Copyright (C) 2005-2016 Mike Pall. All rights reserved. -- Copyright (C) 2005-2017 Mike Pall. All rights reserved.
-- Released under the MIT license. See Copyright Notice in luajit.h -- Released under the MIT license. See Copyright Notice in luajit.h
---------------------------------------------------------------------------- ----------------------------------------------------------------------------
-- This is a helper module used by the LuaJIT machine code dumper module. -- This is a helper module used by the LuaJIT machine code dumper module.

1216
src/jit/dis_arm64.lua Normal file

File diff suppressed because it is too large Load Diff

12
src/jit/dis_arm64be.lua Normal file
View File

@ -0,0 +1,12 @@
----------------------------------------------------------------------------
-- LuaJIT ARM64BE disassembler wrapper module.
--
-- Copyright (C) 2005-2017 Mike Pall. All rights reserved.
-- Released under the MIT license. See Copyright Notice in luajit.h
----------------------------------------------------------------------------
-- ARM64 instructions are always little-endian. So just forward to the
-- common ARM64 disassembler module. All the interesting stuff is there.
------------------------------------------------------------------------------
return require((string.match(..., ".*%.") or "").."dis_arm64")

View File

@ -1,7 +1,7 @@
---------------------------------------------------------------------------- ----------------------------------------------------------------------------
-- LuaJIT MIPS disassembler module. -- LuaJIT MIPS disassembler module.
-- --
-- Copyright (C) 2005-2016 Mike Pall. All rights reserved. -- Copyright (C) 2005-2017 Mike Pall. All rights reserved.
-- Released under the MIT/X license. See Copyright Notice in luajit.h -- Released under the MIT/X license. See Copyright Notice in luajit.h
---------------------------------------------------------------------------- ----------------------------------------------------------------------------
-- This is a helper module used by the LuaJIT machine code dumper module. -- This is a helper module used by the LuaJIT machine code dumper module.
@ -34,15 +34,17 @@ local map_special = {
"jrS", "jalrD1S", "movzDST", "movnDST", "jrS", "jalrD1S", "movzDST", "movnDST",
"syscallY", "breakY", false, "sync", "syscallY", "breakY", false, "sync",
"mfhiD", "mthiS", "mfloD", "mtloS", "mfhiD", "mthiS", "mfloD", "mtloS",
false, false, false, false, "dsllvDST", false, "dsrlvDST", "dsravDST",
"multST", "multuST", "divST", "divuST", "multST", "multuST", "divST", "divuST",
false, false, false, false, "dmultST", "dmultuST", "ddivST", "ddivuST",
"addDST", "addu|moveDST0", "subDST", "subu|neguDS0T", "addDST", "addu|moveDST0", "subDST", "subu|neguDS0T",
"andDST", "or|moveDST0", "xorDST", "nor|notDST0", "andDST", "or|moveDST0", "xorDST", "nor|notDST0",
false, false, "sltDST", "sltuDST", false, false, "sltDST", "sltuDST",
false, false, false, false, "daddDST", "dadduDST", "dsubDST", "dsubuDST",
"tgeSTZ", "tgeuSTZ", "tltSTZ", "tltuSTZ", "tgeSTZ", "tgeuSTZ", "tltSTZ", "tltuSTZ",
"teqSTZ", false, "tneSTZ", "teqSTZ", false, "tneSTZ", false,
"dsllDTA", false, "dsrlDTA", "dsraDTA",
"dsll32DTA", false, "dsrl32DTA", "dsra32DTA",
} }
local map_special2 = { local map_special2 = {
@ -60,11 +62,17 @@ local map_bshfl = {
[24] = "sehDT", [24] = "sehDT",
} }
local map_dbshfl = {
shift = 6, mask = 31,
[2] = "dsbhDT",
[5] = "dshdDT",
}
local map_special3 = { local map_special3 = {
shift = 0, mask = 63, shift = 0, mask = 63,
[0] = "extTSAK", [4] = "insTSAL", [0] = "extTSAK", [1] = "dextmTSAP", [3] = "dextTSAK",
[32] = map_bshfl, [4] = "insTSAL", [6] = "dinsuTSEQ", [7] = "dinsTSAL",
[59] = "rdhwrTD", [32] = map_bshfl, [36] = map_dbshfl, [59] = "rdhwrTD",
} }
local map_regimm = { local map_regimm = {
@ -178,8 +186,8 @@ local map_cop1bc = {
local map_cop1 = { local map_cop1 = {
shift = 21, mask = 31, shift = 21, mask = 31,
[0] = "mfc1TG", false, "cfc1TG", "mfhc1TG", [0] = "mfc1TG", "dmfc1TG", "cfc1TG", "mfhc1TG",
"mtc1TG", false, "ctc1TG", "mthc1TG", "mtc1TG", "dmtc1TG", "ctc1TG", "mthc1TG",
map_cop1bc, false, false, false, map_cop1bc, false, false, false,
false, false, false, false, false, false, false, false,
map_cop1s, map_cop1d, false, false, map_cop1s, map_cop1d, false, false,
@ -213,16 +221,16 @@ local map_pri = {
"andiTSU", "ori|liTS0U", "xoriTSU", "luiTU", "andiTSU", "ori|liTS0U", "xoriTSU", "luiTU",
map_cop0, map_cop1, false, map_cop1x, map_cop0, map_cop1, false, map_cop1x,
"beql|beqzlST0B", "bnel|bnezlST0B", "blezlSB", "bgtzlSB", "beql|beqzlST0B", "bnel|bnezlST0B", "blezlSB", "bgtzlSB",
false, false, false, false, "daddiTSI", "daddiuTSI", false, false,
map_special2, "jalxJ", false, map_special3, map_special2, "jalxJ", false, map_special3,
"lbTSO", "lhTSO", "lwlTSO", "lwTSO", "lbTSO", "lhTSO", "lwlTSO", "lwTSO",
"lbuTSO", "lhuTSO", "lwrTSO", false, "lbuTSO", "lhuTSO", "lwrTSO", false,
"sbTSO", "shTSO", "swlTSO", "swTSO", "sbTSO", "shTSO", "swlTSO", "swTSO",
false, false, "swrTSO", "cacheNSO", false, false, "swrTSO", "cacheNSO",
"llTSO", "lwc1HSO", "lwc2TSO", "prefNSO", "llTSO", "lwc1HSO", "lwc2TSO", "prefNSO",
false, "ldc1HSO", "ldc2TSO", false, false, "ldc1HSO", "ldc2TSO", "ldTSO",
"scTSO", "swc1HSO", "swc2TSO", false, "scTSO", "swc1HSO", "swc2TSO", false,
false, "sdc1HSO", "sdc2TSO", false, false, "sdc1HSO", "sdc2TSO", "sdTSO",
} }
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
@ -306,6 +314,8 @@ local function disass_ins(ctx)
x = "f"..band(rshift(op, 21), 31) x = "f"..band(rshift(op, 21), 31)
elseif p == "A" then elseif p == "A" then
x = band(rshift(op, 6), 31) x = band(rshift(op, 6), 31)
elseif p == "E" then
x = band(rshift(op, 6), 31) + 32
elseif p == "M" then elseif p == "M" then
x = band(rshift(op, 11), 31) x = band(rshift(op, 11), 31)
elseif p == "N" then elseif p == "N" then
@ -315,8 +325,12 @@ local function disass_ins(ctx)
if x == 0 then x = nil end if x == 0 then x = nil end
elseif p == "K" then elseif p == "K" then
x = band(rshift(op, 11), 31) + 1 x = band(rshift(op, 11), 31) + 1
elseif p == "P" then
x = band(rshift(op, 11), 31) + 33
elseif p == "L" then elseif p == "L" then
x = band(rshift(op, 11), 31) - last + 1 x = band(rshift(op, 11), 31) - last + 1
elseif p == "Q" then
x = band(rshift(op, 11), 31) - last + 33
elseif p == "I" then elseif p == "I" then
x = arshift(lshift(op, 16), 16) x = arshift(lshift(op, 16), 16)
elseif p == "U" then elseif p == "U" then
@ -330,11 +344,12 @@ local function disass_ins(ctx)
elseif p == "B" then elseif p == "B" then
x = ctx.addr + ctx.pos + arshift(lshift(op, 16), 16)*4 + 4 x = ctx.addr + ctx.pos + arshift(lshift(op, 16), 16)*4 + 4
ctx.rel = x ctx.rel = x
x = "0x"..tohex(x) x = format("0x%08x", x)
elseif p == "J" then elseif p == "J" then
x = band(ctx.addr + ctx.pos, 0xf0000000) + band(op, 0x03ffffff)*4 local a = ctx.addr + ctx.pos
x = a - band(a, 0x0fffffff) + band(op, 0x03ffffff)*4
ctx.rel = x ctx.rel = x
x = "0x"..tohex(x) x = format("0x%08x", x)
elseif p == "V" then elseif p == "V" then
x = band(rshift(op, 8), 7) x = band(rshift(op, 8), 7)
if x == 0 then x = nil end if x == 0 then x = nil end

17
src/jit/dis_mips64.lua Normal file
View File

@ -0,0 +1,17 @@
----------------------------------------------------------------------------
-- LuaJIT MIPS64 disassembler wrapper module.
--
-- Copyright (C) 2005-2017 Mike Pall. All rights reserved.
-- Released under the MIT license. See Copyright Notice in luajit.h
----------------------------------------------------------------------------
-- This module just exports the big-endian functions from the
-- MIPS disassembler module. All the interesting stuff is there.
------------------------------------------------------------------------------
local dis_mips = require((string.match(..., ".*%.") or "").."dis_mips")
return {
create = dis_mips.create,
disass = dis_mips.disass,
regname = dis_mips.regname
}

17
src/jit/dis_mips64el.lua Normal file
View File

@ -0,0 +1,17 @@
----------------------------------------------------------------------------
-- LuaJIT MIPS64EL disassembler wrapper module.
--
-- Copyright (C) 2005-2017 Mike Pall. All rights reserved.
-- Released under the MIT license. See Copyright Notice in luajit.h
----------------------------------------------------------------------------
-- This module just exports the little-endian functions from the
-- MIPS disassembler module. All the interesting stuff is there.
------------------------------------------------------------------------------
local dis_mips = require((string.match(..., ".*%.") or "").."dis_mips")
return {
create = dis_mips.create_el,
disass = dis_mips.disass_el,
regname = dis_mips.regname
}

View File

@ -1,7 +1,7 @@
---------------------------------------------------------------------------- ----------------------------------------------------------------------------
-- LuaJIT MIPSEL disassembler wrapper module. -- LuaJIT MIPSEL disassembler wrapper module.
-- --
-- Copyright (C) 2005-2016 Mike Pall. All rights reserved. -- Copyright (C) 2005-2017 Mike Pall. All rights reserved.
-- Released under the MIT license. See Copyright Notice in luajit.h -- Released under the MIT license. See Copyright Notice in luajit.h
---------------------------------------------------------------------------- ----------------------------------------------------------------------------
-- This module just exports the little-endian functions from the -- This module just exports the little-endian functions from the

View File

@ -1,7 +1,7 @@
---------------------------------------------------------------------------- ----------------------------------------------------------------------------
-- LuaJIT PPC disassembler module. -- LuaJIT PPC disassembler module.
-- --
-- Copyright (C) 2005-2016 Mike Pall. All rights reserved. -- Copyright (C) 2005-2017 Mike Pall. All rights reserved.
-- Released under the MIT/X license. See Copyright Notice in luajit.h -- Released under the MIT/X license. See Copyright Notice in luajit.h
---------------------------------------------------------------------------- ----------------------------------------------------------------------------
-- This is a helper module used by the LuaJIT machine code dumper module. -- This is a helper module used by the LuaJIT machine code dumper module.

View File

@ -1,7 +1,7 @@
---------------------------------------------------------------------------- ----------------------------------------------------------------------------
-- LuaJIT x64 disassembler wrapper module. -- LuaJIT x64 disassembler wrapper module.
-- --
-- Copyright (C) 2005-2016 Mike Pall. All rights reserved. -- Copyright (C) 2005-2017 Mike Pall. All rights reserved.
-- Released under the MIT license. See Copyright Notice in luajit.h -- Released under the MIT license. See Copyright Notice in luajit.h
---------------------------------------------------------------------------- ----------------------------------------------------------------------------
-- This module just exports the 64 bit functions from the combined -- This module just exports the 64 bit functions from the combined

View File

@ -1,7 +1,7 @@
---------------------------------------------------------------------------- ----------------------------------------------------------------------------
-- LuaJIT x86/x64 disassembler module. -- LuaJIT x86/x64 disassembler module.
-- --
-- Copyright (C) 2005-2016 Mike Pall. All rights reserved. -- Copyright (C) 2005-2017 Mike Pall. All rights reserved.
-- Released under the MIT license. See Copyright Notice in luajit.h -- Released under the MIT license. See Copyright Notice in luajit.h
---------------------------------------------------------------------------- ----------------------------------------------------------------------------
-- This is a helper module used by the LuaJIT machine code dumper module. -- This is a helper module used by the LuaJIT machine code dumper module.

View File

@ -1,7 +1,7 @@
---------------------------------------------------------------------------- ----------------------------------------------------------------------------
-- LuaJIT compiler dump module. -- LuaJIT compiler dump module.
-- --
-- Copyright (C) 2005-2016 Mike Pall. All rights reserved. -- Copyright (C) 2005-2017 Mike Pall. All rights reserved.
-- Released under the MIT license. See Copyright Notice in luajit.h -- Released under the MIT license. See Copyright Notice in luajit.h
---------------------------------------------------------------------------- ----------------------------------------------------------------------------
-- --
@ -85,7 +85,7 @@ local nexitsym = 0
local function fillsymtab_tr(tr, nexit) local function fillsymtab_tr(tr, nexit)
local t = {} local t = {}
symtabmt.__index = t symtabmt.__index = t
if jit.arch == "mips" or jit.arch == "mipsel" then if jit.arch:sub(1, 4) == "mips" then
t[traceexitstub(tr, 0)] = "exit" t[traceexitstub(tr, 0)] = "exit"
return return
end end
@ -338,6 +338,8 @@ local function formatk(tr, idx, sn)
elseif t == 21 then -- int64_t elseif t == 21 then -- int64_t
s = sub(tostring(k), 1, -3) s = sub(tostring(k), 1, -3)
if sub(s, 1, 1) ~= "-" then s = "+"..s end if sub(s, 1, 1) ~= "-" then s = "+"..s end
elseif sn == 0x1057fff then -- SNAP(1, SNAP_FRAME | SNAP_NORESTORE, REF_NIL)
return "----" -- Special case for LJ_FR2 slot 1.
else else
s = tostring(k) -- For primitives. s = tostring(k) -- For primitives.
end end
@ -554,7 +556,7 @@ local function dump_trace(what, tr, func, pc, otr, oex)
if what == "start" then if what == "start" then
if dumpmode.H then out:write('<pre class="ljdump">\n') end if dumpmode.H then out:write('<pre class="ljdump">\n') end
out:write("---- TRACE ", tr, " ", what) out:write("---- TRACE ", tr, " ", what)
if otr then out:write(" ", otr, "/", oex) end if otr then out:write(" ", otr, "/", oex == -1 and "stitch" or oex) end
out:write(" ", fmtfunc(func, pc), "\n") out:write(" ", fmtfunc(func, pc), "\n")
elseif what == "stop" or what == "abort" then elseif what == "stop" or what == "abort" then
out:write("---- TRACE ", tr, " ", what) out:write("---- TRACE ", tr, " ", what)
@ -653,7 +655,8 @@ end
local function dumpon(opt, outfile) local function dumpon(opt, outfile)
if active then dumpoff() end if active then dumpoff() end
local colormode = os.getenv("COLORTERM") and "A" or "T" local term = os.getenv("TERM")
local colormode = (term and term:match("color") or os.getenv("COLORTERM")) and "A" or "T"
if opt then if opt then
opt = gsub(opt, "[TAH]", function(mode) colormode = mode; return ""; end) opt = gsub(opt, "[TAH]", function(mode) colormode = mode; return ""; end)
end end

View File

@ -1,7 +1,7 @@
---------------------------------------------------------------------------- ----------------------------------------------------------------------------
-- LuaJIT profiler. -- LuaJIT profiler.
-- --
-- Copyright (C) 2005-2016 Mike Pall. All rights reserved. -- Copyright (C) 2005-2017 Mike Pall. All rights reserved.
-- Released under the MIT license. See Copyright Notice in luajit.h -- Released under the MIT license. See Copyright Notice in luajit.h
---------------------------------------------------------------------------- ----------------------------------------------------------------------------
-- --
@ -156,6 +156,7 @@ local function prof_annotate(count1, samples)
ms = math.max(ms, v) ms = math.max(ms, v)
if pct >= prof_min then if pct >= prof_min then
local file, line = k:match("^(.*):(%d+)$") local file, line = k:match("^(.*):(%d+)$")
if not file then file = k; line = 0 end
local fl = files[file] local fl = files[file]
if not fl then fl = {}; files[file] = fl; files[#files+1] = file end if not fl then fl = {}; files[file] = fl; files[#files+1] = file end
line = tonumber(line) line = tonumber(line)

View File

@ -1,7 +1,7 @@
---------------------------------------------------------------------------- ----------------------------------------------------------------------------
-- Verbose mode of the LuaJIT compiler. -- Verbose mode of the LuaJIT compiler.
-- --
-- Copyright (C) 2005-2016 Mike Pall. All rights reserved. -- Copyright (C) 2005-2017 Mike Pall. All rights reserved.
-- Released under the MIT license. See Copyright Notice in luajit.h -- Released under the MIT license. See Copyright Notice in luajit.h
---------------------------------------------------------------------------- ----------------------------------------------------------------------------
-- --
@ -99,7 +99,7 @@ end
local function dump_trace(what, tr, func, pc, otr, oex) local function dump_trace(what, tr, func, pc, otr, oex)
if what == "start" then if what == "start" then
startloc = fmtfunc(func, pc) startloc = fmtfunc(func, pc)
startex = otr and "("..otr.."/"..oex..") " or "" startex = otr and "("..otr.."/"..(oex == -1 and "stitch" or oex)..") " or ""
else else
if what == "abort" then if what == "abort" then
local loc = fmtfunc(func, pc) local loc = fmtfunc(func, pc)

View File

@ -1,7 +1,7 @@
---------------------------------------------------------------------------- ----------------------------------------------------------------------------
-- LuaJIT profiler zones. -- LuaJIT profiler zones.
-- --
-- Copyright (C) 2005-2016 Mike Pall. All rights reserved. -- Copyright (C) 2005-2017 Mike Pall. All rights reserved.
-- Released under the MIT license. See Copyright Notice in luajit.h -- Released under the MIT license. See Copyright Notice in luajit.h
---------------------------------------------------------------------------- ----------------------------------------------------------------------------
-- --

View File

@ -15,9 +15,6 @@
#include "lua.h" #include "lua.h"
#define luaL_getn(L,i) ((int)lua_objlen(L, i))
#define luaL_setn(L,i,j) ((void)0) /* no op! */
/* extra error code for `luaL_load' */ /* extra error code for `luaL_load' */
#define LUA_ERRFILE (LUA_ERRERR+1) #define LUA_ERRFILE (LUA_ERRERR+1)
@ -58,6 +55,10 @@ LUALIB_API int (luaL_error) (lua_State *L, const char *fmt, ...);
LUALIB_API int (luaL_checkoption) (lua_State *L, int narg, const char *def, LUALIB_API int (luaL_checkoption) (lua_State *L, int narg, const char *def,
const char *const lst[]); const char *const lst[]);
/* pre-defined references */
#define LUA_NOREF (-2)
#define LUA_REFNIL (-1)
LUALIB_API int (luaL_ref) (lua_State *L, int t); LUALIB_API int (luaL_ref) (lua_State *L, int t);
LUALIB_API void (luaL_unref) (lua_State *L, int t, int ref); LUALIB_API void (luaL_unref) (lua_State *L, int t, int ref);
@ -84,6 +85,11 @@ LUALIB_API int (luaL_loadbufferx) (lua_State *L, const char *buff, size_t sz,
const char *name, const char *mode); const char *name, const char *mode);
LUALIB_API void luaL_traceback (lua_State *L, lua_State *L1, const char *msg, LUALIB_API void luaL_traceback (lua_State *L, lua_State *L1, const char *msg,
int level); int level);
LUALIB_API void (luaL_setfuncs) (lua_State *L, const luaL_Reg *l, int nup);
LUALIB_API void (luaL_pushmodule) (lua_State *L, const char *modname,
int sizehint);
LUALIB_API void *(luaL_testudata) (lua_State *L, int ud, const char *tname);
LUALIB_API void (luaL_setmetatable) (lua_State *L, const char *tname);
/* /*
@ -113,6 +119,11 @@ LUALIB_API void luaL_traceback (lua_State *L, lua_State *L1, const char *msg,
#define luaL_opt(L,f,n,d) (lua_isnoneornil(L,(n)) ? (d) : f(L,(n))) #define luaL_opt(L,f,n,d) (lua_isnoneornil(L,(n)) ? (d) : f(L,(n)))
/* From Lua 5.2. */
#define luaL_newlibtable(L, l) \
lua_createtable(L, 0, sizeof(l)/sizeof((l)[0]) - 1)
#define luaL_newlib(L, l) (luaL_newlibtable(L, l), luaL_setfuncs(L, l, 0))
/* /*
** {====================================================== ** {======================================================
** Generic Buffer manipulation ** Generic Buffer manipulation
@ -147,21 +158,4 @@ LUALIB_API void (luaL_pushresult) (luaL_Buffer *B);
/* }====================================================== */ /* }====================================================== */
/* compatibility with ref system */
/* pre-defined references */
#define LUA_NOREF (-2)
#define LUA_REFNIL (-1)
#define lua_ref(L,lock) ((lock) ? luaL_ref(L, LUA_REGISTRYINDEX) : \
(lua_pushstring(L, "unlocked references are obsolete"), lua_error(L), 0))
#define lua_unref(L,ref) luaL_unref(L, LUA_REGISTRYINDEX, (ref))
#define lua_getref(L,ref) lua_rawgeti(L, LUA_REGISTRYINDEX, (ref))
#define luaL_reg luaL_Reg
#endif #endif

View File

@ -1,6 +1,6 @@
/* /*
** Auxiliary library for the Lua/C API. ** Auxiliary library for the Lua/C API.
** Copyright (C) 2005-2016 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h
** **
** Major parts taken verbatim or adapted from the Lua interpreter. ** Major parts taken verbatim or adapted from the Lua interpreter.
** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h ** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h
@ -107,38 +107,36 @@ LUALIB_API const char *luaL_findtable(lua_State *L, int idx,
static int libsize(const luaL_Reg *l) static int libsize(const luaL_Reg *l)
{ {
int size = 0; int size = 0;
for (; l->name; l++) size++; for (; l && l->name; l++) size++;
return size; return size;
} }
LUALIB_API void luaL_pushmodule(lua_State *L, const char *modname, int sizehint)
{
luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED", 16);
lua_getfield(L, -1, modname);
if (!lua_istable(L, -1)) {
lua_pop(L, 1);
if (luaL_findtable(L, LUA_GLOBALSINDEX, modname, sizehint) != NULL)
lj_err_callerv(L, LJ_ERR_BADMODN, modname);
lua_pushvalue(L, -1);
lua_setfield(L, -3, modname); /* _LOADED[modname] = new table. */
}
lua_remove(L, -2); /* Remove _LOADED table. */
}
LUALIB_API void luaL_openlib(lua_State *L, const char *libname, LUALIB_API void luaL_openlib(lua_State *L, const char *libname,
const luaL_Reg *l, int nup) const luaL_Reg *l, int nup)
{ {
lj_lib_checkfpu(L); lj_lib_checkfpu(L);
if (libname) { if (libname) {
int size = libsize(l); luaL_pushmodule(L, libname, libsize(l));
/* check whether lib already exists */ lua_insert(L, -(nup + 1)); /* Move module table below upvalues. */
luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED", 16);
lua_getfield(L, -1, libname); /* get _LOADED[libname] */
if (!lua_istable(L, -1)) { /* not found? */
lua_pop(L, 1); /* remove previous result */
/* try global variable (and create one if it does not exist) */
if (luaL_findtable(L, LUA_GLOBALSINDEX, libname, size) != NULL)
lj_err_callerv(L, LJ_ERR_BADMODN, libname);
lua_pushvalue(L, -1);
lua_setfield(L, -3, libname); /* _LOADED[libname] = new table */
} }
lua_remove(L, -2); /* remove _LOADED table */ if (l)
lua_insert(L, -(nup+1)); /* move library table to below upvalues */ luaL_setfuncs(L, l, nup);
} else
for (; l->name; l++) { lua_pop(L, nup); /* Remove upvalues. */
int i;
for (i = 0; i < nup; i++) /* copy upvalues to the top */
lua_pushvalue(L, -nup);
lua_pushcclosure(L, l->func, nup);
lua_setfield(L, -(nup+2), l->name);
}
lua_pop(L, nup); /* remove upvalues */
} }
LUALIB_API void luaL_register(lua_State *L, const char *libname, LUALIB_API void luaL_register(lua_State *L, const char *libname,
@ -147,6 +145,19 @@ LUALIB_API void luaL_register(lua_State *L, const char *libname,
luaL_openlib(L, libname, l, 0); luaL_openlib(L, libname, l, 0);
} }
LUALIB_API void luaL_setfuncs(lua_State *L, const luaL_Reg *l, int nup)
{
luaL_checkstack(L, nup, "too many upvalues");
for (; l->name; l++) {
int i;
for (i = 0; i < nup; i++) /* Copy upvalues to the top. */
lua_pushvalue(L, -nup);
lua_pushcclosure(L, l->func, nup);
lua_setfield(L, -(nup + 2), l->name);
}
lua_pop(L, nup); /* Remove upvalues. */
}
LUALIB_API const char *luaL_gsub(lua_State *L, const char *s, LUALIB_API const char *luaL_gsub(lua_State *L, const char *s,
const char *p, const char *r) const char *p, const char *r)
{ {

View File

@ -1,6 +1,6 @@
/* /*
** Base and coroutine library. ** Base and coroutine library.
** Copyright (C) 2005-2016 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h
** **
** Major portions taken verbatim or adapted from the Lua interpreter. ** Major portions taken verbatim or adapted from the Lua interpreter.
** Copyright (C) 1994-2011 Lua.org, PUC-Rio. See Copyright Notice in lua.h ** Copyright (C) 1994-2011 Lua.org, PUC-Rio. See Copyright Notice in lua.h
@ -23,6 +23,7 @@
#include "lj_tab.h" #include "lj_tab.h"
#include "lj_meta.h" #include "lj_meta.h"
#include "lj_state.h" #include "lj_state.h"
#include "lj_frame.h"
#if LJ_HASFFI #if LJ_HASFFI
#include "lj_ctype.h" #include "lj_ctype.h"
#include "lj_cconv.h" #include "lj_cconv.h"
@ -345,7 +346,7 @@ LJLIB_ASM_(xpcall) LJLIB_REC(.)
static int load_aux(lua_State *L, int status, int envarg) static int load_aux(lua_State *L, int status, int envarg)
{ {
if (status == 0) { if (status == LUA_OK) {
if (tvistab(L->base+envarg-1)) { if (tvistab(L->base+envarg-1)) {
GCfunc *fn = funcV(L->top-1); GCfunc *fn = funcV(L->top-1);
GCtab *t = tabV(L->base+envarg-1); GCtab *t = tabV(L->base+envarg-1);
@ -418,7 +419,7 @@ LJLIB_CF(dofile)
GCstr *fname = lj_lib_optstr(L, 1); GCstr *fname = lj_lib_optstr(L, 1);
setnilV(L->top); setnilV(L->top);
L->top = L->base+1; L->top = L->base+1;
if (luaL_loadfile(L, fname ? strdata(fname) : NULL) != 0) if (luaL_loadfile(L, fname ? strdata(fname) : NULL) != LUA_OK)
lua_error(L); lua_error(L);
lua_call(L, 0, LUA_MULTRET); lua_call(L, 0, LUA_MULTRET);
return (int)(L->top - L->base) - 1; return (int)(L->top - L->base) - 1;
@ -536,7 +537,7 @@ LJLIB_CF(coroutine_status)
co = threadV(L->base); co = threadV(L->base);
if (co == L) s = "running"; if (co == L) s = "running";
else if (co->status == LUA_YIELD) s = "suspended"; else if (co->status == LUA_YIELD) s = "suspended";
else if (co->status != 0) s = "dead"; else if (co->status != LUA_OK) s = "dead";
else if (co->base > tvref(co->stack)+1+LJ_FR2) s = "normal"; else if (co->base > tvref(co->stack)+1+LJ_FR2) s = "normal";
else if (co->top == co->base) s = "dead"; else if (co->top == co->base) s = "dead";
else s = "suspended"; else s = "suspended";
@ -557,6 +558,12 @@ LJLIB_CF(coroutine_running)
#endif #endif
} }
LJLIB_CF(coroutine_isyieldable)
{
setboolV(L->top++, cframe_canyield(L->cframe));
return 1;
}
LJLIB_CF(coroutine_create) LJLIB_CF(coroutine_create)
{ {
lua_State *L1; lua_State *L1;
@ -576,7 +583,7 @@ LJLIB_ASM(coroutine_yield)
static int ffh_resume(lua_State *L, lua_State *co, int wrap) static int ffh_resume(lua_State *L, lua_State *co, int wrap)
{ {
if (co->cframe != NULL || co->status > LUA_YIELD || if (co->cframe != NULL || co->status > LUA_YIELD ||
(co->status == 0 && co->top == co->base)) { (co->status == LUA_OK && co->top == co->base)) {
ErrMsg em = co->cframe ? LJ_ERR_CORUN : LJ_ERR_CODEAD; ErrMsg em = co->cframe ? LJ_ERR_CORUN : LJ_ERR_CODEAD;
if (wrap) lj_err_caller(L, em); if (wrap) lj_err_caller(L, em);
setboolV(L->base-1-LJ_FR2, 0); setboolV(L->base-1-LJ_FR2, 0);

View File

@ -1,6 +1,6 @@
/* /*
** Bit manipulation library. ** Bit manipulation library.
** Copyright (C) 2005-2016 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h
*/ */
#define lib_bit_c #define lib_bit_c

View File

@ -1,6 +1,6 @@
/* /*
** Debug library. ** Debug library.
** Copyright (C) 2005-2016 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h
** **
** Major portions taken verbatim or adapted from the Lua interpreter. ** Major portions taken verbatim or adapted from the Lua interpreter.
** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h ** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h
@ -283,13 +283,13 @@ LJLIB_CF(debug_setuservalue)
/* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */
static const char KEY_HOOK = 'h'; #define KEY_HOOK ((void *)0x3004)
static void hookf(lua_State *L, lua_Debug *ar) static void hookf(lua_State *L, lua_Debug *ar)
{ {
static const char *const hooknames[] = static const char *const hooknames[] =
{"call", "return", "line", "count", "tail return"}; {"call", "return", "line", "count", "tail return"};
lua_pushlightuserdata(L, (void *)&KEY_HOOK); lua_pushlightuserdata(L, KEY_HOOK);
lua_rawget(L, LUA_REGISTRYINDEX); lua_rawget(L, LUA_REGISTRYINDEX);
if (lua_isfunction(L, -1)) { if (lua_isfunction(L, -1)) {
lua_pushstring(L, hooknames[(int)ar->event]); lua_pushstring(L, hooknames[(int)ar->event]);
@ -334,7 +334,7 @@ LJLIB_CF(debug_sethook)
count = luaL_optint(L, arg+3, 0); count = luaL_optint(L, arg+3, 0);
func = hookf; mask = makemask(smask, count); func = hookf; mask = makemask(smask, count);
} }
lua_pushlightuserdata(L, (void *)&KEY_HOOK); lua_pushlightuserdata(L, KEY_HOOK);
lua_pushvalue(L, arg+1); lua_pushvalue(L, arg+1);
lua_rawset(L, LUA_REGISTRYINDEX); lua_rawset(L, LUA_REGISTRYINDEX);
lua_sethook(L, func, mask, count); lua_sethook(L, func, mask, count);
@ -349,7 +349,7 @@ LJLIB_CF(debug_gethook)
if (hook != NULL && hook != hookf) { /* external hook? */ if (hook != NULL && hook != hookf) { /* external hook? */
lua_pushliteral(L, "external hook"); lua_pushliteral(L, "external hook");
} else { } else {
lua_pushlightuserdata(L, (void *)&KEY_HOOK); lua_pushlightuserdata(L, KEY_HOOK);
lua_rawget(L, LUA_REGISTRYINDEX); /* get hook */ lua_rawget(L, LUA_REGISTRYINDEX); /* get hook */
} }
lua_pushstring(L, unmakemask(mask, buff)); lua_pushstring(L, unmakemask(mask, buff));

View File

@ -1,6 +1,6 @@
/* /*
** FFI library. ** FFI library.
** Copyright (C) 2005-2016 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h
*/ */
#define lib_ffi_c #define lib_ffi_c
@ -829,7 +829,7 @@ static GCtab *ffi_finalizer(lua_State *L)
settabV(L, L->top++, t); settabV(L, L->top++, t);
setgcref(t->metatable, obj2gco(t)); setgcref(t->metatable, obj2gco(t));
setstrV(L, lj_tab_setstr(L, t, lj_str_newlit(L, "__mode")), setstrV(L, lj_tab_setstr(L, t, lj_str_newlit(L, "__mode")),
lj_str_newlit(L, "K")); lj_str_newlit(L, "k"));
t->nomm = (uint8_t)(~(1u<<MM_mode)); t->nomm = (uint8_t)(~(1u<<MM_mode));
return t; return t;
} }

View File

@ -1,6 +1,6 @@
/* /*
** Library initialization. ** Library initialization.
** Copyright (C) 2005-2016 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h
** **
** Major parts taken verbatim from the Lua interpreter. ** Major parts taken verbatim from the Lua interpreter.
** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h ** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h

View File

@ -1,6 +1,6 @@
/* /*
** I/O library. ** I/O library.
** Copyright (C) 2005-2016 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h
** **
** Major portions taken verbatim or adapted from the Lua interpreter. ** Major portions taken verbatim or adapted from the Lua interpreter.
** Copyright (C) 1994-2011 Lua.org, PUC-Rio. See Copyright Notice in lua.h ** Copyright (C) 1994-2011 Lua.org, PUC-Rio. See Copyright Notice in lua.h
@ -203,13 +203,12 @@ static int io_file_read(lua_State *L, FILE *fp, int start)
for (n = start; nargs-- && ok; n++) { for (n = start; nargs-- && ok; n++) {
if (tvisstr(L->base+n)) { if (tvisstr(L->base+n)) {
const char *p = strVdata(L->base+n); const char *p = strVdata(L->base+n);
if (p[0] != '*') if (p[0] == '*') p++;
lj_err_arg(L, n+1, LJ_ERR_INVOPT); if (p[0] == 'n')
if (p[1] == 'n')
ok = io_file_readnum(L, fp); ok = io_file_readnum(L, fp);
else if ((p[1] & ~0x20) == 'L') else if ((p[0] & ~0x20) == 'L')
ok = io_file_readline(L, fp, (p[1] == 'l')); ok = io_file_readline(L, fp, (p[0] == 'l'));
else if (p[1] == 'a') else if (p[0] == 'a')
io_file_readall(L, fp); io_file_readall(L, fp);
else else
lj_err_arg(L, n+1, LJ_ERR_INVFMT); lj_err_arg(L, n+1, LJ_ERR_INVFMT);

View File

@ -1,6 +1,6 @@
/* /*
** JIT library. ** JIT library.
** Copyright (C) 2005-2016 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h
*/ */
#define lib_jit_c #define lib_jit_c
@ -204,6 +204,7 @@ LJLIB_CF(jit_util_funcinfo)
lua_setfield(L, -2, "source"); lua_setfield(L, -2, "source");
lj_debug_pushloc(L, pt, pc); lj_debug_pushloc(L, pt, pc);
lua_setfield(L, -2, "loc"); lua_setfield(L, -2, "loc");
setprotoV(L, lj_tab_setstr(L, t, lj_str_newlit(L, "proto")), pt);
} else { } else {
GCfunc *fn = funcV(L->base); GCfunc *fn = funcV(L->base);
GCtab *t; GCtab *t;

View File

@ -1,6 +1,6 @@
/* /*
** Math library. ** Math library.
** Copyright (C) 2005-2016 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h
*/ */
#include <math.h> #include <math.h>
@ -221,10 +221,6 @@ LUALIB_API int luaopen_math(lua_State *L)
rs = (RandomState *)lua_newuserdata(L, sizeof(RandomState)); rs = (RandomState *)lua_newuserdata(L, sizeof(RandomState));
rs->valid = 0; /* Use lazy initialization to save some time on startup. */ rs->valid = 0; /* Use lazy initialization to save some time on startup. */
LJ_LIB_REG(L, LUA_MATHLIBNAME, math); LJ_LIB_REG(L, LUA_MATHLIBNAME, math);
#if defined(LUA_COMPAT_MOD) && !LJ_52
lua_getfield(L, -1, "fmod");
lua_setfield(L, -2, "mod");
#endif
return 1; return 1;
} }

View File

@ -1,6 +1,6 @@
/* /*
** OS library. ** OS library.
** Copyright (C) 2005-2016 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h
** **
** Major portions taken verbatim or adapted from the Lua interpreter. ** Major portions taken verbatim or adapted from the Lua interpreter.
** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h ** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h

View File

@ -1,6 +1,6 @@
/* /*
** Package library. ** Package library.
** Copyright (C) 2005-2016 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h
** **
** Major portions taken verbatim or adapted from the Lua interpreter. ** Major portions taken verbatim or adapted from the Lua interpreter.
** Copyright (C) 1994-2012 Lua.org, PUC-Rio. See Copyright Notice in lua.h ** Copyright (C) 1994-2012 Lua.org, PUC-Rio. See Copyright Notice in lua.h
@ -193,8 +193,7 @@ static void **ll_register(lua_State *L, const char *path)
lua_pop(L, 1); lua_pop(L, 1);
plib = (void **)lua_newuserdata(L, sizeof(void *)); plib = (void **)lua_newuserdata(L, sizeof(void *));
*plib = NULL; *plib = NULL;
luaL_getmetatable(L, "_LOADLIB"); luaL_setmetatable(L, "_LOADLIB");
lua_setmetatable(L, -2);
lua_pushfstring(L, "LOADLIB: %s", path); lua_pushfstring(L, "LOADLIB: %s", path);
lua_pushvalue(L, -2); lua_pushvalue(L, -2);
lua_settable(L, LUA_REGISTRYINDEX); lua_settable(L, LUA_REGISTRYINDEX);
@ -399,8 +398,7 @@ static int lj_cf_package_loader_preload(lua_State *L)
/* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */
static const int sentinel_ = 0; #define sentinel ((void *)0x4004)
#define sentinel ((void *)&sentinel_)
static int lj_cf_package_require(lua_State *L) static int lj_cf_package_require(lua_State *L)
{ {
@ -490,29 +488,19 @@ static void modinit(lua_State *L, const char *modname)
static int lj_cf_package_module(lua_State *L) static int lj_cf_package_module(lua_State *L)
{ {
const char *modname = luaL_checkstring(L, 1); const char *modname = luaL_checkstring(L, 1);
int loaded = lua_gettop(L) + 1; /* index of _LOADED table */ int lastarg = (int)(L->top - L->base);
lua_getfield(L, LUA_REGISTRYINDEX, "_LOADED"); luaL_pushmodule(L, modname, 1);
lua_getfield(L, loaded, modname); /* get _LOADED[modname] */
if (!lua_istable(L, -1)) { /* not found? */
lua_pop(L, 1); /* remove previous result */
/* try global variable (and create one if it does not exist) */
if (luaL_findtable(L, LUA_GLOBALSINDEX, modname, 1) != NULL)
lj_err_callerv(L, LJ_ERR_BADMODN, modname);
lua_pushvalue(L, -1);
lua_setfield(L, loaded, modname); /* _LOADED[modname] = new table */
}
/* check whether table already has a _NAME field */
lua_getfield(L, -1, "_NAME"); lua_getfield(L, -1, "_NAME");
if (!lua_isnil(L, -1)) { /* is table an initialized module? */ if (!lua_isnil(L, -1)) { /* Module already initialized? */
lua_pop(L, 1); lua_pop(L, 1);
} else { /* no; initialize it */ } else {
lua_pop(L, 1); lua_pop(L, 1);
modinit(L, modname); modinit(L, modname);
} }
lua_pushvalue(L, -1); lua_pushvalue(L, -1);
setfenv(L); setfenv(L);
dooptions(L, loaded - 1); dooptions(L, lastarg);
return 0; return LJ_52;
} }
static int lj_cf_package_seeall(lua_State *L) static int lj_cf_package_seeall(lua_State *L)
@ -583,13 +571,16 @@ LUALIB_API int luaopen_package(lua_State *L)
lj_lib_pushcf(L, lj_cf_package_unloadlib, 1); lj_lib_pushcf(L, lj_cf_package_unloadlib, 1);
lua_setfield(L, -2, "__gc"); lua_setfield(L, -2, "__gc");
luaL_register(L, LUA_LOADLIBNAME, package_lib); luaL_register(L, LUA_LOADLIBNAME, package_lib);
lua_pushvalue(L, -1); lua_copy(L, -1, LUA_ENVIRONINDEX);
lua_replace(L, LUA_ENVIRONINDEX);
lua_createtable(L, sizeof(package_loaders)/sizeof(package_loaders[0])-1, 0); lua_createtable(L, sizeof(package_loaders)/sizeof(package_loaders[0])-1, 0);
for (i = 0; package_loaders[i] != NULL; i++) { for (i = 0; package_loaders[i] != NULL; i++) {
lj_lib_pushcf(L, package_loaders[i], 1); lj_lib_pushcf(L, package_loaders[i], 1);
lua_rawseti(L, -2, i+1); lua_rawseti(L, -2, i+1);
} }
#if LJ_52
lua_pushvalue(L, -1);
lua_setfield(L, -3, "searchers");
#endif
lua_setfield(L, -2, "loaders"); lua_setfield(L, -2, "loaders");
lua_getfield(L, LUA_REGISTRYINDEX, "LUA_NOENV"); lua_getfield(L, LUA_REGISTRYINDEX, "LUA_NOENV");
noenv = lua_toboolean(L, -1); noenv = lua_toboolean(L, -1);

View File

@ -1,6 +1,6 @@
/* /*
** String library. ** String library.
** Copyright (C) 2005-2016 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h
** **
** Major portions taken verbatim or adapted from the Lua interpreter. ** Major portions taken verbatim or adapted from the Lua interpreter.
** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h ** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h
@ -737,10 +737,6 @@ LUALIB_API int luaopen_string(lua_State *L)
GCtab *mt; GCtab *mt;
global_State *g; global_State *g;
LJ_LIB_REG(L, LUA_STRLIBNAME, string); LJ_LIB_REG(L, LUA_STRLIBNAME, string);
#if defined(LUA_COMPAT_GFIND) && !LJ_52
lua_getfield(L, -1, "gmatch");
lua_setfield(L, -2, "gfind");
#endif
mt = lj_tab_new(L, 0, 1); mt = lj_tab_new(L, 0, 1);
/* NOBARRIER: basemt is a GC root. */ /* NOBARRIER: basemt is a GC root. */
g = G(L); g = G(L);

View File

@ -1,6 +1,6 @@
/* /*
** Table library. ** Table library.
** Copyright (C) 2005-2016 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h
** **
** Major portions taken verbatim or adapted from the Lua interpreter. ** Major portions taken verbatim or adapted from the Lua interpreter.
** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h ** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h
@ -129,6 +129,26 @@ LJLIB_LUA(table_remove) /*
end end
*/ */
LJLIB_LUA(table_move) /*
function(a1, f, e, t, a2)
CHECK_tab(a1)
CHECK_int(f)
CHECK_int(e)
CHECK_int(t)
if a2 == nil then a2 = a1 end
CHECK_tab(a2)
if e >= f then
local d = t - f
if t > e or t <= f or a2 ~= a1 then
for i=f,e do a2[i+d] = a1[i] end
else
for i=e,f,-1 do a2[i+d] = a1[i] end
end
end
return a2
end
*/
LJLIB_CF(table_concat) LJLIB_REC(.) LJLIB_CF(table_concat) LJLIB_REC(.)
{ {
GCtab *t = lj_lib_checktab(L, 1); GCtab *t = lj_lib_checktab(L, 1);

View File

@ -1,6 +1,6 @@
/* /*
** Public Lua/C API. ** Public Lua/C API.
** Copyright (C) 2005-2016 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h
** **
** Major portions taken verbatim or adapted from the Lua interpreter. ** Major portions taken verbatim or adapted from the Lua interpreter.
** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h ** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h
@ -112,6 +112,13 @@ LUA_API void lua_xmove(lua_State *from, lua_State *to, int n)
from->top = f; from->top = f;
} }
LUA_API const lua_Number *lua_version(lua_State *L)
{
static const lua_Number version = LUA_VERSION_NUM;
UNUSED(L);
return &version;
}
/* -- Stack manipulation -------------------------------------------------- */ /* -- Stack manipulation -------------------------------------------------- */
LUA_API int lua_gettop(lua_State *L) LUA_API int lua_gettop(lua_State *L)
@ -152,30 +159,40 @@ LUA_API void lua_insert(lua_State *L, int idx)
copyTV(L, p, L->top); copyTV(L, p, L->top);
} }
LUA_API void lua_replace(lua_State *L, int idx) static void copy_slot(lua_State *L, TValue *f, int idx)
{ {
api_checknelems(L, 1);
if (idx == LUA_GLOBALSINDEX) { if (idx == LUA_GLOBALSINDEX) {
api_check(L, tvistab(L->top-1)); api_check(L, tvistab(f));
/* NOBARRIER: A thread (i.e. L) is never black. */ /* NOBARRIER: A thread (i.e. L) is never black. */
setgcref(L->env, obj2gco(tabV(L->top-1))); setgcref(L->env, obj2gco(tabV(f)));
} else if (idx == LUA_ENVIRONINDEX) { } else if (idx == LUA_ENVIRONINDEX) {
GCfunc *fn = curr_func(L); GCfunc *fn = curr_func(L);
if (fn->c.gct != ~LJ_TFUNC) if (fn->c.gct != ~LJ_TFUNC)
lj_err_msg(L, LJ_ERR_NOENV); lj_err_msg(L, LJ_ERR_NOENV);
api_check(L, tvistab(L->top-1)); api_check(L, tvistab(f));
setgcref(fn->c.env, obj2gco(tabV(L->top-1))); setgcref(fn->c.env, obj2gco(tabV(f)));
lj_gc_barrier(L, fn, L->top-1); lj_gc_barrier(L, fn, f);
} else { } else {
TValue *o = index2adr(L, idx); TValue *o = index2adr(L, idx);
api_checkvalidindex(L, o); api_checkvalidindex(L, o);
copyTV(L, o, L->top-1); copyTV(L, o, f);
if (idx < LUA_GLOBALSINDEX) /* Need a barrier for upvalues. */ if (idx < LUA_GLOBALSINDEX) /* Need a barrier for upvalues. */
lj_gc_barrier(L, curr_func(L), L->top-1); lj_gc_barrier(L, curr_func(L), f);
} }
}
LUA_API void lua_replace(lua_State *L, int idx)
{
api_checknelems(L, 1);
copy_slot(L, L->top - 1, idx);
L->top--; L->top--;
} }
LUA_API void lua_copy(lua_State *L, int fromidx, int toidx)
{
copy_slot(L, index2adr(L, fromidx), toidx);
}
LUA_API void lua_pushvalue(lua_State *L, int idx) LUA_API void lua_pushvalue(lua_State *L, int idx)
{ {
copyTV(L, L->top, index2adr(L, idx)); copyTV(L, L->top, index2adr(L, idx));
@ -325,6 +342,22 @@ LUA_API lua_Number lua_tonumber(lua_State *L, int idx)
return 0; return 0;
} }
LUA_API lua_Number lua_tonumberx(lua_State *L, int idx, int *ok)
{
cTValue *o = index2adr(L, idx);
TValue tmp;
if (LJ_LIKELY(tvisnumber(o))) {
if (ok) *ok = 1;
return numberVnum(o);
} else if (tvisstr(o) && lj_strscan_num(strV(o), &tmp)) {
if (ok) *ok = 1;
return numV(&tmp);
} else {
if (ok) *ok = 0;
return 0;
}
}
LUALIB_API lua_Number luaL_checknumber(lua_State *L, int idx) LUALIB_API lua_Number luaL_checknumber(lua_State *L, int idx)
{ {
cTValue *o = index2adr(L, idx); cTValue *o = index2adr(L, idx);
@ -362,7 +395,7 @@ LUA_API lua_Integer lua_tointeger(lua_State *L, int idx)
if (!(tvisstr(o) && lj_strscan_number(strV(o), &tmp))) if (!(tvisstr(o) && lj_strscan_number(strV(o), &tmp)))
return 0; return 0;
if (tvisint(&tmp)) if (tvisint(&tmp))
return (lua_Integer)intV(&tmp); return intV(&tmp);
n = numV(&tmp); n = numV(&tmp);
} }
#if LJ_64 #if LJ_64
@ -372,6 +405,35 @@ LUA_API lua_Integer lua_tointeger(lua_State *L, int idx)
#endif #endif
} }
LUA_API lua_Integer lua_tointegerx(lua_State *L, int idx, int *ok)
{
cTValue *o = index2adr(L, idx);
TValue tmp;
lua_Number n;
if (LJ_LIKELY(tvisint(o))) {
if (ok) *ok = 1;
return intV(o);
} else if (LJ_LIKELY(tvisnum(o))) {
n = numV(o);
} else {
if (!(tvisstr(o) && lj_strscan_number(strV(o), &tmp))) {
if (ok) *ok = 0;
return 0;
}
if (tvisint(&tmp)) {
if (ok) *ok = 1;
return intV(&tmp);
}
n = numV(&tmp);
}
if (ok) *ok = 1;
#if LJ_64
return (lua_Integer)n;
#else
return lj_num2int(n);
#endif
}
LUALIB_API lua_Integer luaL_checkinteger(lua_State *L, int idx) LUALIB_API lua_Integer luaL_checkinteger(lua_State *L, int idx)
{ {
cTValue *o = index2adr(L, idx); cTValue *o = index2adr(L, idx);
@ -858,7 +920,7 @@ LUA_API void lua_upvaluejoin(lua_State *L, int idx1, int n1, int idx2, int n2)
lj_gc_objbarrier(L, fn1, gcref(fn1->l.uvptr[n1])); lj_gc_objbarrier(L, fn1, gcref(fn1->l.uvptr[n1]));
} }
LUALIB_API void *luaL_checkudata(lua_State *L, int idx, const char *tname) LUALIB_API void *luaL_testudata(lua_State *L, int idx, const char *tname)
{ {
cTValue *o = index2adr(L, idx); cTValue *o = index2adr(L, idx);
if (tvisudata(o)) { if (tvisudata(o)) {
@ -867,8 +929,14 @@ LUALIB_API void *luaL_checkudata(lua_State *L, int idx, const char *tname)
if (tv && tvistab(tv) && tabV(tv) == tabref(ud->metatable)) if (tv && tvistab(tv) && tabV(tv) == tabref(ud->metatable))
return uddata(ud); return uddata(ud);
} }
lj_err_argtype(L, idx, tname); return NULL; /* value is not a userdata with a metatable */
return NULL; /* unreachable */ }
LUALIB_API void *luaL_checkudata(lua_State *L, int idx, const char *tname)
{
void *p = luaL_testudata(L, idx, tname);
if (!p) lj_err_argtype(L, idx, tname);
return p;
} }
/* -- Object setters ------------------------------------------------------ */ /* -- Object setters ------------------------------------------------------ */
@ -977,6 +1045,12 @@ LUA_API int lua_setmetatable(lua_State *L, int idx)
return 1; return 1;
} }
LUALIB_API void luaL_setmetatable(lua_State *L, const char *tname)
{
lua_getfield(L, LUA_REGISTRYINDEX, tname);
lua_setmetatable(L, -2);
}
LUA_API int lua_setfenv(lua_State *L, int idx) LUA_API int lua_setfenv(lua_State *L, int idx)
{ {
cTValue *o = index2adr(L, idx); cTValue *o = index2adr(L, idx);
@ -1032,7 +1106,7 @@ static TValue *api_call_base(lua_State *L, int nargs)
LUA_API void lua_call(lua_State *L, int nargs, int nresults) LUA_API void lua_call(lua_State *L, int nargs, int nresults)
{ {
api_check(L, L->status == 0 || L->status == LUA_ERRERR); api_check(L, L->status == LUA_OK || L->status == LUA_ERRERR);
api_checknelems(L, nargs+1); api_checknelems(L, nargs+1);
lj_vm_call(L, api_call_base(L, nargs), nresults+1); lj_vm_call(L, api_call_base(L, nargs), nresults+1);
} }
@ -1043,7 +1117,7 @@ LUA_API int lua_pcall(lua_State *L, int nargs, int nresults, int errfunc)
uint8_t oldh = hook_save(g); uint8_t oldh = hook_save(g);
ptrdiff_t ef; ptrdiff_t ef;
int status; int status;
api_check(L, L->status == 0 || L->status == LUA_ERRERR); api_check(L, L->status == LUA_OK || L->status == LUA_ERRERR);
api_checknelems(L, nargs+1); api_checknelems(L, nargs+1);
if (errfunc == 0) { if (errfunc == 0) {
ef = 0; ef = 0;
@ -1075,7 +1149,7 @@ LUA_API int lua_cpcall(lua_State *L, lua_CFunction func, void *ud)
global_State *g = G(L); global_State *g = G(L);
uint8_t oldh = hook_save(g); uint8_t oldh = hook_save(g);
int status; int status;
api_check(L, L->status == 0 || L->status == LUA_ERRERR); api_check(L, L->status == LUA_OK || L->status == LUA_ERRERR);
status = lj_vm_cpcall(L, func, ud, cpcall); status = lj_vm_cpcall(L, func, ud, cpcall);
if (status) hook_restore(g, oldh); if (status) hook_restore(g, oldh);
return status; return status;
@ -1096,6 +1170,11 @@ LUALIB_API int luaL_callmeta(lua_State *L, int idx, const char *field)
/* -- Coroutine yield and resume ------------------------------------------ */ /* -- Coroutine yield and resume ------------------------------------------ */
LUA_API int lua_isyieldable(lua_State *L)
{
return cframe_canyield(L->cframe);
}
LUA_API int lua_yield(lua_State *L, int nresults) LUA_API int lua_yield(lua_State *L, int nresults)
{ {
void *cf = L->cframe; void *cf = L->cframe;
@ -1140,7 +1219,7 @@ LUA_API int lua_resume(lua_State *L, int nargs)
{ {
if (L->cframe == NULL && L->status <= LUA_YIELD) if (L->cframe == NULL && L->status <= LUA_YIELD)
return lj_vm_resume(L, return lj_vm_resume(L,
L->status == 0 ? api_call_base(L, nargs) : L->top - nargs, L->status == LUA_OK ? api_call_base(L, nargs) : L->top - nargs,
0, 0); 0, 0);
L->top = L->base; L->top = L->base;
setstrV(L, L->top, lj_err_str(L, LJ_ERR_COSUSP)); setstrV(L, L->top, lj_err_str(L, LJ_ERR_COSUSP));

View File

@ -1,6 +1,6 @@
/* /*
** Target architecture selection. ** Target architecture selection.
** Copyright (C) 2005-2016 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h
*/ */
#ifndef _LJ_ARCH_H #ifndef _LJ_ARCH_H
@ -74,7 +74,7 @@
defined(__NetBSD__) || defined(__OpenBSD__) || \ defined(__NetBSD__) || defined(__OpenBSD__) || \
defined(__DragonFly__)) && !defined(__ORBIS__) defined(__DragonFly__)) && !defined(__ORBIS__)
#define LUAJIT_OS LUAJIT_OS_BSD #define LUAJIT_OS LUAJIT_OS_BSD
#elif (defined(__sun__) && defined(__svr4__)) #elif (defined(__sun__) && defined(__svr4__)) || defined(__HAIKU__)
#define LUAJIT_OS LUAJIT_OS_POSIX #define LUAJIT_OS LUAJIT_OS_POSIX
#elif defined(__CYGWIN__) #elif defined(__CYGWIN__)
#define LJ_TARGET_CYGWIN 1 #define LJ_TARGET_CYGWIN 1
@ -215,9 +215,14 @@
#elif LUAJIT_TARGET == LUAJIT_ARCH_ARM64 #elif LUAJIT_TARGET == LUAJIT_ARCH_ARM64
#define LJ_ARCH_NAME "arm64"
#define LJ_ARCH_BITS 64 #define LJ_ARCH_BITS 64
#if defined(__AARCH64EB__)
#define LJ_ARCH_NAME "arm64be"
#define LJ_ARCH_ENDIAN LUAJIT_BE
#else
#define LJ_ARCH_NAME "arm64"
#define LJ_ARCH_ENDIAN LUAJIT_LE #define LJ_ARCH_ENDIAN LUAJIT_LE
#endif
#define LJ_TARGET_ARM64 1 #define LJ_TARGET_ARM64 1
#define LJ_TARGET_EHRETREG 0 #define LJ_TARGET_EHRETREG 0
#define LJ_TARGET_JUMPRANGE 27 /* +-2^27 = +-128MB */ #define LJ_TARGET_JUMPRANGE 27 /* +-2^27 = +-128MB */
@ -226,7 +231,6 @@
#define LJ_TARGET_UNIFYROT 2 /* Want only IR_BROR. */ #define LJ_TARGET_UNIFYROT 2 /* Want only IR_BROR. */
#define LJ_TARGET_GC64 1 #define LJ_TARGET_GC64 1
#define LJ_ARCH_NUMMODE LJ_NUMMODE_DUAL #define LJ_ARCH_NUMMODE LJ_NUMMODE_DUAL
#define LJ_ARCH_NOJIT 1 /* NYI */
#define LJ_ARCH_VERSION 80 #define LJ_ARCH_VERSION 80
@ -333,10 +337,12 @@
#define LJ_ARCH_BITS 32 #define LJ_ARCH_BITS 32
#define LJ_TARGET_MIPS32 1 #define LJ_TARGET_MIPS32 1
#else #else
#if LJ_ABI_SOFTFP || !LJ_ARCH_HASFPU
#define LJ_ARCH_NOJIT 1 /* NYI */
#endif
#define LJ_ARCH_BITS 64 #define LJ_ARCH_BITS 64
#define LJ_TARGET_MIPS64 1 #define LJ_TARGET_MIPS64 1
#define LJ_TARGET_GC64 1 #define LJ_TARGET_GC64 1
#define LJ_ARCH_NOJIT 1 /* NYI */
#endif #endif
#define LJ_TARGET_MIPS 1 #define LJ_TARGET_MIPS 1
#define LJ_TARGET_EHRETREG 4 #define LJ_TARGET_EHRETREG 4
@ -376,7 +382,7 @@
#endif #endif
#elif LJ_TARGET_ARM64 #elif LJ_TARGET_ARM64
#if __clang__ #if __clang__
#if (__clang_major__ < 3) || ((__clang_major__ == 3) && __clang_minor__ < 5) #if ((__clang_major__ < 3) || ((__clang_major__ == 3) && __clang_minor__ < 5)) && !defined(__NX_TOOLCHAIN_MAJOR__)
#error "Need at least Clang 3.5 or newer" #error "Need at least Clang 3.5 or newer"
#endif #endif
#else #else
@ -408,9 +414,6 @@
#error "Only ARM EABI or iOS 3.0+ ABI is supported" #error "Only ARM EABI or iOS 3.0+ ABI is supported"
#endif #endif
#elif LJ_TARGET_ARM64 #elif LJ_TARGET_ARM64
#if defined(__AARCH64EB__)
#error "No support for big-endian ARM64"
#endif
#if defined(_ILP32) #if defined(_ILP32)
#error "No support for ILP32 model on ARM64" #error "No support for ILP32 model on ARM64"
#endif #endif

View File

@ -1,6 +1,6 @@
/* /*
** IR assembler (SSA IR -> machine code). ** IR assembler (SSA IR -> machine code).
** Copyright (C) 2005-2016 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h
*/ */
#define lj_asm_c #define lj_asm_c
@ -91,7 +91,7 @@ typedef struct ASMState {
MCode *realign; /* Realign loop if not NULL. */ MCode *realign; /* Realign loop if not NULL. */
#ifdef RID_NUM_KREF #ifdef RID_NUM_KREF
int32_t krefk[RID_NUM_KREF]; intptr_t krefk[RID_NUM_KREF];
#endif #endif
IRRef1 phireg[RID_MAX]; /* PHI register references. */ IRRef1 phireg[RID_MAX]; /* PHI register references. */
uint16_t parentmap[LJ_MAX_JSLOTS]; /* Parent instruction to RegSP map. */ uint16_t parentmap[LJ_MAX_JSLOTS]; /* Parent instruction to RegSP map. */
@ -144,7 +144,7 @@ static LJ_AINLINE void checkmclim(ASMState *as)
#define ra_krefreg(ref) ((Reg)(RID_MIN_KREF + (Reg)(ref))) #define ra_krefreg(ref) ((Reg)(RID_MIN_KREF + (Reg)(ref)))
#define ra_krefk(as, ref) (as->krefk[(ref)]) #define ra_krefk(as, ref) (as->krefk[(ref)])
static LJ_AINLINE void ra_setkref(ASMState *as, Reg r, int32_t k) static LJ_AINLINE void ra_setkref(ASMState *as, Reg r, intptr_t k)
{ {
IRRef ref = (IRRef)(r - RID_MIN_KREF); IRRef ref = (IRRef)(r - RID_MIN_KREF);
as->krefk[ref] = k; as->krefk[ref] = k;
@ -171,6 +171,8 @@ IRFLDEF(FLOFS)
#include "lj_emit_x86.h" #include "lj_emit_x86.h"
#elif LJ_TARGET_ARM #elif LJ_TARGET_ARM
#include "lj_emit_arm.h" #include "lj_emit_arm.h"
#elif LJ_TARGET_ARM64
#include "lj_emit_arm64.h"
#elif LJ_TARGET_PPC #elif LJ_TARGET_PPC
#include "lj_emit_ppc.h" #include "lj_emit_ppc.h"
#elif LJ_TARGET_MIPS #elif LJ_TARGET_MIPS
@ -322,7 +324,11 @@ static Reg ra_rematk(ASMState *as, IRRef ref)
lua_assert(!rset_test(as->freeset, r)); lua_assert(!rset_test(as->freeset, r));
ra_free(as, r); ra_free(as, r);
ra_modified(as, r); ra_modified(as, r);
#if LJ_64
emit_loadu64(as, r, ra_krefk(as, ref));
#else
emit_loadi(as, r, ra_krefk(as, ref)); emit_loadi(as, r, ra_krefk(as, ref));
#endif
return r; return r;
} }
ir = IR(ref); ir = IR(ref);
@ -524,7 +530,7 @@ static void ra_evictk(ASMState *as)
#ifdef RID_NUM_KREF #ifdef RID_NUM_KREF
/* Allocate a register for a constant. */ /* Allocate a register for a constant. */
static Reg ra_allock(ASMState *as, int32_t k, RegSet allow) static Reg ra_allock(ASMState *as, intptr_t k, RegSet allow)
{ {
/* First try to find a register which already holds the same constant. */ /* First try to find a register which already holds the same constant. */
RegSet pick, work = ~as->freeset & RSET_GPR; RegSet pick, work = ~as->freeset & RSET_GPR;
@ -533,9 +539,31 @@ static Reg ra_allock(ASMState *as, int32_t k, RegSet allow)
IRRef ref; IRRef ref;
r = rset_pickbot(work); r = rset_pickbot(work);
ref = regcost_ref(as->cost[r]); ref = regcost_ref(as->cost[r]);
#if LJ_64
if (ref < ASMREF_L) {
if (ra_iskref(ref)) {
if (k == ra_krefk(as, ref))
return r;
} else {
IRIns *ir = IR(ref);
if ((ir->o == IR_KINT64 && k == (int64_t)ir_kint64(ir)->u64) ||
#if LJ_GC64
(ir->o == IR_KINT && k == ir->i) ||
(ir->o == IR_KGC && k == (intptr_t)ir_kgc(ir)) ||
((ir->o == IR_KPTR || ir->o == IR_KKPTR) &&
k == (intptr_t)ir_kptr(ir))
#else
(ir->o != IR_KINT64 && k == ir->i)
#endif
)
return r;
}
}
#else
if (ref < ASMREF_L && if (ref < ASMREF_L &&
k == (ra_iskref(ref) ? ra_krefk(as, ref) : IR(ref)->i)) k == (ra_iskref(ref) ? ra_krefk(as, ref) : IR(ref)->i))
return r; return r;
#endif
rset_clear(work, r); rset_clear(work, r);
} }
pick = as->freeset & allow; pick = as->freeset & allow;
@ -555,7 +583,7 @@ static Reg ra_allock(ASMState *as, int32_t k, RegSet allow)
} }
/* Allocate a specific register for a constant. */ /* Allocate a specific register for a constant. */
static void ra_allockreg(ASMState *as, int32_t k, Reg r) static void ra_allockreg(ASMState *as, intptr_t k, Reg r)
{ {
Reg kr = ra_allock(as, k, RID2RSET(r)); Reg kr = ra_allock(as, k, RID2RSET(r));
if (kr != r) { if (kr != r) {
@ -1563,6 +1591,8 @@ static void asm_loop(ASMState *as)
#include "lj_asm_x86.h" #include "lj_asm_x86.h"
#elif LJ_TARGET_ARM #elif LJ_TARGET_ARM
#include "lj_asm_arm.h" #include "lj_asm_arm.h"
#elif LJ_TARGET_ARM64
#include "lj_asm_arm64.h"
#elif LJ_TARGET_PPC #elif LJ_TARGET_PPC
#include "lj_asm_ppc.h" #include "lj_asm_ppc.h"
#elif LJ_TARGET_MIPS #elif LJ_TARGET_MIPS
@ -2363,6 +2393,9 @@ void lj_asm_trace(jit_State *J, GCtrace *T)
if (!as->loopref) if (!as->loopref)
asm_tail_fixup(as, T->link); /* Note: this may change as->mctop! */ asm_tail_fixup(as, T->link); /* Note: this may change as->mctop! */
T->szmcode = (MSize)((char *)as->mctop - (char *)as->mcp); T->szmcode = (MSize)((char *)as->mctop - (char *)as->mcp);
#if LJ_TARGET_MCODE_FIXUP
asm_mcode_fixup(T->mcode, T->szmcode);
#endif
lj_mcode_sync(T->mcode, origtop); lj_mcode_sync(T->mcode, origtop);
} }

View File

@ -1,6 +1,6 @@
/* /*
** IR assembler (SSA IR -> machine code). ** IR assembler (SSA IR -> machine code).
** Copyright (C) 2005-2016 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h
*/ */
#ifndef _LJ_ASM_H #ifndef _LJ_ASM_H

View File

@ -1,6 +1,6 @@
/* /*
** ARM IR assembler (SSA IR -> machine code). ** ARM IR assembler (SSA IR -> machine code).
** Copyright (C) 2005-2016 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h
*/ */
/* -- Register allocator extensions --------------------------------------- */ /* -- Register allocator extensions --------------------------------------- */

2022
src/lj_asm_arm64.h Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
/* /*
** PPC IR assembler (SSA IR -> machine code). ** PPC IR assembler (SSA IR -> machine code).
** Copyright (C) 2005-2016 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h
*/ */
/* -- Register allocator extensions --------------------------------------- */ /* -- Register allocator extensions --------------------------------------- */
@ -809,7 +809,7 @@ static void asm_fload(ASMState *as, IRIns *ir)
int32_t ofs; int32_t ofs;
if (ir->op1 == REF_NIL) { if (ir->op1 == REF_NIL) {
idx = RID_JGL; idx = RID_JGL;
ofs = ir->op2 - 32768; ofs = (ir->op2 << 2) - 32768;
} else { } else {
idx = ra_alloc1(as, ir->op1, RSET_GPR); idx = ra_alloc1(as, ir->op1, RSET_GPR);
if (ir->op2 == IRFL_TAB_ARRAY) { if (ir->op2 == IRFL_TAB_ARRAY) {

View File

@ -1,6 +1,6 @@
/* /*
** x86/x64 IR assembler (SSA IR -> machine code). ** x86/x64 IR assembler (SSA IR -> machine code).
** Copyright (C) 2005-2016 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h
*/ */
/* -- Guard handling ------------------------------------------------------ */ /* -- Guard handling ------------------------------------------------------ */
@ -234,10 +234,10 @@ static void asm_fusefref(ASMState *as, IRIns *ir, RegSet allow)
as->mrm.idx = RID_NONE; as->mrm.idx = RID_NONE;
if (ir->op1 == REF_NIL) { if (ir->op1 == REF_NIL) {
#if LJ_GC64 #if LJ_GC64
as->mrm.ofs = (int32_t)ir->op2 - GG_OFS(dispatch); as->mrm.ofs = (int32_t)(ir->op2 << 2) - GG_OFS(dispatch);
as->mrm.base = RID_DISPATCH; as->mrm.base = RID_DISPATCH;
#else #else
as->mrm.ofs = (int32_t)ir->op2 + ptr2addr(J2GG(as->J)); as->mrm.ofs = (int32_t)(ir->op2 << 2) + ptr2addr(J2GG(as->J));
as->mrm.base = RID_NONE; as->mrm.base = RID_NONE;
#endif #endif
return; return;
@ -1065,7 +1065,8 @@ static void asm_tvptr(ASMState *as, Reg dest, IRRef ref)
emit_u32(as, irt_toitype(ir->t) << 15); emit_u32(as, irt_toitype(ir->t) << 15);
emit_rmro(as, XO_ARITHi, XOg_OR, dest, 4); emit_rmro(as, XO_ARITHi, XOg_OR, dest, 4);
} else { } else {
emit_movmroi(as, dest, 4, (irt_toitype(ir->t) << 15) | 0x7fff); /* Currently, no caller passes integers that might end up here. */
emit_movmroi(as, dest, 4, (irt_toitype(ir->t) << 15));
} }
emit_movtomro(as, REX_64IR(ir, src), dest, 0); emit_movtomro(as, REX_64IR(ir, src), dest, 0);
} }
@ -1246,7 +1247,19 @@ static void asm_href(ASMState *as, IRIns *ir, IROp merge)
#endif #endif
} else { } else {
emit_rr(as, XO_MOV, tmp, key); emit_rr(as, XO_MOV, tmp, key);
#if LJ_GC64
checkmclim(as);
emit_gri(as, XG_ARITHi(XOg_XOR), dest, irt_toitype(kt) << 15);
if ((as->flags & JIT_F_BMI2)) {
emit_i8(as, 32);
emit_mrm(as, XV_RORX|VEX_64, dest, key);
} else {
emit_shifti(as, XOg_SHR|REX_64, dest, 32);
emit_rr(as, XO_MOV, dest|REX_64, key|REX_64);
}
#else
emit_rmro(as, XO_LEA, dest, key, HASH_BIAS); emit_rmro(as, XO_LEA, dest, key, HASH_BIAS);
#endif
} }
} }
} }
@ -1778,8 +1791,9 @@ static void asm_cnew(ASMState *as, IRIns *ir)
Reg r64 = sz == 8 ? REX_64 : 0; Reg r64 = sz == 8 ? REX_64 : 0;
if (irref_isk(ir->op2)) { if (irref_isk(ir->op2)) {
IRIns *irk = IR(ir->op2); IRIns *irk = IR(ir->op2);
uint64_t k = irk->o == IR_KINT64 ? ir_k64(irk)->u64 : uint64_t k = (irk->o == IR_KINT64 ||
(uint64_t)(uint32_t)irk->i; (LJ_GC64 && (irk->o == IR_KPTR || irk->o == IR_KKPTR))) ?
ir_k64(irk)->u64 : (uint64_t)(uint32_t)irk->i;
if (sz == 4 || checki32((int64_t)k)) { if (sz == 4 || checki32((int64_t)k)) {
emit_i32(as, (int32_t)k); emit_i32(as, (int32_t)k);
emit_rmro(as, XO_MOVmi, r64, RID_RET, sizeof(GCcdata)); emit_rmro(as, XO_MOVmi, r64, RID_RET, sizeof(GCcdata));

View File

@ -1,6 +1,6 @@
/* /*
** Bytecode instruction modes. ** Bytecode instruction modes.
** Copyright (C) 2005-2016 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h
*/ */
#define lj_bc_c #define lj_bc_c

View File

@ -1,6 +1,6 @@
/* /*
** Bytecode instruction format. ** Bytecode instruction format.
** Copyright (C) 2005-2016 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h
*/ */
#ifndef _LJ_BC_H #ifndef _LJ_BC_H

View File

@ -1,6 +1,6 @@
/* /*
** Bytecode dump definitions. ** Bytecode dump definitions.
** Copyright (C) 2005-2016 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h
*/ */
#ifndef _LJ_BCDUMP_H #ifndef _LJ_BCDUMP_H

View File

@ -1,6 +1,6 @@
/* /*
** Bytecode reader. ** Bytecode reader.
** Copyright (C) 2005-2016 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h
*/ */
#define lj_bcread_c #define lj_bcread_c

View File

@ -1,6 +1,6 @@
/* /*
** Bytecode writer. ** Bytecode writer.
** Copyright (C) 2005-2016 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h
*/ */
#define lj_bcwrite_c #define lj_bcwrite_c

View File

@ -1,6 +1,6 @@
/* /*
** Buffer handling. ** Buffer handling.
** Copyright (C) 2005-2016 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h
*/ */
#define lj_buf_c #define lj_buf_c

View File

@ -1,6 +1,6 @@
/* /*
** Buffer handling. ** Buffer handling.
** Copyright (C) 2005-2016 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h
*/ */
#ifndef _LJ_BUF_H #ifndef _LJ_BUF_H

View File

@ -1,6 +1,6 @@
/* /*
** C data arithmetic. ** C data arithmetic.
** Copyright (C) 2005-2016 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h
*/ */
#include "lj_obj.h" #include "lj_obj.h"

View File

@ -1,6 +1,6 @@
/* /*
** C data arithmetic. ** C data arithmetic.
** Copyright (C) 2005-2016 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h
*/ */
#ifndef _LJ_CARITH_H #ifndef _LJ_CARITH_H

View File

@ -1,6 +1,6 @@
/* /*
** FFI C call handling. ** FFI C call handling.
** Copyright (C) 2005-2016 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h
*/ */
#include "lj_obj.h" #include "lj_obj.h"
@ -301,7 +301,7 @@
unsigned int cl = ccall_classify_struct(cts, ctr); \ unsigned int cl = ccall_classify_struct(cts, ctr); \
if ((cl & 4)) { /* Combine float HFA from separate registers. */ \ if ((cl & 4)) { /* Combine float HFA from separate registers. */ \
CTSize i = (cl >> 8) - 1; \ CTSize i = (cl >> 8) - 1; \
do { ((uint32_t *)dp)[i] = cc->fpr[i].u32; } while (i--); \ do { ((uint32_t *)dp)[i] = cc->fpr[i].lo; } while (i--); \
} else { \ } else { \
if (cl > 1) sp = (uint8_t *)&cc->fpr[0]; \ if (cl > 1) sp = (uint8_t *)&cc->fpr[0]; \
memcpy(dp, sp, ctr->size); \ memcpy(dp, sp, ctr->size); \
@ -331,7 +331,7 @@
#define CCALL_HANDLE_COMPLEXARG \ #define CCALL_HANDLE_COMPLEXARG \
/* Pass complex by value in separate (!) FPRs or on stack. */ \ /* Pass complex by value in separate (!) FPRs or on stack. */ \
isfp = ctr->size == 2*sizeof(float) ? 2 : 1; isfp = sz == 2*sizeof(float) ? 2 : 1;
#define CCALL_HANDLE_REGARG \ #define CCALL_HANDLE_REGARG \
if (LJ_TARGET_IOS && isva) { \ if (LJ_TARGET_IOS && isva) { \
@ -359,6 +359,13 @@
} \ } \
} }
#if LJ_BE
#define CCALL_HANDLE_RET \
if (ctype_isfp(ctr->info) && ctr->size == sizeof(float)) \
sp = (uint8_t *)&cc->fpr[0].f;
#endif
#elif LJ_TARGET_PPC #elif LJ_TARGET_PPC
/* -- PPC calling conventions --------------------------------------------- */ /* -- PPC calling conventions --------------------------------------------- */
@ -1070,9 +1077,16 @@ static int ccall_set_args(lua_State *L, CTState *cts, CType *ct,
*(int32_t *)dp = d->size == 1 ? (int32_t)*(int8_t *)dp : *(int32_t *)dp = d->size == 1 ? (int32_t)*(int8_t *)dp :
(int32_t)*(int16_t *)dp; (int32_t)*(int16_t *)dp;
} }
#if LJ_TARGET_ARM64 && LJ_BE
if (isfp && d->size == sizeof(float))
((float *)dp)[1] = ((float *)dp)[0]; /* Floats occupy high slot. */
#endif
#if LJ_TARGET_MIPS64 || (LJ_TARGET_ARM64 && LJ_BE)
if ((ctype_isinteger_or_bool(d->info) || ctype_isenum(d->info)
#if LJ_TARGET_MIPS64 #if LJ_TARGET_MIPS64
if ((ctype_isinteger_or_bool(d->info) || ctype_isenum(d->info) || || (isfp && nsp == 0)
(isfp && nsp == 0)) && d->size <= 4) { #endif
) && d->size <= 4) {
*(int64_t *)dp = (int64_t)*(int32_t *)dp; /* Sign-extend to 64 bit. */ *(int64_t *)dp = (int64_t)*(int32_t *)dp; /* Sign-extend to 64 bit. */
} }
#endif #endif

View File

@ -1,6 +1,6 @@
/* /*
** FFI C call handling. ** FFI C call handling.
** Copyright (C) 2005-2016 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h
*/ */
#ifndef _LJ_CCALL_H #ifndef _LJ_CCALL_H
@ -79,8 +79,8 @@ typedef union FPRArg {
typedef intptr_t GPRArg; typedef intptr_t GPRArg;
typedef union FPRArg { typedef union FPRArg {
double d; double d;
float f; struct { LJ_ENDIAN_LOHI(float f; , float g;) };
uint32_t u32; struct { LJ_ENDIAN_LOHI(uint32_t lo; , uint32_t hi;) };
} FPRArg; } FPRArg;
#elif LJ_TARGET_PPC #elif LJ_TARGET_PPC

View File

@ -1,6 +1,6 @@
/* /*
** FFI C callback handling. ** FFI C callback handling.
** Copyright (C) 2005-2016 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h
*/ */
#include "lj_obj.h" #include "lj_obj.h"
@ -177,16 +177,16 @@ static void callback_mcode_init(global_State *g, uint32_t *page)
uint32_t *p = page; uint32_t *p = page;
void *target = (void *)lj_vm_ffi_callback; void *target = (void *)lj_vm_ffi_callback;
MSize slot; MSize slot;
*p++ = A64I_LDRLx | A64F_D(RID_X11) | A64F_S19(4); *p++ = A64I_LE(A64I_LDRLx | A64F_D(RID_X11) | A64F_S19(4));
*p++ = A64I_LDRLx | A64F_D(RID_X10) | A64F_S19(5); *p++ = A64I_LE(A64I_LDRLx | A64F_D(RID_X10) | A64F_S19(5));
*p++ = A64I_BR | A64F_N(RID_X11); *p++ = A64I_LE(A64I_BR | A64F_N(RID_X11));
*p++ = A64I_NOP; *p++ = A64I_LE(A64I_NOP);
((void **)p)[0] = target; ((void **)p)[0] = target;
((void **)p)[1] = g; ((void **)p)[1] = g;
p += 4; p += 4;
for (slot = 0; slot < CALLBACK_MAX_SLOT; slot++) { for (slot = 0; slot < CALLBACK_MAX_SLOT; slot++) {
*p++ = A64I_MOVZw | A64F_D(RID_X9) | A64F_U16(slot); *p++ = A64I_LE(A64I_MOVZw | A64F_D(RID_X9) | A64F_U16(slot));
*p = A64I_B | A64F_S26((page-p) & 0x03ffffffu); *p = A64I_LE(A64I_B | A64F_S26((page-p) & 0x03ffffffu));
p++; p++;
} }
lua_assert(p - page <= CALLBACK_MCODE_SIZE); lua_assert(p - page <= CALLBACK_MCODE_SIZE);
@ -638,6 +638,10 @@ static void callback_conv_result(CTState *cts, lua_State *L, TValue *o)
#if CCALL_NUM_FPR #if CCALL_NUM_FPR
if (ctype_isfp(ctr->info)) if (ctype_isfp(ctr->info))
dp = (uint8_t *)&cts->cb.fpr[0]; dp = (uint8_t *)&cts->cb.fpr[0];
#endif
#if LJ_TARGET_ARM64 && LJ_BE
if (ctype_isfp(ctr->info) && ctr->size == sizeof(float))
dp = (uint8_t *)&cts->cb.fpr[0].f[1];
#endif #endif
lj_cconv_ct_tv(cts, ctr, dp, o, 0); lj_cconv_ct_tv(cts, ctr, dp, o, 0);
#ifdef CALLBACK_HANDLE_RET #ifdef CALLBACK_HANDLE_RET
@ -652,7 +656,7 @@ static void callback_conv_result(CTState *cts, lua_State *L, TValue *o)
*(int32_t *)dp = ctr->size == 1 ? (int32_t)*(int8_t *)dp : *(int32_t *)dp = ctr->size == 1 ? (int32_t)*(int8_t *)dp :
(int32_t)*(int16_t *)dp; (int32_t)*(int16_t *)dp;
} }
#if LJ_TARGET_MIPS64 #if LJ_TARGET_MIPS64 || (LJ_TARGET_ARM64 && LJ_BE)
/* Always sign-extend results to 64 bits. Even a soft-fp 'float'. */ /* Always sign-extend results to 64 bits. Even a soft-fp 'float'. */
if (ctr->size <= 4 && if (ctr->size <= 4 &&
(LJ_ABI_SOFTFP || ctype_isinteger_or_bool(ctr->info))) (LJ_ABI_SOFTFP || ctype_isinteger_or_bool(ctr->info)))

View File

@ -1,6 +1,6 @@
/* /*
** FFI C callback handling. ** FFI C callback handling.
** Copyright (C) 2005-2016 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h
*/ */
#ifndef _LJ_CCALLBACK_H #ifndef _LJ_CCALLBACK_H

View File

@ -1,6 +1,6 @@
/* /*
** C type conversions. ** C type conversions.
** Copyright (C) 2005-2016 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h
*/ */
#include "lj_obj.h" #include "lj_obj.h"
@ -448,8 +448,10 @@ int lj_cconv_tv_bf(CTState *cts, CType *s, TValue *o, uint8_t *sp)
setintV(o, (int32_t)val); setintV(o, (int32_t)val);
} }
} else { } else {
uint32_t b = (val >> pos) & 1;
lua_assert(bsz == 1); lua_assert(bsz == 1);
setboolV(o, (val >> pos) & 1); setboolV(o, b);
setboolV(&cts->g->tmptv2, b); /* Remember for trace recorder. */
} }
return 0; /* No GC step needed. */ return 0; /* No GC step needed. */
} }

Some files were not shown because too many files have changed in this diff Show More