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

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

Issue 2344143003: Moved zones and zone related stuff in its own directory. (Closed)
Patch Set: Merge branch 'master' into zonefolder Created 4 years, 3 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
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 <functional> 5 #include <functional>
6 6
7 #include "src/compiler/graph.h" 7 #include "src/compiler/graph.h"
8 #include "src/compiler/node.h" 8 #include "src/compiler/node.h"
9 #include "src/compiler/operator.h" 9 #include "src/compiler/operator.h"
10 #include "test/cctest/cctest.h" 10 #include "test/cctest/cctest.h"
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 #define CHECK_INPUTS(node, ...) \ 134 #define CHECK_INPUTS(node, ...) \
135 do { \ 135 do { \
136 Node* __array[] = {__VA_ARGS__}; \ 136 Node* __array[] = {__VA_ARGS__}; \
137 int __size = \ 137 int __size = \
138 __array[0] != NONE ? static_cast<int>(arraysize(__array)) : 0; \ 138 __array[0] != NONE ? static_cast<int>(arraysize(__array)) : 0; \
139 CheckInputs(node, __array, __size); \ 139 CheckInputs(node, __array, __size); \
140 } while (false) 140 } while (false)
141 141
142 142
143 TEST(NodeUseIteratorReplaceUses) { 143 TEST(NodeUseIteratorReplaceUses) {
144 base::AccountingAllocator allocator; 144 v8::internal::AccountingAllocator allocator;
145 Zone zone(&allocator); 145 Zone zone(&allocator);
146 Graph graph(&zone); 146 Graph graph(&zone);
147 Node* n0 = graph.NewNode(&dummy_operator0); 147 Node* n0 = graph.NewNode(&dummy_operator0);
148 Node* n1 = graph.NewNode(&dummy_operator1, n0); 148 Node* n1 = graph.NewNode(&dummy_operator1, n0);
149 Node* n2 = graph.NewNode(&dummy_operator1, n0); 149 Node* n2 = graph.NewNode(&dummy_operator1, n0);
150 Node* n3 = graph.NewNode(&dummy_operator0); 150 Node* n3 = graph.NewNode(&dummy_operator0);
151 151
152 CHECK_USES(n0, n1, n2); 152 CHECK_USES(n0, n1, n2);
153 153
154 CHECK_INPUTS(n1, n0); 154 CHECK_INPUTS(n1, n0);
155 CHECK_INPUTS(n2, n0); 155 CHECK_INPUTS(n2, n0);
156 156
157 n0->ReplaceUses(n3); 157 n0->ReplaceUses(n3);
158 158
159 CHECK_USES(n0, NONE); 159 CHECK_USES(n0, NONE);
160 CHECK_USES(n1, NONE); 160 CHECK_USES(n1, NONE);
161 CHECK_USES(n2, NONE); 161 CHECK_USES(n2, NONE);
162 CHECK_USES(n3, n1, n2); 162 CHECK_USES(n3, n1, n2);
163 163
164 CHECK_INPUTS(n1, n3); 164 CHECK_INPUTS(n1, n3);
165 CHECK_INPUTS(n2, n3); 165 CHECK_INPUTS(n2, n3);
166 } 166 }
167 167
168 168
169 TEST(NodeUseIteratorReplaceUsesSelf) { 169 TEST(NodeUseIteratorReplaceUsesSelf) {
170 base::AccountingAllocator allocator; 170 v8::internal::AccountingAllocator allocator;
171 Zone zone(&allocator); 171 Zone zone(&allocator);
172 Graph graph(&zone); 172 Graph graph(&zone);
173 Node* n0 = graph.NewNode(&dummy_operator0); 173 Node* n0 = graph.NewNode(&dummy_operator0);
174 Node* n1 = graph.NewNode(&dummy_operator1, n0); 174 Node* n1 = graph.NewNode(&dummy_operator1, n0);
175 175
176 CHECK_USES(n0, n1); 176 CHECK_USES(n0, n1);
177 CHECK_USES(n1, NONE); 177 CHECK_USES(n1, NONE);
178 178
179 n1->ReplaceInput(0, n1); // Create self-reference. 179 n1->ReplaceInput(0, n1); // Create self-reference.
180 180
181 CHECK_USES(n0, NONE); 181 CHECK_USES(n0, NONE);
182 CHECK_USES(n1, n1); 182 CHECK_USES(n1, n1);
183 183
184 Node* n2 = graph.NewNode(&dummy_operator0); 184 Node* n2 = graph.NewNode(&dummy_operator0);
185 185
186 n1->ReplaceUses(n2); 186 n1->ReplaceUses(n2);
187 187
188 CHECK_USES(n0, NONE); 188 CHECK_USES(n0, NONE);
189 CHECK_USES(n1, NONE); 189 CHECK_USES(n1, NONE);
190 CHECK_USES(n2, n1); 190 CHECK_USES(n2, n1);
191 } 191 }
192 192
193 193
194 TEST(ReplaceInput) { 194 TEST(ReplaceInput) {
195 base::AccountingAllocator allocator; 195 v8::internal::AccountingAllocator allocator;
196 Zone zone(&allocator); 196 Zone zone(&allocator);
197 Graph graph(&zone); 197 Graph graph(&zone);
198 Node* n0 = graph.NewNode(&dummy_operator0); 198 Node* n0 = graph.NewNode(&dummy_operator0);
199 Node* n1 = graph.NewNode(&dummy_operator0); 199 Node* n1 = graph.NewNode(&dummy_operator0);
200 Node* n2 = graph.NewNode(&dummy_operator0); 200 Node* n2 = graph.NewNode(&dummy_operator0);
201 Node* n3 = graph.NewNode(&dummy_operator3, n0, n1, n2); 201 Node* n3 = graph.NewNode(&dummy_operator3, n0, n1, n2);
202 Node* n4 = graph.NewNode(&dummy_operator0); 202 Node* n4 = graph.NewNode(&dummy_operator0);
203 203
204 CHECK_USES(n0, n3); 204 CHECK_USES(n0, n3);
205 CHECK_USES(n1, n3); 205 CHECK_USES(n1, n3);
206 CHECK_USES(n2, n3); 206 CHECK_USES(n2, n3);
207 CHECK_USES(n3, NONE); 207 CHECK_USES(n3, NONE);
208 CHECK_USES(n4, NONE); 208 CHECK_USES(n4, NONE);
209 209
210 CHECK_INPUTS(n3, n0, n1, n2); 210 CHECK_INPUTS(n3, n0, n1, n2);
211 211
212 n3->ReplaceInput(1, n4); 212 n3->ReplaceInput(1, n4);
213 213
214 CHECK_USES(n1, NONE); 214 CHECK_USES(n1, NONE);
215 CHECK_USES(n4, n3); 215 CHECK_USES(n4, n3);
216 216
217 CHECK_INPUTS(n3, n0, n4, n2); 217 CHECK_INPUTS(n3, n0, n4, n2);
218 } 218 }
219 219
220 220
221 TEST(OwnedBy) { 221 TEST(OwnedBy) {
222 base::AccountingAllocator allocator; 222 v8::internal::AccountingAllocator allocator;
223 Zone zone(&allocator); 223 Zone zone(&allocator);
224 Graph graph(&zone); 224 Graph graph(&zone);
225 225
226 { 226 {
227 Node* n0 = graph.NewNode(&dummy_operator0); 227 Node* n0 = graph.NewNode(&dummy_operator0);
228 Node* n1 = graph.NewNode(&dummy_operator0); 228 Node* n1 = graph.NewNode(&dummy_operator0);
229 229
230 CHECK(!n0->OwnedBy(n1)); 230 CHECK(!n0->OwnedBy(n1));
231 CHECK(!n1->OwnedBy(n0)); 231 CHECK(!n1->OwnedBy(n0));
232 232
(...skipping 30 matching lines...) Expand all
263 CHECK(!n1->OwnedBy(n2)); 263 CHECK(!n1->OwnedBy(n2));
264 CHECK(!n2->OwnedBy(n0)); 264 CHECK(!n2->OwnedBy(n0));
265 CHECK(!n2->OwnedBy(n1)); 265 CHECK(!n2->OwnedBy(n1));
266 CHECK(n3->OwnedBy(n2)); 266 CHECK(n3->OwnedBy(n2));
267 CHECK(!n2->OwnedBy(n3)); 267 CHECK(!n2->OwnedBy(n3));
268 } 268 }
269 } 269 }
270 270
271 271
272 TEST(Uses) { 272 TEST(Uses) {
273 base::AccountingAllocator allocator; 273 v8::internal::AccountingAllocator allocator;
274 Zone zone(&allocator); 274 Zone zone(&allocator);
275 Graph graph(&zone); 275 Graph graph(&zone);
276 276
277 Node* n0 = graph.NewNode(&dummy_operator0); 277 Node* n0 = graph.NewNode(&dummy_operator0);
278 Node* n1 = graph.NewNode(&dummy_operator1, n0); 278 Node* n1 = graph.NewNode(&dummy_operator1, n0);
279 279
280 CHECK_USES(n0, n1); 280 CHECK_USES(n0, n1);
281 CHECK_USES(n1, NONE); 281 CHECK_USES(n1, NONE);
282 282
283 Node* n2 = graph.NewNode(&dummy_operator1, n0); 283 Node* n2 = graph.NewNode(&dummy_operator1, n0);
284 284
285 CHECK_USES(n0, n1, n2); 285 CHECK_USES(n0, n1, n2);
286 CHECK_USES(n2, NONE); 286 CHECK_USES(n2, NONE);
287 287
288 Node* n3 = graph.NewNode(&dummy_operator1, n0); 288 Node* n3 = graph.NewNode(&dummy_operator1, n0);
289 289
290 CHECK_USES(n0, n1, n2, n3); 290 CHECK_USES(n0, n1, n2, n3);
291 CHECK_USES(n3, NONE); 291 CHECK_USES(n3, NONE);
292 } 292 }
293 293
294 294
295 TEST(Inputs) { 295 TEST(Inputs) {
296 base::AccountingAllocator allocator; 296 v8::internal::AccountingAllocator allocator;
297 Zone zone(&allocator); 297 Zone zone(&allocator);
298 Graph graph(&zone); 298 Graph graph(&zone);
299 299
300 Node* n0 = graph.NewNode(&dummy_operator0); 300 Node* n0 = graph.NewNode(&dummy_operator0);
301 Node* n1 = graph.NewNode(&dummy_operator1, n0); 301 Node* n1 = graph.NewNode(&dummy_operator1, n0);
302 Node* n2 = graph.NewNode(&dummy_operator1, n0); 302 Node* n2 = graph.NewNode(&dummy_operator1, n0);
303 Node* n3 = graph.NewNode(&dummy_operator3, n0, n1, n2); 303 Node* n3 = graph.NewNode(&dummy_operator3, n0, n1, n2);
304 304
305 CHECK_INPUTS(n3, n0, n1, n2); 305 CHECK_INPUTS(n3, n0, n1, n2);
306 306
307 Node* n4 = graph.NewNode(&dummy_operator3, n0, n1, n2); 307 Node* n4 = graph.NewNode(&dummy_operator3, n0, n1, n2);
308 n3->AppendInput(graph.zone(), n4); 308 n3->AppendInput(graph.zone(), n4);
309 309
310 CHECK_INPUTS(n3, n0, n1, n2, n4); 310 CHECK_INPUTS(n3, n0, n1, n2, n4);
311 CHECK_USES(n4, n3); 311 CHECK_USES(n4, n3);
312 312
313 n3->AppendInput(graph.zone(), n4); 313 n3->AppendInput(graph.zone(), n4);
314 314
315 CHECK_INPUTS(n3, n0, n1, n2, n4, n4); 315 CHECK_INPUTS(n3, n0, n1, n2, n4, n4);
316 CHECK_USES(n4, n3, n3); 316 CHECK_USES(n4, n3, n3);
317 317
318 Node* n5 = graph.NewNode(&dummy_operator1, n4); 318 Node* n5 = graph.NewNode(&dummy_operator1, n4);
319 319
320 CHECK_USES(n4, n3, n3, n5); 320 CHECK_USES(n4, n3, n3, n5);
321 } 321 }
322 322
323 TEST(InsertInputs) { 323 TEST(InsertInputs) {
324 base::AccountingAllocator allocator; 324 v8::internal::AccountingAllocator allocator;
325 Zone zone(&allocator); 325 Zone zone(&allocator);
326 Graph graph(&zone); 326 Graph graph(&zone);
327 327
328 Node* n0 = graph.NewNode(&dummy_operator0); 328 Node* n0 = graph.NewNode(&dummy_operator0);
329 Node* n1 = graph.NewNode(&dummy_operator1, n0); 329 Node* n1 = graph.NewNode(&dummy_operator1, n0);
330 Node* n2 = graph.NewNode(&dummy_operator1, n0); 330 Node* n2 = graph.NewNode(&dummy_operator1, n0);
331 331
332 { 332 {
333 Node* node = graph.NewNode(&dummy_operator1, n0); 333 Node* node = graph.NewNode(&dummy_operator1, n0);
334 node->InsertInputs(graph.zone(), 0, 1); 334 node->InsertInputs(graph.zone(), 0, 1);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 node->InsertInputs(graph.zone(), 2, 4); 389 node->InsertInputs(graph.zone(), 2, 4);
390 node->ReplaceInput(2, node); 390 node->ReplaceInput(2, node);
391 node->ReplaceInput(3, node); 391 node->ReplaceInput(3, node);
392 node->ReplaceInput(4, node); 392 node->ReplaceInput(4, node);
393 node->ReplaceInput(5, node); 393 node->ReplaceInput(5, node);
394 CHECK_INPUTS(node, n0, n1, node, node, node, node, n2); 394 CHECK_INPUTS(node, n0, n1, node, node, node, node, n2);
395 } 395 }
396 } 396 }
397 397
398 TEST(RemoveInput) { 398 TEST(RemoveInput) {
399 base::AccountingAllocator allocator; 399 v8::internal::AccountingAllocator allocator;
400 Zone zone(&allocator); 400 Zone zone(&allocator);
401 Graph graph(&zone); 401 Graph graph(&zone);
402 402
403 Node* n0 = graph.NewNode(&dummy_operator0); 403 Node* n0 = graph.NewNode(&dummy_operator0);
404 Node* n1 = graph.NewNode(&dummy_operator1, n0); 404 Node* n1 = graph.NewNode(&dummy_operator1, n0);
405 Node* n2 = graph.NewNode(&dummy_operator2, n0, n1); 405 Node* n2 = graph.NewNode(&dummy_operator2, n0, n1);
406 406
407 CHECK_INPUTS(n0, NONE); 407 CHECK_INPUTS(n0, NONE);
408 CHECK_INPUTS(n1, n0); 408 CHECK_INPUTS(n1, n0);
409 CHECK_INPUTS(n2, n0, n1); 409 CHECK_INPUTS(n2, n0, n1);
(...skipping 10 matching lines...) Expand all
420 420
421 n2->RemoveInput(0); 421 n2->RemoveInput(0);
422 CHECK_INPUTS(n2, NONE); 422 CHECK_INPUTS(n2, NONE);
423 CHECK_USES(n0, NONE); 423 CHECK_USES(n0, NONE);
424 CHECK_USES(n1, NONE); 424 CHECK_USES(n1, NONE);
425 CHECK_USES(n2, NONE); 425 CHECK_USES(n2, NONE);
426 } 426 }
427 427
428 428
429 TEST(AppendInputsAndIterator) { 429 TEST(AppendInputsAndIterator) {
430 base::AccountingAllocator allocator; 430 v8::internal::AccountingAllocator allocator;
431 Zone zone(&allocator); 431 Zone zone(&allocator);
432 Graph graph(&zone); 432 Graph graph(&zone);
433 433
434 Node* n0 = graph.NewNode(&dummy_operator0); 434 Node* n0 = graph.NewNode(&dummy_operator0);
435 Node* n1 = graph.NewNode(&dummy_operator1, n0); 435 Node* n1 = graph.NewNode(&dummy_operator1, n0);
436 Node* n2 = graph.NewNode(&dummy_operator2, n0, n1); 436 Node* n2 = graph.NewNode(&dummy_operator2, n0, n1);
437 437
438 CHECK_INPUTS(n0, NONE); 438 CHECK_INPUTS(n0, NONE);
439 CHECK_INPUTS(n1, n0); 439 CHECK_INPUTS(n1, n0);
440 CHECK_INPUTS(n2, n0, n1); 440 CHECK_INPUTS(n2, n0, n1);
441 CHECK_USES(n0, n1, n2); 441 CHECK_USES(n0, n1, n2);
442 442
443 Node* n3 = graph.NewNode(&dummy_operator0); 443 Node* n3 = graph.NewNode(&dummy_operator0);
444 444
445 n2->AppendInput(graph.zone(), n3); 445 n2->AppendInput(graph.zone(), n3);
446 446
447 CHECK_INPUTS(n2, n0, n1, n3); 447 CHECK_INPUTS(n2, n0, n1, n3);
448 CHECK_USES(n3, n2); 448 CHECK_USES(n3, n2);
449 } 449 }
450 450
451 451
452 TEST(NullInputsSimple) { 452 TEST(NullInputsSimple) {
453 base::AccountingAllocator allocator; 453 v8::internal::AccountingAllocator allocator;
454 Zone zone(&allocator); 454 Zone zone(&allocator);
455 Graph graph(&zone); 455 Graph graph(&zone);
456 456
457 Node* n0 = graph.NewNode(&dummy_operator0); 457 Node* n0 = graph.NewNode(&dummy_operator0);
458 Node* n1 = graph.NewNode(&dummy_operator1, n0); 458 Node* n1 = graph.NewNode(&dummy_operator1, n0);
459 Node* n2 = graph.NewNode(&dummy_operator2, n0, n1); 459 Node* n2 = graph.NewNode(&dummy_operator2, n0, n1);
460 460
461 CHECK_INPUTS(n0, NONE); 461 CHECK_INPUTS(n0, NONE);
462 CHECK_INPUTS(n1, n0); 462 CHECK_INPUTS(n1, n0);
463 CHECK_INPUTS(n2, n0, n1); 463 CHECK_INPUTS(n2, n0, n1);
464 CHECK_USES(n0, n1, n2); 464 CHECK_USES(n0, n1, n2);
465 465
466 n2->ReplaceInput(0, nullptr); 466 n2->ReplaceInput(0, nullptr);
467 467
468 CHECK_INPUTS(n2, NULL, n1); 468 CHECK_INPUTS(n2, NULL, n1);
469 469
470 CHECK_USES(n0, n1); 470 CHECK_USES(n0, n1);
471 471
472 n2->ReplaceInput(1, nullptr); 472 n2->ReplaceInput(1, nullptr);
473 473
474 CHECK_INPUTS(n2, NULL, NULL); 474 CHECK_INPUTS(n2, NULL, NULL);
475 475
476 CHECK_USES(n1, NONE); 476 CHECK_USES(n1, NONE);
477 } 477 }
478 478
479 479
480 TEST(NullInputsAppended) { 480 TEST(NullInputsAppended) {
481 base::AccountingAllocator allocator; 481 v8::internal::AccountingAllocator allocator;
482 Zone zone(&allocator); 482 Zone zone(&allocator);
483 Graph graph(&zone); 483 Graph graph(&zone);
484 484
485 Node* n0 = graph.NewNode(&dummy_operator0); 485 Node* n0 = graph.NewNode(&dummy_operator0);
486 Node* n1 = graph.NewNode(&dummy_operator1, n0); 486 Node* n1 = graph.NewNode(&dummy_operator1, n0);
487 Node* n2 = graph.NewNode(&dummy_operator1, n0); 487 Node* n2 = graph.NewNode(&dummy_operator1, n0);
488 Node* n3 = graph.NewNode(&dummy_operator1, n0); 488 Node* n3 = graph.NewNode(&dummy_operator1, n0);
489 n3->AppendInput(graph.zone(), n1); 489 n3->AppendInput(graph.zone(), n1);
490 n3->AppendInput(graph.zone(), n2); 490 n3->AppendInput(graph.zone(), n2);
491 491
492 CHECK_INPUTS(n3, n0, n1, n2); 492 CHECK_INPUTS(n3, n0, n1, n2);
493 CHECK_USES(n0, n1, n2, n3); 493 CHECK_USES(n0, n1, n2, n3);
494 CHECK_USES(n1, n3); 494 CHECK_USES(n1, n3);
495 CHECK_USES(n2, n3); 495 CHECK_USES(n2, n3);
496 496
497 n3->ReplaceInput(1, NULL); 497 n3->ReplaceInput(1, NULL);
498 CHECK_USES(n1, NONE); 498 CHECK_USES(n1, NONE);
499 499
500 CHECK_INPUTS(n3, n0, NULL, n2); 500 CHECK_INPUTS(n3, n0, NULL, n2);
501 } 501 }
502 502
503 503
504 TEST(ReplaceUsesFromAppendedInputs) { 504 TEST(ReplaceUsesFromAppendedInputs) {
505 base::AccountingAllocator allocator; 505 v8::internal::AccountingAllocator allocator;
506 Zone zone(&allocator); 506 Zone zone(&allocator);
507 Graph graph(&zone); 507 Graph graph(&zone);
508 508
509 Node* n0 = graph.NewNode(&dummy_operator0); 509 Node* n0 = graph.NewNode(&dummy_operator0);
510 Node* n1 = graph.NewNode(&dummy_operator1, n0); 510 Node* n1 = graph.NewNode(&dummy_operator1, n0);
511 Node* n2 = graph.NewNode(&dummy_operator1, n0); 511 Node* n2 = graph.NewNode(&dummy_operator1, n0);
512 Node* n3 = graph.NewNode(&dummy_operator0); 512 Node* n3 = graph.NewNode(&dummy_operator0);
513 513
514 CHECK_INPUTS(n2, n0); 514 CHECK_INPUTS(n2, n0);
515 515
516 n2->AppendInput(graph.zone(), n1); 516 n2->AppendInput(graph.zone(), n1);
517 CHECK_INPUTS(n2, n0, n1); 517 CHECK_INPUTS(n2, n0, n1);
518 CHECK_USES(n1, n2); 518 CHECK_USES(n1, n2);
519 519
520 n2->AppendInput(graph.zone(), n0); 520 n2->AppendInput(graph.zone(), n0);
521 CHECK_INPUTS(n2, n0, n1, n0); 521 CHECK_INPUTS(n2, n0, n1, n0);
522 CHECK_USES(n1, n2); 522 CHECK_USES(n1, n2);
523 CHECK_USES(n0, n2, n1, n2); 523 CHECK_USES(n0, n2, n1, n2);
524 524
525 n0->ReplaceUses(n3); 525 n0->ReplaceUses(n3);
526 526
527 CHECK_USES(n0, NONE); 527 CHECK_USES(n0, NONE);
528 CHECK_INPUTS(n2, n3, n1, n3); 528 CHECK_INPUTS(n2, n3, n1, n3);
529 CHECK_USES(n3, n2, n1, n2); 529 CHECK_USES(n3, n2, n1, n2);
530 } 530 }
531 531
532 532
533 TEST(ReplaceInputMultipleUses) { 533 TEST(ReplaceInputMultipleUses) {
534 base::AccountingAllocator allocator; 534 v8::internal::AccountingAllocator allocator;
535 Zone zone(&allocator); 535 Zone zone(&allocator);
536 Graph graph(&zone); 536 Graph graph(&zone);
537 537
538 Node* n0 = graph.NewNode(&dummy_operator0); 538 Node* n0 = graph.NewNode(&dummy_operator0);
539 Node* n1 = graph.NewNode(&dummy_operator0); 539 Node* n1 = graph.NewNode(&dummy_operator0);
540 Node* n2 = graph.NewNode(&dummy_operator1, n0); 540 Node* n2 = graph.NewNode(&dummy_operator1, n0);
541 n2->ReplaceInput(0, n1); 541 n2->ReplaceInput(0, n1);
542 CHECK_EQ(0, n0->UseCount()); 542 CHECK_EQ(0, n0->UseCount());
543 CHECK_EQ(1, n1->UseCount()); 543 CHECK_EQ(1, n1->UseCount());
544 544
545 Node* n3 = graph.NewNode(&dummy_operator1, n0); 545 Node* n3 = graph.NewNode(&dummy_operator1, n0);
546 n3->ReplaceInput(0, n1); 546 n3->ReplaceInput(0, n1);
547 CHECK_EQ(0, n0->UseCount()); 547 CHECK_EQ(0, n0->UseCount());
548 CHECK_EQ(2, n1->UseCount()); 548 CHECK_EQ(2, n1->UseCount());
549 } 549 }
550 550
551 551
552 TEST(TrimInputCountInline) { 552 TEST(TrimInputCountInline) {
553 base::AccountingAllocator allocator; 553 v8::internal::AccountingAllocator allocator;
554 Zone zone(&allocator); 554 Zone zone(&allocator);
555 Graph graph(&zone); 555 Graph graph(&zone);
556 556
557 { 557 {
558 Node* n0 = graph.NewNode(&dummy_operator0); 558 Node* n0 = graph.NewNode(&dummy_operator0);
559 Node* n1 = graph.NewNode(&dummy_operator1, n0); 559 Node* n1 = graph.NewNode(&dummy_operator1, n0);
560 n1->TrimInputCount(1); 560 n1->TrimInputCount(1);
561 CHECK_INPUTS(n1, n0); 561 CHECK_INPUTS(n1, n0);
562 CHECK_USES(n0, n1); 562 CHECK_USES(n0, n1);
563 } 563 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 Node* n0 = graph.NewNode(&dummy_operator0); 612 Node* n0 = graph.NewNode(&dummy_operator0);
613 Node* n2 = graph.NewNode(&dummy_operator2, n0, n0); 613 Node* n2 = graph.NewNode(&dummy_operator2, n0, n0);
614 n2->TrimInputCount(0); 614 n2->TrimInputCount(0);
615 CHECK_INPUTS(n2, NONE); 615 CHECK_INPUTS(n2, NONE);
616 CHECK_USES(n0, NONE); 616 CHECK_USES(n0, NONE);
617 } 617 }
618 } 618 }
619 619
620 620
621 TEST(TrimInputCountOutOfLine1) { 621 TEST(TrimInputCountOutOfLine1) {
622 base::AccountingAllocator allocator; 622 v8::internal::AccountingAllocator allocator;
623 Zone zone(&allocator); 623 Zone zone(&allocator);
624 Graph graph(&zone); 624 Graph graph(&zone);
625 625
626 { 626 {
627 Node* n0 = graph.NewNode(&dummy_operator0); 627 Node* n0 = graph.NewNode(&dummy_operator0);
628 Node* n1 = graph.NewNode(&dummy_operator0); 628 Node* n1 = graph.NewNode(&dummy_operator0);
629 n1->AppendInput(graph.zone(), n0); 629 n1->AppendInput(graph.zone(), n0);
630 CHECK_INPUTS(n1, n0); 630 CHECK_INPUTS(n1, n0);
631 CHECK_USES(n0, n1); 631 CHECK_USES(n0, n1);
632 632
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
707 CHECK_INPUTS(n2, n0, n0); 707 CHECK_INPUTS(n2, n0, n0);
708 CHECK_USES(n0, n2, n2); 708 CHECK_USES(n0, n2, n2);
709 n2->TrimInputCount(0); 709 n2->TrimInputCount(0);
710 CHECK_INPUTS(n2, NONE); 710 CHECK_INPUTS(n2, NONE);
711 CHECK_USES(n0, NONE); 711 CHECK_USES(n0, NONE);
712 } 712 }
713 } 713 }
714 714
715 715
716 TEST(TrimInputCountOutOfLine2) { 716 TEST(TrimInputCountOutOfLine2) {
717 base::AccountingAllocator allocator; 717 v8::internal::AccountingAllocator allocator;
718 Zone zone(&allocator); 718 Zone zone(&allocator);
719 Graph graph(&zone); 719 Graph graph(&zone);
720 720
721 { 721 {
722 Node* n0 = graph.NewNode(&dummy_operator0); 722 Node* n0 = graph.NewNode(&dummy_operator0);
723 Node* n1 = graph.NewNode(&dummy_operator0); 723 Node* n1 = graph.NewNode(&dummy_operator0);
724 Node* n2 = graph.NewNode(&dummy_operator1, n0); 724 Node* n2 = graph.NewNode(&dummy_operator1, n0);
725 n2->AppendInput(graph.zone(), n1); 725 n2->AppendInput(graph.zone(), n1);
726 CHECK_INPUTS(n2, n0, n1); 726 CHECK_INPUTS(n2, n0, n1);
727 n2->TrimInputCount(2); 727 n2->TrimInputCount(2);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
777 CHECK_EQ(2, n0->UseCount()); 777 CHECK_EQ(2, n0->UseCount());
778 n2->TrimInputCount(0); 778 n2->TrimInputCount(0);
779 CHECK_EQ(0, n2->InputCount()); 779 CHECK_EQ(0, n2->InputCount());
780 CHECK_EQ(0, n0->UseCount()); 780 CHECK_EQ(0, n0->UseCount());
781 CHECK_EQ(0, n2->UseCount()); 781 CHECK_EQ(0, n2->UseCount());
782 } 782 }
783 } 783 }
784 784
785 785
786 TEST(NullAllInputs) { 786 TEST(NullAllInputs) {
787 base::AccountingAllocator allocator; 787 v8::internal::AccountingAllocator allocator;
788 Zone zone(&allocator); 788 Zone zone(&allocator);
789 Graph graph(&zone); 789 Graph graph(&zone);
790 790
791 for (int i = 0; i < 2; i++) { 791 for (int i = 0; i < 2; i++) {
792 Node* n0 = graph.NewNode(&dummy_operator0); 792 Node* n0 = graph.NewNode(&dummy_operator0);
793 Node* n1 = graph.NewNode(&dummy_operator1, n0); 793 Node* n1 = graph.NewNode(&dummy_operator1, n0);
794 Node* n2; 794 Node* n2;
795 if (i == 0) { 795 if (i == 0) {
796 n2 = graph.NewNode(&dummy_operator2, n0, n1); 796 n2 = graph.NewNode(&dummy_operator2, n0, n1);
797 CHECK_INPUTS(n2, n0, n1); 797 CHECK_INPUTS(n2, n0, n1);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
830 830
831 CHECK_INPUTS(n0, NONE); 831 CHECK_INPUTS(n0, NONE);
832 CHECK_INPUTS(n1, NULL); 832 CHECK_INPUTS(n1, NULL);
833 CHECK_USES(n0, NONE); 833 CHECK_USES(n0, NONE);
834 CHECK_USES(n1, NONE); 834 CHECK_USES(n1, NONE);
835 } 835 }
836 } 836 }
837 837
838 838
839 TEST(AppendAndTrim) { 839 TEST(AppendAndTrim) {
840 base::AccountingAllocator allocator; 840 v8::internal::AccountingAllocator allocator;
841 Zone zone(&allocator); 841 Zone zone(&allocator);
842 Graph graph(&zone); 842 Graph graph(&zone);
843 843
844 Node* nodes[] = { 844 Node* nodes[] = {
845 graph.NewNode(&dummy_operator0), graph.NewNode(&dummy_operator0), 845 graph.NewNode(&dummy_operator0), graph.NewNode(&dummy_operator0),
846 graph.NewNode(&dummy_operator0), graph.NewNode(&dummy_operator0), 846 graph.NewNode(&dummy_operator0), graph.NewNode(&dummy_operator0),
847 graph.NewNode(&dummy_operator0)}; 847 graph.NewNode(&dummy_operator0)};
848 848
849 int max = static_cast<int>(arraysize(nodes)); 849 int max = static_cast<int>(arraysize(nodes));
850 850
(...skipping 20 matching lines...) Expand all
871 if (j >= i) CHECK_USES(nodes[j], NONE); 871 if (j >= i) CHECK_USES(nodes[j], NONE);
872 } 872 }
873 873
874 CHECK_USES(last, NONE); 874 CHECK_USES(last, NONE);
875 } 875 }
876 } 876 }
877 877
878 } // namespace compiler 878 } // namespace compiler
879 } // namespace internal 879 } // namespace internal
880 } // namespace v8 880 } // namespace v8
OLDNEW
« no previous file with comments | « test/cctest/compiler/test-multiple-return.cc ('k') | test/cctest/compiler/test-run-native-calls.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698