ruby-changes:52608
From: k0kubun <ko1@a...>
Date: Mon, 24 Sep 2018 15:10:01 +0900 (JST)
Subject: [ruby-changes:52608] k0kubun:r64820 (trunk): _mjit_compile_send.erb: refactor code to setup iseq
k0kubun 2018-09-24 15:09:55 +0900 (Mon, 24 Sep 2018) New Revision: 64820 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=64820 Log: _mjit_compile_send.erb: refactor code to setup iseq by sharing vm_call_iseq_setup_normal. This is a retry of r64280. vm_insnhelper.c: Remove unused argument `ci` and pass `me` instead of `cc` to share this with JIT. Declare this with ALWAYS_INLINE to make sure this function is inlined in JIT. tool/mk_call_iseq_optimized.rb: deal with the interface change of vm_call_iseq_setup_normal. Modified files: trunk/tool/mk_call_iseq_optimized.rb trunk/tool/ruby_vm/views/_mjit_compile_send.erb trunk/vm_insnhelper.c Index: tool/mk_call_iseq_optimized.rb =================================================================== --- tool/mk_call_iseq_optimized.rb (revision 64819) +++ tool/mk_call_iseq_optimized.rb (revision 64820) @@ -23,7 +23,7 @@ P.each{|param| https://github.com/ruby/ruby/blob/trunk/tool/mk_call_iseq_optimized.rb#L23 static VALUE #{fname(param, local)}(rb_execution_context_t *ec, rb_control_frame_t *cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc) { - return vm_call_iseq_setup_normal(ec, cfp, calling, ci, cc, 0, #{param}, #{local}); + return vm_call_iseq_setup_normal(ec, cfp, calling, cc->me, 0, #{param}, #{local}); } EOS Index: tool/ruby_vm/views/_mjit_compile_send.erb =================================================================== --- tool/ruby_vm/views/_mjit_compile_send.erb (revision 64819) +++ tool/ruby_vm/views/_mjit_compile_send.erb (revision 64820) @@ -50,11 +50,8 @@ https://github.com/ruby/ruby/blob/trunk/tool/ruby_vm/views/_mjit_compile_send.erb#L50 % # JIT: Special CALL_METHOD. Inline vm_call_iseq_setup_normal for vm_call_iseq_setup_func FASTPATH. TODO: modify VM to share code with here fprintf(f, " {\n"); fprintf(f, " VALUE v;\n"); - fprintf(f, " VALUE *argv = reg_cfp->sp - calling.argc;\n"); - fprintf(f, " reg_cfp->sp = argv - 1;\n"); /* recv */ - fprintf(f, " vm_push_frame(ec, (const rb_iseq_t *)0x%"PRIxVALUE", VM_FRAME_MAGIC_METHOD | VM_ENV_FLAG_LOCAL, calling.recv, " - "calling.block_handler, 0x%"PRIxVALUE", (const VALUE *)0x%"PRIxVALUE", argv + %d, %d, %d);\n", - (VALUE)iseq, (VALUE)cc->me, (VALUE)iseq->body->iseq_encoded, param_size, iseq->body->local_table_size - param_size, iseq->body->stack_max); + fprintf(f, " vm_call_iseq_setup_normal(ec, reg_cfp, &calling, (const rb_callable_method_entry_t *)0x%"PRIxVALUE", 0, %d, %d);\n", + (VALUE)cc->me, param_size, iseq->body->local_table_size); /* rb_simple_iseq_p checks rb_simple_iseq_p, which ensures has_opt == FALSE */ if (iseq->body->catch_except_p) { fprintf(f, " VM_ENV_FLAGS_SET(ec->cfp->ep, VM_FRAME_FLAG_FINISH);\n"); fprintf(f, " v = vm_exec(ec, TRUE);\n"); Index: vm_insnhelper.c =================================================================== --- vm_insnhelper.c (revision 64819) +++ vm_insnhelper.c (revision 64820) @@ -1568,7 +1568,7 @@ vm_base_ptr(const rb_control_frame_t *cf https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L1568 #include "vm_args.c" static inline VALUE vm_call_iseq_setup_2(rb_execution_context_t *ec, rb_control_frame_t *cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc, int opt_pc, int param_size, int local_size); -static inline VALUE vm_call_iseq_setup_normal(rb_execution_context_t *ec, rb_control_frame_t *cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc, int opt_pc, int param_size, int local_size); +ALWAYS_INLINE(static VALUE vm_call_iseq_setup_normal(rb_execution_context_t *ec, rb_control_frame_t *cfp, struct rb_calling_info *calling, const rb_callable_method_entry_t *me, int opt_pc, int param_size, int local_size)); static inline VALUE vm_call_iseq_setup_tailcall(rb_execution_context_t *ec, rb_control_frame_t *cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc, int opt_pc); static VALUE vm_call_super_method(rb_execution_context_t *ec, rb_control_frame_t *reg_cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc); static VALUE vm_call_method_nome(rb_execution_context_t *ec, rb_control_frame_t *cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc); @@ -1598,7 +1598,7 @@ vm_call_iseq_setup_normal_0start(rb_exec https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L1598 const rb_iseq_t *iseq = def_iseq_ptr(cc->me->def); int param = iseq->body->param.size; int local = iseq->body->local_table_size; - return vm_call_iseq_setup_normal(ec, cfp, calling, ci, cc, 0, param, local); + return vm_call_iseq_setup_normal(ec, cfp, calling, cc->me, 0, param, local); } int @@ -1650,7 +1650,7 @@ vm_call_iseq_setup_2(rb_execution_contex https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L1650 int opt_pc, int param_size, int local_size) { if (LIKELY(!(ci->flag & VM_CALL_TAILCALL))) { - return vm_call_iseq_setup_normal(ec, cfp, calling, ci, cc, opt_pc, param_size, local_size); + return vm_call_iseq_setup_normal(ec, cfp, calling, cc->me, opt_pc, param_size, local_size); } else { return vm_call_iseq_setup_tailcall(ec, cfp, calling, ci, cc, opt_pc); @@ -1658,10 +1658,9 @@ vm_call_iseq_setup_2(rb_execution_contex https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L1658 } static inline VALUE -vm_call_iseq_setup_normal(rb_execution_context_t *ec, rb_control_frame_t *cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc, +vm_call_iseq_setup_normal(rb_execution_context_t *ec, rb_control_frame_t *cfp, struct rb_calling_info *calling, const rb_callable_method_entry_t *me, int opt_pc, int param_size, int local_size) { - const rb_callable_method_entry_t *me = cc->me; const rb_iseq_t *iseq = def_iseq_ptr(me->def); VALUE *argv = cfp->sp - calling->argc; VALUE *sp = argv + param_size; -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/