Commit 99f6de52 authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto Committed by GitHub

Merge pull request #3290 from bouk/unsafe-peep

Fix unsafe peephole optimization
parents a630c4f4 964427f8
...@@ -1798,8 +1798,10 @@ codegen(codegen_scope *s, node *tree, int val) ...@@ -1798,8 +1798,10 @@ codegen(codegen_scope *s, node *tree, int val)
int pos; int pos;
pop(); pop();
if (val && vsp >= 0) { if (val) {
if (vsp >= 0) {
genop(s, MKOP_AB(OP_MOVE, vsp, cursp())); genop(s, MKOP_AB(OP_MOVE, vsp, cursp()));
}
pos = genop(s, MKOP_AsBx(name[0]=='|'?OP_JMPIF:OP_JMPNOT, cursp(), 0)); pos = genop(s, MKOP_AsBx(name[0]=='|'?OP_JMPIF:OP_JMPNOT, cursp(), 0));
} }
else { else {
......
##
# Codegen tests
assert('peephole optimization does not eliminate move whose result is reused') do
assert_raise LocalJumpError do
def method
yield
end
method(&a &&= 0)
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment