ruby-changes:9994
From: ko1 <ko1@a...>
Date: Fri, 16 Jan 2009 00:32:09 +0900 (JST)
Subject: [ruby-changes:9994] Ruby:r21536 (trunk): * vm.c (rb_vm_inc_const_missing_count, ruby_vm_const_missing_count):
ko1 2009-01-16 00:31:43 +0900 (Fri, 16 Jan 2009) New Revision: 21536 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=21536 Log: * 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: trunk/ChangeLog trunk/bootstraptest/test_class.rb trunk/insns.def trunk/variable.c trunk/vm.c trunk/vm_insnhelper.h Index: insns.def =================================================================== --- insns.def (revision 21535) +++ insns.def (revision 21536) @@ -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: ChangeLog =================================================================== --- ChangeLog (revision 21535) +++ ChangeLog (revision 21536) @@ -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: variable.c =================================================================== --- variable.c (revision 21535) +++ variable.c (revision 21536) @@ -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: bootstraptest/test_class.rb =================================================================== --- bootstraptest/test_class.rb (revision 21535) +++ bootstraptest/test_class.rb (revision 21536) @@ -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: vm.c =================================================================== --- vm.c (revision 21535) +++ vm.c (revision 21536) @@ -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: vm_insnhelper.h =================================================================== --- vm_insnhelper.h (revision 21535) +++ vm_insnhelper.h (revision 21536) @@ -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/