| 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/pipeline.h" | 6 #include "src/compiler/pipeline.h" |
| 7 #include "test/unittests/compiler/instruction-sequence-unittest.h" | 7 #include "test/unittests/compiler/instruction-sequence-unittest.h" |
| 8 #include "test/unittests/test-utils.h" | 8 #include "test/unittests/test-utils.h" |
| 9 #include "testing/gmock/include/gmock/gmock.h" | 9 #include "testing/gmock/include/gmock/gmock.h" |
| 10 | 10 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 | 86 |
| 87 | 87 |
| 88 void InstructionSequenceTest::EndLoop() { | 88 void InstructionSequenceTest::EndLoop() { |
| 89 CHECK(current_block_ == nullptr); | 89 CHECK(current_block_ == nullptr); |
| 90 CHECK(!loop_blocks_.empty()); | 90 CHECK(!loop_blocks_.empty()); |
| 91 CHECK_EQ(0, loop_blocks_.back().expected_blocks_); | 91 CHECK_EQ(0, loop_blocks_.back().expected_blocks_); |
| 92 loop_blocks_.pop_back(); | 92 loop_blocks_.pop_back(); |
| 93 } | 93 } |
| 94 | 94 |
| 95 | 95 |
| 96 void InstructionSequenceTest::StartBlock() { | 96 void InstructionSequenceTest::StartBlock(bool deferred) { |
| 97 block_returns_ = false; | 97 block_returns_ = false; |
| 98 NewBlock(); | 98 NewBlock(deferred); |
| 99 } | 99 } |
| 100 | 100 |
| 101 | 101 |
| 102 Instruction* InstructionSequenceTest::EndBlock(BlockCompletion completion) { | 102 Instruction* InstructionSequenceTest::EndBlock(BlockCompletion completion) { |
| 103 Instruction* result = nullptr; | 103 Instruction* result = nullptr; |
| 104 if (block_returns_) { | 104 if (block_returns_) { |
| 105 CHECK(completion.type_ == kBlockEnd || completion.type_ == kFallThrough); | 105 CHECK(completion.type_ == kBlockEnd || completion.type_ == kFallThrough); |
| 106 completion.type_ = kBlockEnd; | 106 completion.type_ = kBlockEnd; |
| 107 } | 107 } |
| 108 switch (completion.type_) { | 108 switch (completion.type_) { |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 CHECK(0 <= op.value_ && op.value_ < num_general_registers_); | 401 CHECK(0 <= op.value_ && op.value_ < num_general_registers_); |
| 402 return Unallocated(op, UnallocatedOperand::FIXED_REGISTER, op.value_); | 402 return Unallocated(op, UnallocatedOperand::FIXED_REGISTER, op.value_); |
| 403 default: | 403 default: |
| 404 break; | 404 break; |
| 405 } | 405 } |
| 406 CHECK(false); | 406 CHECK(false); |
| 407 return InstructionOperand(); | 407 return InstructionOperand(); |
| 408 } | 408 } |
| 409 | 409 |
| 410 | 410 |
| 411 InstructionBlock* InstructionSequenceTest::NewBlock() { | 411 InstructionBlock* InstructionSequenceTest::NewBlock(bool deferred) { |
| 412 CHECK(current_block_ == nullptr); | 412 CHECK(current_block_ == nullptr); |
| 413 Rpo rpo = Rpo::FromInt(static_cast<int>(instruction_blocks_.size())); | 413 Rpo rpo = Rpo::FromInt(static_cast<int>(instruction_blocks_.size())); |
| 414 Rpo loop_header = Rpo::Invalid(); | 414 Rpo loop_header = Rpo::Invalid(); |
| 415 Rpo loop_end = Rpo::Invalid(); | 415 Rpo loop_end = Rpo::Invalid(); |
| 416 if (!loop_blocks_.empty()) { | 416 if (!loop_blocks_.empty()) { |
| 417 auto& loop_data = loop_blocks_.back(); | 417 auto& loop_data = loop_blocks_.back(); |
| 418 // This is a loop header. | 418 // This is a loop header. |
| 419 if (!loop_data.loop_header_.IsValid()) { | 419 if (!loop_data.loop_header_.IsValid()) { |
| 420 loop_end = Rpo::FromInt(rpo.ToInt() + loop_data.expected_blocks_); | 420 loop_end = Rpo::FromInt(rpo.ToInt() + loop_data.expected_blocks_); |
| 421 loop_data.expected_blocks_--; | 421 loop_data.expected_blocks_--; |
| 422 loop_data.loop_header_ = rpo; | 422 loop_data.loop_header_ = rpo; |
| 423 } else { | 423 } else { |
| 424 // This is a loop body. | 424 // This is a loop body. |
| 425 CHECK_NE(0, loop_data.expected_blocks_); | 425 CHECK_NE(0, loop_data.expected_blocks_); |
| 426 // TODO(dcarney): handle nested loops. | 426 // TODO(dcarney): handle nested loops. |
| 427 loop_data.expected_blocks_--; | 427 loop_data.expected_blocks_--; |
| 428 loop_header = loop_data.loop_header_; | 428 loop_header = loop_data.loop_header_; |
| 429 } | 429 } |
| 430 } | 430 } |
| 431 // Construct instruction block. | 431 // Construct instruction block. |
| 432 auto instruction_block = new (zone()) | 432 auto instruction_block = new (zone()) |
| 433 InstructionBlock(zone(), rpo, loop_header, loop_end, false, false); | 433 InstructionBlock(zone(), rpo, loop_header, loop_end, deferred, false); |
| 434 instruction_blocks_.push_back(instruction_block); | 434 instruction_blocks_.push_back(instruction_block); |
| 435 current_block_ = instruction_block; | 435 current_block_ = instruction_block; |
| 436 sequence()->StartBlock(rpo); | 436 sequence()->StartBlock(rpo); |
| 437 return instruction_block; | 437 return instruction_block; |
| 438 } | 438 } |
| 439 | 439 |
| 440 | 440 |
| 441 void InstructionSequenceTest::WireBlocks() { | 441 void InstructionSequenceTest::WireBlocks() { |
| 442 CHECK(!current_block()); | 442 CHECK(!current_block()); |
| 443 CHECK(instruction_blocks_.size() == completions_.size()); | 443 CHECK(instruction_blocks_.size() == completions_.size()); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 492 | 492 |
| 493 | 493 |
| 494 Instruction* InstructionSequenceTest::AddInstruction(Instruction* instruction) { | 494 Instruction* InstructionSequenceTest::AddInstruction(Instruction* instruction) { |
| 495 sequence()->AddInstruction(instruction); | 495 sequence()->AddInstruction(instruction); |
| 496 return instruction; | 496 return instruction; |
| 497 } | 497 } |
| 498 | 498 |
| 499 } // namespace compiler | 499 } // namespace compiler |
| 500 } // namespace internal | 500 } // namespace internal |
| 501 } // namespace v8 | 501 } // namespace v8 |
| OLD | NEW |