Skip to content

Commit

Permalink
eval.c: use the given thread
Browse files Browse the repository at this point in the history
* eval.c (setup_exception): use the given thread instead of
  implicit current thread.

* load.c (rb_load_internal0): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49709 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
nobu committed Feb 24, 2015
1 parent edad4f3 commit dcc004c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
24 changes: 12 additions & 12 deletions eval.c
Expand Up @@ -167,27 +167,27 @@ ruby_cleanup(volatile int ex)

rb_threadptr_interrupt(th);
rb_threadptr_check_signal(th);
PUSH_TAG();
TH_PUSH_TAG(th);
if ((state = EXEC_TAG()) == 0) {
SAVE_ROOT_JMPBUF(th, { RUBY_VM_CHECK_INTS(th); });
}
POP_TAG();
TH_POP_TAG();

errs[1] = th->errinfo;
th->safe_level = 0;
ruby_init_stack(&errs[STACK_UPPER(errs, 0, 1)]);

PUSH_TAG();
TH_PUSH_TAG(th);
if ((state = EXEC_TAG()) == 0) {
SAVE_ROOT_JMPBUF(th, ruby_finalize_0());
}
POP_TAG();
TH_POP_TAG();

/* protect from Thread#raise */
th->status = THREAD_KILLED;

errs[0] = th->errinfo;
PUSH_TAG();
TH_PUSH_TAG(th);
if ((state = EXEC_TAG()) == 0) {
SAVE_ROOT_JMPBUF(th, rb_thread_terminate_all());
}
Expand Down Expand Up @@ -235,7 +235,7 @@ ruby_cleanup(volatile int ex)

/* unlock again if finalizer took mutexes. */
rb_threadptr_unlock_all_locking_mutexes(GET_THREAD());
POP_TAG();
TH_POP_TAG();
rb_thread_stop_timer_thread(1);
ruby_vm_destruct(GET_VM());
if (state) ruby_default_signal(state);
Expand All @@ -252,14 +252,14 @@ ruby_exec_internal(void *n)

if (!n) return 0;

PUSH_TAG();
TH_PUSH_TAG(th);
if ((state = EXEC_TAG()) == 0) {
SAVE_ROOT_JMPBUF(th, {
th->base_block = 0;
rb_iseq_eval_main(iseq);
});
}
POP_TAG();
TH_POP_TAG();
return state;
}

Expand Down Expand Up @@ -539,7 +539,7 @@ setup_exception(rb_thread_t *th, int tag, volatile VALUE mesg, VALUE cause)
int status;

mesg = e;
PUSH_TAG();
TH_PUSH_TAG(th);
if ((status = EXEC_TAG()) == 0) {
th->errinfo = Qnil;
e = rb_obj_as_string(mesg);
Expand All @@ -557,7 +557,7 @@ setup_exception(rb_thread_t *th, int tag, volatile VALUE mesg, VALUE cause)
rb_obj_class(mesg), e);
}
}
POP_TAG();
TH_POP_TAG();
if (status == TAG_FATAL && th->errinfo == exception_error) {
th->errinfo = mesg;
}
Expand Down Expand Up @@ -907,11 +907,11 @@ rb_ensure(VALUE (*b_proc)(ANYARGS), VALUE data1, VALUE (*e_proc)(ANYARGS), VALUE
ensure_list.entry.data2 = data2;
ensure_list.next = th->ensure_list;
th->ensure_list = &ensure_list;
PUSH_TAG();
TH_PUSH_TAG(th);
if ((state = EXEC_TAG()) == 0) {
result = (*b_proc) (data1);
}
POP_TAG();
TH_POP_TAG();
errinfo = th->errinfo;
th->ensure_list=ensure_list.next;
(*ensure_list.entry.e_proc)(ensure_list.entry.data2);
Expand Down
4 changes: 2 additions & 2 deletions eval_jump.c
Expand Up @@ -116,7 +116,7 @@ rb_exec_end_proc(void)
rb_thread_t *th = GET_THREAD();
volatile VALUE errinfo = th->errinfo;

PUSH_TAG();
TH_PUSH_TAG(th);
if ((status = EXEC_TAG()) == 0) {
again:
exec_end_procs_chain(&ephemeral_end_procs);
Expand All @@ -130,7 +130,7 @@ rb_exec_end_proc(void)
TH_REPUSH_TAG();
goto again;
}
POP_TAG();
TH_POP_TAG();

rb_set_safe_level_force(safe);
th->errinfo = errinfo;
Expand Down
8 changes: 4 additions & 4 deletions load.c
Expand Up @@ -600,7 +600,7 @@ rb_load_internal0(rb_thread_t *th, VALUE fname, int wrap)
}

mild_compile_error = th->mild_compile_error;
PUSH_TAG();
TH_PUSH_TAG(th);
state = EXEC_TAG();
if (state == 0) {
NODE *node;
Expand All @@ -613,7 +613,7 @@ rb_load_internal0(rb_thread_t *th, VALUE fname, int wrap)
th->mild_compile_error--;
rb_iseq_eval(iseq);
}
POP_TAG();
TH_POP_TAG();

#if !defined __GNUC__
th = th0;
Expand Down Expand Up @@ -965,7 +965,7 @@ rb_require_internal(VALUE fname, int safe)
rb_sourceline());
}

PUSH_TAG();
TH_PUSH_TAG(th);
saved.safe = rb_safe_level();
if ((state = EXEC_TAG()) == 0) {
VALUE path;
Expand Down Expand Up @@ -1015,7 +1015,7 @@ rb_require_internal(VALUE fname, int safe)
}
}
}
POP_TAG();
TH_POP_TAG();
load_unlock(ftptr, !state);

rb_set_safe_level_force(saved.safe);
Expand Down

0 comments on commit dcc004c

Please sign in to comment.