Chromium Code Reviews| 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_H_ | 5 #ifndef V8_REGISTER_ALLOCATOR_H_ |
| 6 #define V8_REGISTER_ALLOCATOR_H_ | 6 #define V8_REGISTER_ALLOCATOR_H_ |
| 7 | 7 |
| 8 #include "src/compiler/instruction.h" | 8 #include "src/compiler/instruction.h" |
| 9 #include "src/zone-containers.h" | 9 #include "src/zone-containers.h" |
| 10 | 10 |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 179 class LiveRange FINAL : public ZoneObject { | 179 class LiveRange FINAL : public ZoneObject { |
| 180 public: | 180 public: |
| 181 static const int kInvalidAssignment = 0x7fffffff; | 181 static const int kInvalidAssignment = 0x7fffffff; |
| 182 | 182 |
| 183 LiveRange(int id, Zone* zone); | 183 LiveRange(int id, Zone* zone); |
| 184 | 184 |
| 185 UseInterval* first_interval() const { return first_interval_; } | 185 UseInterval* first_interval() const { return first_interval_; } |
| 186 UsePosition* first_pos() const { return first_pos_; } | 186 UsePosition* first_pos() const { return first_pos_; } |
| 187 LiveRange* parent() const { return parent_; } | 187 LiveRange* parent() const { return parent_; } |
| 188 LiveRange* TopLevel() { return (parent_ == NULL) ? this : parent_; } | 188 LiveRange* TopLevel() { return (parent_ == NULL) ? this : parent_; } |
| 189 const LiveRange* TopLevel() const { | |
| 190 return (parent_ == NULL) ? this : parent_; | |
| 191 } | |
| 189 LiveRange* next() const { return next_; } | 192 LiveRange* next() const { return next_; } |
| 190 bool IsChild() const { return parent() != NULL; } | 193 bool IsChild() const { return parent() != NULL; } |
| 191 int id() const { return id_; } | 194 int id() const { return id_; } |
| 192 bool IsFixed() const { return id_ < 0; } | 195 bool IsFixed() const { return id_ < 0; } |
| 193 bool IsEmpty() const { return first_interval() == NULL; } | 196 bool IsEmpty() const { return first_interval() == NULL; } |
| 194 InstructionOperand* CreateAssignedOperand(Zone* zone); | 197 InstructionOperand* CreateAssignedOperand(Zone* zone) const; |
| 195 int assigned_register() const { return assigned_register_; } | 198 int assigned_register() const { return assigned_register_; } |
| 196 int spill_start_index() const { return spill_start_index_; } | 199 int spill_start_index() const { return spill_start_index_; } |
| 197 void set_assigned_register(int reg, Zone* zone); | 200 void set_assigned_register(int reg, Zone* zone); |
| 198 void MakeSpilled(Zone* zone); | 201 void MakeSpilled(Zone* zone); |
| 199 bool is_phi() const { return is_phi_; } | 202 bool is_phi() const { return is_phi_; } |
| 200 void set_is_phi(bool is_phi) { is_phi_ = is_phi; } | 203 void set_is_phi(bool is_phi) { is_phi_ = is_phi; } |
| 201 bool is_non_loop_phi() const { return is_non_loop_phi_; } | 204 bool is_non_loop_phi() const { return is_non_loop_phi_; } |
| 202 void set_is_non_loop_phi(bool is_non_loop_phi) { | 205 void set_is_non_loop_phi(bool is_non_loop_phi) { |
| 203 is_non_loop_phi_ = is_non_loop_phi; | 206 is_non_loop_phi_ = is_non_loop_phi; |
| 204 } | 207 } |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 340 BitVector* assigned_double_registers() { return assigned_double_registers_; } | 343 BitVector* assigned_double_registers() { return assigned_double_registers_; } |
| 341 | 344 |
| 342 const ZoneList<LiveRange*>& live_ranges() const { return live_ranges_; } | 345 const ZoneList<LiveRange*>& live_ranges() const { return live_ranges_; } |
| 343 const ZoneVector<LiveRange*>& fixed_live_ranges() const { | 346 const ZoneVector<LiveRange*>& fixed_live_ranges() const { |
| 344 return fixed_live_ranges_; | 347 return fixed_live_ranges_; |
| 345 } | 348 } |
| 346 const ZoneVector<LiveRange*>& fixed_double_live_ranges() const { | 349 const ZoneVector<LiveRange*>& fixed_double_live_ranges() const { |
| 347 return fixed_double_live_ranges_; | 350 return fixed_double_live_ranges_; |
| 348 } | 351 } |
| 349 InstructionSequence* code() const { return code_; } | 352 InstructionSequence* code() const { return code_; } |
| 353 // This zone is for datastructures only needed during register allocation. | |
| 354 Zone* zone() const { return zone_; } | |
|
Jarin
2014/11/04 10:42:09
Since you already touching this, could you possibl
dcarney
2014/11/05 09:02:02
Done.
| |
| 350 | 355 |
| 351 private: | 356 private: |
| 352 int GetVirtualRegister() { | 357 int GetVirtualRegister() { |
| 353 int vreg = code()->NextVirtualRegister(); | 358 int vreg = code()->NextVirtualRegister(); |
| 354 if (vreg >= UnallocatedOperand::kMaxVirtualRegisters) { | 359 if (vreg >= UnallocatedOperand::kMaxVirtualRegisters) { |
| 355 allocation_ok_ = false; | 360 allocation_ok_ = false; |
| 356 // Maintain the invariant that we return something below the maximum. | 361 // Maintain the invariant that we return something below the maximum. |
| 357 return 0; | 362 return 0; |
| 358 } | 363 } |
| 359 return vreg; | 364 return vreg; |
| 360 } | 365 } |
| 361 | 366 |
| 362 // Checks whether the value of a given virtual register is a reference. | 367 // Checks whether the value of a given virtual register is a reference. |
| 363 // TODO(titzer): rename this to IsReference. | 368 // TODO(titzer): rename this to IsReference. |
| 364 bool HasTaggedValue(int virtual_register) const; | 369 bool HasTaggedValue(int virtual_register) const; |
| 365 | 370 |
| 366 // Returns the register kind required by the given virtual register. | 371 // Returns the register kind required by the given virtual register. |
| 367 RegisterKind RequiredRegisterKind(int virtual_register) const; | 372 RegisterKind RequiredRegisterKind(int virtual_register) const; |
| 368 | 373 |
| 369 // This zone is for datastructures only needed during register allocation. | |
| 370 Zone* zone() const { return zone_; } | |
| 371 | |
| 372 // This zone is for InstructionOperands and moves that live beyond register | 374 // This zone is for InstructionOperands and moves that live beyond register |
| 373 // allocation. | 375 // allocation. |
| 374 Zone* code_zone() const { return code()->zone(); } | 376 Zone* code_zone() const { return code()->zone(); } |
| 375 | 377 |
| 376 #ifdef DEBUG | 378 #ifdef DEBUG |
| 377 void Verify() const; | 379 void Verify() const; |
| 378 #endif | 380 #endif |
| 379 | 381 |
| 380 void MeetRegisterConstraints(); | 382 void MeetRegisterConstraints(); |
| 381 void ResolvePhis(); | 383 void ResolvePhis(); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 468 | 470 |
| 469 // If we are trying to spill a range inside the loop try to | 471 // If we are trying to spill a range inside the loop try to |
| 470 // hoist spill position out to the point just before the loop. | 472 // hoist spill position out to the point just before the loop. |
| 471 LifetimePosition FindOptimalSpillingPos(LiveRange* range, | 473 LifetimePosition FindOptimalSpillingPos(LiveRange* range, |
| 472 LifetimePosition pos); | 474 LifetimePosition pos); |
| 473 | 475 |
| 474 void Spill(LiveRange* range); | 476 void Spill(LiveRange* range); |
| 475 bool IsBlockBoundary(LifetimePosition pos); | 477 bool IsBlockBoundary(LifetimePosition pos); |
| 476 | 478 |
| 477 // Helper methods for resolving control flow. | 479 // Helper methods for resolving control flow. |
| 478 void ResolveControlFlow(LiveRange* range, const InstructionBlock* block, | 480 void ResolveControlFlow(const InstructionBlock* block, |
| 479 const InstructionBlock* pred); | 481 const LiveRange* cur_cover, |
| 482 const InstructionBlock* pred, | |
| 483 const LiveRange* pred_cover); | |
| 480 | 484 |
| 481 void SetLiveRangeAssignedRegister(LiveRange* range, int reg); | 485 void SetLiveRangeAssignedRegister(LiveRange* range, int reg); |
| 482 | 486 |
| 483 // Return parallel move that should be used to connect ranges split at the | 487 // Return parallel move that should be used to connect ranges split at the |
| 484 // given position. | 488 // given position. |
| 485 ParallelMove* GetConnectingParallelMove(LifetimePosition pos); | 489 ParallelMove* GetConnectingParallelMove(LifetimePosition pos); |
| 486 | 490 |
| 487 // Return the block which contains give lifetime position. | 491 // Return the block which contains give lifetime position. |
| 488 const InstructionBlock* GetInstructionBlock(LifetimePosition pos); | 492 const InstructionBlock* GetInstructionBlock(LifetimePosition pos); |
| 489 | 493 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 540 #endif | 544 #endif |
| 541 | 545 |
| 542 DISALLOW_COPY_AND_ASSIGN(RegisterAllocator); | 546 DISALLOW_COPY_AND_ASSIGN(RegisterAllocator); |
| 543 }; | 547 }; |
| 544 | 548 |
| 545 } | 549 } |
| 546 } | 550 } |
| 547 } // namespace v8::internal::compiler | 551 } // namespace v8::internal::compiler |
| 548 | 552 |
| 549 #endif // V8_REGISTER_ALLOCATOR_H_ | 553 #endif // V8_REGISTER_ALLOCATOR_H_ |
| OLD | NEW |