This commit is contained in:
Sasha Szpakowski
2026-06-22 18:57:43 -03:00
parent c4192fe9ba
commit 774ba85a81
211 changed files with 1708 additions and 847 deletions
+1 -4
View File
@@ -7,7 +7,7 @@
# Also works with MinGW and Cygwin on Windows.
# Please check msvcbuild.bat for building with MSVC on Windows.
#
# Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
# Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
##############################################################################
MAJVER= 2
@@ -302,9 +302,6 @@ endif
ifneq (,$(INSTALL_LJLIBD))
TARGET_XCFLAGS+= -DLUA_LJDIR=\"$(INSTALL_LJLIBD)\"
endif
ifeq (,$(shell $(TARGET_CC) -o /dev/null -c -x c /dev/null -fno-strict-float-cast-overflow 2>/dev/null || echo 1))
TARGET_XCFLAGS+= -fno-strict-float-cast-overflow
endif
##############################################################################
# Target system detection.
+1 -1
View File
@@ -1,6 +1,6 @@
/*
** LuaJIT VM builder.
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
**
** This is a tool to build the hand-tuned assembler code required for
** LuaJIT's bytecode interpreter. It supports a variety of output formats
+1 -1
View File
@@ -1,6 +1,6 @@
/*
** LuaJIT VM builder.
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
*/
#ifndef _BUILDVM_H
+1 -1
View File
@@ -1,6 +1,6 @@
/*
** LuaJIT VM builder: Assembler source code emitter.
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
*/
#include "buildvm.h"
+1 -1
View File
@@ -1,6 +1,6 @@
/*
** LuaJIT VM builder: IR folding hash table generator.
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
*/
#include "buildvm.h"
+1 -1
View File
@@ -1,6 +1,6 @@
/*
** LuaJIT VM builder: library definition compiler.
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
*/
#include "buildvm.h"
+1 -1
View File
@@ -1,6 +1,6 @@
/*
** LuaJIT VM builder: PE object emitter.
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
**
** Only used for building on Windows, since we cannot assume the presence
** of a suitable assembler. The host and target byte order must match.
+1 -1
View File
@@ -2,7 +2,7 @@
-- Lua script to dump the bytecode of the library functions written in Lua.
-- The resulting 'buildvm_libbc.h' is used for the build process of LuaJIT.
----------------------------------------------------------------------------
-- Copyright (C) 2005-2025 Mike Pall. All rights reserved.
-- Copyright (C) 2005-2026 Mike Pall. All rights reserved.
-- Released under the MIT license. See Copyright Notice in luajit.h
----------------------------------------------------------------------------
+3 -3
View File
@@ -2,7 +2,7 @@
-- Lua script to generate a customized, minified version of Lua.
-- The resulting 'minilua' is used for the build process of LuaJIT.
----------------------------------------------------------------------------
-- Copyright (C) 2005-2025 Mike Pall. All rights reserved.
-- Copyright (C) 2005-2026 Mike Pall. All rights reserved.
-- Released under the MIT license. See Copyright Notice in luajit.h
----------------------------------------------------------------------------
@@ -90,11 +90,11 @@ static int bswap(lua_State *L){
UB b=barg(L,1);b=(b>>24)|((b>>8)&0xff00)|((b&0xff00)<<8)|(b<<24);BRET(b)}
static int tohex(lua_State *L){
UB b=barg(L,1);
int n=lua_isnone(L,2)?8:(int)barg(L,2);
UB n=lua_isnone(L,2)?8:barg(L,2);
const char *hexdigits="0123456789abcdef";
char buf[8];
int i;
if(n<0){n=-n;hexdigits="0123456789ABCDEF";}
if((int)n<0){n=~n+1;hexdigits="0123456789ABCDEF";}
if(n>8)n=8;
for(i=(int)n;--i>=0;){buf[i]=hexdigits[b&15];b>>=4;}
lua_pushlstring(L,buf,(size_t)n);
+1 -1
View File
@@ -1,7 +1,7 @@
----------------------------------------------------------------------------
-- Lua script to embed the rolling release version in luajit.h.
----------------------------------------------------------------------------
-- Copyright (C) 2005-2025 Mike Pall. All rights reserved.
-- Copyright (C) 2005-2026 Mike Pall. All rights reserved.
-- Released under the MIT license. See Copyright Notice in luajit.h
----------------------------------------------------------------------------
+2 -2
View File
@@ -7722,11 +7722,11 @@ static int bswap(lua_State*L){
UB b=barg(L,1);b=(b>>24)|((b>>8)&0xff00)|((b&0xff00)<<8)|(b<<24);BRET(b)}
static int tohex(lua_State*L){
UB b=barg(L,1);
int n=lua_isnone(L,2)?8:(int)barg(L,2);
UB n=lua_isnone(L,2)?8:barg(L,2);
const char*hexdigits="0123456789abcdef";
char buf[8];
int i;
if(n<0){n=-n;hexdigits="0123456789ABCDEF";}
if((int)n<0){n=~n+1;hexdigits="0123456789ABCDEF";}
if(n>8)n=8;
for(i=(int)n;--i>=0;){buf[i]=hexdigits[b&15];b>>=4;}
lua_pushlstring(L,buf,(size_t)n);
+1 -1
View File
@@ -1,7 +1,7 @@
----------------------------------------------------------------------------
-- LuaJIT bytecode listing module.
--
-- Copyright (C) 2005-2025 Mike Pall. All rights reserved.
-- Copyright (C) 2005-2026 Mike Pall. All rights reserved.
-- Released under the MIT license. See Copyright Notice in luajit.h
----------------------------------------------------------------------------
--
+21 -13
View File
@@ -1,7 +1,7 @@
----------------------------------------------------------------------------
-- LuaJIT module to save/list bytecode.
--
-- Copyright (C) 2005-2025 Mike Pall. All rights reserved.
-- Copyright (C) 2005-2026 Mike Pall. All rights reserved.
-- Released under the MIT license. See Copyright Notice in luajit.h
----------------------------------------------------------------------------
--
@@ -165,6 +165,8 @@ extern "C"
#endif
#ifdef _WIN32
__declspec(dllexport)
#elif (defined(__ELF__) || defined(__MACH__) || defined(__psp2__)) && !((defined(__sun__) && defined(__svr4__)) || defined(__CELLOS_LV2__))
__attribute__((visibility("default")))
#endif
const unsigned char %s%s[] = {
]], LJBC_PREFIX, ctx.modname))
@@ -465,9 +467,11 @@ typedef struct {
mach_segment_command_64 seg;
mach_section_64 sec;
mach_symtab_command sym;
} mach_obj_64;
typedef struct {
mach_nlist_64 sym_entry;
uint8_t space[4096];
} mach_obj_64;
} mach_obj_64_tail;
]]
local symname = '_'..LJBC_PREFIX..ctx.modname
local cputype, cpusubtype = 0x01000007, 3
@@ -479,7 +483,10 @@ typedef struct {
-- Create Mach-O object and fill in header.
local o = ffi.new("mach_obj_64")
local mach_size = aligned(ffi.offsetof(o, "space")+#symname+2, 8)
local t = ffi.new("mach_obj_64_tail")
local ofs_bc = ffi.sizeof(o)
local sz_bc = aligned(#s, 8)
local ofs_sym = ofs_bc + sz_bc
-- Fill in sections and symbols.
o.hdr.magic = 0xfeedfacf
@@ -491,7 +498,7 @@ typedef struct {
o.seg.cmd = 0x19
o.seg.cmdsize = ffi.sizeof(o.seg)+ffi.sizeof(o.sec)
o.seg.vmsize = #s
o.seg.fileoff = mach_size
o.seg.fileoff = ofs_bc
o.seg.filesize = #s
o.seg.maxprot = 1
o.seg.initprot = 1
@@ -499,22 +506,23 @@ typedef struct {
ffi.copy(o.sec.sectname, "__data")
ffi.copy(o.sec.segname, "__DATA")
o.sec.size = #s
o.sec.offset = mach_size
o.sec.offset = ofs_bc
o.sym.cmd = 2
o.sym.cmdsize = ffi.sizeof(o.sym)
o.sym.symoff = ffi.offsetof(o, "sym_entry")
o.sym.symoff = ofs_sym
o.sym.nsyms = 1
o.sym.stroff = ffi.offsetof(o, "sym_entry")+ffi.sizeof(o.sym_entry)
o.sym.stroff = ofs_sym + ffi.offsetof(t, "space")
o.sym.strsize = aligned(#symname+2, 8)
o.sym_entry.type = 0xf
o.sym_entry.sect = 1
o.sym_entry.strx = 1
ffi.copy(o.space+1, symname)
t.sym_entry.type = 0xf
t.sym_entry.sect = 1
t.sym_entry.strx = 1
ffi.copy(t.space+1, symname)
-- Write Mach-O object file.
local fp = savefile(output, "wb")
fp:write(ffi.string(o, mach_size))
bcsave_tail(fp, output, s)
fp:write(ffi.string(o, ofs_bc))
fp:write(s, ("\0"):rep(sz_bc - #s))
bcsave_tail(fp, output, ffi.string(t, ffi.offsetof(t, "space") + o.sym.strsize))
end
local function bcsave_obj(ctx, output, s)
+1 -1
View File
@@ -1,7 +1,7 @@
----------------------------------------------------------------------------
-- LuaJIT ARM disassembler module.
--
-- Copyright (C) 2005-2025 Mike Pall. All rights reserved.
-- Copyright (C) 2005-2026 Mike Pall. All rights reserved.
-- Released under the MIT license. See Copyright Notice in luajit.h
----------------------------------------------------------------------------
-- This is a helper module used by the LuaJIT machine code dumper module.
+4 -4
View File
@@ -1,7 +1,7 @@
----------------------------------------------------------------------------
-- LuaJIT ARM64 disassembler module.
--
-- Copyright (C) 2005-2025 Mike Pall. All rights reserved.
-- Copyright (C) 2005-2026 Mike Pall. All rights reserved.
-- Released under the MIT license. See Copyright Notice in luajit.h
--
-- Contributed by Djordje Kovacevic and Stefan Pejic from RT-RK.com.
@@ -485,15 +485,15 @@ local map_ls = { -- Loads and stores.
shift = 30, mask = 3,
[0] = {
shift = 22, mask = 3,
[0] = "strbDwzU", "ldrbDwzU"
[0] = "strbDwzU", "ldrbDwzU", "ldrsbDwzU", "ldrsbDxzU"
},
{
shift = 22, mask = 3,
[0] = "strhDwzU", "ldrhDwzU"
[0] = "strhDwzU", "ldrhDwzU", "ldrshDwzU", "ldrshDxzU"
},
{
shift = 22, mask = 3,
[0] = "strDwzU", "ldrDwzU"
[0] = "strDwzU", "ldrDwzU", "ldrswDxzU"
},
{
shift = 22, mask = 3,
+1 -1
View File
@@ -1,7 +1,7 @@
----------------------------------------------------------------------------
-- LuaJIT ARM64BE disassembler wrapper module.
--
-- Copyright (C) 2005-2025 Mike Pall. All rights reserved.
-- Copyright (C) 2005-2026 Mike Pall. All rights reserved.
-- Released under the MIT license. See Copyright Notice in luajit.h
----------------------------------------------------------------------------
-- ARM64 instructions are always little-endian. So just forward to the
+1 -1
View File
@@ -1,7 +1,7 @@
----------------------------------------------------------------------------
-- LuaJIT MIPS disassembler module.
--
-- Copyright (C) 2005-2025 Mike Pall. All rights reserved.
-- Copyright (C) 2005-2026 Mike Pall. All rights reserved.
-- Released under the MIT/X license. See Copyright Notice in luajit.h
----------------------------------------------------------------------------
-- This is a helper module used by the LuaJIT machine code dumper module.
+1 -1
View File
@@ -1,7 +1,7 @@
----------------------------------------------------------------------------
-- LuaJIT MIPS64 disassembler wrapper module.
--
-- Copyright (C) 2005-2025 Mike Pall. All rights reserved.
-- Copyright (C) 2005-2026 Mike Pall. All rights reserved.
-- Released under the MIT license. See Copyright Notice in luajit.h
----------------------------------------------------------------------------
-- This module just exports the big-endian functions from the
+1 -1
View File
@@ -1,7 +1,7 @@
----------------------------------------------------------------------------
-- LuaJIT MIPS64EL disassembler wrapper module.
--
-- Copyright (C) 2005-2025 Mike Pall. All rights reserved.
-- Copyright (C) 2005-2026 Mike Pall. All rights reserved.
-- Released under the MIT license. See Copyright Notice in luajit.h
----------------------------------------------------------------------------
-- This module just exports the little-endian functions from the
+1 -1
View File
@@ -1,7 +1,7 @@
----------------------------------------------------------------------------
-- LuaJIT MIPS64R6 disassembler wrapper module.
--
-- Copyright (C) 2005-2025 Mike Pall. All rights reserved.
-- Copyright (C) 2005-2026 Mike Pall. All rights reserved.
-- Released under the MIT license. See Copyright Notice in luajit.h
----------------------------------------------------------------------------
-- This module just exports the r6 big-endian functions from the
+1 -1
View File
@@ -1,7 +1,7 @@
----------------------------------------------------------------------------
-- LuaJIT MIPS64R6EL disassembler wrapper module.
--
-- Copyright (C) 2005-2025 Mike Pall. All rights reserved.
-- Copyright (C) 2005-2026 Mike Pall. All rights reserved.
-- Released under the MIT license. See Copyright Notice in luajit.h
----------------------------------------------------------------------------
-- This module just exports the r6 little-endian functions from the
+1 -1
View File
@@ -1,7 +1,7 @@
----------------------------------------------------------------------------
-- LuaJIT MIPSEL disassembler wrapper module.
--
-- Copyright (C) 2005-2025 Mike Pall. All rights reserved.
-- Copyright (C) 2005-2026 Mike Pall. All rights reserved.
-- Released under the MIT license. See Copyright Notice in luajit.h
----------------------------------------------------------------------------
-- This module just exports the little-endian functions from the
+1 -1
View File
@@ -1,7 +1,7 @@
----------------------------------------------------------------------------
-- LuaJIT PPC disassembler module.
--
-- Copyright (C) 2005-2025 Mike Pall. All rights reserved.
-- Copyright (C) 2005-2026 Mike Pall. All rights reserved.
-- Released under the MIT/X license. See Copyright Notice in luajit.h
----------------------------------------------------------------------------
-- This is a helper module used by the LuaJIT machine code dumper module.
+1 -1
View File
@@ -1,7 +1,7 @@
----------------------------------------------------------------------------
-- LuaJIT x64 disassembler wrapper module.
--
-- Copyright (C) 2005-2025 Mike Pall. All rights reserved.
-- Copyright (C) 2005-2026 Mike Pall. All rights reserved.
-- Released under the MIT license. See Copyright Notice in luajit.h
----------------------------------------------------------------------------
-- This module just exports the 64 bit functions from the combined
+1 -1
View File
@@ -1,7 +1,7 @@
----------------------------------------------------------------------------
-- LuaJIT x86/x64 disassembler module.
--
-- Copyright (C) 2005-2025 Mike Pall. All rights reserved.
-- Copyright (C) 2005-2026 Mike Pall. All rights reserved.
-- Released under the MIT license. See Copyright Notice in luajit.h
----------------------------------------------------------------------------
-- This is a helper module used by the LuaJIT machine code dumper module.
+1 -1
View File
@@ -1,7 +1,7 @@
----------------------------------------------------------------------------
-- LuaJIT compiler dump module.
--
-- Copyright (C) 2005-2025 Mike Pall. All rights reserved.
-- Copyright (C) 2005-2026 Mike Pall. All rights reserved.
-- Released under the MIT license. See Copyright Notice in luajit.h
----------------------------------------------------------------------------
--
+1 -1
View File
@@ -1,7 +1,7 @@
----------------------------------------------------------------------------
-- LuaJIT profiler.
--
-- Copyright (C) 2005-2025 Mike Pall. All rights reserved.
-- Copyright (C) 2005-2026 Mike Pall. All rights reserved.
-- Released under the MIT license. See Copyright Notice in luajit.h
----------------------------------------------------------------------------
--
+1 -1
View File
@@ -1,7 +1,7 @@
----------------------------------------------------------------------------
-- Verbose mode of the LuaJIT compiler.
--
-- Copyright (C) 2005-2025 Mike Pall. All rights reserved.
-- Copyright (C) 2005-2026 Mike Pall. All rights reserved.
-- Released under the MIT license. See Copyright Notice in luajit.h
----------------------------------------------------------------------------
--
+1 -1
View File
@@ -1,7 +1,7 @@
----------------------------------------------------------------------------
-- LuaJIT profiler zones.
--
-- Copyright (C) 2005-2025 Mike Pall. All rights reserved.
-- Copyright (C) 2005-2026 Mike Pall. All rights reserved.
-- Released under the MIT license. See Copyright Notice in luajit.h
----------------------------------------------------------------------------
--
+1 -1
View File
@@ -1,6 +1,6 @@
/*
** Auxiliary library for the Lua/C API.
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
**
** Major parts taken verbatim or adapted from the Lua interpreter.
** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h
+4 -2
View File
@@ -1,6 +1,6 @@
/*
** Base and coroutine library.
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
**
** Major portions taken verbatim or adapted from the Lua interpreter.
** Copyright (C) 1994-2011 Lua.org, PUC-Rio. See Copyright Notice in lua.h
@@ -243,7 +243,9 @@ LJLIB_CF(unpack)
} else {
setnilV(L->top++);
}
} while (i++ < e);
if (i >= e) break;
i++;
} while (1);
return n;
}
+1 -1
View File
@@ -1,6 +1,6 @@
/*
** Bit manipulation library.
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
*/
#define lib_bit_c
+1 -1
View File
@@ -1,6 +1,6 @@
/*
** Buffer library.
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
*/
#define lib_buffer_c
+2 -2
View File
@@ -1,6 +1,6 @@
/*
** Debug library.
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
**
** Major portions taken verbatim or adapted from the Lua interpreter.
** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h
@@ -283,7 +283,7 @@ LJLIB_CF(debug_setuservalue)
/* ------------------------------------------------------------------------ */
#define KEY_HOOK (U64x(80000000,00000000)|'h')
#define KEY_HOOK (U64x(81000000,00000000)|'h')
static void hookf(lua_State *L, lua_Debug *ar)
{
+4 -1
View File
@@ -1,6 +1,6 @@
/*
** FFI library.
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
*/
#define lib_ffi_c
@@ -758,6 +758,9 @@ LJLIB_CF(ffi_abi) LJLIB_REC(.)
#endif
#if LJ_GC64
"\004gc64"
#endif
#if LJ_DUALNUM
"\007dualnum"
#endif
) >= 0;
setboolV(L->top-1, b);
+1 -1
View File
@@ -1,6 +1,6 @@
/*
** Library initialization.
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
**
** Major parts taken verbatim from the Lua interpreter.
** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h
+5 -4
View File
@@ -1,6 +1,6 @@
/*
** I/O library.
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
**
** Major portions taken verbatim or adapted from the Lua interpreter.
** Copyright (C) 1994-2011 Lua.org, PUC-Rio. See Copyright Notice in lua.h
@@ -127,8 +127,9 @@ static int io_file_readnum(lua_State *L, FILE *fp)
lua_Number d;
if (fscanf(fp, LUA_NUMBER_SCAN, &d) == 1) {
if (LJ_DUALNUM) {
int32_t i = lj_num2int(d);
if (d == (lua_Number)i && !tvismzero((cTValue *)&d)) {
int64_t i64;
int32_t i;
if (lj_num2int_check(d, i64, i) && !tvismzero((cTValue *)&d)) {
setintV(L->top++, i);
return 1;
}
@@ -335,7 +336,7 @@ LJLIB_CF(io_method_seek)
if (tvisint(o))
ofs = (int64_t)intV(o);
else if (tvisnum(o))
ofs = (int64_t)numV(o);
ofs = lj_num2i64(numV(o));
else if (!tvisnil(o))
lj_err_argt(L, 3, LUA_TNUMBER);
}
+21 -5
View File
@@ -1,6 +1,6 @@
/*
** JIT library.
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
*/
#define lib_jit_c
@@ -340,11 +340,12 @@ LJLIB_CF(jit_util_tracek)
return 0;
}
/* local snap = jit.util.tracesnap(tr, sn) */
/* local snap = jit.util.tracesnap(tr, sn[, getpos]) */
LJLIB_CF(jit_util_tracesnap)
{
GCtrace *T = jit_checktrace(L);
SnapNo sn = (SnapNo)lj_lib_checkint(L, 2);
int getpos = (L->base+2 < L->top && tvistruecond(L->base+2));
if (T && sn < T->nsnap) {
SnapShot *snap = &T->snap[sn];
SnapEntry *map = &T->snapmap[snap->mapofs];
@@ -357,6 +358,12 @@ LJLIB_CF(jit_util_tracesnap)
for (n = 0; n < nent; n++)
setintV(lj_tab_setint(L, t, (int32_t)(n+2)), (int32_t)map[n]);
setintV(lj_tab_setint(L, t, (int32_t)(nent+2)), (int32_t)SNAP(255, 0, 0));
if (getpos) {
const BCIns *pc = snap_pc(&map[nent]), *startpc = pc;
while (bc_op(*startpc) < BC_FUNCF) startpc--;
setintV(L->top++, (int)(pc - startpc));
return 2;
}
return 1;
}
return 0;
@@ -535,8 +542,8 @@ LJLIB_CF(jit_opt_start)
/* Not loaded by default, use: local profile = require("jit.profile") */
#define KEY_PROFILE_THREAD (U64x(80000000,00000000)|'t')
#define KEY_PROFILE_FUNC (U64x(80000000,00000000)|'f')
#define KEY_PROFILE_THREAD (U64x(81000000,00000000)|'t')
#define KEY_PROFILE_FUNC (U64x(81000000,00000000)|'f')
static void jit_profile_callback(lua_State *L2, lua_State *L, int samples,
int vmstate)
@@ -723,7 +730,16 @@ static void jit_init(lua_State *L)
jit_State *J = L2J(L);
J->flags = jit_cpudetect() | JIT_F_ON | JIT_F_OPT_DEFAULT;
memcpy(J->param, jit_param_default, sizeof(J->param));
lj_dispatch_update(G(L));
#if LJ_TARGET_UNALIGNED
G(L)->tmptv.u64 = U64x(0000504d,4d500000);
#endif
lj_dispatch_update(G(L), 0);
#if LJ_TARGET_UNALIGNED
/* If you get a crash below then your toolchain indicates unaligned
** accesses are OK, but your kernel disagrees. I.e. fix your toolchain.
*/
if (*(uint32_t *)((char *)&G(L)->tmptv + 2) != 0x504d4d50u) L->top = NULL;
#endif
}
#endif
+1 -1
View File
@@ -1,6 +1,6 @@
/*
** Math library.
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
*/
#include <math.h>
+10 -7
View File
@@ -1,6 +1,6 @@
/*
** OS library.
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
**
** Major portions taken verbatim or adapted from the Lua interpreter.
** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h
@@ -171,7 +171,8 @@ static int getfield(lua_State *L, const char *key, int d)
LJLIB_CF(os_date)
{
const char *s = luaL_optstring(L, 1, "%c");
time_t t = luaL_opt(L, (time_t)luaL_checknumber, 2, time(NULL));
time_t t = lua_isnoneornil(L, 2) ? time(NULL) :
lj_num2int_type(luaL_checknumber(L, 2), time_t);
struct tm *stm;
#if LJ_TARGET_POSIX
struct tm rtm;
@@ -239,12 +240,13 @@ LJLIB_CF(os_time)
ts.tm_min = getfield(L, "min", 0);
ts.tm_hour = getfield(L, "hour", 12);
ts.tm_mday = getfield(L, "day", -1);
ts.tm_mon = getfield(L, "month", -1) - 1;
ts.tm_year = getfield(L, "year", -1) - 1900;
ts.tm_mon = (int)((unsigned int)getfield(L, "month", -1) - 1u);
ts.tm_year = (int)((unsigned int)getfield(L, "year", -1) - 1900u);
ts.tm_isdst = getboolfield(L, "isdst");
errno = 0;
t = mktime(&ts);
}
if (t == (time_t)(-1))
if (t == (time_t)(-1) && errno != 0)
lua_pushnil(L);
else
lua_pushnumber(L, (lua_Number)t);
@@ -253,8 +255,9 @@ LJLIB_CF(os_time)
LJLIB_CF(os_difftime)
{
lua_pushnumber(L, difftime((time_t)(luaL_checknumber(L, 1)),
(time_t)(luaL_optnumber(L, 2, (lua_Number)0))));
lua_pushnumber(L,
difftime(lj_num2int_type(luaL_checknumber(L, 1), time_t),
lj_num2int_type(luaL_optnumber(L, 2, (lua_Number)0), time_t)));
return 1;
}
+2 -2
View File
@@ -1,6 +1,6 @@
/*
** Package library.
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
**
** Major portions taken verbatim or adapted from the Lua interpreter.
** Copyright (C) 1994-2012 Lua.org, PUC-Rio. See Copyright Notice in lua.h
@@ -425,7 +425,7 @@ static int lj_cf_package_loader_preload(lua_State *L)
/* ------------------------------------------------------------------------ */
#define KEY_SENTINEL (U64x(80000000,00000000)|'s')
#define KEY_SENTINEL (U64x(81000000,00000000)|'s')
static int lj_cf_package_require(lua_State *L)
{
+1 -1
View File
@@ -1,6 +1,6 @@
/*
** String library.
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
**
** Major portions taken verbatim or adapted from the Lua interpreter.
** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h
+1 -1
View File
@@ -1,6 +1,6 @@
/*
** Table library.
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
**
** Major portions taken verbatim or adapted from the Lua interpreter.
** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h
+2 -2
View File
@@ -100,8 +100,8 @@
#if LJ_GC64
#define LJ_ALLOC_MBITS 47 /* 128 TB in LJ_GC64 mode. */
#elif LJ_TARGET_X64 && LJ_HASJIT
/* Due to limitations in the x64 compiler backend. */
#elif LJ_TARGET_X64
/* Due to limitations in the x64 non-GC64 VM. */
#define LJ_ALLOC_MBITS 31 /* 2 GB on x64 with !LJ_GC64. */
#else
#define LJ_ALLOC_MBITS 32 /* 4 GB on other archs with !LJ_GC64. */
+6 -22
View File
@@ -1,6 +1,6 @@
/*
** Public Lua/C API.
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
**
** Major portions taken verbatim or adapted from the Lua interpreter.
** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h
@@ -416,11 +416,7 @@ LUA_API lua_Integer lua_tointeger(lua_State *L, int idx)
return intV(&tmp);
n = numV(&tmp);
}
#if LJ_64
return (lua_Integer)n;
#else
return lj_num2int(n);
#endif
return lj_num2int_type(n, lua_Integer);
}
LUA_API lua_Integer lua_tointegerx(lua_State *L, int idx, int *ok)
@@ -445,11 +441,7 @@ LUA_API lua_Integer lua_tointegerx(lua_State *L, int idx, int *ok)
n = numV(&tmp);
}
if (ok) *ok = 1;
#if LJ_64
return (lua_Integer)n;
#else
return lj_num2int(n);
#endif
return lj_num2int_type(n, lua_Integer);
}
LUALIB_API lua_Integer luaL_checkinteger(lua_State *L, int idx)
@@ -468,11 +460,7 @@ LUALIB_API lua_Integer luaL_checkinteger(lua_State *L, int idx)
return (lua_Integer)intV(&tmp);
n = numV(&tmp);
}
#if LJ_64
return (lua_Integer)n;
#else
return lj_num2int(n);
#endif
return lj_num2int_type(n, lua_Integer);
}
LUALIB_API lua_Integer luaL_optinteger(lua_State *L, int idx, lua_Integer def)
@@ -493,11 +481,7 @@ LUALIB_API lua_Integer luaL_optinteger(lua_State *L, int idx, lua_Integer def)
return (lua_Integer)intV(&tmp);
n = numV(&tmp);
}
#if LJ_64
return (lua_Integer)n;
#else
return lj_num2int(n);
#endif
return lj_num2int_type(n, lua_Integer);
}
LUA_API int lua_toboolean(lua_State *L, int idx)
@@ -724,7 +708,7 @@ LUA_API void lua_pushlightuserdata(lua_State *L, void *p)
LUA_API void lua_createtable(lua_State *L, int narray, int nrec)
{
lj_gc_check(L);
settabV(L, L->top, lj_tab_new_ah(L, narray, nrec));
settabV(L, L->top, lj_tab_new_ah(L, (uint32_t)narray, (uint32_t)nrec));
incr_top(L);
}
+5 -1
View File
@@ -1,6 +1,6 @@
/*
** Target architecture selection.
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
*/
#ifndef _LJ_ARCH_H
@@ -304,6 +304,10 @@
#define LJ_PAGESIZE 16384
#define LJ_ARCH_NUMMODE LJ_NUMMODE_DUAL
#if __ARM_FEATURE_UNALIGNED
#define LJ_TARGET_UNALIGNED 1
#endif
#define LJ_ARCH_VERSION 80
#elif LUAJIT_TARGET == LUAJIT_ARCH_PPC
+14 -9
View File
@@ -1,6 +1,6 @@
/*
** IR assembler (SSA IR -> machine code).
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
*/
#define lj_asm_c
@@ -1329,27 +1329,32 @@ static void asm_conv64(ASMState *as, IRIns *ir)
IRType st = (IRType)((ir-1)->op2 & IRCONV_SRCMASK);
IRType dt = (((ir-1)->op2 & IRCONV_DSTMASK) >> IRCONV_DSH);
IRCallID id;
const CCallInfo *ci;
#if LJ_TARGET_ARM && !LJ_ABI_SOFTFP
CCallInfo cim;
#endif
IRRef args[2];
lj_assertA((ir-1)->o == IR_CONV && ir->o == IR_HIOP,
"not a CONV/HIOP pair at IR %04d", (int)(ir - as->ir) - REF_BIAS);
args[LJ_BE] = (ir-1)->op1;
args[LJ_LE] = ir->op1;
if (st == IRT_NUM || st == IRT_FLOAT) {
id = IRCALL_fp64_d2l + ((st == IRT_FLOAT) ? 2 : 0) + (dt - IRT_I64);
lj_assertA(st != IRT_FLOAT, "bad CONV *64.float emitted");
if (st == IRT_NUM) {
id = IRCALL_lj_vm_num2u64;
ir--;
ci = &lj_ir_callinfo[id];
} else {
id = IRCALL_fp64_l2d + ((dt == IRT_FLOAT) ? 2 : 0) + (st - IRT_I64);
}
{
#if LJ_TARGET_ARM && !LJ_ABI_SOFTFP
CCallInfo cim = lj_ir_callinfo[id], *ci = &cim;
cim = lj_ir_callinfo[id];
cim.flags |= CCI_VARARG; /* These calls don't use the hard-float ABI! */
ci = &cim;
#else
const CCallInfo *ci = &lj_ir_callinfo[id];
ci = &lj_ir_callinfo[id];
#endif
asm_setupresult(as, ir, ci);
asm_gencall(as, ci, args);
}
asm_setupresult(as, ir, ci);
asm_gencall(as, ci, args);
}
#endif
+1 -1
View File
@@ -1,6 +1,6 @@
/*
** IR assembler (SSA IR -> machine code).
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
*/
#ifndef _LJ_ASM_H
+3 -4
View File
@@ -1,6 +1,6 @@
/*
** ARM IR assembler (SSA IR -> machine code).
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
*/
/* -- Register allocator extensions --------------------------------------- */
@@ -624,10 +624,9 @@ static void asm_conv(ASMState *as, IRIns *ir)
Reg tmp = ra_scratch(as, rset_exclude(RSET_FPR, left));
Reg dest = ra_dest(as, ir, RSET_GPR);
ARMIns ai;
lj_assertA(!irt_isu32(ir->t), "bad CONV u32.fp emitted");
emit_dn(as, ARMI_VMOV_R_S, dest, (tmp & 15));
ai = irt_isint(ir->t) ?
(st == IRT_NUM ? ARMI_VCVT_S32_F64 : ARMI_VCVT_S32_F32) :
(st == IRT_NUM ? ARMI_VCVT_U32_F64 : ARMI_VCVT_U32_F32);
ai = st == IRT_NUM ? ARMI_VCVT_S32_F64 : ARMI_VCVT_S32_F32;
emit_dm(as, ai, (tmp & 15), (left & 15));
}
} else
+15 -10
View File
@@ -1,6 +1,6 @@
/*
** ARM64 IR assembler (SSA IR -> machine code).
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
**
** Contributed by Djordje Kovacevic and Stefan Pejic from RT-RK.com.
** Sponsored by Cisco Systems, Inc.
@@ -648,14 +648,18 @@ static void asm_conv(ASMState *as, IRIns *ir)
} else {
Reg left = ra_alloc1(as, lref, RSET_FPR);
Reg dest = ra_dest(as, ir, RSET_GPR);
A64Ins ai = irt_is64(ir->t) ?
(st == IRT_NUM ?
(irt_isi64(ir->t) ? A64I_FCVT_S64_F64 : A64I_FCVT_U64_F64) :
(irt_isi64(ir->t) ? A64I_FCVT_S64_F32 : A64I_FCVT_U64_F32)) :
(st == IRT_NUM ?
(irt_isint(ir->t) ? A64I_FCVT_S32_F64 : A64I_FCVT_U32_F64) :
(irt_isint(ir->t) ? A64I_FCVT_S32_F32 : A64I_FCVT_U32_F32));
emit_dn(as, ai, dest, (left & 31));
lj_assertA(!irt_isu32(ir->t), "bad CONV u32.fp emitted");
if (irt_isu64(ir->t)) {
emit_dnm(as, A64I_CSELx | A64F_CC(CC_VC), dest, dest, RID_TMP);
emit_n(as, (A64I_CMNx^A64I_K12) | A64F_U12(1), dest);
emit_dn(as, st == IRT_NUM ? A64I_FCVT_U64_F64 : A64I_FCVT_U64_F32, RID_TMP, (left & 31));
emit_dn(as, st == IRT_NUM ? A64I_FCVT_S64_F64 : A64I_FCVT_S64_F32, dest, (left & 31));
} else {
A64Ins ai = irt_is64(ir->t) ?
(st == IRT_NUM ? A64I_FCVT_S64_F64 : A64I_FCVT_S64_F32) :
(st == IRT_NUM ? A64I_FCVT_S32_F64 : A64I_FCVT_S32_F32);
emit_dn(as, ai, dest, (left & 31));
}
}
} else if (st >= IRT_I8 && st <= IRT_U16) { /* Extend to 32 bit integer. */
Reg dest = ra_dest(as, ir, RSET_GPR);
@@ -1056,7 +1060,8 @@ static void asm_fstore(ASMState *as, IRIns *ir)
static void asm_xload(ASMState *as, IRIns *ir)
{
Reg dest = ra_dest(as, ir, irt_isfp(ir->t) ? RSET_FPR : RSET_GPR);
lj_assertA(!(ir->op2 & IRXLOAD_UNALIGNED), "unaligned XLOAD");
lj_assertA(LJ_TARGET_UNALIGNED || !(ir->op2 & IRXLOAD_UNALIGNED),
"unaligned XLOAD");
asm_fusexref(as, asm_fxloadins(ir), dest, ir->op1, RSET_GPR);
}
+28 -53
View File
@@ -1,6 +1,6 @@
/*
** MIPS IR assembler (SSA IR -> machine code).
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
*/
/* -- Register allocator extensions --------------------------------------- */
@@ -635,64 +635,38 @@ static void asm_conv(ASMState *as, IRIns *ir)
Reg dest = ra_dest(as, ir, RSET_GPR);
Reg left = ra_alloc1(as, lref, RSET_FPR);
Reg tmp = ra_scratch(as, rset_exclude(RSET_FPR, left));
if (irt_isu32(ir->t)) { /* FP to U32 conversion. */
/* y = (int)floor(x - 2147483648.0) ^ 0x80000000 */
emit_dst(as, MIPSI_XOR, dest, dest, RID_TMP);
emit_ti(as, MIPSI_LUI, RID_TMP, 0x8000);
emit_tg(as, MIPSI_MFC1, dest, tmp);
emit_fg(as, st == IRT_FLOAT ? MIPSI_FLOOR_W_S : MIPSI_FLOOR_W_D,
tmp, tmp);
emit_fgh(as, st == IRT_FLOAT ? MIPSI_SUB_S : MIPSI_SUB_D,
tmp, left, tmp);
if (st == IRT_FLOAT)
emit_lsptr(as, MIPSI_LWC1, (tmp & 31),
(void *)&as->J->k32[LJ_K32_2P31], RSET_GPR);
else
emit_lsptr(as, MIPSI_LDC1, (tmp & 31),
(void *)&as->J->k64[LJ_K64_2P31], RSET_GPR);
lj_assertA(!irt_isu32(ir->t), "bad CONV u32.fp emitted");
#if LJ_64
} else if (irt_isu64(ir->t)) { /* FP to U64 conversion. */
MCLabel l_end;
if (irt_isu64(ir->t)) { /* FP to U64 conversion. */
MCLabel l_end = emit_label(as);
emit_tg(as, MIPSI_DMFC1, dest, tmp);
l_end = emit_label(as);
/* For inputs >= 2^63 add -2^64 and convert again. */
/* For result == INT64_MAX add -2^64 and convert again. */
if (st == IRT_NUM) {
emit_fg(as, MIPSI_TRUNC_L_D, tmp, tmp);
emit_fgh(as, MIPSI_ADD_D, tmp, left, tmp);
emit_lsptr(as, MIPSI_LDC1, (tmp & 31),
(void *)&as->J->k64[LJ_K64_M2P64],
rset_exclude(RSET_GPR, dest));
emit_fg(as, MIPSI_TRUNC_L_D, tmp, left); /* Delay slot. */
#if !LJ_TARGET_MIPSR6
emit_branch(as, MIPSI_BC1T, 0, 0, l_end);
emit_fgh(as, MIPSI_C_OLT_D, 0, left, tmp);
#else
emit_branch(as, MIPSI_BC1NEZ, 0, (tmp&31), l_end);
emit_fgh(as, MIPSI_CMP_LT_D, tmp, left, tmp);
#endif
emit_lsptr(as, MIPSI_LDC1, (tmp & 31),
(void *)&as->J->k64[LJ_K64_2P63],
rset_exclude(RSET_GPR, dest));
rset_exclude(RSET_GPR, dest)); /* Delay slot. */
emit_branch(as, MIPSI_BNE, RID_TMP, dest, l_end); /* != INT64_MAX? */
emit_dta(as, MIPSI_DSRL, RID_TMP, RID_TMP, 1);
emit_ti(as, MIPSI_LI, RID_TMP, -1);
emit_tg(as, MIPSI_DMFC1, dest, tmp);
emit_fg(as, MIPSI_TRUNC_L_D, tmp, left);
} else {
emit_fg(as, MIPSI_TRUNC_L_S, tmp, tmp);
emit_fgh(as, MIPSI_ADD_S, tmp, left, tmp);
emit_lsptr(as, MIPSI_LWC1, (tmp & 31),
(void *)&as->J->k32[LJ_K32_M2P64],
rset_exclude(RSET_GPR, dest));
emit_fg(as, MIPSI_TRUNC_L_S, tmp, left); /* Delay slot. */
#if !LJ_TARGET_MIPSR6
emit_branch(as, MIPSI_BC1T, 0, 0, l_end);
emit_fgh(as, MIPSI_C_OLT_S, 0, left, tmp);
#else
emit_branch(as, MIPSI_BC1NEZ, 0, (tmp&31), l_end);
emit_fgh(as, MIPSI_CMP_LT_S, tmp, left, tmp);
#endif
emit_lsptr(as, MIPSI_LWC1, (tmp & 31),
(void *)&as->J->k32[LJ_K32_2P63],
rset_exclude(RSET_GPR, dest));
rset_exclude(RSET_GPR, dest)); /* Delay slot. */
emit_branch(as, MIPSI_BNE, RID_TMP, dest, l_end); /* != INT64_MAX? */
emit_dta(as, MIPSI_DSRL, RID_TMP, RID_TMP, 1);
emit_ti(as, MIPSI_LI, RID_TMP, -1);
emit_tg(as, MIPSI_DMFC1, dest, tmp);
emit_fg(as, MIPSI_TRUNC_L_S, tmp, left);
}
} else
#endif
} else {
{
#if LJ_32
emit_tg(as, MIPSI_MFC1, dest, tmp);
emit_fg(as, st == IRT_FLOAT ? MIPSI_TRUNC_W_S : MIPSI_TRUNC_W_D,
@@ -733,13 +707,11 @@ static void asm_conv(ASMState *as, IRIns *ir)
"bad type for checked CONV");
asm_tointg(as, ir, RID_NONE);
} else {
IRCallID cid = irt_is64(ir->t) ?
((st == IRT_NUM) ?
(irt_isi64(ir->t) ? IRCALL_fp64_d2l : IRCALL_fp64_d2ul) :
(irt_isi64(ir->t) ? IRCALL_fp64_f2l : IRCALL_fp64_f2ul)) :
((st == IRT_NUM) ?
(irt_isint(ir->t) ? IRCALL_softfp_d2i : IRCALL_softfp_d2ui) :
(irt_isint(ir->t) ? IRCALL_softfp_f2i : IRCALL_softfp_f2ui));
IRCallID cid;
lj_assertA(!irt_isu32(ir->t), "bad CONV u32.fp emitted");
lj_assertA(!(irt_is64(ir->t) && st != IRT_NUM), "bad CONV *64.float emitted");
cid = irt_is64(ir->t) ? IRCALL_lj_vm_num2u64 :
(st == IRT_NUM ? IRCALL_softfp_d2i : IRCALL_softfp_f2i);
asm_callid(as, ir, cid);
}
} else
@@ -780,7 +752,10 @@ static void asm_conv(ASMState *as, IRIns *ir)
}
}
} else {
if (st64 && !(ir->op2 & IRCONV_NONE)) {
if (!irt_isu32(ir->t)) { /* Implicit sign extension. */
Reg left = ra_alloc1(as, lref, RSET_GPR);
emit_dta(as, MIPSI_SLL, dest, left, 0);
} else if (st64 && !(ir->op2 & IRCONV_NONE)) {
/* This is either a 32 bit reg/reg mov which zeroes the hiword
** or a load of the loword from a 64 bit address.
*/
+5 -24
View File
@@ -1,6 +1,6 @@
/*
** PPC IR assembler (SSA IR -> machine code).
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
*/
/* -- Register allocator extensions --------------------------------------- */
@@ -512,29 +512,10 @@ static void asm_conv(ASMState *as, IRIns *ir)
Reg dest = ra_dest(as, ir, RSET_GPR);
Reg left = ra_alloc1(as, lref, RSET_FPR);
Reg tmp = ra_scratch(as, rset_exclude(RSET_FPR, left));
if (irt_isu32(ir->t)) {
/* Convert both x and x-2^31 to int and merge results. */
Reg tmpi = ra_scratch(as, rset_exclude(RSET_GPR, dest));
emit_asb(as, PPCI_OR, dest, dest, tmpi); /* Select with mask idiom. */
emit_asb(as, PPCI_AND, tmpi, tmpi, RID_TMP);
emit_asb(as, PPCI_ANDC, dest, dest, RID_TMP);
emit_tai(as, PPCI_LWZ, tmpi, RID_SP, SPOFS_TMPLO); /* tmp = (int)(x) */
emit_tai(as, PPCI_ADDIS, dest, dest, 0x8000); /* dest += 2^31 */
emit_asb(as, PPCI_SRAWI, RID_TMP, dest, 31); /* mask = -(dest < 0) */
emit_fai(as, PPCI_STFD, tmp, RID_SP, SPOFS_TMP);
emit_tai(as, PPCI_LWZ, dest,
RID_SP, SPOFS_TMPLO); /* dest = (int)(x-2^31) */
emit_fb(as, PPCI_FCTIWZ, tmp, left);
emit_fai(as, PPCI_STFD, tmp, RID_SP, SPOFS_TMP);
emit_fb(as, PPCI_FCTIWZ, tmp, tmp);
emit_fab(as, PPCI_FSUB, tmp, left, tmp);
emit_lsptr(as, PPCI_LFS, (tmp & 31),
(void *)&as->J->k32[LJ_K32_2P31], RSET_GPR);
} else {
emit_tai(as, PPCI_LWZ, dest, RID_SP, SPOFS_TMPLO);
emit_fai(as, PPCI_STFD, tmp, RID_SP, SPOFS_TMP);
emit_fb(as, PPCI_FCTIWZ, tmp, left);
}
lj_assertA(!irt_isu32(ir->t), "bad CONV u32.fp emitted");
emit_tai(as, PPCI_LWZ, dest, RID_SP, SPOFS_TMPLO);
emit_fai(as, PPCI_STFD, tmp, RID_SP, SPOFS_TMP);
emit_fb(as, PPCI_FCTIWZ, tmp, left);
}
} else
#endif
+24 -21
View File
@@ -1,6 +1,6 @@
/*
** x86/x64 IR assembler (SSA IR -> machine code).
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
*/
/* -- Guard handling ------------------------------------------------------ */
@@ -905,29 +905,28 @@ static void asm_conv(ASMState *as, IRIns *ir)
} else {
Reg dest = ra_dest(as, ir, RSET_GPR);
x86Op op = st == IRT_NUM ? XO_CVTTSD2SI : XO_CVTTSS2SI;
if (LJ_64 ? irt_isu64(ir->t) : irt_isu32(ir->t)) {
/* LJ_64: For inputs >= 2^63 add -2^64, convert again. */
/* LJ_32: For inputs >= 2^31 add -2^31, convert again and add 2^31. */
lj_assertA(!irt_isu32(ir->t), "bad CONV u32.fp emitted");
#if LJ_64
if (irt_isu64(ir->t)) {
/* For the indefinite result -2^63, add -2^64 and convert again. */
Reg tmp = ra_noreg(IR(lref)->r) ? ra_alloc1(as, lref, RSET_FPR) :
ra_scratch(as, RSET_FPR);
MCLabel l_end = emit_label(as);
if (LJ_32)
emit_gri(as, XG_ARITHi(XOg_ADD), dest, (int32_t)0x80000000);
emit_rr(as, op, dest|REX_64, tmp);
if (st == IRT_NUM)
emit_rma(as, XO_ADDSD, tmp, &as->J->k64[LJ_K64_M2P64_31]);
emit_rma(as, XO_ADDSD, tmp, &as->J->k64[LJ_K64_M2P64]);
else
emit_rma(as, XO_ADDSS, tmp, &as->J->k32[LJ_K32_M2P64_31]);
emit_sjcc(as, CC_NS, l_end);
emit_rr(as, XO_TEST, dest|REX_64, dest); /* Check if dest negative. */
emit_rma(as, XO_ADDSS, tmp, &as->J->k32[LJ_K32_M2P64]);
emit_sjcc(as, CC_NO, l_end);
emit_gmrmi(as, XG_ARITHi(XOg_CMP), dest|REX_64, 1);
emit_rr(as, op, dest|REX_64, tmp);
ra_left(as, tmp, lref);
} else {
if (LJ_64 && irt_isu32(ir->t))
emit_rr(as, XO_MOV, dest, dest); /* Zero hiword. */
} else
#endif
{
emit_mrm(as, op,
dest|((LJ_64 &&
(irt_is64(ir->t) || irt_isu32(ir->t))) ? REX_64 : 0),
dest|((LJ_64 && irt_is64(ir->t)) ? REX_64 : 0),
asm_fuseload(as, lref, RSET_FPR));
}
}
@@ -1020,6 +1019,7 @@ static void asm_conv_int64_fp(ASMState *as, IRIns *ir)
IRType st = (IRType)((ir-1)->op2 & IRCONV_SRCMASK);
IRType dt = (((ir-1)->op2 & IRCONV_DSTMASK) >> IRCONV_DSH);
Reg lo, hi;
int usehi = ra_used(ir);
lj_assertA(st == IRT_NUM || st == IRT_FLOAT, "bad type for CONV");
lj_assertA(dt == IRT_I64 || dt == IRT_U64, "bad type for CONV");
hi = ra_dest(as, ir, RSET_GPR);
@@ -1032,21 +1032,24 @@ static void asm_conv_int64_fp(ASMState *as, IRIns *ir)
emit_gri(as, XG_ARITHi(XOg_AND), lo, 0xf3ff);
}
if (dt == IRT_U64) {
/* For inputs in [2^63,2^64-1] add -2^64 and convert again. */
/* For the indefinite result -2^63, add -2^64 and convert again. */
MCLabel l_pop, l_end = emit_label(as);
emit_x87op(as, XI_FPOP);
l_pop = emit_label(as);
emit_sjmp(as, l_end);
emit_rmro(as, XO_MOV, hi, RID_ESP, 4);
if (usehi) emit_rmro(as, XO_MOV, hi, RID_ESP, 4);
if ((as->flags & JIT_F_SSE3))
emit_rmro(as, XO_FISTTPq, XOg_FISTTPq, RID_ESP, 0);
else
emit_rmro(as, XO_FISTPq, XOg_FISTPq, RID_ESP, 0);
emit_rma(as, XO_FADDq, XOg_FADDq, &as->J->k64[LJ_K64_M2P64]);
emit_sjcc(as, CC_NS, l_pop);
emit_rr(as, XO_TEST, hi, hi); /* Check if out-of-range (2^63). */
emit_rma(as, XO_FADDd, XOg_FADDd, &as->J->k32[LJ_K32_M2P64]);
emit_sjcc(as, CC_NE, l_pop);
emit_gmroi(as, XG_ARITHi(XOg_CMP), RID_ESP, 0, 0);
emit_sjcc(as, CC_NO, l_pop);
emit_gmrmi(as, XG_ARITHi(XOg_CMP), hi, 1);
usehi = 1;
}
emit_rmro(as, XO_MOV, hi, RID_ESP, 4);
if (usehi) emit_rmro(as, XO_MOV, hi, RID_ESP, 4);
if ((as->flags & JIT_F_SSE3)) { /* Truncation is easy with SSE3. */
emit_rmro(as, XO_FISTTPq, XOg_FISTTPq, RID_ESP, 0);
} else { /* Otherwise set FPU rounding mode to truncate before the store. */
+1 -1
View File
@@ -1,6 +1,6 @@
/*
** Internal assertions.
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
*/
#define lj_assert_c
+1 -1
View File
@@ -1,6 +1,6 @@
/*
** Bytecode instruction modes.
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
*/
#define lj_bc_c
+1 -1
View File
@@ -1,6 +1,6 @@
/*
** Bytecode instruction format.
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
*/
#ifndef _LJ_BC_H
+1 -1
View File
@@ -1,6 +1,6 @@
/*
** Bytecode dump definitions.
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
*/
#ifndef _LJ_BCDUMP_H
+1 -1
View File
@@ -1,6 +1,6 @@
/*
** Bytecode reader.
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
*/
#define lj_bcread_c
+6 -7
View File
@@ -1,6 +1,6 @@
/*
** Bytecode writer.
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
*/
#define lj_bcwrite_c
@@ -59,9 +59,9 @@ static void bcwrite_ktabk(BCWriteCtx *ctx, cTValue *o, int narrow)
p = lj_strfmt_wuleb128(p, intV(o));
} else if (tvisnum(o)) {
if (!LJ_DUALNUM && narrow) { /* Narrow number constants to integers. */
lua_Number num = numV(o);
int32_t k = lj_num2int(num);
if (num == (lua_Number)k) { /* -0 is never a constant. */
int64_t i64;
int32_t k;
if (lj_num2int_check(numV(o), i64, k)) { /* -0 is never a constant. */
*p++ = BCDUMP_KTAB_INT;
p = lj_strfmt_wuleb128(p, k);
ctx->sb.w = p;
@@ -270,9 +270,8 @@ static void bcwrite_knum(BCWriteCtx *ctx, GCproto *pt)
/* Write a 33 bit ULEB128 for the int (lsb=0) or loword (lsb=1). */
if (!LJ_DUALNUM && o->u32.hi != LJ_KEYINDEX) {
/* Narrow number constants to integers. */
lua_Number num = numV(o);
k = lj_num2int(num);
if (num == (lua_Number)k) { /* -0 is never a constant. */
int64_t i64;
if (lj_num2int_check(numV(o), i64, k)) { /* -0 is never a constant. */
save_int:
p = lj_strfmt_wuleb128(p, 2*(uint32_t)k | ((uint32_t)k&0x80000000u));
if (k < 0)
+1 -1
View File
@@ -1,6 +1,6 @@
/*
** Buffer handling.
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
*/
#define lj_buf_c
+1 -1
View File
@@ -1,6 +1,6 @@
/*
** Buffer handling.
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
*/
#ifndef _LJ_BUF_H
+3 -3
View File
@@ -1,6 +1,6 @@
/*
** C data arithmetic.
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
*/
#include "lj_obj.h"
@@ -120,7 +120,7 @@ static int carith_ptr(lua_State *L, CTState *cts, CDArith *ca, MMS mm)
/* All valid pointer differences on x64 are in (-2^47, +2^47),
** which fits into a double without loss of precision.
*/
setintptrV(L->top-1, (int32_t)diff);
setintptrV(L->top-1, diff);
return 1;
} else if (mm == MM_lt) { /* Pointer comparison (unsigned). */
setboolV(L->top-1, ((uintptr_t)pp < (uintptr_t)pp2));
@@ -135,7 +135,7 @@ static int carith_ptr(lua_State *L, CTState *cts, CDArith *ca, MMS mm)
return 0;
lj_cconv_ct_ct(cts, ctype_get(cts, CTID_INT_PSZ), ca->ct[1],
(uint8_t *)&idx, ca->p[1], 0);
if (mm == MM_sub) idx = -idx;
if (mm == MM_sub) idx = (ptrdiff_t)(~(uintptr_t)idx+1u);
} else if (mm == MM_add && ctype_isnum(ctp->info) &&
(ctype_isptr(ca->ct[1]->info) || ctype_isrefarray(ca->ct[1]->info))) {
/* Swap pointer and index. */
+1 -1
View File
@@ -1,6 +1,6 @@
/*
** C data arithmetic.
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
*/
#ifndef _LJ_CARITH_H
+51 -10
View File
@@ -1,6 +1,6 @@
/*
** FFI C call handling.
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
*/
#include "lj_obj.h"
@@ -168,7 +168,9 @@
if (ccall_struct_arg(cc, cts, d, rcl, o, narg)) goto err_nyi; \
nsp = cc->nsp; ngpr = cc->ngpr; nfpr = cc->nfpr; \
continue; \
} /* Pass all other structs by value on stack. */
} else { /* Pass all other structs by value on stack. */ \
onstack = 1; \
}
#define CCALL_HANDLE_COMPLEXARG \
isfp = 2; /* Pass complex in FPRs or on stack. Needs postprocessing. */
@@ -183,7 +185,7 @@
} \
} else { /* Try to pass argument in GPRs. */ \
/* Note that reordering is explicitly allowed in the x64 ABI. */ \
if (n <= 2 && ngpr + n <= maxgpr) { \
if (!onstack && n <= 2 && ngpr + n <= maxgpr) { \
dp = &cc->gpr[ngpr]; \
ngpr += n; \
goto done; \
@@ -350,7 +352,7 @@
nfpr = CCALL_NARG_FPR; /* Prevent reordering. */ \
} \
} else { /* Try to pass argument in GPRs. */ \
if (!LJ_TARGET_OSX && (d->info & CTF_ALIGN) > CTALIGN_PTR) \
if (!LJ_TARGET_OSX && !rp && ccall_struct_align(cts, d) > CTALIGN_PTR) \
ngpr = (ngpr + 1u) & ~1u; /* Align to regpair. */ \
if (ngpr + n <= maxgpr) { \
dp = &cc->gpr[ngpr]; \
@@ -661,7 +663,7 @@ static int ccall_classify_struct(CTState *cts, CType *ct, int *rcl, CTSize ofs)
fofs = ofs+ct->size;
if (ctype_isfield(ct->info))
ccall_classify_ct(cts, ctype_rawchild(cts, ct), rcl, fofs);
else if (ctype_isbitfield(ct->info))
else if (ctype_isbitfield(ct->info) && ctype_bitbsz(ct->info))
rcl[(fofs >= 8)] |= CCALL_RCL_INT; /* NYI: unaligned bitfields? */
else if (ctype_isxattrib(ct->info, CTA_SUBTYPE))
ccall_classify_struct(cts, ctype_rawchild(cts, ct), rcl, fofs);
@@ -700,8 +702,11 @@ static int ccall_struct_arg(CCallState *cc, CTState *cts, CType *d, int *rcl,
if (ccall_struct_reg(cc, cts, dp, rcl)) {
/* Register overflow? Pass on stack. */
MSize nsp = cc->nsp, sz = rcl[1] ? 2*CTSIZE_PTR : CTSIZE_PTR;
MSize align = (1u << ctype_align(d->info)) - 1;
if (nsp + sz > CCALL_SIZE_STACK)
return 1; /* Too many arguments. */
if (CCALL_ALIGN_STACKARG && align > CTSIZE_PTR-1)
nsp = (nsp + align) & ~align; /* Align argument on stack. */
cc->nsp = nsp + sz;
memcpy((uint8_t *)cc->stack + nsp, dp, sz);
}
@@ -776,6 +781,31 @@ noth: /* Not a homogeneous float/double aggregate. */
#if LJ_TARGET_ARM64
#if !LJ_TARGET_OSX
/* Alignment of pass-by-value structs: 8 or 16. */
static CTInfo ccall_struct_align_arm64(CTState *cts, CType *ct)
{
CTSize sz;
if (ct->sib) {
while (ct->sib) {
ct = ctype_get(cts, ct->sib);
if (ctype_isfield(ct->info)) {
if ((ct->info & CTF_ALIGN) > CTALIGN_PTR) return CTALIGN(4);
} else if (ctype_isxattrib(ct->info, CTA_SUBTYPE)) {
CType *sct = ctype_rawchild(cts, ct);
CTInfo info = lj_ctype_info(cts, ctype_typeid(cts, sct), &sz);
if ((info & CTF_ALIGN) > CTALIGN_PTR) return CTALIGN(4);
}
}
} else {
CTInfo info = lj_ctype_info(cts, ctype_typeid(cts, ct), &sz);
if ((info & CTF_ALIGN) > CTALIGN_PTR) return CTALIGN(4);
}
return CTALIGN_PTR;
}
#define ccall_struct_align(cts, ct) ccall_struct_align_arm64((cts), (ct))
#endif
/* Classify a struct based on its fields. */
static unsigned int ccall_classify_struct(CTState *cts, CType *ct)
{
@@ -787,10 +817,10 @@ static unsigned int ccall_classify_struct(CTState *cts, CType *ct)
ct = ctype_get(cts, ct->sib);
if (ctype_isfield(ct->info)) {
sct = ctype_rawchild(cts, ct);
if (ctype_isarray(sct->info)) {
if (ctype_isarray(sct->info) && !sct->size) goto noth;
while (ctype_isarray(sct->info)) {
CType *cct = ctype_rawchild(cts, sct);
if (!cct->size) continue;
m = sct->size / cct->size;
m *= sct->size / cct->size;
sct = cct;
}
if (ctype_isfp(sct->info)) {
@@ -804,7 +834,7 @@ static unsigned int ccall_classify_struct(CTState *cts, CType *ct)
} else {
goto noth;
}
} else if (ctype_isbitfield(ct->info)) {
} else if (ctype_isbitfield(ct->info) && ctype_bitbsz(ct->info)) {
goto noth;
} else if (ctype_isxattrib(ct->info, CTA_SUBTYPE)) {
sct = ctype_rawchild(cts, ct);
@@ -899,6 +929,11 @@ static void ccall_copy_struct(CCallState *cc, CType *ctr, void *dp, void *sp,
#endif
#ifndef ccall_struct_align
/* Alignment of pass-by-value structs. */
#define ccall_struct_align(cts, ct) ((ct)->info & CTF_ALIGN)
#endif
/* -- Common C call handling ---------------------------------------------- */
/* Infer the destination CTypeID for a vararg argument.
@@ -1013,6 +1048,9 @@ static int ccall_set_args(lua_State *L, CTState *cts, CType *ct,
CTSize sz;
MSize n, isfp = 0, isva = 0;
void *dp, *rp = NULL;
#if LJ_TARGET_X64 && !LJ_ABI_WIN
int onstack = 0;
#endif
if (fid) { /* Get argument type from field. */
CType *ctf = ctype_get(cts, fid);
@@ -1051,7 +1089,10 @@ static int ccall_set_args(lua_State *L, CTState *cts, CType *ct,
/* Otherwise pass argument on stack. */
if (CCALL_ALIGN_STACKARG) { /* Align argument on stack. */
MSize align = (1u << ctype_align(d->info)) - 1;
MSize align = (1u << ctype_align(ccall_struct_align(cts, d))) - 1;
#if LJ_TARGET_ARM64 && LJ_TARGET_OSX
isva = ctype_isstruct(d->info);
#endif
if (rp || (CCALL_PACK_STACKARG && isva && align < CTSIZE_PTR-1))
align = CTSIZE_PTR-1;
nsp = (nsp + align) & ~align;
+1 -1
View File
@@ -1,6 +1,6 @@
/*
** FFI C call handling.
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
*/
#ifndef _LJ_CCALL_H
+1 -1
View File
@@ -1,6 +1,6 @@
/*
** FFI C callback handling.
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
*/
#include "lj_obj.h"
+1 -1
View File
@@ -1,6 +1,6 @@
/*
** FFI C callback handling.
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
*/
#ifndef _LJ_CCALLBACK_H
+6 -8
View File
@@ -1,6 +1,6 @@
/*
** C type conversions.
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
*/
#include "lj_obj.h"
@@ -197,18 +197,16 @@ void lj_cconv_ct_ct(CTState *cts, CType *d, CType *s,
else goto err_conv; /* NYI: long double. */
/* Then convert double to integer. */
/* The conversion must exactly match the semantics of JIT-compiled code! */
if (dsize < 4 || (dsize == 4 && !(dinfo & CTF_UNSIGNED))) {
int32_t i = (int32_t)n;
if (dsize < 8) {
int64_t i = lj_num2i64(n); /* Always convert via int64_t. */
if (dsize == 4) *(int32_t *)dp = i;
else if (dsize == 2) *(int16_t *)dp = (int16_t)i;
else *(int8_t *)dp = (int8_t)i;
} else if (dsize == 4) {
*(uint32_t *)dp = (uint32_t)n;
} else if (dsize == 8) {
if (!(dinfo & CTF_UNSIGNED))
*(int64_t *)dp = (int64_t)n;
else
if ((dinfo & CTF_UNSIGNED))
*(uint64_t *)dp = lj_num2u64(n);
else
*(int64_t *)dp = lj_num2i64(n);
} else {
goto err_conv; /* NYI: conversion to >64 bit integers. */
}
+1 -1
View File
@@ -1,6 +1,6 @@
/*
** C type conversions.
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
*/
#ifndef _LJ_CCONV_H
+2 -7
View File
@@ -1,6 +1,6 @@
/*
** C data management.
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
*/
#include "lj_obj.h"
@@ -133,12 +133,7 @@ collect_attrib:
idx = (ptrdiff_t)intV(key);
goto integer_key;
} else if (tvisnum(key)) { /* Numeric key. */
#ifdef _MSC_VER
/* Workaround for MSVC bug. */
volatile
#endif
lua_Number n = numV(key);
idx = LJ_64 ? (ptrdiff_t)n : (ptrdiff_t)lj_num2int(n);
idx = lj_num2int_type(numV(key), ptrdiff_t);
integer_key:
if (ctype_ispointer(ct->info)) {
CTSize sz = lj_ctype_size(cts, ctype_cid(ct->info)); /* Element size. */
+1 -1
View File
@@ -1,6 +1,6 @@
/*
** C data management.
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
*/
#ifndef _LJ_CDATA_H
+2 -2
View File
@@ -1,6 +1,6 @@
/*
** FFI C library loader.
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
*/
#include "lj_obj.h"
@@ -81,7 +81,7 @@ static const char *clib_extname(lua_State *L, const char *name)
/* Check for a recognized ld script line. */
static const char *clib_check_lds(lua_State *L, const char *buf)
{
char *p, *e;
const char *p, *e;
if ((!strncmp(buf, "GROUP", 5) || !strncmp(buf, "INPUT", 5)) &&
(p = strchr(buf, '('))) {
while (*++p == ' ') ;
+1 -1
View File
@@ -1,6 +1,6 @@
/*
** FFI C library loader.
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
*/
#ifndef _LJ_CLIB_H
+9 -4
View File
@@ -1,6 +1,6 @@
/*
** C declaration parser.
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
*/
#include "lj_obj.h"
@@ -1309,14 +1309,16 @@ static void cp_struct_layout(CPState *cp, CTypeID sid, CTInfo sattr)
align = ctype_align(attr);
if (cp->packstack[cp->curpack] < align)
align = cp->packstack[cp->curpack];
if (align > maxalign) maxalign = align;
bsz = ctype_bitcsz(ct->info); /* Bitfield size (temp.). */
if (align > maxalign && bsz) maxalign = align;
amask = (8u << align) - 1;
bsz = ctype_bitcsz(ct->info); /* Bitfield size (temp.). */
if (bsz == CTBSZ_FIELD || !ctype_isfield(ct->info)) {
bsz = csz; /* Regular fields or subtypes always fill the container. */
bofs = (bofs + amask) & ~amask; /* Start new aligned field. */
ct->size = (bofs >> 3); /* Store field offset. */
if (ctype_isfield(ct->info))
ct->info = CTINFO(CT_FIELD, ctype_cid(ct->info)) + CTALIGN(align);
} else { /* Bitfield. */
if (bsz == 0 || (attr & CTFP_ALIGNED) ||
(!((attr|sattr) & CTFP_PACKED) && (bofs & amask) + bsz > csz))
@@ -1324,9 +1326,12 @@ static void cp_struct_layout(CPState *cp, CTypeID sid, CTInfo sattr)
/* Prefer regular field over bitfield. */
if (bsz == csz && (bofs & amask) == 0) {
ct->info = CTINFO(CT_FIELD, ctype_cid(ct->info));
ct->info = CTINFO(CT_FIELD, ctype_cid(ct->info)) +
CTALIGN(lj_fls(sz));
ct->size = (bofs >> 3); /* Store field offset. */
} else {
if (csz > amask+1 && bsz <= amask+1)
csz = amask+1; /* Shrink container of packed bitfield. */
ct->info = CTINFO(CT_BITFIELD,
(info & (CTF_QUAL|CTF_UNSIGNED|CTF_BOOL)) +
(csz << (CTSHIFT_BITCSZ-3)) + (bsz << CTSHIFT_BITBSZ));
+1 -1
View File
@@ -1,6 +1,6 @@
/*
** C declaration parser.
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
*/
#ifndef _LJ_CPARSE_H
+28 -12
View File
@@ -1,6 +1,6 @@
/*
** Trace recorder for C data operations.
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
*/
#define lj_ffrecord_c
@@ -445,7 +445,20 @@ static TRef crec_ct_ct(jit_State *J, CType *d, CType *s, TRef dp, TRef sp,
/* fallthrough */
case CCX(I, F):
if (dt == IRT_CDATA || st == IRT_CDATA) goto err_nyi;
sp = emitconv(sp, dsize < 4 ? IRT_INT : dt, st, IRCONV_ANY);
conv_I_F:
#if LJ_SOFTFP || LJ_32
if (st == IRT_FLOAT) { /* Uncommon. Simplify split backends. */
sp = emitconv(sp, IRT_NUM, IRT_FLOAT, 0);
st = IRT_NUM;
}
#endif
if (dsize < 8) {
lj_needsplit(J);
sp = emitconv(sp, IRT_I64, st, IRCONV_ANY);
sp = emitconv(sp, dsize < 4 ? IRT_INT : dt, IRT_I64, 0);
} else {
sp = emitconv(sp, dt, st, IRCONV_ANY);
}
goto xstore;
case CCX(I, P):
case CCX(I, A):
@@ -523,10 +536,9 @@ static TRef crec_ct_ct(jit_State *J, CType *d, CType *s, TRef dp, TRef sp,
goto xstore;
case CCX(P, F):
if (st == IRT_CDATA) goto err_nyi;
/* The signed conversion is cheaper. x64 really has 47 bit pointers. */
sp = emitconv(sp, (LJ_64 && dsize == 8) ? IRT_I64 : IRT_U32,
st, IRCONV_ANY);
goto xstore;
/* The signed 64 bit conversion is cheaper. */
dt = (LJ_64 && dsize == 8) ? IRT_I64 : IRT_U32;
goto conv_I_F;
/* Destination is an array. */
case CCX(A, A):
@@ -883,6 +895,8 @@ again:
}
J->base[0] = lj_ir_kint(J, (int32_t)fct->size);
return; /* Interpreter will throw for newindex. */
} else if (cd && cd->ctypeid == CTID_CTYPEID) {
/* Only resolve constants and metamethods for constructors. */
} else if (ctype_isbitfield(fct->info)) {
if (ofs)
ptr = emitir(IRT(IR_ADD, IRT_PTR), ptr, lj_ir_kintp(J, ofs));
@@ -1878,7 +1892,7 @@ int LJ_FASTCALL recff_bit64_shift(jit_State *J, RecordFFData *rd)
if (J->base[0] && tref_iscdata(J->base[1])) {
tsh = crec_bit64_arg(J, ctype_get(cts, CTID_INT64),
J->base[1], &rd->argv[1]);
if (!tref_isinteger(tsh))
if (LJ_32 && !tref_isinteger(tsh))
tsh = emitconv(tsh, IRT_INT, tref_type(tsh), 0);
J->base[1] = tsh;
}
@@ -1886,15 +1900,17 @@ int LJ_FASTCALL recff_bit64_shift(jit_State *J, RecordFFData *rd)
if (id) {
TRef tr = crec_bit64_arg(J, ctype_get(cts, id), J->base[0], &rd->argv[0]);
uint32_t op = rd->data;
IRType t;
if (!tsh) tsh = lj_opt_narrow_tobit(J, J->base[1]);
t = tref_isinteger(tsh) ? IRT_INT : tref_type(tsh);
if (!(op < IR_BROL ? LJ_TARGET_MASKSHIFT : LJ_TARGET_MASKROT) &&
!tref_isk(tsh))
tsh = emitir(IRTI(IR_BAND), tsh, lj_ir_kint(J, 63));
tsh = emitir(IRT(IR_BAND, t), tsh, lj_ir_kint(J, 63));
#ifdef LJ_TARGET_UNIFYROT
if (op == (LJ_TARGET_UNIFYROT == 1 ? IR_BROR : IR_BROL)) {
op = LJ_TARGET_UNIFYROT == 1 ? IR_BROL : IR_BROR;
tsh = emitir(IRTI(IR_NEG), tsh, tsh);
}
if (op == (LJ_TARGET_UNIFYROT == 1 ? IR_BROR : IR_BROL)) {
op = LJ_TARGET_UNIFYROT == 1 ? IR_BROL : IR_BROR;
tsh = emitir(IRT(IR_NEG, t), tsh, tsh);
}
#endif
tr = emitir(IRT(op, id-CTID_INT64+IRT_I64), tr, tsh);
J->base[0] = emitir(IRTG(IR_CNEWI, IRT_CDATA), lj_ir_kint(J, id), tr);
+1 -1
View File
@@ -1,6 +1,6 @@
/*
** Trace recorder for C data operations.
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
*/
#ifndef _LJ_CRECORD_H
+1 -1
View File
@@ -1,6 +1,6 @@
/*
** C type management.
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
*/
#include "lj_obj.h"
+2 -2
View File
@@ -1,6 +1,6 @@
/*
** C type management.
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
*/
#ifndef _LJ_CTYPE_H
@@ -51,7 +51,7 @@ LJ_STATIC_ASSERT(((int)CT_STRUCT & (int)CT_ARRAY) == CT_STRUCT);
** |FUNC ....VS.. cc cid | nargs | field | name? | name? |
** |TYPEDEF cid | | | name | name |
** |ATTRIB attrnum cid | attr | sib? | type? | |
** |FIELD cid | offset | field | | name? |
** |FIELD A cid | offset | field | | name? |
** |BITFIELD B.cvU csz bsz pos | offset | field | | name? |
** |CONSTVAL c cid | value | const | name | name |
** |EXTERN cid | | sib? | name | name |
+1 -1
View File
@@ -1,6 +1,6 @@
/*
** Debugging and introspection.
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
*/
#define lj_debug_c
+1 -1
View File
@@ -1,6 +1,6 @@
/*
** Debugging and introspection.
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
*/
#ifndef _LJ_DEBUG_H
+3 -1
View File
@@ -1,6 +1,6 @@
/*
** LuaJIT common internal definitions.
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
*/
#ifndef _LJ_DEF_H
@@ -127,6 +127,7 @@ typedef uintptr_t BloomFilter;
#define LJ_INLINE inline
#define LJ_AINLINE inline __attribute__((always_inline))
#define LJ_NOINLINE __attribute__((noinline))
#define LJ_CONSTF __attribute__((nothrow,const))
#if defined(__ELF__) || defined(__MACH__) || defined(__psp2__)
#if !((defined(__sun__) && defined(__svr4__)) || defined(__CELLOS_LV2__))
@@ -245,6 +246,7 @@ static LJ_AINLINE uint32_t lj_getu32(const void *p)
#define LJ_INLINE __inline
#define LJ_AINLINE __forceinline
#define LJ_NOINLINE __declspec(noinline)
#define LJ_CONSTF __declspec(noalias)
#if defined(_M_IX86)
#define LJ_FASTCALL __fastcall
#endif
+24 -14
View File
@@ -1,6 +1,6 @@
/*
** Instruction dispatch handling.
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
*/
#define lj_dispatch_c
@@ -103,8 +103,11 @@ void lj_dispatch_init_hotcount(global_State *g)
#define DISPMODE_PROF 0x40 /* Profiling active. */
/* Update dispatch table depending on various flags. */
void lj_dispatch_update(global_State *g)
void LJ_FASTCALL lj_dispatch_update(global_State *g, int nolock)
{
#if LJ_HASPROFILE && !LJ_PROFILE_SIGPROF
int profile_locked = nolock ? 0 : lj_profile_lock();
#endif
uint8_t oldmode = g->dispatchmode;
uint8_t mode = 0;
#if LJ_HASJIT
@@ -208,6 +211,11 @@ void lj_dispatch_update(global_State *g)
lj_dispatch_init_hotcount(g);
#endif
}
#if LJ_HASPROFILE && !LJ_PROFILE_SIGPROF
if (profile_locked) lj_profile_unlock();
#else
UNUSED(nolock);
#endif
}
/* -- JIT mode setting ---------------------------------------------------- */
@@ -260,7 +268,7 @@ int luaJIT_setmode(lua_State *L, int idx, int mode)
G2J(g)->flags &= ~(uint32_t)JIT_F_ON;
else
G2J(g)->flags |= (uint32_t)JIT_F_ON;
lj_dispatch_update(g);
lj_dispatch_update(g, 0);
}
break;
case LUAJIT_MODE_FUNC:
@@ -335,7 +343,7 @@ LUA_API int lua_sethook(lua_State *L, lua_Hook func, int mask, int count)
g->hookcount = g->hookcstart = (int32_t)count;
g->hookmask = (uint8_t)((g->hookmask & ~HOOK_EVENTMASK) | mask);
lj_trace_abort(g); /* Abort recording on any hook change. */
lj_dispatch_update(g);
lj_dispatch_update(g, 0);
return 1;
}
@@ -523,16 +531,18 @@ out:
/* Stitch a new trace. */
void LJ_FASTCALL lj_dispatch_stitch(jit_State *J, const BCIns *pc)
{
ERRNO_SAVE
lua_State *L = J->L;
void *cf = cframe_raw(L->cframe);
const BCIns *oldpc = cframe_pc(cf);
setcframe_pc(cf, pc);
/* Before dispatch, have to bias PC by 1. */
L->top = L->base + cur_topslot(curr_proto(L), pc+1, cframe_multres_n(cf));
lj_trace_stitch(J, pc-1); /* Point to the CALL instruction. */
setcframe_pc(cf, oldpc);
ERRNO_RESTORE
if (!(J2G(J)->hookmask & HOOK_VMEVENT)) {
ERRNO_SAVE
lua_State *L = J->L;
void *cf = cframe_raw(L->cframe);
const BCIns *oldpc = cframe_pc(cf);
setcframe_pc(cf, pc);
/* Before dispatch, have to bias PC by 1. */
L->top = L->base + cur_topslot(curr_proto(L), pc+1, cframe_multres_n(cf));
lj_trace_stitch(J, pc-1); /* Point to the CALL instruction. */
setcframe_pc(cf, oldpc);
ERRNO_RESTORE
}
}
#endif
+2 -2
View File
@@ -1,6 +1,6 @@
/*
** Instruction dispatch handling.
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
*/
#ifndef _LJ_DISPATCH_H
@@ -132,7 +132,7 @@ LJ_FUNC void lj_dispatch_init(GG_State *GG);
#if LJ_HASJIT
LJ_FUNC void lj_dispatch_init_hotcount(global_State *g);
#endif
LJ_FUNC void lj_dispatch_update(global_State *g);
LJ_FUNC void LJ_FASTCALL lj_dispatch_update(global_State *g, int nolock);
/* Instruction dispatch callback for hooks or when recording. */
LJ_FUNCA void LJ_FASTCALL lj_dispatch_ins(lua_State *L, const BCIns *pc);
+1 -1
View File
@@ -1,6 +1,6 @@
/*
** ARM instruction emitter.
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
*/
/* -- Constant encoding --------------------------------------------------- */
+1 -1
View File
@@ -1,6 +1,6 @@
/*
** ARM64 instruction emitter.
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
**
** Contributed by Djordje Kovacevic and Stefan Pejic from RT-RK.com.
** Sponsored by Cisco Systems, Inc.
+1 -1
View File
@@ -1,6 +1,6 @@
/*
** MIPS instruction emitter.
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
*/
#if LJ_64
+1 -1
View File
@@ -1,6 +1,6 @@
/*
** PPC instruction emitter.
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
*/
/* -- Emit basic instructions --------------------------------------------- */
+1 -1
View File
@@ -1,6 +1,6 @@
/*
** x86/x64 instruction emitter.
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
*/
/* -- Emit basic instructions --------------------------------------------- */
+1 -1
View File
@@ -1,6 +1,6 @@
/*
** Error handling.
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
*/
#define lj_err_c
+1 -1
View File
@@ -1,6 +1,6 @@
/*
** Error handling.
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
*/
#ifndef _LJ_ERR_H
+1 -1
View File
@@ -1,6 +1,6 @@
/*
** VM error messages.
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
*/
/* This file may be included multiple times with different ERRDEF macros. */
+1 -1
View File
@@ -1,6 +1,6 @@
/*
** Fast function IDs.
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
*/
#ifndef _LJ_FF_H
+10 -10
View File
@@ -1,6 +1,6 @@
/*
** Fast function call recorder.
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
*/
#define lj_ffrecord_c
@@ -70,7 +70,7 @@ static int32_t argv2int(jit_State *J, TValue *o)
{
if (!lj_strscan_numberobj(o))
lj_trace_err(J, LJ_TRERR_BADTYPE);
return tvisint(o) ? intV(o) : lj_num2int(numV(o));
return numberVint(o);
}
/* Get runtime value of string argument. */
@@ -586,7 +586,7 @@ static void LJ_FASTCALL recff_math_round(jit_State *J, RecordFFData *rd)
/* Result is integral (or NaN/Inf), but may not fit an int32_t. */
if (LJ_DUALNUM) { /* Try to narrow using a guarded conversion to int. */
lua_Number n = lj_vm_foldfpm(numberVnum(&rd->argv[0]), rd->data);
if (n == (lua_Number)lj_num2int(n))
if (lj_num2int_ok(n))
tr = emitir(IRTGI(IR_CONV), tr, IRCONV_INT_NUM|IRCONV_CHECK);
}
J->base[0] = tr;
@@ -796,7 +796,7 @@ static TRef recff_string_start(jit_State *J, GCstr *s, int32_t *st, TRef tr,
emitir(IRTGI(IR_EQ), tr, tr0);
tr = tr0;
} else {
tr = emitir(IRTI(IR_ADD), tr, lj_ir_kint(J, -1));
tr = emitir(IRTGI(IR_ADDOV), tr, lj_ir_kint(J, -1));
emitir(IRTGI(IR_GE), tr, tr0);
start--;
}
@@ -848,15 +848,15 @@ static void LJ_FASTCALL recff_string_range(jit_State *J, RecordFFData *rd)
} else if ((MSize)end <= str->len) {
emitir(IRTGI(IR_ULE), trend, trlen);
} else {
emitir(IRTGI(IR_UGT), trend, trlen);
emitir(IRTGI(IR_GT), trend, trlen);
end = (int32_t)str->len;
trend = trlen;
}
trstart = recff_string_start(J, str, &start, trstart, trlen, tr0);
if (rd->data) { /* Return string.sub result. */
if (end - start >= 0) {
if (start <= end) {
/* Also handle empty range here, to avoid extra traces. */
TRef trptr, trslen = emitir(IRTI(IR_SUB), trend, trstart);
TRef trptr, trslen = emitir(IRTGI(IR_SUBOV), trend, trstart);
emitir(IRTGI(IR_GE), trslen, tr0);
trptr = emitir(IRT(IR_STRREF, IRT_PGC), trstr, trstart);
J->base[0] = emitir(IRT(IR_SNEW, IRT_STR), trptr, trslen);
@@ -865,9 +865,9 @@ static void LJ_FASTCALL recff_string_range(jit_State *J, RecordFFData *rd)
J->base[0] = lj_ir_kstr(J, &J2G(J)->strempty);
}
} else { /* Return string.byte result(s). */
ptrdiff_t i, len = end - start;
if (len > 0) {
TRef trslen = emitir(IRTI(IR_SUB), trend, trstart);
if (start < end) {
ptrdiff_t i, len = end - start;
TRef trslen = emitir(IRTGI(IR_SUBOV), trend, trstart);
emitir(IRTGI(IR_EQ), trslen, lj_ir_kint(J, (int32_t)len));
if (J->baseslot + len > LJ_MAX_JSLOTS)
lj_trace_err_info(J, LJ_TRERR_STACKOV);
+1 -1
View File
@@ -1,6 +1,6 @@
/*
** Fast function call recorder.
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
*/
#ifndef _LJ_FFRECORD_H
+1 -1
View File
@@ -1,6 +1,6 @@
/*
** Stack frames.
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
*/
#ifndef _LJ_FRAME_H
+1 -1
View File
@@ -1,6 +1,6 @@
/*
** Function handling (prototypes, functions and upvalues).
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
**
** Portions taken verbatim or adapted from the Lua interpreter.
** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h
+1 -1
View File
@@ -1,6 +1,6 @@
/*
** Function handling (prototypes, functions and upvalues).
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
*/
#ifndef _LJ_FUNC_H
+16 -12
View File
@@ -1,6 +1,6 @@
/*
** Garbage collector.
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
**
** Major portions taken verbatim or adapted from the Lua interpreter.
** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h
@@ -106,6 +106,7 @@ static void gc_mark_start(global_State *g)
setgcrefnull(g->gc.weak);
gc_markobj(g, mainthread(g));
gc_markobj(g, tabref(mainthread(g)->env));
gc_markobj(g, vmthread(g));
gc_marktv(g, &g->registrytv);
gc_mark_gcroot(g);
g->gc.state = GCSpropagate;
@@ -507,26 +508,29 @@ static void gc_call_finalizer(global_State *g, lua_State *L,
uint8_t oldh = hook_save(g);
GCSize oldt = g->gc.threshold;
int errcode;
lua_State *VL = vmthread(g);
TValue *top;
lj_trace_abort(g);
hook_entergc(g); /* Disable hooks and new traces during __gc. */
if (LJ_HASPROFILE && (oldh & HOOK_PROFILE)) lj_dispatch_update(g);
if (LJ_HASPROFILE && (oldh & HOOK_PROFILE)) lj_dispatch_update(g, 0);
g->gc.threshold = LJ_MAX_MEM; /* Prevent GC steps. */
top = L->top;
copyTV(L, top++, mo);
top = VL->top;
copyTV(VL, top++, mo);
if (LJ_FR2) setnilV(top++);
setgcV(L, top, o, ~o->gch.gct);
L->top = top+1;
errcode = lj_vm_pcall(L, top, 1+0, -1); /* Stack: |mo|o| -> | */
setgcV(VL, top, o, ~o->gch.gct);
VL->top = top+1;
errcode = lj_vm_pcall(VL, top, 1+0, -1); /* Stack: |mo|o| -> | */
setgcref(g->cur_L, obj2gco(L));
hook_restore(g, oldh);
if (LJ_HASPROFILE && (oldh & HOOK_PROFILE)) lj_dispatch_update(g);
if (LJ_HASPROFILE && (oldh & HOOK_PROFILE)) lj_dispatch_update(g, 0);
g->gc.threshold = oldt; /* Restore GC threshold. */
if (errcode) {
ptrdiff_t errobj = savestack(L, L->top-1); /* Stack may be resized. */
lj_vmevent_send(L, ERRFIN,
copyTV(L, L->top++, restorestack(L, errobj));
TValue tmp;
copyTV(VL, &tmp, VL->top-1);
VL->top--;
lj_vmevent_send(g, ERRFIN,
copyTV(V, V->top++, &tmp);
);
L->top--;
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
/*
** Garbage collector.
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2026 Mike Pall. See Copyright Notice in luajit.h
*/
#ifndef _LJ_GC_H

Some files were not shown because too many files have changed in this diff Show More