Project

General

Profile

Feature #7816 » feature-7816-v2.patch

Anonymous, 02/10/2013 10:13 PM

View differences:

class.c
RCLASS_SUPER(klass) = super;
RCLASS_M_TBL(klass) = st_init_numtable();
FL_SET(super, RCLASS_INHERITED_FLAG);
OBJ_INFECT(klass, super);
return (VALUE)klass;
}
include/ruby/ruby.h
#define RMODULE_IS_OVERLAID FL_USER2
#define RMODULE_IS_REFINEMENT FL_USER3
#define RMODULE_INCLUDED_INTO_REFINEMENT FL_USER4
#define RCLASS_INHERITED_FLAG FL_USER5
struct RFloat {
struct RBasic basic;
insns.def
class_iseq->local_size, 0);
RESTORE_REGS();
INC_VM_STATE_VERSION();
NEXT_INSN();
}
vm.c
if (!is_singleton && noex == NOEX_MODFUNC) {
rb_add_method(rb_singleton_class(klass), id, VM_METHOD_TYPE_ISEQ, miseq, NOEX_PUBLIC);
}
INC_VM_STATE_VERSION();
}
#define REWIND_CFP(expr) do { \
......
static VALUE usage_analysis_register_stop(VALUE self);
#endif
/*
* call-seq:
* RubyVM.state_version -> int
*
* Returns the current VM state version. The state version is used for
* invalidating inline method and constant caches.
*
* The state version is not guaranteed to be monotonic and may wrap around in
* long running processes.
*/
static VALUE
vm_state_version()
{
return INT2FIX(ruby_vm_global_state_version);
}
void
Init_VM(void)
{
......
rb_cRubyVM = rb_define_class("RubyVM", rb_cObject);
rb_undef_alloc_func(rb_cRubyVM);
rb_undef_method(CLASS_OF(rb_cRubyVM), "new");
rb_define_singleton_method(rb_cRubyVM, "state_version", vm_state_version, 0);
/* FrozenCore (hidden) */
fcore = rb_class_new(rb_cBasicObject);
vm_method.c
}
}
static inline rb_method_entry_t*
search_method(VALUE klass, ID id, VALUE *defined_class_ptr);
static rb_method_entry_t *
rb_method_entry_make(VALUE klass, ID mid, rb_method_type_t type,
rb_method_definition_t *def, rb_method_flag_t noex)
......
me = ALLOC(rb_method_entry_t);
rb_clear_cache_by_id(mid);
if (search_method(klass, mid, NULL) /* clear cache if overriding existing method */
|| FL_TEST(klass, RCLASS_INHERITED_FLAG) /* or this class has subclasses */
|| RB_TYPE_P(klass, T_MODULE) /* or this is a module */)
{
rb_clear_cache_by_id(mid);
}
me->flag = NOEX_WITH_SAFE(noex);
me->mark = 0;
......
ent = cache + EXPR1(klass, id);
if (ent->filled_version == GET_VM_STATE_VERSION() &&
ent->mid == id && ent->klass == klass) {
ent->mid == id && ent->klass == klass && ent->me) {
if (defined_class_ptr)
*defined_class_ptr = ent->defined_class;
return ent->me;
(2-2/3)