| 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/compiler/common-operator.h" | 5 #include "src/compiler/common-operator.h" |
| 6 #include "src/compiler/diamond.h" | 6 #include "src/compiler/diamond.h" |
| 7 #include "test/unittests/compiler/graph-unittest.h" | 7 #include "test/unittests/compiler/graph-unittest.h" |
| 8 #include "test/unittests/compiler/node-test-utils.h" | 8 #include "test/unittests/compiler/node-test-utils.h" |
| 9 #include "testing/gmock-support.h" | 9 #include "testing/gmock-support.h" |
| 10 | 10 |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 | 121 |
| 122 EXPECT_THAT(d.branch, IsBranch(p0, graph()->start())); | 122 EXPECT_THAT(d.branch, IsBranch(p0, graph()->start())); |
| 123 EXPECT_THAT(d.if_true, IsIfTrue(d.branch)); | 123 EXPECT_THAT(d.if_true, IsIfTrue(d.branch)); |
| 124 EXPECT_THAT(d.if_false, IsIfFalse(d.branch)); | 124 EXPECT_THAT(d.if_false, IsIfFalse(d.branch)); |
| 125 EXPECT_THAT(d.merge, IsMerge(d.if_true, d.if_false)); | 125 EXPECT_THAT(d.merge, IsMerge(d.if_true, d.if_false)); |
| 126 EXPECT_THAT(phi, IsPhi(types[i], p1, p2, d.merge)); | 126 EXPECT_THAT(phi, IsPhi(types[i], p1, p2, d.merge)); |
| 127 } | 127 } |
| 128 } | 128 } |
| 129 | 129 |
| 130 | 130 |
| 131 TEST_F(DiamondTest, DiamondEffectPhis) { | |
| 132 Node* p0 = Parameter(0); | |
| 133 Node* p1 = Parameter(1); | |
| 134 Node* p2 = Parameter(2); | |
| 135 Diamond d(graph(), common(), p0); | |
| 136 | |
| 137 Node* phi = d.EffectPhi(p1, p2); | |
| 138 | |
| 139 EXPECT_THAT(d.branch, IsBranch(p0, graph()->start())); | |
| 140 EXPECT_THAT(d.if_true, IsIfTrue(d.branch)); | |
| 141 EXPECT_THAT(d.if_false, IsIfFalse(d.branch)); | |
| 142 EXPECT_THAT(d.merge, IsMerge(d.if_true, d.if_false)); | |
| 143 EXPECT_THAT(phi, IsEffectPhi(p1, p2, d.merge)); | |
| 144 } | |
| 145 | |
| 146 | |
| 147 TEST_F(DiamondTest, BranchHint) { | 131 TEST_F(DiamondTest, BranchHint) { |
| 148 Diamond dn(graph(), common(), Parameter(0)); | 132 Diamond dn(graph(), common(), Parameter(0)); |
| 149 CHECK(BranchHint::kNone == BranchHintOf(dn.branch->op())); | 133 CHECK(BranchHint::kNone == BranchHintOf(dn.branch->op())); |
| 150 | 134 |
| 151 Diamond dt(graph(), common(), Parameter(0), BranchHint::kTrue); | 135 Diamond dt(graph(), common(), Parameter(0), BranchHint::kTrue); |
| 152 CHECK(BranchHint::kTrue == BranchHintOf(dt.branch->op())); | 136 CHECK(BranchHint::kTrue == BranchHintOf(dt.branch->op())); |
| 153 | 137 |
| 154 Diamond df(graph(), common(), Parameter(0), BranchHint::kFalse); | 138 Diamond df(graph(), common(), Parameter(0), BranchHint::kFalse); |
| 155 CHECK(BranchHint::kFalse == BranchHintOf(df.branch->op())); | 139 CHECK(BranchHint::kFalse == BranchHintOf(df.branch->op())); |
| 156 } | 140 } |
| 157 | 141 |
| 158 | 142 |
| 159 } // namespace compiler | 143 } // namespace compiler |
| 160 } // namespace internal | 144 } // namespace internal |
| 161 } // namespace v8 | 145 } // namespace v8 |
| OLD | NEW |