* method.h: back to share rb_method_definition_t by

rb_method_entry_t.
  r50728 changed sharing `def's to isolating `def's
  on alias and so on. However, this change conflicts
  future improvement plan. So I change back to sharing approach.
* method.h: move rb_method_definition_t::flags to
  rb_method_entry_t::attr::flags.
  rb_method_entry_t::attr is union with VALUE because this field
  should have same size of VALUE. rb_method_entry_t is T_IMEMO).
  And also add the following access macros to it's fileds.
  * METHOD_ENTRY_VISI(me)
  * METHOD_ENTRY_BASIC(me)
  * METHOD_ENTRY_SAFE(me)
* vm_method.c (rb_method_definition_addref): added instead of
  rb_method_definition_clone().
  Do not create new definition, but increment alias_count.
* class.c (clone_method): catch up this fix.
* class.c (method_entry_i): ditto.
* proc.c (mnew_internal): ditto.
* proc.c (mnew_missing): ditto.
* vm_eval.c: ditto.
* vm_insnhelper.c: ditto.
* vm_method.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50792 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ko1 2015-06-06 10:19:48 +00:00
parent c9044a2472
commit c19d373750
7 changed files with 114 additions and 90 deletions

12
proc.c
View file

@ -1161,11 +1161,11 @@ mnew_missing(VALUE rclass, VALUE klass, VALUE obj, ID id, ID rid, VALUE mclass)
data->id = rid;
def = ZALLOC(rb_method_definition_t);
def->flags.visi = METHOD_VISI_UNDEF;
def->type = VM_METHOD_TYPE_MISSING;
def->original_id = id;
me = rb_method_entry_create(id, klass, def);
me = rb_method_entry_create(id, klass, METHOD_VISI_UNDEF, def);
RB_OBJ_WRITE(method, &data->me, me);
OBJ_INFECT(method, klass);
@ -1181,7 +1181,6 @@ mnew_internal(const rb_method_entry_t *me, VALUE defined_class, VALUE klass,
VALUE rclass = klass;
VALUE method;
ID rid = id;
rb_method_definition_t *def = 0;
rb_method_visibility_t visi = METHOD_VISI_UNDEF;
again:
@ -1192,17 +1191,16 @@ mnew_internal(const rb_method_entry_t *me, VALUE defined_class, VALUE klass,
if (!error) return Qnil;
rb_print_undef(klass, id, 0);
}
def = me->def;
if (visi == METHOD_VISI_UNDEF) {
visi = def->flags.visi;
visi = METHOD_ENTRY_VISI(me);
if (scope && (visi != METHOD_VISI_PUBLIC)) {
if (!error) return Qnil;
rb_print_inaccessible(klass, id, visi);
}
}
if (def->type == VM_METHOD_TYPE_ZSUPER) {
if (me->def->type == VM_METHOD_TYPE_ZSUPER) {
klass = RCLASS_SUPER(defined_class);
id = def->original_id;
id = me->def->original_id;
me = rb_method_entry_without_refinements(klass, id, &defined_class);
goto again;
}