ruby-changes:43538
From: shugo <ko1@a...>
Date: Fri, 8 Jul 2016 14:22:00 +0900 (JST)
Subject: [ruby-changes:43538] shugo:r55611 (trunk): * vm_args.c (vm_caller_setup_arg_block): call rb_sym_to_proc()
shugo 2016-07-08 14:21:54 +0900 (Fri, 08 Jul 2016) New Revision: 55611 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=55611 Log: * vm_args.c (vm_caller_setup_arg_block): call rb_sym_to_proc() directly to reduce method dispatch overhead. Modified files: trunk/ChangeLog trunk/vm_args.c Index: vm_args.c =================================================================== --- vm_args.c (revision 55610) +++ vm_args.c (revision 55611) @@ -766,12 +766,23 @@ vm_caller_setup_arg_kw(rb_control_frame_ https://github.com/ruby/ruby/blob/trunk/vm_args.c#L766 calling->argc -= kw_len - 1; } +static inline void +vm_caller_setup_proc_as_block(rb_control_frame_t *reg_cfp, + struct rb_calling_info *calling, + VALUE proc) +{ + rb_proc_t *po; + + GetProcPtr(proc, po); + calling->blockptr = &po->block; + RUBY_VM_GET_BLOCK_PTR_IN_CFP(reg_cfp)->proc = proc; +} + static void vm_caller_setup_arg_block(const rb_thread_t *th, rb_control_frame_t *reg_cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, rb_iseq_t *blockiseq, const int is_super) { if (ci->flag & VM_CALL_ARGS_BLOCKARG) { - rb_proc_t *po; VALUE proc; proc = *(--reg_cfp->sp); @@ -779,11 +790,17 @@ vm_caller_setup_arg_block(const rb_threa https://github.com/ruby/ruby/blob/trunk/vm_args.c#L790 if (NIL_P(proc)) { calling->blockptr = NULL; } - else if (LIKELY(!(ci->flag & VM_CALL_TAILCALL)) && SYMBOL_P(proc) && + else if (SYMBOL_P(proc) && rb_method_basic_definition_p(rb_cSymbol, idTo_proc)) { - calling->blockptr = RUBY_VM_GET_BLOCK_PTR_IN_CFP(reg_cfp); - calling->blockptr->iseq = (rb_iseq_t *)proc; - calling->blockptr->proc = proc; + if (LIKELY(!(ci->flag & VM_CALL_TAILCALL))) { + calling->blockptr = RUBY_VM_GET_BLOCK_PTR_IN_CFP(reg_cfp); + calling->blockptr->iseq = (rb_iseq_t *)proc; + calling->blockptr->proc = proc; + } + else { + proc = rb_sym_to_proc(proc); + vm_caller_setup_proc_as_block(reg_cfp, calling, proc); + } } else { if (!rb_obj_is_proc(proc)) { @@ -797,9 +814,7 @@ vm_caller_setup_arg_block(const rb_threa https://github.com/ruby/ruby/blob/trunk/vm_args.c#L814 } proc = b; } - GetProcPtr(proc, po); - calling->blockptr = &po->block; - RUBY_VM_GET_BLOCK_PTR_IN_CFP(reg_cfp)->proc = proc; + vm_caller_setup_proc_as_block(reg_cfp, calling, proc); } } else if (blockiseq != 0) { /* likely */ Index: ChangeLog =================================================================== --- ChangeLog (revision 55610) +++ ChangeLog (revision 55611) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Fri Jul 8 14:16:48 2016 Shugo Maeda <shugo@r...> + + * vm_args.c (vm_caller_setup_arg_block): call rb_sym_to_proc() + directly to reduce method dispatch overhead. + Fri Jul 8 08:43:31 2016 Shugo Maeda <shugo@r...> * io.c (rb_io_s_read): add description of pipes to the documentation -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/