ruby-changes:38667
From: ko1 <ko1@a...>
Date: Wed, 3 Jun 2015 20:10:33 +0900 (JST)
Subject: [ruby-changes:38667] ko1:r50748 (trunk): * class.c (clone_method): remove redundant check for me->def != NULL.
ko1 2015-06-03 20:10:16 +0900 (Wed, 03 Jun 2015) New Revision: 50748 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=50748 Log: * class.c (clone_method): remove redundant check for me->def != NULL. Now, all `me` have `me->def`. * proc.c (rb_method_entry_location): ditto. * vm.c (rb_vm_check_redefinition_opt_method): ditto. * vm.c (add_opt_method): ditto. * vm_eval.c (vm_call0_body): ditto. Modified files: trunk/ChangeLog trunk/class.c trunk/proc.c trunk/vm.c trunk/vm_eval.c Index: ChangeLog =================================================================== --- ChangeLog (revision 50747) +++ ChangeLog (revision 50748) @@ -1,3 +1,16 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Wed Jun 3 20:07:07 2015 Koichi Sasada <ko1@a...> + + * class.c (clone_method): remove redundant check for me->def != NULL. + Now, all `me` have `me->def`. + + * proc.c (rb_method_entry_location): ditto. + + * vm.c (rb_vm_check_redefinition_opt_method): ditto. + + * vm.c (add_opt_method): ditto. + + * vm_eval.c (vm_call0_body): ditto. + Wed Jun 3 19:24:12 2015 Koichi Sasada <ko1@a...> * vm_core.h: rename enum missing_reason to enum method_missing_reason. Index: vm_eval.c =================================================================== --- vm_eval.c (revision 50747) +++ vm_eval.c (revision 50748) @@ -153,8 +153,6 @@ vm_call0_body(rb_thread_t* th, rb_call_i https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L153 { VALUE ret; - if (!ci->me->def) return Qnil; - if (th->passed_block) { ci->blockptr = (rb_block_t *)th->passed_block; th->passed_block = 0; @@ -213,7 +211,6 @@ vm_call0_body(rb_thread_t* th, rb_call_i https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L211 goto success; } RUBY_VM_CHECK_INTS(th); - if (!ci->me->def) return Qnil; goto again; } case VM_METHOD_TYPE_ALIAS: Index: proc.c =================================================================== --- proc.c (revision 50747) +++ proc.c (revision 50748) @@ -2239,7 +2239,7 @@ method_def_location(const rb_method_defi https://github.com/ruby/ruby/blob/trunk/proc.c#L2239 VALUE rb_method_entry_location(const rb_method_entry_t *me) { - if (!me || !me->def) return Qnil; + if (!me) return Qnil; return method_def_location(me->def); } Index: class.c =================================================================== --- class.c (revision 50747) +++ class.c (revision 50748) @@ -243,21 +243,16 @@ rb_class_new(VALUE super) https://github.com/ruby/ruby/blob/trunk/class.c#L243 static void clone_method(VALUE klass, ID mid, const rb_method_entry_t *me) { - if (me->def) { - if (me->def->type == VM_METHOD_TYPE_ISEQ) { - VALUE newiseqval; - rb_cref_t *new_cref; - newiseqval = rb_iseq_clone(me->def->body.iseq.iseqptr->self, klass); - rb_vm_rewrite_cref_stack(me->def->body.iseq.cref, me->klass, klass, &new_cref); - rb_add_method_iseq(klass, mid, newiseqval, new_cref, me->def->flags.visi); - RB_GC_GUARD(newiseqval); - } - else { - rb_method_entry_set(klass, mid, me, me->def->flags.visi); - } + if (me->def->type == VM_METHOD_TYPE_ISEQ) { + VALUE newiseqval; + rb_cref_t *new_cref; + newiseqval = rb_iseq_clone(me->def->body.iseq.iseqptr->self, klass); + rb_vm_rewrite_cref_stack(me->def->body.iseq.cref, me->klass, klass, &new_cref); + rb_add_method_iseq(klass, mid, newiseqval, new_cref, me->def->flags.visi); + RB_GC_GUARD(newiseqval); } else { - rb_bug("clone_method: unsupported"); + rb_method_entry_set(klass, mid, me, me->def->flags.visi); } } Index: vm.c =================================================================== --- vm.c (revision 50747) +++ vm.c (revision 50748) @@ -1237,7 +1237,7 @@ static void https://github.com/ruby/ruby/blob/trunk/vm.c#L1237 rb_vm_check_redefinition_opt_method(const rb_method_entry_t *me, VALUE klass) { st_data_t bop; - if (!me->def || me->def->type == VM_METHOD_TYPE_CFUNC) { + if (me->def->type == VM_METHOD_TYPE_CFUNC) { if (st_lookup(vm_opt_method_table, (st_data_t)me, &bop)) { int flag = vm_redefinition_check_flag(klass); @@ -1272,8 +1272,7 @@ add_opt_method(VALUE klass, ID mid, VALU https://github.com/ruby/ruby/blob/trunk/vm.c#L1272 { rb_method_entry_t *me = rb_method_entry_at(klass, mid); - if (me && me->def && - me->def->type == VM_METHOD_TYPE_CFUNC) { + if (me && me->def->type == VM_METHOD_TYPE_CFUNC) { st_insert(vm_opt_method_table, (st_data_t)me, (st_data_t)bop); } else { -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/