1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Ensure non-OPT_GLOBAL_METHOD_CACHE code valid

This commit is contained in:
Nobuyoshi Nakada 2019-08-17 23:29:54 +09:00
parent 6db3051fcc
commit 1d11a8b193
No known key found for this signature in database
GPG key ID: 4BC7D6DF58D8DF60

View file

@ -803,8 +803,8 @@ verify_method_cache(VALUE klass, ID id, VALUE defined_class, rb_method_entry_t *
static rb_method_entry_t *
method_entry_get(VALUE klass, ID id, VALUE *defined_class_ptr)
{
#if OPT_GLOBAL_METHOD_CACHE
struct cache_entry *ent;
if (!OPT_GLOBAL_METHOD_CACHE) goto nocache;
ent = GLOBAL_METHOD_CACHE(klass, id);
if (ent->method_state == GET_GLOBAL_METHOD_STATE() &&
ent->class_serial == RCLASS_SERIAL(klass) &&
@ -814,8 +814,8 @@ method_entry_get(VALUE klass, ID id, VALUE *defined_class_ptr)
RB_DEBUG_COUNTER_INC(mc_global_hit);
return ent->me;
}
#endif
nocache:
RB_DEBUG_COUNTER_INC(mc_global_miss);
return method_entry_get_without_cache(klass, id, defined_class_ptr);
}
@ -2090,7 +2090,7 @@ obj_respond_to_missing(VALUE obj, VALUE mid, VALUE priv)
void
Init_Method(void)
{
#if OPT_GLOBAL_METHOD_CACHE
if (!OPT_GLOBAL_METHOD_CACHE) return;
char *ptr = getenv("RUBY_GLOBAL_METHOD_CACHE_SIZE");
int val;
@ -2109,7 +2109,6 @@ Init_Method(void)
fprintf(stderr, "[FATAL] failed to allocate memory\n");
exit(EXIT_FAILURE);
}
#endif
}
void