diff --git a/luajit-2.1-update.patch b/luajit-2.1-224129a-update.patch similarity index 99% rename from luajit-2.1-update.patch rename to luajit-2.1-224129a-update.patch index 37aece63d59df3a29a4b44dc3c0c01ac11998301..a00f7053f1e5cffc9a9ea67a29e895642d4e52ab 100644 --- a/luajit-2.1-update.patch +++ b/luajit-2.1-224129a-update.patch @@ -6729,14 +6729,14 @@ index f56465d1..30d64be2 100644 $(Q)$(DASM) $(DASM_FLAGS) -o $@ $(DASM_DASC) diff --git a/src/Makefile.dep b/src/Makefile.dep -index 2b1cb5ef..1ad6701a 100644 +index 2b1cb5ef..400ef8b0 100644 --- a/src/Makefile.dep +++ b/src/Makefile.dep @@ -1,15 +1,19 @@ lib_aux.o: lib_aux.c lua.h luaconf.h lauxlib.h lj_obj.h lj_def.h \ lj_arch.h lj_err.h lj_errmsg.h lj_state.h lj_trace.h lj_jit.h lj_ir.h \ - lj_dispatch.h lj_bc.h lj_traceerr.h lj_lib.h lj_alloc.h -+ lj_dispatch.h lj_bc.h lj_traceerr.h lj_lib.h ++ lj_dispatch.h lj_bc.h lj_traceerr.h lj_lib.h lj_vmevent.h lib_base.o: lib_base.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_debug.h lj_str.h \ - lj_tab.h lj_meta.h lj_state.h lj_frame.h lj_bc.h lj_ctype.h lj_cconv.h \ @@ -6801,7 +6801,7 @@ index 2b1cb5ef..1ad6701a 100644 lj_cdata.o: lj_cdata.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ lj_gc.h lj_err.h lj_errmsg.h lj_tab.h lj_ctype.h lj_cconv.h lj_cdata.h lj_char.o: lj_char.c lj_char.h lj_def.h lua.h luaconf.h -@@ -108,10 +114,10 @@ lj_err.o: lj_err.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_err.h \ +@@ -108,38 +114,38 @@ lj_err.o: lj_err.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_err.h \ lj_ff.h lj_ffdef.h lj_trace.h lj_jit.h lj_ir.h lj_dispatch.h \ lj_traceerr.h lj_vm.h lj_strfmt.h lj_ffrecord.o: lj_ffrecord.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ @@ -6816,7 +6816,14 @@ index 2b1cb5ef..1ad6701a 100644 lj_func.o: lj_func.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \ lj_func.h lj_trace.h lj_jit.h lj_ir.h lj_dispatch.h lj_bc.h \ lj_traceerr.h lj_vm.h -@@ -125,21 +131,21 @@ lj_gdbjit.o: lj_gdbjit.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ + lj_gc.o: lj_gc.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \ + lj_err.h lj_errmsg.h lj_buf.h lj_str.h lj_tab.h lj_func.h lj_udata.h \ + lj_meta.h lj_state.h lj_frame.h lj_bc.h lj_ctype.h lj_cdata.h lj_trace.h \ +- lj_jit.h lj_ir.h lj_dispatch.h lj_traceerr.h lj_vm.h ++ lj_jit.h lj_ir.h lj_dispatch.h lj_traceerr.h lj_vm.h lj_vmevent.h + lj_gdbjit.o: lj_gdbjit.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ + lj_gc.h lj_err.h lj_errmsg.h lj_debug.h lj_frame.h lj_bc.h lj_buf.h \ + lj_str.h lj_strfmt.h lj_jit.h lj_ir.h lj_dispatch.h lj_ir.o: lj_ir.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \ lj_buf.h lj_str.h lj_tab.h lj_ir.h lj_jit.h lj_ircall.h lj_iropt.h \ lj_trace.h lj_dispatch.h lj_bc.h lj_traceerr.h lj_ctype.h lj_cdata.h \ @@ -6888,7 +6895,7 @@ index 2b1cb5ef..1ad6701a 100644 lj_strfmt_num.o: lj_strfmt_num.c lj_obj.h lua.h luaconf.h lj_def.h \ lj_arch.h lj_buf.h lj_gc.h lj_str.h lj_strfmt.h lj_strscan.o: lj_strscan.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ -@@ -198,36 +210,37 @@ lj_trace.o: lj_trace.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ +@@ -198,24 +210,25 @@ lj_trace.o: lj_trace.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ lj_gc.h lj_err.h lj_errmsg.h lj_debug.h lj_str.h lj_frame.h lj_bc.h \ lj_state.h lj_ir.h lj_jit.h lj_iropt.h lj_mcode.h lj_trace.h \ lj_dispatch.h lj_traceerr.h lj_snap.h lj_gdbjit.h lj_record.h lj_asm.h \ @@ -6912,41 +6919,26 @@ index 2b1cb5ef..1ad6701a 100644 - lj_state.c lj_lex.h lj_alloc.h luajit.h lj_dispatch.c lj_ccallback.h \ - lj_profile.h lj_vmevent.c lj_vmevent.h lj_vmmath.c lj_strscan.c \ - lj_strfmt.c lj_strfmt_num.c lj_api.c lj_profile.c lj_lex.c lualib.h \ -- lj_parse.h lj_parse.c lj_bcread.c lj_bcdump.h lj_bcwrite.c lj_load.c \ -- lj_ctype.c lj_cdata.c lj_cconv.h lj_cconv.c lj_ccall.c lj_ccall.h \ -- lj_ccallback.c lj_target.h lj_target_*.h lj_mcode.h lj_carith.c \ -- lj_carith.h lj_clib.c lj_clib.h lj_cparse.c lj_cparse.h lj_lib.c lj_ir.c \ -- lj_ircall.h lj_iropt.h lj_opt_mem.c lj_opt_fold.c lj_folddef.h \ -- lj_opt_narrow.c lj_opt_dce.c lj_opt_loop.c lj_snap.h lj_opt_split.c \ -- lj_opt_sink.c lj_mcode.c lj_snap.c lj_record.c lj_record.h lj_ffrecord.h \ -- lj_crecord.c lj_crecord.h lj_ffrecord.c lj_recdef.h lj_asm.c lj_asm.h \ -- lj_emit_*.h lj_asm_*.h lj_trace.c lj_gdbjit.h lj_gdbjit.c lj_alloc.c \ -- lib_aux.c lib_base.c lj_libdef.h lib_math.c lib_string.c lib_table.c \ -- lib_io.c lib_os.c lib_package.c lib_debug.c lib_bit.c lib_jit.c \ -- lib_ffi.c lib_init.c +ljamalg.o: ljamalg.c lua.h luaconf.h lauxlib.h lj_assert.c lj_obj.h \ + lj_def.h lj_arch.h lj_gc.c lj_gc.h lj_err.h lj_errmsg.h lj_buf.h \ + lj_str.h lj_tab.h lj_func.h lj_udata.h lj_meta.h lj_state.h lj_frame.h \ + lj_bc.h lj_ctype.h lj_cdata.h lj_trace.h lj_jit.h lj_ir.h lj_dispatch.h \ -+ lj_traceerr.h lj_vm.h lj_err.c lj_debug.h lj_ff.h lj_ffdef.h lj_strfmt.h \ -+ lj_char.c lj_char.h lj_bc.c lj_bcdef.h lj_obj.c lj_buf.c lj_str.c \ -+ lj_prng.h lj_tab.c lj_func.c lj_udata.c lj_meta.c lj_strscan.h lj_lib.h \ -+ lj_debug.c lj_prng.c lj_state.c lj_lex.h lj_alloc.h luajit.h \ -+ lj_dispatch.c lj_ccallback.h lj_profile.h lj_vmevent.c lj_vmevent.h \ -+ lj_vmmath.c lj_strscan.c lj_strfmt.c lj_strfmt_num.c lj_serialize.c \ -+ lj_serialize.h lj_api.c lj_profile.c lj_lex.c lualib.h lj_parse.h \ -+ lj_parse.c lj_bcread.c lj_bcdump.h lj_bcwrite.c lj_load.c lj_ctype.c \ -+ lj_cdata.c lj_cconv.h lj_cconv.c lj_ccall.c lj_ccall.h lj_ccallback.c \ -+ lj_target.h lj_target_*.h lj_mcode.h lj_carith.c lj_carith.h lj_clib.c \ -+ lj_clib.h lj_cparse.c lj_cparse.h lj_lib.c lj_ir.c lj_ircall.h \ -+ lj_iropt.h lj_opt_mem.c lj_opt_fold.c lj_folddef.h lj_opt_narrow.c \ -+ lj_opt_dce.c lj_opt_loop.c lj_snap.h lj_opt_split.c lj_opt_sink.c \ -+ lj_mcode.c lj_snap.c lj_record.c lj_record.h lj_ffrecord.h lj_crecord.c \ -+ lj_crecord.h lj_ffrecord.c lj_recdef.h lj_asm.c lj_asm.h lj_emit_*.h \ -+ lj_asm_*.h lj_trace.c lj_gdbjit.h lj_gdbjit.c lj_alloc.c lib_aux.c \ -+ lib_base.c lj_libdef.h lib_math.c lib_string.c lib_table.c lib_io.c \ -+ lib_os.c lib_package.c lib_debug.c lib_bit.c lib_jit.c lib_ffi.c \ -+ lib_buffer.c lib_init.c ++ lj_traceerr.h lj_vm.h lj_vmevent.h lj_err.c lj_debug.h lj_ff.h \ ++ lj_ffdef.h lj_strfmt.h lj_char.c lj_char.h lj_bc.c lj_bcdef.h lj_obj.c \ ++ lj_buf.c lj_str.c lj_prng.h lj_tab.c lj_func.c lj_udata.c lj_meta.c \ ++ lj_strscan.h lj_lib.h lj_debug.c lj_prng.c lj_state.c lj_lex.h \ ++ lj_alloc.h luajit.h lj_dispatch.c lj_ccallback.h lj_profile.h \ ++ lj_vmevent.c lj_vmmath.c lj_strscan.c lj_strfmt.c lj_strfmt_num.c \ ++ lj_serialize.c lj_serialize.h lj_api.c lj_profile.c lj_lex.c lualib.h \ + lj_parse.h lj_parse.c lj_bcread.c lj_bcdump.h lj_bcwrite.c lj_load.c \ + lj_ctype.c lj_cdata.c lj_cconv.h lj_cconv.c lj_ccall.c lj_ccall.h \ + lj_ccallback.c lj_target.h lj_target_*.h lj_mcode.h lj_carith.c \ +@@ -227,7 +240,7 @@ ljamalg.o: ljamalg.c lua.h luaconf.h lauxlib.h lj_gc.c lj_obj.h lj_def.h \ + lj_emit_*.h lj_asm_*.h lj_trace.c lj_gdbjit.h lj_gdbjit.c lj_alloc.c \ + lib_aux.c lib_base.c lj_libdef.h lib_math.c lib_string.c lib_table.c \ + lib_io.c lib_os.c lib_package.c lib_debug.c lib_bit.c lib_jit.c \ +- lib_ffi.c lib_init.c ++ lib_ffi.c lib_buffer.c lib_init.c luajit.o: luajit.c lua.h luaconf.h lauxlib.h lualib.h luajit.h lj_arch.h host/buildvm.o: host/buildvm.c host/buildvm.h lj_def.h lua.h luaconf.h \ lj_arch.h lj_obj.h lj_def.h lj_arch.h lj_gc.h lj_obj.h lj_bc.h lj_ir.h \ @@ -8344,66 +8336,52 @@ index 2b1470af..7c478d2d 100644 -- Released under the MIT license. See Copyright Notice in luajit.h ---------------------------------------------------------------------------- -- This module just exports the little-endian functions from the -diff --git a/src/jit/dis_mips64el.lua b/src/jit/dis_mips64r6.lua -similarity index 67% -copy from src/jit/dis_mips64el.lua -copy to src/jit/dis_mips64r6.lua -index 2b1470af..c5789ce4 100644 ---- a/src/jit/dis_mips64el.lua +diff --git a/src/jit/dis_mips64r6.lua b/src/jit/dis_mips64r6.lua +new file mode 100644 +index 00000000..c5789ce4 +--- /dev/null +++ b/src/jit/dis_mips64r6.lua -@@ -1,17 +1,17 @@ - ---------------------------------------------------------------------------- ---- LuaJIT MIPS64EL disassembler wrapper module. +@@ -0,0 +1,17 @@ ++---------------------------------------------------------------------------- +-- LuaJIT MIPS64R6 disassembler wrapper module. - -- ---- Copyright (C) 2005-2017 Mike Pall. All rights reserved. ++-- +-- Copyright (C) 2005-2022 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 ++-- Released under the MIT license. See Copyright Notice in luajit.h ++---------------------------------------------------------------------------- +-- This module just exports the r6 big-endian functions from the - -- MIPS disassembler module. All the interesting stuff is there. - ------------------------------------------------------------------------------ - - local dis_mips = require((string.match(..., ".*%.") or "").."dis_mips") - return { -- create = dis_mips.create_el, -- disass = dis_mips.disass_el, ++-- MIPS disassembler module. All the interesting stuff is there. ++------------------------------------------------------------------------------ ++ ++local dis_mips = require((string.match(..., ".*%.") or "").."dis_mips") ++return { + create = dis_mips.create_r6, + disass = dis_mips.disass_r6, - regname = dis_mips.regname - } - -diff --git a/src/jit/dis_mips64el.lua b/src/jit/dis_mips64r6el.lua -similarity index 66% -copy from src/jit/dis_mips64el.lua -copy to src/jit/dis_mips64r6el.lua -index 2b1470af..f67f6240 100644 ---- a/src/jit/dis_mips64el.lua ++ regname = dis_mips.regname ++} ++ +diff --git a/src/jit/dis_mips64r6el.lua b/src/jit/dis_mips64r6el.lua +new file mode 100644 +index 00000000..f67f6240 +--- /dev/null +++ b/src/jit/dis_mips64r6el.lua -@@ -1,17 +1,17 @@ - ---------------------------------------------------------------------------- ---- LuaJIT MIPS64EL disassembler wrapper module. +@@ -0,0 +1,17 @@ ++---------------------------------------------------------------------------- +-- LuaJIT MIPS64R6EL disassembler wrapper module. - -- ---- Copyright (C) 2005-2017 Mike Pall. All rights reserved. ++-- +-- Copyright (C) 2005-2022 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 ++-- Released under the MIT license. See Copyright Notice in luajit.h ++---------------------------------------------------------------------------- +-- This module just exports the r6 little-endian functions from the - -- MIPS disassembler module. All the interesting stuff is there. - ------------------------------------------------------------------------------ - - local dis_mips = require((string.match(..., ".*%.") or "").."dis_mips") - return { -- create = dis_mips.create_el, -- disass = dis_mips.disass_el, ++-- MIPS disassembler module. All the interesting stuff is there. ++------------------------------------------------------------------------------ ++ ++local dis_mips = require((string.match(..., ".*%.") or "").."dis_mips") ++return { + create = dis_mips.create_r6_el, + disass = dis_mips.disass_r6_el, - regname = dis_mips.regname - } - ++ regname = dis_mips.regname ++} ++ diff --git a/src/jit/dis_mipsel.lua b/src/jit/dis_mipsel.lua index f69b11f0..a4fa6c60 100644 --- a/src/jit/dis_mipsel.lua @@ -8718,7 +8696,7 @@ index fa702c4e..1308cb74 100644 ---------------------------------------------------------------------------- -- diff --git a/src/lib_aux.c b/src/lib_aux.c -index c40565c3..b8e56436 100644 +index c40565c3..4222367d 100644 --- a/src/lib_aux.c +++ b/src/lib_aux.c @@ -1,6 +1,6 @@ @@ -8729,7 +8707,15 @@ index c40565c3..b8e56436 100644 ** ** Major parts taken verbatim or adapted from the Lua interpreter. ** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h -@@ -218,8 +218,15 @@ LUALIB_API char *luaL_prepbuffer(luaL_Buffer *B) +@@ -21,6 +21,7 @@ + #include "lj_state.h" + #include "lj_trace.h" + #include "lj_lib.h" ++#include "lj_vmevent.h" + + #if LJ_TARGET_POSIX + #include +@@ -218,8 +219,15 @@ LUALIB_API char *luaL_prepbuffer(luaL_Buffer *B) LUALIB_API void luaL_addlstring(luaL_Buffer *B, const char *s, size_t l) { @@ -8747,7 +8733,42 @@ index c40565c3..b8e56436 100644 } LUALIB_API void luaL_addstring(luaL_Buffer *B, const char *s) -@@ -338,17 +345,13 @@ LUALIB_API lua_State *luaL_newstate(void) +@@ -311,6 +319,18 @@ static int panic(lua_State *L) + return 0; + } + ++#ifndef LUAJIT_DISABLE_VMEVENT ++static int error_finalizer(lua_State *L) ++{ ++ const char *s = lua_tostring(L, -1); ++ fputs("ERROR in finalizer: ", stderr); ++ fputs(s ? s : "?", stderr); ++ fputc('\n', stderr); ++ fflush(stderr); ++ return 0; ++} ++#endif ++ + #ifdef LUAJIT_USE_SYSMALLOC + + #if LJ_64 && !LJ_GC64 && !defined(LUAJIT_USE_VALGRIND) +@@ -332,25 +352,39 @@ static void *mem_alloc(void *ud, void *ptr, size_t osize, size_t nsize) + LUALIB_API lua_State *luaL_newstate(void) + { + lua_State *L = lua_newstate(mem_alloc, NULL); +- if (L) G(L)->panic = panic; ++ if (L) { ++ G(L)->panic = panic; ++#ifndef LUAJIT_DISABLE_VMEVENT ++ luaL_findtable(L, LUA_REGISTRYINDEX, LJ_VMEVENTS_REGKEY, LJ_VMEVENTS_HSIZE); ++ lua_pushcfunction(L, error_finalizer); ++ lua_rawseti(L, -2, VMEVENT_HASH(LJ_VMEVENT_ERRFIN)); ++ G(L)->vmevmask = VMEVENT_MASK(LJ_VMEVENT_ERRFIN); ++ L->top--; ++#endif ++ } + return L; + } #else @@ -8765,8 +8786,20 @@ index c40565c3..b8e56436 100644 - L = lua_newstate(lj_alloc_f, ud); + L = lua_newstate(LJ_ALLOCF_INTERNAL, NULL); #endif - if (L) G(L)->panic = panic; +- if (L) G(L)->panic = panic; ++ if (L) { ++ G(L)->panic = panic; ++#ifndef LUAJIT_DISABLE_VMEVENT ++ luaL_findtable(L, LUA_REGISTRYINDEX, LJ_VMEVENTS_REGKEY, LJ_VMEVENTS_HSIZE); ++ lua_pushcfunction(L, error_finalizer); ++ lua_rawseti(L, -2, VMEVENT_HASH(LJ_VMEVENT_ERRFIN)); ++ G(L)->vmevmask = VMEVENT_MASK(LJ_VMEVENT_ERRFIN); ++ L->top--; ++#endif ++ } return L; + } + diff --git a/src/lib_base.c b/src/lib_base.c index 3a757870..c59d54a2 100644 --- a/src/lib_base.c @@ -24236,7 +24269,7 @@ index 901751b9..44df4deb 100644 #ifndef _LJ_FUNC_H diff --git a/src/lj_gc.c b/src/lj_gc.c -index 2aaf5b2c..2fc52ec1 100644 +index 2aaf5b2c..6c3187c3 100644 --- a/src/lj_gc.c +++ b/src/lj_gc.c @@ -1,6 +1,6 @@ @@ -24247,15 +24280,17 @@ index 2aaf5b2c..2fc52ec1 100644 ** ** Major portions taken verbatim or adapted from the Lua interpreter. ** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h -@@ -25,6 +25,7 @@ +@@ -25,7 +25,9 @@ #include "lj_cdata.h" #endif #include "lj_trace.h" +#include "lj_dispatch.h" #include "lj_vm.h" ++#include "lj_vmevent.h" #define GCSTEPSIZE 1024u -@@ -41,7 +42,8 @@ + #define GCSWEEPMAX 40 +@@ -41,7 +43,8 @@ /* Mark a TValue (if needed). */ #define gc_marktv(g, tv) \ @@ -24265,7 +24300,7 @@ index 2aaf5b2c..2fc52ec1 100644 if (tviswhite(tv)) gc_mark(g, gcV(tv)); } /* Mark a GCobj (if needed). */ -@@ -55,21 +57,32 @@ +@@ -55,21 +58,32 @@ static void gc_mark(global_State *g, GCobj *o) { int gct = o->gch.gct; @@ -24301,7 +24336,7 @@ index 2aaf5b2c..2fc52ec1 100644 setgcrefr(o->gch.gclist, g->gc.gray); setgcref(g->gc.gray, o); } -@@ -102,7 +115,8 @@ static void gc_mark_uv(global_State *g) +@@ -102,7 +116,8 @@ static void gc_mark_uv(global_State *g) { GCupval *uv; for (uv = uvnext(&g->uvhead); uv != &g->uvhead; uv = uvnext(uv)) { @@ -24311,7 +24346,7 @@ index 2aaf5b2c..2fc52ec1 100644 if (isgray(obj2gco(uv))) gc_marktv(g, uvval(uv)); } -@@ -197,7 +211,7 @@ static int gc_traverse_tab(global_State *g, GCtab *t) +@@ -197,7 +212,7 @@ static int gc_traverse_tab(global_State *g, GCtab *t) for (i = 0; i <= hmask; i++) { Node *n = &node[i]; if (!tvisnil(&n->val)) { /* Mark non-empty slot. */ @@ -24320,7 +24355,7 @@ index 2aaf5b2c..2fc52ec1 100644 if (!(weak & LJ_GC_WEAKKEY)) gc_marktv(g, &n->key); if (!(weak & LJ_GC_WEAKVAL)) gc_marktv(g, &n->val); } -@@ -212,7 +226,8 @@ static void gc_traverse_func(global_State *g, GCfunc *fn) +@@ -212,7 +227,8 @@ static void gc_traverse_func(global_State *g, GCfunc *fn) gc_markobj(g, tabref(fn->c.env)); if (isluafunc(fn)) { uint32_t i; @@ -24330,7 +24365,7 @@ index 2aaf5b2c..2fc52ec1 100644 gc_markobj(g, funcproto(fn)); for (i = 0; i < fn->l.nupvalues; i++) /* Mark Lua function upvalues. */ gc_markobj(g, &gcref(fn->l.uvptr[i])->uv); -@@ -228,7 +243,7 @@ static void gc_traverse_func(global_State *g, GCfunc *fn) +@@ -228,7 +244,7 @@ static void gc_traverse_func(global_State *g, GCfunc *fn) static void gc_marktrace(global_State *g, TraceNo traceno) { GCobj *o = obj2gco(traceref(G2J(g), traceno)); @@ -24339,7 +24374,7 @@ index 2aaf5b2c..2fc52ec1 100644 if (iswhite(o)) { white2gray(o); setgcrefr(o->gch.gclist, g->gc.gray); -@@ -309,7 +324,7 @@ static size_t propagatemark(global_State *g) +@@ -309,7 +325,7 @@ static size_t propagatemark(global_State *g) { GCobj *o = gcref(g->gc.gray); int gct = o->gch.gct; @@ -24348,7 +24383,7 @@ index 2aaf5b2c..2fc52ec1 100644 gray2black(o); setgcrefr(g->gc.gray, o->gch.gclist); /* Remove from gray list. */ if (LJ_LIKELY(gct == ~LJ_TTAB)) { -@@ -341,7 +356,7 @@ static size_t propagatemark(global_State *g) +@@ -341,7 +357,7 @@ static size_t propagatemark(global_State *g) return ((sizeof(GCtrace)+7)&~7) + (T->nins-T->nk)*sizeof(IRIns) + T->nsnap*sizeof(SnapShot) + T->nsnapmap*sizeof(SnapEntry); #else @@ -24357,7 +24392,7 @@ index 2aaf5b2c..2fc52ec1 100644 return 0; #endif } -@@ -395,11 +410,13 @@ static GCRef *gc_sweep(global_State *g, GCRef *p, uint32_t lim) +@@ -395,11 +411,13 @@ static GCRef *gc_sweep(global_State *g, GCRef *p, uint32_t lim) if (o->gch.gct == ~LJ_TTHREAD) /* Need to sweep open upvalues, too. */ gc_fullsweep(g, &gco2th(o)->openupval); if (((o->gch.marked ^ LJ_GC_WHITES) & ow)) { /* Black or current white? */ @@ -24373,7 +24408,7 @@ index 2aaf5b2c..2fc52ec1 100644 setgcrefr(*p, o->gch.nextgc); if (o == gcref(g->gc.root)) setgcrefr(g->gc.root, o->gch.nextgc); /* Adjust list anchor. */ -@@ -409,6 +426,32 @@ static GCRef *gc_sweep(global_State *g, GCRef *p, uint32_t lim) +@@ -409,6 +427,32 @@ static GCRef *gc_sweep(global_State *g, GCRef *p, uint32_t lim) return p; } @@ -24406,7 +24441,7 @@ index 2aaf5b2c..2fc52ec1 100644 /* Check whether we can clear a key or a value slot from a table. */ static int gc_mayclear(cTValue *o, int val) { -@@ -426,11 +469,12 @@ static int gc_mayclear(cTValue *o, int val) +@@ -426,11 +470,12 @@ static int gc_mayclear(cTValue *o, int val) } /* Clear collected entries from weak tables. */ @@ -24421,7 +24456,7 @@ index 2aaf5b2c..2fc52ec1 100644 if ((t->marked & LJ_GC_WEAKVAL)) { MSize i, asize = t->asize; for (i = 0; i < asize; i++) { -@@ -466,6 +510,7 @@ static void gc_call_finalizer(global_State *g, lua_State *L, +@@ -466,6 +511,7 @@ static void gc_call_finalizer(global_State *g, lua_State *L, TValue *top; lj_trace_abort(g); hook_entergc(g); /* Disable hooks and new traces during __gc. */ @@ -24429,15 +24464,25 @@ index 2aaf5b2c..2fc52ec1 100644 g->gc.threshold = LJ_MAX_MEM; /* Prevent GC steps. */ top = L->top; copyTV(L, top++, mo); -@@ -474,6 +519,7 @@ static void gc_call_finalizer(global_State *g, lua_State *L, +@@ -474,9 +520,15 @@ static void gc_call_finalizer(global_State *g, lua_State *L, L->top = top+1; errcode = lj_vm_pcall(L, top, 1+0, -1); /* Stack: |mo|o| -> | */ hook_restore(g, oldh); + if (LJ_HASPROFILE && (oldh & HOOK_PROFILE)) lj_dispatch_update(g); g->gc.threshold = oldt; /* Restore GC threshold. */ - if (errcode) - lj_err_throw(L, errcode); /* Propagate errors. */ -@@ -485,7 +531,7 @@ static void gc_finalize(lua_State *L) +- if (errcode) +- lj_err_throw(L, errcode); /* Propagate errors. */ ++ 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)); ++ ); ++ L->top--; ++ } + } + + /* Finalize one userdata or cdata object from the mmudata list. */ +@@ -485,7 +537,7 @@ static void gc_finalize(lua_State *L) global_State *g = G(L); GCobj *o = gcnext(gcref(g->gc.mmudata)); cTValue *mo; @@ -24446,7 +24491,7 @@ index 2aaf5b2c..2fc52ec1 100644 /* Unchain from list of userdata to be finalized. */ if (o == gcref(g->gc.mmudata)) setgcrefnull(g->gc.mmudata); -@@ -560,9 +606,9 @@ void lj_gc_freeall(global_State *g) +@@ -560,9 +612,9 @@ void lj_gc_freeall(global_State *g) /* Free everything, except super-fixed objects (the main thread). */ g->gc.currentwhite = LJ_GC_WHITES | LJ_GC_SFIXED; gc_fullsweep(g, &g->gc.root); @@ -24458,7 +24503,7 @@ index 2aaf5b2c..2fc52ec1 100644 } /* -- Collector ----------------------------------------------------------- */ -@@ -577,7 +623,7 @@ static void atomic(global_State *g, lua_State *L) +@@ -577,7 +629,7 @@ static void atomic(global_State *g, lua_State *L) setgcrefr(g->gc.gray, g->gc.weak); /* Empty the list of weak tables. */ setgcrefnull(g->gc.weak); @@ -24467,7 +24512,7 @@ index 2aaf5b2c..2fc52ec1 100644 gc_markobj(g, L); /* Mark running thread. */ gc_traverse_curtrace(g); /* Traverse current trace. */ gc_mark_gcroot(g); /* Mark GC roots (again). */ -@@ -592,7 +638,7 @@ static void atomic(global_State *g, lua_State *L) +@@ -592,7 +644,7 @@ static void atomic(global_State *g, lua_State *L) udsize += gc_propagate_gray(g); /* And propagate the marks. */ /* All marking done, clear weak tables. */ @@ -24476,7 +24521,7 @@ index 2aaf5b2c..2fc52ec1 100644 lj_buf_shrink(L, &g->tmpbuf); /* Shrink temp buffer. */ -@@ -625,21 +671,21 @@ static size_t gc_onestep(lua_State *L) +@@ -625,21 +677,21 @@ static size_t gc_onestep(lua_State *L) return 0; case GCSsweepstring: { GCSize old = g->gc.total; @@ -24504,7 +24549,7 @@ index 2aaf5b2c..2fc52ec1 100644 if (gcref(g->gc.mmudata)) { /* Need any finalizations? */ g->gc.state = GCSfinalize; #if LJ_HASFFI -@@ -654,9 +700,12 @@ static size_t gc_onestep(lua_State *L) +@@ -654,9 +706,12 @@ static size_t gc_onestep(lua_State *L) } case GCSfinalize: if (gcref(g->gc.mmudata) != NULL) { @@ -24517,7 +24562,7 @@ index 2aaf5b2c..2fc52ec1 100644 if (g->gc.estimate > GCFINALIZECOST) g->gc.estimate -= GCFINALIZECOST; return GCFINALIZECOST; -@@ -668,7 +717,7 @@ static size_t gc_onestep(lua_State *L) +@@ -668,7 +723,7 @@ static size_t gc_onestep(lua_State *L) g->gc.debt = 0; return 0; default: @@ -24526,7 +24571,7 @@ index 2aaf5b2c..2fc52ec1 100644 return 0; } } -@@ -742,7 +791,8 @@ void lj_gc_fullgc(lua_State *L) +@@ -742,7 +797,8 @@ void lj_gc_fullgc(lua_State *L) } while (g->gc.state == GCSsweepstring || g->gc.state == GCSsweep) gc_onestep(L); /* Finish sweep. */ @@ -24536,7 +24581,7 @@ index 2aaf5b2c..2fc52ec1 100644 /* Now perform a full GC. */ g->gc.state = GCSpause; do { gc_onestep(L); } while (g->gc.state != GCSpause); -@@ -755,9 +805,11 @@ void lj_gc_fullgc(lua_State *L) +@@ -755,9 +811,11 @@ void lj_gc_fullgc(lua_State *L) /* Move the GC propagation frontier forward. */ void lj_gc_barrierf(global_State *g, GCobj *o, GCobj *v) { @@ -24551,7 +24596,7 @@ index 2aaf5b2c..2fc52ec1 100644 /* Preserve invariant during propagation. Otherwise it doesn't matter. */ if (g->gc.state == GCSpropagate || g->gc.state == GCSatomic) gc_mark(g, v); /* Move frontier forward. */ -@@ -794,7 +846,8 @@ void lj_gc_closeuv(global_State *g, GCupval *uv) +@@ -794,7 +852,8 @@ void lj_gc_closeuv(global_State *g, GCupval *uv) lj_gc_barrierf(g, o, gcV(&uv->tv)); } else { makewhite(g, o); /* Make it white, i.e. sweep the upvalue. */ @@ -24561,7 +24606,7 @@ index 2aaf5b2c..2fc52ec1 100644 } } } -@@ -814,12 +867,13 @@ void lj_gc_barriertrace(global_State *g, uint32_t traceno) +@@ -814,12 +873,13 @@ void lj_gc_barriertrace(global_State *g, uint32_t traceno) void *lj_mem_realloc(lua_State *L, void *p, GCSize osz, GCSize nsz) { global_State *g = G(L); @@ -24578,7 +24623,7 @@ index 2aaf5b2c..2fc52ec1 100644 g->gc.total = (g->gc.total - osz) + nsz; return p; } -@@ -831,7 +885,8 @@ void * LJ_FASTCALL lj_mem_newgco(lua_State *L, GCSize size) +@@ -831,7 +891,8 @@ void * LJ_FASTCALL lj_mem_newgco(lua_State *L, GCSize size) GCobj *o = (GCobj *)g->allocf(g->allocd, NULL, 0, size); if (o == NULL) lj_err_mem(L); @@ -27600,7 +27645,7 @@ index 04c6d06d..ee3ee049 100644 J->guardemit.irt = 0; lj_ir_rollback(J, ins); diff --git a/src/lj_opt_mem.c b/src/lj_opt_mem.c -index cc177d39..09de2f05 100644 +index cc177d39..455b0ca6 100644 --- a/src/lj_opt_mem.c +++ b/src/lj_opt_mem.c @@ -3,7 +3,7 @@ @@ -27687,7 +27732,7 @@ index cc177d39..09de2f05 100644 if (!irt_sametype(keya->t, keyb->t)) return ALIAS_NO; /* Different key types. */ } -@@ -152,7 +182,8 @@ static TRef fwd_ahload(jit_State *J, IRRef xref) +@@ -152,9 +182,11 @@ static TRef fwd_ahload(jit_State *J, IRRef xref) IRIns *ir = (xr->o == IR_HREFK || xr->o == IR_AREF) ? IR(xr->op1) : xr; IRRef tab = ir->op1; ir = IR(tab); @@ -27696,8 +27741,23 @@ index cc177d39..09de2f05 100644 + fwd_aa_tab_clear(J, tab, tab)) { /* A NEWREF with a number key may end up pointing to the array part. ** But it's referenced from HSTORE and not found in the ASTORE chain. ++ ** Or a NEWREF may rehash the table and move unrelated number keys. ** For now simply consider this a conflict without forwarding anything. -@@ -180,7 +211,8 @@ static TRef fwd_ahload(jit_State *J, IRRef xref) + */ + if (xr->o == IR_AREF) { +@@ -165,6 +197,11 @@ static TRef fwd_ahload(jit_State *J, IRRef xref) + goto cselim; + ref2 = newref->prev; + } ++ } else { ++ IRIns *key = IR(xr->op2); ++ if (key->o == IR_KSLOT) key = IR(key->op1); ++ if (irt_isnum(key->t) && J->chain[IR_NEWREF] > tab) ++ goto cselim; + } + /* NEWREF inhibits CSE for HREF, and dependent FLOADs from HREFK/AREF. + ** But the above search for conflicting stores was limited by xref. +@@ -180,7 +217,8 @@ static TRef fwd_ahload(jit_State *J, IRRef xref) } ref = store->prev; } @@ -27707,7 +27767,7 @@ index cc177d39..09de2f05 100644 if (irt_ispri(fins->t)) { return TREF_PRI(irt_type(fins->t)); } else if (irt_isnum(fins->t) || (LJ_DUALNUM && irt_isint(fins->t)) || -@@ -191,7 +223,8 @@ static TRef fwd_ahload(jit_State *J, IRRef xref) +@@ -191,7 +229,8 @@ static TRef fwd_ahload(jit_State *J, IRRef xref) if (key->o == IR_KSLOT) key = IR(key->op1); lj_ir_kvalue(J->L, &keyv, key); tv = lj_tab_get(J->L, ir_ktab(IR(ir->op1)), &keyv); @@ -27717,7 +27777,7 @@ index cc177d39..09de2f05 100644 if (irt_isnum(fins->t)) return lj_ir_knum_u64(J, tv->u64); else if (LJ_DUALNUM && irt_isint(fins->t)) -@@ -265,7 +298,7 @@ TRef LJ_FASTCALL lj_opt_fwd_hrefk(jit_State *J) +@@ -265,7 +304,7 @@ TRef LJ_FASTCALL lj_opt_fwd_hrefk(jit_State *J) while (ref > tab) { IRIns *newref = IR(ref); if (tab == newref->op1) { @@ -27726,7 +27786,7 @@ index cc177d39..09de2f05 100644 return ref; /* Forward from NEWREF. */ else goto docse; -@@ -275,7 +308,7 @@ TRef LJ_FASTCALL lj_opt_fwd_hrefk(jit_State *J) +@@ -275,7 +314,7 @@ TRef LJ_FASTCALL lj_opt_fwd_hrefk(jit_State *J) ref = newref->prev; } /* No conflicting NEWREF: key location unchanged for HREFK of TDUP. */ @@ -27735,7 +27795,7 @@ index cc177d39..09de2f05 100644 fins->t.irt &= ~IRT_GUARD; /* Drop HREFK guard. */ docse: return CSEFOLD; -@@ -309,34 +342,6 @@ int LJ_FASTCALL lj_opt_fwd_href_nokey(jit_State *J) +@@ -309,34 +348,6 @@ int LJ_FASTCALL lj_opt_fwd_href_nokey(jit_State *J) return 1; /* No conflict. Can fold to niltv. */ } @@ -27770,7 +27830,7 @@ index cc177d39..09de2f05 100644 /* ASTORE/HSTORE elimination. */ TRef LJ_FASTCALL lj_opt_dse_ahstore(jit_State *J) { -@@ -360,16 +365,16 @@ TRef LJ_FASTCALL lj_opt_dse_ahstore(jit_State *J) +@@ -360,16 +371,16 @@ TRef LJ_FASTCALL lj_opt_dse_ahstore(jit_State *J) /* Different value: try to eliminate the redundant store. */ if (ref > J->chain[IR_LOOP]) { /* Quick check to avoid crossing LOOP. */ IRIns *ir; @@ -27793,7 +27853,7 @@ index cc177d39..09de2f05 100644 /* Now emit the new store instead. */ } goto doemit; -@@ -380,6 +385,67 @@ doemit: +@@ -380,6 +391,67 @@ doemit: return EMITFOLD; /* Otherwise we have a conflict or simply no match. */ } @@ -27861,7 +27921,7 @@ index cc177d39..09de2f05 100644 /* -- ULOAD forwarding ---------------------------------------------------- */ /* The current alias analysis for upvalues is very simplistic. It only -@@ -429,7 +495,6 @@ TRef LJ_FASTCALL lj_opt_fwd_uload(jit_State *J) +@@ -429,7 +501,6 @@ TRef LJ_FASTCALL lj_opt_fwd_uload(jit_State *J) cselim: /* Try to find a matching load. Below the conflicting store, if any. */ @@ -27869,7 +27929,7 @@ index cc177d39..09de2f05 100644 ref = J->chain[IR_ULOAD]; while (ref > lim) { IRIns *ir = IR(ref); -@@ -470,10 +535,7 @@ TRef LJ_FASTCALL lj_opt_dse_ustore(jit_State *J) +@@ -470,10 +541,7 @@ TRef LJ_FASTCALL lj_opt_dse_ustore(jit_State *J) goto doemit; /* No elimination possible. */ /* Remove redundant store from chain and replace with NOP. */ *refp = store->prev; @@ -27881,7 +27941,7 @@ index cc177d39..09de2f05 100644 if (ref+1 < J->cur.nins && store[1].o == IR_OBAR && store[1].op1 == xref) { IRRef1 *bp = &J->chain[IR_OBAR]; -@@ -482,10 +544,7 @@ TRef LJ_FASTCALL lj_opt_dse_ustore(jit_State *J) +@@ -482,10 +550,7 @@ TRef LJ_FASTCALL lj_opt_dse_ustore(jit_State *J) bp = &obar->prev; /* Remove OBAR, too. */ *bp = obar->prev; @@ -27893,7 +27953,7 @@ index cc177d39..09de2f05 100644 } /* Now emit the new store instead. */ } -@@ -565,8 +624,9 @@ TRef LJ_FASTCALL lj_opt_dse_fstore(jit_State *J) +@@ -565,8 +630,9 @@ TRef LJ_FASTCALL lj_opt_dse_fstore(jit_State *J) goto doemit; break; /* Otherwise continue searching. */ case ALIAS_MUST: @@ -27905,7 +27965,7 @@ index cc177d39..09de2f05 100644 /* Different value: try to eliminate the redundant store. */ if (ref > J->chain[IR_LOOP]) { /* Quick check to avoid crossing LOOP. */ IRIns *ir; -@@ -576,10 +636,7 @@ TRef LJ_FASTCALL lj_opt_dse_fstore(jit_State *J) +@@ -576,10 +642,7 @@ TRef LJ_FASTCALL lj_opt_dse_fstore(jit_State *J) goto doemit; /* No elimination possible. */ /* Remove redundant store from chain and replace with NOP. */ *refp = store->prev; @@ -27917,7 +27977,7 @@ index cc177d39..09de2f05 100644 /* Now emit the new store instead. */ } goto doemit; -@@ -590,6 +647,29 @@ doemit: +@@ -590,6 +653,29 @@ doemit: return EMITFOLD; /* Otherwise we have a conflict or simply no match. */ } @@ -27947,7 +28007,7 @@ index cc177d39..09de2f05 100644 /* -- XLOAD forwarding and XSTORE elimination ----------------------------- */ /* Find cdata allocation for a reference (if any). */ -@@ -830,10 +910,7 @@ TRef LJ_FASTCALL lj_opt_dse_xstore(jit_State *J) +@@ -830,10 +916,7 @@ TRef LJ_FASTCALL lj_opt_dse_xstore(jit_State *J) goto doemit; /* No elimination possible. */ /* Remove redundant store from chain and replace with NOP. */ *refp = store->prev; @@ -27959,7 +28019,7 @@ index cc177d39..09de2f05 100644 /* Now emit the new store instead. */ } goto doemit; -@@ -844,39 +921,6 @@ doemit: +@@ -844,39 +927,6 @@ doemit: return EMITFOLD; /* Otherwise we have a conflict or simply no match. */ } @@ -29246,7 +29306,7 @@ index 0cccfd78..3969f8e8 100644 #ifndef _LJ_PROFILE_H diff --git a/src/lj_record.c b/src/lj_record.c -index 9d0469c4..79ee6172 100644 +index 9d0469c4..b2639cbc 100644 --- a/src/lj_record.c +++ b/src/lj_record.c @@ -1,6 +1,6 @@ @@ -29778,7 +29838,7 @@ index 9d0469c4..79ee6172 100644 /* Otherwise retry lookup with metaobject. */ ix->tab = ix->mobj; copyTV(J->L, &ix->tabv, &ix->mobjv); -@@ -1464,10 +1592,10 @@ TRef lj_record_idx(jit_State *J, RecordIndex *ix) +@@ -1464,14 +1592,16 @@ TRef lj_record_idx(jit_State *J, RecordIndex *ix) emitir(IRTG(oldv == niltvg(J2G(J)) ? IR_EQ : IR_NE, IRT_PGC), xref, lj_ir_kkptr(J, niltvg(J2G(J)))); if (ix->idxchain && lj_record_mm_lookup(J, ix, MM_newindex)) { @@ -29791,7 +29851,13 @@ index 9d0469c4..79ee6172 100644 if (oldv == niltvg(J2G(J))) { /* Need to insert a new key. */ TRef key = ix->key; if (tref_isinteger(key)) /* NEWREF needs a TValue as a key. */ -@@ -1512,6 +1640,47 @@ TRef lj_record_idx(jit_State *J, RecordIndex *ix) + key = emitir(IRTN(IR_CONV), key, IRCONV_NUM_INT); ++ else if (tref_isnumber(key) && tref_isk(key) && tvismzero(&ix->keyv)) ++ key = lj_ir_knum_zero(J); /* Canonicalize -0.0 to +0.0. */ + xref = emitir(IRT(IR_NEWREF, IRT_PGC), ix->tab, key); + keybarrier = 0; /* NEWREF already takes care of the key barrier. */ + #ifdef LUAJIT_ENABLE_TABLE_BUMP +@@ -1512,6 +1642,47 @@ TRef lj_record_idx(jit_State *J, RecordIndex *ix) } } @@ -29839,7 +29905,7 @@ index 9d0469c4..79ee6172 100644 static void rec_tsetm(jit_State *J, BCReg ra, BCReg rn, int32_t i) { RecordIndex ix; -@@ -1573,7 +1742,7 @@ static TRef rec_upvalue(jit_State *J, uint32_t uv, TRef val) +@@ -1573,7 +1744,7 @@ static TRef rec_upvalue(jit_State *J, uint32_t uv, TRef val) int needbarrier = 0; if (rec_upvalue_constify(J, uvp)) { /* Try to constify immutable upvalue. */ TRef tr, kfunc; @@ -29848,7 +29914,7 @@ index 9d0469c4..79ee6172 100644 if (!tref_isk(fn)) { /* Late specialization of current function. */ if (J->pt->flags >= PROTO_CLC_POLY) goto noconstify; -@@ -1667,7 +1836,7 @@ static void check_call_unroll(jit_State *J, TraceNo lnk) +@@ -1667,7 +1838,7 @@ static void check_call_unroll(jit_State *J, TraceNo lnk) if (lnk) { /* Possible tail- or up-recursion. */ lj_trace_flush(J, lnk); /* Flush trace that only returns. */ /* Set a small, pseudo-random hotcount for a quick retry of JFUNC*. */ @@ -29857,7 +29923,7 @@ index 9d0469c4..79ee6172 100644 } lj_trace_err(J, LJ_TRERR_CUNROLL); } -@@ -1695,7 +1864,7 @@ static void rec_func_vararg(jit_State *J) +@@ -1695,7 +1866,7 @@ static void rec_func_vararg(jit_State *J) { GCproto *pt = J->pt; BCReg s, fixargs, vframe = J->maxslot+1+LJ_FR2; @@ -29866,7 +29932,7 @@ index 9d0469c4..79ee6172 100644 if (J->baseslot + vframe + pt->framesize >= LJ_MAX_JSLOTS) lj_trace_err(J, LJ_TRERR_STACKOV); J->base[vframe-1-LJ_FR2] = J->base[-1-LJ_FR2]; /* Copy function up. */ -@@ -1764,7 +1933,7 @@ static void rec_varg(jit_State *J, BCReg dst, ptrdiff_t nresults) +@@ -1764,7 +1935,7 @@ static void rec_varg(jit_State *J, BCReg dst, ptrdiff_t nresults) { int32_t numparams = J->pt->numparams; ptrdiff_t nvararg = frame_delta(J->L->base-1) - numparams - 1 - LJ_FR2; @@ -29875,7 +29941,7 @@ index 9d0469c4..79ee6172 100644 if (LJ_FR2 && dst > J->maxslot) J->base[dst-1] = 0; /* Prevent resurrection of unrelated slot. */ if (J->framedepth > 0) { /* Simple case: varargs defined on-trace. */ -@@ -1776,6 +1945,8 @@ static void rec_varg(jit_State *J, BCReg dst, ptrdiff_t nresults) +@@ -1776,6 +1947,8 @@ static void rec_varg(jit_State *J, BCReg dst, ptrdiff_t nresults) } else if (dst + nresults > J->maxslot) { J->maxslot = dst + (BCReg)nresults; } @@ -29884,7 +29950,7 @@ index 9d0469c4..79ee6172 100644 for (i = 0; i < nresults; i++) J->base[dst+i] = i < nvararg ? getslot(J, i - nvararg - 1 - LJ_FR2) : TREF_NIL; } else { /* Unknown number of varargs passed to trace. */ -@@ -1792,14 +1963,10 @@ static void rec_varg(jit_State *J, BCReg dst, ptrdiff_t nresults) +@@ -1792,14 +1965,10 @@ static void rec_varg(jit_State *J, BCReg dst, ptrdiff_t nresults) emitir(IRTGI(IR_EQ), fr, lj_ir_kint(J, (int32_t)frame_ftsz(J->L->base-1))); vbase = emitir(IRT(IR_SUB, IRT_IGC), REF_BASE, fr); @@ -29901,7 +29967,7 @@ index 9d0469c4..79ee6172 100644 } } else { emitir(IRTGI(IR_LE), fr, lj_ir_kint(J, frofs)); -@@ -1846,8 +2013,7 @@ static void rec_varg(jit_State *J, BCReg dst, ptrdiff_t nresults) +@@ -1846,8 +2015,7 @@ static void rec_varg(jit_State *J, BCReg dst, ptrdiff_t nresults) lj_ir_kint(J, frofs-(8<L->base[idx-2-LJ_FR2-nvararg]); aref = emitir(IRT(IR_AREF, IRT_PGC), vbase, tridx); @@ -29911,7 +29977,7 @@ index 9d0469c4..79ee6172 100644 } J->base[dst-2-LJ_FR2] = tr; J->maxslot = dst-1-LJ_FR2; -@@ -1882,10 +2048,10 @@ static TRef rec_tnew(jit_State *J, uint32_t ah) +@@ -1882,10 +2050,10 @@ static TRef rec_tnew(jit_State *J, uint32_t ah) static TRef rec_cat(jit_State *J, BCReg baseslot, BCReg topslot) { TRef *top = &J->base[topslot]; @@ -29924,7 +29990,7 @@ index 9d0469c4..79ee6172 100644 for (s = baseslot; s <= topslot; s++) (void)getslot(J, s); /* Ensure all arguments have a reference. */ if (tref_isnumber_str(top[0]) && tref_isnumber_str(top[-1])) { -@@ -1902,9 +2068,9 @@ static TRef rec_cat(jit_State *J, BCReg baseslot, BCReg topslot) +@@ -1902,9 +2070,9 @@ static TRef rec_cat(jit_State *J, BCReg baseslot, BCReg topslot) tr = hdr = emitir(IRT(IR_BUFHDR, IRT_PGC), lj_ir_kptr(J, &J2G(J)->tmpbuf), IRBUFHDR_RESET); do { @@ -29936,7 +30002,7 @@ index 9d0469c4..79ee6172 100644 J->maxslot = (BCReg)(xbase - J->base); if (xbase == base) return tr; /* Return simple concatenation result. */ /* Pass partial result. */ -@@ -2009,7 +2175,7 @@ void lj_record_ins(jit_State *J) +@@ -2009,7 +2177,7 @@ void lj_record_ins(jit_State *J) if (bc_op(*J->pc) >= BC__MAX) return; break; @@ -29945,7 +30011,7 @@ index 9d0469c4..79ee6172 100644 } J->postproc = LJ_POST_NONE; } -@@ -2017,7 +2183,7 @@ void lj_record_ins(jit_State *J) +@@ -2017,7 +2185,7 @@ void lj_record_ins(jit_State *J) /* Need snapshot before recording next bytecode (e.g. after a store). */ if (J->needsnap) { J->needsnap = 0; @@ -29954,7 +30020,7 @@ index 9d0469c4..79ee6172 100644 lj_snap_add(J); J->mergesnap = 1; } -@@ -2072,6 +2238,7 @@ void lj_record_ins(jit_State *J) +@@ -2072,6 +2240,7 @@ void lj_record_ins(jit_State *J) case BCMpri: setpriV(rcv, ~rc); ix.key = rc = TREF_PRI(IRT_NIL+rc); break; case BCMnum: { cTValue *tv = proto_knumtv(J->pt, rc); copyTV(J->L, rcv, tv); ix.key = rc = tvisint(tv) ? lj_ir_kint(J, intV(tv)) : @@ -29962,7 +30028,7 @@ index 9d0469c4..79ee6172 100644 lj_ir_knumint(J, numV(tv)); } break; case BCMstr: { GCstr *s = gco2str(proto_kgc(J->pt, ~(ptrdiff_t)rc)); setstrV(J->L, rcv, s); ix.key = rc = lj_ir_kstr(J, s); } break; -@@ -2187,7 +2354,7 @@ void lj_record_ins(jit_State *J) +@@ -2187,7 +2356,7 @@ void lj_record_ins(jit_State *J) if (tref_isstr(rc)) rc = emitir(IRTI(IR_FLOAD), rc, IRFL_STR_LEN); else if (!LJ_52 && tref_istab(rc)) @@ -29971,7 +30037,7 @@ index 9d0469c4..79ee6172 100644 else rc = rec_mm_len(J, rc, rcv); break; -@@ -2234,7 +2401,7 @@ void lj_record_ins(jit_State *J) +@@ -2234,7 +2403,7 @@ void lj_record_ins(jit_State *J) case BC_POW: if (tref_isnumber_str(rb) && tref_isnumber_str(rc)) @@ -29980,7 +30046,7 @@ index 9d0469c4..79ee6172 100644 else rc = rec_mm_arith(J, &ix, MM_pow); break; -@@ -2377,7 +2544,8 @@ void lj_record_ins(jit_State *J) +@@ -2377,7 +2546,8 @@ void lj_record_ins(jit_State *J) J->loopref = J->cur.nins; break; case BC_JFORI: @@ -29990,7 +30056,7 @@ index 9d0469c4..79ee6172 100644 if (rec_for(J, pc, 0) != LOOPEV_LEAVE) /* Link to existing loop. */ lj_record_stop(J, LJ_TRLINK_ROOT, bc_d(pc[(ptrdiff_t)rc-BCBIAS_J])); /* Continue tracing if the loop is not entered. */ -@@ -2389,8 +2557,11 @@ void lj_record_ins(jit_State *J) +@@ -2389,8 +2559,11 @@ void lj_record_ins(jit_State *J) case BC_ITERL: rec_loop_interp(J, pc, rec_iterl(J, *pc)); break; @@ -30003,7 +30069,7 @@ index 9d0469c4..79ee6172 100644 break; case BC_JFORL: -@@ -2400,7 +2571,9 @@ void lj_record_ins(jit_State *J) +@@ -2400,7 +2573,9 @@ void lj_record_ins(jit_State *J) rec_loop_jit(J, rc, rec_iterl(J, traceref(J, rc)->startins)); break; case BC_JLOOP: @@ -30014,7 +30080,7 @@ index 9d0469c4..79ee6172 100644 break; case BC_IFORL: -@@ -2416,6 +2589,10 @@ void lj_record_ins(jit_State *J) +@@ -2416,6 +2591,10 @@ void lj_record_ins(jit_State *J) J->maxslot = ra; /* Shrink used slots. */ break; @@ -30025,7 +30091,7 @@ index 9d0469c4..79ee6172 100644 /* -- Function headers -------------------------------------------------- */ case BC_FUNCF: -@@ -2430,7 +2607,8 @@ void lj_record_ins(jit_State *J) +@@ -2430,7 +2609,8 @@ void lj_record_ins(jit_State *J) rec_func_lua(J); break; case BC_JFUNCV: @@ -30035,7 +30101,7 @@ index 9d0469c4..79ee6172 100644 break; case BC_FUNCC: -@@ -2444,8 +2622,6 @@ void lj_record_ins(jit_State *J) +@@ -2444,8 +2624,6 @@ void lj_record_ins(jit_State *J) break; } /* fallthrough */ @@ -30044,7 +30110,7 @@ index 9d0469c4..79ee6172 100644 case BC_UCLO: case BC_FNEW: setintV(&J->errinfo, (int32_t)op); -@@ -2468,8 +2644,9 @@ void lj_record_ins(jit_State *J) +@@ -2468,8 +2646,9 @@ void lj_record_ins(jit_State *J) #undef rbv #undef rcv @@ -30056,7 +30122,7 @@ index 9d0469c4..79ee6172 100644 lj_trace_err(J, LJ_TRERR_TRACEOV); } -@@ -2489,13 +2666,22 @@ static const BCIns *rec_setup_root(jit_State *J) +@@ -2489,13 +2668,22 @@ static const BCIns *rec_setup_root(jit_State *J) J->bc_min = pc; break; case BC_ITERL: @@ -30081,7 +30147,7 @@ index 9d0469c4..79ee6172 100644 case BC_LOOP: /* Only check BC range for real loops, but not for "repeat until true". */ pcj = pc + bc_j(ins); -@@ -2525,7 +2711,7 @@ static const BCIns *rec_setup_root(jit_State *J) +@@ -2525,7 +2713,7 @@ static const BCIns *rec_setup_root(jit_State *J) pc++; break; default: @@ -30090,7 +30156,7 @@ index 9d0469c4..79ee6172 100644 break; } return pc; -@@ -2592,9 +2778,14 @@ void lj_record_setup(jit_State *J) +@@ -2592,9 +2780,14 @@ void lj_record_setup(jit_State *J) } lj_snap_replay(J, T); sidecheck: @@ -30108,7 +30174,7 @@ index 9d0469c4..79ee6172 100644 lj_record_stop(J, LJ_TRLINK_INTERP, 0); } } else { /* Root trace. */ -@@ -2603,6 +2794,7 @@ void lj_record_setup(jit_State *J) +@@ -2603,6 +2796,7 @@ void lj_record_setup(jit_State *J) J->pc = rec_setup_root(J); /* Note: the loop instruction itself is recorded at the end and not ** at the start! So snapshot #0 needs to point to the *next* instruction. @@ -33932,7 +33998,7 @@ index 86640804..c8491d82 100644 #include diff --git a/src/lj_vmevent.h b/src/lj_vmevent.h -index 050fb4dd..40f9c631 100644 +index 050fb4dd..c08a26dc 100644 --- a/src/lj_vmevent.h +++ b/src/lj_vmevent.h @@ -1,6 +1,6 @@ @@ -33943,6 +34009,20 @@ index 050fb4dd..40f9c631 100644 */ #ifndef _LJ_VMEVENT_H +@@ -24,9 +24,10 @@ + /* VM event IDs. */ + typedef enum { + VMEVENT_DEF(BC, 0x00003883), +- VMEVENT_DEF(TRACE, 0xb2d91467), +- VMEVENT_DEF(RECORD, 0x9284bf4f), +- VMEVENT_DEF(TEXIT, 0xb29df2b0), ++ VMEVENT_DEF(TRACE, 0x12d91467), ++ VMEVENT_DEF(RECORD, 0x1284bf4f), ++ VMEVENT_DEF(TEXIT, 0x129df2b0), ++ VMEVENT_DEF(ERRFIN, 0x12d93888), + LJ_VMEVENT__MAX + } VMEvent; + diff --git a/src/lj_vmmath.c b/src/lj_vmmath.c index b231d3e8..4fa79ae4 100644 --- a/src/lj_vmmath.c @@ -34618,101 +34698,135 @@ index e4a7defe..034e2c87 100644 @if "%1" neq "debug" goto :NODEBUG @shift -diff --git a/src/ps4build.bat b/src/ps5build.bat -similarity index 76% -copy from src/ps4build.bat -copy to src/ps5build.bat -index e4a7defe..56818c2e 100644 ---- a/src/ps4build.bat +diff --git a/src/ps5build.bat b/src/ps5build.bat +new file mode 100644 +index 00000000..56818c2e +--- /dev/null +++ b/src/ps5build.bat -@@ -1,15 +1,15 @@ --@rem Script to build LuaJIT with the PS4 SDK. +@@ -0,0 +1,123 @@ +@rem Script to build LuaJIT with the PS5 SDK. - @rem Donated to the public domain. - @rem - @rem Open a "Visual Studio .NET Command Prompt" (64 bit host compiler) --@rem or "VS2015 x64 Native Tools Command Prompt". ++@rem Donated to the public domain. ++@rem ++@rem Open a "Visual Studio .NET Command Prompt" (64 bit host compiler) +@rem or "VS20xx x64 Native Tools Command Prompt". - @rem - @rem Then cd to this directory and run this script. - @rem - @rem Recommended invocation: - @rem --@rem ps4build release build, amalgamated, 64-bit GC --@rem ps4build debug debug build, amalgamated, 64-bit GC ++@rem ++@rem Then cd to this directory and run this script. ++@rem ++@rem Recommended invocation: ++@rem +@rem ps5build release build, amalgamated, 64-bit GC +@rem ps5build debug debug build, amalgamated, 64-bit GC - @rem - @rem Additional command-line options (not generally recommended): - @rem -@@ -17,7 +17,7 @@ - @rem noamalg (after debug) non-amalgamated build - - @if not defined INCLUDE goto :FAIL --@if not defined SCE_ORBIS_SDK_DIR goto :FAIL ++@rem ++@rem Additional command-line options (not generally recommended): ++@rem ++@rem gc32 (before debug) 32-bit GC ++@rem noamalg (after debug) non-amalgamated build ++ ++@if not defined INCLUDE goto :FAIL +@if not defined SCE_PROSPERO_SDK_DIR goto :FAIL - - @setlocal - @rem ---- Host compiler ---- -@@ -26,13 +26,13 @@ - @set LJMT=mt /nologo - @set DASMDIR=..\dynasm - @set DASM=%DASMDIR%\dynasm.lua --@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 --@set GC64=-DLUAJIT_ENABLE_GC64 ++ ++@setlocal ++@rem ---- Host compiler ---- ++@set LJCOMPILE=cl /nologo /c /MD /O2 /W3 /D_CRT_SECURE_NO_DEPRECATE ++@set LJLINK=link /nologo ++@set LJMT=mt /nologo ++@set DASMDIR=..\dynasm ++@set DASM=%DASMDIR%\dynasm.lua +@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 +@set GC64= - @set DASC=vm_x64.dasc - - @if "%1" neq "gc32" goto :NOGC32 - @shift --@set GC64= ++@set DASC=vm_x64.dasc ++ ++@if "%1" neq "gc32" goto :NOGC32 ++@shift +@set GC64=-DLUAJIT_DISABLE_GC64 - @set DASC=vm_x86.dasc - :NOGC32 - -@@ -74,20 +74,20 @@ buildvm -m folddef -o lj_folddef.h lj_opt_fold.c - @if errorlevel 1 goto :BAD - - @rem ---- Cross compiler ---- --@set LJCOMPILE="%SCE_ORBIS_SDK_DIR%\host_tools\bin\orbis-clang" -c -Wall -DLUAJIT_DISABLE_FFI %GC64% --@set LJLIB="%SCE_ORBIS_SDK_DIR%\host_tools\bin\orbis-ar" rcus ++@set DASC=vm_x86.dasc ++:NOGC32 ++ ++%LJCOMPILE% host\minilua.c ++@if errorlevel 1 goto :BAD ++%LJLINK% /out:minilua.exe minilua.obj ++@if errorlevel 1 goto :BAD ++if exist minilua.exe.manifest^ ++ %LJMT% -manifest minilua.exe.manifest -outputresource:minilua.exe ++ ++@rem Check for 64 bit host compiler. ++@minilua ++@if not errorlevel 8 goto :FAIL ++ ++@set DASMFLAGS=-D P64 -D NO_UNWIND ++minilua %DASM% -LN %DASMFLAGS% -o host\buildvm_arch.h %DASC% ++@if errorlevel 1 goto :BAD ++ ++%LJCOMPILE% /I "." /I %DASMDIR% %GC64% -DLUAJIT_TARGET=LUAJIT_ARCH_X64 -DLUAJIT_OS=LUAJIT_OS_OTHER -DLUAJIT_DISABLE_JIT -DLUAJIT_DISABLE_FFI -DLUAJIT_NO_UNWIND host\buildvm*.c ++@if errorlevel 1 goto :BAD ++%LJLINK% /out:buildvm.exe buildvm*.obj ++@if errorlevel 1 goto :BAD ++if exist buildvm.exe.manifest^ ++ %LJMT% -manifest buildvm.exe.manifest -outputresource:buildvm.exe ++ ++buildvm -m elfasm -o lj_vm.s ++@if errorlevel 1 goto :BAD ++buildvm -m bcdef -o lj_bcdef.h %ALL_LIB% ++@if errorlevel 1 goto :BAD ++buildvm -m ffdef -o lj_ffdef.h %ALL_LIB% ++@if errorlevel 1 goto :BAD ++buildvm -m libdef -o lj_libdef.h %ALL_LIB% ++@if errorlevel 1 goto :BAD ++buildvm -m recdef -o lj_recdef.h %ALL_LIB% ++@if errorlevel 1 goto :BAD ++buildvm -m vmdef -o jit\vmdef.lua %ALL_LIB% ++@if errorlevel 1 goto :BAD ++buildvm -m folddef -o lj_folddef.h lj_opt_fold.c ++@if errorlevel 1 goto :BAD ++ ++@rem ---- Cross compiler ---- +@set LJCOMPILE="%SCE_PROSPERO_SDK_DIR%\host_tools\bin\prospero-clang" -c -Wall -DLUAJIT_DISABLE_FFI -DLUAJIT_USE_SYSMALLOC %GC64% +@set LJLIB="%SCE_PROSPERO_SDK_DIR%\host_tools\bin\prospero-llvm-ar" rcus - @set INCLUDE="" - --orbis-as -o lj_vm.o lj_vm.s ++@set INCLUDE="" ++ +"%SCE_PROSPERO_SDK_DIR%\host_tools\bin\prospero-clang" -c -o lj_vm.o lj_vm.s - - @if "%1" neq "debug" goto :NODEBUG - @shift - @set LJCOMPILE=%LJCOMPILE% -g -O0 --@set TARGETLIB=libluajitD_ps4.a ++ ++@if "%1" neq "debug" goto :NODEBUG ++@shift ++@set LJCOMPILE=%LJCOMPILE% -g -O0 +@set TARGETLIB=libluajitD_ps5.a - goto :BUILD - :NODEBUG - @set LJCOMPILE=%LJCOMPILE% -O2 --@set TARGETLIB=libluajit_ps4.a ++goto :BUILD ++:NODEBUG ++@set LJCOMPILE=%LJCOMPILE% -O2 +@set TARGETLIB=libluajit_ps5.a - :BUILD - del %TARGETLIB% - @if "%1" neq "noamalg" goto :AMALG -@@ -108,7 +108,7 @@ for %%f in (lj_*.c lib_*.c) do ( - - @del *.o *.obj *.manifest minilua.exe buildvm.exe - @echo. --@echo === Successfully built LuaJIT for PS4 === ++:BUILD ++del %TARGETLIB% ++@if "%1" neq "noamalg" goto :AMALG ++for %%f in (lj_*.c lib_*.c) do ( ++ %LJCOMPILE% %%f ++ @if errorlevel 1 goto :BAD ++) ++ ++%LJLIB% %TARGETLIB% lj_*.o lib_*.o ++@if errorlevel 1 goto :BAD ++@goto :NOAMALG ++:AMALG ++%LJCOMPILE% ljamalg.c ++@if errorlevel 1 goto :BAD ++%LJLIB% %TARGETLIB% ljamalg.o lj_vm.o ++@if errorlevel 1 goto :BAD ++:NOAMALG ++ ++@del *.o *.obj *.manifest minilua.exe buildvm.exe ++@echo. +@echo === Successfully built LuaJIT for PS5 === - - @goto :END - :BAD -@@ -119,5 +119,5 @@ for %%f in (lj_*.c lib_*.c) do ( - @goto :END - :FAIL - @echo To run this script you must open a "Visual Studio .NET Command Prompt" --@echo (64 bit host compiler). The PS4 Orbis SDK must be installed, too. ++ ++@goto :END ++:BAD ++@echo. ++@echo ******************************************************* ++@echo *** Build FAILED -- Please check the error messages *** ++@echo ******************************************************* ++@goto :END ++:FAIL ++@echo To run this script you must open a "Visual Studio .NET Command Prompt" +@echo (64 bit host compiler). The PS5 Prospero SDK must be installed, too. - :END ++:END diff --git a/src/psvitabuild.bat b/src/psvitabuild.bat index 3991dc65..2980e157 100644 --- a/src/psvitabuild.bat diff --git a/luajit.spec b/luajit.spec index c9209b4664f0f6b7ab6e8ac2a7aa87343e38b1fd..8fa93c3b2b2c72ba0785dbf32a068cdaa121374d 100644 --- a/luajit.spec +++ b/luajit.spec @@ -2,7 +2,7 @@ Name: luajit Version: 2.1.0 -Release: 5 +Release: 6 Summary: Just-In-Time Compiler for Lua License: MIT URL: http://luajit.org/ @@ -10,7 +10,7 @@ Source0: http://luajit.org/download/LuaJIT-2.1.0-beta3.tar.gz # Patches from https://github.com/LuaJit/LuaJIT.git # Generated from v2.1 branch against the 2.1.0-beta3 tag using # git diff v2.1.0-beta3..v2.1 > luajit-2.1-update.patch -Patch0001: luajit-2.1-update.patch +Patch0001: luajit-2.1-224129a-update.patch Patch0002: 0002-luajit-add-secure-compile-option-fstack.patch ExclusiveArch: %{arm} %{ix86} x86_64 %{mips} aarch64 @@ -76,6 +76,9 @@ ln -s luajit-2.1.0-beta3 %{buildroot}%{_bindir}/luajit %{_mandir}/man1/%{name}.1* %changelog +* Mon May 15 2023 xu_ping <707078654@qq.com> - 2.1.0-6 +- Update upstream commit + * Fri Mar 24 2023 liyanan - 2.1.0-5 - Round upstream commit