summaryrefslogtreecommitdiff
path: root/tool
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 /tool
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
Diffstat (limited to 'tool')
-rw-r--r--tool/ruby_vm/views/_mjit_compile_insn.erb9
1 files changed, 7 insertions, 2 deletions
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?