mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21536 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
e39bd71126
commit
a3a45fafa3
6 changed files with 42 additions and 2 deletions
12
ChangeLog
12
ChangeLog
|
@ -1,3 +1,15 @@
|
|||
Fri Jan 16 00:27:03 2009 Koichi Sasada <ko1@atdot.net>
|
||||
|
||||
* 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@atdot.net>
|
||||
|
||||
* common.mk: btest-ruby should receive option with OPTS.
|
||||
|
|
|
@ -130,3 +130,17 @@ assert_equal "ok", %q{
|
|||
: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
|
||||
}
|
||||
|
|
|
@ -1222,7 +1222,8 @@ setinlinecache
|
|||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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 @@ rb_const_get_0(VALUE klass, ID id, int exclude, int recurse)
|
|||
goto retry;
|
||||
}
|
||||
|
||||
return const_missing(klass, id);
|
||||
value = const_missing(klass, id);
|
||||
rb_vm_inc_const_missing_count();
|
||||
return value;
|
||||
}
|
||||
|
||||
VALUE
|
||||
|
|
8
vm.c
8
vm.c
|
@ -34,6 +34,8 @@ VALUE rb_cEnv;
|
|||
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 @@ rb_vm_change_state(void)
|
|||
INC_VM_STATE_VERSION();
|
||||
}
|
||||
|
||||
void
|
||||
rb_vm_inc_const_missing_count(void)
|
||||
{
|
||||
ruby_vm_const_missing_count +=1;
|
||||
}
|
||||
|
||||
/* control stack frame */
|
||||
|
||||
static inline VALUE
|
||||
|
|
|
@ -58,6 +58,7 @@ enum {
|
|||
|
||||
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() \
|
||||
|
|
Loading…
Reference in a new issue