Chromium Code Reviews| Index: test/unittests/compiler/register-allocator-unittest.cc |
| diff --git a/test/unittests/compiler/register-allocator-unittest.cc b/test/unittests/compiler/register-allocator-unittest.cc |
| index 873b4ecd2aca2a240c83266058f15c65e7965e41..669474fac26807ecbfb49f148efbbd51c12d3e8e 100644 |
| --- a/test/unittests/compiler/register-allocator-unittest.cc |
| +++ b/test/unittests/compiler/register-allocator-unittest.cc |
| @@ -9,6 +9,22 @@ namespace v8 { |
| namespace internal { |
| namespace compiler { |
| + |
| +namespace { |
| + |
| +// We can't just use the size of the moves collection, because of |
| +// redundant moves which need to be discounted. |
| +int GetMoveCount(const ParallelMove& moves) { |
| + int move_count = 0; |
| + for (auto move : moves) { |
| + if (move->IsEliminated() || move->IsRedundant()) continue; |
| + ++move_count; |
| + } |
| + return move_count; |
| +} |
| +} |
| + |
| + |
| class RegisterAllocatorTest : public InstructionSequenceTest { |
| public: |
| void Allocate() { |
| @@ -492,6 +508,48 @@ TEST_F(RegisterAllocatorTest, RegressionLoadConstantBeforeSpill) { |
| } |
| +TEST_F(RegisterAllocatorTest, DeferredBlockSpill) { |
| + StartBlock(); // B0 |
| + auto var = EmitOI(Reg(0)); |
| + EndBlock(Branch(Reg(var), 1, 2)); |
| + |
| + StartBlock(); // B1 |
| + EndBlock(Jump(3)); |
| + |
| + StartBlock(true); // B2 |
| + EmitCall(Slot(-1), Slot(var)); |
| + EndBlock(); |
| + |
| + StartBlock(); // B3 |
| + EmitNop(); |
| + EndBlock(); |
| + |
| + StartBlock(); // B4 |
| + Return(Reg(var, 0)); |
| + EndBlock(); |
| + |
| + Allocate(); |
| + |
| + int expect_0 = FLAG_turbo_greedy_regalloc ? 1 : 3; |
| + int expect_1 = FLAG_turbo_greedy_regalloc ? 3 : 1; |
|
Jarin
2015/07/22 12:59:36
Could you please explain what the magic constants
Mircea Trofin
2015/07/23 02:20:04
Done.
|
| + |
| + const ParallelMove* moves = |
| + sequence()->InstructionAt(expect_0)->GetOrCreateParallelMove( |
| + Instruction::START, zone()); |
| + |
| + EXPECT_EQ(0, GetMoveCount(*moves)); |
|
Jarin
2015/07/22 12:59:36
Please explain what you are checking here, this wi
Mircea Trofin
2015/07/23 02:20:04
Done, but please let me know if, still, the commen
|
| + |
| + moves = sequence()->InstructionAt(expect_1)->GetOrCreateParallelMove( |
| + Instruction::START, zone()); |
| + EXPECT_EQ(1, GetMoveCount(*moves)); |
| + for (auto move : *moves) { |
| + if (move->IsEliminated() || move->IsRedundant()) continue; |
| + EXPECT_TRUE(move->source().IsRegister()); |
| + EXPECT_TRUE(move->destination().IsStackSlot()); |
| + } |
| +} |
| + |
| + |
| namespace { |
| enum class ParameterType { kFixedSlot, kSlot, kRegister, kFixedRegister }; |