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

ruby-changes:35260

From: usa <ko1@a...>
Date: Sun, 31 Aug 2014 17:14:34 +0900 (JST)
Subject: [ruby-changes:35260] usa:r47342 (ruby_2_0_0): merge revision(s) 46465, 46469, 46484: [Backport #9961]

usa	2014-08-31 17:14:15 +0900 (Sun, 31 Aug 2014)

  New Revision: 47342

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

  Log:
    merge revision(s) 46465,46469,46484: [Backport #9961]
    
    * vm.c (rb_vm_rewind_cfp): add new function to rewind specified cfp
      with invoking RUBY_EVENT_C_RETURN.
      [Bug #9961]
    
    * vm_core.h: ditto.
    
    * eval.c (rb_protect): use it.
    
    * eval.c (rb_rescue2): ditto.
    
    * vm_eval.c (rb_iterate): ditto.
    
    * test/ruby/test_settracefunc.rb: add a test.
    
    * vm_core.h (rb_name_err_mesg_new): 
    
    * vm_eval.c (rb_catch_protect): fix same problem of [Bug #9961].
    
    * vm_eval.c (rb_iterate): ditto.
    
    * vm_core.h (rb_vm_rewind_cfp): add the prototype declaration.

  Modified directories:
    branches/ruby_2_0_0/
  Modified files:
    branches/ruby_2_0_0/ChangeLog
    branches/ruby_2_0_0/eval.c
    branches/ruby_2_0_0/test/ruby/test_settracefunc.rb
    branches/ruby_2_0_0/version.h
    branches/ruby_2_0_0/vm.c
    branches/ruby_2_0_0/vm_core.h
    branches/ruby_2_0_0/vm_eval.c
Index: ruby_2_0_0/ChangeLog
===================================================================
--- ruby_2_0_0/ChangeLog	(revision 47341)
+++ ruby_2_0_0/ChangeLog	(revision 47342)
@@ -1,3 +1,27 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ChangeLog#L1
+Sun Aug 31 16:59:45 2014  Koichi Sasada  <ko1@a...>
+
+	* vm_eval.c (rb_catch_protect): fix same problem of [Bug #9961].
+
+	* vm_eval.c (rb_iterate): ditto.
+
+Sun Aug 31 16:59:45 2014  Koichi Sasada  <ko1@a...>
+
+	* vm.c (rb_vm_rewind_cfp): add new function to rewind specified cfp
+	  with invoking RUBY_EVENT_C_RETURN.
+	  [Bug #9961]
+
+	* vm_core.h: ditto.
+
+	* eval.c (rb_protect): use it.
+
+	* eval.c (rb_rescue2): ditto.
+
+	* vm_eval.c (rb_iterate): ditto.
+
+	* test/ruby/test_settracefunc.rb: add a test.
+
+	* vm_core.h (rb_name_err_mesg_new): 
+
 Sun Aug 31 16:50:06 2014  Koichi Sasada  <ko1@a...>
 
 	* compile.c (rb_iseq_compile_node): put start label of block after
Index: ruby_2_0_0/vm_core.h
===================================================================
--- ruby_2_0_0/vm_core.h	(revision 47341)
+++ ruby_2_0_0/vm_core.h	(revision 47342)
@@ -854,6 +854,7 @@ VALUE rb_name_err_mesg_new(VALUE obj, VA https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/vm_core.h#L854
 void rb_vm_stack_to_heap(rb_thread_t *th);
 void ruby_thread_init_stack(rb_thread_t *th);
 int rb_vm_control_frame_id_and_class(const rb_control_frame_t *cfp, ID *idp, VALUE *klassp);
+void rb_vm_rewind_cfp(rb_thread_t *th, rb_control_frame_t *cfp);
 
 void rb_gc_mark_machine_stack(rb_thread_t *th);
 
Index: ruby_2_0_0/vm_eval.c
===================================================================
--- ruby_2_0_0/vm_eval.c	(revision 47341)
+++ ruby_2_0_0/vm_eval.c	(revision 47342)
@@ -1068,18 +1068,7 @@ rb_iterate(VALUE (* it_proc) (VALUE), VA https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/vm_eval.c#L1068
 		th->errinfo = Qnil;
 		retval = GET_THROWOBJ_VAL(err);
 
-		/* check skipped frame */
-		while (th->cfp != cfp) {
-#if VMDEBUG
-		    printf("skipped frame: %s\n", vm_frametype_name(th->cfp));
-#endif
-		    if (VM_FRAME_TYPE(th->cfp) != VM_FRAME_MAGIC_CFUNC) {
-			vm_pop_frame(th);
-		    }
-		    else { /* unlikely path */
-			rb_vm_pop_cfunc_frame();
-		    }
-		}
+		rb_vm_rewind_cfp(th, cfp);
 	    }
 	    else{
 		/* SDR(); printf("%p, %p\n", cdfp, escape_dfp); */
@@ -1090,10 +1079,11 @@ rb_iterate(VALUE (* it_proc) (VALUE), VA https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/vm_eval.c#L1079
 	    VALUE *cep = cfp->ep;
 
 	    if (cep == escape_ep) {
+		rb_vm_rewind_cfp(th, cfp);
+
 		state = 0;
 		th->state = 0;
 		th->errinfo = Qnil;
-		th->cfp = cfp;
 		goto iter_retry;
 	    }
 	}
@@ -1835,7 +1825,7 @@ rb_catch_obj(VALUE tag, VALUE (*func)(), https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/vm_eval.c#L1825
 	val = (*func)(tag, data, 1, &tag, Qnil);
     }
     else if (state == TAG_THROW && RNODE(th->errinfo)->u1.value == tag) {
-	th->cfp = saved_cfp;
+	rb_vm_rewind_cfp(th, saved_cfp);
 	val = th->tag->retval;
 	th->errinfo = Qnil;
 	state = 0;
Index: ruby_2_0_0/eval.c
===================================================================
--- ruby_2_0_0/eval.c	(revision 47341)
+++ ruby_2_0_0/eval.c	(revision 47342)
@@ -714,7 +714,7 @@ rb_rescue2(VALUE (* b_proc) (ANYARGS), V https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/eval.c#L714
 	result = (*b_proc) (data1);
     }
     else {
-	th->cfp = cfp; /* restore */
+	rb_vm_rewind_cfp(th, cfp);
 
 	if (state == TAG_RAISE) {
 	    int handle = FALSE;
@@ -793,7 +793,7 @@ rb_protect(VALUE (* proc) (VALUE), VALUE https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/eval.c#L793
 	*state = status;
     }
     if (status != 0) {
-	th->cfp = cfp;
+	rb_vm_rewind_cfp(th, cfp);
 	return Qnil;
     }
 
Index: ruby_2_0_0/vm.c
===================================================================
--- ruby_2_0_0/vm.c	(revision 47341)
+++ ruby_2_0_0/vm.c	(revision 47342)
@@ -241,6 +241,23 @@ rb_vm_pop_cfunc_frame(void) https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/vm.c#L241
     vm_pop_frame(th);
 }
 
+void
+rb_vm_rewind_cfp(rb_thread_t *th, rb_control_frame_t *cfp)
+{
+    /* check skipped frame */
+    while (th->cfp != cfp) {
+#if VMDEBUG
+	printf("skipped frame: %s\n", vm_frametype_name(th->cfp));
+#endif
+	if (VM_FRAME_TYPE(th->cfp) != VM_FRAME_MAGIC_CFUNC) {
+	    vm_pop_frame(th);
+	}
+	else { /* unlikely path */
+	    rb_vm_pop_cfunc_frame();
+	}
+    }
+}
+
 /* obsolete */
 void
 rb_frame_pop(void)
Index: ruby_2_0_0/version.h
===================================================================
--- ruby_2_0_0/version.h	(revision 47341)
+++ ruby_2_0_0/version.h	(revision 47342)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/version.h#L1
 #define RUBY_VERSION "2.0.0"
 #define RUBY_RELEASE_DATE "2014-08-31"
-#define RUBY_PATCHLEVEL 541
+#define RUBY_PATCHLEVEL 542
 
 #define RUBY_RELEASE_YEAR 2014
 #define RUBY_RELEASE_MONTH 8
Index: ruby_2_0_0/test/ruby/test_settracefunc.rb
===================================================================
--- ruby_2_0_0/test/ruby/test_settracefunc.rb	(revision 47341)
+++ ruby_2_0_0/test/ruby/test_settracefunc.rb	(revision 47342)
@@ -1184,6 +1184,57 @@ class TestSetTraceFunc < Test::Unit::Tes https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/ruby/test_settracefunc.rb#L1184
     assert_equal call_events, return_events.reverse, message
   end
 
+  def test_rb_rescue
+    events = []
+    curr_thread = Thread.current
+    TracePoint.new(:b_call, :b_return, :c_call, :c_return){|tp|
+      next if curr_thread != Thread.current
+      events << [tp.event, tp.method_id]
+    }.enable do
+      begin
+        -Numeric.new
+      rescue => e
+        # ignore
+      end
+    end
+
+    assert_equal [
+    [:b_call, :test_rb_rescue],
+      [:c_call, :new],
+        [:c_call, :initialize],
+        [:c_return, :initialize],
+      [:c_return, :new],
+      [:c_call, :-@],
+        [:c_call, :coerce],
+          [:c_call, :to_s],
+          [:c_return, :to_s],
+          [:c_call, :new],
+            [:c_call, :initialize],
+            [:c_return, :initialize],
+          [:c_return, :new],
+          [:c_call, :exception],
+          [:c_return, :exception],
+          [:c_call, :backtrace],
+          [:c_return, :backtrace],
+        [:c_return, :coerce],            # don't miss it!
+        [:c_call, :to_s],
+        [:c_return, :to_s],
+        [:c_call, :to_s],
+        [:c_return, :to_s],
+        [:c_call, :new],
+          [:c_call, :initialize],
+          [:c_return, :initialize],
+        [:c_return, :new],
+        [:c_call, :exception],
+        [:c_return, :exception],
+        [:c_call, :backtrace],
+        [:c_return, :backtrace],
+      [:c_return, :-@],
+      [:c_call, :===],
+      [:c_return, :===],
+    [:b_return, :test_rb_rescue]], events
+  end
+
   def test_b_call_with_redo
     assert_consistent_call_return do
       i = 0

Property changes on: ruby_2_0_0
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r46465,46469,46484


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

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