compile.c: stop the jump-jump optimization if the second has any event

Fixes [Bug #17868]
This commit is contained in:
Yusuke Endoh 2021-05-20 19:13:39 +09:00
Родитель 821e3c128f
Коммит 5026f9a5d5
2 изменённых файлов: 17 добавлений и 1 удалений

Просмотреть файл

@ -2926,7 +2926,8 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal
}
else if (iobj != diobj && IS_INSN(&diobj->link) &&
IS_INSN_ID(diobj, jump) &&
OPERAND_AT(iobj, 0) != OPERAND_AT(diobj, 0)) {
OPERAND_AT(iobj, 0) != OPERAND_AT(diobj, 0) &&
diobj->insn_info.events == 0) {
/*
* useless jump elimination:
* jump LABEL1

Просмотреть файл

@ -2386,4 +2386,19 @@ class TestSetTraceFunc < Test::Unit::TestCase
EOS
assert_equal [:return, :unpack], event
end
def test_while_in_while
lines = []
TracePoint.new(:line){|tp|
next unless target_thread?
lines << tp.lineno
}.enable{
n = 3
while n > 0
n -= 1 while n > 0
end
}
assert_equal [__LINE__ - 5, __LINE__ - 4, __LINE__ - 3], lines, 'Bug #17868'
end
end