]> git.ipfire.org Git - thirdparty/LuaJIT.git/commitdiff
Call error function on rethrow after trace exit.
authorMike Pall <mike>
Sun, 9 Aug 2020 20:50:31 +0000 (22:50 +0200)
committerMike Pall <mike>
Sun, 9 Aug 2020 20:50:31 +0000 (22:50 +0200)
src/lj_debug.c
src/lj_dispatch.h
src/lj_err.c
src/lj_err.h
src/lj_trace.c
src/vm_arm.dasc
src/vm_mips.dasc
src/vm_ppc.dasc
src/vm_x86.dasc

index 1d73da7eaf217ba3fbaf685538ea63c29a942fbe..6863cffdb8345a95c10f3cf830831fed1321b010 100644 (file)
@@ -94,6 +94,7 @@ static BCPos debug_framepc(lua_State *L, GCfunc *fn, cTValue *nextframe)
        }
       }
       ins = cframe_pc(cf);
+      if (!ins) return NO_BCPOS;
     }
   }
   pt = funcproto(fn);
index 6a3bc2bd157cc3cfef263c4a5ba5d57a13485ec2..372de01449b2cc928b97374eeeedd121bc5bf75f 100644 (file)
@@ -29,7 +29,7 @@
   _(floor) _(ceil) _(trunc) _(log) _(log10) _(exp) _(sin) _(cos) _(tan) \
   _(asin) _(acos) _(atan) _(sinh) _(cosh) _(tanh) _(frexp) _(modf) _(atan2) \
   _(pow) _(fmod) _(ldexp) \
-  _(lj_dispatch_call) _(lj_dispatch_ins) _(lj_err_throw) \
+  _(lj_dispatch_call) _(lj_dispatch_ins) _(lj_err_throw) _(lj_err_run) \
   _(lj_ffh_coroutine_wrap_err) _(lj_func_closeuv) _(lj_func_newL_gc) \
   _(lj_gc_barrieruv) _(lj_gc_step) _(lj_gc_step_fixtop) _(lj_meta_arith) \
   _(lj_meta_call) _(lj_meta_cat) _(lj_meta_comp) _(lj_meta_equal) \
index e3e0c2eb7ea83ece77abd144a5dccf0fa35a808d..ad3394dfed428676156df3c960d81dade8c9146b 100644 (file)
@@ -546,7 +546,7 @@ static ptrdiff_t finderrfunc(lua_State *L)
 }
 
 /* Runtime error. */
-LJ_NOINLINE void lj_err_run(lua_State *L)
+LJ_NOINLINE void LJ_FASTCALL lj_err_run(lua_State *L)
 {
   ptrdiff_t ef = finderrfunc(L);
   if (ef) {
index ed148d797c925a13261c448556021ff281071158..4ae637d463140bf876862556513469a5a0879605 100644 (file)
@@ -23,7 +23,7 @@ LJ_DATA const char *lj_err_allmsg;
 LJ_FUNC GCstr *lj_err_str(lua_State *L, ErrMsg em);
 LJ_FUNCA_NORET void LJ_FASTCALL lj_err_throw(lua_State *L, int errcode);
 LJ_FUNC_NORET void lj_err_mem(lua_State *L);
-LJ_FUNC_NORET void lj_err_run(lua_State *L);
+LJ_FUNCA_NORET void LJ_FASTCALL lj_err_run(lua_State *L);
 LJ_FUNC_NORET void lj_err_msg(lua_State *L, ErrMsg em);
 LJ_FUNC_NORET void lj_err_lex(lua_State *L, GCstr *src, const char *tok,
                              BCLine line, ErrMsg em, va_list argp);
index 123e6eb838d1fb143cdec5e00b357414c575c4e1..c7f3f52dbebf3ba4c2de0674f18c0b8b3fc045b6 100644 (file)
@@ -700,8 +700,8 @@ typedef struct ExitDataCP {
 static TValue *trace_exit_cp(lua_State *L, lua_CFunction dummy, void *ud)
 {
   ExitDataCP *exd = (ExitDataCP *)ud;
-  cframe_errfunc(L->cframe) = -1;  /* Inherit error function. */
-  /* Always catch error here. */
+  /* Always catch error here and don't call error function. */
+  cframe_errfunc(L->cframe) = 0;
   cframe_nres(L->cframe) = -2*LUAI_MAXSTACK*(int)sizeof(TValue);
   exd->pc = lj_snap_restore(exd->J, exd->exptr);
   UNUSED(dummy);
index c5e0498e4acc7d27aa7ab76c3a1ac7e86177562c..dcfb10b3e8d90fd388cbfceb79d33cc9e44ba4f6 100644 (file)
@@ -2201,9 +2201,8 @@ static void build_subroutines(BuildCtx *ctx)
   |  bx OP
   |
   |3:  // Rethrow error from the right C frame.
-  |  rsb CARG2, CARG1, #0
   |  mov CARG1, L
-  |  bl extern lj_err_throw            // (lua_State *L, int errcode)
+  |  bl extern lj_err_run              // (lua_State *L)
   |.endif
   |
   |//-----------------------------------------------------------------------
index e6b53e0df59290191f57f8e7da4b2e5f9712c425..6bbad37b740c676daee38dd52e922b1d9267aaec 100644 (file)
@@ -2163,9 +2163,8 @@ static void build_subroutines(BuildCtx *ctx)
   |.  addu RA, RA, BASE
   |
   |3:  // Rethrow error from the right C frame.
-  |  load_got lj_err_throw
-  |  negu CARG2, CRET1
-  |  call_intern lj_err_throw          // (lua_State *L, int errcode)
+  |  load_got lj_err_run
+  |  call_intern lj_err_run            // (lua_State *L)
   |.  move CARG1, L
   |.endif
   |
index 6b973d4ec248a340f6ca01fe3aca6d8d6248c63b..de44027b1360a479ce2bcdbf512e24eb7a3e11cc 100644 (file)
@@ -2699,9 +2699,8 @@ static void build_subroutines(BuildCtx *ctx)
   |  bctr
   |
   |3:  // Rethrow error from the right C frame.
-  |  neg CARG2, CARG1
   |  mr CARG1, L
-  |  bl extern lj_err_throw            // (lua_State *L, int errcode)
+  |  bl extern lj_err_run              // (lua_State *L)
   |.endif
   |
   |//-----------------------------------------------------------------------
index 2ccc671fd542dcfe26850930a07dbe899a9941da..b23d046b76472cfdf8a1cc55c9cc9fa998c75289 100644 (file)
@@ -3060,10 +3060,8 @@ static void build_subroutines(BuildCtx *ctx)
   |.endif
   |
   |3:  // Rethrow error from the right C frame.
-  |  neg RD
   |  mov FCARG1, L:RB
-  |  mov FCARG2, RD
-  |  call extern lj_err_throw@8                // (lua_State *L, int errcode)
+  |  call extern lj_err_run@4          // (lua_State *L)
   |.endif
   |
   |//-----------------------------------------------------------------------