ruby-changes:52478
From: k0kubun <ko1@a...>
Date: Wed, 12 Sep 2018 00:15:00 +0900 (JST)
Subject: [ruby-changes:52478] k0kubun:r64687 (trunk): _mjit_compile_insn.erb: move pc on JIT cancel
k0kubun 2018-09-12 00:14:56 +0900 (Wed, 12 Sep 2018) New Revision: 64687 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=64687 Log: _mjit_compile_insn.erb: move pc on JIT cancel if and only if it's not moved yet, to avoid potential bugs in the future. _mjit_compile_send.erb: ditto Modified files: trunk/tool/ruby_vm/views/_mjit_compile_insn.erb trunk/tool/ruby_vm/views/_mjit_compile_pc_and_sp.erb trunk/tool/ruby_vm/views/_mjit_compile_send.erb Index: tool/ruby_vm/views/_mjit_compile_pc_and_sp.erb =================================================================== --- tool/ruby_vm/views/_mjit_compile_pc_and_sp.erb (revision 64686) +++ tool/ruby_vm/views/_mjit_compile_pc_and_sp.erb (revision 64687) @@ -8,6 +8,7 @@ https://github.com/ruby/ruby/blob/trunk/tool/ruby_vm/views/_mjit_compile_pc_and_sp.erb#L8 % # JIT: Move pc for catch table on catch_except_p, and for #caller_locations and rb_profile_frames on !insn.always_leaf? if (body->catch_except_p || <%= insn.always_leaf? ? 'FALSE' : 'TRUE' %>) { fprintf(f, " reg_cfp->pc = original_body_iseq + %d;\n", next_pos); /* ADD_PC(INSN_ATTR(width)); */ + pc_moved_p = TRUE; } % % # JIT: move sp to use or preserve stack variables Index: tool/ruby_vm/views/_mjit_compile_send.erb =================================================================== --- tool/ruby_vm/views/_mjit_compile_send.erb (revision 64686) +++ tool/ruby_vm/views/_mjit_compile_send.erb (revision 64687) @@ -8,6 +8,7 @@ https://github.com/ruby/ruby/blob/trunk/tool/ruby_vm/views/_mjit_compile_send.erb#L8 % % # Optimized case of send / opt_send_without_block instructions. { + MAYBE_UNUSED(int pc_moved_p) = FALSE; % # compiler: Prepare operands which may be used by `insn.call_attribute` % insn.opes.each_with_index do |ope, i| MAYBE_UNUSED(<%= ope.fetch(:decl) %>) = (<%= ope.fetch(:type) %>)operands[<%= i %>]; @@ -72,7 +73,7 @@ https://github.com/ruby/ruby/blob/trunk/tool/ruby_vm/views/_mjit_compile_send.erb#L73 % # JIT: We should evaluate ISeq modified for TracePoint if it's enabled. Note: This is slow. fprintf(f, " if (UNLIKELY(ruby_vm_event_enabled_flags & ISEQ_TRACE_EVENTS)) {\n"); fprintf(f, " reg_cfp->sp = (VALUE *)reg_cfp->bp + %d;\n", b->stack_size + (int)<%= insn.call_attribute('sp_inc') %> + 1); - if (!body->catch_except_p) { + if (!pc_moved_p) { fprintf(f, " reg_cfp->pc = original_body_iseq + %d;\n", next_pos); } fprintf(f, " goto cancel;\n"); Index: tool/ruby_vm/views/_mjit_compile_insn.erb =================================================================== --- tool/ruby_vm/views/_mjit_compile_insn.erb (revision 64686) +++ tool/ruby_vm/views/_mjit_compile_insn.erb (revision 64687) @@ -7,6 +7,7 @@ https://github.com/ruby/ruby/blob/trunk/tool/ruby_vm/views/_mjit_compile_insn.erb#L7 % # details. fprintf(f, "{\n"); { + MAYBE_UNUSED(int pc_moved_p) = FALSE; % # compiler: Prepare operands which may be used by `insn.call_attribute` % insn.opes.each_with_index do |ope, i| MAYBE_UNUSED(<%= ope.fetch(:decl) %>) = (<%= ope.fetch(:type) %>)operands[<%= i %>]; @@ -62,7 +63,7 @@ https://github.com/ruby/ruby/blob/trunk/tool/ruby_vm/views/_mjit_compile_insn.erb#L63 % unless insn.always_leaf? fprintf(f, " if (UNLIKELY(ruby_vm_event_enabled_flags & ISEQ_TRACE_EVENTS)) {\n"); fprintf(f, " reg_cfp->sp = (VALUE *)reg_cfp->bp + %d;\n", b->stack_size + (int)<%= insn.call_attribute('sp_inc') %> + 1); - if (!body->catch_except_p) { + if (!pc_moved_p) { fprintf(f, " reg_cfp->pc = original_body_iseq + %d;\n", next_pos); } fprintf(f, " goto cancel;\n"); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/