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

ruby-changes:47905

From: nobu <ko1@a...>
Date: Tue, 26 Sep 2017 06:52:02 +0900 (JST)
Subject: [ruby-changes:47905] nobu:r60024 (trunk): vm.c: fetch retval iff necessary

nobu	2017-09-26 06:51:56 +0900 (Tue, 26 Sep 2017)

  New Revision: 60024

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

  Log:
    vm.c: fetch retval iff necessary
    
    * vm.c (rb_vm_make_jump_tag_but_local_jump): get rid of fetching
      retval when it is not used.  it is necessary for local jump
      state only.

  Modified files:
    trunk/load.c
    trunk/vm.c
Index: load.c
===================================================================
--- load.c	(revision 60023)
+++ load.c	(revision 60024)
@@ -627,6 +627,8 @@ rb_load_internal0(rb_thread_t *th, VALUE https://github.com/ruby/ruby/blob/trunk/load.c#L627
     th->top_wrapper = wrapper;
 
     if (state) {
+	/* usually state == TAG_RAISE only, except for
+	 * rb_iseq_load_iseq case */
 	VALUE exc = rb_vm_make_jump_tag_but_local_jump(state, Qundef);
 	if (NIL_P(exc)) return state;
 	th->ec.errinfo = exc;
Index: vm.c
===================================================================
--- vm.c	(revision 60023)
+++ vm.c	(revision 60024)
@@ -1421,33 +1421,33 @@ rb_vm_localjump_error(const char *mesg, https://github.com/ruby/ruby/blob/trunk/vm.c#L1421
 VALUE
 rb_vm_make_jump_tag_but_local_jump(int state, VALUE val)
 {
-    VALUE result = Qnil;
+    const char *mesg;
 
-    if (val == Qundef) {
-	val = GET_THREAD()->ec.tag->retval;
-    }
     switch (state) {
-      case 0:
-	break;
       case TAG_RETURN:
-	result = make_localjump_error("unexpected return", val, state);
+	mesg = "unexpected return";
 	break;
       case TAG_BREAK:
-	result = make_localjump_error("unexpected break", val, state);
+	mesg = "unexpected break";
 	break;
       case TAG_NEXT:
-	result = make_localjump_error("unexpected next", val, state);
+	mesg = "unexpected next";
 	break;
       case TAG_REDO:
-	result = make_localjump_error("unexpected redo", Qnil, state);
+	mesg = "unexpected redo";
+	val = Qnil;
 	break;
       case TAG_RETRY:
-	result = make_localjump_error("retry outside of rescue clause", Qnil, state);
+	mesg = "retry outside of rescue clause";
+	val = Qnil;
 	break;
       default:
-	break;
+	return Qnil;
+    }
+    if (val == Qundef) {
+	val = GET_THREAD()->ec.tag->retval;
     }
-    return result;
+    return make_localjump_error(mesg, val, state);
 }
 
 void

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

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