From e496dfe6db6a7ea574295de277bed2864835e2d8 Mon Sep 17 00:00:00 2001 From: nobu Date: Sat, 23 Apr 2016 03:23:51 +0000 Subject: [PATCH] eval.c: reuse VM tag * eval.c (ruby_cleanup): reuse same VM tag by managing steps. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54723 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- eval.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/eval.c b/eval.c index 66db86757f..3df3b5dd77 100644 --- a/eval.c +++ b/eval.c @@ -163,35 +163,34 @@ ruby_cleanup(volatile int ex) rb_thread_t *th = GET_THREAD(); int nerr; volatile int sysex = EXIT_SUCCESS; + volatile int step = 0; rb_threadptr_interrupt(th); rb_threadptr_check_signal(th); TH_PUSH_TAG(th); if ((state = EXEC_TAG()) == 0) { SAVE_ROOT_JMPBUF(th, { RUBY_VM_CHECK_INTS(th); }); - } - TH_POP_TAG(); - errs[1] = th->errinfo; - th->safe_level = 0; - ruby_init_stack(&errs[STACK_UPPER(errs, 0, 1)]); + step_0: step++; + errs[1] = th->errinfo; + th->safe_level = 0; + ruby_init_stack(&errs[STACK_UPPER(errs, 0, 1)]); - TH_PUSH_TAG(th); - if ((state = EXEC_TAG()) == 0) { SAVE_ROOT_JMPBUF(th, ruby_finalize_0()); - } - TH_POP_TAG(); - /* protect from Thread#raise */ - th->status = THREAD_KILLED; + step_1: step++; + /* protect from Thread#raise */ + th->status = THREAD_KILLED; - errs[0] = th->errinfo; - TH_PUSH_TAG(th); - if ((state = EXEC_TAG()) == 0) { + errs[0] = th->errinfo; SAVE_ROOT_JMPBUF(th, rb_thread_terminate_all()); } - else if (ex == 0) { - ex = state; + else { + switch (step) { + case 0: goto step_0; + case 1: goto step_1; + } + if (ex == 0) ex = state; } th->errinfo = errs[1]; sysex = error_handle(ex);