ruby-changes:47712
From: nobu <ko1@a...>
Date: Mon, 11 Sep 2017 01:19:47 +0900 (JST)
Subject: [ruby-changes:47712] nobu:r59828 (trunk): compile.c: pop coverage trace
nobu 2017-09-11 01:19:40 +0900 (Mon, 11 Sep 2017) New Revision: 59828 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=59828 Log: compile.c: pop coverage trace * compile.c (iseq_compile_each0): pop trace for coverage only and clear its corresponding line. [ruby-core:82726] [Bug #13886] Modified files: trunk/compile.c trunk/test/coverage/test_coverage.rb Index: test/coverage/test_coverage.rb =================================================================== --- test/coverage/test_coverage.rb (revision 59827) +++ test/coverage/test_coverage.rb (revision 59828) @@ -165,4 +165,14 @@ class TestCoverage < Test::Unit::TestCas https://github.com/ruby/ruby/blob/trunk/test/coverage/test_coverage.rb#L165 } } end + + def test_nocoverage_optimized_line + assert_ruby_status(%w[], "#{<<-"begin;"}\n#{<<-'end;'}") + begin; + def foo(x) + x # optimized away + nil + end + end; + end end Index: compile.c =================================================================== --- compile.c (revision 59827) +++ compile.c (revision 59828) @@ -6594,7 +6594,8 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK https://github.com/ruby/ruby/blob/trunk/compile.c#L6594 ((INSN *)saved_last_element)->insn_id == BIN(trace)) { POP_ELEMENT(ret); /* remove trace(coverage) */ - if (((INSN *)ret->last)->insn_id == BIN(trace)) { + if (IS_INSN_ID(ret->last, trace) && + (FIX2LONG(OPERAND_AT(ret->last, 0)) & RUBY_EVENT_COVERAGE)) { POP_ELEMENT(ret); RARRAY_ASET(ISEQ_LINE_COVERAGE(iseq), line - 1, Qnil); } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/