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

ruby-changes:34390

From: ko1 <ko1@a...>
Date: Fri, 20 Jun 2014 07:09:33 +0900 (JST)
Subject: [ruby-changes:34390] ko1:r46471 (trunk): * compile.c (rb_iseq_compile_node): put start label of block after

ko1	2014-06-20 07:09:23 +0900 (Fri, 20 Jun 2014)

  New Revision: 46471

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

  Log:
    * 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 files:
    trunk/ChangeLog
    trunk/compile.c
    trunk/test/ruby/test_settracefunc.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 46470)
+++ ChangeLog	(revision 46471)
@@ -1,3 +1,14 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Fri Jun 20 07:07:28 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.
+
 Fri Jun 20 05:26:27 2014  Koichi Sasada  <ko1@a...>
 
 	* vm_eval.c (rb_catch_protect): fix same problem of [Bug #9961].
Index: compile.c
===================================================================
--- compile.c	(revision 46470)
+++ compile.c	(revision 46471)
@@ -483,8 +483,8 @@ rb_iseq_compile_node(VALUE self, NODE *n https://github.com/ruby/ruby/blob/trunk/compile.c#L483
 		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: test/ruby/test_settracefunc.rb
===================================================================
--- test/ruby/test_settracefunc.rb	(revision 46470)
+++ test/ruby/test_settracefunc.rb	(revision 46471)
@@ -1308,4 +1308,52 @@ class TestSetTraceFunc < Test::Unit::Tes https://github.com/ruby/ruby/blob/trunk/test/ruby/test_settracefunc.rb#L1308
       [:c_return, :===],
     [:b_return, :test_rb_rescue]], events
   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

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

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