diff --git a/build/luajit-2.1.0b3/.gitignore b/build/luajit-2.1.0b3/.gitignore
new file mode 100644
index 000000000..1a07bf75b
--- /dev/null
+++ b/build/luajit-2.1.0b3/.gitignore
@@ -0,0 +1,11 @@
+*.[oa]
+*.so
+*.obj
+*.lib
+*.exp
+*.dll
+*.exe
+*.manifest
+*.dmp
+*.swp
+.tags
diff --git a/build/luajit-2.1.0b3/COPYRIGHT b/build/luajit-2.1.0b3/COPYRIGHT
index 6ed40025a..9c2bca55a 100644
--- a/build/luajit-2.1.0b3/COPYRIGHT
+++ b/build/luajit-2.1.0b3/COPYRIGHT
@@ -1,7 +1,7 @@
===============================================================================
-LuaJIT -- a Just-In-Time Compiler for Lua. http://luajit.org/
+LuaJIT -- a Just-In-Time Compiler for Lua. https://luajit.org/
-Copyright (C) 2005-2017 Mike Pall. All rights reserved.
+Copyright (C) 2005-2021 Mike Pall. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -21,7 +21,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-[ MIT license: http://www.opensource.org/licenses/mit-license.php ]
+[ MIT license: https://www.opensource.org/licenses/mit-license.php ]
===============================================================================
[ LuaJIT includes code from Lua 5.1/5.2, which has this license statement: ]
@@ -51,6 +51,6 @@ THE SOFTWARE.
This is a version (aka dlmalloc) of malloc/free/realloc written by
Doug Lea and released to the public domain, as explained at
-http://creativecommons.org/licenses/publicdomain
+https://creativecommons.org/licenses/publicdomain
===============================================================================
diff --git a/build/luajit-2.1.0b3/Makefile b/build/luajit-2.1.0b3/Makefile
index 0f9330893..aa1b84bd7 100644
--- a/build/luajit-2.1.0b3/Makefile
+++ b/build/luajit-2.1.0b3/Makefile
@@ -10,7 +10,7 @@
# For MSVC, please follow the instructions given in src/msvcbuild.bat.
# For MinGW and Cygwin, cd to src and run make with the Makefile there.
#
-# Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h
+# Copyright (C) 2005-2021 Mike Pall. See Copyright Notice in luajit.h
##############################################################################
MAJVER= 2
@@ -75,7 +75,7 @@ SYMLINK= ln -sf
INSTALL_X= install -m 0755
INSTALL_F= install -m 0644
UNINSTALL= $(RM)
-LDCONFIG= ldconfig -n
+LDCONFIG= ldconfig -n 2>/dev/null
SED_PC= sed -e "s|^prefix=.*|prefix=$(PREFIX)|" \
-e "s|^multilib=.*|multilib=$(MULTILIB)|"
@@ -121,7 +121,7 @@ install: $(INSTALL_DEP)
$(RM) $(INSTALL_DYN) $(INSTALL_SHORT1) $(INSTALL_SHORT2)
cd src && test -f $(FILE_SO) && \
$(INSTALL_X) $(FILE_SO) $(INSTALL_DYN) && \
- $(LDCONFIG) $(INSTALL_LIB) && \
+ ( $(LDCONFIG) $(INSTALL_LIB) || : ) && \
$(SYMLINK) $(INSTALL_SONAME) $(INSTALL_SHORT1) && \
$(SYMLINK) $(INSTALL_SONAME) $(INSTALL_SHORT2) || :
cd etc && $(INSTALL_F) $(FILE_MAN) $(INSTALL_MAN)
diff --git a/build/luajit-2.1.0b3/README b/build/luajit-2.1.0b3/README
index 2b9ae9d22..c9f7d9ad9 100644
--- a/build/luajit-2.1.0b3/README
+++ b/build/luajit-2.1.0b3/README
@@ -3,9 +3,9 @@ README for LuaJIT 2.1.0-beta3
LuaJIT is a Just-In-Time (JIT) compiler for the Lua programming language.
-Project Homepage: http://luajit.org/
+Project Homepage: https://luajit.org/
-LuaJIT is Copyright (C) 2005-2017 Mike Pall.
+LuaJIT is Copyright (C) 2005-2021 Mike Pall.
LuaJIT is free software, released under the MIT license.
See full Copyright Notice in the COPYRIGHT file or in luajit.h.
diff --git a/build/luajit-2.1.0b3/doc/bluequad-print.css b/build/luajit-2.1.0b3/doc/bluequad-print.css
index 62e1c1659..0b385cee4 100644
--- a/build/luajit-2.1.0b3/doc/bluequad-print.css
+++ b/build/luajit-2.1.0b3/doc/bluequad-print.css
@@ -1,4 +1,4 @@
-/* Copyright (C) 2004-2017 Mike Pall.
+/* Copyright (C) 2004-2021 Mike Pall.
*
* You are welcome to use the general ideas of this design for your own sites.
* But please do not steal the stylesheet, the layout or the color scheme.
diff --git a/build/luajit-2.1.0b3/doc/bluequad.css b/build/luajit-2.1.0b3/doc/bluequad.css
index be2c4bf2d..86cd9ac0d 100644
--- a/build/luajit-2.1.0b3/doc/bluequad.css
+++ b/build/luajit-2.1.0b3/doc/bluequad.css
@@ -1,4 +1,4 @@
-/* Copyright (C) 2004-2017 Mike Pall.
+/* Copyright (C) 2004-2021 Mike Pall.
*
* You are welcome to use the general ideas of this design for your own sites.
* But please do not steal the stylesheet, the layout or the color scheme.
diff --git a/build/luajit-2.1.0b3/doc/contact.html b/build/luajit-2.1.0b3/doc/contact.html
index fe4751c0e..c253a08be 100644
--- a/build/luajit-2.1.0b3/doc/contact.html
+++ b/build/luajit-2.1.0b3/doc/contact.html
@@ -1,17 +1,16 @@
-
+
+Unlike Lua strings, which are constants, string buffers are
+mutable sequences of 8-bit (binary-transparent) characters. Data
+can be stored, formatted and encoded into a string buffer and later
+converted, extracted or decoded.
+
+
+The convenient string buffer API simplifies common string manipulation
+tasks, that would otherwise require creating many intermediate strings.
+String buffers improve performance by eliminating redundant memory
+copies, object creation, string interning and garbage collection
+overhead. In conjunction with the FFI library, they allow zero-copy
+operations.
+
+
+The string buffer libary also includes a high-performance
+serializer for Lua objects.
+
+
+
Work in Progress
+
+This library is a work in progress. More
+functionality will be added soon.
+
+
+
Using the String Buffer Library
+
+The string buffer library is built into LuaJIT by default, but it's not
+loaded by default. Add this to the start of every Lua file that needs
+one of its functions:
+
+
+local buffer = require("string.buffer")
+
+
+The convention for the syntax shown on this page is that buffer
+refers to the buffer library and buf refers to an individual
+buffer object.
+
+
+Please note the difference between a Lua function call, e.g.
+buffer.new() (with a dot) and a Lua method call, e.g.
+buf:reset() (with a colon).
+
+
+
Buffer Objects
+
+A buffer object is a garbage-collected Lua object. After creation with
+buffer.new(), it can (and should) be reused for many operations.
+When the last reference to a buffer object is gone, it will eventually
+be freed by the garbage collector, along with the allocated buffer
+space.
+
+
+Buffers operate like a FIFO (first-in first-out) data structure. Data
+can be appended (written) to the end of the buffer and consumed (read)
+from the front of the buffer. These operations may be freely mixed.
+
+
+The buffer space that holds the characters is managed automatically
+— it grows as needed and already consumed space is recycled. Use
+buffer.new(size) and buf:free(), if you need more
+control.
+
+
+The maximum size of a single buffer is the same as the maximum size of a
+Lua string, which is slightly below two gigabytes. For huge data sizes,
+neither strings nor buffers are the right data structure — use the
+FFI library to directly map memory or files up to the virtual memory
+limit of your OS.
+
+
+
Buffer Method Overview
+
+
+The buf:put*()-like methods append (write) characters to the
+end of the buffer.
+
+
+The buf:get*()-like methods consume (read) characters from the
+front of the buffer.
+
+
+Other methods, like buf:tostring() only read the buffer
+contents, but don't change the buffer.
+
+
+The buf:set() method allows zero-copy consumption of a string
+or an FFI cdata object as a buffer.
+
+
+The FFI-specific methods allow zero-copy read/write-style operations or
+modifying the buffer contents in-place. Please check the
+FFI caveats below, too.
+
+
+Methods that don't need to return anything specific, return the buffer
+object itself as a convenience. This allows method chaining, e.g.:
+buf:reset():encode(obj) or buf:skip(len):get()
+
+
+
+
Buffer Creation and Management
+
+
local buf = buffer.new([size [,options]])
+local buf = buffer.new([options])
+
+Creates a new buffer object.
+
+
+The optional size argument ensures a minimum initial buffer
+size. This is strictly an optimization when the required buffer size is
+known beforehand. The buffer space will grow as needed, in any case.
+
+Reset (empty) the buffer. The allocated buffer space is not freed and
+may be reused.
+
+
+
buf = buf:free()
+
+The buffer space of the buffer object is freed. The object itself
+remains intact, empty and may be reused.
+
+
+Note: you normally don't need to use this method. The garbage collector
+automatically frees the buffer space, when the buffer object is
+collected. Use this method, if you need to free the associated memory
+immediately.
+
+
+
Buffer Writers
+
+
buf = buf:put([str|num|obj] [,…])
+
+Appends a string str, a number num or any object
+obj with a __tostring metamethod to the buffer.
+Multiple arguments are appended in the given order.
+
+
+Appending a buffer to a buffer is possible and short-circuited
+internally. But it still involves a copy. Better combine the buffer
+writes to use a single buffer.
+
+
+
buf = buf:putf(format, …)
+
+Appends the formatted arguments to the buffer. The format
+string supports the same options as string.format().
+
+
+
buf = buf:putcdata(cdata, len)FFI
+
+Appends the given len number of bytes from the memory pointed
+to by the FFI cdata object to the buffer. The object needs to
+be convertible to a (constant) pointer.
+
+
+
buf = buf:set(str)
+buf = buf:set(cdata, len)FFI
+
+This method allows zero-copy consumption of a string or an FFI cdata
+object as a buffer. It stores a reference to the passed string
+str or the FFI cdata object in the buffer. Any buffer
+space originally allocated is freed. This is not an append
+operation, unlike the buf:put*() methods.
+
+
+After calling this method, the buffer behaves as if
+buf:free():put(str) or buf:free():put(cdata, len)
+had been called. However, the data is only referenced and not copied, as
+long as the buffer is only consumed.
+
+
+In case the buffer is written to later on, the referenced data is copied
+and the object reference is removed (copy-on-write semantics).
+
+
+The stored reference is an anchor for the garbage collector and keeps the
+originally passed string or FFI cdata object alive.
+
+
+
ptr, len = buf:reserve(size)FFI
+buf = buf:commit(used)FFI
+
+The reserve method reserves at least size bytes of
+write space in the buffer. It returns an uint8_t * FFI
+cdata pointer ptr that points to this space.
+
+
+The available length in bytes is returned in len. This is at
+least size bytes, but may be more to facilitate efficient
+buffer growth. You can either make use of the additional space or ignore
+len and only use size bytes.
+
+
+The commit method appends the used bytes of the
+previously returned write space to the buffer data.
+
+
+This pair of methods allows zero-copy use of C read-style APIs:
+
+
+local MIN_SIZE = 65536
+repeat
+ local ptr, len = buf:reserve(MIN_SIZE)
+ local n = C.read(fd, ptr, len)
+ if n == 0 then break end -- EOF.
+ if n < 0 then error("read error") end
+ buf:commit(n)
+until false
+
+
+The reserved write space is not initialized. At least the
+used bytes must be written to before calling the
+commit method. There's no need to call the commit
+method, if nothing is added to the buffer (e.g. on error).
+
+
+
Buffer Readers
+
+
len = #buf
+
+Returns the current length of the buffer data in bytes.
+
+
+
res = str|num|buf .. str|num|buf […]
+
+The Lua concatenation operator .. also accepts buffers, just
+like strings or numbers. It always returns a string and not a buffer.
+
+
+Note that although this is supported for convenience, this thwarts one
+of the main reasons to use buffers, which is to avoid string
+allocations. Rewrite it with buf:put() and buf:get().
+
+
+Mixing this with unrelated objects that have a __concat
+metamethod may not work, since these probably only expect strings.
+
+
+
buf = buf:skip(len)
+
+Skips (consumes) len bytes from the buffer up to the current
+length of the buffer data.
+
+
+
str, … = buf:get([len|nil] [,…])
+
+Consumes the buffer data and returns one or more strings. If called
+without arguments, the whole buffer data is consumed. If called with a
+number, up to len bytes are consumed. A nil argument
+consumes the remaining buffer space (this only makes sense as the last
+argument). Multiple arguments consume the buffer data in the given
+order.
+
+
+Note: a zero length or no remaining buffer data returns an empty string
+and not nil.
+
+
+
str = buf:tostring()
+str = tostring(buf)
+
+Creates a string from the buffer data, but doesn't consume it. The
+buffer remains unchanged.
+
+
+Buffer objects also define a __tostring metamethod. This means
+buffers can be passed to the global tostring() function and
+many other functions that accept this in place of strings. The important
+internal uses in functions like io.write() are short-circuited
+to avoid the creation of an intermediate string object.
+
+
+
ptr, len = buf:ref()FFI
+
+Returns an uint8_t * FFI cdata pointer ptr that
+points to the buffer data. The length of the buffer data in bytes is
+returned in len.
+
+
+The returned pointer can be directly passed to C functions that expect a
+buffer and a length. You can also do bytewise reads
+(local x = ptr[i]) or writes
+(ptr[i] = 0x40) of the buffer data.
+
+
+In conjunction with the skip method, this allows zero-copy use
+of C write-style APIs:
+
+
+repeat
+ local ptr, len = buf:ref()
+ if len == 0 then break end
+ local n = C.write(fd, ptr, len)
+ if n < 0 then error("write error") end
+ buf:skip(n)
+until n >= len
+
+
+Unlike Lua strings, buffer data is not implicitly
+zero-terminated. It's not safe to pass ptr to C functions that
+expect zero-terminated strings. If you're not using len, then
+you're doing something wrong.
+
+
+
Serialization of Lua Objects
+
+The following functions and methods allow high-speed serialization
+(encoding) of a Lua object into a string and decoding it back to a Lua
+object. This allows convenient storage and transport of structured
+data.
+
+
+The encoded data is in an internal binary
+format. The data can be stored in files, binary-transparent
+databases or transmitted to other LuaJIT instances across threads,
+processes or networks.
+
+
+Encoding speed can reach up to 1 Gigabyte/second on a modern desktop- or
+server-class system, even when serializing many small objects. Decoding
+speed is mostly constrained by object creation cost.
+
+
+The serializer handles most Lua types, common FFI number types and
+nested structures. Functions, thread objects, other FFI cdata and full
+userdata cannot be serialized (yet).
+
+
+The encoder serializes nested structures as trees. Multiple references
+to a single object will be stored separately and create distinct objects
+after decoding. Circular references cause an error.
+
+
+
Serialization Functions and Methods
+
+
str = buffer.encode(obj)
+buf = buf:encode(obj)
+
+Serializes (encodes) the Lua object obj. The stand-alone
+function returns a string str. The buffer method appends the
+encoding to the buffer.
+
+
+obj can be any of the supported Lua types — it doesn't
+need to be a Lua table.
+
+
+This function may throw an error when attempting to serialize
+unsupported object types, circular references or deeply nested tables.
+
+
+
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
+buffer. Both return a Lua object obj.
+
+
+The returned object may be any of the supported Lua types —
+even nil.
+
+
+This function may throw an error when fed with malformed or incomplete
+encoded data. The stand-alone function throws when there's left-over
+data after decoding a single top-level object. The buffer method leaves
+any left-over data in the buffer.
+
+
+
Serialization Options
+
+The options table passed to buffer.new() may contain
+the following members (all optional):
+
+
+
+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
+dictionary saves space and improves serialization performance.
+
+
+metatable is a Lua table holding a dictionary of metatables
+for the table objects you are serializing.
+
+
+
+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
+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().
+
+
+The dict and metatable tables used by the encoder and
+decoder must be the same. Put the most common entries at the front. Extend
+at the end to ensure backwards-compatibility — older encodings can
+then still be read. You may also set some indexes to false to
+explicitly drop backwards-compatibility. Old encodings that use these
+indexes will throw an error when decoded.
+
+
+Metatables that are not found in the metatable dictionary are
+ignored when encoding. Decoding returns a table with a nil
+metatable.
+
+
+Note: parsing and preparation of the options table is somewhat
+expensive. Create a buffer object only once and recycle it for multiple
+uses. Avoid mixing encoder and decoder buffers, since the
+buf:set() method frees the already allocated buffer space:
+
+In some contexts, it's desirable to do piecewise serialization of large
+datasets, also known as streaming.
+
+
+This serialization format can be safely concatenated and supports streaming.
+Multiple encodings can simply be appended to a buffer and later decoded
+individually:
+
+while #buf ~= 0 do
+ local obj = buf:decode()
+ -- Do something with obj.
+end
+
+
+Since the serialization format doesn't prepend a length to its encoding,
+network applications may need to transmit the length, too.
+
+
+
Serialization Format Specification
+
+This serialization format is designed for internal use by LuaJIT
+applications. Serialized data is upwards-compatible and portable across
+all supported LuaJIT platforms.
+
+
+It's an 8-bit binary format and not human-readable. It uses e.g.
+embedded zeroes and stores embedded Lua string objects unmodified, which
+are 8-bit-clean, too. Encoded data can be safely concatenated for
+streaming and later decoded one top-level object at a time.
+
+
+The encoding is reasonably compact, but tuned for maximum performance,
+not for minimum space usage. It compresses well with any of the common
+byte-oriented data compression algorithms.
+
+
+Although documented here for reference, this format is explicitly
+not intended to be a 'public standard' for structured data
+interchange across computer languages (like JSON or MessagePack). Please
+do not use it as such.
+
+
+The specification is given below as a context-free grammar with a
+top-level object as the starting point. Alternatives are
+separated by the | symbol and * indicates repeats.
+Grouping is implicit or indicated by {…}. Terminals are
+either plain hex numbers, encoded as bytes, or have a .format
+suffix.
+
+Many of the buffer methods can throw an error. Out-of-memory or usage
+errors are best caught with an outer wrapper for larger parts of code.
+There's not much one can do after that, anyway.
+
+
+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:
+
+
+local ok, err = pcall(buf.encode, buf, obj)
+if not ok then
+ -- Handle error in err.
+end
+
+
+
FFI caveats
+
+The string buffer library has been designed to work well together with
+the FFI library. But due to the low-level nature of the FFI library,
+some care needs to be taken:
+
+
+First, please remember that FFI pointers are zero-indexed. The space
+returned by buf:reserve() and buf:ref() starts at the
+returned pointer and ends before len bytes after that.
+
+
+I.e. the first valid index is ptr[0] and the last valid index
+is ptr[len-1]. If the returned length is zero, there's no valid
+index at all. The returned pointer may even be NULL.
+
+
+The space pointed to by the returned pointer is only valid as long as
+the buffer is not modified in any way (neither append, nor consume, nor
+reset, etc.). The pointer is also not a GC anchor for the buffer object
+itself.
+
+
+Buffer data is only guaranteed to be byte-aligned. Casting the returned
+pointer to a data type with higher alignment may cause unaligned
+accesses. It depends on the CPU architecture whether this is allowed or
+not (it's always OK on x86/x64 and mostly OK on other modern
+architectures).
+
+
+FFI pointers or references do not count as GC anchors for an underlying
+object. E.g. an array allocated with ffi.new() is
+anchored by buf:set(array, len), but not by
+buf:set(array+offset, len). The addition of the offset
+creates a new pointer, even when the offset is zero. In this case, you
+need to make sure there's still a reference to the original array as
+long as its contents are in use by the buffer.
+
+
+Even though each LuaJIT VM instance is single-threaded (but you can
+create multiple VMs), FFI data structures can be accessed concurrently.
+Be careful when reading/writing FFI cdata from/to buffers to avoid
+concurrent accesses or modifications. In particular, the memory
+referenced by buf:set(cdata, len) must not be modified
+while buffer readers are working on it. Shared, but read-only memory
+mappings of files are OK, but only if the file does not change.
+
The third argument specifies the mode, which is 'or'ed with a flag.
-The flag can be LUAJIT_MODE_OFF to turn a feature on,
-LUAJIT_MODE_ON to turn a feature off, or
+The flag can be LUAJIT_MODE_OFF to turn a feature off,
+LUAJIT_MODE_ON to turn a feature on, or
LUAJIT_MODE_FLUSH to flush cached code.
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
-precedence (e.g. declared field names cannot be overriden).
+precedence (e.g. declared field names cannot be overridden).
All standard Lua metamethods are implemented. These are called directly,
@@ -469,6 +465,8 @@
constructor. This is equivalent
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 contructor. Note that you have to
+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.
@@ -864,7 +860,7 @@
Parameterized Types
The main use for parameterized types are libraries implementing abstract
data types
-(» example),
+(» example),
similar to what can be achieved with C++ template metaprogramming.
Another use case are derived types of anonymous structs, which avoids
pollution of the global struct namespace.
@@ -1225,7 +1221,7 @@
Current Status
Table initializers.
Initialization of nested struct/union types.
Non-default initialization of VLA/VLS or large C types
-(> 128 bytes or > 16 array elements.
+(> 128 bytes or > 16 array elements).
Bitfield initializations.
Pointer differences for element sizes that are not a power of
two.
The following code shows how to access the zlib compression library from Lua code.
+href="https://zlib.net/">» zlib compression library from Lua code.
We'll define two convenience wrapper functions that take a string and
compress or uncompress it to another string:
@@ -305,7 +301,7 @@
Accessing the zlib Compression Library
missing standard prefixes/suffixes, we can simply load the
"z" library. On Windows it's named zlib1.dll and
you'll have to download it first from the
-» zlib site. The check for
+» zlib site. The check for
ffi.os makes sure we pass the right name to
ffi.load().
@@ -593,7 +589,7 @@
Note: LJ_GC64 mode requires a different frame layout, which implies
-a different, incompatible bytecode format for ports that use this mode (e.g.
-ARM64 or MIPS64) or when explicitly enabled for x64. This may be rectified
-in the future.
+a different, incompatible bytecode format for all 64 bit ports. This may be
+rectified in the future.
table.new(narray, nhash) allocates a pre-sized table
@@ -254,6 +249,10 @@
Enhanced PRNG for math.random()
It's correctly scaled up and rounded for math.random(n [,m]) to
preserve uniformity.
+
+Important: Neither this nor any other PRNG based on the simplistic
+math.random() API is suitable for cryptographic use.
+
io.* functions handle 64 bit file offsets
@@ -374,6 +373,7 @@
Extensions from Lua 5.3
Unicode escape '\u{XX...}' embeds the UTF-8 encoding in string literals.
The argument table arg can be read (and modified) by LUA_INIT and -e chunks.
io.read() and file:read() accept formats with or without a leading *.
+
assert() accepts any type of error object.
table.move(a1, f, e, t [,a2]).
coroutine.isyieldable().
Lua/C API extensions:
@@ -394,29 +394,19 @@
C++ Exception Interoperability
Interoperability
-
POSIX/x64, DWARF2 unwinding
-
GCC 4.3+, Clang
+
External frame unwinding
+
GCC, Clang, MSVC
Full
-
ARM -DLUAJIT_UNWIND_EXTERNAL
-
GCC, Clang
-
Full
-
-
-
Other platforms, DWARF2 unwinding
+
Internal frame unwinding + DWARF2
GCC, Clang
Limited
-
-
Windows/x64
-
MSVC or WinSDK
-
Full
-
-
Windows/x86
-
Any
-
Full
+
Windows 64 bit
+
non-MSVC
+
Limited
Other platforms
@@ -437,7 +427,9 @@
C++ Exception Interoperability
on the C stack. The contents of the C++ exception object
pass through unmodified.
Lua errors can be caught on the C++ side with catch(...).
-The corresponding Lua error message can be retrieved from the Lua stack.
+The corresponding Lua error message can be retrieved from the Lua stack.
+For MSVC for Windows 64 bit this requires compilation of your C++ code
+with /EHa.
Throwing Lua errors across C++ frames is safe. C++ destructors
will be called.
The » LuaJIT wiki gathers community
resources about LuaJIT.
News about Lua itself can be found at the
-» Lua mailing list.
+» Lua mailing list.
The mailing list archives are worth checking out for older postings
about LuaJIT.
Q: Why do I get this error: "attempt to index global 'arg' (a nil value)"?
Q: My vararg functions fail after switching to LuaJIT!
LuaJIT is compatible to the Lua 5.1 language standard. It doesn't
support the implicit arg parameter for old-style vararg
functions from Lua 5.0. Please convert your code to the
-» Lua 5.1
+» Lua 5.1
vararg syntax.
-
+
Q: Why do I get this error: "bad FPU precision"?
Q: I get weird behavior after initializing Direct3D.
Q: Some FPU operations crash after I load a Delphi DLL.
@@ -127,56 +121,75 @@
Frequently Asked Questions (FAQ)
Similarly, the Borland/Delphi runtime modifies the FPU control word and
enables FP exceptions. Of course this violates the Windows ABI, too.
-Please check the Delphi docs for the Set8087CW method.
-
+Please check the Delphi docs for the Set8087CW method.
-
+
Q: Sometimes Ctrl-C fails to stop my Lua program. Why?
The interrupt signal handler sets a Lua debug hook. But this is
-currently ignored by compiled code (this will eventually be fixed). 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. In the meantime you have to press Ctrl-C
-twice to get stop your program. That's similar to when it's stuck
-running inside a C function under the Lua interpreter.
+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
+to when it's stuck running inside a C function under the Lua interpreter.
-
-
Q: Why doesn't my favorite power-patch for Lua apply against LuaJIT?
-
Because it's a completely redesigned VM and has very little code
-in common with Lua anymore. Also, if the patch introduces changes to
-the Lua semantics, these would need to be reflected everywhere in the
-VM, from the interpreter up to all stages of the compiler. Please
-use only standard Lua language constructs. For many common needs you
-can use source transformations or use wrapper or proxy functions.
-The compiler will happily optimize away such indirections.
+
+
Q: Table iteration with pairs() does not result in the same order?
+
The order of table iteration is explicitly undefined by
+the Lua language standard.
+Different Lua implementations or versions may use different orders for
+otherwise identical tables. Different ways of constructing a table may
+result in different orders, too.
+Due to improved VM security, LuaJIT 2.1 may even use a different order
+on separate VM invocations or when string keys are newly interned.
+If your program relies on a deterministic order, it has a bug. Rewrite it,
+so it doesn't rely on the key order. Or sort the table keys, if you must.
-
+
+
Q: Can Lua code be safely sandboxed?
+
+Maybe for an extremly 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),
+it's very hard to get this right even for the Lua core libraries. Of course,
+you'll need to inspect any extension library, too. And there are libraries
+that are inherently unsafe, e.g. the FFI library.
+
+More reading material at the » Lua Wiki and » Wikipedia.
+
+Relatedly, loading untrusted bytecode is not safe!
+
+It's trivial to crash the Lua or LuaJIT VM with maliciously crafted bytecode.
+This is well known and there's no bytecode verification on purpose, so please
+don't report a bug about it. Check the mode parameter for the
+load*() functions to disable loading of bytecode.
+
+In general, the only promising approach is to sandbox Lua code at the
+process level and not the VM level.
+
+
+
+
Q: Lua runs everywhere. Why doesn't LuaJIT support my CPU?
Because it's a compiler — it needs to generate native
machine code. This means the code generator must be ported to each
architecture. And the fast interpreter is written in assembler and
must be ported, too. This is quite an undertaking.
The install documentation shows the supported
-architectures. Other architectures will follow based on sufficient user
-demand and/or sponsoring.
-
-
-
-
Q: When will feature X be added? When will the next version be released?
-
When it's ready.
-C'mon, it's open source — I'm doing it on my own time and you're
-getting it for free. You can either contribute a patch or sponsor
-the development of certain features, if they are important to you.
-
+architectures.
+Other architectures may follow based on sufficient user demand and
+market-relevance of the architecture. Sponsoring is required to develop
+the port itself, to integrate it and to continuously maintain it in the
+actively developed branches.
src/Makefile has settings for compiling LuaJIT
under POSIX, MinGW or Cygwin.
src/msvcbuild.bat has settings for compiling LuaJIT with
-MSVC or WinSDK.
+MSVC (Visual Studio).
Please read the instructions given in these files, before changing
any settings.
-LuaJIT on x64 currently uses 32 bit GC objects by default.
-LJ_GC64 mode may be explicitly enabled:
-add XCFLAGS=-DLUAJIT_ENABLE_GC64 to the make command or run
-msvcbuild gc64 for MSVC/WinSDK. Please check the note
-about the bytecode format
-differences, too.
+All LuaJIT 64 bit ports use 64 bit GC objects by default (LJ_GC64).
+For x64, you can select the old 32-on-64 bit mode by adding
+XCFLAGS=-DLUAJIT_DISABLE_GC64 to the make command.
+Please check the note about the
+bytecode format differences, too.
-
POSIX Systems (Linux, OSX, *BSD etc.)
+
POSIX Systems (Linux, macOS, *BSD etc.)
Prerequisites
Depending on your distribution, you may need to install a package for
@@ -192,14 +187,19 @@
Prerequisites
Debian/Ubuntu, install libc6-dev with the package manager.
-Download the current source package of LuaJIT (pick the .tar.gz),
-if you haven't already done so. 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:
+The recommended way to fetch the latest version is to do a pull from
+the git repository.
+
+
+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):
The supplied Makefiles try to auto-detect the settings needed for your
@@ -223,9 +223,12 @@
Building LuaJIT
make PREFIX=/home/myself/lj2
-Note for OSX: if the MACOSX_DEPLOYMENT_TARGET environment
-variable is not set, then it's forced to 10.4.
+Note for macOS: you must set the MACOSX_DEPLOYMENT_TARGET
+environment variable to a value supported by your toolchain:
+
+MACOSX_DEPLOYMENT_TARGET=XX.YY make
+
Installing LuaJIT
The top-level Makefile installs LuaJIT by default under
@@ -252,27 +255,18 @@
Prerequisites
Either install one of the open source SDKs
(» MinGW or
-» Cygwin), which come with a modified
+» Cygwin), which come with a modified
GCC plus the required development headers.
+Or install Microsoft's Visual Studio (MSVC).
-Or install Microsoft's Visual C++ (MSVC). The freely downloadable
-» Express Edition
-works just fine, but only contains an x86 compiler.
-
-
-The freely downloadable
-» Windows SDK
-only comes with command line tools, but this is all you need to build LuaJIT.
-It contains x86 and x64 compilers.
-
-
-Next, download the source package and unpack it using an archive manager
-(e.g. the Windows Explorer) to a directory of your choice.
+Next, pull from the git repository or download the source package and
+unpack it using an archive manager (e.g. the Windows Explorer) to
+a directory of your choice.
Building with MSVC
-Open a "Visual Studio .NET Command Prompt", cd to the
+Open a "Visual Studio Command Prompt" (either x86 or x64), cd to the
directory where you've unpacked the sources and run these commands:
@@ -280,37 +274,14 @@
Building with MSVC
msvcbuild
-Then follow the installation instructions below.
-
-
Building with the Windows SDK
-
-Open a "Windows SDK Command Shell" and select the x86 compiler:
-
-
-setenv /release /x86
-
-
-Or select the x64 compiler:
-
-
-setenv /release /x64
-
-
-Then cd to the directory where you've unpacked the sources
-and run these commands:
-
-
-cd src
-msvcbuild
-
-
+Check the msvcbuild.bat file for more options.
Then follow the installation instructions below.
Building with MinGW or Cygwin
Open a command prompt window and make sure the MinGW or Cygwin programs
-are in your path. Then cd to the directory where
-you've unpacked the sources and run this command for MinGW:
+are in your path. Then cd to the directory of the git repository
+or where you've unpacked the sources. Then run this command for MinGW:
mingw32-make
@@ -365,7 +336,7 @@
Cross-compiling LuaJIT
target OS differ, or you'll get assembler or linker errors:
-
E.g. if you're compiling on a Windows or OSX host for embedded Linux or Android, you need to add TARGET_SYS=Linux to the examples below.
+
E.g. if you're compiling on a Windows or macOS host for embedded Linux or Android, you need to add TARGET_SYS=Linux to the examples below.
For a minimal target OS, you may need to disable the built-in allocator in src/Makefile and use TARGET_SYS=Other.
Don't forget to specify the same TARGET_SYS for the install step, too.
@@ -428,52 +399,33 @@
Cross-compiling LuaJIT
make CROSS=mipsel-linux- TARGET_CFLAGS="-mips64r2 -mabi=64"
-You can cross-compile for Android using the Android NDK.
-The environment variables need to match the install locations and the
-desired target platform. E.g. Android 4.0 corresponds to ABI level 14.
-For details check the folder docs in the NDK directory.
-
-
-Only a few common variations for the different CPUs, ABIs and platforms
-are listed. Please use your own judgement for which combination you want
-to build/deploy or which lowest common denominator you want to pick:
+You can cross-compile for Android using the » Android NDK.
+Please adapt the environment variables to match the install locations and the
+desired target platform. E.g. Android 4.1 corresponds to ABI level 16.
-If you're building a 64 bit application on OSX which links directly or
-indirectly against LuaJIT which is not built for LJ_GC64 mode,
-you need to link your main executable with these flags:
-
--pagezero_size 10000 -image_base 100000000
-
-
Additional hints for initializing LuaJIT using the C API functions:
@@ -606,7 +543,7 @@
Embedding LuaJIT
for embedding Lua or LuaJIT into your application.
Make sure you use luaL_newstate. Avoid using
lua_newstate, since this uses the (slower) default memory
-allocator from your system (no support for this on x64).
+allocator from your system (no support for this on 64 bit architectures).
Make sure you use luaL_openlibs and not the old Lua 5.0 style
of calling luaopen_base etc. directly.
To change or extend the list of standard libraries to load, copy
@@ -615,7 +552,7 @@
Embedding LuaJIT
will not be activated.
The bit.* module for bitwise operations
is already built-in. There's no need to statically link
-» Lua BitOp to your application.
LuaJIT is a Just-In-Time Compiler (JIT) for the
-» Lua programming language.
+» Lua programming language.
Lua is a powerful, dynamic and light-weight programming language.
It may be embedded or used as a general-purpose, stand-alone language.
games, appliances, network and graphics apps, numerical simulations,
trading platforms and many other specialty applications. It scales from
embedded devices, smartphones, desktops up to server farms. It combines
-high flexibility with » high performance
+high flexibility with high performance
and an unmatched low memory footprint.
version of the regular lua stand-alone executable.
It supports the same basic options, too. luajit -h
prints a short list of the available options. Please have a look at the
-» Lua manual
+» Lua manual
for details.
@@ -189,8 +185,8 @@
-j cmd[=arg[,arg...]]
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
-this is /usr/local/share/luajit-2.0.5/jit on POSIX
-systems.
+this is /usr/local/share/luajit-XX.YY.ZZ>/jit on POSIX
+systems (replace XX.YY.ZZ by the installed version).
-LuaJIT 2.0 is the current
-stable branch. This branch is in
-feature-freeze — new features will only be added to LuaJIT 2.1.
+This documentation is for LuaJIT 2.1.0-beta3. Please check the doc
+directory in each git branch for the version-specific documentation.
+
+
+The currently developed branches are LuaJIT 2.1 and LuaJIT 2.0.
+
+
+LuaJIT 2.0 is in feature-freeze — new features will only
+be added to LuaJIT 2.1.
Current Status
@@ -90,30 +92,12 @@
Current Status
hooks for non-Lua functions) and shows slightly different behavior
in LuaJIT (no per-coroutine hooks, no tail call counting).
-
-Currently some out-of-memory errors from on-trace code are not
-handled correctly. The error may fall through an on-trace
-pcall or it may be passed on to the function set with
-lua_atpanic on x64. This issue will be fixed with the new
-garbage collector.
-
-
-LuaJIT on 64 bit systems provides a limited range of 47 bits for the
-legacy lightuserdata data type.
-This is only relevant on x64 systems which use the negative part of the
-virtual address space in user mode, e.g. Solaris/x64, and on ARM64 systems
-configured with a 48 bit or 52 bit VA.
-Avoid using lightuserdata to hold pointers that may point outside
-of that range, e.g. variables on the stack. In general, avoid this data
-type for new code and replace it with (much more performant) FFI bindings.
-FFI cdata pointers can address the full 64 bit range.
-