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

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

Issue 460633002: Remove duplication in Scheduler and simplify interface. Make ComputeSchedule() and ComputeSpecialRP… (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-instruction.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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 CHECK(num >= header->rpo_number_ && num < header->loop_end_); 61 CHECK(num >= header->rpo_number_ && num < header->loop_end_);
62 CHECK(header->LoopContains(blocks[i])); 62 CHECK(header->LoopContains(blocks[i]));
63 CHECK(header->IsLoopHeader() || blocks[i]->loop_header_ == header); 63 CHECK(header->IsLoopHeader() || blocks[i]->loop_header_ == header);
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 Scheduler scheduler(scope.main_zone(), NULL, &schedule);
72 71
73 BasicBlockVector* order = scheduler.ComputeSpecialRPO(); 72 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&schedule);
74 CheckRPONumbers(order, 1, false); 73 CheckRPONumbers(order, 1, false);
75 CHECK_EQ(schedule.entry(), order->at(0)); 74 CHECK_EQ(schedule.entry(), order->at(0));
76 } 75 }
77 76
78 77
79 TEST(RPODegenerate2) { 78 TEST(RPODegenerate2) {
80 HandleAndZoneScope scope; 79 HandleAndZoneScope scope;
81 Schedule schedule(scope.main_zone()); 80 Schedule schedule(scope.main_zone());
82 Scheduler scheduler(scope.main_zone(), NULL, &schedule);
83 81
84 schedule.AddGoto(schedule.entry(), schedule.exit()); 82 schedule.AddGoto(schedule.entry(), schedule.exit());
85 BasicBlockVector* order = scheduler.ComputeSpecialRPO(); 83 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&schedule);
86 CheckRPONumbers(order, 2, false); 84 CheckRPONumbers(order, 2, false);
87 CHECK_EQ(schedule.entry(), order->at(0)); 85 CHECK_EQ(schedule.entry(), order->at(0));
88 CHECK_EQ(schedule.exit(), order->at(1)); 86 CHECK_EQ(schedule.exit(), order->at(1));
89 } 87 }
90 88
91 89
92 TEST(RPOLine) { 90 TEST(RPOLine) {
93 HandleAndZoneScope scope; 91 HandleAndZoneScope scope;
94 92
95 for (int i = 0; i < 10; i++) { 93 for (int i = 0; i < 10; i++) {
96 Schedule schedule(scope.main_zone()); 94 Schedule schedule(scope.main_zone());
97 Scheduler scheduler(scope.main_zone(), NULL, &schedule);
98 95
99 BasicBlock* last = schedule.entry(); 96 BasicBlock* last = schedule.entry();
100 for (int j = 0; j < i; j++) { 97 for (int j = 0; j < i; j++) {
101 BasicBlock* block = schedule.NewBasicBlock(); 98 BasicBlock* block = schedule.NewBasicBlock();
102 schedule.AddGoto(last, block); 99 schedule.AddGoto(last, block);
103 last = block; 100 last = block;
104 } 101 }
105 BasicBlockVector* order = scheduler.ComputeSpecialRPO(); 102 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&schedule);
106 CheckRPONumbers(order, 1 + i, false); 103 CheckRPONumbers(order, 1 + i, false);
107 104
108 Schedule::BasicBlocks blocks(schedule.all_blocks()); 105 Schedule::BasicBlocks blocks(schedule.all_blocks());
109 for (Schedule::BasicBlocks::iterator iter = blocks.begin(); 106 for (Schedule::BasicBlocks::iterator iter = blocks.begin();
110 iter != blocks.end(); ++iter) { 107 iter != blocks.end(); ++iter) {
111 BasicBlock* block = *iter; 108 BasicBlock* block = *iter;
112 if (block->rpo_number_ >= 0 && block->SuccessorCount() == 1) { 109 if (block->rpo_number_ >= 0 && block->SuccessorCount() == 1) {
113 CHECK(block->rpo_number_ + 1 == block->SuccessorAt(0)->rpo_number_); 110 CHECK(block->rpo_number_ + 1 == block->SuccessorAt(0)->rpo_number_);
114 } 111 }
115 } 112 }
116 } 113 }
117 } 114 }
118 115
119 116
120 TEST(RPOSelfLoop) { 117 TEST(RPOSelfLoop) {
121 HandleAndZoneScope scope; 118 HandleAndZoneScope scope;
122 Schedule schedule(scope.main_zone()); 119 Schedule schedule(scope.main_zone());
123 Scheduler scheduler(scope.main_zone(), NULL, &schedule);
124 schedule.AddSuccessor(schedule.entry(), schedule.entry()); 120 schedule.AddSuccessor(schedule.entry(), schedule.entry());
125 BasicBlockVector* order = scheduler.ComputeSpecialRPO(); 121 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&schedule);
126 CheckRPONumbers(order, 1, true); 122 CheckRPONumbers(order, 1, true);
127 BasicBlock* loop[] = {schedule.entry()}; 123 BasicBlock* loop[] = {schedule.entry()};
128 CheckLoopContains(loop, 1); 124 CheckLoopContains(loop, 1);
129 } 125 }
130 126
131 127
132 TEST(RPOEntryLoop) { 128 TEST(RPOEntryLoop) {
133 HandleAndZoneScope scope; 129 HandleAndZoneScope scope;
134 Schedule schedule(scope.main_zone()); 130 Schedule schedule(scope.main_zone());
135 Scheduler scheduler(scope.main_zone(), NULL, &schedule);
136 schedule.AddSuccessor(schedule.entry(), schedule.exit()); 131 schedule.AddSuccessor(schedule.entry(), schedule.exit());
137 schedule.AddSuccessor(schedule.exit(), schedule.entry()); 132 schedule.AddSuccessor(schedule.exit(), schedule.entry());
138 BasicBlockVector* order = scheduler.ComputeSpecialRPO(); 133 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&schedule);
139 CheckRPONumbers(order, 2, true); 134 CheckRPONumbers(order, 2, true);
140 BasicBlock* loop[] = {schedule.entry(), schedule.exit()}; 135 BasicBlock* loop[] = {schedule.entry(), schedule.exit()};
141 CheckLoopContains(loop, 2); 136 CheckLoopContains(loop, 2);
142 } 137 }
143 138
144 139
145 TEST(RPOEndLoop) { 140 TEST(RPOEndLoop) {
146 HandleAndZoneScope scope; 141 HandleAndZoneScope scope;
147 Schedule schedule(scope.main_zone()); 142 Schedule schedule(scope.main_zone());
148 Scheduler scheduler(scope.main_zone(), NULL, &schedule);
149 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, 2)); 143 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, 2));
150 schedule.AddSuccessor(schedule.entry(), loop1->header()); 144 schedule.AddSuccessor(schedule.entry(), loop1->header());
151 BasicBlockVector* order = scheduler.ComputeSpecialRPO(); 145 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&schedule);
152 CheckRPONumbers(order, 3, true); 146 CheckRPONumbers(order, 3, true);
153 CheckLoopContains(loop1->nodes, loop1->count); 147 CheckLoopContains(loop1->nodes, loop1->count);
154 } 148 }
155 149
156 150
157 TEST(RPOEndLoopNested) { 151 TEST(RPOEndLoopNested) {
158 HandleAndZoneScope scope; 152 HandleAndZoneScope scope;
159 Schedule schedule(scope.main_zone()); 153 Schedule schedule(scope.main_zone());
160 Scheduler scheduler(scope.main_zone(), NULL, &schedule);
161 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, 2)); 154 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, 2));
162 schedule.AddSuccessor(schedule.entry(), loop1->header()); 155 schedule.AddSuccessor(schedule.entry(), loop1->header());
163 schedule.AddSuccessor(loop1->last(), schedule.entry()); 156 schedule.AddSuccessor(loop1->last(), schedule.entry());
164 BasicBlockVector* order = scheduler.ComputeSpecialRPO(); 157 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&schedule);
165 CheckRPONumbers(order, 3, true); 158 CheckRPONumbers(order, 3, true);
166 CheckLoopContains(loop1->nodes, loop1->count); 159 CheckLoopContains(loop1->nodes, loop1->count);
167 } 160 }
168 161
169 162
170 TEST(RPODiamond) { 163 TEST(RPODiamond) {
171 HandleAndZoneScope scope; 164 HandleAndZoneScope scope;
172 Schedule schedule(scope.main_zone()); 165 Schedule schedule(scope.main_zone());
173 Scheduler scheduler(scope.main_zone(), NULL, &schedule);
174 166
175 BasicBlock* A = schedule.entry(); 167 BasicBlock* A = schedule.entry();
176 BasicBlock* B = schedule.NewBasicBlock(); 168 BasicBlock* B = schedule.NewBasicBlock();
177 BasicBlock* C = schedule.NewBasicBlock(); 169 BasicBlock* C = schedule.NewBasicBlock();
178 BasicBlock* D = schedule.exit(); 170 BasicBlock* D = schedule.exit();
179 171
180 schedule.AddSuccessor(A, B); 172 schedule.AddSuccessor(A, B);
181 schedule.AddSuccessor(A, C); 173 schedule.AddSuccessor(A, C);
182 schedule.AddSuccessor(B, D); 174 schedule.AddSuccessor(B, D);
183 schedule.AddSuccessor(C, D); 175 schedule.AddSuccessor(C, D);
184 176
185 BasicBlockVector* order = scheduler.ComputeSpecialRPO(); 177 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&schedule);
186 CheckRPONumbers(order, 4, false); 178 CheckRPONumbers(order, 4, false);
187 179
188 CHECK_EQ(0, A->rpo_number_); 180 CHECK_EQ(0, A->rpo_number_);
189 CHECK((B->rpo_number_ == 1 && C->rpo_number_ == 2) || 181 CHECK((B->rpo_number_ == 1 && C->rpo_number_ == 2) ||
190 (B->rpo_number_ == 2 && C->rpo_number_ == 1)); 182 (B->rpo_number_ == 2 && C->rpo_number_ == 1));
191 CHECK_EQ(3, D->rpo_number_); 183 CHECK_EQ(3, D->rpo_number_);
192 } 184 }
193 185
194 186
195 TEST(RPOLoop1) { 187 TEST(RPOLoop1) {
196 HandleAndZoneScope scope; 188 HandleAndZoneScope scope;
197 Schedule schedule(scope.main_zone()); 189 Schedule schedule(scope.main_zone());
198 Scheduler scheduler(scope.main_zone(), NULL, &schedule);
199 190
200 BasicBlock* A = schedule.entry(); 191 BasicBlock* A = schedule.entry();
201 BasicBlock* B = schedule.NewBasicBlock(); 192 BasicBlock* B = schedule.NewBasicBlock();
202 BasicBlock* C = schedule.NewBasicBlock(); 193 BasicBlock* C = schedule.NewBasicBlock();
203 BasicBlock* D = schedule.exit(); 194 BasicBlock* D = schedule.exit();
204 195
205 schedule.AddSuccessor(A, B); 196 schedule.AddSuccessor(A, B);
206 schedule.AddSuccessor(B, C); 197 schedule.AddSuccessor(B, C);
207 schedule.AddSuccessor(C, B); 198 schedule.AddSuccessor(C, B);
208 schedule.AddSuccessor(C, D); 199 schedule.AddSuccessor(C, D);
209 200
210 BasicBlockVector* order = scheduler.ComputeSpecialRPO(); 201 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&schedule);
211 CheckRPONumbers(order, 4, true); 202 CheckRPONumbers(order, 4, true);
212 BasicBlock* loop[] = {B, C}; 203 BasicBlock* loop[] = {B, C};
213 CheckLoopContains(loop, 2); 204 CheckLoopContains(loop, 2);
214 } 205 }
215 206
216 207
217 TEST(RPOLoop2) { 208 TEST(RPOLoop2) {
218 HandleAndZoneScope scope; 209 HandleAndZoneScope scope;
219 Schedule schedule(scope.main_zone()); 210 Schedule schedule(scope.main_zone());
220 Scheduler scheduler(scope.main_zone(), NULL, &schedule);
221 211
222 BasicBlock* A = schedule.entry(); 212 BasicBlock* A = schedule.entry();
223 BasicBlock* B = schedule.NewBasicBlock(); 213 BasicBlock* B = schedule.NewBasicBlock();
224 BasicBlock* C = schedule.NewBasicBlock(); 214 BasicBlock* C = schedule.NewBasicBlock();
225 BasicBlock* D = schedule.exit(); 215 BasicBlock* D = schedule.exit();
226 216
227 schedule.AddSuccessor(A, B); 217 schedule.AddSuccessor(A, B);
228 schedule.AddSuccessor(B, C); 218 schedule.AddSuccessor(B, C);
229 schedule.AddSuccessor(C, B); 219 schedule.AddSuccessor(C, B);
230 schedule.AddSuccessor(B, D); 220 schedule.AddSuccessor(B, D);
231 221
232 BasicBlockVector* order = scheduler.ComputeSpecialRPO(); 222 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&schedule);
233 CheckRPONumbers(order, 4, true); 223 CheckRPONumbers(order, 4, true);
234 BasicBlock* loop[] = {B, C}; 224 BasicBlock* loop[] = {B, C};
235 CheckLoopContains(loop, 2); 225 CheckLoopContains(loop, 2);
236 } 226 }
237 227
238 228
239 TEST(RPOLoopN) { 229 TEST(RPOLoopN) {
240 HandleAndZoneScope scope; 230 HandleAndZoneScope scope;
241 231
242 for (int i = 0; i < 11; i++) { 232 for (int i = 0; i < 11; i++) {
243 Schedule schedule(scope.main_zone()); 233 Schedule schedule(scope.main_zone());
244 Scheduler scheduler(scope.main_zone(), NULL, &schedule);
245 BasicBlock* A = schedule.entry(); 234 BasicBlock* A = schedule.entry();
246 BasicBlock* B = schedule.NewBasicBlock(); 235 BasicBlock* B = schedule.NewBasicBlock();
247 BasicBlock* C = schedule.NewBasicBlock(); 236 BasicBlock* C = schedule.NewBasicBlock();
248 BasicBlock* D = schedule.NewBasicBlock(); 237 BasicBlock* D = schedule.NewBasicBlock();
249 BasicBlock* E = schedule.NewBasicBlock(); 238 BasicBlock* E = schedule.NewBasicBlock();
250 BasicBlock* F = schedule.NewBasicBlock(); 239 BasicBlock* F = schedule.NewBasicBlock();
251 BasicBlock* G = schedule.exit(); 240 BasicBlock* G = schedule.exit();
252 241
253 schedule.AddSuccessor(A, B); 242 schedule.AddSuccessor(A, B);
254 schedule.AddSuccessor(B, C); 243 schedule.AddSuccessor(B, C);
(...skipping 10 matching lines...) Expand all
265 if (i == 4) schedule.AddSuccessor(E, B); 254 if (i == 4) schedule.AddSuccessor(E, B);
266 if (i == 5) schedule.AddSuccessor(F, B); 255 if (i == 5) schedule.AddSuccessor(F, B);
267 256
268 // Throw in extra loop exits from time to time. 257 // Throw in extra loop exits from time to time.
269 if (i == 6) schedule.AddSuccessor(B, G); 258 if (i == 6) schedule.AddSuccessor(B, G);
270 if (i == 7) schedule.AddSuccessor(C, G); 259 if (i == 7) schedule.AddSuccessor(C, G);
271 if (i == 8) schedule.AddSuccessor(D, G); 260 if (i == 8) schedule.AddSuccessor(D, G);
272 if (i == 9) schedule.AddSuccessor(E, G); 261 if (i == 9) schedule.AddSuccessor(E, G);
273 if (i == 10) schedule.AddSuccessor(F, G); 262 if (i == 10) schedule.AddSuccessor(F, G);
274 263
275 BasicBlockVector* order = scheduler.ComputeSpecialRPO(); 264 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&schedule);
276 CheckRPONumbers(order, 7, true); 265 CheckRPONumbers(order, 7, true);
277 BasicBlock* loop[] = {B, C, D, E, F}; 266 BasicBlock* loop[] = {B, C, D, E, F};
278 CheckLoopContains(loop, 5); 267 CheckLoopContains(loop, 5);
279 } 268 }
280 } 269 }
281 270
282 271
283 TEST(RPOLoopNest1) { 272 TEST(RPOLoopNest1) {
284 HandleAndZoneScope scope; 273 HandleAndZoneScope scope;
285 Schedule schedule(scope.main_zone()); 274 Schedule schedule(scope.main_zone());
286 Scheduler scheduler(scope.main_zone(), NULL, &schedule);
287 275
288 BasicBlock* A = schedule.entry(); 276 BasicBlock* A = schedule.entry();
289 BasicBlock* B = schedule.NewBasicBlock(); 277 BasicBlock* B = schedule.NewBasicBlock();
290 BasicBlock* C = schedule.NewBasicBlock(); 278 BasicBlock* C = schedule.NewBasicBlock();
291 BasicBlock* D = schedule.NewBasicBlock(); 279 BasicBlock* D = schedule.NewBasicBlock();
292 BasicBlock* E = schedule.NewBasicBlock(); 280 BasicBlock* E = schedule.NewBasicBlock();
293 BasicBlock* F = schedule.exit(); 281 BasicBlock* F = schedule.exit();
294 282
295 schedule.AddSuccessor(A, B); 283 schedule.AddSuccessor(A, B);
296 schedule.AddSuccessor(B, C); 284 schedule.AddSuccessor(B, C);
297 schedule.AddSuccessor(C, D); 285 schedule.AddSuccessor(C, D);
298 schedule.AddSuccessor(D, C); 286 schedule.AddSuccessor(D, C);
299 schedule.AddSuccessor(D, E); 287 schedule.AddSuccessor(D, E);
300 schedule.AddSuccessor(E, B); 288 schedule.AddSuccessor(E, B);
301 schedule.AddSuccessor(E, F); 289 schedule.AddSuccessor(E, F);
302 290
303 BasicBlockVector* order = scheduler.ComputeSpecialRPO(); 291 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&schedule);
304 CheckRPONumbers(order, 6, true); 292 CheckRPONumbers(order, 6, true);
305 BasicBlock* loop1[] = {B, C, D, E}; 293 BasicBlock* loop1[] = {B, C, D, E};
306 CheckLoopContains(loop1, 4); 294 CheckLoopContains(loop1, 4);
307 295
308 BasicBlock* loop2[] = {C, D}; 296 BasicBlock* loop2[] = {C, D};
309 CheckLoopContains(loop2, 2); 297 CheckLoopContains(loop2, 2);
310 } 298 }
311 299
312 300
313 TEST(RPOLoopNest2) { 301 TEST(RPOLoopNest2) {
314 HandleAndZoneScope scope; 302 HandleAndZoneScope scope;
315 Schedule schedule(scope.main_zone()); 303 Schedule schedule(scope.main_zone());
316 Scheduler scheduler(scope.main_zone(), NULL, &schedule);
317 304
318 BasicBlock* A = schedule.entry(); 305 BasicBlock* A = schedule.entry();
319 BasicBlock* B = schedule.NewBasicBlock(); 306 BasicBlock* B = schedule.NewBasicBlock();
320 BasicBlock* C = schedule.NewBasicBlock(); 307 BasicBlock* C = schedule.NewBasicBlock();
321 BasicBlock* D = schedule.NewBasicBlock(); 308 BasicBlock* D = schedule.NewBasicBlock();
322 BasicBlock* E = schedule.NewBasicBlock(); 309 BasicBlock* E = schedule.NewBasicBlock();
323 BasicBlock* F = schedule.NewBasicBlock(); 310 BasicBlock* F = schedule.NewBasicBlock();
324 BasicBlock* G = schedule.NewBasicBlock(); 311 BasicBlock* G = schedule.NewBasicBlock();
325 BasicBlock* H = schedule.exit(); 312 BasicBlock* H = schedule.exit();
326 313
327 schedule.AddSuccessor(A, B); 314 schedule.AddSuccessor(A, B);
328 schedule.AddSuccessor(B, C); 315 schedule.AddSuccessor(B, C);
329 schedule.AddSuccessor(C, D); 316 schedule.AddSuccessor(C, D);
330 schedule.AddSuccessor(D, E); 317 schedule.AddSuccessor(D, E);
331 schedule.AddSuccessor(E, F); 318 schedule.AddSuccessor(E, F);
332 schedule.AddSuccessor(F, G); 319 schedule.AddSuccessor(F, G);
333 schedule.AddSuccessor(G, H); 320 schedule.AddSuccessor(G, H);
334 321
335 schedule.AddSuccessor(E, D); 322 schedule.AddSuccessor(E, D);
336 schedule.AddSuccessor(F, C); 323 schedule.AddSuccessor(F, C);
337 schedule.AddSuccessor(G, B); 324 schedule.AddSuccessor(G, B);
338 325
339 BasicBlockVector* order = scheduler.ComputeSpecialRPO(); 326 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&schedule);
340 CheckRPONumbers(order, 8, true); 327 CheckRPONumbers(order, 8, true);
341 BasicBlock* loop1[] = {B, C, D, E, F, G}; 328 BasicBlock* loop1[] = {B, C, D, E, F, G};
342 CheckLoopContains(loop1, 6); 329 CheckLoopContains(loop1, 6);
343 330
344 BasicBlock* loop2[] = {C, D, E, F}; 331 BasicBlock* loop2[] = {C, D, E, F};
345 CheckLoopContains(loop2, 4); 332 CheckLoopContains(loop2, 4);
346 333
347 BasicBlock* loop3[] = {D, E}; 334 BasicBlock* loop3[] = {D, E};
348 CheckLoopContains(loop3, 2); 335 CheckLoopContains(loop3, 2);
349 } 336 }
350 337
351 338
352 TEST(RPOLoopFollow1) { 339 TEST(RPOLoopFollow1) {
353 HandleAndZoneScope scope; 340 HandleAndZoneScope scope;
354 Schedule schedule(scope.main_zone()); 341 Schedule schedule(scope.main_zone());
355 Scheduler scheduler(scope.main_zone(), NULL, &schedule);
356 342
357 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, 1)); 343 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, 1));
358 SmartPointer<TestLoop> loop2(CreateLoop(&schedule, 1)); 344 SmartPointer<TestLoop> loop2(CreateLoop(&schedule, 1));
359 345
360 BasicBlock* A = schedule.entry(); 346 BasicBlock* A = schedule.entry();
361 BasicBlock* E = schedule.exit(); 347 BasicBlock* E = schedule.exit();
362 348
363 schedule.AddSuccessor(A, loop1->header()); 349 schedule.AddSuccessor(A, loop1->header());
364 schedule.AddSuccessor(loop1->header(), loop2->header()); 350 schedule.AddSuccessor(loop1->header(), loop2->header());
365 schedule.AddSuccessor(loop2->last(), E); 351 schedule.AddSuccessor(loop2->last(), E);
366 352
367 BasicBlockVector* order = scheduler.ComputeSpecialRPO(); 353 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&schedule);
368 354
369 CheckLoopContains(loop1->nodes, loop1->count); 355 CheckLoopContains(loop1->nodes, loop1->count);
370 356
371 CHECK_EQ(schedule.BasicBlockCount(), static_cast<int>(order->size())); 357 CHECK_EQ(schedule.BasicBlockCount(), static_cast<int>(order->size()));
372 CheckLoopContains(loop1->nodes, loop1->count); 358 CheckLoopContains(loop1->nodes, loop1->count);
373 CheckLoopContains(loop2->nodes, loop2->count); 359 CheckLoopContains(loop2->nodes, loop2->count);
374 } 360 }
375 361
376 362
377 TEST(RPOLoopFollow2) { 363 TEST(RPOLoopFollow2) {
378 HandleAndZoneScope scope; 364 HandleAndZoneScope scope;
379 Schedule schedule(scope.main_zone()); 365 Schedule schedule(scope.main_zone());
380 Scheduler scheduler(scope.main_zone(), NULL, &schedule);
381 366
382 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, 1)); 367 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, 1));
383 SmartPointer<TestLoop> loop2(CreateLoop(&schedule, 1)); 368 SmartPointer<TestLoop> loop2(CreateLoop(&schedule, 1));
384 369
385 BasicBlock* A = schedule.entry(); 370 BasicBlock* A = schedule.entry();
386 BasicBlock* S = schedule.NewBasicBlock(); 371 BasicBlock* S = schedule.NewBasicBlock();
387 BasicBlock* E = schedule.exit(); 372 BasicBlock* E = schedule.exit();
388 373
389 schedule.AddSuccessor(A, loop1->header()); 374 schedule.AddSuccessor(A, loop1->header());
390 schedule.AddSuccessor(loop1->header(), S); 375 schedule.AddSuccessor(loop1->header(), S);
391 schedule.AddSuccessor(S, loop2->header()); 376 schedule.AddSuccessor(S, loop2->header());
392 schedule.AddSuccessor(loop2->last(), E); 377 schedule.AddSuccessor(loop2->last(), E);
393 378
394 BasicBlockVector* order = scheduler.ComputeSpecialRPO(); 379 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&schedule);
395 380
396 CheckLoopContains(loop1->nodes, loop1->count); 381 CheckLoopContains(loop1->nodes, loop1->count);
397 382
398 CHECK_EQ(schedule.BasicBlockCount(), static_cast<int>(order->size())); 383 CHECK_EQ(schedule.BasicBlockCount(), static_cast<int>(order->size()));
399 CheckLoopContains(loop1->nodes, loop1->count); 384 CheckLoopContains(loop1->nodes, loop1->count);
400 CheckLoopContains(loop2->nodes, loop2->count); 385 CheckLoopContains(loop2->nodes, loop2->count);
401 } 386 }
402 387
403 388
404 TEST(RPOLoopFollowN) { 389 TEST(RPOLoopFollowN) {
405 HandleAndZoneScope scope; 390 HandleAndZoneScope scope;
406 391
407 for (int size = 1; size < 5; size++) { 392 for (int size = 1; size < 5; size++) {
408 for (int exit = 0; exit < size; exit++) { 393 for (int exit = 0; exit < size; exit++) {
409 Schedule schedule(scope.main_zone()); 394 Schedule schedule(scope.main_zone());
410 Scheduler scheduler(scope.main_zone(), NULL, &schedule);
411 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, size)); 395 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, size));
412 SmartPointer<TestLoop> loop2(CreateLoop(&schedule, size)); 396 SmartPointer<TestLoop> loop2(CreateLoop(&schedule, size));
413 BasicBlock* A = schedule.entry(); 397 BasicBlock* A = schedule.entry();
414 BasicBlock* E = schedule.exit(); 398 BasicBlock* E = schedule.exit();
415 399
416 schedule.AddSuccessor(A, loop1->header()); 400 schedule.AddSuccessor(A, loop1->header());
417 schedule.AddSuccessor(loop1->nodes[exit], loop2->header()); 401 schedule.AddSuccessor(loop1->nodes[exit], loop2->header());
418 schedule.AddSuccessor(loop2->nodes[exit], E); 402 schedule.AddSuccessor(loop2->nodes[exit], E);
419 BasicBlockVector* order = scheduler.ComputeSpecialRPO(); 403 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&schedule);
420 CheckLoopContains(loop1->nodes, loop1->count); 404 CheckLoopContains(loop1->nodes, loop1->count);
421 405
422 CHECK_EQ(schedule.BasicBlockCount(), static_cast<int>(order->size())); 406 CHECK_EQ(schedule.BasicBlockCount(), static_cast<int>(order->size()));
423 CheckLoopContains(loop1->nodes, loop1->count); 407 CheckLoopContains(loop1->nodes, loop1->count);
424 CheckLoopContains(loop2->nodes, loop2->count); 408 CheckLoopContains(loop2->nodes, loop2->count);
425 } 409 }
426 } 410 }
427 } 411 }
428 412
429 413
430 TEST(RPONestedLoopFollow1) { 414 TEST(RPONestedLoopFollow1) {
431 HandleAndZoneScope scope; 415 HandleAndZoneScope scope;
432 Schedule schedule(scope.main_zone()); 416 Schedule schedule(scope.main_zone());
433 Scheduler scheduler(scope.main_zone(), NULL, &schedule);
434 417
435 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, 1)); 418 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, 1));
436 SmartPointer<TestLoop> loop2(CreateLoop(&schedule, 1)); 419 SmartPointer<TestLoop> loop2(CreateLoop(&schedule, 1));
437 420
438 BasicBlock* A = schedule.entry(); 421 BasicBlock* A = schedule.entry();
439 BasicBlock* B = schedule.NewBasicBlock(); 422 BasicBlock* B = schedule.NewBasicBlock();
440 BasicBlock* C = schedule.NewBasicBlock(); 423 BasicBlock* C = schedule.NewBasicBlock();
441 BasicBlock* E = schedule.exit(); 424 BasicBlock* E = schedule.exit();
442 425
443 schedule.AddSuccessor(A, B); 426 schedule.AddSuccessor(A, B);
444 schedule.AddSuccessor(B, loop1->header()); 427 schedule.AddSuccessor(B, loop1->header());
445 schedule.AddSuccessor(loop1->header(), loop2->header()); 428 schedule.AddSuccessor(loop1->header(), loop2->header());
446 schedule.AddSuccessor(loop2->last(), C); 429 schedule.AddSuccessor(loop2->last(), C);
447 schedule.AddSuccessor(C, E); 430 schedule.AddSuccessor(C, E);
448 schedule.AddSuccessor(C, B); 431 schedule.AddSuccessor(C, B);
449 432
450 BasicBlockVector* order = scheduler.ComputeSpecialRPO(); 433 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&schedule);
451 434
452 CheckLoopContains(loop1->nodes, loop1->count); 435 CheckLoopContains(loop1->nodes, loop1->count);
453 436
454 CHECK_EQ(schedule.BasicBlockCount(), static_cast<int>(order->size())); 437 CHECK_EQ(schedule.BasicBlockCount(), static_cast<int>(order->size()));
455 CheckLoopContains(loop1->nodes, loop1->count); 438 CheckLoopContains(loop1->nodes, loop1->count);
456 CheckLoopContains(loop2->nodes, loop2->count); 439 CheckLoopContains(loop2->nodes, loop2->count);
457 440
458 BasicBlock* loop3[] = {B, loop1->nodes[0], loop2->nodes[0], C}; 441 BasicBlock* loop3[] = {B, loop1->nodes[0], loop2->nodes[0], C};
459 CheckLoopContains(loop3, 4); 442 CheckLoopContains(loop3, 4);
460 } 443 }
461 444
462 445
463 TEST(RPOLoopBackedges1) { 446 TEST(RPOLoopBackedges1) {
464 HandleAndZoneScope scope; 447 HandleAndZoneScope scope;
465 448
466 int size = 8; 449 int size = 8;
467 for (int i = 0; i < size; i++) { 450 for (int i = 0; i < size; i++) {
468 for (int j = 0; j < size; j++) { 451 for (int j = 0; j < size; j++) {
469 Schedule schedule(scope.main_zone()); 452 Schedule schedule(scope.main_zone());
470 Scheduler scheduler(scope.main_zone(), NULL, &schedule);
471 BasicBlock* A = schedule.entry(); 453 BasicBlock* A = schedule.entry();
472 BasicBlock* E = schedule.exit(); 454 BasicBlock* E = schedule.exit();
473 455
474 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, size)); 456 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, size));
475 schedule.AddSuccessor(A, loop1->header()); 457 schedule.AddSuccessor(A, loop1->header());
476 schedule.AddSuccessor(loop1->last(), E); 458 schedule.AddSuccessor(loop1->last(), E);
477 459
478 schedule.AddSuccessor(loop1->nodes[i], loop1->header()); 460 schedule.AddSuccessor(loop1->nodes[i], loop1->header());
479 schedule.AddSuccessor(loop1->nodes[j], E); 461 schedule.AddSuccessor(loop1->nodes[j], E);
480 462
481 BasicBlockVector* order = scheduler.ComputeSpecialRPO(); 463 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&schedule);
482 CheckRPONumbers(order, schedule.BasicBlockCount(), true); 464 CheckRPONumbers(order, schedule.BasicBlockCount(), true);
483 CheckLoopContains(loop1->nodes, loop1->count); 465 CheckLoopContains(loop1->nodes, loop1->count);
484 } 466 }
485 } 467 }
486 } 468 }
487 469
488 470
489 TEST(RPOLoopOutedges1) { 471 TEST(RPOLoopOutedges1) {
490 HandleAndZoneScope scope; 472 HandleAndZoneScope scope;
491 473
492 int size = 8; 474 int size = 8;
493 for (int i = 0; i < size; i++) { 475 for (int i = 0; i < size; i++) {
494 for (int j = 0; j < size; j++) { 476 for (int j = 0; j < size; j++) {
495 Schedule schedule(scope.main_zone()); 477 Schedule schedule(scope.main_zone());
496 Scheduler scheduler(scope.main_zone(), NULL, &schedule);
497 BasicBlock* A = schedule.entry(); 478 BasicBlock* A = schedule.entry();
498 BasicBlock* D = schedule.NewBasicBlock(); 479 BasicBlock* D = schedule.NewBasicBlock();
499 BasicBlock* E = schedule.exit(); 480 BasicBlock* E = schedule.exit();
500 481
501 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, size)); 482 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, size));
502 schedule.AddSuccessor(A, loop1->header()); 483 schedule.AddSuccessor(A, loop1->header());
503 schedule.AddSuccessor(loop1->last(), E); 484 schedule.AddSuccessor(loop1->last(), E);
504 485
505 schedule.AddSuccessor(loop1->nodes[i], loop1->header()); 486 schedule.AddSuccessor(loop1->nodes[i], loop1->header());
506 schedule.AddSuccessor(loop1->nodes[j], D); 487 schedule.AddSuccessor(loop1->nodes[j], D);
507 schedule.AddSuccessor(D, E); 488 schedule.AddSuccessor(D, E);
508 489
509 BasicBlockVector* order = scheduler.ComputeSpecialRPO(); 490 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&schedule);
510 CheckRPONumbers(order, schedule.BasicBlockCount(), true); 491 CheckRPONumbers(order, schedule.BasicBlockCount(), true);
511 CheckLoopContains(loop1->nodes, loop1->count); 492 CheckLoopContains(loop1->nodes, loop1->count);
512 } 493 }
513 } 494 }
514 } 495 }
515 496
516 497
517 TEST(RPOLoopOutedges2) { 498 TEST(RPOLoopOutedges2) {
518 HandleAndZoneScope scope; 499 HandleAndZoneScope scope;
519 500
520 int size = 8; 501 int size = 8;
521 for (int i = 0; i < size; i++) { 502 for (int i = 0; i < size; i++) {
522 Schedule schedule(scope.main_zone()); 503 Schedule schedule(scope.main_zone());
523 Scheduler scheduler(scope.main_zone(), NULL, &schedule);
524 BasicBlock* A = schedule.entry(); 504 BasicBlock* A = schedule.entry();
525 BasicBlock* E = schedule.exit(); 505 BasicBlock* E = schedule.exit();
526 506
527 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, size)); 507 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, size));
528 schedule.AddSuccessor(A, loop1->header()); 508 schedule.AddSuccessor(A, loop1->header());
529 schedule.AddSuccessor(loop1->last(), E); 509 schedule.AddSuccessor(loop1->last(), E);
530 510
531 for (int j = 0; j < size; j++) { 511 for (int j = 0; j < size; j++) {
532 BasicBlock* O = schedule.NewBasicBlock(); 512 BasicBlock* O = schedule.NewBasicBlock();
533 schedule.AddSuccessor(loop1->nodes[j], O); 513 schedule.AddSuccessor(loop1->nodes[j], O);
534 schedule.AddSuccessor(O, E); 514 schedule.AddSuccessor(O, E);
535 } 515 }
536 516
537 BasicBlockVector* order = scheduler.ComputeSpecialRPO(); 517 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&schedule);
538 CheckRPONumbers(order, schedule.BasicBlockCount(), true); 518 CheckRPONumbers(order, schedule.BasicBlockCount(), true);
539 CheckLoopContains(loop1->nodes, loop1->count); 519 CheckLoopContains(loop1->nodes, loop1->count);
540 } 520 }
541 } 521 }
542 522
543 523
544 TEST(RPOLoopOutloops1) { 524 TEST(RPOLoopOutloops1) {
545 HandleAndZoneScope scope; 525 HandleAndZoneScope scope;
546 526
547 int size = 8; 527 int size = 8;
548 for (int i = 0; i < size; i++) { 528 for (int i = 0; i < size; i++) {
549 Schedule schedule(scope.main_zone()); 529 Schedule schedule(scope.main_zone());
550 Scheduler scheduler(scope.main_zone(), NULL, &schedule);
551 BasicBlock* A = schedule.entry(); 530 BasicBlock* A = schedule.entry();
552 BasicBlock* E = schedule.exit(); 531 BasicBlock* E = schedule.exit();
553 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, size)); 532 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, size));
554 schedule.AddSuccessor(A, loop1->header()); 533 schedule.AddSuccessor(A, loop1->header());
555 schedule.AddSuccessor(loop1->last(), E); 534 schedule.AddSuccessor(loop1->last(), E);
556 535
557 TestLoop** loopN = new TestLoop* [size]; 536 TestLoop** loopN = new TestLoop* [size];
558 for (int j = 0; j < size; j++) { 537 for (int j = 0; j < size; j++) {
559 loopN[j] = CreateLoop(&schedule, 2); 538 loopN[j] = CreateLoop(&schedule, 2);
560 schedule.AddSuccessor(loop1->nodes[j], loopN[j]->header()); 539 schedule.AddSuccessor(loop1->nodes[j], loopN[j]->header());
561 schedule.AddSuccessor(loopN[j]->last(), E); 540 schedule.AddSuccessor(loopN[j]->last(), E);
562 } 541 }
563 542
564 BasicBlockVector* order = scheduler.ComputeSpecialRPO(); 543 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&schedule);
565 CheckRPONumbers(order, schedule.BasicBlockCount(), true); 544 CheckRPONumbers(order, schedule.BasicBlockCount(), true);
566 CheckLoopContains(loop1->nodes, loop1->count); 545 CheckLoopContains(loop1->nodes, loop1->count);
567 546
568 for (int j = 0; j < size; j++) { 547 for (int j = 0; j < size; j++) {
569 CheckLoopContains(loopN[j]->nodes, loopN[j]->count); 548 CheckLoopContains(loopN[j]->nodes, loopN[j]->count);
570 delete loopN[j]; 549 delete loopN[j];
571 } 550 }
572 delete[] loopN; 551 delete[] loopN;
573 } 552 }
574 } 553 }
575 554
576 555
577 TEST(RPOLoopMultibackedge) { 556 TEST(RPOLoopMultibackedge) {
578 HandleAndZoneScope scope; 557 HandleAndZoneScope scope;
579 Schedule schedule(scope.main_zone()); 558 Schedule schedule(scope.main_zone());
580 Scheduler scheduler(scope.main_zone(), NULL, &schedule);
581 559
582 BasicBlock* A = schedule.entry(); 560 BasicBlock* A = schedule.entry();
583 BasicBlock* B = schedule.NewBasicBlock(); 561 BasicBlock* B = schedule.NewBasicBlock();
584 BasicBlock* C = schedule.NewBasicBlock(); 562 BasicBlock* C = schedule.NewBasicBlock();
585 BasicBlock* D = schedule.exit(); 563 BasicBlock* D = schedule.exit();
586 BasicBlock* E = schedule.NewBasicBlock(); 564 BasicBlock* E = schedule.NewBasicBlock();
587 565
588 schedule.AddSuccessor(A, B); 566 schedule.AddSuccessor(A, B);
589 schedule.AddSuccessor(B, C); 567 schedule.AddSuccessor(B, C);
590 schedule.AddSuccessor(B, D); 568 schedule.AddSuccessor(B, D);
591 schedule.AddSuccessor(B, E); 569 schedule.AddSuccessor(B, E);
592 schedule.AddSuccessor(C, B); 570 schedule.AddSuccessor(C, B);
593 schedule.AddSuccessor(D, B); 571 schedule.AddSuccessor(D, B);
594 schedule.AddSuccessor(E, B); 572 schedule.AddSuccessor(E, B);
595 573
596 BasicBlockVector* order = scheduler.ComputeSpecialRPO(); 574 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&schedule);
597 CheckRPONumbers(order, 5, true); 575 CheckRPONumbers(order, 5, true);
598 576
599 BasicBlock* loop1[] = {B, C, D, E}; 577 BasicBlock* loop1[] = {B, C, D, E};
600 CheckLoopContains(loop1, 4); 578 CheckLoopContains(loop1, 4);
601 } 579 }
602 580
603 581
604 TEST(BuildScheduleEmpty) { 582 TEST(BuildScheduleEmpty) {
605 HandleAndZoneScope scope; 583 HandleAndZoneScope scope;
606 Graph graph(scope.main_zone()); 584 Graph graph(scope.main_zone());
607 CommonOperatorBuilder builder(scope.main_zone()); 585 CommonOperatorBuilder builder(scope.main_zone());
608 graph.SetStart(graph.NewNode(builder.Start(0))); 586 graph.SetStart(graph.NewNode(builder.Start(0)));
609 graph.SetEnd(graph.NewNode(builder.End(), graph.start())); 587 graph.SetEnd(graph.NewNode(builder.End(), graph.start()));
610 588
611 Scheduler scheduler(scope.main_zone()); 589 USE(Scheduler::ComputeSchedule(&graph));
612 USE(scheduler.NewSchedule(&graph));
613 } 590 }
614 591
615 592
616 TEST(BuildScheduleOneParameter) { 593 TEST(BuildScheduleOneParameter) {
617 HandleAndZoneScope scope; 594 HandleAndZoneScope scope;
618 Graph graph(scope.main_zone()); 595 Graph graph(scope.main_zone());
619 CommonOperatorBuilder builder(scope.main_zone()); 596 CommonOperatorBuilder builder(scope.main_zone());
620 graph.SetStart(graph.NewNode(builder.Start(0))); 597 graph.SetStart(graph.NewNode(builder.Start(0)));
621 598
622 Node* p1 = graph.NewNode(builder.Parameter(0), graph.start()); 599 Node* p1 = graph.NewNode(builder.Parameter(0), graph.start());
623 Node* ret = graph.NewNode(builder.Return(), p1, graph.start(), graph.start()); 600 Node* ret = graph.NewNode(builder.Return(), p1, graph.start(), graph.start());
624 601
625 graph.SetEnd(graph.NewNode(builder.End(), ret)); 602 graph.SetEnd(graph.NewNode(builder.End(), ret));
626 603
627 Scheduler scheduler(scope.main_zone()); 604 USE(Scheduler::ComputeSchedule(&graph));
628 USE(scheduler.NewSchedule(&graph));
629 } 605 }
630 606
631 607
632 static int GetScheduledNodeCount(Schedule* schedule) { 608 static int GetScheduledNodeCount(Schedule* schedule) {
633 int node_count = 0; 609 int node_count = 0;
634 for (BasicBlockVectorIter i = schedule->rpo_order()->begin(); 610 for (BasicBlockVectorIter i = schedule->rpo_order()->begin();
635 i != schedule->rpo_order()->end(); ++i) { 611 i != schedule->rpo_order()->end(); ++i) {
636 BasicBlock* block = *i; 612 BasicBlock* block = *i;
637 for (BasicBlock::const_iterator j = block->begin(); j != block->end(); 613 for (BasicBlock::const_iterator j = block->begin(); j != block->end();
638 ++j) { 614 ++j) {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
677 Node* true_branch = graph.NewNode(builder.IfTrue(), branch); 653 Node* true_branch = graph.NewNode(builder.IfTrue(), branch);
678 Node* false_branch = graph.NewNode(builder.IfFalse(), branch); 654 Node* false_branch = graph.NewNode(builder.IfFalse(), branch);
679 655
680 Node* ret1 = graph.NewNode(builder.Return(), p4, graph.start(), true_branch); 656 Node* ret1 = graph.NewNode(builder.Return(), p4, graph.start(), true_branch);
681 Node* ret2 = graph.NewNode(builder.Return(), p5, graph.start(), false_branch); 657 Node* ret2 = graph.NewNode(builder.Return(), p5, graph.start(), false_branch);
682 Node* merge = graph.NewNode(builder.Merge(2), ret1, ret2); 658 Node* merge = graph.NewNode(builder.Merge(2), ret1, ret2);
683 graph.SetEnd(graph.NewNode(builder.End(), merge)); 659 graph.SetEnd(graph.NewNode(builder.End(), merge));
684 660
685 PrintGraph(&graph); 661 PrintGraph(&graph);
686 662
687 Scheduler scheduler(scope.main_zone()); 663 Schedule* schedule = Scheduler::ComputeSchedule(&graph);
688 Schedule* schedule = scheduler.NewSchedule(&graph);
689 664
690 PrintSchedule(schedule); 665 PrintSchedule(schedule);
691 666
692 667
693 CHECK_EQ(13, GetScheduledNodeCount(schedule)); 668 CHECK_EQ(13, GetScheduledNodeCount(schedule));
694 } 669 }
695 670
696 671
697 TEST(BuildScheduleIfSplitWithEffects) { 672 TEST(BuildScheduleIfSplitWithEffects) {
698 HandleAndZoneScope scope; 673 HandleAndZoneScope scope;
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
831 n21->ReplaceInput(1, n20); 806 n21->ReplaceInput(1, n20);
832 n21->ReplaceInput(2, n18); 807 n21->ReplaceInput(2, n18);
833 n22->ReplaceInput(1, n21); 808 n22->ReplaceInput(1, n21);
834 n23->ReplaceInput(0, n22); 809 n23->ReplaceInput(0, n22);
835 810
836 graph.SetStart(n0); 811 graph.SetStart(n0);
837 graph.SetEnd(n23); 812 graph.SetEnd(n23);
838 813
839 PrintGraph(&graph); 814 PrintGraph(&graph);
840 815
841 Scheduler scheduler(scope.main_zone()); 816 Schedule* schedule = Scheduler::ComputeSchedule(&graph);
842 Schedule* schedule = scheduler.NewSchedule(&graph);
843 817
844 PrintSchedule(schedule); 818 PrintSchedule(schedule);
845 819
846 CHECK_EQ(20, GetScheduledNodeCount(schedule)); 820 CHECK_EQ(20, GetScheduledNodeCount(schedule));
847 } 821 }
848 822
849 823
850 TEST(BuildScheduleSimpleLoop) { 824 TEST(BuildScheduleSimpleLoop) {
851 HandleAndZoneScope scope; 825 HandleAndZoneScope scope;
852 Isolate* isolate = scope.main_isolate(); 826 Isolate* isolate = scope.main_isolate();
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
951 USE(n15); 925 USE(n15);
952 n15->ReplaceInput(0, n13); 926 n15->ReplaceInput(0, n13);
953 n19->ReplaceInput(2, n15); 927 n19->ReplaceInput(2, n15);
954 n20->ReplaceInput(0, n19); 928 n20->ReplaceInput(0, n19);
955 929
956 graph.SetStart(n0); 930 graph.SetStart(n0);
957 graph.SetEnd(n20); 931 graph.SetEnd(n20);
958 932
959 PrintGraph(&graph); 933 PrintGraph(&graph);
960 934
961 Scheduler scheduler(scope.main_zone()); 935 Schedule* schedule = Scheduler::ComputeSchedule(&graph);
962 Schedule* schedule = scheduler.NewSchedule(&graph);
963 936
964 PrintSchedule(schedule); 937 PrintSchedule(schedule);
965 938
966 CHECK_EQ(19, GetScheduledNodeCount(schedule)); 939 CHECK_EQ(19, GetScheduledNodeCount(schedule));
967 } 940 }
968 941
969 942
970 TEST(BuildScheduleComplexLoops) { 943 TEST(BuildScheduleComplexLoops) {
971 HandleAndZoneScope scope; 944 HandleAndZoneScope scope;
972 Isolate* isolate = scope.main_isolate(); 945 Isolate* isolate = scope.main_isolate();
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
1206 USE(n42); 1179 USE(n42);
1207 n42->ReplaceInput(0, n40); 1180 n42->ReplaceInput(0, n40);
1208 n45->ReplaceInput(2, n42); 1181 n45->ReplaceInput(2, n42);
1209 n46->ReplaceInput(0, n45); 1182 n46->ReplaceInput(0, n45);
1210 1183
1211 graph.SetStart(n0); 1184 graph.SetStart(n0);
1212 graph.SetEnd(n46); 1185 graph.SetEnd(n46);
1213 1186
1214 PrintGraph(&graph); 1187 PrintGraph(&graph);
1215 1188
1216 Scheduler scheduler(scope.main_zone()); 1189 Schedule* schedule = Scheduler::ComputeSchedule(&graph);
1217 Schedule* schedule = scheduler.NewSchedule(&graph);
1218 1190
1219 PrintSchedule(schedule); 1191 PrintSchedule(schedule);
1220 1192
1221 CHECK_EQ(46, GetScheduledNodeCount(schedule)); 1193 CHECK_EQ(46, GetScheduledNodeCount(schedule));
1222 } 1194 }
1223 1195
1224 1196
1225 TEST(BuildScheduleBreakAndContinue) { 1197 TEST(BuildScheduleBreakAndContinue) {
1226 HandleAndZoneScope scope; 1198 HandleAndZoneScope scope;
1227 Isolate* isolate = scope.main_isolate(); 1199 Isolate* isolate = scope.main_isolate();
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
1543 n57->ReplaceInput(0, n56); 1515 n57->ReplaceInput(0, n56);
1544 n57->ReplaceInput(1, n56); 1516 n57->ReplaceInput(1, n56);
1545 n57->ReplaceInput(2, n19); 1517 n57->ReplaceInput(2, n19);
1546 n58->ReplaceInput(0, n57); 1518 n58->ReplaceInput(0, n57);
1547 1519
1548 graph.SetStart(n0); 1520 graph.SetStart(n0);
1549 graph.SetEnd(n58); 1521 graph.SetEnd(n58);
1550 1522
1551 PrintGraph(&graph); 1523 PrintGraph(&graph);
1552 1524
1553 Scheduler scheduler(scope.main_zone()); 1525 Schedule* schedule = Scheduler::ComputeSchedule(&graph);
1554 Schedule* schedule = scheduler.NewSchedule(&graph);
1555 1526
1556 PrintSchedule(schedule); 1527 PrintSchedule(schedule);
1557 1528
1558 CHECK_EQ(62, GetScheduledNodeCount(schedule)); 1529 CHECK_EQ(62, GetScheduledNodeCount(schedule));
1559 } 1530 }
1560 1531
1561 1532
1562 TEST(BuildScheduleSimpleLoopWithCodeMotion) { 1533 TEST(BuildScheduleSimpleLoopWithCodeMotion) {
1563 HandleAndZoneScope scope; 1534 HandleAndZoneScope scope;
1564 Isolate* isolate = scope.main_isolate(); 1535 Isolate* isolate = scope.main_isolate();
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
1675 USE(n18); 1646 USE(n18);
1676 n18->ReplaceInput(0, n16); 1647 n18->ReplaceInput(0, n16);
1677 n21->ReplaceInput(2, n18); 1648 n21->ReplaceInput(2, n18);
1678 n22->ReplaceInput(0, n21); 1649 n22->ReplaceInput(0, n21);
1679 1650
1680 graph.SetStart(n0); 1651 graph.SetStart(n0);
1681 graph.SetEnd(n22); 1652 graph.SetEnd(n22);
1682 1653
1683 PrintGraph(&graph); 1654 PrintGraph(&graph);
1684 1655
1685 Scheduler scheduler(scope.main_zone()); 1656 Schedule* schedule = Scheduler::ComputeSchedule(&graph);
1686 Schedule* schedule = scheduler.NewSchedule(&graph);
1687 1657
1688 PrintSchedule(schedule); 1658 PrintSchedule(schedule);
1689 1659
1690 CHECK_EQ(19, GetScheduledNodeCount(schedule)); 1660 CHECK_EQ(19, GetScheduledNodeCount(schedule));
1691 1661
1692 // Make sure the integer-only add gets hoisted to a different block that the 1662 // Make sure the integer-only add gets hoisted to a different block that the
1693 // JSAdd. 1663 // JSAdd.
1694 CHECK(schedule->block(n19) != schedule->block(n20)); 1664 CHECK(schedule->block(n19) != schedule->block(n20));
1695 } 1665 }
1696 1666
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
1796 Node* merge_node = 1766 Node* merge_node =
1797 graph.NewNode(common.Merge(2), return_node, deoptimization_node); 1767 graph.NewNode(common.Merge(2), return_node, deoptimization_node);
1798 1768
1799 Node* end_node = graph.NewNode(common.End(), merge_node); 1769 Node* end_node = graph.NewNode(common.End(), merge_node);
1800 1770
1801 graph.SetStart(start_node); 1771 graph.SetStart(start_node);
1802 graph.SetEnd(end_node); 1772 graph.SetEnd(end_node);
1803 1773
1804 PrintGraph(&graph); 1774 PrintGraph(&graph);
1805 1775
1806 Scheduler scheduler(scope.main_zone()); 1776 Schedule* schedule = Scheduler::ComputeSchedule(&graph);
1807 Schedule* schedule = scheduler.NewSchedule(&graph);
1808 1777
1809 PrintSchedule(schedule); 1778 PrintSchedule(schedule);
1810 1779
1811 // Tests: 1780 // Tests:
1812 // Continuation and deopt have basic blocks. 1781 // Continuation and deopt have basic blocks.
1813 BasicBlock* cont_block = schedule->block(cont_node); 1782 BasicBlock* cont_block = schedule->block(cont_node);
1814 BasicBlock* deopt_block = schedule->block(lazy_deopt_node); 1783 BasicBlock* deopt_block = schedule->block(lazy_deopt_node);
1815 BasicBlock* call_block = schedule->block(call_node); 1784 BasicBlock* call_block = schedule->block(call_node);
1816 CHECK_NE(NULL, cont_block); 1785 CHECK_NE(NULL, cont_block);
1817 CHECK_NE(NULL, deopt_block); 1786 CHECK_NE(NULL, deopt_block);
(...skipping 13 matching lines...) Expand all
1831 CHECK_EQ(deoptimization_node, deopt_block->control_input_); 1800 CHECK_EQ(deoptimization_node, deopt_block->control_input_);
1832 CHECK_EQ(5, static_cast<int>(deopt_block->nodes_.size())); 1801 CHECK_EQ(5, static_cast<int>(deopt_block->nodes_.size()));
1833 CHECK_EQ(lazy_deopt_node, deopt_block->nodes_[0]); 1802 CHECK_EQ(lazy_deopt_node, deopt_block->nodes_[0]);
1834 CHECK_EQ(IrOpcode::kStateValues, deopt_block->nodes_[1]->op()->opcode()); 1803 CHECK_EQ(IrOpcode::kStateValues, deopt_block->nodes_[1]->op()->opcode());
1835 CHECK_EQ(IrOpcode::kStateValues, deopt_block->nodes_[2]->op()->opcode()); 1804 CHECK_EQ(IrOpcode::kStateValues, deopt_block->nodes_[2]->op()->opcode());
1836 CHECK_EQ(IrOpcode::kStateValues, deopt_block->nodes_[3]->op()->opcode()); 1805 CHECK_EQ(IrOpcode::kStateValues, deopt_block->nodes_[3]->op()->opcode());
1837 CHECK_EQ(state_node, deopt_block->nodes_[4]); 1806 CHECK_EQ(state_node, deopt_block->nodes_[4]);
1838 } 1807 }
1839 1808
1840 #endif 1809 #endif
OLDNEW
« no previous file with comments | « test/cctest/compiler/test-instruction.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698