ruby-changes:33242
From: nobu <ko1@a...>
Date: Wed, 12 Mar 2014 11:19:19 +0900 (JST)
Subject: [ruby-changes:33242] nobu:r45321 (trunk): vm_insnhelper.c: disable fastpath if splat
nobu 2014-03-12 11:19:13 +0900 (Wed, 12 Mar 2014) New Revision: 45321 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=45321 Log: vm_insnhelper.c: disable fastpath if splat * vm_insnhelper.c (vm_callee_setup_arg): disable fastpath if splat argument, since argc may differ for each calls. [ruby-core:61422] [Bug #9622] Modified files: trunk/ChangeLog trunk/test/ruby/test_call.rb trunk/vm_insnhelper.c Index: ChangeLog =================================================================== --- ChangeLog (revision 45320) +++ ChangeLog (revision 45321) @@ -1,4 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 -Wed Mar 12 11:18:40 2014 Nobuyoshi Nakada <nobu@r...> +Wed Mar 12 11:19:03 2014 Nobuyoshi Nakada <nobu@r...> + + * vm_insnhelper.c (vm_callee_setup_arg): disable fastpath if splat + argument, since argc may differ for each calls. + [ruby-core:61422] [Bug #9622] * vm_insnhelper.c (vm_callee_setup_arg): turn a macro into an inline function. Index: vm_insnhelper.c =================================================================== --- vm_insnhelper.c (revision 45320) +++ vm_insnhelper.c (revision 45321) @@ -1210,7 +1210,9 @@ vm_callee_setup_arg(rb_thread_t *th, rb_ https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L1210 (UNLIKELY(ci->flag & VM_CALL_TAILCALL) ? vm_call_iseq_setup_tailcall : vm_call_iseq_setup_normal), - !is_lambda && !(ci->me->flag & NOEX_PROTECTED)); + (!is_lambda && + !(ci->flag & VM_CALL_ARGS_SPLAT) && /* argc may differ for each calls */ + !(ci->me->flag & NOEX_PROTECTED))); } else { ci->aux.opt_pc = vm_callee_setup_arg_complex(th, ci, iseq, argv); Index: test/ruby/test_call.rb =================================================================== --- test/ruby/test_call.rb (revision 45320) +++ test/ruby/test_call.rb (revision 45321) @@ -16,4 +16,19 @@ class TestCall < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_call.rb#L16 assert_equal([1, 2, 3, 4], aaa(1, 2, 3, 4)) assert_equal([1, 2, 3, 4], aaa(1, *[2, 3, 4])) end + + def test_callinfo + bug9622 = '[ruby-core:61422] [Bug #9622]' + o = Class.new do + def foo(*args) + bar(:foo, *args) + end + def bar(name) + name + end + end.new + e = assert_raise(ArgumentError) {o.foo(100)} + assert_nothing_raised(ArgumentError) {o.foo} + assert_raise_with_message(ArgumentError, e.message, bug9622) {o.foo(100)} + end end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/