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

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

Issue 665893006: [turbofan] add ZonePool to correctly track compiler phase memory usage (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: 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-instruction.cc ('k') | test/unittests/compiler/zone-pool-unittest.cc » ('j') | 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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 return node_count; 86 return node_count;
87 } 87 }
88 88
89 89
90 static Schedule* ComputeAndVerifySchedule(int expected, Graph* graph) { 90 static Schedule* ComputeAndVerifySchedule(int expected, Graph* graph) {
91 if (FLAG_trace_turbo) { 91 if (FLAG_trace_turbo) {
92 OFStream os(stdout); 92 OFStream os(stdout);
93 os << AsDOT(*graph); 93 os << AsDOT(*graph);
94 } 94 }
95 95
96 Schedule* schedule = Scheduler::ComputeSchedule(graph); 96 ZonePool zone_pool(graph->zone()->isolate());
97 Schedule* schedule = Scheduler::ComputeSchedule(&zone_pool, graph);
97 98
98 if (FLAG_trace_turbo_scheduler) { 99 if (FLAG_trace_turbo_scheduler) {
99 OFStream os(stdout); 100 OFStream os(stdout);
100 os << *schedule << std::endl; 101 os << *schedule << std::endl;
101 } 102 }
102 ScheduleVerifier::Run(schedule); 103 ScheduleVerifier::Run(schedule);
103 CHECK_EQ(expected, GetScheduledNodeCount(schedule)); 104 CHECK_EQ(expected, GetScheduledNodeCount(schedule));
104 return schedule; 105 return schedule;
105 } 106 }
106 107
107 108
108 TEST(RPODegenerate1) { 109 TEST(RPODegenerate1) {
109 HandleAndZoneScope scope; 110 HandleAndZoneScope scope;
110 Schedule schedule(scope.main_zone()); 111 Schedule schedule(scope.main_zone());
111 112
112 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&schedule); 113 ZonePool zone_pool(scope.main_isolate());
114 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&zone_pool, &schedule);
113 CheckRPONumbers(order, 1, false); 115 CheckRPONumbers(order, 1, false);
114 CHECK_EQ(schedule.start(), order->at(0)); 116 CHECK_EQ(schedule.start(), order->at(0));
115 } 117 }
116 118
117 119
118 TEST(RPODegenerate2) { 120 TEST(RPODegenerate2) {
119 HandleAndZoneScope scope; 121 HandleAndZoneScope scope;
120 Schedule schedule(scope.main_zone()); 122 Schedule schedule(scope.main_zone());
121 123
122 schedule.AddGoto(schedule.start(), schedule.end()); 124 schedule.AddGoto(schedule.start(), schedule.end());
123 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&schedule); 125 ZonePool zone_pool(scope.main_isolate());
126 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&zone_pool, &schedule);
124 CheckRPONumbers(order, 2, false); 127 CheckRPONumbers(order, 2, false);
125 CHECK_EQ(schedule.start(), order->at(0)); 128 CHECK_EQ(schedule.start(), order->at(0));
126 CHECK_EQ(schedule.end(), order->at(1)); 129 CHECK_EQ(schedule.end(), order->at(1));
127 } 130 }
128 131
129 132
130 TEST(RPOLine) { 133 TEST(RPOLine) {
131 HandleAndZoneScope scope; 134 HandleAndZoneScope scope;
132 135
133 for (int i = 0; i < 10; i++) { 136 for (int i = 0; i < 10; i++) {
134 Schedule schedule(scope.main_zone()); 137 Schedule schedule(scope.main_zone());
135 138
136 BasicBlock* last = schedule.start(); 139 BasicBlock* last = schedule.start();
137 for (int j = 0; j < i; j++) { 140 for (int j = 0; j < i; j++) {
138 BasicBlock* block = schedule.NewBasicBlock(); 141 BasicBlock* block = schedule.NewBasicBlock();
139 schedule.AddGoto(last, block); 142 schedule.AddGoto(last, block);
140 last = block; 143 last = block;
141 } 144 }
142 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&schedule); 145 ZonePool zone_pool(scope.main_isolate());
146 BasicBlockVector* order =
147 Scheduler::ComputeSpecialRPO(&zone_pool, &schedule);
143 CheckRPONumbers(order, 1 + i, false); 148 CheckRPONumbers(order, 1 + i, false);
144 149
145 for (size_t i = 0; i < schedule.BasicBlockCount(); i++) { 150 for (size_t i = 0; i < schedule.BasicBlockCount(); i++) {
146 BasicBlock* block = schedule.GetBlockById(BasicBlock::Id::FromSize(i)); 151 BasicBlock* block = schedule.GetBlockById(BasicBlock::Id::FromSize(i));
147 if (block->rpo_number() >= 0 && block->SuccessorCount() == 1) { 152 if (block->rpo_number() >= 0 && block->SuccessorCount() == 1) {
148 CHECK(block->rpo_number() + 1 == block->SuccessorAt(0)->rpo_number()); 153 CHECK(block->rpo_number() + 1 == block->SuccessorAt(0)->rpo_number());
149 } 154 }
150 } 155 }
151 } 156 }
152 } 157 }
153 158
154 159
155 TEST(RPOSelfLoop) { 160 TEST(RPOSelfLoop) {
156 HandleAndZoneScope scope; 161 HandleAndZoneScope scope;
157 Schedule schedule(scope.main_zone()); 162 Schedule schedule(scope.main_zone());
158 schedule.AddSuccessor(schedule.start(), schedule.start()); 163 schedule.AddSuccessor(schedule.start(), schedule.start());
159 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&schedule); 164 ZonePool zone_pool(scope.main_isolate());
165 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&zone_pool, &schedule);
160 CheckRPONumbers(order, 1, true); 166 CheckRPONumbers(order, 1, true);
161 BasicBlock* loop[] = {schedule.start()}; 167 BasicBlock* loop[] = {schedule.start()};
162 CheckLoopContains(loop, 1); 168 CheckLoopContains(loop, 1);
163 } 169 }
164 170
165 171
166 TEST(RPOEntryLoop) { 172 TEST(RPOEntryLoop) {
167 HandleAndZoneScope scope; 173 HandleAndZoneScope scope;
168 Schedule schedule(scope.main_zone()); 174 Schedule schedule(scope.main_zone());
169 schedule.AddSuccessor(schedule.start(), schedule.end()); 175 schedule.AddSuccessor(schedule.start(), schedule.end());
170 schedule.AddSuccessor(schedule.end(), schedule.start()); 176 schedule.AddSuccessor(schedule.end(), schedule.start());
171 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&schedule); 177 ZonePool zone_pool(scope.main_isolate());
178 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&zone_pool, &schedule);
172 CheckRPONumbers(order, 2, true); 179 CheckRPONumbers(order, 2, true);
173 BasicBlock* loop[] = {schedule.start(), schedule.end()}; 180 BasicBlock* loop[] = {schedule.start(), schedule.end()};
174 CheckLoopContains(loop, 2); 181 CheckLoopContains(loop, 2);
175 } 182 }
176 183
177 184
178 TEST(RPOEndLoop) { 185 TEST(RPOEndLoop) {
179 HandleAndZoneScope scope; 186 HandleAndZoneScope scope;
180 Schedule schedule(scope.main_zone()); 187 Schedule schedule(scope.main_zone());
181 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, 2)); 188 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, 2));
182 schedule.AddSuccessor(schedule.start(), loop1->header()); 189 schedule.AddSuccessor(schedule.start(), loop1->header());
183 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&schedule); 190 ZonePool zone_pool(scope.main_isolate());
191 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&zone_pool, &schedule);
184 CheckRPONumbers(order, 3, true); 192 CheckRPONumbers(order, 3, true);
185 CheckLoopContains(loop1->nodes, loop1->count); 193 CheckLoopContains(loop1->nodes, loop1->count);
186 } 194 }
187 195
188 196
189 TEST(RPOEndLoopNested) { 197 TEST(RPOEndLoopNested) {
190 HandleAndZoneScope scope; 198 HandleAndZoneScope scope;
191 Schedule schedule(scope.main_zone()); 199 Schedule schedule(scope.main_zone());
192 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, 2)); 200 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, 2));
193 schedule.AddSuccessor(schedule.start(), loop1->header()); 201 schedule.AddSuccessor(schedule.start(), loop1->header());
194 schedule.AddSuccessor(loop1->last(), schedule.start()); 202 schedule.AddSuccessor(loop1->last(), schedule.start());
195 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&schedule); 203 ZonePool zone_pool(scope.main_isolate());
204 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&zone_pool, &schedule);
196 CheckRPONumbers(order, 3, true); 205 CheckRPONumbers(order, 3, true);
197 CheckLoopContains(loop1->nodes, loop1->count); 206 CheckLoopContains(loop1->nodes, loop1->count);
198 } 207 }
199 208
200 209
201 TEST(RPODiamond) { 210 TEST(RPODiamond) {
202 HandleAndZoneScope scope; 211 HandleAndZoneScope scope;
203 Schedule schedule(scope.main_zone()); 212 Schedule schedule(scope.main_zone());
204 213
205 BasicBlock* A = schedule.start(); 214 BasicBlock* A = schedule.start();
206 BasicBlock* B = schedule.NewBasicBlock(); 215 BasicBlock* B = schedule.NewBasicBlock();
207 BasicBlock* C = schedule.NewBasicBlock(); 216 BasicBlock* C = schedule.NewBasicBlock();
208 BasicBlock* D = schedule.end(); 217 BasicBlock* D = schedule.end();
209 218
210 schedule.AddSuccessor(A, B); 219 schedule.AddSuccessor(A, B);
211 schedule.AddSuccessor(A, C); 220 schedule.AddSuccessor(A, C);
212 schedule.AddSuccessor(B, D); 221 schedule.AddSuccessor(B, D);
213 schedule.AddSuccessor(C, D); 222 schedule.AddSuccessor(C, D);
214 223
215 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&schedule); 224 ZonePool zone_pool(scope.main_isolate());
225 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&zone_pool, &schedule);
216 CheckRPONumbers(order, 4, false); 226 CheckRPONumbers(order, 4, false);
217 227
218 CHECK_EQ(0, A->rpo_number()); 228 CHECK_EQ(0, A->rpo_number());
219 CHECK((B->rpo_number() == 1 && C->rpo_number() == 2) || 229 CHECK((B->rpo_number() == 1 && C->rpo_number() == 2) ||
220 (B->rpo_number() == 2 && C->rpo_number() == 1)); 230 (B->rpo_number() == 2 && C->rpo_number() == 1));
221 CHECK_EQ(3, D->rpo_number()); 231 CHECK_EQ(3, D->rpo_number());
222 } 232 }
223 233
224 234
225 TEST(RPOLoop1) { 235 TEST(RPOLoop1) {
226 HandleAndZoneScope scope; 236 HandleAndZoneScope scope;
227 Schedule schedule(scope.main_zone()); 237 Schedule schedule(scope.main_zone());
228 238
229 BasicBlock* A = schedule.start(); 239 BasicBlock* A = schedule.start();
230 BasicBlock* B = schedule.NewBasicBlock(); 240 BasicBlock* B = schedule.NewBasicBlock();
231 BasicBlock* C = schedule.NewBasicBlock(); 241 BasicBlock* C = schedule.NewBasicBlock();
232 BasicBlock* D = schedule.end(); 242 BasicBlock* D = schedule.end();
233 243
234 schedule.AddSuccessor(A, B); 244 schedule.AddSuccessor(A, B);
235 schedule.AddSuccessor(B, C); 245 schedule.AddSuccessor(B, C);
236 schedule.AddSuccessor(C, B); 246 schedule.AddSuccessor(C, B);
237 schedule.AddSuccessor(C, D); 247 schedule.AddSuccessor(C, D);
238 248
239 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&schedule); 249 ZonePool zone_pool(scope.main_isolate());
250 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&zone_pool, &schedule);
240 CheckRPONumbers(order, 4, true); 251 CheckRPONumbers(order, 4, true);
241 BasicBlock* loop[] = {B, C}; 252 BasicBlock* loop[] = {B, C};
242 CheckLoopContains(loop, 2); 253 CheckLoopContains(loop, 2);
243 } 254 }
244 255
245 256
246 TEST(RPOLoop2) { 257 TEST(RPOLoop2) {
247 HandleAndZoneScope scope; 258 HandleAndZoneScope scope;
248 Schedule schedule(scope.main_zone()); 259 Schedule schedule(scope.main_zone());
249 260
250 BasicBlock* A = schedule.start(); 261 BasicBlock* A = schedule.start();
251 BasicBlock* B = schedule.NewBasicBlock(); 262 BasicBlock* B = schedule.NewBasicBlock();
252 BasicBlock* C = schedule.NewBasicBlock(); 263 BasicBlock* C = schedule.NewBasicBlock();
253 BasicBlock* D = schedule.end(); 264 BasicBlock* D = schedule.end();
254 265
255 schedule.AddSuccessor(A, B); 266 schedule.AddSuccessor(A, B);
256 schedule.AddSuccessor(B, C); 267 schedule.AddSuccessor(B, C);
257 schedule.AddSuccessor(C, B); 268 schedule.AddSuccessor(C, B);
258 schedule.AddSuccessor(B, D); 269 schedule.AddSuccessor(B, D);
259 270
260 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&schedule); 271 ZonePool zone_pool(scope.main_isolate());
272 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&zone_pool, &schedule);
261 CheckRPONumbers(order, 4, true); 273 CheckRPONumbers(order, 4, true);
262 BasicBlock* loop[] = {B, C}; 274 BasicBlock* loop[] = {B, C};
263 CheckLoopContains(loop, 2); 275 CheckLoopContains(loop, 2);
264 } 276 }
265 277
266 278
267 TEST(RPOLoopN) { 279 TEST(RPOLoopN) {
268 HandleAndZoneScope scope; 280 HandleAndZoneScope scope;
269 281
270 for (int i = 0; i < 11; i++) { 282 for (int i = 0; i < 11; i++) {
(...skipping 21 matching lines...) Expand all
292 if (i == 4) schedule.AddSuccessor(E, B); 304 if (i == 4) schedule.AddSuccessor(E, B);
293 if (i == 5) schedule.AddSuccessor(F, B); 305 if (i == 5) schedule.AddSuccessor(F, B);
294 306
295 // Throw in extra loop exits from time to time. 307 // Throw in extra loop exits from time to time.
296 if (i == 6) schedule.AddSuccessor(B, G); 308 if (i == 6) schedule.AddSuccessor(B, G);
297 if (i == 7) schedule.AddSuccessor(C, G); 309 if (i == 7) schedule.AddSuccessor(C, G);
298 if (i == 8) schedule.AddSuccessor(D, G); 310 if (i == 8) schedule.AddSuccessor(D, G);
299 if (i == 9) schedule.AddSuccessor(E, G); 311 if (i == 9) schedule.AddSuccessor(E, G);
300 if (i == 10) schedule.AddSuccessor(F, G); 312 if (i == 10) schedule.AddSuccessor(F, G);
301 313
302 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&schedule); 314 ZonePool zone_pool(scope.main_isolate());
315 BasicBlockVector* order =
316 Scheduler::ComputeSpecialRPO(&zone_pool, &schedule);
303 CheckRPONumbers(order, 7, true); 317 CheckRPONumbers(order, 7, true);
304 BasicBlock* loop[] = {B, C, D, E, F}; 318 BasicBlock* loop[] = {B, C, D, E, F};
305 CheckLoopContains(loop, 5); 319 CheckLoopContains(loop, 5);
306 } 320 }
307 } 321 }
308 322
309 323
310 TEST(RPOLoopNest1) { 324 TEST(RPOLoopNest1) {
311 HandleAndZoneScope scope; 325 HandleAndZoneScope scope;
312 Schedule schedule(scope.main_zone()); 326 Schedule schedule(scope.main_zone());
313 327
314 BasicBlock* A = schedule.start(); 328 BasicBlock* A = schedule.start();
315 BasicBlock* B = schedule.NewBasicBlock(); 329 BasicBlock* B = schedule.NewBasicBlock();
316 BasicBlock* C = schedule.NewBasicBlock(); 330 BasicBlock* C = schedule.NewBasicBlock();
317 BasicBlock* D = schedule.NewBasicBlock(); 331 BasicBlock* D = schedule.NewBasicBlock();
318 BasicBlock* E = schedule.NewBasicBlock(); 332 BasicBlock* E = schedule.NewBasicBlock();
319 BasicBlock* F = schedule.end(); 333 BasicBlock* F = schedule.end();
320 334
321 schedule.AddSuccessor(A, B); 335 schedule.AddSuccessor(A, B);
322 schedule.AddSuccessor(B, C); 336 schedule.AddSuccessor(B, C);
323 schedule.AddSuccessor(C, D); 337 schedule.AddSuccessor(C, D);
324 schedule.AddSuccessor(D, C); 338 schedule.AddSuccessor(D, C);
325 schedule.AddSuccessor(D, E); 339 schedule.AddSuccessor(D, E);
326 schedule.AddSuccessor(E, B); 340 schedule.AddSuccessor(E, B);
327 schedule.AddSuccessor(E, F); 341 schedule.AddSuccessor(E, F);
328 342
329 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&schedule); 343 ZonePool zone_pool(scope.main_isolate());
344 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&zone_pool, &schedule);
330 CheckRPONumbers(order, 6, true); 345 CheckRPONumbers(order, 6, true);
331 BasicBlock* loop1[] = {B, C, D, E}; 346 BasicBlock* loop1[] = {B, C, D, E};
332 CheckLoopContains(loop1, 4); 347 CheckLoopContains(loop1, 4);
333 348
334 BasicBlock* loop2[] = {C, D}; 349 BasicBlock* loop2[] = {C, D};
335 CheckLoopContains(loop2, 2); 350 CheckLoopContains(loop2, 2);
336 } 351 }
337 352
338 353
339 TEST(RPOLoopNest2) { 354 TEST(RPOLoopNest2) {
(...skipping 14 matching lines...) Expand all
354 schedule.AddSuccessor(C, D); 369 schedule.AddSuccessor(C, D);
355 schedule.AddSuccessor(D, E); 370 schedule.AddSuccessor(D, E);
356 schedule.AddSuccessor(E, F); 371 schedule.AddSuccessor(E, F);
357 schedule.AddSuccessor(F, G); 372 schedule.AddSuccessor(F, G);
358 schedule.AddSuccessor(G, H); 373 schedule.AddSuccessor(G, H);
359 374
360 schedule.AddSuccessor(E, D); 375 schedule.AddSuccessor(E, D);
361 schedule.AddSuccessor(F, C); 376 schedule.AddSuccessor(F, C);
362 schedule.AddSuccessor(G, B); 377 schedule.AddSuccessor(G, B);
363 378
364 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&schedule); 379 ZonePool zone_pool(scope.main_isolate());
380 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&zone_pool, &schedule);
365 CheckRPONumbers(order, 8, true); 381 CheckRPONumbers(order, 8, true);
366 BasicBlock* loop1[] = {B, C, D, E, F, G}; 382 BasicBlock* loop1[] = {B, C, D, E, F, G};
367 CheckLoopContains(loop1, 6); 383 CheckLoopContains(loop1, 6);
368 384
369 BasicBlock* loop2[] = {C, D, E, F}; 385 BasicBlock* loop2[] = {C, D, E, F};
370 CheckLoopContains(loop2, 4); 386 CheckLoopContains(loop2, 4);
371 387
372 BasicBlock* loop3[] = {D, E}; 388 BasicBlock* loop3[] = {D, E};
373 CheckLoopContains(loop3, 2); 389 CheckLoopContains(loop3, 2);
374 } 390 }
375 391
376 392
377 TEST(RPOLoopFollow1) { 393 TEST(RPOLoopFollow1) {
378 HandleAndZoneScope scope; 394 HandleAndZoneScope scope;
379 Schedule schedule(scope.main_zone()); 395 Schedule schedule(scope.main_zone());
380 396
381 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, 1)); 397 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, 1));
382 SmartPointer<TestLoop> loop2(CreateLoop(&schedule, 1)); 398 SmartPointer<TestLoop> loop2(CreateLoop(&schedule, 1));
383 399
384 BasicBlock* A = schedule.start(); 400 BasicBlock* A = schedule.start();
385 BasicBlock* E = schedule.end(); 401 BasicBlock* E = schedule.end();
386 402
387 schedule.AddSuccessor(A, loop1->header()); 403 schedule.AddSuccessor(A, loop1->header());
388 schedule.AddSuccessor(loop1->header(), loop2->header()); 404 schedule.AddSuccessor(loop1->header(), loop2->header());
389 schedule.AddSuccessor(loop2->last(), E); 405 schedule.AddSuccessor(loop2->last(), E);
390 406
391 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&schedule); 407 ZonePool zone_pool(scope.main_isolate());
408 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&zone_pool, &schedule);
392 409
393 CheckLoopContains(loop1->nodes, loop1->count); 410 CheckLoopContains(loop1->nodes, loop1->count);
394 411
395 CHECK_EQ(static_cast<int>(schedule.BasicBlockCount()), 412 CHECK_EQ(static_cast<int>(schedule.BasicBlockCount()),
396 static_cast<int>(order->size())); 413 static_cast<int>(order->size()));
397 CheckLoopContains(loop1->nodes, loop1->count); 414 CheckLoopContains(loop1->nodes, loop1->count);
398 CheckLoopContains(loop2->nodes, loop2->count); 415 CheckLoopContains(loop2->nodes, loop2->count);
399 } 416 }
400 417
401 418
402 TEST(RPOLoopFollow2) { 419 TEST(RPOLoopFollow2) {
403 HandleAndZoneScope scope; 420 HandleAndZoneScope scope;
404 Schedule schedule(scope.main_zone()); 421 Schedule schedule(scope.main_zone());
405 422
406 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, 1)); 423 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, 1));
407 SmartPointer<TestLoop> loop2(CreateLoop(&schedule, 1)); 424 SmartPointer<TestLoop> loop2(CreateLoop(&schedule, 1));
408 425
409 BasicBlock* A = schedule.start(); 426 BasicBlock* A = schedule.start();
410 BasicBlock* S = schedule.NewBasicBlock(); 427 BasicBlock* S = schedule.NewBasicBlock();
411 BasicBlock* E = schedule.end(); 428 BasicBlock* E = schedule.end();
412 429
413 schedule.AddSuccessor(A, loop1->header()); 430 schedule.AddSuccessor(A, loop1->header());
414 schedule.AddSuccessor(loop1->header(), S); 431 schedule.AddSuccessor(loop1->header(), S);
415 schedule.AddSuccessor(S, loop2->header()); 432 schedule.AddSuccessor(S, loop2->header());
416 schedule.AddSuccessor(loop2->last(), E); 433 schedule.AddSuccessor(loop2->last(), E);
417 434
418 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&schedule); 435 ZonePool zone_pool(scope.main_isolate());
436 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&zone_pool, &schedule);
419 437
420 CheckLoopContains(loop1->nodes, loop1->count); 438 CheckLoopContains(loop1->nodes, loop1->count);
421 439
422 CHECK_EQ(static_cast<int>(schedule.BasicBlockCount()), 440 CHECK_EQ(static_cast<int>(schedule.BasicBlockCount()),
423 static_cast<int>(order->size())); 441 static_cast<int>(order->size()));
424 CheckLoopContains(loop1->nodes, loop1->count); 442 CheckLoopContains(loop1->nodes, loop1->count);
425 CheckLoopContains(loop2->nodes, loop2->count); 443 CheckLoopContains(loop2->nodes, loop2->count);
426 } 444 }
427 445
428 446
429 TEST(RPOLoopFollowN) { 447 TEST(RPOLoopFollowN) {
430 HandleAndZoneScope scope; 448 HandleAndZoneScope scope;
431 449
432 for (int size = 1; size < 5; size++) { 450 for (int size = 1; size < 5; size++) {
433 for (int exit = 0; exit < size; exit++) { 451 for (int exit = 0; exit < size; exit++) {
434 Schedule schedule(scope.main_zone()); 452 Schedule schedule(scope.main_zone());
435 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, size)); 453 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, size));
436 SmartPointer<TestLoop> loop2(CreateLoop(&schedule, size)); 454 SmartPointer<TestLoop> loop2(CreateLoop(&schedule, size));
437 BasicBlock* A = schedule.start(); 455 BasicBlock* A = schedule.start();
438 BasicBlock* E = schedule.end(); 456 BasicBlock* E = schedule.end();
439 457
440 schedule.AddSuccessor(A, loop1->header()); 458 schedule.AddSuccessor(A, loop1->header());
441 schedule.AddSuccessor(loop1->nodes[exit], loop2->header()); 459 schedule.AddSuccessor(loop1->nodes[exit], loop2->header());
442 schedule.AddSuccessor(loop2->nodes[exit], E); 460 schedule.AddSuccessor(loop2->nodes[exit], E);
443 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&schedule); 461 ZonePool zone_pool(scope.main_isolate());
462 BasicBlockVector* order =
463 Scheduler::ComputeSpecialRPO(&zone_pool, &schedule);
444 CheckLoopContains(loop1->nodes, loop1->count); 464 CheckLoopContains(loop1->nodes, loop1->count);
445 465
446 CHECK_EQ(static_cast<int>(schedule.BasicBlockCount()), 466 CHECK_EQ(static_cast<int>(schedule.BasicBlockCount()),
447 static_cast<int>(order->size())); 467 static_cast<int>(order->size()));
448 CheckLoopContains(loop1->nodes, loop1->count); 468 CheckLoopContains(loop1->nodes, loop1->count);
449 CheckLoopContains(loop2->nodes, loop2->count); 469 CheckLoopContains(loop2->nodes, loop2->count);
450 } 470 }
451 } 471 }
452 } 472 }
453 473
(...skipping 10 matching lines...) Expand all
464 BasicBlock* C = schedule.NewBasicBlock(); 484 BasicBlock* C = schedule.NewBasicBlock();
465 BasicBlock* E = schedule.end(); 485 BasicBlock* E = schedule.end();
466 486
467 schedule.AddSuccessor(A, B); 487 schedule.AddSuccessor(A, B);
468 schedule.AddSuccessor(B, loop1->header()); 488 schedule.AddSuccessor(B, loop1->header());
469 schedule.AddSuccessor(loop1->header(), loop2->header()); 489 schedule.AddSuccessor(loop1->header(), loop2->header());
470 schedule.AddSuccessor(loop2->last(), C); 490 schedule.AddSuccessor(loop2->last(), C);
471 schedule.AddSuccessor(C, E); 491 schedule.AddSuccessor(C, E);
472 schedule.AddSuccessor(C, B); 492 schedule.AddSuccessor(C, B);
473 493
474 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&schedule); 494 ZonePool zone_pool(scope.main_isolate());
495 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&zone_pool, &schedule);
475 496
476 CheckLoopContains(loop1->nodes, loop1->count); 497 CheckLoopContains(loop1->nodes, loop1->count);
477 498
478 CHECK_EQ(static_cast<int>(schedule.BasicBlockCount()), 499 CHECK_EQ(static_cast<int>(schedule.BasicBlockCount()),
479 static_cast<int>(order->size())); 500 static_cast<int>(order->size()));
480 CheckLoopContains(loop1->nodes, loop1->count); 501 CheckLoopContains(loop1->nodes, loop1->count);
481 CheckLoopContains(loop2->nodes, loop2->count); 502 CheckLoopContains(loop2->nodes, loop2->count);
482 503
483 BasicBlock* loop3[] = {B, loop1->nodes[0], loop2->nodes[0], C}; 504 BasicBlock* loop3[] = {B, loop1->nodes[0], loop2->nodes[0], C};
484 CheckLoopContains(loop3, 4); 505 CheckLoopContains(loop3, 4);
(...skipping 10 matching lines...) Expand all
495 BasicBlock* A = schedule.start(); 516 BasicBlock* A = schedule.start();
496 BasicBlock* E = schedule.end(); 517 BasicBlock* E = schedule.end();
497 518
498 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, size)); 519 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, size));
499 schedule.AddSuccessor(A, loop1->header()); 520 schedule.AddSuccessor(A, loop1->header());
500 schedule.AddSuccessor(loop1->last(), E); 521 schedule.AddSuccessor(loop1->last(), E);
501 522
502 schedule.AddSuccessor(loop1->nodes[i], loop1->header()); 523 schedule.AddSuccessor(loop1->nodes[i], loop1->header());
503 schedule.AddSuccessor(loop1->nodes[j], E); 524 schedule.AddSuccessor(loop1->nodes[j], E);
504 525
505 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&schedule); 526 ZonePool zone_pool(scope.main_isolate());
527 BasicBlockVector* order =
528 Scheduler::ComputeSpecialRPO(&zone_pool, &schedule);
506 CheckRPONumbers(order, schedule.BasicBlockCount(), true); 529 CheckRPONumbers(order, schedule.BasicBlockCount(), true);
507 CheckLoopContains(loop1->nodes, loop1->count); 530 CheckLoopContains(loop1->nodes, loop1->count);
508 } 531 }
509 } 532 }
510 } 533 }
511 534
512 535
513 TEST(RPOLoopOutedges1) { 536 TEST(RPOLoopOutedges1) {
514 HandleAndZoneScope scope; 537 HandleAndZoneScope scope;
515 538
516 int size = 8; 539 int size = 8;
517 for (int i = 0; i < size; i++) { 540 for (int i = 0; i < size; i++) {
518 for (int j = 0; j < size; j++) { 541 for (int j = 0; j < size; j++) {
519 Schedule schedule(scope.main_zone()); 542 Schedule schedule(scope.main_zone());
520 BasicBlock* A = schedule.start(); 543 BasicBlock* A = schedule.start();
521 BasicBlock* D = schedule.NewBasicBlock(); 544 BasicBlock* D = schedule.NewBasicBlock();
522 BasicBlock* E = schedule.end(); 545 BasicBlock* E = schedule.end();
523 546
524 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, size)); 547 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, size));
525 schedule.AddSuccessor(A, loop1->header()); 548 schedule.AddSuccessor(A, loop1->header());
526 schedule.AddSuccessor(loop1->last(), E); 549 schedule.AddSuccessor(loop1->last(), E);
527 550
528 schedule.AddSuccessor(loop1->nodes[i], loop1->header()); 551 schedule.AddSuccessor(loop1->nodes[i], loop1->header());
529 schedule.AddSuccessor(loop1->nodes[j], D); 552 schedule.AddSuccessor(loop1->nodes[j], D);
530 schedule.AddSuccessor(D, E); 553 schedule.AddSuccessor(D, E);
531 554
532 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&schedule); 555 ZonePool zone_pool(scope.main_isolate());
556 BasicBlockVector* order =
557 Scheduler::ComputeSpecialRPO(&zone_pool, &schedule);
533 CheckRPONumbers(order, schedule.BasicBlockCount(), true); 558 CheckRPONumbers(order, schedule.BasicBlockCount(), true);
534 CheckLoopContains(loop1->nodes, loop1->count); 559 CheckLoopContains(loop1->nodes, loop1->count);
535 } 560 }
536 } 561 }
537 } 562 }
538 563
539 564
540 TEST(RPOLoopOutedges2) { 565 TEST(RPOLoopOutedges2) {
541 HandleAndZoneScope scope; 566 HandleAndZoneScope scope;
542 567
543 int size = 8; 568 int size = 8;
544 for (int i = 0; i < size; i++) { 569 for (int i = 0; i < size; i++) {
545 Schedule schedule(scope.main_zone()); 570 Schedule schedule(scope.main_zone());
546 BasicBlock* A = schedule.start(); 571 BasicBlock* A = schedule.start();
547 BasicBlock* E = schedule.end(); 572 BasicBlock* E = schedule.end();
548 573
549 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, size)); 574 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, size));
550 schedule.AddSuccessor(A, loop1->header()); 575 schedule.AddSuccessor(A, loop1->header());
551 schedule.AddSuccessor(loop1->last(), E); 576 schedule.AddSuccessor(loop1->last(), E);
552 577
553 for (int j = 0; j < size; j++) { 578 for (int j = 0; j < size; j++) {
554 BasicBlock* O = schedule.NewBasicBlock(); 579 BasicBlock* O = schedule.NewBasicBlock();
555 schedule.AddSuccessor(loop1->nodes[j], O); 580 schedule.AddSuccessor(loop1->nodes[j], O);
556 schedule.AddSuccessor(O, E); 581 schedule.AddSuccessor(O, E);
557 } 582 }
558 583
559 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&schedule); 584 ZonePool zone_pool(scope.main_isolate());
585 BasicBlockVector* order =
586 Scheduler::ComputeSpecialRPO(&zone_pool, &schedule);
560 CheckRPONumbers(order, schedule.BasicBlockCount(), true); 587 CheckRPONumbers(order, schedule.BasicBlockCount(), true);
561 CheckLoopContains(loop1->nodes, loop1->count); 588 CheckLoopContains(loop1->nodes, loop1->count);
562 } 589 }
563 } 590 }
564 591
565 592
566 TEST(RPOLoopOutloops1) { 593 TEST(RPOLoopOutloops1) {
567 HandleAndZoneScope scope; 594 HandleAndZoneScope scope;
568 595
569 int size = 8; 596 int size = 8;
570 for (int i = 0; i < size; i++) { 597 for (int i = 0; i < size; i++) {
571 Schedule schedule(scope.main_zone()); 598 Schedule schedule(scope.main_zone());
572 BasicBlock* A = schedule.start(); 599 BasicBlock* A = schedule.start();
573 BasicBlock* E = schedule.end(); 600 BasicBlock* E = schedule.end();
574 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, size)); 601 SmartPointer<TestLoop> loop1(CreateLoop(&schedule, size));
575 schedule.AddSuccessor(A, loop1->header()); 602 schedule.AddSuccessor(A, loop1->header());
576 schedule.AddSuccessor(loop1->last(), E); 603 schedule.AddSuccessor(loop1->last(), E);
577 604
578 TestLoop** loopN = new TestLoop* [size]; 605 TestLoop** loopN = new TestLoop* [size];
579 for (int j = 0; j < size; j++) { 606 for (int j = 0; j < size; j++) {
580 loopN[j] = CreateLoop(&schedule, 2); 607 loopN[j] = CreateLoop(&schedule, 2);
581 schedule.AddSuccessor(loop1->nodes[j], loopN[j]->header()); 608 schedule.AddSuccessor(loop1->nodes[j], loopN[j]->header());
582 schedule.AddSuccessor(loopN[j]->last(), E); 609 schedule.AddSuccessor(loopN[j]->last(), E);
583 } 610 }
584 611
585 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&schedule); 612 ZonePool zone_pool(scope.main_isolate());
613 BasicBlockVector* order =
614 Scheduler::ComputeSpecialRPO(&zone_pool, &schedule);
586 CheckRPONumbers(order, schedule.BasicBlockCount(), true); 615 CheckRPONumbers(order, schedule.BasicBlockCount(), true);
587 CheckLoopContains(loop1->nodes, loop1->count); 616 CheckLoopContains(loop1->nodes, loop1->count);
588 617
589 for (int j = 0; j < size; j++) { 618 for (int j = 0; j < size; j++) {
590 CheckLoopContains(loopN[j]->nodes, loopN[j]->count); 619 CheckLoopContains(loopN[j]->nodes, loopN[j]->count);
591 delete loopN[j]; 620 delete loopN[j];
592 } 621 }
593 delete[] loopN; 622 delete[] loopN;
594 } 623 }
595 } 624 }
(...skipping 10 matching lines...) Expand all
606 BasicBlock* E = schedule.NewBasicBlock(); 635 BasicBlock* E = schedule.NewBasicBlock();
607 636
608 schedule.AddSuccessor(A, B); 637 schedule.AddSuccessor(A, B);
609 schedule.AddSuccessor(B, C); 638 schedule.AddSuccessor(B, C);
610 schedule.AddSuccessor(B, D); 639 schedule.AddSuccessor(B, D);
611 schedule.AddSuccessor(B, E); 640 schedule.AddSuccessor(B, E);
612 schedule.AddSuccessor(C, B); 641 schedule.AddSuccessor(C, B);
613 schedule.AddSuccessor(D, B); 642 schedule.AddSuccessor(D, B);
614 schedule.AddSuccessor(E, B); 643 schedule.AddSuccessor(E, B);
615 644
616 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&schedule); 645 ZonePool zone_pool(scope.main_isolate());
646 BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&zone_pool, &schedule);
617 CheckRPONumbers(order, 5, true); 647 CheckRPONumbers(order, 5, true);
618 648
619 BasicBlock* loop1[] = {B, C, D, E}; 649 BasicBlock* loop1[] = {B, C, D, E};
620 CheckLoopContains(loop1, 4); 650 CheckLoopContains(loop1, 4);
621 } 651 }
622 652
623 653
624 TEST(BuildScheduleEmpty) { 654 TEST(BuildScheduleEmpty) {
625 HandleAndZoneScope scope; 655 HandleAndZoneScope scope;
626 Graph graph(scope.main_zone()); 656 Graph graph(scope.main_zone());
627 CommonOperatorBuilder builder(scope.main_zone()); 657 CommonOperatorBuilder builder(scope.main_zone());
628 graph.SetStart(graph.NewNode(builder.Start(0))); 658 graph.SetStart(graph.NewNode(builder.Start(0)));
629 graph.SetEnd(graph.NewNode(builder.End(), graph.start())); 659 graph.SetEnd(graph.NewNode(builder.End(), graph.start()));
630 660
631 USE(Scheduler::ComputeSchedule(&graph)); 661 ZonePool zone_pool(scope.main_isolate());
662 USE(Scheduler::ComputeSchedule(&zone_pool, &graph));
632 } 663 }
633 664
634 665
635 TEST(BuildScheduleOneParameter) { 666 TEST(BuildScheduleOneParameter) {
636 HandleAndZoneScope scope; 667 HandleAndZoneScope scope;
637 Graph graph(scope.main_zone()); 668 Graph graph(scope.main_zone());
638 CommonOperatorBuilder builder(scope.main_zone()); 669 CommonOperatorBuilder builder(scope.main_zone());
639 graph.SetStart(graph.NewNode(builder.Start(0))); 670 graph.SetStart(graph.NewNode(builder.Start(0)));
640 671
641 Node* p1 = graph.NewNode(builder.Parameter(0), graph.start()); 672 Node* p1 = graph.NewNode(builder.Parameter(0), graph.start());
642 Node* ret = graph.NewNode(builder.Return(), p1, graph.start(), graph.start()); 673 Node* ret = graph.NewNode(builder.Return(), p1, graph.start(), graph.start());
643 674
644 graph.SetEnd(graph.NewNode(builder.End(), ret)); 675 graph.SetEnd(graph.NewNode(builder.End(), ret));
645 676
646 USE(Scheduler::ComputeSchedule(&graph)); 677 ZonePool zone_pool(scope.main_isolate());
678 USE(Scheduler::ComputeSchedule(&zone_pool, &graph));
647 } 679 }
648 680
649 681
650 TEST(BuildScheduleIfSplit) { 682 TEST(BuildScheduleIfSplit) {
651 HandleAndZoneScope scope; 683 HandleAndZoneScope scope;
652 Graph graph(scope.main_zone()); 684 Graph graph(scope.main_zone());
653 CommonOperatorBuilder builder(scope.main_zone()); 685 CommonOperatorBuilder builder(scope.main_zone());
654 JSOperatorBuilder js_builder(scope.main_zone()); 686 JSOperatorBuilder js_builder(scope.main_zone());
655 graph.SetStart(graph.NewNode(builder.Start(3))); 687 graph.SetStart(graph.NewNode(builder.Start(3)));
656 688
(...skipping 1137 matching lines...) Expand 10 before | Expand all | Expand 10 after
1794 1826
1795 Node* ret = graph.NewNode(common.Return(), phi3, start, start); 1827 Node* ret = graph.NewNode(common.Return(), phi3, start, start);
1796 Node* end = graph.NewNode(common.End(), ret, start); 1828 Node* end = graph.NewNode(common.End(), ret, start);
1797 1829
1798 graph.SetEnd(end); 1830 graph.SetEnd(end);
1799 1831
1800 ComputeAndVerifySchedule(24, &graph); 1832 ComputeAndVerifySchedule(24, &graph);
1801 } 1833 }
1802 1834
1803 #endif 1835 #endif
OLDNEW
« no previous file with comments | « test/cctest/compiler/test-instruction.cc ('k') | test/unittests/compiler/zone-pool-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698