aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-04-23 03:23:51 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-04-23 03:23:51 +0000
commite496dfe6db6a7ea574295de277bed2864835e2d8 (patch)
treeba079406d5f443aab7c31d6de9bfe345c4057557
parent53d5f865e65ce7f40b986f3d77f0b99d1ffab38b (diff)
downloadruby-e496dfe6db6a7ea574295de277bed2864835e2d8.tar.gz
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
-rw-r--r--eval.c31
1 files 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);