diff --git a/CMakeLists.txt b/CMakeLists.txt index 97cd4abf..4d3b059d 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -221,7 +221,7 @@ endif() set(MEGA_ZLIB_VER "1.3.1") set(MEGA_LUA51_VER "5.1.5") -set(MEGA_LUAJIT_VER "2.1.1710088188") +set(MEGA_LUAJIT_VER "2.1.1734355927") set(MEGA_LIBOGG_VER "1.3.2") set(MEGA_LIBVORBIS_VER "1.3.5") set(MEGA_LIBTHEORA_VER "1.1.1") diff --git a/libs/LuaJIT/.relver b/libs/LuaJIT/.relver index b1fbd688..88689fbd 100644 --- a/libs/LuaJIT/.relver +++ b/libs/LuaJIT/.relver @@ -1 +1 @@ -1710088188 +1734355927 diff --git a/libs/LuaJIT/Makefile b/libs/LuaJIT/Makefile index 3aed365d..6b67f54d 100644 --- a/libs/LuaJIT/Makefile +++ b/libs/LuaJIT/Makefile @@ -37,12 +37,13 @@ export MULTILIB= lib DPREFIX= $(DESTDIR)$(PREFIX) INSTALL_BIN= $(DPREFIX)/bin INSTALL_LIB= $(DPREFIX)/$(MULTILIB) -INSTALL_SHARE= $(DPREFIX)/share +INSTALL_SHARE_= $(PREFIX)/share +INSTALL_SHARE= $(DESTDIR)$(INSTALL_SHARE_) INSTALL_DEFINC= $(DPREFIX)/include/luajit-$(MMVERSION) INSTALL_INC= $(INSTALL_DEFINC) -INSTALL_LJLIBD= $(INSTALL_SHARE)/luajit-$(MMVERSION) -INSTALL_JITLIB= $(INSTALL_LJLIBD)/jit +export INSTALL_LJLIBD= $(INSTALL_SHARE_)/luajit-$(MMVERSION) +INSTALL_JITLIB= $(DESTDIR)$(INSTALL_LJLIBD)/jit INSTALL_LMODD= $(INSTALL_SHARE)/lua INSTALL_LMOD= $(INSTALL_LMODD)/$(ABIVER) INSTALL_CMODD= $(INSTALL_LIB)/lua @@ -71,7 +72,7 @@ INSTALL_PC= $(INSTALL_PKGCONFIG)/$(INSTALL_PCNAME) INSTALL_DIRS= $(INSTALL_BIN) $(INSTALL_LIB) $(INSTALL_INC) $(INSTALL_MAN) \ $(INSTALL_PKGCONFIG) $(INSTALL_JITLIB) $(INSTALL_LMOD) $(INSTALL_CMOD) -UNINSTALL_DIRS= $(INSTALL_JITLIB) $(INSTALL_LJLIBD) $(INSTALL_INC) \ +UNINSTALL_DIRS= $(INSTALL_JITLIB) $(DESTDIR)$(INSTALL_LJLIBD) $(INSTALL_INC) \ $(INSTALL_LMOD) $(INSTALL_LMODD) $(INSTALL_CMOD) $(INSTALL_CMODD) RM= rm -f @@ -114,6 +115,7 @@ ifeq (Darwin,$(TARGET_SYS)) INSTALL_SOSHORT1= $(INSTALL_DYLIBSHORT1) INSTALL_SOSHORT2= $(INSTALL_DYLIBSHORT2) LDCONFIG= : + SED_PC+= -e "s| -Wl,-E||" endif ############################################################################## diff --git a/libs/LuaJIT/android/arm64-v8a/jit/bcsave.lua b/libs/LuaJIT/android/arm64-v8a/jit/bcsave.lua index 131bf39b..48378819 100644 --- a/libs/LuaJIT/android/arm64-v8a/jit/bcsave.lua +++ b/libs/LuaJIT/android/arm64-v8a/jit/bcsave.lua @@ -439,24 +439,12 @@ typedef struct { mach_header; uint32_t reserved; } mach_header_64; -typedef struct { - uint32_t cmd, cmdsize; - char segname[16]; - uint32_t vmaddr, vmsize, fileoff, filesize; - uint32_t maxprot, initprot, nsects, flags; -} mach_segment_command; typedef struct { uint32_t cmd, cmdsize; char segname[16]; uint64_t vmaddr, vmsize, fileoff, filesize; uint32_t maxprot, initprot, nsects, flags; } mach_segment_command_64; -typedef struct { - char sectname[16], segname[16]; - uint32_t addr, size; - uint32_t offset, align, reloff, nreloc, flags; - uint32_t reserved1, reserved2; -} mach_section; typedef struct { char sectname[16], segname[16]; uint64_t addr, size; @@ -466,139 +454,64 @@ typedef struct { typedef struct { uint32_t cmd, cmdsize, symoff, nsyms, stroff, strsize; } mach_symtab_command; -typedef struct { - int32_t strx; - uint8_t type, sect; - int16_t desc; - uint32_t value; -} mach_nlist; typedef struct { int32_t strx; uint8_t type, sect; uint16_t desc; uint64_t value; } mach_nlist_64; -typedef struct -{ - int32_t magic, nfat_arch; -} mach_fat_header; -typedef struct -{ - int32_t cputype, cpusubtype, offset, size, align; -} mach_fat_arch; typedef struct { - struct { - mach_header hdr; - mach_segment_command seg; - mach_section sec; - mach_symtab_command sym; - } arch[1]; - mach_nlist sym_entry; - uint8_t space[4096]; -} mach_obj; -typedef struct { - struct { - mach_header_64 hdr; - mach_segment_command_64 seg; - mach_section_64 sec; - mach_symtab_command sym; - } arch[1]; + mach_header_64 hdr; + mach_segment_command_64 seg; + mach_section_64 sec; + mach_symtab_command sym; mach_nlist_64 sym_entry; uint8_t space[4096]; } mach_obj_64; -typedef struct { - mach_fat_header fat; - mach_fat_arch fat_arch[2]; - struct { - mach_header hdr; - mach_segment_command seg; - mach_section sec; - mach_symtab_command sym; - } arch[2]; - mach_nlist sym_entry; - uint8_t space[4096]; -} mach_fat_obj; -typedef struct { - mach_fat_header fat; - mach_fat_arch fat_arch[2]; - struct { - mach_header_64 hdr; - mach_segment_command_64 seg; - mach_section_64 sec; - mach_symtab_command sym; - } arch[2]; - mach_nlist_64 sym_entry; - uint8_t space[4096]; -} mach_fat_obj_64; ]] local symname = '_'..LJBC_PREFIX..ctx.modname - local isfat, is64, align, mobj = false, false, 4, "mach_obj" - if ctx.arch == "x64" then - is64, align, mobj = true, 8, "mach_obj_64" - elseif ctx.arch == "arm" then - isfat, mobj = true, "mach_fat_obj" - elseif ctx.arch == "arm64" then - is64, align, isfat, mobj = true, 8, true, "mach_fat_obj_64" - else - check(ctx.arch == "x86", "unsupported architecture for OSX") + local cputype, cpusubtype = 0x01000007, 3 + if ctx.arch ~= "x64" then + check(ctx.arch == "arm64", "unsupported architecture for OSX") + cputype, cpusubtype = 0x0100000c, 0 end local function aligned(v, a) return bit.band(v+a-1, -a) end - local be32 = bit.bswap -- Mach-O FAT is BE, supported archs are LE. -- Create Mach-O object and fill in header. - local o = ffi.new(mobj) - local mach_size = aligned(ffi.offsetof(o, "space")+#symname+2, align) - local cputype = ({ x86={7}, x64={0x01000007}, arm={7,12}, arm64={0x01000007,0x0100000c} })[ctx.arch] - local cpusubtype = ({ x86={3}, x64={3}, arm={3,9}, arm64={3,0} })[ctx.arch] - if isfat then - o.fat.magic = be32(0xcafebabe) - o.fat.nfat_arch = be32(#cpusubtype) - end + local o = ffi.new("mach_obj_64") + local mach_size = aligned(ffi.offsetof(o, "space")+#symname+2, 8) -- Fill in sections and symbols. - for i=0,#cpusubtype-1 do - local ofs = 0 - if isfat then - local a = o.fat_arch[i] - a.cputype = be32(cputype[i+1]) - a.cpusubtype = be32(cpusubtype[i+1]) - -- Subsequent slices overlap each other to share data. - ofs = ffi.offsetof(o, "arch") + i*ffi.sizeof(o.arch[0]) - a.offset = be32(ofs) - a.size = be32(mach_size-ofs+#s) - end - local a = o.arch[i] - a.hdr.magic = is64 and 0xfeedfacf or 0xfeedface - a.hdr.cputype = cputype[i+1] - a.hdr.cpusubtype = cpusubtype[i+1] - a.hdr.filetype = 1 - a.hdr.ncmds = 2 - a.hdr.sizeofcmds = ffi.sizeof(a.seg)+ffi.sizeof(a.sec)+ffi.sizeof(a.sym) - a.seg.cmd = is64 and 0x19 or 0x1 - a.seg.cmdsize = ffi.sizeof(a.seg)+ffi.sizeof(a.sec) - a.seg.vmsize = #s - a.seg.fileoff = mach_size-ofs - a.seg.filesize = #s - a.seg.maxprot = 1 - a.seg.initprot = 1 - a.seg.nsects = 1 - ffi.copy(a.sec.sectname, "__data") - ffi.copy(a.sec.segname, "__DATA") - a.sec.size = #s - a.sec.offset = mach_size-ofs - a.sym.cmd = 2 - a.sym.cmdsize = ffi.sizeof(a.sym) - a.sym.symoff = ffi.offsetof(o, "sym_entry")-ofs - a.sym.nsyms = 1 - a.sym.stroff = ffi.offsetof(o, "sym_entry")+ffi.sizeof(o.sym_entry)-ofs - a.sym.strsize = aligned(#symname+2, align) - end + o.hdr.magic = 0xfeedfacf + o.hdr.cputype = cputype + o.hdr.cpusubtype = cpusubtype + o.hdr.filetype = 1 + o.hdr.ncmds = 2 + o.hdr.sizeofcmds = ffi.sizeof(o.seg)+ffi.sizeof(o.sec)+ffi.sizeof(o.sym) + 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.filesize = #s + o.seg.maxprot = 1 + o.seg.initprot = 1 + o.seg.nsects = 1 + ffi.copy(o.sec.sectname, "__data") + ffi.copy(o.sec.segname, "__DATA") + o.sec.size = #s + o.sec.offset = mach_size + o.sym.cmd = 2 + o.sym.cmdsize = ffi.sizeof(o.sym) + o.sym.symoff = ffi.offsetof(o, "sym_entry") + o.sym.nsyms = 1 + o.sym.stroff = ffi.offsetof(o, "sym_entry")+ffi.sizeof(o.sym_entry) + 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) - -- Write Macho-O object file. + -- Write Mach-O object file. local fp = savefile(output, "wb") fp:write(ffi.string(o, mach_size)) bcsave_tail(fp, output, s) diff --git a/libs/LuaJIT/android/arm64-v8a/jit/dis_arm64.lua b/libs/LuaJIT/android/arm64-v8a/jit/dis_arm64.lua index 84677666..2741cd2e 100644 --- a/libs/LuaJIT/android/arm64-v8a/jit/dis_arm64.lua +++ b/libs/LuaJIT/android/arm64-v8a/jit/dis_arm64.lua @@ -658,6 +658,10 @@ local map_datafp = { -- Data processing, SIMD and FP. } } } + }, + { -- 010 + shift = 0, mask = 0x81f8fc00, + [0x100e400] = "moviDdG" } } @@ -832,6 +836,20 @@ local function parse_fpimm8(op) return sign * frac * 2^exp end +local function decode_fpmovi(op) + local lo = rshift(op, 5) + local hi = rshift(op, 9) + lo = bor(band(lo, 1) * 0xff, band(lo, 2) * 0x7f80, band(lo, 4) * 0x3fc000, + band(lo, 8) * 0x1fe00000) + hi = bor(band(hi, 1) * 0xff, band(hi, 0x80) * 0x1fe, + band(hi, 0x100) * 0xff00, band(hi, 0x200) * 0x7f8000) + if hi ~= 0 then + return fmt_hex32(hi)..tohex(lo) + else + return fmt_hex32(lo) + end +end + local function prefer_bfx(sf, uns, imms, immr) if imms < immr or imms == 31 or imms == 63 then return false @@ -1131,6 +1149,8 @@ local function disass_ins(ctx) x = 0 elseif p == "F" then x = parse_fpimm8(op) + elseif p == "G" then + x = "#0x"..decode_fpmovi(op) elseif p == "g" or p == "f" or p == "x" or p == "w" or p == "d" or p == "s" then -- These are handled in D/N/M/A. diff --git a/libs/LuaJIT/android/arm64-v8a/jit/dump.lua b/libs/LuaJIT/android/arm64-v8a/jit/dump.lua index 746732f9..f296a517 100644 --- a/libs/LuaJIT/android/arm64-v8a/jit/dump.lua +++ b/libs/LuaJIT/android/arm64-v8a/jit/dump.lua @@ -552,7 +552,12 @@ local recdepth = 0 local function fmterr(err, info) if type(err) == "number" then if type(info) == "function" then info = fmtfunc(info) end - err = format(vmdef.traceerr[err], info) + local fmt = vmdef.traceerr[err] + if fmt == "NYI: bytecode %s" then + local oidx = 6 * info + info = sub(vmdef.bcnames, oidx+1, oidx+6) + end + err = format(fmt, info) end return err end diff --git a/libs/LuaJIT/android/arm64-v8a/jit/p.lua b/libs/LuaJIT/android/arm64-v8a/jit/p.lua index 36f836c5..ef2ee82f 100644 --- a/libs/LuaJIT/android/arm64-v8a/jit/p.lua +++ b/libs/LuaJIT/android/arm64-v8a/jit/p.lua @@ -227,9 +227,7 @@ local function prof_finish() local samples = prof_samples if samples == 0 then if prof_raw ~= true then out:write("[No samples collected]\n") end - return - end - if prof_ann then + elseif prof_ann then prof_annotate(prof_count1, samples) else prof_top(prof_count1, prof_count2, samples, "") diff --git a/libs/LuaJIT/android/arm64-v8a/jit/v.lua b/libs/LuaJIT/android/arm64-v8a/jit/v.lua index 8e91f494..45a663d7 100644 --- a/libs/LuaJIT/android/arm64-v8a/jit/v.lua +++ b/libs/LuaJIT/android/arm64-v8a/jit/v.lua @@ -62,7 +62,7 @@ local jit = require("jit") local jutil = require("jit.util") local vmdef = require("jit.vmdef") local funcinfo, traceinfo = jutil.funcinfo, jutil.traceinfo -local type, format = type, string.format +local type, sub, format = type, string.sub, string.format local stdout, stderr = io.stdout, io.stderr -- Active flag and output file handle. @@ -89,7 +89,12 @@ end local function fmterr(err, info) if type(err) == "number" then if type(info) == "function" then info = fmtfunc(info) end - err = format(vmdef.traceerr[err], info) + local fmt = vmdef.traceerr[err] + if fmt == "NYI: bytecode %s" then + local oidx = 6 * info + info = sub(vmdef.bcnames, oidx+1, oidx+6) + end + err = format(fmt, info) end return err end diff --git a/libs/LuaJIT/android/arm64-v8a/jit/vmdef.lua b/libs/LuaJIT/android/arm64-v8a/jit/vmdef.lua index 75bc8b87..96003c05 100644 --- a/libs/LuaJIT/android/arm64-v8a/jit/vmdef.lua +++ b/libs/LuaJIT/android/arm64-v8a/jit/vmdef.lua @@ -1,6 +1,6 @@ -- This is a generated file. DO NOT EDIT! -assert(require("jit").version == "LuaJIT 2.1.1710088188", "LuaJIT core/library version mismatch") +assert(require("jit").version == "LuaJIT 2.1.1734355927", "LuaJIT core/library version mismatch") return { @@ -136,7 +136,7 @@ traceerr = { "too many snapshots", "blacklisted", "retry recording", -"NYI: bytecode %d", +"NYI: bytecode %s", "leaving loop in root trace", "inner loop in root trace", "loop unroll limit reached", diff --git a/libs/LuaJIT/android/arm64-v8a/libluajit.a b/libs/LuaJIT/android/arm64-v8a/libluajit.a index d7354680..d13cb171 100644 Binary files a/libs/LuaJIT/android/arm64-v8a/libluajit.a and b/libs/LuaJIT/android/arm64-v8a/libluajit.a differ diff --git a/libs/LuaJIT/android/arm64-v8a/libluajit.so b/libs/LuaJIT/android/arm64-v8a/libluajit.so index cf113c39..fb38ad3b 100644 Binary files a/libs/LuaJIT/android/arm64-v8a/libluajit.so and b/libs/LuaJIT/android/arm64-v8a/libluajit.so differ diff --git a/libs/LuaJIT/android/arm64-v8a/luajit.h b/libs/LuaJIT/android/arm64-v8a/luajit.h index 39794a55..d871b000 100644 --- a/libs/LuaJIT/android/arm64-v8a/luajit.h +++ b/libs/LuaJIT/android/arm64-v8a/luajit.h @@ -30,9 +30,9 @@ #include "lua.h" -#define LUAJIT_VERSION "LuaJIT 2.1.1710088188" +#define LUAJIT_VERSION "LuaJIT 2.1.1734355927" #define LUAJIT_VERSION_NUM 20199 /* Deprecated. */ -#define LUAJIT_VERSION_SYM luaJIT_version_2_1_1710088188 +#define LUAJIT_VERSION_SYM luaJIT_version_2_1_1734355927 #define LUAJIT_COPYRIGHT "Copyright (C) 2005-2023 Mike Pall" #define LUAJIT_URL "https://luajit.org/" diff --git a/libs/LuaJIT/android/armeabi-v7a/jit/bcsave.lua b/libs/LuaJIT/android/armeabi-v7a/jit/bcsave.lua index 131bf39b..48378819 100644 --- a/libs/LuaJIT/android/armeabi-v7a/jit/bcsave.lua +++ b/libs/LuaJIT/android/armeabi-v7a/jit/bcsave.lua @@ -439,24 +439,12 @@ typedef struct { mach_header; uint32_t reserved; } mach_header_64; -typedef struct { - uint32_t cmd, cmdsize; - char segname[16]; - uint32_t vmaddr, vmsize, fileoff, filesize; - uint32_t maxprot, initprot, nsects, flags; -} mach_segment_command; typedef struct { uint32_t cmd, cmdsize; char segname[16]; uint64_t vmaddr, vmsize, fileoff, filesize; uint32_t maxprot, initprot, nsects, flags; } mach_segment_command_64; -typedef struct { - char sectname[16], segname[16]; - uint32_t addr, size; - uint32_t offset, align, reloff, nreloc, flags; - uint32_t reserved1, reserved2; -} mach_section; typedef struct { char sectname[16], segname[16]; uint64_t addr, size; @@ -466,139 +454,64 @@ typedef struct { typedef struct { uint32_t cmd, cmdsize, symoff, nsyms, stroff, strsize; } mach_symtab_command; -typedef struct { - int32_t strx; - uint8_t type, sect; - int16_t desc; - uint32_t value; -} mach_nlist; typedef struct { int32_t strx; uint8_t type, sect; uint16_t desc; uint64_t value; } mach_nlist_64; -typedef struct -{ - int32_t magic, nfat_arch; -} mach_fat_header; -typedef struct -{ - int32_t cputype, cpusubtype, offset, size, align; -} mach_fat_arch; typedef struct { - struct { - mach_header hdr; - mach_segment_command seg; - mach_section sec; - mach_symtab_command sym; - } arch[1]; - mach_nlist sym_entry; - uint8_t space[4096]; -} mach_obj; -typedef struct { - struct { - mach_header_64 hdr; - mach_segment_command_64 seg; - mach_section_64 sec; - mach_symtab_command sym; - } arch[1]; + mach_header_64 hdr; + mach_segment_command_64 seg; + mach_section_64 sec; + mach_symtab_command sym; mach_nlist_64 sym_entry; uint8_t space[4096]; } mach_obj_64; -typedef struct { - mach_fat_header fat; - mach_fat_arch fat_arch[2]; - struct { - mach_header hdr; - mach_segment_command seg; - mach_section sec; - mach_symtab_command sym; - } arch[2]; - mach_nlist sym_entry; - uint8_t space[4096]; -} mach_fat_obj; -typedef struct { - mach_fat_header fat; - mach_fat_arch fat_arch[2]; - struct { - mach_header_64 hdr; - mach_segment_command_64 seg; - mach_section_64 sec; - mach_symtab_command sym; - } arch[2]; - mach_nlist_64 sym_entry; - uint8_t space[4096]; -} mach_fat_obj_64; ]] local symname = '_'..LJBC_PREFIX..ctx.modname - local isfat, is64, align, mobj = false, false, 4, "mach_obj" - if ctx.arch == "x64" then - is64, align, mobj = true, 8, "mach_obj_64" - elseif ctx.arch == "arm" then - isfat, mobj = true, "mach_fat_obj" - elseif ctx.arch == "arm64" then - is64, align, isfat, mobj = true, 8, true, "mach_fat_obj_64" - else - check(ctx.arch == "x86", "unsupported architecture for OSX") + local cputype, cpusubtype = 0x01000007, 3 + if ctx.arch ~= "x64" then + check(ctx.arch == "arm64", "unsupported architecture for OSX") + cputype, cpusubtype = 0x0100000c, 0 end local function aligned(v, a) return bit.band(v+a-1, -a) end - local be32 = bit.bswap -- Mach-O FAT is BE, supported archs are LE. -- Create Mach-O object and fill in header. - local o = ffi.new(mobj) - local mach_size = aligned(ffi.offsetof(o, "space")+#symname+2, align) - local cputype = ({ x86={7}, x64={0x01000007}, arm={7,12}, arm64={0x01000007,0x0100000c} })[ctx.arch] - local cpusubtype = ({ x86={3}, x64={3}, arm={3,9}, arm64={3,0} })[ctx.arch] - if isfat then - o.fat.magic = be32(0xcafebabe) - o.fat.nfat_arch = be32(#cpusubtype) - end + local o = ffi.new("mach_obj_64") + local mach_size = aligned(ffi.offsetof(o, "space")+#symname+2, 8) -- Fill in sections and symbols. - for i=0,#cpusubtype-1 do - local ofs = 0 - if isfat then - local a = o.fat_arch[i] - a.cputype = be32(cputype[i+1]) - a.cpusubtype = be32(cpusubtype[i+1]) - -- Subsequent slices overlap each other to share data. - ofs = ffi.offsetof(o, "arch") + i*ffi.sizeof(o.arch[0]) - a.offset = be32(ofs) - a.size = be32(mach_size-ofs+#s) - end - local a = o.arch[i] - a.hdr.magic = is64 and 0xfeedfacf or 0xfeedface - a.hdr.cputype = cputype[i+1] - a.hdr.cpusubtype = cpusubtype[i+1] - a.hdr.filetype = 1 - a.hdr.ncmds = 2 - a.hdr.sizeofcmds = ffi.sizeof(a.seg)+ffi.sizeof(a.sec)+ffi.sizeof(a.sym) - a.seg.cmd = is64 and 0x19 or 0x1 - a.seg.cmdsize = ffi.sizeof(a.seg)+ffi.sizeof(a.sec) - a.seg.vmsize = #s - a.seg.fileoff = mach_size-ofs - a.seg.filesize = #s - a.seg.maxprot = 1 - a.seg.initprot = 1 - a.seg.nsects = 1 - ffi.copy(a.sec.sectname, "__data") - ffi.copy(a.sec.segname, "__DATA") - a.sec.size = #s - a.sec.offset = mach_size-ofs - a.sym.cmd = 2 - a.sym.cmdsize = ffi.sizeof(a.sym) - a.sym.symoff = ffi.offsetof(o, "sym_entry")-ofs - a.sym.nsyms = 1 - a.sym.stroff = ffi.offsetof(o, "sym_entry")+ffi.sizeof(o.sym_entry)-ofs - a.sym.strsize = aligned(#symname+2, align) - end + o.hdr.magic = 0xfeedfacf + o.hdr.cputype = cputype + o.hdr.cpusubtype = cpusubtype + o.hdr.filetype = 1 + o.hdr.ncmds = 2 + o.hdr.sizeofcmds = ffi.sizeof(o.seg)+ffi.sizeof(o.sec)+ffi.sizeof(o.sym) + 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.filesize = #s + o.seg.maxprot = 1 + o.seg.initprot = 1 + o.seg.nsects = 1 + ffi.copy(o.sec.sectname, "__data") + ffi.copy(o.sec.segname, "__DATA") + o.sec.size = #s + o.sec.offset = mach_size + o.sym.cmd = 2 + o.sym.cmdsize = ffi.sizeof(o.sym) + o.sym.symoff = ffi.offsetof(o, "sym_entry") + o.sym.nsyms = 1 + o.sym.stroff = ffi.offsetof(o, "sym_entry")+ffi.sizeof(o.sym_entry) + 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) - -- Write Macho-O object file. + -- Write Mach-O object file. local fp = savefile(output, "wb") fp:write(ffi.string(o, mach_size)) bcsave_tail(fp, output, s) diff --git a/libs/LuaJIT/android/armeabi-v7a/jit/dis_arm64.lua b/libs/LuaJIT/android/armeabi-v7a/jit/dis_arm64.lua index 84677666..2741cd2e 100644 --- a/libs/LuaJIT/android/armeabi-v7a/jit/dis_arm64.lua +++ b/libs/LuaJIT/android/armeabi-v7a/jit/dis_arm64.lua @@ -658,6 +658,10 @@ local map_datafp = { -- Data processing, SIMD and FP. } } } + }, + { -- 010 + shift = 0, mask = 0x81f8fc00, + [0x100e400] = "moviDdG" } } @@ -832,6 +836,20 @@ local function parse_fpimm8(op) return sign * frac * 2^exp end +local function decode_fpmovi(op) + local lo = rshift(op, 5) + local hi = rshift(op, 9) + lo = bor(band(lo, 1) * 0xff, band(lo, 2) * 0x7f80, band(lo, 4) * 0x3fc000, + band(lo, 8) * 0x1fe00000) + hi = bor(band(hi, 1) * 0xff, band(hi, 0x80) * 0x1fe, + band(hi, 0x100) * 0xff00, band(hi, 0x200) * 0x7f8000) + if hi ~= 0 then + return fmt_hex32(hi)..tohex(lo) + else + return fmt_hex32(lo) + end +end + local function prefer_bfx(sf, uns, imms, immr) if imms < immr or imms == 31 or imms == 63 then return false @@ -1131,6 +1149,8 @@ local function disass_ins(ctx) x = 0 elseif p == "F" then x = parse_fpimm8(op) + elseif p == "G" then + x = "#0x"..decode_fpmovi(op) elseif p == "g" or p == "f" or p == "x" or p == "w" or p == "d" or p == "s" then -- These are handled in D/N/M/A. diff --git a/libs/LuaJIT/android/armeabi-v7a/jit/dump.lua b/libs/LuaJIT/android/armeabi-v7a/jit/dump.lua index 746732f9..f296a517 100644 --- a/libs/LuaJIT/android/armeabi-v7a/jit/dump.lua +++ b/libs/LuaJIT/android/armeabi-v7a/jit/dump.lua @@ -552,7 +552,12 @@ local recdepth = 0 local function fmterr(err, info) if type(err) == "number" then if type(info) == "function" then info = fmtfunc(info) end - err = format(vmdef.traceerr[err], info) + local fmt = vmdef.traceerr[err] + if fmt == "NYI: bytecode %s" then + local oidx = 6 * info + info = sub(vmdef.bcnames, oidx+1, oidx+6) + end + err = format(fmt, info) end return err end diff --git a/libs/LuaJIT/android/armeabi-v7a/jit/p.lua b/libs/LuaJIT/android/armeabi-v7a/jit/p.lua index 36f836c5..ef2ee82f 100644 --- a/libs/LuaJIT/android/armeabi-v7a/jit/p.lua +++ b/libs/LuaJIT/android/armeabi-v7a/jit/p.lua @@ -227,9 +227,7 @@ local function prof_finish() local samples = prof_samples if samples == 0 then if prof_raw ~= true then out:write("[No samples collected]\n") end - return - end - if prof_ann then + elseif prof_ann then prof_annotate(prof_count1, samples) else prof_top(prof_count1, prof_count2, samples, "") diff --git a/libs/LuaJIT/android/armeabi-v7a/jit/v.lua b/libs/LuaJIT/android/armeabi-v7a/jit/v.lua index 8e91f494..45a663d7 100644 --- a/libs/LuaJIT/android/armeabi-v7a/jit/v.lua +++ b/libs/LuaJIT/android/armeabi-v7a/jit/v.lua @@ -62,7 +62,7 @@ local jit = require("jit") local jutil = require("jit.util") local vmdef = require("jit.vmdef") local funcinfo, traceinfo = jutil.funcinfo, jutil.traceinfo -local type, format = type, string.format +local type, sub, format = type, string.sub, string.format local stdout, stderr = io.stdout, io.stderr -- Active flag and output file handle. @@ -89,7 +89,12 @@ end local function fmterr(err, info) if type(err) == "number" then if type(info) == "function" then info = fmtfunc(info) end - err = format(vmdef.traceerr[err], info) + local fmt = vmdef.traceerr[err] + if fmt == "NYI: bytecode %s" then + local oidx = 6 * info + info = sub(vmdef.bcnames, oidx+1, oidx+6) + end + err = format(fmt, info) end return err end diff --git a/libs/LuaJIT/android/armeabi-v7a/jit/vmdef.lua b/libs/LuaJIT/android/armeabi-v7a/jit/vmdef.lua index 75bc8b87..96003c05 100644 --- a/libs/LuaJIT/android/armeabi-v7a/jit/vmdef.lua +++ b/libs/LuaJIT/android/armeabi-v7a/jit/vmdef.lua @@ -1,6 +1,6 @@ -- This is a generated file. DO NOT EDIT! -assert(require("jit").version == "LuaJIT 2.1.1710088188", "LuaJIT core/library version mismatch") +assert(require("jit").version == "LuaJIT 2.1.1734355927", "LuaJIT core/library version mismatch") return { @@ -136,7 +136,7 @@ traceerr = { "too many snapshots", "blacklisted", "retry recording", -"NYI: bytecode %d", +"NYI: bytecode %s", "leaving loop in root trace", "inner loop in root trace", "loop unroll limit reached", diff --git a/libs/LuaJIT/android/armeabi-v7a/libluajit.a b/libs/LuaJIT/android/armeabi-v7a/libluajit.a index f59778d4..9c9aedf6 100644 Binary files a/libs/LuaJIT/android/armeabi-v7a/libluajit.a and b/libs/LuaJIT/android/armeabi-v7a/libluajit.a differ diff --git a/libs/LuaJIT/android/armeabi-v7a/libluajit.so b/libs/LuaJIT/android/armeabi-v7a/libluajit.so index a1a1b40f..a456e56c 100644 Binary files a/libs/LuaJIT/android/armeabi-v7a/libluajit.so and b/libs/LuaJIT/android/armeabi-v7a/libluajit.so differ diff --git a/libs/LuaJIT/android/armeabi-v7a/luajit.h b/libs/LuaJIT/android/armeabi-v7a/luajit.h index 39794a55..d871b000 100644 --- a/libs/LuaJIT/android/armeabi-v7a/luajit.h +++ b/libs/LuaJIT/android/armeabi-v7a/luajit.h @@ -30,9 +30,9 @@ #include "lua.h" -#define LUAJIT_VERSION "LuaJIT 2.1.1710088188" +#define LUAJIT_VERSION "LuaJIT 2.1.1734355927" #define LUAJIT_VERSION_NUM 20199 /* Deprecated. */ -#define LUAJIT_VERSION_SYM luaJIT_version_2_1_1710088188 +#define LUAJIT_VERSION_SYM luaJIT_version_2_1_1734355927 #define LUAJIT_COPYRIGHT "Copyright (C) 2005-2023 Mike Pall" #define LUAJIT_URL "https://luajit.org/" diff --git a/libs/LuaJIT/android/x86/jit/bcsave.lua b/libs/LuaJIT/android/x86/jit/bcsave.lua index 131bf39b..48378819 100644 --- a/libs/LuaJIT/android/x86/jit/bcsave.lua +++ b/libs/LuaJIT/android/x86/jit/bcsave.lua @@ -439,24 +439,12 @@ typedef struct { mach_header; uint32_t reserved; } mach_header_64; -typedef struct { - uint32_t cmd, cmdsize; - char segname[16]; - uint32_t vmaddr, vmsize, fileoff, filesize; - uint32_t maxprot, initprot, nsects, flags; -} mach_segment_command; typedef struct { uint32_t cmd, cmdsize; char segname[16]; uint64_t vmaddr, vmsize, fileoff, filesize; uint32_t maxprot, initprot, nsects, flags; } mach_segment_command_64; -typedef struct { - char sectname[16], segname[16]; - uint32_t addr, size; - uint32_t offset, align, reloff, nreloc, flags; - uint32_t reserved1, reserved2; -} mach_section; typedef struct { char sectname[16], segname[16]; uint64_t addr, size; @@ -466,139 +454,64 @@ typedef struct { typedef struct { uint32_t cmd, cmdsize, symoff, nsyms, stroff, strsize; } mach_symtab_command; -typedef struct { - int32_t strx; - uint8_t type, sect; - int16_t desc; - uint32_t value; -} mach_nlist; typedef struct { int32_t strx; uint8_t type, sect; uint16_t desc; uint64_t value; } mach_nlist_64; -typedef struct -{ - int32_t magic, nfat_arch; -} mach_fat_header; -typedef struct -{ - int32_t cputype, cpusubtype, offset, size, align; -} mach_fat_arch; typedef struct { - struct { - mach_header hdr; - mach_segment_command seg; - mach_section sec; - mach_symtab_command sym; - } arch[1]; - mach_nlist sym_entry; - uint8_t space[4096]; -} mach_obj; -typedef struct { - struct { - mach_header_64 hdr; - mach_segment_command_64 seg; - mach_section_64 sec; - mach_symtab_command sym; - } arch[1]; + mach_header_64 hdr; + mach_segment_command_64 seg; + mach_section_64 sec; + mach_symtab_command sym; mach_nlist_64 sym_entry; uint8_t space[4096]; } mach_obj_64; -typedef struct { - mach_fat_header fat; - mach_fat_arch fat_arch[2]; - struct { - mach_header hdr; - mach_segment_command seg; - mach_section sec; - mach_symtab_command sym; - } arch[2]; - mach_nlist sym_entry; - uint8_t space[4096]; -} mach_fat_obj; -typedef struct { - mach_fat_header fat; - mach_fat_arch fat_arch[2]; - struct { - mach_header_64 hdr; - mach_segment_command_64 seg; - mach_section_64 sec; - mach_symtab_command sym; - } arch[2]; - mach_nlist_64 sym_entry; - uint8_t space[4096]; -} mach_fat_obj_64; ]] local symname = '_'..LJBC_PREFIX..ctx.modname - local isfat, is64, align, mobj = false, false, 4, "mach_obj" - if ctx.arch == "x64" then - is64, align, mobj = true, 8, "mach_obj_64" - elseif ctx.arch == "arm" then - isfat, mobj = true, "mach_fat_obj" - elseif ctx.arch == "arm64" then - is64, align, isfat, mobj = true, 8, true, "mach_fat_obj_64" - else - check(ctx.arch == "x86", "unsupported architecture for OSX") + local cputype, cpusubtype = 0x01000007, 3 + if ctx.arch ~= "x64" then + check(ctx.arch == "arm64", "unsupported architecture for OSX") + cputype, cpusubtype = 0x0100000c, 0 end local function aligned(v, a) return bit.band(v+a-1, -a) end - local be32 = bit.bswap -- Mach-O FAT is BE, supported archs are LE. -- Create Mach-O object and fill in header. - local o = ffi.new(mobj) - local mach_size = aligned(ffi.offsetof(o, "space")+#symname+2, align) - local cputype = ({ x86={7}, x64={0x01000007}, arm={7,12}, arm64={0x01000007,0x0100000c} })[ctx.arch] - local cpusubtype = ({ x86={3}, x64={3}, arm={3,9}, arm64={3,0} })[ctx.arch] - if isfat then - o.fat.magic = be32(0xcafebabe) - o.fat.nfat_arch = be32(#cpusubtype) - end + local o = ffi.new("mach_obj_64") + local mach_size = aligned(ffi.offsetof(o, "space")+#symname+2, 8) -- Fill in sections and symbols. - for i=0,#cpusubtype-1 do - local ofs = 0 - if isfat then - local a = o.fat_arch[i] - a.cputype = be32(cputype[i+1]) - a.cpusubtype = be32(cpusubtype[i+1]) - -- Subsequent slices overlap each other to share data. - ofs = ffi.offsetof(o, "arch") + i*ffi.sizeof(o.arch[0]) - a.offset = be32(ofs) - a.size = be32(mach_size-ofs+#s) - end - local a = o.arch[i] - a.hdr.magic = is64 and 0xfeedfacf or 0xfeedface - a.hdr.cputype = cputype[i+1] - a.hdr.cpusubtype = cpusubtype[i+1] - a.hdr.filetype = 1 - a.hdr.ncmds = 2 - a.hdr.sizeofcmds = ffi.sizeof(a.seg)+ffi.sizeof(a.sec)+ffi.sizeof(a.sym) - a.seg.cmd = is64 and 0x19 or 0x1 - a.seg.cmdsize = ffi.sizeof(a.seg)+ffi.sizeof(a.sec) - a.seg.vmsize = #s - a.seg.fileoff = mach_size-ofs - a.seg.filesize = #s - a.seg.maxprot = 1 - a.seg.initprot = 1 - a.seg.nsects = 1 - ffi.copy(a.sec.sectname, "__data") - ffi.copy(a.sec.segname, "__DATA") - a.sec.size = #s - a.sec.offset = mach_size-ofs - a.sym.cmd = 2 - a.sym.cmdsize = ffi.sizeof(a.sym) - a.sym.symoff = ffi.offsetof(o, "sym_entry")-ofs - a.sym.nsyms = 1 - a.sym.stroff = ffi.offsetof(o, "sym_entry")+ffi.sizeof(o.sym_entry)-ofs - a.sym.strsize = aligned(#symname+2, align) - end + o.hdr.magic = 0xfeedfacf + o.hdr.cputype = cputype + o.hdr.cpusubtype = cpusubtype + o.hdr.filetype = 1 + o.hdr.ncmds = 2 + o.hdr.sizeofcmds = ffi.sizeof(o.seg)+ffi.sizeof(o.sec)+ffi.sizeof(o.sym) + 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.filesize = #s + o.seg.maxprot = 1 + o.seg.initprot = 1 + o.seg.nsects = 1 + ffi.copy(o.sec.sectname, "__data") + ffi.copy(o.sec.segname, "__DATA") + o.sec.size = #s + o.sec.offset = mach_size + o.sym.cmd = 2 + o.sym.cmdsize = ffi.sizeof(o.sym) + o.sym.symoff = ffi.offsetof(o, "sym_entry") + o.sym.nsyms = 1 + o.sym.stroff = ffi.offsetof(o, "sym_entry")+ffi.sizeof(o.sym_entry) + 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) - -- Write Macho-O object file. + -- Write Mach-O object file. local fp = savefile(output, "wb") fp:write(ffi.string(o, mach_size)) bcsave_tail(fp, output, s) diff --git a/libs/LuaJIT/android/x86/jit/dis_arm64.lua b/libs/LuaJIT/android/x86/jit/dis_arm64.lua index 84677666..2741cd2e 100644 --- a/libs/LuaJIT/android/x86/jit/dis_arm64.lua +++ b/libs/LuaJIT/android/x86/jit/dis_arm64.lua @@ -658,6 +658,10 @@ local map_datafp = { -- Data processing, SIMD and FP. } } } + }, + { -- 010 + shift = 0, mask = 0x81f8fc00, + [0x100e400] = "moviDdG" } } @@ -832,6 +836,20 @@ local function parse_fpimm8(op) return sign * frac * 2^exp end +local function decode_fpmovi(op) + local lo = rshift(op, 5) + local hi = rshift(op, 9) + lo = bor(band(lo, 1) * 0xff, band(lo, 2) * 0x7f80, band(lo, 4) * 0x3fc000, + band(lo, 8) * 0x1fe00000) + hi = bor(band(hi, 1) * 0xff, band(hi, 0x80) * 0x1fe, + band(hi, 0x100) * 0xff00, band(hi, 0x200) * 0x7f8000) + if hi ~= 0 then + return fmt_hex32(hi)..tohex(lo) + else + return fmt_hex32(lo) + end +end + local function prefer_bfx(sf, uns, imms, immr) if imms < immr or imms == 31 or imms == 63 then return false @@ -1131,6 +1149,8 @@ local function disass_ins(ctx) x = 0 elseif p == "F" then x = parse_fpimm8(op) + elseif p == "G" then + x = "#0x"..decode_fpmovi(op) elseif p == "g" or p == "f" or p == "x" or p == "w" or p == "d" or p == "s" then -- These are handled in D/N/M/A. diff --git a/libs/LuaJIT/android/x86/jit/dump.lua b/libs/LuaJIT/android/x86/jit/dump.lua index 746732f9..f296a517 100644 --- a/libs/LuaJIT/android/x86/jit/dump.lua +++ b/libs/LuaJIT/android/x86/jit/dump.lua @@ -552,7 +552,12 @@ local recdepth = 0 local function fmterr(err, info) if type(err) == "number" then if type(info) == "function" then info = fmtfunc(info) end - err = format(vmdef.traceerr[err], info) + local fmt = vmdef.traceerr[err] + if fmt == "NYI: bytecode %s" then + local oidx = 6 * info + info = sub(vmdef.bcnames, oidx+1, oidx+6) + end + err = format(fmt, info) end return err end diff --git a/libs/LuaJIT/android/x86/jit/p.lua b/libs/LuaJIT/android/x86/jit/p.lua index 36f836c5..ef2ee82f 100644 --- a/libs/LuaJIT/android/x86/jit/p.lua +++ b/libs/LuaJIT/android/x86/jit/p.lua @@ -227,9 +227,7 @@ local function prof_finish() local samples = prof_samples if samples == 0 then if prof_raw ~= true then out:write("[No samples collected]\n") end - return - end - if prof_ann then + elseif prof_ann then prof_annotate(prof_count1, samples) else prof_top(prof_count1, prof_count2, samples, "") diff --git a/libs/LuaJIT/android/x86/jit/v.lua b/libs/LuaJIT/android/x86/jit/v.lua index 8e91f494..45a663d7 100644 --- a/libs/LuaJIT/android/x86/jit/v.lua +++ b/libs/LuaJIT/android/x86/jit/v.lua @@ -62,7 +62,7 @@ local jit = require("jit") local jutil = require("jit.util") local vmdef = require("jit.vmdef") local funcinfo, traceinfo = jutil.funcinfo, jutil.traceinfo -local type, format = type, string.format +local type, sub, format = type, string.sub, string.format local stdout, stderr = io.stdout, io.stderr -- Active flag and output file handle. @@ -89,7 +89,12 @@ end local function fmterr(err, info) if type(err) == "number" then if type(info) == "function" then info = fmtfunc(info) end - err = format(vmdef.traceerr[err], info) + local fmt = vmdef.traceerr[err] + if fmt == "NYI: bytecode %s" then + local oidx = 6 * info + info = sub(vmdef.bcnames, oidx+1, oidx+6) + end + err = format(fmt, info) end return err end diff --git a/libs/LuaJIT/android/x86/jit/vmdef.lua b/libs/LuaJIT/android/x86/jit/vmdef.lua index 75bc8b87..96003c05 100644 --- a/libs/LuaJIT/android/x86/jit/vmdef.lua +++ b/libs/LuaJIT/android/x86/jit/vmdef.lua @@ -1,6 +1,6 @@ -- This is a generated file. DO NOT EDIT! -assert(require("jit").version == "LuaJIT 2.1.1710088188", "LuaJIT core/library version mismatch") +assert(require("jit").version == "LuaJIT 2.1.1734355927", "LuaJIT core/library version mismatch") return { @@ -136,7 +136,7 @@ traceerr = { "too many snapshots", "blacklisted", "retry recording", -"NYI: bytecode %d", +"NYI: bytecode %s", "leaving loop in root trace", "inner loop in root trace", "loop unroll limit reached", diff --git a/libs/LuaJIT/android/x86/libluajit.a b/libs/LuaJIT/android/x86/libluajit.a index 1da53f4c..bd98194d 100644 Binary files a/libs/LuaJIT/android/x86/libluajit.a and b/libs/LuaJIT/android/x86/libluajit.a differ diff --git a/libs/LuaJIT/android/x86/libluajit.so b/libs/LuaJIT/android/x86/libluajit.so index 999a1492..14bbc23a 100644 Binary files a/libs/LuaJIT/android/x86/libluajit.so and b/libs/LuaJIT/android/x86/libluajit.so differ diff --git a/libs/LuaJIT/android/x86/luajit.h b/libs/LuaJIT/android/x86/luajit.h index 39794a55..d871b000 100644 --- a/libs/LuaJIT/android/x86/luajit.h +++ b/libs/LuaJIT/android/x86/luajit.h @@ -30,9 +30,9 @@ #include "lua.h" -#define LUAJIT_VERSION "LuaJIT 2.1.1710088188" +#define LUAJIT_VERSION "LuaJIT 2.1.1734355927" #define LUAJIT_VERSION_NUM 20199 /* Deprecated. */ -#define LUAJIT_VERSION_SYM luaJIT_version_2_1_1710088188 +#define LUAJIT_VERSION_SYM luaJIT_version_2_1_1734355927 #define LUAJIT_COPYRIGHT "Copyright (C) 2005-2023 Mike Pall" #define LUAJIT_URL "https://luajit.org/" diff --git a/libs/LuaJIT/android/x86_64/jit/bcsave.lua b/libs/LuaJIT/android/x86_64/jit/bcsave.lua index 131bf39b..48378819 100644 --- a/libs/LuaJIT/android/x86_64/jit/bcsave.lua +++ b/libs/LuaJIT/android/x86_64/jit/bcsave.lua @@ -439,24 +439,12 @@ typedef struct { mach_header; uint32_t reserved; } mach_header_64; -typedef struct { - uint32_t cmd, cmdsize; - char segname[16]; - uint32_t vmaddr, vmsize, fileoff, filesize; - uint32_t maxprot, initprot, nsects, flags; -} mach_segment_command; typedef struct { uint32_t cmd, cmdsize; char segname[16]; uint64_t vmaddr, vmsize, fileoff, filesize; uint32_t maxprot, initprot, nsects, flags; } mach_segment_command_64; -typedef struct { - char sectname[16], segname[16]; - uint32_t addr, size; - uint32_t offset, align, reloff, nreloc, flags; - uint32_t reserved1, reserved2; -} mach_section; typedef struct { char sectname[16], segname[16]; uint64_t addr, size; @@ -466,139 +454,64 @@ typedef struct { typedef struct { uint32_t cmd, cmdsize, symoff, nsyms, stroff, strsize; } mach_symtab_command; -typedef struct { - int32_t strx; - uint8_t type, sect; - int16_t desc; - uint32_t value; -} mach_nlist; typedef struct { int32_t strx; uint8_t type, sect; uint16_t desc; uint64_t value; } mach_nlist_64; -typedef struct -{ - int32_t magic, nfat_arch; -} mach_fat_header; -typedef struct -{ - int32_t cputype, cpusubtype, offset, size, align; -} mach_fat_arch; typedef struct { - struct { - mach_header hdr; - mach_segment_command seg; - mach_section sec; - mach_symtab_command sym; - } arch[1]; - mach_nlist sym_entry; - uint8_t space[4096]; -} mach_obj; -typedef struct { - struct { - mach_header_64 hdr; - mach_segment_command_64 seg; - mach_section_64 sec; - mach_symtab_command sym; - } arch[1]; + mach_header_64 hdr; + mach_segment_command_64 seg; + mach_section_64 sec; + mach_symtab_command sym; mach_nlist_64 sym_entry; uint8_t space[4096]; } mach_obj_64; -typedef struct { - mach_fat_header fat; - mach_fat_arch fat_arch[2]; - struct { - mach_header hdr; - mach_segment_command seg; - mach_section sec; - mach_symtab_command sym; - } arch[2]; - mach_nlist sym_entry; - uint8_t space[4096]; -} mach_fat_obj; -typedef struct { - mach_fat_header fat; - mach_fat_arch fat_arch[2]; - struct { - mach_header_64 hdr; - mach_segment_command_64 seg; - mach_section_64 sec; - mach_symtab_command sym; - } arch[2]; - mach_nlist_64 sym_entry; - uint8_t space[4096]; -} mach_fat_obj_64; ]] local symname = '_'..LJBC_PREFIX..ctx.modname - local isfat, is64, align, mobj = false, false, 4, "mach_obj" - if ctx.arch == "x64" then - is64, align, mobj = true, 8, "mach_obj_64" - elseif ctx.arch == "arm" then - isfat, mobj = true, "mach_fat_obj" - elseif ctx.arch == "arm64" then - is64, align, isfat, mobj = true, 8, true, "mach_fat_obj_64" - else - check(ctx.arch == "x86", "unsupported architecture for OSX") + local cputype, cpusubtype = 0x01000007, 3 + if ctx.arch ~= "x64" then + check(ctx.arch == "arm64", "unsupported architecture for OSX") + cputype, cpusubtype = 0x0100000c, 0 end local function aligned(v, a) return bit.band(v+a-1, -a) end - local be32 = bit.bswap -- Mach-O FAT is BE, supported archs are LE. -- Create Mach-O object and fill in header. - local o = ffi.new(mobj) - local mach_size = aligned(ffi.offsetof(o, "space")+#symname+2, align) - local cputype = ({ x86={7}, x64={0x01000007}, arm={7,12}, arm64={0x01000007,0x0100000c} })[ctx.arch] - local cpusubtype = ({ x86={3}, x64={3}, arm={3,9}, arm64={3,0} })[ctx.arch] - if isfat then - o.fat.magic = be32(0xcafebabe) - o.fat.nfat_arch = be32(#cpusubtype) - end + local o = ffi.new("mach_obj_64") + local mach_size = aligned(ffi.offsetof(o, "space")+#symname+2, 8) -- Fill in sections and symbols. - for i=0,#cpusubtype-1 do - local ofs = 0 - if isfat then - local a = o.fat_arch[i] - a.cputype = be32(cputype[i+1]) - a.cpusubtype = be32(cpusubtype[i+1]) - -- Subsequent slices overlap each other to share data. - ofs = ffi.offsetof(o, "arch") + i*ffi.sizeof(o.arch[0]) - a.offset = be32(ofs) - a.size = be32(mach_size-ofs+#s) - end - local a = o.arch[i] - a.hdr.magic = is64 and 0xfeedfacf or 0xfeedface - a.hdr.cputype = cputype[i+1] - a.hdr.cpusubtype = cpusubtype[i+1] - a.hdr.filetype = 1 - a.hdr.ncmds = 2 - a.hdr.sizeofcmds = ffi.sizeof(a.seg)+ffi.sizeof(a.sec)+ffi.sizeof(a.sym) - a.seg.cmd = is64 and 0x19 or 0x1 - a.seg.cmdsize = ffi.sizeof(a.seg)+ffi.sizeof(a.sec) - a.seg.vmsize = #s - a.seg.fileoff = mach_size-ofs - a.seg.filesize = #s - a.seg.maxprot = 1 - a.seg.initprot = 1 - a.seg.nsects = 1 - ffi.copy(a.sec.sectname, "__data") - ffi.copy(a.sec.segname, "__DATA") - a.sec.size = #s - a.sec.offset = mach_size-ofs - a.sym.cmd = 2 - a.sym.cmdsize = ffi.sizeof(a.sym) - a.sym.symoff = ffi.offsetof(o, "sym_entry")-ofs - a.sym.nsyms = 1 - a.sym.stroff = ffi.offsetof(o, "sym_entry")+ffi.sizeof(o.sym_entry)-ofs - a.sym.strsize = aligned(#symname+2, align) - end + o.hdr.magic = 0xfeedfacf + o.hdr.cputype = cputype + o.hdr.cpusubtype = cpusubtype + o.hdr.filetype = 1 + o.hdr.ncmds = 2 + o.hdr.sizeofcmds = ffi.sizeof(o.seg)+ffi.sizeof(o.sec)+ffi.sizeof(o.sym) + 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.filesize = #s + o.seg.maxprot = 1 + o.seg.initprot = 1 + o.seg.nsects = 1 + ffi.copy(o.sec.sectname, "__data") + ffi.copy(o.sec.segname, "__DATA") + o.sec.size = #s + o.sec.offset = mach_size + o.sym.cmd = 2 + o.sym.cmdsize = ffi.sizeof(o.sym) + o.sym.symoff = ffi.offsetof(o, "sym_entry") + o.sym.nsyms = 1 + o.sym.stroff = ffi.offsetof(o, "sym_entry")+ffi.sizeof(o.sym_entry) + 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) - -- Write Macho-O object file. + -- Write Mach-O object file. local fp = savefile(output, "wb") fp:write(ffi.string(o, mach_size)) bcsave_tail(fp, output, s) diff --git a/libs/LuaJIT/android/x86_64/jit/dis_arm64.lua b/libs/LuaJIT/android/x86_64/jit/dis_arm64.lua index 84677666..2741cd2e 100644 --- a/libs/LuaJIT/android/x86_64/jit/dis_arm64.lua +++ b/libs/LuaJIT/android/x86_64/jit/dis_arm64.lua @@ -658,6 +658,10 @@ local map_datafp = { -- Data processing, SIMD and FP. } } } + }, + { -- 010 + shift = 0, mask = 0x81f8fc00, + [0x100e400] = "moviDdG" } } @@ -832,6 +836,20 @@ local function parse_fpimm8(op) return sign * frac * 2^exp end +local function decode_fpmovi(op) + local lo = rshift(op, 5) + local hi = rshift(op, 9) + lo = bor(band(lo, 1) * 0xff, band(lo, 2) * 0x7f80, band(lo, 4) * 0x3fc000, + band(lo, 8) * 0x1fe00000) + hi = bor(band(hi, 1) * 0xff, band(hi, 0x80) * 0x1fe, + band(hi, 0x100) * 0xff00, band(hi, 0x200) * 0x7f8000) + if hi ~= 0 then + return fmt_hex32(hi)..tohex(lo) + else + return fmt_hex32(lo) + end +end + local function prefer_bfx(sf, uns, imms, immr) if imms < immr or imms == 31 or imms == 63 then return false @@ -1131,6 +1149,8 @@ local function disass_ins(ctx) x = 0 elseif p == "F" then x = parse_fpimm8(op) + elseif p == "G" then + x = "#0x"..decode_fpmovi(op) elseif p == "g" or p == "f" or p == "x" or p == "w" or p == "d" or p == "s" then -- These are handled in D/N/M/A. diff --git a/libs/LuaJIT/android/x86_64/jit/dump.lua b/libs/LuaJIT/android/x86_64/jit/dump.lua index 746732f9..f296a517 100644 --- a/libs/LuaJIT/android/x86_64/jit/dump.lua +++ b/libs/LuaJIT/android/x86_64/jit/dump.lua @@ -552,7 +552,12 @@ local recdepth = 0 local function fmterr(err, info) if type(err) == "number" then if type(info) == "function" then info = fmtfunc(info) end - err = format(vmdef.traceerr[err], info) + local fmt = vmdef.traceerr[err] + if fmt == "NYI: bytecode %s" then + local oidx = 6 * info + info = sub(vmdef.bcnames, oidx+1, oidx+6) + end + err = format(fmt, info) end return err end diff --git a/libs/LuaJIT/android/x86_64/jit/p.lua b/libs/LuaJIT/android/x86_64/jit/p.lua index 36f836c5..ef2ee82f 100644 --- a/libs/LuaJIT/android/x86_64/jit/p.lua +++ b/libs/LuaJIT/android/x86_64/jit/p.lua @@ -227,9 +227,7 @@ local function prof_finish() local samples = prof_samples if samples == 0 then if prof_raw ~= true then out:write("[No samples collected]\n") end - return - end - if prof_ann then + elseif prof_ann then prof_annotate(prof_count1, samples) else prof_top(prof_count1, prof_count2, samples, "") diff --git a/libs/LuaJIT/android/x86_64/jit/v.lua b/libs/LuaJIT/android/x86_64/jit/v.lua index 8e91f494..45a663d7 100644 --- a/libs/LuaJIT/android/x86_64/jit/v.lua +++ b/libs/LuaJIT/android/x86_64/jit/v.lua @@ -62,7 +62,7 @@ local jit = require("jit") local jutil = require("jit.util") local vmdef = require("jit.vmdef") local funcinfo, traceinfo = jutil.funcinfo, jutil.traceinfo -local type, format = type, string.format +local type, sub, format = type, string.sub, string.format local stdout, stderr = io.stdout, io.stderr -- Active flag and output file handle. @@ -89,7 +89,12 @@ end local function fmterr(err, info) if type(err) == "number" then if type(info) == "function" then info = fmtfunc(info) end - err = format(vmdef.traceerr[err], info) + local fmt = vmdef.traceerr[err] + if fmt == "NYI: bytecode %s" then + local oidx = 6 * info + info = sub(vmdef.bcnames, oidx+1, oidx+6) + end + err = format(fmt, info) end return err end diff --git a/libs/LuaJIT/android/x86_64/jit/vmdef.lua b/libs/LuaJIT/android/x86_64/jit/vmdef.lua index 75bc8b87..96003c05 100644 --- a/libs/LuaJIT/android/x86_64/jit/vmdef.lua +++ b/libs/LuaJIT/android/x86_64/jit/vmdef.lua @@ -1,6 +1,6 @@ -- This is a generated file. DO NOT EDIT! -assert(require("jit").version == "LuaJIT 2.1.1710088188", "LuaJIT core/library version mismatch") +assert(require("jit").version == "LuaJIT 2.1.1734355927", "LuaJIT core/library version mismatch") return { @@ -136,7 +136,7 @@ traceerr = { "too many snapshots", "blacklisted", "retry recording", -"NYI: bytecode %d", +"NYI: bytecode %s", "leaving loop in root trace", "inner loop in root trace", "loop unroll limit reached", diff --git a/libs/LuaJIT/android/x86_64/libluajit.a b/libs/LuaJIT/android/x86_64/libluajit.a index 12918830..9bd0c964 100644 Binary files a/libs/LuaJIT/android/x86_64/libluajit.a and b/libs/LuaJIT/android/x86_64/libluajit.a differ diff --git a/libs/LuaJIT/android/x86_64/libluajit.so b/libs/LuaJIT/android/x86_64/libluajit.so index 5b82b749..ae1da983 100644 Binary files a/libs/LuaJIT/android/x86_64/libluajit.so and b/libs/LuaJIT/android/x86_64/libluajit.so differ diff --git a/libs/LuaJIT/android/x86_64/luajit.h b/libs/LuaJIT/android/x86_64/luajit.h index 39794a55..d871b000 100644 --- a/libs/LuaJIT/android/x86_64/luajit.h +++ b/libs/LuaJIT/android/x86_64/luajit.h @@ -30,9 +30,9 @@ #include "lua.h" -#define LUAJIT_VERSION "LuaJIT 2.1.1710088188" +#define LUAJIT_VERSION "LuaJIT 2.1.1734355927" #define LUAJIT_VERSION_NUM 20199 /* Deprecated. */ -#define LUAJIT_VERSION_SYM luaJIT_version_2_1_1710088188 +#define LUAJIT_VERSION_SYM luaJIT_version_2_1_1734355927 #define LUAJIT_COPYRIGHT "Copyright (C) 2005-2023 Mike Pall" #define LUAJIT_URL "https://luajit.org/" diff --git a/libs/LuaJIT/doc/ext_buffer.html b/libs/LuaJIT/doc/ext_buffer.html index bfaa24cb..54bb66f6 100644 --- a/libs/LuaJIT/doc/ext_buffer.html +++ b/libs/LuaJIT/doc/ext_buffer.html @@ -85,7 +85,7 @@ operations.
The string buffer library also includes a high-performance -serializer for Lua objects. +serializer for Lua objects.
+Note: this is the only place where creating a boxed scalar number type is +actually useful. Never use ffi.new("int"), ffi.new("float") +etc. anywhere else! +
++Ditto for ffi.cast(). Explicitly boxing scalars does not +improve performance or force int or float arithmetic! It +just adds costly boxing, unboxing and conversions steps. And it may lead +to surprise results, because +cdata arithmetic on scalar numbers +is always performed on 64 bit integers. +
diff --git a/libs/LuaJIT/doc/extensions.html b/libs/LuaJIT/doc/extensions.html index c1c9a808..e9aaa096 100644 --- a/libs/LuaJIT/doc/extensions.html +++ b/libs/LuaJIT/doc/extensions.html @@ -265,7 +265,7 @@ and let the GC do its work. LuaJIT uses a Tausworthe PRNG with period 2^223 to implement math.random() and math.randomseed(). The quality of the PRNG results is much superior compared to the standard Lua -implementation, which uses the platform-specific ANSI rand(). +implementation, which uses the platform-specific ANSI rand().
The PRNG generates the same sequences from the same seeds on all @@ -276,6 +276,10 @@ It's correctly scaled up and rounded for math.random(n [,m]) to preserve uniformity.
+Call math.randomseed() without any arguments to seed it from +system entropy. +
+Important: Neither this nor any other PRNG based on the simplistic math.random() API is suitable for cryptographic use.
diff --git a/libs/LuaJIT/src/Makefile b/libs/LuaJIT/src/Makefile index 224d21e7..99642be7 100644 --- a/libs/LuaJIT/src/Makefile +++ b/libs/LuaJIT/src/Makefile @@ -299,6 +299,9 @@ endif ifneq (,$(LMULTILIB)) TARGET_XCFLAGS+= -DLUA_LMULTILIB=\"$(LMULTILIB)\" endif +ifneq (,$(INSTALL_LJLIBD)) + TARGET_XCFLAGS+= -DLUA_LJDIR=\"$(INSTALL_LJLIBD)\" +endif ############################################################################## # Target system detection. @@ -320,13 +323,13 @@ ifeq (Darwin,$(TARGET_SYS)) endif TARGET_STRIP+= -x TARGET_XCFLAGS+= -DLUAJIT_UNWIND_EXTERNAL - TARGET_XSHLDFLAGS= -dynamiclib -single_module -undefined dynamic_lookup -fPIC + TARGET_XSHLDFLAGS= -dynamiclib -undefined dynamic_lookup -fPIC TARGET_DYNXLDOPTS= TARGET_XSHLDFLAGS+= -install_name $(TARGET_DYLIBPATH) -compatibility_version $(MAJVER).$(MINVER) -current_version $(MAJVER).$(MINVER).255 else ifeq (iOS,$(TARGET_SYS)) TARGET_STRIP+= -x - TARGET_XSHLDFLAGS= -dynamiclib -single_module -undefined dynamic_lookup -fPIC + TARGET_XSHLDFLAGS= -dynamiclib -undefined dynamic_lookup -fPIC TARGET_DYNXLDOPTS= TARGET_XSHLDFLAGS+= -install_name $(TARGET_DYLIBPATH) -compatibility_version $(MAJVER).$(MINVER) -current_version $(MAJVER).$(MINVER).255 ifeq (arm64,$(TARGET_LJARCH)) diff --git a/libs/LuaJIT/src/Makefile.dep b/libs/LuaJIT/src/Makefile.dep index fda77c83..7b534b05 100644 --- a/libs/LuaJIT/src/Makefile.dep +++ b/libs/LuaJIT/src/Makefile.dep @@ -32,7 +32,8 @@ lib_jit.o: lib_jit.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h lj_def.h \ lj_target.h lj_target_*.h lj_trace.h lj_dispatch.h lj_traceerr.h \ lj_vm.h lj_vmevent.h lj_lib.h luajit.h lj_libdef.h lib_math.o: lib_math.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h \ - lj_def.h lj_arch.h lj_lib.h lj_vm.h lj_prng.h lj_libdef.h + lj_def.h lj_arch.h lj_err.h lj_errmsg.h lj_lib.h lj_vm.h lj_prng.h \ + lj_libdef.h lib_os.o: lib_os.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h lj_def.h \ lj_arch.h lj_gc.h lj_err.h lj_errmsg.h lj_buf.h lj_str.h lj_lib.h \ lj_libdef.h @@ -97,7 +98,7 @@ lj_crecord.o: lj_crecord.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ lj_cdata.h lj_cparse.h lj_cconv.h lj_carith.h lj_clib.h lj_ccall.h \ lj_ff.h lj_ffdef.h lj_ir.h lj_jit.h lj_ircall.h lj_iropt.h lj_trace.h \ lj_dispatch.h lj_traceerr.h lj_record.h lj_ffrecord.h lj_snap.h \ - lj_crecord.h lj_strfmt.h + lj_crecord.h lj_strfmt.h lj_strscan.h lj_ctype.o: lj_ctype.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_strfmt.h lj_ctype.h \ lj_ccallback.h lj_buf.h diff --git a/libs/LuaJIT/src/host/buildvm_asm.c b/libs/LuaJIT/src/host/buildvm_asm.c index e7c5de70..1b261206 100644 --- a/libs/LuaJIT/src/host/buildvm_asm.c +++ b/libs/LuaJIT/src/host/buildvm_asm.c @@ -339,6 +339,10 @@ void emit_asm(BuildCtx *ctx) fprintf(ctx->fp, "\t.ident \"%s\"\n", ctx->dasm_ident); break; case BUILD_machasm: +#if defined(__apple_build_version__) && __apple_build_version__ >= 15000000 && __apple_build_version__ < 15000300 + /* Workaround for XCode 15.0 - 15.2. */ + fprintf(ctx->fp, "\t.subsections_via_symbols\n"); +#endif fprintf(ctx->fp, "\t.cstring\n" "\t.ascii \"%s\\0\"\n", ctx->dasm_ident); diff --git a/libs/LuaJIT/src/jit/bcsave.lua b/libs/LuaJIT/src/jit/bcsave.lua index 131bf39b..48378819 100644 --- a/libs/LuaJIT/src/jit/bcsave.lua +++ b/libs/LuaJIT/src/jit/bcsave.lua @@ -439,24 +439,12 @@ typedef struct { mach_header; uint32_t reserved; } mach_header_64; -typedef struct { - uint32_t cmd, cmdsize; - char segname[16]; - uint32_t vmaddr, vmsize, fileoff, filesize; - uint32_t maxprot, initprot, nsects, flags; -} mach_segment_command; typedef struct { uint32_t cmd, cmdsize; char segname[16]; uint64_t vmaddr, vmsize, fileoff, filesize; uint32_t maxprot, initprot, nsects, flags; } mach_segment_command_64; -typedef struct { - char sectname[16], segname[16]; - uint32_t addr, size; - uint32_t offset, align, reloff, nreloc, flags; - uint32_t reserved1, reserved2; -} mach_section; typedef struct { char sectname[16], segname[16]; uint64_t addr, size; @@ -466,139 +454,64 @@ typedef struct { typedef struct { uint32_t cmd, cmdsize, symoff, nsyms, stroff, strsize; } mach_symtab_command; -typedef struct { - int32_t strx; - uint8_t type, sect; - int16_t desc; - uint32_t value; -} mach_nlist; typedef struct { int32_t strx; uint8_t type, sect; uint16_t desc; uint64_t value; } mach_nlist_64; -typedef struct -{ - int32_t magic, nfat_arch; -} mach_fat_header; -typedef struct -{ - int32_t cputype, cpusubtype, offset, size, align; -} mach_fat_arch; typedef struct { - struct { - mach_header hdr; - mach_segment_command seg; - mach_section sec; - mach_symtab_command sym; - } arch[1]; - mach_nlist sym_entry; - uint8_t space[4096]; -} mach_obj; -typedef struct { - struct { - mach_header_64 hdr; - mach_segment_command_64 seg; - mach_section_64 sec; - mach_symtab_command sym; - } arch[1]; + mach_header_64 hdr; + mach_segment_command_64 seg; + mach_section_64 sec; + mach_symtab_command sym; mach_nlist_64 sym_entry; uint8_t space[4096]; } mach_obj_64; -typedef struct { - mach_fat_header fat; - mach_fat_arch fat_arch[2]; - struct { - mach_header hdr; - mach_segment_command seg; - mach_section sec; - mach_symtab_command sym; - } arch[2]; - mach_nlist sym_entry; - uint8_t space[4096]; -} mach_fat_obj; -typedef struct { - mach_fat_header fat; - mach_fat_arch fat_arch[2]; - struct { - mach_header_64 hdr; - mach_segment_command_64 seg; - mach_section_64 sec; - mach_symtab_command sym; - } arch[2]; - mach_nlist_64 sym_entry; - uint8_t space[4096]; -} mach_fat_obj_64; ]] local symname = '_'..LJBC_PREFIX..ctx.modname - local isfat, is64, align, mobj = false, false, 4, "mach_obj" - if ctx.arch == "x64" then - is64, align, mobj = true, 8, "mach_obj_64" - elseif ctx.arch == "arm" then - isfat, mobj = true, "mach_fat_obj" - elseif ctx.arch == "arm64" then - is64, align, isfat, mobj = true, 8, true, "mach_fat_obj_64" - else - check(ctx.arch == "x86", "unsupported architecture for OSX") + local cputype, cpusubtype = 0x01000007, 3 + if ctx.arch ~= "x64" then + check(ctx.arch == "arm64", "unsupported architecture for OSX") + cputype, cpusubtype = 0x0100000c, 0 end local function aligned(v, a) return bit.band(v+a-1, -a) end - local be32 = bit.bswap -- Mach-O FAT is BE, supported archs are LE. -- Create Mach-O object and fill in header. - local o = ffi.new(mobj) - local mach_size = aligned(ffi.offsetof(o, "space")+#symname+2, align) - local cputype = ({ x86={7}, x64={0x01000007}, arm={7,12}, arm64={0x01000007,0x0100000c} })[ctx.arch] - local cpusubtype = ({ x86={3}, x64={3}, arm={3,9}, arm64={3,0} })[ctx.arch] - if isfat then - o.fat.magic = be32(0xcafebabe) - o.fat.nfat_arch = be32(#cpusubtype) - end + local o = ffi.new("mach_obj_64") + local mach_size = aligned(ffi.offsetof(o, "space")+#symname+2, 8) -- Fill in sections and symbols. - for i=0,#cpusubtype-1 do - local ofs = 0 - if isfat then - local a = o.fat_arch[i] - a.cputype = be32(cputype[i+1]) - a.cpusubtype = be32(cpusubtype[i+1]) - -- Subsequent slices overlap each other to share data. - ofs = ffi.offsetof(o, "arch") + i*ffi.sizeof(o.arch[0]) - a.offset = be32(ofs) - a.size = be32(mach_size-ofs+#s) - end - local a = o.arch[i] - a.hdr.magic = is64 and 0xfeedfacf or 0xfeedface - a.hdr.cputype = cputype[i+1] - a.hdr.cpusubtype = cpusubtype[i+1] - a.hdr.filetype = 1 - a.hdr.ncmds = 2 - a.hdr.sizeofcmds = ffi.sizeof(a.seg)+ffi.sizeof(a.sec)+ffi.sizeof(a.sym) - a.seg.cmd = is64 and 0x19 or 0x1 - a.seg.cmdsize = ffi.sizeof(a.seg)+ffi.sizeof(a.sec) - a.seg.vmsize = #s - a.seg.fileoff = mach_size-ofs - a.seg.filesize = #s - a.seg.maxprot = 1 - a.seg.initprot = 1 - a.seg.nsects = 1 - ffi.copy(a.sec.sectname, "__data") - ffi.copy(a.sec.segname, "__DATA") - a.sec.size = #s - a.sec.offset = mach_size-ofs - a.sym.cmd = 2 - a.sym.cmdsize = ffi.sizeof(a.sym) - a.sym.symoff = ffi.offsetof(o, "sym_entry")-ofs - a.sym.nsyms = 1 - a.sym.stroff = ffi.offsetof(o, "sym_entry")+ffi.sizeof(o.sym_entry)-ofs - a.sym.strsize = aligned(#symname+2, align) - end + o.hdr.magic = 0xfeedfacf + o.hdr.cputype = cputype + o.hdr.cpusubtype = cpusubtype + o.hdr.filetype = 1 + o.hdr.ncmds = 2 + o.hdr.sizeofcmds = ffi.sizeof(o.seg)+ffi.sizeof(o.sec)+ffi.sizeof(o.sym) + 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.filesize = #s + o.seg.maxprot = 1 + o.seg.initprot = 1 + o.seg.nsects = 1 + ffi.copy(o.sec.sectname, "__data") + ffi.copy(o.sec.segname, "__DATA") + o.sec.size = #s + o.sec.offset = mach_size + o.sym.cmd = 2 + o.sym.cmdsize = ffi.sizeof(o.sym) + o.sym.symoff = ffi.offsetof(o, "sym_entry") + o.sym.nsyms = 1 + o.sym.stroff = ffi.offsetof(o, "sym_entry")+ffi.sizeof(o.sym_entry) + 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) - -- Write Macho-O object file. + -- Write Mach-O object file. local fp = savefile(output, "wb") fp:write(ffi.string(o, mach_size)) bcsave_tail(fp, output, s) diff --git a/libs/LuaJIT/src/jit/dis_arm64.lua b/libs/LuaJIT/src/jit/dis_arm64.lua index 84677666..2741cd2e 100644 --- a/libs/LuaJIT/src/jit/dis_arm64.lua +++ b/libs/LuaJIT/src/jit/dis_arm64.lua @@ -658,6 +658,10 @@ local map_datafp = { -- Data processing, SIMD and FP. } } } + }, + { -- 010 + shift = 0, mask = 0x81f8fc00, + [0x100e400] = "moviDdG" } } @@ -832,6 +836,20 @@ local function parse_fpimm8(op) return sign * frac * 2^exp end +local function decode_fpmovi(op) + local lo = rshift(op, 5) + local hi = rshift(op, 9) + lo = bor(band(lo, 1) * 0xff, band(lo, 2) * 0x7f80, band(lo, 4) * 0x3fc000, + band(lo, 8) * 0x1fe00000) + hi = bor(band(hi, 1) * 0xff, band(hi, 0x80) * 0x1fe, + band(hi, 0x100) * 0xff00, band(hi, 0x200) * 0x7f8000) + if hi ~= 0 then + return fmt_hex32(hi)..tohex(lo) + else + return fmt_hex32(lo) + end +end + local function prefer_bfx(sf, uns, imms, immr) if imms < immr or imms == 31 or imms == 63 then return false @@ -1131,6 +1149,8 @@ local function disass_ins(ctx) x = 0 elseif p == "F" then x = parse_fpimm8(op) + elseif p == "G" then + x = "#0x"..decode_fpmovi(op) elseif p == "g" or p == "f" or p == "x" or p == "w" or p == "d" or p == "s" then -- These are handled in D/N/M/A. diff --git a/libs/LuaJIT/src/jit/dump.lua b/libs/LuaJIT/src/jit/dump.lua index 746732f9..f296a517 100644 --- a/libs/LuaJIT/src/jit/dump.lua +++ b/libs/LuaJIT/src/jit/dump.lua @@ -552,7 +552,12 @@ local recdepth = 0 local function fmterr(err, info) if type(err) == "number" then if type(info) == "function" then info = fmtfunc(info) end - err = format(vmdef.traceerr[err], info) + local fmt = vmdef.traceerr[err] + if fmt == "NYI: bytecode %s" then + local oidx = 6 * info + info = sub(vmdef.bcnames, oidx+1, oidx+6) + end + err = format(fmt, info) end return err end diff --git a/libs/LuaJIT/src/jit/p.lua b/libs/LuaJIT/src/jit/p.lua index 36f836c5..ef2ee82f 100644 --- a/libs/LuaJIT/src/jit/p.lua +++ b/libs/LuaJIT/src/jit/p.lua @@ -227,9 +227,7 @@ local function prof_finish() local samples = prof_samples if samples == 0 then if prof_raw ~= true then out:write("[No samples collected]\n") end - return - end - if prof_ann then + elseif prof_ann then prof_annotate(prof_count1, samples) else prof_top(prof_count1, prof_count2, samples, "") diff --git a/libs/LuaJIT/src/jit/v.lua b/libs/LuaJIT/src/jit/v.lua index 8e91f494..45a663d7 100644 --- a/libs/LuaJIT/src/jit/v.lua +++ b/libs/LuaJIT/src/jit/v.lua @@ -62,7 +62,7 @@ local jit = require("jit") local jutil = require("jit.util") local vmdef = require("jit.vmdef") local funcinfo, traceinfo = jutil.funcinfo, jutil.traceinfo -local type, format = type, string.format +local type, sub, format = type, string.sub, string.format local stdout, stderr = io.stdout, io.stderr -- Active flag and output file handle. @@ -89,7 +89,12 @@ end local function fmterr(err, info) if type(err) == "number" then if type(info) == "function" then info = fmtfunc(info) end - err = format(vmdef.traceerr[err], info) + local fmt = vmdef.traceerr[err] + if fmt == "NYI: bytecode %s" then + local oidx = 6 * info + info = sub(vmdef.bcnames, oidx+1, oidx+6) + end + err = format(fmt, info) end return err end diff --git a/libs/LuaJIT/src/lib_bit.c b/libs/LuaJIT/src/lib_bit.c index ce40e298..ada9614d 100644 --- a/libs/LuaJIT/src/lib_bit.c +++ b/libs/LuaJIT/src/lib_bit.c @@ -98,7 +98,7 @@ LJLIB_ASM(bit_lshift) LJLIB_REC(bit_shift IR_BSHL) x = lj_carith_shift64(x, sh, curr_func(L)->c.ffid - (int)FF_bit_lshift); return bit_result64(L, id, x); } - if (id2) setintV(L->base+1, sh); + setintV(L->base+1, sh); return FFH_RETRY; #else lj_lib_checknumber(L, 1); diff --git a/libs/LuaJIT/src/lib_ffi.c b/libs/LuaJIT/src/lib_ffi.c index ba783173..ddeb10c5 100644 --- a/libs/LuaJIT/src/lib_ffi.c +++ b/libs/LuaJIT/src/lib_ffi.c @@ -305,7 +305,7 @@ LJLIB_CF(ffi_meta___tostring) p = *(void **)p; } else if (ctype_isenum(ct->info)) { msg = "cdata<%s>: %d"; - p = (void *)(uintptr_t)*(uint32_t **)p; + p = (void *)(uintptr_t)*(uint32_t *)p; } else { if (ctype_isptr(ct->info)) { p = cdata_getptr(p, ct->size); @@ -513,7 +513,7 @@ LJLIB_CF(ffi_new) LJLIB_REC(.) /* Handle ctype __gc metamethod. Use the fast lookup here. */ cTValue *tv = lj_tab_getinth(cts->miscmap, -(int32_t)id); if (tv && tvistab(tv) && (tv = lj_meta_fast(L, tabV(tv), MM_gc))) { - GCtab *t = cts->finalizer; + GCtab *t = tabref(G(L)->gcroot[GCROOT_FFI_FIN]); if (gcref(t->metatable)) { /* Add to finalizer table, if still enabled. */ copyTV(L, lj_tab_set(L, t, o-1), tv); @@ -765,7 +765,7 @@ LJLIB_CF(ffi_abi) LJLIB_REC(.) return 1; } -LJLIB_PUSH(top-8) LJLIB_SET(!) /* Store reference to miscmap table. */ +LJLIB_PUSH(top-7) LJLIB_SET(!) /* Store reference to miscmap table. */ LJLIB_CF(ffi_metatype) { @@ -791,8 +791,6 @@ LJLIB_CF(ffi_metatype) return 1; } -LJLIB_PUSH(top-7) LJLIB_SET(!) /* Store reference to finalizer table. */ - LJLIB_CF(ffi_gc) LJLIB_REC(.) { GCcdata *cd = ffi_checkcdata(L, 1); @@ -825,19 +823,6 @@ LJLIB_PUSH(top-2) LJLIB_SET(arch) /* ------------------------------------------------------------------------ */ -/* Create special weak-keyed finalizer table. */ -static GCtab *ffi_finalizer(lua_State *L) -{ - /* NOBARRIER: The table is new (marked white). */ - GCtab *t = lj_tab_new(L, 0, 1); - settabV(L, L->top++, t); - setgcref(t->metatable, obj2gco(t)); - setstrV(L, lj_tab_setstr(L, t, lj_str_newlit(L, "__mode")), - lj_str_newlit(L, "k")); - t->nomm = (uint8_t)(~(1u<