From dea5c9e1dc60891391ee9170f9952e7c9d53273e Mon Sep 17 00:00:00 2001 From: dearblue Date: Sun, 5 May 2024 21:30:18 +0900 Subject: [PATCH] Remove `exc_caught` from `mrb_vm_exec()` Only go to exception handling if `mrb->exc` is non-null. This may cause some compatibility problems, but I doubt that it is necessary to maintain that compatibility. Here is how I see the incompatibility with the change at this time: - If `mrb->exc` is non-null and `mrb_vm_exec()` is called, an exception will be thrown immediately. - If `MRB_THROW()` is used while `mrb->exc` is `NULL`, it will not go to exception handling. --- src/vm.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/vm.c b/src/vm.c index 6e2b65a5d..1b94ee5e1 100644 --- a/src/vm.c +++ b/src/vm.c @@ -1432,15 +1432,13 @@ mrb_vm_exec(mrb_state *mrb, const struct RProc *proc, const mrb_code *pc) }; #endif - volatile mrb_bool exc_caught = FALSE; RETRY_TRY_BLOCK: MRB_TRY(&c_jmp) { - if (exc_caught) { - exc_caught = FALSE; + if (mrb->exc) { mrb_gc_arena_restore(mrb, ai); - if (mrb->exc && mrb->exc->tt == MRB_TT_BREAK) + if (mrb->exc->tt == MRB_TT_BREAK) goto L_BREAK; goto L_RAISE; } @@ -3130,7 +3128,6 @@ RETRY_TRY_BLOCK: while (ci > mrb->c->cibase && ci->cci == CINFO_DIRECT) { ci = cipop(mrb); } - exc_caught = TRUE; pc = ci->pc; goto RETRY_TRY_BLOCK; }