[前][次][番号順一覧][スレッド一覧]

ruby-changes:48403

From: ko1 <ko1@a...>
Date: Sat, 28 Oct 2017 20:41:12 +0900 (JST)
Subject: [ruby-changes:48403] ko1:r60517 (trunk): `th` -> `ec` for rb_longjmp() and related functions.

ko1	2017-10-28 20:41:08 +0900 (Sat, 28 Oct 2017)

  New Revision: 60517

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=60517

  Log:
    `th` -> `ec` for rb_longjmp() and related functions.
    
    * eval.c: `th` -> `ec` for the following functions:
      * rb_longjmp
      * exc_setup_message
      * setup_exception
      * errinfo_place
    
    * eval.c (get_thread_errinfo): rename to get_ec_errinfo() and accepts `ec`.

  Modified files:
    trunk/eval.c
    trunk/eval_intern.h
Index: eval_intern.h
===================================================================
--- eval_intern.h	(revision 60516)
+++ eval_intern.h	(revision 60517)
@@ -183,9 +183,9 @@ rb_threadptr_tag_state(const rb_executio https://github.com/ruby/ruby/blob/trunk/eval_intern.h#L183
     return state;
 }
 
-NORETURN(static inline void rb_ec_tag_jump(rb_execution_context_t *ec, enum ruby_tag_type st));
+NORETURN(static inline void rb_ec_tag_jump(const rb_execution_context_t *ec, enum ruby_tag_type st));
 static inline void
-rb_ec_tag_jump(rb_execution_context_t *ec, enum ruby_tag_type st)
+rb_ec_tag_jump(const rb_execution_context_t *ec, enum ruby_tag_type st)
 {
     ec->tag->state = st;
     ruby_longjmp(ec->tag->buf, 1);
Index: eval.c
===================================================================
--- eval.c	(revision 60516)
+++ eval.c	(revision 60517)
@@ -442,9 +442,9 @@ rb_frozen_class_p(VALUE klass) https://github.com/ruby/ruby/blob/trunk/eval.c#L442
     }
 }
 
-NORETURN(static void rb_longjmp(rb_thread_t *, int, volatile VALUE, VALUE));
+NORETURN(static void rb_longjmp(rb_execution_context_t *, int, volatile VALUE, VALUE));
 static VALUE get_errinfo(void);
-static VALUE get_thread_errinfo(rb_thread_t *th);
+static VALUE get_ec_errinfo(const rb_execution_context_t *ec);
 
 static VALUE
 exc_setup_cause(VALUE exc, VALUE cause)
@@ -473,13 +473,13 @@ exc_setup_cause(VALUE exc, VALUE cause) https://github.com/ruby/ruby/blob/trunk/eval.c#L473
 }
 
 static inline VALUE
-exc_setup_message(rb_thread_t *th, VALUE mesg, VALUE *cause)
+exc_setup_message(const rb_execution_context_t *ec, VALUE mesg, VALUE *cause)
 {
     int nocause = 0;
 
     if (NIL_P(mesg)) {
-	mesg = th->ec->errinfo;
-	if (INTERNAL_EXCEPTION_P(mesg)) EC_JUMP_TAG(th->ec, TAG_FATAL);
+	mesg = ec->errinfo;
+	if (INTERNAL_EXCEPTION_P(mesg)) EC_JUMP_TAG(ec, TAG_FATAL);
 	nocause = 1;
     }
     if (NIL_P(mesg)) {
@@ -491,14 +491,14 @@ exc_setup_message(rb_thread_t *th, VALUE https://github.com/ruby/ruby/blob/trunk/eval.c#L491
 	    *cause = Qnil;
 	}
 	else if (!rb_ivar_defined(mesg, id_cause)) {
-	    *cause = get_thread_errinfo(th);
+	    *cause = get_ec_errinfo(ec);
 	}
     }
     return mesg;
 }
 
 static void
-setup_exception(rb_thread_t *th, int tag, volatile VALUE mesg, VALUE cause)
+setup_exception(rb_execution_context_t *ec, int tag, volatile VALUE mesg, VALUE cause)
 {
     VALUE e;
     const char *file = 0;
@@ -508,8 +508,8 @@ setup_exception(rb_thread_t *th, int tag https://github.com/ruby/ruby/blob/trunk/eval.c#L508
     if ((file && !NIL_P(mesg)) || (cause != Qundef))  {
 	volatile int state = 0;
 
-	EC_PUSH_TAG(th->ec);
-	if (EXEC_TAG() == TAG_NONE && !(state = rb_threadptr_set_raised(th))) {
+	EC_PUSH_TAG(ec);
+	if (EXEC_TAG() == TAG_NONE && !(state = rb_threadptr_set_raised(rb_ec_thread_ptr(ec)))) {
 	    VALUE bt = rb_get_backtrace(mesg);
 	    if (!NIL_P(bt) || cause == Qundef) {
 		if (OBJ_FROZEN(mesg)) {
@@ -520,30 +520,30 @@ setup_exception(rb_thread_t *th, int tag https://github.com/ruby/ruby/blob/trunk/eval.c#L520
 		exc_setup_cause(mesg, cause);
 	    }
 	    if (NIL_P(bt)) {
-		VALUE at = rb_threadptr_backtrace_object(th);
+		VALUE at = rb_threadptr_backtrace_object(rb_ec_thread_ptr(ec));
 		rb_ivar_set(mesg, idBt_locations, at);
 		set_backtrace(mesg, at);
 	    }
-	    rb_threadptr_reset_raised(th);
+	    rb_threadptr_reset_raised(rb_ec_thread_ptr(ec));
 	}
 	EC_POP_TAG();
 	if (state) goto fatal;
     }
 
     if (!NIL_P(mesg)) {
-	th->ec->errinfo = mesg;
+	ec->errinfo = mesg;
     }
 
-    if (RTEST(ruby_debug) && !NIL_P(e = th->ec->errinfo) &&
+    if (RTEST(ruby_debug) && !NIL_P(e = ec->errinfo) &&
 	!rb_obj_is_kind_of(e, rb_eSystemExit)) {
 	enum ruby_tag_type state;
 
 	mesg = e;
-	EC_PUSH_TAG(th->ec);
+	EC_PUSH_TAG(ec);
 	if ((state = EXEC_TAG()) == TAG_NONE) {
-	    th->ec->errinfo = Qnil;
+	    ec->errinfo = Qnil;
 	    e = rb_obj_as_string(mesg);
-	    th->ec->errinfo = mesg;
+	    ec->errinfo = mesg;
 	    if (file && line) {
 		e = rb_sprintf("Exception `%"PRIsVALUE"' at %s:%d - %"PRIsVALUE"\n",
 			       rb_obj_class(mesg), file, line, e);
@@ -559,25 +559,25 @@ setup_exception(rb_thread_t *th, int tag https://github.com/ruby/ruby/blob/trunk/eval.c#L559
 	    warn_print_str(e);
 	}
 	EC_POP_TAG();
-	if (state == TAG_FATAL && th->ec->errinfo == exception_error) {
-	    th->ec->errinfo = mesg;
+	if (state == TAG_FATAL && ec->errinfo == exception_error) {
+	    ec->errinfo = mesg;
 	}
 	else if (state) {
-	    rb_threadptr_reset_raised(th);
-	    EC_JUMP_TAG(th->ec, state);
+	    rb_threadptr_reset_raised(rb_ec_thread_ptr(ec));
+	    EC_JUMP_TAG(ec, state);
 	}
     }
 
-    if (rb_threadptr_set_raised(th)) {
+    if (rb_threadptr_set_raised(rb_ec_thread_ptr(ec))) {
       fatal:
-	th->ec->errinfo = exception_error;
-	rb_threadptr_reset_raised(th);
-	EC_JUMP_TAG(th->ec, TAG_FATAL);
+	ec->errinfo = exception_error;
+	rb_threadptr_reset_raised(rb_ec_thread_ptr(ec));
+	EC_JUMP_TAG(ec, TAG_FATAL);
     }
 
     if (tag != TAG_FATAL) {
-	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);
+	RUBY_DTRACE_HOOK(RAISE, rb_obj_classname(ec->errinfo));
+	EXEC_EVENT_HOOK(rb_ec_thread_ptr(ec), RUBY_EVENT_RAISE, ec->cfp->self, 0, 0, 0, mesg);
     }
 }
 
@@ -586,7 +586,7 @@ void https://github.com/ruby/ruby/blob/trunk/eval.c#L586
 rb_threadptr_setup_exception(rb_thread_t *th, VALUE mesg, VALUE cause)
 {
     if (cause == Qundef) {
-	cause = get_thread_errinfo(th);
+	cause = get_ec_errinfo(th->ec);
     }
     if (cause != mesg) {
 	rb_ivar_set(mesg, id_cause, cause);
@@ -594,12 +594,12 @@ rb_threadptr_setup_exception(rb_thread_t https://github.com/ruby/ruby/blob/trunk/eval.c#L594
 }
 
 static void
-rb_longjmp(rb_thread_t *th, int tag, volatile VALUE mesg, VALUE cause)
+rb_longjmp(rb_execution_context_t *ec, int tag, volatile VALUE mesg, VALUE cause)
 {
-    mesg = exc_setup_message(th, mesg, &cause);
-    setup_exception(th, tag, mesg, cause);
-    rb_thread_raised_clear(th);
-    EC_JUMP_TAG(th->ec, tag);
+    mesg = exc_setup_message(ec, mesg, &cause);
+    setup_exception(ec, tag, mesg, cause);
+    rb_thread_raised_clear(rb_ec_thread_ptr(ec));
+    EC_JUMP_TAG(ec, tag);
 }
 
 static VALUE make_exception(int argc, const VALUE *argv, int isstr);
@@ -617,7 +617,7 @@ rb_exc_raise(VALUE mesg) https://github.com/ruby/ruby/blob/trunk/eval.c#L617
     if (!NIL_P(mesg)) {
 	mesg = make_exception(1, &mesg, FALSE);
     }
-    rb_longjmp(GET_THREAD(), TAG_RAISE, mesg, Qundef);
+    rb_longjmp(GET_EC(), TAG_RAISE, mesg, Qundef);
 }
 
 /*!
@@ -633,7 +633,7 @@ rb_exc_fatal(VALUE mesg) https://github.com/ruby/ruby/blob/trunk/eval.c#L633
     if (!NIL_P(mesg)) {
 	mesg = make_exception(1, &mesg, FALSE);
     }
-    rb_longjmp(GET_THREAD(), TAG_FATAL, mesg, Qnil);
+    rb_longjmp(GET_EC(), TAG_FATAL, mesg, Qnil);
 }
 
 /*!
@@ -806,7 +806,7 @@ rb_raise_jump(VALUE mesg, VALUE cause) https://github.com/ruby/ruby/blob/trunk/eval.c#L806
     rb_vm_pop_frame(th->ec);
     EXEC_EVENT_HOOK(th, RUBY_EVENT_C_RETURN, self, me->def->original_id, mid, klass, Qnil);
 
-    rb_longjmp(th, TAG_RAISE, mesg, cause);
+    rb_longjmp(th->ec, TAG_RAISE, mesg, cause);
 }
 
 /*!
@@ -1722,10 +1722,10 @@ top_using(VALUE self, VALUE module) https://github.com/ruby/ruby/blob/trunk/eval.c#L1722
 }
 
 static const VALUE *
-errinfo_place(const rb_thread_t *th)
+errinfo_place(const rb_execution_context_t *ec)
 {
-    const rb_control_frame_t *cfp = th->ec->cfp;
-    const rb_control_frame_t *end_cfp = RUBY_VM_END_CONTROL_FRAME(th->ec);
+    const rb_control_frame_t *cfp = ec->cfp;
+    const rb_control_frame_t *end_cfp = RUBY_VM_END_CONTROL_FRAME(ec);
 
     while (RUBY_VM_VALID_CONTROL_FRAME_P(cfp, end_cfp)) {
 	if (VM_FRAME_RUBYFRAME_P(cfp)) {
@@ -1744,21 +1744,21 @@ errinfo_place(const rb_thread_t *th) https://github.com/ruby/ruby/blob/trunk/eval.c#L1744
 }
 
 static VALUE
-get_thread_errinfo(rb_thread_t *th)
+get_ec_errinfo(const rb_execution_context_t *ec)
 {
-    const VALUE *ptr = errinfo_place(th);
+    const VALUE *ptr = errinfo_place(ec);
     if (ptr) {
 	return *ptr;
     }
     else {
-	return th->ec->errinfo;
+	return ec->errinfo;
     }
 }
 
 static VALUE
 get_errinfo(void)
 {
-    return get_thread_errinfo(GET_THREAD());
+    return get_ec_errinfo(GET_EC());
 }
 
 static VALUE

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]