Merge branch 'master' into v2.1

This commit is contained in:
Mike Pall 2023-09-21 02:23:25 +02:00
commit 4b605a7da8
3 changed files with 31 additions and 15 deletions

View File

@ -1991,8 +1991,11 @@ static void rec_varg(jit_State *J, BCReg dst, ptrdiff_t nresults)
TRef tr = TREF_NIL; TRef tr = TREF_NIL;
ptrdiff_t idx = lj_ffrecord_select_mode(J, tridx, &J->L->base[dst-1]); ptrdiff_t idx = lj_ffrecord_select_mode(J, tridx, &J->L->base[dst-1]);
if (idx < 0) goto nyivarg; if (idx < 0) goto nyivarg;
if (idx != 0 && !tref_isinteger(tridx)) if (idx != 0 && !tref_isinteger(tridx)) {
if (tref_isstr(tridx))
tridx = emitir(IRTG(IR_STRTO, IRT_NUM), tridx, 0);
tridx = emitir(IRTGI(IR_CONV), tridx, IRCONV_INT_NUM|IRCONV_INDEX); tridx = emitir(IRTGI(IR_CONV), tridx, IRCONV_INT_NUM|IRCONV_INDEX);
}
if (idx != 0 && tref_isk(tridx)) { if (idx != 0 && tref_isk(tridx)) {
emitir(IRTGI(idx <= nvararg ? IR_GE : IR_LT), emitir(IRTGI(idx <= nvararg ? IR_GE : IR_LT),
fr, lj_ir_kint(J, frofs+8*(int32_t)idx)); fr, lj_ir_kint(J, frofs+8*(int32_t)idx));

View File

@ -103,8 +103,17 @@ void lj_state_shrinkstack(lua_State *L, MSize used)
void LJ_FASTCALL lj_state_growstack(lua_State *L, MSize need) void LJ_FASTCALL lj_state_growstack(lua_State *L, MSize need)
{ {
MSize n; MSize n;
if (L->stacksize > LJ_STACK_MAXEX) /* Overflow while handling overflow? */ if (L->stacksize >= LJ_STACK_MAXEX) {
lj_err_throw(L, LUA_ERRERR); /* 4. Throw 'error in error handling' when we are _over_ the limit. */
if (L->stacksize > LJ_STACK_MAXEX)
lj_err_throw(L, LUA_ERRERR); /* Does not invoke an error handler. */
/* 1. We are _at_ the limit after the last growth. */
if (!L->status) { /* 2. Throw 'stack overflow'. */
L->status = LUA_ERRRUN; /* Prevent ending here again for pushed msg. */
lj_err_msg(L, LJ_ERR_STKOV); /* May invoke an error handler. */
}
/* 3. Add space (over the limit) for pushed message and error handler. */
}
n = L->stacksize + need; n = L->stacksize + need;
if (n > LJ_STACK_MAX) { if (n > LJ_STACK_MAX) {
n += 2*LUA_MINSTACK; n += 2*LUA_MINSTACK;
@ -114,8 +123,6 @@ void LJ_FASTCALL lj_state_growstack(lua_State *L, MSize need)
n = LJ_STACK_MAX; n = LJ_STACK_MAX;
} }
resizestack(L, n); resizestack(L, n);
if (L->stacksize >= LJ_STACK_MAXEX)
lj_err_msg(L, LJ_ERR_STKOV);
} }
void LJ_FASTCALL lj_state_growstack1(lua_State *L) void LJ_FASTCALL lj_state_growstack1(lua_State *L)

View File

@ -613,21 +613,27 @@ static int trace_abort(jit_State *J)
J->cur.link = 0; J->cur.link = 0;
J->cur.linktype = LJ_TRLINK_NONE; J->cur.linktype = LJ_TRLINK_NONE;
lj_vmevent_send(L, TRACE, lj_vmevent_send(L, TRACE,
TValue *frame; cTValue *bot = tvref(L->stack)+LJ_FR2;
cTValue *frame;
const BCIns *pc; const BCIns *pc;
GCfunc *fn; BCPos pos = 0;
setstrV(L, L->top++, lj_str_newlit(L, "abort")); setstrV(L, L->top++, lj_str_newlit(L, "abort"));
setintV(L->top++, traceno); setintV(L->top++, traceno);
/* Find original Lua function call to generate a better error message. */ /* Find original Lua function call to generate a better error message. */
frame = J->L->base-1; for (frame = J->L->base-1, pc = J->pc; ; frame = frame_prev(frame)) {
pc = J->pc; if (isluafunc(frame_func(frame))) {
while (!isluafunc(frame_func(frame))) { pos = proto_bcpos(funcproto(frame_func(frame)), pc);
pc = (frame_iscont(frame) ? frame_contpc(frame) : frame_pc(frame)) - 1; break;
frame = frame_prev(frame); } else if (frame_prev(frame) <= bot) {
break;
} else if (frame_iscont(frame)) {
pc = frame_contpc(frame) - 1;
} else {
pc = frame_pc(frame) - 1;
}
} }
fn = frame_func(frame); setfuncV(L, L->top++, frame_func(frame));
setfuncV(L, L->top++, fn); setintV(L->top++, pos);
setintV(L->top++, proto_bcpos(funcproto(fn), pc));
copyTV(L, L->top++, restorestack(L, errobj)); copyTV(L, L->top++, restorestack(L, errobj));
copyTV(L, L->top++, &J->errinfo); copyTV(L, L->top++, &J->errinfo);
); );