ruby-changes:55122
From: k0kubun <ko1@a...>
Date: Thu, 21 Mar 2019 15:25:14 +0900 (JST)
Subject: [ruby-changes:55122] k0kubun:r67329 (trunk): Share vm_call_iseq_optimizable_p to reduce copy-paste
k0kubun 2019-03-21 15:25:09 +0900 (Thu, 21 Mar 2019) New Revision: 67329 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=67329 Log: Share vm_call_iseq_optimizable_p to reduce copy-paste Modified files: trunk/mjit_compile.c trunk/vm_insnhelper.c trunk/vm_insnhelper.h Index: vm_insnhelper.c =================================================================== --- vm_insnhelper.c (revision 67328) +++ vm_insnhelper.c (revision 67329) @@ -1782,9 +1782,7 @@ vm_callee_setup_arg(rb_execution_context https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L1782 argument_arity_error(ec, iseq, calling->argc, iseq->body->param.lead_num, iseq->body->param.lead_num); } - CC_SET_FASTPATH(cc, vm_call_iseq_setup_func(ci, param_size, local_size), - (!IS_ARGS_SPLAT(ci) && !IS_ARGS_KEYWORD(ci) && - !(METHOD_ENTRY_VISI(cc->me) == METHOD_VISI_PROTECTED))); + CC_SET_FASTPATH(cc, vm_call_iseq_setup_func(ci, param_size, local_size), vm_call_iseq_optimizable_p(ci, cc)); return 0; } else if (rb_iseq_only_optparam_p(iseq)) { Index: vm_insnhelper.h =================================================================== --- vm_insnhelper.h (revision 67328) +++ vm_insnhelper.h (revision 67329) @@ -239,4 +239,13 @@ THROW_DATA_CONSUMED_SET(struct vm_throw_ https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.h#L239 #define IS_ARGS_SPLAT(ci) ((ci)->flag & VM_CALL_ARGS_SPLAT) #define IS_ARGS_KEYWORD(ci) ((ci)->flag & VM_CALL_KWARG) +/* If this returns true, an optimized function returned by `vm_call_iseq_setup_func` + can be used as a fastpath. */ +static bool +vm_call_iseq_optimizable_p(const struct rb_call_info *ci, const struct rb_call_cache *cc) +{ + return !IS_ARGS_SPLAT(ci) && !IS_ARGS_KEYWORD(ci) && + !(METHOD_ENTRY_VISI(cc->me) == METHOD_VISI_PROTECTED); +} + #endif /* RUBY_INSNHELPER_H */ Index: mjit_compile.c =================================================================== --- mjit_compile.c (revision 67328) +++ mjit_compile.c (revision 67329) @@ -69,8 +69,8 @@ inlinable_iseq_p(CALL_INFO ci, CALL_CACH https://github.com/ruby/ruby/blob/trunk/mjit_compile.c#L69 { extern bool rb_simple_iseq_p(const rb_iseq_t *iseq); return iseq != NULL - && rb_simple_iseq_p(iseq) && !(ci->flag & VM_CALL_KW_SPLAT) /* Top of vm_callee_setup_arg. In this case, opt_pc is 0. */ - && (!IS_ARGS_SPLAT(ci) && !IS_ARGS_KEYWORD(ci) && !(METHOD_ENTRY_VISI(cc->me) == METHOD_VISI_PROTECTED)); /* CC_SET_FASTPATH */ + && !(ci->flag & VM_CALL_KW_SPLAT) && rb_simple_iseq_p(iseq) // Top of vm_callee_setup_arg. In this case, opt_pc is 0. + && vm_call_iseq_optimizable_p(ci, cc); // CC_SET_FASTPATH condition } static int -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/