OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/schedule.h" |
5 #include "src/compiler/access-builder.h" | 6 #include "src/compiler/access-builder.h" |
6 #include "src/compiler/common-operator.h" | 7 #include "src/compiler/common-operator.h" |
| 8 #include "src/compiler/graph-visualizer.h" |
7 #include "src/compiler/graph.h" | 9 #include "src/compiler/graph.h" |
8 #include "src/compiler/graph-visualizer.h" | |
9 #include "src/compiler/js-operator.h" | 10 #include "src/compiler/js-operator.h" |
10 #include "src/compiler/node.h" | 11 #include "src/compiler/node.h" |
11 #include "src/compiler/opcodes.h" | 12 #include "src/compiler/opcodes.h" |
12 #include "src/compiler/operator.h" | 13 #include "src/compiler/operator.h" |
13 #include "src/compiler/schedule.h" | |
14 #include "src/compiler/scheduler.h" | 14 #include "src/compiler/scheduler.h" |
15 #include "src/compiler/simplified-operator.h" | 15 #include "src/compiler/simplified-operator.h" |
16 #include "src/compiler/source-position.h" | 16 #include "src/compiler/source-position.h" |
17 #include "src/compiler/verifier.h" | 17 #include "src/compiler/verifier.h" |
18 #include "test/unittests/compiler/compiler-test-utils.h" | 18 #include "test/unittests/compiler/compiler-test-utils.h" |
19 #include "test/unittests/test-utils.h" | 19 #include "test/unittests/test-utils.h" |
20 #include "testing/gmock/include/gmock/gmock.h" | 20 #include "testing/gmock/include/gmock/gmock.h" |
21 | 21 |
22 using testing::AnyOf; | 22 using testing::AnyOf; |
23 | 23 |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 Node* p0 = graph()->NewNode(common()->Parameter(0), start); | 129 Node* p0 = graph()->NewNode(common()->Parameter(0), start); |
130 Node* d1 = CreateDiamond(graph(), common(), p0); | 130 Node* d1 = CreateDiamond(graph(), common(), p0); |
131 Node* ret = graph()->NewNode(common()->Return(), d1, start, start); | 131 Node* ret = graph()->NewNode(common()->Return(), d1, start, start); |
132 Node* end = graph()->NewNode(common()->End(1), ret); | 132 Node* end = graph()->NewNode(common()->End(1), ret); |
133 | 133 |
134 graph()->SetEnd(end); | 134 graph()->SetEnd(end); |
135 | 135 |
136 ComputeAndVerifySchedule(13); | 136 ComputeAndVerifySchedule(13); |
137 } | 137 } |
138 | 138 |
| 139 TARGET_TEST_F(SchedulerTest, FloatingDeadDiamond1) { |
| 140 Node* start = graph()->NewNode(common()->Start(1)); |
| 141 graph()->SetStart(start); |
| 142 |
| 143 Node* p0 = graph()->NewNode(common()->Parameter(0), start); |
| 144 Node* d1 = CreateDiamond(graph(), common(), p0); |
| 145 USE(d1); |
| 146 Node* ret = graph()->NewNode(common()->Return(), p0, start, start); |
| 147 Node* end = graph()->NewNode(common()->End(1), ret); |
| 148 |
| 149 graph()->SetEnd(end); |
| 150 |
| 151 ComputeAndVerifySchedule(4); |
| 152 } |
| 153 |
| 154 TARGET_TEST_F(SchedulerTest, FloatingDeadDiamond2) { |
| 155 Graph* g = graph(); |
| 156 Node* start = g->NewNode(common()->Start(1)); |
| 157 g->SetStart(start); |
| 158 |
| 159 Node* n1 = g->NewNode(common()->Parameter(1), start); |
| 160 |
| 161 Node* n2 = g->NewNode(common()->Branch(), n1, start); |
| 162 Node* n3 = g->NewNode(common()->IfTrue(), n2); |
| 163 Node* n4 = g->NewNode(common()->IfFalse(), n2); |
| 164 Node* n5 = g->NewNode(common()->Int32Constant(-100)); |
| 165 Node* n6 = g->NewNode(common()->Return(), n5, start, n4); |
| 166 Node* n7 = g->NewNode(common()->Int32Constant(0)); |
| 167 Node* n8 = g->NewNode(common()->Return(), n7, start, n3); |
| 168 Node* n9 = g->NewNode(common()->End(2), n6, n8); |
| 169 |
| 170 // Dead nodes |
| 171 Node* n10 = g->NewNode(common()->Branch(), n1, n3); |
| 172 Node* n11 = g->NewNode(common()->IfTrue(), n10); |
| 173 Node* n12 = g->NewNode(common()->IfFalse(), n10); |
| 174 Node* n13 = g->NewNode(common()->Merge(2), n11, n12); |
| 175 Node* n14 = |
| 176 g->NewNode(common()->Phi(MachineRepresentation::kWord32, 2), n1, n7, n13); |
| 177 |
| 178 USE(n14); |
| 179 |
| 180 g->SetEnd(n9); |
| 181 |
| 182 ComputeAndVerifySchedule(10); |
| 183 } |
139 | 184 |
140 TARGET_TEST_F(SchedulerTest, FloatingDiamond2) { | 185 TARGET_TEST_F(SchedulerTest, FloatingDiamond2) { |
141 Node* start = graph()->NewNode(common()->Start(2)); | 186 Node* start = graph()->NewNode(common()->Start(2)); |
142 graph()->SetStart(start); | 187 graph()->SetStart(start); |
143 | 188 |
144 Node* p0 = graph()->NewNode(common()->Parameter(0), start); | 189 Node* p0 = graph()->NewNode(common()->Parameter(0), start); |
145 Node* p1 = graph()->NewNode(common()->Parameter(1), start); | 190 Node* p1 = graph()->NewNode(common()->Parameter(1), start); |
146 Node* d1 = CreateDiamond(graph(), common(), p0); | 191 Node* d1 = CreateDiamond(graph(), common(), p0); |
147 Node* d2 = CreateDiamond(graph(), common(), p1); | 192 Node* d2 = CreateDiamond(graph(), common(), p1); |
148 Node* add = graph()->NewNode(&kIntAdd, d1, d2); | 193 Node* add = graph()->NewNode(&kIntAdd, d1, d2); |
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
609 | 654 |
610 Schedule* schedule = ComputeAndVerifySchedule(6); | 655 Schedule* schedule = ComputeAndVerifySchedule(6); |
611 BasicBlock* block = schedule->block(loop); | 656 BasicBlock* block = schedule->block(loop); |
612 EXPECT_EQ(block, schedule->block(effect)); | 657 EXPECT_EQ(block, schedule->block(effect)); |
613 EXPECT_GE(block->rpo_number(), 0); | 658 EXPECT_GE(block->rpo_number(), 0); |
614 } | 659 } |
615 | 660 |
616 } // namespace compiler | 661 } // namespace compiler |
617 } // namespace internal | 662 } // namespace internal |
618 } // namespace v8 | 663 } // namespace v8 |
OLD | NEW |