summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authork0kubun <k0kubun@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-03-06 13:23:22 +0000
committerk0kubun <k0kubun@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-03-06 13:23:22 +0000
commitd2127cb304b5be119e6e5bc6f8f372bf166dc07d (patch)
tree8b5cd07c93633d4deb1650a2f811d655c6ba7aeb
parenteeaa053eae991780107be8b2860d024e490043f4 (diff)
_mjit_compile_pc_and_sp.erb: skip moving pc
on !body->catch_except_p. We need to move pc only when JIT execution is canceled if the frame does not catch an exception. _mjit_compile_insn.erb: lazily move pc for such optimized case _mjit_compile_insn_body.erb: ditto _mjit_compile_send.erb: ditto * Optcarrot benchmark (--jit) Before: 65.31 fps After: 67.82 fps git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62678 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--tool/ruby_vm/views/_mjit_compile_insn.erb3
-rw-r--r--tool/ruby_vm/views/_mjit_compile_insn_body.erb3
-rw-r--r--tool/ruby_vm/views/_mjit_compile_pc_and_sp.erb9
-rw-r--r--tool/ruby_vm/views/_mjit_compile_send.erb3
4 files changed, 15 insertions, 3 deletions
diff --git a/tool/ruby_vm/views/_mjit_compile_insn.erb b/tool/ruby_vm/views/_mjit_compile_insn.erb
index 5627be4ada..b3c663441d 100644
--- a/tool/ruby_vm/views/_mjit_compile_insn.erb
+++ b/tool/ruby_vm/views/_mjit_compile_insn.erb
@@ -74,6 +74,9 @@
% if trace_enablable_insns.include?(insn.name)
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) {
+ fprintf(f, " reg_cfp->pc = original_body_iseq + %d;\n", next_pos);
+ }
fprintf(f, " goto cancel;\n");
fprintf(f, " }\n");
% end
diff --git a/tool/ruby_vm/views/_mjit_compile_insn_body.erb b/tool/ruby_vm/views/_mjit_compile_insn_body.erb
index b209786525..9880689a84 100644
--- a/tool/ruby_vm/views/_mjit_compile_insn_body.erb
+++ b/tool/ruby_vm/views/_mjit_compile_insn_body.erb
@@ -72,6 +72,9 @@
if (status->local_stack_p) {
fprintf(f, " reg_cfp->sp = (VALUE *)reg_cfp->bp + %d;\n", b->stack_size + 1);
}
+ if (!body->catch_except_p) {
+ fprintf(f, " reg_cfp->pc = original_body_iseq + %d;\n", pos);
+ }
fprintf(f, " goto cancel;\n");
% else
% if insn.handles_frame?
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 ae142e9ee8..084a3dd6c8 100644
--- a/tool/ruby_vm/views/_mjit_compile_pc_and_sp.erb
+++ b/tool/ruby_vm/views/_mjit_compile_pc_and_sp.erb
@@ -5,12 +5,15 @@
% # conditions mentioned in the file COPYING are met. Consult the file for
% # details.
%
-% # JIT: move pc so that catch table lookup condition is met
+% # JIT: Move pc so that catch table lookup condition is met. If the ISeq might not catch an exception,
+% # the pc motion is optimized away and thus pc should be set properly before `goto cancel`.
+ if (body->catch_except_p) {
% if insn.handles_frame?
- fprintf(f, " reg_cfp->pc = original_body_iseq + %d;\n", next_pos); /* ADD_PC(INSN_ATTR(width)); */
+ fprintf(f, " reg_cfp->pc = original_body_iseq + %d;\n", next_pos); /* ADD_PC(INSN_ATTR(width)); */
% else
- fprintf(f, " reg_cfp->pc = original_body_iseq + %d;\n", pos);
+ fprintf(f, " reg_cfp->pc = original_body_iseq + %d;\n", pos);
% end
+ }
%
% # JIT: move sp to use or preserve stack variables
if (status->local_stack_p) {
diff --git a/tool/ruby_vm/views/_mjit_compile_send.erb b/tool/ruby_vm/views/_mjit_compile_send.erb
index 6781bba696..5b32ac42db 100644
--- a/tool/ruby_vm/views/_mjit_compile_send.erb
+++ b/tool/ruby_vm/views/_mjit_compile_send.erb
@@ -75,6 +75,9 @@
% # 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) {
+ fprintf(f, " reg_cfp->pc = original_body_iseq + %d;\n", next_pos);
+ }
fprintf(f, " goto cancel;\n");
fprintf(f, " }\n");