Beispiel #1
0
static void
verify_method_cache(VALUE klass, ID id, VALUE defined_class, rb_method_entry_t *me)
{
    VALUE actual_defined_class;
    rb_method_entry_t *actual_me =
	rb_method_entry_get_without_cache(klass, id, &actual_defined_class);

    if (me != actual_me || defined_class != actual_defined_class) {
	rb_bug("method cache verification failed");
    }
}
rb_method_entry_t *
rb_method_entry(VALUE klass, ID id)
{
    struct cache_entry *ent;

    ent = cache + EXPR1(klass, id);
    if (ent->filled_version == GET_VM_STATE_VERSION() &&
	ent->mid == id && ent->klass == klass) {
	return ent->me;
    }

    return rb_method_entry_get_without_cache(klass, id);
}
Beispiel #3
0
rb_method_entry_t *
rb_method_entry(VALUE klass, ID id, VALUE *defined_class_ptr)
{
#if OPT_GLOBAL_METHOD_CACHE
    struct cache_entry *ent;
    ent = GLOBAL_METHOD_CACHE(klass, id);
    if (ent->method_state == GET_GLOBAL_METHOD_STATE() &&
	ent->class_serial == RCLASS_SERIAL(klass) &&
	ent->mid == id) {
	if (defined_class_ptr)
	    *defined_class_ptr = ent->defined_class;
#if VM_DEBUG_VERIFY_METHOD_CACHE
	verify_method_cache(klass, id, ent->defined_class, ent->me);
#endif
	return ent->me;
    }
#endif

    return rb_method_entry_get_without_cache(klass, id, defined_class_ptr);
}