diff --git a/third_party/luajit/luajit/.gitattributes b/third_party/luajit/luajit/.gitattributes
new file mode 100644
index 000000000..c048531e2
--- /dev/null
+++ b/third_party/luajit/luajit/.gitattributes
@@ -0,0 +1 @@
+/.relver export-subst
diff --git a/third_party/luajit/luajit/.gitignore b/third_party/luajit/luajit/.gitignore
index 1a07bf75b..9dd51e85f 100644
--- a/third_party/luajit/luajit/.gitignore
+++ b/third_party/luajit/luajit/.gitignore
@@ -9,3 +9,6 @@
*.dmp
*.swp
.tags
+*~
+tags
+*.swo
diff --git a/third_party/luajit/luajit/.relver b/third_party/luajit/luajit/.relver
new file mode 100644
index 000000000..2707647aa
--- /dev/null
+++ b/third_party/luajit/luajit/.relver
@@ -0,0 +1 @@
+$Format:%ct$
diff --git a/third_party/luajit/luajit/.travis.yml b/third_party/luajit/luajit/.travis.yml
new file mode 100644
index 000000000..9077c9426
--- /dev/null
+++ b/third_party/luajit/luajit/.travis.yml
@@ -0,0 +1,61 @@
+sudo: required
+dist: bionic
+
+branches:
+ only:
+ - "v2.1-agentzh"
+
+os: linux
+arch:
+ - amd64
+ - arm64
+ - s390x
+
+language: c
+
+compiler:
+ - gcc
+
+addons:
+ apt:
+ packages:
+ - axel
+ - cpanminus
+ - libtest-base-perl
+ - libtext-diff-perl
+ - libtest-longstring-perl
+ - liblist-moreutils-perl
+ - libparallel-forkmanager-perl
+ - libgd-dev
+ - libmpc-dev
+ - build-essential
+ - libgtk2.0-dev
+ - valgrind
+
+env:
+ global:
+ - JOBS=3
+ - LUAJIT_PREFIX=/opt/luajit21
+ - LUAJIT_SYSM_PREFIX=/opt/luajit21-sysm
+ - LUAJIT_COMMON_XCFLAGS="-DLUA_USE_APICHECK -DLUA_USE_ASSERT -DLUAJIT_NUMMODE=2 -O1"
+ - LUAJIT_COMMON_XCFLAGS=$( [ ${TRAVIS_CPU_ARCH} == "amd64" ] && echo "$LUAJIT_COMMON_XCFLAGS -msse4.2" || echo "$LUAJIT_COMMON_XCFLAGS" )
+
+ matrix:
+ - LUAJIT_XCFLAGS="$LUAJIT_COMMON_XCFLAGS"
+ - LUAJIT_XCFLAGS="-DLUAJIT_ENABLE_LUA52COMPAT $LUAJIT_COMMON_XCFLAGS" LUA52=1
+ - LUAJIT_XCFLAGS="-DLUAJIT_USE_VALGRIND -DLUAJIT_USE_SYSMALLOC -DLUAJIT_ENABLE_LUA52COMPAT $LUAJIT_COMMON_XCFLAGS" LUA52=1 FLAGS=$( [ ${TRAVIS_CPU_ARCH} != "s390x" ] && echo '-v' )
+ - LUAJIT_XCFLAGS="-DLUAJIT_DISABLE_GC64 -DLUAJIT_ENABLE_LUA52COMPAT $LUAJIT_COMMON_XCFLAGS" LUA52=1
+
+install:
+ - git clone https://github.com/openresty/luajit2-test-suite.git ../luajit2-test-suite
+
+script:
+ - echo ${LUAJIT_COMMON_XCFLAGS}
+ - valgrind --version
+ - /usr/bin/env perl $(command -v cpanm) --sudo --notest IPC::Run3 Test::Base Test::LongString Parallel::ForkManager > build.log 2>&1 || (cat build.log && exit 1)
+ - cd ../luajit2
+ - make -j$JOBS CCDEBUG=-g Q= PREFIX=$LUAJIT_PREFIX CC=$CC XCFLAGS="$LUAJIT_XCFLAGS" > build.log 2>&1 || (cat build.log && exit 1)
+ - sudo make install PREFIX=$LUAJIT_PREFIX > build.log 2>&1 || (cat build.log && exit 1)
+ - if [ ${TRAVIS_CPU_ARCH} == "amd64" ]; then PATH=/opt/luajit21/bin:$PATH prove -I. t; fi
+ - cd ../luajit2-test-suite
+ - ./run-tests -j 1 $FLAGS $LUAJIT_PREFIX
diff --git a/third_party/luajit/luajit/COPYRIGHT b/third_party/luajit/luajit/COPYRIGHT
index c74216c3e..f57d0d4cf 100644
--- a/third_party/luajit/luajit/COPYRIGHT
+++ b/third_party/luajit/luajit/COPYRIGHT
@@ -1,7 +1,11 @@
===============================================================================
LuaJIT -- a Just-In-Time Compiler for Lua. https://luajit.org/
-Copyright (C) 2005-2022 Mike Pall. All rights reserved.
+Copyright (C) 2005-2023 Mike Pall. All rights reserved.
+
+Copyright (C) 2017-2018 Yichun Zhang. All rights reserved.
+
+Copyright (C) 2017-2018 OpenResty Inc. 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
diff --git a/third_party/luajit/luajit/Makefile b/third_party/luajit/luajit/Makefile
index b0288b4db..3aed365db 100644
--- a/third_party/luajit/luajit/Makefile
+++ b/third_party/luajit/luajit/Makefile
@@ -10,16 +10,21 @@
# 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-2022 Mike Pall. See Copyright Notice in luajit.h
+# Copyright (C) 2005-2023 Mike Pall. See Copyright Notice in luajit.h
##############################################################################
MAJVER= 2
MINVER= 1
-RELVER= 0
-PREREL= -beta3
-VERSION= $(MAJVER).$(MINVER).$(RELVER)$(PREREL)
ABIVER= 5.1
+# LuaJIT uses rolling releases. The release version is based on the time of
+# the latest git commit. The 'git' command must be available during the build.
+RELVER= $(shell cat src/luajit_relver.txt 2>/dev/null || : )
+# Note: setting it with := doesn't work, since it will change during the build.
+
+MMVERSION= $(MAJVER).$(MINVER)
+VERSION= $(MMVERSION).$(RELVER)
+
##############################################################################
#
# Change the installation path as needed. This automatically adjusts
@@ -33,10 +38,10 @@ DPREFIX= $(DESTDIR)$(PREFIX)
INSTALL_BIN= $(DPREFIX)/bin
INSTALL_LIB= $(DPREFIX)/$(MULTILIB)
INSTALL_SHARE= $(DPREFIX)/share
-INSTALL_DEFINC= $(DPREFIX)/include/luajit-$(MAJVER).$(MINVER)
+INSTALL_DEFINC= $(DPREFIX)/include/luajit-$(MMVERSION)
INSTALL_INC= $(INSTALL_DEFINC)
-INSTALL_LJLIBD= $(INSTALL_SHARE)/luajit-$(VERSION)
+INSTALL_LJLIBD= $(INSTALL_SHARE)/luajit-$(MMVERSION)
INSTALL_JITLIB= $(INSTALL_LJLIBD)/jit
INSTALL_LMODD= $(INSTALL_SHARE)/lua
INSTALL_LMOD= $(INSTALL_LMODD)/$(ABIVER)
@@ -50,10 +55,10 @@ INSTALL_TSYMNAME= luajit
INSTALL_ANAME= libluajit-$(ABIVER).a
INSTALL_SOSHORT1= libluajit-$(ABIVER).so
INSTALL_SOSHORT2= libluajit-$(ABIVER).so.$(MAJVER)
-INSTALL_SONAME= $(INSTALL_SOSHORT2).$(MINVER).$(RELVER)
+INSTALL_SONAME= libluajit-$(ABIVER).so.$(VERSION)
INSTALL_DYLIBSHORT1= libluajit-$(ABIVER).dylib
INSTALL_DYLIBSHORT2= libluajit-$(ABIVER).$(MAJVER).dylib
-INSTALL_DYLIBNAME= libluajit-$(ABIVER).$(MAJVER).$(MINVER).$(RELVER).dylib
+INSTALL_DYLIBNAME= libluajit-$(ABIVER).$(VERSION).dylib
INSTALL_PCNAME= luajit.pc
INSTALL_STATIC= $(INSTALL_LIB)/$(INSTALL_ANAME)
@@ -78,7 +83,8 @@ INSTALL_F= install -m 0644
UNINSTALL= $(RM)
LDCONFIG= ldconfig -n 2>/dev/null
SED_PC= sed -e "s|^prefix=.*|prefix=$(PREFIX)|" \
- -e "s|^multilib=.*|multilib=$(MULTILIB)|"
+ -e "s|^multilib=.*|multilib=$(MULTILIB)|" \
+ -e "s|^relver=.*|relver=$(RELVER)|"
ifneq ($(INSTALL_DEFINC),$(INSTALL_INC))
SED_PC+= -e "s|^includedir=.*|includedir=$(INSTALL_INC)|"
endif
@@ -92,7 +98,9 @@ FILES_INC= lua.h lualib.h lauxlib.h luaconf.h lua.hpp luajit.h
FILES_JITLIB= bc.lua bcsave.lua dump.lua p.lua v.lua zone.lua \
dis_x86.lua dis_x64.lua dis_arm.lua dis_arm64.lua \
dis_arm64be.lua dis_ppc.lua dis_mips.lua dis_mipsel.lua \
- dis_mips64.lua dis_mips64el.lua vmdef.lua
+ dis_mips64.lua dis_mips64el.lua \
+ dis_mips64r6.lua dis_mips64r6el.lua \
+ vmdef.lua
ifeq (,$(findstring Windows,$(OS)))
HOST_SYS:= $(shell uname -s)
@@ -113,9 +121,9 @@ endif
INSTALL_DEP= src/luajit
default all $(INSTALL_DEP):
- @echo "==== Building LuaJIT $(VERSION) ===="
+ @echo "==== Building LuaJIT $(MMVERSION) ===="
$(MAKE) -C src
- @echo "==== Successfully built LuaJIT $(VERSION) ===="
+ @echo "==== Successfully built LuaJIT $(MMVERSION) ===="
install: $(INSTALL_DEP)
@echo "==== Installing LuaJIT $(VERSION) to $(PREFIX) ===="
@@ -134,18 +142,12 @@ install: $(INSTALL_DEP)
$(RM) $(FILE_PC).tmp
cd src && $(INSTALL_F) $(FILES_INC) $(INSTALL_INC)
cd src/jit && $(INSTALL_F) $(FILES_JITLIB) $(INSTALL_JITLIB)
+ $(SYMLINK) $(INSTALL_TNAME) $(INSTALL_TSYM)
@echo "==== Successfully installed LuaJIT $(VERSION) to $(PREFIX) ===="
- @echo ""
- @echo "Note: the development releases deliberately do NOT install a symlink for luajit"
- @echo "You can do this now by running this command (with sudo):"
- @echo ""
- @echo " $(SYMLINK) $(INSTALL_TNAME) $(INSTALL_TSYM)"
- @echo ""
-
uninstall:
@echo "==== Uninstalling LuaJIT $(VERSION) from $(PREFIX) ===="
- $(UNINSTALL) $(INSTALL_T) $(INSTALL_STATIC) $(INSTALL_DYN) $(INSTALL_SHORT1) $(INSTALL_SHORT2) $(INSTALL_MAN)/$(FILE_MAN) $(INSTALL_PC)
+ $(UNINSTALL) $(INSTALL_TSYM) $(INSTALL_T) $(INSTALL_STATIC) $(INSTALL_DYN) $(INSTALL_SHORT1) $(INSTALL_SHORT2) $(INSTALL_MAN)/$(FILE_MAN) $(INSTALL_PC)
for file in $(FILES_JITLIB); do \
$(UNINSTALL) $(INSTALL_JITLIB)/$$file; \
done
@@ -159,8 +161,9 @@ uninstall:
##############################################################################
amalg:
- @echo "Building LuaJIT $(VERSION)"
+ @echo "==== Building LuaJIT $(MMVERSION) (amalgamation) ===="
$(MAKE) -C src amalg
+ @echo "==== Successfully built LuaJIT $(MMVERSION) (amalgamation) ===="
clean:
$(MAKE) -C src clean
diff --git a/third_party/luajit/luajit/README b/third_party/luajit/luajit/README
index 1faef2559..e4a692654 100644
--- a/third_party/luajit/luajit/README
+++ b/third_party/luajit/luajit/README
@@ -1,11 +1,11 @@
-README for LuaJIT 2.1.0-beta3
------------------------------
+README for LuaJIT 2.1
+---------------------
LuaJIT is a Just-In-Time (JIT) compiler for the Lua programming language.
Project Homepage: https://luajit.org/
-LuaJIT is Copyright (C) 2005-2022 Mike Pall.
+LuaJIT is Copyright (C) 2005-2023 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/third_party/luajit/luajit/README.md b/third_party/luajit/luajit/README.md
new file mode 100644
index 000000000..4e6463e94
--- /dev/null
+++ b/third_party/luajit/luajit/README.md
@@ -0,0 +1,415 @@
+# Name
+
+openresty/luajit2 - OpenResty's maintained branch of LuaJIT.
+
+Table of Contents
+=================
+
+* [Name](#name)
+* [Description](#description)
+* [OpenResty extensions](#openresty-extensions)
+ * [New Lua APIs](#new-lua-apis)
+ * [table.isempty](#tableisempty)
+ * [table.isarray](#tableisarray)
+ * [table.nkeys](#tablenkeys)
+ * [table.clone](#tableclone)
+ * [jit.prngstate](#jitprngstate)
+ * [thread.exdata](#threadexdata)
+ * [thread.exdata2](#threadexdata2)
+ * [New C API](#new-c-api)
+ * [lua_setexdata](#lua_setexdata)
+ * [lua_getexdata](#lua_getexdata)
+ * [lua_setexdata2](#lua_setexdata2)
+ * [lua_getexdata2](#lua_getexdata2)
+ * [lua_resetthread](#lua_resetthread)
+ * [New macros](#new-macros)
+ * [`OPENRESTY_LUAJIT`](#openresty_luajit)
+ * [`HAVE_LUA_RESETTHREAD`](#have_lua_resetthread)
+ * [Optimizations](#optimizations)
+ * [Updated JIT default parameters](#updated-jit-default-parameters)
+ * [String hashing](#string-hashing)
+ * [Updated bytecode options](#updated-bytecode-options)
+ * [New `-bL` option](#new--bl-option)
+ * [Updated `-bl` option](#updated--bl-option)
+ * [Miscellaneous](#miscellaneous)
+* [Copyright & License](#copyright--license)
+
+# Description
+
+This is the official OpenResty branch of LuaJIT. It is not to be considered a
+fork, since we still regularly synchronize changes from the upstream LuaJIT
+project (https://github.com/LuaJIT/LuaJIT).
+
+# OpenResty extensions
+
+Additionally to synchronizing upstream changes, we introduce our own changes
+which haven't been merged yet (or never will be). This document describes those
+changes that are specific to this branch.
+
+## New Lua APIs
+
+### table.isempty
+
+**syntax:** *res = isempty(tab)*
+
+Returns `true` when the given Lua table contains neither non-nil array elements
+nor non-nil key-value pairs, or `false` otherwise.
+
+This API can be JIT compiled.
+
+Usage:
+
+```lua
+local isempty = require "table.isempty"
+
+print(isempty({})) -- true
+print(isempty({nil, dog = nil})) -- true
+print(isempty({"a", "b"})) -- false
+print(isempty({nil, 3})) -- false
+print(isempty({cat = 3})) -- false
+```
+
+[Back to TOC](#table-of-contents)
+
+### table.isarray
+
+**syntax:** *res = isarray(tab)*
+
+Returns `true` when the given Lua table is a pure array-like Lua table, or
+`false` otherwise.
+
+Empty Lua tables are treated as arrays.
+
+This API can be JIT compiled.
+
+Usage:
+
+```lua
+local isarray = require "table.isarray"
+
+print(isarray{"a", true, 3.14}) -- true
+print(isarray{dog = 3}) -- false
+print(isarray{}) -- true
+```
+
+[Back to TOC](#table-of-contents)
+
+### table.nkeys
+
+**syntax:** *n = nkeys(tab)*
+
+Returns the total number of elements in a given Lua table (i.e. from both the
+array and hash parts combined).
+
+This API can be JIT compiled.
+
+Usage:
+
+```lua
+local nkeys = require "table.nkeys"
+
+print(nkeys({})) -- 0
+print(nkeys({ "a", nil, "b" })) -- 2
+print(nkeys({ dog = 3, cat = 4, bird = nil })) -- 2
+print(nkeys({ "a", dog = 3, cat = 4 })) -- 3
+```
+
+[Back to TOC](#table-of-contents)
+
+### table.clone
+
+**syntax:** *t = clone(tab)*
+
+Returns a shallow copy of the given Lua table.
+
+This API can be JIT compiled.
+
+Usage:
+
+```lua
+local clone = require "table.clone"
+
+local x = {x=12, y={5, 6, 7}}
+local y = clone(x)
+... use y ...
+```
+
+**Note:** We observe 7% over-all speedup in the edgelang-fan compiler's
+compiling speed whose Lua is generated by the fanlang compiler.
+
+**Note bis:** Deep cloning is planned to be supported by adding `true` as a
+second argument.
+
+[Back to TOC](#table-of-contents)
+
+### jit.prngstate
+
+**syntax:** *state = jit.prngstate(state?)*
+
+Returns (and optionally sets) the current PRNG state (an array of 8 Lua
+numbers with 32-bit integer values) currently used by the JIT compiler.
+
+When the `state` argument is non-nil, it is expected to be an array of up to 8
+unsigned Lua numbers, each with value less than 2\*\*32-1. This will set the
+current PRNG state and return the state that was overridden.
+
+**Note:** For backward compatibility, `state` argument can also be an unsigned
+Lua number less than 2\*\*32-1.
+
+**Note:** When the `state` argument is an array and less than 8 numbers, or the
+`state` is a number, the remaining positions are filled with zeros.
+
+Usage:
+
+```lua
+local state = jit.prngstate()
+local oldstate = jit.prngstate{ a, b, c, ... }
+
+jit.prngstate(32) -- {32, 0, 0, 0, 0, 0, 0, 0}
+jit.prngstate{432, 23, 50} -- {432, 23, 50, 0, 0, 0, 0, 0}
+```
+
+**Note:** This API has no effect if LuaJIT is compiled with
+`-DLUAJIT_DISABLE_JIT`, and will return a table with all `0`.
+
+[Back to TOC](#table-of-contents)
+
+### thread.exdata
+
+**syntax:** *exdata = th_exdata(data?)*
+
+This API allows for embedding user data into a thread (`lua_State`).
+
+The retrieved `exdata` value on the Lua land is represented as a cdata object
+of the ctype `void*`.
+
+As of this version, retrieving the `exdata` (i.e. `th_exdata()` without any
+argument) can be JIT compiled.
+
+Usage:
+
+```lua
+local th_exdata = require "thread.exdata"
+
+th_exdata(0xdeadbeefLL) -- set the exdata of the current Lua thread
+local exdata = th_exdata() -- fetch the exdata of the current Lua thread
+```
+
+Also available are the following public C API functions for manipulating
+`exdata` on the C land:
+
+```C
+void lua_setexdata(lua_State *L, void *exdata);
+void *lua_getexdata(lua_State *L);
+```
+
+The `exdata` pointer is initialized to `NULL` when the main thread is created.
+Any child Lua thread will inherit its parent's `exdata`, but still can override
+it.
+
+**Note:** This API will not be available if LuaJIT is compiled with
+`-DLUAJIT_DISABLE_FFI`.
+
+**Note bis:** This API is used internally by the OpenResty core, and it is
+strongly discouraged to use it yourself in the context of OpenResty.
+
+[Back to TOC](#table-of-contents)
+
+### thread.exdata2
+
+**syntax:** *exdata = th_exdata2(data?)*
+
+Similar to `thread.exdata` but for a 2nd separate user data as a pointer value.
+
+[Back to TOC](#table-of-contents)
+
+## New C API
+
+### lua_setexdata
+
+```C
+void lua_setexdata(lua_State *L, void *exdata);
+```
+
+Sets extra user data as a pointer value to the current Lua state or thread.
+
+[Back to TOC](#table-of-contents)
+
+### lua_getexdata
+
+```C
+void *lua_getexdata(lua_State *L);
+```
+
+Gets extra user data as a pointer value to the current Lua state or thread.
+
+[Back to TOC](#table-of-contents)
+
+### lua_setexdata2
+
+```C
+void lua_setexdata2(lua_State *L, void *exdata2);
+```
+
+Similar to `lua_setexdata` but for a 2nd user data (pointer) value.
+
+[Back to TOC](#table-of-contents)
+
+### lua_getexdata2
+
+```C
+void *lua_getexdata2(lua_State *L);
+```
+
+Similar to `lua_getexdata` but for a 2nd user data (pointer) value.
+
+[Back to TOC](#table-of-contents)
+
+### lua_resetthread
+
+```C
+void lua_resetthread(lua_State *L, lua_State *th);
+```
+
+Resets the state of `th` to the initial state of a newly created Lua thread
+object as returned by `lua_newthread()`. This is mainly for Lua thread
+recycling. Lua threads in arbitrary states (like yielded or errored) can be
+reset properly.
+
+The current implementation does not shrink the already allocated Lua stack
+though. It only clears it.
+
+[Back to TOC](#table-of-contents)
+
+## New macros
+
+The macros described in this section have been added to this branch.
+
+[Back to TOC](#table-of-contents)
+
+### `OPENRESTY_LUAJIT`
+
+In the `luajit.h` header file, a new macro `OPENRESTY_LUAJIT` was defined to
+help distinguishing this OpenResty-specific branch of LuaJIT.
+
+### `HAVE_LUA_RESETTHREAD`
+
+This macro is set when the `lua_resetthread` C API is present.
+
+[Back to TOC](#table-of-contents)
+
+## Optimizations
+
+### Updated JIT default parameters
+
+We use more appressive default JIT compiler options to help large OpenResty
+Lua applications.
+
+The following `jit.opt` options are used by default:
+
+```lua
+maxtrace=8000
+maxrecord=16000
+minstitch=3
+maxmcode=40960 -- in KB
+```
+
+[Back to TOC](#table-of-contents)
+
+### String hashing
+
+This optimization only applies to Intel CPUs supporting the SSE 4.2 instruction
+sets. For such CPUs, and when this branch is compiled with `-msse4.2`, the
+string hashing function used for strings interning will be based on an
+optimized crc32 implementation (see `lj_str_new()`).
+
+This optimization still provides constant-time hashing complexity (`O(n)`), but
+makes hash collision attacks harder for strings up to 127 bytes of size.
+
+[Back to TOC](#table-of-contents)
+
+## Updated bytecode options
+
+### New `-bL` option
+
+The bytecode option `L` was added to display Lua sources line numbers.
+
+For example, `luajit -bL -e 'print(1)'` now produces bytecode dumps like below:
+
+```
+-- BYTECODE -- "print(1)":0-1
+0001 [1] GGET 0 0 ; "print"
+0002 [1] KSHORT 1 1
+0003 [1] CALL 0 1 2
+0004 [1] RET0 0 1
+```
+
+The `[N]` column corresponds to the Lua source line number. For example, `[1]`
+means "the first source line".
+
+[Back to TOC](#table-of-contents)
+
+### Updated `-bl` option
+
+The bytecode option `l` was updated to display the constant tables of each Lua
+prototype.
+
+For example, `luajit -bl a.lua'` now produces bytecode dumps like below:
+
+```
+-- BYTECODE -- a.lua:0-48
+KGC 0 "print"
+KGC 1 "hi"
+KGC 2 table
+KGC 3 a.lua:17
+KN 1 1000000
+KN 2 1.390671161567e-309
+...
+```
+
+[Back to TOC](#table-of-contents)
+
+## Miscellaneous
+
+* Increased the maximum number of allowed upvalues from 60 to 120.
+* Various important bugfixes in the JIT compiler and Lua VM which have
+ not been merged in upstream LuaJIT.
+* Removed the GCC 4 requirement for x86 on older systems such as Solaris i386.
+* In the `Makefile` file, make sure we always install the symlink for "luajit"
+ even for alpha or beta versions.
+* Applied a patch to fix DragonFlyBSD compatibility. Note: this is not an
+ officially supported target.
+* feature: jit.dump: output Lua source location after every BC.
+* feature: added internal memory-buffer-based trace entry/exit/start-recording
+ event logging, mainly for debugging bugs in the JIT compiler. it requires
+ `-DLUA_USE_TRACE_LOGS` when building LuaJIT.
+* feature: save `g->jit_base` to `g->saved_jit_base` before `lj_err_throw`
+ clears `g->jit_base` which makes it impossible to get Lua backtrace in such
+ states.
+
+[Back to TOC](#table-of-contents)
+
+# Copyright & License
+
+LuaJIT is a Just-In-Time (JIT) compiler for the Lua programming language.
+
+Project Homepage: http://luajit.org/
+
+LuaJIT is Copyright (C) 2005-2019 Mike Pall.
+
+Additional patches for OpenResty are copyrighted by Yichun Zhang and OpenResty
+Inc.:
+
+Copyright (C) 2017-2019 Yichun Zhang. All rights reserved.
+
+Copyright (C) 2017-2019 OpenResty Inc. All rights reserved.
+
+LuaJIT is free software, released under the MIT license.
+See full Copyright Notice in the COPYRIGHT file or in luajit.h.
+
+Documentation for the official LuaJIT is available in HTML format.
+Please point your favorite browser to:
+
+ doc/luajit.html
+
+[Back to TOC](#table-of-contents)
diff --git a/third_party/luajit/luajit/doc/bluequad-print.css b/third_party/luajit/luajit/doc/bluequad-print.css
index a49d309ff..4a1392789 100644
--- a/third_party/luajit/luajit/doc/bluequad-print.css
+++ b/third_party/luajit/luajit/doc/bluequad-print.css
@@ -1,4 +1,4 @@
-/* Copyright (C) 2004-2022 Mike Pall.
+/* Copyright (C) 2004-2023 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/third_party/luajit/luajit/doc/bluequad.css b/third_party/luajit/luajit/doc/bluequad.css
index 4c1a9082e..7399f6251 100644
--- a/third_party/luajit/luajit/doc/bluequad.css
+++ b/third_party/luajit/luajit/doc/bluequad.css
@@ -1,4 +1,4 @@
-/* Copyright (C) 2004-2022 Mike Pall.
+/* Copyright (C) 2004-2023 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.
@@ -206,11 +206,9 @@ img.right {
.ext {
color: #ff8000;
}
-.new {
- font-size: 6pt;
- vertical-align: middle;
- background: #ff8000;
- color: #ffffff;
+.note {
+ padding: 0.5em 1em;
+ border-left: 3px solid #bfcfff;
}
#site {
clear: both;
diff --git a/third_party/luajit/luajit/doc/contact.html b/third_party/luajit/luajit/doc/contact.html
index 6d609286e..cc4d8c723 100644
--- a/third_party/luajit/luajit/doc/contact.html
+++ b/third_party/luajit/luajit/doc/contact.html
@@ -3,7 +3,7 @@
Contains the version number of the LuaJIT core. Version xx.yy.zz
-is represented by the decimal number xxyyzz.
+is represented by the decimal number xxyyzz.
+DEPRECATED after the switch to
+» rolling releases. zz is frozen at 99.
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
-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.
-
-
-
-DirectX/Direct3D (up to version 9) sets the x87 FPU to single-precision
-mode by default. This violates the Windows ABI and interferes with the
-operation of many programs — LuaJIT is affected, too. Please make
-sure you always use the D3DCREATE_FPU_PRESERVE flag when
-initializing Direct3D.
-
-Direct3D version 10 or higher do not show this behavior anymore.
-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.
-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
-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 stop your program. That's similar
-to when it's stuck running inside a C function under the Lua interpreter.
-
-
-
-
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 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),
-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 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.
-LuaJIT is only distributed as a source package. This page explains
-how to build and install LuaJIT with different operating systems
-and C compilers.
+LuaJIT is only distributed as source code — get it from the
+» git repository. This page explains how to build
+and install the LuaJIT binary and library for different operating systems.
For the impatient (on POSIX systems):
@@ -90,201 +90,21 @@
Installation
Requirements
-
Systems
-LuaJIT currently builds out-of-the box on most systems:
+LuaJIT currently builds out-of-the box on most systems. Please check the
+supported operating systems and CPU architectures on the
+» status page.
-The codebase has compatibility defines for some more systems, but
-without official support.
-
-
Toolchains
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.
+Batch files are provided for MSVC++ builds and console cross-builds.
Configuring LuaJIT
@@ -294,7 +114,6 @@
Configuring LuaJIT
hold all user-configurable settings:
-
src/luaconf.h sets some configuration variables.
Makefile has settings for installing LuaJIT (POSIX
only).
src/Makefile has settings for compiling LuaJIT
@@ -317,23 +136,11 @@
Configuring LuaJIT
POSIX Systems (Linux, macOS, *BSD etc.)
Prerequisites
-Depending on your distribution, you may need to install a package for
-GCC, the development headers and/or a complete SDK. E.g. on a current
-Debian/Ubuntu, install libc6-dev with the package manager.
+Depending on your distribution, you may need to install a package for a
+compiler (GCC or Clang/LLVM), the development headers and/or a complete SDK.
+E.g. on a current Debian/Ubuntu, install build-essential with the
+package manager.
-
-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):
-
GCC plus the required development headers.
Or install Microsoft's Visual Studio (MSVC).
-
-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 Command Prompt" (either x86 or x64), cd to the
-directory where you've unpacked the sources and run these commands:
+Open a "Visual Studio Command Prompt" (x86, x64 or ARM64), cd to the
+directory with the source code and run these commands:
cd src
@@ -412,11 +214,14 @@
Building with MSVC
Check the msvcbuild.bat file for more options.
Then follow the installation instructions below.
+
+For an x64 to ARM64 cross-build run this first: vcvarsall.bat x64_arm64
+
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 of the git repository
-or where you've unpacked the sources. Then run this command for MinGW:
+are in your path. Then cd to the directory of the git repository.
+Then run this command for MinGW:
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:
+Then cd to the src directory below the source code
+and run the build command given in the table:
LuaJIT has been successfully used as a scripting middleware in
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
-and an unmatched low memory footprint.
+trading platforms and many other specialty applications.
+
+
+LuaJIT is part of a hundred million web sites, huge SaaS installations,
+network switches, set-top boxes and other embedded devices. You've probably
+already used LuaJIT without knowing about it.
+
+
+LuaJIT scales from embedded devices, smartphones, desktops up to server
+farms. It combines high flexibility with high performance and an unmatched
+low memory footprint.
LuaJIT has been in continuous development since 2005. It's widely
@@ -220,7 +193,7 @@
LuaJIT has only a single stand-alone executable, called luajit on
POSIX systems or luajit.exe on Windows. It can be used to run simple
@@ -302,7 +303,7 @@
-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
-
-LuaJIT ought to run all Lua 5.1-compatible source code just fine.
-It's considered a serious bug if the VM crashes or produces unexpected
-results — please report this.
-
-
-Known incompatibilities and issues in LuaJIT 2.0:
-
-
-
-There are some differences in implementation-defined behavior.
-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.
-
-
-The Lua debug API is missing a couple of features (return
-hooks for non-Lua functions) and shows slightly different behavior
-in LuaJIT (no per-coroutine hooks, no tail call counting).
-