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

ruby-changes:34931

From: nagachika <ko1@a...>
Date: Thu, 31 Jul 2014 02:06:13 +0900 (JST)
Subject: [ruby-changes:34931] nagachika:r47014 (ruby_2_1): merge revision(s) r46471: [Backport #9964]

nagachika	2014-07-31 02:05:55 +0900 (Thu, 31 Jul 2014)

  New Revision: 47014

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

  Log:
    merge revision(s) r46471: [Backport #9964]
    
    * compile.c (rb_iseq_compile_node): put start label of block after
      trace (b_call).
      [Bug #9964]
    
    * test/ruby/test_settracefunc.rb: add a test.
      added assert_consistent_call_return() method check call/return
      consistency.

  Modified directories:
    branches/ruby_2_1/
  Modified files:
    branches/ruby_2_1/ChangeLog
    branches/ruby_2_1/compile.c
    branches/ruby_2_1/test/ruby/test_settracefunc.rb
    branches/ruby_2_1/version.h
Index: ruby_2_1/ChangeLog
===================================================================
--- ruby_2_1/ChangeLog	(revision 47013)
+++ ruby_2_1/ChangeLog	(revision 47014)
@@ -1,3 +1,14 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_1/ChangeLog#L1
+Thu Jul 31 01:56:11 2014  Koichi Sasada  <ko1@a...>
+
+	* compile.c (rb_iseq_compile_node): put start label of block after
+	  trace (b_call).
+	  [Bug #9964]
+
+	* test/ruby/test_settracefunc.rb: add a test.
+
+	  added assert_consistent_call_return() method check call/return
+	  consistency.
+
 Thu Jul 31 01:22:43 2014  Koichi Sasada  <ko1@a...>
 
 	* vm.c (invoke_block_from_c): move call/return event timing for
Index: ruby_2_1/compile.c
===================================================================
--- ruby_2_1/compile.c	(revision 47013)
+++ ruby_2_1/compile.c	(revision 47014)
@@ -478,8 +478,8 @@ rb_iseq_compile_node(VALUE self, NODE *n https://github.com/ruby/ruby/blob/trunk/ruby_2_1/compile.c#L478
 		LABEL *start = iseq->compile_data->start_label = NEW_LABEL(0);
 		LABEL *end = iseq->compile_data->end_label = NEW_LABEL(0);
 
-		ADD_LABEL(ret, start);
 		ADD_TRACE(ret, FIX2INT(iseq->location.first_lineno), RUBY_EVENT_B_CALL);
+		ADD_LABEL(ret, start);
 		COMPILE(ret, "block body", node->nd_body);
 		ADD_LABEL(ret, end);
 		ADD_TRACE(ret, nd_line(node), RUBY_EVENT_B_RETURN);
Index: ruby_2_1/version.h
===================================================================
--- ruby_2_1/version.h	(revision 47013)
+++ ruby_2_1/version.h	(revision 47014)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_1/version.h#L1
 #define RUBY_VERSION "2.1.2"
 #define RUBY_RELEASE_DATE "2014-07-31"
-#define RUBY_PATCHLEVEL 185
+#define RUBY_PATCHLEVEL 186
 
 #define RUBY_RELEASE_YEAR 2014
 #define RUBY_RELEASE_MONTH 7
Index: ruby_2_1/test/ruby/test_settracefunc.rb
===================================================================
--- ruby_2_1/test/ruby/test_settracefunc.rb	(revision 47013)
+++ ruby_2_1/test/ruby/test_settracefunc.rb	(revision 47014)
@@ -1251,4 +1251,52 @@ class TestSetTraceFunc < Test::Unit::Tes https://github.com/ruby/ruby/blob/trunk/ruby_2_1/test/ruby/test_settracefunc.rb#L1251
 
     assert_equal [], events # should be empty.
   end
+
+  def method_prefix event
+    case event
+    when :call, :return
+      :n
+    when :c_call, :c_return
+      :c
+    when :b_call, :b_return
+      :b
+    end
+  end
+
+  def method_label tp
+    "#{method_prefix(tp.event)}##{tp.method_id}"
+  end
+
+  def assert_consistent_call_return message='', check_events: nil
+    check_events ||= %i(a_call a_return)
+    call_events = []
+    return_events = []
+
+    TracePoint.new(*check_events){|tp|
+      next unless target_thread?
+
+      case tp.event.to_s
+      when /call/
+        call_events << method_label(tp)
+      when /return/
+        return_events << method_label(tp)
+      end
+    }.enable do
+      yield
+    end
+
+    assert_equal false, call_events.empty?
+    assert_equal false, return_events.empty?
+    assert_equal call_events, return_events.reverse, message
+  end
+
+  def test_b_call_with_redo
+    assert_consistent_call_return do
+      i = 0
+      1.times{
+        break if (i+=1) > 10
+        redo
+      }
+    end
+  end
 end

Property changes on: ruby_2_1
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r46471


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

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