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/compiler/common-operator.h" | 5 #include "src/compiler/common-operator.h" |
6 #include "src/compiler/graph.h" | 6 #include "src/compiler/graph.h" |
7 #include "src/compiler/instruction.h" | 7 #include "src/compiler/instruction.h" |
8 #include "src/compiler/schedule.h" | 8 #include "src/compiler/schedule.h" |
9 #include "src/compiler/state-values-utils.h" | 9 #include "src/compiler/state-values-utils.h" |
10 | 10 |
(...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
608 for (BasicBlockVector::const_iterator it = schedule->rpo_order()->begin(); | 608 for (BasicBlockVector::const_iterator it = schedule->rpo_order()->begin(); |
609 it != schedule->rpo_order()->end(); ++it, ++rpo_number) { | 609 it != schedule->rpo_order()->end(); ++it, ++rpo_number) { |
610 DCHECK(!(*blocks)[rpo_number]); | 610 DCHECK(!(*blocks)[rpo_number]); |
611 DCHECK(GetRpo(*it).ToSize() == rpo_number); | 611 DCHECK(GetRpo(*it).ToSize() == rpo_number); |
612 (*blocks)[rpo_number] = InstructionBlockFor(zone, *it); | 612 (*blocks)[rpo_number] = InstructionBlockFor(zone, *it); |
613 } | 613 } |
614 ComputeAssemblyOrder(blocks); | 614 ComputeAssemblyOrder(blocks); |
615 return blocks; | 615 return blocks; |
616 } | 616 } |
617 | 617 |
| 618 void InstructionSequence::Validate() { |
| 619 // Validate blocks are in edge-split form: no block with multiple successors |
| 620 // has an edge to a block (== a successor) with more than one predecessors. |
| 621 for (const InstructionBlock* block : instruction_blocks()) { |
| 622 if (block->SuccessorCount() > 1) { |
| 623 for (const RpoNumber& successor_id : block->successors()) { |
| 624 const InstructionBlock* successor = InstructionBlockAt(successor_id); |
| 625 // Expect precisely one predecessor: "block". |
| 626 CHECK(successor->PredecessorCount() == 1 && |
| 627 successor->predecessors()[0] == block->rpo_number()); |
| 628 } |
| 629 } |
| 630 } |
| 631 } |
618 | 632 |
619 void InstructionSequence::ComputeAssemblyOrder(InstructionBlocks* blocks) { | 633 void InstructionSequence::ComputeAssemblyOrder(InstructionBlocks* blocks) { |
620 int ao = 0; | 634 int ao = 0; |
621 for (auto const block : *blocks) { | 635 for (auto const block : *blocks) { |
622 if (!block->IsDeferred()) { | 636 if (!block->IsDeferred()) { |
623 block->set_ao_number(RpoNumber::FromInt(ao++)); | 637 block->set_ao_number(RpoNumber::FromInt(ao++)); |
624 } | 638 } |
625 } | 639 } |
626 for (auto const block : *blocks) { | 640 for (auto const block : *blocks) { |
627 if (block->IsDeferred()) { | 641 if (block->IsDeferred()) { |
(...skipping 13 matching lines...) Expand all Loading... |
641 block_starts_(zone()), | 655 block_starts_(zone()), |
642 constants_(ConstantMap::key_compare(), | 656 constants_(ConstantMap::key_compare(), |
643 ConstantMap::allocator_type(zone())), | 657 ConstantMap::allocator_type(zone())), |
644 immediates_(zone()), | 658 immediates_(zone()), |
645 instructions_(zone()), | 659 instructions_(zone()), |
646 next_virtual_register_(0), | 660 next_virtual_register_(0), |
647 reference_maps_(zone()), | 661 reference_maps_(zone()), |
648 representations_(zone()), | 662 representations_(zone()), |
649 deoptimization_entries_(zone()) { | 663 deoptimization_entries_(zone()) { |
650 block_starts_.reserve(instruction_blocks_->size()); | 664 block_starts_.reserve(instruction_blocks_->size()); |
| 665 |
| 666 #if DEBUG |
| 667 Validate(); |
| 668 #endif |
651 } | 669 } |
652 | 670 |
653 | 671 |
654 int InstructionSequence::NextVirtualRegister() { | 672 int InstructionSequence::NextVirtualRegister() { |
655 int virtual_register = next_virtual_register_++; | 673 int virtual_register = next_virtual_register_++; |
656 CHECK_NE(virtual_register, InstructionOperand::kInvalidVirtualRegister); | 674 CHECK_NE(virtual_register, InstructionOperand::kInvalidVirtualRegister); |
657 return virtual_register; | 675 return virtual_register; |
658 } | 676 } |
659 | 677 |
660 | 678 |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
958 } | 976 } |
959 for (int i = 0; i < code.InstructionBlockCount(); i++) { | 977 for (int i = 0; i < code.InstructionBlockCount(); i++) { |
960 printable.sequence_->PrintBlock(printable.register_configuration_, i); | 978 printable.sequence_->PrintBlock(printable.register_configuration_, i); |
961 } | 979 } |
962 return os; | 980 return os; |
963 } | 981 } |
964 | 982 |
965 } // namespace compiler | 983 } // namespace compiler |
966 } // namespace internal | 984 } // namespace internal |
967 } // namespace v8 | 985 } // namespace v8 |
OLD | NEW |