From 7d0144e055fdbd7110cf84275b9e145550b77fd3 Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Sat, 19 Dec 2020 21:35:59 -0800 Subject: Check mjit_call_p only when interrupted for leaf_without_check_ints insns. $ benchmark-driver -v --rbenv 'before --jit;after --jit' --repeat-count=12 --alternate --output=all benchmark.yml before --jit: ruby 3.0.0dev (2020-12-20T05:02:18Z master 02b3555874) +JIT [x86_64-linux] after --jit: ruby 3.0.0dev (2020-12-20T05:36:00Z master 3f58de4eab) +JIT [x86_64-linux] last_commit=Check mjit_call_p only when interrupted Calculating ------------------------------------- before --jit after --jit Optcarrot Lan_Master.nes 84.50647332260259 85.85057800433144 fps 91.17796644338372 92.09930605656054 91.29346683444497 93.01336611323687 91.50322318568884 93.07234029037433 91.66560903214686 93.22773241529644 91.82315142636172 93.37032901061119 92.15066379608260 93.83701526141679 92.37897097456643 93.86032792681507 92.53049815524908 93.91211970920320 92.78414507914283 94.09109196967890 92.90299756525958 94.40107239595325 93.70279428858790 95.01326369371263 --- tool/ruby_vm/views/_mjit_compile_insn.erb | 3 ++- tool/ruby_vm/views/_mjit_compile_insn_body.erb | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'tool') diff --git a/tool/ruby_vm/views/_mjit_compile_insn.erb b/tool/ruby_vm/views/_mjit_compile_insn.erb index e688f0853e..f54d1b0e0e 100644 --- a/tool/ruby_vm/views/_mjit_compile_insn.erb +++ b/tool/ruby_vm/views/_mjit_compile_insn.erb @@ -59,7 +59,8 @@ % end % % # JIT: We should evaluate ISeq modified for TracePoint if it's enabled. Note: This is slow. -% unless insn.always_leaf? +% # leaf insn may not cancel JIT. leaf_without_check_ints is covered in RUBY_VM_CHECK_INTS of _mjit_compile_insn_body.erb. +% unless insn.always_leaf? || insn.leaf_without_check_ints? fprintf(f, " if (UNLIKELY(!mjit_call_p)) {\n"); fprintf(f, " reg_cfp->sp = vm_base_ptr(reg_cfp) + %d;\n", b->stack_size + (int)<%= insn.call_attribute('sp_inc') %>); if (!pc_moved_p) { diff --git a/tool/ruby_vm/views/_mjit_compile_insn_body.erb b/tool/ruby_vm/views/_mjit_compile_insn_body.erb index 900480ddc0..187e043837 100644 --- a/tool/ruby_vm/views/_mjit_compile_insn_body.erb +++ b/tool/ruby_vm/views/_mjit_compile_insn_body.erb @@ -48,10 +48,15 @@ % # TODO: support combination of following macros in the same line % case line % when /\A\s+RUBY_VM_CHECK_INTS\(ec\);\s+\z/ -% if insn.leaf_without_check_ints? # lazily move PC here +% if insn.leaf_without_check_ints? # lazily move PC and optionalize mjit_call_p here fprintf(f, " if (UNLIKELY(RUBY_VM_INTERRUPTED_ANY(ec))) {\n"); fprintf(f, " reg_cfp->pc = original_body_iseq + %d;\n", next_pos); /* ADD_PC(INSN_ATTR(width)); */ fprintf(f, " rb_threadptr_execute_interrupts(rb_ec_thread_ptr(ec), 0);\n"); + fprintf(f, " if (UNLIKELY(!mjit_call_p)) {\n"); + fprintf(f, " reg_cfp->sp = vm_base_ptr(reg_cfp) + %d;\n", b->stack_size); + fprintf(f, " RB_DEBUG_COUNTER_INC(mjit_cancel_invalidate_all);\n"); + fprintf(f, " goto cancel;\n"); + fprintf(f, " }\n"); fprintf(f, " }\n"); % else fprintf(f, <%= to_cstr.call(line) %>); -- cgit v1.2.3