OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/v8.h" | 5 #include "src/v8.h" |
6 #include "test/cctest/cctest.h" | 6 #include "test/cctest/cctest.h" |
7 | 7 |
8 #include "src/base/bits.h" | 8 #include "src/base/bits.h" |
9 #include "src/compiler/all-nodes.h" | 9 #include "src/compiler/all-nodes.h" |
10 #include "src/compiler/common-operator.h" | 10 #include "src/compiler/common-operator.h" |
(...skipping 1243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1254 Node* if_true = R.graph.NewNode(R.common.IfTrue(), branch); | 1254 Node* if_true = R.graph.NewNode(R.common.IfTrue(), branch); |
1255 Node* if_false = R.graph.NewNode(R.common.IfFalse(), branch); | 1255 Node* if_false = R.graph.NewNode(R.common.IfFalse(), branch); |
1256 Node* merge = R.graph.NewNode(R.common.Merge(2), if_false, if_true); | 1256 Node* merge = R.graph.NewNode(R.common.Merge(2), if_false, if_true); |
1257 R.ReduceMergeIterative(R.start, merge); | 1257 R.ReduceMergeIterative(R.start, merge); |
1258 } | 1258 } |
1259 | 1259 |
1260 | 1260 |
1261 TEST(CDeadLoop1) { | 1261 TEST(CDeadLoop1) { |
1262 ControlReducerTester R; | 1262 ControlReducerTester R; |
1263 | 1263 |
1264 Node* loop = R.graph.NewNode(R.common.Loop(1), R.start); | |
1265 Branch b(R, R.p0, loop); | |
1266 loop->ReplaceInput(0, b.if_true); // loop is not connected to start. | |
1267 Node* merge = R.graph.NewNode(R.common.Merge(2), R.start, b.if_false); | |
1268 R.ReduceMergeIterative(R.start, merge); | |
1269 | |
1270 DeadChecker dead(&R.graph); | |
1271 dead.Check(b.if_true); | |
1272 dead.Check(b.if_false); | |
1273 dead.Check(b.branch); | |
1274 dead.Check(loop); | |
1275 } | |
1276 | |
1277 | |
1278 TEST(CDeadLoop2) { | |
1279 ControlReducerTester R; | |
1280 | |
1281 While w(R, R.p0); | 1264 While w(R, R.p0); |
1282 Diamond d(R, R.zero); | 1265 Diamond d(R, R.zero); |
1283 // if (0) { while (p0) ; } else { } | 1266 // if (0) { while (p0) ; } else { } |
1284 w.branch->ReplaceInput(1, d.if_true); | 1267 w.branch->ReplaceInput(1, d.if_true); |
1285 d.merge->ReplaceInput(0, w.exit); | 1268 d.merge->ReplaceInput(0, w.exit); |
1286 | 1269 |
1287 R.ReduceMergeIterative(R.start, d.merge); | 1270 R.ReduceMergeIterative(R.start, d.merge); |
1288 | 1271 |
1289 DeadChecker dead(&R.graph); | 1272 DeadChecker dead(&R.graph); |
1290 dead.Check(d); | 1273 dead.Check(d); |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1632 | 1615 |
1633 R.ReduceGraph(); // d1 gets folded true. | 1616 R.ReduceGraph(); // d1 gets folded true. |
1634 | 1617 |
1635 CheckInputs(ret, y2, R.start, R.start); | 1618 CheckInputs(ret, y2, R.start, R.start); |
1636 | 1619 |
1637 DeadChecker dead(&R.graph); | 1620 DeadChecker dead(&R.graph); |
1638 dead.Check(d1); | 1621 dead.Check(d1); |
1639 dead.Check(d2); | 1622 dead.Check(d2); |
1640 dead.Check(d3); | 1623 dead.Check(d3); |
1641 } | 1624 } |
OLD | NEW |