summaryrefslogtreecommitdiff
path: root/gc.c
diff options
context:
space:
mode:
authorshugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-11-29 12:50:10 +0000
committershugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-11-29 12:50:10 +0000
commit421314cf4e532cd4b840924b73f73fe33f25647b (patch)
tree0be26d7e4bdb9b4ef264f4c0ca3260c390b29c69 /gc.c
parentbda0aca2afa263022876432c5a91259193192a25 (diff)
* vm_method.c (rb_method_entry_make): add a method entry with
VM_METHOD_TYPE_REFINED to the class refined by the refinement if the target module is a refinement. When a method entry with VM_METHOD_TYPE_UNDEF is invoked by vm_call_method(), a method with the same name is searched in refinements. If such a method is found, the method is invoked. Otherwise, the original method in the refined class (rb_method_definition_t::body.orig_def) is invoked. This change is made to simplify the normal method lookup and to improve the performance of normal method calls. * vm_method.c (EXPR1, search_method, rb_method_entry), vm_eval.c (rb_call0, rb_search_method_entry): do not use refinements for method lookup. * vm_insnhelper.c (vm_call_method): search methods in refinements if ci->me is VM_METHOD_TYPE_REFINED. If the method is called by super (i.e., ci->call == vm_call_super_method), skip the same method entry as the current method to avoid infinite call of the same method. * class.c (include_modules_at): add a refined method entry for each method defined in a module included in a refinement. * class.c (rb_prepend_module): set an empty table to RCLASS_M_TBL(klass) to add refined method entries, because refinements should have priority over prepended modules. * proc.c (mnew): use rb_method_entry_with_refinements() to get a refined method. * test/ruby/test_refinement.rb (test_inline_method_cache): do not skip the test because it should pass successfully. * test/ruby/test_refinement.rb (test_redefine_refined_method): new test for the case a refined method is redefined. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37993 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'gc.c')
-rw-r--r--gc.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/gc.c b/gc.c
index 515fb8cde1..ff8549fad2 100644
--- a/gc.c
+++ b/gc.c
@@ -2432,6 +2432,7 @@ mark_method_entry(rb_objspace_t *objspace, const rb_method_entry_t *me)
const rb_method_definition_t *def = me->def;
gc_mark(objspace, me->klass);
+ again:
if (!def) return;
switch (def->type) {
case VM_METHOD_TYPE_ISEQ:
@@ -2444,6 +2445,9 @@ mark_method_entry(rb_objspace_t *objspace, const rb_method_entry_t *me)
case VM_METHOD_TYPE_IVAR:
gc_mark(objspace, def->body.attr.location);
break;
+ case VM_METHOD_TYPE_REFINED:
+ def = def->body.orig_def;
+ goto again;
default:
break; /* ignore */
}