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 900 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
911 // Represents architecture-specific generated code before, during, and after | 911 // Represents architecture-specific generated code before, during, and after |
912 // register allocation. | 912 // register allocation. |
913 // TODO(titzer): s/IsDouble/IsFloat64/ | 913 // TODO(titzer): s/IsDouble/IsFloat64/ |
914 class InstructionSequence FINAL : public ZoneObject { | 914 class InstructionSequence FINAL : public ZoneObject { |
915 public: | 915 public: |
916 static InstructionBlocks* InstructionBlocksFor(Zone* zone, | 916 static InstructionBlocks* InstructionBlocksFor(Zone* zone, |
917 const Schedule* schedule); | 917 const Schedule* schedule); |
918 // Puts the deferred blocks last. | 918 // Puts the deferred blocks last. |
919 static void ComputeAssemblyOrder(InstructionBlocks* blocks); | 919 static void ComputeAssemblyOrder(InstructionBlocks* blocks); |
920 | 920 |
921 InstructionSequence(Zone* zone, InstructionBlocks* instruction_blocks); | 921 InstructionSequence(Isolate* isolate, Zone* zone, |
| 922 InstructionBlocks* instruction_blocks); |
922 | 923 |
923 int NextVirtualRegister(); | 924 int NextVirtualRegister(); |
924 int VirtualRegisterCount() const { return next_virtual_register_; } | 925 int VirtualRegisterCount() const { return next_virtual_register_; } |
925 | 926 |
926 const InstructionBlocks& instruction_blocks() const { | 927 const InstructionBlocks& instruction_blocks() const { |
927 return *instruction_blocks_; | 928 return *instruction_blocks_; |
928 } | 929 } |
929 | 930 |
930 int InstructionBlockCount() const { | 931 int InstructionBlockCount() const { |
931 return static_cast<int>(instruction_blocks_->size()); | 932 return static_cast<int>(instruction_blocks_->size()); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
965 GapInstruction* GapAt(int index) const { | 966 GapInstruction* GapAt(int index) const { |
966 return GapInstruction::cast(InstructionAt(index)); | 967 return GapInstruction::cast(InstructionAt(index)); |
967 } | 968 } |
968 bool IsGapAt(int index) const { return InstructionAt(index)->IsGapMoves(); } | 969 bool IsGapAt(int index) const { return InstructionAt(index)->IsGapMoves(); } |
969 Instruction* InstructionAt(int index) const { | 970 Instruction* InstructionAt(int index) const { |
970 DCHECK(index >= 0); | 971 DCHECK(index >= 0); |
971 DCHECK(index < static_cast<int>(instructions_.size())); | 972 DCHECK(index < static_cast<int>(instructions_.size())); |
972 return instructions_[index]; | 973 return instructions_[index]; |
973 } | 974 } |
974 | 975 |
975 Isolate* isolate() const { return zone()->isolate(); } | 976 Isolate* isolate() const { return isolate_; } |
976 const PointerMapDeque* pointer_maps() const { return &pointer_maps_; } | 977 const PointerMapDeque* pointer_maps() const { return &pointer_maps_; } |
977 Zone* zone() const { return zone_; } | 978 Zone* zone() const { return zone_; } |
978 | 979 |
979 // Used by the instruction selector while adding instructions. | 980 // Used by the instruction selector while adding instructions. |
980 int AddInstruction(Instruction* instr); | 981 int AddInstruction(Instruction* instr); |
981 void StartBlock(BasicBlock::RpoNumber rpo); | 982 void StartBlock(BasicBlock::RpoNumber rpo); |
982 void EndBlock(BasicBlock::RpoNumber rpo); | 983 void EndBlock(BasicBlock::RpoNumber rpo); |
983 | 984 |
984 int AddConstant(int virtual_register, Constant constant) { | 985 int AddConstant(int virtual_register, Constant constant) { |
985 // TODO(titzer): allow RPO numbers as constants? | 986 // TODO(titzer): allow RPO numbers as constants? |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1030 : GetConstant(operand->index()); | 1031 : GetConstant(operand->index()); |
1031 return constant.ToRpoNumber(); | 1032 return constant.ToRpoNumber(); |
1032 } | 1033 } |
1033 | 1034 |
1034 private: | 1035 private: |
1035 friend std::ostream& operator<<(std::ostream& os, | 1036 friend std::ostream& operator<<(std::ostream& os, |
1036 const PrintableInstructionSequence& code); | 1037 const PrintableInstructionSequence& code); |
1037 | 1038 |
1038 typedef std::set<int, std::less<int>, ZoneIntAllocator> VirtualRegisterSet; | 1039 typedef std::set<int, std::less<int>, ZoneIntAllocator> VirtualRegisterSet; |
1039 | 1040 |
| 1041 Isolate* isolate_; |
1040 Zone* const zone_; | 1042 Zone* const zone_; |
1041 InstructionBlocks* const instruction_blocks_; | 1043 InstructionBlocks* const instruction_blocks_; |
1042 IntVector block_starts_; | 1044 IntVector block_starts_; |
1043 ConstantMap constants_; | 1045 ConstantMap constants_; |
1044 Immediates immediates_; | 1046 Immediates immediates_; |
1045 InstructionDeque instructions_; | 1047 InstructionDeque instructions_; |
1046 int next_virtual_register_; | 1048 int next_virtual_register_; |
1047 PointerMapDeque pointer_maps_; | 1049 PointerMapDeque pointer_maps_; |
1048 VirtualRegisterSet doubles_; | 1050 VirtualRegisterSet doubles_; |
1049 VirtualRegisterSet references_; | 1051 VirtualRegisterSet references_; |
(...skipping 10 matching lines...) Expand all Loading... |
1060 | 1062 |
1061 | 1063 |
1062 std::ostream& operator<<(std::ostream& os, | 1064 std::ostream& operator<<(std::ostream& os, |
1063 const PrintableInstructionSequence& code); | 1065 const PrintableInstructionSequence& code); |
1064 | 1066 |
1065 } // namespace compiler | 1067 } // namespace compiler |
1066 } // namespace internal | 1068 } // namespace internal |
1067 } // namespace v8 | 1069 } // namespace v8 |
1068 | 1070 |
1069 #endif // V8_COMPILER_INSTRUCTION_H_ | 1071 #endif // V8_COMPILER_INSTRUCTION_H_ |
OLD | NEW |