diff -Nru luajit-2.1.20220411/debian/changelog luajit-2.1.20230119/debian/changelog
--- luajit-2.1.20220411/debian/changelog 2022-07-16 23:01:49.000000000 +0000
+++ luajit-2.1.20230119/debian/changelog 2023-01-19 11:00:06.000000000 +0000
@@ -1,7 +1,7 @@
-luajit (2.1.20220411-3myguard2~bionic) bionic; urgency=medium
+luajit (2.1.20230119-3myguard1~bionic) bionic; urgency=medium
* luajit2 from openresty
* See for more http://deb.myguard.nl
- -- Thijs Eilander Sun, 17 Jul 2022 01:01:49 +0200
+ -- Thijs Eilander Thu, 19 Jan 2023 12:00:06 +0100
diff -Nru luajit-2.1.20220411/doc/contact.html luajit-2.1.20230119/doc/contact.html
--- luajit-2.1.20220411/doc/contact.html 2022-04-05 12:12:47.000000000 +0000
+++ luajit-2.1.20230119/doc/contact.html 2023-01-02 04:12:33.000000000 +0000
@@ -50,8 +50,6 @@
FAQ
-Wiki »
-
Mailing List »
@@ -86,6 +84,13 @@
+
+Note: I cannot reply to GMail, Google Workplace, Outlook or Office365
+mail addresses, since they prefer to mindlessly filter out mails sent
+from small domains using independent mail servers, such as mine. If you
+don't like that, please complain to Google or Microsoft, not me.
+
+
Copyright
All documentation is
diff -Nru luajit-2.1.20220411/doc/ext_buffer.html luajit-2.1.20230119/doc/ext_buffer.html
--- luajit-2.1.20220411/doc/ext_buffer.html 2022-04-05 12:12:47.000000000 +0000
+++ luajit-2.1.20230119/doc/ext_buffer.html 2023-01-02 04:12:33.000000000 +0000
@@ -61,8 +61,6 @@
FAQ
-Wiki »
-
Mailing List »
@@ -86,7 +84,7 @@
operations.
-The string buffer libary also includes a high-performance
+The string buffer library also includes a high-performance
serializer for Lua objects.
@@ -434,8 +432,8 @@
obj = buffer.decode(str)
obj = buf:decode()
-The stand-alone function de-serializes (decodes) the string
-str, the buffer method de-serializes one object from the
+The stand-alone function deserializes (decodes) the string
+str, the buffer method deserializes one object from the
buffer. Both return a Lua object obj.
@@ -449,7 +447,7 @@
any left-over data in the buffer.
-Attempting to de-serialize an FFI type will throw an error, if the FFI
+Attempting to deserialize an FFI type will throw an error, if the FFI
library is not built-in or has not been loaded, yet.
@@ -462,7 +460,7 @@
dict is a Lua table holding a dictionary of strings that
commonly occur as table keys of objects you are serializing. These keys
-are compactly encoded as indexes during serialization. A well chosen
+are compactly encoded as indexes during serialization. A well-chosen
dictionary saves space and improves serialization performance.
@@ -473,7 +471,7 @@
dict needs to be an array of strings and metatable needs
to be an array of tables. Both starting at index 1 and without holes (no
-nil inbetween). The tables are anchored in the buffer object and
+nil in between). The tables are anchored in the buffer object and
internally modified into a two-way index (don't do this yourself, just pass
a plain array). The tables must not be modified after they have been passed
to buffer.new().
@@ -624,7 +622,7 @@
There's not much one can do after that, anyway.
-OTOH you may want to catch some errors individually. Buffer methods need
+OTOH, you may want to catch some errors individually. Buffer methods need
to receive the buffer object as the first argument. The Lua colon-syntax
obj:method() does that implicitly. But to wrap a method with
pcall(), the arguments need to be passed like this:
diff -Nru luajit-2.1.20220411/doc/ext_c_api.html luajit-2.1.20230119/doc/ext_c_api.html
--- luajit-2.1.20220411/doc/ext_c_api.html 2022-04-05 12:12:47.000000000 +0000
+++ luajit-2.1.20230119/doc/ext_c_api.html 2023-01-02 04:12:33.000000000 +0000
@@ -50,8 +50,6 @@
FAQ
-Wiki »
-
Mailing List »
@@ -107,7 +105,7 @@
This sets the mode for the function at the stack index idx or
the parent of the calling function (idx = 0). It either
enables JIT compilation for a function, disables it and flushes any
-already compiled code or only flushes already compiled code. This
+already compiled code, or only flushes already compiled code. This
applies recursively to all sub-functions of the function with
LUAJIT_MODE_ALLFUNC or only to the sub-functions with
LUAJIT_MODE_ALLSUBFUNC.
@@ -126,7 +124,7 @@
This mode defines a wrapper function for calls to C functions. If
called with LUAJIT_MODE_ON, the stack index at idx
must be a lightuserdata object holding a pointer to the wrapper
-function. From now on all C functions are called through the wrapper
+function. From now on, all C functions are called through the wrapper
function. If called with LUAJIT_MODE_OFF this mode is turned
off and all C functions are directly called.
diff -Nru luajit-2.1.20220411/doc/extensions.html luajit-2.1.20230119/doc/extensions.html
--- luajit-2.1.20220411/doc/extensions.html 2022-04-05 12:12:47.000000000 +0000
+++ luajit-2.1.20230119/doc/extensions.html 2023-01-02 04:12:33.000000000 +0000
@@ -67,8 +67,6 @@
FAQ
-Wiki »
-
Mailing List »
@@ -88,7 +86,7 @@
LuaJIT extends the standard Lua VM with new functionality and adds
-several extension modules. Please note this page is only about
+several extension modules. Please note, this page is only about
functional enhancements and not about performance enhancements,
such as the optimized VM, the faster interpreter or the JIT compiler.
@@ -197,7 +195,7 @@
The generated bytecode is portable and can be loaded on any architecture
-that LuaJIT supports, independent of word size or endianess. However the
+that LuaJIT supports, independent of word size or endianess. However, the
bytecode compatibility versions must match. Bytecode stays compatible
for dot releases (x.y.0 → x.y.1), but may change with major or
minor releases (2.0 → 2.1) or between any beta release. Foreign
@@ -229,7 +227,7 @@
incremental array/hash part growth.
-Please note this function is meant for very specific situations. In most
+Please note, this function is meant for very specific situations. In most
cases it's better to replace the (usually single) link with a new table
and let the GC do its work.
@@ -239,7 +237,7 @@
LuaJIT uses a Tausworthe PRNG with period 2^223 to implement
math.random() and math.randomseed(). The quality of
the PRNG results is much superior compared to the standard Lua
-implementation which uses the platform-specific ANSI rand().
+implementation, which uses the platform-specific ANSI rand().
The PRNG generates the same sequences from the same seeds on all
@@ -257,7 +255,7 @@
io.* functions handle 64 bit file offsets
The file I/O functions in the standard io.* library handle
-64 bit file offsets. In particular this means it's possible
+64 bit file offsets. In particular, this means it's possible
to open files larger than 2 Gigabytes and to reposition or obtain
the current file position for offsets beyond 2 GB
(fp:seek() method).
diff -Nru luajit-2.1.20220411/doc/ext_ffi_api.html luajit-2.1.20230119/doc/ext_ffi_api.html
--- luajit-2.1.20220411/doc/ext_ffi_api.html 2022-04-05 12:12:47.000000000 +0000
+++ luajit-2.1.20230119/doc/ext_ffi_api.html 2023-01-02 04:12:33.000000000 +0000
@@ -55,8 +55,6 @@
FAQ
-Wiki »
-
Mailing List »
@@ -121,7 +119,7 @@
declaration may be omitted.
-Please note that external symbols are only declared, but they
+Please note, that external symbols are only declared, but they
are not bound to any specific address, yet. Binding is
achieved with C library namespaces (see below).
@@ -209,7 +207,7 @@
ffi.typeof(). Then use the ctype as a constructor repeatedly.
-Please note that an anonymous struct declaration implicitly
+Please note, that an anonymous struct declaration implicitly
creates a new and distinguished ctype every time you use it for
ffi.new(). This is probably not what you want,
especially if you create more than one cdata object. Different anonymous
@@ -256,12 +254,12 @@
contents of an __index table (if any) may be modified
afterwards. The associated metatable automatically applies to all uses
of this type, no matter how the objects are created or where they
-originate from. Note that pre-defined operations on types have
+originate from. Note that predefined operations on types have
precedence (e.g. declared field names cannot be overridden).
All standard Lua metamethods are implemented. These are called directly,
-without shortcuts and on any mix of types. For binary operations, the
+without shortcuts, and on any mix of types. For binary operations, the
left operand is checked first for a valid ctype metamethod. The
__gc metamethod only applies to struct/union
types and performs an implicit ffi.gc()
@@ -492,7 +490,7 @@
Free the resources associated with a callback. The associated Lua
function is unanchored and may be garbage collected. The callback
-function pointer is no longer valid and must not be called anymore
+function pointer is no longer valid and must not be called again
(it may be reused by a subsequently created callback).
diff -Nru luajit-2.1.20220411/doc/ext_ffi.html luajit-2.1.20230119/doc/ext_ffi.html
--- luajit-2.1.20220411/doc/ext_ffi.html 2022-04-05 12:12:47.000000000 +0000
+++ luajit-2.1.20230119/doc/ext_ffi.html 2023-01-02 04:12:33.000000000 +0000
@@ -50,8 +50,6 @@
FAQ
-Wiki »
-
Mailing List »
@@ -157,7 +155,7 @@
Motivating Example: Using C Data Structures
The FFI library allows you to create and access C data
-structures. Of course the main use for this is for interfacing with
+structures. Of course, the main use for this is for interfacing with
C functions. But they can be used stand-alone, too.
@@ -169,7 +167,7 @@
both a substantial memory overhead as well as a performance overhead.
-Here's a sketch of a library that operates on color images plus a
+Here's a sketch of a library that operates on color images, plus a
simple benchmark. First, the plain Lua version:
@@ -184,7 +182,7 @@
return img
end
-local function image_to_grey(img, n)
+local function image_to_gray(img, n)
for i=1,n do
local y = floor(0.3*img[i].red + 0.59*img[i].green + 0.11*img[i].blue)
img[i].red = y; img[i].green = y; img[i].blue = y
@@ -194,14 +192,14 @@
local N = 400*400
local img = image_ramp_green(N)
for i=1,1000 do
- image_to_grey(img, N)
+ image_to_gray(img, N)
end
This creates a table with 160.000 pixels, each of which is a table
-holding four number values in the range of 0-255. First an image with
+holding four number values in the range of 0-255. First, an image with
a green ramp is created (1D for simplicity), then the image is
-converted to greyscale 1000 times. Yes, that's silly, but I was in
+converted to grayscale 1000 times. Yes, that's silly, but I was in
need of a simple example ...
@@ -308,7 +306,7 @@
~1.7x). Switching to a struct-of-arrays would help, too.
-However the resulting code would be less idiomatic and rather
+However, the resulting code would be less idiomatic and rather
error-prone. And it still doesn't get even close to the performance of
the FFI version of the code. Also, high-level data structures cannot
be easily passed to other C functions, especially I/O functions,
diff -Nru luajit-2.1.20220411/doc/ext_ffi_semantics.html luajit-2.1.20230119/doc/ext_ffi_semantics.html
--- luajit-2.1.20220411/doc/ext_ffi_semantics.html 2022-04-05 12:12:47.000000000 +0000
+++ luajit-2.1.20230119/doc/ext_ffi_semantics.html 2023-01-02 04:12:33.000000000 +0000
@@ -55,8 +55,6 @@
FAQ
-Wiki »
-
Mailing List »
@@ -88,7 +86,7 @@
functions to declare C types or external symbols.
-It's only purpose is to parse C declarations, as found e.g. in
+Its only purpose is to parse C declarations, as found e.g. in
C header files. Although it does evaluate constant expressions,
it's not a C compiler. The body of inline
C function definitions is simply ignored.
@@ -165,7 +163,7 @@
-The following C types are pre-defined by the C parser (like
+The following C types are predefined by the C parser (like
a typedef, except re-declarations will be ignored):
@@ -583,9 +581,9 @@
Operations on cdata Objects
-All of the standard Lua operators can be applied to cdata objects or a
+All standard Lua operators can be applied to cdata objects or a
mix of a cdata object and another Lua object. The following list shows
-the pre-defined operations.
+the predefined operations.
Reference types are dereferenced before performing each of
@@ -593,7 +591,7 @@
C type pointed to by the reference.
-The pre-defined operations are always tried first before deferring to a
+The predefined operations are always tried first before deferring to a
metamethod or index table (if any) for the corresponding ctype (except
for __new). An error is raised if the metamethod lookup or
index table lookup fails.
@@ -643,7 +641,7 @@
A ctype object can be indexed with a string key, too. The only
-pre-defined operation is reading scoped constants of
+predefined operation is reading scoped constants of
struct/union types. All other accesses defer
to the corresponding metamethods or index tables (if any).
@@ -656,7 +654,7 @@
As a consequence, the elements of complex numbers and
vectors are immutable. But the elements of an aggregate holding these
-types may be modified of course. I.e. you cannot assign to
+types may be modified, of course. I.e. you cannot assign to
foo.c.im, but you can assign a (newly created) complex number
to foo.c.
@@ -675,8 +673,8 @@
to ffi.new(ct, ...), unless a __new metamethod is
defined. The __new metamethod is called with the ctype object
plus any other arguments passed to the constructor. Note that you have to
-use ffi.new inside of it, since calling ct(...) would
-cause infinite recursion.
+use ffi.new inside the metamethod, since calling ct(...)
+would cause infinite recursion.
C function call: a cdata function or cdata function
pointer can be called. The passed arguments are
@@ -687,7 +685,7 @@
C function is called and the return value (if any) is
converted to a Lua object.
On Windows/x86 systems, __stdcall functions are automatically
-detected and a function declared as __cdecl (the default) is
+detected, and a function declared as __cdecl (the default) is
silently fixed up after the first call.
@@ -697,7 +695,7 @@
Pointer arithmetic: a cdata pointer/array and a cdata
number or a Lua number can be added or subtracted. The number must be
-on the right hand side for a subtraction. The result is a pointer of
+on the right-hand side for a subtraction. The result is a pointer of
the same type with an address plus or minus the number value
multiplied by the element size in bytes. An error is raised if the
element size is undefined.
@@ -712,7 +710,7 @@
minus) can be applied to two cdata numbers, or a cdata number and a
Lua number. If one of them is an uint64_t, the other side is
converted to an uint64_t and an unsigned arithmetic operation
-is performed. Otherwise both sides are converted to an
+is performed. Otherwise, both sides are converted to an
int64_t and a signed arithmetic operation is performed. The
result is a boxed 64 bit cdata object.
@@ -759,7 +757,7 @@
64 bit integer comparison: two cdata numbers, or a
cdata number and a Lua number can be compared with each other. If one
of them is an uint64_t, the other side is converted to an
-uint64_t and an unsigned comparison is performed. Otherwise
+uint64_t and an unsigned comparison is performed. Otherwise,
both sides are converted to an int64_t and a signed
comparison is performed.
@@ -784,9 +782,9 @@
A cdata object is treated like any other garbage-collected object and
is hashed and compared by its address for table indexing. Since
there's no interning for cdata value types, the same value may be
-boxed in different cdata objects with different addresses. Thus
+boxed in different cdata objects with different addresses. Thus,
t[1LL+1LL] and t[2LL] usually do not point to
-the same hash slot and they certainly do not point to the same
+the same hash slot, and they certainly do not point to the same
hash slot as t[2].
@@ -808,7 +806,7 @@
One obvious benefit: t[tonumber(2LL)] does point to
the same slot as t[2].
-Otherwise use either tostring() on 64 bit integers
+Otherwise, use either tostring() on 64 bit integers
or complex numbers or combine multiple fields of a cdata aggregate to
a Lua string (e.g. with
ffi.string()). Then
@@ -816,7 +814,7 @@
Create your own specialized hash table implementation using the
C types provided by the FFI library, just like you would in
-C code. Ultimately this may give much better performance than the
+C code. Ultimately, this may give much better performance than the
other alternatives or what a generic by-value hash table could
possibly provide.
@@ -882,7 +880,7 @@
the end of the next GC cycle).
-Please note that pointers themselves are cdata objects, however they
+Please note, that pointers themselves are cdata objects, however they
are not followed by the garbage collector. So e.g. if you
assign a cdata array to a pointer, you must keep the cdata object
holding the array alive as long as the pointer is still in use:
@@ -931,18 +929,18 @@
This can happen implicitly due to the usual conversions, e.g. when
-passing a Lua function to a function pointer argument. Or you can use
+passing a Lua function to a function pointer argument. Or, you can use
ffi.cast() to explicitly cast a Lua function to a
C function pointer.
-Currently only certain C function types can be used as callback
+Currently, only certain C function types can be used as callback
functions. Neither C vararg functions nor functions with
pass-by-value aggregate argument or result types are supported. There
-are no restrictions for the kind of Lua functions that can be called
+are no restrictions on the kind of Lua functions that can be called
from the callback — no checks for the proper number of arguments
are made. The return value of the Lua function will be converted to the
-result type and an error will be thrown for invalid conversions.
+result type, and an error will be thrown for invalid conversions.
It's allowed to throw errors across a callback invocation, but it's not
@@ -1003,7 +1001,7 @@
__stdcall calls to Windows functions.
-For some use cases it's necessary to free up the resources or to
+For some use cases, it's necessary to free up the resources or to
dynamically redirect callbacks. Use an explicit cast to a
C function pointer and keep the resulting cdata object. Then use
the cb:free()
@@ -1056,7 +1054,7 @@
For new designs avoid push-style APIs: a C function repeatedly
-calling a callback for each result. Instead use pull-style APIs:
+calling a callback for each result. Instead, use pull-style APIs:
call a C function repeatedly to get a new result. Calls from Lua
to C via the FFI are much faster than the other way round. Most well-designed
libraries already use pull-style APIs (read/write, get/put).
@@ -1075,7 +1073,7 @@
Indexing a C library namespace object with a symbol name (a Lua
-string) automatically binds it to the library. First the symbol type
+string) automatically binds it to the library. First, the symbol type
is resolved — it must have been declared with
ffi.cdef. Then the
symbol address is resolved by searching for the symbol name in the
@@ -1130,7 +1128,7 @@
namespace objects and to the strings used to index it. This
effectively turns function cdata objects into constants. It's not
useful and actually counter-productive to explicitly cache these
-function objects, e.g. local strlen = ffi.C.strlen. OTOH it
+function objects, e.g. local strlen = ffi.C.strlen. OTOH, it
is useful to cache the namespace itself, e.g. local C =
ffi.C.
@@ -1155,14 +1153,14 @@
interoperability with C code. Adding extra safety measures, like
bounds checks, would be futile. There's no way to detect
misdeclarations of C functions, since shared libraries only
-provide symbol names, but no type information. Likewise there's no way
+provide symbol names, but no type information. Likewise, there's no way
to infer the valid range of indexes for a returned pointer.
Again: the FFI library is a low-level library. This implies it needs
to be used with care, but it's flexibility and performance often
outweigh this concern. If you're a C or C++ developer, it'll be easy
-to apply your existing knowledge. OTOH writing code for the FFI
+to apply your existing knowledge. OTOH, writing code for the FFI
library is not for the faint of heart and probably shouldn't be the
first exercise for someone with little experience in Lua, C or C++.
@@ -1190,7 +1188,7 @@
C declarations are not passed through a C pre-processor,
yet.
The C parser is able to evaluate most constant expressions
-commonly found in C header files. However it doesn't handle the
+commonly found in C header files. However, it doesn't handle the
full range of C expression semantics and may fail for some
obscure constructs.
static const declarations only work for integer types
diff -Nru luajit-2.1.20220411/doc/ext_ffi_tutorial.html luajit-2.1.20230119/doc/ext_ffi_tutorial.html
--- luajit-2.1.20220411/doc/ext_ffi_tutorial.html 2022-04-05 12:12:47.000000000 +0000
+++ luajit-2.1.20230119/doc/ext_ffi_tutorial.html 2023-01-02 04:12:33.000000000 +0000
@@ -57,8 +57,6 @@
FAQ
-Wiki »
-
Mailing List »
@@ -85,7 +83,7 @@
local ffi = require("ffi")
-Please note this doesn't define an ffi variable in the table
+Please note, this doesn't define an ffi variable in the table
of globals — you really need to use the local variable. The
require function ensures the library is only loaded once.
@@ -194,7 +192,7 @@
⑤ The poll()
function takes a couple more arguments we're not going to use. You can
simply use nil to pass a NULL pointer and 0
-for the nfds parameter. Please note that the
+for the nfds parameter. Please note, that the
number 0 does not convert to a pointer value,
unlike in C++. You really have to pass pointers to pointer arguments
and numbers to number arguments.
@@ -291,12 +289,12 @@
① This defines some of the
C functions provided by zlib. For the sake of this example, some
-type indirections have been reduced and it uses the pre-defined
+type indirections have been reduced and it uses the predefined
fixed-size integer types, while still adhering to the zlib API/ABI.
② This loads the zlib shared
-library. On POSIX systems it's named libz.so and usually
+library. On POSIX systems, it's named libz.so and usually
comes pre-installed. Since ffi.load() automatically adds any
missing standard prefixes/suffixes, we can simply load the
"z" library. On Windows it's named zlib1.dll and
@@ -324,7 +322,7 @@
In C you'd pass in the address of a local variable
(&buflen). But since there's no address-of operator in
-Lua, we'll just pass in a one-element array. Conveniently it can be
+Lua, we'll just pass in a one-element array. Conveniently, it can be
initialized with the maximum buffer size in one step. Calling the
actual zlib.compress2 function is then straightforward.
@@ -348,7 +346,7 @@
⑥ The uncompress
functions does the exact opposite of the compress function.
The compressed data doesn't include the size of the original string,
-so this needs to be passed in. Otherwise no surprises here.
+so this needs to be passed in. Otherwise, no surprises here.
⑦ The code, that makes use
@@ -382,7 +380,7 @@
wherever you'd want to use a number. That's why we get a away with
passing n to ffi.string() above. But other Lua
library functions or modules don't know how to deal with this. So for
-maximum portability one needs to use tonumber() on returned
+maximum portability, one needs to use tonumber() on returned
long results before passing them on. Otherwise the
application might work on some systems, but would fail in a POSIX/x64
environment.
@@ -454,7 +452,7 @@
④ If we run out of operators, we can
-define named methods, too. Here the __index table defines an
+define named methods, too. Here, the __index table defines an
area function. For custom indexing needs, one might want to
define __index and __newindex functions instead.
@@ -468,13 +466,13 @@
apply to any and all uses of this type.
-Please note that the association with a metatable is permanent and
+Please note, that the association with a metatable is permanent and
the metatable must not be modified afterwards! Ditto for the
__index table.
⑥ Here are some simple usage examples
-for the point type and their expected results. The pre-defined
+for the point type and their expected results. The predefined
operations (such as a.x) can be freely mixed with the newly
defined metamethods. Note that area is a method and must be
called with the Lua syntax for methods: a:area(), not
@@ -483,7 +481,7 @@
The C type metamethod mechanism is most useful when used in
conjunction with C libraries that are written in an object-oriented
-style. Creators return a pointer to a new instance and methods take an
+style. Creators return a pointer to a new instance, and methods take an
instance pointer as the first argument. Sometimes you can just point
__index to the library namespace and __gc to the
destructor and you're done. But often enough you'll want to add
@@ -569,7 +567,7 @@
This turns them into indirect calls and generates bigger and slower
-machine code. Instead you'll want to cache the namespace itself and
+machine code. Instead, you'll want to cache the namespace itself and
rely on the JIT compiler to eliminate the lookups:
diff -Nru luajit-2.1.20220411/doc/ext_jit.html luajit-2.1.20230119/doc/ext_jit.html
--- luajit-2.1.20220411/doc/ext_jit.html 2022-04-05 12:12:47.000000000 +0000
+++ luajit-2.1.20230119/doc/ext_jit.html 2023-01-02 04:12:33.000000000 +0000
@@ -50,8 +50,6 @@
FAQ
-Wiki »
-
Mailing List »
@@ -154,7 +152,7 @@
jit.opt.* — JIT compiler optimization control
-This sub-module provides the backend for the -O command line
+This submodule provides the backend for the -O command line
option.
@@ -174,7 +172,7 @@
jit.util.* — JIT compiler introspection
-This sub-module holds functions to introspect the bytecode, generated
+This submodule holds functions to introspect the bytecode, generated
traces, the IR and the generated machine code. The functionality
provided by this module is still in flux and therefore undocumented.
diff -Nru luajit-2.1.20220411/doc/ext_profiler.html luajit-2.1.20230119/doc/ext_profiler.html
--- luajit-2.1.20220411/doc/ext_profiler.html 2022-04-05 12:12:47.000000000 +0000
+++ luajit-2.1.20230119/doc/ext_profiler.html 2023-01-02 04:12:33.000000000 +0000
@@ -50,8 +50,6 @@
FAQ
-Wiki »
-
Mailing List »
@@ -158,7 +156,7 @@
Combinations of v/z with f/F/l produce two-level
views, e.g. -jp=vf or -jp=fv. This shows the time
spent in a VM state or zone vs. hotspots. This can be used to answer
-questions like "Which time consuming functions are only interpreted?" or
+questions like "Which time-consuming functions are only interpreted?" or
"What's the garbage collector overhead for a specific function?".
@@ -217,7 +215,7 @@
This module can be used to implement your own higher-level profiler.
A typical profiling run starts the profiler, captures stack dumps in
the profiler callback, adds them to a hash table to aggregate the number
-of samples, stops the profiler and then analyzes all of the captured
+of samples, stops the profiler and then analyzes all captured
stack dumps. Other parameters can be sampled in the profiler callback,
too. But it's important not to spend too much time in the callback,
since this may skew the statistics.
@@ -271,9 +269,9 @@
formatted according to the fmt argument:
-- p — Preserve the full path for module names. Otherwise
+
- p — Preserve the full path for module names. Otherwise,
only the file name is used.
-- f — Dump the function name if it can be derived. Otherwise
+
- f — Dump the function name if it can be derived. Otherwise,
use module:line.
- F — Ditto, but dump module:name.
- l — Dump module:line.
diff -Nru luajit-2.1.20220411/doc/faq.html luajit-2.1.20230119/doc/faq.html
--- luajit-2.1.20220411/doc/faq.html 2022-04-05 12:12:47.000000000 +0000
+++ luajit-2.1.20230119/doc/faq.html 2023-01-02 04:12:33.000000000 +0000
@@ -53,8 +53,6 @@
-
FAQ
-
-Wiki »
-
-
Mailing List »
@@ -65,8 +63,6 @@
- The » LuaJIT mailing list focuses on topics
related to LuaJIT.
-- The » LuaJIT wiki gathers community
-resources about LuaJIT.
- News about Lua itself can be found at the
» Lua mailing list.
The mailing list archives are worth checking out for older postings
@@ -120,7 +116,7 @@
Consider testing your application with older versions, too.
Similarly, the Borland/Delphi runtime modifies the FPU control word and
-enables FP exceptions. Of course this violates the Windows ABI, too.
+enables FP exceptions. Of course, this violates the Windows ABI, too.
Please check the Delphi docs for the Set8087CW method.
@@ -130,7 +126,7 @@
ignored by compiled code. If your program is running in a tight loop
and never falls back to the interpreter, the debug hook never runs and
can't throw the "interrupted!" error.
-You have to press Ctrl-C twice to get stop your program. That's similar
+You have to press Ctrl-C twice to stop your program. That's similar
to when it's stuck running inside a C function under the Lua interpreter.
@@ -150,7 +146,7 @@
- Q: Can Lua code be safely sandboxed?
-
-Maybe for an extremly restricted subset of Lua and if you relentlessly
+Maybe for an extremely restricted subset of Lua and if you relentlessly
scrutinize every single interface function you offer to the untrusted code.
Although Lua provides some sandboxing functionality (setfenv(), hooks),
diff -Nru luajit-2.1.20220411/doc/install.html luajit-2.1.20230119/doc/install.html
--- luajit-2.1.20220411/doc/install.html 2022-04-05 12:12:47.000000000 +0000
+++ luajit-2.1.20230119/doc/install.html 2023-01-02 04:12:33.000000000 +0000
@@ -14,25 +14,20 @@
}
table.compat td {
border: 1px solid #bfcfff;
- height: 2.5em;
+ height: 1.5em;
}
table.compat tr.compathead td {
font-weight: bold;
border-bottom: 2px solid #bfcfff;
}
-tr.compathead td.compatos {
- vertical-align: top;
+td.compatname, td.compatver {
+ width: 10%;
}
-table.compat td.compatcpu {
- width: 18%;
- border-right: 2px solid #bfcfff;
+td.compatbits {
+ width: 5%;
}
-td.compatos {
+td.compatx {
width: 21%;
- vertical-align: middle;
-}
-td.compatno {
- background-color: #d0d0d0;
}
@@ -78,8 +73,6 @@
-
FAQ
-
-Wiki »
-
-
Mailing List »
@@ -95,62 +88,204 @@
make && sudo make install
+
+Requirements
+Systems
-LuaJIT currently builds out-of-the box on most systems.
-Here's the compatibility matrix for the supported combinations of
-operating systems, CPUs and compilers:
+LuaJIT currently builds out-of-the box on most systems:
+
+The codebase has compatibility defines for some more systems, but
+without official support.
+
+
+
+Building LuaJIT requires a recent toolchain based on GCC, Clang/LLVM or
+MSVC++.
+
+
+The Makefile-based build system requires GNU Make and supports
+cross-builds. Batch files are provided for MSVC++ builds and console
+cross-builds.
+
+CPU Architectures
+
+
+CPU |
+Bits |
+Requirements |
+Variants |
+LuaJIT Versions |
+
+
+x86 |
+32 |
+v2.1+: SSE2 |
+ |
+v2.0 – |
+
+
+x64 |
+64 |
+ |
+ |
+v2.0 – |
+
+
+ARM |
+32 |
+ARMv5+, ARM9E+ |
+hard-fp + soft-fp |
+v2.0 – |
+
+
+ARM64 |
+64 |
+ |
+ARM64le + ARM64be |
+v2.1 – |
+
+
+PPC32 |
+32 |
+ |
+hard-fp + soft-fp |
+v2.0 – v2.1 EOL |
+
+
+PPC/e500 |
+32 |
+e500v2 |
+ |
+v2.0 EOL |
+
+
+MIPS32 |
+32 |
+MIPS32r1 – r5 |
+hard-fp + soft-fp |
+v2.0 – |
+
+
+MIPS64 |
+64 |
+MIPS64r1 – r5 |
+hard-fp + soft-fp |
+v2.1 – |
+
+
+MIPS64 |
+64 |
+MIPS64r6 |
+hard-fp + soft-fp |
+v2.1 EOL |
+
+
+RISC-V |
+64 |
+RVA22+ |
+ |
+TBA |
+
+
+
+There are no plans to add historic architectures or to continue support
+for end-of-life (EOL) architectures, for which no new CPUs are commonly
+available anymore. Likewise, there are no plans to support marginal
+and/or de-facto-dead architectures.
+
Configuring LuaJIT
@@ -191,7 +326,7 @@
the git repository.
-Alternatively download the latest source package of LuaJIT (pick the .tar.gz).
+Alternatively, download the latest source package of LuaJIT (pick the .tar.gz).
Move it to a directory of your choice, open a terminal window and change
to this directory. Now unpack the archive and change to the newly created
directory (replace XX.YY.ZZ with the version you downloaded):
@@ -446,8 +581,7 @@
Cross-compiling for consoles
Building LuaJIT for consoles requires both a supported host compiler
-(x86 or x64) and a cross-compiler (to PPC or ARM) from the official
-console SDK.
+(x86 or x64) and a cross-compiler from the official console SDK.
Due to restrictions on consoles, the JIT compiler is disabled and only
@@ -468,45 +602,58 @@
make HOST_CC="gcc -m32" CROSS=ppu-lv2-
-To cross-compile for PS4 from a Windows host,
-open a "Visual Studio .NET Command Prompt" (64 bit host compiler),
-cd to the directory where you've unpacked the sources and
-run the following commands:
+To cross-compile for the other consoles from a Windows host, open a
+"Native Tools Command Prompt for VS". You need to choose either the 32
+or the 64 bit version of the host compiler to match the target.
+Then cd to the src directory below where you've
+unpacked the sources and run the build command given in the table:
-
-cd src
-ps4build
-
-
-To cross-compile for PS Vita from a Windows host,
-open a "Visual Studio .NET Command Prompt" (32 bit host compiler),
-cd to the directory where you've unpacked the sources and
-run the following commands:
-
-
-cd src
-psvitabuild
-
-
-To cross-compile for Xbox 360 from a Windows host,
-open a "Visual Studio .NET Command Prompt" (32 bit host compiler),
-cd to the directory where you've unpacked the sources and run
-the following commands:
-
-
-cd src
-xedkbuild
-
+
+
+Console |
+Bits |
+Build Command |
+
+
+PS4 |
+64 |
+ps4build |
+
+
+PS5 |
+64 |
+ps5build |
+
+
+PS Vita |
+32 |
+psvitabuild |
+
+
+Xbox 360 |
+32 |
+xedkbuild |
+
+
+Xbox One |
+64 |
+xb1build |
+
+
+Nintendo Switch NX32 |
+32 |
+nxbuild |
+
+
+Nintendo Switch NX64 |
+64 |
+nxbuild |
+
+
-To cross-compile for Xbox One from a Windows host,
-open a "Visual Studio .NET Command Prompt" (64 bit host compiler),
-cd to the directory where you've unpacked the sources and run
-the following commands:
+Please check out the comments in the corresponding *.bat
+file for more options.
-
-cd src
-xb1build
-
Embedding LuaJIT
@@ -548,7 +695,7 @@
of calling luaopen_base etc. directly.
To change or extend the list of standard libraries to load, copy
src/lib_init.c to your project and modify it accordingly.
-Make sure the jit library is loaded or the JIT compiler
+Make sure the jit library is loaded, or the JIT compiler
will not be activated.
The bit.* module for bitwise operations
is already built-in. There's no need to statically link
@@ -567,7 +714,7 @@
There should be absolutely no need to patch luaconf.h or any
of the Makefiles. And please do not hand-pick files for your packages —
simply use whatever make install creates. There's a reason
-for all of the files and directories it creates.
+for all the files and directories it creates.
The build system uses GNU make and auto-detects most settings based on
diff -Nru luajit-2.1.20220411/doc/luajit.html luajit-2.1.20230119/doc/luajit.html
--- luajit-2.1.20220411/doc/luajit.html 2022-04-05 12:12:47.000000000 +0000
+++ luajit-2.1.20230119/doc/luajit.html 2023-01-02 04:12:33.000000000 +0000
@@ -135,8 +135,6 @@
FAQ
-Wiki »
-
Mailing List »
@@ -162,7 +160,7 @@
Embedded | Android | iOS |
-PS3 | PS4 | PS Vita | Xbox 360 | Xbox One |
+PS3 | PS4 PS5 | PS Vita | Xbox 360 | Xbox One | Nintendo Switch |
GCC | Clang LLVM | MSVC |
diff -Nru luajit-2.1.20220411/doc/running.html luajit-2.1.20230119/doc/running.html
--- luajit-2.1.20220411/doc/running.html 2022-04-05 12:12:47.000000000 +0000
+++ luajit-2.1.20230119/doc/running.html 2023-01-02 04:12:33.000000000 +0000
@@ -72,8 +72,6 @@
FAQ
-Wiki »
-
Mailing List »
@@ -111,6 +109,7 @@
-t type — Set output file type (default: auto-detect from output name).
-a arch — Override architecture for object files (default: native).
-o os — Override OS for object files (default: native).
+-F name — Override filename (default: input filename).
-e chunk — Use chunk string as input.
- (a single minus sign) — Use stdin as input and/or stdout as output.
@@ -184,7 +183,7 @@
itself. For a description of their options and output format, please
read the comment block at the start of their source.
They can be found in the lib directory of the source
-distribution or installed under the jit directory. By default
+distribution or installed under the jit directory. By default,
this is /usr/local/share/luajit-XX.YY.ZZ>/jit on POSIX
systems (replace XX.YY.ZZ by the installed version).
@@ -216,11 +215,17 @@
You can either use this option multiple times (like -Ocse
-O-dce -Ohotloop=10) or separate several settings with a comma
(like -O+cse,-dce,hotloop=10). The settings are applied from
-left to right and later settings override earlier ones. You can freely
+left to right, and later settings override earlier ones. You can freely
mix the three forms, but note that setting an optimization level
overrides all earlier flags.
+Note that -Ofma is not enabled by default at any level,
+because it affects floating-point result accuracy. Only enable this,
+if you fully understand the trade-offs of FMA for performance (higher),
+determinism (lower) and numerical accuracy (higher).
+
+
Here are the available flags and at what optimization levels they
are enabled:
@@ -252,6 +257,8 @@
sink | | | • | Allocation/Store Sinking |
fuse | | | • | Fusion of operands into instructions |
+
+fma | | | | Fused multiply-add |
Here are the parameters and their default settings:
diff -Nru luajit-2.1.20220411/doc/status.html luajit-2.1.20230119/doc/status.html
--- luajit-2.1.20220411/doc/status.html 2022-04-05 12:12:47.000000000 +0000
+++ luajit-2.1.20230119/doc/status.html 2023-01-02 04:12:33.000000000 +0000
@@ -53,8 +53,6 @@
FAQ
-Wiki »
-
Mailing List »
@@ -83,7 +81,7 @@
-
There are some differences in implementation-defined behavior.
-These either have a good reason, are arbitrary design choices
+These either have a good reason, are arbitrary design choices,
or are due to quirks in the VM. The latter cases may get fixed if a
demonstrable need is shown.
diff -Nru luajit-2.1.20220411/dynasm/dasm_arm64.h luajit-2.1.20230119/dynasm/dasm_arm64.h
--- luajit-2.1.20220411/dynasm/dasm_arm64.h 2022-04-05 12:12:47.000000000 +0000
+++ luajit-2.1.20230119/dynasm/dasm_arm64.h 2023-01-02 04:12:33.000000000 +0000
@@ -158,10 +158,10 @@
#ifdef DASM_CHECKS
#define CK(x, st) \
do { if (!(x)) { \
- D->status = DASM_S_##st|(p-D->actionlist-1); return; } } while (0)
+ D->status = DASM_S_##st|(int)(p-D->actionlist-1); return; } } while (0)
#define CKPL(kind, st) \
do { if ((size_t)((char *)pl-(char *)D->kind##labels) >= D->kind##size) { \
- D->status = DASM_S_RANGE_##st|(p-D->actionlist-1); return; } } while (0)
+ D->status = DASM_S_RANGE_##st|(int)(p-D->actionlist-1); return; } } while (0)
#else
#define CK(x, st) ((void)0)
#define CKPL(kind, st) ((void)0)
@@ -190,7 +190,9 @@
unsigned long long n = (((unsigned long long)hi) << 32) | (unsigned int)lo;
unsigned long long m = 1ULL, a, b, c;
if (n & 1) { n = ~n; inv = 1; }
- a = n & -n; b = (n+a)&-(n+a); c = (n+a-b)&-(n+a-b);
+ a = n & (unsigned long long)-(long long)n;
+ b = (n+a)&(unsigned long long)-(long long)(n+a);
+ c = (n+a-b)&(unsigned long long)-(long long)(n+a-b);
xa = dasm_ffs(a); xb = dasm_ffs(b);
if (c) {
w = dasm_ffs(c) - xa;
@@ -406,7 +408,7 @@
#ifdef DASM_CHECKS
#define CK(x, st) \
- do { if (!(x)) return DASM_S_##st|(p-D->actionlist-1); } while (0)
+ do { if (!(x)) return DASM_S_##st|(int)(p-D->actionlist-1); } while (0)
#else
#define CK(x, st) ((void)0)
#endif
@@ -554,7 +556,7 @@
}
if (D->status == DASM_S_OK && secmatch >= 0 &&
D->section != &D->sections[secmatch])
- D->status = DASM_S_MATCH_SEC|(D->section-D->sections);
+ D->status = DASM_S_MATCH_SEC|(int)(D->section-D->sections);
return D->status;
}
#endif
diff -Nru luajit-2.1.20220411/dynasm/dasm_arm64.lua luajit-2.1.20230119/dynasm/dasm_arm64.lua
--- luajit-2.1.20220411/dynasm/dasm_arm64.lua 2022-04-05 12:12:47.000000000 +0000
+++ luajit-2.1.20230119/dynasm/dasm_arm64.lua 2023-01-02 04:12:33.000000000 +0000
@@ -248,7 +248,7 @@
local parse_reg_type
-local function parse_reg(expr, shift)
+local function parse_reg(expr, shift, no_vreg)
if not expr then werror("expected register name") end
local tname, ovreg = match(expr, "^([%w_]+):(@?%l%d+)$")
if not tname then
@@ -281,7 +281,7 @@
elseif parse_reg_type ~= vrt then
werror("register size mismatch")
end
- if shift then waction("VREG", shift, vreg) end
+ if not no_vreg then waction("VREG", shift, vreg) end
return 0
end
werror("bad register name `"..expr.."'")
@@ -638,7 +638,7 @@
end
local function alias_bfiz(p)
- parse_reg(p[1], 0)
+ parse_reg(p[1], 0, true)
if parse_reg_type == "w" then
p[3] = "#(32-("..p[3]:sub(2).."))%32"
p[4] = "#("..p[4]:sub(2)..")-1"
@@ -649,7 +649,7 @@
end
local alias_lslimm = op_alias("ubfm_4", function(p)
- parse_reg(p[1], 0)
+ parse_reg(p[1], 0, true)
local sh = p[3]:sub(2)
if parse_reg_type == "w" then
p[3] = "#(32-("..sh.."))%32"
diff -Nru luajit-2.1.20220411/dynasm/dasm_mips.h luajit-2.1.20230119/dynasm/dasm_mips.h
--- luajit-2.1.20220411/dynasm/dasm_mips.h 2022-04-05 12:12:47.000000000 +0000
+++ luajit-2.1.20230119/dynasm/dasm_mips.h 2023-01-02 04:12:33.000000000 +0000
@@ -155,10 +155,10 @@
#ifdef DASM_CHECKS
#define CK(x, st) \
do { if (!(x)) { \
- D->status = DASM_S_##st|(p-D->actionlist-1); return; } } while (0)
+ D->status = DASM_S_##st|(int)(p-D->actionlist-1); return; } } while (0)
#define CKPL(kind, st) \
do { if ((size_t)((char *)pl-(char *)D->kind##labels) >= D->kind##size) { \
- D->status = DASM_S_RANGE_##st|(p-D->actionlist-1); return; } } while (0)
+ D->status = DASM_S_RANGE_##st|(int)(p-D->actionlist-1); return; } } while (0)
#else
#define CK(x, st) ((void)0)
#define CKPL(kind, st) ((void)0)
@@ -314,7 +314,7 @@
#ifdef DASM_CHECKS
#define CK(x, st) \
- do { if (!(x)) return DASM_S_##st|(p-D->actionlist-1); } while (0)
+ do { if (!(x)) return DASM_S_##st|(int)(p-D->actionlist-1); } while (0)
#else
#define CK(x, st) ((void)0)
#endif
@@ -417,7 +417,7 @@
}
if (D->status == DASM_S_OK && secmatch >= 0 &&
D->section != &D->sections[secmatch])
- D->status = DASM_S_MATCH_SEC|(D->section-D->sections);
+ D->status = DASM_S_MATCH_SEC|(int)(D->section-D->sections);
return D->status;
}
#endif
diff -Nru luajit-2.1.20220411/dynasm/dasm_s390x.lua luajit-2.1.20230119/dynasm/dasm_s390x.lua
--- luajit-2.1.20220411/dynasm/dasm_s390x.lua 2022-04-05 12:12:47.000000000 +0000
+++ luajit-2.1.20230119/dynasm/dasm_s390x.lua 2023-01-02 04:12:33.000000000 +0000
@@ -823,6 +823,7 @@
esxtr_2 = "0000b3ef0000RRE",
ex_2 = "000044000000RX-a",
exrl_2 = "c60000000000RIL-b",
+ fidbra_4 = "0000b35f0000RRF-e",
fidr_2 = "0000b37f0000RRE",
fier_2 = "0000b3770000RRE",
fixr_2 = "0000b3670000RRE",
diff -Nru luajit-2.1.20220411/Makefile luajit-2.1.20230119/Makefile
--- luajit-2.1.20220411/Makefile 2022-04-05 12:12:47.000000000 +0000
+++ luajit-2.1.20230119/Makefile 2023-01-02 04:12:33.000000000 +0000
@@ -33,7 +33,8 @@
INSTALL_BIN= $(DPREFIX)/bin
INSTALL_LIB= $(DPREFIX)/$(MULTILIB)
INSTALL_SHARE= $(DPREFIX)/share
-INSTALL_INC= $(DPREFIX)/include/luajit-$(MAJVER).$(MINVER)
+INSTALL_DEFINC= $(DPREFIX)/include/luajit-$(MAJVER).$(MINVER)
+INSTALL_INC= $(INSTALL_DEFINC)
INSTALL_LJLIBD= $(INSTALL_SHARE)/luajit-$(VERSION)
INSTALL_JITLIB= $(INSTALL_LJLIBD)/jit
@@ -78,6 +79,9 @@
LDCONFIG= ldconfig -n 2>/dev/null
SED_PC= sed -e "s|^prefix=.*|prefix=$(PREFIX)|" \
-e "s|^multilib=.*|multilib=$(MULTILIB)|"
+ifneq ($(INSTALL_DEFINC),$(INSTALL_INC))
+ SED_PC+= -e "s|^includedir=.*|includedir=$(INSTALL_INC)|"
+endif
FILE_T= luajit
FILE_A= libluajit.a
diff -Nru luajit-2.1.20220411/src/host/buildvm.c luajit-2.1.20230119/src/host/buildvm.c
--- luajit-2.1.20220411/src/host/buildvm.c 2022-04-05 12:12:47.000000000 +0000
+++ luajit-2.1.20230119/src/host/buildvm.c 2023-01-02 04:12:33.000000000 +0000
@@ -18,8 +18,10 @@
#include "lj_obj.h"
#include "lj_gc.h"
#include "lj_bc.h"
+#if LJ_HASJIT
#include "lj_ir.h"
#include "lj_ircall.h"
+#endif
#include "lj_frame.h"
#include "lj_dispatch.h"
#if LJ_HASFFI
@@ -252,6 +254,7 @@
NULL
};
+#if LJ_HASJIT
const char *const ir_names[] = {
#define IRNAME(name, m, m1, m2) #name,
IRDEF(IRNAME)
@@ -292,7 +295,9 @@
#include "lj_traceerr.h"
NULL
};
+#endif
+#if LJ_HASJIT
static const char *lower(char *buf, const char *s)
{
char *p = buf;
@@ -303,6 +308,7 @@
*p = '\0';
return buf;
}
+#endif
/* Emit C source code for bytecode-related definitions. */
static void emit_bcdef(BuildCtx *ctx)
@@ -320,7 +326,9 @@
/* Emit VM definitions as Lua code for debug modules. */
static void emit_vmdef(BuildCtx *ctx)
{
+#if LJ_HASJIT
char buf[80];
+#endif
int i;
fprintf(ctx->fp, "-- This is a generated file. DO NOT EDIT!\n\n");
fprintf(ctx->fp, "return {\n\n");
@@ -329,6 +337,7 @@
for (i = 0; bc_names[i]; i++) fprintf(ctx->fp, "%-6s", bc_names[i]);
fprintf(ctx->fp, "\",\n\n");
+#if LJ_HASJIT
fprintf(ctx->fp, "irnames = \"");
for (i = 0; ir_names[i]; i++) fprintf(ctx->fp, "%-6s", ir_names[i]);
fprintf(ctx->fp, "\",\n\n");
@@ -357,6 +366,7 @@
for (i = 0; trace_errors[i]; i++)
fprintf(ctx->fp, "\"%s\",\n", trace_errors[i]);
fprintf(ctx->fp, "},\n\n");
+#endif
}
/* -- Argument parsing ---------------------------------------------------- */
diff -Nru luajit-2.1.20220411/src/host/buildvm_fold.c luajit-2.1.20230119/src/host/buildvm_fold.c
--- luajit-2.1.20220411/src/host/buildvm_fold.c 2022-04-05 12:12:47.000000000 +0000
+++ luajit-2.1.20230119/src/host/buildvm_fold.c 2023-01-02 04:12:33.000000000 +0000
@@ -5,6 +5,7 @@
#include "buildvm.h"
#include "lj_obj.h"
+#if LJ_HASJIT
#include "lj_ir.h"
/* Context for the folding hash table generator. */
@@ -226,4 +227,10 @@
makehash(ctx);
}
+#else
+void emit_fold(BuildCtx *ctx)
+{
+ UNUSED(ctx);
+}
+#endif
diff -Nru luajit-2.1.20220411/src/host/buildvm_libbc.h luajit-2.1.20230119/src/host/buildvm_libbc.h
--- luajit-2.1.20220411/src/host/buildvm_libbc.h 2022-04-05 12:12:47.000000000 +0000
+++ luajit-2.1.20230119/src/host/buildvm_libbc.h 2023-01-02 04:12:33.000000000 +0000
@@ -4,42 +4,67 @@
static const uint8_t libbc_code[] = {
#if LJ_FR2
-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,
-16,0,5,0,21,1,0,0,76,1,2,0,0,2,10,0,0,0,15,16,0,12,0,16,1,9,0,41,2,1,0,21,3,
-0,0,41,4,1,0,77,2,8,128,18,6,1,0,18,8,5,0,59,9,5,0,66,6,3,2,10,6,0,0,88,7,1,
-128,76,6,2,0,79,2,248,127,75,0,1,0,0,2,11,0,0,0,16,16,0,12,0,16,1,9,0,43,2,
-0,0,18,3,0,0,41,4,0,0,88,5,7,128,18,7,1,0,18,9,5,0,18,10,6,0,66,7,3,2,10,7,
-0,0,88,8,1,128,76,7,2,0,70,5,3,3,82,5,247,127,75,0,1,0,0,1,2,0,0,0,3,16,0,12,
-0,21,1,0,0,76,1,2,0,0,2,10,0,0,2,30,16,0,12,0,21,2,0,0,11,1,0,0,88,3,7,128,
-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,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,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
+/* math.deg */ 0,1,2,0,0,1,2,BC_MULVN,1,0,0,BC_RET1,1,2,0,241,135,158,166,3,
+220,203,178,130,4,
+/* math.rad */ 0,1,2,0,0,1,2,BC_MULVN,1,0,0,BC_RET1,1,2,0,243,244,148,165,20,
+198,190,199,252,3,
+/* string.len */ 0,1,2,0,0,0,3,BC_ISTYPE,0,5,0,BC_LEN,1,0,0,BC_RET1,1,2,0,
+/* table.foreachi */ 0,2,10,0,0,0,15,BC_ISTYPE,0,12,0,BC_ISTYPE,1,9,0,
+BC_KSHORT,2,1,0,BC_LEN,3,0,0,BC_KSHORT,4,1,0,BC_FORI,2,8,128,BC_MOV,6,1,0,
+BC_MOV,8,5,0,BC_TGETR,9,5,0,BC_CALL,6,3,2,BC_ISEQP,6,0,0,BC_JMP,7,1,128,
+BC_RET1,6,2,0,BC_FORL,2,248,127,BC_RET0,0,1,0,
+/* table.foreach */ 0,2,11,0,0,1,16,BC_ISTYPE,0,12,0,BC_ISTYPE,1,9,0,BC_KPRI,
+2,0,0,BC_MOV,3,0,0,BC_KNUM,4,0,0,BC_JMP,5,7,128,BC_MOV,7,1,0,BC_MOV,9,5,0,
+BC_MOV,10,6,0,BC_CALL,7,3,2,BC_ISEQP,7,0,0,BC_JMP,8,1,128,BC_RET1,7,2,0,
+BC_ITERN,5,3,3,BC_ITERL,5,247,127,BC_RET0,0,1,0,1,255,255,249,255,15,
+/* table.getn */ 0,1,2,0,0,0,3,BC_ISTYPE,0,12,0,BC_LEN,1,0,0,BC_RET1,1,2,0,
+/* table.remove */ 0,2,10,0,0,2,30,BC_ISTYPE,0,12,0,BC_LEN,2,0,0,BC_ISNEP,1,0,
+0,BC_JMP,3,7,128,BC_ISEQN,2,0,0,BC_JMP,3,23,128,BC_TGETR,3,2,0,BC_KPRI,4,0,0,
+BC_TSETR,4,2,0,BC_RET1,3,2,0,BC_JMP,3,18,128,BC_ISTYPE,1,14,0,BC_KSHORT,3,1,0,
+BC_ISGT,3,1,0,BC_JMP,3,14,128,BC_ISGT,1,2,0,BC_JMP,3,12,128,BC_TGETR,3,1,0,
+BC_ADDVN,4,1,1,BC_MOV,5,2,0,BC_KSHORT,6,1,0,BC_FORI,4,4,128,BC_SUBVN,8,1,7,
+BC_TGETR,9,7,0,BC_TSETR,9,8,0,BC_FORL,4,252,127,BC_KPRI,4,0,0,BC_TSETR,4,2,0,
+BC_RET1,3,2,0,BC_RET0,0,1,0,0,2,
+/* table.move */ 0,5,12,0,0,0,35,BC_ISTYPE,0,12,0,BC_ISTYPE,1,14,0,BC_ISTYPE,
+2,14,0,BC_ISTYPE,3,14,0,BC_ISNEP,4,0,0,BC_JMP,5,1,128,BC_MOV,4,0,0,BC_ISTYPE,
+4,12,0,BC_ISGT,1,2,0,BC_JMP,5,24,128,BC_SUBVV,5,1,3,BC_ISLT,2,3,0,BC_JMP,6,4,
+128,BC_ISLE,3,1,0,BC_JMP,6,2,128,BC_ISEQV,4,0,0,BC_JMP,6,9,128,BC_MOV,6,1,0,
+BC_MOV,7,2,0,BC_KSHORT,8,1,0,BC_FORI,6,4,128,BC_ADDVV,10,5,9,BC_TGETR,11,9,0,
+BC_TSETR,11,10,4,BC_FORL,6,252,127,BC_JMP,6,8,128,BC_MOV,6,2,0,BC_MOV,7,1,0,
+BC_KSHORT,8,255,255,BC_FORI,6,4,128,BC_ADDVV,10,5,9,BC_TGETR,11,9,0,BC_TSETR,
+11,10,4,BC_FORL,6,252,127,BC_RET1,4,2,0,
#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,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,
-16,0,5,0,21,1,0,0,76,1,2,0,0,2,9,0,0,0,15,16,0,12,0,16,1,9,0,41,2,1,0,21,3,
-0,0,41,4,1,0,77,2,8,128,18,6,1,0,18,7,5,0,59,8,5,0,66,6,3,2,10,6,0,0,88,7,1,
-128,76,6,2,0,79,2,248,127,75,0,1,0,0,2,10,0,0,0,16,16,0,12,0,16,1,9,0,43,2,
-0,0,18,3,0,0,41,4,0,0,88,5,7,128,18,7,1,0,18,8,5,0,18,9,6,0,66,7,3,2,10,7,0,
-0,88,8,1,128,76,7,2,0,70,5,3,3,82,5,247,127,75,0,1,0,0,1,2,0,0,0,3,16,0,12,
-0,21,1,0,0,76,1,2,0,0,2,10,0,0,2,30,16,0,12,0,21,2,0,0,11,1,0,0,88,3,7,128,
-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,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,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
+/* math.deg */ 0,1,2,0,0,1,2,BC_MULVN,1,0,0,BC_RET1,1,2,0,241,135,158,166,3,
+220,203,178,130,4,
+/* math.rad */ 0,1,2,0,0,1,2,BC_MULVN,1,0,0,BC_RET1,1,2,0,243,244,148,165,20,
+198,190,199,252,3,
+/* string.len */ 0,1,2,0,0,0,3,BC_ISTYPE,0,5,0,BC_LEN,1,0,0,BC_RET1,1,2,0,
+/* table.foreachi */ 0,2,9,0,0,0,15,BC_ISTYPE,0,12,0,BC_ISTYPE,1,9,0,
+BC_KSHORT,2,1,0,BC_LEN,3,0,0,BC_KSHORT,4,1,0,BC_FORI,2,8,128,BC_MOV,6,1,0,
+BC_MOV,7,5,0,BC_TGETR,8,5,0,BC_CALL,6,3,2,BC_ISEQP,6,0,0,BC_JMP,7,1,128,
+BC_RET1,6,2,0,BC_FORL,2,248,127,BC_RET0,0,1,0,
+/* table.foreach */ 0,2,10,0,0,1,16,BC_ISTYPE,0,12,0,BC_ISTYPE,1,9,0,BC_KPRI,
+2,0,0,BC_MOV,3,0,0,BC_KNUM,4,0,0,BC_JMP,5,7,128,BC_MOV,7,1,0,BC_MOV,8,5,0,
+BC_MOV,9,6,0,BC_CALL,7,3,2,BC_ISEQP,7,0,0,BC_JMP,8,1,128,BC_RET1,7,2,0,
+BC_ITERN,5,3,3,BC_ITERL,5,247,127,BC_RET0,0,1,0,1,255,255,249,255,15,
+/* table.getn */ 0,1,2,0,0,0,3,BC_ISTYPE,0,12,0,BC_LEN,1,0,0,BC_RET1,1,2,0,
+/* table.remove */ 0,2,10,0,0,2,30,BC_ISTYPE,0,12,0,BC_LEN,2,0,0,BC_ISNEP,1,0,
+0,BC_JMP,3,7,128,BC_ISEQN,2,0,0,BC_JMP,3,23,128,BC_TGETR,3,2,0,BC_KPRI,4,0,0,
+BC_TSETR,4,2,0,BC_RET1,3,2,0,BC_JMP,3,18,128,BC_ISTYPE,1,14,0,BC_KSHORT,3,1,0,
+BC_ISGT,3,1,0,BC_JMP,3,14,128,BC_ISGT,1,2,0,BC_JMP,3,12,128,BC_TGETR,3,1,0,
+BC_ADDVN,4,1,1,BC_MOV,5,2,0,BC_KSHORT,6,1,0,BC_FORI,4,4,128,BC_SUBVN,8,1,7,
+BC_TGETR,9,7,0,BC_TSETR,9,8,0,BC_FORL,4,252,127,BC_KPRI,4,0,0,BC_TSETR,4,2,0,
+BC_RET1,3,2,0,BC_RET0,0,1,0,0,2,
+/* table.move */ 0,5,12,0,0,0,35,BC_ISTYPE,0,12,0,BC_ISTYPE,1,14,0,BC_ISTYPE,
+2,14,0,BC_ISTYPE,3,14,0,BC_ISNEP,4,0,0,BC_JMP,5,1,128,BC_MOV,4,0,0,BC_ISTYPE,
+4,12,0,BC_ISGT,1,2,0,BC_JMP,5,24,128,BC_SUBVV,5,1,3,BC_ISLT,2,3,0,BC_JMP,6,4,
+128,BC_ISLE,3,1,0,BC_JMP,6,2,128,BC_ISEQV,4,0,0,BC_JMP,6,9,128,BC_MOV,6,1,0,
+BC_MOV,7,2,0,BC_KSHORT,8,1,0,BC_FORI,6,4,128,BC_ADDVV,10,5,9,BC_TGETR,11,9,0,
+BC_TSETR,11,10,4,BC_FORL,6,252,127,BC_JMP,6,8,128,BC_MOV,6,2,0,BC_MOV,7,1,0,
+BC_KSHORT,8,255,255,BC_FORI,6,4,128,BC_ADDVV,10,5,9,BC_TGETR,11,9,0,BC_TSETR,
+11,10,4,BC_FORL,6,252,127,BC_RET1,4,2,0,
#endif
+0
};
static const struct { const char *name; int ofs; } libbc_map[] = {
@@ -48,9 +73,9 @@
{"string_len",50},
{"table_foreachi",69},
{"table_foreach",136},
-{"table_getn",207},
-{"table_remove",226},
-{"table_move",355},
-{NULL,502}
+{"table_getn",213},
+{"table_remove",232},
+{"table_move",361},
+{NULL,508}
};
diff -Nru luajit-2.1.20220411/src/host/genlibbc.lua luajit-2.1.20230119/src/host/genlibbc.lua
--- luajit-2.1.20220411/src/host/genlibbc.lua 2022-04-05 12:12:47.000000000 +0000
+++ luajit-2.1.20230119/src/host/genlibbc.lua 2023-01-02 04:12:33.000000000 +0000
@@ -55,7 +55,7 @@
end)
code = string.gsub(code, "PAIRS%((.-)%)", function(var)
fixup.PAIRS = true
- return format("nil, %s, 0", var)
+ return format("nil, %s, 0x4dp80", var)
end)
return "return "..code, fixup
end
@@ -79,9 +79,11 @@
str = 5, func = 9, tab = 12, int = 14, num = 15
}
-local BC = {}
+local BC, BCN = {}, {}
for i=0,#bcnames/6-1 do
- BC[string.gsub(string.sub(bcnames, i*6+1, i*6+6), " ", "")] = i
+ local name = bcnames:sub(i*6+1, i*6+6):gsub(" ", "")
+ BC[name] = i
+ BCN[i] = name
end
local xop, xra = isbe and 3 or 0, isbe and 2 or 1
local xrc, xrb = isbe and 1 or 2, isbe and 0 or 3
@@ -96,6 +98,7 @@
p = read_uleb128(p)
p = read_uleb128(p)
p, sizebc = read_uleb128(p)
+ local startbc = tonumber(p - start)
local rawtab = {}
for i=0,sizebc-1 do
local op = p[xop]
@@ -129,7 +132,10 @@
end
p = p + 4
end
- return ffi.string(start, n)
+ local ndump = ffi.string(start, n)
+ -- Fixup hi-part of 0x4dp80 to LJ_KEYINDEX.
+ ndump = ndump:gsub("\x80\x80\xcd\xaa\x04", "\xff\xff\xf9\xff\x0f")
+ return { dump = ndump, startbc = startbc, sizebc = sizebc }
end
local function find_defs(src)
@@ -149,24 +155,46 @@
local function w(x) t[#t+1] = x end
w("/* This is a generated file. DO NOT EDIT! */\n\n")
w("static const int libbc_endian = ") w(isbe and 1 or 0) w(";\n\n")
- local s = ""
- for _,name in ipairs(defs) do
- s = s .. defs[name]
+ local s, sb = "", ""
+ for i,name in ipairs(defs) do
+ local d = defs[name]
+ s = s .. d.dump
+ sb = sb .. string.char(i) .. ("\0"):rep(d.startbc - 1)
+ .. (isbe and "\0\0\0\255" or "\255\0\0\0"):rep(d.sizebc)
+ .. ("\0"):rep(#d.dump - d.startbc - d.sizebc*4)
end
w("static const uint8_t libbc_code[] = {\n")
local n = 0
for i=1,#s do
local x = string.byte(s, i)
- w(x); w(",")
- n = n + (x < 10 and 2 or (x < 100 and 3 or 4))
- if n >= 75 then n = 0; w("\n") end
+ local xb = string.byte(sb, i)
+ if xb == 255 then
+ local name = BCN[x]
+ local m = #name + 4
+ if n + m > 78 then n = 0; w("\n") end
+ n = n + m
+ w("BC_"); w(name)
+ else
+ local m = x < 10 and 2 or (x < 100 and 3 or 4)
+ if xb == 0 then
+ if n + m > 78 then n = 0; w("\n") end
+ else
+ local name = defs[xb]:gsub("_", ".")
+ if n ~= 0 then w("\n") end
+ w("/* "); w(name); w(" */ ")
+ n = #name + 7
+ end
+ n = n + m
+ w(x)
+ end
+ w(",")
end
- w("0\n};\n\n")
+ w("\n0\n};\n\n")
w("static const struct { const char *name; int ofs; } libbc_map[] = {\n")
local m = 0
for _,name in ipairs(defs) do
w('{"'); w(name); w('",'); w(m) w('},\n')
- m = m + #defs[name]
+ m = m + #defs[name].dump
end
w("{NULL,"); w(m); w("}\n};\n\n")
return table.concat(t)
diff -Nru luajit-2.1.20220411/src/host/genminilua.lua luajit-2.1.20230119/src/host/genminilua.lua
--- luajit-2.1.20220411/src/host/genminilua.lua 2022-04-05 12:12:47.000000000 +0000
+++ luajit-2.1.20230119/src/host/genminilua.lua 2023-01-02 04:12:33.000000000 +0000
@@ -327,6 +327,12 @@
return gsub(src, "ZY([%w_]+)", "union %1")
end
+local function fix_bugs_and_warnings(src)
+ src = gsub(src, "(luaD_checkstack%(L,p%->maxstacksize)%)", "%1+p->numparams)")
+ src = gsub(src, "if%(sep==%-1%)(return'%[';)\nelse (luaX_lexerror%b();)", "if (sep!=-1)%2\n%1")
+ return gsub(src, "(default:{\nNode%*n=mainposition)", "/*fallthrough*/\n%1")
+end
+
local function func_gather(src)
local nodes, list = {}, {}
local pos, len = 1, #src
@@ -425,5 +431,6 @@
src = func_collect(src)
src = rename_tokens2(src)
src = restore_strings(src)
+src = fix_bugs_and_warnings(src)
src = merge_header(src, license)
io.write(src)
diff -Nru luajit-2.1.20220411/src/host/minilua.c luajit-2.1.20230119/src/host/minilua.c
--- luajit-2.1.20220411/src/host/minilua.c 2022-04-05 12:12:47.000000000 +0000
+++ luajit-2.1.20230119/src/host/minilua.c 2023-01-02 04:12:33.000000000 +0000
@@ -1639,6 +1639,7 @@
if(luai_numeq(cast_num(k),nvalue(key)))
return luaH_getnum(t,k);
}
+/*fallthrough*/
default:{
Node*n=mainposition(t,key);
do{
@@ -2905,8 +2906,8 @@
read_long_string(ls,seminfo,sep);
return TK_STRING;
}
-else if(sep==-1)return'[';
-else luaX_lexerror(ls,"invalid long string delimiter",TK_STRING);
+else if (sep!=-1)luaX_lexerror(ls,"invalid long string delimiter",TK_STRING);
+return'[';
}
case'=':{
next(ls);
diff -Nru luajit-2.1.20220411/src/jit/bcsave.lua luajit-2.1.20230119/src/jit/bcsave.lua
--- luajit-2.1.20220411/src/jit/bcsave.lua 2022-04-05 12:12:47.000000000 +0000
+++ luajit-2.1.20230119/src/jit/bcsave.lua 2023-01-02 04:12:33.000000000 +0000
@@ -34,6 +34,7 @@
-t type Set output file type (default: auto-detect from output name).
-a arch Override architecture for object files (default: native).
-o os Override OS for object files (default: native).
+ -F name Override filename (default: input filename).
-e chunk Use chunk string as input.
-- Stop handling options.
- Use stdin as input and/or stdout as output.
@@ -50,10 +51,22 @@
os.exit(1)
end
-local function readfile(input)
+local function readfile(ctx, input)
if type(input) == "function" then return input end
- if input == "-" then input = nil end
- return check(loadfile(input))
+ if ctx.filename then
+ local data
+ if input == "-" then
+ data = io.stdin:read("*a")
+ else
+ local fp = assert(io.open(input, "rb"))
+ data = assert(fp:read("*a"))
+ assert(fp:close())
+ end
+ return check(load(data, ctx.filename))
+ else
+ if input == "-" then input = nil end
+ return check(loadfile(input))
+ end
end
local function savefile(name, mode)
@@ -457,18 +470,18 @@
uint32_t value;
} mach_nlist;
typedef struct {
- uint32_t strx;
+ int32_t strx;
uint8_t type, sect;
uint16_t desc;
uint64_t value;
} mach_nlist_64;
typedef struct
{
- uint32_t magic, nfat_arch;
+ int32_t magic, nfat_arch;
} mach_fat_header;
typedef struct
{
- uint32_t cputype, cpusubtype, offset, size, align;
+ int32_t cputype, cpusubtype, offset, size, align;
} mach_fat_arch;
typedef struct {
struct {
@@ -502,6 +515,18 @@
mach_nlist sym_entry;
uint8_t space[4096];
} mach_fat_obj;
+typedef struct {
+ mach_fat_header fat;
+ mach_fat_arch fat_arch[2];
+ struct {
+ mach_header_64 hdr;
+ mach_segment_command_64 seg;
+ mach_section_64 sec;
+ mach_symtab_command sym;
+ } arch[2];
+ mach_nlist_64 sym_entry;
+ uint8_t space[4096];
+} mach_fat_obj_64;
]]
local symname = '_'..LJBC_PREFIX..ctx.modname
local isfat, is64, align, mobj = false, false, 4, "mach_obj"
@@ -510,7 +535,7 @@
elseif ctx.arch == "arm" then
isfat, mobj = true, "mach_fat_obj"
elseif ctx.arch == "arm64" then
- is64, align, isfat, mobj = true, 8, true, "mach_fat_obj"
+ is64, align, isfat, mobj = true, 8, true, "mach_fat_obj_64"
else
check(ctx.arch == "x86", "unsupported architecture for OSX")
end
@@ -593,13 +618,13 @@
------------------------------------------------------------------------------
-local function bclist(input, output, lineinfo)
- local f = readfile(input)
+local function bclist(ctx, input, output, lineinfo)
+ local f = readfile(ctx, input)
require("jit.bc").dump(f, savefile(output, "w"), true, lineinfo)
end
local function bcsave(ctx, input, output)
- local f = readfile(input)
+ local f = readfile(ctx, input)
local s = string.dump(f, ctx.strip)
local t = ctx.type
if not t then
@@ -656,6 +681,8 @@
ctx.arch = checkarg(tremove(arg, n), map_arch, "architecture")
elseif opt == "o" then
ctx.os = checkarg(tremove(arg, n), map_os, "OS name")
+ elseif opt == "F" then
+ ctx.filename = "@"..tremove(arg, n)
else
usage()
end
@@ -667,7 +694,7 @@
end
if list then
if #arg == 0 or #arg > 2 then usage() end
- bclist(arg[1], arg[2] or "-", lineinfo)
+ bclist(ctx, arg[1], arg[2] or "-", lineinfo)
else
if #arg ~= 2 then usage() end
bcsave(ctx, arg[1], arg[2])
diff -Nru luajit-2.1.20220411/src/lib_base.c luajit-2.1.20230119/src/lib_base.c
--- luajit-2.1.20220411/src/lib_base.c 2022-04-05 12:12:47.000000000 +0000
+++ luajit-2.1.20230119/src/lib_base.c 2023-01-02 04:12:33.000000000 +0000
@@ -304,7 +304,7 @@
while (lj_char_isspace((unsigned char)(*ep))) ep++;
if (*ep == '\0') {
if (LJ_DUALNUM && LJ_LIKELY(ul < 0x80000000u+neg)) {
- if (neg) ul = (unsigned long)-(long)ul;
+ if (neg) ul = ~ul+1u;
setintV(L->base-1-LJ_FR2, (int32_t)ul);
} else {
lua_Number n = (lua_Number)ul;
diff -Nru luajit-2.1.20220411/src/lib_bit.c luajit-2.1.20230119/src/lib_bit.c
--- luajit-2.1.20220411/src/lib_bit.c 2022-04-05 12:12:47.000000000 +0000
+++ luajit-2.1.20230119/src/lib_bit.c 2023-01-02 04:12:33.000000000 +0000
@@ -155,7 +155,8 @@
#endif
SBuf *sb = lj_buf_tmp_(L);
SFormat sf = (STRFMT_UINT|STRFMT_T_HEX);
- if (n < 0) { n = -n; sf |= STRFMT_F_UPPER; }
+ if (n < 0) { n = (int32_t)(~(uint32_t)n+1u); sf |= STRFMT_F_UPPER; }
+ if ((uint32_t)n > 254) n = 254;
sf |= ((SFormat)((n+1)&255) << STRFMT_SH_PREC);
#if LJ_HASFFI
if (n < 16) b &= ((uint64_t)1 << 4*n)-1;
diff -Nru luajit-2.1.20220411/src/lib_buffer.c luajit-2.1.20230119/src/lib_buffer.c
--- luajit-2.1.20220411/src/lib_buffer.c 2022-04-05 12:12:47.000000000 +0000
+++ luajit-2.1.20230119/src/lib_buffer.c 2023-01-02 04:12:33.000000000 +0000
@@ -128,7 +128,7 @@
lj_strfmt_putfnum((SBuf *)sbx, STRFMT_G14, numV(o));
} else if (tvisbuf(o)) {
SBufExt *sbx2 = bufV(o);
- if (sbx2 == sbx) lj_err_arg(L, arg+1, LJ_ERR_BUFFER_SELF);
+ if (sbx2 == sbx) lj_err_arg(L, (int)(arg+1), LJ_ERR_BUFFER_SELF);
lj_buf_putmem((SBuf *)sbx, sbx2->r, sbufxlen(sbx2));
} else if (!mo && !tvisnil(mo = lj_meta_lookup(L, o, MM_tostring))) {
/* Call __tostring metamethod inline. */
@@ -140,7 +140,7 @@
L->top = L->base + narg;
goto retry; /* Retry with the result. */
} else {
- lj_err_argtype(L, arg+1, "string/number/__tostring");
+ lj_err_argtype(L, (int)(arg+1), "string/number/__tostring");
}
/* Probably not useful to inline other __tostring MMs, e.g. FFI numbers. */
}
@@ -169,7 +169,7 @@
for (arg = 1; arg < narg; arg++) {
TValue *o = &L->base[arg];
MSize n = tvisnil(o) ? LJ_MAX_BUF :
- (MSize) lj_lib_checkintrange(L, arg+1, 0, LJ_MAX_BUF);
+ (MSize) lj_lib_checkintrange(L, (int)(arg+1), 0, LJ_MAX_BUF);
MSize len = sbufxlen(sbx);
if (n > len) n = len;
setstrV(L, o, lj_str_new(L, sbx->r, n));
@@ -177,7 +177,7 @@
}
if (sbx->r == sbx->w && !sbufiscow(sbx)) sbx->r = sbx->w = sbx->b;
lj_gc_check(L);
- return narg-1;
+ return (int)(narg-1);
}
#if LJ_HASFFI
@@ -323,6 +323,7 @@
setgcref(sbx->dict_str, obj2gco(dict_str));
setgcref(sbx->dict_mt, obj2gco(dict_mt));
if (sz > 0) lj_buf_need2((SBuf *)sbx, sz);
+ lj_gc_check(L);
return 1;
}
@@ -339,6 +340,7 @@
GCstr *str = lj_lib_checkstrx(L, 1);
setnilV(L->top++);
lj_serialize_decode(L, L->top-1, str);
+ lj_gc_check(L);
return 1;
}
diff -Nru luajit-2.1.20220411/src/lib_ffi.c luajit-2.1.20230119/src/lib_ffi.c
--- luajit-2.1.20220411/src/lib_ffi.c 2022-04-05 12:12:47.000000000 +0000
+++ luajit-2.1.20230119/src/lib_ffi.c 2023-01-02 04:12:33.000000000 +0000
@@ -639,7 +639,7 @@
CTState *cts = ctype_cts(L);
CTypeID id = ffi_checkctype(L, cts, NULL);
CTSize sz = 0;
- CTInfo info = lj_ctype_info(cts, id, &sz);
+ CTInfo info = lj_ctype_info_raw(cts, id, &sz);
setintV(L->top-1, 1 << ctype_align(info));
return 1;
}
@@ -770,7 +770,7 @@
CTypeID id = ffi_checkctype(L, cts, NULL);
GCtab *mt = lj_lib_checktab(L, 2);
GCtab *t = cts->miscmap;
- CType *ct = ctype_get(cts, id); /* Only allow raw types. */
+ CType *ct = ctype_raw(cts, id);
TValue *tv;
GCcdata *cd;
if (!(ctype_isstruct(ct->info) || ctype_iscomplex(ct->info) ||
diff -Nru luajit-2.1.20220411/src/lib_io.c luajit-2.1.20230119/src/lib_io.c
--- luajit-2.1.20220411/src/lib_io.c 2022-04-05 12:12:47.000000000 +0000
+++ luajit-2.1.20230119/src/lib_io.c 2023-01-02 04:12:33.000000000 +0000
@@ -439,7 +439,7 @@
LJLIB_CF(io_tmpfile)
{
IOFileUD *iof = io_file_new(L);
-#if LJ_TARGET_PS3 || LJ_TARGET_PS4 || LJ_TARGET_PSVITA
+#if LJ_TARGET_PS3 || LJ_TARGET_PS4 || LJ_TARGET_PS5 || LJ_TARGET_PSVITA || LJ_TARGET_NX
iof->fp = NULL; errno = ENOSYS;
#else
iof->fp = tmpfile();
diff -Nru luajit-2.1.20220411/src/lib_os.c luajit-2.1.20230119/src/lib_os.c
--- luajit-2.1.20220411/src/lib_os.c 2022-04-05 12:12:47.000000000 +0000
+++ luajit-2.1.20230119/src/lib_os.c 2023-01-02 04:12:33.000000000 +0000
@@ -76,7 +76,7 @@
LJLIB_CF(os_tmpname)
{
-#if LJ_TARGET_PS3 || LJ_TARGET_PS4 || LJ_TARGET_PSVITA
+#if LJ_TARGET_PS3 || LJ_TARGET_PS4 || LJ_TARGET_PS5 || LJ_TARGET_PSVITA || LJ_TARGET_NX
lj_err_caller(L, LJ_ERR_OSUNIQF);
return 0;
#else
diff -Nru luajit-2.1.20220411/src/lib_package.c luajit-2.1.20230119/src/lib_package.c
--- luajit-2.1.20220411/src/lib_package.c 2022-04-05 12:12:47.000000000 +0000
+++ luajit-2.1.20230119/src/lib_package.c 2023-01-02 04:12:33.000000000 +0000
@@ -57,7 +57,7 @@
static const char *ll_bcsym(void *lib, const char *sym)
{
-#if defined(RTLD_DEFAULT)
+#if defined(RTLD_DEFAULT) && !defined(NO_RTLD_DEFAULT)
if (lib == NULL) lib = RTLD_DEFAULT;
#elif LJ_TARGET_OSX || LJ_TARGET_BSD
if (lib == NULL) lib = (void *)(intptr_t)-2;
diff -Nru luajit-2.1.20220411/src/lj_alloc.c luajit-2.1.20230119/src/lj_alloc.c
--- luajit-2.1.20220411/src/lj_alloc.c 2022-04-05 12:12:47.000000000 +0000
+++ luajit-2.1.20230119/src/lj_alloc.c 2023-01-02 04:12:33.000000000 +0000
@@ -330,7 +330,7 @@
#define CALL_MMAP(prng, size) mmap_plain(size)
#endif
-#if LJ_64 && !LJ_GC64 && ((defined(__FreeBSD__) && __FreeBSD__ < 10) || defined(__FreeBSD_kernel__)) && !LJ_TARGET_PS4
+#if LJ_64 && !LJ_GC64 && ((defined(__FreeBSD__) && __FreeBSD__ < 10) || defined(__FreeBSD_kernel__)) && !LJ_TARGET_PS4 && !LJ_TARGET_PS5
#include
diff -Nru luajit-2.1.20220411/src/lj_api.c luajit-2.1.20230119/src/lj_api.c
--- luajit-2.1.20220411/src/lj_api.c 2022-04-05 12:12:47.000000000 +0000
+++ luajit-2.1.20230119/src/lj_api.c 2023-01-02 04:12:33.000000000 +0000
@@ -779,7 +779,7 @@
L->top -= n;
break;
}
- n -= (int)(L->top - top);
+ n -= (int)(L->top - (top - 2*LJ_FR2));
L->top = top+2;
lj_vm_call(L, top, 1+1);
L->top -= 1+LJ_FR2;
diff -Nru luajit-2.1.20220411/src/lj_arch.h luajit-2.1.20230119/src/lj_arch.h
--- luajit-2.1.20220411/src/lj_arch.h 2022-04-05 12:12:47.000000000 +0000
+++ luajit-2.1.20230119/src/lj_arch.h 2023-01-02 04:12:33.000000000 +0000
@@ -87,7 +87,7 @@
#define LUAJIT_OS LUAJIT_OS_OSX
#elif (defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || \
defined(__NetBSD__) || defined(__OpenBSD__) || \
- defined(__DragonFly__)) && !defined(__ORBIS__)
+ defined(__DragonFly__)) && !defined(__ORBIS__) && !defined(__PROSPERO__)
#define LUAJIT_OS LUAJIT_OS_BSD
#elif (defined(__sun__) && defined(__svr4__))
#define LJ_TARGET_SOLARIS 1
@@ -97,6 +97,9 @@
#elif defined(__CYGWIN__)
#define LJ_TARGET_CYGWIN 1
#define LUAJIT_OS LUAJIT_OS_POSIX
+#elif defined(__QNX__)
+#define LJ_TARGET_QNX 1
+#define LUAJIT_OS LUAJIT_OS_POSIX
#else
#define LUAJIT_OS LUAJIT_OS_OTHER
#endif
@@ -143,6 +146,13 @@
#define NULL ((void*)0)
#endif
+#ifdef __PROSPERO__
+#define LJ_TARGET_PS5 1
+#define LJ_TARGET_CONSOLE 1
+#undef NULL
+#define NULL ((void*)0)
+#endif
+
#ifdef __psp2__
#define LJ_TARGET_PSVITA 1
#define LJ_TARGET_CONSOLE 1
@@ -159,6 +169,13 @@
#define LJ_TARGET_GC64 1
#endif
+#ifdef __NX__
+#define LJ_TARGET_NX 1
+#define LJ_TARGET_CONSOLE 1
+#undef NULL
+#define NULL ((void*)0)
+#endif
+
#ifdef _UWP
#define LJ_TARGET_UWP 1
#if LUAJIT_TARGET == LUAJIT_ARCH_X64
@@ -664,7 +681,7 @@
#endif
#endif
-#if defined(LUAJIT_NO_UNWIND) || __GNU_COMPACT_EH__ || defined(__symbian__) || LJ_TARGET_IOS || LJ_TARGET_PS3 || LJ_TARGET_PS4
+#if defined(LUAJIT_NO_UNWIND) || __GNU_COMPACT_EH__ || defined(__symbian__) || LJ_TARGET_IOS || LJ_TARGET_PS3 || LJ_TARGET_PS4 || LJ_TARGET_PS5
#define LJ_NO_UNWIND 1
#endif
diff -Nru luajit-2.1.20220411/src/lj_asm_arm64.h luajit-2.1.20230119/src/lj_asm_arm64.h
--- luajit-2.1.20220411/src/lj_asm_arm64.h 2022-04-05 12:12:47.000000000 +0000
+++ luajit-2.1.20230119/src/lj_asm_arm64.h 2023-01-02 04:12:33.000000000 +0000
@@ -337,7 +337,8 @@
{
IRRef lref = ir->op1, rref = ir->op2;
IRIns *irm;
- if (lref != rref &&
+ if ((as->flags & JIT_F_OPT_FMA) &&
+ lref != rref &&
((mayfuse(as, lref) && (irm = IR(lref), irm->o == IR_MUL) &&
ra_noreg(irm->r)) ||
(mayfuse(as, rref) && (irm = IR(rref), irm->o == IR_MUL) &&
@@ -1250,7 +1251,7 @@
tmp = ra_scratch(as, allow);
rset_clear(allow, tmp);
}
- if (irt_isnum(t) && !(ir->op2 & IRSLOAD_CONVERT))
+ if (ra_hasreg(dest) && tmp != dest)
emit_dn(as, A64I_FMOV_D_R, (dest & 31), tmp);
/* Need type check, even if the load result is unused. */
asm_guardcc(as, irt_isnum(t) ? CC_LS : CC_NE);
diff -Nru luajit-2.1.20220411/src/lj_asm_arm.h luajit-2.1.20230119/src/lj_asm_arm.h
--- luajit-2.1.20220411/src/lj_asm_arm.h 2022-04-05 12:12:47.000000000 +0000
+++ luajit-2.1.20230119/src/lj_asm_arm.h 2023-01-02 04:12:33.000000000 +0000
@@ -313,7 +313,11 @@
}
#if !LJ_SOFTFP
-/* Fuse to multiply-add/sub instruction. */
+/*
+** Fuse to multiply-add/sub instruction.
+** VMLA rounds twice (UMA, not FMA) -- no need to check for JIT_F_OPT_FMA.
+** VFMA needs VFPv4, which is uncommon on the remaining ARM32 targets.
+*/
static int asm_fusemadd(ASMState *as, IRIns *ir, ARMIns ai, ARMIns air)
{
IRRef lref = ir->op1, rref = ir->op2;
diff -Nru luajit-2.1.20220411/src/lj_asm_mips.h luajit-2.1.20230119/src/lj_asm_mips.h
--- luajit-2.1.20220411/src/lj_asm_mips.h 2022-04-05 12:12:47.000000000 +0000
+++ luajit-2.1.20230119/src/lj_asm_mips.h 2023-01-02 04:12:33.000000000 +0000
@@ -1894,7 +1894,7 @@
lj_assertA(!irt_is64(ir->t), "bad usage");
if (irref_isk(ir->op2)) {
int k = IR(ir->op2)->i;
- if (ir->o == IR_SUBOV) k = -k;
+ if (ir->o == IR_SUBOV) k = (int)(~(unsigned int)k+1u);
if (checki16(k)) { /* (dest < left) == (k >= 0 ? 1 : 0) */
left = ra_alloc1(as, ir->op1, RSET_GPR);
asm_guard(as, k >= 0 ? MIPSI_BNE : MIPSI_BEQ, RID_TMP, RID_ZERO);
diff -Nru luajit-2.1.20220411/src/lj_asm_ppc.h luajit-2.1.20230119/src/lj_asm_ppc.h
--- luajit-2.1.20220411/src/lj_asm_ppc.h 2022-04-05 12:12:47.000000000 +0000
+++ luajit-2.1.20230119/src/lj_asm_ppc.h 2023-01-02 04:12:33.000000000 +0000
@@ -235,7 +235,8 @@
{
IRRef lref = ir->op1, rref = ir->op2;
IRIns *irm;
- if (lref != rref &&
+ if ((as->flags & JIT_F_OPT_FMA) &&
+ lref != rref &&
((mayfuse(as, lref) && (irm = IR(lref), irm->o == IR_MUL) &&
ra_noreg(irm->r)) ||
(mayfuse(as, rref) && (irm = IR(rref), irm->o == IR_MUL) &&
diff -Nru luajit-2.1.20220411/src/lj_asm_x86.h luajit-2.1.20230119/src/lj_asm_x86.h
--- luajit-2.1.20220411/src/lj_asm_x86.h 2022-04-05 12:12:47.000000000 +0000
+++ luajit-2.1.20230119/src/lj_asm_x86.h 2023-01-02 04:12:33.000000000 +0000
@@ -485,7 +485,8 @@
asm_fusexref(as, ir->op1, xallow);
return RID_MRM;
}
- } else if (ir->o == IR_VLOAD && !(LJ_GC64 && irt_isaddr(ir->t))) {
+ } else if (ir->o == IR_VLOAD && IR(ir->op1)->o == IR_AREF &&
+ !(LJ_GC64 && irt_isaddr(ir->t))) {
asm_fuseahuref(as, ir->op1, xallow);
as->mrm.ofs += 8 * ir->op2;
return RID_MRM;
diff -Nru luajit-2.1.20220411/src/lj_carith.c luajit-2.1.20230119/src/lj_carith.c
--- luajit-2.1.20220411/src/lj_carith.c 2022-04-05 12:12:47.000000000 +0000
+++ luajit-2.1.20230119/src/lj_carith.c 2023-01-02 04:12:33.000000000 +0000
@@ -207,7 +207,7 @@
else
*up = lj_carith_powu64(u0, u1);
break;
- case MM_unm: *up = (uint64_t)-(int64_t)u0; break;
+ case MM_unm: *up = ~u0+1u; break;
default:
lj_assertL(0, "bad metamethod %d", mm);
break;
diff -Nru luajit-2.1.20220411/src/lj_clib.c luajit-2.1.20230119/src/lj_clib.c
--- luajit-2.1.20220411/src/lj_clib.c 2022-04-05 12:12:47.000000000 +0000
+++ luajit-2.1.20230119/src/lj_clib.c 2023-01-02 04:12:33.000000000 +0000
@@ -25,7 +25,7 @@
#include
#include
-#if defined(RTLD_DEFAULT)
+#if defined(RTLD_DEFAULT) && !defined(NO_RTLD_DEFAULT)
#define CLIB_DEFHANDLE RTLD_DEFAULT
#elif LJ_TARGET_OSX || LJ_TARGET_BSD
#define CLIB_DEFHANDLE ((void *)(intptr_t)-2)
diff -Nru luajit-2.1.20220411/src/lj_cparse.c luajit-2.1.20230119/src/lj_cparse.c
--- luajit-2.1.20220411/src/lj_cparse.c 2022-04-05 12:12:47.000000000 +0000
+++ luajit-2.1.20230119/src/lj_cparse.c 2023-01-02 04:12:33.000000000 +0000
@@ -468,7 +468,7 @@
} else {
cp_expr_unary(cp, k);
}
- info = lj_ctype_info(cp->cts, k->id, &sz);
+ info = lj_ctype_info_raw(cp->cts, k->id, &sz);
if (wantsz) {
if (sz != CTSIZE_INVALID)
k->u32 = sz;
@@ -488,7 +488,7 @@
} else if (cp_opt(cp, '+')) {
cp_expr_unary(cp, k); /* Nothing to do (well, integer promotion). */
} else if (cp_opt(cp, '-')) {
- cp_expr_unary(cp, k); k->i32 = -k->i32;
+ cp_expr_unary(cp, k); k->i32 = (int32_t)(~(uint32_t)k->i32+1);
} else if (cp_opt(cp, '~')) {
cp_expr_unary(cp, k); k->i32 = ~k->i32;
} else if (cp_opt(cp, '!')) {
diff -Nru luajit-2.1.20220411/src/lj_crecord.c luajit-2.1.20230119/src/lj_crecord.c
--- luajit-2.1.20220411/src/lj_crecord.c 2022-04-05 12:12:47.000000000 +0000
+++ luajit-2.1.20230119/src/lj_crecord.c 2023-01-02 04:12:33.000000000 +0000
@@ -1504,9 +1504,13 @@
if (ctype_isenum(ct->info)) ct = ctype_child(cts, ct);
goto ok;
} else if (ctype_isfunc(ct->info)) {
+ CTypeID id0 = i ? ctype_typeid(cts, s[0]) : 0;
tr = emitir(IRT(IR_FLOAD, IRT_PTR), tr, IRFL_CDATA_PTR);
ct = ctype_get(cts,
lj_ctype_intern(cts, CTINFO(CT_PTR, CTALIGN_PTR|id), CTSIZE_PTR));
+ if (i) {
+ s[0] = ctype_get(cts, id0); /* cts->tab may have been reallocated. */
+ }
goto ok;
} else {
tr = emitir(IRT(IR_ADD, IRT_PTR), tr, lj_ir_kintp(J, sizeof(GCcdata)));
@@ -1875,7 +1879,8 @@
} else {
n = id ? 16 : 8;
}
- if (n < 0) { n = -n; sf |= STRFMT_F_UPPER; }
+ if (n < 0) { n = (int32_t)(~n+1u); sf |= STRFMT_F_UPPER; }
+ if ((uint32_t)n > 254) n = 254;
sf |= ((SFormat)((n+1)&255) << STRFMT_SH_PREC);
if (id) {
tr = crec_ct_tv(J, ctype_get(cts, id), 0, J->base[0], &rd->argv[0]);
diff -Nru luajit-2.1.20220411/src/lj_ctype.c luajit-2.1.20230119/src/lj_ctype.c
--- luajit-2.1.20220411/src/lj_ctype.c 2022-04-05 12:12:47.000000000 +0000
+++ luajit-2.1.20230119/src/lj_ctype.c 2023-01-02 04:12:33.000000000 +0000
@@ -191,8 +191,20 @@
}
id = cts->top;
if (LJ_UNLIKELY(id >= cts->sizetab)) {
+#ifdef LUAJIT_CTYPE_CHECK_ANCHOR
+ CType *ct;
+#endif
if (id >= CTID_MAX) lj_err_msg(cts->L, LJ_ERR_TABOV);
+#ifdef LUAJIT_CTYPE_CHECK_ANCHOR
+ ct = lj_mem_newvec(cts->L, id+1, CType);
+ memcpy(ct, cts->tab, id*sizeof(CType));
+ memset(cts->tab, 0, id*sizeof(CType));
+ lj_mem_freevec(cts->g, cts->tab, cts->sizetab, CType);
+ cts->tab = ct;
+ cts->sizetab = id+1;
+#else
lj_mem_growvec(cts->L, cts->tab, cts->sizetab, CTID_MAX, CType);
+#endif
}
cts->top = id+1;
cts->tab[id].info = info;
@@ -333,6 +345,14 @@
return qual;
}
+/* Ditto, but follow a reference. */
+CTInfo lj_ctype_info_raw(CTState *cts, CTypeID id, CTSize *szp)
+{
+ CType *ct = ctype_get(cts, id);
+ if (ctype_isref(ct->info)) id = ctype_cid(ct->info);
+ return lj_ctype_info(cts, id, szp);
+}
+
/* Get ctype metamethod. */
cTValue *lj_ctype_meta(CTState *cts, CTypeID id, MMS mm)
{
@@ -562,7 +582,7 @@
if (isunsigned) {
*--p = 'U';
} else if ((int64_t)n < 0) {
- n = (uint64_t)-(int64_t)n;
+ n = ~n+1u;
sign = 1;
}
do { *--p = (char)('0' + n % 10); } while (n /= 10);
diff -Nru luajit-2.1.20220411/src/lj_ctype.h luajit-2.1.20230119/src/lj_ctype.h
--- luajit-2.1.20220411/src/lj_ctype.h 2022-04-05 12:12:47.000000000 +0000
+++ luajit-2.1.20230119/src/lj_ctype.h 2023-01-02 04:12:33.000000000 +0000
@@ -468,6 +468,7 @@
LJ_FUNC CTSize lj_ctype_size(CTState *cts, CTypeID id);
LJ_FUNC CTSize lj_ctype_vlsize(CTState *cts, CType *ct, CTSize nelem);
LJ_FUNC CTInfo lj_ctype_info(CTState *cts, CTypeID id, CTSize *szp);
+LJ_FUNC CTInfo lj_ctype_info_raw(CTState *cts, CTypeID id, CTSize *szp);
LJ_FUNC cTValue *lj_ctype_meta(CTState *cts, CTypeID id, MMS mm);
LJ_FUNC GCstr *lj_ctype_repr(lua_State *L, CTypeID id, GCstr *name);
LJ_FUNC GCstr *lj_ctype_repr_int64(lua_State *L, uint64_t n, int isunsigned);
diff -Nru luajit-2.1.20220411/src/lj_debug.c luajit-2.1.20230119/src/lj_debug.c
--- luajit-2.1.20220411/src/lj_debug.c 2022-04-05 12:12:47.000000000 +0000
+++ luajit-2.1.20230119/src/lj_debug.c 2023-01-02 04:12:33.000000000 +0000
@@ -101,9 +101,12 @@
pos = proto_bcpos(pt, ins) - 1;
#if LJ_HASJIT
if (pos > pt->sizebc) { /* Undo the effects of lj_trace_exit for JLOOP. */
- GCtrace *T = (GCtrace *)((char *)(ins-1) - offsetof(GCtrace, startins));
- lj_assertL(bc_isret(bc_op(ins[-1])), "return bytecode expected");
- pos = proto_bcpos(pt, mref(T->startpc, const BCIns));
+ if (bc_isret(bc_op(ins[-1]))) {
+ GCtrace *T = (GCtrace *)((char *)(ins-1) - offsetof(GCtrace, startins));
+ pos = proto_bcpos(pt, mref(T->startpc, const BCIns));
+ } else {
+ pos = NO_BCPOS; /* Punt in case of stack overflow for stitched trace. */
+ }
}
#endif
return pos;
diff -Nru luajit-2.1.20220411/src/lj_dispatch.h luajit-2.1.20230119/src/lj_dispatch.h
--- luajit-2.1.20220411/src/lj_dispatch.h 2022-04-05 12:12:47.000000000 +0000
+++ luajit-2.1.20230119/src/lj_dispatch.h 2023-01-02 04:12:33.000000000 +0000
@@ -89,7 +89,7 @@
typedef struct GG_State {
lua_State L; /* Main thread. */
global_State g; /* Global state. */
-#if LJ_TARGET_ARM
+#if LJ_TARGET_ARM && !LJ_TARGET_NX
/* Make g reachable via K12 encoded DISPATCH-relative addressing. */
uint8_t align1[(16-sizeof(global_State))&15];
#endif
@@ -99,7 +99,7 @@
#if LJ_HASJIT
jit_State J; /* JIT state. */
HotCount hotcount[HOTCOUNT_SIZE]; /* Hot counters. */
-#if LJ_TARGET_ARM
+#if LJ_TARGET_ARM && !LJ_TARGET_NX
/* Ditto for J. */
uint8_t align2[(16-sizeof(jit_State)-sizeof(HotCount)*HOTCOUNT_SIZE)&15];
#endif
diff -Nru luajit-2.1.20220411/src/lj_emit_arm64.h luajit-2.1.20230119/src/lj_emit_arm64.h
--- luajit-2.1.20220411/src/lj_emit_arm64.h 2022-04-05 12:12:47.000000000 +0000
+++ luajit-2.1.20230119/src/lj_emit_arm64.h 2023-01-02 04:12:33.000000000 +0000
@@ -27,8 +27,8 @@
/* Encode constant in K12 format for data processing instructions. */
static uint32_t emit_isk12(int64_t n)
{
- uint64_t k = (n < 0) ? -n : n;
- uint32_t m = (n < 0) ? 0x40000000 : 0;
+ uint64_t k = n < 0 ? ~(uint64_t)n+1u : (uint64_t)n;
+ uint32_t m = n < 0 ? 0x40000000 : 0;
if (k < 0x1000) {
return A64I_K12|m|A64F_U12(k);
} else if ((k & 0xfff000) == k) {
@@ -177,7 +177,7 @@
emit_dm(as, A64I_MOVx, rd, r);
return 1;
} else {
- uint32_t k12 = emit_isk12(delta < 0 ? -delta : delta);
+ uint32_t k12 = emit_isk12(delta < 0 ? (int64_t)(~(uint64_t)delta+1u) : delta);
if (k12) {
emit_dn(as, (delta < 0 ? A64I_SUBx : A64I_ADDx)^k12, rd, r);
return 1;
@@ -417,7 +417,8 @@
{
if (ofs)
emit_opk(as, ofs < 0 ? A64I_SUBx : A64I_ADDx, r, r,
- ofs < 0 ? -ofs : ofs, rset_exclude(RSET_GPR, r));
+ ofs < 0 ? (int32_t)(~(uint32_t)ofs+1u) : ofs,
+ rset_exclude(RSET_GPR, r));
}
#define emit_spsub(as, ofs) emit_addptr(as, RID_SP, -(ofs))
diff -Nru luajit-2.1.20220411/src/lj_emit_arm.h luajit-2.1.20230119/src/lj_emit_arm.h
--- luajit-2.1.20220411/src/lj_emit_arm.h 2022-04-05 12:12:47.000000000 +0000
+++ luajit-2.1.20230119/src/lj_emit_arm.h 2023-01-02 04:12:33.000000000 +0000
@@ -157,7 +157,7 @@
if (other) {
int32_t delta = i - other;
uint32_t sh, inv = 0, k2, k;
- if (delta < 0) { delta = -delta; inv = ARMI_ADD^ARMI_SUB; }
+ if (delta < 0) { delta = (int32_t)(~(uint32_t)delta+1u); inv = ARMI_ADD^ARMI_SUB; }
sh = lj_ffs(delta) & ~1;
k2 = emit_isk12(0, delta & (255 << sh));
k = emit_isk12(0, delta & ~(255 << sh));
diff -Nru luajit-2.1.20220411/src/lj_err.c luajit-2.1.20230119/src/lj_err.c
--- luajit-2.1.20220411/src/lj_err.c 2022-04-05 12:12:47.000000000 +0000
+++ luajit-2.1.20230119/src/lj_err.c 2023-01-02 04:12:33.000000000 +0000
@@ -781,6 +781,7 @@
{
if (L->status == LUA_ERRERR+1) /* Don't touch the stack during lua_open. */
lj_vm_unwind_c(L->cframe, LUA_ERRMEM);
+ if (curr_funcisL(L)) L->top = curr_topL(L);
setstrV(L, L->top++, lj_err_str(L, LJ_ERR_ERRMEM));
lj_err_throw(L, LUA_ERRMEM);
}
diff -Nru luajit-2.1.20220411/src/lj_ffrecord.c luajit-2.1.20230119/src/lj_ffrecord.c
--- luajit-2.1.20220411/src/lj_ffrecord.c 2022-04-05 12:12:47.000000000 +0000
+++ luajit-2.1.20230119/src/lj_ffrecord.c 2023-01-02 04:12:33.000000000 +0000
@@ -1118,7 +1118,7 @@
}
/* Emit typecheck for string buffer. */
-static TRef recff_sbufx_check(jit_State *J, RecordFFData *rd, int arg)
+static TRef recff_sbufx_check(jit_State *J, RecordFFData *rd, ptrdiff_t arg)
{
TRef trtype, ud = J->base[arg];
if (!tvisbuf(&rd->argv[arg])) lj_trace_err(J, LJ_TRERR_BADTYPE);
@@ -1136,7 +1136,7 @@
}
/* Check for integer in range for the buffer API. */
-static TRef recff_sbufx_checkint(jit_State *J, RecordFFData *rd, int arg)
+static TRef recff_sbufx_checkint(jit_State *J, RecordFFData *rd, ptrdiff_t arg)
{
TRef tr = J->base[arg];
TRef trlim = lj_ir_kint(J, LJ_MAX_BUF);
diff -Nru luajit-2.1.20220411/src/lj_gc.c luajit-2.1.20230119/src/lj_gc.c
--- luajit-2.1.20220411/src/lj_gc.c 2022-04-05 12:12:47.000000000 +0000
+++ luajit-2.1.20230119/src/lj_gc.c 2023-01-02 04:12:33.000000000 +0000
@@ -700,9 +700,12 @@
}
case GCSfinalize:
if (gcref(g->gc.mmudata) != NULL) {
+ GCSize old = g->gc.total;
if (tvref(g->jit_base)) /* Don't call finalizers on trace. */
return LJ_MAX_MEM;
gc_finalize(L); /* Finalize one userdata object. */
+ if (old >= g->gc.total && g->gc.estimate > old - g->gc.total)
+ g->gc.estimate -= old - g->gc.total;
if (g->gc.estimate > GCFINALIZECOST)
g->gc.estimate -= GCFINALIZECOST;
return GCFINALIZECOST;
diff -Nru luajit-2.1.20220411/src/lj_jit.h luajit-2.1.20230119/src/lj_jit.h
--- luajit-2.1.20220411/src/lj_jit.h 2022-04-05 12:12:47.000000000 +0000
+++ luajit-2.1.20230119/src/lj_jit.h 2023-01-02 04:12:33.000000000 +0000
@@ -7,6 +7,7 @@
#define _LJ_JIT_H
#include "lj_obj.h"
+#if LJ_HASJIT
#include "lj_ir.h"
/* -- JIT engine flags ---------------------------------------------------- */
@@ -87,10 +88,11 @@
#define JIT_F_OPT_ABC (JIT_F_OPT << 7)
#define JIT_F_OPT_SINK (JIT_F_OPT << 8)
#define JIT_F_OPT_FUSE (JIT_F_OPT << 9)
+#define JIT_F_OPT_FMA (JIT_F_OPT << 10)
/* Optimizations names for -O. Must match the order above. */
#define JIT_F_OPTSTRING \
- "\4fold\3cse\3dce\3fwd\3dse\6narrow\4loop\3abc\4sink\4fuse"
+ "\4fold\3cse\3dce\3fwd\3dse\6narrow\4loop\3abc\4sink\4fuse\3fma"
/* Optimization levels set a fixed combination of flags. */
#define JIT_F_OPT_0 0
@@ -99,6 +101,7 @@
#define JIT_F_OPT_3 (JIT_F_OPT_2|\
JIT_F_OPT_FWD|JIT_F_OPT_DSE|JIT_F_OPT_ABC|JIT_F_OPT_SINK|JIT_F_OPT_FUSE)
#define JIT_F_OPT_DEFAULT JIT_F_OPT_3
+/* Note: FMA is not set by default. */
/* -- JIT engine parameters ----------------------------------------------- */
@@ -372,6 +375,7 @@
#endif
LJ_K64__MAX,
};
+#define LJ_K64__USED (LJ_TARGET_X86ORX64 || LJ_TARGET_MIPS)
enum {
#if LJ_TARGET_X86ORX64
@@ -390,6 +394,7 @@
#endif
LJ_K32__MAX
};
+#define LJ_K32__USED (LJ_TARGET_X86ORX64 || LJ_TARGET_PPC || LJ_TARGET_MIPS)
/* Get 16 byte aligned pointer to SIMD constant. */
#define LJ_KSIMD(J, n) \
@@ -444,9 +449,13 @@
int32_t framedepth; /* Current frame depth. */
int32_t retdepth; /* Return frame depth (count of RETF). */
+#if LJ_K32__USED
uint32_t k32[LJ_K32__MAX]; /* Common 4 byte constants used by backends. */
+#endif
TValue ksimd[LJ_KSIMD__MAX*2+1]; /* 16 byte aligned SIMD constants. */
+#if LJ_K64__USED
TValue k64[LJ_K64__MAX]; /* Common 8 byte constants. */
+#endif
IRIns *irbuf; /* Temp. IR instruction buffer. Biased with REF_BIAS. */
IRRef irtoplim; /* Upper limit of instuction buffer (biased). */
@@ -519,5 +528,6 @@
#else
#define lj_assertJ(c, ...) ((void)J)
#endif
+#endif
#endif
diff -Nru luajit-2.1.20220411/src/lj_obj.h luajit-2.1.20230119/src/lj_obj.h
--- luajit-2.1.20220411/src/lj_obj.h 2022-04-05 12:12:47.000000000 +0000
+++ luajit-2.1.20230119/src/lj_obj.h 2023-01-02 04:12:33.000000000 +0000
@@ -413,7 +413,7 @@
#define PROTO_UV_IMMUTABLE 0x4000 /* Immutable upvalue. */
#define proto_kgc(pt, idx) \
- check_exp((uintptr_t)(intptr_t)(idx) >= (uintptr_t)-(intptr_t)(pt)->sizekgc, \
+ check_exp((uintptr_t)(intptr_t)(idx) >= ~(uintptr_t)(pt)->sizekgc+1u, \
gcref(mref((pt)->k, GCRef)[(idx)]))
#define proto_knumtv(pt, idx) \
check_exp((uintptr_t)(idx) < (pt)->sizekn, &mref((pt)->k, TValue)[(idx)])
@@ -511,7 +511,7 @@
} GCtab;
#define sizetabcolo(n) ((n)*sizeof(TValue) + sizeof(GCtab))
-#define tabref(r) (&gcref((r))->tab)
+#define tabref(r) ((GCtab *)gcref((r)))
#define noderef(r) (mref((r), Node))
#define nextnode(n) (mref((n)->next, Node))
#if LJ_GC64
diff -Nru luajit-2.1.20220411/src/lj_opt_fold.c luajit-2.1.20230119/src/lj_opt_fold.c
--- luajit-2.1.20220411/src/lj_opt_fold.c 2022-04-05 12:12:47.000000000 +0000
+++ luajit-2.1.20230119/src/lj_opt_fold.c 2023-01-02 04:12:33.000000000 +0000
@@ -267,7 +267,7 @@
case IR_SUB: k1 -= k2; break;
case IR_MUL: k1 *= k2; break;
case IR_MOD: k1 = lj_vm_modi(k1, k2); break;
- case IR_NEG: k1 = -k1; break;
+ case IR_NEG: k1 = (int32_t)(~(uint32_t)k1+1u); break;
case IR_BAND: k1 &= k2; break;
case IR_BOR: k1 |= k2; break;
case IR_BXOR: k1 ^= k2; break;
@@ -1366,7 +1366,7 @@
if (fright->i == 0) /* i - 0 ==> i */
return LEFTFOLD;
fins->o = IR_ADD; /* i - k ==> i + (-k) */
- fins->op2 = (IRRef1)lj_ir_kint(J, -fright->i); /* Overflow for -2^31 ok. */
+ fins->op2 = (IRRef1)lj_ir_kint(J, (int32_t)(~(uint32_t)fright->i+1u)); /* Overflow for -2^31 ok. */
return RETRYFOLD;
}
@@ -1397,7 +1397,7 @@
if (k == 0) /* i - 0 ==> i */
return LEFTFOLD;
fins->o = IR_ADD; /* i - k ==> i + (-k) */
- fins->op2 = (IRRef1)lj_ir_kint64(J, (uint64_t)-(int64_t)k);
+ fins->op2 = (IRRef1)lj_ir_kint64(J, ~k+1u);
return RETRYFOLD;
}
diff -Nru luajit-2.1.20220411/src/lj_opt_mem.c luajit-2.1.20230119/src/lj_opt_mem.c
--- luajit-2.1.20220411/src/lj_opt_mem.c 2022-04-05 12:12:47.000000000 +0000
+++ luajit-2.1.20230119/src/lj_opt_mem.c 2023-01-02 04:12:33.000000000 +0000
@@ -434,7 +434,7 @@
fins->op2 = aref->op2; /* Set ALEN hint. */
}
goto doemit; /* Conflicting store, possibly giving a hint. */
- } else if (aa_table(J, tab, fref->op1) == ALIAS_NO) {
+ } else if (aa_table(J, tab, fref->op1) != ALIAS_NO) {
goto doemit; /* Conflicting store. */
}
sref = store->prev;
diff -Nru luajit-2.1.20220411/src/lj_parse.c luajit-2.1.20230119/src/lj_parse.c
--- luajit-2.1.20220411/src/lj_parse.c 2022-04-05 12:12:47.000000000 +0000
+++ luajit-2.1.20230119/src/lj_parse.c 2023-01-02 04:12:33.000000000 +0000
@@ -964,22 +964,22 @@
#if LJ_HASFFI
if (e->k == VKCDATA) { /* Fold in-place since cdata is not interned. */
GCcdata *cd = cdataV(&e->u.nval);
- int64_t *p = (int64_t *)cdataptr(cd);
+ uint64_t *p = (uint64_t *)cdataptr(cd);
if (cd->ctypeid == CTID_COMPLEX_DOUBLE)
- p[1] ^= (int64_t)U64x(80000000,00000000);
+ p[1] ^= U64x(80000000,00000000);
else
- *p = -*p;
+ *p = ~*p+1u;
return;
} else
#endif
if (expr_isnumk(e) && !expr_numiszero(e)) { /* Avoid folding to -0. */
TValue *o = expr_numtv(e);
if (tvisint(o)) {
- int32_t k = intV(o);
- if (k == -k)
+ int32_t k = intV(o), negk = (int32_t)(~(uint32_t)k+1u);
+ if (k == negk)
setnumV(o, -(lua_Number)k);
else
- setintV(o, -k);
+ setintV(o, negk);
return;
} else {
o->u64 ^= U64x(80000000,00000000);
diff -Nru luajit-2.1.20220411/src/lj_prng.c luajit-2.1.20230119/src/lj_prng.c
--- luajit-2.1.20220411/src/lj_prng.c 2022-04-05 12:12:47.000000000 +0000
+++ luajit-2.1.20230119/src/lj_prng.c 2023-01-02 04:12:33.000000000 +0000
@@ -83,10 +83,14 @@
extern int sys_get_random_number(void *buf, uint64_t len);
-#elif LJ_TARGET_PS4 || LJ_TARGET_PSVITA
+#elif LJ_TARGET_PS4 || LJ_TARGET_PS5 || LJ_TARGET_PSVITA
extern int sceRandomGetRandomNumber(void *buf, size_t len);
+#elif LJ_TARGET_NX
+
+#include
+
#elif LJ_TARGET_WINDOWS || LJ_TARGET_XBOXONE
#define WIN32_LEAN_AND_MEAN
@@ -121,7 +125,7 @@
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
#define LJ_TARGET_HAS_GETENTROPY 1
#endif
-#elif (LJ_TARGET_BSD && !defined(__NetBSD__)) || LJ_TARGET_SOLARIS || LJ_TARGET_CYGWIN
+#elif (LJ_TARGET_BSD && !defined(__NetBSD__)) || LJ_TARGET_SOLARIS || LJ_TARGET_CYGWIN || LJ_TARGET_QNX
#define LJ_TARGET_HAS_GETENTROPY 1
#endif
@@ -171,11 +175,16 @@
if (sys_get_random_number(rs->u, sizeof(rs->u)) == 0)
goto ok;
-#elif LJ_TARGET_PS4 || LJ_TARGET_PSVITA
+#elif LJ_TARGET_PS4 || LJ_TARGET_PS5 || LJ_TARGET_PSVITA
if (sceRandomGetRandomNumber(rs->u, sizeof(rs->u)) == 0)
goto ok;
+#elif LJ_TARGET_NX
+
+ if (getentropy(rs->u, sizeof(rs->u)) == 0)
+ goto ok;
+
#elif LJ_TARGET_UWP || LJ_TARGET_XBOXONE
if (BCryptGenRandom(NULL, (PUCHAR)(rs->u), (ULONG)sizeof(rs->u),
diff -Nru luajit-2.1.20220411/src/lj_profile.c luajit-2.1.20230119/src/lj_profile.c
--- luajit-2.1.20220411/src/lj_profile.c 2022-04-05 12:12:47.000000000 +0000
+++ luajit-2.1.20230119/src/lj_profile.c 2023-01-02 04:12:33.000000000 +0000
@@ -185,7 +185,11 @@
tm.it_value.tv_sec = tm.it_interval.tv_sec = interval / 1000;
tm.it_value.tv_usec = tm.it_interval.tv_usec = (interval % 1000) * 1000;
setitimer(ITIMER_PROF, &tm, NULL);
+#if LJ_TARGET_QNX
+ sa.sa_flags = 0;
+#else
sa.sa_flags = SA_RESTART;
+#endif
sa.sa_handler = profile_signal;
sigemptyset(&sa.sa_mask);
sigaction(SIGPROF, &sa, &ps->oldsa);
diff -Nru luajit-2.1.20220411/src/lj_record.c luajit-2.1.20230119/src/lj_record.c
--- luajit-2.1.20220411/src/lj_record.c 2022-04-05 12:12:47.000000000 +0000
+++ luajit-2.1.20230119/src/lj_record.c 2023-01-02 04:12:33.000000000 +0000
@@ -664,12 +664,17 @@
RecordIndex ix;
/* Since ITERN is recorded at the start, we need our own loop detection. */
if (J->pc == J->startpc &&
- (J->cur.nins > REF_FIRST+1 ||
- (J->cur.nins == REF_FIRST+1 && J->cur.ir[REF_FIRST].o != IR_PROF)) &&
J->framedepth + J->retdepth == 0 && J->parent == 0 && J->exitno == 0) {
- J->instunroll = 0; /* Cannot continue unrolling across an ITERN. */
- lj_record_stop(J, LJ_TRLINK_LOOP, J->cur.traceno); /* Looping trace. */
- return LOOPEV_ENTER;
+ IRRef ref = REF_FIRST + LJ_HASPROFILE;
+#ifdef LUAJIT_ENABLE_CHECKHOOK
+ ref += 3;
+#endif
+ if (J->cur.nins > ref ||
+ (LJ_HASPROFILE && J->cur.nins == ref && J->cur.ir[ref-1].o != IR_PROF)) {
+ J->instunroll = 0; /* Cannot continue unrolling across an ITERN. */
+ lj_record_stop(J, LJ_TRLINK_LOOP, J->cur.traceno); /* Looping trace. */
+ return LOOPEV_ENTER;
+ }
}
J->maxslot = ra;
lj_snap_add(J); /* Required to make JLOOP the first ins in a side-trace. */
@@ -1448,16 +1453,16 @@
key = emitir(IRTN(IR_CONV), key, IRCONV_NUM_INT);
if (tref_isk(key)) {
/* Optimize lookup of constant hash keys. */
- MSize hslot = (MSize)((char *)ix->oldv - (char *)&noderef(t->node)[0].val);
- if (t->hmask > 0 && hslot <= t->hmask*(MSize)sizeof(Node) &&
- hslot <= 65535*(MSize)sizeof(Node)) {
+ GCSize hslot = (GCSize)((char *)ix->oldv-(char *)&noderef(t->node)[0].val);
+ if (hslot <= t->hmask*(GCSize)sizeof(Node) &&
+ hslot <= 65535*(GCSize)sizeof(Node)) {
TRef node, kslot, hm;
*rbref = J->cur.nins; /* Mark possible rollback point. */
*rbguard = J->guardemit;
hm = emitir(IRTI(IR_FLOAD), ix->tab, IRFL_TAB_HMASK);
emitir(IRTGI(IR_EQ), hm, lj_ir_kint(J, (int32_t)t->hmask));
node = emitir(IRT(IR_FLOAD, IRT_PGC), ix->tab, IRFL_TAB_NODE);
- kslot = lj_ir_kslot(J, key, hslot / sizeof(Node));
+ kslot = lj_ir_kslot(J, key, (IRRef)(hslot / sizeof(Node)));
return emitir(IRTG(IR_HREFK, IRT_PGC), node, kslot);
}
}
@@ -1940,6 +1945,8 @@
} else if (dst + nresults > J->maxslot) {
J->maxslot = dst + (BCReg)nresults;
}
+ if (J->baseslot + J->maxslot >= LJ_MAX_JSLOTS)
+ lj_trace_err(J, LJ_TRERR_STACKOV);
for (i = 0; i < nresults; i++)
J->base[dst+i] = i < nvararg ? getslot(J, i - nvararg - 1 - LJ_FR2) : TREF_NIL;
} else { /* Unknown number of varargs passed to trace. */
@@ -1956,10 +1963,10 @@
emitir(IRTGI(IR_EQ), fr,
lj_ir_kint(J, (int32_t)frame_ftsz(J->L->base-1)));
vbase = emitir(IRT(IR_SUB, IRT_IGC), REF_BASE, fr);
- vbase = emitir(IRT(IR_ADD, IRT_PGC), vbase, lj_ir_kint(J, frofs-8));
+ vbase = emitir(IRT(IR_ADD, IRT_PGC), vbase, lj_ir_kint(J, frofs-8*(1+LJ_FR2)));
for (i = 0; i < nload; i++) {
IRType t = itype2irt(&J->L->base[i-1-LJ_FR2-nvararg]);
- J->base[dst+i] = lj_record_vload(J, vbase, i, t);
+ J->base[dst+i] = lj_record_vload(J, vbase, (MSize)i, t);
}
} else {
emitir(IRTGI(IR_LE), fr, lj_ir_kint(J, frofs));
@@ -2017,8 +2024,6 @@
lj_trace_err_info(J, LJ_TRERR_NYIBC);
}
}
- if (J->baseslot + J->maxslot >= LJ_MAX_JSLOTS)
- lj_trace_err(J, LJ_TRERR_STACKOV);
}
/* -- Record allocations -------------------------------------------------- */
@@ -2043,7 +2048,7 @@
static TRef rec_cat(jit_State *J, BCReg baseslot, BCReg topslot)
{
TRef *top = &J->base[topslot];
- TValue savetv[5];
+ TValue savetv[5+LJ_FR2];
BCReg s;
RecordIndex ix;
lj_assertJ(baseslot < topslot, "bad CAT arg");
@@ -2233,6 +2238,7 @@
case BCMpri: setpriV(rcv, ~rc); ix.key = rc = TREF_PRI(IRT_NIL+rc); break;
case BCMnum: { cTValue *tv = proto_knumtv(J->pt, rc);
copyTV(J->L, rcv, tv); ix.key = rc = tvisint(tv) ? lj_ir_kint(J, intV(tv)) :
+ tv->u32.hi == LJ_KEYINDEX ? (lj_ir_kint(J, 0) | TREF_KEYINDEX) :
lj_ir_knumint(J, numV(tv)); } break;
case BCMstr: { GCstr *s = gco2str(proto_kgc(J->pt, ~(ptrdiff_t)rc));
setstrV(J->L, rcv, s); ix.key = rc = lj_ir_kstr(J, s); } break;
@@ -2566,7 +2572,8 @@
break;
case BC_JLOOP:
rec_loop_jit(J, rc, rec_loop(J, ra,
- !bc_isret(bc_op(traceref(J, rc)->startins))));
+ !bc_isret(bc_op(traceref(J, rc)->startins)) &&
+ bc_op(traceref(J, rc)->startins) != BC_ITERN));
break;
case BC_IFORL:
@@ -2659,6 +2666,8 @@
J->bc_min = pc;
break;
case BC_ITERL:
+ if (bc_op(pc[-1]) == BC_JLOOP)
+ lj_trace_err(J, LJ_TRERR_LINNER);
lj_assertJ(bc_op(pc[-1]) == BC_ITERC, "no ITERC before ITERL");
J->maxslot = ra + bc_b(pc[-1]) - 1;
J->bc_extent = (MSize)(-bc_j(ins))*sizeof(BCIns);
diff -Nru luajit-2.1.20220411/src/lj_str.c luajit-2.1.20230119/src/lj_str.c
--- luajit-2.1.20220411/src/lj_str.c 2022-04-05 12:12:47.000000000 +0000
+++ luajit-2.1.20230119/src/lj_str.c 2023-01-02 04:12:33.000000000 +0000
@@ -318,9 +318,7 @@
s->sid = hash;
#else
#ifndef STRID_RESEED_INTERVAL
- /* s->sid = g->str.id++; */
- /* if use g->str.id++ as sid, the order of the tab will be indeterminate. */
- s->sid = hash;
+ s->sid = g->str.id++;
#elif STRID_RESEED_INTERVAL
if (!g->str.idreseed--) {
uint64_t r = lj_prng_u64(&g->prng);
diff -Nru luajit-2.1.20220411/src/lj_strfmt.c luajit-2.1.20230119/src/lj_strfmt.c
--- luajit-2.1.20220411/src/lj_strfmt.c 2022-04-05 12:12:47.000000000 +0000
+++ luajit-2.1.20230119/src/lj_strfmt.c 2023-01-02 04:12:33.000000000 +0000
@@ -102,7 +102,7 @@
char * LJ_FASTCALL lj_strfmt_wint(char *p, int32_t k)
{
uint32_t u = (uint32_t)k;
- if (k < 0) { u = (uint32_t)-k; *p++ = '-'; }
+ if (k < 0) { u = ~u+1u; *p++ = '-'; }
if (u < 10000) {
if (u < 10) goto dig1;
if (u < 100) goto dig2;
@@ -287,7 +287,7 @@
/* Figure out signed prefixes. */
if (STRFMT_TYPE(sf) == STRFMT_INT) {
if ((int64_t)k < 0) {
- k = (uint64_t)-(int64_t)k;
+ k = ~k+1u;
prefix = 256 + '-';
} else if ((sf & STRFMT_F_PLUS)) {
prefix = 256 + '+';
diff -Nru luajit-2.1.20220411/src/lj_strscan.c luajit-2.1.20230119/src/lj_strscan.c
--- luajit-2.1.20220411/src/lj_strscan.c 2022-04-05 12:12:47.000000000 +0000
+++ luajit-2.1.20230119/src/lj_strscan.c 2023-01-02 04:12:33.000000000 +0000
@@ -124,19 +124,19 @@
case STRSCAN_INT:
if (!(opt & STRSCAN_OPT_TONUM) && x < 0x80000000u+neg &&
!(x == 0 && neg)) {
- o->i = neg ? -(int32_t)x : (int32_t)x;
+ o->i = neg ? (int32_t)(~x+1u) : (int32_t)x;
return STRSCAN_INT; /* Fast path for 32 bit integers. */
}
if (!(opt & STRSCAN_OPT_C)) { fmt = STRSCAN_NUM; break; }
/* fallthrough */
case STRSCAN_U32:
if (dig > 8) return STRSCAN_ERROR;
- o->i = neg ? -(int32_t)x : (int32_t)x;
+ o->i = neg ? (int32_t)(~x+1u) : (int32_t)x;
return STRSCAN_U32;
case STRSCAN_I64:
case STRSCAN_U64:
if (dig > 16) return STRSCAN_ERROR;
- o->u64 = neg ? (uint64_t)-(int64_t)x : x;
+ o->u64 = neg ? ~x+1u : x;
return fmt;
default:
break;
@@ -168,12 +168,12 @@
/* fallthrough */
case STRSCAN_U32:
if ((x >> 32)) return STRSCAN_ERROR;
- o->i = neg ? -(int32_t)x : (int32_t)x;
+ o->i = neg ? (int32_t)(~(uint32_t)x+1u) : (int32_t)x;
break;
default:
case STRSCAN_I64:
case STRSCAN_U64:
- o->u64 = neg ? (uint64_t)-(int64_t)x : x;
+ o->u64 = neg ? ~x+1u : x;
break;
}
return fmt;
@@ -229,18 +229,18 @@
switch (fmt) {
case STRSCAN_INT:
if (!(opt & STRSCAN_OPT_TONUM) && x < 0x80000000u+neg) {
- o->i = neg ? -(int32_t)x : (int32_t)x;
+ o->i = neg ? (int32_t)(~x+1u) : (int32_t)x;
return STRSCAN_INT; /* Fast path for 32 bit integers. */
}
if (!(opt & STRSCAN_OPT_C)) { fmt = STRSCAN_NUM; goto plainnumber; }
/* fallthrough */
case STRSCAN_U32:
if ((x >> 32) != 0) return STRSCAN_ERROR;
- o->i = neg ? -(int32_t)x : (int32_t)x;
+ o->i = neg ? (int32_t)(~x+1u) : (int32_t)x;
return STRSCAN_U32;
case STRSCAN_I64:
case STRSCAN_U64:
- o->u64 = neg ? (uint64_t)-(int64_t)x : x;
+ o->u64 = neg ? ~x+1u : x;
return fmt;
default:
plainnumber: /* Fast path for plain numbers < 2^63. */
@@ -348,18 +348,18 @@
switch (fmt) {
case STRSCAN_INT:
if (!(opt & STRSCAN_OPT_TONUM) && x < 0x80000000u+neg) {
- o->i = neg ? -(int32_t)x : (int32_t)x;
+ o->i = neg ? (int32_t)(~x+1u) : (int32_t)x;
return STRSCAN_INT; /* Fast path for 32 bit integers. */
}
if (!(opt & STRSCAN_OPT_C)) { fmt = STRSCAN_NUM; break; }
/* fallthrough */
case STRSCAN_U32:
if (dig > 32) return STRSCAN_ERROR;
- o->i = neg ? -(int32_t)x : (int32_t)x;
+ o->i = neg ? (int32_t)(~x+1u) : (int32_t)x;
return STRSCAN_U32;
case STRSCAN_I64:
case STRSCAN_U64:
- o->u64 = neg ? (uint64_t)-(int64_t)x : x;
+ o->u64 = neg ? ~x+1u : x;
return fmt;
default:
break;
@@ -468,7 +468,7 @@
if (xx >= STRSCAN_MAXEXP) return STRSCAN_ERROR;
p++;
}
- ex += negx ? -(int32_t)xx : (int32_t)xx;
+ ex += negx ? (int32_t)(~xx+1u) : (int32_t)xx;
}
/* Parse suffix. */
@@ -507,7 +507,7 @@
o->n = -0.0;
return STRSCAN_NUM;
} else {
- o->i = neg ? -(int32_t)x : (int32_t)x;
+ o->i = neg ? (int32_t)(~x+1u) : (int32_t)x;
return STRSCAN_INT;
}
}
diff -Nru luajit-2.1.20220411/src/lj_vmmath.c luajit-2.1.20230119/src/lj_vmmath.c
--- luajit-2.1.20220411/src/lj_vmmath.c 2022-04-05 12:12:47.000000000 +0000
+++ luajit-2.1.20230119/src/lj_vmmath.c 2023-01-02 04:12:33.000000000 +0000
@@ -36,6 +36,17 @@
/* -- Helper functions ---------------------------------------------------- */
+/* Required to prevent the C compiler from applying FMA optimizations.
+**
+** Yes, there's -ffp-contract and the FP_CONTRACT pragma ... in theory.
+** But the current state of C compilers is a mess in this regard.
+** Also, this function is not performance sensitive at all.
+*/
+LJ_NOINLINE static double lj_vm_floormul(double x, double y)
+{
+ return lj_vm_floor(x / y) * y;
+}
+
double lj_vm_foldarith(double x, double y, int op)
{
switch (op) {
@@ -43,7 +54,7 @@
case IR_SUB - IR_ADD: return x-y; break;
case IR_MUL - IR_ADD: return x*y; break;
case IR_DIV - IR_ADD: return x/y; break;
- case IR_MOD - IR_ADD: return x-lj_vm_floor(x/y)*y; break;
+ case IR_MOD - IR_ADD: return x-lj_vm_floormul(x, y); break;
case IR_POW - IR_ADD: return pow(x, y); break;
case IR_NEG - IR_ADD: return -x; break;
case IR_ABS - IR_ADD: return fabs(x); break;
@@ -64,11 +75,11 @@
uint32_t y, ua, ub;
/* This must be checked before using this function. */
lj_assertX(b != 0, "modulo with zero divisor");
- ua = a < 0 ? (uint32_t)-a : (uint32_t)a;
- ub = b < 0 ? (uint32_t)-b : (uint32_t)b;
+ ua = a < 0 ? ~(uint32_t)a+1u : (uint32_t)a;
+ ub = b < 0 ? ~(uint32_t)b+1u : (uint32_t)b;
y = ua % ub;
if (y != 0 && (a^b) < 0) y = y - ub;
- if (((int32_t)y^b) < 0) y = (uint32_t)-(int32_t)y;
+ if (((int32_t)y^b) < 0) y = ~y+1u;
return (int32_t)y;
}
#endif
diff -Nru luajit-2.1.20220411/src/nxbuild.bat luajit-2.1.20230119/src/nxbuild.bat
--- luajit-2.1.20220411/src/nxbuild.bat 1970-01-01 00:00:00.000000000 +0000
+++ luajit-2.1.20230119/src/nxbuild.bat 2023-01-02 04:12:33.000000000 +0000
@@ -0,0 +1,160 @@
+@rem Script to build LuaJIT with NintendoSDK + NX Addon.
+@rem Donated to the public domain by Swyter.
+@rem
+@rem To run this script you must open a "Native Tools Command Prompt for VS".
+@rem
+@rem Either the x86 version for NX32, or x64 for the NX64 target.
+@rem This is because the pointer size of the LuaJIT host tools (buildvm.exe)
+@rem must match the cross-compiled target (32 or 64 bits).
+@rem
+@rem Then cd to this directory and run this script.
+@rem
+@rem Recommended invocation:
+@rem
+@rem nxbuild # release build, amalgamated
+@rem nxbuild debug # debug build, amalgamated
+@rem
+@rem Additional command-line options (not generally recommended):
+@rem
+@rem noamalg # (after debug) non-amalgamated build
+
+@if not defined INCLUDE goto :FAIL
+@if not defined NINTENDO_SDK_ROOT goto :FAIL
+@if not defined PLATFORM goto :FAIL
+
+@if "%platform%" == "x86" goto :DO_NX32
+@if "%platform%" == "x64" goto :DO_NX64
+
+@echo Error: Current host platform is %platform%!
+@echo.
+@goto :FAIL
+
+@setlocal
+
+:DO_NX32
+@set DASC=vm_arm.dasc
+@set DASMFLAGS= -D HFABI -D FPU
+@set DASMTARGET= -D LUAJIT_TARGET=LUAJIT_ARCH_ARM
+@set HOST_PTR_SIZE=4
+goto :BEGIN
+
+:DO_NX64
+@set DASC=vm_arm64.dasc
+@set DASMFLAGS= -D ENDIAN_LE
+@set DASMTARGET= -D LUAJIT_TARGET=LUAJIT_ARCH_ARM64
+@set HOST_PTR_SIZE=8
+
+:BEGIN
+@rem ---- Host compiler ----
+@set LJCOMPILE=cl /nologo /c /MD /O2 /W3 /wo4146 /wo4244 /D_CRT_SECURE_NO_DEPRECATE
+@set LJLINK=link /nologo
+@set LJMT=mt /nologo
+@set DASMDIR=..\dynasm
+@set DASM=%DASMDIR%\dynasm.lua
+@set ALL_LIB=lib_base.c lib_math.c lib_bit.c lib_string.c lib_table.c lib_io.c lib_os.c lib_package.c lib_debug.c lib_jit.c lib_ffi.c lib_buffer.c
+
+%LJCOMPILE% host\minilua.c
+@if errorlevel 1 goto :BAD
+%LJLINK% /out:minilua.exe minilua.obj
+@if errorlevel 1 goto :BAD
+if exist minilua.exe.manifest^
+ %LJMT% -manifest minilua.exe.manifest -outputresource:minilua.exe
+
+@rem Check that we have the right 32/64 bit host compiler to generate the right virtual machine files.
+@minilua
+@if "%ERRORLEVEL%" == "%HOST_PTR_SIZE%" goto :PASSED_PTR_CHECK
+
+@echo The pointer size of the host in bytes (%HOST_PTR_SIZE%) does not match the expected value (%errorlevel%).
+@echo Check that the script is being ran under the correct x86/x64 VS prompt.
+@goto :BAD
+
+:PASSED_PTR_CHECK
+@set DASMFLAGS=%DASMFLAGS% %DASMTARGET% -D LJ_TARGET_NX -D LUAJIT_OS=LUAJIT_OS_OTHER -D LUAJIT_DISABLE_JIT -D LUAJIT_DISABLE_FFI
+minilua %DASM% -LN %DASMFLAGS% -o host\buildvm_arch.h %DASC%
+@if errorlevel 1 goto :BAD
+%LJCOMPILE% /I "." /I %DASMDIR% %DASMTARGET% -D LJ_TARGET_NX -DLUAJIT_OS=LUAJIT_OS_OTHER -DLUAJIT_DISABLE_JIT -DLUAJIT_DISABLE_FFI host\buildvm*.c
+@if errorlevel 1 goto :BAD
+%LJLINK% /out:buildvm.exe buildvm*.obj
+@if errorlevel 1 goto :BAD
+if exist buildvm.exe.manifest^
+ %LJMT% -manifest buildvm.exe.manifest -outputresource:buildvm.exe
+
+buildvm -m elfasm -o lj_vm.s
+@if errorlevel 1 goto :BAD
+buildvm -m bcdef -o lj_bcdef.h %ALL_LIB%
+@if errorlevel 1 goto :BAD
+buildvm -m ffdef -o lj_ffdef.h %ALL_LIB%
+@if errorlevel 1 goto :BAD
+buildvm -m libdef -o lj_libdef.h %ALL_LIB%
+@if errorlevel 1 goto :BAD
+buildvm -m recdef -o lj_recdef.h %ALL_LIB%
+@if errorlevel 1 goto :BAD
+buildvm -m vmdef -o jit\vmdef.lua %ALL_LIB%
+@if errorlevel 1 goto :BAD
+buildvm -m folddef -o lj_folddef.h lj_opt_fold.c
+@if errorlevel 1 goto :BAD
+
+@rem ---- Cross compiler ----
+@if "%platform%" neq "x64" goto :NX32_CROSSBUILD
+@set LJCOMPILE="%NINTENDO_SDK_ROOT%\Compilers\NX\nx\aarch64\bin\clang" -Wall -I%NINTENDO_SDK_ROOT%\Include %DASMTARGET% -DLUAJIT_OS=LUAJIT_OS_OTHER -DLUAJIT_DISABLE_JIT -DLUAJIT_DISABLE_FFI -DLUAJIT_USE_SYSMALLOC -c
+@set LJLIB="%NINTENDO_SDK_ROOT%\Compilers\NX\nx\aarch64\bin\aarch64-nintendo-nx-elf-ar" rc
+@set TARGETLIB_SUFFIX=nx64
+
+%NINTENDO_SDK_ROOT%\Compilers\NX\nx\aarch64\bin\aarch64-nintendo-nx-elf-as -o lj_vm.o lj_vm.s
+goto :DEBUGCHECK
+
+:NX32_CROSSBUILD
+@set LJCOMPILE="%NINTENDO_SDK_ROOT%\Compilers\NX\nx\armv7l\bin\clang" -Wall -I%NINTENDO_SDK_ROOT%\Include %DASMTARGET% -DLUAJIT_OS=LUAJIT_OS_OTHER -DLUAJIT_DISABLE_JIT -DLUAJIT_DISABLE_FFI -DLUAJIT_USE_SYSMALLOC -c
+@set LJLIB="%NINTENDO_SDK_ROOT%\Compilers\NX\nx\armv7l\bin\armv7l-nintendo-nx-eabihf-ar" rc
+@set TARGETLIB_SUFFIX=nx32
+
+%NINTENDO_SDK_ROOT%\Compilers\NX\nx\armv7l\bin\armv7l-nintendo-nx-eabihf-as -o lj_vm.o lj_vm.s
+:DEBUGCHECK
+
+@if "%1" neq "debug" goto :NODEBUG
+@shift
+@set LJCOMPILE=%LJCOMPILE% -DNN_SDK_BUILD_DEBUG -g -O0
+@set TARGETLIB=libluajitD_%TARGETLIB_SUFFIX%.a
+goto :BUILD
+:NODEBUG
+@set LJCOMPILE=%LJCOMPILE% -DNN_SDK_BUILD_RELEASE -O3
+@set TARGETLIB=libluajit_%TARGETLIB_SUFFIX%.a
+:BUILD
+del %TARGETLIB%
+@set LJCOMPILE=%LJCOMPILE% -fPIC
+@if "%1" neq "noamalg" goto :AMALG
+for %%f in (lj_*.c lib_*.c) do (
+ %LJCOMPILE% %%f
+ @if errorlevel 1 goto :BAD
+)
+
+%LJLIB% %TARGETLIB% lj_*.o lib_*.o
+@if errorlevel 1 goto :BAD
+@goto :NOAMALG
+:AMALG
+%LJCOMPILE% ljamalg.c
+@if errorlevel 1 goto :BAD
+%LJLIB% %TARGETLIB% ljamalg.o lj_vm.o
+@if errorlevel 1 goto :BAD
+:NOAMALG
+
+@del *.o *.obj *.manifest minilua.exe buildvm.exe
+@echo.
+@echo === Successfully built LuaJIT for Nintendo Switch (%TARGETLIB_SUFFIX%) ===
+
+@goto :END
+:BAD
+@echo.
+@echo *******************************************************
+@echo *** Build FAILED -- Please check the error messages ***
+@echo *******************************************************
+@goto :END
+:FAIL
+@echo To run this script you must open a "Native Tools Command Prompt for VS".
+@echo.
+@echo Either the x86 version for NX32, or x64 for the NX64 target.
+@echo This is because the pointer size of the LuaJIT host tools (buildvm.exe)
+@echo must match the cross-compiled target (32 or 64 bits).
+@echo.
+@echo Keep in mind that NintendoSDK + NX Addon must be installed, too.
+:END
diff -Nru luajit-2.1.20220411/src/ps4build.bat luajit-2.1.20230119/src/ps4build.bat
--- luajit-2.1.20220411/src/ps4build.bat 2022-04-05 12:12:47.000000000 +0000
+++ luajit-2.1.20230119/src/ps4build.bat 2023-01-02 04:12:33.000000000 +0000
@@ -51,7 +51,7 @@
minilua %DASM% -LN %DASMFLAGS% -o host\buildvm_arch.h %DASC%
@if errorlevel 1 goto :BAD
-%LJCOMPILE% /I "." /I %DASMDIR% %GC64% -DLUAJIT_TARGET=LUAJIT_ARCH_X64 -DLUAJIT_OS=LUAJIT_OS_OTHER -DLUAJIT_DISABLE_JIT -DLUAJIT_DISABLE_FFI -DLUAJIT_NO_UNWIND host\buildvm*.c
+%LJCOMPILE% /I "." /I %DASMDIR% %GC64% -DLUAJIT_TARGET=LUAJIT_ARCH_X64 -DLUAJIT_OS=LUAJIT_OS_OTHER -DLUAJIT_DISABLE_JIT -DLUAJIT_DISABLE_FFI -DLUAJIT_USE_SYSMALLOC -DLUAJIT_NO_UNWIND host\buildvm*.c
@if errorlevel 1 goto :BAD
%LJLINK% /out:buildvm.exe buildvm*.obj
@if errorlevel 1 goto :BAD
@@ -78,7 +78,7 @@
@set LJLIB="%SCE_ORBIS_SDK_DIR%\host_tools\bin\orbis-ar" rcus
@set INCLUDE=""
-orbis-as -o lj_vm.o lj_vm.s
+"%SCE_ORBIS_SDK_DIR%\host_tools\bin\orbis-as" -o lj_vm.o lj_vm.s
@if "%1" neq "debug" goto :NODEBUG
@shift
diff -Nru luajit-2.1.20220411/src/ps5build.bat luajit-2.1.20230119/src/ps5build.bat
--- luajit-2.1.20220411/src/ps5build.bat 1970-01-01 00:00:00.000000000 +0000
+++ luajit-2.1.20230119/src/ps5build.bat 2023-01-02 04:12:33.000000000 +0000
@@ -0,0 +1,123 @@
+@rem Script to build LuaJIT with the PS5 SDK.
+@rem Donated to the public domain.
+@rem
+@rem Open a "Visual Studio .NET Command Prompt" (64 bit host compiler)
+@rem or "VS20xx x64 Native Tools Command Prompt".
+@rem
+@rem Then cd to this directory and run this script.
+@rem
+@rem Recommended invocation:
+@rem
+@rem ps5build release build, amalgamated, 64-bit GC
+@rem ps5build debug debug build, amalgamated, 64-bit GC
+@rem
+@rem Additional command-line options (not generally recommended):
+@rem
+@rem gc32 (before debug) 32-bit GC
+@rem noamalg (after debug) non-amalgamated build
+
+@if not defined INCLUDE goto :FAIL
+@if not defined SCE_PROSPERO_SDK_DIR goto :FAIL
+
+@setlocal
+@rem ---- Host compiler ----
+@set LJCOMPILE=cl /nologo /c /MD /O2 /W3 /D_CRT_SECURE_NO_DEPRECATE
+@set LJLINK=link /nologo
+@set LJMT=mt /nologo
+@set DASMDIR=..\dynasm
+@set DASM=%DASMDIR%\dynasm.lua
+@set ALL_LIB=lib_base.c lib_math.c lib_bit.c lib_string.c lib_table.c lib_io.c lib_os.c lib_package.c lib_debug.c lib_jit.c lib_ffi.c lib_buffer.c
+@set GC64=
+@set DASC=vm_x64.dasc
+
+@if "%1" neq "gc32" goto :NOGC32
+@shift
+@set GC64=-DLUAJIT_DISABLE_GC64
+@set DASC=vm_x86.dasc
+:NOGC32
+
+%LJCOMPILE% host\minilua.c
+@if errorlevel 1 goto :BAD
+%LJLINK% /out:minilua.exe minilua.obj
+@if errorlevel 1 goto :BAD
+if exist minilua.exe.manifest^
+ %LJMT% -manifest minilua.exe.manifest -outputresource:minilua.exe
+
+@rem Check for 64 bit host compiler.
+@minilua
+@if not errorlevel 8 goto :FAIL
+
+@set DASMFLAGS=-D P64 -D NO_UNWIND
+minilua %DASM% -LN %DASMFLAGS% -o host\buildvm_arch.h %DASC%
+@if errorlevel 1 goto :BAD
+
+%LJCOMPILE% /I "." /I %DASMDIR% %GC64% -DLUAJIT_TARGET=LUAJIT_ARCH_X64 -DLUAJIT_OS=LUAJIT_OS_OTHER -DLUAJIT_DISABLE_JIT -DLUAJIT_DISABLE_FFI -DLUAJIT_NO_UNWIND host\buildvm*.c
+@if errorlevel 1 goto :BAD
+%LJLINK% /out:buildvm.exe buildvm*.obj
+@if errorlevel 1 goto :BAD
+if exist buildvm.exe.manifest^
+ %LJMT% -manifest buildvm.exe.manifest -outputresource:buildvm.exe
+
+buildvm -m elfasm -o lj_vm.s
+@if errorlevel 1 goto :BAD
+buildvm -m bcdef -o lj_bcdef.h %ALL_LIB%
+@if errorlevel 1 goto :BAD
+buildvm -m ffdef -o lj_ffdef.h %ALL_LIB%
+@if errorlevel 1 goto :BAD
+buildvm -m libdef -o lj_libdef.h %ALL_LIB%
+@if errorlevel 1 goto :BAD
+buildvm -m recdef -o lj_recdef.h %ALL_LIB%
+@if errorlevel 1 goto :BAD
+buildvm -m vmdef -o jit\vmdef.lua %ALL_LIB%
+@if errorlevel 1 goto :BAD
+buildvm -m folddef -o lj_folddef.h lj_opt_fold.c
+@if errorlevel 1 goto :BAD
+
+@rem ---- Cross compiler ----
+@set LJCOMPILE="%SCE_PROSPERO_SDK_DIR%\host_tools\bin\prospero-clang" -c -Wall -DLUAJIT_DISABLE_FFI -DLUAJIT_USE_SYSMALLOC %GC64%
+@set LJLIB="%SCE_PROSPERO_SDK_DIR%\host_tools\bin\prospero-llvm-ar" rcus
+@set INCLUDE=""
+
+"%SCE_PROSPERO_SDK_DIR%\host_tools\bin\prospero-clang" -c -o lj_vm.o lj_vm.s
+
+@if "%1" neq "debug" goto :NODEBUG
+@shift
+@set LJCOMPILE=%LJCOMPILE% -g -O0
+@set TARGETLIB=libluajitD_ps5.a
+goto :BUILD
+:NODEBUG
+@set LJCOMPILE=%LJCOMPILE% -O2
+@set TARGETLIB=libluajit_ps5.a
+:BUILD
+del %TARGETLIB%
+@if "%1" neq "noamalg" goto :AMALG
+for %%f in (lj_*.c lib_*.c) do (
+ %LJCOMPILE% %%f
+ @if errorlevel 1 goto :BAD
+)
+
+%LJLIB% %TARGETLIB% lj_*.o lib_*.o
+@if errorlevel 1 goto :BAD
+@goto :NOAMALG
+:AMALG
+%LJCOMPILE% ljamalg.c
+@if errorlevel 1 goto :BAD
+%LJLIB% %TARGETLIB% ljamalg.o lj_vm.o
+@if errorlevel 1 goto :BAD
+:NOAMALG
+
+@del *.o *.obj *.manifest minilua.exe buildvm.exe
+@echo.
+@echo === Successfully built LuaJIT for PS5 ===
+
+@goto :END
+:BAD
+@echo.
+@echo *******************************************************
+@echo *** Build FAILED -- Please check the error messages ***
+@echo *******************************************************
+@goto :END
+:FAIL
+@echo To run this script you must open a "Visual Studio .NET Command Prompt"
+@echo (64 bit host compiler). The PS5 Prospero SDK must be installed, too.
+:END
diff -Nru luajit-2.1.20220411/src/vm_arm64.dasc luajit-2.1.20230119/src/vm_arm64.dasc
--- luajit-2.1.20220411/src/vm_arm64.dasc 2022-04-05 12:12:47.000000000 +0000
+++ luajit-2.1.20230119/src/vm_arm64.dasc 2023-01-02 04:12:33.000000000 +0000
@@ -2636,7 +2636,9 @@
|.macro ins_arithmod, res, reg1, reg2
| fdiv d2, reg1, reg2
| frintm d2, d2
- | fmsub res, d2, reg2, reg1
+ | // Cannot use fmsub, because FMA is not enabled by default.
+ | fmul d2, d2, reg2
+ | fsub res, reg1, d2
|.endmacro
|
|.macro ins_arithdn, intins, fpins
@@ -3988,6 +3990,7 @@
"\t.align 3\n"
".LEFDE1:\n\n", (int)ctx->codesz - fcofs);
#endif
+#if !LJ_NO_UNWIND
fprintf(ctx->fp, "\t.section .eh_frame,\"a\",%%progbits\n");
fprintf(ctx->fp,
".Lframe1:\n"
@@ -4056,6 +4059,7 @@
"\t.align 3\n"
".LEFDE3:\n\n", (int)ctx->codesz - fcofs);
#endif
+#endif
break;
#if !LJ_NO_UNWIND
case BUILD_machasm: {
diff -Nru luajit-2.1.20220411/src/vm_s390x.dasc luajit-2.1.20230119/src/vm_s390x.dasc
--- luajit-2.1.20220411/src/vm_s390x.dasc 2022-04-05 12:12:47.000000000 +0000
+++ luajit-2.1.20230119/src/vm_s390x.dasc 2023-01-02 04:12:33.000000000 +0000
@@ -2098,11 +2098,13 @@
|// Value to round is in f0. May clobber f0-f7 and r0. Return address is r14.
|.macro vm_round, name, mask
|->name:
+ | ldr f4, f0
| lghi r0, 1
| cdfbr f1, r0
| didbr f0, f2, f1, mask // f0=remainder, f2=quotient.
+ | fidbra f4, mask, f4, 0
+ | ldr f0, f4
| jnle >1
- | ldr f0, f2
| br r14
|1: // partial remainder (sanity check)
| stg r0, 0
diff -Nru luajit-2.1.20220411/src/vm_x64.dasc luajit-2.1.20230119/src/vm_x64.dasc
--- luajit-2.1.20220411/src/vm_x64.dasc 2022-04-05 12:12:47.000000000 +0000
+++ luajit-2.1.20230119/src/vm_x64.dasc 2023-01-02 04:12:33.000000000 +0000
@@ -359,9 +359,6 @@
|.macro sseconst_1, reg, tmp // Synthesize 1.0.
| sseconst_hi reg, tmp, 3ff00000
|.endmacro
-|.macro sseconst_m1, reg, tmp // Synthesize -1.0.
-| sseconst_hi reg, tmp, bff00000
-|.endmacro
|.macro sseconst_2p52, reg, tmp // Synthesize 2^52.
| sseconst_hi reg, tmp, 43300000
|.endmacro
@@ -2543,15 +2540,17 @@
| addsd xmm1, xmm3 // (|x| + 2^52) - 2^52
| subsd xmm1, xmm3
| orpd xmm1, xmm2 // Merge sign bit back in.
+ | sseconst_1 xmm3, RD
| .if mode == 1 // ceil(x)?
- | sseconst_m1 xmm2, RD // Must subtract -1 to preserve -0.
| cmpsd xmm0, xmm1, 6 // x > result?
+ | andpd xmm0, xmm3
+ | addsd xmm1, xmm0 // If yes, add 1.
+ | orpd xmm1, xmm2 // Merge sign bit back in (again).
| .else // floor(x)?
- | sseconst_1 xmm2, RD
| cmpsd xmm0, xmm1, 1 // x < result?
+ | andpd xmm0, xmm3
+ | subsd xmm1, xmm0 // If yes, subtract 1.
| .endif
- | andpd xmm0, xmm2
- | subsd xmm1, xmm0 // If yes, subtract +-1.
|.endif
| movaps xmm0, xmm1
|1:
diff -Nru luajit-2.1.20220411/src/vm_x86.dasc luajit-2.1.20230119/src/vm_x86.dasc
--- luajit-2.1.20220411/src/vm_x86.dasc 2022-04-05 12:12:47.000000000 +0000
+++ luajit-2.1.20230119/src/vm_x86.dasc 2023-01-02 04:12:33.000000000 +0000
@@ -464,9 +464,6 @@
|.macro sseconst_1, reg, tmp // Synthesize 1.0.
| sseconst_hi reg, tmp, 3ff00000
|.endmacro
-|.macro sseconst_m1, reg, tmp // Synthesize -1.0.
-| sseconst_hi reg, tmp, bff00000
-|.endmacro
|.macro sseconst_2p52, reg, tmp // Synthesize 2^52.
| sseconst_hi reg, tmp, 43300000
|.endmacro
@@ -3004,15 +3001,17 @@
| addsd xmm1, xmm3 // (|x| + 2^52) - 2^52
| subsd xmm1, xmm3
| orpd xmm1, xmm2 // Merge sign bit back in.
+ | sseconst_1 xmm3, RDa
| .if mode == 1 // ceil(x)?
- | sseconst_m1 xmm2, RDa // Must subtract -1 to preserve -0.
| cmpsd xmm0, xmm1, 6 // x > result?
+ | andpd xmm0, xmm3
+ | addsd xmm1, xmm0 // If yes, add 1.
+ | orpd xmm1, xmm2 // Merge sign bit back in (again).
| .else // floor(x)?
- | sseconst_1 xmm2, RDa
| cmpsd xmm0, xmm1, 1 // x < result?
+ | andpd xmm0, xmm3
+ | subsd xmm1, xmm0 // If yes, subtract 1.
| .endif
- | andpd xmm0, xmm2
- | subsd xmm1, xmm0 // If yes, subtract +-1.
|.endif
| movaps xmm0, xmm1
|1: