diff options
author | Yusuke Endoh <mame@ruby-lang.org> | 2019-12-04 10:33:35 +0900 |
---|---|---|
committer | Yusuke Endoh <mame@ruby-lang.org> | 2019-12-04 10:40:54 +0900 |
commit | f9e5c74cd24025a5aa19e318e8fecabf207f1b7b (patch) | |
tree | ec8826ff9768c25b0e3a88761aec5fdc83b272ec /test/coverage/test_coverage.rb | |
parent | 5a404efd29d255402e30f4f23a09d4e5398600b8 (diff) | |
download | ruby-f9e5c74cd24025a5aa19e318e8fecabf207f1b7b.tar.gz |
compile.c: stop wrong peephole optimization when covearge is enabled
jump-jump optimization ignores the event flags of the jump instruction
being skipped, which leads to overlook of line events.
This changeset stops the wrong optimization when coverage measurement is
neabled and when the jump instruction has any event flag.
Note that this issue is not only for coverage but also for TracePoint,
and this change does not fix TracePoint.
However, fixing it fundamentally is tough (which requires revamp of
the compiler). This issue is critical in terms of coverage measurement,
but minor for TracePoint (ko1 said), so we here choose a stopgap
measurement.
[Bug #15980] [Bug #16397]
Note for backporters: this changeset can be viewed by `git diff -w`.
Diffstat (limited to 'test/coverage/test_coverage.rb')
-rw-r--r-- | test/coverage/test_coverage.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/test/coverage/test_coverage.rb b/test/coverage/test_coverage.rb index f88e97e9d6..1de39bf569 100644 --- a/test/coverage/test_coverage.rb +++ b/test/coverage/test_coverage.rb @@ -728,4 +728,16 @@ class TestCoverage < Test::Unit::TestCase } } end + + def test_stop_wrong_peephole_optimization + result = { + :lines => [1, 1, 1, nil] + } + assert_coverage(<<~"end;", { lines: true }, result) + raise if 1 == 2 + while true + break + end + end; + end end |