Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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) { | |
|
mvstanton
2016/07/26 10:55:03
Nice test, thanks!
| |
| 324 base::AccountingAllocator allocator; | |
| 325 Zone zone(&allocator); | |
| 326 Graph graph(&zone); | |
| 327 | |
| 328 Node* n0 = graph.NewNode(&dummy_operator0); | |
| 329 Node* n1 = graph.NewNode(&dummy_operator1, n0); | |
| 330 Node* n2 = graph.NewNode(&dummy_operator1, n0); | |
| 331 | |
| 332 { | |
| 333 Node* node = graph.NewNode(&dummy_operator1, n0); | |
| 334 node->InsertInputs(graph.zone(), 0, 1); | |
| 335 node->ReplaceInput(0, n1); | |
| 336 CHECK_INPUTS(node, n1, n0); | |
| 337 } | |
| 338 { | |
| 339 Node* node = graph.NewNode(&dummy_operator1, n0); | |
| 340 node->InsertInputs(graph.zone(), 0, 2); | |
| 341 node->ReplaceInput(0, node); | |
| 342 node->ReplaceInput(1, n2); | |
| 343 CHECK_INPUTS(node, node, n2, n0); | |
| 344 } | |
| 345 { | |
| 346 Node* node = graph.NewNode(&dummy_operator3, n0, n1, n2); | |
| 347 node->InsertInputs(graph.zone(), 0, 1); | |
| 348 node->ReplaceInput(0, node); | |
| 349 CHECK_INPUTS(node, node, n0, n1, n2); | |
| 350 } | |
| 351 { | |
| 352 Node* node = graph.NewNode(&dummy_operator3, n0, n1, n2); | |
| 353 node->InsertInputs(graph.zone(), 1, 1); | |
| 354 node->ReplaceInput(1, node); | |
| 355 CHECK_INPUTS(node, n0, node, n1, n2); | |
| 356 } | |
| 357 { | |
| 358 Node* node = graph.NewNode(&dummy_operator3, n0, n1, n2); | |
| 359 node->InsertInputs(graph.zone(), 2, 1); | |
| 360 node->ReplaceInput(2, node); | |
| 361 CHECK_INPUTS(node, n0, n1, node, n2); | |
| 362 } | |
| 363 { | |
| 364 Node* node = graph.NewNode(&dummy_operator3, n0, n1, n2); | |
| 365 node->InsertInputs(graph.zone(), 2, 1); | |
| 366 node->ReplaceInput(2, node); | |
| 367 CHECK_INPUTS(node, n0, n1, node, n2); | |
| 368 } | |
| 369 { | |
| 370 Node* node = graph.NewNode(&dummy_operator3, n0, n1, n2); | |
| 371 node->InsertInputs(graph.zone(), 0, 4); | |
| 372 node->ReplaceInput(0, node); | |
| 373 node->ReplaceInput(1, node); | |
| 374 node->ReplaceInput(2, node); | |
| 375 node->ReplaceInput(3, node); | |
| 376 CHECK_INPUTS(node, node, node, node, node, n0, n1, n2); | |
| 377 } | |
| 378 { | |
| 379 Node* node = graph.NewNode(&dummy_operator3, n0, n1, n2); | |
| 380 node->InsertInputs(graph.zone(), 1, 4); | |
| 381 node->ReplaceInput(1, node); | |
| 382 node->ReplaceInput(2, node); | |
| 383 node->ReplaceInput(3, node); | |
| 384 node->ReplaceInput(4, node); | |
| 385 CHECK_INPUTS(node, n0, node, node, node, node, n1, n2); | |
| 386 } | |
| 387 { | |
| 388 Node* node = graph.NewNode(&dummy_operator3, n0, n1, n2); | |
| 389 node->InsertInputs(graph.zone(), 2, 4); | |
| 390 node->ReplaceInput(2, node); | |
| 391 node->ReplaceInput(3, node); | |
| 392 node->ReplaceInput(4, node); | |
| 393 node->ReplaceInput(5, node); | |
| 394 CHECK_INPUTS(node, n0, n1, node, node, node, node, n2); | |
| 395 } | |
| 396 } | |
| 323 | 397 |
| 324 TEST(RemoveInput) { | 398 TEST(RemoveInput) { |
| 325 base::AccountingAllocator allocator; | 399 base::AccountingAllocator allocator; |
| 326 Zone zone(&allocator); | 400 Zone zone(&allocator); |
| 327 Graph graph(&zone); | 401 Graph graph(&zone); |
| 328 | 402 |
| 329 Node* n0 = graph.NewNode(&dummy_operator0); | 403 Node* n0 = graph.NewNode(&dummy_operator0); |
| 330 Node* n1 = graph.NewNode(&dummy_operator1, n0); | 404 Node* n1 = graph.NewNode(&dummy_operator1, n0); |
| 331 Node* n2 = graph.NewNode(&dummy_operator2, n0, n1); | 405 Node* n2 = graph.NewNode(&dummy_operator2, n0, n1); |
| 332 | 406 |
| (...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 797 if (j >= i) CHECK_USES(nodes[j], NONE); | 871 if (j >= i) CHECK_USES(nodes[j], NONE); |
| 798 } | 872 } |
| 799 | 873 |
| 800 CHECK_USES(last, NONE); | 874 CHECK_USES(last, NONE); |
| 801 } | 875 } |
| 802 } | 876 } |
| 803 | 877 |
| 804 } // namespace compiler | 878 } // namespace compiler |
| 805 } // namespace internal | 879 } // namespace internal |
| 806 } // namespace v8 | 880 } // namespace v8 |
| OLD | NEW |