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

ruby-changes:10031

From: yugui <ko1@a...>
Date: Fri, 16 Jan 2009 01:33:22 +0900 (JST)
Subject: [ruby-changes:10031] Ruby:r21574 (ruby_1_9_1): merges r21536 from trunk into ruby_1_9_1.

yugui	2009-01-16 01:32:49 +0900 (Fri, 16 Jan 2009)

  New Revision: 21574

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

  Log:
    merges r21536 from trunk into ruby_1_9_1.
    * vm.c (rb_vm_inc_const_missing_count, ruby_vm_const_missing_count):
      added.
    * vm_insnhelper.h: ditto.
    * variable.c (rb_const_get_0), insns.def: Constants should not be
      cached if const_missing is called.  [ruby-core:21059] [Bug #967]
    * bootstraptest/test_class.rb: add a test.

  Modified files:
    branches/ruby_1_9_1/ChangeLog
    branches/ruby_1_9_1/bootstraptest/test_class.rb
    branches/ruby_1_9_1/insns.def
    branches/ruby_1_9_1/variable.c
    branches/ruby_1_9_1/vm.c
    branches/ruby_1_9_1/vm_insnhelper.h

Index: ruby_1_9_1/insns.def
===================================================================
--- ruby_1_9_1/insns.def	(revision 21573)
+++ ruby_1_9_1/insns.def	(revision 21574)
@@ -1222,7 +1222,8 @@
     IC ic = GET_CONST_INLINE_CACHE(dst);
 
     ic->ic_value = val;
-    ic->ic_vmstat = GET_VM_STATE_VERSION();
+    ic->ic_vmstat = GET_VM_STATE_VERSION() - ruby_vm_const_missing_count;
+    ruby_vm_const_missing_count = 0;
 }
 
 /**
Index: ruby_1_9_1/ChangeLog
===================================================================
--- ruby_1_9_1/ChangeLog	(revision 21573)
+++ ruby_1_9_1/ChangeLog	(revision 21574)
@@ -1,3 +1,15 @@
+Fri Jan 16 00:27:03 2009  Koichi Sasada  <ko1@a...>
+
+	* vm.c (rb_vm_inc_const_missing_count, ruby_vm_const_missing_count): 
+	  added.
+
+	* vm_insnhelper.h: ditto.
+
+	* variable.c (rb_const_get_0), insns.def: Constants should not be
+	  cached if const_missing is called.  [ruby-core:21059] [Bug #967]
+
+	* bootstraptest/test_class.rb: add a test.
+
 Fri Jan 16 00:25:09 2009  Koichi Sasada  <ko1@a...>
 
 	* common.mk: btest-ruby should receive option with OPTS.
Index: ruby_1_9_1/variable.c
===================================================================
--- ruby_1_9_1/variable.c	(revision 21573)
+++ ruby_1_9_1/variable.c	(revision 21574)
@@ -17,6 +17,8 @@
 #include "node.h"
 
 void rb_vm_change_state(void);
+void rb_vm_inc_const_missing_count(void);
+
 st_table *rb_global_tbl;
 st_table *rb_class_tbl;
 static ID autoload, classpath, tmp_classpath;
@@ -1488,7 +1490,9 @@
 	goto retry;
     }
 
-    return const_missing(klass, id);
+    value = const_missing(klass, id);
+    rb_vm_inc_const_missing_count();
+    return value;
 }
 
 VALUE
Index: ruby_1_9_1/bootstraptest/test_class.rb
===================================================================
--- ruby_1_9_1/bootstraptest/test_class.rb	(revision 21573)
+++ ruby_1_9_1/bootstraptest/test_class.rb	(revision 21574)
@@ -130,3 +130,17 @@
     :ok
   end
 }, '[ruby-core:14378]'
+
+assert_equal '3', %q{
+  $i = 0
+  class C
+    def self.const_missing *args
+      $i+=1
+    end
+  end
+
+  3.times{
+    C::FOO
+  }
+  $i
+}
Index: ruby_1_9_1/vm.c
===================================================================
--- ruby_1_9_1/vm.c	(revision 21573)
+++ ruby_1_9_1/vm.c	(revision 21574)
@@ -34,6 +34,8 @@
 VALUE rb_mRubyVMFrozenCore;
 
 VALUE ruby_vm_global_state_version = 1;
+VALUE ruby_vm_const_missing_count = 0;
+
 char ruby_vm_redefined_flag[BOP_LAST_];
 
 rb_thread_t *ruby_current_thread = 0;
@@ -49,6 +51,12 @@
     INC_VM_STATE_VERSION();
 }
 
+void
+rb_vm_inc_const_missing_count(void)
+{
+    ruby_vm_const_missing_count +=1;
+}
+
 /* control stack frame */
 
 static inline VALUE
Index: ruby_1_9_1/vm_insnhelper.h
===================================================================
--- ruby_1_9_1/vm_insnhelper.h	(revision 21573)
+++ ruby_1_9_1/vm_insnhelper.h	(revision 21574)
@@ -58,6 +58,7 @@
 
 extern char ruby_vm_redefined_flag[BOP_LAST_];
 extern VALUE ruby_vm_global_state_version;
+extern VALUE ruby_vm_const_missing_count;
 
 #define GET_VM_STATE_VERSION() (ruby_vm_global_state_version)
 #define INC_VM_STATE_VERSION() \

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

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