[前][次][番号順一覧][スレッド一覧][生データ]

yarv-dev:720

From: Minero Aoki <aamine loveruby.net>
Date: Tue, 27 Dec 2005 16:47:16 +0900 (JST)
Subject: [yarv-dev:720] open> const_set does not flush inline cache

青木です。

次のように、const_set であとから追加した定数が見えないことがあります。

~/c/yarv % cat BUGS/const-cref2.rb
class A
  C = "BAD"
  class B
    def self.c
      C
    end
  end
end

A::B.c   # cache
A::B.const_set :C, "OK"
p A::B.c

~/c/yarv % ruby -v BUGS/const-cref2.rb
ruby 1.9.0 (2005-12-21) [x86_64-linux]
"OK"
~/c/yarv % ./miniruby -v BUGS/const-cref2.rb
ruby 1.9.0 (2005-11-18) [x86_64-linux]
YARVCore 0.3.3 (rev: 332) [opts: ]
"BAD"


こんな感じでしょうか。

Index: variable.c
===================================================================
--- variable.c	(revision 332)
+++ variable.c	(working copy)
@@ -1507,6 +1507,7 @@
     }
 
     st_insert(RCLASS(klass)->iv_tbl, id, val);
+    rb_vm_change_state();
 }
 
 void


ついでに、クラス変数を remove_class_variable で削除したときにも
同じ問題があるように思われます。

Index: variable.c
===================================================================
--- variable.c	(revision 332)
+++ variable.c	(working copy)
@@ -1668,6 +1669,7 @@
     if (OBJ_FROZEN(mod)) rb_error_frozen("class/module");
 
     if (RCLASS(mod)->iv_tbl && st_delete(ROBJECT(mod)->iv_tbl, (st_data_t*)&id, &val)) {
+	rb_vm_change_state();
 	return val;
     }
     if (rb_cvar_defined(mod, id)) {

--
青木峰郎

-- 
ML: yarv-dev quickml.atdot.net
使い方: http://www.atdot.net/~ko1/quickml

[前][次][番号順一覧][スレッド一覧][生データ]

->     720 2005-12-27 16:47 [aamine loveruby.net ] open> const_set does not flush inline cache
       721 2005-12-27 16:53 ┣[aamine loveruby.net ] Re: const_set does not flush inline cache
       728 2005-12-28 11:01 ┗[ko1 atdot.net       ] fixed> Re: open> const_set does not flush inline cache
       778 2006-01-09 17:07  ┗[aamine loveruby.net ] close> Re: const_set does not flush inline cache