From 9d85ed6cbb50960d08bdb24c303a8f5e06b7e922 Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Mon, 14 Dec 2020 21:06:53 -0800 Subject: Simplify positioning of '{' and '}' and fix inconsistent indentation in mjit_compile.inc.erb --- tool/ruby_vm/views/mjit_compile.inc.erb | 57 ++++++++++++++++----------------- 1 file changed, 27 insertions(+), 30 deletions(-) (limited to 'tool') diff --git a/tool/ruby_vm/views/mjit_compile.inc.erb b/tool/ruby_vm/views/mjit_compile.inc.erb index 32fd65ad6c..a7068c8532 100644 --- a/tool/ruby_vm/views/mjit_compile.inc.erb +++ b/tool/ruby_vm/views/mjit_compile.inc.erb @@ -48,7 +48,7 @@ switch (insn) { % (RubyVM::BareInstructions.to_a + RubyVM::OperandsUnifications.to_a).each do |insn| % next if unsupported_insns.include?(insn.name) - case BIN(<%= insn.name %>): + case BIN(<%= insn.name %>): { % # Instruction-specific behavior in JIT % case insn.name % when 'opt_send_without_block', 'send' @@ -56,50 +56,47 @@ switch (insn) { % when *send_compatible_opt_insns % # To avoid cancel, just emit `opt_send_without_block` instead of `opt_*` insn if call cache is populated. % cd_index = insn.opes.index { |o| o.fetch(:type) == 'CALL_DATA' } - if (has_cache_for_send(captured_cc_entries(status)[call_data_index((CALL_DATA)operands[<%= cd_index %>], body)], BIN(<%= insn.name %>))) { -<%= render 'mjit_compile_send', locals: { insn: opt_send_without_block } -%> -<%= render 'mjit_compile_insn', locals: { insn: opt_send_without_block } -%> - break; - } + if (has_cache_for_send(captured_cc_entries(status)[call_data_index((CALL_DATA)operands[<%= cd_index %>], body)], BIN(<%= insn.name %>))) { +<%= 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 'invokebuiltin', 'opt_invokebuiltin_delegate' - { <%= render 'mjit_compile_invokebuiltin', locals: { insn: insn } -%> - } % when 'leave', 'opt_invokebuiltin_delegate_leave' - { % # opt_invokebuiltin_delegate_leave also implements leave insn. We need to handle it here for inlining. % if insn.name == 'opt_invokebuiltin_delegate_leave' -<%= render 'mjit_compile_invokebuiltin', locals: { insn: insn } -%> +<%= render 'mjit_compile_invokebuiltin', locals: { insn: insn } -%> % else - 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 -% # Skip vm_pop_frame for inlined call - if (status->inlined_iseqs != NULL) { // the current ISeq is NOT being inlined -% # Cancel on interrupts to make leave insn leaf - fprintf(f, " if (UNLIKELY(RUBY_VM_INTERRUPTED_ANY(ec))) {\n"); - fprintf(f, " reg_cfp->sp = vm_base_ptr(reg_cfp) + %d;\n", b->stack_size); - fprintf(f, " reg_cfp->pc = original_body_iseq + %d;\n", pos); - fprintf(f, " RB_DEBUG_COUNTER_INC(mjit_cancel_leave);\n"); - fprintf(f, " goto cancel;\n"); - fprintf(f, " }\n"); - fprintf(f, " ec->cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(reg_cfp);\n"); // vm_pop_frame - } - fprintf(f, " return stack[0];\n"); - b->stack_size += <%= insn.call_attribute('sp_inc') %>; - b->finish_p = TRUE; - break; +% # Skip vm_pop_frame for inlined call + if (status->inlined_iseqs != NULL) { // the current ISeq is NOT being inlined +% # Cancel on interrupts to make leave insn leaf + fprintf(f, " if (UNLIKELY(RUBY_VM_INTERRUPTED_ANY(ec))) {\n"); + fprintf(f, " reg_cfp->sp = vm_base_ptr(reg_cfp) + %d;\n", b->stack_size); + fprintf(f, " reg_cfp->pc = original_body_iseq + %d;\n", pos); + fprintf(f, " RB_DEBUG_COUNTER_INC(mjit_cancel_leave);\n"); + fprintf(f, " goto cancel;\n"); + fprintf(f, " }\n"); + fprintf(f, " ec->cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(reg_cfp);\n"); // vm_pop_frame } + fprintf(f, " return stack[0];\n"); + b->stack_size += <%= insn.call_attribute('sp_inc') %>; + b->finish_p = TRUE; + break; % end % % # Main insn implementation generated by insns.def <%= render 'mjit_compile_insn', locals: { insn: insn } -%> break; + } % end % % # We don't support InstructionsUnifications yet because it's not used for now. -- cgit v1.2.3