| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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_GREEDY_ALLOCATOR_H_ | 5 #ifndef V8_GREEDY_ALLOCATOR_H_ |
| 6 #define V8_GREEDY_ALLOCATOR_H_ | 6 #define V8_GREEDY_ALLOCATOR_H_ |
| 7 | 7 |
| 8 #include "src/compiler/coalesced-live-ranges.h" | 8 #include "src/compiler/coalesced-live-ranges.h" |
| 9 #include "src/compiler/register-allocator.h" | 9 #include "src/compiler/register-allocator.h" |
| 10 #include "src/zone-containers.h" | 10 #include "src/zone-containers.h" |
| 11 | 11 |
| 12 namespace v8 { | 12 namespace v8 { |
| 13 namespace internal { | 13 namespace internal { |
| 14 namespace compiler { | 14 namespace compiler { |
| 15 | 15 |
| 16 | 16 |
| 17 // The object of allocation scheduling. At minimum, this is a LiveRange, but | 17 // The object of allocation scheduling. At minimum, this is a LiveRange, but |
| 18 // we may extend this to groups of LiveRanges. It has to be comparable. | 18 // we may extend this to groups of LiveRanges. It has to be comparable. |
| 19 class AllocationCandidate { | 19 class AllocationCandidate { |
| 20 public: | 20 public: |
| 21 explicit AllocationCandidate(LiveRange* range) : range_(range) {} | 21 explicit AllocationCandidate(LiveRange* range) : range_(range) {} |
| 22 | 22 |
| 23 // Strict ordering operators | 23 // Strict ordering operators |
| 24 bool operator<(const AllocationCandidate& other) const { | 24 bool operator<(const AllocationCandidate& other) const { |
| 25 return range_->GetSize() < other.range_->GetSize(); | 25 DCHECK(range_->IsSizeValid()); |
| 26 DCHECK(other.range_->IsSizeValid()); |
| 27 return range_->size() < other.range_->size(); |
| 26 } | 28 } |
| 27 | 29 |
| 28 bool operator>(const AllocationCandidate& other) const { | 30 bool operator>(const AllocationCandidate& other) const { |
| 29 return range_->GetSize() > other.range_->GetSize(); | 31 DCHECK(range_->IsSizeValid()); |
| 32 DCHECK(other.range_->IsSizeValid()); |
| 33 return range_->size() > other.range_->size(); |
| 30 } | 34 } |
| 31 | 35 |
| 32 LiveRange* live_range() const { return range_; } | 36 LiveRange* live_range() const { return range_; } |
| 33 | 37 |
| 34 private: | 38 private: |
| 35 LiveRange* range_; | 39 LiveRange* range_; |
| 36 }; | 40 }; |
| 37 | 41 |
| 38 | 42 |
| 39 // Schedule processing (allocating) of AllocationCandidates. | 43 // Schedule processing (allocating) of AllocationCandidates. |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 | 136 |
| 133 Zone* local_zone_; | 137 Zone* local_zone_; |
| 134 ZoneVector<CoalescedLiveRanges*> allocations_; | 138 ZoneVector<CoalescedLiveRanges*> allocations_; |
| 135 AllocationScheduler scheduler_; | 139 AllocationScheduler scheduler_; |
| 136 DISALLOW_COPY_AND_ASSIGN(GreedyAllocator); | 140 DISALLOW_COPY_AND_ASSIGN(GreedyAllocator); |
| 137 }; | 141 }; |
| 138 } // namespace compiler | 142 } // namespace compiler |
| 139 } // namespace internal | 143 } // namespace internal |
| 140 } // namespace v8 | 144 } // namespace v8 |
| 141 #endif // V8_GREEDY_ALLOCATOR_H_ | 145 #endif // V8_GREEDY_ALLOCATOR_H_ |
| OLD | NEW |