Merge branch 'master' into v2.1

This commit is contained in:
Mike Pall 2024-08-15 00:19:35 +02:00
commit 833600390c
4 changed files with 20 additions and 8 deletions

View File

@ -1935,9 +1935,10 @@ LJFOLDF(abc_k)
LJFOLD(ABC any any)
LJFOLDF(abc_invar)
{
/* Invariant ABC marked as PTR. Drop if op1 is invariant, too. */
/* Invariant ABC marked as P32 or U32. Drop if op1 is invariant too. */
if (!irt_isint(fins->t) && fins->op1 < J->chain[IR_LOOP] &&
!irt_isphi(IR(fins->op1)->t))
(irt_isu32(fins->t) ||
(!irref_isk(fins->op1) && !irt_isphi(IR(fins->op1)->t))))
return DROPFOLD;
return NEXTFOLD;
}
@ -2485,6 +2486,17 @@ LJFOLD(CNEW any any)
LJFOLD(XSNEW any any)
LJFOLDX(lj_ir_emit)
/* -- Miscellaneous ------------------------------------------------------- */
LJFOLD(CARG any any)
LJFOLDF(cse_carg)
{
TRef tr = lj_opt_cse(J);
if (tref_ref(tr) < J->chain[IR_LOOP]) /* CSE across loop? */
return EMITFOLD; /* Raw emit. Assumes fins is left intact by CSE. */
return tr;
}
/* ------------------------------------------------------------------------ */
/* Every entry in the generated hash table is a 32 bit pattern:

View File

@ -1395,12 +1395,13 @@ static void rec_idx_abc(jit_State *J, TRef asizeref, TRef ikey, uint32_t asize)
/* Runtime value for stop of loop is within bounds? */
if ((uint64_t)stop + ofs < (uint64_t)asize) {
/* Emit invariant bounds check for stop. */
emitir(IRTG(IR_ABC, IRT_P32), asizeref, ofs == 0 ? J->scev.stop :
uint32_t abc = IRTG(IR_ABC, tref_isk(asizeref) ? IRT_U32 : IRT_P32);
emitir(abc, asizeref, ofs == 0 ? J->scev.stop :
emitir(IRTI(IR_ADD), J->scev.stop, ofsref));
/* Emit invariant bounds check for start, if not const or negative. */
if (!(J->scev.dir && J->scev.start &&
(int64_t)IR(J->scev.start)->i + ofs >= 0))
emitir(IRTG(IR_ABC, IRT_P32), asizeref, ikey);
emitir(abc, asizeref, ikey);
return;
}
}

View File

@ -957,7 +957,8 @@ const BCIns *lj_snap_restore(jit_State *J, void *exptr)
lua_State *L = J->L;
/* Set interpreter PC to the next PC to get correct error messages. */
setcframe_pc(cframe_raw(L->cframe), pc+1);
setcframe_pc(L->cframe, pc+1);
setcframe_pc(cframe_raw(cframe_prev(L->cframe)), pc);
/* Make sure the stack is big enough for the slots from the snapshot. */
if (LJ_UNLIKELY(L->base + snap->topslot >= tvref(L->maxstack))) {

View File

@ -905,10 +905,8 @@ int LJ_FASTCALL lj_trace_exit(jit_State *J, void *exptr)
exd.J = J;
exd.exptr = exptr;
errcode = lj_vm_cpcall(L, NULL, &exd, trace_exit_cp);
if (errcode) {
setcframe_pc(cframe_raw(L->cframe), L); /* Point to any valid memory. */
if (errcode)
return -errcode; /* Return negated error code. */
}
if (exitcode) copyTV(L, L->top++, &exiterr); /* Anchor the error object. */