summaryrefslogtreecommitdiff
path: root/vm_method.c
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-06-12 08:53:15 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-06-12 08:53:15 +0000
commit8c09664a94ed4e1bf043847b28e4567da845292b (patch)
tree7681a8998eeec57eaf1457e95c43091b5ff9358f /vm_method.c
parent483efa1fda9b3701ca72842d28bd8b17a36a8ccd (diff)
* vm_method.c (rb_clear_cache*): update only vm state version.
* vm_method.c (rb_method_entry_get_without_cache, rb_method_entry): Fill method cache entry with vm state version, and check current vm state version for method (cache) look up. This modification speed-up invaridating of global method cache table. [Ruby 1.9 - Feature #3905] [ruby-core:36908] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32024 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm_method.c')
-rw-r--r--vm_method.c59
1 files changed, 4 insertions, 55 deletions
diff --git a/vm_method.c b/vm_method.c
index 20873713e6..34fddcc01c 100644
--- a/vm_method.c
+++ b/vm_method.c
@@ -13,6 +13,7 @@ static ID removed, singleton_removed, undefined, singleton_undefined;
static ID added, singleton_added, attached;
struct cache_entry { /* method hash table. */
+ VALUE filled_version; /* filled state version */
ID mid; /* method's id */
VALUE klass; /* receiver's class */
rb_method_entry_t *me;
@@ -25,79 +26,25 @@ static struct cache_entry cache[CACHE_SIZE];
void
rb_clear_cache(void)
{
- struct cache_entry *ent, *end;
-
rb_vm_change_state();
-
- if (!ruby_running)
- return;
- ent = cache;
- end = ent + CACHE_SIZE;
- while (ent < end) {
- ent->me = 0;
- ent->mid = 0;
- ent++;
- }
}
static void
rb_clear_cache_for_undef(VALUE klass, ID id)
{
- struct cache_entry *ent, *end;
-
rb_vm_change_state();
-
- if (!ruby_running)
- return;
- ent = cache;
- end = ent + CACHE_SIZE;
- while (ent < end) {
- if ((ent->me && ent->me->klass == klass) && ent->mid == id) {
- ent->me = 0;
- ent->mid = 0;
- }
- ent++;
- }
}
static void
rb_clear_cache_by_id(ID id)
{
- struct cache_entry *ent, *end;
-
rb_vm_change_state();
-
- if (!ruby_running)
- return;
- ent = cache;
- end = ent + CACHE_SIZE;
- while (ent < end) {
- if (ent->mid == id) {
- ent->me = 0;
- ent->mid = 0;
- }
- ent++;
- }
}
void
rb_clear_cache_by_class(VALUE klass)
{
- struct cache_entry *ent, *end;
-
rb_vm_change_state();
-
- if (!ruby_running)
- return;
- ent = cache;
- end = ent + CACHE_SIZE;
- while (ent < end) {
- if (ent->klass == klass || (ent->me && ent->me->klass == klass)) {
- ent->me = 0;
- ent->mid = 0;
- }
- ent++;
- }
}
VALUE
@@ -420,6 +367,7 @@ rb_method_entry_get_without_cache(VALUE klass, ID id)
if (ruby_running) {
struct cache_entry *ent;
ent = cache + EXPR1(klass, id);
+ ent->filled_version = GET_VM_STATE_VERSION();
ent->klass = klass;
if (UNDEFINED_METHOD_ENTRY_P(me)) {
@@ -442,7 +390,8 @@ rb_method_entry(VALUE klass, ID id)
struct cache_entry *ent;
ent = cache + EXPR1(klass, id);
- if (ent->mid == id && ent->klass == klass) {
+ if (ent->filled_version == GET_VM_STATE_VERSION() &&
+ ent->mid == id && ent->klass == klass) {
return ent->me;
}