diff options
author | 卜部昌平 <shyouhei@ruby-lang.org> | 2019-09-26 10:26:40 +0900 |
---|---|---|
committer | 卜部昌平 <shyouhei@ruby-lang.org> | 2019-09-30 10:26:38 +0900 |
commit | 86427a321997b733bf8ebb6036157c341a52edfc (patch) | |
tree | 8b2816538a62b48bf11e66d9be5eb61d631f2807 | |
parent | 6fdd701472af5355562cb2394167b26a4c3a2a97 (diff) | |
download | ruby-86427a321997b733bf8ebb6036157c341a52edfc.tar.gz |
refactor delete METHOD_ENTRY_COMPLEMENTED flag
Because rb_method_definition_t tracks its own complemented_count,
we no longer have to check it in rb_method_entry_t side.
-rw-r--r-- | method.h | 2 | ||||
-rw-r--r-- | vm_method.c | 15 |
2 files changed, 5 insertions, 12 deletions
@@ -66,8 +66,6 @@ typedef struct rb_callable_method_entry_struct { /* same fields with rb_method_e #define METHOD_ENTRY_VISI(me) (rb_method_visibility_t)(((me)->flags & (IMEMO_FL_USER0 | IMEMO_FL_USER1)) >> (IMEMO_FL_USHIFT+0)) #define METHOD_ENTRY_BASIC(me) (int) (((me)->flags & (IMEMO_FL_USER2 )) >> (IMEMO_FL_USHIFT+2)) -#define METHOD_ENTRY_COMPLEMENTED(me) ((me)->flags & IMEMO_FL_USER3) -#define METHOD_ENTRY_COMPLEMENTED_SET(me) ((me)->flags = (me)->flags | IMEMO_FL_USER3) static inline void METHOD_ENTRY_VISI_SET(rb_method_entry_t *me, rb_method_visibility_t visi) diff --git a/vm_method.c b/vm_method.c index 554d209110..241bb30a26 100644 --- a/vm_method.c +++ b/vm_method.c @@ -142,9 +142,11 @@ rb_add_method_cfunc(VALUE klass, ID mid, VALUE (*func)(ANYARGS), int argc, rb_me } } -static void -rb_method_definition_release(rb_method_definition_t *def, int complemented) +void +rb_free_method_entry(const rb_method_entry_t *me) { + rb_method_definition_t *def = me->def; + if (def != NULL) { const int alias_count = def->alias_count; const int complemented_count = def->complemented_count; @@ -158,7 +160,7 @@ rb_method_definition_release(rb_method_definition_t *def, int complemented) xfree(def); } else { - if (complemented) def->complemented_count--; + if (def->complemented_count > 0) def->complemented_count--; else if (def->alias_count > 0) def->alias_count--; if (METHOD_DEBUG) fprintf(stderr, "-%p-%s:%d->%d,%d->%d (dec)\n", (void *)def, rb_id2name(def->original_id), @@ -167,12 +169,6 @@ rb_method_definition_release(rb_method_definition_t *def, int complemented) } } -void -rb_free_method_entry(const rb_method_entry_t *me) -{ - rb_method_definition_release(me->def, METHOD_ENTRY_COMPLEMENTED(me)); -} - static inline rb_method_entry_t *search_method(VALUE klass, ID id, VALUE *defined_class_ptr); extern int rb_method_definition_eq(const rb_method_definition_t *d1, const rb_method_definition_t *d2); @@ -431,7 +427,6 @@ rb_method_entry_complement_defined_class(const rb_method_entry_t *src_me, ID cal } me = rb_method_entry_alloc(called_id, src_me->owner, defined_class, def); METHOD_ENTRY_FLAGS_COPY(me, src_me); - METHOD_ENTRY_COMPLEMENTED_SET(me); if (!def) { def = rb_method_definition_create(VM_METHOD_TYPE_REFINED, called_id); rb_method_definition_set(me, def, &refined); |