mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Avoid jumping to a wrong destination
when the next insn is already compiled by former branches.
This commit is contained in:
parent
f0b815dc67
commit
c4794ed73a
2 changed files with 17 additions and 2 deletions
|
@ -828,6 +828,16 @@ class TestJIT < Test::Unit::TestCase
|
||||||
end;
|
end;
|
||||||
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
|
def test_clean_so
|
||||||
if RUBY_PLATFORM.match?(/mswin/)
|
if RUBY_PLATFORM.match?(/mswin/)
|
||||||
skip 'Removing so file is randomly failing on AppVeyor/RubyCI mswin due to Permission Denied.'
|
skip 'Removing so file is randomly failing on AppVeyor/RubyCI mswin due to Permission Denied.'
|
||||||
|
|
|
@ -76,9 +76,14 @@
|
||||||
}
|
}
|
||||||
fprintf(f, "}\n");
|
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\([^)]+\);[^{}]+\}/
|
% 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
|
% end
|
||||||
%
|
%
|
||||||
% # compiler: If insn returns (leave) or does longjmp (throw), the branch should no longer be compiled. TODO: create attr for it?
|
% # compiler: If insn returns (leave) or does longjmp (throw), the branch should no longer be compiled. TODO: create attr for it?
|
||||||
|
|
Loading…
Reference in a new issue