diff --git a/src/bluajit/jit/p.lua b/src/bluajit/jit/p.lua index 36f836c51..ef2ee82f5 100644 --- a/src/bluajit/jit/p.lua +++ b/src/bluajit/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/src/bluajit/lib_bit.c b/src/bluajit/lib_bit.c index ce40e2983..ada9614d0 100644 --- a/src/bluajit/lib_bit.c +++ b/src/bluajit/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/src/bluajit/lj_asm.c b/src/bluajit/lj_asm.c index 844910ad9..c31dd1dec 100644 --- a/src/bluajit/lj_asm.c +++ b/src/bluajit/lj_asm.c @@ -949,11 +949,11 @@ static int asm_sunk_store(ASMState *as, IRIns *ira, IRIns *irs) static void asm_snap_alloc1(ASMState *as, IRRef ref) { IRIns *ir = IR(ref); - if (!irref_isk(ref) && ir->r != RID_SUNK) { + if (!irref_isk(ref)) { bloomset(as->snapfilt1, ref); bloomset(as->snapfilt2, hashrot(ref, ref + HASH_BIAS)); if (ra_used(ir)) return; - if (ir->r == RID_SINK) { + if (ir->r == RID_SINK || ir->r == RID_SUNK) { ir->r = RID_SUNK; #if LJ_HASFFI if (ir->o == IR_CNEWI) { /* Allocate CNEWI value. */ diff --git a/src/bluajit/lj_bcread.c b/src/bluajit/lj_bcread.c index 637ef0679..54f483c71 100644 --- a/src/bluajit/lj_bcread.c +++ b/src/bluajit/lj_bcread.c @@ -408,7 +408,7 @@ static int bcread_header(LexState *ls) #endif } if ((flags & BCDUMP_F_STRIP)) { - ls->chunkname = lj_str_newz(ls->L, ls->chunkarg); + ls->chunkname = lj_str_newz(ls->L, *ls->chunkarg == BCDUMP_HEAD1 ? "=?" : ls->chunkarg); } else { MSize len = bcread_uleb128(ls); bcread_need(ls, len); diff --git a/src/bluajit/lj_record.c b/src/bluajit/lj_record.c index 28c725d10..81c4f2635 100644 --- a/src/bluajit/lj_record.c +++ b/src/bluajit/lj_record.c @@ -2084,25 +2084,19 @@ static TRef rec_tnew(jit_State *J, uint32_t ah) typedef struct RecCatDataCP { jit_State *J; - RecordIndex *ix; + BCReg baseslot, topslot; + TRef tr; } RecCatDataCP; static TValue *rec_mm_concat_cp(lua_State *L, lua_CFunction dummy, void *ud) { RecCatDataCP *rcd = (RecCatDataCP *)ud; - UNUSED(L); UNUSED(dummy); - rec_mm_arith(rcd->J, rcd->ix, MM_concat); /* Call __concat metamethod. */ - return NULL; -} - -static TRef rec_cat(jit_State *J, BCReg baseslot, BCReg topslot) -{ + jit_State *J = rcd->J; + BCReg baseslot = rcd->baseslot, topslot = rcd->topslot; TRef *top = &J->base[topslot]; - TValue savetv[5+LJ_FR2]; BCReg s; RecordIndex ix; - RecCatDataCP rcd; - int errcode; + UNUSED(L); UNUSED(dummy); lj_assertJ(baseslot < topslot, "bad CAT arg"); for (s = baseslot; s <= topslot; s++) (void)getslot(J, s); /* Ensure all arguments have a reference. */ @@ -2124,7 +2118,10 @@ static TRef rec_cat(jit_State *J, BCReg baseslot, BCReg topslot) } while (trp <= top); tr = emitir(IRTG(IR_BUFSTR, IRT_STR), tr, hdr); J->maxslot = (BCReg)(xbase - J->base); - if (xbase == base) return tr; /* Return simple concatenation result. */ + if (xbase == base) { + rcd->tr = tr; /* Return simple concatenation result. */ + return NULL; + } /* Pass partial result. */ topslot = J->maxslot--; *xbase = tr; @@ -2137,13 +2134,31 @@ static TRef rec_cat(jit_State *J, BCReg baseslot, BCReg topslot) copyTV(J->L, &ix.tabv, &J->L->base[topslot-1]); ix.tab = top[-1]; ix.key = top[0]; - memcpy(savetv, &J->L->base[topslot-1], sizeof(savetv)); /* Save slots. */ + rec_mm_arith(J, &ix, MM_concat); /* Call __concat metamethod. */ + rcd->tr = 0; /* No result yet. */ + return NULL; +} + +static TRef rec_cat(jit_State *J, BCReg baseslot, BCReg topslot) +{ + lua_State *L = J->L; + ptrdiff_t delta = L->top - L->base; + TValue savetv[5+LJ_FR2], errobj; + RecCatDataCP rcd; + int errcode; rcd.J = J; - rcd.ix = &ix; - errcode = lj_vm_cpcall(J->L, NULL, &rcd, rec_mm_concat_cp); - memcpy(&J->L->base[topslot-1], savetv, sizeof(savetv)); /* Restore slots. */ - if (errcode) return (TRef)(-errcode); - return 0; /* No result yet. */ + rcd.baseslot = baseslot; + rcd.topslot = topslot; + memcpy(savetv, &L->base[topslot-1], sizeof(savetv)); /* Save slots. */ + errcode = lj_vm_cpcall(L, NULL, &rcd, rec_mm_concat_cp); + if (errcode) copyTV(L, &errobj, L->top-1); + memcpy(&L->base[topslot-1], savetv, sizeof(savetv)); /* Restore slots. */ + if (errcode) { + L->top = L->base + delta; + copyTV(L, L->top++, &errobj); + return (TRef)(-errcode); + } + return rcd.tr; } /* -- Record bytecode ops ------------------------------------------------- */ diff --git a/src/bluajit/lj_tab.c b/src/bluajit/lj_tab.c index 535a69f5d..869c5f03c 100644 --- a/src/bluajit/lj_tab.c +++ b/src/bluajit/lj_tab.c @@ -635,7 +635,7 @@ LJ_NOINLINE static MSize tab_len_slow(GCtab *t, size_t hi) while ((tv = lj_tab_getint(t, (int32_t)hi)) && !tvisnil(tv)) { lo = hi; hi += hi; - if (hi > (size_t)(INT_MAX-2)) { /* Punt and do a linear search. */ + if (hi > (size_t)(0x7fffffff - 2)) { /* Punt and do a linear search. */ lo = 1; while ((tv = lj_tab_getint(t, (int32_t)lo)) && !tvisnil(tv)) lo++; return (MSize)(lo - 1); diff --git a/src/bluajit/luaconf.h b/src/bluajit/luaconf.h index 669ca8cb1..f59cc1b5f 100644 --- a/src/bluajit/luaconf.h +++ b/src/bluajit/luaconf.h @@ -9,7 +9,6 @@ #ifndef WINVER #define WINVER 0x0501 #endif -#include #include /* Default path for loading Lua and C modules with require(). */ diff --git a/src/bluajit/vm_mips64.dasc b/src/bluajit/vm_mips64.dasc index a8d204137..1f0118ecf 100644 --- a/src/bluajit/vm_mips64.dasc +++ b/src/bluajit/vm_mips64.dasc @@ -1420,9 +1420,10 @@ static void build_subroutines(BuildCtx *ctx) | sltu AT, TMP1, TMP2 | bnez AT, ->fff_fallback |. lbu TMP3, DISPATCH_GL(hookmask)(DISPATCH) - | daddiu NARGS8:RC, NARGS8:RC, -8 - | bltz NARGS8:RC, ->fff_fallback + | daddiu NARGS8:TMP0, NARGS8:RC, -8 + | bltz NARGS8:TMP0, ->fff_fallback |. move TMP2, BASE + | move NARGS8:RC, NARGS8:TMP0 | daddiu BASE, BASE, 16 | // Remember active hook before pcall. | srl TMP3, TMP3, HOOK_ACTIVE_SHIFT