rb_ec_error_print().

* eval_error.c (rb_threadptr_error_print): renamed to
  rb_ec_error_print() and it accepts `ec`.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60545 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ko1 2017-10-29 14:06:58 +00:00
parent 5256f77527
commit a93c650312
5 changed files with 20 additions and 20 deletions

2
eval.c
View File

@ -78,7 +78,7 @@ ruby_init(void)
int state = ruby_setup(); int state = ruby_setup();
if (state) { if (state) {
if (RTEST(ruby_debug)) if (RTEST(ruby_debug))
error_print(GET_THREAD()); error_print(GET_EC());
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
} }

View File

@ -67,9 +67,9 @@ set_backtrace(VALUE info, VALUE bt)
} }
static void static void
error_print(rb_thread_t *th) error_print(rb_execution_context_t *ec)
{ {
rb_threadptr_error_print(th, th->ec->errinfo); rb_ec_error_print(ec, ec->errinfo);
} }
static void static void
@ -164,17 +164,17 @@ print_backtrace(const VALUE eclass, const VALUE errat, int reverse)
} }
void void
rb_threadptr_error_print(rb_thread_t *volatile th, volatile VALUE errinfo) rb_ec_error_print(rb_execution_context_t * volatile ec, volatile VALUE errinfo)
{ {
volatile VALUE errat = Qundef; volatile VALUE errat = Qundef;
volatile int raised_flag = th->ec->raised_flag; volatile int raised_flag = ec->raised_flag;
volatile VALUE eclass = Qundef, emesg = Qundef; volatile VALUE eclass = Qundef, emesg = Qundef;
if (NIL_P(errinfo)) if (NIL_P(errinfo))
return; return;
rb_thread_raised_clear(th); rb_thread_raised_clear(rb_ec_thread_ptr(ec));
EC_PUSH_TAG(th->ec); EC_PUSH_TAG(ec);
if (EC_EXEC_TAG() == TAG_NONE) { if (EC_EXEC_TAG() == TAG_NONE) {
errat = rb_get_backtrace(errinfo); errat = rb_get_backtrace(errinfo);
} }
@ -202,8 +202,8 @@ rb_threadptr_error_print(rb_thread_t *volatile th, volatile VALUE errinfo)
} }
error: error:
EC_POP_TAG(); EC_POP_TAG();
th->ec->errinfo = errinfo; ec->errinfo = errinfo;
rb_thread_raised_set(th, raised_flag); rb_thread_raised_set(rb_ec_thread_ptr(ec), raised_flag);
} }
#define undef_mesg_for(v, k) rb_fstring_cstr("undefined"v" method `%1$s' for "k" `%2$s'") #define undef_mesg_for(v, k) rb_fstring_cstr("undefined"v" method `%1$s' for "k" `%2$s'")
@ -269,9 +269,9 @@ static int
error_handle(int ex) error_handle(int ex)
{ {
int status = EXIT_FAILURE; int status = EXIT_FAILURE;
rb_thread_t *th = GET_THREAD(); rb_execution_context_t *ec = GET_EC();
if (rb_threadptr_set_raised(th)) if (rb_threadptr_set_raised(rb_ec_thread_ptr(ec)))
return EXIT_FAILURE; return EXIT_FAILURE;
switch (ex & TAG_MASK) { switch (ex & TAG_MASK) {
case 0: case 0:
@ -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->ec->errinfo; VALUE errinfo = 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);
} }
@ -313,17 +313,17 @@ error_handle(int ex)
/* no message when exiting by signal */ /* no message when exiting by signal */
} }
else { else {
rb_threadptr_error_print(th, errinfo); rb_ec_error_print(ec, errinfo);
} }
break; break;
} }
case TAG_FATAL: case TAG_FATAL:
error_print(th); error_print(ec);
break; break;
default: default:
unknown_longjmp_status(ex); unknown_longjmp_status(ex);
break; break;
} }
rb_threadptr_reset_raised(th); rb_threadptr_reset_raised(rb_ec_thread_ptr(ec));
return status; return status;
} }

View File

@ -3850,10 +3850,10 @@ 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_execution_context_t *ec = GET_EC();
VALUE errinfo = th->ec->errinfo; VALUE errinfo = ec->errinfo;
if (!NIL_P(errinfo)) { if (!NIL_P(errinfo)) {
rb_threadptr_error_print(th, errinfo); rb_ec_error_print(ec, errinfo);
} }
rb_exit(EXIT_FAILURE); rb_exit(EXIT_FAILURE);
} }

View File

@ -642,7 +642,7 @@ thread_start_func_2(rb_thread_t *th, VALUE *stack_start, VALUE *register_stack_s
VALUE mesg = rb_thread_to_s(th->self); VALUE mesg = rb_thread_to_s(th->self);
rb_str_cat_cstr(mesg, " terminated with exception:\n"); rb_str_cat_cstr(mesg, " terminated with exception:\n");
rb_write_error_str(mesg); rb_write_error_str(mesg);
rb_threadptr_error_print(th, errinfo); rb_ec_error_print(th->ec, errinfo);
} }
if (th->vm->thread_abort_on_exception || if (th->vm->thread_abort_on_exception ||
th->abort_on_exception || RTEST(ruby_debug)) { th->abort_on_exception || RTEST(ruby_debug)) {

View File

@ -1676,7 +1676,7 @@ void rb_threadptr_unlock_all_locking_mutexes(rb_thread_t *th);
void rb_threadptr_pending_interrupt_clear(rb_thread_t *th); void rb_threadptr_pending_interrupt_clear(rb_thread_t *th);
void rb_threadptr_pending_interrupt_enque(rb_thread_t *th, VALUE v); void rb_threadptr_pending_interrupt_enque(rb_thread_t *th, VALUE v);
int rb_threadptr_pending_interrupt_active_p(rb_thread_t *th); int rb_threadptr_pending_interrupt_active_p(rb_thread_t *th);
void rb_threadptr_error_print(rb_thread_t *volatile th, volatile VALUE errinfo); void rb_ec_error_print(rb_execution_context_t * volatile ec, volatile VALUE errinfo);
void rb_execution_context_mark(const rb_execution_context_t *ec); void rb_execution_context_mark(const rb_execution_context_t *ec);
void rb_fiber_close(rb_fiber_t *fib); void rb_fiber_close(rb_fiber_t *fib);
void Init_native_thread(rb_thread_t *th); void Init_native_thread(rb_thread_t *th);