aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-06-28 14:27:49 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-06-28 14:27:49 +0000
commit478770b81a1839d17de0c75edbb84bc937d97f91 (patch)
treefb3e3b2351ee24ff78d21116d18b9604c4a53fa0
parent6ea99f4571a52a0de5232a41f17ef7533d14e910 (diff)
downloadruby-478770b81a1839d17de0c75edbb84bc937d97f91.tar.gz
move fields to ec.
* vm_core.h (rb_thread.h): move errinfo and trace_arg to rb_execution_context_t. * cont.c (fiber_switch, rb_cont_call): do not restore "trace_arg" here. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59199 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--cont.c22
-rw-r--r--eval.c50
-rw-r--r--eval_error.c6
-rw-r--r--eval_jump.c10
-rw-r--r--gc.c2
-rw-r--r--insns.def4
-rw-r--r--iseq.c4
-rw-r--r--load.c12
-rw-r--r--process.c2
-rw-r--r--thread.c16
-rw-r--r--vm.c20
-rw-r--r--vm_core.h11
-rw-r--r--vm_eval.c14
-rw-r--r--vm_exec.c4
-rw-r--r--vm_exec.h2
-rw-r--r--vm_insnhelper.c2
-rw-r--r--vm_trace.c36
17 files changed, 105 insertions, 112 deletions
diff --git a/cont.c b/cont.c
index 251b943110..32a4aa57b6 100644
--- a/cont.c
+++ b/cont.c
@@ -408,15 +408,12 @@ cont_save_thread(rb_context_t *cont, rb_thread_t *th)
{
rb_thread_t *sth = &cont->saved_thread;
+ VM_ASSERT(th->status == THREAD_RUNNABLE);
+
/* save thread context */
sth->ec = th->ec;
-
- VM_ASSERT(th->status == THREAD_RUNNABLE);
- sth->errinfo = th->errinfo;
sth->first_proc = th->first_proc;
- sth->trace_arg = th->trace_arg;
-
/* saved_thread->machine.stack_(start|end) should be NULL */
/* because it may happen GC afterward */
sth->machine.stack_start = 0;
@@ -548,6 +545,8 @@ cont_restore_thread(rb_context_t *cont)
th->ec.root_lep = sth->ec.root_lep;
th->ec.root_svar = sth->ec.root_svar;
th->ec.ensure_list = sth->ec.ensure_list;
+ th->ec.errinfo = sth->ec.errinfo;
+ th->ec.trace_arg = sth->ec.trace_arg;
}
else {
/* fiber */
@@ -556,7 +555,6 @@ cont_restore_thread(rb_context_t *cont)
th->fiber = (rb_fiber_t*)cont;
}
- th->errinfo = sth->errinfo;
th->first_proc = sth->first_proc;
VM_ASSERT(sth->status == THREAD_RUNNABLE);
@@ -1067,8 +1065,6 @@ rb_cont_call(int argc, VALUE *argv, VALUE contval)
cont->argc = argc;
cont->value = make_passing_arg(argc, argv);
- /* restore `tracing' context. see [Feature #4347] */
- th->trace_arg = cont->saved_thread.trace_arg;
cont_restore_0(cont, &contval);
return Qnil; /* unreachable */
}
@@ -1261,7 +1257,7 @@ rb_fiber_start(void)
GetProcPtr(cont->saved_thread.first_proc, proc);
argv = (argc = cont->argc) > 1 ? RARRAY_CONST_PTR(args) : &args;
cont->value = Qnil;
- th->errinfo = Qnil;
+ th->ec.errinfo = Qnil;
th->ec.root_lep = rb_vm_proc_local_ep(cont->saved_thread.first_proc);
th->ec.root_svar = Qfalse;
fib->status = FIBER_RUNNING;
@@ -1273,10 +1269,10 @@ rb_fiber_start(void)
if (state) {
if (state == TAG_RAISE || state == TAG_FATAL) {
- rb_threadptr_pending_interrupt_enque(th, th->errinfo);
+ rb_threadptr_pending_interrupt_enque(th, th->ec.errinfo);
}
else {
- VALUE err = rb_vm_make_jump_tag_but_local_jump(state, th->errinfo);
+ VALUE err = rb_vm_make_jump_tag_but_local_jump(state, th->ec.errinfo);
if (!NIL_P(err))
rb_threadptr_pending_interrupt_enque(th, err);
}
@@ -1445,10 +1441,6 @@ fiber_switch(rb_fiber_t *fib, int argc, const VALUE *argv, int is_resume)
if (is_resume) {
fib->prev = fiber_current();
}
- else {
- /* restore `tracing' context. see [Feature #4347] */
- th->trace_arg = cont->saved_thread.trace_arg;
- }
cont->argc = argc;
cont->value = make_passing_arg(argc, argv);
diff --git a/eval.c b/eval.c
index a49364ba41..b60d7606d4 100644
--- a/eval.c
+++ b/eval.c
@@ -127,7 +127,7 @@ static void
ruby_finalize_1(void)
{
ruby_sig_finalize();
- GET_THREAD()->errinfo = Qnil;
+ GET_THREAD()->ec.errinfo = Qnil;
rb_gc_call_finalizer_at_exit();
}
@@ -172,7 +172,7 @@ ruby_cleanup(volatile int ex)
SAVE_ROOT_JMPBUF(th, { RUBY_VM_CHECK_INTS(th); });
step_0: step++;
- errs[1] = th->errinfo;
+ errs[1] = th->ec.errinfo;
th->ec.safe_level = 0;
ruby_init_stack(&errs[STACK_UPPER(errs, 0, 1)]);
@@ -182,7 +182,7 @@ ruby_cleanup(volatile int ex)
/* protect from Thread#raise */
th->status = THREAD_KILLED;
- errs[0] = th->errinfo;
+ errs[0] = th->ec.errinfo;
SAVE_ROOT_JMPBUF(th, rb_thread_terminate_all());
}
else {
@@ -192,7 +192,7 @@ ruby_cleanup(volatile int ex)
}
if (ex == 0) ex = state;
}
- th->errinfo = errs[1];
+ th->ec.errinfo = errs[1];
sysex = error_handle(ex);
state = 0;
@@ -201,7 +201,7 @@ ruby_cleanup(volatile int ex)
if (!RTEST(err)) continue;
- /* th->errinfo contains a NODE while break'ing */
+ /* th->ec.errinfo contains a NODE while break'ing */
if (THROW_DATA_P(err)) continue;
if (rb_obj_is_kind_of(err, rb_eSystemExit)) {
@@ -473,7 +473,7 @@ setup_exception(rb_thread_t *th, int tag, volatile VALUE mesg, VALUE cause)
int nocause = 0;
if (NIL_P(mesg)) {
- mesg = th->errinfo;
+ mesg = th->ec.errinfo;
if (INTERNAL_EXCEPTION_P(mesg)) TH_JUMP_TAG(th, TAG_FATAL);
nocause = 1;
}
@@ -517,19 +517,19 @@ setup_exception(rb_thread_t *th, int tag, volatile VALUE mesg, VALUE cause)
}
if (!NIL_P(mesg)) {
- th->errinfo = mesg;
+ th->ec.errinfo = mesg;
}
- if (RTEST(ruby_debug) && !NIL_P(e = th->errinfo) &&
+ if (RTEST(ruby_debug) && !NIL_P(e = th->ec.errinfo) &&
!rb_obj_is_kind_of(e, rb_eSystemExit)) {
enum ruby_tag_type state;
mesg = e;
TH_PUSH_TAG(th);
if ((state = EXEC_TAG()) == TAG_NONE) {
- th->errinfo = Qnil;
+ th->ec.errinfo = Qnil;
e = rb_obj_as_string(mesg);
- th->errinfo = mesg;
+ th->ec.errinfo = mesg;
if (file && line) {
e = rb_sprintf("Exception `%"PRIsVALUE"' at %s:%d - %"PRIsVALUE"\n",
rb_obj_class(mesg), file, line, e);
@@ -545,8 +545,8 @@ setup_exception(rb_thread_t *th, int tag, volatile VALUE mesg, VALUE cause)
warn_print_str(e);
}
TH_POP_TAG();
- if (state == TAG_FATAL && th->errinfo == exception_error) {
- th->errinfo = mesg;
+ if (state == TAG_FATAL && th->ec.errinfo == exception_error) {
+ th->ec.errinfo = mesg;
}
else if (state) {
rb_threadptr_reset_raised(th);
@@ -556,13 +556,13 @@ setup_exception(rb_thread_t *th, int tag, volatile VALUE mesg, VALUE cause)
if (rb_threadptr_set_raised(th)) {
fatal:
- th->errinfo = exception_error;
+ th->ec.errinfo = exception_error;
rb_threadptr_reset_raised(th);
TH_JUMP_TAG(th, TAG_FATAL);
}
if (tag != TAG_FATAL) {
- RUBY_DTRACE_HOOK(RAISE, rb_obj_classname(th->errinfo));
+ RUBY_DTRACE_HOOK(RAISE, rb_obj_classname(th->ec.errinfo));
EXEC_EVENT_HOOK(th, RUBY_EVENT_RAISE, th->ec.cfp->self, 0, 0, 0, mesg);
}
}
@@ -797,7 +797,7 @@ rb_rescue2(VALUE (* b_proc) (ANYARGS), VALUE data1,
rb_thread_t *th = GET_THREAD();
rb_control_frame_t *volatile cfp = th->ec.cfp;
volatile VALUE result = Qfalse;
- volatile VALUE e_info = th->errinfo;
+ volatile VALUE e_info = th->ec.errinfo;
va_list args;
TH_PUSH_TAG(th);
@@ -809,7 +809,7 @@ rb_rescue2(VALUE (* b_proc) (ANYARGS), VALUE data1,
/* escape from r_proc */
if (state == TAG_RETRY) {
state = 0;
- th->errinfo = Qnil;
+ th->ec.errinfo = Qnil;
result = Qfalse;
goto retry_entry;
}
@@ -823,7 +823,7 @@ rb_rescue2(VALUE (* b_proc) (ANYARGS), VALUE data1,
va_init_list(args, data2);
while ((eclass = va_arg(args, VALUE)) != 0) {
- if (rb_obj_is_kind_of(th->errinfo, eclass)) {
+ if (rb_obj_is_kind_of(th->ec.errinfo, eclass)) {
handle = TRUE;
break;
}
@@ -834,9 +834,9 @@ rb_rescue2(VALUE (* b_proc) (ANYARGS), VALUE data1,
result = Qnil;
state = 0;
if (r_proc) {
- result = (*r_proc) (data2, th->errinfo);
+ result = (*r_proc) (data2, th->ec.errinfo);
}
- th->errinfo = e_info;
+ th->ec.errinfo = e_info;
}
}
}
@@ -902,13 +902,13 @@ rb_ensure(VALUE (*b_proc)(ANYARGS), VALUE data1, VALUE (*e_proc)(ANYARGS), VALUE
result = (*b_proc) (data1);
}
TH_POP_TAG();
- errinfo = th->errinfo;
+ errinfo = th->ec.errinfo;
if (!NIL_P(errinfo) && !RB_TYPE_P(errinfo, T_OBJECT)) {
- th->errinfo = Qnil;
+ th->ec.errinfo = Qnil;
}
th->ec.ensure_list=ensure_list.next;
(*ensure_list.entry.e_proc)(ensure_list.entry.data2);
- th->errinfo = errinfo;
+ th->ec.errinfo = errinfo;
if (state)
TH_JUMP_TAG(th, state);
return result;
@@ -1549,7 +1549,7 @@ get_thread_errinfo(rb_thread_t *th)
return *ptr;
}
else {
- return th->errinfo;
+ return th->ec.errinfo;
}
}
@@ -1588,7 +1588,7 @@ VALUE
rb_errinfo(void)
{
rb_thread_t *th = GET_THREAD();
- return th->errinfo;
+ return th->ec.errinfo;
}
void
@@ -1597,7 +1597,7 @@ rb_set_errinfo(VALUE err)
if (!NIL_P(err) && !rb_obj_is_kind_of(err, rb_eException)) {
rb_raise(rb_eTypeError, "assigning non-exception to $!");
}
- GET_THREAD()->errinfo = err;
+ GET_THREAD()->ec.errinfo = err;
}
VALUE
diff --git a/eval_error.c b/eval_error.c
index 4340f60676..fe6bae1145 100644
--- a/eval_error.c
+++ b/eval_error.c
@@ -69,7 +69,7 @@ set_backtrace(VALUE info, VALUE bt)
static void
error_print(rb_thread_t *th)
{
- rb_threadptr_error_print(th, th->errinfo);
+ rb_threadptr_error_print(th, th->ec.errinfo);
}
static void
@@ -202,7 +202,7 @@ rb_threadptr_error_print(rb_thread_t *volatile th, volatile VALUE errinfo)
}
error:
TH_POP_TAG();
- th->errinfo = errinfo;
+ th->ec.errinfo = errinfo;
rb_thread_raised_set(th, raised_flag);
}
@@ -304,7 +304,7 @@ error_handle(int ex)
warn_print("unexpected throw\n");
break;
case TAG_RAISE: {
- VALUE errinfo = th->errinfo;
+ VALUE errinfo = th->ec.errinfo;
if (rb_obj_is_kind_of(errinfo, rb_eSystemExit)) {
status = sysexit_status(errinfo);
}
diff --git a/eval_jump.c b/eval_jump.c
index 37f5ab591d..22722719b5 100644
--- a/eval_jump.c
+++ b/eval_jump.c
@@ -116,26 +116,26 @@ rb_exec_end_proc(void)
enum ruby_tag_type state;
volatile int safe = rb_safe_level();
rb_thread_t *th = GET_THREAD();
- volatile VALUE errinfo = th->errinfo;
+ volatile VALUE errinfo = th->ec.errinfo;
TH_PUSH_TAG(th);
if ((state = EXEC_TAG()) == TAG_NONE) {
again:
- exec_end_procs_chain(&ephemeral_end_procs, &th->errinfo);
- exec_end_procs_chain(&end_procs, &th->errinfo);
+ exec_end_procs_chain(&ephemeral_end_procs, &th->ec.errinfo);
+ exec_end_procs_chain(&end_procs, &th->ec.errinfo);
}
else {
VAR_INITIALIZED(th);
TH_TMPPOP_TAG();
error_handle(state);
- if (!NIL_P(th->errinfo)) errinfo = th->errinfo;
+ if (!NIL_P(th->ec.errinfo)) errinfo = th->ec.errinfo;
TH_REPUSH_TAG();
goto again;
}
TH_POP_TAG();
rb_set_safe_level_force(safe);
- th->errinfo = errinfo;
+ th->ec.errinfo = errinfo;
}
void
diff --git a/gc.c b/gc.c
index 86f6071a38..6b49be68c1 100644
--- a/gc.c
+++ b/gc.c
@@ -7695,7 +7695,7 @@ rb_memerror(void)
rb_thread_raised_set(th, RAISED_NOMEMORY);
exc = ruby_vm_special_exception_copy(exc);
}
- th->errinfo = exc;
+ th->ec.errinfo = exc;
TH_JUMP_TAG(th, TAG_RAISE);
}
diff --git a/insns.def b/insns.def
index 96bcc43db8..75ed734c6f 100644
--- a/insns.def
+++ b/insns.def
@@ -1584,8 +1584,8 @@ opt_call_c_function
reg_cfp = (funcptr)(th, reg_cfp);
if (reg_cfp == 0) {
- VALUE err = th->errinfo;
- th->errinfo = Qnil;
+ VALUE err = th->ec.errinfo;
+ th->ec.errinfo = Qnil;
THROW_EXCEPTION(err);
}
diff --git a/iseq.c b/iseq.c
index a4e86677c9..be131229b3 100644
--- a/iseq.c
+++ b/iseq.c
@@ -663,7 +663,7 @@ rb_iseq_compile_with_option(VALUE src, VALUE file, VALUE realpath, VALUE line, c
}
if (!node) {
- rb_exc_raise(th->errinfo);
+ rb_exc_raise(th->ec.errinfo);
}
else {
INITIALIZED VALUE label = parent ?
@@ -870,7 +870,7 @@ iseqw_s_compile_file(int argc, VALUE *argv, VALUE self)
parser = rb_parser_new();
rb_parser_set_context(parser, NULL, FALSE);
node = rb_parser_compile_file_path(parser, file, f, NUM2INT(line));
- if (!node) exc = GET_THREAD()->errinfo;
+ if (!node) exc = GET_THREAD()->ec.errinfo;
rb_io_close(f);
if (!node) rb_exc_raise(exc);
diff --git a/load.c b/load.c
index d424d4caf2..1b9dd48150 100644
--- a/load.c
+++ b/load.c
@@ -586,7 +586,7 @@ rb_load_internal0(rb_thread_t *th, VALUE fname, int wrap)
rb_thread_t *volatile th0 = th;
#endif
- th->errinfo = Qnil; /* ensure */
+ th->ec.errinfo = Qnil; /* ensure */
if (!wrap) {
th->top_wrapper = 0;
@@ -628,11 +628,11 @@ rb_load_internal0(rb_thread_t *th, VALUE fname, int wrap)
if (state) {
VALUE exc = rb_vm_make_jump_tag_but_local_jump(state, Qundef);
if (NIL_P(exc)) return state;
- th->errinfo = exc;
+ th->ec.errinfo = exc;
return TAG_RAISE;
}
- if (!NIL_P(th->errinfo)) {
+ if (!NIL_P(th->ec.errinfo)) {
/* exception during load */
return TAG_RAISE;
}
@@ -645,7 +645,7 @@ rb_load_internal(VALUE fname, int wrap)
rb_thread_t *curr_th = GET_THREAD();
int state = rb_load_internal0(curr_th, fname, wrap);
if (state) {
- if (state == TAG_RAISE) rb_exc_raise(curr_th->errinfo);
+ if (state == TAG_RAISE) rb_exc_raise(curr_th->ec.errinfo);
TH_JUMP_TAG(curr_th, state);
}
}
@@ -960,7 +960,7 @@ rb_require_internal(VALUE fname, int safe)
{
volatile int result = -1;
rb_thread_t *th = GET_THREAD();
- volatile VALUE errinfo = th->errinfo;
+ volatile VALUE errinfo = th->ec.errinfo;
enum ruby_tag_type state;
struct {
int safe;
@@ -1021,7 +1021,7 @@ rb_require_internal(VALUE fname, int safe)
return state;
}
- th->errinfo = errinfo;
+ th->ec.errinfo = errinfo;
RUBY_DTRACE_HOOK(REQUIRE_RETURN, RSTRING_PTR(fname));
diff --git a/process.c b/process.c
index a167562f00..f45ff2f5c5 100644
--- a/process.c
+++ b/process.c
@@ -3858,7 +3858,7 @@ rb_f_abort(int argc, const VALUE *argv)
rb_check_arity(argc, 0, 1);
if (argc == 0) {
rb_thread_t *th = GET_THREAD();
- VALUE errinfo = th->errinfo;
+ VALUE errinfo = th->ec.errinfo;
if (!NIL_P(errinfo)) {
rb_threadptr_error_print(th, errinfo);
}
diff --git a/thread.c b/thread.c
index e7f6273199..b7ee1d8d9b 100644
--- a/thread.c
+++ b/thread.c
@@ -580,7 +580,7 @@ thread_do_start(rb_thread_t *th, VALUE args)
if (!th->first_func) {
rb_proc_t *proc;
GetProcPtr(th->first_proc, proc);
- th->errinfo = Qnil;
+ th->ec.errinfo = Qnil;
th->ec.root_lep = rb_vm_proc_local_ep(th->first_proc);
th->ec.root_svar = Qfalse;
EXEC_EVENT_HOOK(th, RUBY_EVENT_THREAD_BEGIN, th->self, 0, 0, 0, Qundef);
@@ -629,7 +629,7 @@ thread_start_func_2(rb_thread_t *th, VALUE *stack_start, VALUE *register_stack_s
SAVE_ROOT_JMPBUF(th, thread_do_start(th, args));
}
else {
- errinfo = th->errinfo;
+ errinfo = th->ec.errinfo;
if (state == TAG_FATAL) {
/* fatal error within this thread, need to stop whole script */
}
@@ -923,8 +923,8 @@ thread_join(rb_thread_t *target_th, double delay)
thread_debug("thread_join: success (thid: %"PRI_THREAD_ID")\n",
thread_id_str(target_th));
- if (target_th->errinfo != Qnil) {
- VALUE err = target_th->errinfo;
+ if (target_th->ec.errinfo != Qnil) {
+ VALUE err = target_th->ec.errinfo;
if (FIXNUM_P(err)) {
switch (err) {
@@ -935,7 +935,7 @@ thread_join(rb_thread_t *target_th, double delay)
rb_bug("thread_join: Fixnum (%d) should not reach here.", FIX2INT(err));
}
}
- else if (THROW_DATA_P(target_th->errinfo)) {
+ else if (THROW_DATA_P(target_th->ec.errinfo)) {
rb_bug("thread_join: THROW_DATA should not reach here.");
}
else {
@@ -2008,7 +2008,7 @@ rb_threadptr_to_kill(rb_thread_t *th)
rb_threadptr_pending_interrupt_clear(th);
th->status = THREAD_RUNNABLE;
th->to_kill = 1;
- th->errinfo = INT2FIX(TAG_FATAL);
+ th->ec.errinfo = INT2FIX(TAG_FATAL);
TH_JUMP_TAG(th, TAG_FATAL);
}
@@ -2822,8 +2822,8 @@ rb_thread_status(VALUE thread)
rb_thread_t *target_th = rb_thread_ptr(thread);
if (rb_threadptr_dead(target_th)) {
- if (!NIL_P(target_th->errinfo) &&
- !FIXNUM_P(target_th->errinfo)) {
+ if (!NIL_P(target_th->ec.errinfo) &&
+ !FIXNUM_P(target_th->ec.errinfo)) {
return Qnil;
}
else {
diff --git a/vm.c b/vm.c
index 2e94f72c0e..6ff1d234a3 100644
--- a/vm.c
+++ b/vm.c
@@ -1476,7 +1476,7 @@ vm_iter_break(rb_thread_t *th, VALUE val)
}
#endif
- th->errinfo = (VALUE)THROW_DATA_NEW(val, target_cfp, TAG_BREAK);
+ th->ec.errinfo = (VALUE)THROW_DATA_NEW(val, target_cfp, TAG_BREAK);
TH_JUMP_TAG(th, TAG_BREAK);
}
@@ -1803,7 +1803,7 @@ vm_exec(rb_thread_t *th)
VALUE type;
const rb_control_frame_t *escape_cfp;
- err = (struct vm_throw_data *)th->errinfo;
+ err = (struct vm_throw_data *)th->ec.errinfo;
exception_handler:
cont_pc = cont_sp = 0;
@@ -1849,7 +1849,7 @@ vm_exec(rb_thread_t *th)
}
}
if (catch_iseq == NULL) {
- th->errinfo = Qnil;
+ th->ec.errinfo = Qnil;
result = THROW_DATA_VAL(err);
THROW_DATA_CATCH_FRAME_SET(err, cfp + 1);
hook_before_rewind(th, th->ec.cfp, TRUE, state, err);
@@ -1866,7 +1866,7 @@ vm_exec(rb_thread_t *th)
#else
*th->ec.cfp->sp++ = THROW_DATA_VAL(err);
#endif
- th->errinfo = Qnil;
+ th->ec.errinfo = Qnil;
goto vm_loop_start;
}
}
@@ -1905,7 +1905,7 @@ vm_exec(rb_thread_t *th)
escape_cfp = THROW_DATA_CATCH_FRAME(err);
if (cfp == escape_cfp) {
cfp->pc = cfp->iseq->body->iseq_encoded + entry->cont;
- th->errinfo = Qnil;
+ th->ec.errinfo = Qnil;
goto vm_loop_start;
}
}
@@ -1938,7 +1938,7 @@ vm_exec(rb_thread_t *th)
*th->ec.cfp->sp++ = THROW_DATA_VAL(err);
#endif
}
- th->errinfo = Qnil;
+ th->ec.errinfo = Qnil;
VM_ASSERT(th->ec.tag->state == TAG_NONE);
goto vm_loop_start;
}
@@ -1990,7 +1990,7 @@ vm_exec(rb_thread_t *th)
state = 0;
th->ec.tag->state = TAG_NONE;
- th->errinfo = Qnil;
+ th->ec.errinfo = Qnil;
goto vm_loop_start;
}
else {
@@ -1998,7 +1998,7 @@ vm_exec(rb_thread_t *th)
if (VM_FRAME_FINISHED_P(th->ec.cfp)) {
rb_vm_pop_frame(th);
- th->errinfo = (VALUE)err;
+ th->ec.errinfo = (VALUE)err;
TH_TMPPOP_TAG();
TH_JUMP_TAG(th, state);
}
@@ -2404,7 +2404,7 @@ rb_thread_mark(void *ptr)
RUBY_MARK_UNLESS_NULL(th->thgroup);
RUBY_MARK_UNLESS_NULL(th->value);
- RUBY_MARK_UNLESS_NULL(th->errinfo);
+ RUBY_MARK_UNLESS_NULL(th->ec.errinfo);
RUBY_MARK_UNLESS_NULL(th->pending_interrupt_queue);
RUBY_MARK_UNLESS_NULL(th->pending_interrupt_mask_stack);
RUBY_MARK_UNLESS_NULL(th->ec.root_svar);
@@ -2537,8 +2537,8 @@ th_init(rb_thread_t *th, VALUE self)
0 /* dummy pc */, th->ec.stack, 0, 0);
th->status = THREAD_RUNNABLE;
- th->errinfo = Qnil;
th->last_status = Qnil;
+ th->ec.errinfo = Qnil;
th->ec.root_svar = Qfalse;
th->ec.local_storage_recursive_hash = Qnil;
th->ec.local_storage_recursive_hash_for_trace = Qnil;
diff --git a/vm_core.h b/vm_core.h
index d58130af07..679512390d 100644
--- a/vm_core.h
+++ b/vm_core.h
@@ -743,10 +743,12 @@ typedef struct rb_thread_context_struct {
struct rb_vm_tag *tag;
struct rb_vm_protect_tag *protect_tag;
-
int safe_level;
int raised_flag;
+ /* temporary place of errinfo */
+ VALUE errinfo;
+
/* storage (ec (fiber) local) */
st_table *local_storage;
VALUE local_storage_recursive_hash;
@@ -756,6 +758,9 @@ typedef struct rb_thread_context_struct {
const VALUE *root_lep;
VALUE root_svar;
+ /* trace information */
+ struct rb_trace_arg_struct *trace_arg;
+
/* ensure & callcc */
rb_ensure_list_t *ensure_list;
} rb_execution_context_t;
@@ -797,9 +802,6 @@ typedef struct rb_thread_struct {
VALUE thgroup;
VALUE value;
- /* temporary place of errinfo */
- VALUE errinfo;
-
/* temporary place of retval on OPT_CALL_THREADED_CODE */
#if OPT_CALL_THREADED_CODE
VALUE retval;
@@ -841,7 +843,6 @@ typedef struct rb_thread_struct {
/* tracer */
rb_hook_list_t event_hooks;
- struct rb_trace_arg_struct *trace_arg; /* trace information */
/* fiber */
rb_fiber_t *fiber;
diff --git a/vm_eval.c b/vm_eval.c
index a3482d15b6..911dc187b9 100644
--- a/vm_eval.c
+++ b/vm_eval.c
@@ -1129,7 +1129,7 @@ rb_iterate0(VALUE (* it_proc) (VALUE), VALUE data1,
retval = (*it_proc) (data1);
}
else if (state == TAG_BREAK || state == TAG_RETRY) {
- const struct vm_throw_data *const err = (struct vm_throw_data *)th->errinfo;
+ const struct vm_throw_data *const err = (struct vm_throw_data *)th->ec.errinfo;
const rb_control_frame_t *const escape_cfp = THROW_DATA_CATCH_FRAME(err);
if (cfp == escape_cfp) {
@@ -1137,7 +1137,7 @@ rb_iterate0(VALUE (* it_proc) (VALUE), VALUE data1,
state = 0;
th->ec.tag->state = TAG_NONE;
- th->errinfo = Qnil;
+ th->ec.errinfo = Qnil;
if (state == TAG_RETRY) goto iter_retry;
retval = THROW_DATA_VAL(err);
@@ -1296,7 +1296,7 @@ eval_string_with_cref(VALUE self, VALUE src, VALUE scope, rb_cref_t *const cref_
iseq = rb_iseq_compile_with_option(src, fname, realpath, INT2FIX(line), base_block, Qnil);
if (!iseq) {
- rb_exc_raise(adjust_backtrace_in_eval(th, th->errinfo));
+ rb_exc_raise(adjust_backtrace_in_eval(th, th->ec.errinfo));
}
/* TODO: what the code checking? */
@@ -1335,7 +1335,7 @@ eval_string_with_cref(VALUE self, VALUE src, VALUE scope, rb_cref_t *const cref_
if (state) {
if (state == TAG_RAISE) {
- adjust_backtrace_in_eval(th, th->errinfo);
+ adjust_backtrace_in_eval(th, th->ec.errinfo);
}
TH_JUMP_TAG(th, state);
}
@@ -1870,7 +1870,7 @@ rb_throw_obj(VALUE tag, VALUE value)
rb_exc_raise(rb_class_new_instance(numberof(desc), desc, rb_eUncaughtThrow));
}
- th->errinfo = (VALUE)THROW_DATA_NEW(tag, NULL, TAG_THROW);
+ th->ec.errinfo = (VALUE)THROW_DATA_NEW(tag, NULL, TAG_THROW);
TH_JUMP_TAG(th, TAG_THROW);
}
@@ -1974,10 +1974,10 @@ vm_catch_protect(VALUE tag, rb_block_call_func *func, VALUE data,
/* call with argc=1, argv = [tag], block = Qnil to insure compatibility */
val = (*func)(tag, data, 1, (const VALUE *)&tag, Qnil);
}
- else if (state == TAG_THROW && THROW_DATA_VAL((struct vm_throw_data *)th->errinfo) == tag) {
+ else if (state == TAG_THROW && THROW_DATA_VAL((struct vm_throw_data *)th->ec.errinfo) == tag) {
rb_vm_rewind_cfp(th, saved_cfp);
val = th->ec.tag->retval;
- th->errinfo = Qnil;
+ th->ec.errinfo = Qnil;
state = 0;
}
TH_POP_TAG();
diff --git a/vm_exec.c b/vm_exec.c
index 26c2a8fc78..1ce9a02403 100644
--- a/vm_exec.c
+++ b/vm_exec.c
@@ -162,8 +162,8 @@ vm_exec_core(rb_thread_t *th, VALUE initial)
return ret;
}
else {
- VALUE err = th->errinfo;
- th->errinfo = Qnil;
+ VALUE err = th->ec.errinfo;
+ th->ec.errinfo = Qnil;
return err;
}
}
diff --git a/vm_exec.h b/vm_exec.h
index 7128113f15..2b5f7a9473 100644
--- a/vm_exec.h
+++ b/vm_exec.h
@@ -161,7 +161,7 @@ default: \
#if OPT_CALL_THREADED_CODE
#define THROW_EXCEPTION(exc) do { \
- th->errinfo = (VALUE)(exc); \
+ th->ec.errinfo = (VALUE)(exc); \
return 0; \
} while (0)
#else
diff --git a/vm_insnhelper.c b/vm_insnhelper.c
index 3a8abb345a..37e7637450 100644
--- a/vm_insnhelper.c
+++ b/vm_insnhelper.c
@@ -42,7 +42,7 @@ threadptr_stack_overflow(rb_thread_t *th, int setup)
rb_ivar_set(mesg, idBt, at);
rb_ivar_set(mesg, idBt_locations, at);
}
- th->errinfo = mesg;
+ th->ec.errinfo = mesg;
TH_JUMP_TAG(th, TAG_RAISE);
}
diff --git a/vm_trace.c b/vm_trace.c
index 0f2323284f..7b8c76b3b4 100644
--- a/vm_trace.c
+++ b/vm_trace.c
@@ -304,31 +304,31 @@ rb_threadptr_exec_event_hooks_orig(rb_trace_arg_t *trace_arg, int pop_p)
rb_thread_t *th = trace_arg->th;
if (trace_arg->event & RUBY_INTERNAL_EVENT_MASK) {
- if (th->trace_arg && (th->trace_arg->event & RUBY_INTERNAL_EVENT_MASK)) {
+ if (th->ec.trace_arg && (th->ec.trace_arg->event & RUBY_INTERNAL_EVENT_MASK)) {
/* skip hooks because this thread doing INTERNAL_EVENT */
}
else {
- rb_trace_arg_t *prev_trace_arg = th->trace_arg;
+ rb_trace_arg_t *prev_trace_arg = th->ec.trace_arg;
th->vm->trace_running++;
- th->trace_arg = trace_arg;
+ th->ec.trace_arg = trace_arg;
exec_hooks_unprotected(th, &th->event_hooks, trace_arg);
exec_hooks_unprotected(th, &th->vm->event_hooks, trace_arg);
- th->trace_arg = prev_trace_arg;
+ th->ec.trace_arg = prev_trace_arg;
th->vm->trace_running--;
}
}
else {
- if (th->trace_arg == 0 && /* check reentrant */
+ if (th->ec.trace_arg == NULL && /* check reentrant */
trace_arg->self != rb_mRubyVMFrozenCore /* skip special methods. TODO: remove it. */) {
- const VALUE errinfo = th->errinfo;
+ const VALUE errinfo = th->ec.errinfo;
const VALUE old_recursive = th->ec.local_storage_recursive_hash;
int state = 0;
th->ec.local_storage_recursive_hash = th->ec.local_storage_recursive_hash_for_trace;
- th->errinfo = Qnil;
+ th->ec.errinfo = Qnil;
th->vm->trace_running++;
- th->trace_arg = trace_arg;
+ th->ec.trace_arg = trace_arg;
{
/* thread local traces */
state = exec_hooks_protected(th, &th->event_hooks, trace_arg);
@@ -338,10 +338,10 @@ rb_threadptr_exec_event_hooks_orig(rb_trace_arg_t *trace_arg, int pop_p)
state = exec_hooks_protected(th, &th->vm->event_hooks, trace_arg);
if (state) goto terminate;
- th->errinfo = errinfo;
+ th->ec.errinfo = errinfo;
}
terminate:
- th->trace_arg = 0;
+ th->ec.trace_arg = NULL;
th->vm->trace_running--;
th->ec.local_storage_recursive_hash_for_trace = th->ec.local_storage_recursive_hash;
@@ -379,12 +379,12 @@ rb_suppress_tracing(VALUE (*func)(VALUE), VALUE arg)
VALUE result = Qnil;
rb_thread_t *volatile th = GET_THREAD();
enum ruby_tag_type state;
- const int tracing = th->trace_arg ? 1 : 0;
+ const int tracing = th->ec.trace_arg ? 1 : 0;
rb_trace_arg_t dummy_trace_arg;
dummy_trace_arg.event = 0;
if (!tracing) th->vm->trace_running++;
- if (!th->trace_arg) th->trace_arg = &dummy_trace_arg;
+ if (!th->ec.trace_arg) th->ec.trace_arg = &dummy_trace_arg;
raised = rb_threadptr_reset_raised(th);
@@ -398,7 +398,7 @@ rb_suppress_tracing(VALUE (*func)(VALUE), VALUE arg)
rb_threadptr_set_raised(th);
}
- if (th->trace_arg == &dummy_trace_arg) th->trace_arg = 0;
+ if (th->ec.trace_arg == &dummy_trace_arg) th->ec.trace_arg = 0;
if (!tracing) th->vm->trace_running--;
if (state) {
@@ -703,7 +703,7 @@ tpptr(VALUE tpval)
static rb_trace_arg_t *
get_trace_arg(void)
{
- rb_trace_arg_t *trace_arg = GET_THREAD()->trace_arg;
+ rb_trace_arg_t *trace_arg = GET_THREAD()->ec.trace_arg;
if (trace_arg == 0) {
rb_raise(rb_eRuntimeError, "access from outside");
}
@@ -1307,7 +1307,7 @@ static VALUE
tracepoint_inspect(VALUE self)
{
rb_tp_t *tp = tpptr(self);
- rb_trace_arg_t *trace_arg = GET_THREAD()->trace_arg;
+ rb_trace_arg_t *trace_arg = GET_THREAD()->ec.trace_arg;
if (trace_arg) {
switch (trace_arg->event) {
@@ -1591,9 +1591,9 @@ rb_postponed_job_flush(rb_vm_t *vm)
rb_thread_t *th = GET_THREAD();
const unsigned long block_mask = POSTPONED_JOB_INTERRUPT_MASK|TRAP_INTERRUPT_MASK;
unsigned long saved_mask = th->interrupt_mask & block_mask;
- VALUE saved_errno = th->errinfo;
+ VALUE saved_errno = th->ec.errinfo;
- th->errinfo = Qnil;
+ th->ec.errinfo = Qnil;
/* mask POSTPONED_JOB dispatch */
th->interrupt_mask |= block_mask;
{
@@ -1611,5 +1611,5 @@ rb_postponed_job_flush(rb_vm_t *vm)
}
/* restore POSTPONED_JOB mask */
th->interrupt_mask &= ~(saved_mask ^ block_mask);
- th->errinfo = saved_errno;
+ th->ec.errinfo = saved_errno;
}