summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2020-03-07 09:57:02 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2020-03-07 09:57:02 +0000
commit4ccfb9d123338bdf2f89d1f37025da27c312b3c3 (patch)
tree483b2a56bd8a46d679577c43232fb117f9810d1f
parent773b45bcc86861c30db135a2c558444ca7193761 (diff)
merge revision(s) c4794ed73ad348a61a7cfbe3da0a7eb49ba46eb9: [Backport #16641]
Avoid jumping to a wrong destination when the next insn is already compiled by former branches. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_6@67840 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--test/ruby/test_jit.rb10
-rw-r--r--tool/ruby_vm/views/_mjit_compile_insn.erb9
-rw-r--r--version.h2
3 files changed, 18 insertions, 3 deletions
diff --git a/test/ruby/test_jit.rb b/test/ruby/test_jit.rb
index 7fe58ea336..ca74c2a212 100644
--- a/test/ruby/test_jit.rb
+++ b/test/ruby/test_jit.rb
@@ -763,6 +763,16 @@ class TestJIT < Test::Unit::TestCase
end;
end
+ def test_jump_to_precompiled_branch
+ assert_eval_with_jit("#{<<~'begin;'}\n#{<<~'end;'}", stdout: ".0", success_count: 1, min_calls: 1)
+ begin;
+ def test(foo)
+ ".#{foo unless foo == 1}" if true
+ end
+ print test(0)
+ end;
+ end
+
def test_clean_so
if appveyor_mswin?
skip 'Removing so file is failing on AppVeyor mswin due to Permission Denied.'
diff --git a/tool/ruby_vm/views/_mjit_compile_insn.erb b/tool/ruby_vm/views/_mjit_compile_insn.erb
index a52c928abf..d1b06bb398 100644
--- a/tool/ruby_vm/views/_mjit_compile_insn.erb
+++ b/tool/ruby_vm/views/_mjit_compile_insn.erb
@@ -75,9 +75,14 @@
}
fprintf(f, "}\n");
%
-% # compiler: If insn has conditional JUMP, the branch which is not targeted by JUMP should be compiled too.
+% # compiler: If insn has conditional JUMP, the code should go to the branch not targeted by JUMP next.
% if insn.expr.expr =~ /if\s+\([^{}]+\)\s+\{[^{}]+JUMP\([^)]+\);[^{}]+\}/
- compile_insns(f, body, b->stack_size, pos + insn_len(insn), status);
+ if (ALREADY_COMPILED_P(status, pos + insn_len(insn))) {
+ fprintf(f, "goto label_%d;\n", pos + insn_len(insn));
+ }
+ else {
+ compile_insns(f, body, b->stack_size, pos + insn_len(insn), status);
+ }
% end
%
% # compiler: If insn returns (leave) or does longjmp (throw), the branch should no longer be compiled. TODO: create attr for it?
diff --git a/version.h b/version.h
index c37b9e33d5..52ec4e488e 100644
--- a/version.h
+++ b/version.h
@@ -1,6 +1,6 @@
#define RUBY_VERSION "2.6.6"
#define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR
-#define RUBY_PATCHLEVEL 127
+#define RUBY_PATCHLEVEL 128
#define RUBY_RELEASE_YEAR 2020
#define RUBY_RELEASE_MONTH 3