[#46329] [ruby-trunk - Feature #7252][Assigned] version number of 2.0 release — "usa (Usaku NAKAMURA)" <usa@...>

26 messages 2012/11/01

[#46350] RubySpecメンテナ — Yukihiro Matsumoto <matz@...>

まつもと ゆきひろです

15 messages 2012/11/02
[#46352] Re: RubySpecメンテナ — Urabe Shyouhei <shyouhei@...> 2012/11/02

On 11/01/2012 07:43 PM, Yukihiro Matsumoto wrote:

[#46414] [ruby-trunk - Bug #7287][Open] please rename atomic.h which conflicts with /usr/include/atomic.h in Solaris10 — "ngoto (Naohisa Goto)" <ngotogenome@...>

10 messages 2012/11/06

[#46434] トラップハンドラで許されない操作はなにか — KOSAKI Motohiro <kosaki.motohiro@...>

GyRCPi46aiRHJDkbKEIKCltCdWcgIzcxMzRdIBskQiRyRDQkWSRGJCQkRj88SiUkSjtFTU1MZEJq

9 messages 2012/11/06

[#46440] [ruby-trunk - Bug #7300][Open] Hash#[] の挙動が 1.9.3 と異なっている — "hsbt (Hiroshi SHIBATA)" <shibata.hiroshi@...>

12 messages 2012/11/07

[#46477] Fwd: [ruby-changes:25559] shugo:r37616 (trunk): * vm_core.h (rb_call_info_t::refinements), compile.c (new_callinfo): — SASADA Koichi <ko1@...>

refinement を導入するときの性能に対する excuse が「method cache に殆どあ

20 messages 2012/11/11
[#46480] Re: Fwd: [ruby-changes:25559] shugo:r37616 (trunk): * vm_core.h (rb_call_info_t::refinements), compile.c (new_callinfo): — Shugo Maeda <shugo@...> 2012/11/11

前田です。

[#46488] Re: Fwd: [ruby-changes:25559] shugo:r37616 (trunk): * vm_core.h (rb_call_info_t::refinements), compile.c (new_callinfo): — SASADA Koichi <ko1@...> 2012/11/12

 ささだです.

[#46491] Re: Fwd: [ruby-changes:25559] shugo:r37616 (trunk): * vm_core.h (rb_call_info_t::refinements), compile.c (new_callinfo): — Shugo Maeda <shugo@...> 2012/11/12

前田です。

[#46493] Re: Fwd: [ruby-changes:25559] shugo:r37616 (trunk): * vm_core.h (rb_call_info_t::refinements), compile.c (new_callinfo): — SASADA Koichi <ko1@...> 2012/11/12

 ささだです.

[#46495] Re: Fwd: [ruby-changes:25559] shugo:r37616 (trunk): * vm_core.h (rb_call_info_t::refinements), compile.c (new_callinfo): — Shugo Maeda <shugo@...> 2012/11/12

前田です。

[#46497] Re: Fwd: [ruby-changes:25559] shugo:r37616 (trunk): * vm_core.h (rb_call_info_t::refinements), compile.c (new_callinfo): — SASADA Koichi <ko1@...> 2012/11/12

(2012/11/12 18:20), Shugo Maeda wrote:

[#46501] Re: Fwd: [ruby-changes:25559] shugo:r37616 (trunk): * vm_core.h (rb_call_info_t::refinements), compile.c (new_callinfo): — Shugo Maeda <shugo@...> 2012/11/12

前田です。

[#46513] Re: Fwd: [ruby-changes:25559] shugo:r37616 (trunk): * vm_core.h (rb_call_info_t::refinements), compile.c (new_callinfo): — Nobuyoshi Nakada <nobu@...> 2012/11/14

なかだです。

[#46509] [ruby-trunk - Bug #7344][Open] gem pristine bigdecimal が失敗してしまう — "hsbt (Hiroshi SHIBATA)" <shibata.hiroshi@...>

31 messages 2012/11/13

[#46520] [ruby-trunk - Bug #7356][Open] ruby-2.0.0-preview1 で adlint-2.6.10 が性能劣化 — "yanoh (Yutaka Yanoh)" <yutaka@...>

11 messages 2012/11/15

[#46647] [ruby-trunk - Bug #7452][Assigned] Main thread is stopped after running finalizers if the main thread has a finalizer — "mrkn (Kenta Murata)" <muraken@...>

8 messages 2012/11/28

[ruby-dev:46477] Fwd: [ruby-changes:25559] shugo:r37616 (trunk): * vm_core.h (rb_call_info_t::refinements), compile.c (new_callinfo):

From: SASADA Koichi <ko1@...>
Date: 2012-11-11 02:58:09 UTC
List: ruby-dev #46477
refinement を導入するときの性能に対する excuse が「method cache に殆どあ
たるから,(refinement に関係無い部分の)性能低下はない」という話だった
と思うのですが,今回のコードを見ると,それなりにメソッド探索コストが増え
そうな気がするんですが,いかがでしょうか.

昨日相談させて頂いたとおり,実装としては refinement は
 - メソッド探索から refinement 関係の処理を削除
 - 探索したメソッドが refine されたメソッドだったら,
   その時点で適切なメソッドを呼び出す
のが良いと思います.

ちょっと,現状のコードは受け入れられません.


-------- Original Message --------
Subject: [ruby-changes:25559] shugo:r37616 (trunk): * vm_core.h
(rb_call_info_t::refinements), compile.c (new_callinfo):
Date: Sun, 11 Nov 2012 11:42:16 +0900 (JST)
From: shugo <ko1@atdot.net>
Reply-To: ruby-changes@quickml.atdot.net
To: ruby-changes@quickml.atdot.net

shugo	2012-11-11 11:42:04 +0900 (Sun, 11 Nov 2012)

  New Revision: 37616

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

  Log:
    * vm_core.h (rb_call_info_t::refinements), compile.c (new_callinfo):
      add a new field for inline method cache.

    * vm_insnhelper.c (vm_search_method): check rb_call_info_t::refinements
      not to confuse inline method cache when module_eval is used with
      refinements.

    * test/ruby/test_refinement.rb: related test.

  Modified files:
    trunk/ChangeLog
    trunk/compile.c
    trunk/test/ruby/test_refinement.rb
    trunk/vm_core.h
    trunk/vm_insnhelper.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 37615)
+++ ChangeLog	(revision 37616)
@@ -1,3 +1,14 @@
+Sun Nov 11 11:36:19 2012  Shugo Maeda  <shugo@ruby-lang.org>
+
+	* vm_core.h (rb_call_info_t::refinements), compile.c (new_callinfo):
+	  add a new field for inline method cache.
+
+	* vm_insnhelper.c (vm_search_method): check rb_call_info_t::refinements
+	  not to confuse inline method cache when module_eval is used with
+	  refinements.
+
+	* test/ruby/test_refinement.rb: related test.
+
 Sun Nov 11 08:45:45 2012  Martin Duerst  <duerst@it.aoyama.ac.jp>

 	* ruby.c: removed a comma before "before"
Index: vm_core.h
===================================================================
--- vm_core.h	(revision 37615)
+++ vm_core.h	(revision 37616)
@@ -153,6 +153,7 @@
     /* inline cache: keys */
     VALUE vmstat;
     VALUE klass;
+    VALUE refinements;

     /* inline cache: values */
     const rb_method_entry_t *me;
Index: compile.c
===================================================================
--- compile.c	(revision 37615)
+++ compile.c	(revision 37616)
@@ -954,6 +954,7 @@
 	}
     }
     ci->vmstat = 0;
+    ci->refinements = Qundef;
     ci->blockptr = 0;
     ci->recv = Qundef;
     ci->call = 0; /* TODO: should set default function? */
Index: vm_insnhelper.c
===================================================================
--- vm_insnhelper.c	(revision 37615)
+++ vm_insnhelper.c	(revision 37616)
@@ -843,19 +843,30 @@
 vm_search_method(rb_call_info_t *ci, VALUE recv)
 {
     VALUE klass = CLASS_OF(recv);
+    NODE *cref = rb_vm_cref();
+    VALUE refinements = Qnil;

+    if (cref && !NIL_P(cref->nd_refinements)) {
+	refinements = cref->nd_refinements;
+    }
+
 #if OPT_INLINE_METHOD_CACHE
-    if (LIKELY(GET_VM_STATE_VERSION() == ci->vmstat && klass ==
ci->klass)) {
+    if (LIKELY(GET_VM_STATE_VERSION() == ci->vmstat && klass ==
ci->klass &&
+	       refinements == ci->refinements)) {
 	/* cache hit! */
     }
     else {
-	ci->me = rb_method_entry(klass, ci->mid, &ci->defined_class);
+	ci->me = rb_method_entry_get_with_refinements(refinements, klass,
+						      ci->mid,
+						      &ci->defined_class);
 	ci->klass = klass;
+	ci->refinements = refinements;
 	ci->vmstat = GET_VM_STATE_VERSION();
 	ci->call = vm_call_general;
     }
 #else
-    ci->me = rb_method_entry(klass, ci->mid, &ci->defined_class);
+    ci->me = rb_method_entry_get_with_refinements(refinements, klass,
ci->mid,
+						  &ci->defined_class);
     ci->call = vm_call_general;
     ci->klass = klass;
 #endif
Index: test/ruby/test_refinement.rb
===================================================================
--- test/ruby/test_refinement.rb	(revision 37615)
+++ test/ruby/test_refinement.rb	(revision 37616)
@@ -685,4 +685,28 @@
     assert_equal("#<refinement:#{c.inspect}@#{m.inspect}>",
                  m.refinements[c].inspect)
   end
+
+  module InlineMethodCache
+    class C
+      def foo
+        "original"
+      end
+    end
+
+    module M
+      refine C do
+        def foo
+          "refined"
+        end
+      end
+    end
+  end
+
+  def test_inline_method_cache
+    c = InlineMethodCache::C.new
+    f = Proc.new { c.foo }
+    assert_equal("original", f.call)
+    assert_equal("refined", InlineMethodCache::M.module_eval(&f))
+    assert_equal("original", f.call)
+  end
 end

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


Attachments (1)

添付メッセージ部 (0 Bytes, text/plain)

  

In This Thread

Prev Next