ruby-changes:55339
From: k0kubun <ko1@a...>
Date: Sun, 14 Apr 2019 17:33:50 +0900 (JST)
Subject: [ruby-changes:55339] k0kubun:r67547 (trunk): Allow falling back to non-inlined opt_send_without_block
k0kubun 2019-04-14 17:33:43 +0900 (Sun, 14 Apr 2019) New Revision: 67547 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=67547 Log: Allow falling back to non-inlined opt_send_without_block for opt_aref with inline cache to minimize the possibility of JIT cancel. Also opt_aset and opt_mod are added for the targets. Modified files: trunk/tool/ruby_vm/views/mjit_compile.inc.erb Index: tool/ruby_vm/views/mjit_compile.inc.erb =================================================================== --- tool/ruby_vm/views/mjit_compile.inc.erb (revision 67546) +++ tool/ruby_vm/views/mjit_compile.inc.erb (revision 67547) @@ -50,16 +50,22 @@ switch (insn) { https://github.com/ruby/ruby/blob/trunk/tool/ruby_vm/views/mjit_compile.inc.erb#L50 % case insn.name % when 'opt_send_without_block', 'send' <%= render 'mjit_compile_send', locals: { insn: insn } -%> -% when 'opt_aref' # experimental. TODO: increase insns and make the list automatically by finding DISPATCH_ORIGINAL_INSN -<%= render 'mjit_compile_send', locals: { insn: opt_send_without_block } -%> +% when 'opt_aref', 'opt_aset', 'opt_mod' # TODO: automatically find them with CALL_SIMPLE_METHOD +% # To avoid cancel, just emit `opt_send_without_block` instead of `opt_*` insn if call cache is populated. +% cc_index = insn.opes.index { |o| o.fetch(:type) == 'CALL_CACHE' } + if (has_valid_method_type(status->cc_entries + ((CALL_CACHE)operands[<%= cc_index %>] - body->cc_entries))) { +<%= render 'mjit_compile_send', locals: { insn: opt_send_without_block } -%> +<%= render 'mjit_compile_insn', locals: { insn: opt_send_without_block } -%> + break; + } % when 'getinstancevariable', 'setinstancevariable' <%= render 'mjit_compile_ivar', locals: { insn: insn } -%> % when 'leave' - if (b->stack_size != 1) { - if (mjit_opts.warnings || mjit_opts.verbose) - fprintf(stderr, "MJIT warning: Unexpected JIT stack_size on leave: %d\n", b->stack_size); - status->success = false; - } + if (b->stack_size != 1) { + if (mjit_opts.warnings || mjit_opts.verbose) + fprintf(stderr, "MJIT warning: Unexpected JIT stack_size on leave: %d\n", b->stack_size); + status->success = false; + } % end % % # Main insn implementation generated by insns.def -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/