diff --git a/src/deps/src/luajit/.travis.yml b/src/deps/src/luajit/.travis.yml index 9077c9426..fbf3acf88 100644 --- a/src/deps/src/luajit/.travis.yml +++ b/src/deps/src/luajit/.travis.yml @@ -10,6 +10,7 @@ arch: - amd64 - arm64 - s390x + - ppc64le language: c diff --git a/src/deps/src/luajit/doc/ext_buffer.html b/src/deps/src/luajit/doc/ext_buffer.html index bfaa24cbd..54bb66f69 100644 --- a/src/deps/src/luajit/doc/ext_buffer.html +++ b/src/deps/src/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.

Using the String Buffer Library

@@ -588,9 +588,9 @@ num → 0x07 double.L tab → 0x08 // Empty table | 0x09 h.U h*{object object} // Key/value hash | 0x0a a.U a*object // 0-based array - | 0x0b a.U a*object h.U h*{object object} // Mixed + | 0x0b a.U h.U a*object h*{object object} // Mixed | 0x0c a.U (a-1)*object // 1-based array - | 0x0d a.U (a-1)*object h.U h*{object object} // Mixed + | 0x0d a.U h.U (a-1)*object h*{object object} // Mixed tab_mt → 0x0e (index-1).U tab // Metatable dict entry int64 → 0x10 int.L // FFI int64_t diff --git a/src/deps/src/luajit/doc/ext_ffi_semantics.html b/src/deps/src/luajit/doc/ext_ffi_semantics.html index 5ba82a1e7..b56e57a16 100644 --- a/src/deps/src/luajit/doc/ext_ffi_semantics.html +++ b/src/deps/src/luajit/doc/ext_ffi_semantics.html @@ -440,6 +440,19 @@ If you don't do this, the default Lua number → double conversion rule applies. A vararg C function expecting an integer will see a garbled or uninitialized value.

+

+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. +

Initializers

diff --git a/src/deps/src/luajit/src/jit/bcsave.lua b/src/deps/src/luajit/src/jit/bcsave.lua index eba2a0c06..8c7c6f827 100644 --- a/src/deps/src/luajit/src/jit/bcsave.lua +++ b/src/deps/src/luajit/src/jit/bcsave.lua @@ -441,24 +441,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; @@ -468,133 +456,58 @@ 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 diff --git a/src/deps/src/luajit/src/jit/dump.lua b/src/deps/src/luajit/src/jit/dump.lua index 2d1cc53be..616e95b5c 100644 --- a/src/deps/src/luajit/src/jit/dump.lua +++ b/src/deps/src/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/src/deps/src/luajit/src/jit/v.lua b/src/deps/src/luajit/src/jit/v.lua index 8e91f4942..45a663d79 100644 --- a/src/deps/src/luajit/src/jit/v.lua +++ b/src/deps/src/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/src/deps/src/luajit/src/lib_ffi.c b/src/deps/src/luajit/src/lib_ffi.c index ba7831738..fb7f86f38 100644 --- a/src/deps/src/luajit/src/lib_ffi.c +++ b/src/deps/src/luajit/src/lib_ffi.c @@ -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<top++, (cts->miscmap = lj_tab_new(L, 0, 1))); - cts->finalizer = ffi_finalizer(L); LJ_LIB_REG(L, NULL, ffi_meta); /* NOBARRIER: basemt is a GC root. */ setgcref(basemt_it(G(L), LJ_TCDATA), obj2gco(tabV(L->top-1))); diff --git a/src/deps/src/luajit/src/lj_alloc.c b/src/deps/src/luajit/src/lj_alloc.c index 20e604935..cb704f7b3 100644 --- a/src/deps/src/luajit/src/lj_alloc.c +++ b/src/deps/src/luajit/src/lj_alloc.c @@ -1057,7 +1057,7 @@ static size_t release_unused_segments(mstate m) mchunkptr p = align_as_chunk(base); size_t psize = chunksize(p); /* Can unmap if first chunk holds entire segment and not pinned */ - if (!cinuse(p) && (char *)p + psize >= base + size - TOP_FOOT_SIZE) { + if (!cinuse(p) && (char *)p + psize == (char *)mem2chunk(sp)) { tchunkptr tp = (tchunkptr)p; if (p == m->dv) { m->dv = 0; diff --git a/src/deps/src/luajit/src/lj_arch.h b/src/deps/src/luajit/src/lj_arch.h index fbd18b366..112c23269 100644 --- a/src/deps/src/luajit/src/lj_arch.h +++ b/src/deps/src/luajit/src/lj_arch.h @@ -128,7 +128,7 @@ #define LJ_TARGET_POSIX (LUAJIT_OS > LUAJIT_OS_WINDOWS) #define LJ_TARGET_DLOPEN LJ_TARGET_POSIX -#if TARGET_OS_IPHONE +#if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE #define LJ_TARGET_IOS 1 #else #define LJ_TARGET_IOS 0 diff --git a/src/deps/src/luajit/src/lj_asm_arm64.h b/src/deps/src/luajit/src/lj_asm_arm64.h index 4b81a15ee..a277aa509 100644 --- a/src/deps/src/luajit/src/lj_asm_arm64.h +++ b/src/deps/src/luajit/src/lj_asm_arm64.h @@ -816,7 +816,7 @@ static void asm_href(ASMState *as, IRIns *ir, IROp merge) int destused = ra_used(ir); Reg dest = ra_dest(as, ir, allow); Reg tab = ra_alloc1(as, ir->op1, rset_clear(allow, dest)); - Reg tmp = RID_TMP, type = RID_NONE, key, tkey; + Reg tmp = RID_TMP, type = RID_NONE, key = RID_NONE, tkey; IRRef refkey = ir->op2; IRIns *irkey = IR(refkey); int isk = irref_isk(refkey); diff --git a/src/deps/src/luajit/src/lj_cdata.c b/src/deps/src/luajit/src/lj_cdata.c index 77d9730f3..2879e2a83 100644 --- a/src/deps/src/luajit/src/lj_cdata.c +++ b/src/deps/src/luajit/src/lj_cdata.c @@ -86,7 +86,7 @@ void LJ_FASTCALL lj_cdata_free(global_State *g, GCcdata *cd) void lj_cdata_setfin(lua_State *L, GCcdata *cd, GCobj *obj, uint32_t it) { - GCtab *t = ctype_ctsG(G(L))->finalizer; + GCtab *t = tabref(G(L)->gcroot[GCROOT_FFI_FIN]); if (gcref(t->metatable)) { /* Add cdata to finalizer table, if still enabled. */ TValue *tv, tmp; diff --git a/src/deps/src/luajit/src/lj_ctype.c b/src/deps/src/luajit/src/lj_ctype.c index 8a4a55f8a..0f6baac90 100644 --- a/src/deps/src/luajit/src/lj_ctype.c +++ b/src/deps/src/luajit/src/lj_ctype.c @@ -643,6 +643,18 @@ CTState *lj_ctype_init(lua_State *L) return cts; } +/* Create special weak-keyed finalizer table. */ +void lj_ctype_initfin(lua_State *L) +{ + /* NOBARRIER: The table is new (marked white). */ + GCtab *t = lj_tab_new(L, 0, 1); + 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<gcroot[GCROOT_FFI_FIN], obj2gco(t)); +} + /* Free C type table and state. */ void lj_ctype_freestate(global_State *g) { diff --git a/src/deps/src/luajit/src/lj_ctype.h b/src/deps/src/luajit/src/lj_ctype.h index 0ed02bc1d..5b481d15c 100644 --- a/src/deps/src/luajit/src/lj_ctype.h +++ b/src/deps/src/luajit/src/lj_ctype.h @@ -177,7 +177,6 @@ typedef struct CTState { MSize sizetab; /* Size of C type table. */ lua_State *L; /* Lua state (needed for errors and allocations). */ global_State *g; /* Global state. */ - GCtab *finalizer; /* Map of cdata to finalizer. */ GCtab *miscmap; /* Map of -CTypeID to metatable and cb slot to func. */ CCallback cb; /* Temporary callback state. */ CTypeID1 hash[CTHASH_SIZE]; /* Hash anchors for C type table. */ @@ -476,6 +475,7 @@ LJ_FUNC GCstr *lj_ctype_repr(lua_State *L, CTypeID id, GCstr *name); LJ_FUNC GCstr *lj_ctype_repr_int64(lua_State *L, uint64_t n, int isunsigned); LJ_FUNC GCstr *lj_ctype_repr_complex(lua_State *L, void *sp, CTSize size); LJ_FUNC CTState *lj_ctype_init(lua_State *L); +LJ_FUNC void lj_ctype_initfin(lua_State *L); LJ_FUNC void lj_ctype_freestate(global_State *g); #endif diff --git a/src/deps/src/luajit/src/lj_ffrecord.c b/src/deps/src/luajit/src/lj_ffrecord.c index 396183a07..2ad6e158b 100644 --- a/src/deps/src/luajit/src/lj_ffrecord.c +++ b/src/deps/src/luajit/src/lj_ffrecord.c @@ -153,6 +153,8 @@ static void recff_stitch(jit_State *J) if (errcode) { if (errcode == LUA_ERRRUN) copyTV(L, L->top-1, L->top + (1 + LJ_FR2)); + else + setintV(L->top-1, (int32_t)LJ_TRERR_RECERR); lj_err_throw(L, errcode); /* Propagate errors. */ } } @@ -1004,6 +1006,7 @@ static void recff_format(jit_State *J, RecordFFData *rd, TRef hdr, int sbufx) GCstr *fmt = argv2str(J, &rd->argv[arg]); FormatState fs; SFormat sf; + int nfmt = 0; /* Specialize to the format string. */ emitir(IRTG(IR_EQ, IRT_STR), trfmt, lj_ir_kstr(J, fmt)); lj_strfmt_init(&fs, strdata(fmt), fmt->len); @@ -1081,6 +1084,7 @@ static void recff_format(jit_State *J, RecordFFData *rd, TRef hdr, int sbufx) recff_nyiu(J, rd); return; } + if (++nfmt > 100) lj_trace_err(J, LJ_TRERR_TRACEOV); } if (sbufx) { emitir(IRT(IR_USE, IRT_NIL), tr, 0); diff --git a/src/deps/src/luajit/src/lj_gc.c b/src/deps/src/luajit/src/lj_gc.c index eebc751b2..9cabdef0f 100644 --- a/src/deps/src/luajit/src/lj_gc.c +++ b/src/deps/src/luajit/src/lj_gc.c @@ -108,9 +108,6 @@ static void gc_mark_start(global_State *g) gc_markobj(g, tabref(mainthread(g)->env)); gc_marktv(g, &g->registrytv); gc_mark_gcroot(g); -#if LJ_HASFFI - if (ctype_ctsG(g)) gc_markobj(g, ctype_ctsG(g)->finalizer); -#endif g->gc.state = GCSpropagate; } @@ -190,8 +187,7 @@ static int gc_traverse_tab(global_State *g, GCtab *t) } if (weak) { /* Weak tables are cleared in the atomic phase. */ #if LJ_HASFFI - CTState *cts = ctype_ctsG(g); - if (cts && cts->finalizer == t) { + if (gcref(g->gcroot[GCROOT_FFI_FIN]) == obj2gco(t)) { weak = (int)(~0u & ~LJ_GC_WEAKVAL); } else #endif @@ -556,7 +552,7 @@ static void gc_finalize(lua_State *L) o->gch.marked &= (uint8_t)~LJ_GC_CDATA_FIN; /* Resolve finalizer. */ setcdataV(L, &tmp, gco2cd(o)); - tv = lj_tab_set(L, ctype_ctsG(g)->finalizer, &tmp); + tv = lj_tab_set(L, tabref(g->gcroot[GCROOT_FFI_FIN]), &tmp); if (!tvisnil(tv)) { g->gc.nocdatafin = 0; copyTV(L, &tmp, tv); @@ -588,23 +584,20 @@ void lj_gc_finalize_udata(lua_State *L) void lj_gc_finalize_cdata(lua_State *L) { global_State *g = G(L); - CTState *cts = ctype_ctsG(g); - if (cts) { - GCtab *t = cts->finalizer; - Node *node = noderef(t->node); - ptrdiff_t i; - setgcrefnull(t->metatable); /* Mark finalizer table as disabled. */ - for (i = (ptrdiff_t)t->hmask; i >= 0; i--) - if (!tvisnil(&node[i].val) && tviscdata(&node[i].key)) { - GCobj *o = gcV(&node[i].key); - TValue tmp; - makewhite(g, o); - o->gch.marked &= (uint8_t)~LJ_GC_CDATA_FIN; - copyTV(L, &tmp, &node[i].val); - setnilV(&node[i].val); - gc_call_finalizer(g, L, &tmp, o); - } - } + GCtab *t = tabref(g->gcroot[GCROOT_FFI_FIN]); + Node *node = noderef(t->node); + ptrdiff_t i; + setgcrefnull(t->metatable); /* Mark finalizer table as disabled. */ + for (i = (ptrdiff_t)t->hmask; i >= 0; i--) + if (!tvisnil(&node[i].val) && tviscdata(&node[i].key)) { + GCobj *o = gcV(&node[i].key); + TValue tmp; + makewhite(g, o); + o->gch.marked &= (uint8_t)~LJ_GC_CDATA_FIN; + copyTV(L, &tmp, &node[i].val); + setnilV(&node[i].val); + gc_call_finalizer(g, L, &tmp, o); + } } #endif @@ -720,7 +713,7 @@ static size_t gc_onestep(lua_State *L) return GCFINALIZECOST; } #if LJ_HASFFI - if (!g->gc.nocdatafin) lj_tab_rehash(L, ctype_ctsG(g)->finalizer); + if (!g->gc.nocdatafin) lj_tab_rehash(L, tabref(g->gcroot[GCROOT_FFI_FIN])); #endif g->gc.state = GCSpause; /* End of GC cycle. */ g->gc.debt = 0; diff --git a/src/deps/src/luajit/src/lj_jit.h b/src/deps/src/luajit/src/lj_jit.h index a60a9aea7..a11ef7292 100644 --- a/src/deps/src/luajit/src/lj_jit.h +++ b/src/deps/src/luajit/src/lj_jit.h @@ -461,8 +461,8 @@ typedef struct jit_State { #endif IRIns *irbuf; /* Temp. IR instruction buffer. Biased with REF_BIAS. */ - IRRef irtoplim; /* Upper limit of instuction buffer (biased). */ - IRRef irbotlim; /* Lower limit of instuction buffer (biased). */ + IRRef irtoplim; /* Upper limit of instruction buffer (biased). */ + IRRef irbotlim; /* Lower limit of instruction buffer (biased). */ IRRef loopref; /* Last loop reference or ref of final LOOP (or 0). */ MSize sizesnap; /* Size of temp. snapshot buffer. */ diff --git a/src/deps/src/luajit/src/lj_obj.h b/src/deps/src/luajit/src/lj_obj.h index 434805d38..d927a4b8e 100644 --- a/src/deps/src/luajit/src/lj_obj.h +++ b/src/deps/src/luajit/src/lj_obj.h @@ -579,6 +579,9 @@ typedef enum { GCROOT_BASEMT_NUM = GCROOT_BASEMT + ~LJ_TNUMX, GCROOT_IO_INPUT, /* Userdata for default I/O input file. */ GCROOT_IO_OUTPUT, /* Userdata for default I/O output file. */ +#if LJ_HASFFI + GCROOT_FFI_FIN, /* FFI finalizer table. */ +#endif GCROOT_MAX } GCRootID; diff --git a/src/deps/src/luajit/src/lj_snap.c b/src/deps/src/luajit/src/lj_snap.c index f3645e876..6fda08ba3 100644 --- a/src/deps/src/luajit/src/lj_snap.c +++ b/src/deps/src/luajit/src/lj_snap.c @@ -801,7 +801,6 @@ static void snap_restoredata(jit_State *J, GCtrace *T, ExitState *ex, *(lua_Number *)dst = (lua_Number)*(int32_t *)dst; return; } - src = (int32_t *)&ex->gpr[r-RID_MIN_GPR]; #if !LJ_SOFTFP if (r >= RID_MAX_GPR) { src = (int32_t *)&ex->fpr[r-RID_MIN_FPR]; @@ -815,7 +814,10 @@ static void snap_restoredata(jit_State *J, GCtrace *T, ExitState *ex, #endif } else #endif - if (LJ_64 && LJ_BE && sz == 4) src++; + { + src = (int32_t *)&ex->gpr[r-RID_MIN_GPR]; + if (LJ_64 && LJ_BE && sz == 4) src++; + } } } lj_assertJ(sz == 1 || sz == 2 || sz == 4 || sz == 8, diff --git a/src/deps/src/luajit/src/lj_state.c b/src/deps/src/luajit/src/lj_state.c index 1b793da98..85ffb1a84 100644 --- a/src/deps/src/luajit/src/lj_state.c +++ b/src/deps/src/luajit/src/lj_state.c @@ -196,6 +196,9 @@ static TValue *cpluaopen(lua_State *L, lua_CFunction dummy, void *ud) lj_lex_init(L); fixstring(lj_err_str(L, LJ_ERR_ERRMEM)); /* Preallocate memory error msg. */ g->gc.threshold = 4*g->gc.total; +#if LJ_HASFFI + lj_ctype_initfin(L); +#endif lj_trace_initstate(g); lj_err_verify(); return NULL; diff --git a/src/deps/src/luajit/src/lj_str_hash.c b/src/deps/src/luajit/src/lj_str_hash.c index 0ee4b5f6a..60b972b13 100644 --- a/src/deps/src/luajit/src/lj_str_hash.c +++ b/src/deps/src/luajit/src/lj_str_hash.c @@ -300,10 +300,12 @@ static StrHash hash_dense_sse42(uint64_t seed, uint32_t h, const char* str, void str_hash_init_sse42(void) { - hash_sparse = hash_sparse_sse42; + if (0) { + hash_sparse = hash_sparse_sse42; #if LUAJIT_SECURITY_STRHASH - hash_dense = hash_dense_sse42; + hash_dense = hash_dense_sse42; #endif - str_hash_init_random(); + str_hash_init_random(); + } } #endif diff --git a/src/deps/src/luajit/src/lj_traceerr.h b/src/deps/src/luajit/src/lj_traceerr.h index 19ce30ad8..08134dc54 100644 --- a/src/deps/src/luajit/src/lj_traceerr.h +++ b/src/deps/src/luajit/src/lj_traceerr.h @@ -13,7 +13,7 @@ TREDEF(STACKOV, "trace too deep") TREDEF(SNAPOV, "too many snapshots") TREDEF(BLACKL, "blacklisted") TREDEF(RETRY, "retry recording") -TREDEF(NYIBC, "NYI: bytecode %d") +TREDEF(NYIBC, "NYI: bytecode %s") /* Recording loop ops. */ TREDEF(LLEAVE, "leaving loop in root trace") diff --git a/src/deps/src/luajit/src/msvcbuild.bat b/src/deps/src/luajit/src/msvcbuild.bat index 91cfd0650..13b8175ad 100644 --- a/src/deps/src/luajit/src/msvcbuild.bat +++ b/src/deps/src/luajit/src/msvcbuild.bat @@ -13,10 +13,15 @@ @if not defined INCLUDE goto :FAIL @setlocal -@rem Add more debug flags here, e.g. DEBUGCFLAGS=/DLUA_USE_APICHECK +@rem Add more debug flags here, e.g. DEBUGCFLAGS=/DLUA_USE_ASSERT @set DEBUGCFLAGS= @set LJCOMPILE=cl /nologo /c /O2 /W3 /D_CRT_SECURE_NO_DEPRECATE /D_CRT_STDIO_INLINE=__declspec(dllexport)__inline -@set LJDYNBUILD=/MD /DLUA_BUILD_AS_DLL +@set LJDYNBUILD=/DLUA_BUILD_AS_DLL /MD +@set LJDYNBUILD_DEBUG=/DLUA_BUILD_AS_DLL /MDd +@set LJCOMPILETARGET=/Zi +@set LJLINKTYPE=/DEBUG /RELEASE +@set LJLINKTYPE_DEBUG=/DEBUG +@set LJLINKTARGET=/OPT:REF /OPT:ICF /INCREMENTAL:NO @set LJLINK=link /nologo @set LJMT=mt /nologo @set LJLIB=lib /nologo /nodefaultlib @@ -25,7 +30,6 @@ @set DASC=vm_x64.dasc @set LJDLLNAME=lua51.dll @set LJLIBNAME=lua51.lib -@set BUILDTYPE=release @set ALL_LIB=lib_base.c lib_math.c lib_bit.c lib_string.c lib_table.c lib_io.c lib_os.c lib_package.c lib_debug.c lib_jit.c lib_ffi.c lib_buffer.c @setlocal @@ -92,12 +96,12 @@ buildvm -m folddef -o lj_folddef.h lj_opt_fold.c @if "%1" neq "debug" goto :NODEBUG @shift -@set BUILDTYPE=debug -@set LJCOMPILE=%LJCOMPILE% /Zi %DEBUGCFLAGS% -@set LJDYNBUILD=/MDd /DLUA_BUILD_AS_DLL -@set LJLINK=%LJLINK% /opt:ref /opt:icf /incremental:no +@set LJCOMPILE=%LJCOMPILE% %DEBUGCFLAGS% +@set LJDYNBUILD=%LJDYNBUILD_DEBUG% +@set LJLINKTYPE=%LJLINKTYPE_DEBUG% :NODEBUG -@set LJLINK=%LJLINK% /%BUILDTYPE% +@set LJCOMPILE=%LJCOMPILE% %LJCOMPILETARGET% +@set LJLINK=%LJLINK% %LJLINKTYPE% %LJLINKTARGET% @if "%1"=="amalg" goto :AMALGDLL @if "%1"=="static" goto :STATIC %LJCOMPILE% %LJDYNBUILD% lj_*.c lib_*.c diff --git a/src/deps/src/luajit/src/nxbuild.bat b/src/deps/src/luajit/src/nxbuild.bat index 7f84b747d..915133977 100644 --- a/src/deps/src/luajit/src/nxbuild.bat +++ b/src/deps/src/luajit/src/nxbuild.bat @@ -99,20 +99,21 @@ buildvm -m folddef -o lj_folddef.h lj_opt_fold.c @if errorlevel 1 goto :BAD @rem ---- Cross compiler ---- +@set NXCOMPILER_ROOT="%NINTENDO_SDK_ROOT%\Compilers\NintendoClang" @if "%platform%" neq "x64" goto :NX32_CROSSBUILD -@set LJCOMPILE="%NINTENDO_SDK_ROOT%\Compilers\NX\nx\aarch64\bin\clang" -Wall -I%NINTENDO_SDK_ROOT%\Include %DASMTARGET% -DLUAJIT_OS=LUAJIT_OS_OTHER -DLUAJIT_DISABLE_JIT -DLUAJIT_DISABLE_FFI -DLUAJIT_USE_SYSMALLOC -c -@set LJLIB="%NINTENDO_SDK_ROOT%\Compilers\NX\nx\aarch64\bin\aarch64-nintendo-nx-elf-ar" rc +@set LJCOMPILE="%NXCOMPILER_ROOT%\bin\clang" --target=aarch64-nintendo-nx-elf -Wall -I%NINTENDO_SDK_ROOT%\Include %DASMTARGET% -DLUAJIT_OS=LUAJIT_OS_OTHER -DLUAJIT_DISABLE_JIT -DLUAJIT_DISABLE_FFI -DLUAJIT_USE_SYSMALLOC -c +@set LJLIB="%NXCOMPILER_ROOT%\bin\llvm-ar" rc @set TARGETLIB_SUFFIX=nx64 -%NINTENDO_SDK_ROOT%\Compilers\NX\nx\aarch64\bin\aarch64-nintendo-nx-elf-as -o lj_vm.o lj_vm.s +%NXCOMPILER_ROOT%\bin\clang --target=aarch64-nintendo-nx-elf -o lj_vm.o -c lj_vm.s goto :DEBUGCHECK :NX32_CROSSBUILD -@set LJCOMPILE="%NINTENDO_SDK_ROOT%\Compilers\NX\nx\armv7l\bin\clang" -Wall -I%NINTENDO_SDK_ROOT%\Include %DASMTARGET% -DLUAJIT_OS=LUAJIT_OS_OTHER -DLUAJIT_DISABLE_JIT -DLUAJIT_DISABLE_FFI -DLUAJIT_USE_SYSMALLOC -c -@set LJLIB="%NINTENDO_SDK_ROOT%\Compilers\NX\nx\armv7l\bin\armv7l-nintendo-nx-eabihf-ar" rc +@set LJCOMPILE="%NXCOMPILER_ROOT%\bin\clang" --target=armv7l-nintendo-nx-eabihf -Wall -I%NINTENDO_SDK_ROOT%\Include %DASMTARGET% -DLUAJIT_OS=LUAJIT_OS_OTHER -DLUAJIT_DISABLE_JIT -DLUAJIT_DISABLE_FFI -DLUAJIT_USE_SYSMALLOC -c +@set LJLIB="%NXCOMPILER_ROOT%\bin\llvm-ar" rc @set TARGETLIB_SUFFIX=nx32 -%NINTENDO_SDK_ROOT%\Compilers\NX\nx\armv7l\bin\armv7l-nintendo-nx-eabihf-as -o lj_vm.o lj_vm.s +%NXCOMPILER_ROOT%\bin\clang --target=armv7l-nintendo-nx-eabihf -o lj_vm.o -c lj_vm.s :DEBUGCHECK @if "%1" neq "debug" goto :NODEBUG diff --git a/src/deps/src/luajit/src/vm_ppc.dasc b/src/deps/src/luajit/src/vm_ppc.dasc index 8bb5bcefa..5364c580b 100644 --- a/src/deps/src/luajit/src/vm_ppc.dasc +++ b/src/deps/src/luajit/src/vm_ppc.dasc @@ -981,7 +981,6 @@ static void build_subroutines(BuildCtx *ctx) | lwz PC, FRAME_CONTPC(RB) // Restore PC from [cont|PC]. | addi BASEP4, BASE, 4 | addi TMP2, RD, WORD_HI-8 - | lwz TMP1, LFUNC:TMP1->pc | stwx TISNIL, RA, TMP2 // Ensure one valid arg. |.if P64 | ld TMP3, 0(DISPATCH) @@ -992,6 +991,7 @@ static void build_subroutines(BuildCtx *ctx) |.if P64 | add TMP0, TMP0, TMP3 |.endif + | lwz TMP1, LFUNC:TMP1->pc | lwz KBASE, PC2PROTO(k)(TMP1) | // BASE = base, RA = resultptr, RB = meta base | mtctr TMP0