mirror of
https://github.com/love2d/megasource.git
synced 2026-08-12 00:20:55 +02:00
update luajit to LuaJIT/LuaJIT@8e6520a
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
*.obj
|
||||
*.lib
|
||||
*.exp
|
||||
*.pdb
|
||||
*.dll
|
||||
*.exe
|
||||
*.manifest
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
1762386122
|
||||
1781602682
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
===============================================================================
|
||||
LuaJIT -- a Just-In-Time Compiler for Lua. https://luajit.org/
|
||||
|
||||
Copyright (C) 2005-2025 Mike Pall. All rights reserved.
|
||||
Copyright (C) 2005-2026 Mike Pall. All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
# 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.
|
||||
#
|
||||
# Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
|
||||
# Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
|
||||
##############################################################################
|
||||
|
||||
MAJVER= 2
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ LuaJIT is a Just-In-Time (JIT) compiler for the Lua programming language.
|
||||
|
||||
Project Homepage: https://luajit.org/
|
||||
|
||||
LuaJIT is Copyright (C) 2005-2025 Mike Pall.
|
||||
LuaJIT is Copyright (C) 2005-2026 Mike Pall.
|
||||
LuaJIT is free software, released under the MIT license.
|
||||
See full Copyright Notice in the COPYRIGHT file or in luajit.h.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2004-2025 Mike Pall.
|
||||
/* Copyright (C) 2004-2026 Mike Pall.
|
||||
*
|
||||
* 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.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2004-2025 Mike Pall.
|
||||
/* Copyright (C) 2004-2026 Mike Pall.
|
||||
*
|
||||
* 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.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<title>Contact</title>
|
||||
<meta charset="utf-8">
|
||||
<meta name="Copyright" content="Copyright (C) 2005-2025">
|
||||
<meta name="Copyright" content="Copyright (C) 2005-2026">
|
||||
<meta name="Language" content="en">
|
||||
<link rel="stylesheet" type="text/css" href="bluequad.css" media="screen">
|
||||
<link rel="stylesheet" type="text/css" href="bluequad-print.css" media="print">
|
||||
@@ -94,7 +94,7 @@ don't like that, please complain to Google or Microsoft, not me.
|
||||
<h2>Copyright</h2>
|
||||
<p>
|
||||
All documentation is
|
||||
Copyright © 2005-2025 Mike Pall.
|
||||
Copyright © 2005-2026 Mike Pall.
|
||||
</p>
|
||||
|
||||
|
||||
@@ -102,7 +102,7 @@ Copyright © 2005-2025 Mike Pall.
|
||||
</div>
|
||||
<div id="foot">
|
||||
<hr class="hide">
|
||||
Copyright © 2005-2025
|
||||
Copyright © 2005-2026
|
||||
<span class="noprint">
|
||||
·
|
||||
<a href="contact.html">Contact</a>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<title>String Buffer Library</title>
|
||||
<meta charset="utf-8">
|
||||
<meta name="Copyright" content="Copyright (C) 2005-2025">
|
||||
<meta name="Copyright" content="Copyright (C) 2005-2026">
|
||||
<meta name="Language" content="en">
|
||||
<link rel="stylesheet" type="text/css" href="bluequad.css" media="screen">
|
||||
<link rel="stylesheet" type="text/css" href="bluequad-print.css" media="print">
|
||||
@@ -679,7 +679,7 @@ mappings of files are OK, but only if the file does not change.
|
||||
</div>
|
||||
<div id="foot">
|
||||
<hr class="hide">
|
||||
Copyright © 2005-2025
|
||||
Copyright © 2005-2026
|
||||
<span class="noprint">
|
||||
·
|
||||
<a href="contact.html">Contact</a>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<title>Lua/C API Extensions</title>
|
||||
<meta charset="utf-8">
|
||||
<meta name="Copyright" content="Copyright (C) 2005-2025">
|
||||
<meta name="Copyright" content="Copyright (C) 2005-2026">
|
||||
<meta name="Language" content="en">
|
||||
<link rel="stylesheet" type="text/css" href="bluequad.css" media="screen">
|
||||
<link rel="stylesheet" type="text/css" href="bluequad-print.css" media="print">
|
||||
@@ -173,7 +173,7 @@ Also note that this mechanism is not without overhead.
|
||||
</div>
|
||||
<div id="foot">
|
||||
<hr class="hide">
|
||||
Copyright © 2005-2025
|
||||
Copyright © 2005-2026
|
||||
<span class="noprint">
|
||||
·
|
||||
<a href="contact.html">Contact</a>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<title>FFI Library</title>
|
||||
<meta charset="utf-8">
|
||||
<meta name="Copyright" content="Copyright (C) 2005-2025">
|
||||
<meta name="Copyright" content="Copyright (C) 2005-2026">
|
||||
<meta name="Language" content="en">
|
||||
<link rel="stylesheet" type="text/css" href="bluequad.css" media="screen">
|
||||
<link rel="stylesheet" type="text/css" href="bluequad-print.css" media="print">
|
||||
@@ -316,7 +316,7 @@ without undue conversion penalties.
|
||||
</div>
|
||||
<div id="foot">
|
||||
<hr class="hide">
|
||||
Copyright © 2005-2025
|
||||
Copyright © 2005-2026
|
||||
<span class="noprint">
|
||||
·
|
||||
<a href="contact.html">Contact</a>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<title>ffi.* API Functions</title>
|
||||
<meta charset="utf-8">
|
||||
<meta name="Copyright" content="Copyright (C) 2005-2025">
|
||||
<meta name="Copyright" content="Copyright (C) 2005-2026">
|
||||
<meta name="Language" content="en">
|
||||
<link rel="stylesheet" type="text/css" href="bluequad.css" media="screen">
|
||||
<link rel="stylesheet" type="text/css" href="bluequad-print.css" media="print">
|
||||
@@ -468,6 +468,8 @@ otherwise. The following parameters are currently defined:
|
||||
<td class="abiparam">uwp</td><td class="abidesc">Universal Windows Platform</td></tr>
|
||||
<tr class="even">
|
||||
<td class="abiparam">gc64</td><td class="abidesc">64 bit GC references</td></tr>
|
||||
<tr class="odd">
|
||||
<td class="abiparam">dualnum</td><td class="abidesc">Dual-number mode</td></tr>
|
||||
</table>
|
||||
|
||||
<h3 id="ffi_os"><tt>ffi.os</tt></h3>
|
||||
@@ -558,7 +560,7 @@ named <tt>i</tt>.
|
||||
</div>
|
||||
<div id="foot">
|
||||
<hr class="hide">
|
||||
Copyright © 2005-2025
|
||||
Copyright © 2005-2026
|
||||
<span class="noprint">
|
||||
·
|
||||
<a href="contact.html">Contact</a>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<title>FFI Semantics</title>
|
||||
<meta charset="utf-8">
|
||||
<meta name="Copyright" content="Copyright (C) 2005-2025">
|
||||
<meta name="Copyright" content="Copyright (C) 2005-2026">
|
||||
<meta name="Language" content="en">
|
||||
<link rel="stylesheet" type="text/css" href="bluequad.css" media="screen">
|
||||
<link rel="stylesheet" type="text/css" href="bluequad-print.css" media="print">
|
||||
@@ -338,42 +338,44 @@ pointer or type compatibility:
|
||||
<tr class="odd">
|
||||
<td class="convin">Integer</td><td class="convop">→<sup>round</sup></td><td class="convout"><tt>double</tt>, <tt>float</tt></td></tr>
|
||||
<tr class="even">
|
||||
<td class="convin"><tt>double</tt>, <tt>float</tt></td><td class="convop">→<sup>trunc</sup> <tt>int32_t</tt> →<sup>narrow</sup></td><td class="convout"><tt>(u)int8_t</tt>, <tt>(u)int16_t</tt></td></tr>
|
||||
<td class="convin"><tt>double</tt>, <tt>float</tt></td><td class="convop">→<sup>trunc</sup> <tt>int64_t</tt> →<sup>narrow</sup> <sup>*</sup></td><td class="convout"><tt>(u)int8_t</tt>, <tt>(u)int16_t</tt>, <tt>(u)int32_t</tt></td></tr>
|
||||
<tr class="odd">
|
||||
<td class="convin"><tt>double</tt>, <tt>float</tt></td><td class="convop">→<sup>trunc</sup></td><td class="convout"><tt>(u)int32_t</tt>, <tt>(u)int64_t</tt></td></tr>
|
||||
<td class="convin"><tt>double</tt>, <tt>float</tt></td><td class="convop">→<sup>trunc</sup></td><td class="convout"><tt>int64_t</tt></td></tr>
|
||||
<tr class="even">
|
||||
<td class="convin"><tt>double</tt>, <tt>float</tt></td><td class="convop">→<sup>trunc</sup> uint64_t ∪ int64_t →<sup>reinterpret</sup> <sup>*</sup></td><td class="convout"><tt>uint64_t</tt></td></tr>
|
||||
<tr class="odd">
|
||||
<td class="convin"><tt>double</tt>, <tt>float</tt></td><td class="convop">→<sup>round</sup></td><td class="convout"><tt>float</tt>, <tt>double</tt></td></tr>
|
||||
<tr class="odd separate">
|
||||
<tr class="even separate">
|
||||
<td class="convin">Number</td><td class="convop">n == 0 → 0, otherwise 1</td><td class="convout"><tt>bool</tt></td></tr>
|
||||
<tr class="even">
|
||||
<tr class="odd">
|
||||
<td class="convin"><tt>bool</tt></td><td class="convop"><tt>false</tt> → 0, <tt>true</tt> → 1</td><td class="convout">Number</td></tr>
|
||||
<tr class="odd separate">
|
||||
<tr class="even separate">
|
||||
<td class="convin">Complex number</td><td class="convop">convert real part</td><td class="convout">Number</td></tr>
|
||||
<tr class="even">
|
||||
<tr class="odd">
|
||||
<td class="convin">Number</td><td class="convop">convert real part, imag = 0</td><td class="convout">Complex number</td></tr>
|
||||
<tr class="odd">
|
||||
<tr class="even">
|
||||
<td class="convin">Complex number</td><td class="convop">convert real and imag part</td><td class="convout">Complex number</td></tr>
|
||||
<tr class="even separate">
|
||||
<tr class="odd separate">
|
||||
<td class="convin">Number</td><td class="convop">convert scalar and replicate</td><td class="convout">Vector</td></tr>
|
||||
<tr class="odd">
|
||||
<tr class="even">
|
||||
<td class="convin">Vector</td><td class="convop">copy (same size)</td><td class="convout">Vector</td></tr>
|
||||
<tr class="even separate">
|
||||
<tr class="odd separate">
|
||||
<td class="convin"><tt>struct</tt>/<tt>union</tt></td><td class="convop">take base address (compat)</td><td class="convout">Pointer</td></tr>
|
||||
<tr class="odd">
|
||||
<tr class="even">
|
||||
<td class="convin">Array</td><td class="convop">take base address (compat)</td><td class="convout">Pointer</td></tr>
|
||||
<tr class="even">
|
||||
<td class="convin">Function</td><td class="convop">take function address</td><td class="convout">Function pointer</td></tr>
|
||||
<tr class="odd separate">
|
||||
<td class="convin">Number</td><td class="convop">convert via <tt>uintptr_t</tt> (cast)</td><td class="convout">Pointer</td></tr>
|
||||
<tr class="even">
|
||||
<td class="convin">Pointer</td><td class="convop">convert address (compat/cast)</td><td class="convout">Pointer</td></tr>
|
||||
<tr class="odd">
|
||||
<td class="convin">Function</td><td class="convop">take function address</td><td class="convout">Function pointer</td></tr>
|
||||
<tr class="even separate">
|
||||
<td class="convin">Number</td><td class="convop">convert via <tt>uintptr_t</tt> (cast)</td><td class="convout">Pointer</td></tr>
|
||||
<tr class="odd">
|
||||
<td class="convin">Pointer</td><td class="convop">convert address (compat/cast)</td><td class="convout">Pointer</td></tr>
|
||||
<tr class="even">
|
||||
<td class="convin">Pointer</td><td class="convop">convert address (cast)</td><td class="convout">Integer</td></tr>
|
||||
<tr class="even">
|
||||
<tr class="odd">
|
||||
<td class="convin">Array</td><td class="convop">convert base address (cast)</td><td class="convout">Integer</td></tr>
|
||||
<tr class="odd separate">
|
||||
<tr class="even separate">
|
||||
<td class="convin">Array</td><td class="convop">copy (compat)</td><td class="convout">Array</td></tr>
|
||||
<tr class="even">
|
||||
<tr class="odd">
|
||||
<td class="convin"><tt>struct</tt>/<tt>union</tt></td><td class="convop">copy (identical type)</td><td class="convout"><tt>struct</tt>/<tt>union</tt></td></tr>
|
||||
</table>
|
||||
<p>
|
||||
@@ -384,6 +386,24 @@ type.
|
||||
Conversions not listed above will raise an error. E.g. it's not
|
||||
possible to convert a pointer to a complex number or vice versa.
|
||||
</p>
|
||||
<p>
|
||||
* Some conversions from <tt>double</tt> have a larger defined range to
|
||||
allow for mixed-signedness conversions, which are common in C code.
|
||||
E.g. initializing an <tt>int32_t</tt> field with <tt>0xffffffff</tt>
|
||||
or initializing an <tt>uint32_t</tt> or <tt>uint64_t</tt> field with
|
||||
<tt>-1</tt>. Under strict conversion rules, these assignments would
|
||||
give undefined results, since Lua numbers are doubles. The extended
|
||||
ranges make these conversions defined. Lua numbers that are even
|
||||
outside that range give an architecture-specific result.
|
||||
</p>
|
||||
<p>
|
||||
Please note that doubles do not have the precision to represent the
|
||||
whole signed or unsigned 64 bit integer range. Beware of large hex
|
||||
constants in particular: e.g. <tt>0xffffffffffffffff</tt> is a double
|
||||
rounded up to <tt>0x1p64</tt> during parsing. This will <em>not</em>
|
||||
convert to a defined 64 bit integer value. Use the 64 bit literal
|
||||
syntax instead, i.e. <tt>0xffffffffffffffffULL</tt>.
|
||||
</p>
|
||||
|
||||
<h3 id="convert_vararg">Conversions for vararg C function arguments</h3>
|
||||
<p>
|
||||
@@ -1259,7 +1279,7 @@ compiled.</li>
|
||||
</div>
|
||||
<div id="foot">
|
||||
<hr class="hide">
|
||||
Copyright © 2005-2025
|
||||
Copyright © 2005-2026
|
||||
<span class="noprint">
|
||||
·
|
||||
<a href="contact.html">Contact</a>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<title>FFI Tutorial</title>
|
||||
<meta charset="utf-8">
|
||||
<meta name="Copyright" content="Copyright (C) 2005-2025">
|
||||
<meta name="Copyright" content="Copyright (C) 2005-2026">
|
||||
<meta name="Language" content="en">
|
||||
<link rel="stylesheet" type="text/css" href="bluequad.css" media="screen">
|
||||
<link rel="stylesheet" type="text/css" href="bluequad-print.css" media="print">
|
||||
@@ -587,7 +587,7 @@ it to a local variable in the function scope is unnecessary.
|
||||
</div>
|
||||
<div id="foot">
|
||||
<hr class="hide">
|
||||
Copyright © 2005-2025
|
||||
Copyright © 2005-2026
|
||||
<span class="noprint">
|
||||
·
|
||||
<a href="contact.html">Contact</a>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<title>jit.* Library</title>
|
||||
<meta charset="utf-8">
|
||||
<meta name="Copyright" content="Copyright (C) 2005-2025">
|
||||
<meta name="Copyright" content="Copyright (C) 2005-2026">
|
||||
<meta name="Language" content="en">
|
||||
<link rel="stylesheet" type="text/css" href="bluequad.css" media="screen">
|
||||
<link rel="stylesheet" type="text/css" href="bluequad-print.css" media="print">
|
||||
@@ -187,7 +187,7 @@ if you want to know more.
|
||||
</div>
|
||||
<div id="foot">
|
||||
<hr class="hide">
|
||||
Copyright © 2005-2025
|
||||
Copyright © 2005-2026
|
||||
<span class="noprint">
|
||||
·
|
||||
<a href="contact.html">Contact</a>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<title>Profiler</title>
|
||||
<meta charset="utf-8">
|
||||
<meta name="Copyright" content="Copyright (C) 2005-2025">
|
||||
<meta name="Copyright" content="Copyright (C) 2005-2026">
|
||||
<meta name="Language" content="en">
|
||||
<link rel="stylesheet" type="text/css" href="bluequad.css" media="screen">
|
||||
<link rel="stylesheet" type="text/css" href="bluequad-print.css" media="print">
|
||||
@@ -349,7 +349,7 @@ use.
|
||||
</div>
|
||||
<div id="foot">
|
||||
<hr class="hide">
|
||||
Copyright © 2005-2025
|
||||
Copyright © 2005-2026
|
||||
<span class="noprint">
|
||||
·
|
||||
<a href="contact.html">Contact</a>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<title>Extensions</title>
|
||||
<meta charset="utf-8">
|
||||
<meta name="Copyright" content="Copyright (C) 2005-2025">
|
||||
<meta name="Copyright" content="Copyright (C) 2005-2026">
|
||||
<meta name="Language" content="en">
|
||||
<link rel="stylesheet" type="text/css" href="bluequad.css" media="screen">
|
||||
<link rel="stylesheet" type="text/css" href="bluequad-print.css" media="print">
|
||||
@@ -492,7 +492,7 @@ C++ destructors.</li>
|
||||
</div>
|
||||
<div id="foot">
|
||||
<hr class="hide">
|
||||
Copyright © 2005-2025
|
||||
Copyright © 2005-2026
|
||||
<span class="noprint">
|
||||
·
|
||||
<a href="contact.html">Contact</a>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<title>Installation</title>
|
||||
<meta charset="utf-8">
|
||||
<meta name="Copyright" content="Copyright (C) 2005-2025">
|
||||
<meta name="Copyright" content="Copyright (C) 2005-2026">
|
||||
<meta name="Language" content="en">
|
||||
<link rel="stylesheet" type="text/css" href="bluequad.css" media="screen">
|
||||
<link rel="stylesheet" type="text/css" href="bluequad-print.css" media="print">
|
||||
@@ -577,7 +577,7 @@ to me (the upstream) and not you (the package maintainer), anyway.
|
||||
</div>
|
||||
<div id="foot">
|
||||
<hr class="hide">
|
||||
Copyright © 2005-2025
|
||||
Copyright © 2005-2026
|
||||
<span class="noprint">
|
||||
·
|
||||
<a href="contact.html">Contact</a>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<title>LuaJIT</title>
|
||||
<meta charset="utf-8">
|
||||
<meta name="Copyright" content="Copyright (C) 2005-2025">
|
||||
<meta name="Copyright" content="Copyright (C) 2005-2026">
|
||||
<meta name="Language" content="en">
|
||||
<link rel="stylesheet" type="text/css" href="bluequad.css" media="screen">
|
||||
<link rel="stylesheet" type="text/css" href="bluequad-print.css" media="print">
|
||||
@@ -122,7 +122,7 @@ Lua is a powerful, dynamic and light-weight programming language.
|
||||
It may be embedded or used as a general-purpose, stand-alone language.
|
||||
</p>
|
||||
<p>
|
||||
LuaJIT is Copyright © 2005-2025 Mike Pall, released under the
|
||||
LuaJIT is Copyright © 2005-2026 Mike Pall, released under the
|
||||
<a href="https://www.opensource.org/licenses/mit-license.php"><span class="ext">»</span> MIT open source license</a>.
|
||||
</p>
|
||||
<p>
|
||||
@@ -193,7 +193,7 @@ Please select a sub-topic in the navigation bar to learn more about LuaJIT.
|
||||
</div>
|
||||
<div id="foot">
|
||||
<hr class="hide">
|
||||
Copyright © 2005-2025
|
||||
Copyright © 2005-2026
|
||||
<span class="noprint">
|
||||
·
|
||||
<a href="contact.html">Contact</a>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<title>Running LuaJIT</title>
|
||||
<meta charset="utf-8">
|
||||
<meta name="Copyright" content="Copyright (C) 2005-2025">
|
||||
<meta name="Copyright" content="Copyright (C) 2005-2026">
|
||||
<meta name="Language" content="en">
|
||||
<link rel="stylesheet" type="text/css" href="bluequad.css" media="screen">
|
||||
<link rel="stylesheet" type="text/css" href="bluequad-print.css" media="print">
|
||||
@@ -307,7 +307,7 @@ Here are the parameters and their default settings:
|
||||
</div>
|
||||
<div id="foot">
|
||||
<hr class="hide">
|
||||
Copyright © 2005-2025
|
||||
Copyright © 2005-2026
|
||||
<span class="noprint">
|
||||
·
|
||||
<a href="contact.html">Contact</a>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
** DynASM ARM encoding engine.
|
||||
** Copyright (C) 2005-2025 Mike Pall. All rights reserved.
|
||||
** Copyright (C) 2005-2026 Mike Pall. All rights reserved.
|
||||
** Released under the MIT license. See dynasm.lua for full copyright notice.
|
||||
*/
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
------------------------------------------------------------------------------
|
||||
-- DynASM ARM module.
|
||||
--
|
||||
-- Copyright (C) 2005-2025 Mike Pall. All rights reserved.
|
||||
-- Copyright (C) 2005-2026 Mike Pall. All rights reserved.
|
||||
-- See dynasm.lua for full copyright notice.
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
** DynASM ARM64 encoding engine.
|
||||
** Copyright (C) 2005-2025 Mike Pall. All rights reserved.
|
||||
** Copyright (C) 2005-2026 Mike Pall. All rights reserved.
|
||||
** Released under the MIT license. See dynasm.lua for full copyright notice.
|
||||
*/
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
------------------------------------------------------------------------------
|
||||
-- DynASM ARM64 module.
|
||||
--
|
||||
-- Copyright (C) 2005-2025 Mike Pall. All rights reserved.
|
||||
-- Copyright (C) 2005-2026 Mike Pall. All rights reserved.
|
||||
-- See dynasm.lua for full copyright notice.
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
** DynASM MIPS encoding engine.
|
||||
** Copyright (C) 2005-2025 Mike Pall. All rights reserved.
|
||||
** Copyright (C) 2005-2026 Mike Pall. All rights reserved.
|
||||
** Released under the MIT license. See dynasm.lua for full copyright notice.
|
||||
*/
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
------------------------------------------------------------------------------
|
||||
-- DynASM MIPS32/MIPS64 module.
|
||||
--
|
||||
-- Copyright (C) 2005-2025 Mike Pall. All rights reserved.
|
||||
-- Copyright (C) 2005-2026 Mike Pall. All rights reserved.
|
||||
-- See dynasm.lua for full copyright notice.
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
------------------------------------------------------------------------------
|
||||
-- DynASM MIPS64 module.
|
||||
--
|
||||
-- Copyright (C) 2005-2025 Mike Pall. All rights reserved.
|
||||
-- Copyright (C) 2005-2026 Mike Pall. All rights reserved.
|
||||
-- See dynasm.lua for full copyright notice.
|
||||
------------------------------------------------------------------------------
|
||||
-- This module just sets 64 bit mode for the combined MIPS/MIPS64 module.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
** DynASM PPC/PPC64 encoding engine.
|
||||
** Copyright (C) 2005-2025 Mike Pall. All rights reserved.
|
||||
** Copyright (C) 2005-2026 Mike Pall. All rights reserved.
|
||||
** Released under the MIT license. See dynasm.lua for full copyright notice.
|
||||
*/
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
------------------------------------------------------------------------------
|
||||
-- DynASM PPC/PPC64 module.
|
||||
--
|
||||
-- Copyright (C) 2005-2025 Mike Pall. All rights reserved.
|
||||
-- Copyright (C) 2005-2026 Mike Pall. All rights reserved.
|
||||
-- See dynasm.lua for full copyright notice.
|
||||
--
|
||||
-- Support for various extensions contributed by Caio Souza Oliveira.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
** DynASM encoding engine prototypes.
|
||||
** Copyright (C) 2005-2025 Mike Pall. All rights reserved.
|
||||
** Copyright (C) 2005-2026 Mike Pall. All rights reserved.
|
||||
** Released under the MIT license. See dynasm.lua for full copyright notice.
|
||||
*/
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
------------------------------------------------------------------------------
|
||||
-- DynASM x64 module.
|
||||
--
|
||||
-- Copyright (C) 2005-2025 Mike Pall. All rights reserved.
|
||||
-- Copyright (C) 2005-2026 Mike Pall. All rights reserved.
|
||||
-- See dynasm.lua for full copyright notice.
|
||||
------------------------------------------------------------------------------
|
||||
-- This module just sets 64 bit mode for the combined x86/x64 module.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
** DynASM x86 encoding engine.
|
||||
** Copyright (C) 2005-2025 Mike Pall. All rights reserved.
|
||||
** Copyright (C) 2005-2026 Mike Pall. All rights reserved.
|
||||
** Released under the MIT license. See dynasm.lua for full copyright notice.
|
||||
*/
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
------------------------------------------------------------------------------
|
||||
-- DynASM x86/x64 module.
|
||||
--
|
||||
-- Copyright (C) 2005-2025 Mike Pall. All rights reserved.
|
||||
-- Copyright (C) 2005-2026 Mike Pall. All rights reserved.
|
||||
-- See dynasm.lua for full copyright notice.
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
-- DynASM. A dynamic assembler for code generation engines.
|
||||
-- Originally designed and implemented for LuaJIT.
|
||||
--
|
||||
-- Copyright (C) 2005-2025 Mike Pall. All rights reserved.
|
||||
-- Copyright (C) 2005-2026 Mike Pall. All rights reserved.
|
||||
-- See below for full copyright notice.
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
@@ -17,7 +17,7 @@ local _info = {
|
||||
url = "https://luajit.org/dynasm.html",
|
||||
license = "MIT",
|
||||
copyright = [[
|
||||
Copyright (C) 2005-2025 Mike Pall. All rights reserved.
|
||||
Copyright (C) 2005-2026 Mike Pall. All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
|
||||
@@ -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.
|
||||
.SH COPYRIGHT
|
||||
.PP
|
||||
\fBLuaJIT\fR is Copyright \(co 2005-2025 Mike Pall.
|
||||
\fBLuaJIT\fR is Copyright \(co 2005-2026 Mike Pall.
|
||||
.br
|
||||
\fBLuaJIT\fR is open source software, released under the MIT license.
|
||||
.SH SEE ALSO
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
# Also works with MinGW and Cygwin on Windows.
|
||||
# Please check msvcbuild.bat for building with MSVC on Windows.
|
||||
#
|
||||
# Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
|
||||
# Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
|
||||
##############################################################################
|
||||
|
||||
MAJVER= 2
|
||||
@@ -302,9 +302,6 @@ endif
|
||||
ifneq (,$(INSTALL_LJLIBD))
|
||||
TARGET_XCFLAGS+= -DLUA_LJDIR=\"$(INSTALL_LJLIBD)\"
|
||||
endif
|
||||
ifeq (,$(shell $(TARGET_CC) -o /dev/null -c -x c /dev/null -fno-strict-float-cast-overflow 2>/dev/null || echo 1))
|
||||
TARGET_XCFLAGS+= -fno-strict-float-cast-overflow
|
||||
endif
|
||||
|
||||
##############################################################################
|
||||
# Target system detection.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
** LuaJIT VM builder.
|
||||
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
|
||||
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
|
||||
**
|
||||
** This is a tool to build the hand-tuned assembler code required for
|
||||
** LuaJIT's bytecode interpreter. It supports a variety of output formats
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
** LuaJIT VM builder.
|
||||
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
|
||||
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
|
||||
*/
|
||||
|
||||
#ifndef _BUILDVM_H
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
** LuaJIT VM builder: Assembler source code emitter.
|
||||
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
|
||||
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
|
||||
*/
|
||||
|
||||
#include "buildvm.h"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
** LuaJIT VM builder: IR folding hash table generator.
|
||||
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
|
||||
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
|
||||
*/
|
||||
|
||||
#include "buildvm.h"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
** LuaJIT VM builder: library definition compiler.
|
||||
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
|
||||
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
|
||||
*/
|
||||
|
||||
#include "buildvm.h"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
** LuaJIT VM builder: PE object emitter.
|
||||
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
|
||||
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
|
||||
**
|
||||
** Only used for building on Windows, since we cannot assume the presence
|
||||
** of a suitable assembler. The host and target byte order must match.
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
-- 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.
|
||||
----------------------------------------------------------------------------
|
||||
-- Copyright (C) 2005-2025 Mike Pall. All rights reserved.
|
||||
-- Copyright (C) 2005-2026 Mike Pall. All rights reserved.
|
||||
-- Released under the MIT license. See Copyright Notice in luajit.h
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
-- Lua script to generate a customized, minified version of Lua.
|
||||
-- The resulting 'minilua' is used for the build process of LuaJIT.
|
||||
----------------------------------------------------------------------------
|
||||
-- Copyright (C) 2005-2025 Mike Pall. All rights reserved.
|
||||
-- Copyright (C) 2005-2026 Mike Pall. All rights reserved.
|
||||
-- Released under the MIT license. See Copyright Notice in luajit.h
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
@@ -90,11 +90,11 @@ static int bswap(lua_State *L){
|
||||
UB b=barg(L,1);b=(b>>24)|((b>>8)&0xff00)|((b&0xff00)<<8)|(b<<24);BRET(b)}
|
||||
static int tohex(lua_State *L){
|
||||
UB b=barg(L,1);
|
||||
int n=lua_isnone(L,2)?8:(int)barg(L,2);
|
||||
UB n=lua_isnone(L,2)?8:barg(L,2);
|
||||
const char *hexdigits="0123456789abcdef";
|
||||
char buf[8];
|
||||
int i;
|
||||
if(n<0){n=-n;hexdigits="0123456789ABCDEF";}
|
||||
if((int)n<0){n=~n+1;hexdigits="0123456789ABCDEF";}
|
||||
if(n>8)n=8;
|
||||
for(i=(int)n;--i>=0;){buf[i]=hexdigits[b&15];b>>=4;}
|
||||
lua_pushlstring(L,buf,(size_t)n);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
----------------------------------------------------------------------------
|
||||
-- Lua script to embed the rolling release version in luajit.h.
|
||||
----------------------------------------------------------------------------
|
||||
-- Copyright (C) 2005-2025 Mike Pall. All rights reserved.
|
||||
-- Copyright (C) 2005-2026 Mike Pall. All rights reserved.
|
||||
-- Released under the MIT license. See Copyright Notice in luajit.h
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -7722,11 +7722,11 @@ static int bswap(lua_State*L){
|
||||
UB b=barg(L,1);b=(b>>24)|((b>>8)&0xff00)|((b&0xff00)<<8)|(b<<24);BRET(b)}
|
||||
static int tohex(lua_State*L){
|
||||
UB b=barg(L,1);
|
||||
int n=lua_isnone(L,2)?8:(int)barg(L,2);
|
||||
UB n=lua_isnone(L,2)?8:barg(L,2);
|
||||
const char*hexdigits="0123456789abcdef";
|
||||
char buf[8];
|
||||
int i;
|
||||
if(n<0){n=-n;hexdigits="0123456789ABCDEF";}
|
||||
if((int)n<0){n=~n+1;hexdigits="0123456789ABCDEF";}
|
||||
if(n>8)n=8;
|
||||
for(i=(int)n;--i>=0;){buf[i]=hexdigits[b&15];b>>=4;}
|
||||
lua_pushlstring(L,buf,(size_t)n);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
----------------------------------------------------------------------------
|
||||
-- LuaJIT bytecode listing module.
|
||||
--
|
||||
-- Copyright (C) 2005-2025 Mike Pall. All rights reserved.
|
||||
-- Copyright (C) 2005-2026 Mike Pall. All rights reserved.
|
||||
-- Released under the MIT license. See Copyright Notice in luajit.h
|
||||
----------------------------------------------------------------------------
|
||||
--
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
----------------------------------------------------------------------------
|
||||
-- LuaJIT module to save/list bytecode.
|
||||
--
|
||||
-- Copyright (C) 2005-2025 Mike Pall. All rights reserved.
|
||||
-- Copyright (C) 2005-2026 Mike Pall. All rights reserved.
|
||||
-- Released under the MIT license. See Copyright Notice in luajit.h
|
||||
----------------------------------------------------------------------------
|
||||
--
|
||||
@@ -165,6 +165,8 @@ extern "C"
|
||||
#endif
|
||||
#ifdef _WIN32
|
||||
__declspec(dllexport)
|
||||
#elif (defined(__ELF__) || defined(__MACH__) || defined(__psp2__)) && !((defined(__sun__) && defined(__svr4__)) || defined(__CELLOS_LV2__))
|
||||
__attribute__((visibility("default")))
|
||||
#endif
|
||||
const unsigned char %s%s[] = {
|
||||
]], LJBC_PREFIX, ctx.modname))
|
||||
@@ -465,9 +467,11 @@ typedef struct {
|
||||
mach_segment_command_64 seg;
|
||||
mach_section_64 sec;
|
||||
mach_symtab_command sym;
|
||||
} mach_obj_64;
|
||||
typedef struct {
|
||||
mach_nlist_64 sym_entry;
|
||||
uint8_t space[4096];
|
||||
} mach_obj_64;
|
||||
} mach_obj_64_tail;
|
||||
]]
|
||||
local symname = '_'..LJBC_PREFIX..ctx.modname
|
||||
local cputype, cpusubtype = 0x01000007, 3
|
||||
@@ -479,7 +483,10 @@ typedef struct {
|
||||
|
||||
-- Create Mach-O object and fill in header.
|
||||
local o = ffi.new("mach_obj_64")
|
||||
local mach_size = aligned(ffi.offsetof(o, "space")+#symname+2, 8)
|
||||
local t = ffi.new("mach_obj_64_tail")
|
||||
local ofs_bc = ffi.sizeof(o)
|
||||
local sz_bc = aligned(#s, 8)
|
||||
local ofs_sym = ofs_bc + sz_bc
|
||||
|
||||
-- Fill in sections and symbols.
|
||||
o.hdr.magic = 0xfeedfacf
|
||||
@@ -491,7 +498,7 @@ typedef struct {
|
||||
o.seg.cmd = 0x19
|
||||
o.seg.cmdsize = ffi.sizeof(o.seg)+ffi.sizeof(o.sec)
|
||||
o.seg.vmsize = #s
|
||||
o.seg.fileoff = mach_size
|
||||
o.seg.fileoff = ofs_bc
|
||||
o.seg.filesize = #s
|
||||
o.seg.maxprot = 1
|
||||
o.seg.initprot = 1
|
||||
@@ -499,22 +506,23 @@ typedef struct {
|
||||
ffi.copy(o.sec.sectname, "__data")
|
||||
ffi.copy(o.sec.segname, "__DATA")
|
||||
o.sec.size = #s
|
||||
o.sec.offset = mach_size
|
||||
o.sec.offset = ofs_bc
|
||||
o.sym.cmd = 2
|
||||
o.sym.cmdsize = ffi.sizeof(o.sym)
|
||||
o.sym.symoff = ffi.offsetof(o, "sym_entry")
|
||||
o.sym.symoff = ofs_sym
|
||||
o.sym.nsyms = 1
|
||||
o.sym.stroff = ffi.offsetof(o, "sym_entry")+ffi.sizeof(o.sym_entry)
|
||||
o.sym.stroff = ofs_sym + ffi.offsetof(t, "space")
|
||||
o.sym.strsize = aligned(#symname+2, 8)
|
||||
o.sym_entry.type = 0xf
|
||||
o.sym_entry.sect = 1
|
||||
o.sym_entry.strx = 1
|
||||
ffi.copy(o.space+1, symname)
|
||||
t.sym_entry.type = 0xf
|
||||
t.sym_entry.sect = 1
|
||||
t.sym_entry.strx = 1
|
||||
ffi.copy(t.space+1, symname)
|
||||
|
||||
-- Write Mach-O object file.
|
||||
local fp = savefile(output, "wb")
|
||||
fp:write(ffi.string(o, mach_size))
|
||||
bcsave_tail(fp, output, s)
|
||||
fp:write(ffi.string(o, ofs_bc))
|
||||
fp:write(s, ("\0"):rep(sz_bc - #s))
|
||||
bcsave_tail(fp, output, ffi.string(t, ffi.offsetof(t, "space") + o.sym.strsize))
|
||||
end
|
||||
|
||||
local function bcsave_obj(ctx, output, s)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
----------------------------------------------------------------------------
|
||||
-- LuaJIT ARM disassembler module.
|
||||
--
|
||||
-- Copyright (C) 2005-2025 Mike Pall. All rights reserved.
|
||||
-- Copyright (C) 2005-2026 Mike Pall. All rights reserved.
|
||||
-- Released under the MIT license. See Copyright Notice in luajit.h
|
||||
----------------------------------------------------------------------------
|
||||
-- This is a helper module used by the LuaJIT machine code dumper module.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
----------------------------------------------------------------------------
|
||||
-- LuaJIT ARM64 disassembler module.
|
||||
--
|
||||
-- Copyright (C) 2005-2025 Mike Pall. All rights reserved.
|
||||
-- Copyright (C) 2005-2026 Mike Pall. All rights reserved.
|
||||
-- Released under the MIT license. See Copyright Notice in luajit.h
|
||||
--
|
||||
-- Contributed by Djordje Kovacevic and Stefan Pejic from RT-RK.com.
|
||||
@@ -485,15 +485,15 @@ local map_ls = { -- Loads and stores.
|
||||
shift = 30, mask = 3,
|
||||
[0] = {
|
||||
shift = 22, mask = 3,
|
||||
[0] = "strbDwzU", "ldrbDwzU"
|
||||
[0] = "strbDwzU", "ldrbDwzU", "ldrsbDwzU", "ldrsbDxzU"
|
||||
},
|
||||
{
|
||||
shift = 22, mask = 3,
|
||||
[0] = "strhDwzU", "ldrhDwzU"
|
||||
[0] = "strhDwzU", "ldrhDwzU", "ldrshDwzU", "ldrshDxzU"
|
||||
},
|
||||
{
|
||||
shift = 22, mask = 3,
|
||||
[0] = "strDwzU", "ldrDwzU"
|
||||
[0] = "strDwzU", "ldrDwzU", "ldrswDxzU"
|
||||
},
|
||||
{
|
||||
shift = 22, mask = 3,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
----------------------------------------------------------------------------
|
||||
-- LuaJIT ARM64BE disassembler wrapper module.
|
||||
--
|
||||
-- Copyright (C) 2005-2025 Mike Pall. All rights reserved.
|
||||
-- Copyright (C) 2005-2026 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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
----------------------------------------------------------------------------
|
||||
-- LuaJIT MIPS disassembler module.
|
||||
--
|
||||
-- Copyright (C) 2005-2025 Mike Pall. All rights reserved.
|
||||
-- Copyright (C) 2005-2026 Mike Pall. All rights reserved.
|
||||
-- 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.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
----------------------------------------------------------------------------
|
||||
-- LuaJIT MIPS64 disassembler wrapper module.
|
||||
--
|
||||
-- Copyright (C) 2005-2025 Mike Pall. All rights reserved.
|
||||
-- Copyright (C) 2005-2026 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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
----------------------------------------------------------------------------
|
||||
-- LuaJIT MIPS64EL disassembler wrapper module.
|
||||
--
|
||||
-- Copyright (C) 2005-2025 Mike Pall. All rights reserved.
|
||||
-- Copyright (C) 2005-2026 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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
----------------------------------------------------------------------------
|
||||
-- LuaJIT MIPS64R6 disassembler wrapper module.
|
||||
--
|
||||
-- Copyright (C) 2005-2025 Mike Pall. All rights reserved.
|
||||
-- Copyright (C) 2005-2026 Mike Pall. All rights reserved.
|
||||
-- Released under the MIT license. See Copyright Notice in luajit.h
|
||||
----------------------------------------------------------------------------
|
||||
-- This module just exports the r6 big-endian functions from the
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
----------------------------------------------------------------------------
|
||||
-- LuaJIT MIPS64R6EL disassembler wrapper module.
|
||||
--
|
||||
-- Copyright (C) 2005-2025 Mike Pall. All rights reserved.
|
||||
-- Copyright (C) 2005-2026 Mike Pall. All rights reserved.
|
||||
-- Released under the MIT license. See Copyright Notice in luajit.h
|
||||
----------------------------------------------------------------------------
|
||||
-- This module just exports the r6 little-endian functions from the
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
----------------------------------------------------------------------------
|
||||
-- LuaJIT MIPSEL disassembler wrapper module.
|
||||
--
|
||||
-- Copyright (C) 2005-2025 Mike Pall. All rights reserved.
|
||||
-- Copyright (C) 2005-2026 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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
----------------------------------------------------------------------------
|
||||
-- LuaJIT PPC disassembler module.
|
||||
--
|
||||
-- Copyright (C) 2005-2025 Mike Pall. All rights reserved.
|
||||
-- Copyright (C) 2005-2026 Mike Pall. All rights reserved.
|
||||
-- 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.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
----------------------------------------------------------------------------
|
||||
-- LuaJIT x64 disassembler wrapper module.
|
||||
--
|
||||
-- Copyright (C) 2005-2025 Mike Pall. All rights reserved.
|
||||
-- Copyright (C) 2005-2026 Mike Pall. All rights reserved.
|
||||
-- Released under the MIT license. See Copyright Notice in luajit.h
|
||||
----------------------------------------------------------------------------
|
||||
-- This module just exports the 64 bit functions from the combined
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
----------------------------------------------------------------------------
|
||||
-- LuaJIT x86/x64 disassembler module.
|
||||
--
|
||||
-- Copyright (C) 2005-2025 Mike Pall. All rights reserved.
|
||||
-- Copyright (C) 2005-2026 Mike Pall. All rights reserved.
|
||||
-- Released under the MIT license. See Copyright Notice in luajit.h
|
||||
----------------------------------------------------------------------------
|
||||
-- This is a helper module used by the LuaJIT machine code dumper module.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
----------------------------------------------------------------------------
|
||||
-- LuaJIT compiler dump module.
|
||||
--
|
||||
-- Copyright (C) 2005-2025 Mike Pall. All rights reserved.
|
||||
-- Copyright (C) 2005-2026 Mike Pall. All rights reserved.
|
||||
-- Released under the MIT license. See Copyright Notice in luajit.h
|
||||
----------------------------------------------------------------------------
|
||||
--
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
----------------------------------------------------------------------------
|
||||
-- LuaJIT profiler.
|
||||
--
|
||||
-- Copyright (C) 2005-2025 Mike Pall. All rights reserved.
|
||||
-- Copyright (C) 2005-2026 Mike Pall. All rights reserved.
|
||||
-- Released under the MIT license. See Copyright Notice in luajit.h
|
||||
----------------------------------------------------------------------------
|
||||
--
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
----------------------------------------------------------------------------
|
||||
-- Verbose mode of the LuaJIT compiler.
|
||||
--
|
||||
-- Copyright (C) 2005-2025 Mike Pall. All rights reserved.
|
||||
-- Copyright (C) 2005-2026 Mike Pall. All rights reserved.
|
||||
-- Released under the MIT license. See Copyright Notice in luajit.h
|
||||
----------------------------------------------------------------------------
|
||||
--
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
----------------------------------------------------------------------------
|
||||
-- LuaJIT profiler zones.
|
||||
--
|
||||
-- Copyright (C) 2005-2025 Mike Pall. All rights reserved.
|
||||
-- Copyright (C) 2005-2026 Mike Pall. All rights reserved.
|
||||
-- Released under the MIT license. See Copyright Notice in luajit.h
|
||||
----------------------------------------------------------------------------
|
||||
--
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
** Auxiliary library for the Lua/C API.
|
||||
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
|
||||
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
|
||||
**
|
||||
** Major parts taken verbatim or adapted from the Lua interpreter.
|
||||
** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
** Base and coroutine library.
|
||||
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
|
||||
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
|
||||
**
|
||||
** Major portions taken verbatim or adapted from the Lua interpreter.
|
||||
** Copyright (C) 1994-2011 Lua.org, PUC-Rio. See Copyright Notice in lua.h
|
||||
@@ -243,7 +243,9 @@ LJLIB_CF(unpack)
|
||||
} else {
|
||||
setnilV(L->top++);
|
||||
}
|
||||
} while (i++ < e);
|
||||
if (i >= e) break;
|
||||
i++;
|
||||
} while (1);
|
||||
return n;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
** Bit manipulation library.
|
||||
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
|
||||
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
|
||||
*/
|
||||
|
||||
#define lib_bit_c
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
** Buffer library.
|
||||
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
|
||||
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
|
||||
*/
|
||||
|
||||
#define lib_buffer_c
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
** Debug library.
|
||||
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
|
||||
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
|
||||
**
|
||||
** Major portions taken verbatim or adapted from the Lua interpreter.
|
||||
** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h
|
||||
@@ -283,7 +283,7 @@ LJLIB_CF(debug_setuservalue)
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
#define KEY_HOOK (U64x(80000000,00000000)|'h')
|
||||
#define KEY_HOOK (U64x(81000000,00000000)|'h')
|
||||
|
||||
static void hookf(lua_State *L, lua_Debug *ar)
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
** FFI library.
|
||||
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
|
||||
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
|
||||
*/
|
||||
|
||||
#define lib_ffi_c
|
||||
@@ -758,6 +758,9 @@ LJLIB_CF(ffi_abi) LJLIB_REC(.)
|
||||
#endif
|
||||
#if LJ_GC64
|
||||
"\004gc64"
|
||||
#endif
|
||||
#if LJ_DUALNUM
|
||||
"\007dualnum"
|
||||
#endif
|
||||
) >= 0;
|
||||
setboolV(L->top-1, b);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
** Library initialization.
|
||||
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
|
||||
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
|
||||
**
|
||||
** Major parts taken verbatim from the Lua interpreter.
|
||||
** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
** I/O library.
|
||||
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
|
||||
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
|
||||
**
|
||||
** Major portions taken verbatim or adapted from the Lua interpreter.
|
||||
** Copyright (C) 1994-2011 Lua.org, PUC-Rio. See Copyright Notice in lua.h
|
||||
@@ -127,8 +127,9 @@ static int io_file_readnum(lua_State *L, FILE *fp)
|
||||
lua_Number d;
|
||||
if (fscanf(fp, LUA_NUMBER_SCAN, &d) == 1) {
|
||||
if (LJ_DUALNUM) {
|
||||
int32_t i = lj_num2int(d);
|
||||
if (d == (lua_Number)i && !tvismzero((cTValue *)&d)) {
|
||||
int64_t i64;
|
||||
int32_t i;
|
||||
if (lj_num2int_check(d, i64, i) && !tvismzero((cTValue *)&d)) {
|
||||
setintV(L->top++, i);
|
||||
return 1;
|
||||
}
|
||||
@@ -335,7 +336,7 @@ LJLIB_CF(io_method_seek)
|
||||
if (tvisint(o))
|
||||
ofs = (int64_t)intV(o);
|
||||
else if (tvisnum(o))
|
||||
ofs = (int64_t)numV(o);
|
||||
ofs = lj_num2i64(numV(o));
|
||||
else if (!tvisnil(o))
|
||||
lj_err_argt(L, 3, LUA_TNUMBER);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
** JIT library.
|
||||
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
|
||||
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
|
||||
*/
|
||||
|
||||
#define lib_jit_c
|
||||
@@ -340,11 +340,12 @@ LJLIB_CF(jit_util_tracek)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* local snap = jit.util.tracesnap(tr, sn) */
|
||||
/* local snap = jit.util.tracesnap(tr, sn[, getpos]) */
|
||||
LJLIB_CF(jit_util_tracesnap)
|
||||
{
|
||||
GCtrace *T = jit_checktrace(L);
|
||||
SnapNo sn = (SnapNo)lj_lib_checkint(L, 2);
|
||||
int getpos = (L->base+2 < L->top && tvistruecond(L->base+2));
|
||||
if (T && sn < T->nsnap) {
|
||||
SnapShot *snap = &T->snap[sn];
|
||||
SnapEntry *map = &T->snapmap[snap->mapofs];
|
||||
@@ -357,6 +358,12 @@ LJLIB_CF(jit_util_tracesnap)
|
||||
for (n = 0; n < nent; n++)
|
||||
setintV(lj_tab_setint(L, t, (int32_t)(n+2)), (int32_t)map[n]);
|
||||
setintV(lj_tab_setint(L, t, (int32_t)(nent+2)), (int32_t)SNAP(255, 0, 0));
|
||||
if (getpos) {
|
||||
const BCIns *pc = snap_pc(&map[nent]), *startpc = pc;
|
||||
while (bc_op(*startpc) < BC_FUNCF) startpc--;
|
||||
setintV(L->top++, (int)(pc - startpc));
|
||||
return 2;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
@@ -535,8 +542,8 @@ LJLIB_CF(jit_opt_start)
|
||||
|
||||
/* Not loaded by default, use: local profile = require("jit.profile") */
|
||||
|
||||
#define KEY_PROFILE_THREAD (U64x(80000000,00000000)|'t')
|
||||
#define KEY_PROFILE_FUNC (U64x(80000000,00000000)|'f')
|
||||
#define KEY_PROFILE_THREAD (U64x(81000000,00000000)|'t')
|
||||
#define KEY_PROFILE_FUNC (U64x(81000000,00000000)|'f')
|
||||
|
||||
static void jit_profile_callback(lua_State *L2, lua_State *L, int samples,
|
||||
int vmstate)
|
||||
@@ -723,7 +730,16 @@ static void jit_init(lua_State *L)
|
||||
jit_State *J = L2J(L);
|
||||
J->flags = jit_cpudetect() | JIT_F_ON | JIT_F_OPT_DEFAULT;
|
||||
memcpy(J->param, jit_param_default, sizeof(J->param));
|
||||
lj_dispatch_update(G(L));
|
||||
#if LJ_TARGET_UNALIGNED
|
||||
G(L)->tmptv.u64 = U64x(0000504d,4d500000);
|
||||
#endif
|
||||
lj_dispatch_update(G(L), 0);
|
||||
#if LJ_TARGET_UNALIGNED
|
||||
/* If you get a crash below then your toolchain indicates unaligned
|
||||
** accesses are OK, but your kernel disagrees. I.e. fix your toolchain.
|
||||
*/
|
||||
if (*(uint32_t *)((char *)&G(L)->tmptv + 2) != 0x504d4d50u) L->top = NULL;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
** Math library.
|
||||
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
|
||||
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
** OS library.
|
||||
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
|
||||
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
|
||||
**
|
||||
** Major portions taken verbatim or adapted from the Lua interpreter.
|
||||
** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h
|
||||
@@ -171,7 +171,8 @@ static int getfield(lua_State *L, const char *key, int d)
|
||||
LJLIB_CF(os_date)
|
||||
{
|
||||
const char *s = luaL_optstring(L, 1, "%c");
|
||||
time_t t = luaL_opt(L, (time_t)luaL_checknumber, 2, time(NULL));
|
||||
time_t t = lua_isnoneornil(L, 2) ? time(NULL) :
|
||||
lj_num2int_type(luaL_checknumber(L, 2), time_t);
|
||||
struct tm *stm;
|
||||
#if LJ_TARGET_POSIX
|
||||
struct tm rtm;
|
||||
@@ -239,12 +240,13 @@ LJLIB_CF(os_time)
|
||||
ts.tm_min = getfield(L, "min", 0);
|
||||
ts.tm_hour = getfield(L, "hour", 12);
|
||||
ts.tm_mday = getfield(L, "day", -1);
|
||||
ts.tm_mon = getfield(L, "month", -1) - 1;
|
||||
ts.tm_year = getfield(L, "year", -1) - 1900;
|
||||
ts.tm_mon = (int)((unsigned int)getfield(L, "month", -1) - 1u);
|
||||
ts.tm_year = (int)((unsigned int)getfield(L, "year", -1) - 1900u);
|
||||
ts.tm_isdst = getboolfield(L, "isdst");
|
||||
errno = 0;
|
||||
t = mktime(&ts);
|
||||
}
|
||||
if (t == (time_t)(-1))
|
||||
if (t == (time_t)(-1) && errno != 0)
|
||||
lua_pushnil(L);
|
||||
else
|
||||
lua_pushnumber(L, (lua_Number)t);
|
||||
@@ -253,8 +255,9 @@ LJLIB_CF(os_time)
|
||||
|
||||
LJLIB_CF(os_difftime)
|
||||
{
|
||||
lua_pushnumber(L, difftime((time_t)(luaL_checknumber(L, 1)),
|
||||
(time_t)(luaL_optnumber(L, 2, (lua_Number)0))));
|
||||
lua_pushnumber(L,
|
||||
difftime(lj_num2int_type(luaL_checknumber(L, 1), time_t),
|
||||
lj_num2int_type(luaL_optnumber(L, 2, (lua_Number)0), time_t)));
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
** Package library.
|
||||
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
|
||||
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
|
||||
**
|
||||
** Major portions taken verbatim or adapted from the Lua interpreter.
|
||||
** Copyright (C) 1994-2012 Lua.org, PUC-Rio. See Copyright Notice in lua.h
|
||||
@@ -425,7 +425,7 @@ static int lj_cf_package_loader_preload(lua_State *L)
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
#define KEY_SENTINEL (U64x(80000000,00000000)|'s')
|
||||
#define KEY_SENTINEL (U64x(81000000,00000000)|'s')
|
||||
|
||||
static int lj_cf_package_require(lua_State *L)
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
** String library.
|
||||
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
|
||||
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
|
||||
**
|
||||
** Major portions taken verbatim or adapted from the Lua interpreter.
|
||||
** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
** Table library.
|
||||
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
|
||||
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
|
||||
**
|
||||
** Major portions taken verbatim or adapted from the Lua interpreter.
|
||||
** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h
|
||||
|
||||
@@ -100,8 +100,8 @@
|
||||
|
||||
#if LJ_GC64
|
||||
#define LJ_ALLOC_MBITS 47 /* 128 TB in LJ_GC64 mode. */
|
||||
#elif LJ_TARGET_X64 && LJ_HASJIT
|
||||
/* Due to limitations in the x64 compiler backend. */
|
||||
#elif LJ_TARGET_X64
|
||||
/* Due to limitations in the x64 non-GC64 VM. */
|
||||
#define LJ_ALLOC_MBITS 31 /* 2 GB on x64 with !LJ_GC64. */
|
||||
#else
|
||||
#define LJ_ALLOC_MBITS 32 /* 4 GB on other archs with !LJ_GC64. */
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
** Public Lua/C API.
|
||||
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
|
||||
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
|
||||
**
|
||||
** Major portions taken verbatim or adapted from the Lua interpreter.
|
||||
** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h
|
||||
@@ -416,11 +416,7 @@ LUA_API lua_Integer lua_tointeger(lua_State *L, int idx)
|
||||
return intV(&tmp);
|
||||
n = numV(&tmp);
|
||||
}
|
||||
#if LJ_64
|
||||
return (lua_Integer)n;
|
||||
#else
|
||||
return lj_num2int(n);
|
||||
#endif
|
||||
return lj_num2int_type(n, lua_Integer);
|
||||
}
|
||||
|
||||
LUA_API lua_Integer lua_tointegerx(lua_State *L, int idx, int *ok)
|
||||
@@ -445,11 +441,7 @@ LUA_API lua_Integer lua_tointegerx(lua_State *L, int idx, int *ok)
|
||||
n = numV(&tmp);
|
||||
}
|
||||
if (ok) *ok = 1;
|
||||
#if LJ_64
|
||||
return (lua_Integer)n;
|
||||
#else
|
||||
return lj_num2int(n);
|
||||
#endif
|
||||
return lj_num2int_type(n, lua_Integer);
|
||||
}
|
||||
|
||||
LUALIB_API lua_Integer luaL_checkinteger(lua_State *L, int idx)
|
||||
@@ -468,11 +460,7 @@ LUALIB_API lua_Integer luaL_checkinteger(lua_State *L, int idx)
|
||||
return (lua_Integer)intV(&tmp);
|
||||
n = numV(&tmp);
|
||||
}
|
||||
#if LJ_64
|
||||
return (lua_Integer)n;
|
||||
#else
|
||||
return lj_num2int(n);
|
||||
#endif
|
||||
return lj_num2int_type(n, lua_Integer);
|
||||
}
|
||||
|
||||
LUALIB_API lua_Integer luaL_optinteger(lua_State *L, int idx, lua_Integer def)
|
||||
@@ -493,11 +481,7 @@ LUALIB_API lua_Integer luaL_optinteger(lua_State *L, int idx, lua_Integer def)
|
||||
return (lua_Integer)intV(&tmp);
|
||||
n = numV(&tmp);
|
||||
}
|
||||
#if LJ_64
|
||||
return (lua_Integer)n;
|
||||
#else
|
||||
return lj_num2int(n);
|
||||
#endif
|
||||
return lj_num2int_type(n, lua_Integer);
|
||||
}
|
||||
|
||||
LUA_API int lua_toboolean(lua_State *L, int idx)
|
||||
@@ -724,7 +708,7 @@ LUA_API void lua_pushlightuserdata(lua_State *L, void *p)
|
||||
LUA_API void lua_createtable(lua_State *L, int narray, int nrec)
|
||||
{
|
||||
lj_gc_check(L);
|
||||
settabV(L, L->top, lj_tab_new_ah(L, narray, nrec));
|
||||
settabV(L, L->top, lj_tab_new_ah(L, (uint32_t)narray, (uint32_t)nrec));
|
||||
incr_top(L);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
** Target architecture selection.
|
||||
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
|
||||
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
|
||||
*/
|
||||
|
||||
#ifndef _LJ_ARCH_H
|
||||
@@ -304,6 +304,10 @@
|
||||
#define LJ_PAGESIZE 16384
|
||||
#define LJ_ARCH_NUMMODE LJ_NUMMODE_DUAL
|
||||
|
||||
#if __ARM_FEATURE_UNALIGNED
|
||||
#define LJ_TARGET_UNALIGNED 1
|
||||
#endif
|
||||
|
||||
#define LJ_ARCH_VERSION 80
|
||||
|
||||
#elif LUAJIT_TARGET == LUAJIT_ARCH_PPC
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
** IR assembler (SSA IR -> machine code).
|
||||
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
|
||||
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
|
||||
*/
|
||||
|
||||
#define lj_asm_c
|
||||
@@ -1329,27 +1329,32 @@ static void asm_conv64(ASMState *as, IRIns *ir)
|
||||
IRType st = (IRType)((ir-1)->op2 & IRCONV_SRCMASK);
|
||||
IRType dt = (((ir-1)->op2 & IRCONV_DSTMASK) >> IRCONV_DSH);
|
||||
IRCallID id;
|
||||
const CCallInfo *ci;
|
||||
#if LJ_TARGET_ARM && !LJ_ABI_SOFTFP
|
||||
CCallInfo cim;
|
||||
#endif
|
||||
IRRef args[2];
|
||||
lj_assertA((ir-1)->o == IR_CONV && ir->o == IR_HIOP,
|
||||
"not a CONV/HIOP pair at IR %04d", (int)(ir - as->ir) - REF_BIAS);
|
||||
args[LJ_BE] = (ir-1)->op1;
|
||||
args[LJ_LE] = ir->op1;
|
||||
if (st == IRT_NUM || st == IRT_FLOAT) {
|
||||
id = IRCALL_fp64_d2l + ((st == IRT_FLOAT) ? 2 : 0) + (dt - IRT_I64);
|
||||
lj_assertA(st != IRT_FLOAT, "bad CONV *64.float emitted");
|
||||
if (st == IRT_NUM) {
|
||||
id = IRCALL_lj_vm_num2u64;
|
||||
ir--;
|
||||
ci = &lj_ir_callinfo[id];
|
||||
} else {
|
||||
id = IRCALL_fp64_l2d + ((dt == IRT_FLOAT) ? 2 : 0) + (st - IRT_I64);
|
||||
}
|
||||
{
|
||||
#if LJ_TARGET_ARM && !LJ_ABI_SOFTFP
|
||||
CCallInfo cim = lj_ir_callinfo[id], *ci = &cim;
|
||||
cim = lj_ir_callinfo[id];
|
||||
cim.flags |= CCI_VARARG; /* These calls don't use the hard-float ABI! */
|
||||
ci = &cim;
|
||||
#else
|
||||
const CCallInfo *ci = &lj_ir_callinfo[id];
|
||||
ci = &lj_ir_callinfo[id];
|
||||
#endif
|
||||
asm_setupresult(as, ir, ci);
|
||||
asm_gencall(as, ci, args);
|
||||
}
|
||||
asm_setupresult(as, ir, ci);
|
||||
asm_gencall(as, ci, args);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
** IR assembler (SSA IR -> machine code).
|
||||
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
|
||||
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
|
||||
*/
|
||||
|
||||
#ifndef _LJ_ASM_H
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
** ARM IR assembler (SSA IR -> machine code).
|
||||
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
|
||||
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
|
||||
*/
|
||||
|
||||
/* -- Register allocator extensions --------------------------------------- */
|
||||
@@ -624,10 +624,9 @@ static void asm_conv(ASMState *as, IRIns *ir)
|
||||
Reg tmp = ra_scratch(as, rset_exclude(RSET_FPR, left));
|
||||
Reg dest = ra_dest(as, ir, RSET_GPR);
|
||||
ARMIns ai;
|
||||
lj_assertA(!irt_isu32(ir->t), "bad CONV u32.fp emitted");
|
||||
emit_dn(as, ARMI_VMOV_R_S, dest, (tmp & 15));
|
||||
ai = irt_isint(ir->t) ?
|
||||
(st == IRT_NUM ? ARMI_VCVT_S32_F64 : ARMI_VCVT_S32_F32) :
|
||||
(st == IRT_NUM ? ARMI_VCVT_U32_F64 : ARMI_VCVT_U32_F32);
|
||||
ai = st == IRT_NUM ? ARMI_VCVT_S32_F64 : ARMI_VCVT_S32_F32;
|
||||
emit_dm(as, ai, (tmp & 15), (left & 15));
|
||||
}
|
||||
} else
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
** ARM64 IR assembler (SSA IR -> machine code).
|
||||
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
|
||||
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
|
||||
**
|
||||
** Contributed by Djordje Kovacevic and Stefan Pejic from RT-RK.com.
|
||||
** Sponsored by Cisco Systems, Inc.
|
||||
@@ -648,14 +648,18 @@ static void asm_conv(ASMState *as, IRIns *ir)
|
||||
} else {
|
||||
Reg left = ra_alloc1(as, lref, RSET_FPR);
|
||||
Reg dest = ra_dest(as, ir, RSET_GPR);
|
||||
A64Ins ai = irt_is64(ir->t) ?
|
||||
(st == IRT_NUM ?
|
||||
(irt_isi64(ir->t) ? A64I_FCVT_S64_F64 : A64I_FCVT_U64_F64) :
|
||||
(irt_isi64(ir->t) ? A64I_FCVT_S64_F32 : A64I_FCVT_U64_F32)) :
|
||||
(st == IRT_NUM ?
|
||||
(irt_isint(ir->t) ? A64I_FCVT_S32_F64 : A64I_FCVT_U32_F64) :
|
||||
(irt_isint(ir->t) ? A64I_FCVT_S32_F32 : A64I_FCVT_U32_F32));
|
||||
emit_dn(as, ai, dest, (left & 31));
|
||||
lj_assertA(!irt_isu32(ir->t), "bad CONV u32.fp emitted");
|
||||
if (irt_isu64(ir->t)) {
|
||||
emit_dnm(as, A64I_CSELx | A64F_CC(CC_VC), dest, dest, RID_TMP);
|
||||
emit_n(as, (A64I_CMNx^A64I_K12) | A64F_U12(1), dest);
|
||||
emit_dn(as, st == IRT_NUM ? A64I_FCVT_U64_F64 : A64I_FCVT_U64_F32, RID_TMP, (left & 31));
|
||||
emit_dn(as, st == IRT_NUM ? A64I_FCVT_S64_F64 : A64I_FCVT_S64_F32, dest, (left & 31));
|
||||
} else {
|
||||
A64Ins ai = irt_is64(ir->t) ?
|
||||
(st == IRT_NUM ? A64I_FCVT_S64_F64 : A64I_FCVT_S64_F32) :
|
||||
(st == IRT_NUM ? A64I_FCVT_S32_F64 : A64I_FCVT_S32_F32);
|
||||
emit_dn(as, ai, dest, (left & 31));
|
||||
}
|
||||
}
|
||||
} else if (st >= IRT_I8 && st <= IRT_U16) { /* Extend to 32 bit integer. */
|
||||
Reg dest = ra_dest(as, ir, RSET_GPR);
|
||||
@@ -1056,7 +1060,8 @@ static void asm_fstore(ASMState *as, IRIns *ir)
|
||||
static void asm_xload(ASMState *as, IRIns *ir)
|
||||
{
|
||||
Reg dest = ra_dest(as, ir, irt_isfp(ir->t) ? RSET_FPR : RSET_GPR);
|
||||
lj_assertA(!(ir->op2 & IRXLOAD_UNALIGNED), "unaligned XLOAD");
|
||||
lj_assertA(LJ_TARGET_UNALIGNED || !(ir->op2 & IRXLOAD_UNALIGNED),
|
||||
"unaligned XLOAD");
|
||||
asm_fusexref(as, asm_fxloadins(ir), dest, ir->op1, RSET_GPR);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
** MIPS IR assembler (SSA IR -> machine code).
|
||||
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
|
||||
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
|
||||
*/
|
||||
|
||||
/* -- Register allocator extensions --------------------------------------- */
|
||||
@@ -635,64 +635,38 @@ static void asm_conv(ASMState *as, IRIns *ir)
|
||||
Reg dest = ra_dest(as, ir, RSET_GPR);
|
||||
Reg left = ra_alloc1(as, lref, RSET_FPR);
|
||||
Reg tmp = ra_scratch(as, rset_exclude(RSET_FPR, left));
|
||||
if (irt_isu32(ir->t)) { /* FP to U32 conversion. */
|
||||
/* y = (int)floor(x - 2147483648.0) ^ 0x80000000 */
|
||||
emit_dst(as, MIPSI_XOR, dest, dest, RID_TMP);
|
||||
emit_ti(as, MIPSI_LUI, RID_TMP, 0x8000);
|
||||
emit_tg(as, MIPSI_MFC1, dest, tmp);
|
||||
emit_fg(as, st == IRT_FLOAT ? MIPSI_FLOOR_W_S : MIPSI_FLOOR_W_D,
|
||||
tmp, tmp);
|
||||
emit_fgh(as, st == IRT_FLOAT ? MIPSI_SUB_S : MIPSI_SUB_D,
|
||||
tmp, left, tmp);
|
||||
if (st == IRT_FLOAT)
|
||||
emit_lsptr(as, MIPSI_LWC1, (tmp & 31),
|
||||
(void *)&as->J->k32[LJ_K32_2P31], RSET_GPR);
|
||||
else
|
||||
emit_lsptr(as, MIPSI_LDC1, (tmp & 31),
|
||||
(void *)&as->J->k64[LJ_K64_2P31], RSET_GPR);
|
||||
lj_assertA(!irt_isu32(ir->t), "bad CONV u32.fp emitted");
|
||||
#if LJ_64
|
||||
} else if (irt_isu64(ir->t)) { /* FP to U64 conversion. */
|
||||
MCLabel l_end;
|
||||
if (irt_isu64(ir->t)) { /* FP to U64 conversion. */
|
||||
MCLabel l_end = emit_label(as);
|
||||
emit_tg(as, MIPSI_DMFC1, dest, tmp);
|
||||
l_end = emit_label(as);
|
||||
/* For inputs >= 2^63 add -2^64 and convert again. */
|
||||
/* For result == INT64_MAX add -2^64 and convert again. */
|
||||
if (st == IRT_NUM) {
|
||||
emit_fg(as, MIPSI_TRUNC_L_D, tmp, tmp);
|
||||
emit_fgh(as, MIPSI_ADD_D, tmp, left, tmp);
|
||||
emit_lsptr(as, MIPSI_LDC1, (tmp & 31),
|
||||
(void *)&as->J->k64[LJ_K64_M2P64],
|
||||
rset_exclude(RSET_GPR, dest));
|
||||
emit_fg(as, MIPSI_TRUNC_L_D, tmp, left); /* Delay slot. */
|
||||
#if !LJ_TARGET_MIPSR6
|
||||
emit_branch(as, MIPSI_BC1T, 0, 0, l_end);
|
||||
emit_fgh(as, MIPSI_C_OLT_D, 0, left, tmp);
|
||||
#else
|
||||
emit_branch(as, MIPSI_BC1NEZ, 0, (tmp&31), l_end);
|
||||
emit_fgh(as, MIPSI_CMP_LT_D, tmp, left, tmp);
|
||||
#endif
|
||||
emit_lsptr(as, MIPSI_LDC1, (tmp & 31),
|
||||
(void *)&as->J->k64[LJ_K64_2P63],
|
||||
rset_exclude(RSET_GPR, dest));
|
||||
rset_exclude(RSET_GPR, dest)); /* Delay slot. */
|
||||
emit_branch(as, MIPSI_BNE, RID_TMP, dest, l_end); /* != INT64_MAX? */
|
||||
emit_dta(as, MIPSI_DSRL, RID_TMP, RID_TMP, 1);
|
||||
emit_ti(as, MIPSI_LI, RID_TMP, -1);
|
||||
emit_tg(as, MIPSI_DMFC1, dest, tmp);
|
||||
emit_fg(as, MIPSI_TRUNC_L_D, tmp, left);
|
||||
} else {
|
||||
emit_fg(as, MIPSI_TRUNC_L_S, tmp, tmp);
|
||||
emit_fgh(as, MIPSI_ADD_S, tmp, left, tmp);
|
||||
emit_lsptr(as, MIPSI_LWC1, (tmp & 31),
|
||||
(void *)&as->J->k32[LJ_K32_M2P64],
|
||||
rset_exclude(RSET_GPR, dest));
|
||||
emit_fg(as, MIPSI_TRUNC_L_S, tmp, left); /* Delay slot. */
|
||||
#if !LJ_TARGET_MIPSR6
|
||||
emit_branch(as, MIPSI_BC1T, 0, 0, l_end);
|
||||
emit_fgh(as, MIPSI_C_OLT_S, 0, left, tmp);
|
||||
#else
|
||||
emit_branch(as, MIPSI_BC1NEZ, 0, (tmp&31), l_end);
|
||||
emit_fgh(as, MIPSI_CMP_LT_S, tmp, left, tmp);
|
||||
#endif
|
||||
emit_lsptr(as, MIPSI_LWC1, (tmp & 31),
|
||||
(void *)&as->J->k32[LJ_K32_2P63],
|
||||
rset_exclude(RSET_GPR, dest));
|
||||
rset_exclude(RSET_GPR, dest)); /* Delay slot. */
|
||||
emit_branch(as, MIPSI_BNE, RID_TMP, dest, l_end); /* != INT64_MAX? */
|
||||
emit_dta(as, MIPSI_DSRL, RID_TMP, RID_TMP, 1);
|
||||
emit_ti(as, MIPSI_LI, RID_TMP, -1);
|
||||
emit_tg(as, MIPSI_DMFC1, dest, tmp);
|
||||
emit_fg(as, MIPSI_TRUNC_L_S, tmp, left);
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
} else {
|
||||
{
|
||||
#if LJ_32
|
||||
emit_tg(as, MIPSI_MFC1, dest, tmp);
|
||||
emit_fg(as, st == IRT_FLOAT ? MIPSI_TRUNC_W_S : MIPSI_TRUNC_W_D,
|
||||
@@ -733,13 +707,11 @@ static void asm_conv(ASMState *as, IRIns *ir)
|
||||
"bad type for checked CONV");
|
||||
asm_tointg(as, ir, RID_NONE);
|
||||
} else {
|
||||
IRCallID cid = irt_is64(ir->t) ?
|
||||
((st == IRT_NUM) ?
|
||||
(irt_isi64(ir->t) ? IRCALL_fp64_d2l : IRCALL_fp64_d2ul) :
|
||||
(irt_isi64(ir->t) ? IRCALL_fp64_f2l : IRCALL_fp64_f2ul)) :
|
||||
((st == IRT_NUM) ?
|
||||
(irt_isint(ir->t) ? IRCALL_softfp_d2i : IRCALL_softfp_d2ui) :
|
||||
(irt_isint(ir->t) ? IRCALL_softfp_f2i : IRCALL_softfp_f2ui));
|
||||
IRCallID cid;
|
||||
lj_assertA(!irt_isu32(ir->t), "bad CONV u32.fp emitted");
|
||||
lj_assertA(!(irt_is64(ir->t) && st != IRT_NUM), "bad CONV *64.float emitted");
|
||||
cid = irt_is64(ir->t) ? IRCALL_lj_vm_num2u64 :
|
||||
(st == IRT_NUM ? IRCALL_softfp_d2i : IRCALL_softfp_f2i);
|
||||
asm_callid(as, ir, cid);
|
||||
}
|
||||
} else
|
||||
@@ -780,7 +752,10 @@ static void asm_conv(ASMState *as, IRIns *ir)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (st64 && !(ir->op2 & IRCONV_NONE)) {
|
||||
if (!irt_isu32(ir->t)) { /* Implicit sign extension. */
|
||||
Reg left = ra_alloc1(as, lref, RSET_GPR);
|
||||
emit_dta(as, MIPSI_SLL, dest, left, 0);
|
||||
} else if (st64 && !(ir->op2 & IRCONV_NONE)) {
|
||||
/* This is either a 32 bit reg/reg mov which zeroes the hiword
|
||||
** or a load of the loword from a 64 bit address.
|
||||
*/
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
** PPC IR assembler (SSA IR -> machine code).
|
||||
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
|
||||
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
|
||||
*/
|
||||
|
||||
/* -- Register allocator extensions --------------------------------------- */
|
||||
@@ -512,29 +512,10 @@ static void asm_conv(ASMState *as, IRIns *ir)
|
||||
Reg dest = ra_dest(as, ir, RSET_GPR);
|
||||
Reg left = ra_alloc1(as, lref, RSET_FPR);
|
||||
Reg tmp = ra_scratch(as, rset_exclude(RSET_FPR, left));
|
||||
if (irt_isu32(ir->t)) {
|
||||
/* Convert both x and x-2^31 to int and merge results. */
|
||||
Reg tmpi = ra_scratch(as, rset_exclude(RSET_GPR, dest));
|
||||
emit_asb(as, PPCI_OR, dest, dest, tmpi); /* Select with mask idiom. */
|
||||
emit_asb(as, PPCI_AND, tmpi, tmpi, RID_TMP);
|
||||
emit_asb(as, PPCI_ANDC, dest, dest, RID_TMP);
|
||||
emit_tai(as, PPCI_LWZ, tmpi, RID_SP, SPOFS_TMPLO); /* tmp = (int)(x) */
|
||||
emit_tai(as, PPCI_ADDIS, dest, dest, 0x8000); /* dest += 2^31 */
|
||||
emit_asb(as, PPCI_SRAWI, RID_TMP, dest, 31); /* mask = -(dest < 0) */
|
||||
emit_fai(as, PPCI_STFD, tmp, RID_SP, SPOFS_TMP);
|
||||
emit_tai(as, PPCI_LWZ, dest,
|
||||
RID_SP, SPOFS_TMPLO); /* dest = (int)(x-2^31) */
|
||||
emit_fb(as, PPCI_FCTIWZ, tmp, left);
|
||||
emit_fai(as, PPCI_STFD, tmp, RID_SP, SPOFS_TMP);
|
||||
emit_fb(as, PPCI_FCTIWZ, tmp, tmp);
|
||||
emit_fab(as, PPCI_FSUB, tmp, left, tmp);
|
||||
emit_lsptr(as, PPCI_LFS, (tmp & 31),
|
||||
(void *)&as->J->k32[LJ_K32_2P31], RSET_GPR);
|
||||
} else {
|
||||
emit_tai(as, PPCI_LWZ, dest, RID_SP, SPOFS_TMPLO);
|
||||
emit_fai(as, PPCI_STFD, tmp, RID_SP, SPOFS_TMP);
|
||||
emit_fb(as, PPCI_FCTIWZ, tmp, left);
|
||||
}
|
||||
lj_assertA(!irt_isu32(ir->t), "bad CONV u32.fp emitted");
|
||||
emit_tai(as, PPCI_LWZ, dest, RID_SP, SPOFS_TMPLO);
|
||||
emit_fai(as, PPCI_STFD, tmp, RID_SP, SPOFS_TMP);
|
||||
emit_fb(as, PPCI_FCTIWZ, tmp, left);
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
** x86/x64 IR assembler (SSA IR -> machine code).
|
||||
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
|
||||
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
|
||||
*/
|
||||
|
||||
/* -- Guard handling ------------------------------------------------------ */
|
||||
@@ -905,29 +905,28 @@ static void asm_conv(ASMState *as, IRIns *ir)
|
||||
} else {
|
||||
Reg dest = ra_dest(as, ir, RSET_GPR);
|
||||
x86Op op = st == IRT_NUM ? XO_CVTTSD2SI : XO_CVTTSS2SI;
|
||||
if (LJ_64 ? irt_isu64(ir->t) : irt_isu32(ir->t)) {
|
||||
/* LJ_64: For inputs >= 2^63 add -2^64, convert again. */
|
||||
/* LJ_32: For inputs >= 2^31 add -2^31, convert again and add 2^31. */
|
||||
lj_assertA(!irt_isu32(ir->t), "bad CONV u32.fp emitted");
|
||||
#if LJ_64
|
||||
if (irt_isu64(ir->t)) {
|
||||
/* For the indefinite result -2^63, add -2^64 and convert again. */
|
||||
Reg tmp = ra_noreg(IR(lref)->r) ? ra_alloc1(as, lref, RSET_FPR) :
|
||||
ra_scratch(as, RSET_FPR);
|
||||
MCLabel l_end = emit_label(as);
|
||||
if (LJ_32)
|
||||
emit_gri(as, XG_ARITHi(XOg_ADD), dest, (int32_t)0x80000000);
|
||||
emit_rr(as, op, dest|REX_64, tmp);
|
||||
if (st == IRT_NUM)
|
||||
emit_rma(as, XO_ADDSD, tmp, &as->J->k64[LJ_K64_M2P64_31]);
|
||||
emit_rma(as, XO_ADDSD, tmp, &as->J->k64[LJ_K64_M2P64]);
|
||||
else
|
||||
emit_rma(as, XO_ADDSS, tmp, &as->J->k32[LJ_K32_M2P64_31]);
|
||||
emit_sjcc(as, CC_NS, l_end);
|
||||
emit_rr(as, XO_TEST, dest|REX_64, dest); /* Check if dest negative. */
|
||||
emit_rma(as, XO_ADDSS, tmp, &as->J->k32[LJ_K32_M2P64]);
|
||||
emit_sjcc(as, CC_NO, l_end);
|
||||
emit_gmrmi(as, XG_ARITHi(XOg_CMP), dest|REX_64, 1);
|
||||
emit_rr(as, op, dest|REX_64, tmp);
|
||||
ra_left(as, tmp, lref);
|
||||
} else {
|
||||
if (LJ_64 && irt_isu32(ir->t))
|
||||
emit_rr(as, XO_MOV, dest, dest); /* Zero hiword. */
|
||||
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
emit_mrm(as, op,
|
||||
dest|((LJ_64 &&
|
||||
(irt_is64(ir->t) || irt_isu32(ir->t))) ? REX_64 : 0),
|
||||
dest|((LJ_64 && irt_is64(ir->t)) ? REX_64 : 0),
|
||||
asm_fuseload(as, lref, RSET_FPR));
|
||||
}
|
||||
}
|
||||
@@ -1020,6 +1019,7 @@ static void asm_conv_int64_fp(ASMState *as, IRIns *ir)
|
||||
IRType st = (IRType)((ir-1)->op2 & IRCONV_SRCMASK);
|
||||
IRType dt = (((ir-1)->op2 & IRCONV_DSTMASK) >> IRCONV_DSH);
|
||||
Reg lo, hi;
|
||||
int usehi = ra_used(ir);
|
||||
lj_assertA(st == IRT_NUM || st == IRT_FLOAT, "bad type for CONV");
|
||||
lj_assertA(dt == IRT_I64 || dt == IRT_U64, "bad type for CONV");
|
||||
hi = ra_dest(as, ir, RSET_GPR);
|
||||
@@ -1032,21 +1032,24 @@ static void asm_conv_int64_fp(ASMState *as, IRIns *ir)
|
||||
emit_gri(as, XG_ARITHi(XOg_AND), lo, 0xf3ff);
|
||||
}
|
||||
if (dt == IRT_U64) {
|
||||
/* For inputs in [2^63,2^64-1] add -2^64 and convert again. */
|
||||
/* For the indefinite result -2^63, add -2^64 and convert again. */
|
||||
MCLabel l_pop, l_end = emit_label(as);
|
||||
emit_x87op(as, XI_FPOP);
|
||||
l_pop = emit_label(as);
|
||||
emit_sjmp(as, l_end);
|
||||
emit_rmro(as, XO_MOV, hi, RID_ESP, 4);
|
||||
if (usehi) emit_rmro(as, XO_MOV, hi, RID_ESP, 4);
|
||||
if ((as->flags & JIT_F_SSE3))
|
||||
emit_rmro(as, XO_FISTTPq, XOg_FISTTPq, RID_ESP, 0);
|
||||
else
|
||||
emit_rmro(as, XO_FISTPq, XOg_FISTPq, RID_ESP, 0);
|
||||
emit_rma(as, XO_FADDq, XOg_FADDq, &as->J->k64[LJ_K64_M2P64]);
|
||||
emit_sjcc(as, CC_NS, l_pop);
|
||||
emit_rr(as, XO_TEST, hi, hi); /* Check if out-of-range (2^63). */
|
||||
emit_rma(as, XO_FADDd, XOg_FADDd, &as->J->k32[LJ_K32_M2P64]);
|
||||
emit_sjcc(as, CC_NE, l_pop);
|
||||
emit_gmroi(as, XG_ARITHi(XOg_CMP), RID_ESP, 0, 0);
|
||||
emit_sjcc(as, CC_NO, l_pop);
|
||||
emit_gmrmi(as, XG_ARITHi(XOg_CMP), hi, 1);
|
||||
usehi = 1;
|
||||
}
|
||||
emit_rmro(as, XO_MOV, hi, RID_ESP, 4);
|
||||
if (usehi) emit_rmro(as, XO_MOV, hi, RID_ESP, 4);
|
||||
if ((as->flags & JIT_F_SSE3)) { /* Truncation is easy with SSE3. */
|
||||
emit_rmro(as, XO_FISTTPq, XOg_FISTTPq, RID_ESP, 0);
|
||||
} else { /* Otherwise set FPU rounding mode to truncate before the store. */
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
** Internal assertions.
|
||||
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
|
||||
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
|
||||
*/
|
||||
|
||||
#define lj_assert_c
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
** Bytecode instruction modes.
|
||||
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
|
||||
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
|
||||
*/
|
||||
|
||||
#define lj_bc_c
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
** Bytecode instruction format.
|
||||
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
|
||||
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
|
||||
*/
|
||||
|
||||
#ifndef _LJ_BC_H
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
** Bytecode dump definitions.
|
||||
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
|
||||
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
|
||||
*/
|
||||
|
||||
#ifndef _LJ_BCDUMP_H
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
** Bytecode reader.
|
||||
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
|
||||
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
|
||||
*/
|
||||
|
||||
#define lj_bcread_c
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
** Bytecode writer.
|
||||
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
|
||||
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
|
||||
*/
|
||||
|
||||
#define lj_bcwrite_c
|
||||
@@ -59,9 +59,9 @@ static void bcwrite_ktabk(BCWriteCtx *ctx, cTValue *o, int narrow)
|
||||
p = lj_strfmt_wuleb128(p, intV(o));
|
||||
} else if (tvisnum(o)) {
|
||||
if (!LJ_DUALNUM && narrow) { /* Narrow number constants to integers. */
|
||||
lua_Number num = numV(o);
|
||||
int32_t k = lj_num2int(num);
|
||||
if (num == (lua_Number)k) { /* -0 is never a constant. */
|
||||
int64_t i64;
|
||||
int32_t k;
|
||||
if (lj_num2int_check(numV(o), i64, k)) { /* -0 is never a constant. */
|
||||
*p++ = BCDUMP_KTAB_INT;
|
||||
p = lj_strfmt_wuleb128(p, k);
|
||||
ctx->sb.w = p;
|
||||
@@ -270,9 +270,8 @@ static void bcwrite_knum(BCWriteCtx *ctx, GCproto *pt)
|
||||
/* Write a 33 bit ULEB128 for the int (lsb=0) or loword (lsb=1). */
|
||||
if (!LJ_DUALNUM && o->u32.hi != LJ_KEYINDEX) {
|
||||
/* Narrow number constants to integers. */
|
||||
lua_Number num = numV(o);
|
||||
k = lj_num2int(num);
|
||||
if (num == (lua_Number)k) { /* -0 is never a constant. */
|
||||
int64_t i64;
|
||||
if (lj_num2int_check(numV(o), i64, k)) { /* -0 is never a constant. */
|
||||
save_int:
|
||||
p = lj_strfmt_wuleb128(p, 2*(uint32_t)k | ((uint32_t)k&0x80000000u));
|
||||
if (k < 0)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
** Buffer handling.
|
||||
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
|
||||
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
|
||||
*/
|
||||
|
||||
#define lj_buf_c
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
** Buffer handling.
|
||||
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
|
||||
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
|
||||
*/
|
||||
|
||||
#ifndef _LJ_BUF_H
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
** C data arithmetic.
|
||||
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
|
||||
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
|
||||
*/
|
||||
|
||||
#include "lj_obj.h"
|
||||
@@ -120,7 +120,7 @@ static int carith_ptr(lua_State *L, CTState *cts, CDArith *ca, MMS mm)
|
||||
/* All valid pointer differences on x64 are in (-2^47, +2^47),
|
||||
** which fits into a double without loss of precision.
|
||||
*/
|
||||
setintptrV(L->top-1, (int32_t)diff);
|
||||
setintptrV(L->top-1, diff);
|
||||
return 1;
|
||||
} else if (mm == MM_lt) { /* Pointer comparison (unsigned). */
|
||||
setboolV(L->top-1, ((uintptr_t)pp < (uintptr_t)pp2));
|
||||
@@ -135,7 +135,7 @@ static int carith_ptr(lua_State *L, CTState *cts, CDArith *ca, MMS mm)
|
||||
return 0;
|
||||
lj_cconv_ct_ct(cts, ctype_get(cts, CTID_INT_PSZ), ca->ct[1],
|
||||
(uint8_t *)&idx, ca->p[1], 0);
|
||||
if (mm == MM_sub) idx = -idx;
|
||||
if (mm == MM_sub) idx = (ptrdiff_t)(~(uintptr_t)idx+1u);
|
||||
} else if (mm == MM_add && ctype_isnum(ctp->info) &&
|
||||
(ctype_isptr(ca->ct[1]->info) || ctype_isrefarray(ca->ct[1]->info))) {
|
||||
/* Swap pointer and index. */
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
** C data arithmetic.
|
||||
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
|
||||
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
|
||||
*/
|
||||
|
||||
#ifndef _LJ_CARITH_H
|
||||
|
||||
+51
-10
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
** FFI C call handling.
|
||||
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
|
||||
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
|
||||
*/
|
||||
|
||||
#include "lj_obj.h"
|
||||
@@ -168,7 +168,9 @@
|
||||
if (ccall_struct_arg(cc, cts, d, rcl, o, narg)) goto err_nyi; \
|
||||
nsp = cc->nsp; ngpr = cc->ngpr; nfpr = cc->nfpr; \
|
||||
continue; \
|
||||
} /* Pass all other structs by value on stack. */
|
||||
} else { /* Pass all other structs by value on stack. */ \
|
||||
onstack = 1; \
|
||||
}
|
||||
|
||||
#define CCALL_HANDLE_COMPLEXARG \
|
||||
isfp = 2; /* Pass complex in FPRs or on stack. Needs postprocessing. */
|
||||
@@ -183,7 +185,7 @@
|
||||
} \
|
||||
} else { /* Try to pass argument in GPRs. */ \
|
||||
/* Note that reordering is explicitly allowed in the x64 ABI. */ \
|
||||
if (n <= 2 && ngpr + n <= maxgpr) { \
|
||||
if (!onstack && n <= 2 && ngpr + n <= maxgpr) { \
|
||||
dp = &cc->gpr[ngpr]; \
|
||||
ngpr += n; \
|
||||
goto done; \
|
||||
@@ -350,7 +352,7 @@
|
||||
nfpr = CCALL_NARG_FPR; /* Prevent reordering. */ \
|
||||
} \
|
||||
} else { /* Try to pass argument in GPRs. */ \
|
||||
if (!LJ_TARGET_OSX && (d->info & CTF_ALIGN) > CTALIGN_PTR) \
|
||||
if (!LJ_TARGET_OSX && !rp && ccall_struct_align(cts, d) > CTALIGN_PTR) \
|
||||
ngpr = (ngpr + 1u) & ~1u; /* Align to regpair. */ \
|
||||
if (ngpr + n <= maxgpr) { \
|
||||
dp = &cc->gpr[ngpr]; \
|
||||
@@ -661,7 +663,7 @@ static int ccall_classify_struct(CTState *cts, CType *ct, int *rcl, CTSize ofs)
|
||||
fofs = ofs+ct->size;
|
||||
if (ctype_isfield(ct->info))
|
||||
ccall_classify_ct(cts, ctype_rawchild(cts, ct), rcl, fofs);
|
||||
else if (ctype_isbitfield(ct->info))
|
||||
else if (ctype_isbitfield(ct->info) && ctype_bitbsz(ct->info))
|
||||
rcl[(fofs >= 8)] |= CCALL_RCL_INT; /* NYI: unaligned bitfields? */
|
||||
else if (ctype_isxattrib(ct->info, CTA_SUBTYPE))
|
||||
ccall_classify_struct(cts, ctype_rawchild(cts, ct), rcl, fofs);
|
||||
@@ -700,8 +702,11 @@ static int ccall_struct_arg(CCallState *cc, CTState *cts, CType *d, int *rcl,
|
||||
if (ccall_struct_reg(cc, cts, dp, rcl)) {
|
||||
/* Register overflow? Pass on stack. */
|
||||
MSize nsp = cc->nsp, sz = rcl[1] ? 2*CTSIZE_PTR : CTSIZE_PTR;
|
||||
MSize align = (1u << ctype_align(d->info)) - 1;
|
||||
if (nsp + sz > CCALL_SIZE_STACK)
|
||||
return 1; /* Too many arguments. */
|
||||
if (CCALL_ALIGN_STACKARG && align > CTSIZE_PTR-1)
|
||||
nsp = (nsp + align) & ~align; /* Align argument on stack. */
|
||||
cc->nsp = nsp + sz;
|
||||
memcpy((uint8_t *)cc->stack + nsp, dp, sz);
|
||||
}
|
||||
@@ -776,6 +781,31 @@ noth: /* Not a homogeneous float/double aggregate. */
|
||||
|
||||
#if LJ_TARGET_ARM64
|
||||
|
||||
#if !LJ_TARGET_OSX
|
||||
/* Alignment of pass-by-value structs: 8 or 16. */
|
||||
static CTInfo ccall_struct_align_arm64(CTState *cts, CType *ct)
|
||||
{
|
||||
CTSize sz;
|
||||
if (ct->sib) {
|
||||
while (ct->sib) {
|
||||
ct = ctype_get(cts, ct->sib);
|
||||
if (ctype_isfield(ct->info)) {
|
||||
if ((ct->info & CTF_ALIGN) > CTALIGN_PTR) return CTALIGN(4);
|
||||
} else if (ctype_isxattrib(ct->info, CTA_SUBTYPE)) {
|
||||
CType *sct = ctype_rawchild(cts, ct);
|
||||
CTInfo info = lj_ctype_info(cts, ctype_typeid(cts, sct), &sz);
|
||||
if ((info & CTF_ALIGN) > CTALIGN_PTR) return CTALIGN(4);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
CTInfo info = lj_ctype_info(cts, ctype_typeid(cts, ct), &sz);
|
||||
if ((info & CTF_ALIGN) > CTALIGN_PTR) return CTALIGN(4);
|
||||
}
|
||||
return CTALIGN_PTR;
|
||||
}
|
||||
#define ccall_struct_align(cts, ct) ccall_struct_align_arm64((cts), (ct))
|
||||
#endif
|
||||
|
||||
/* Classify a struct based on its fields. */
|
||||
static unsigned int ccall_classify_struct(CTState *cts, CType *ct)
|
||||
{
|
||||
@@ -787,10 +817,10 @@ static unsigned int ccall_classify_struct(CTState *cts, CType *ct)
|
||||
ct = ctype_get(cts, ct->sib);
|
||||
if (ctype_isfield(ct->info)) {
|
||||
sct = ctype_rawchild(cts, ct);
|
||||
if (ctype_isarray(sct->info)) {
|
||||
if (ctype_isarray(sct->info) && !sct->size) goto noth;
|
||||
while (ctype_isarray(sct->info)) {
|
||||
CType *cct = ctype_rawchild(cts, sct);
|
||||
if (!cct->size) continue;
|
||||
m = sct->size / cct->size;
|
||||
m *= sct->size / cct->size;
|
||||
sct = cct;
|
||||
}
|
||||
if (ctype_isfp(sct->info)) {
|
||||
@@ -804,7 +834,7 @@ static unsigned int ccall_classify_struct(CTState *cts, CType *ct)
|
||||
} else {
|
||||
goto noth;
|
||||
}
|
||||
} else if (ctype_isbitfield(ct->info)) {
|
||||
} else if (ctype_isbitfield(ct->info) && ctype_bitbsz(ct->info)) {
|
||||
goto noth;
|
||||
} else if (ctype_isxattrib(ct->info, CTA_SUBTYPE)) {
|
||||
sct = ctype_rawchild(cts, ct);
|
||||
@@ -899,6 +929,11 @@ static void ccall_copy_struct(CCallState *cc, CType *ctr, void *dp, void *sp,
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef ccall_struct_align
|
||||
/* Alignment of pass-by-value structs. */
|
||||
#define ccall_struct_align(cts, ct) ((ct)->info & CTF_ALIGN)
|
||||
#endif
|
||||
|
||||
/* -- Common C call handling ---------------------------------------------- */
|
||||
|
||||
/* Infer the destination CTypeID for a vararg argument.
|
||||
@@ -1013,6 +1048,9 @@ static int ccall_set_args(lua_State *L, CTState *cts, CType *ct,
|
||||
CTSize sz;
|
||||
MSize n, isfp = 0, isva = 0;
|
||||
void *dp, *rp = NULL;
|
||||
#if LJ_TARGET_X64 && !LJ_ABI_WIN
|
||||
int onstack = 0;
|
||||
#endif
|
||||
|
||||
if (fid) { /* Get argument type from field. */
|
||||
CType *ctf = ctype_get(cts, fid);
|
||||
@@ -1051,7 +1089,10 @@ static int ccall_set_args(lua_State *L, CTState *cts, CType *ct,
|
||||
|
||||
/* Otherwise pass argument on stack. */
|
||||
if (CCALL_ALIGN_STACKARG) { /* Align argument on stack. */
|
||||
MSize align = (1u << ctype_align(d->info)) - 1;
|
||||
MSize align = (1u << ctype_align(ccall_struct_align(cts, d))) - 1;
|
||||
#if LJ_TARGET_ARM64 && LJ_TARGET_OSX
|
||||
isva = ctype_isstruct(d->info);
|
||||
#endif
|
||||
if (rp || (CCALL_PACK_STACKARG && isva && align < CTSIZE_PTR-1))
|
||||
align = CTSIZE_PTR-1;
|
||||
nsp = (nsp + align) & ~align;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
** FFI C call handling.
|
||||
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
|
||||
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
|
||||
*/
|
||||
|
||||
#ifndef _LJ_CCALL_H
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user