| 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 777 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 788 DCHECK(code_end_ >= code_start_); | 788 DCHECK(code_end_ >= code_start_); |
| 789 return code_end_ - 1; | 789 return code_end_ - 1; |
| 790 } | 790 } |
| 791 | 791 |
| 792 int32_t code_start() const { return code_start_; } | 792 int32_t code_start() const { return code_start_; } |
| 793 void set_code_start(int32_t start) { code_start_ = start; } | 793 void set_code_start(int32_t start) { code_start_ = start; } |
| 794 | 794 |
| 795 int32_t code_end() const { return code_end_; } | 795 int32_t code_end() const { return code_end_; } |
| 796 void set_code_end(int32_t end) { code_end_ = end; } | 796 void set_code_end(int32_t end) { code_end_ = end; } |
| 797 | 797 |
| 798 bool IsDeferred() const { return deferred_; } |
| 799 |
| 798 BasicBlock::Id id() const { return id_; } | 800 BasicBlock::Id id() const { return id_; } |
| 801 BasicBlock::RpoNumber ao_number() const { return ao_number_; } |
| 799 BasicBlock::RpoNumber rpo_number() const { return rpo_number_; } | 802 BasicBlock::RpoNumber rpo_number() const { return rpo_number_; } |
| 800 BasicBlock::RpoNumber loop_header() const { return loop_header_; } | 803 BasicBlock::RpoNumber loop_header() const { return loop_header_; } |
| 801 BasicBlock::RpoNumber loop_end() const { | 804 BasicBlock::RpoNumber loop_end() const { |
| 802 DCHECK(IsLoopHeader()); | 805 DCHECK(IsLoopHeader()); |
| 803 return loop_end_; | 806 return loop_end_; |
| 804 } | 807 } |
| 805 inline bool IsLoopHeader() const { return loop_end_.IsValid(); } | 808 inline bool IsLoopHeader() const { return loop_end_.IsValid(); } |
| 806 | 809 |
| 807 typedef ZoneVector<BasicBlock::RpoNumber> Predecessors; | 810 typedef ZoneVector<BasicBlock::RpoNumber> Predecessors; |
| 808 const Predecessors& predecessors() const { return predecessors_; } | 811 const Predecessors& predecessors() const { return predecessors_; } |
| 809 size_t PredecessorCount() const { return predecessors_.size(); } | 812 size_t PredecessorCount() const { return predecessors_.size(); } |
| 810 size_t PredecessorIndexOf(BasicBlock::RpoNumber rpo_number) const; | 813 size_t PredecessorIndexOf(BasicBlock::RpoNumber rpo_number) const; |
| 811 | 814 |
| 812 typedef ZoneVector<BasicBlock::RpoNumber> Successors; | 815 typedef ZoneVector<BasicBlock::RpoNumber> Successors; |
| 813 const Successors& successors() const { return successors_; } | 816 const Successors& successors() const { return successors_; } |
| 814 size_t SuccessorCount() const { return successors_.size(); } | 817 size_t SuccessorCount() const { return successors_.size(); } |
| 815 | 818 |
| 816 typedef ZoneVector<PhiInstruction*> PhiInstructions; | 819 typedef ZoneVector<PhiInstruction*> PhiInstructions; |
| 817 const PhiInstructions& phis() const { return phis_; } | 820 const PhiInstructions& phis() const { return phis_; } |
| 818 void AddPhi(PhiInstruction* phi) { phis_.push_back(phi); } | 821 void AddPhi(PhiInstruction* phi) { phis_.push_back(phi); } |
| 819 | 822 |
| 820 private: | 823 private: |
| 821 Successors successors_; | 824 Successors successors_; |
| 822 Predecessors predecessors_; | 825 Predecessors predecessors_; |
| 823 PhiInstructions phis_; | 826 PhiInstructions phis_; |
| 824 BasicBlock::Id id_; | 827 BasicBlock::Id id_; |
| 828 BasicBlock::RpoNumber ao_number_; // Assembly order number. |
| 825 // TODO(dcarney): probably dont't need this. | 829 // TODO(dcarney): probably dont't need this. |
| 826 BasicBlock::RpoNumber rpo_number_; | 830 BasicBlock::RpoNumber rpo_number_; |
| 827 BasicBlock::RpoNumber loop_header_; | 831 BasicBlock::RpoNumber loop_header_; |
| 828 BasicBlock::RpoNumber loop_end_; | 832 BasicBlock::RpoNumber loop_end_; |
| 829 int32_t code_start_; // start index of arch-specific code. | 833 int32_t code_start_; // start index of arch-specific code. |
| 830 int32_t code_end_; // end index of arch-specific code. | 834 int32_t code_end_; // end index of arch-specific code. |
| 835 const bool deferred_; // Block contains deferred code. |
| 831 }; | 836 }; |
| 832 | 837 |
| 833 typedef ZoneDeque<Constant> ConstantDeque; | 838 typedef ZoneDeque<Constant> ConstantDeque; |
| 834 typedef std::map<int, Constant, std::less<int>, | 839 typedef std::map<int, Constant, std::less<int>, |
| 835 zone_allocator<std::pair<int, Constant> > > ConstantMap; | 840 zone_allocator<std::pair<int, Constant> > > ConstantMap; |
| 836 | 841 |
| 837 typedef ZoneDeque<Instruction*> InstructionDeque; | 842 typedef ZoneDeque<Instruction*> InstructionDeque; |
| 838 typedef ZoneDeque<PointerMap*> PointerMapDeque; | 843 typedef ZoneDeque<PointerMap*> PointerMapDeque; |
| 839 typedef ZoneVector<FrameStateDescriptor*> DeoptimizationVector; | 844 typedef ZoneVector<FrameStateDescriptor*> DeoptimizationVector; |
| 840 typedef ZoneVector<InstructionBlock*> InstructionBlocks; | 845 typedef ZoneVector<InstructionBlock*> InstructionBlocks; |
| 841 typedef IntVector NodeToVregMap; | 846 typedef IntVector NodeToVregMap; |
| 842 | 847 |
| 843 // Represents architecture-specific generated code before, during, and after | 848 // Represents architecture-specific generated code before, during, and after |
| 844 // register allocation. | 849 // register allocation. |
| 845 // TODO(titzer): s/IsDouble/IsFloat64/ | 850 // TODO(titzer): s/IsDouble/IsFloat64/ |
| 846 class InstructionSequence FINAL { | 851 class InstructionSequence FINAL { |
| 847 public: | 852 public: |
| 848 static const int kNodeUnmapped = -1; | 853 static const int kNodeUnmapped = -1; |
| 849 | 854 |
| 850 InstructionSequence(Zone* zone, const Graph* graph, const Schedule* schedule); | 855 InstructionSequence(Zone* zone, const Graph* graph, const Schedule* schedule); |
| 851 | 856 |
| 852 int NextVirtualRegister() { return next_virtual_register_++; } | 857 int NextVirtualRegister() { return next_virtual_register_++; } |
| 853 int VirtualRegisterCount() const { return next_virtual_register_; } | 858 int VirtualRegisterCount() const { return next_virtual_register_; } |
| 854 | 859 |
| 855 int node_count() const { return static_cast<int>(node_map_.size()); } | 860 int node_count() const { return static_cast<int>(node_map_.size()); } |
| 856 | 861 |
| 862 const InstructionBlocks& instruction_blocks() const { |
| 863 return instruction_blocks_; |
| 864 } |
| 865 |
| 857 int InstructionBlockCount() const { | 866 int InstructionBlockCount() const { |
| 858 return static_cast<int>(instruction_blocks_.size()); | 867 return static_cast<int>(instruction_blocks_.size()); |
| 859 } | 868 } |
| 860 | 869 |
| 861 InstructionBlock* InstructionBlockAt(BasicBlock::RpoNumber rpo_number) { | 870 InstructionBlock* InstructionBlockAt(BasicBlock::RpoNumber rpo_number) { |
| 862 return instruction_blocks_[rpo_number.ToSize()]; | 871 return instruction_blocks_[rpo_number.ToSize()]; |
| 863 } | 872 } |
| 864 | 873 |
| 865 int LastLoopInstructionIndex(const InstructionBlock* block) { | 874 int LastLoopInstructionIndex(const InstructionBlock* block) { |
| 866 return instruction_blocks_[block->loop_end().ToSize() - 1] | 875 return instruction_blocks_[block->loop_end().ToSize() - 1] |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 971 DeoptimizationVector deoptimization_entries_; | 980 DeoptimizationVector deoptimization_entries_; |
| 972 }; | 981 }; |
| 973 | 982 |
| 974 std::ostream& operator<<(std::ostream& os, const InstructionSequence& code); | 983 std::ostream& operator<<(std::ostream& os, const InstructionSequence& code); |
| 975 | 984 |
| 976 } // namespace compiler | 985 } // namespace compiler |
| 977 } // namespace internal | 986 } // namespace internal |
| 978 } // namespace v8 | 987 } // namespace v8 |
| 979 | 988 |
| 980 #endif // V8_COMPILER_INSTRUCTION_H_ | 989 #endif // V8_COMPILER_INSTRUCTION_H_ |
| OLD | NEW |