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
This commit is contained in:
parent
75392e45f1
commit
8dd9c12c58
22
cont.c
22
cont.c
@ -408,15 +408,12 @@ cont_save_thread(rb_context_t *cont, rb_thread_t *th)
|
|||||||
{
|
{
|
||||||
rb_thread_t *sth = &cont->saved_thread;
|
rb_thread_t *sth = &cont->saved_thread;
|
||||||
|
|
||||||
|
VM_ASSERT(th->status == THREAD_RUNNABLE);
|
||||||
|
|
||||||
/* save thread context */
|
/* save thread context */
|
||||||
sth->ec = th->ec;
|
sth->ec = th->ec;
|
||||||
|
|
||||||
VM_ASSERT(th->status == THREAD_RUNNABLE);
|
|
||||||
sth->errinfo = th->errinfo;
|
|
||||||
sth->first_proc = th->first_proc;
|
sth->first_proc = th->first_proc;
|
||||||
|
|
||||||
sth->trace_arg = th->trace_arg;
|
|
||||||
|
|
||||||
/* saved_thread->machine.stack_(start|end) should be NULL */
|
/* saved_thread->machine.stack_(start|end) should be NULL */
|
||||||
/* because it may happen GC afterward */
|
/* because it may happen GC afterward */
|
||||||
sth->machine.stack_start = 0;
|
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_lep = sth->ec.root_lep;
|
||||||
th->ec.root_svar = sth->ec.root_svar;
|
th->ec.root_svar = sth->ec.root_svar;
|
||||||
th->ec.ensure_list = sth->ec.ensure_list;
|
th->ec.ensure_list = sth->ec.ensure_list;
|
||||||
|
th->ec.errinfo = sth->ec.errinfo;
|
||||||
|
th->ec.trace_arg = sth->ec.trace_arg;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* fiber */
|
/* fiber */
|
||||||
@ -556,7 +555,6 @@ cont_restore_thread(rb_context_t *cont)
|
|||||||
th->fiber = (rb_fiber_t*)cont;
|
th->fiber = (rb_fiber_t*)cont;
|
||||||
}
|
}
|
||||||
|
|
||||||
th->errinfo = sth->errinfo;
|
|
||||||
th->first_proc = sth->first_proc;
|
th->first_proc = sth->first_proc;
|
||||||
|
|
||||||
VM_ASSERT(sth->status == THREAD_RUNNABLE);
|
VM_ASSERT(sth->status == THREAD_RUNNABLE);
|
||||||
@ -1067,8 +1065,6 @@ rb_cont_call(int argc, VALUE *argv, VALUE contval)
|
|||||||
cont->argc = argc;
|
cont->argc = argc;
|
||||||
cont->value = make_passing_arg(argc, argv);
|
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);
|
cont_restore_0(cont, &contval);
|
||||||
return Qnil; /* unreachable */
|
return Qnil; /* unreachable */
|
||||||
}
|
}
|
||||||
@ -1261,7 +1257,7 @@ rb_fiber_start(void)
|
|||||||
GetProcPtr(cont->saved_thread.first_proc, proc);
|
GetProcPtr(cont->saved_thread.first_proc, proc);
|
||||||
argv = (argc = cont->argc) > 1 ? RARRAY_CONST_PTR(args) : &args;
|
argv = (argc = cont->argc) > 1 ? RARRAY_CONST_PTR(args) : &args;
|
||||||
cont->value = Qnil;
|
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_lep = rb_vm_proc_local_ep(cont->saved_thread.first_proc);
|
||||||
th->ec.root_svar = Qfalse;
|
th->ec.root_svar = Qfalse;
|
||||||
fib->status = FIBER_RUNNING;
|
fib->status = FIBER_RUNNING;
|
||||||
@ -1273,10 +1269,10 @@ rb_fiber_start(void)
|
|||||||
|
|
||||||
if (state) {
|
if (state) {
|
||||||
if (state == TAG_RAISE || state == TAG_FATAL) {
|
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 {
|
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))
|
if (!NIL_P(err))
|
||||||
rb_threadptr_pending_interrupt_enque(th, 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) {
|
if (is_resume) {
|
||||||
fib->prev = fiber_current();
|
fib->prev = fiber_current();
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
/* restore `tracing' context. see [Feature #4347] */
|
|
||||||
th->trace_arg = cont->saved_thread.trace_arg;
|
|
||||||
}
|
|
||||||
|
|
||||||
cont->argc = argc;
|
cont->argc = argc;
|
||||||
cont->value = make_passing_arg(argc, argv);
|
cont->value = make_passing_arg(argc, argv);
|
||||||
|
50
eval.c
50
eval.c
@ -127,7 +127,7 @@ static void
|
|||||||
ruby_finalize_1(void)
|
ruby_finalize_1(void)
|
||||||
{
|
{
|
||||||
ruby_sig_finalize();
|
ruby_sig_finalize();
|
||||||
GET_THREAD()->errinfo = Qnil;
|
GET_THREAD()->ec.errinfo = Qnil;
|
||||||
rb_gc_call_finalizer_at_exit();
|
rb_gc_call_finalizer_at_exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -172,7 +172,7 @@ ruby_cleanup(volatile int ex)
|
|||||||
SAVE_ROOT_JMPBUF(th, { RUBY_VM_CHECK_INTS(th); });
|
SAVE_ROOT_JMPBUF(th, { RUBY_VM_CHECK_INTS(th); });
|
||||||
|
|
||||||
step_0: step++;
|
step_0: step++;
|
||||||
errs[1] = th->errinfo;
|
errs[1] = th->ec.errinfo;
|
||||||
th->ec.safe_level = 0;
|
th->ec.safe_level = 0;
|
||||||
ruby_init_stack(&errs[STACK_UPPER(errs, 0, 1)]);
|
ruby_init_stack(&errs[STACK_UPPER(errs, 0, 1)]);
|
||||||
|
|
||||||
@ -182,7 +182,7 @@ ruby_cleanup(volatile int ex)
|
|||||||
/* protect from Thread#raise */
|
/* protect from Thread#raise */
|
||||||
th->status = THREAD_KILLED;
|
th->status = THREAD_KILLED;
|
||||||
|
|
||||||
errs[0] = th->errinfo;
|
errs[0] = th->ec.errinfo;
|
||||||
SAVE_ROOT_JMPBUF(th, rb_thread_terminate_all());
|
SAVE_ROOT_JMPBUF(th, rb_thread_terminate_all());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -192,7 +192,7 @@ ruby_cleanup(volatile int ex)
|
|||||||
}
|
}
|
||||||
if (ex == 0) ex = state;
|
if (ex == 0) ex = state;
|
||||||
}
|
}
|
||||||
th->errinfo = errs[1];
|
th->ec.errinfo = errs[1];
|
||||||
sysex = error_handle(ex);
|
sysex = error_handle(ex);
|
||||||
|
|
||||||
state = 0;
|
state = 0;
|
||||||
@ -201,7 +201,7 @@ ruby_cleanup(volatile int ex)
|
|||||||
|
|
||||||
if (!RTEST(err)) continue;
|
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 (THROW_DATA_P(err)) continue;
|
||||||
|
|
||||||
if (rb_obj_is_kind_of(err, rb_eSystemExit)) {
|
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;
|
int nocause = 0;
|
||||||
|
|
||||||
if (NIL_P(mesg)) {
|
if (NIL_P(mesg)) {
|
||||||
mesg = th->errinfo;
|
mesg = th->ec.errinfo;
|
||||||
if (INTERNAL_EXCEPTION_P(mesg)) TH_JUMP_TAG(th, TAG_FATAL);
|
if (INTERNAL_EXCEPTION_P(mesg)) TH_JUMP_TAG(th, TAG_FATAL);
|
||||||
nocause = 1;
|
nocause = 1;
|
||||||
}
|
}
|
||||||
@ -517,19 +517,19 @@ setup_exception(rb_thread_t *th, int tag, volatile VALUE mesg, VALUE cause)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!NIL_P(mesg)) {
|
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)) {
|
!rb_obj_is_kind_of(e, rb_eSystemExit)) {
|
||||||
enum ruby_tag_type state;
|
enum ruby_tag_type state;
|
||||||
|
|
||||||
mesg = e;
|
mesg = e;
|
||||||
TH_PUSH_TAG(th);
|
TH_PUSH_TAG(th);
|
||||||
if ((state = EXEC_TAG()) == TAG_NONE) {
|
if ((state = EXEC_TAG()) == TAG_NONE) {
|
||||||
th->errinfo = Qnil;
|
th->ec.errinfo = Qnil;
|
||||||
e = rb_obj_as_string(mesg);
|
e = rb_obj_as_string(mesg);
|
||||||
th->errinfo = mesg;
|
th->ec.errinfo = mesg;
|
||||||
if (file && line) {
|
if (file && line) {
|
||||||
e = rb_sprintf("Exception `%"PRIsVALUE"' at %s:%d - %"PRIsVALUE"\n",
|
e = rb_sprintf("Exception `%"PRIsVALUE"' at %s:%d - %"PRIsVALUE"\n",
|
||||||
rb_obj_class(mesg), file, line, e);
|
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);
|
warn_print_str(e);
|
||||||
}
|
}
|
||||||
TH_POP_TAG();
|
TH_POP_TAG();
|
||||||
if (state == TAG_FATAL && th->errinfo == exception_error) {
|
if (state == TAG_FATAL && th->ec.errinfo == exception_error) {
|
||||||
th->errinfo = mesg;
|
th->ec.errinfo = mesg;
|
||||||
}
|
}
|
||||||
else if (state) {
|
else if (state) {
|
||||||
rb_threadptr_reset_raised(th);
|
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)) {
|
if (rb_threadptr_set_raised(th)) {
|
||||||
fatal:
|
fatal:
|
||||||
th->errinfo = exception_error;
|
th->ec.errinfo = exception_error;
|
||||||
rb_threadptr_reset_raised(th);
|
rb_threadptr_reset_raised(th);
|
||||||
TH_JUMP_TAG(th, TAG_FATAL);
|
TH_JUMP_TAG(th, TAG_FATAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tag != 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);
|
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_thread_t *th = GET_THREAD();
|
||||||
rb_control_frame_t *volatile cfp = th->ec.cfp;
|
rb_control_frame_t *volatile cfp = th->ec.cfp;
|
||||||
volatile VALUE result = Qfalse;
|
volatile VALUE result = Qfalse;
|
||||||
volatile VALUE e_info = th->errinfo;
|
volatile VALUE e_info = th->ec.errinfo;
|
||||||
va_list args;
|
va_list args;
|
||||||
|
|
||||||
TH_PUSH_TAG(th);
|
TH_PUSH_TAG(th);
|
||||||
@ -809,7 +809,7 @@ rb_rescue2(VALUE (* b_proc) (ANYARGS), VALUE data1,
|
|||||||
/* escape from r_proc */
|
/* escape from r_proc */
|
||||||
if (state == TAG_RETRY) {
|
if (state == TAG_RETRY) {
|
||||||
state = 0;
|
state = 0;
|
||||||
th->errinfo = Qnil;
|
th->ec.errinfo = Qnil;
|
||||||
result = Qfalse;
|
result = Qfalse;
|
||||||
goto retry_entry;
|
goto retry_entry;
|
||||||
}
|
}
|
||||||
@ -823,7 +823,7 @@ rb_rescue2(VALUE (* b_proc) (ANYARGS), VALUE data1,
|
|||||||
|
|
||||||
va_init_list(args, data2);
|
va_init_list(args, data2);
|
||||||
while ((eclass = va_arg(args, VALUE)) != 0) {
|
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;
|
handle = TRUE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -834,9 +834,9 @@ rb_rescue2(VALUE (* b_proc) (ANYARGS), VALUE data1,
|
|||||||
result = Qnil;
|
result = Qnil;
|
||||||
state = 0;
|
state = 0;
|
||||||
if (r_proc) {
|
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);
|
result = (*b_proc) (data1);
|
||||||
}
|
}
|
||||||
TH_POP_TAG();
|
TH_POP_TAG();
|
||||||
errinfo = th->errinfo;
|
errinfo = th->ec.errinfo;
|
||||||
if (!NIL_P(errinfo) && !RB_TYPE_P(errinfo, T_OBJECT)) {
|
if (!NIL_P(errinfo) && !RB_TYPE_P(errinfo, T_OBJECT)) {
|
||||||
th->errinfo = Qnil;
|
th->ec.errinfo = Qnil;
|
||||||
}
|
}
|
||||||
th->ec.ensure_list=ensure_list.next;
|
th->ec.ensure_list=ensure_list.next;
|
||||||
(*ensure_list.entry.e_proc)(ensure_list.entry.data2);
|
(*ensure_list.entry.e_proc)(ensure_list.entry.data2);
|
||||||
th->errinfo = errinfo;
|
th->ec.errinfo = errinfo;
|
||||||
if (state)
|
if (state)
|
||||||
TH_JUMP_TAG(th, state);
|
TH_JUMP_TAG(th, state);
|
||||||
return result;
|
return result;
|
||||||
@ -1549,7 +1549,7 @@ get_thread_errinfo(rb_thread_t *th)
|
|||||||
return *ptr;
|
return *ptr;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return th->errinfo;
|
return th->ec.errinfo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1588,7 +1588,7 @@ VALUE
|
|||||||
rb_errinfo(void)
|
rb_errinfo(void)
|
||||||
{
|
{
|
||||||
rb_thread_t *th = GET_THREAD();
|
rb_thread_t *th = GET_THREAD();
|
||||||
return th->errinfo;
|
return th->ec.errinfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -1597,7 +1597,7 @@ rb_set_errinfo(VALUE err)
|
|||||||
if (!NIL_P(err) && !rb_obj_is_kind_of(err, rb_eException)) {
|
if (!NIL_P(err) && !rb_obj_is_kind_of(err, rb_eException)) {
|
||||||
rb_raise(rb_eTypeError, "assigning non-exception to $!");
|
rb_raise(rb_eTypeError, "assigning non-exception to $!");
|
||||||
}
|
}
|
||||||
GET_THREAD()->errinfo = err;
|
GET_THREAD()->ec.errinfo = err;
|
||||||
}
|
}
|
||||||
|
|
||||||
VALUE
|
VALUE
|
||||||
|
@ -69,7 +69,7 @@ set_backtrace(VALUE info, VALUE bt)
|
|||||||
static void
|
static void
|
||||||
error_print(rb_thread_t *th)
|
error_print(rb_thread_t *th)
|
||||||
{
|
{
|
||||||
rb_threadptr_error_print(th, th->errinfo);
|
rb_threadptr_error_print(th, th->ec.errinfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -202,7 +202,7 @@ rb_threadptr_error_print(rb_thread_t *volatile th, volatile VALUE errinfo)
|
|||||||
}
|
}
|
||||||
error:
|
error:
|
||||||
TH_POP_TAG();
|
TH_POP_TAG();
|
||||||
th->errinfo = errinfo;
|
th->ec.errinfo = errinfo;
|
||||||
rb_thread_raised_set(th, raised_flag);
|
rb_thread_raised_set(th, raised_flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -304,7 +304,7 @@ error_handle(int ex)
|
|||||||
warn_print("unexpected throw\n");
|
warn_print("unexpected throw\n");
|
||||||
break;
|
break;
|
||||||
case TAG_RAISE: {
|
case TAG_RAISE: {
|
||||||
VALUE errinfo = th->errinfo;
|
VALUE errinfo = th->ec.errinfo;
|
||||||
if (rb_obj_is_kind_of(errinfo, rb_eSystemExit)) {
|
if (rb_obj_is_kind_of(errinfo, rb_eSystemExit)) {
|
||||||
status = sysexit_status(errinfo);
|
status = sysexit_status(errinfo);
|
||||||
}
|
}
|
||||||
|
10
eval_jump.c
10
eval_jump.c
@ -116,26 +116,26 @@ rb_exec_end_proc(void)
|
|||||||
enum ruby_tag_type state;
|
enum ruby_tag_type state;
|
||||||
volatile int safe = rb_safe_level();
|
volatile int safe = rb_safe_level();
|
||||||
rb_thread_t *th = GET_THREAD();
|
rb_thread_t *th = GET_THREAD();
|
||||||
volatile VALUE errinfo = th->errinfo;
|
volatile VALUE errinfo = th->ec.errinfo;
|
||||||
|
|
||||||
TH_PUSH_TAG(th);
|
TH_PUSH_TAG(th);
|
||||||
if ((state = EXEC_TAG()) == TAG_NONE) {
|
if ((state = EXEC_TAG()) == TAG_NONE) {
|
||||||
again:
|
again:
|
||||||
exec_end_procs_chain(&ephemeral_end_procs, &th->errinfo);
|
exec_end_procs_chain(&ephemeral_end_procs, &th->ec.errinfo);
|
||||||
exec_end_procs_chain(&end_procs, &th->errinfo);
|
exec_end_procs_chain(&end_procs, &th->ec.errinfo);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
VAR_INITIALIZED(th);
|
VAR_INITIALIZED(th);
|
||||||
TH_TMPPOP_TAG();
|
TH_TMPPOP_TAG();
|
||||||
error_handle(state);
|
error_handle(state);
|
||||||
if (!NIL_P(th->errinfo)) errinfo = th->errinfo;
|
if (!NIL_P(th->ec.errinfo)) errinfo = th->ec.errinfo;
|
||||||
TH_REPUSH_TAG();
|
TH_REPUSH_TAG();
|
||||||
goto again;
|
goto again;
|
||||||
}
|
}
|
||||||
TH_POP_TAG();
|
TH_POP_TAG();
|
||||||
|
|
||||||
rb_set_safe_level_force(safe);
|
rb_set_safe_level_force(safe);
|
||||||
th->errinfo = errinfo;
|
th->ec.errinfo = errinfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
2
gc.c
2
gc.c
@ -7695,7 +7695,7 @@ rb_memerror(void)
|
|||||||
rb_thread_raised_set(th, RAISED_NOMEMORY);
|
rb_thread_raised_set(th, RAISED_NOMEMORY);
|
||||||
exc = ruby_vm_special_exception_copy(exc);
|
exc = ruby_vm_special_exception_copy(exc);
|
||||||
}
|
}
|
||||||
th->errinfo = exc;
|
th->ec.errinfo = exc;
|
||||||
TH_JUMP_TAG(th, TAG_RAISE);
|
TH_JUMP_TAG(th, TAG_RAISE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1584,8 +1584,8 @@ opt_call_c_function
|
|||||||
reg_cfp = (funcptr)(th, reg_cfp);
|
reg_cfp = (funcptr)(th, reg_cfp);
|
||||||
|
|
||||||
if (reg_cfp == 0) {
|
if (reg_cfp == 0) {
|
||||||
VALUE err = th->errinfo;
|
VALUE err = th->ec.errinfo;
|
||||||
th->errinfo = Qnil;
|
th->ec.errinfo = Qnil;
|
||||||
THROW_EXCEPTION(err);
|
THROW_EXCEPTION(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
4
iseq.c
4
iseq.c
@ -663,7 +663,7 @@ rb_iseq_compile_with_option(VALUE src, VALUE file, VALUE realpath, VALUE line, c
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!node) {
|
if (!node) {
|
||||||
rb_exc_raise(th->errinfo);
|
rb_exc_raise(th->ec.errinfo);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
INITIALIZED VALUE label = parent ?
|
INITIALIZED VALUE label = parent ?
|
||||||
@ -870,7 +870,7 @@ iseqw_s_compile_file(int argc, VALUE *argv, VALUE self)
|
|||||||
parser = rb_parser_new();
|
parser = rb_parser_new();
|
||||||
rb_parser_set_context(parser, NULL, FALSE);
|
rb_parser_set_context(parser, NULL, FALSE);
|
||||||
node = rb_parser_compile_file_path(parser, file, f, NUM2INT(line));
|
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);
|
rb_io_close(f);
|
||||||
if (!node) rb_exc_raise(exc);
|
if (!node) rb_exc_raise(exc);
|
||||||
|
12
load.c
12
load.c
@ -586,7 +586,7 @@ rb_load_internal0(rb_thread_t *th, VALUE fname, int wrap)
|
|||||||
rb_thread_t *volatile th0 = th;
|
rb_thread_t *volatile th0 = th;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
th->errinfo = Qnil; /* ensure */
|
th->ec.errinfo = Qnil; /* ensure */
|
||||||
|
|
||||||
if (!wrap) {
|
if (!wrap) {
|
||||||
th->top_wrapper = 0;
|
th->top_wrapper = 0;
|
||||||
@ -628,11 +628,11 @@ rb_load_internal0(rb_thread_t *th, VALUE fname, int wrap)
|
|||||||
if (state) {
|
if (state) {
|
||||||
VALUE exc = rb_vm_make_jump_tag_but_local_jump(state, Qundef);
|
VALUE exc = rb_vm_make_jump_tag_but_local_jump(state, Qundef);
|
||||||
if (NIL_P(exc)) return state;
|
if (NIL_P(exc)) return state;
|
||||||
th->errinfo = exc;
|
th->ec.errinfo = exc;
|
||||||
return TAG_RAISE;
|
return TAG_RAISE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!NIL_P(th->errinfo)) {
|
if (!NIL_P(th->ec.errinfo)) {
|
||||||
/* exception during load */
|
/* exception during load */
|
||||||
return TAG_RAISE;
|
return TAG_RAISE;
|
||||||
}
|
}
|
||||||
@ -645,7 +645,7 @@ rb_load_internal(VALUE fname, int wrap)
|
|||||||
rb_thread_t *curr_th = GET_THREAD();
|
rb_thread_t *curr_th = GET_THREAD();
|
||||||
int state = rb_load_internal0(curr_th, fname, wrap);
|
int state = rb_load_internal0(curr_th, fname, wrap);
|
||||||
if (state) {
|
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);
|
TH_JUMP_TAG(curr_th, state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -960,7 +960,7 @@ rb_require_internal(VALUE fname, int safe)
|
|||||||
{
|
{
|
||||||
volatile int result = -1;
|
volatile int result = -1;
|
||||||
rb_thread_t *th = GET_THREAD();
|
rb_thread_t *th = GET_THREAD();
|
||||||
volatile VALUE errinfo = th->errinfo;
|
volatile VALUE errinfo = th->ec.errinfo;
|
||||||
enum ruby_tag_type state;
|
enum ruby_tag_type state;
|
||||||
struct {
|
struct {
|
||||||
int safe;
|
int safe;
|
||||||
@ -1021,7 +1021,7 @@ rb_require_internal(VALUE fname, int safe)
|
|||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
th->errinfo = errinfo;
|
th->ec.errinfo = errinfo;
|
||||||
|
|
||||||
RUBY_DTRACE_HOOK(REQUIRE_RETURN, RSTRING_PTR(fname));
|
RUBY_DTRACE_HOOK(REQUIRE_RETURN, RSTRING_PTR(fname));
|
||||||
|
|
||||||
|
@ -3858,7 +3858,7 @@ rb_f_abort(int argc, const VALUE *argv)
|
|||||||
rb_check_arity(argc, 0, 1);
|
rb_check_arity(argc, 0, 1);
|
||||||
if (argc == 0) {
|
if (argc == 0) {
|
||||||
rb_thread_t *th = GET_THREAD();
|
rb_thread_t *th = GET_THREAD();
|
||||||
VALUE errinfo = th->errinfo;
|
VALUE errinfo = th->ec.errinfo;
|
||||||
if (!NIL_P(errinfo)) {
|
if (!NIL_P(errinfo)) {
|
||||||
rb_threadptr_error_print(th, errinfo);
|
rb_threadptr_error_print(th, errinfo);
|
||||||
}
|
}
|
||||||
|
16
thread.c
16
thread.c
@ -580,7 +580,7 @@ thread_do_start(rb_thread_t *th, VALUE args)
|
|||||||
if (!th->first_func) {
|
if (!th->first_func) {
|
||||||
rb_proc_t *proc;
|
rb_proc_t *proc;
|
||||||
GetProcPtr(th->first_proc, 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_lep = rb_vm_proc_local_ep(th->first_proc);
|
||||||
th->ec.root_svar = Qfalse;
|
th->ec.root_svar = Qfalse;
|
||||||
EXEC_EVENT_HOOK(th, RUBY_EVENT_THREAD_BEGIN, th->self, 0, 0, 0, Qundef);
|
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));
|
SAVE_ROOT_JMPBUF(th, thread_do_start(th, args));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
errinfo = th->errinfo;
|
errinfo = th->ec.errinfo;
|
||||||
if (state == TAG_FATAL) {
|
if (state == TAG_FATAL) {
|
||||||
/* fatal error within this thread, need to stop whole script */
|
/* 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_debug("thread_join: success (thid: %"PRI_THREAD_ID")\n",
|
||||||
thread_id_str(target_th));
|
thread_id_str(target_th));
|
||||||
|
|
||||||
if (target_th->errinfo != Qnil) {
|
if (target_th->ec.errinfo != Qnil) {
|
||||||
VALUE err = target_th->errinfo;
|
VALUE err = target_th->ec.errinfo;
|
||||||
|
|
||||||
if (FIXNUM_P(err)) {
|
if (FIXNUM_P(err)) {
|
||||||
switch (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));
|
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.");
|
rb_bug("thread_join: THROW_DATA should not reach here.");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -2008,7 +2008,7 @@ rb_threadptr_to_kill(rb_thread_t *th)
|
|||||||
rb_threadptr_pending_interrupt_clear(th);
|
rb_threadptr_pending_interrupt_clear(th);
|
||||||
th->status = THREAD_RUNNABLE;
|
th->status = THREAD_RUNNABLE;
|
||||||
th->to_kill = 1;
|
th->to_kill = 1;
|
||||||
th->errinfo = INT2FIX(TAG_FATAL);
|
th->ec.errinfo = INT2FIX(TAG_FATAL);
|
||||||
TH_JUMP_TAG(th, 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);
|
rb_thread_t *target_th = rb_thread_ptr(thread);
|
||||||
|
|
||||||
if (rb_threadptr_dead(target_th)) {
|
if (rb_threadptr_dead(target_th)) {
|
||||||
if (!NIL_P(target_th->errinfo) &&
|
if (!NIL_P(target_th->ec.errinfo) &&
|
||||||
!FIXNUM_P(target_th->errinfo)) {
|
!FIXNUM_P(target_th->ec.errinfo)) {
|
||||||
return Qnil;
|
return Qnil;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
20
vm.c
20
vm.c
@ -1476,7 +1476,7 @@ vm_iter_break(rb_thread_t *th, VALUE val)
|
|||||||
}
|
}
|
||||||
#endif
|
#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);
|
TH_JUMP_TAG(th, TAG_BREAK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1803,7 +1803,7 @@ vm_exec(rb_thread_t *th)
|
|||||||
VALUE type;
|
VALUE type;
|
||||||
const rb_control_frame_t *escape_cfp;
|
const rb_control_frame_t *escape_cfp;
|
||||||
|
|
||||||
err = (struct vm_throw_data *)th->errinfo;
|
err = (struct vm_throw_data *)th->ec.errinfo;
|
||||||
|
|
||||||
exception_handler:
|
exception_handler:
|
||||||
cont_pc = cont_sp = 0;
|
cont_pc = cont_sp = 0;
|
||||||
@ -1849,7 +1849,7 @@ vm_exec(rb_thread_t *th)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (catch_iseq == NULL) {
|
if (catch_iseq == NULL) {
|
||||||
th->errinfo = Qnil;
|
th->ec.errinfo = Qnil;
|
||||||
result = THROW_DATA_VAL(err);
|
result = THROW_DATA_VAL(err);
|
||||||
THROW_DATA_CATCH_FRAME_SET(err, cfp + 1);
|
THROW_DATA_CATCH_FRAME_SET(err, cfp + 1);
|
||||||
hook_before_rewind(th, th->ec.cfp, TRUE, state, err);
|
hook_before_rewind(th, th->ec.cfp, TRUE, state, err);
|
||||||
@ -1866,7 +1866,7 @@ vm_exec(rb_thread_t *th)
|
|||||||
#else
|
#else
|
||||||
*th->ec.cfp->sp++ = THROW_DATA_VAL(err);
|
*th->ec.cfp->sp++ = THROW_DATA_VAL(err);
|
||||||
#endif
|
#endif
|
||||||
th->errinfo = Qnil;
|
th->ec.errinfo = Qnil;
|
||||||
goto vm_loop_start;
|
goto vm_loop_start;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1905,7 +1905,7 @@ vm_exec(rb_thread_t *th)
|
|||||||
escape_cfp = THROW_DATA_CATCH_FRAME(err);
|
escape_cfp = THROW_DATA_CATCH_FRAME(err);
|
||||||
if (cfp == escape_cfp) {
|
if (cfp == escape_cfp) {
|
||||||
cfp->pc = cfp->iseq->body->iseq_encoded + entry->cont;
|
cfp->pc = cfp->iseq->body->iseq_encoded + entry->cont;
|
||||||
th->errinfo = Qnil;
|
th->ec.errinfo = Qnil;
|
||||||
goto vm_loop_start;
|
goto vm_loop_start;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1938,7 +1938,7 @@ vm_exec(rb_thread_t *th)
|
|||||||
*th->ec.cfp->sp++ = THROW_DATA_VAL(err);
|
*th->ec.cfp->sp++ = THROW_DATA_VAL(err);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
th->errinfo = Qnil;
|
th->ec.errinfo = Qnil;
|
||||||
VM_ASSERT(th->ec.tag->state == TAG_NONE);
|
VM_ASSERT(th->ec.tag->state == TAG_NONE);
|
||||||
goto vm_loop_start;
|
goto vm_loop_start;
|
||||||
}
|
}
|
||||||
@ -1990,7 +1990,7 @@ vm_exec(rb_thread_t *th)
|
|||||||
|
|
||||||
state = 0;
|
state = 0;
|
||||||
th->ec.tag->state = TAG_NONE;
|
th->ec.tag->state = TAG_NONE;
|
||||||
th->errinfo = Qnil;
|
th->ec.errinfo = Qnil;
|
||||||
goto vm_loop_start;
|
goto vm_loop_start;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -1998,7 +1998,7 @@ vm_exec(rb_thread_t *th)
|
|||||||
|
|
||||||
if (VM_FRAME_FINISHED_P(th->ec.cfp)) {
|
if (VM_FRAME_FINISHED_P(th->ec.cfp)) {
|
||||||
rb_vm_pop_frame(th);
|
rb_vm_pop_frame(th);
|
||||||
th->errinfo = (VALUE)err;
|
th->ec.errinfo = (VALUE)err;
|
||||||
TH_TMPPOP_TAG();
|
TH_TMPPOP_TAG();
|
||||||
TH_JUMP_TAG(th, state);
|
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->thgroup);
|
||||||
RUBY_MARK_UNLESS_NULL(th->value);
|
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_queue);
|
||||||
RUBY_MARK_UNLESS_NULL(th->pending_interrupt_mask_stack);
|
RUBY_MARK_UNLESS_NULL(th->pending_interrupt_mask_stack);
|
||||||
RUBY_MARK_UNLESS_NULL(th->ec.root_svar);
|
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);
|
0 /* dummy pc */, th->ec.stack, 0, 0);
|
||||||
|
|
||||||
th->status = THREAD_RUNNABLE;
|
th->status = THREAD_RUNNABLE;
|
||||||
th->errinfo = Qnil;
|
|
||||||
th->last_status = Qnil;
|
th->last_status = Qnil;
|
||||||
|
th->ec.errinfo = Qnil;
|
||||||
th->ec.root_svar = Qfalse;
|
th->ec.root_svar = Qfalse;
|
||||||
th->ec.local_storage_recursive_hash = Qnil;
|
th->ec.local_storage_recursive_hash = Qnil;
|
||||||
th->ec.local_storage_recursive_hash_for_trace = Qnil;
|
th->ec.local_storage_recursive_hash_for_trace = Qnil;
|
||||||
|
11
vm_core.h
11
vm_core.h
@ -743,10 +743,12 @@ typedef struct rb_thread_context_struct {
|
|||||||
|
|
||||||
struct rb_vm_tag *tag;
|
struct rb_vm_tag *tag;
|
||||||
struct rb_vm_protect_tag *protect_tag;
|
struct rb_vm_protect_tag *protect_tag;
|
||||||
|
|
||||||
int safe_level;
|
int safe_level;
|
||||||
int raised_flag;
|
int raised_flag;
|
||||||
|
|
||||||
|
/* temporary place of errinfo */
|
||||||
|
VALUE errinfo;
|
||||||
|
|
||||||
/* storage (ec (fiber) local) */
|
/* storage (ec (fiber) local) */
|
||||||
st_table *local_storage;
|
st_table *local_storage;
|
||||||
VALUE local_storage_recursive_hash;
|
VALUE local_storage_recursive_hash;
|
||||||
@ -756,6 +758,9 @@ typedef struct rb_thread_context_struct {
|
|||||||
const VALUE *root_lep;
|
const VALUE *root_lep;
|
||||||
VALUE root_svar;
|
VALUE root_svar;
|
||||||
|
|
||||||
|
/* trace information */
|
||||||
|
struct rb_trace_arg_struct *trace_arg;
|
||||||
|
|
||||||
/* ensure & callcc */
|
/* ensure & callcc */
|
||||||
rb_ensure_list_t *ensure_list;
|
rb_ensure_list_t *ensure_list;
|
||||||
} rb_execution_context_t;
|
} rb_execution_context_t;
|
||||||
@ -797,9 +802,6 @@ typedef struct rb_thread_struct {
|
|||||||
VALUE thgroup;
|
VALUE thgroup;
|
||||||
VALUE value;
|
VALUE value;
|
||||||
|
|
||||||
/* temporary place of errinfo */
|
|
||||||
VALUE errinfo;
|
|
||||||
|
|
||||||
/* temporary place of retval on OPT_CALL_THREADED_CODE */
|
/* temporary place of retval on OPT_CALL_THREADED_CODE */
|
||||||
#if OPT_CALL_THREADED_CODE
|
#if OPT_CALL_THREADED_CODE
|
||||||
VALUE retval;
|
VALUE retval;
|
||||||
@ -841,7 +843,6 @@ typedef struct rb_thread_struct {
|
|||||||
|
|
||||||
/* tracer */
|
/* tracer */
|
||||||
rb_hook_list_t event_hooks;
|
rb_hook_list_t event_hooks;
|
||||||
struct rb_trace_arg_struct *trace_arg; /* trace information */
|
|
||||||
|
|
||||||
/* fiber */
|
/* fiber */
|
||||||
rb_fiber_t *fiber;
|
rb_fiber_t *fiber;
|
||||||
|
14
vm_eval.c
14
vm_eval.c
@ -1129,7 +1129,7 @@ rb_iterate0(VALUE (* it_proc) (VALUE), VALUE data1,
|
|||||||
retval = (*it_proc) (data1);
|
retval = (*it_proc) (data1);
|
||||||
}
|
}
|
||||||
else if (state == TAG_BREAK || state == TAG_RETRY) {
|
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);
|
const rb_control_frame_t *const escape_cfp = THROW_DATA_CATCH_FRAME(err);
|
||||||
|
|
||||||
if (cfp == escape_cfp) {
|
if (cfp == escape_cfp) {
|
||||||
@ -1137,7 +1137,7 @@ rb_iterate0(VALUE (* it_proc) (VALUE), VALUE data1,
|
|||||||
|
|
||||||
state = 0;
|
state = 0;
|
||||||
th->ec.tag->state = TAG_NONE;
|
th->ec.tag->state = TAG_NONE;
|
||||||
th->errinfo = Qnil;
|
th->ec.errinfo = Qnil;
|
||||||
|
|
||||||
if (state == TAG_RETRY) goto iter_retry;
|
if (state == TAG_RETRY) goto iter_retry;
|
||||||
retval = THROW_DATA_VAL(err);
|
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);
|
iseq = rb_iseq_compile_with_option(src, fname, realpath, INT2FIX(line), base_block, Qnil);
|
||||||
|
|
||||||
if (!iseq) {
|
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? */
|
/* 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) {
|
||||||
if (state == TAG_RAISE) {
|
if (state == TAG_RAISE) {
|
||||||
adjust_backtrace_in_eval(th, th->errinfo);
|
adjust_backtrace_in_eval(th, th->ec.errinfo);
|
||||||
}
|
}
|
||||||
TH_JUMP_TAG(th, state);
|
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));
|
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);
|
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 */
|
/* call with argc=1, argv = [tag], block = Qnil to insure compatibility */
|
||||||
val = (*func)(tag, data, 1, (const VALUE *)&tag, Qnil);
|
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);
|
rb_vm_rewind_cfp(th, saved_cfp);
|
||||||
val = th->ec.tag->retval;
|
val = th->ec.tag->retval;
|
||||||
th->errinfo = Qnil;
|
th->ec.errinfo = Qnil;
|
||||||
state = 0;
|
state = 0;
|
||||||
}
|
}
|
||||||
TH_POP_TAG();
|
TH_POP_TAG();
|
||||||
|
@ -162,8 +162,8 @@ vm_exec_core(rb_thread_t *th, VALUE initial)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
VALUE err = th->errinfo;
|
VALUE err = th->ec.errinfo;
|
||||||
th->errinfo = Qnil;
|
th->ec.errinfo = Qnil;
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -161,7 +161,7 @@ default: \
|
|||||||
|
|
||||||
#if OPT_CALL_THREADED_CODE
|
#if OPT_CALL_THREADED_CODE
|
||||||
#define THROW_EXCEPTION(exc) do { \
|
#define THROW_EXCEPTION(exc) do { \
|
||||||
th->errinfo = (VALUE)(exc); \
|
th->ec.errinfo = (VALUE)(exc); \
|
||||||
return 0; \
|
return 0; \
|
||||||
} while (0)
|
} while (0)
|
||||||
#else
|
#else
|
||||||
|
@ -42,7 +42,7 @@ threadptr_stack_overflow(rb_thread_t *th, int setup)
|
|||||||
rb_ivar_set(mesg, idBt, at);
|
rb_ivar_set(mesg, idBt, at);
|
||||||
rb_ivar_set(mesg, idBt_locations, at);
|
rb_ivar_set(mesg, idBt_locations, at);
|
||||||
}
|
}
|
||||||
th->errinfo = mesg;
|
th->ec.errinfo = mesg;
|
||||||
TH_JUMP_TAG(th, TAG_RAISE);
|
TH_JUMP_TAG(th, TAG_RAISE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
36
vm_trace.c
36
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;
|
rb_thread_t *th = trace_arg->th;
|
||||||
|
|
||||||
if (trace_arg->event & RUBY_INTERNAL_EVENT_MASK) {
|
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 */
|
/* skip hooks because this thread doing INTERNAL_EVENT */
|
||||||
}
|
}
|
||||||
else {
|
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->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->event_hooks, trace_arg);
|
||||||
exec_hooks_unprotected(th, &th->vm->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--;
|
th->vm->trace_running--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
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. */) {
|
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;
|
const VALUE old_recursive = th->ec.local_storage_recursive_hash;
|
||||||
int state = 0;
|
int state = 0;
|
||||||
|
|
||||||
th->ec.local_storage_recursive_hash = th->ec.local_storage_recursive_hash_for_trace;
|
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->vm->trace_running++;
|
||||||
th->trace_arg = trace_arg;
|
th->ec.trace_arg = trace_arg;
|
||||||
{
|
{
|
||||||
/* thread local traces */
|
/* thread local traces */
|
||||||
state = exec_hooks_protected(th, &th->event_hooks, trace_arg);
|
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);
|
state = exec_hooks_protected(th, &th->vm->event_hooks, trace_arg);
|
||||||
if (state) goto terminate;
|
if (state) goto terminate;
|
||||||
|
|
||||||
th->errinfo = errinfo;
|
th->ec.errinfo = errinfo;
|
||||||
}
|
}
|
||||||
terminate:
|
terminate:
|
||||||
th->trace_arg = 0;
|
th->ec.trace_arg = NULL;
|
||||||
th->vm->trace_running--;
|
th->vm->trace_running--;
|
||||||
|
|
||||||
th->ec.local_storage_recursive_hash_for_trace = th->ec.local_storage_recursive_hash;
|
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;
|
VALUE result = Qnil;
|
||||||
rb_thread_t *volatile th = GET_THREAD();
|
rb_thread_t *volatile th = GET_THREAD();
|
||||||
enum ruby_tag_type state;
|
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;
|
rb_trace_arg_t dummy_trace_arg;
|
||||||
dummy_trace_arg.event = 0;
|
dummy_trace_arg.event = 0;
|
||||||
|
|
||||||
if (!tracing) th->vm->trace_running++;
|
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);
|
raised = rb_threadptr_reset_raised(th);
|
||||||
|
|
||||||
@ -398,7 +398,7 @@ rb_suppress_tracing(VALUE (*func)(VALUE), VALUE arg)
|
|||||||
rb_threadptr_set_raised(th);
|
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 (!tracing) th->vm->trace_running--;
|
||||||
|
|
||||||
if (state) {
|
if (state) {
|
||||||
@ -703,7 +703,7 @@ tpptr(VALUE tpval)
|
|||||||
static rb_trace_arg_t *
|
static rb_trace_arg_t *
|
||||||
get_trace_arg(void)
|
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) {
|
if (trace_arg == 0) {
|
||||||
rb_raise(rb_eRuntimeError, "access from outside");
|
rb_raise(rb_eRuntimeError, "access from outside");
|
||||||
}
|
}
|
||||||
@ -1307,7 +1307,7 @@ static VALUE
|
|||||||
tracepoint_inspect(VALUE self)
|
tracepoint_inspect(VALUE self)
|
||||||
{
|
{
|
||||||
rb_tp_t *tp = tpptr(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) {
|
if (trace_arg) {
|
||||||
switch (trace_arg->event) {
|
switch (trace_arg->event) {
|
||||||
@ -1591,9 +1591,9 @@ rb_postponed_job_flush(rb_vm_t *vm)
|
|||||||
rb_thread_t *th = GET_THREAD();
|
rb_thread_t *th = GET_THREAD();
|
||||||
const unsigned long block_mask = POSTPONED_JOB_INTERRUPT_MASK|TRAP_INTERRUPT_MASK;
|
const unsigned long block_mask = POSTPONED_JOB_INTERRUPT_MASK|TRAP_INTERRUPT_MASK;
|
||||||
unsigned long saved_mask = th->interrupt_mask & block_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 */
|
/* mask POSTPONED_JOB dispatch */
|
||||||
th->interrupt_mask |= block_mask;
|
th->interrupt_mask |= block_mask;
|
||||||
{
|
{
|
||||||
@ -1611,5 +1611,5 @@ rb_postponed_job_flush(rb_vm_t *vm)
|
|||||||
}
|
}
|
||||||
/* restore POSTPONED_JOB mask */
|
/* restore POSTPONED_JOB mask */
|
||||||
th->interrupt_mask &= ~(saved_mask ^ block_mask);
|
th->interrupt_mask &= ~(saved_mask ^ block_mask);
|
||||||
th->errinfo = saved_errno;
|
th->ec.errinfo = saved_errno;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user