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

ruby-changes:27620

From: nagachika <ko1@a...>
Date: Sat, 9 Mar 2013 23:36:56 +0900 (JST)
Subject: [ruby-changes:27620] nagachika:r39672 (ruby_2_0_0): merge revision(s) 39451: [Backport #7925]

nagachika	2013-03-09 23:36:34 +0900 (Sat, 09 Mar 2013)

  New Revision: 39672

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

  Log:
    merge revision(s) 39451: [Backport #7925]
    
    * vm_insnhelper.c (vm_call_method): block level control frame does not
      have method entry, so obtain the method entry from method top-level
      control frame to be compared with refined method entry.
      [ruby-core:52750] [Bug #7925]

  Modified directories:
    branches/ruby_2_0_0/
  Modified files:
    branches/ruby_2_0_0/ChangeLog
    branches/ruby_2_0_0/test/ruby/test_refinement.rb
    branches/ruby_2_0_0/version.h
    branches/ruby_2_0_0/vm_insnhelper.c

Index: ruby_2_0_0/ChangeLog
===================================================================
--- ruby_2_0_0/ChangeLog	(revision 39671)
+++ ruby_2_0_0/ChangeLog	(revision 39672)
@@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ChangeLog#L1
+Sat Mar  9 23:31:46 2013  Nobuyoshi Nakada  <nobu@r...>
+
+	* vm_insnhelper.c (vm_call_method): block level control frame does not
+	  have method entry, so obtain the method entry from method top-level
+	  control frame to be compared with refined method entry.
+	  [ruby-core:52750] [Bug #7925]
+
 Sat Mar  9 23:15:06 2013  KOSAKI Motohiro  <kosaki.motohiro@g...>
 
 	* signal.c (sigsegv): suppress unused result warning. Because
Index: ruby_2_0_0/version.h
===================================================================
--- ruby_2_0_0/version.h	(revision 39671)
+++ ruby_2_0_0/version.h	(revision 39672)
@@ -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 "2013-03-09"
-#define RUBY_PATCHLEVEL 41
+#define RUBY_PATCHLEVEL 42
 
 #define RUBY_RELEASE_YEAR 2013
 #define RUBY_RELEASE_MONTH 3
Index: ruby_2_0_0/vm_insnhelper.c
===================================================================
--- ruby_2_0_0/vm_insnhelper.c	(revision 39671)
+++ ruby_2_0_0/vm_insnhelper.c	(revision 39672)
@@ -1675,6 +1675,24 @@ find_refinement(VALUE refinements, VALUE https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/vm_insnhelper.c#L1675
 static int rb_method_definition_eq(const rb_method_definition_t *d1, const rb_method_definition_t *d2);
 static VALUE vm_call_super_method(rb_thread_t *th, rb_control_frame_t *reg_cfp, rb_call_info_t *ci);
 
+static rb_control_frame_t *
+current_method_entry(rb_thread_t *th, rb_control_frame_t *cfp)
+{
+    rb_control_frame_t *top_cfp = cfp;
+
+    if (cfp->iseq && cfp->iseq->type == ISEQ_TYPE_BLOCK) {
+	rb_iseq_t *local_iseq = cfp->iseq->local_iseq;
+	do {
+	    cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp);
+	    if (RUBY_VM_CONTROL_FRAME_STACK_OVERFLOW_P(th, cfp)) {
+		/* TODO: orphan block */
+		return top_cfp;
+	    }
+	} while (cfp->iseq != local_iseq);
+    }
+    return cfp;
+}
+
 static
 #ifdef _MSC_VER
 __forceinline
@@ -1767,10 +1785,12 @@ vm_call_method(rb_thread_t *th, rb_contr https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/vm_insnhelper.c#L1785
 		}
 		me = rb_method_entry(refinement, ci->mid, &defined_class);
 		if (me) {
-		    if (ci->call == vm_call_super_method &&
-			cfp->me &&
-			rb_method_definition_eq(me->def, cfp->me->def)) {
-			goto no_refinement_dispatch;
+		    if (ci->call == vm_call_super_method) {
+			rb_control_frame_t *top_cfp = current_method_entry(th, cfp);
+			if (top_cfp->me &&
+			    rb_method_definition_eq(me->def, top_cfp->me->def)) {
+			    goto no_refinement_dispatch;
+			}
 		    }
 		    ci->me = me;
 		    ci->defined_class = defined_class;
Index: ruby_2_0_0/test/ruby/test_refinement.rb
===================================================================
--- ruby_2_0_0/test/ruby/test_refinement.rb	(revision 39671)
+++ ruby_2_0_0/test/ruby/test_refinement.rb	(revision 39672)
@@ -801,6 +801,31 @@ class TestRefinement < Test::Unit::TestC https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/ruby/test_refinement.rb#L801
     assert_equal("mixin", TestRefinement::PrependAfterRefine::C.new.bar)
   end
 
+  module SuperInBlock
+    class C
+      def foo(*args)
+        [:foo, *args]
+      end
+    end
+
+    module R
+      refine C do
+        def foo(*args)
+          tap do
+            return super(:ref, *args)
+          end
+        end
+      end
+    end
+  end
+
+  def test_super_in_block
+    bug7925 = '[ruby-core:52750] [Bug #7925]'
+    x = eval_using(SuperInBlock::R,
+                   "TestRefinement:: SuperInBlock::C.new.foo(#{bug7925.dump})")
+    assert_equal([:foo, :ref, bug7925], x, bug7925)
+  end
+
   private
 
   def eval_using(mod, s)

Property changes on: ruby_2_0_0
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r39451


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

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