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

ruby-changes:35258

From: usa <ko1@a...>
Date: Sun, 31 Aug 2014 16:55:49 +0900 (JST)
Subject: [ruby-changes:35258] usa:r47340 (ruby_2_0_0): merge revision(s) 46471: [Backport #9964]

usa	2014-08-31 16:55:32 +0900 (Sun, 31 Aug 2014)

  New Revision: 47340

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

  Log:
    merge revision(s) 46471: [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_0_0/
  Modified files:
    branches/ruby_2_0_0/ChangeLog
    branches/ruby_2_0_0/compile.c
    branches/ruby_2_0_0/test/ruby/test_settracefunc.rb
    branches/ruby_2_0_0/version.h
Index: ruby_2_0_0/ChangeLog
===================================================================
--- ruby_2_0_0/ChangeLog	(revision 47339)
+++ ruby_2_0_0/ChangeLog	(revision 47340)
@@ -1,3 +1,14 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ChangeLog#L1
+Sun Aug 31 16:50:06 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.
+
 Sun Aug 31 16:38:26 2014  Koichi Sasada  <ko1@a...>
 
 	* vm_core.h: add VM_FRAME_MAGIC_RESCUE to recognize normal block or
Index: ruby_2_0_0/compile.c
===================================================================
--- ruby_2_0_0/compile.c	(revision 47339)
+++ ruby_2_0_0/compile.c	(revision 47340)
@@ -480,8 +480,8 @@ rb_iseq_compile_node(VALUE self, NODE *n https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/compile.c#L480
 		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_0_0/version.h
===================================================================
--- ruby_2_0_0/version.h	(revision 47339)
+++ ruby_2_0_0/version.h	(revision 47340)
@@ -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 540
+#define RUBY_PATCHLEVEL 541
 
 #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 47339)
+++ ruby_2_0_0/test/ruby/test_settracefunc.rb	(revision 47340)
@@ -8,11 +8,17 @@ class TestSetTraceFunc < Test::Unit::Tes https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/ruby/test_settracefunc.rb#L8
       :trace_instruction => true,
       :specialized_instruction => false
     }
+    @target_thread = Thread.current
   end
 
   def teardown
     set_trace_func(nil)
     RubyVM::InstructionSequence.compile_option = @original_compile_option
+    @target_thread = nil
+  end
+
+  def target_thread?
+    Thread.current == @target_thread
   end
 
   def test_c_call
@@ -1140,4 +1146,51 @@ class TestSetTraceFunc < Test::Unit::Tes https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/ruby/test_settracefunc.rb#L1146
       trace.disable
     end
   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
+    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_0_0
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r46471


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

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