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

ruby-changes:32107

From: nobu <ko1@a...>
Date: Sat, 14 Dec 2013 01:32:05 +0900 (JST)
Subject: [ruby-changes:32107] nobu:r44186 (trunk): eval.c: reuse tag

nobu	2013-12-14 01:32:00 +0900 (Sat, 14 Dec 2013)

  New Revision: 44186

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=44186

  Log:
    eval.c: reuse tag
    
    * eval.c (rb_rescue2): reuse tags pushed for body proc to protect
      rescue proc too.

  Modified files:
    trunk/ChangeLog
    trunk/eval.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 44185)
+++ ChangeLog	(revision 44186)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sat Dec 14 01:31:52 2013  Nobuyoshi Nakada  <nobu@r...>
+
+	* eval.c (rb_rescue2): reuse tags pushed for body proc to protect
+	  rescue proc too.
+
 Sat Dec 14 01:15:51 2013  Masaya Tarui  <tarui@r...>
 
 	* gc.c (wmap_final_func): Bugfix. Should update *value to new pointer.
Index: eval.c
===================================================================
--- eval.c	(revision 44185)
+++ eval.c	(revision 44186)
@@ -741,7 +741,7 @@ rb_rescue2(VALUE (* b_proc) (ANYARGS), V https://github.com/ruby/ruby/blob/trunk/eval.c#L741
     int state;
     rb_thread_t *th = GET_THREAD();
     rb_control_frame_t *cfp = th->cfp;
-    volatile VALUE result;
+    volatile VALUE result = Qfalse;
     volatile VALUE e_info = th->errinfo;
     va_list args;
 
@@ -750,6 +750,15 @@ rb_rescue2(VALUE (* b_proc) (ANYARGS), V https://github.com/ruby/ruby/blob/trunk/eval.c#L750
       retry_entry:
 	result = (*b_proc) (data1);
     }
+    else if (result) {
+	/* escape from r_proc */
+	if (state == TAG_RETRY) {
+	    state = 0;
+	    th->errinfo = Qnil;
+	    result = Qfalse;
+	    goto retry_entry;
+	}
+    }
     else {
 	th->cfp = cfp; /* restore */
 
@@ -767,25 +776,12 @@ rb_rescue2(VALUE (* b_proc) (ANYARGS), V https://github.com/ruby/ruby/blob/trunk/eval.c#L776
 	    va_end(args);
 
 	    if (handle) {
+		result = Qnil;
+		state = 0;
 		if (r_proc) {
-		    PUSH_TAG();
-		    if ((state = EXEC_TAG()) == 0) {
-			result = (*r_proc) (data2, th->errinfo);
-		    }
-		    POP_TAG();
-		    if (state == TAG_RETRY) {
-			state = 0;
-			th->errinfo = Qnil;
-			goto retry_entry;
-		    }
-		}
-		else {
-		    result = Qnil;
-		    state = 0;
-		}
-		if (state == 0) {
-		    th->errinfo = e_info;
+		    result = (*r_proc) (data2, th->errinfo);
 		}
+		th->errinfo = e_info;
 	    }
 	}
     }

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

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