diff --git a/gc.c b/gc.c index eada017888..dc9974be22 100644 --- a/gc.c +++ b/gc.c @@ -6684,7 +6684,6 @@ mark_method_entry(rb_objspace_t *objspace, const rb_method_entry_t *me) return; case VM_METHOD_TYPE_REFINED: gc_mark(objspace, (VALUE)def->body.refined.orig_me); - gc_mark(objspace, (VALUE)def->body.refined.owner); break; case VM_METHOD_TYPE_CFUNC: case VM_METHOD_TYPE_ZSUPER: @@ -10308,7 +10307,6 @@ gc_ref_update_method_entry(rb_objspace_t *objspace, rb_method_entry_t *me) return; case VM_METHOD_TYPE_REFINED: TYPED_UPDATE_IF_MOVED(objspace, struct rb_method_entry_struct *, def->body.refined.orig_me); - UPDATE_IF_MOVED(objspace, def->body.refined.owner); break; case VM_METHOD_TYPE_CFUNC: case VM_METHOD_TYPE_ZSUPER: diff --git a/method.h b/method.h index fece2e54c3..ad66690c6a 100644 --- a/method.h +++ b/method.h @@ -153,7 +153,6 @@ typedef struct rb_method_alias_struct { typedef struct rb_method_refined_struct { struct rb_method_entry_struct * orig_me; - VALUE owner; } rb_method_refined_t; typedef struct rb_method_bmethod_struct { diff --git a/vm_method.c b/vm_method.c index 6b05b38e4d..1f14d82bcd 100644 --- a/vm_method.c +++ b/vm_method.c @@ -585,9 +585,7 @@ rb_method_definition_set(const rb_method_entry_t *me, rb_method_definition_t *de return; case VM_METHOD_TYPE_REFINED: { - const rb_method_refined_t *refined = (rb_method_refined_t *)opts; - RB_OBJ_WRITE(me, &def->body.refined.orig_me, refined->orig_me); - RB_OBJ_WRITE(me, &def->body.refined.owner, refined->owner); + RB_OBJ_WRITE(me, &def->body.refined.orig_me, (rb_method_entry_t *)opts); return; } case VM_METHOD_TYPE_ALIAS: @@ -623,7 +621,6 @@ method_definition_reset(const rb_method_entry_t *me) break; case VM_METHOD_TYPE_REFINED: RB_OBJ_WRITTEN(me, Qundef, def->body.refined.orig_me); - RB_OBJ_WRITTEN(me, Qundef, def->body.refined.owner); break; case VM_METHOD_TYPE_ALIAS: RB_OBJ_WRITTEN(me, Qundef, def->body.alias.original_me); @@ -706,12 +703,7 @@ rb_method_entry_clone(const rb_method_entry_t *src_me) // can create reference edges we can't run WBs for. rb_method_definition_t *clone_def = rb_method_definition_create(VM_METHOD_TYPE_REFINED, src_me->called_id); - - rb_method_refined_t refined = { - .owner = src_me->def->body.refined.owner, - .orig_me = orig_clone, - }; - rb_method_definition_set(me, clone_def, &refined); + rb_method_definition_set(me, clone_def, orig_clone); } return me; } @@ -721,10 +713,7 @@ rb_method_entry_complement_defined_class(const rb_method_entry_t *src_me, ID cal { rb_method_definition_t *def = src_me->def; rb_method_entry_t *me; - struct { - const struct rb_method_entry_struct *orig_me; - VALUE owner; - } refined = {0}; + const rb_method_entry_t *refined_orig_me = NULL; if (!src_me->defined_class && def->type == VM_METHOD_TYPE_REFINED && @@ -732,8 +721,7 @@ rb_method_entry_complement_defined_class(const rb_method_entry_t *src_me, ID cal const rb_method_entry_t *orig_me = rb_method_entry_clone(def->body.refined.orig_me); RB_OBJ_WRITE((VALUE)orig_me, &orig_me->defined_class, defined_class); - refined.orig_me = orig_me; - refined.owner = orig_me->owner; + refined_orig_me = orig_me; def = NULL; } @@ -742,7 +730,7 @@ rb_method_entry_complement_defined_class(const rb_method_entry_t *src_me, ID cal 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); + rb_method_definition_set(me, def, (void *)refined_orig_me); } VM_ASSERT(RB_TYPE_P(me->owner, T_MODULE)); @@ -769,25 +757,19 @@ make_method_entry_refined(VALUE owner, rb_method_entry_t *me) return; } else { - struct { - struct rb_method_entry_struct *orig_me; - VALUE owner; - } refined; rb_method_definition_t *def; rb_vm_check_redefinition_opt_method(me, me->owner); - refined.orig_me = + struct rb_method_entry_struct *orig_me = rb_method_entry_alloc(me->called_id, me->owner, - me->defined_class ? - me->defined_class : owner, + me->defined_class ? me->defined_class : owner, me->def, true); - METHOD_ENTRY_FLAGS_COPY(refined.orig_me, me); - refined.owner = owner; + METHOD_ENTRY_FLAGS_COPY(orig_me, me); def = rb_method_definition_create(VM_METHOD_TYPE_REFINED, me->called_id); - rb_method_definition_set(me, def, (void *)&refined); + rb_method_definition_set(me, def, orig_me); METHOD_ENTRY_VISI_SET(me, METHOD_VISI_PUBLIC); } }