diff options
author | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2021-02-28 14:16:37 +0000 |
---|---|---|
committer | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2021-02-28 14:16:37 +0000 |
commit | 3f4f5fdf0b0ef9df7a8a32a73b4af2c46a2373a5 (patch) | |
tree | d0ddfdb98f59852e7d9a8117dfcbb9e4e2746e5a /test/coverage | |
parent | c64fbfae6f67a70b76fd9048ee9b764577cdef49 (diff) |
merge revision(s) f9e5c74c: [Backport #15980]
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`.
---
compile.c | 232 +++++++++++++++++++++++------------------
test/coverage/test_coverage.rb | 12 +++
2 files changed, 141 insertions(+), 103 deletions(-)
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_6@67898 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/coverage')
-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 30523c341a..1625d48845 100644 --- a/test/coverage/test_coverage.rb +++ b/test/coverage/test_coverage.rb @@ -696,4 +696,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 |