summaryrefslogtreecommitdiff
path: root/tool
diff options
context:
space:
mode:
Diffstat (limited to 'tool')
-rwxr-xr-xtool/ruby_vm/models/bare_instructions.rb4
-rw-r--r--tool/ruby_vm/views/_leaf_helpers.erb4
-rw-r--r--tool/ruby_vm/views/_mjit_compile_insn_body.erb13
-rw-r--r--tool/ruby_vm/views/_mjit_compile_pc_and_sp.erb5
4 files changed, 22 insertions, 4 deletions
diff --git a/tool/ruby_vm/models/bare_instructions.rb b/tool/ruby_vm/models/bare_instructions.rb
index b0cc83a65a..6b5f1f6cf8 100755
--- a/tool/ruby_vm/models/bare_instructions.rb
+++ b/tool/ruby_vm/models/bare_instructions.rb
@@ -112,6 +112,10 @@ class RubyVM::BareInstructions
@attrs.fetch('leaf').expr.expr == 'true;'
end
+ def leaf_without_check_ints?
+ @attrs.fetch('leaf').expr.expr == 'leafness_of_check_ints;'
+ end
+
def handle_canary stmt
# Stack canary is basically a good thing that we want to add, however:
#
diff --git a/tool/ruby_vm/views/_leaf_helpers.erb b/tool/ruby_vm/views/_leaf_helpers.erb
index 2637f8777d..cbb7373e1c 100644
--- a/tool/ruby_vm/views/_leaf_helpers.erb
+++ b/tool/ruby_vm/views/_leaf_helpers.erb
@@ -10,6 +10,10 @@
#include "iseq.h"
+// This is used to tell MJIT that this insn would be leaf if CHECK_INTS didn't exist.
+// It should be used only when RUBY_VM_CHECK_INTS is directly written in insns.def.
+static bool leafness_of_check_ints = false;
+
static bool
leafness_of_defined(rb_num_t op_type)
{
diff --git a/tool/ruby_vm/views/_mjit_compile_insn_body.erb b/tool/ruby_vm/views/_mjit_compile_insn_body.erb
index bc77b02b71..900480ddc0 100644
--- a/tool/ruby_vm/views/_mjit_compile_insn_body.erb
+++ b/tool/ruby_vm/views/_mjit_compile_insn_body.erb
@@ -20,14 +20,14 @@
% # For `leave`. We can't proceed next ISeq in the same JIT function.
% expr.gsub!(/^(?<indent>\s*)RESTORE_REGS\(\);\n/) do
% indent = Regexp.last_match[:indent]
-% <<-RESTORE_REGS.gsub(/^ +/, '')
+% <<-end.gsub(/^ +/, '')
% #if OPT_CALL_THREADED_CODE
% #{indent}rb_ec_thread_ptr(ec)->retval = val;
% #{indent}return 0;
% #else
% #{indent}return val;
% #endif
-% RESTORE_REGS
+% end
% end
% expr.gsub!(/^(?<indent>\s*)NEXT_INSN\(\);\n/) do
% indent = Regexp.last_match[:indent]
@@ -47,6 +47,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
+ 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, " }\n");
+% else
+ fprintf(f, <%= to_cstr.call(line) %>);
+% end
% when /\A\s+JUMP\((?<dest>[^)]+)\);\s+\z/
% dest = Regexp.last_match[:dest]
%
diff --git a/tool/ruby_vm/views/_mjit_compile_pc_and_sp.erb b/tool/ruby_vm/views/_mjit_compile_pc_and_sp.erb
index f6d611693d..390b3ce525 100644
--- a/tool/ruby_vm/views/_mjit_compile_pc_and_sp.erb
+++ b/tool/ruby_vm/views/_mjit_compile_pc_and_sp.erb
@@ -5,9 +5,10 @@
% # conditions mentioned in the file COPYING are met. Consult the file for
% # details.
%
-% # JIT: Move pc for catch table on catch_except_p, and for #caller_locations and rb_profile_frames on !insn.always_leaf?
+% # JIT: When an insn is leaf, we don't need to Move pc for a catch table on catch_except_p, #caller_locations,
+% # and rb_profile_frames. For check_ints, we lazily move PC when we have interruptions.
MAYBE_UNUSED(bool pc_moved_p) = false;
- if (<%= insn.always_leaf? ? 'false' : 'true' %>) {
+ if (<%= !(insn.always_leaf? || insn.leaf_without_check_ints?) %>) {
fprintf(f, " reg_cfp->pc = original_body_iseq + %d;\n", next_pos); /* ADD_PC(INSN_ATTR(width)); */
pc_moved_p = true;
}