From ba5ea548cefd82307e96a6308e2b85425030e461 Mon Sep 17 00:00:00 2001 From: shugo Date: Sun, 11 Nov 2012 02:42:04 +0000 Subject: * vm_core.h (rb_call_info_t::refinements), compile.c (new_callinfo): add a new field for inline method cache. * vm_insnhelper.c (vm_search_method): check rb_call_info_t::refinements not to confuse inline method cache when module_eval is used with refinements. * test/ruby/test_refinement.rb: related test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37616 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- vm_insnhelper.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'vm_insnhelper.c') diff --git a/vm_insnhelper.c b/vm_insnhelper.c index 554aad47b1..cf64c14684 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -843,19 +843,30 @@ static void vm_search_method(rb_call_info_t *ci, VALUE recv) { VALUE klass = CLASS_OF(recv); + NODE *cref = rb_vm_cref(); + VALUE refinements = Qnil; + + if (cref && !NIL_P(cref->nd_refinements)) { + refinements = cref->nd_refinements; + } #if OPT_INLINE_METHOD_CACHE - if (LIKELY(GET_VM_STATE_VERSION() == ci->vmstat && klass == ci->klass)) { + if (LIKELY(GET_VM_STATE_VERSION() == ci->vmstat && klass == ci->klass && + refinements == ci->refinements)) { /* cache hit! */ } else { - ci->me = rb_method_entry(klass, ci->mid, &ci->defined_class); + ci->me = rb_method_entry_get_with_refinements(refinements, klass, + ci->mid, + &ci->defined_class); ci->klass = klass; + ci->refinements = refinements; ci->vmstat = GET_VM_STATE_VERSION(); ci->call = vm_call_general; } #else - ci->me = rb_method_entry(klass, ci->mid, &ci->defined_class); + ci->me = rb_method_entry_get_with_refinements(refinements, klass, ci->mid, + &ci->defined_class); ci->call = vm_call_general; ci->klass = klass; #endif -- cgit v1.2.3