Chromium Code Reviews| 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 | 6 |
| 7 #include "src/compiler/access-builder.h" | 7 #include "src/compiler/access-builder.h" |
| 8 #include "src/compiler/common-operator.h" | 8 #include "src/compiler/common-operator.h" |
| 9 #include "src/compiler/graph.h" | 9 #include "src/compiler/graph.h" |
| 10 #include "src/compiler/graph-visualizer.h" | 10 #include "src/compiler/graph-visualizer.h" |
| 11 #include "src/compiler/js-operator.h" | 11 #include "src/compiler/js-operator.h" |
| 12 #include "src/compiler/node.h" | 12 #include "src/compiler/node.h" |
| 13 #include "src/compiler/opcodes.h" | 13 #include "src/compiler/opcodes.h" |
| 14 #include "src/compiler/operator.h" | 14 #include "src/compiler/operator.h" |
| 15 #include "src/compiler/schedule.h" | 15 #include "src/compiler/schedule.h" |
| 16 #include "src/compiler/scheduler.h" | 16 #include "src/compiler/scheduler.h" |
| 17 #include "src/compiler/simplified-operator.h" | 17 #include "src/compiler/simplified-operator.h" |
| 18 #include "src/compiler/verifier.h" | 18 #include "src/compiler/verifier.h" |
| 19 #include "test/cctest/cctest.h" | 19 #include "test/unittests/test-utils.h" |
| 20 | 20 |
| 21 using namespace v8::internal; | 21 using namespace v8::internal; |
| 22 using namespace v8::internal::compiler; | 22 using namespace v8::internal::compiler; |
| 23 | 23 |
| 24 namespace { | |
| 25 | |
| 26 class SchedulerTest : public TestWithZone { | |
| 27 public: | |
| 28 SchedulerTest() {} | |
| 29 }; | |
| 30 | |
| 24 Operator kIntAdd(IrOpcode::kInt32Add, Operator::kPure, "Int32Add", 2, 0, 0, 1, | 31 Operator kIntAdd(IrOpcode::kInt32Add, Operator::kPure, "Int32Add", 2, 0, 0, 1, |
| 25 0, 0); | 32 0, 0); |
| 26 | 33 |
| 27 // TODO(titzer): pull RPO tests out to their own file. | 34 // TODO(titzer): pull RPO tests out to their own file. |
| 28 static void CheckRPONumbers(BasicBlockVector* order, size_t expected, | 35 static void CheckRPONumbers(BasicBlockVector* order, size_t expected, |
|
Michael Starzinger
2015/01/22 16:10:36
These static methods could be made into member met
danno
2015/01/23 16:51:36
Done.
| |
| 29 bool loops_allowed) { | 36 bool loops_allowed) { |
| 30 CHECK(expected == order->size()); | 37 CHECK(expected == order->size()); |
| 31 for (int i = 0; i < static_cast<int>(order->size()); i++) { | 38 for (int i = 0; i < static_cast<int>(order->size()); i++) { |
| 32 CHECK(order->at(i)->rpo_number() == i); | 39 CHECK(order->at(i)->rpo_number() == i); |
| 33 if (!loops_allowed) { | 40 if (!loops_allowed) { |
| 34 CHECK_EQ(NULL, order->at(i)->loop_end()); | 41 CHECK_EQ(NULL, order->at(i)->loop_end()); |
| 35 CHECK_EQ(NULL, order->at(i)->loop_header()); | 42 CHECK_EQ(NULL, order->at(i)->loop_header()); |
| 36 } | 43 } |
| 37 } | 44 } |
| 38 } | 45 } |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 114 | 121 |
| 115 if (FLAG_trace_turbo_scheduler) { | 122 if (FLAG_trace_turbo_scheduler) { |
| 116 OFStream os(stdout); | 123 OFStream os(stdout); |
| 117 os << *schedule << std::endl; | 124 os << *schedule << std::endl; |
| 118 } | 125 } |
| 119 ScheduleVerifier::Run(schedule); | 126 ScheduleVerifier::Run(schedule); |
| 120 CHECK_EQ(expected, GetScheduledNodeCount(schedule)); | 127 CHECK_EQ(expected, GetScheduledNodeCount(schedule)); |
| 121 return schedule; | 128 return schedule; |
| 122 } | 129 } |
| 123 | 130 |
| 131 } // namespace | |
| 124 | 132 |
| 125 TEST(RPODegenerate1) { | 133 TEST_F(SchedulerTest, RPODegenerate1) { |
| 126 HandleAndZoneScope scope; | 134 Schedule schedule(zone()); |
| 127 Schedule schedule(scope.main_zone()); | 135 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(zone(), &schedule); |
| 128 | |
| 129 BasicBlockVector* order = | |
| 130 Scheduler::ComputeSpecialRPO(scope.main_zone(), &schedule); | |
| 131 CheckRPONumbers(order, 1, false); | 136 CheckRPONumbers(order, 1, false); |
| 132 CHECK_EQ(schedule.start(), order->at(0)); | 137 CHECK_EQ(schedule.start(), order->at(0)); |
| 133 } | 138 } |
| 134 | 139 |
| 135 | 140 |
| 136 TEST(RPODegenerate2) { | 141 TEST_F(SchedulerTest, RPODegenerate2) { |
| 137 HandleAndZoneScope scope; | 142 Schedule schedule(zone()); |
| 138 Schedule schedule(scope.main_zone()); | |
| 139 | 143 |
| 140 schedule.AddGoto(schedule.start(), schedule.end()); | 144 schedule.AddGoto(schedule.start(), schedule.end()); |
| 141 BasicBlockVector* order = | 145 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(zone(), &schedule); |
| 142 Scheduler::ComputeSpecialRPO(scope.main_zone(), &schedule); | |
| 143 CheckRPONumbers(order, 2, false); | 146 CheckRPONumbers(order, 2, false); |
| 144 CHECK_EQ(schedule.start(), order->at(0)); | 147 CHECK_EQ(schedule.start(), order->at(0)); |
| 145 CHECK_EQ(schedule.end(), order->at(1)); | 148 CHECK_EQ(schedule.end(), order->at(1)); |
| 146 } | 149 } |
| 147 | 150 |
| 148 | 151 |
| 149 TEST(RPOLine) { | 152 TEST_F(SchedulerTest, RPOLine) { |
| 150 HandleAndZoneScope scope; | |
| 151 | |
| 152 for (int i = 0; i < 10; i++) { | 153 for (int i = 0; i < 10; i++) { |
| 153 Schedule schedule(scope.main_zone()); | 154 Schedule schedule(zone()); |
| 154 | 155 |
| 155 BasicBlock* last = schedule.start(); | 156 BasicBlock* last = schedule.start(); |
| 156 for (int j = 0; j < i; j++) { | 157 for (int j = 0; j < i; j++) { |
| 157 BasicBlock* block = schedule.NewBasicBlock(); | 158 BasicBlock* block = schedule.NewBasicBlock(); |
| 158 block->set_deferred(i & 1); | 159 block->set_deferred(i & 1); |
| 159 schedule.AddGoto(last, block); | 160 schedule.AddGoto(last, block); |
| 160 last = block; | 161 last = block; |
| 161 } | 162 } |
| 162 BasicBlockVector* order = | 163 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(zone(), &schedule); |
| 163 Scheduler::ComputeSpecialRPO(scope.main_zone(), &schedule); | |
| 164 CheckRPONumbers(order, 1 + i, false); | 164 CheckRPONumbers(order, 1 + i, false); |
| 165 | 165 |
| 166 for (size_t i = 0; i < schedule.BasicBlockCount(); i++) { | 166 for (size_t i = 0; i < schedule.BasicBlockCount(); i++) { |
| 167 BasicBlock* block = schedule.GetBlockById(BasicBlock::Id::FromSize(i)); | 167 BasicBlock* block = schedule.GetBlockById(BasicBlock::Id::FromSize(i)); |
| 168 if (block->rpo_number() >= 0 && block->SuccessorCount() == 1) { | 168 if (block->rpo_number() >= 0 && block->SuccessorCount() == 1) { |
| 169 CHECK(block->rpo_number() + 1 == block->SuccessorAt(0)->rpo_number()); | 169 CHECK(block->rpo_number() + 1 == block->SuccessorAt(0)->rpo_number()); |
| 170 } | 170 } |
| 171 } | 171 } |
| 172 } | 172 } |
| 173 } | 173 } |
| 174 | 174 |
| 175 | 175 |
| 176 TEST(RPOSelfLoop) { | 176 TEST_F(SchedulerTest, RPOSelfLoop) { |
| 177 HandleAndZoneScope scope; | 177 Schedule schedule(zone()); |
| 178 Schedule schedule(scope.main_zone()); | |
| 179 schedule.AddSuccessorForTesting(schedule.start(), schedule.start()); | 178 schedule.AddSuccessorForTesting(schedule.start(), schedule.start()); |
| 180 BasicBlockVector* order = | 179 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(zone(), &schedule); |
| 181 Scheduler::ComputeSpecialRPO(scope.main_zone(), &schedule); | |
| 182 CheckRPONumbers(order, 1, true); | 180 CheckRPONumbers(order, 1, true); |
| 183 BasicBlock* loop[] = {schedule.start()}; | 181 BasicBlock* loop[] = {schedule.start()}; |
| 184 CheckLoop(order, loop, 1); | 182 CheckLoop(order, loop, 1); |
| 185 } | 183 } |
| 186 | 184 |
| 187 | 185 |
| 188 TEST(RPOEntryLoop) { | 186 TEST_F(SchedulerTest, RPOEntryLoop) { |
| 189 HandleAndZoneScope scope; | 187 Schedule schedule(zone()); |
| 190 Schedule schedule(scope.main_zone()); | |
| 191 BasicBlock* body = schedule.NewBasicBlock(); | 188 BasicBlock* body = schedule.NewBasicBlock(); |
| 192 schedule.AddSuccessorForTesting(schedule.start(), body); | 189 schedule.AddSuccessorForTesting(schedule.start(), body); |
| 193 schedule.AddSuccessorForTesting(body, schedule.start()); | 190 schedule.AddSuccessorForTesting(body, schedule.start()); |
| 194 BasicBlockVector* order = | 191 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(zone(), &schedule); |
| 195 Scheduler::ComputeSpecialRPO(scope.main_zone(), &schedule); | |
| 196 CheckRPONumbers(order, 2, true); | 192 CheckRPONumbers(order, 2, true); |
| 197 BasicBlock* loop[] = {schedule.start(), body}; | 193 BasicBlock* loop[] = {schedule.start(), body}; |
| 198 CheckLoop(order, loop, 2); | 194 CheckLoop(order, loop, 2); |
| 199 } | 195 } |
| 200 | 196 |
| 201 | 197 |
| 202 TEST(RPOEndLoop) { | 198 TEST_F(SchedulerTest, RPOEndLoop) { |
| 203 HandleAndZoneScope scope; | 199 Schedule schedule(zone()); |
| 204 Schedule schedule(scope.main_zone()); | |
| 205 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, 2)); | 200 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, 2)); |
| 206 schedule.AddSuccessorForTesting(schedule.start(), loop1->header()); | 201 schedule.AddSuccessorForTesting(schedule.start(), loop1->header()); |
| 207 BasicBlockVector* order = | 202 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(zone(), &schedule); |
| 208 Scheduler::ComputeSpecialRPO(scope.main_zone(), &schedule); | |
| 209 CheckRPONumbers(order, 3, true); | 203 CheckRPONumbers(order, 3, true); |
| 210 loop1->Check(order); | 204 loop1->Check(order); |
| 211 } | 205 } |
| 212 | 206 |
| 213 | 207 |
| 214 TEST(RPOEndLoopNested) { | 208 TEST_F(SchedulerTest, RPOEndLoopNested) { |
| 215 HandleAndZoneScope scope; | 209 Schedule schedule(zone()); |
| 216 Schedule schedule(scope.main_zone()); | |
| 217 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, 2)); | 210 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, 2)); |
| 218 schedule.AddSuccessorForTesting(schedule.start(), loop1->header()); | 211 schedule.AddSuccessorForTesting(schedule.start(), loop1->header()); |
| 219 schedule.AddSuccessorForTesting(loop1->last(), schedule.start()); | 212 schedule.AddSuccessorForTesting(loop1->last(), schedule.start()); |
| 220 BasicBlockVector* order = | 213 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(zone(), &schedule); |
| 221 Scheduler::ComputeSpecialRPO(scope.main_zone(), &schedule); | |
| 222 CheckRPONumbers(order, 3, true); | 214 CheckRPONumbers(order, 3, true); |
| 223 loop1->Check(order); | 215 loop1->Check(order); |
| 224 } | 216 } |
| 225 | 217 |
| 226 | 218 |
| 227 TEST(RPODiamond) { | 219 TEST_F(SchedulerTest, RPODiamond) { |
| 228 HandleAndZoneScope scope; | 220 Schedule schedule(zone()); |
| 229 Schedule schedule(scope.main_zone()); | |
| 230 | 221 |
| 231 BasicBlock* A = schedule.start(); | 222 BasicBlock* A = schedule.start(); |
| 232 BasicBlock* B = schedule.NewBasicBlock(); | 223 BasicBlock* B = schedule.NewBasicBlock(); |
| 233 BasicBlock* C = schedule.NewBasicBlock(); | 224 BasicBlock* C = schedule.NewBasicBlock(); |
| 234 BasicBlock* D = schedule.end(); | 225 BasicBlock* D = schedule.end(); |
| 235 | 226 |
| 236 schedule.AddSuccessorForTesting(A, B); | 227 schedule.AddSuccessorForTesting(A, B); |
| 237 schedule.AddSuccessorForTesting(A, C); | 228 schedule.AddSuccessorForTesting(A, C); |
| 238 schedule.AddSuccessorForTesting(B, D); | 229 schedule.AddSuccessorForTesting(B, D); |
| 239 schedule.AddSuccessorForTesting(C, D); | 230 schedule.AddSuccessorForTesting(C, D); |
| 240 | 231 |
| 241 BasicBlockVector* order = | 232 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(zone(), &schedule); |
| 242 Scheduler::ComputeSpecialRPO(scope.main_zone(), &schedule); | |
| 243 CheckRPONumbers(order, 4, false); | 233 CheckRPONumbers(order, 4, false); |
| 244 | 234 |
| 245 CHECK_EQ(0, A->rpo_number()); | 235 CHECK_EQ(0, A->rpo_number()); |
| 246 CHECK((B->rpo_number() == 1 && C->rpo_number() == 2) || | 236 CHECK((B->rpo_number() == 1 && C->rpo_number() == 2) || |
| 247 (B->rpo_number() == 2 && C->rpo_number() == 1)); | 237 (B->rpo_number() == 2 && C->rpo_number() == 1)); |
| 248 CHECK_EQ(3, D->rpo_number()); | 238 CHECK_EQ(3, D->rpo_number()); |
| 249 } | 239 } |
| 250 | 240 |
| 251 | 241 |
| 252 TEST(RPOLoop1) { | 242 TEST_F(SchedulerTest, RPOLoop1) { |
| 253 HandleAndZoneScope scope; | 243 Schedule schedule(zone()); |
| 254 Schedule schedule(scope.main_zone()); | |
| 255 | 244 |
| 256 BasicBlock* A = schedule.start(); | 245 BasicBlock* A = schedule.start(); |
| 257 BasicBlock* B = schedule.NewBasicBlock(); | 246 BasicBlock* B = schedule.NewBasicBlock(); |
| 258 BasicBlock* C = schedule.NewBasicBlock(); | 247 BasicBlock* C = schedule.NewBasicBlock(); |
| 259 BasicBlock* D = schedule.end(); | 248 BasicBlock* D = schedule.end(); |
| 260 | 249 |
| 261 schedule.AddSuccessorForTesting(A, B); | 250 schedule.AddSuccessorForTesting(A, B); |
| 262 schedule.AddSuccessorForTesting(B, C); | 251 schedule.AddSuccessorForTesting(B, C); |
| 263 schedule.AddSuccessorForTesting(C, B); | 252 schedule.AddSuccessorForTesting(C, B); |
| 264 schedule.AddSuccessorForTesting(C, D); | 253 schedule.AddSuccessorForTesting(C, D); |
| 265 | 254 |
| 266 BasicBlockVector* order = | 255 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(zone(), &schedule); |
| 267 Scheduler::ComputeSpecialRPO(scope.main_zone(), &schedule); | |
| 268 CheckRPONumbers(order, 4, true); | 256 CheckRPONumbers(order, 4, true); |
| 269 BasicBlock* loop[] = {B, C}; | 257 BasicBlock* loop[] = {B, C}; |
| 270 CheckLoop(order, loop, 2); | 258 CheckLoop(order, loop, 2); |
| 271 } | 259 } |
| 272 | 260 |
| 273 | 261 |
| 274 TEST(RPOLoop2) { | 262 TEST_F(SchedulerTest, RPOLoop2) { |
| 275 HandleAndZoneScope scope; | 263 Schedule schedule(zone()); |
| 276 Schedule schedule(scope.main_zone()); | |
| 277 | 264 |
| 278 BasicBlock* A = schedule.start(); | 265 BasicBlock* A = schedule.start(); |
| 279 BasicBlock* B = schedule.NewBasicBlock(); | 266 BasicBlock* B = schedule.NewBasicBlock(); |
| 280 BasicBlock* C = schedule.NewBasicBlock(); | 267 BasicBlock* C = schedule.NewBasicBlock(); |
| 281 BasicBlock* D = schedule.end(); | 268 BasicBlock* D = schedule.end(); |
| 282 | 269 |
| 283 schedule.AddSuccessorForTesting(A, B); | 270 schedule.AddSuccessorForTesting(A, B); |
| 284 schedule.AddSuccessorForTesting(B, C); | 271 schedule.AddSuccessorForTesting(B, C); |
| 285 schedule.AddSuccessorForTesting(C, B); | 272 schedule.AddSuccessorForTesting(C, B); |
| 286 schedule.AddSuccessorForTesting(B, D); | 273 schedule.AddSuccessorForTesting(B, D); |
| 287 | 274 |
| 288 BasicBlockVector* order = | 275 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(zone(), &schedule); |
| 289 Scheduler::ComputeSpecialRPO(scope.main_zone(), &schedule); | |
| 290 CheckRPONumbers(order, 4, true); | 276 CheckRPONumbers(order, 4, true); |
| 291 BasicBlock* loop[] = {B, C}; | 277 BasicBlock* loop[] = {B, C}; |
| 292 CheckLoop(order, loop, 2); | 278 CheckLoop(order, loop, 2); |
| 293 } | 279 } |
| 294 | 280 |
| 295 | 281 |
| 296 TEST(RPOLoopN) { | 282 TEST_F(SchedulerTest, RPOLoopN) { |
| 297 HandleAndZoneScope scope; | |
| 298 | |
| 299 for (int i = 0; i < 11; i++) { | 283 for (int i = 0; i < 11; i++) { |
| 300 Schedule schedule(scope.main_zone()); | 284 Schedule schedule(zone()); |
| 301 BasicBlock* A = schedule.start(); | 285 BasicBlock* A = schedule.start(); |
| 302 BasicBlock* B = schedule.NewBasicBlock(); | 286 BasicBlock* B = schedule.NewBasicBlock(); |
| 303 BasicBlock* C = schedule.NewBasicBlock(); | 287 BasicBlock* C = schedule.NewBasicBlock(); |
| 304 BasicBlock* D = schedule.NewBasicBlock(); | 288 BasicBlock* D = schedule.NewBasicBlock(); |
| 305 BasicBlock* E = schedule.NewBasicBlock(); | 289 BasicBlock* E = schedule.NewBasicBlock(); |
| 306 BasicBlock* F = schedule.NewBasicBlock(); | 290 BasicBlock* F = schedule.NewBasicBlock(); |
| 307 BasicBlock* G = schedule.end(); | 291 BasicBlock* G = schedule.end(); |
| 308 | 292 |
| 309 schedule.AddSuccessorForTesting(A, B); | 293 schedule.AddSuccessorForTesting(A, B); |
| 310 schedule.AddSuccessorForTesting(B, C); | 294 schedule.AddSuccessorForTesting(B, C); |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 321 if (i == 4) schedule.AddSuccessorForTesting(E, B); | 305 if (i == 4) schedule.AddSuccessorForTesting(E, B); |
| 322 if (i == 5) schedule.AddSuccessorForTesting(F, B); | 306 if (i == 5) schedule.AddSuccessorForTesting(F, B); |
| 323 | 307 |
| 324 // Throw in extra loop exits from time to time. | 308 // Throw in extra loop exits from time to time. |
| 325 if (i == 6) schedule.AddSuccessorForTesting(B, G); | 309 if (i == 6) schedule.AddSuccessorForTesting(B, G); |
| 326 if (i == 7) schedule.AddSuccessorForTesting(C, G); | 310 if (i == 7) schedule.AddSuccessorForTesting(C, G); |
| 327 if (i == 8) schedule.AddSuccessorForTesting(D, G); | 311 if (i == 8) schedule.AddSuccessorForTesting(D, G); |
| 328 if (i == 9) schedule.AddSuccessorForTesting(E, G); | 312 if (i == 9) schedule.AddSuccessorForTesting(E, G); |
| 329 if (i == 10) schedule.AddSuccessorForTesting(F, G); | 313 if (i == 10) schedule.AddSuccessorForTesting(F, G); |
| 330 | 314 |
| 331 BasicBlockVector* order = | 315 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(zone(), &schedule); |
| 332 Scheduler::ComputeSpecialRPO(scope.main_zone(), &schedule); | |
| 333 CheckRPONumbers(order, 7, true); | 316 CheckRPONumbers(order, 7, true); |
| 334 BasicBlock* loop[] = {B, C, D, E, F}; | 317 BasicBlock* loop[] = {B, C, D, E, F}; |
| 335 CheckLoop(order, loop, 5); | 318 CheckLoop(order, loop, 5); |
| 336 } | 319 } |
| 337 } | 320 } |
| 338 | 321 |
| 339 | 322 |
| 340 TEST(RPOLoopNest1) { | 323 TEST_F(SchedulerTest, RPOLoopNest1) { |
| 341 HandleAndZoneScope scope; | 324 Schedule schedule(zone()); |
| 342 Schedule schedule(scope.main_zone()); | |
| 343 | 325 |
| 344 BasicBlock* A = schedule.start(); | 326 BasicBlock* A = schedule.start(); |
| 345 BasicBlock* B = schedule.NewBasicBlock(); | 327 BasicBlock* B = schedule.NewBasicBlock(); |
| 346 BasicBlock* C = schedule.NewBasicBlock(); | 328 BasicBlock* C = schedule.NewBasicBlock(); |
| 347 BasicBlock* D = schedule.NewBasicBlock(); | 329 BasicBlock* D = schedule.NewBasicBlock(); |
| 348 BasicBlock* E = schedule.NewBasicBlock(); | 330 BasicBlock* E = schedule.NewBasicBlock(); |
| 349 BasicBlock* F = schedule.end(); | 331 BasicBlock* F = schedule.end(); |
| 350 | 332 |
| 351 schedule.AddSuccessorForTesting(A, B); | 333 schedule.AddSuccessorForTesting(A, B); |
| 352 schedule.AddSuccessorForTesting(B, C); | 334 schedule.AddSuccessorForTesting(B, C); |
| 353 schedule.AddSuccessorForTesting(C, D); | 335 schedule.AddSuccessorForTesting(C, D); |
| 354 schedule.AddSuccessorForTesting(D, C); | 336 schedule.AddSuccessorForTesting(D, C); |
| 355 schedule.AddSuccessorForTesting(D, E); | 337 schedule.AddSuccessorForTesting(D, E); |
| 356 schedule.AddSuccessorForTesting(E, B); | 338 schedule.AddSuccessorForTesting(E, B); |
| 357 schedule.AddSuccessorForTesting(E, F); | 339 schedule.AddSuccessorForTesting(E, F); |
| 358 | 340 |
| 359 BasicBlockVector* order = | 341 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(zone(), &schedule); |
| 360 Scheduler::ComputeSpecialRPO(scope.main_zone(), &schedule); | |
| 361 CheckRPONumbers(order, 6, true); | 342 CheckRPONumbers(order, 6, true); |
| 362 BasicBlock* loop1[] = {B, C, D, E}; | 343 BasicBlock* loop1[] = {B, C, D, E}; |
| 363 CheckLoop(order, loop1, 4); | 344 CheckLoop(order, loop1, 4); |
| 364 | 345 |
| 365 BasicBlock* loop2[] = {C, D}; | 346 BasicBlock* loop2[] = {C, D}; |
| 366 CheckLoop(order, loop2, 2); | 347 CheckLoop(order, loop2, 2); |
| 367 } | 348 } |
| 368 | 349 |
| 369 | 350 |
| 370 TEST(RPOLoopNest2) { | 351 TEST_F(SchedulerTest, RPOLoopNest2) { |
| 371 HandleAndZoneScope scope; | 352 Schedule schedule(zone()); |
| 372 Schedule schedule(scope.main_zone()); | |
| 373 | 353 |
| 374 BasicBlock* A = schedule.start(); | 354 BasicBlock* A = schedule.start(); |
| 375 BasicBlock* B = schedule.NewBasicBlock(); | 355 BasicBlock* B = schedule.NewBasicBlock(); |
| 376 BasicBlock* C = schedule.NewBasicBlock(); | 356 BasicBlock* C = schedule.NewBasicBlock(); |
| 377 BasicBlock* D = schedule.NewBasicBlock(); | 357 BasicBlock* D = schedule.NewBasicBlock(); |
| 378 BasicBlock* E = schedule.NewBasicBlock(); | 358 BasicBlock* E = schedule.NewBasicBlock(); |
| 379 BasicBlock* F = schedule.NewBasicBlock(); | 359 BasicBlock* F = schedule.NewBasicBlock(); |
| 380 BasicBlock* G = schedule.NewBasicBlock(); | 360 BasicBlock* G = schedule.NewBasicBlock(); |
| 381 BasicBlock* H = schedule.end(); | 361 BasicBlock* H = schedule.end(); |
| 382 | 362 |
| 383 schedule.AddSuccessorForTesting(A, B); | 363 schedule.AddSuccessorForTesting(A, B); |
| 384 schedule.AddSuccessorForTesting(B, C); | 364 schedule.AddSuccessorForTesting(B, C); |
| 385 schedule.AddSuccessorForTesting(C, D); | 365 schedule.AddSuccessorForTesting(C, D); |
| 386 schedule.AddSuccessorForTesting(D, E); | 366 schedule.AddSuccessorForTesting(D, E); |
| 387 schedule.AddSuccessorForTesting(E, F); | 367 schedule.AddSuccessorForTesting(E, F); |
| 388 schedule.AddSuccessorForTesting(F, G); | 368 schedule.AddSuccessorForTesting(F, G); |
| 389 schedule.AddSuccessorForTesting(G, H); | 369 schedule.AddSuccessorForTesting(G, H); |
| 390 | 370 |
| 391 schedule.AddSuccessorForTesting(E, D); | 371 schedule.AddSuccessorForTesting(E, D); |
| 392 schedule.AddSuccessorForTesting(F, C); | 372 schedule.AddSuccessorForTesting(F, C); |
| 393 schedule.AddSuccessorForTesting(G, B); | 373 schedule.AddSuccessorForTesting(G, B); |
| 394 | 374 |
| 395 BasicBlockVector* order = | 375 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(zone(), &schedule); |
| 396 Scheduler::ComputeSpecialRPO(scope.main_zone(), &schedule); | |
| 397 CheckRPONumbers(order, 8, true); | 376 CheckRPONumbers(order, 8, true); |
| 398 BasicBlock* loop1[] = {B, C, D, E, F, G}; | 377 BasicBlock* loop1[] = {B, C, D, E, F, G}; |
| 399 CheckLoop(order, loop1, 6); | 378 CheckLoop(order, loop1, 6); |
| 400 | 379 |
| 401 BasicBlock* loop2[] = {C, D, E, F}; | 380 BasicBlock* loop2[] = {C, D, E, F}; |
| 402 CheckLoop(order, loop2, 4); | 381 CheckLoop(order, loop2, 4); |
| 403 | 382 |
| 404 BasicBlock* loop3[] = {D, E}; | 383 BasicBlock* loop3[] = {D, E}; |
| 405 CheckLoop(order, loop3, 2); | 384 CheckLoop(order, loop3, 2); |
| 406 } | 385 } |
| 407 | 386 |
| 408 | 387 |
| 409 TEST(RPOLoopFollow1) { | 388 TEST_F(SchedulerTest, RPOLoopFollow1) { |
| 410 HandleAndZoneScope scope; | 389 Schedule schedule(zone()); |
| 411 Schedule schedule(scope.main_zone()); | |
| 412 | 390 |
| 413 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, 1)); | 391 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, 1)); |
| 414 SmartPointer<TestLoop> loop2(CreateLoop(&schedule, 1)); | 392 SmartPointer<TestLoop> loop2(CreateLoop(&schedule, 1)); |
| 415 | 393 |
| 416 BasicBlock* A = schedule.start(); | 394 BasicBlock* A = schedule.start(); |
| 417 BasicBlock* E = schedule.end(); | 395 BasicBlock* E = schedule.end(); |
| 418 | 396 |
| 419 schedule.AddSuccessorForTesting(A, loop1->header()); | 397 schedule.AddSuccessorForTesting(A, loop1->header()); |
| 420 schedule.AddSuccessorForTesting(loop1->header(), loop2->header()); | 398 schedule.AddSuccessorForTesting(loop1->header(), loop2->header()); |
| 421 schedule.AddSuccessorForTesting(loop2->last(), E); | 399 schedule.AddSuccessorForTesting(loop2->last(), E); |
| 422 | 400 |
| 423 BasicBlockVector* order = | 401 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(zone(), &schedule); |
| 424 Scheduler::ComputeSpecialRPO(scope.main_zone(), &schedule); | |
| 425 | 402 |
| 426 CHECK_EQ(static_cast<int>(schedule.BasicBlockCount()), | 403 CHECK_EQ(static_cast<int>(schedule.BasicBlockCount()), |
| 427 static_cast<int>(order->size())); | 404 static_cast<int>(order->size())); |
| 428 | 405 |
| 429 loop1->Check(order); | 406 loop1->Check(order); |
| 430 loop2->Check(order); | 407 loop2->Check(order); |
| 431 } | 408 } |
| 432 | 409 |
| 433 | 410 |
| 434 TEST(RPOLoopFollow2) { | 411 TEST_F(SchedulerTest, RPOLoopFollow2) { |
| 435 HandleAndZoneScope scope; | 412 Schedule schedule(zone()); |
| 436 Schedule schedule(scope.main_zone()); | |
| 437 | 413 |
| 438 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, 1)); | 414 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, 1)); |
| 439 SmartPointer<TestLoop> loop2(CreateLoop(&schedule, 1)); | 415 SmartPointer<TestLoop> loop2(CreateLoop(&schedule, 1)); |
| 440 | 416 |
| 441 BasicBlock* A = schedule.start(); | 417 BasicBlock* A = schedule.start(); |
| 442 BasicBlock* S = schedule.NewBasicBlock(); | 418 BasicBlock* S = schedule.NewBasicBlock(); |
| 443 BasicBlock* E = schedule.end(); | 419 BasicBlock* E = schedule.end(); |
| 444 | 420 |
| 445 schedule.AddSuccessorForTesting(A, loop1->header()); | 421 schedule.AddSuccessorForTesting(A, loop1->header()); |
| 446 schedule.AddSuccessorForTesting(loop1->header(), S); | 422 schedule.AddSuccessorForTesting(loop1->header(), S); |
| 447 schedule.AddSuccessorForTesting(S, loop2->header()); | 423 schedule.AddSuccessorForTesting(S, loop2->header()); |
| 448 schedule.AddSuccessorForTesting(loop2->last(), E); | 424 schedule.AddSuccessorForTesting(loop2->last(), E); |
| 449 | 425 |
| 450 BasicBlockVector* order = | 426 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(zone(), &schedule); |
| 451 Scheduler::ComputeSpecialRPO(scope.main_zone(), &schedule); | |
| 452 | 427 |
| 453 CHECK_EQ(static_cast<int>(schedule.BasicBlockCount()), | 428 CHECK_EQ(static_cast<int>(schedule.BasicBlockCount()), |
| 454 static_cast<int>(order->size())); | 429 static_cast<int>(order->size())); |
| 455 loop1->Check(order); | 430 loop1->Check(order); |
| 456 loop2->Check(order); | 431 loop2->Check(order); |
| 457 } | 432 } |
| 458 | 433 |
| 459 | 434 |
| 460 TEST(RPOLoopFollowN) { | 435 TEST_F(SchedulerTest, RPOLoopFollowN) { |
| 461 HandleAndZoneScope scope; | |
| 462 | |
| 463 for (int size = 1; size < 5; size++) { | 436 for (int size = 1; size < 5; size++) { |
| 464 for (int exit = 0; exit < size; exit++) { | 437 for (int exit = 0; exit < size; exit++) { |
| 465 Schedule schedule(scope.main_zone()); | 438 Schedule schedule(zone()); |
| 466 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, size)); | 439 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, size)); |
| 467 SmartPointer<TestLoop> loop2(CreateLoop(&schedule, size)); | 440 SmartPointer<TestLoop> loop2(CreateLoop(&schedule, size)); |
| 468 BasicBlock* A = schedule.start(); | 441 BasicBlock* A = schedule.start(); |
| 469 BasicBlock* E = schedule.end(); | 442 BasicBlock* E = schedule.end(); |
| 470 | 443 |
| 471 schedule.AddSuccessorForTesting(A, loop1->header()); | 444 schedule.AddSuccessorForTesting(A, loop1->header()); |
| 472 schedule.AddSuccessorForTesting(loop1->nodes[exit], loop2->header()); | 445 schedule.AddSuccessorForTesting(loop1->nodes[exit], loop2->header()); |
| 473 schedule.AddSuccessorForTesting(loop2->nodes[exit], E); | 446 schedule.AddSuccessorForTesting(loop2->nodes[exit], E); |
| 474 BasicBlockVector* order = | 447 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(zone(), &schedule); |
| 475 Scheduler::ComputeSpecialRPO(scope.main_zone(), &schedule); | |
| 476 | 448 |
| 477 CHECK_EQ(static_cast<int>(schedule.BasicBlockCount()), | 449 CHECK_EQ(static_cast<int>(schedule.BasicBlockCount()), |
| 478 static_cast<int>(order->size())); | 450 static_cast<int>(order->size())); |
| 479 loop1->Check(order); | 451 loop1->Check(order); |
| 480 loop2->Check(order); | 452 loop2->Check(order); |
| 481 } | 453 } |
| 482 } | 454 } |
| 483 } | 455 } |
| 484 | 456 |
| 485 | 457 |
| 486 TEST(RPONestedLoopFollow1) { | 458 TEST_F(SchedulerTest, RPONestedLoopFollow1) { |
| 487 HandleAndZoneScope scope; | 459 Schedule schedule(zone()); |
| 488 Schedule schedule(scope.main_zone()); | |
| 489 | 460 |
| 490 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, 1)); | 461 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, 1)); |
| 491 SmartPointer<TestLoop> loop2(CreateLoop(&schedule, 1)); | 462 SmartPointer<TestLoop> loop2(CreateLoop(&schedule, 1)); |
| 492 | 463 |
| 493 BasicBlock* A = schedule.start(); | 464 BasicBlock* A = schedule.start(); |
| 494 BasicBlock* B = schedule.NewBasicBlock(); | 465 BasicBlock* B = schedule.NewBasicBlock(); |
| 495 BasicBlock* C = schedule.NewBasicBlock(); | 466 BasicBlock* C = schedule.NewBasicBlock(); |
| 496 BasicBlock* E = schedule.end(); | 467 BasicBlock* E = schedule.end(); |
| 497 | 468 |
| 498 schedule.AddSuccessorForTesting(A, B); | 469 schedule.AddSuccessorForTesting(A, B); |
| 499 schedule.AddSuccessorForTesting(B, loop1->header()); | 470 schedule.AddSuccessorForTesting(B, loop1->header()); |
| 500 schedule.AddSuccessorForTesting(loop1->header(), loop2->header()); | 471 schedule.AddSuccessorForTesting(loop1->header(), loop2->header()); |
| 501 schedule.AddSuccessorForTesting(loop2->last(), C); | 472 schedule.AddSuccessorForTesting(loop2->last(), C); |
| 502 schedule.AddSuccessorForTesting(C, E); | 473 schedule.AddSuccessorForTesting(C, E); |
| 503 schedule.AddSuccessorForTesting(C, B); | 474 schedule.AddSuccessorForTesting(C, B); |
| 504 | 475 |
| 505 BasicBlockVector* order = | 476 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(zone(), &schedule); |
| 506 Scheduler::ComputeSpecialRPO(scope.main_zone(), &schedule); | |
| 507 | 477 |
| 508 CHECK_EQ(static_cast<int>(schedule.BasicBlockCount()), | 478 CHECK_EQ(static_cast<int>(schedule.BasicBlockCount()), |
| 509 static_cast<int>(order->size())); | 479 static_cast<int>(order->size())); |
| 510 loop1->Check(order); | 480 loop1->Check(order); |
| 511 loop2->Check(order); | 481 loop2->Check(order); |
| 512 | 482 |
| 513 BasicBlock* loop3[] = {B, loop1->nodes[0], loop2->nodes[0], C}; | 483 BasicBlock* loop3[] = {B, loop1->nodes[0], loop2->nodes[0], C}; |
| 514 CheckLoop(order, loop3, 4); | 484 CheckLoop(order, loop3, 4); |
| 515 } | 485 } |
| 516 | 486 |
| 517 | 487 |
| 518 TEST(RPOLoopBackedges1) { | 488 TEST_F(SchedulerTest, RPOLoopBackedges1) { |
| 519 HandleAndZoneScope scope; | |
| 520 | |
| 521 int size = 8; | 489 int size = 8; |
| 522 for (int i = 0; i < size; i++) { | 490 for (int i = 0; i < size; i++) { |
| 523 for (int j = 0; j < size; j++) { | 491 for (int j = 0; j < size; j++) { |
| 524 Schedule schedule(scope.main_zone()); | 492 Schedule schedule(zone()); |
| 525 BasicBlock* A = schedule.start(); | 493 BasicBlock* A = schedule.start(); |
| 526 BasicBlock* E = schedule.end(); | 494 BasicBlock* E = schedule.end(); |
| 527 | 495 |
| 528 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, size)); | 496 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, size)); |
| 529 schedule.AddSuccessorForTesting(A, loop1->header()); | 497 schedule.AddSuccessorForTesting(A, loop1->header()); |
| 530 schedule.AddSuccessorForTesting(loop1->last(), E); | 498 schedule.AddSuccessorForTesting(loop1->last(), E); |
| 531 | 499 |
| 532 schedule.AddSuccessorForTesting(loop1->nodes[i], loop1->header()); | 500 schedule.AddSuccessorForTesting(loop1->nodes[i], loop1->header()); |
| 533 schedule.AddSuccessorForTesting(loop1->nodes[j], E); | 501 schedule.AddSuccessorForTesting(loop1->nodes[j], E); |
| 534 | 502 |
| 535 BasicBlockVector* order = | 503 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(zone(), &schedule); |
| 536 Scheduler::ComputeSpecialRPO(scope.main_zone(), &schedule); | |
| 537 CheckRPONumbers(order, schedule.BasicBlockCount(), true); | 504 CheckRPONumbers(order, schedule.BasicBlockCount(), true); |
| 538 loop1->Check(order); | 505 loop1->Check(order); |
| 539 } | 506 } |
| 540 } | 507 } |
| 541 } | 508 } |
| 542 | 509 |
| 543 | 510 |
| 544 TEST(RPOLoopOutedges1) { | 511 TEST_F(SchedulerTest, RPOLoopOutedges1) { |
| 545 HandleAndZoneScope scope; | |
| 546 | |
| 547 int size = 8; | 512 int size = 8; |
| 548 for (int i = 0; i < size; i++) { | 513 for (int i = 0; i < size; i++) { |
| 549 for (int j = 0; j < size; j++) { | 514 for (int j = 0; j < size; j++) { |
| 550 Schedule schedule(scope.main_zone()); | 515 Schedule schedule(zone()); |
| 551 BasicBlock* A = schedule.start(); | 516 BasicBlock* A = schedule.start(); |
| 552 BasicBlock* D = schedule.NewBasicBlock(); | 517 BasicBlock* D = schedule.NewBasicBlock(); |
| 553 BasicBlock* E = schedule.end(); | 518 BasicBlock* E = schedule.end(); |
| 554 | 519 |
| 555 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, size)); | 520 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, size)); |
| 556 schedule.AddSuccessorForTesting(A, loop1->header()); | 521 schedule.AddSuccessorForTesting(A, loop1->header()); |
| 557 schedule.AddSuccessorForTesting(loop1->last(), E); | 522 schedule.AddSuccessorForTesting(loop1->last(), E); |
| 558 | 523 |
| 559 schedule.AddSuccessorForTesting(loop1->nodes[i], loop1->header()); | 524 schedule.AddSuccessorForTesting(loop1->nodes[i], loop1->header()); |
| 560 schedule.AddSuccessorForTesting(loop1->nodes[j], D); | 525 schedule.AddSuccessorForTesting(loop1->nodes[j], D); |
| 561 schedule.AddSuccessorForTesting(D, E); | 526 schedule.AddSuccessorForTesting(D, E); |
| 562 | 527 |
| 563 BasicBlockVector* order = | 528 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(zone(), &schedule); |
| 564 Scheduler::ComputeSpecialRPO(scope.main_zone(), &schedule); | |
| 565 CheckRPONumbers(order, schedule.BasicBlockCount(), true); | 529 CheckRPONumbers(order, schedule.BasicBlockCount(), true); |
| 566 loop1->Check(order); | 530 loop1->Check(order); |
| 567 } | 531 } |
| 568 } | 532 } |
| 569 } | 533 } |
| 570 | 534 |
| 571 | 535 |
| 572 TEST(RPOLoopOutedges2) { | 536 TEST_F(SchedulerTest, RPOLoopOutedges2) { |
| 573 HandleAndZoneScope scope; | |
| 574 | |
| 575 int size = 8; | 537 int size = 8; |
| 576 for (int i = 0; i < size; i++) { | 538 for (int i = 0; i < size; i++) { |
| 577 Schedule schedule(scope.main_zone()); | 539 Schedule schedule(zone()); |
| 578 BasicBlock* A = schedule.start(); | 540 BasicBlock* A = schedule.start(); |
| 579 BasicBlock* E = schedule.end(); | 541 BasicBlock* E = schedule.end(); |
| 580 | 542 |
| 581 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, size)); | 543 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, size)); |
| 582 schedule.AddSuccessorForTesting(A, loop1->header()); | 544 schedule.AddSuccessorForTesting(A, loop1->header()); |
| 583 schedule.AddSuccessorForTesting(loop1->last(), E); | 545 schedule.AddSuccessorForTesting(loop1->last(), E); |
| 584 | 546 |
| 585 for (int j = 0; j < size; j++) { | 547 for (int j = 0; j < size; j++) { |
| 586 BasicBlock* O = schedule.NewBasicBlock(); | 548 BasicBlock* O = schedule.NewBasicBlock(); |
| 587 schedule.AddSuccessorForTesting(loop1->nodes[j], O); | 549 schedule.AddSuccessorForTesting(loop1->nodes[j], O); |
| 588 schedule.AddSuccessorForTesting(O, E); | 550 schedule.AddSuccessorForTesting(O, E); |
| 589 } | 551 } |
| 590 | 552 |
| 591 BasicBlockVector* order = | 553 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(zone(), &schedule); |
| 592 Scheduler::ComputeSpecialRPO(scope.main_zone(), &schedule); | |
| 593 CheckRPONumbers(order, schedule.BasicBlockCount(), true); | 554 CheckRPONumbers(order, schedule.BasicBlockCount(), true); |
| 594 loop1->Check(order); | 555 loop1->Check(order); |
| 595 } | 556 } |
| 596 } | 557 } |
| 597 | 558 |
| 598 | 559 |
| 599 TEST(RPOLoopOutloops1) { | 560 TEST_F(SchedulerTest, RPOLoopOutloops1) { |
| 600 HandleAndZoneScope scope; | |
| 601 | |
| 602 int size = 8; | 561 int size = 8; |
| 603 for (int i = 0; i < size; i++) { | 562 for (int i = 0; i < size; i++) { |
| 604 Schedule schedule(scope.main_zone()); | 563 Schedule schedule(zone()); |
| 605 BasicBlock* A = schedule.start(); | 564 BasicBlock* A = schedule.start(); |
| 606 BasicBlock* E = schedule.end(); | 565 BasicBlock* E = schedule.end(); |
| 607 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, size)); | 566 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, size)); |
| 608 schedule.AddSuccessorForTesting(A, loop1->header()); | 567 schedule.AddSuccessorForTesting(A, loop1->header()); |
| 609 schedule.AddSuccessorForTesting(loop1->last(), E); | 568 schedule.AddSuccessorForTesting(loop1->last(), E); |
| 610 | 569 |
| 611 TestLoop** loopN = new TestLoop* [size]; | 570 TestLoop** loopN = new TestLoop* [size]; |
| 612 for (int j = 0; j < size; j++) { | 571 for (int j = 0; j < size; j++) { |
| 613 loopN[j] = CreateLoop(&schedule, 2); | 572 loopN[j] = CreateLoop(&schedule, 2); |
| 614 schedule.AddSuccessorForTesting(loop1->nodes[j], loopN[j]->header()); | 573 schedule.AddSuccessorForTesting(loop1->nodes[j], loopN[j]->header()); |
| 615 schedule.AddSuccessorForTesting(loopN[j]->last(), E); | 574 schedule.AddSuccessorForTesting(loopN[j]->last(), E); |
| 616 } | 575 } |
| 617 | 576 |
| 618 BasicBlockVector* order = | 577 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(zone(), &schedule); |
| 619 Scheduler::ComputeSpecialRPO(scope.main_zone(), &schedule); | |
| 620 CheckRPONumbers(order, schedule.BasicBlockCount(), true); | 578 CheckRPONumbers(order, schedule.BasicBlockCount(), true); |
| 621 loop1->Check(order); | 579 loop1->Check(order); |
| 622 | 580 |
| 623 for (int j = 0; j < size; j++) { | 581 for (int j = 0; j < size; j++) { |
| 624 loopN[j]->Check(order); | 582 loopN[j]->Check(order); |
| 625 delete loopN[j]; | 583 delete loopN[j]; |
| 626 } | 584 } |
| 627 delete[] loopN; | 585 delete[] loopN; |
| 628 } | 586 } |
| 629 } | 587 } |
| 630 | 588 |
| 631 | 589 |
| 632 TEST(RPOLoopMultibackedge) { | 590 TEST_F(SchedulerTest, RPOLoopMultibackedge) { |
| 633 HandleAndZoneScope scope; | 591 Schedule schedule(zone()); |
| 634 Schedule schedule(scope.main_zone()); | |
| 635 | 592 |
| 636 BasicBlock* A = schedule.start(); | 593 BasicBlock* A = schedule.start(); |
| 637 BasicBlock* B = schedule.NewBasicBlock(); | 594 BasicBlock* B = schedule.NewBasicBlock(); |
| 638 BasicBlock* C = schedule.NewBasicBlock(); | 595 BasicBlock* C = schedule.NewBasicBlock(); |
| 639 BasicBlock* D = schedule.NewBasicBlock(); | 596 BasicBlock* D = schedule.NewBasicBlock(); |
| 640 BasicBlock* E = schedule.NewBasicBlock(); | 597 BasicBlock* E = schedule.NewBasicBlock(); |
| 641 | 598 |
| 642 schedule.AddSuccessorForTesting(A, B); | 599 schedule.AddSuccessorForTesting(A, B); |
| 643 schedule.AddSuccessorForTesting(B, C); | 600 schedule.AddSuccessorForTesting(B, C); |
| 644 schedule.AddSuccessorForTesting(B, D); | 601 schedule.AddSuccessorForTesting(B, D); |
| 645 schedule.AddSuccessorForTesting(B, E); | 602 schedule.AddSuccessorForTesting(B, E); |
| 646 schedule.AddSuccessorForTesting(C, B); | 603 schedule.AddSuccessorForTesting(C, B); |
| 647 schedule.AddSuccessorForTesting(D, B); | 604 schedule.AddSuccessorForTesting(D, B); |
| 648 schedule.AddSuccessorForTesting(E, B); | 605 schedule.AddSuccessorForTesting(E, B); |
| 649 | 606 |
| 650 BasicBlockVector* order = | 607 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(zone(), &schedule); |
| 651 Scheduler::ComputeSpecialRPO(scope.main_zone(), &schedule); | |
| 652 CheckRPONumbers(order, 5, true); | 608 CheckRPONumbers(order, 5, true); |
| 653 | 609 |
| 654 BasicBlock* loop1[] = {B, C, D, E}; | 610 BasicBlock* loop1[] = {B, C, D, E}; |
| 655 CheckLoop(order, loop1, 4); | 611 CheckLoop(order, loop1, 4); |
| 656 } | 612 } |
| 657 | 613 |
| 658 | 614 |
| 659 TEST(BuildScheduleEmpty) { | 615 TEST_F(SchedulerTest, BuildScheduleEmpty) { |
| 660 HandleAndZoneScope scope; | 616 Graph graph(zone()); |
| 661 Graph graph(scope.main_zone()); | 617 CommonOperatorBuilder builder(zone()); |
| 662 CommonOperatorBuilder builder(scope.main_zone()); | |
| 663 graph.SetStart(graph.NewNode(builder.Start(0))); | 618 graph.SetStart(graph.NewNode(builder.Start(0))); |
| 664 graph.SetEnd(graph.NewNode(builder.End(), graph.start())); | 619 graph.SetEnd(graph.NewNode(builder.End(), graph.start())); |
| 665 | 620 |
| 666 USE(Scheduler::ComputeSchedule(scope.main_zone(), &graph)); | 621 USE(Scheduler::ComputeSchedule(zone(), &graph)); |
| 667 } | 622 } |
| 668 | 623 |
| 669 | 624 |
| 670 TEST(BuildScheduleOneParameter) { | 625 TEST_F(SchedulerTest, BuildScheduleOneParameter) { |
| 671 HandleAndZoneScope scope; | 626 Graph graph(zone()); |
| 672 Graph graph(scope.main_zone()); | 627 CommonOperatorBuilder builder(zone()); |
| 673 CommonOperatorBuilder builder(scope.main_zone()); | |
| 674 graph.SetStart(graph.NewNode(builder.Start(0))); | 628 graph.SetStart(graph.NewNode(builder.Start(0))); |
| 675 | 629 |
| 676 Node* p1 = graph.NewNode(builder.Parameter(0), graph.start()); | 630 Node* p1 = graph.NewNode(builder.Parameter(0), graph.start()); |
| 677 Node* ret = graph.NewNode(builder.Return(), p1, graph.start(), graph.start()); | 631 Node* ret = graph.NewNode(builder.Return(), p1, graph.start(), graph.start()); |
| 678 | 632 |
| 679 graph.SetEnd(graph.NewNode(builder.End(), ret)); | 633 graph.SetEnd(graph.NewNode(builder.End(), ret)); |
| 680 | 634 |
| 681 USE(Scheduler::ComputeSchedule(scope.main_zone(), &graph)); | 635 USE(Scheduler::ComputeSchedule(zone(), &graph)); |
| 682 } | 636 } |
| 683 | 637 |
| 684 | 638 |
| 685 TEST(BuildScheduleIfSplit) { | 639 TEST_F(SchedulerTest, BuildScheduleIfSplit) { |
| 686 HandleAndZoneScope scope; | 640 Graph graph(zone()); |
| 687 Graph graph(scope.main_zone()); | 641 CommonOperatorBuilder builder(zone()); |
| 688 CommonOperatorBuilder builder(scope.main_zone()); | 642 JSOperatorBuilder js_builder(zone()); |
| 689 JSOperatorBuilder js_builder(scope.main_zone()); | |
| 690 graph.SetStart(graph.NewNode(builder.Start(3))); | 643 graph.SetStart(graph.NewNode(builder.Start(3))); |
| 691 | 644 |
| 692 Node* p1 = graph.NewNode(builder.Parameter(0), graph.start()); | 645 Node* p1 = graph.NewNode(builder.Parameter(0), graph.start()); |
| 693 Node* p2 = graph.NewNode(builder.Parameter(1), graph.start()); | 646 Node* p2 = graph.NewNode(builder.Parameter(1), graph.start()); |
| 694 Node* p3 = graph.NewNode(builder.Parameter(2), graph.start()); | 647 Node* p3 = graph.NewNode(builder.Parameter(2), graph.start()); |
| 695 Node* p4 = graph.NewNode(builder.Parameter(3), graph.start()); | 648 Node* p4 = graph.NewNode(builder.Parameter(3), graph.start()); |
| 696 Node* p5 = graph.NewNode(builder.Parameter(4), graph.start()); | 649 Node* p5 = graph.NewNode(builder.Parameter(4), graph.start()); |
| 697 Node* cmp = graph.NewNode(js_builder.LessThanOrEqual(), p1, p2, p3, | 650 Node* cmp = graph.NewNode(js_builder.LessThanOrEqual(), p1, p2, p3, |
| 698 graph.start(), graph.start()); | 651 graph.start(), graph.start()); |
| 699 Node* branch = graph.NewNode(builder.Branch(), cmp, graph.start()); | 652 Node* branch = graph.NewNode(builder.Branch(), cmp, graph.start()); |
| 700 Node* true_branch = graph.NewNode(builder.IfTrue(), branch); | 653 Node* true_branch = graph.NewNode(builder.IfTrue(), branch); |
| 701 Node* false_branch = graph.NewNode(builder.IfFalse(), branch); | 654 Node* false_branch = graph.NewNode(builder.IfFalse(), branch); |
| 702 | 655 |
| 703 Node* ret1 = graph.NewNode(builder.Return(), p4, graph.start(), true_branch); | 656 Node* ret1 = graph.NewNode(builder.Return(), p4, graph.start(), true_branch); |
| 704 Node* ret2 = graph.NewNode(builder.Return(), p5, graph.start(), false_branch); | 657 Node* ret2 = graph.NewNode(builder.Return(), p5, graph.start(), false_branch); |
| 705 Node* merge = graph.NewNode(builder.Merge(2), ret1, ret2); | 658 Node* merge = graph.NewNode(builder.Merge(2), ret1, ret2); |
| 706 graph.SetEnd(graph.NewNode(builder.End(), merge)); | 659 graph.SetEnd(graph.NewNode(builder.End(), merge)); |
| 707 | 660 |
| 708 ComputeAndVerifySchedule(13, &graph); | 661 ComputeAndVerifySchedule(13, &graph); |
| 709 } | 662 } |
| 710 | 663 |
| 711 | 664 |
| 712 TEST(BuildScheduleIfSplitWithEffects) { | 665 TEST_F(SchedulerTest, BuildScheduleIfSplitWithEffects) { |
| 713 HandleAndZoneScope scope; | 666 Graph graph(zone()); |
| 714 Isolate* isolate = scope.main_isolate(); | 667 CommonOperatorBuilder common_builder(zone()); |
| 715 Graph graph(scope.main_zone()); | 668 JSOperatorBuilder js_builder(zone()); |
| 716 CommonOperatorBuilder common_builder(scope.main_zone()); | |
| 717 JSOperatorBuilder js_builder(scope.main_zone()); | |
| 718 const Operator* op; | 669 const Operator* op; |
| 719 | 670 |
| 720 Handle<HeapObject> object = | 671 Handle<HeapObject> object = |
|
Michael Starzinger
2015/01/22 16:10:36
I am not an expert on how the unit-tests should be
danno
2015/01/23 16:51:36
Done.
| |
| 721 Handle<HeapObject>(isolate->heap()->undefined_value(), isolate); | 672 Handle<HeapObject>(isolate()->heap()->undefined_value(), isolate()); |
| 722 Unique<HeapObject> unique_constant = | 673 Unique<HeapObject> unique_constant = |
| 723 Unique<HeapObject>::CreateUninitialized(object); | 674 Unique<HeapObject>::CreateUninitialized(object); |
| 724 | 675 |
| 725 // Manually transcripted code for: | 676 // Manually transcripted code for: |
| 726 // function turbo_fan_test(a, b, c, y) { | 677 // function turbo_fan_test(a, b, c, y) { |
| 727 // if (a < b) { | 678 // if (a < b) { |
| 728 // return a + b - c * c - a + y; | 679 // return a + b - c * c - a + y; |
| 729 // } else { | 680 // } else { |
| 730 // return c * c - a; | 681 // return c * c - a; |
| 731 // } | 682 // } |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 848 n22->ReplaceInput(1, n21); | 799 n22->ReplaceInput(1, n21); |
| 849 n23->ReplaceInput(0, n22); | 800 n23->ReplaceInput(0, n22); |
| 850 | 801 |
| 851 graph.SetStart(n0); | 802 graph.SetStart(n0); |
| 852 graph.SetEnd(n23); | 803 graph.SetEnd(n23); |
| 853 | 804 |
| 854 ComputeAndVerifySchedule(20, &graph); | 805 ComputeAndVerifySchedule(20, &graph); |
| 855 } | 806 } |
| 856 | 807 |
| 857 | 808 |
| 858 TEST(BuildScheduleSimpleLoop) { | 809 TEST_F(SchedulerTest, BuildScheduleSimpleLoop) { |
| 859 HandleAndZoneScope scope; | 810 Graph graph(zone()); |
| 860 Isolate* isolate = scope.main_isolate(); | 811 CommonOperatorBuilder common_builder(zone()); |
| 861 Graph graph(scope.main_zone()); | 812 JSOperatorBuilder js_builder(zone()); |
| 862 CommonOperatorBuilder common_builder(scope.main_zone()); | |
| 863 JSOperatorBuilder js_builder(scope.main_zone()); | |
| 864 const Operator* op; | 813 const Operator* op; |
| 865 | 814 |
| 866 Handle<HeapObject> object = | 815 Handle<HeapObject> object = |
| 867 Handle<HeapObject>(isolate->heap()->undefined_value(), isolate); | 816 Handle<HeapObject>(isolate()->heap()->undefined_value(), isolate()); |
| 868 Unique<HeapObject> unique_constant = | 817 Unique<HeapObject> unique_constant = |
| 869 Unique<HeapObject>::CreateUninitialized(object); | 818 Unique<HeapObject>::CreateUninitialized(object); |
| 870 | 819 |
| 871 // Manually transcripted code for: | 820 // Manually transcripted code for: |
| 872 // function turbo_fan_test(a, b) { | 821 // function turbo_fan_test(a, b) { |
| 873 // while (a < b) { | 822 // while (a < b) { |
| 874 // a++; | 823 // a++; |
| 875 // } | 824 // } |
| 876 // return a; | 825 // return a; |
| 877 // } | 826 // } |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 961 n19->ReplaceInput(2, n15); | 910 n19->ReplaceInput(2, n15); |
| 962 n20->ReplaceInput(0, n19); | 911 n20->ReplaceInput(0, n19); |
| 963 | 912 |
| 964 graph.SetStart(n0); | 913 graph.SetStart(n0); |
| 965 graph.SetEnd(n20); | 914 graph.SetEnd(n20); |
| 966 | 915 |
| 967 ComputeAndVerifySchedule(19, &graph); | 916 ComputeAndVerifySchedule(19, &graph); |
| 968 } | 917 } |
| 969 | 918 |
| 970 | 919 |
| 971 TEST(BuildScheduleComplexLoops) { | 920 TEST_F(SchedulerTest, BuildScheduleComplexLoops) { |
| 972 HandleAndZoneScope scope; | 921 Graph graph(zone()); |
| 973 Isolate* isolate = scope.main_isolate(); | 922 CommonOperatorBuilder common_builder(zone()); |
| 974 Graph graph(scope.main_zone()); | 923 JSOperatorBuilder js_builder(zone()); |
| 975 CommonOperatorBuilder common_builder(scope.main_zone()); | |
| 976 JSOperatorBuilder js_builder(scope.main_zone()); | |
| 977 const Operator* op; | 924 const Operator* op; |
| 978 | 925 |
| 979 Handle<HeapObject> object = | 926 Handle<HeapObject> object = |
| 980 Handle<HeapObject>(isolate->heap()->undefined_value(), isolate); | 927 Handle<HeapObject>(isolate()->heap()->undefined_value(), isolate()); |
| 981 Unique<HeapObject> unique_constant = | 928 Unique<HeapObject> unique_constant = |
| 982 Unique<HeapObject>::CreateUninitialized(object); | 929 Unique<HeapObject>::CreateUninitialized(object); |
| 983 | 930 |
| 984 // Manually transcripted code for: | 931 // Manually transcripted code for: |
| 985 // function turbo_fan_test(a, b, c) { | 932 // function turbo_fan_test(a, b, c) { |
| 986 // while (a < b) { | 933 // while (a < b) { |
| 987 // a++; | 934 // a++; |
| 988 // while (c < b) { | 935 // while (c < b) { |
| 989 // c++; | 936 // c++; |
| 990 // } | 937 // } |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1209 n45->ReplaceInput(2, n42); | 1156 n45->ReplaceInput(2, n42); |
| 1210 n46->ReplaceInput(0, n45); | 1157 n46->ReplaceInput(0, n45); |
| 1211 | 1158 |
| 1212 graph.SetStart(n0); | 1159 graph.SetStart(n0); |
| 1213 graph.SetEnd(n46); | 1160 graph.SetEnd(n46); |
| 1214 | 1161 |
| 1215 ComputeAndVerifySchedule(46, &graph); | 1162 ComputeAndVerifySchedule(46, &graph); |
| 1216 } | 1163 } |
| 1217 | 1164 |
| 1218 | 1165 |
| 1219 TEST(BuildScheduleBreakAndContinue) { | 1166 TEST_F(SchedulerTest, BuildScheduleBreakAndContinue) { |
| 1220 HandleAndZoneScope scope; | 1167 Graph graph(zone()); |
| 1221 Isolate* isolate = scope.main_isolate(); | 1168 CommonOperatorBuilder common_builder(zone()); |
| 1222 Graph graph(scope.main_zone()); | 1169 JSOperatorBuilder js_builder(zone()); |
| 1223 CommonOperatorBuilder common_builder(scope.main_zone()); | |
| 1224 JSOperatorBuilder js_builder(scope.main_zone()); | |
| 1225 const Operator* op; | 1170 const Operator* op; |
| 1226 | 1171 |
| 1227 Handle<HeapObject> object = | 1172 Handle<HeapObject> object = |
| 1228 Handle<HeapObject>(isolate->heap()->undefined_value(), isolate); | 1173 Handle<HeapObject>(isolate()->heap()->undefined_value(), isolate()); |
| 1229 Unique<HeapObject> unique_constant = | 1174 Unique<HeapObject> unique_constant = |
| 1230 Unique<HeapObject>::CreateUninitialized(object); | 1175 Unique<HeapObject>::CreateUninitialized(object); |
| 1231 | 1176 |
| 1232 // Manually transcripted code for: | 1177 // Manually transcripted code for: |
| 1233 // function turbo_fan_test(a, b, c) { | 1178 // function turbo_fan_test(a, b, c) { |
| 1234 // var d = 0; | 1179 // var d = 0; |
| 1235 // while (a < b) { | 1180 // while (a < b) { |
| 1236 // a++; | 1181 // a++; |
| 1237 // while (c < b) { | 1182 // while (c < b) { |
| 1238 // c++; | 1183 // c++; |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1539 n57->ReplaceInput(2, n19); | 1484 n57->ReplaceInput(2, n19); |
| 1540 n58->ReplaceInput(0, n57); | 1485 n58->ReplaceInput(0, n57); |
| 1541 | 1486 |
| 1542 graph.SetStart(n0); | 1487 graph.SetStart(n0); |
| 1543 graph.SetEnd(n58); | 1488 graph.SetEnd(n58); |
| 1544 | 1489 |
| 1545 ComputeAndVerifySchedule(62, &graph); | 1490 ComputeAndVerifySchedule(62, &graph); |
| 1546 } | 1491 } |
| 1547 | 1492 |
| 1548 | 1493 |
| 1549 TEST(BuildScheduleSimpleLoopWithCodeMotion) { | 1494 TEST_F(SchedulerTest, BuildScheduleSimpleLoopWithCodeMotion) { |
| 1550 HandleAndZoneScope scope; | 1495 Graph graph(zone()); |
| 1551 Isolate* isolate = scope.main_isolate(); | 1496 CommonOperatorBuilder common_builder(zone()); |
| 1552 Graph graph(scope.main_zone()); | 1497 JSOperatorBuilder js_builder(zone()); |
| 1553 CommonOperatorBuilder common_builder(scope.main_zone()); | |
| 1554 JSOperatorBuilder js_builder(scope.main_zone()); | |
| 1555 const Operator* op; | 1498 const Operator* op; |
| 1556 | 1499 |
| 1557 Handle<HeapObject> object = | 1500 Handle<HeapObject> object = |
| 1558 Handle<HeapObject>(isolate->heap()->undefined_value(), isolate); | 1501 Handle<HeapObject>(isolate()->heap()->undefined_value(), isolate()); |
| 1559 Unique<HeapObject> unique_constant = | 1502 Unique<HeapObject> unique_constant = |
| 1560 Unique<HeapObject>::CreateUninitialized(object); | 1503 Unique<HeapObject>::CreateUninitialized(object); |
| 1561 | 1504 |
| 1562 // Manually transcripted code for: | 1505 // Manually transcripted code for: |
| 1563 // function turbo_fan_test(a, b, c) { | 1506 // function turbo_fan_test(a, b, c) { |
| 1564 // while (a < b) { | 1507 // while (a < b) { |
| 1565 // a += b + c; | 1508 // a += b + c; |
| 1566 // } | 1509 // } |
| 1567 // return a; | 1510 // return a; |
| 1568 // } | 1511 // } |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1681 Node* fv = graph->NewNode(common->Int32Constant(7)); | 1624 Node* fv = graph->NewNode(common->Int32Constant(7)); |
| 1682 Node* br = graph->NewNode(common->Branch(), cond, graph->start()); | 1625 Node* br = graph->NewNode(common->Branch(), cond, graph->start()); |
| 1683 Node* t = graph->NewNode(common->IfTrue(), br); | 1626 Node* t = graph->NewNode(common->IfTrue(), br); |
| 1684 Node* f = graph->NewNode(common->IfFalse(), br); | 1627 Node* f = graph->NewNode(common->IfFalse(), br); |
| 1685 Node* m = graph->NewNode(common->Merge(2), t, f); | 1628 Node* m = graph->NewNode(common->Merge(2), t, f); |
| 1686 Node* phi = graph->NewNode(common->Phi(kMachAnyTagged, 2), tv, fv, m); | 1629 Node* phi = graph->NewNode(common->Phi(kMachAnyTagged, 2), tv, fv, m); |
| 1687 return phi; | 1630 return phi; |
| 1688 } | 1631 } |
| 1689 | 1632 |
| 1690 | 1633 |
| 1691 TEST(FloatingDiamond1) { | 1634 TEST_F(SchedulerTest, FloatingDiamond1) { |
| 1692 HandleAndZoneScope scope; | 1635 Graph graph(zone()); |
| 1693 Graph graph(scope.main_zone()); | 1636 CommonOperatorBuilder common(zone()); |
| 1694 CommonOperatorBuilder common(scope.main_zone()); | |
| 1695 | 1637 |
| 1696 Node* start = graph.NewNode(common.Start(1)); | 1638 Node* start = graph.NewNode(common.Start(1)); |
| 1697 graph.SetStart(start); | 1639 graph.SetStart(start); |
| 1698 | 1640 |
| 1699 Node* p0 = graph.NewNode(common.Parameter(0), start); | 1641 Node* p0 = graph.NewNode(common.Parameter(0), start); |
| 1700 Node* d1 = CreateDiamond(&graph, &common, p0); | 1642 Node* d1 = CreateDiamond(&graph, &common, p0); |
| 1701 Node* ret = graph.NewNode(common.Return(), d1, start, start); | 1643 Node* ret = graph.NewNode(common.Return(), d1, start, start); |
| 1702 Node* end = graph.NewNode(common.End(), ret, start); | 1644 Node* end = graph.NewNode(common.End(), ret, start); |
| 1703 | 1645 |
| 1704 graph.SetEnd(end); | 1646 graph.SetEnd(end); |
| 1705 | 1647 |
| 1706 ComputeAndVerifySchedule(13, &graph); | 1648 ComputeAndVerifySchedule(13, &graph); |
| 1707 } | 1649 } |
| 1708 | 1650 |
| 1709 | 1651 |
| 1710 TEST(FloatingDiamond2) { | 1652 TEST_F(SchedulerTest, FloatingDiamond2) { |
| 1711 HandleAndZoneScope scope; | 1653 Graph graph(zone()); |
| 1712 Graph graph(scope.main_zone()); | 1654 CommonOperatorBuilder common(zone()); |
| 1713 CommonOperatorBuilder common(scope.main_zone()); | |
| 1714 | 1655 |
| 1715 Node* start = graph.NewNode(common.Start(2)); | 1656 Node* start = graph.NewNode(common.Start(2)); |
| 1716 graph.SetStart(start); | 1657 graph.SetStart(start); |
| 1717 | 1658 |
| 1718 Node* p0 = graph.NewNode(common.Parameter(0), start); | 1659 Node* p0 = graph.NewNode(common.Parameter(0), start); |
| 1719 Node* p1 = graph.NewNode(common.Parameter(1), start); | 1660 Node* p1 = graph.NewNode(common.Parameter(1), start); |
| 1720 Node* d1 = CreateDiamond(&graph, &common, p0); | 1661 Node* d1 = CreateDiamond(&graph, &common, p0); |
| 1721 Node* d2 = CreateDiamond(&graph, &common, p1); | 1662 Node* d2 = CreateDiamond(&graph, &common, p1); |
| 1722 Node* add = graph.NewNode(&kIntAdd, d1, d2); | 1663 Node* add = graph.NewNode(&kIntAdd, d1, d2); |
| 1723 Node* ret = graph.NewNode(common.Return(), add, start, start); | 1664 Node* ret = graph.NewNode(common.Return(), add, start, start); |
| 1724 Node* end = graph.NewNode(common.End(), ret, start); | 1665 Node* end = graph.NewNode(common.End(), ret, start); |
| 1725 | 1666 |
| 1726 graph.SetEnd(end); | 1667 graph.SetEnd(end); |
| 1727 | 1668 |
| 1728 ComputeAndVerifySchedule(24, &graph); | 1669 ComputeAndVerifySchedule(24, &graph); |
| 1729 } | 1670 } |
| 1730 | 1671 |
| 1731 | 1672 |
| 1732 TEST(FloatingDiamond3) { | 1673 TEST_F(SchedulerTest, FloatingDiamond3) { |
| 1733 HandleAndZoneScope scope; | 1674 Graph graph(zone()); |
| 1734 Graph graph(scope.main_zone()); | 1675 CommonOperatorBuilder common(zone()); |
| 1735 CommonOperatorBuilder common(scope.main_zone()); | |
| 1736 | 1676 |
| 1737 Node* start = graph.NewNode(common.Start(2)); | 1677 Node* start = graph.NewNode(common.Start(2)); |
| 1738 graph.SetStart(start); | 1678 graph.SetStart(start); |
| 1739 | 1679 |
| 1740 Node* p0 = graph.NewNode(common.Parameter(0), start); | 1680 Node* p0 = graph.NewNode(common.Parameter(0), start); |
| 1741 Node* p1 = graph.NewNode(common.Parameter(1), start); | 1681 Node* p1 = graph.NewNode(common.Parameter(1), start); |
| 1742 Node* d1 = CreateDiamond(&graph, &common, p0); | 1682 Node* d1 = CreateDiamond(&graph, &common, p0); |
| 1743 Node* d2 = CreateDiamond(&graph, &common, p1); | 1683 Node* d2 = CreateDiamond(&graph, &common, p1); |
| 1744 Node* add = graph.NewNode(&kIntAdd, d1, d2); | 1684 Node* add = graph.NewNode(&kIntAdd, d1, d2); |
| 1745 Node* d3 = CreateDiamond(&graph, &common, add); | 1685 Node* d3 = CreateDiamond(&graph, &common, add); |
| 1746 Node* ret = graph.NewNode(common.Return(), d3, start, start); | 1686 Node* ret = graph.NewNode(common.Return(), d3, start, start); |
| 1747 Node* end = graph.NewNode(common.End(), ret, start); | 1687 Node* end = graph.NewNode(common.End(), ret, start); |
| 1748 | 1688 |
| 1749 graph.SetEnd(end); | 1689 graph.SetEnd(end); |
| 1750 | 1690 |
| 1751 ComputeAndVerifySchedule(33, &graph); | 1691 ComputeAndVerifySchedule(33, &graph); |
| 1752 } | 1692 } |
| 1753 | 1693 |
| 1754 | 1694 |
| 1755 TEST(NestedFloatingDiamonds) { | 1695 TEST_F(SchedulerTest, NestedFloatingDiamonds) { |
| 1756 HandleAndZoneScope scope; | 1696 Graph graph(zone()); |
| 1757 Graph graph(scope.main_zone()); | 1697 CommonOperatorBuilder common(zone()); |
| 1758 CommonOperatorBuilder common(scope.main_zone()); | 1698 SimplifiedOperatorBuilder simplified(zone()); |
| 1759 SimplifiedOperatorBuilder simplified(scope.main_zone()); | |
| 1760 | 1699 |
| 1761 Node* start = graph.NewNode(common.Start(2)); | 1700 Node* start = graph.NewNode(common.Start(2)); |
| 1762 graph.SetStart(start); | 1701 graph.SetStart(start); |
| 1763 | 1702 |
| 1764 Node* p0 = graph.NewNode(common.Parameter(0), start); | 1703 Node* p0 = graph.NewNode(common.Parameter(0), start); |
| 1765 | 1704 |
| 1766 Node* fv = graph.NewNode(common.Int32Constant(7)); | 1705 Node* fv = graph.NewNode(common.Int32Constant(7)); |
| 1767 Node* br = graph.NewNode(common.Branch(), p0, graph.start()); | 1706 Node* br = graph.NewNode(common.Branch(), p0, graph.start()); |
| 1768 Node* t = graph.NewNode(common.IfTrue(), br); | 1707 Node* t = graph.NewNode(common.IfTrue(), br); |
| 1769 Node* f = graph.NewNode(common.IfFalse(), br); | 1708 Node* f = graph.NewNode(common.IfFalse(), br); |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 1786 | 1725 |
| 1787 Node* ret = graph.NewNode(common.Return(), phi, ephi1, start); | 1726 Node* ret = graph.NewNode(common.Return(), phi, ephi1, start); |
| 1788 Node* end = graph.NewNode(common.End(), ret, start); | 1727 Node* end = graph.NewNode(common.End(), ret, start); |
| 1789 | 1728 |
| 1790 graph.SetEnd(end); | 1729 graph.SetEnd(end); |
| 1791 | 1730 |
| 1792 ComputeAndVerifySchedule(23, &graph); | 1731 ComputeAndVerifySchedule(23, &graph); |
| 1793 } | 1732 } |
| 1794 | 1733 |
| 1795 | 1734 |
| 1796 TEST(NestedFloatingDiamondWithChain) { | 1735 TEST_F(SchedulerTest, NestedFloatingDiamondWithChain) { |
| 1797 HandleAndZoneScope scope; | 1736 Graph graph(zone()); |
| 1798 Graph graph(scope.main_zone()); | 1737 CommonOperatorBuilder common(zone()); |
| 1799 CommonOperatorBuilder common(scope.main_zone()); | |
| 1800 | 1738 |
| 1801 Node* start = graph.NewNode(common.Start(2)); | 1739 Node* start = graph.NewNode(common.Start(2)); |
| 1802 graph.SetStart(start); | 1740 graph.SetStart(start); |
| 1803 | 1741 |
| 1804 Node* p0 = graph.NewNode(common.Parameter(0), start); | 1742 Node* p0 = graph.NewNode(common.Parameter(0), start); |
| 1805 Node* p1 = graph.NewNode(common.Parameter(1), start); | 1743 Node* p1 = graph.NewNode(common.Parameter(1), start); |
| 1806 Node* c = graph.NewNode(common.Int32Constant(7)); | 1744 Node* c = graph.NewNode(common.Int32Constant(7)); |
| 1807 | 1745 |
| 1808 Node* brA1 = graph.NewNode(common.Branch(), p0, graph.start()); | 1746 Node* brA1 = graph.NewNode(common.Branch(), p0, graph.start()); |
| 1809 Node* tA1 = graph.NewNode(common.IfTrue(), brA1); | 1747 Node* tA1 = graph.NewNode(common.IfTrue(), brA1); |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 1832 Node* add = graph.NewNode(&kIntAdd, phiA2, phiB2); | 1770 Node* add = graph.NewNode(&kIntAdd, phiA2, phiB2); |
| 1833 Node* ret = graph.NewNode(common.Return(), add, start, start); | 1771 Node* ret = graph.NewNode(common.Return(), add, start, start); |
| 1834 Node* end = graph.NewNode(common.End(), ret, start); | 1772 Node* end = graph.NewNode(common.End(), ret, start); |
| 1835 | 1773 |
| 1836 graph.SetEnd(end); | 1774 graph.SetEnd(end); |
| 1837 | 1775 |
| 1838 ComputeAndVerifySchedule(35, &graph); | 1776 ComputeAndVerifySchedule(35, &graph); |
| 1839 } | 1777 } |
| 1840 | 1778 |
| 1841 | 1779 |
| 1842 TEST(NestedFloatingDiamondWithLoop) { | 1780 TEST_F(SchedulerTest, NestedFloatingDiamondWithLoop) { |
| 1843 HandleAndZoneScope scope; | 1781 Graph graph(zone()); |
| 1844 Graph graph(scope.main_zone()); | 1782 CommonOperatorBuilder common(zone()); |
| 1845 CommonOperatorBuilder common(scope.main_zone()); | |
| 1846 | 1783 |
| 1847 Node* start = graph.NewNode(common.Start(2)); | 1784 Node* start = graph.NewNode(common.Start(2)); |
| 1848 graph.SetStart(start); | 1785 graph.SetStart(start); |
| 1849 | 1786 |
| 1850 Node* p0 = graph.NewNode(common.Parameter(0), start); | 1787 Node* p0 = graph.NewNode(common.Parameter(0), start); |
| 1851 | 1788 |
| 1852 Node* fv = graph.NewNode(common.Int32Constant(7)); | 1789 Node* fv = graph.NewNode(common.Int32Constant(7)); |
| 1853 Node* br = graph.NewNode(common.Branch(), p0, graph.start()); | 1790 Node* br = graph.NewNode(common.Branch(), p0, graph.start()); |
| 1854 Node* t = graph.NewNode(common.IfTrue(), br); | 1791 Node* t = graph.NewNode(common.IfTrue(), br); |
| 1855 Node* f = graph.NewNode(common.IfFalse(), br); | 1792 Node* f = graph.NewNode(common.IfFalse(), br); |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 1870 | 1807 |
| 1871 Node* ret = graph.NewNode(common.Return(), phi, start, start); | 1808 Node* ret = graph.NewNode(common.Return(), phi, start, start); |
| 1872 Node* end = graph.NewNode(common.End(), ret, start); | 1809 Node* end = graph.NewNode(common.End(), ret, start); |
| 1873 | 1810 |
| 1874 graph.SetEnd(end); | 1811 graph.SetEnd(end); |
| 1875 | 1812 |
| 1876 ComputeAndVerifySchedule(20, &graph); | 1813 ComputeAndVerifySchedule(20, &graph); |
| 1877 } | 1814 } |
| 1878 | 1815 |
| 1879 | 1816 |
| 1880 TEST(LoopedFloatingDiamond1) { | 1817 TEST_F(SchedulerTest, LoopedFloatingDiamond1) { |
| 1881 HandleAndZoneScope scope; | 1818 Graph graph(zone()); |
| 1882 Graph graph(scope.main_zone()); | 1819 CommonOperatorBuilder common(zone()); |
| 1883 CommonOperatorBuilder common(scope.main_zone()); | |
| 1884 | 1820 |
| 1885 Node* start = graph.NewNode(common.Start(2)); | 1821 Node* start = graph.NewNode(common.Start(2)); |
| 1886 graph.SetStart(start); | 1822 graph.SetStart(start); |
| 1887 | 1823 |
| 1888 Node* p0 = graph.NewNode(common.Parameter(0), start); | 1824 Node* p0 = graph.NewNode(common.Parameter(0), start); |
| 1889 | 1825 |
| 1890 Node* c = graph.NewNode(common.Int32Constant(7)); | 1826 Node* c = graph.NewNode(common.Int32Constant(7)); |
| 1891 Node* loop = graph.NewNode(common.Loop(2), start, start); | 1827 Node* loop = graph.NewNode(common.Loop(2), start, start); |
| 1892 Node* ind = graph.NewNode(common.Phi(kMachAnyTagged, 2), p0, p0, loop); | 1828 Node* ind = graph.NewNode(common.Phi(kMachAnyTagged, 2), p0, p0, loop); |
| 1893 Node* add = graph.NewNode(&kIntAdd, ind, c); | 1829 Node* add = graph.NewNode(&kIntAdd, ind, c); |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 1907 | 1843 |
| 1908 Node* ret = graph.NewNode(common.Return(), ind, start, f); | 1844 Node* ret = graph.NewNode(common.Return(), ind, start, f); |
| 1909 Node* end = graph.NewNode(common.End(), ret, f); | 1845 Node* end = graph.NewNode(common.End(), ret, f); |
| 1910 | 1846 |
| 1911 graph.SetEnd(end); | 1847 graph.SetEnd(end); |
| 1912 | 1848 |
| 1913 ComputeAndVerifySchedule(20, &graph); | 1849 ComputeAndVerifySchedule(20, &graph); |
| 1914 } | 1850 } |
| 1915 | 1851 |
| 1916 | 1852 |
| 1917 TEST(LoopedFloatingDiamond2) { | 1853 TEST_F(SchedulerTest, LoopedFloatingDiamond2) { |
| 1918 HandleAndZoneScope scope; | 1854 Graph graph(zone()); |
| 1919 Graph graph(scope.main_zone()); | 1855 CommonOperatorBuilder common(zone()); |
| 1920 CommonOperatorBuilder common(scope.main_zone()); | |
| 1921 | 1856 |
| 1922 Node* start = graph.NewNode(common.Start(2)); | 1857 Node* start = graph.NewNode(common.Start(2)); |
| 1923 graph.SetStart(start); | 1858 graph.SetStart(start); |
| 1924 | 1859 |
| 1925 Node* p0 = graph.NewNode(common.Parameter(0), start); | 1860 Node* p0 = graph.NewNode(common.Parameter(0), start); |
| 1926 | 1861 |
| 1927 Node* c = graph.NewNode(common.Int32Constant(7)); | 1862 Node* c = graph.NewNode(common.Int32Constant(7)); |
| 1928 Node* loop = graph.NewNode(common.Loop(2), start, start); | 1863 Node* loop = graph.NewNode(common.Loop(2), start, start); |
| 1929 Node* ind = graph.NewNode(common.Phi(kMachAnyTagged, 2), p0, p0, loop); | 1864 Node* ind = graph.NewNode(common.Phi(kMachAnyTagged, 2), p0, p0, loop); |
| 1930 | 1865 |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 1945 | 1880 |
| 1946 Node* ret = graph.NewNode(common.Return(), ind, start, f); | 1881 Node* ret = graph.NewNode(common.Return(), ind, start, f); |
| 1947 Node* end = graph.NewNode(common.End(), ret, f); | 1882 Node* end = graph.NewNode(common.End(), ret, f); |
| 1948 | 1883 |
| 1949 graph.SetEnd(end); | 1884 graph.SetEnd(end); |
| 1950 | 1885 |
| 1951 ComputeAndVerifySchedule(20, &graph); | 1886 ComputeAndVerifySchedule(20, &graph); |
| 1952 } | 1887 } |
| 1953 | 1888 |
| 1954 | 1889 |
| 1955 TEST(LoopedFloatingDiamond3) { | 1890 TEST_F(SchedulerTest, LoopedFloatingDiamond3) { |
| 1956 HandleAndZoneScope scope; | 1891 Graph graph(zone()); |
| 1957 Graph graph(scope.main_zone()); | 1892 CommonOperatorBuilder common(zone()); |
| 1958 CommonOperatorBuilder common(scope.main_zone()); | |
| 1959 | 1893 |
| 1960 Node* start = graph.NewNode(common.Start(2)); | 1894 Node* start = graph.NewNode(common.Start(2)); |
| 1961 graph.SetStart(start); | 1895 graph.SetStart(start); |
| 1962 | 1896 |
| 1963 Node* p0 = graph.NewNode(common.Parameter(0), start); | 1897 Node* p0 = graph.NewNode(common.Parameter(0), start); |
| 1964 | 1898 |
| 1965 Node* c = graph.NewNode(common.Int32Constant(7)); | 1899 Node* c = graph.NewNode(common.Int32Constant(7)); |
| 1966 Node* loop = graph.NewNode(common.Loop(2), start, start); | 1900 Node* loop = graph.NewNode(common.Loop(2), start, start); |
| 1967 Node* ind = graph.NewNode(common.Phi(kMachAnyTagged, 2), p0, p0, loop); | 1901 Node* ind = graph.NewNode(common.Phi(kMachAnyTagged, 2), p0, p0, loop); |
| 1968 | 1902 |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 1995 | 1929 |
| 1996 Node* ret = graph.NewNode(common.Return(), ind, start, f); | 1930 Node* ret = graph.NewNode(common.Return(), ind, start, f); |
| 1997 Node* end = graph.NewNode(common.End(), ret, f); | 1931 Node* end = graph.NewNode(common.End(), ret, f); |
| 1998 | 1932 |
| 1999 graph.SetEnd(end); | 1933 graph.SetEnd(end); |
| 2000 | 1934 |
| 2001 ComputeAndVerifySchedule(28, &graph); | 1935 ComputeAndVerifySchedule(28, &graph); |
| 2002 } | 1936 } |
| 2003 | 1937 |
| 2004 | 1938 |
| 2005 TEST(PhisPushedDownToDifferentBranches) { | 1939 TEST_F(SchedulerTest, PhisPushedDownToDifferentBranches) { |
| 2006 HandleAndZoneScope scope; | 1940 Graph graph(zone()); |
| 2007 Graph graph(scope.main_zone()); | 1941 CommonOperatorBuilder common(zone()); |
| 2008 CommonOperatorBuilder common(scope.main_zone()); | |
| 2009 | 1942 |
| 2010 Node* start = graph.NewNode(common.Start(2)); | 1943 Node* start = graph.NewNode(common.Start(2)); |
| 2011 graph.SetStart(start); | 1944 graph.SetStart(start); |
| 2012 | 1945 |
| 2013 Node* p0 = graph.NewNode(common.Parameter(0), start); | 1946 Node* p0 = graph.NewNode(common.Parameter(0), start); |
| 2014 Node* p1 = graph.NewNode(common.Parameter(1), start); | 1947 Node* p1 = graph.NewNode(common.Parameter(1), start); |
| 2015 | 1948 |
| 2016 Node* v1 = graph.NewNode(common.Int32Constant(1)); | 1949 Node* v1 = graph.NewNode(common.Int32Constant(1)); |
| 2017 Node* v2 = graph.NewNode(common.Int32Constant(2)); | 1950 Node* v2 = graph.NewNode(common.Int32Constant(2)); |
| 2018 Node* v3 = graph.NewNode(common.Int32Constant(3)); | 1951 Node* v3 = graph.NewNode(common.Int32Constant(3)); |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 2032 | 1965 |
| 2033 Node* ret = graph.NewNode(common.Return(), phi3, start, start); | 1966 Node* ret = graph.NewNode(common.Return(), phi3, start, start); |
| 2034 Node* end = graph.NewNode(common.End(), ret, start); | 1967 Node* end = graph.NewNode(common.End(), ret, start); |
| 2035 | 1968 |
| 2036 graph.SetEnd(end); | 1969 graph.SetEnd(end); |
| 2037 | 1970 |
| 2038 ComputeAndVerifySchedule(24, &graph); | 1971 ComputeAndVerifySchedule(24, &graph); |
| 2039 } | 1972 } |
| 2040 | 1973 |
| 2041 | 1974 |
| 2042 TEST(BranchHintTrue) { | 1975 TEST_F(SchedulerTest, BranchHintTrue) { |
| 2043 HandleAndZoneScope scope; | 1976 Graph graph(zone()); |
| 2044 Graph graph(scope.main_zone()); | 1977 CommonOperatorBuilder common(zone()); |
| 2045 CommonOperatorBuilder common(scope.main_zone()); | |
| 2046 | 1978 |
| 2047 Node* start = graph.NewNode(common.Start(1)); | 1979 Node* start = graph.NewNode(common.Start(1)); |
| 2048 graph.SetStart(start); | 1980 graph.SetStart(start); |
| 2049 | 1981 |
| 2050 Node* p0 = graph.NewNode(common.Parameter(0), start); | 1982 Node* p0 = graph.NewNode(common.Parameter(0), start); |
| 2051 Node* tv = graph.NewNode(common.Int32Constant(6)); | 1983 Node* tv = graph.NewNode(common.Int32Constant(6)); |
| 2052 Node* fv = graph.NewNode(common.Int32Constant(7)); | 1984 Node* fv = graph.NewNode(common.Int32Constant(7)); |
| 2053 Node* br = graph.NewNode(common.Branch(BranchHint::kTrue), p0, start); | 1985 Node* br = graph.NewNode(common.Branch(BranchHint::kTrue), p0, start); |
| 2054 Node* t = graph.NewNode(common.IfTrue(), br); | 1986 Node* t = graph.NewNode(common.IfTrue(), br); |
| 2055 Node* f = graph.NewNode(common.IfFalse(), br); | 1987 Node* f = graph.NewNode(common.IfFalse(), br); |
| 2056 Node* m = graph.NewNode(common.Merge(2), t, f); | 1988 Node* m = graph.NewNode(common.Merge(2), t, f); |
| 2057 Node* phi = graph.NewNode(common.Phi(kMachAnyTagged, 2), tv, fv, m); | 1989 Node* phi = graph.NewNode(common.Phi(kMachAnyTagged, 2), tv, fv, m); |
| 2058 Node* ret = graph.NewNode(common.Return(), phi, start, start); | 1990 Node* ret = graph.NewNode(common.Return(), phi, start, start); |
| 2059 Node* end = graph.NewNode(common.End(), ret, start); | 1991 Node* end = graph.NewNode(common.End(), ret, start); |
| 2060 | 1992 |
| 2061 graph.SetEnd(end); | 1993 graph.SetEnd(end); |
| 2062 | 1994 |
| 2063 Schedule* schedule = ComputeAndVerifySchedule(13, &graph); | 1995 Schedule* schedule = ComputeAndVerifySchedule(13, &graph); |
| 2064 // Make sure the false block is marked as deferred. | 1996 // Make sure the false block is marked as deferred. |
| 2065 CHECK(!schedule->block(t)->deferred()); | 1997 CHECK(!schedule->block(t)->deferred()); |
| 2066 CHECK(schedule->block(f)->deferred()); | 1998 CHECK(schedule->block(f)->deferred()); |
| 2067 } | 1999 } |
| 2068 | 2000 |
| 2069 | 2001 |
| 2070 TEST(BranchHintFalse) { | 2002 TEST_F(SchedulerTest, BranchHintFalse) { |
| 2071 HandleAndZoneScope scope; | 2003 Graph graph(zone()); |
| 2072 Graph graph(scope.main_zone()); | 2004 CommonOperatorBuilder common(zone()); |
| 2073 CommonOperatorBuilder common(scope.main_zone()); | |
| 2074 | 2005 |
| 2075 Node* start = graph.NewNode(common.Start(1)); | 2006 Node* start = graph.NewNode(common.Start(1)); |
| 2076 graph.SetStart(start); | 2007 graph.SetStart(start); |
| 2077 | 2008 |
| 2078 Node* p0 = graph.NewNode(common.Parameter(0), start); | 2009 Node* p0 = graph.NewNode(common.Parameter(0), start); |
| 2079 Node* tv = graph.NewNode(common.Int32Constant(6)); | 2010 Node* tv = graph.NewNode(common.Int32Constant(6)); |
| 2080 Node* fv = graph.NewNode(common.Int32Constant(7)); | 2011 Node* fv = graph.NewNode(common.Int32Constant(7)); |
| 2081 Node* br = graph.NewNode(common.Branch(BranchHint::kFalse), p0, start); | 2012 Node* br = graph.NewNode(common.Branch(BranchHint::kFalse), p0, start); |
| 2082 Node* t = graph.NewNode(common.IfTrue(), br); | 2013 Node* t = graph.NewNode(common.IfTrue(), br); |
| 2083 Node* f = graph.NewNode(common.IfFalse(), br); | 2014 Node* f = graph.NewNode(common.IfFalse(), br); |
| 2084 Node* m = graph.NewNode(common.Merge(2), t, f); | 2015 Node* m = graph.NewNode(common.Merge(2), t, f); |
| 2085 Node* phi = graph.NewNode(common.Phi(kMachAnyTagged, 2), tv, fv, m); | 2016 Node* phi = graph.NewNode(common.Phi(kMachAnyTagged, 2), tv, fv, m); |
| 2086 Node* ret = graph.NewNode(common.Return(), phi, start, start); | 2017 Node* ret = graph.NewNode(common.Return(), phi, start, start); |
| 2087 Node* end = graph.NewNode(common.End(), ret, start); | 2018 Node* end = graph.NewNode(common.End(), ret, start); |
| 2088 | 2019 |
| 2089 graph.SetEnd(end); | 2020 graph.SetEnd(end); |
| 2090 | 2021 |
| 2091 Schedule* schedule = ComputeAndVerifySchedule(13, &graph); | 2022 Schedule* schedule = ComputeAndVerifySchedule(13, &graph); |
| 2092 // Make sure the true block is marked as deferred. | 2023 // Make sure the true block is marked as deferred. |
| 2093 CHECK(schedule->block(t)->deferred()); | 2024 CHECK(schedule->block(t)->deferred()); |
| 2094 CHECK(!schedule->block(f)->deferred()); | 2025 CHECK(!schedule->block(f)->deferred()); |
| 2095 } | 2026 } |
| 2096 | 2027 |
| 2097 | 2028 |
| 2098 TEST(ScheduleTerminate) { | 2029 TEST_F(SchedulerTest, ScheduleTerminate) { |
| 2099 HandleAndZoneScope scope; | 2030 Graph graph(zone()); |
| 2100 Graph graph(scope.main_zone()); | 2031 CommonOperatorBuilder common(zone()); |
| 2101 CommonOperatorBuilder common(scope.main_zone()); | |
| 2102 | 2032 |
| 2103 Node* start = graph.NewNode(common.Start(1)); | 2033 Node* start = graph.NewNode(common.Start(1)); |
| 2104 graph.SetStart(start); | 2034 graph.SetStart(start); |
| 2105 | 2035 |
| 2106 Node* loop = graph.NewNode(common.Loop(2), start, start); | 2036 Node* loop = graph.NewNode(common.Loop(2), start, start); |
| 2107 loop->ReplaceInput(1, loop); // self loop, NTL. | 2037 loop->ReplaceInput(1, loop); // self loop, NTL. |
| 2108 | 2038 |
| 2109 Node* effect = graph.NewNode(common.EffectPhi(1), start, loop); | 2039 Node* effect = graph.NewNode(common.EffectPhi(1), start, loop); |
| 2110 effect->ReplaceInput(0, effect); | 2040 effect->ReplaceInput(0, effect); |
| 2111 | 2041 |
| 2112 Node* terminate = graph.NewNode(common.Terminate(1), effect, loop); | 2042 Node* terminate = graph.NewNode(common.Terminate(1), effect, loop); |
| 2113 Node* end = graph.NewNode(common.End(), terminate); | 2043 Node* end = graph.NewNode(common.End(), terminate); |
| 2114 | 2044 |
| 2115 graph.SetEnd(end); | 2045 graph.SetEnd(end); |
| 2116 | 2046 |
| 2117 Schedule* schedule = ComputeAndVerifySchedule(6, &graph); | 2047 Schedule* schedule = ComputeAndVerifySchedule(6, &graph); |
| 2118 BasicBlock* block = schedule->block(loop); | 2048 BasicBlock* block = schedule->block(loop); |
| 2119 CHECK_NE(NULL, loop); | 2049 CHECK_NE(NULL, loop); |
| 2120 CHECK_EQ(block, schedule->block(effect)); | 2050 CHECK_EQ(block, schedule->block(effect)); |
| 2121 CHECK_GE(block->rpo_number(), 0); | 2051 CHECK_GE(block->rpo_number(), 0); |
| 2122 } | 2052 } |
| 2123 | 2053 |
| 2124 #endif | 2054 #endif |
| OLD | NEW |