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_REGISTER_ALLOCATOR_VERIFIER_H_ | 5 #ifndef V8_REGISTER_ALLOCATOR_VERIFIER_H_ |
6 #define V8_REGISTER_ALLOCATOR_VERIFIER_H_ | 6 #define V8_REGISTER_ALLOCATOR_VERIFIER_H_ |
7 | 7 |
8 #include "src/zone-containers.h" | 8 #include "src/zone-containers.h" |
9 | 9 |
10 namespace v8 { | 10 namespace v8 { |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 // FinalAssessmens are associated to operands that we know to be a certain | 92 // FinalAssessmens are associated to operands that we know to be a certain |
93 // virtual register. | 93 // virtual register. |
94 class FinalAssessment final : public Assessment { | 94 class FinalAssessment final : public Assessment { |
95 public: | 95 public: |
96 explicit FinalAssessment(int virtual_register, | 96 explicit FinalAssessment(int virtual_register, |
97 const PendingAssessment* original_pending = nullptr) | 97 const PendingAssessment* original_pending = nullptr) |
98 : Assessment(Final), | 98 : Assessment(Final), |
99 virtual_register_(virtual_register), | 99 virtual_register_(virtual_register), |
100 original_pending_assessment_(original_pending) {} | 100 original_pending_assessment_(original_pending) {} |
101 | 101 |
| 102 int virtual_register() const { return virtual_register_; } |
102 static const FinalAssessment* cast(const Assessment* assessment) { | 103 static const FinalAssessment* cast(const Assessment* assessment) { |
103 CHECK(assessment->kind() == Final); | 104 CHECK(assessment->kind() == Final); |
104 return static_cast<const FinalAssessment*>(assessment); | 105 return static_cast<const FinalAssessment*>(assessment); |
105 } | 106 } |
106 | 107 |
107 int virtual_register() const { return virtual_register_; } | |
108 const PendingAssessment* original_pending_assessment() const { | 108 const PendingAssessment* original_pending_assessment() const { |
109 return original_pending_assessment_; | 109 return original_pending_assessment_; |
110 } | 110 } |
111 | 111 |
112 private: | 112 private: |
113 int virtual_register_; | 113 int virtual_register_; |
114 const PendingAssessment* original_pending_assessment_; | 114 const PendingAssessment* original_pending_assessment_; |
115 | 115 |
116 DISALLOW_COPY_AND_ASSIGN(FinalAssessment); | 116 DISALLOW_COPY_AND_ASSIGN(FinalAssessment); |
117 }; | 117 }; |
118 | 118 |
| 119 struct OperandAsKeyLess { |
| 120 bool operator()(const InstructionOperand& a, |
| 121 const InstructionOperand& b) const { |
| 122 return a.CompareCanonicalized(b); |
| 123 } |
| 124 }; |
| 125 |
119 // Assessments associated with a basic block. | 126 // Assessments associated with a basic block. |
120 class BlockAssessments : public ZoneObject { | 127 class BlockAssessments : public ZoneObject { |
121 public: | 128 public: |
122 typedef ZoneMap<InstructionOperand, Assessment*, CompareOperandModuloType> | 129 typedef ZoneMap<InstructionOperand, Assessment*, OperandAsKeyLess> OperandMap; |
123 OperandMap; | |
124 explicit BlockAssessments(Zone* zone) | 130 explicit BlockAssessments(Zone* zone) |
125 : map_(zone), map_for_moves_(zone), zone_(zone) {} | 131 : map_(zone), map_for_moves_(zone), zone_(zone) {} |
126 void Drop(InstructionOperand operand) { map_.erase(operand); } | 132 void Drop(InstructionOperand operand) { map_.erase(operand); } |
127 void DropRegisters(); | 133 void DropRegisters(); |
128 void AddDefinition(InstructionOperand operand, int virtual_register) { | 134 void AddDefinition(InstructionOperand operand, int virtual_register) { |
129 auto existent = map_.find(operand); | 135 auto existent = map_.find(operand); |
130 if (existent != map_.end()) { | 136 if (existent != map_.end()) { |
131 // Drop the assignment | 137 // Drop the assignment |
132 map_.erase(existent); | 138 map_.erase(existent); |
133 } | 139 } |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 struct InstructionConstraint { | 197 struct InstructionConstraint { |
192 const Instruction* instruction_; | 198 const Instruction* instruction_; |
193 size_t operand_constaints_size_; | 199 size_t operand_constaints_size_; |
194 OperandConstraint* operand_constraints_; | 200 OperandConstraint* operand_constraints_; |
195 }; | 201 }; |
196 | 202 |
197 typedef ZoneVector<InstructionConstraint> Constraints; | 203 typedef ZoneVector<InstructionConstraint> Constraints; |
198 | 204 |
199 class DelayedAssessments : public ZoneObject { | 205 class DelayedAssessments : public ZoneObject { |
200 public: | 206 public: |
201 typedef ZoneMap<InstructionOperand, int, CompareOperandModuloType> | |
202 OperandMap; | |
203 explicit DelayedAssessments(Zone* zone) : map_(zone) {} | 207 explicit DelayedAssessments(Zone* zone) : map_(zone) {} |
204 | 208 |
205 const OperandMap& map() const { return map_; } | 209 const ZoneMap<InstructionOperand, int, OperandAsKeyLess>& map() const { |
| 210 return map_; |
| 211 } |
206 | 212 |
207 void AddDelayedAssessment(InstructionOperand op, int vreg) { | 213 void AddDelayedAssessment(InstructionOperand op, int vreg) { |
208 auto it = map_.find(op); | 214 auto it = map_.find(op); |
209 if (it == map_.end()) { | 215 if (it == map_.end()) { |
210 map_.insert(std::make_pair(op, vreg)); | 216 map_.insert(std::make_pair(op, vreg)); |
211 } else { | 217 } else { |
212 CHECK_EQ(it->second, vreg); | 218 CHECK_EQ(it->second, vreg); |
213 } | 219 } |
214 } | 220 } |
215 | 221 |
216 private: | 222 private: |
217 OperandMap map_; | 223 ZoneMap<InstructionOperand, int, OperandAsKeyLess> map_; |
218 }; | 224 }; |
219 | 225 |
220 Zone* zone() const { return zone_; } | 226 Zone* zone() const { return zone_; } |
221 const RegisterConfiguration* config() { return config_; } | 227 const RegisterConfiguration* config() { return config_; } |
222 const InstructionSequence* sequence() const { return sequence_; } | 228 const InstructionSequence* sequence() const { return sequence_; } |
223 Constraints* constraints() { return &constraints_; } | 229 Constraints* constraints() { return &constraints_; } |
224 | 230 |
225 static void VerifyInput(const OperandConstraint& constraint); | 231 static void VerifyInput(const OperandConstraint& constraint); |
226 static void VerifyTemp(const OperandConstraint& constraint); | 232 static void VerifyTemp(const OperandConstraint& constraint); |
227 static void VerifyOutput(const OperandConstraint& constraint); | 233 static void VerifyOutput(const OperandConstraint& constraint); |
(...skipping 23 matching lines...) Expand all Loading... |
251 ZoneMap<RpoNumber, DelayedAssessments*> outstanding_assessments_; | 257 ZoneMap<RpoNumber, DelayedAssessments*> outstanding_assessments_; |
252 | 258 |
253 DISALLOW_COPY_AND_ASSIGN(RegisterAllocatorVerifier); | 259 DISALLOW_COPY_AND_ASSIGN(RegisterAllocatorVerifier); |
254 }; | 260 }; |
255 | 261 |
256 } // namespace compiler | 262 } // namespace compiler |
257 } // namespace internal | 263 } // namespace internal |
258 } // namespace v8 | 264 } // namespace v8 |
259 | 265 |
260 #endif | 266 #endif |
OLD | NEW |