Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: test/cctest/compiler/test-scheduler.cc

Issue 675983002: Add Schedule::InsertBranch to fuse control flow graphs. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments by Jaro. Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « test/cctest/compiler/test-schedule.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/compiler/access-builder.h" 8 #include "src/compiler/access-builder.h"
9 #include "src/compiler/common-operator.h" 9 #include "src/compiler/common-operator.h"
10 #include "src/compiler/generic-node-inl.h" 10 #include "src/compiler/generic-node-inl.h"
(...skipping 21 matching lines...) Expand all
32 ~TestLoop() { delete[] nodes; } 32 ~TestLoop() { delete[] nodes; }
33 }; 33 };
34 34
35 35
36 static TestLoop* CreateLoop(Schedule* schedule, int count) { 36 static TestLoop* CreateLoop(Schedule* schedule, int count) {
37 TestLoop* loop = new TestLoop(); 37 TestLoop* loop = new TestLoop();
38 loop->count = count; 38 loop->count = count;
39 loop->nodes = new BasicBlock* [count]; 39 loop->nodes = new BasicBlock* [count];
40 for (int i = 0; i < count; i++) { 40 for (int i = 0; i < count; i++) {
41 loop->nodes[i] = schedule->NewBasicBlock(); 41 loop->nodes[i] = schedule->NewBasicBlock();
42 if (i > 0) schedule->AddSuccessor(loop->nodes[i - 1], loop->nodes[i]); 42 if (i > 0) {
43 schedule->AddSuccessorForTesting(loop->nodes[i - 1], loop->nodes[i]);
44 }
43 } 45 }
44 schedule->AddSuccessor(loop->nodes[count - 1], loop->nodes[0]); 46 schedule->AddSuccessorForTesting(loop->nodes[count - 1], loop->nodes[0]);
45 return loop; 47 return loop;
46 } 48 }
47 49
48 50
49 static void CheckRPONumbers(BasicBlockVector* order, size_t expected, 51 static void CheckRPONumbers(BasicBlockVector* order, size_t expected,
50 bool loops_allowed) { 52 bool loops_allowed) {
51 CHECK(expected == order->size()); 53 CHECK(expected == order->size());
52 for (int i = 0; i < static_cast<int>(order->size()); i++) { 54 for (int i = 0; i < static_cast<int>(order->size()); i++) {
53 CHECK(order->at(i)->rpo_number() == i); 55 CHECK(order->at(i)->rpo_number() == i);
54 if (!loops_allowed) CHECK_LT(order->at(i)->loop_end(), 0); 56 if (!loops_allowed) CHECK_LT(order->at(i)->loop_end(), 0);
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 CHECK(block->rpo_number() + 1 == block->SuccessorAt(0)->rpo_number()); 155 CHECK(block->rpo_number() + 1 == block->SuccessorAt(0)->rpo_number());
154 } 156 }
155 } 157 }
156 } 158 }
157 } 159 }
158 160
159 161
160 TEST(RPOSelfLoop) { 162 TEST(RPOSelfLoop) {
161 HandleAndZoneScope scope; 163 HandleAndZoneScope scope;
162 Schedule schedule(scope.main_zone()); 164 Schedule schedule(scope.main_zone());
163 schedule.AddSuccessor(schedule.start(), schedule.start()); 165 schedule.AddSuccessorForTesting(schedule.start(), schedule.start());
164 ZonePool zone_pool(scope.main_isolate()); 166 ZonePool zone_pool(scope.main_isolate());
165 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&zone_pool, &schedule); 167 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&zone_pool, &schedule);
166 CheckRPONumbers(order, 1, true); 168 CheckRPONumbers(order, 1, true);
167 BasicBlock* loop[] = {schedule.start()}; 169 BasicBlock* loop[] = {schedule.start()};
168 CheckLoopContains(loop, 1); 170 CheckLoopContains(loop, 1);
169 } 171 }
170 172
171 173
172 TEST(RPOEntryLoop) { 174 TEST(RPOEntryLoop) {
173 HandleAndZoneScope scope; 175 HandleAndZoneScope scope;
174 Schedule schedule(scope.main_zone()); 176 Schedule schedule(scope.main_zone());
175 schedule.AddSuccessor(schedule.start(), schedule.end()); 177 schedule.AddSuccessorForTesting(schedule.start(), schedule.end());
176 schedule.AddSuccessor(schedule.end(), schedule.start()); 178 schedule.AddSuccessorForTesting(schedule.end(), schedule.start());
177 ZonePool zone_pool(scope.main_isolate()); 179 ZonePool zone_pool(scope.main_isolate());
178 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&zone_pool, &schedule); 180 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&zone_pool, &schedule);
179 CheckRPONumbers(order, 2, true); 181 CheckRPONumbers(order, 2, true);
180 BasicBlock* loop[] = {schedule.start(), schedule.end()}; 182 BasicBlock* loop[] = {schedule.start(), schedule.end()};
181 CheckLoopContains(loop, 2); 183 CheckLoopContains(loop, 2);
182 } 184 }
183 185
184 186
185 TEST(RPOEndLoop) { 187 TEST(RPOEndLoop) {
186 HandleAndZoneScope scope; 188 HandleAndZoneScope scope;
187 Schedule schedule(scope.main_zone()); 189 Schedule schedule(scope.main_zone());
188 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, 2)); 190 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, 2));
189 schedule.AddSuccessor(schedule.start(), loop1->header()); 191 schedule.AddSuccessorForTesting(schedule.start(), loop1->header());
190 ZonePool zone_pool(scope.main_isolate()); 192 ZonePool zone_pool(scope.main_isolate());
191 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&zone_pool, &schedule); 193 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&zone_pool, &schedule);
192 CheckRPONumbers(order, 3, true); 194 CheckRPONumbers(order, 3, true);
193 CheckLoopContains(loop1->nodes, loop1->count); 195 CheckLoopContains(loop1->nodes, loop1->count);
194 } 196 }
195 197
196 198
197 TEST(RPOEndLoopNested) { 199 TEST(RPOEndLoopNested) {
198 HandleAndZoneScope scope; 200 HandleAndZoneScope scope;
199 Schedule schedule(scope.main_zone()); 201 Schedule schedule(scope.main_zone());
200 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, 2)); 202 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, 2));
201 schedule.AddSuccessor(schedule.start(), loop1->header()); 203 schedule.AddSuccessorForTesting(schedule.start(), loop1->header());
202 schedule.AddSuccessor(loop1->last(), schedule.start()); 204 schedule.AddSuccessorForTesting(loop1->last(), schedule.start());
203 ZonePool zone_pool(scope.main_isolate()); 205 ZonePool zone_pool(scope.main_isolate());
204 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&zone_pool, &schedule); 206 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&zone_pool, &schedule);
205 CheckRPONumbers(order, 3, true); 207 CheckRPONumbers(order, 3, true);
206 CheckLoopContains(loop1->nodes, loop1->count); 208 CheckLoopContains(loop1->nodes, loop1->count);
207 } 209 }
208 210
209 211
210 TEST(RPODiamond) { 212 TEST(RPODiamond) {
211 HandleAndZoneScope scope; 213 HandleAndZoneScope scope;
212 Schedule schedule(scope.main_zone()); 214 Schedule schedule(scope.main_zone());
213 215
214 BasicBlock* A = schedule.start(); 216 BasicBlock* A = schedule.start();
215 BasicBlock* B = schedule.NewBasicBlock(); 217 BasicBlock* B = schedule.NewBasicBlock();
216 BasicBlock* C = schedule.NewBasicBlock(); 218 BasicBlock* C = schedule.NewBasicBlock();
217 BasicBlock* D = schedule.end(); 219 BasicBlock* D = schedule.end();
218 220
219 schedule.AddSuccessor(A, B); 221 schedule.AddSuccessorForTesting(A, B);
220 schedule.AddSuccessor(A, C); 222 schedule.AddSuccessorForTesting(A, C);
221 schedule.AddSuccessor(B, D); 223 schedule.AddSuccessorForTesting(B, D);
222 schedule.AddSuccessor(C, D); 224 schedule.AddSuccessorForTesting(C, D);
223 225
224 ZonePool zone_pool(scope.main_isolate()); 226 ZonePool zone_pool(scope.main_isolate());
225 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&zone_pool, &schedule); 227 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&zone_pool, &schedule);
226 CheckRPONumbers(order, 4, false); 228 CheckRPONumbers(order, 4, false);
227 229
228 CHECK_EQ(0, A->rpo_number()); 230 CHECK_EQ(0, A->rpo_number());
229 CHECK((B->rpo_number() == 1 && C->rpo_number() == 2) || 231 CHECK((B->rpo_number() == 1 && C->rpo_number() == 2) ||
230 (B->rpo_number() == 2 && C->rpo_number() == 1)); 232 (B->rpo_number() == 2 && C->rpo_number() == 1));
231 CHECK_EQ(3, D->rpo_number()); 233 CHECK_EQ(3, D->rpo_number());
232 } 234 }
233 235
234 236
235 TEST(RPOLoop1) { 237 TEST(RPOLoop1) {
236 HandleAndZoneScope scope; 238 HandleAndZoneScope scope;
237 Schedule schedule(scope.main_zone()); 239 Schedule schedule(scope.main_zone());
238 240
239 BasicBlock* A = schedule.start(); 241 BasicBlock* A = schedule.start();
240 BasicBlock* B = schedule.NewBasicBlock(); 242 BasicBlock* B = schedule.NewBasicBlock();
241 BasicBlock* C = schedule.NewBasicBlock(); 243 BasicBlock* C = schedule.NewBasicBlock();
242 BasicBlock* D = schedule.end(); 244 BasicBlock* D = schedule.end();
243 245
244 schedule.AddSuccessor(A, B); 246 schedule.AddSuccessorForTesting(A, B);
245 schedule.AddSuccessor(B, C); 247 schedule.AddSuccessorForTesting(B, C);
246 schedule.AddSuccessor(C, B); 248 schedule.AddSuccessorForTesting(C, B);
247 schedule.AddSuccessor(C, D); 249 schedule.AddSuccessorForTesting(C, D);
248 250
249 ZonePool zone_pool(scope.main_isolate()); 251 ZonePool zone_pool(scope.main_isolate());
250 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&zone_pool, &schedule); 252 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&zone_pool, &schedule);
251 CheckRPONumbers(order, 4, true); 253 CheckRPONumbers(order, 4, true);
252 BasicBlock* loop[] = {B, C}; 254 BasicBlock* loop[] = {B, C};
253 CheckLoopContains(loop, 2); 255 CheckLoopContains(loop, 2);
254 } 256 }
255 257
256 258
257 TEST(RPOLoop2) { 259 TEST(RPOLoop2) {
258 HandleAndZoneScope scope; 260 HandleAndZoneScope scope;
259 Schedule schedule(scope.main_zone()); 261 Schedule schedule(scope.main_zone());
260 262
261 BasicBlock* A = schedule.start(); 263 BasicBlock* A = schedule.start();
262 BasicBlock* B = schedule.NewBasicBlock(); 264 BasicBlock* B = schedule.NewBasicBlock();
263 BasicBlock* C = schedule.NewBasicBlock(); 265 BasicBlock* C = schedule.NewBasicBlock();
264 BasicBlock* D = schedule.end(); 266 BasicBlock* D = schedule.end();
265 267
266 schedule.AddSuccessor(A, B); 268 schedule.AddSuccessorForTesting(A, B);
267 schedule.AddSuccessor(B, C); 269 schedule.AddSuccessorForTesting(B, C);
268 schedule.AddSuccessor(C, B); 270 schedule.AddSuccessorForTesting(C, B);
269 schedule.AddSuccessor(B, D); 271 schedule.AddSuccessorForTesting(B, D);
270 272
271 ZonePool zone_pool(scope.main_isolate()); 273 ZonePool zone_pool(scope.main_isolate());
272 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&zone_pool, &schedule); 274 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&zone_pool, &schedule);
273 CheckRPONumbers(order, 4, true); 275 CheckRPONumbers(order, 4, true);
274 BasicBlock* loop[] = {B, C}; 276 BasicBlock* loop[] = {B, C};
275 CheckLoopContains(loop, 2); 277 CheckLoopContains(loop, 2);
276 } 278 }
277 279
278 280
279 TEST(RPOLoopN) { 281 TEST(RPOLoopN) {
280 HandleAndZoneScope scope; 282 HandleAndZoneScope scope;
281 283
282 for (int i = 0; i < 11; i++) { 284 for (int i = 0; i < 11; i++) {
283 Schedule schedule(scope.main_zone()); 285 Schedule schedule(scope.main_zone());
284 BasicBlock* A = schedule.start(); 286 BasicBlock* A = schedule.start();
285 BasicBlock* B = schedule.NewBasicBlock(); 287 BasicBlock* B = schedule.NewBasicBlock();
286 BasicBlock* C = schedule.NewBasicBlock(); 288 BasicBlock* C = schedule.NewBasicBlock();
287 BasicBlock* D = schedule.NewBasicBlock(); 289 BasicBlock* D = schedule.NewBasicBlock();
288 BasicBlock* E = schedule.NewBasicBlock(); 290 BasicBlock* E = schedule.NewBasicBlock();
289 BasicBlock* F = schedule.NewBasicBlock(); 291 BasicBlock* F = schedule.NewBasicBlock();
290 BasicBlock* G = schedule.end(); 292 BasicBlock* G = schedule.end();
291 293
292 schedule.AddSuccessor(A, B); 294 schedule.AddSuccessorForTesting(A, B);
293 schedule.AddSuccessor(B, C); 295 schedule.AddSuccessorForTesting(B, C);
294 schedule.AddSuccessor(C, D); 296 schedule.AddSuccessorForTesting(C, D);
295 schedule.AddSuccessor(D, E); 297 schedule.AddSuccessorForTesting(D, E);
296 schedule.AddSuccessor(E, F); 298 schedule.AddSuccessorForTesting(E, F);
297 schedule.AddSuccessor(F, B); 299 schedule.AddSuccessorForTesting(F, B);
298 schedule.AddSuccessor(B, G); 300 schedule.AddSuccessorForTesting(B, G);
299 301
300 // Throw in extra backedges from time to time. 302 // Throw in extra backedges from time to time.
301 if (i == 1) schedule.AddSuccessor(B, B); 303 if (i == 1) schedule.AddSuccessorForTesting(B, B);
302 if (i == 2) schedule.AddSuccessor(C, B); 304 if (i == 2) schedule.AddSuccessorForTesting(C, B);
303 if (i == 3) schedule.AddSuccessor(D, B); 305 if (i == 3) schedule.AddSuccessorForTesting(D, B);
304 if (i == 4) schedule.AddSuccessor(E, B); 306 if (i == 4) schedule.AddSuccessorForTesting(E, B);
305 if (i == 5) schedule.AddSuccessor(F, B); 307 if (i == 5) schedule.AddSuccessorForTesting(F, B);
306 308
307 // Throw in extra loop exits from time to time. 309 // Throw in extra loop exits from time to time.
308 if (i == 6) schedule.AddSuccessor(B, G); 310 if (i == 6) schedule.AddSuccessorForTesting(B, G);
309 if (i == 7) schedule.AddSuccessor(C, G); 311 if (i == 7) schedule.AddSuccessorForTesting(C, G);
310 if (i == 8) schedule.AddSuccessor(D, G); 312 if (i == 8) schedule.AddSuccessorForTesting(D, G);
311 if (i == 9) schedule.AddSuccessor(E, G); 313 if (i == 9) schedule.AddSuccessorForTesting(E, G);
312 if (i == 10) schedule.AddSuccessor(F, G); 314 if (i == 10) schedule.AddSuccessorForTesting(F, G);
313 315
314 ZonePool zone_pool(scope.main_isolate()); 316 ZonePool zone_pool(scope.main_isolate());
315 BasicBlockVector* order = 317 BasicBlockVector* order =
316 Scheduler::ComputeSpecialRPO(&zone_pool, &schedule); 318 Scheduler::ComputeSpecialRPO(&zone_pool, &schedule);
317 CheckRPONumbers(order, 7, true); 319 CheckRPONumbers(order, 7, true);
318 BasicBlock* loop[] = {B, C, D, E, F}; 320 BasicBlock* loop[] = {B, C, D, E, F};
319 CheckLoopContains(loop, 5); 321 CheckLoopContains(loop, 5);
320 } 322 }
321 } 323 }
322 324
323 325
324 TEST(RPOLoopNest1) { 326 TEST(RPOLoopNest1) {
325 HandleAndZoneScope scope; 327 HandleAndZoneScope scope;
326 Schedule schedule(scope.main_zone()); 328 Schedule schedule(scope.main_zone());
327 329
328 BasicBlock* A = schedule.start(); 330 BasicBlock* A = schedule.start();
329 BasicBlock* B = schedule.NewBasicBlock(); 331 BasicBlock* B = schedule.NewBasicBlock();
330 BasicBlock* C = schedule.NewBasicBlock(); 332 BasicBlock* C = schedule.NewBasicBlock();
331 BasicBlock* D = schedule.NewBasicBlock(); 333 BasicBlock* D = schedule.NewBasicBlock();
332 BasicBlock* E = schedule.NewBasicBlock(); 334 BasicBlock* E = schedule.NewBasicBlock();
333 BasicBlock* F = schedule.end(); 335 BasicBlock* F = schedule.end();
334 336
335 schedule.AddSuccessor(A, B); 337 schedule.AddSuccessorForTesting(A, B);
336 schedule.AddSuccessor(B, C); 338 schedule.AddSuccessorForTesting(B, C);
337 schedule.AddSuccessor(C, D); 339 schedule.AddSuccessorForTesting(C, D);
338 schedule.AddSuccessor(D, C); 340 schedule.AddSuccessorForTesting(D, C);
339 schedule.AddSuccessor(D, E); 341 schedule.AddSuccessorForTesting(D, E);
340 schedule.AddSuccessor(E, B); 342 schedule.AddSuccessorForTesting(E, B);
341 schedule.AddSuccessor(E, F); 343 schedule.AddSuccessorForTesting(E, F);
342 344
343 ZonePool zone_pool(scope.main_isolate()); 345 ZonePool zone_pool(scope.main_isolate());
344 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&zone_pool, &schedule); 346 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&zone_pool, &schedule);
345 CheckRPONumbers(order, 6, true); 347 CheckRPONumbers(order, 6, true);
346 BasicBlock* loop1[] = {B, C, D, E}; 348 BasicBlock* loop1[] = {B, C, D, E};
347 CheckLoopContains(loop1, 4); 349 CheckLoopContains(loop1, 4);
348 350
349 BasicBlock* loop2[] = {C, D}; 351 BasicBlock* loop2[] = {C, D};
350 CheckLoopContains(loop2, 2); 352 CheckLoopContains(loop2, 2);
351 } 353 }
352 354
353 355
354 TEST(RPOLoopNest2) { 356 TEST(RPOLoopNest2) {
355 HandleAndZoneScope scope; 357 HandleAndZoneScope scope;
356 Schedule schedule(scope.main_zone()); 358 Schedule schedule(scope.main_zone());
357 359
358 BasicBlock* A = schedule.start(); 360 BasicBlock* A = schedule.start();
359 BasicBlock* B = schedule.NewBasicBlock(); 361 BasicBlock* B = schedule.NewBasicBlock();
360 BasicBlock* C = schedule.NewBasicBlock(); 362 BasicBlock* C = schedule.NewBasicBlock();
361 BasicBlock* D = schedule.NewBasicBlock(); 363 BasicBlock* D = schedule.NewBasicBlock();
362 BasicBlock* E = schedule.NewBasicBlock(); 364 BasicBlock* E = schedule.NewBasicBlock();
363 BasicBlock* F = schedule.NewBasicBlock(); 365 BasicBlock* F = schedule.NewBasicBlock();
364 BasicBlock* G = schedule.NewBasicBlock(); 366 BasicBlock* G = schedule.NewBasicBlock();
365 BasicBlock* H = schedule.end(); 367 BasicBlock* H = schedule.end();
366 368
367 schedule.AddSuccessor(A, B); 369 schedule.AddSuccessorForTesting(A, B);
368 schedule.AddSuccessor(B, C); 370 schedule.AddSuccessorForTesting(B, C);
369 schedule.AddSuccessor(C, D); 371 schedule.AddSuccessorForTesting(C, D);
370 schedule.AddSuccessor(D, E); 372 schedule.AddSuccessorForTesting(D, E);
371 schedule.AddSuccessor(E, F); 373 schedule.AddSuccessorForTesting(E, F);
372 schedule.AddSuccessor(F, G); 374 schedule.AddSuccessorForTesting(F, G);
373 schedule.AddSuccessor(G, H); 375 schedule.AddSuccessorForTesting(G, H);
374 376
375 schedule.AddSuccessor(E, D); 377 schedule.AddSuccessorForTesting(E, D);
376 schedule.AddSuccessor(F, C); 378 schedule.AddSuccessorForTesting(F, C);
377 schedule.AddSuccessor(G, B); 379 schedule.AddSuccessorForTesting(G, B);
378 380
379 ZonePool zone_pool(scope.main_isolate()); 381 ZonePool zone_pool(scope.main_isolate());
380 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&zone_pool, &schedule); 382 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&zone_pool, &schedule);
381 CheckRPONumbers(order, 8, true); 383 CheckRPONumbers(order, 8, true);
382 BasicBlock* loop1[] = {B, C, D, E, F, G}; 384 BasicBlock* loop1[] = {B, C, D, E, F, G};
383 CheckLoopContains(loop1, 6); 385 CheckLoopContains(loop1, 6);
384 386
385 BasicBlock* loop2[] = {C, D, E, F}; 387 BasicBlock* loop2[] = {C, D, E, F};
386 CheckLoopContains(loop2, 4); 388 CheckLoopContains(loop2, 4);
387 389
388 BasicBlock* loop3[] = {D, E}; 390 BasicBlock* loop3[] = {D, E};
389 CheckLoopContains(loop3, 2); 391 CheckLoopContains(loop3, 2);
390 } 392 }
391 393
392 394
393 TEST(RPOLoopFollow1) { 395 TEST(RPOLoopFollow1) {
394 HandleAndZoneScope scope; 396 HandleAndZoneScope scope;
395 Schedule schedule(scope.main_zone()); 397 Schedule schedule(scope.main_zone());
396 398
397 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, 1)); 399 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, 1));
398 SmartPointer<TestLoop> loop2(CreateLoop(&schedule, 1)); 400 SmartPointer<TestLoop> loop2(CreateLoop(&schedule, 1));
399 401
400 BasicBlock* A = schedule.start(); 402 BasicBlock* A = schedule.start();
401 BasicBlock* E = schedule.end(); 403 BasicBlock* E = schedule.end();
402 404
403 schedule.AddSuccessor(A, loop1->header()); 405 schedule.AddSuccessorForTesting(A, loop1->header());
404 schedule.AddSuccessor(loop1->header(), loop2->header()); 406 schedule.AddSuccessorForTesting(loop1->header(), loop2->header());
405 schedule.AddSuccessor(loop2->last(), E); 407 schedule.AddSuccessorForTesting(loop2->last(), E);
406 408
407 ZonePool zone_pool(scope.main_isolate()); 409 ZonePool zone_pool(scope.main_isolate());
408 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&zone_pool, &schedule); 410 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&zone_pool, &schedule);
409 411
410 CheckLoopContains(loop1->nodes, loop1->count); 412 CheckLoopContains(loop1->nodes, loop1->count);
411 413
412 CHECK_EQ(static_cast<int>(schedule.BasicBlockCount()), 414 CHECK_EQ(static_cast<int>(schedule.BasicBlockCount()),
413 static_cast<int>(order->size())); 415 static_cast<int>(order->size()));
414 CheckLoopContains(loop1->nodes, loop1->count); 416 CheckLoopContains(loop1->nodes, loop1->count);
415 CheckLoopContains(loop2->nodes, loop2->count); 417 CheckLoopContains(loop2->nodes, loop2->count);
416 } 418 }
417 419
418 420
419 TEST(RPOLoopFollow2) { 421 TEST(RPOLoopFollow2) {
420 HandleAndZoneScope scope; 422 HandleAndZoneScope scope;
421 Schedule schedule(scope.main_zone()); 423 Schedule schedule(scope.main_zone());
422 424
423 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, 1)); 425 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, 1));
424 SmartPointer<TestLoop> loop2(CreateLoop(&schedule, 1)); 426 SmartPointer<TestLoop> loop2(CreateLoop(&schedule, 1));
425 427
426 BasicBlock* A = schedule.start(); 428 BasicBlock* A = schedule.start();
427 BasicBlock* S = schedule.NewBasicBlock(); 429 BasicBlock* S = schedule.NewBasicBlock();
428 BasicBlock* E = schedule.end(); 430 BasicBlock* E = schedule.end();
429 431
430 schedule.AddSuccessor(A, loop1->header()); 432 schedule.AddSuccessorForTesting(A, loop1->header());
431 schedule.AddSuccessor(loop1->header(), S); 433 schedule.AddSuccessorForTesting(loop1->header(), S);
432 schedule.AddSuccessor(S, loop2->header()); 434 schedule.AddSuccessorForTesting(S, loop2->header());
433 schedule.AddSuccessor(loop2->last(), E); 435 schedule.AddSuccessorForTesting(loop2->last(), E);
434 436
435 ZonePool zone_pool(scope.main_isolate()); 437 ZonePool zone_pool(scope.main_isolate());
436 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&zone_pool, &schedule); 438 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&zone_pool, &schedule);
437 439
438 CheckLoopContains(loop1->nodes, loop1->count); 440 CheckLoopContains(loop1->nodes, loop1->count);
439 441
440 CHECK_EQ(static_cast<int>(schedule.BasicBlockCount()), 442 CHECK_EQ(static_cast<int>(schedule.BasicBlockCount()),
441 static_cast<int>(order->size())); 443 static_cast<int>(order->size()));
442 CheckLoopContains(loop1->nodes, loop1->count); 444 CheckLoopContains(loop1->nodes, loop1->count);
443 CheckLoopContains(loop2->nodes, loop2->count); 445 CheckLoopContains(loop2->nodes, loop2->count);
444 } 446 }
445 447
446 448
447 TEST(RPOLoopFollowN) { 449 TEST(RPOLoopFollowN) {
448 HandleAndZoneScope scope; 450 HandleAndZoneScope scope;
449 451
450 for (int size = 1; size < 5; size++) { 452 for (int size = 1; size < 5; size++) {
451 for (int exit = 0; exit < size; exit++) { 453 for (int exit = 0; exit < size; exit++) {
452 Schedule schedule(scope.main_zone()); 454 Schedule schedule(scope.main_zone());
453 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, size)); 455 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, size));
454 SmartPointer<TestLoop> loop2(CreateLoop(&schedule, size)); 456 SmartPointer<TestLoop> loop2(CreateLoop(&schedule, size));
455 BasicBlock* A = schedule.start(); 457 BasicBlock* A = schedule.start();
456 BasicBlock* E = schedule.end(); 458 BasicBlock* E = schedule.end();
457 459
458 schedule.AddSuccessor(A, loop1->header()); 460 schedule.AddSuccessorForTesting(A, loop1->header());
459 schedule.AddSuccessor(loop1->nodes[exit], loop2->header()); 461 schedule.AddSuccessorForTesting(loop1->nodes[exit], loop2->header());
460 schedule.AddSuccessor(loop2->nodes[exit], E); 462 schedule.AddSuccessorForTesting(loop2->nodes[exit], E);
461 ZonePool zone_pool(scope.main_isolate()); 463 ZonePool zone_pool(scope.main_isolate());
462 BasicBlockVector* order = 464 BasicBlockVector* order =
463 Scheduler::ComputeSpecialRPO(&zone_pool, &schedule); 465 Scheduler::ComputeSpecialRPO(&zone_pool, &schedule);
464 CheckLoopContains(loop1->nodes, loop1->count); 466 CheckLoopContains(loop1->nodes, loop1->count);
465 467
466 CHECK_EQ(static_cast<int>(schedule.BasicBlockCount()), 468 CHECK_EQ(static_cast<int>(schedule.BasicBlockCount()),
467 static_cast<int>(order->size())); 469 static_cast<int>(order->size()));
468 CheckLoopContains(loop1->nodes, loop1->count); 470 CheckLoopContains(loop1->nodes, loop1->count);
469 CheckLoopContains(loop2->nodes, loop2->count); 471 CheckLoopContains(loop2->nodes, loop2->count);
470 } 472 }
471 } 473 }
472 } 474 }
473 475
474 476
475 TEST(RPONestedLoopFollow1) { 477 TEST(RPONestedLoopFollow1) {
476 HandleAndZoneScope scope; 478 HandleAndZoneScope scope;
477 Schedule schedule(scope.main_zone()); 479 Schedule schedule(scope.main_zone());
478 480
479 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, 1)); 481 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, 1));
480 SmartPointer<TestLoop> loop2(CreateLoop(&schedule, 1)); 482 SmartPointer<TestLoop> loop2(CreateLoop(&schedule, 1));
481 483
482 BasicBlock* A = schedule.start(); 484 BasicBlock* A = schedule.start();
483 BasicBlock* B = schedule.NewBasicBlock(); 485 BasicBlock* B = schedule.NewBasicBlock();
484 BasicBlock* C = schedule.NewBasicBlock(); 486 BasicBlock* C = schedule.NewBasicBlock();
485 BasicBlock* E = schedule.end(); 487 BasicBlock* E = schedule.end();
486 488
487 schedule.AddSuccessor(A, B); 489 schedule.AddSuccessorForTesting(A, B);
488 schedule.AddSuccessor(B, loop1->header()); 490 schedule.AddSuccessorForTesting(B, loop1->header());
489 schedule.AddSuccessor(loop1->header(), loop2->header()); 491 schedule.AddSuccessorForTesting(loop1->header(), loop2->header());
490 schedule.AddSuccessor(loop2->last(), C); 492 schedule.AddSuccessorForTesting(loop2->last(), C);
491 schedule.AddSuccessor(C, E); 493 schedule.AddSuccessorForTesting(C, E);
492 schedule.AddSuccessor(C, B); 494 schedule.AddSuccessorForTesting(C, B);
493 495
494 ZonePool zone_pool(scope.main_isolate()); 496 ZonePool zone_pool(scope.main_isolate());
495 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&zone_pool, &schedule); 497 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&zone_pool, &schedule);
496 498
497 CheckLoopContains(loop1->nodes, loop1->count); 499 CheckLoopContains(loop1->nodes, loop1->count);
498 500
499 CHECK_EQ(static_cast<int>(schedule.BasicBlockCount()), 501 CHECK_EQ(static_cast<int>(schedule.BasicBlockCount()),
500 static_cast<int>(order->size())); 502 static_cast<int>(order->size()));
501 CheckLoopContains(loop1->nodes, loop1->count); 503 CheckLoopContains(loop1->nodes, loop1->count);
502 CheckLoopContains(loop2->nodes, loop2->count); 504 CheckLoopContains(loop2->nodes, loop2->count);
503 505
504 BasicBlock* loop3[] = {B, loop1->nodes[0], loop2->nodes[0], C}; 506 BasicBlock* loop3[] = {B, loop1->nodes[0], loop2->nodes[0], C};
505 CheckLoopContains(loop3, 4); 507 CheckLoopContains(loop3, 4);
506 } 508 }
507 509
508 510
509 TEST(RPOLoopBackedges1) { 511 TEST(RPOLoopBackedges1) {
510 HandleAndZoneScope scope; 512 HandleAndZoneScope scope;
511 513
512 int size = 8; 514 int size = 8;
513 for (int i = 0; i < size; i++) { 515 for (int i = 0; i < size; i++) {
514 for (int j = 0; j < size; j++) { 516 for (int j = 0; j < size; j++) {
515 Schedule schedule(scope.main_zone()); 517 Schedule schedule(scope.main_zone());
516 BasicBlock* A = schedule.start(); 518 BasicBlock* A = schedule.start();
517 BasicBlock* E = schedule.end(); 519 BasicBlock* E = schedule.end();
518 520
519 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, size)); 521 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, size));
520 schedule.AddSuccessor(A, loop1->header()); 522 schedule.AddSuccessorForTesting(A, loop1->header());
521 schedule.AddSuccessor(loop1->last(), E); 523 schedule.AddSuccessorForTesting(loop1->last(), E);
522 524
523 schedule.AddSuccessor(loop1->nodes[i], loop1->header()); 525 schedule.AddSuccessorForTesting(loop1->nodes[i], loop1->header());
524 schedule.AddSuccessor(loop1->nodes[j], E); 526 schedule.AddSuccessorForTesting(loop1->nodes[j], E);
525 527
526 ZonePool zone_pool(scope.main_isolate()); 528 ZonePool zone_pool(scope.main_isolate());
527 BasicBlockVector* order = 529 BasicBlockVector* order =
528 Scheduler::ComputeSpecialRPO(&zone_pool, &schedule); 530 Scheduler::ComputeSpecialRPO(&zone_pool, &schedule);
529 CheckRPONumbers(order, schedule.BasicBlockCount(), true); 531 CheckRPONumbers(order, schedule.BasicBlockCount(), true);
530 CheckLoopContains(loop1->nodes, loop1->count); 532 CheckLoopContains(loop1->nodes, loop1->count);
531 } 533 }
532 } 534 }
533 } 535 }
534 536
535 537
536 TEST(RPOLoopOutedges1) { 538 TEST(RPOLoopOutedges1) {
537 HandleAndZoneScope scope; 539 HandleAndZoneScope scope;
538 540
539 int size = 8; 541 int size = 8;
540 for (int i = 0; i < size; i++) { 542 for (int i = 0; i < size; i++) {
541 for (int j = 0; j < size; j++) { 543 for (int j = 0; j < size; j++) {
542 Schedule schedule(scope.main_zone()); 544 Schedule schedule(scope.main_zone());
543 BasicBlock* A = schedule.start(); 545 BasicBlock* A = schedule.start();
544 BasicBlock* D = schedule.NewBasicBlock(); 546 BasicBlock* D = schedule.NewBasicBlock();
545 BasicBlock* E = schedule.end(); 547 BasicBlock* E = schedule.end();
546 548
547 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, size)); 549 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, size));
548 schedule.AddSuccessor(A, loop1->header()); 550 schedule.AddSuccessorForTesting(A, loop1->header());
549 schedule.AddSuccessor(loop1->last(), E); 551 schedule.AddSuccessorForTesting(loop1->last(), E);
550 552
551 schedule.AddSuccessor(loop1->nodes[i], loop1->header()); 553 schedule.AddSuccessorForTesting(loop1->nodes[i], loop1->header());
552 schedule.AddSuccessor(loop1->nodes[j], D); 554 schedule.AddSuccessorForTesting(loop1->nodes[j], D);
553 schedule.AddSuccessor(D, E); 555 schedule.AddSuccessorForTesting(D, E);
554 556
555 ZonePool zone_pool(scope.main_isolate()); 557 ZonePool zone_pool(scope.main_isolate());
556 BasicBlockVector* order = 558 BasicBlockVector* order =
557 Scheduler::ComputeSpecialRPO(&zone_pool, &schedule); 559 Scheduler::ComputeSpecialRPO(&zone_pool, &schedule);
558 CheckRPONumbers(order, schedule.BasicBlockCount(), true); 560 CheckRPONumbers(order, schedule.BasicBlockCount(), true);
559 CheckLoopContains(loop1->nodes, loop1->count); 561 CheckLoopContains(loop1->nodes, loop1->count);
560 } 562 }
561 } 563 }
562 } 564 }
563 565
564 566
565 TEST(RPOLoopOutedges2) { 567 TEST(RPOLoopOutedges2) {
566 HandleAndZoneScope scope; 568 HandleAndZoneScope scope;
567 569
568 int size = 8; 570 int size = 8;
569 for (int i = 0; i < size; i++) { 571 for (int i = 0; i < size; i++) {
570 Schedule schedule(scope.main_zone()); 572 Schedule schedule(scope.main_zone());
571 BasicBlock* A = schedule.start(); 573 BasicBlock* A = schedule.start();
572 BasicBlock* E = schedule.end(); 574 BasicBlock* E = schedule.end();
573 575
574 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, size)); 576 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, size));
575 schedule.AddSuccessor(A, loop1->header()); 577 schedule.AddSuccessorForTesting(A, loop1->header());
576 schedule.AddSuccessor(loop1->last(), E); 578 schedule.AddSuccessorForTesting(loop1->last(), E);
577 579
578 for (int j = 0; j < size; j++) { 580 for (int j = 0; j < size; j++) {
579 BasicBlock* O = schedule.NewBasicBlock(); 581 BasicBlock* O = schedule.NewBasicBlock();
580 schedule.AddSuccessor(loop1->nodes[j], O); 582 schedule.AddSuccessorForTesting(loop1->nodes[j], O);
581 schedule.AddSuccessor(O, E); 583 schedule.AddSuccessorForTesting(O, E);
582 } 584 }
583 585
584 ZonePool zone_pool(scope.main_isolate()); 586 ZonePool zone_pool(scope.main_isolate());
585 BasicBlockVector* order = 587 BasicBlockVector* order =
586 Scheduler::ComputeSpecialRPO(&zone_pool, &schedule); 588 Scheduler::ComputeSpecialRPO(&zone_pool, &schedule);
587 CheckRPONumbers(order, schedule.BasicBlockCount(), true); 589 CheckRPONumbers(order, schedule.BasicBlockCount(), true);
588 CheckLoopContains(loop1->nodes, loop1->count); 590 CheckLoopContains(loop1->nodes, loop1->count);
589 } 591 }
590 } 592 }
591 593
592 594
593 TEST(RPOLoopOutloops1) { 595 TEST(RPOLoopOutloops1) {
594 HandleAndZoneScope scope; 596 HandleAndZoneScope scope;
595 597
596 int size = 8; 598 int size = 8;
597 for (int i = 0; i < size; i++) { 599 for (int i = 0; i < size; i++) {
598 Schedule schedule(scope.main_zone()); 600 Schedule schedule(scope.main_zone());
599 BasicBlock* A = schedule.start(); 601 BasicBlock* A = schedule.start();
600 BasicBlock* E = schedule.end(); 602 BasicBlock* E = schedule.end();
601 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, size)); 603 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, size));
602 schedule.AddSuccessor(A, loop1->header()); 604 schedule.AddSuccessorForTesting(A, loop1->header());
603 schedule.AddSuccessor(loop1->last(), E); 605 schedule.AddSuccessorForTesting(loop1->last(), E);
604 606
605 TestLoop** loopN = new TestLoop* [size]; 607 TestLoop** loopN = new TestLoop* [size];
606 for (int j = 0; j < size; j++) { 608 for (int j = 0; j < size; j++) {
607 loopN[j] = CreateLoop(&schedule, 2); 609 loopN[j] = CreateLoop(&schedule, 2);
608 schedule.AddSuccessor(loop1->nodes[j], loopN[j]->header()); 610 schedule.AddSuccessorForTesting(loop1->nodes[j], loopN[j]->header());
609 schedule.AddSuccessor(loopN[j]->last(), E); 611 schedule.AddSuccessorForTesting(loopN[j]->last(), E);
610 } 612 }
611 613
612 ZonePool zone_pool(scope.main_isolate()); 614 ZonePool zone_pool(scope.main_isolate());
613 BasicBlockVector* order = 615 BasicBlockVector* order =
614 Scheduler::ComputeSpecialRPO(&zone_pool, &schedule); 616 Scheduler::ComputeSpecialRPO(&zone_pool, &schedule);
615 CheckRPONumbers(order, schedule.BasicBlockCount(), true); 617 CheckRPONumbers(order, schedule.BasicBlockCount(), true);
616 CheckLoopContains(loop1->nodes, loop1->count); 618 CheckLoopContains(loop1->nodes, loop1->count);
617 619
618 for (int j = 0; j < size; j++) { 620 for (int j = 0; j < size; j++) {
619 CheckLoopContains(loopN[j]->nodes, loopN[j]->count); 621 CheckLoopContains(loopN[j]->nodes, loopN[j]->count);
620 delete loopN[j]; 622 delete loopN[j];
621 } 623 }
622 delete[] loopN; 624 delete[] loopN;
623 } 625 }
624 } 626 }
625 627
626 628
627 TEST(RPOLoopMultibackedge) { 629 TEST(RPOLoopMultibackedge) {
628 HandleAndZoneScope scope; 630 HandleAndZoneScope scope;
629 Schedule schedule(scope.main_zone()); 631 Schedule schedule(scope.main_zone());
630 632
631 BasicBlock* A = schedule.start(); 633 BasicBlock* A = schedule.start();
632 BasicBlock* B = schedule.NewBasicBlock(); 634 BasicBlock* B = schedule.NewBasicBlock();
633 BasicBlock* C = schedule.NewBasicBlock(); 635 BasicBlock* C = schedule.NewBasicBlock();
634 BasicBlock* D = schedule.end(); 636 BasicBlock* D = schedule.end();
635 BasicBlock* E = schedule.NewBasicBlock(); 637 BasicBlock* E = schedule.NewBasicBlock();
636 638
637 schedule.AddSuccessor(A, B); 639 schedule.AddSuccessorForTesting(A, B);
638 schedule.AddSuccessor(B, C); 640 schedule.AddSuccessorForTesting(B, C);
639 schedule.AddSuccessor(B, D); 641 schedule.AddSuccessorForTesting(B, D);
640 schedule.AddSuccessor(B, E); 642 schedule.AddSuccessorForTesting(B, E);
641 schedule.AddSuccessor(C, B); 643 schedule.AddSuccessorForTesting(C, B);
642 schedule.AddSuccessor(D, B); 644 schedule.AddSuccessorForTesting(D, B);
643 schedule.AddSuccessor(E, B); 645 schedule.AddSuccessorForTesting(E, B);
644 646
645 ZonePool zone_pool(scope.main_isolate()); 647 ZonePool zone_pool(scope.main_isolate());
646 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&zone_pool, &schedule); 648 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&zone_pool, &schedule);
647 CheckRPONumbers(order, 5, true); 649 CheckRPONumbers(order, 5, true);
648 650
649 BasicBlock* loop1[] = {B, C, D, E}; 651 BasicBlock* loop1[] = {B, C, D, E};
650 CheckLoopContains(loop1, 4); 652 CheckLoopContains(loop1, 4);
651 } 653 }
652 654
653 655
(...skipping 1255 matching lines...) Expand 10 before | Expand all | Expand 10 after
1909 graph.SetEnd(end); 1911 graph.SetEnd(end);
1910 1912
1911 Schedule* schedule = ComputeAndVerifySchedule(5, &graph); 1913 Schedule* schedule = ComputeAndVerifySchedule(5, &graph);
1912 BasicBlock* block = schedule->block(loop); 1914 BasicBlock* block = schedule->block(loop);
1913 CHECK_NE(NULL, loop); 1915 CHECK_NE(NULL, loop);
1914 CHECK_EQ(block, schedule->block(effect)); 1916 CHECK_EQ(block, schedule->block(effect));
1915 CHECK_GE(block->rpo_number(), 0); 1917 CHECK_GE(block->rpo_number(), 0);
1916 } 1918 }
1917 1919
1918 #endif 1920 #endif
OLDNEW
« no previous file with comments | « test/cctest/compiler/test-schedule.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698