ruby-changes:37424
From: nobu <ko1@a...>
Date: Thu, 5 Feb 2015 12:31:14 +0900 (JST)
Subject: [ruby-changes:37424] nobu:r49505 (trunk): vm_insnhelper.c: fix missing reason
nobu 2015-02-05 12:31:07 +0900 (Thu, 05 Feb 2015) New Revision: 49505 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=49505 Log: vm_insnhelper.c: fix missing reason * vm_insnhelper.c (ci_missing_reason): return the reason of method missing in call info. * vm_insnhelper.c (vm_call_opt_send): re-apply r49500 with the proper missing reason. [Bug #10828] Modified files: trunk/ChangeLog trunk/test/-ext-/symbol/test_inadvertent_creation.rb trunk/vm_insnhelper.c Index: ChangeLog =================================================================== --- ChangeLog (revision 49504) +++ ChangeLog (revision 49505) @@ -1,3 +1,11 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Thu Feb 5 12:31:05 2015 Nobuyoshi Nakada <nobu@r...> + + * vm_insnhelper.c (ci_missing_reason): return the reason of method + missing in call info. + + * vm_insnhelper.c (vm_call_opt_send): re-apply r49500 with the + proper missing reason. [Bug #10828] + Thu Feb 5 10:31:46 2015 Shugo Maeda <shugo@r...> * class.c (rb_obj_singleton_methods): should use RTEST() to convert Index: vm_insnhelper.c =================================================================== --- vm_insnhelper.c (revision 49504) +++ vm_insnhelper.c (revision 49505) @@ -1497,6 +1497,19 @@ vm_call_bmethod(rb_thread_t *th, rb_cont https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L1497 return vm_call_bmethod_body(th, ci, argv); } +static int +ci_missing_reason(const rb_call_info_t *ci) +{ + int stat = 0; + if (ci->flag & VM_CALL_VCALL) { + stat |= NOEX_VCALL; + } + if (ci->flag & VM_CALL_SUPER) { + stat |= NOEX_SUPER; + } + return stat; +} + static #ifdef _MSC_VER __forceinline @@ -1531,16 +1544,18 @@ vm_call_opt_send(rb_thread_t *th, rb_con https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L1544 VALUE exc = make_no_method_exception(rb_eNoMethodError, NULL, ci->recv, rb_long2int(ci->argc), &TOPN(i)); rb_exc_raise(exc); } - ci->mid = rb_to_id(sym); + ci->mid = idMethodMissing; + th->method_missing_reason = ci->aux.missing_reason = ci_missing_reason(ci); } - - /* shift arguments */ - if (i > 0) { - MEMMOVE(&TOPN(i), &TOPN(i-1), VALUE, i); + else { + /* shift arguments */ + if (i > 0) { + MEMMOVE(&TOPN(i), &TOPN(i-1), VALUE, i); + } + ci->argc -= 1; + DEC_SP(1); } ci->me = rb_method_entry_without_refinements(CLASS_OF(ci->recv), ci->mid, &ci->defined_class); - ci->argc -= 1; - DEC_SP(1); ci->flag = VM_CALL_FCALL | VM_CALL_OPT_SEND; @@ -1785,13 +1800,7 @@ vm_call_method(rb_thread_t *th, rb_contr https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L1800 } else { /* method missing */ - int stat = 0; - if (ci->flag & VM_CALL_VCALL) { - stat |= NOEX_VCALL; - } - if (ci->flag & VM_CALL_SUPER) { - stat |= NOEX_SUPER; - } + const int stat = ci_missing_reason(ci); if (ci->mid == idMethodMissing) { rb_control_frame_t *reg_cfp = cfp; VALUE *argv = STACK_ADDR_FROM_TOP(ci->argc); Index: test/-ext-/symbol/test_inadvertent_creation.rb =================================================================== --- test/-ext-/symbol/test_inadvertent_creation.rb (revision 49504) +++ test/-ext-/symbol/test_inadvertent_creation.rb (revision 49505) @@ -383,7 +383,7 @@ module Test_Symbol https://github.com/ruby/ruby/blob/trunk/test/-ext-/symbol/test_inadvertent_creation.rb#L383 assert_no_immortal_symbol_created("send should not leak - str mm") do |name| assert_nothing_raised(NoMethodError) {x.send(name)} end - end if false + end def test_send_leak_symbol_custom_method_missing x = Object.new @@ -391,7 +391,7 @@ module Test_Symbol https://github.com/ruby/ruby/blob/trunk/test/-ext-/symbol/test_inadvertent_creation.rb#L391 assert_no_immortal_symbol_created("send should not leak - sym mm") do |name| assert_nothing_raised(NoMethodError) {x.send(name.to_sym)} end - end if false + end def test_send_leak_string_no_optimization assert_no_immortal_symbol_created("send should not leak - str slow") do |name| -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/