Bug #7111 ยป opt_global_method_cache.diff
vm_method.c | ||
---|---|---|
static ID removed, singleton_removed, undefined, singleton_undefined;
|
||
static ID added, singleton_added, attached;
|
||
#if OPT_GLOBAL_METHOD_CACHE
|
||
struct cache_entry { /* method hash table. */
|
||
VALUE filled_version; /* filled state version */
|
||
ID mid; /* method's id */
|
||
... | ... | |
};
|
||
static struct cache_entry cache[CACHE_SIZE];
|
||
#endif
|
||
#define ruby_running (GET_VM()->running)
|
||
/* int ruby_running = 0; */
|
||
static void
|
||
vm_clear_global_method_cache(void)
|
||
{
|
||
#if OPT_GLOBAL_METHOD_CACHE
|
||
struct cache_entry *ent, *end;
|
||
ent = cache;
|
||
... | ... | |
ent->filled_version = 0;
|
||
ent++;
|
||
}
|
||
#endif
|
||
}
|
||
void
|
||
... | ... | |
VALUE defined_class;
|
||
rb_method_entry_t *me = search_method(klass, id, omod, &defined_class);
|
||
#if OPT_GLOBAL_METHOD_CACHE
|
||
if (ruby_running) {
|
||
struct cache_entry *ent;
|
||
ent = cache + EXPR1(klass, omod, id);
|
||
... | ... | |
ent->me = me;
|
||
}
|
||
}
|
||
#endif
|
||
if (defined_class_ptr)
|
||
*defined_class_ptr = defined_class;
|
||
... | ... | |
rb_method_entry_get_with_omod(VALUE omod, VALUE klass, ID id,
|
||
VALUE *defined_class_ptr)
|
||
{
|
||
#if OPT_GLOBAL_METHOD_CACHE
|
||
struct cache_entry *ent;
|
||
ent = cache + EXPR1(klass, omod, id);
|
||
... | ... | |
*defined_class_ptr = ent->defined_class;
|
||
return ent->me;
|
||
}
|
||
#endif
|
||
return rb_method_entry_get_without_cache(klass, omod, id,
|
||
defined_class_ptr);
|
vm_opts.h | ||
---|---|---|
/* VM running option */
|
||
#define OPT_CHECKED_RUN 1
|
||
#define OPT_INLINE_METHOD_CACHE 1
|
||
#define OPT_GLOBAL_METHOD_CACHE 1
|
||
#define OPT_BLOCKINLINING 0
|
||
/* architecture independent, affects generated code */
|