diff options
| author | Mike Pall <mike> | 2023-09-21 02:23:25 +0200 |
|---|---|---|
| committer | Mike Pall <mike> | 2023-09-21 02:23:25 +0200 |
| commit | 4b605a7da85f4c82d40f54635d1880e1d858c785 (patch) | |
| tree | 582a0cf3506df08766990a56757be1fb28733fe3 /src | |
| parent | e897c5743f97a6b05c59852709092e7da4119914 (diff) | |
| parent | b138ccfa918518a152bc830fef3d53cd0a922e36 (diff) | |
| download | luajit-4b605a7da85f4c82d40f54635d1880e1d858c785.tar.gz luajit-4b605a7da85f4c82d40f54635d1880e1d858c785.tar.bz2 luajit-4b605a7da85f4c82d40f54635d1880e1d858c785.zip | |
Merge branch 'master' into v2.1
Diffstat (limited to 'src')
| -rw-r--r-- | src/lj_record.c | 5 | ||||
| -rw-r--r-- | src/lj_state.c | 15 | ||||
| -rw-r--r-- | src/lj_trace.c | 26 |
3 files changed, 31 insertions, 15 deletions
diff --git a/src/lj_record.c b/src/lj_record.c index 134fad83..7a970628 100644 --- a/src/lj_record.c +++ b/src/lj_record.c | |||
| @@ -1991,8 +1991,11 @@ static void rec_varg(jit_State *J, BCReg dst, ptrdiff_t nresults) | |||
| 1991 | TRef tr = TREF_NIL; | 1991 | TRef tr = TREF_NIL; |
| 1992 | ptrdiff_t idx = lj_ffrecord_select_mode(J, tridx, &J->L->base[dst-1]); | 1992 | ptrdiff_t idx = lj_ffrecord_select_mode(J, tridx, &J->L->base[dst-1]); |
| 1993 | if (idx < 0) goto nyivarg; | 1993 | if (idx < 0) goto nyivarg; |
| 1994 | if (idx != 0 && !tref_isinteger(tridx)) | 1994 | if (idx != 0 && !tref_isinteger(tridx)) { |
| 1995 | if (tref_isstr(tridx)) | ||
| 1996 | tridx = emitir(IRTG(IR_STRTO, IRT_NUM), tridx, 0); | ||
| 1995 | tridx = emitir(IRTGI(IR_CONV), tridx, IRCONV_INT_NUM|IRCONV_INDEX); | 1997 | tridx = emitir(IRTGI(IR_CONV), tridx, IRCONV_INT_NUM|IRCONV_INDEX); |
| 1998 | } | ||
| 1996 | if (idx != 0 && tref_isk(tridx)) { | 1999 | if (idx != 0 && tref_isk(tridx)) { |
| 1997 | emitir(IRTGI(idx <= nvararg ? IR_GE : IR_LT), | 2000 | emitir(IRTGI(idx <= nvararg ? IR_GE : IR_LT), |
| 1998 | fr, lj_ir_kint(J, frofs+8*(int32_t)idx)); | 2001 | fr, lj_ir_kint(J, frofs+8*(int32_t)idx)); |
diff --git a/src/lj_state.c b/src/lj_state.c index b45a2043..6b3f58ff 100644 --- a/src/lj_state.c +++ b/src/lj_state.c | |||
| @@ -103,8 +103,17 @@ void lj_state_shrinkstack(lua_State *L, MSize used) | |||
| 103 | void LJ_FASTCALL lj_state_growstack(lua_State *L, MSize need) | 103 | void LJ_FASTCALL lj_state_growstack(lua_State *L, MSize need) |
| 104 | { | 104 | { |
| 105 | MSize n; | 105 | MSize n; |
| 106 | if (L->stacksize > LJ_STACK_MAXEX) /* Overflow while handling overflow? */ | 106 | if (L->stacksize >= LJ_STACK_MAXEX) { |
| 107 | lj_err_throw(L, LUA_ERRERR); | 107 | /* 4. Throw 'error in error handling' when we are _over_ the limit. */ |
| 108 | if (L->stacksize > LJ_STACK_MAXEX) | ||
| 109 | lj_err_throw(L, LUA_ERRERR); /* Does not invoke an error handler. */ | ||
| 110 | /* 1. We are _at_ the limit after the last growth. */ | ||
| 111 | if (!L->status) { /* 2. Throw 'stack overflow'. */ | ||
| 112 | L->status = LUA_ERRRUN; /* Prevent ending here again for pushed msg. */ | ||
| 113 | lj_err_msg(L, LJ_ERR_STKOV); /* May invoke an error handler. */ | ||
| 114 | } | ||
| 115 | /* 3. Add space (over the limit) for pushed message and error handler. */ | ||
| 116 | } | ||
| 108 | n = L->stacksize + need; | 117 | n = L->stacksize + need; |
| 109 | if (n > LJ_STACK_MAX) { | 118 | if (n > LJ_STACK_MAX) { |
| 110 | n += 2*LUA_MINSTACK; | 119 | n += 2*LUA_MINSTACK; |
| @@ -114,8 +123,6 @@ void LJ_FASTCALL lj_state_growstack(lua_State *L, MSize need) | |||
| 114 | n = LJ_STACK_MAX; | 123 | n = LJ_STACK_MAX; |
| 115 | } | 124 | } |
| 116 | resizestack(L, n); | 125 | resizestack(L, n); |
| 117 | if (L->stacksize >= LJ_STACK_MAXEX) | ||
| 118 | lj_err_msg(L, LJ_ERR_STKOV); | ||
| 119 | } | 126 | } |
| 120 | 127 | ||
| 121 | void LJ_FASTCALL lj_state_growstack1(lua_State *L) | 128 | void LJ_FASTCALL lj_state_growstack1(lua_State *L) |
diff --git a/src/lj_trace.c b/src/lj_trace.c index f311d54b..fee78e2e 100644 --- a/src/lj_trace.c +++ b/src/lj_trace.c | |||
| @@ -613,21 +613,27 @@ static int trace_abort(jit_State *J) | |||
| 613 | J->cur.link = 0; | 613 | J->cur.link = 0; |
| 614 | J->cur.linktype = LJ_TRLINK_NONE; | 614 | J->cur.linktype = LJ_TRLINK_NONE; |
| 615 | lj_vmevent_send(L, TRACE, | 615 | lj_vmevent_send(L, TRACE, |
| 616 | TValue *frame; | 616 | cTValue *bot = tvref(L->stack)+LJ_FR2; |
| 617 | cTValue *frame; | ||
| 617 | const BCIns *pc; | 618 | const BCIns *pc; |
| 618 | GCfunc *fn; | 619 | BCPos pos = 0; |
| 619 | setstrV(L, L->top++, lj_str_newlit(L, "abort")); | 620 | setstrV(L, L->top++, lj_str_newlit(L, "abort")); |
| 620 | setintV(L->top++, traceno); | 621 | setintV(L->top++, traceno); |
| 621 | /* Find original Lua function call to generate a better error message. */ | 622 | /* Find original Lua function call to generate a better error message. */ |
| 622 | frame = J->L->base-1; | 623 | for (frame = J->L->base-1, pc = J->pc; ; frame = frame_prev(frame)) { |
| 623 | pc = J->pc; | 624 | if (isluafunc(frame_func(frame))) { |
| 624 | while (!isluafunc(frame_func(frame))) { | 625 | pos = proto_bcpos(funcproto(frame_func(frame)), pc); |
| 625 | pc = (frame_iscont(frame) ? frame_contpc(frame) : frame_pc(frame)) - 1; | 626 | break; |
| 626 | frame = frame_prev(frame); | 627 | } else if (frame_prev(frame) <= bot) { |
| 628 | break; | ||
| 629 | } else if (frame_iscont(frame)) { | ||
| 630 | pc = frame_contpc(frame) - 1; | ||
| 631 | } else { | ||
| 632 | pc = frame_pc(frame) - 1; | ||
| 633 | } | ||
| 627 | } | 634 | } |
| 628 | fn = frame_func(frame); | 635 | setfuncV(L, L->top++, frame_func(frame)); |
| 629 | setfuncV(L, L->top++, fn); | 636 | setintV(L->top++, pos); |
| 630 | setintV(L->top++, proto_bcpos(funcproto(fn), pc)); | ||
| 631 | copyTV(L, L->top++, restorestack(L, errobj)); | 637 | copyTV(L, L->top++, restorestack(L, errobj)); |
| 632 | copyTV(L, L->top++, &J->errinfo); | 638 | copyTV(L, L->top++, &J->errinfo); |
| 633 | ); | 639 | ); |
