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 #ifndef V8_COMPILER_INSTRUCTION_H_ | 5 #ifndef V8_COMPILER_INSTRUCTION_H_ |
6 #define V8_COMPILER_INSTRUCTION_H_ | 6 #define V8_COMPILER_INSTRUCTION_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 #include <iosfwd> | 9 #include <iosfwd> |
10 #include <map> | 10 #include <map> |
(...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
617 | 617 |
618 // This special kind of gap move instruction represents the beginning of a | 618 // This special kind of gap move instruction represents the beginning of a |
619 // block of code. | 619 // block of code. |
620 // TODO(titzer): move code_start and code_end from BasicBlock to here. | 620 // TODO(titzer): move code_start and code_end from BasicBlock to here. |
621 class BlockStartInstruction FINAL : public GapInstruction { | 621 class BlockStartInstruction FINAL : public GapInstruction { |
622 public: | 622 public: |
623 Label* label() { return &label_; } | 623 Label* label() { return &label_; } |
624 BasicBlock::RpoNumber rpo_number() const { return rpo_number_; } | 624 BasicBlock::RpoNumber rpo_number() const { return rpo_number_; } |
625 BasicBlock::Id id() const { return id_; } | 625 BasicBlock::Id id() const { return id_; } |
626 | 626 |
627 static BlockStartInstruction* New(Zone* zone, BasicBlock* block) { | 627 static BlockStartInstruction* New(Zone* zone, BasicBlock::Id id, |
| 628 BasicBlock::RpoNumber rpo_number) { |
628 void* buffer = zone->New(sizeof(BlockStartInstruction)); | 629 void* buffer = zone->New(sizeof(BlockStartInstruction)); |
629 return new (buffer) BlockStartInstruction(block); | 630 return new (buffer) BlockStartInstruction(id, rpo_number); |
630 } | 631 } |
631 | 632 |
632 static BlockStartInstruction* cast(Instruction* instr) { | 633 static BlockStartInstruction* cast(Instruction* instr) { |
633 DCHECK(instr->IsBlockStart()); | 634 DCHECK(instr->IsBlockStart()); |
634 return static_cast<BlockStartInstruction*>(instr); | 635 return static_cast<BlockStartInstruction*>(instr); |
635 } | 636 } |
636 | 637 |
637 private: | 638 private: |
638 explicit BlockStartInstruction(BasicBlock* block) | 639 BlockStartInstruction(BasicBlock::Id id, BasicBlock::RpoNumber rpo_number) |
639 : GapInstruction(kBlockStartInstruction), | 640 : GapInstruction(kBlockStartInstruction), |
640 id_(block->id()), | 641 id_(id), |
641 rpo_number_(block->GetRpoNumber()) {} | 642 rpo_number_(rpo_number) {} |
642 | 643 |
643 BasicBlock::Id id_; | 644 BasicBlock::Id id_; |
644 BasicBlock::RpoNumber rpo_number_; | 645 BasicBlock::RpoNumber rpo_number_; |
645 Label label_; | 646 Label label_; |
646 }; | 647 }; |
647 | 648 |
648 | 649 |
649 class SourcePositionInstruction FINAL : public Instruction { | 650 class SourcePositionInstruction FINAL : public Instruction { |
650 public: | 651 public: |
651 static SourcePositionInstruction* New(Zone* zone, SourcePosition position) { | 652 static SourcePositionInstruction* New(Zone* zone, SourcePosition position) { |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
792 | 793 |
793 private: | 794 private: |
794 const int virtual_register_; | 795 const int virtual_register_; |
795 IntVector operands_; | 796 IntVector operands_; |
796 }; | 797 }; |
797 | 798 |
798 | 799 |
799 // Analogue of BasicBlock for Instructions instead of Nodes. | 800 // Analogue of BasicBlock for Instructions instead of Nodes. |
800 class InstructionBlock FINAL : public ZoneObject { | 801 class InstructionBlock FINAL : public ZoneObject { |
801 public: | 802 public: |
802 explicit InstructionBlock(Zone* zone, const BasicBlock* block); | 803 InstructionBlock(Zone* zone, BasicBlock::Id id, |
| 804 BasicBlock::RpoNumber ao_number, |
| 805 BasicBlock::RpoNumber rpo_number, |
| 806 BasicBlock::RpoNumber loop_header, |
| 807 BasicBlock::RpoNumber loop_end, bool deferred); |
803 | 808 |
804 // Instruction indexes (used by the register allocator). | 809 // Instruction indexes (used by the register allocator). |
805 int first_instruction_index() const { | 810 int first_instruction_index() const { |
806 DCHECK(code_start_ >= 0); | 811 DCHECK(code_start_ >= 0); |
807 DCHECK(code_end_ > 0); | 812 DCHECK(code_end_ > 0); |
808 DCHECK(code_end_ >= code_start_); | 813 DCHECK(code_end_ >= code_start_); |
809 return code_start_; | 814 return code_start_; |
810 } | 815 } |
811 int last_instruction_index() const { | 816 int last_instruction_index() const { |
812 DCHECK(code_start_ >= 0); | 817 DCHECK(code_start_ >= 0); |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
936 DCHECK(index < static_cast<int>(instructions_.size())); | 941 DCHECK(index < static_cast<int>(instructions_.size())); |
937 return instructions_[index]; | 942 return instructions_[index]; |
938 } | 943 } |
939 | 944 |
940 Isolate* isolate() const { return zone()->isolate(); } | 945 Isolate* isolate() const { return zone()->isolate(); } |
941 const PointerMapDeque* pointer_maps() const { return &pointer_maps_; } | 946 const PointerMapDeque* pointer_maps() const { return &pointer_maps_; } |
942 Zone* zone() const { return zone_; } | 947 Zone* zone() const { return zone_; } |
943 | 948 |
944 // Used by the instruction selector while adding instructions. | 949 // Used by the instruction selector while adding instructions. |
945 int AddInstruction(Instruction* instr); | 950 int AddInstruction(Instruction* instr); |
946 void StartBlock(BasicBlock* block); | 951 void StartBlock(BasicBlock::RpoNumber rpo); |
947 void EndBlock(BasicBlock* block); | 952 void EndBlock(BasicBlock::RpoNumber rpo); |
948 | 953 |
949 int AddConstant(int virtual_register, Constant constant) { | 954 int AddConstant(int virtual_register, Constant constant) { |
950 DCHECK(virtual_register >= 0 && virtual_register < next_virtual_register_); | 955 DCHECK(virtual_register >= 0 && virtual_register < next_virtual_register_); |
951 DCHECK(constants_.find(virtual_register) == constants_.end()); | 956 DCHECK(constants_.find(virtual_register) == constants_.end()); |
952 constants_.insert(std::make_pair(virtual_register, constant)); | 957 constants_.insert(std::make_pair(virtual_register, constant)); |
953 return virtual_register; | 958 return virtual_register; |
954 } | 959 } |
955 Constant GetConstant(int virtual_register) const { | 960 Constant GetConstant(int virtual_register) const { |
956 ConstantMap::const_iterator it = constants_.find(virtual_register); | 961 ConstantMap::const_iterator it = constants_.find(virtual_register); |
957 DCHECK(it != constants_.end()); | 962 DCHECK(it != constants_.end()); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1013 | 1018 |
1014 | 1019 |
1015 std::ostream& operator<<(std::ostream& os, | 1020 std::ostream& operator<<(std::ostream& os, |
1016 const PrintableInstructionSequence& code); | 1021 const PrintableInstructionSequence& code); |
1017 | 1022 |
1018 } // namespace compiler | 1023 } // namespace compiler |
1019 } // namespace internal | 1024 } // namespace internal |
1020 } // namespace v8 | 1025 } // namespace v8 |
1021 | 1026 |
1022 #endif // V8_COMPILER_INSTRUCTION_H_ | 1027 #endif // V8_COMPILER_INSTRUCTION_H_ |
OLD | NEW |