OLD | NEW |
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/base/utils/random-number-generator.h" | 5 #include "src/base/utils/random-number-generator.h" |
6 #include "src/compiler/register-allocator.h" | 6 #include "src/compiler/register-allocator.h" |
7 #include "test/unittests/test-utils.h" | 7 #include "test/unittests/test-utils.h" |
8 #include "testing/gmock/include/gmock/gmock.h" | 8 #include "testing/gmock/include/gmock/gmock.h" |
9 | 9 |
10 namespace v8 { | 10 namespace v8 { |
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
446 Return(DefineConstant()); | 446 Return(DefineConstant()); |
447 EndBlock(); | 447 EndBlock(); |
448 | 448 |
449 StartLastBlock(); | 449 StartLastBlock(); |
450 Return(DefineConstant()); | 450 Return(DefineConstant()); |
451 EndBlock(); | 451 EndBlock(); |
452 | 452 |
453 Allocate(); | 453 Allocate(); |
454 } | 454 } |
455 | 455 |
| 456 |
| 457 TEST_F(RegisterAllocatorTest, RegressionPhisNeedTooManyRegisters) { |
| 458 const size_t kNumRegs = 3; |
| 459 const size_t kParams = kNumRegs + 1; |
| 460 int parameters[kParams]; |
| 461 |
| 462 // Override number of registers. |
| 463 SetNumRegs(kNumRegs, kNumRegs); |
| 464 |
| 465 // Initial block. |
| 466 StartBlock(); |
| 467 int constant = DefineConstant(); |
| 468 for (size_t i = 0; i < arraysize(parameters); ++i) { |
| 469 parameters[i] = DefineConstant(); |
| 470 } |
| 471 EndBlock(); |
| 472 |
| 473 PhiInstruction* phis[kParams]; |
| 474 { |
| 475 StartLoop(2); |
| 476 |
| 477 // Loop header. |
| 478 StartBlock(); |
| 479 |
| 480 for (size_t i = 0; i < arraysize(parameters); ++i) { |
| 481 phis[i] = Phi(parameters[i]); |
| 482 } |
| 483 |
| 484 // Perform some computations. |
| 485 // something like phi[i] += const |
| 486 for (size_t i = 0; i < arraysize(parameters); ++i) { |
| 487 int result = NewReg(); |
| 488 EmitFRU(result, phis[i]->virtual_register(), constant); |
| 489 phis[i]->operands().push_back(result); |
| 490 } |
| 491 |
| 492 EndBlock(Branch(DefineConstant(), 1, 2)); |
| 493 |
| 494 // Jump back to loop header. |
| 495 StartBlock(); |
| 496 EndBlock(Jump(-1)); |
| 497 |
| 498 EndLoop(); |
| 499 } |
| 500 |
| 501 // End block. |
| 502 StartLastBlock(); |
| 503 |
| 504 // Return sum. |
| 505 Return(DefineConstant()); |
| 506 EndBlock(); |
| 507 |
| 508 Allocate(); |
| 509 } |
| 510 |
456 } // namespace compiler | 511 } // namespace compiler |
457 } // namespace internal | 512 } // namespace internal |
458 } // namespace v8 | 513 } // namespace v8 |
OLD | NEW |