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

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

Issue 484653002: Finish TODO in Schedule. s/entry/start/g and s/exit/end/g to be more regular. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 4 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/common-operator.h" 8 #include "src/compiler/common-operator.h"
9 #include "src/compiler/generic-node-inl.h" 9 #include "src/compiler/generic-node-inl.h"
10 #include "src/compiler/generic-node.h" 10 #include "src/compiler/generic-node.h"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 } 64 }
65 } 65 }
66 66
67 67
68 TEST(RPODegenerate1) { 68 TEST(RPODegenerate1) {
69 HandleAndZoneScope scope; 69 HandleAndZoneScope scope;
70 Schedule schedule(scope.main_zone()); 70 Schedule schedule(scope.main_zone());
71 71
72 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&schedule); 72 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&schedule);
73 CheckRPONumbers(order, 1, false); 73 CheckRPONumbers(order, 1, false);
74 CHECK_EQ(schedule.entry(), order->at(0)); 74 CHECK_EQ(schedule.start(), order->at(0));
75 } 75 }
76 76
77 77
78 TEST(RPODegenerate2) { 78 TEST(RPODegenerate2) {
79 HandleAndZoneScope scope; 79 HandleAndZoneScope scope;
80 Schedule schedule(scope.main_zone()); 80 Schedule schedule(scope.main_zone());
81 81
82 schedule.AddGoto(schedule.entry(), schedule.exit()); 82 schedule.AddGoto(schedule.start(), schedule.end());
83 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&schedule); 83 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&schedule);
84 CheckRPONumbers(order, 2, false); 84 CheckRPONumbers(order, 2, false);
85 CHECK_EQ(schedule.entry(), order->at(0)); 85 CHECK_EQ(schedule.start(), order->at(0));
86 CHECK_EQ(schedule.exit(), order->at(1)); 86 CHECK_EQ(schedule.end(), order->at(1));
87 } 87 }
88 88
89 89
90 TEST(RPOLine) { 90 TEST(RPOLine) {
91 HandleAndZoneScope scope; 91 HandleAndZoneScope scope;
92 92
93 for (int i = 0; i < 10; i++) { 93 for (int i = 0; i < 10; i++) {
94 Schedule schedule(scope.main_zone()); 94 Schedule schedule(scope.main_zone());
95 95
96 BasicBlock* last = schedule.entry(); 96 BasicBlock* last = schedule.start();
97 for (int j = 0; j < i; j++) { 97 for (int j = 0; j < i; j++) {
98 BasicBlock* block = schedule.NewBasicBlock(); 98 BasicBlock* block = schedule.NewBasicBlock();
99 schedule.AddGoto(last, block); 99 schedule.AddGoto(last, block);
100 last = block; 100 last = block;
101 } 101 }
102 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&schedule); 102 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&schedule);
103 CheckRPONumbers(order, 1 + i, false); 103 CheckRPONumbers(order, 1 + i, false);
104 104
105 Schedule::BasicBlocks blocks(schedule.all_blocks()); 105 Schedule::BasicBlocks blocks(schedule.all_blocks());
106 for (Schedule::BasicBlocks::iterator iter = blocks.begin(); 106 for (Schedule::BasicBlocks::iterator iter = blocks.begin();
107 iter != blocks.end(); ++iter) { 107 iter != blocks.end(); ++iter) {
108 BasicBlock* block = *iter; 108 BasicBlock* block = *iter;
109 if (block->rpo_number_ >= 0 && block->SuccessorCount() == 1) { 109 if (block->rpo_number_ >= 0 && block->SuccessorCount() == 1) {
110 CHECK(block->rpo_number_ + 1 == block->SuccessorAt(0)->rpo_number_); 110 CHECK(block->rpo_number_ + 1 == block->SuccessorAt(0)->rpo_number_);
111 } 111 }
112 } 112 }
113 } 113 }
114 } 114 }
115 115
116 116
117 TEST(RPOSelfLoop) { 117 TEST(RPOSelfLoop) {
118 HandleAndZoneScope scope; 118 HandleAndZoneScope scope;
119 Schedule schedule(scope.main_zone()); 119 Schedule schedule(scope.main_zone());
120 schedule.AddSuccessor(schedule.entry(), schedule.entry()); 120 schedule.AddSuccessor(schedule.start(), schedule.start());
121 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&schedule); 121 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&schedule);
122 CheckRPONumbers(order, 1, true); 122 CheckRPONumbers(order, 1, true);
123 BasicBlock* loop[] = {schedule.entry()}; 123 BasicBlock* loop[] = {schedule.start()};
124 CheckLoopContains(loop, 1); 124 CheckLoopContains(loop, 1);
125 } 125 }
126 126
127 127
128 TEST(RPOEntryLoop) { 128 TEST(RPOEntryLoop) {
129 HandleAndZoneScope scope; 129 HandleAndZoneScope scope;
130 Schedule schedule(scope.main_zone()); 130 Schedule schedule(scope.main_zone());
131 schedule.AddSuccessor(schedule.entry(), schedule.exit()); 131 schedule.AddSuccessor(schedule.start(), schedule.end());
132 schedule.AddSuccessor(schedule.exit(), schedule.entry()); 132 schedule.AddSuccessor(schedule.end(), schedule.start());
133 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&schedule); 133 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&schedule);
134 CheckRPONumbers(order, 2, true); 134 CheckRPONumbers(order, 2, true);
135 BasicBlock* loop[] = {schedule.entry(), schedule.exit()}; 135 BasicBlock* loop[] = {schedule.start(), schedule.end()};
136 CheckLoopContains(loop, 2); 136 CheckLoopContains(loop, 2);
137 } 137 }
138 138
139 139
140 TEST(RPOEndLoop) { 140 TEST(RPOEndLoop) {
141 HandleAndZoneScope scope; 141 HandleAndZoneScope scope;
142 Schedule schedule(scope.main_zone()); 142 Schedule schedule(scope.main_zone());
143 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, 2)); 143 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, 2));
144 schedule.AddSuccessor(schedule.entry(), loop1->header()); 144 schedule.AddSuccessor(schedule.start(), loop1->header());
145 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&schedule); 145 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&schedule);
146 CheckRPONumbers(order, 3, true); 146 CheckRPONumbers(order, 3, true);
147 CheckLoopContains(loop1->nodes, loop1->count); 147 CheckLoopContains(loop1->nodes, loop1->count);
148 } 148 }
149 149
150 150
151 TEST(RPOEndLoopNested) { 151 TEST(RPOEndLoopNested) {
152 HandleAndZoneScope scope; 152 HandleAndZoneScope scope;
153 Schedule schedule(scope.main_zone()); 153 Schedule schedule(scope.main_zone());
154 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, 2)); 154 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, 2));
155 schedule.AddSuccessor(schedule.entry(), loop1->header()); 155 schedule.AddSuccessor(schedule.start(), loop1->header());
156 schedule.AddSuccessor(loop1->last(), schedule.entry()); 156 schedule.AddSuccessor(loop1->last(), schedule.start());
157 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&schedule); 157 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&schedule);
158 CheckRPONumbers(order, 3, true); 158 CheckRPONumbers(order, 3, true);
159 CheckLoopContains(loop1->nodes, loop1->count); 159 CheckLoopContains(loop1->nodes, loop1->count);
160 } 160 }
161 161
162 162
163 TEST(RPODiamond) { 163 TEST(RPODiamond) {
164 HandleAndZoneScope scope; 164 HandleAndZoneScope scope;
165 Schedule schedule(scope.main_zone()); 165 Schedule schedule(scope.main_zone());
166 166
167 BasicBlock* A = schedule.entry(); 167 BasicBlock* A = schedule.start();
168 BasicBlock* B = schedule.NewBasicBlock(); 168 BasicBlock* B = schedule.NewBasicBlock();
169 BasicBlock* C = schedule.NewBasicBlock(); 169 BasicBlock* C = schedule.NewBasicBlock();
170 BasicBlock* D = schedule.exit(); 170 BasicBlock* D = schedule.end();
171 171
172 schedule.AddSuccessor(A, B); 172 schedule.AddSuccessor(A, B);
173 schedule.AddSuccessor(A, C); 173 schedule.AddSuccessor(A, C);
174 schedule.AddSuccessor(B, D); 174 schedule.AddSuccessor(B, D);
175 schedule.AddSuccessor(C, D); 175 schedule.AddSuccessor(C, D);
176 176
177 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&schedule); 177 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&schedule);
178 CheckRPONumbers(order, 4, false); 178 CheckRPONumbers(order, 4, false);
179 179
180 CHECK_EQ(0, A->rpo_number_); 180 CHECK_EQ(0, A->rpo_number_);
181 CHECK((B->rpo_number_ == 1 && C->rpo_number_ == 2) || 181 CHECK((B->rpo_number_ == 1 && C->rpo_number_ == 2) ||
182 (B->rpo_number_ == 2 && C->rpo_number_ == 1)); 182 (B->rpo_number_ == 2 && C->rpo_number_ == 1));
183 CHECK_EQ(3, D->rpo_number_); 183 CHECK_EQ(3, D->rpo_number_);
184 } 184 }
185 185
186 186
187 TEST(RPOLoop1) { 187 TEST(RPOLoop1) {
188 HandleAndZoneScope scope; 188 HandleAndZoneScope scope;
189 Schedule schedule(scope.main_zone()); 189 Schedule schedule(scope.main_zone());
190 190
191 BasicBlock* A = schedule.entry(); 191 BasicBlock* A = schedule.start();
192 BasicBlock* B = schedule.NewBasicBlock(); 192 BasicBlock* B = schedule.NewBasicBlock();
193 BasicBlock* C = schedule.NewBasicBlock(); 193 BasicBlock* C = schedule.NewBasicBlock();
194 BasicBlock* D = schedule.exit(); 194 BasicBlock* D = schedule.end();
195 195
196 schedule.AddSuccessor(A, B); 196 schedule.AddSuccessor(A, B);
197 schedule.AddSuccessor(B, C); 197 schedule.AddSuccessor(B, C);
198 schedule.AddSuccessor(C, B); 198 schedule.AddSuccessor(C, B);
199 schedule.AddSuccessor(C, D); 199 schedule.AddSuccessor(C, D);
200 200
201 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&schedule); 201 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&schedule);
202 CheckRPONumbers(order, 4, true); 202 CheckRPONumbers(order, 4, true);
203 BasicBlock* loop[] = {B, C}; 203 BasicBlock* loop[] = {B, C};
204 CheckLoopContains(loop, 2); 204 CheckLoopContains(loop, 2);
205 } 205 }
206 206
207 207
208 TEST(RPOLoop2) { 208 TEST(RPOLoop2) {
209 HandleAndZoneScope scope; 209 HandleAndZoneScope scope;
210 Schedule schedule(scope.main_zone()); 210 Schedule schedule(scope.main_zone());
211 211
212 BasicBlock* A = schedule.entry(); 212 BasicBlock* A = schedule.start();
213 BasicBlock* B = schedule.NewBasicBlock(); 213 BasicBlock* B = schedule.NewBasicBlock();
214 BasicBlock* C = schedule.NewBasicBlock(); 214 BasicBlock* C = schedule.NewBasicBlock();
215 BasicBlock* D = schedule.exit(); 215 BasicBlock* D = schedule.end();
216 216
217 schedule.AddSuccessor(A, B); 217 schedule.AddSuccessor(A, B);
218 schedule.AddSuccessor(B, C); 218 schedule.AddSuccessor(B, C);
219 schedule.AddSuccessor(C, B); 219 schedule.AddSuccessor(C, B);
220 schedule.AddSuccessor(B, D); 220 schedule.AddSuccessor(B, D);
221 221
222 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&schedule); 222 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&schedule);
223 CheckRPONumbers(order, 4, true); 223 CheckRPONumbers(order, 4, true);
224 BasicBlock* loop[] = {B, C}; 224 BasicBlock* loop[] = {B, C};
225 CheckLoopContains(loop, 2); 225 CheckLoopContains(loop, 2);
226 } 226 }
227 227
228 228
229 TEST(RPOLoopN) { 229 TEST(RPOLoopN) {
230 HandleAndZoneScope scope; 230 HandleAndZoneScope scope;
231 231
232 for (int i = 0; i < 11; i++) { 232 for (int i = 0; i < 11; i++) {
233 Schedule schedule(scope.main_zone()); 233 Schedule schedule(scope.main_zone());
234 BasicBlock* A = schedule.entry(); 234 BasicBlock* A = schedule.start();
235 BasicBlock* B = schedule.NewBasicBlock(); 235 BasicBlock* B = schedule.NewBasicBlock();
236 BasicBlock* C = schedule.NewBasicBlock(); 236 BasicBlock* C = schedule.NewBasicBlock();
237 BasicBlock* D = schedule.NewBasicBlock(); 237 BasicBlock* D = schedule.NewBasicBlock();
238 BasicBlock* E = schedule.NewBasicBlock(); 238 BasicBlock* E = schedule.NewBasicBlock();
239 BasicBlock* F = schedule.NewBasicBlock(); 239 BasicBlock* F = schedule.NewBasicBlock();
240 BasicBlock* G = schedule.exit(); 240 BasicBlock* G = schedule.end();
241 241
242 schedule.AddSuccessor(A, B); 242 schedule.AddSuccessor(A, B);
243 schedule.AddSuccessor(B, C); 243 schedule.AddSuccessor(B, C);
244 schedule.AddSuccessor(C, D); 244 schedule.AddSuccessor(C, D);
245 schedule.AddSuccessor(D, E); 245 schedule.AddSuccessor(D, E);
246 schedule.AddSuccessor(E, F); 246 schedule.AddSuccessor(E, F);
247 schedule.AddSuccessor(F, B); 247 schedule.AddSuccessor(F, B);
248 schedule.AddSuccessor(B, G); 248 schedule.AddSuccessor(B, G);
249 249
250 // Throw in extra backedges from time to time. 250 // Throw in extra backedges from time to time.
(...skipping 15 matching lines...) Expand all
266 BasicBlock* loop[] = {B, C, D, E, F}; 266 BasicBlock* loop[] = {B, C, D, E, F};
267 CheckLoopContains(loop, 5); 267 CheckLoopContains(loop, 5);
268 } 268 }
269 } 269 }
270 270
271 271
272 TEST(RPOLoopNest1) { 272 TEST(RPOLoopNest1) {
273 HandleAndZoneScope scope; 273 HandleAndZoneScope scope;
274 Schedule schedule(scope.main_zone()); 274 Schedule schedule(scope.main_zone());
275 275
276 BasicBlock* A = schedule.entry(); 276 BasicBlock* A = schedule.start();
277 BasicBlock* B = schedule.NewBasicBlock(); 277 BasicBlock* B = schedule.NewBasicBlock();
278 BasicBlock* C = schedule.NewBasicBlock(); 278 BasicBlock* C = schedule.NewBasicBlock();
279 BasicBlock* D = schedule.NewBasicBlock(); 279 BasicBlock* D = schedule.NewBasicBlock();
280 BasicBlock* E = schedule.NewBasicBlock(); 280 BasicBlock* E = schedule.NewBasicBlock();
281 BasicBlock* F = schedule.exit(); 281 BasicBlock* F = schedule.end();
282 282
283 schedule.AddSuccessor(A, B); 283 schedule.AddSuccessor(A, B);
284 schedule.AddSuccessor(B, C); 284 schedule.AddSuccessor(B, C);
285 schedule.AddSuccessor(C, D); 285 schedule.AddSuccessor(C, D);
286 schedule.AddSuccessor(D, C); 286 schedule.AddSuccessor(D, C);
287 schedule.AddSuccessor(D, E); 287 schedule.AddSuccessor(D, E);
288 schedule.AddSuccessor(E, B); 288 schedule.AddSuccessor(E, B);
289 schedule.AddSuccessor(E, F); 289 schedule.AddSuccessor(E, F);
290 290
291 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&schedule); 291 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&schedule);
292 CheckRPONumbers(order, 6, true); 292 CheckRPONumbers(order, 6, true);
293 BasicBlock* loop1[] = {B, C, D, E}; 293 BasicBlock* loop1[] = {B, C, D, E};
294 CheckLoopContains(loop1, 4); 294 CheckLoopContains(loop1, 4);
295 295
296 BasicBlock* loop2[] = {C, D}; 296 BasicBlock* loop2[] = {C, D};
297 CheckLoopContains(loop2, 2); 297 CheckLoopContains(loop2, 2);
298 } 298 }
299 299
300 300
301 TEST(RPOLoopNest2) { 301 TEST(RPOLoopNest2) {
302 HandleAndZoneScope scope; 302 HandleAndZoneScope scope;
303 Schedule schedule(scope.main_zone()); 303 Schedule schedule(scope.main_zone());
304 304
305 BasicBlock* A = schedule.entry(); 305 BasicBlock* A = schedule.start();
306 BasicBlock* B = schedule.NewBasicBlock(); 306 BasicBlock* B = schedule.NewBasicBlock();
307 BasicBlock* C = schedule.NewBasicBlock(); 307 BasicBlock* C = schedule.NewBasicBlock();
308 BasicBlock* D = schedule.NewBasicBlock(); 308 BasicBlock* D = schedule.NewBasicBlock();
309 BasicBlock* E = schedule.NewBasicBlock(); 309 BasicBlock* E = schedule.NewBasicBlock();
310 BasicBlock* F = schedule.NewBasicBlock(); 310 BasicBlock* F = schedule.NewBasicBlock();
311 BasicBlock* G = schedule.NewBasicBlock(); 311 BasicBlock* G = schedule.NewBasicBlock();
312 BasicBlock* H = schedule.exit(); 312 BasicBlock* H = schedule.end();
313 313
314 schedule.AddSuccessor(A, B); 314 schedule.AddSuccessor(A, B);
315 schedule.AddSuccessor(B, C); 315 schedule.AddSuccessor(B, C);
316 schedule.AddSuccessor(C, D); 316 schedule.AddSuccessor(C, D);
317 schedule.AddSuccessor(D, E); 317 schedule.AddSuccessor(D, E);
318 schedule.AddSuccessor(E, F); 318 schedule.AddSuccessor(E, F);
319 schedule.AddSuccessor(F, G); 319 schedule.AddSuccessor(F, G);
320 schedule.AddSuccessor(G, H); 320 schedule.AddSuccessor(G, H);
321 321
322 schedule.AddSuccessor(E, D); 322 schedule.AddSuccessor(E, D);
(...skipping 13 matching lines...) Expand all
336 } 336 }
337 337
338 338
339 TEST(RPOLoopFollow1) { 339 TEST(RPOLoopFollow1) {
340 HandleAndZoneScope scope; 340 HandleAndZoneScope scope;
341 Schedule schedule(scope.main_zone()); 341 Schedule schedule(scope.main_zone());
342 342
343 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, 1)); 343 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, 1));
344 SmartPointer<TestLoop> loop2(CreateLoop(&schedule, 1)); 344 SmartPointer<TestLoop> loop2(CreateLoop(&schedule, 1));
345 345
346 BasicBlock* A = schedule.entry(); 346 BasicBlock* A = schedule.start();
347 BasicBlock* E = schedule.exit(); 347 BasicBlock* E = schedule.end();
348 348
349 schedule.AddSuccessor(A, loop1->header()); 349 schedule.AddSuccessor(A, loop1->header());
350 schedule.AddSuccessor(loop1->header(), loop2->header()); 350 schedule.AddSuccessor(loop1->header(), loop2->header());
351 schedule.AddSuccessor(loop2->last(), E); 351 schedule.AddSuccessor(loop2->last(), E);
352 352
353 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&schedule); 353 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&schedule);
354 354
355 CheckLoopContains(loop1->nodes, loop1->count); 355 CheckLoopContains(loop1->nodes, loop1->count);
356 356
357 CHECK_EQ(schedule.BasicBlockCount(), static_cast<int>(order->size())); 357 CHECK_EQ(schedule.BasicBlockCount(), static_cast<int>(order->size()));
358 CheckLoopContains(loop1->nodes, loop1->count); 358 CheckLoopContains(loop1->nodes, loop1->count);
359 CheckLoopContains(loop2->nodes, loop2->count); 359 CheckLoopContains(loop2->nodes, loop2->count);
360 } 360 }
361 361
362 362
363 TEST(RPOLoopFollow2) { 363 TEST(RPOLoopFollow2) {
364 HandleAndZoneScope scope; 364 HandleAndZoneScope scope;
365 Schedule schedule(scope.main_zone()); 365 Schedule schedule(scope.main_zone());
366 366
367 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, 1)); 367 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, 1));
368 SmartPointer<TestLoop> loop2(CreateLoop(&schedule, 1)); 368 SmartPointer<TestLoop> loop2(CreateLoop(&schedule, 1));
369 369
370 BasicBlock* A = schedule.entry(); 370 BasicBlock* A = schedule.start();
371 BasicBlock* S = schedule.NewBasicBlock(); 371 BasicBlock* S = schedule.NewBasicBlock();
372 BasicBlock* E = schedule.exit(); 372 BasicBlock* E = schedule.end();
373 373
374 schedule.AddSuccessor(A, loop1->header()); 374 schedule.AddSuccessor(A, loop1->header());
375 schedule.AddSuccessor(loop1->header(), S); 375 schedule.AddSuccessor(loop1->header(), S);
376 schedule.AddSuccessor(S, loop2->header()); 376 schedule.AddSuccessor(S, loop2->header());
377 schedule.AddSuccessor(loop2->last(), E); 377 schedule.AddSuccessor(loop2->last(), E);
378 378
379 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&schedule); 379 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&schedule);
380 380
381 CheckLoopContains(loop1->nodes, loop1->count); 381 CheckLoopContains(loop1->nodes, loop1->count);
382 382
383 CHECK_EQ(schedule.BasicBlockCount(), static_cast<int>(order->size())); 383 CHECK_EQ(schedule.BasicBlockCount(), static_cast<int>(order->size()));
384 CheckLoopContains(loop1->nodes, loop1->count); 384 CheckLoopContains(loop1->nodes, loop1->count);
385 CheckLoopContains(loop2->nodes, loop2->count); 385 CheckLoopContains(loop2->nodes, loop2->count);
386 } 386 }
387 387
388 388
389 TEST(RPOLoopFollowN) { 389 TEST(RPOLoopFollowN) {
390 HandleAndZoneScope scope; 390 HandleAndZoneScope scope;
391 391
392 for (int size = 1; size < 5; size++) { 392 for (int size = 1; size < 5; size++) {
393 for (int exit = 0; exit < size; exit++) { 393 for (int exit = 0; exit < size; exit++) {
394 Schedule schedule(scope.main_zone()); 394 Schedule schedule(scope.main_zone());
395 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, size)); 395 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, size));
396 SmartPointer<TestLoop> loop2(CreateLoop(&schedule, size)); 396 SmartPointer<TestLoop> loop2(CreateLoop(&schedule, size));
397 BasicBlock* A = schedule.entry(); 397 BasicBlock* A = schedule.start();
398 BasicBlock* E = schedule.exit(); 398 BasicBlock* E = schedule.end();
399 399
400 schedule.AddSuccessor(A, loop1->header()); 400 schedule.AddSuccessor(A, loop1->header());
401 schedule.AddSuccessor(loop1->nodes[exit], loop2->header()); 401 schedule.AddSuccessor(loop1->nodes[exit], loop2->header());
402 schedule.AddSuccessor(loop2->nodes[exit], E); 402 schedule.AddSuccessor(loop2->nodes[exit], E);
403 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&schedule); 403 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&schedule);
404 CheckLoopContains(loop1->nodes, loop1->count); 404 CheckLoopContains(loop1->nodes, loop1->count);
405 405
406 CHECK_EQ(schedule.BasicBlockCount(), static_cast<int>(order->size())); 406 CHECK_EQ(schedule.BasicBlockCount(), static_cast<int>(order->size()));
407 CheckLoopContains(loop1->nodes, loop1->count); 407 CheckLoopContains(loop1->nodes, loop1->count);
408 CheckLoopContains(loop2->nodes, loop2->count); 408 CheckLoopContains(loop2->nodes, loop2->count);
409 } 409 }
410 } 410 }
411 } 411 }
412 412
413 413
414 TEST(RPONestedLoopFollow1) { 414 TEST(RPONestedLoopFollow1) {
415 HandleAndZoneScope scope; 415 HandleAndZoneScope scope;
416 Schedule schedule(scope.main_zone()); 416 Schedule schedule(scope.main_zone());
417 417
418 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, 1)); 418 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, 1));
419 SmartPointer<TestLoop> loop2(CreateLoop(&schedule, 1)); 419 SmartPointer<TestLoop> loop2(CreateLoop(&schedule, 1));
420 420
421 BasicBlock* A = schedule.entry(); 421 BasicBlock* A = schedule.start();
422 BasicBlock* B = schedule.NewBasicBlock(); 422 BasicBlock* B = schedule.NewBasicBlock();
423 BasicBlock* C = schedule.NewBasicBlock(); 423 BasicBlock* C = schedule.NewBasicBlock();
424 BasicBlock* E = schedule.exit(); 424 BasicBlock* E = schedule.end();
425 425
426 schedule.AddSuccessor(A, B); 426 schedule.AddSuccessor(A, B);
427 schedule.AddSuccessor(B, loop1->header()); 427 schedule.AddSuccessor(B, loop1->header());
428 schedule.AddSuccessor(loop1->header(), loop2->header()); 428 schedule.AddSuccessor(loop1->header(), loop2->header());
429 schedule.AddSuccessor(loop2->last(), C); 429 schedule.AddSuccessor(loop2->last(), C);
430 schedule.AddSuccessor(C, E); 430 schedule.AddSuccessor(C, E);
431 schedule.AddSuccessor(C, B); 431 schedule.AddSuccessor(C, B);
432 432
433 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&schedule); 433 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&schedule);
434 434
435 CheckLoopContains(loop1->nodes, loop1->count); 435 CheckLoopContains(loop1->nodes, loop1->count);
436 436
437 CHECK_EQ(schedule.BasicBlockCount(), static_cast<int>(order->size())); 437 CHECK_EQ(schedule.BasicBlockCount(), static_cast<int>(order->size()));
438 CheckLoopContains(loop1->nodes, loop1->count); 438 CheckLoopContains(loop1->nodes, loop1->count);
439 CheckLoopContains(loop2->nodes, loop2->count); 439 CheckLoopContains(loop2->nodes, loop2->count);
440 440
441 BasicBlock* loop3[] = {B, loop1->nodes[0], loop2->nodes[0], C}; 441 BasicBlock* loop3[] = {B, loop1->nodes[0], loop2->nodes[0], C};
442 CheckLoopContains(loop3, 4); 442 CheckLoopContains(loop3, 4);
443 } 443 }
444 444
445 445
446 TEST(RPOLoopBackedges1) { 446 TEST(RPOLoopBackedges1) {
447 HandleAndZoneScope scope; 447 HandleAndZoneScope scope;
448 448
449 int size = 8; 449 int size = 8;
450 for (int i = 0; i < size; i++) { 450 for (int i = 0; i < size; i++) {
451 for (int j = 0; j < size; j++) { 451 for (int j = 0; j < size; j++) {
452 Schedule schedule(scope.main_zone()); 452 Schedule schedule(scope.main_zone());
453 BasicBlock* A = schedule.entry(); 453 BasicBlock* A = schedule.start();
454 BasicBlock* E = schedule.exit(); 454 BasicBlock* E = schedule.end();
455 455
456 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, size)); 456 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, size));
457 schedule.AddSuccessor(A, loop1->header()); 457 schedule.AddSuccessor(A, loop1->header());
458 schedule.AddSuccessor(loop1->last(), E); 458 schedule.AddSuccessor(loop1->last(), E);
459 459
460 schedule.AddSuccessor(loop1->nodes[i], loop1->header()); 460 schedule.AddSuccessor(loop1->nodes[i], loop1->header());
461 schedule.AddSuccessor(loop1->nodes[j], E); 461 schedule.AddSuccessor(loop1->nodes[j], E);
462 462
463 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&schedule); 463 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&schedule);
464 CheckRPONumbers(order, schedule.BasicBlockCount(), true); 464 CheckRPONumbers(order, schedule.BasicBlockCount(), true);
465 CheckLoopContains(loop1->nodes, loop1->count); 465 CheckLoopContains(loop1->nodes, loop1->count);
466 } 466 }
467 } 467 }
468 } 468 }
469 469
470 470
471 TEST(RPOLoopOutedges1) { 471 TEST(RPOLoopOutedges1) {
472 HandleAndZoneScope scope; 472 HandleAndZoneScope scope;
473 473
474 int size = 8; 474 int size = 8;
475 for (int i = 0; i < size; i++) { 475 for (int i = 0; i < size; i++) {
476 for (int j = 0; j < size; j++) { 476 for (int j = 0; j < size; j++) {
477 Schedule schedule(scope.main_zone()); 477 Schedule schedule(scope.main_zone());
478 BasicBlock* A = schedule.entry(); 478 BasicBlock* A = schedule.start();
479 BasicBlock* D = schedule.NewBasicBlock(); 479 BasicBlock* D = schedule.NewBasicBlock();
480 BasicBlock* E = schedule.exit(); 480 BasicBlock* E = schedule.end();
481 481
482 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, size)); 482 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, size));
483 schedule.AddSuccessor(A, loop1->header()); 483 schedule.AddSuccessor(A, loop1->header());
484 schedule.AddSuccessor(loop1->last(), E); 484 schedule.AddSuccessor(loop1->last(), E);
485 485
486 schedule.AddSuccessor(loop1->nodes[i], loop1->header()); 486 schedule.AddSuccessor(loop1->nodes[i], loop1->header());
487 schedule.AddSuccessor(loop1->nodes[j], D); 487 schedule.AddSuccessor(loop1->nodes[j], D);
488 schedule.AddSuccessor(D, E); 488 schedule.AddSuccessor(D, E);
489 489
490 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&schedule); 490 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&schedule);
491 CheckRPONumbers(order, schedule.BasicBlockCount(), true); 491 CheckRPONumbers(order, schedule.BasicBlockCount(), true);
492 CheckLoopContains(loop1->nodes, loop1->count); 492 CheckLoopContains(loop1->nodes, loop1->count);
493 } 493 }
494 } 494 }
495 } 495 }
496 496
497 497
498 TEST(RPOLoopOutedges2) { 498 TEST(RPOLoopOutedges2) {
499 HandleAndZoneScope scope; 499 HandleAndZoneScope scope;
500 500
501 int size = 8; 501 int size = 8;
502 for (int i = 0; i < size; i++) { 502 for (int i = 0; i < size; i++) {
503 Schedule schedule(scope.main_zone()); 503 Schedule schedule(scope.main_zone());
504 BasicBlock* A = schedule.entry(); 504 BasicBlock* A = schedule.start();
505 BasicBlock* E = schedule.exit(); 505 BasicBlock* E = schedule.end();
506 506
507 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, size)); 507 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, size));
508 schedule.AddSuccessor(A, loop1->header()); 508 schedule.AddSuccessor(A, loop1->header());
509 schedule.AddSuccessor(loop1->last(), E); 509 schedule.AddSuccessor(loop1->last(), E);
510 510
511 for (int j = 0; j < size; j++) { 511 for (int j = 0; j < size; j++) {
512 BasicBlock* O = schedule.NewBasicBlock(); 512 BasicBlock* O = schedule.NewBasicBlock();
513 schedule.AddSuccessor(loop1->nodes[j], O); 513 schedule.AddSuccessor(loop1->nodes[j], O);
514 schedule.AddSuccessor(O, E); 514 schedule.AddSuccessor(O, E);
515 } 515 }
516 516
517 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&schedule); 517 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&schedule);
518 CheckRPONumbers(order, schedule.BasicBlockCount(), true); 518 CheckRPONumbers(order, schedule.BasicBlockCount(), true);
519 CheckLoopContains(loop1->nodes, loop1->count); 519 CheckLoopContains(loop1->nodes, loop1->count);
520 } 520 }
521 } 521 }
522 522
523 523
524 TEST(RPOLoopOutloops1) { 524 TEST(RPOLoopOutloops1) {
525 HandleAndZoneScope scope; 525 HandleAndZoneScope scope;
526 526
527 int size = 8; 527 int size = 8;
528 for (int i = 0; i < size; i++) { 528 for (int i = 0; i < size; i++) {
529 Schedule schedule(scope.main_zone()); 529 Schedule schedule(scope.main_zone());
530 BasicBlock* A = schedule.entry(); 530 BasicBlock* A = schedule.start();
531 BasicBlock* E = schedule.exit(); 531 BasicBlock* E = schedule.end();
532 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, size)); 532 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, size));
533 schedule.AddSuccessor(A, loop1->header()); 533 schedule.AddSuccessor(A, loop1->header());
534 schedule.AddSuccessor(loop1->last(), E); 534 schedule.AddSuccessor(loop1->last(), E);
535 535
536 TestLoop** loopN = new TestLoop* [size]; 536 TestLoop** loopN = new TestLoop* [size];
537 for (int j = 0; j < size; j++) { 537 for (int j = 0; j < size; j++) {
538 loopN[j] = CreateLoop(&schedule, 2); 538 loopN[j] = CreateLoop(&schedule, 2);
539 schedule.AddSuccessor(loop1->nodes[j], loopN[j]->header()); 539 schedule.AddSuccessor(loop1->nodes[j], loopN[j]->header());
540 schedule.AddSuccessor(loopN[j]->last(), E); 540 schedule.AddSuccessor(loopN[j]->last(), E);
541 } 541 }
542 542
543 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&schedule); 543 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&schedule);
544 CheckRPONumbers(order, schedule.BasicBlockCount(), true); 544 CheckRPONumbers(order, schedule.BasicBlockCount(), true);
545 CheckLoopContains(loop1->nodes, loop1->count); 545 CheckLoopContains(loop1->nodes, loop1->count);
546 546
547 for (int j = 0; j < size; j++) { 547 for (int j = 0; j < size; j++) {
548 CheckLoopContains(loopN[j]->nodes, loopN[j]->count); 548 CheckLoopContains(loopN[j]->nodes, loopN[j]->count);
549 delete loopN[j]; 549 delete loopN[j];
550 } 550 }
551 delete[] loopN; 551 delete[] loopN;
552 } 552 }
553 } 553 }
554 554
555 555
556 TEST(RPOLoopMultibackedge) { 556 TEST(RPOLoopMultibackedge) {
557 HandleAndZoneScope scope; 557 HandleAndZoneScope scope;
558 Schedule schedule(scope.main_zone()); 558 Schedule schedule(scope.main_zone());
559 559
560 BasicBlock* A = schedule.entry(); 560 BasicBlock* A = schedule.start();
561 BasicBlock* B = schedule.NewBasicBlock(); 561 BasicBlock* B = schedule.NewBasicBlock();
562 BasicBlock* C = schedule.NewBasicBlock(); 562 BasicBlock* C = schedule.NewBasicBlock();
563 BasicBlock* D = schedule.exit(); 563 BasicBlock* D = schedule.end();
564 BasicBlock* E = schedule.NewBasicBlock(); 564 BasicBlock* E = schedule.NewBasicBlock();
565 565
566 schedule.AddSuccessor(A, B); 566 schedule.AddSuccessor(A, B);
567 schedule.AddSuccessor(B, C); 567 schedule.AddSuccessor(B, C);
568 schedule.AddSuccessor(B, D); 568 schedule.AddSuccessor(B, D);
569 schedule.AddSuccessor(B, E); 569 schedule.AddSuccessor(B, E);
570 schedule.AddSuccessor(C, B); 570 schedule.AddSuccessor(C, B);
571 schedule.AddSuccessor(D, B); 571 schedule.AddSuccessor(D, B);
572 schedule.AddSuccessor(E, B); 572 schedule.AddSuccessor(E, B);
573 573
(...skipping 1226 matching lines...) Expand 10 before | Expand all | Expand 10 after
1800 CHECK_EQ(deoptimization_node, deopt_block->control_input_); 1800 CHECK_EQ(deoptimization_node, deopt_block->control_input_);
1801 CHECK_EQ(5, static_cast<int>(deopt_block->nodes_.size())); 1801 CHECK_EQ(5, static_cast<int>(deopt_block->nodes_.size()));
1802 CHECK_EQ(lazy_deopt_node, deopt_block->nodes_[0]); 1802 CHECK_EQ(lazy_deopt_node, deopt_block->nodes_[0]);
1803 CHECK_EQ(IrOpcode::kStateValues, deopt_block->nodes_[1]->op()->opcode()); 1803 CHECK_EQ(IrOpcode::kStateValues, deopt_block->nodes_[1]->op()->opcode());
1804 CHECK_EQ(IrOpcode::kStateValues, deopt_block->nodes_[2]->op()->opcode()); 1804 CHECK_EQ(IrOpcode::kStateValues, deopt_block->nodes_[2]->op()->opcode());
1805 CHECK_EQ(IrOpcode::kStateValues, deopt_block->nodes_[3]->op()->opcode()); 1805 CHECK_EQ(IrOpcode::kStateValues, deopt_block->nodes_[3]->op()->opcode());
1806 CHECK_EQ(state_node, deopt_block->nodes_[4]); 1806 CHECK_EQ(state_node, deopt_block->nodes_[4]);
1807 } 1807 }
1808 1808
1809 #endif 1809 #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