ruby-changes:19977
From: ko1 <ko1@a...>
Date: Sun, 12 Jun 2011 17:53:29 +0900 (JST)
Subject: [ruby-changes:19977] ko1:r32024 (trunk): * vm_method.c (rb_clear_cache*): update only vm state version.
ko1 2011-06-12 17:53:15 +0900 (Sun, 12 Jun 2011) New Revision: 32024 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=32024 Log: * 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] Modified files: trunk/ChangeLog trunk/vm_method.c Index: ChangeLog =================================================================== --- ChangeLog (revision 32023) +++ ChangeLog (revision 32024) @@ -1,3 +1,13 @@ +Sun Jun 12 17:40:29 2011 Koichi Sasada <ko1@a...> + + * 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] + Sun Jun 12 16:19:48 2011 Hidetoshi NAGAI <nagai@a...> * ext/tk/extconf.rb: fail on Mac OS X. [Bug #4853][ruby-dev:43655] Index: vm_method.c =================================================================== --- vm_method.c (revision 32023) +++ vm_method.c (revision 32024) @@ -13,6 +13,7 @@ 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 @@ 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 @@ 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 @@ 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; } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/