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/bit-vector.h" | 5 #include "src/bit-vector.h" |
6 #include "src/compiler/instruction.h" | 6 #include "src/compiler/instruction.h" |
7 #include "src/compiler/register-allocator-verifier.h" | 7 #include "src/compiler/register-allocator-verifier.h" |
8 | 8 |
9 namespace v8 { | 9 namespace v8 { |
10 namespace internal { | 10 namespace internal { |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 operands.insert(operands.begin(), phi->operands().begin(), | 233 operands.insert(operands.begin(), phi->operands().begin(), |
234 phi->operands().end()); | 234 phi->operands().end()); |
235 } | 235 } |
236 const Rpo definition_rpo; | 236 const Rpo definition_rpo; |
237 const int virtual_register; | 237 const int virtual_register; |
238 const int first_pred_vreg; | 238 const int first_pred_vreg; |
239 const PhiData* first_pred_phi; | 239 const PhiData* first_pred_phi; |
240 IntVector operands; | 240 IntVector operands; |
241 }; | 241 }; |
242 | 242 |
243 typedef std::map<int, PhiData*, std::less<int>, | 243 class PhiMap : public ZoneMap<int, PhiData*>, public ZoneObject { |
244 zone_allocator<std::pair<int, PhiData*>>> PhiMapBase; | |
245 | |
246 class PhiMap : public PhiMapBase, public ZoneObject { | |
247 public: | 244 public: |
248 explicit PhiMap(Zone* zone) | 245 explicit PhiMap(Zone* zone) : ZoneMap<int, PhiData*>(zone) {} |
249 : PhiMapBase(key_compare(), allocator_type(zone)) {} | |
250 }; | 246 }; |
251 | 247 |
252 struct OperandLess { | 248 struct OperandLess { |
253 bool operator()(const InstructionOperand* a, | 249 bool operator()(const InstructionOperand* a, |
254 const InstructionOperand* b) const { | 250 const InstructionOperand* b) const { |
255 if (a->kind() == b->kind()) return a->index() < b->index(); | 251 if (a->kind() == b->kind()) return a->index() < b->index(); |
256 return a->kind() < b->kind(); | 252 return a->kind() < b->kind(); |
257 } | 253 } |
258 }; | 254 }; |
259 | 255 |
260 class OperandMap : public ZoneObject { | 256 class OperandMap : public ZoneObject { |
261 public: | 257 public: |
262 struct MapValue : public ZoneObject { | 258 struct MapValue : public ZoneObject { |
263 MapValue() | 259 MapValue() |
264 : incoming(nullptr), | 260 : incoming(nullptr), |
265 define_vreg(kInvalidVreg), | 261 define_vreg(kInvalidVreg), |
266 use_vreg(kInvalidVreg), | 262 use_vreg(kInvalidVreg), |
267 succ_vreg(kInvalidVreg) {} | 263 succ_vreg(kInvalidVreg) {} |
268 MapValue* incoming; // value from first predecessor block. | 264 MapValue* incoming; // value from first predecessor block. |
269 int define_vreg; // valid if this value was defined in this block. | 265 int define_vreg; // valid if this value was defined in this block. |
270 int use_vreg; // valid if this value was used in this block. | 266 int use_vreg; // valid if this value was used in this block. |
271 int succ_vreg; // valid if propagated back from successor block. | 267 int succ_vreg; // valid if propagated back from successor block. |
272 }; | 268 }; |
273 | 269 |
274 typedef std::map< | 270 class Map |
275 const InstructionOperand*, MapValue*, OperandLess, | 271 : public ZoneMap<const InstructionOperand*, MapValue*, OperandLess> { |
276 zone_allocator<std::pair<const InstructionOperand*, MapValue*>>> MapBase; | |
277 | |
278 class Map : public MapBase { | |
279 public: | 272 public: |
280 explicit Map(Zone* zone) : MapBase(key_compare(), allocator_type(zone)) {} | 273 explicit Map(Zone* zone) |
| 274 : ZoneMap<const InstructionOperand*, MapValue*, OperandLess>(zone) {} |
281 | 275 |
282 // Remove all entries with keys not in other. | 276 // Remove all entries with keys not in other. |
283 void Intersect(const Map& other) { | 277 void Intersect(const Map& other) { |
284 if (this->empty()) return; | 278 if (this->empty()) return; |
285 auto it = this->begin(); | 279 auto it = this->begin(); |
286 OperandLess less; | 280 OperandLess less; |
287 for (const auto& o : other) { | 281 for (const auto& o : other) { |
288 while (less(it->first, o.first)) { | 282 while (less(it->first, o.first)) { |
289 this->erase(it++); | 283 this->erase(it++); |
290 if (it == this->end()) return; | 284 if (it == this->end()) return; |
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
670 int virtual_register = op_constraints[count].virtual_register_; | 664 int virtual_register = op_constraints[count].virtual_register_; |
671 current->Define(zone(), instr->OutputAt(i), virtual_register); | 665 current->Define(zone(), instr->OutputAt(i), virtual_register); |
672 } | 666 } |
673 } | 667 } |
674 } | 668 } |
675 } | 669 } |
676 | 670 |
677 } // namespace compiler | 671 } // namespace compiler |
678 } // namespace internal | 672 } // namespace internal |
679 } // namespace v8 | 673 } // namespace v8 |
OLD | NEW |