ruby-changes:54457
From: mame <ko1@a...>
Date: Tue, 1 Jan 2019 10:47:17 +0900 (JST)
Subject: [ruby-changes:54457] mame:r66672 (trunk): Revert r66670 because of wrong ticket number
mame 2019-01-01 10:47:14 +0900 (Tue, 01 Jan 2019) New Revision: 66672 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=66672 Log: Revert r66670 because of wrong ticket number Modified files: trunk/compile.c trunk/test/coverage/test_coverage.rb Index: test/coverage/test_coverage.rb =================================================================== --- test/coverage/test_coverage.rb (revision 66671) +++ test/coverage/test_coverage.rb (revision 66672) @@ -348,22 +348,15 @@ class TestCoverage < Test::Unit::TestCas https://github.com/ruby/ruby/blob/trunk/test/coverage/test_coverage.rb#L348 def test_branch_coverage_for_safe_method_invocation result = { :branches=>{ - [:"&.", 0, 6, 0, 6, 6] => {[:then, 1, 6, 0, 6, 6]=>1, [:else, 2, 6, 0, 6, 6]=>0}, - [:"&.", 3, 7, 0, 7, 6] => {[:then, 4, 7, 0, 7, 6]=>0, [:else, 5, 7, 0, 7, 6]=>1}, - [:"&.", 6, 8, 0, 8, 10] => {[:then, 7, 8, 0, 8, 10]=>1, [:else, 8, 8, 0, 8, 10]=>0}, - [:"&.", 9, 9, 0, 9, 10] => {[:then, 10, 9, 0, 9, 10]=>0, [:else, 11, 9, 0, 9, 10]=>1}, + [:"&.", 0, 3, 0, 3, 6] => {[:then, 1, 3, 0, 3, 6]=>1, [:else, 2, 3, 0, 3, 6]=>0}, + [:"&.", 3, 4, 0, 4, 6] => {[:then, 4, 4, 0, 4, 6]=>0, [:else, 5, 4, 0, 4, 6]=>1}, } } assert_coverage(<<~"end;", { branches: true }, result) - class Dummy; def foo; end; def foo=(x); end; end - a = Dummy.new + a = 10 b = nil - c = Dummy.new - d = nil - a&.foo - b&.foo - c&.foo = 1 - d&.foo = 1 + a&.abs + b&.hoo end; end Index: compile.c =================================================================== --- compile.c (revision 66671) +++ compile.c (revision 66672) @@ -7462,10 +7462,8 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK https://github.com/ruby/ruby/blob/trunk/compile.c#L7462 DECL_ANCHOR(args); unsigned int flag = 0; ID mid = node->nd_mid; - LABEL *else_label = 0; - LABEL *end_label = 0; + LABEL *lskip = 0; VALUE argc; - VALUE branches = 0; /* optimization shortcut * obj["literal"] = value -> opt_aset_with(obj, "literal", value) @@ -7505,11 +7503,8 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK https://github.com/ruby/ruby/blob/trunk/compile.c#L7503 /* safe nav attr */ mid = rb_id_attrset(mid); ADD_INSN(recv, line, dup); - else_label = NEW_LABEL(line); - end_label = NEW_LABEL(line); - DECL_BRANCH_BASE(branches, nd_first_lineno(node), nd_first_column(node), nd_last_lineno(node), nd_last_column(node), "&."); - ADD_INSNL(recv, line, branchnil, else_label); - ADD_TRACE_BRANCH_COVERAGE(recv, nd_first_lineno(node), nd_first_column(node), nd_last_lineno(node), nd_last_column(node), "then", branches); + lskip = NEW_LABEL(line); + ADD_INSNL(recv, line, branchnil, lskip); } if (!popped) { ADD_INSN(ret, line, putnil); @@ -7541,12 +7536,7 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK https://github.com/ruby/ruby/blob/trunk/compile.c#L7536 ADD_SEQ(ret, args); } ADD_SEND_WITH_FLAG(ret, line, mid, argc, INT2FIX(flag)); - if (else_label && end_label) { - ADD_INSNL(ret, line, jump, end_label); - ADD_LABEL(ret, else_label); - ADD_TRACE_BRANCH_COVERAGE(ret, nd_first_lineno(node), nd_first_column(node), nd_last_lineno(node), nd_last_column(node), "else", branches); - ADD_LABEL(ret, end_label); - } + if (lskip) ADD_LABEL(ret, lskip); ADD_INSN(ret, line, pop); break; -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/