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

ruby-changes:17871

From: nobu <ko1@a...>
Date: Tue, 23 Nov 2010 18:54:17 +0900 (JST)
Subject: [ruby-changes:17871] Ruby:r29885 (trunk): * vm.c (rb_thread_mark): should mark self in conrol

nobu	2010-11-23 18:54:07 +0900 (Tue, 23 Nov 2010)

  New Revision: 29885

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

  Log:
    * vm.c (rb_thread_mark): should mark self in conrol
      frames.  [ruby-core:33289]

  Modified files:
    trunk/ChangeLog
    trunk/test/ruby/test_optimization.rb
    trunk/vm.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 29884)
+++ ChangeLog	(revision 29885)
@@ -1,3 +1,8 @@
+Tue Nov 23 18:54:03 2010  Nobuyoshi Nakada  <nobu@r...>
+
+	* vm.c (rb_thread_mark): should mark self in conrol
+	  frames.  [ruby-core:33289]
+
 Tue Nov 23 07:57:31 2010  Tadayoshi Funaba  <tadf@d...>
 
 	* lib/date/delta/parser.{ry,rb}: fixed a bug of token scanner.
Index: vm.c
===================================================================
--- vm.c	(revision 29884)
+++ vm.c	(revision 29885)
@@ -1644,6 +1644,7 @@
 	    while (cfp != limit_cfp) {
 		rb_iseq_t *iseq = cfp->iseq;
 		rb_gc_mark(cfp->proc);
+		rb_gc_mark(cfp->self);
 		if (iseq) {
 		    rb_gc_mark(RUBY_VM_NORMAL_ISEQ_P(iseq) ? iseq->self : (VALUE)iseq);
 		}
Index: test/ruby/test_optimization.rb
===================================================================
--- test/ruby/test_optimization.rb	(revision 29884)
+++ test/ruby/test_optimization.rb	(revision 29885)
@@ -137,4 +137,27 @@
     assert_equal true, MyObj.new == nil
   end
 
+  def test_tailcall
+    bug4082 = '[ruby-core:33289]'
+
+    option = {
+      tailcall_optimization: true,
+      trace_instruction: false,
+    }
+    iseq = RubyVM::InstructionSequence.new(<<-EOF, "Bug#4082", bug4082, nil, option).eval
+      class #{self.class}::Tailcall
+        def fact_helper(n, res)
+          if n == 1
+            res
+          else
+            fact_helper(n - 1, n * res)
+          end
+        end
+        def fact(n)
+          fact_helper(n, 1)
+        end
+      end
+    EOF
+    assert_equal(9131, Tailcall.new.fact(3000).to_s.size, bug4082)
+  end
 end

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

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