ruby-changes:58037
From: =E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3 <ko1@a...>
Date: Mon, 30 Sep 2019 10:43:19 +0900 (JST)
Subject: [ruby-changes:58037] 86427a3219 (master): refactor delete METHOD_ENTRY_COMPLEMENTED flag
https://git.ruby-lang.org/ruby.git/commit/?id=86427a3219 From 86427a321997b733bf8ebb6036157c341a52edfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3?= <shyouhei@r...> Date: Thu, 26 Sep 2019 10:26:40 +0900 Subject: 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. diff --git a/method.h b/method.h index 84ade7f..b26f678 100644 --- a/method.h +++ b/method.h @@ -66,8 +66,6 @@ typedef struct rb_callable_method_entry_struct { /* same fields with rb_method_e https://github.com/ruby/ruby/blob/trunk/method.h#L66 #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 554d209..241bb30 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 https://github.com/ruby/ruby/blob/trunk/vm_method.c#L142 } } -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) https://github.com/ruby/ruby/blob/trunk/vm_method.c#L160 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) https://github.com/ruby/ruby/blob/trunk/vm_method.c#L169 } } -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 https://github.com/ruby/ruby/blob/trunk/vm_method.c#L427 } 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); -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/