Skip to content

Commit e296f56

Browse files
author
Mike Pall
committed
Call error function on rethrow after trace exit.
1 parent 12ab596 commit e296f56

9 files changed

+11
-15
lines changed

src/lj_debug.c

+1
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ static BCPos debug_framepc(lua_State *L, GCfunc *fn, cTValue *nextframe)
9494
}
9595
}
9696
ins = cframe_pc(cf);
97+
if (!ins) return NO_BCPOS;
9798
}
9899
}
99100
pt = funcproto(fn);

src/lj_dispatch.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
_(floor) _(ceil) _(trunc) _(log) _(log10) _(exp) _(sin) _(cos) _(tan) \
3030
_(asin) _(acos) _(atan) _(sinh) _(cosh) _(tanh) _(frexp) _(modf) _(atan2) \
3131
_(pow) _(fmod) _(ldexp) \
32-
_(lj_dispatch_call) _(lj_dispatch_ins) _(lj_err_throw) \
32+
_(lj_dispatch_call) _(lj_dispatch_ins) _(lj_err_throw) _(lj_err_run) \
3333
_(lj_ffh_coroutine_wrap_err) _(lj_func_closeuv) _(lj_func_newL_gc) \
3434
_(lj_gc_barrieruv) _(lj_gc_step) _(lj_gc_step_fixtop) _(lj_meta_arith) \
3535
_(lj_meta_call) _(lj_meta_cat) _(lj_meta_comp) _(lj_meta_equal) \

src/lj_err.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ static ptrdiff_t finderrfunc(lua_State *L)
546546
}
547547

548548
/* Runtime error. */
549-
LJ_NOINLINE void lj_err_run(lua_State *L)
549+
LJ_NOINLINE void LJ_FASTCALL lj_err_run(lua_State *L)
550550
{
551551
ptrdiff_t ef = finderrfunc(L);
552552
if (ef) {

src/lj_err.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ LJ_DATA const char *lj_err_allmsg;
2323
LJ_FUNC GCstr *lj_err_str(lua_State *L, ErrMsg em);
2424
LJ_FUNCA_NORET void LJ_FASTCALL lj_err_throw(lua_State *L, int errcode);
2525
LJ_FUNC_NORET void lj_err_mem(lua_State *L);
26-
LJ_FUNC_NORET void lj_err_run(lua_State *L);
26+
LJ_FUNCA_NORET void LJ_FASTCALL lj_err_run(lua_State *L);
2727
LJ_FUNC_NORET void lj_err_msg(lua_State *L, ErrMsg em);
2828
LJ_FUNC_NORET void lj_err_lex(lua_State *L, GCstr *src, const char *tok,
2929
BCLine line, ErrMsg em, va_list argp);

src/lj_trace.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -700,8 +700,8 @@ typedef struct ExitDataCP {
700700
static TValue *trace_exit_cp(lua_State *L, lua_CFunction dummy, void *ud)
701701
{
702702
ExitDataCP *exd = (ExitDataCP *)ud;
703-
cframe_errfunc(L->cframe) = -1; /* Inherit error function. */
704-
/* Always catch error here. */
703+
/* Always catch error here and don't call error function. */
704+
cframe_errfunc(L->cframe) = 0;
705705
cframe_nres(L->cframe) = -2*LUAI_MAXSTACK*(int)sizeof(TValue);
706706
exd->pc = lj_snap_restore(exd->J, exd->exptr);
707707
UNUSED(dummy);

src/vm_arm.dasc

+1-2
Original file line numberDiff line numberDiff line change
@@ -2201,9 +2201,8 @@ static void build_subroutines(BuildCtx *ctx)
22012201
| bx OP
22022202
|
22032203
|3: // Rethrow error from the right C frame.
2204-
| rsb CARG2, CARG1, #0
22052204
| mov CARG1, L
2206-
| bl extern lj_err_throw // (lua_State *L, int errcode)
2205+
| bl extern lj_err_run // (lua_State *L)
22072206
|.endif
22082207
|
22092208
|//-----------------------------------------------------------------------

src/vm_mips.dasc

+2-3
Original file line numberDiff line numberDiff line change
@@ -2163,9 +2163,8 @@ static void build_subroutines(BuildCtx *ctx)
21632163
|. addu RA, RA, BASE
21642164
|
21652165
|3: // Rethrow error from the right C frame.
2166-
| load_got lj_err_throw
2167-
| negu CARG2, CRET1
2168-
| call_intern lj_err_throw // (lua_State *L, int errcode)
2166+
| load_got lj_err_run
2167+
| call_intern lj_err_run // (lua_State *L)
21692168
|. move CARG1, L
21702169
|.endif
21712170
|

src/vm_ppc.dasc

+1-2
Original file line numberDiff line numberDiff line change
@@ -2699,9 +2699,8 @@ static void build_subroutines(BuildCtx *ctx)
26992699
| bctr
27002700
|
27012701
|3: // Rethrow error from the right C frame.
2702-
| neg CARG2, CARG1
27032702
| mr CARG1, L
2704-
| bl extern lj_err_throw // (lua_State *L, int errcode)
2703+
| bl extern lj_err_run // (lua_State *L)
27052704
|.endif
27062705
|
27072706
|//-----------------------------------------------------------------------

src/vm_x86.dasc

+1-3
Original file line numberDiff line numberDiff line change
@@ -3060,10 +3060,8 @@ static void build_subroutines(BuildCtx *ctx)
30603060
|.endif
30613061
|
30623062
|3: // Rethrow error from the right C frame.
3063-
| neg RD
30643063
| mov FCARG1, L:RB
3065-
| mov FCARG2, RD
3066-
| call extern lj_err_throw@8 // (lua_State *L, int errcode)
3064+
| call extern lj_err_run@4 // (lua_State *L)
30673065
|.endif
30683066
|
30693067
|//-----------------------------------------------------------------------

0 commit comments

Comments
 (0)