From 3b3d427ae3bdb56c46ee75f7f596c837e97c5043 Mon Sep 17 00:00:00 2001 From: Mike Pall Date: Mon, 15 Aug 2022 14:16:14 +0200 Subject: [PATCH 1/8] Patch luajit.pc with INSTALL_INC, if customized. Suggested by Henrique Bucher. --- Makefile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 35da2e73..0004c2c5 100644 --- a/Makefile +++ b/Makefile @@ -32,7 +32,8 @@ DPREFIX= $(DESTDIR)$(PREFIX) 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 @@ -77,6 +78,9 @@ UNINSTALL= $(RM) 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 From 03080b795aa3496ed62d4a0697c9f4767e7ca7e5 Mon Sep 17 00:00:00 2001 From: Mike Pall Date: Mon, 15 Aug 2022 14:16:58 +0200 Subject: [PATCH 2/8] Add -F option to override filename in jit.bcsave (luajit -b). Suggested by Mathias Westerdahl. --- doc/running.html | 1 + src/jit/bcsave.lua | 29 ++++++++++++++++++++++------- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/doc/running.html b/doc/running.html index 177e6357..91a719f9 100644 --- a/doc/running.html +++ b/doc/running.html @@ -111,6 +111,7 @@ are accepted:
  • -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.
  • diff --git a/src/jit/bcsave.lua b/src/jit/bcsave.lua index f8ed3a1b..90fe9daf 100644 --- a/src/jit/bcsave.lua +++ b/src/jit/bcsave.lua @@ -33,6 +33,7 @@ Save LuaJIT bytecode: luajit -b[options] input output -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. @@ -49,10 +50,22 @@ local function check(ok, ...) 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) @@ -604,13 +617,13 @@ end ------------------------------------------------------------------------------ -local function bclist(input, output) - local f = readfile(input) +local function bclist(ctx, input, output) + local f = readfile(ctx, input) require("jit.bc").dump(f, savefile(output, "w"), true) 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 @@ -663,6 +676,8 @@ local function docmd(...) 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 @@ -674,7 +689,7 @@ local function docmd(...) end if list then if #arg == 0 or #arg > 2 then usage() end - bclist(arg[1], arg[2] or "-") + bclist(ctx, arg[1], arg[2] or "-") else if #arg ~= 2 then usage() end bcsave(ctx, arg[1], arg[2]) From e19db605129ea755b325e4396f58141dbdfd23a0 Mon Sep 17 00:00:00 2001 From: Mike Pall Date: Mon, 12 Sep 2022 11:16:20 +0200 Subject: [PATCH 3/8] Fix QNX build. Note: this is not an officially supported target. Contributed by Wen Yang. --- src/lj_arch.h | 3 +++ src/lj_prng.c | 2 +- src/lj_profile.c | 4 ++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/lj_arch.h b/src/lj_arch.h index 882c99cb..5fb798d9 100644 --- a/src/lj_arch.h +++ b/src/lj_arch.h @@ -93,6 +93,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 diff --git a/src/lj_prng.c b/src/lj_prng.c index 9e57505e..01935e57 100644 --- a/src/lj_prng.c +++ b/src/lj_prng.c @@ -125,7 +125,7 @@ static PRGR libfunc_rgr; #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 diff --git a/src/lj_profile.c b/src/lj_profile.c index f0af91cb..4a13537d 100644 --- a/src/lj_profile.c +++ b/src/lj_profile.c @@ -185,7 +185,11 @@ static void profile_timer_start(ProfileState *ps) 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); From b907ffc49f564c68a7659bcd52a33abdd8650d2a Mon Sep 17 00:00:00 2001 From: Mike Pall Date: Tue, 13 Sep 2022 11:21:30 +0200 Subject: [PATCH 4/8] Remove dead Wiki links. The lost content may be resurrected later. --- doc/contact.html | 2 -- doc/ext_c_api.html | 2 -- doc/ext_ffi.html | 2 -- doc/ext_ffi_api.html | 2 -- doc/ext_ffi_semantics.html | 2 -- doc/ext_ffi_tutorial.html | 2 -- doc/ext_jit.html | 2 -- doc/extensions.html | 2 -- doc/faq.html | 3 --- doc/install.html | 2 -- doc/luajit.html | 2 -- doc/running.html | 2 -- doc/status.html | 2 -- 13 files changed, 27 deletions(-) diff --git a/doc/contact.html b/doc/contact.html index 5629eb23..5a5a8691 100644 --- a/doc/contact.html +++ b/doc/contact.html @@ -46,8 +46,6 @@
  • FAQ
  • -Wiki » -
  • Mailing List »
  • diff --git a/doc/ext_c_api.html b/doc/ext_c_api.html index b328047a..6b5e06d3 100644 --- a/doc/ext_c_api.html +++ b/doc/ext_c_api.html @@ -46,8 +46,6 @@
  • FAQ
  • -Wiki » -
  • Mailing List »
  • diff --git a/doc/ext_ffi.html b/doc/ext_ffi.html index 04b78d98..82ee9425 100644 --- a/doc/ext_ffi.html +++ b/doc/ext_ffi.html @@ -46,8 +46,6 @@
  • FAQ
  • -Wiki » -
  • Mailing List »
  • diff --git a/doc/ext_ffi_api.html b/doc/ext_ffi_api.html index 962db6dc..2e0840df 100644 --- a/doc/ext_ffi_api.html +++ b/doc/ext_ffi_api.html @@ -51,8 +51,6 @@ td.abiparam { font-weight: bold; width: 6em; }
  • FAQ
  • -Wiki » -
  • Mailing List »
  • diff --git a/doc/ext_ffi_semantics.html b/doc/ext_ffi_semantics.html index 6c6f8ad7..e3491696 100644 --- a/doc/ext_ffi_semantics.html +++ b/doc/ext_ffi_semantics.html @@ -51,8 +51,6 @@ td.convop { font-style: italic; width: 40%; }
  • FAQ
  • -Wiki » -
  • Mailing List »
  • diff --git a/doc/ext_ffi_tutorial.html b/doc/ext_ffi_tutorial.html index de6b6f5e..18b78d8b 100644 --- a/doc/ext_ffi_tutorial.html +++ b/doc/ext_ffi_tutorial.html @@ -53,8 +53,6 @@ td.idiomlua b { font-weight: normal; color: #2142bf; }
  • FAQ
  • -Wiki » -
  • Mailing List »
  • diff --git a/doc/ext_jit.html b/doc/ext_jit.html index 8f58a0c7..7778e618 100644 --- a/doc/ext_jit.html +++ b/doc/ext_jit.html @@ -46,8 +46,6 @@
  • FAQ
  • -Wiki » -
  • Mailing List »
  • diff --git a/doc/extensions.html b/doc/extensions.html index 3ed13804..19ec9907 100644 --- a/doc/extensions.html +++ b/doc/extensions.html @@ -63,8 +63,6 @@ td.excinterop {
  • FAQ
  • -Wiki » -
  • Mailing List »
  • diff --git a/doc/faq.html b/doc/faq.html index 0b4b2df0..09cfbf09 100644 --- a/doc/faq.html +++ b/doc/faq.html @@ -49,8 +49,6 @@ dd { margin-left: 1.5em; }
  • FAQ
  • -Wiki » -
  • Mailing List »
  • @@ -61,7 +59,6 @@ dd { margin-left: 1.5em; } diff --git a/doc/luajit.html b/doc/luajit.html index 88d4c194..ecb13fa8 100644 --- a/doc/luajit.html +++ b/doc/luajit.html @@ -131,8 +131,6 @@ table.feature small {
  • FAQ
  • -Wiki » -
  • Mailing List »
  • diff --git a/doc/running.html b/doc/running.html index 3f408141..5689249f 100644 --- a/doc/running.html +++ b/doc/running.html @@ -68,8 +68,6 @@ td.param_default {
  • FAQ
  • -Wiki » -
  • Mailing List »
  • diff --git a/doc/status.html b/doc/status.html index 7ecedf3d..62a0d40a 100644 --- a/doc/status.html +++ b/doc/status.html @@ -49,8 +49,6 @@ ul li { padding-bottom: 0.3em; }
  • FAQ
  • -Wiki » -
  • Mailing List »
  • From 46e62cd963a426e83a60f691dcbbeb742c7b3ba2 Mon Sep 17 00:00:00 2001 From: Mike Pall Date: Tue, 13 Sep 2022 11:32:53 +0200 Subject: [PATCH 5/8] Fix last edit. --- doc/faq.html | 1 - 1 file changed, 1 deletion(-) diff --git a/doc/faq.html b/doc/faq.html index 09cfbf09..5427a5c8 100644 --- a/doc/faq.html +++ b/doc/faq.html @@ -59,7 +59,6 @@ dd { margin-left: 1.5em; }
    • The » LuaJIT mailing list focuses on topics related to LuaJIT.
    • -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 From fffd3eafc4d71f3c60160f60a9744a8012fe2a90 Mon Sep 17 00:00:00 2001 From: Mike Pall Date: Tue, 13 Sep 2022 13:43:03 +0200 Subject: [PATCH 6/8] Fix compiler warnings. Reported by gan74. --- src/lib_buffer.c | 8 ++++---- src/lj_ffrecord.c | 4 ++-- src/lj_record.c | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/lib_buffer.c b/src/lib_buffer.c index aad8e7eb..d6ff1346 100644 --- a/src/lib_buffer.c +++ b/src/lib_buffer.c @@ -128,7 +128,7 @@ LJLIB_CF(buffer_method_put) LJLIB_REC(.) 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 @@ LJLIB_CF(buffer_method_put) LJLIB_REC(.) 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 @@ LJLIB_CF(buffer_method_get) LJLIB_REC(.) 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 @@ LJLIB_CF(buffer_method_get) LJLIB_REC(.) } 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 diff --git a/src/lj_ffrecord.c b/src/lj_ffrecord.c index 60c1d84f..022de1aa 100644 --- a/src/lj_ffrecord.c +++ b/src/lj_ffrecord.c @@ -1117,7 +1117,7 @@ static LJ_AINLINE TRef recff_sbufx_len(jit_State *J, TRef trr, TRef trw) } /* 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); @@ -1135,7 +1135,7 @@ static TRef recff_sbufx_write(jit_State *J, TRef ud) } /* 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 --git a/src/lj_record.c b/src/lj_record.c index 92bdbfc9..5d02d24a 100644 --- a/src/lj_record.c +++ b/src/lj_record.c @@ -1964,7 +1964,7 @@ static void rec_varg(jit_State *J, BCReg dst, ptrdiff_t nresults) 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)); From dad04f1754723e76ba9dcf9f401f3134a0cd3972 Mon Sep 17 00:00:00 2001 From: Mike Pall Date: Wed, 14 Sep 2022 12:26:53 +0200 Subject: [PATCH 7/8] Fix trace join to BC_JLOOP originating from BC_ITERN. Reported by OpenResty Inc. --- src/lj_record.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lj_record.c b/src/lj_record.c index 5d02d24a..bfd41236 100644 --- a/src/lj_record.c +++ b/src/lj_record.c @@ -2572,7 +2572,8 @@ void lj_record_ins(jit_State *J) 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: From 6c4826f12c4d33b8b978004bc681eb1eef2be977 Mon Sep 17 00:00:00 2001 From: Mike Pall Date: Tue, 4 Oct 2022 12:04:17 +0200 Subject: [PATCH 8/8] ARM64: Fix IR_SLOAD assembly. Reported by Gate88. --- src/lj_asm_arm64.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lj_asm_arm64.h b/src/lj_asm_arm64.h index 1f44d023..4b7066f2 100644 --- a/src/lj_asm_arm64.h +++ b/src/lj_asm_arm64.h @@ -1201,7 +1201,7 @@ dotypecheck: tmp = ra_scratch(as, allow); rset_clear(allow, tmp); } - if (irt_isnum(t) && !(ir->op2 & IRSLOAD_CONVERT)) + if (ra_hasreg(dest) && irt_isnum(t) && !(ir->op2 & IRSLOAD_CONVERT)) 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);