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/ostreams.h" | 9 #include "src/ostreams.h" |
10 #include "src/register-configuration.h" | 10 #include "src/register-configuration.h" |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 // For hinting only. | 268 // For hinting only. |
269 void set_assigned_register(int register_code) { | 269 void set_assigned_register(int register_code) { |
270 flags_ = AssignedRegisterField::update(flags_, register_code); | 270 flags_ = AssignedRegisterField::update(flags_, register_code); |
271 } | 271 } |
272 | 272 |
273 UsePositionHintType hint_type() const { | 273 UsePositionHintType hint_type() const { |
274 return HintTypeField::decode(flags_); | 274 return HintTypeField::decode(flags_); |
275 } | 275 } |
276 bool HasHint() const; | 276 bool HasHint() const; |
277 bool HintRegister(int* register_code) const; | 277 bool HintRegister(int* register_code) const; |
| 278 void SetHint(UsePosition* use_pos); |
278 void ResolveHint(UsePosition* use_pos); | 279 void ResolveHint(UsePosition* use_pos); |
279 bool IsResolved() const { | 280 bool IsResolved() const { |
280 return hint_type() != UsePositionHintType::kUnresolved; | 281 return hint_type() != UsePositionHintType::kUnresolved; |
281 } | 282 } |
282 static UsePositionHintType HintTypeForOperand(const InstructionOperand& op); | 283 static UsePositionHintType HintTypeForOperand(const InstructionOperand& op); |
283 | 284 |
284 private: | 285 private: |
285 typedef BitField<UsePositionType, 0, 2> TypeField; | 286 typedef BitField<UsePositionType, 0, 2> TypeField; |
286 typedef BitField<UsePositionHintType, 2, 3> HintTypeField; | 287 typedef BitField<UsePositionHintType, 2, 3> HintTypeField; |
287 typedef BitField<bool, 5, 1> RegisterBeneficialField; | 288 typedef BitField<bool, 5, 1> RegisterBeneficialField; |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 // Can this live range be spilled at this position. | 362 // Can this live range be spilled at this position. |
362 bool CanBeSpilled(LifetimePosition pos) const; | 363 bool CanBeSpilled(LifetimePosition pos) const; |
363 | 364 |
364 // Splitting primitive used by both splitting and splintering members. | 365 // Splitting primitive used by both splitting and splintering members. |
365 // Performs the split, but does not link the resulting ranges. | 366 // Performs the split, but does not link the resulting ranges. |
366 // The given position must follow the start of the range. | 367 // The given position must follow the start of the range. |
367 // All uses following the given position will be moved from this | 368 // All uses following the given position will be moved from this |
368 // live range to the result live range. | 369 // live range to the result live range. |
369 // The current range will terminate at position, while result will start from | 370 // The current range will terminate at position, while result will start from |
370 // position. | 371 // position. |
| 372 enum HintConnectionOption : bool { |
| 373 DoNotConnectHints = false, |
| 374 ConnectHints = true |
| 375 }; |
371 UsePosition* DetachAt(LifetimePosition position, LiveRange* result, | 376 UsePosition* DetachAt(LifetimePosition position, LiveRange* result, |
372 Zone* zone); | 377 Zone* zone, HintConnectionOption connect_hints); |
373 | 378 |
374 // Detaches at position, and then links the resulting ranges. Returns the | 379 // Detaches at position, and then links the resulting ranges. Returns the |
375 // child, which starts at position. | 380 // child, which starts at position. |
376 LiveRange* SplitAt(LifetimePosition position, Zone* zone); | 381 LiveRange* SplitAt(LifetimePosition position, Zone* zone); |
377 | 382 |
378 // Returns nullptr when no register is hinted, otherwise sets register_index. | 383 // Returns nullptr when no register is hinted, otherwise sets register_index. |
379 UsePosition* FirstHintPosition(int* register_index) const; | 384 UsePosition* FirstHintPosition(int* register_index) const; |
380 UsePosition* FirstHintPosition() const { | 385 UsePosition* FirstHintPosition() const { |
381 int register_index; | 386 int register_index; |
382 return FirstHintPosition(®ister_index); | 387 return FirstHintPosition(®ister_index); |
(...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1040 void AddToUnhandledUnsorted(LiveRange* range); | 1045 void AddToUnhandledUnsorted(LiveRange* range); |
1041 void SortUnhandled(); | 1046 void SortUnhandled(); |
1042 bool UnhandledIsSorted(); | 1047 bool UnhandledIsSorted(); |
1043 void ActiveToHandled(LiveRange* range); | 1048 void ActiveToHandled(LiveRange* range); |
1044 void ActiveToInactive(LiveRange* range); | 1049 void ActiveToInactive(LiveRange* range); |
1045 void InactiveToHandled(LiveRange* range); | 1050 void InactiveToHandled(LiveRange* range); |
1046 void InactiveToActive(LiveRange* range); | 1051 void InactiveToActive(LiveRange* range); |
1047 | 1052 |
1048 // Helper methods for allocating registers. | 1053 // Helper methods for allocating registers. |
1049 bool TryReuseSpillForPhi(TopLevelLiveRange* range); | 1054 bool TryReuseSpillForPhi(TopLevelLiveRange* range); |
1050 bool TryAllocateFreeReg(LiveRange* range); | 1055 bool TryAllocateFreeReg(LiveRange* range, |
| 1056 const Vector<LifetimePosition>& free_until_pos); |
| 1057 bool TryAllocatePreferredReg(LiveRange* range, |
| 1058 const Vector<LifetimePosition>& free_until_pos); |
| 1059 void FindFreeRegistersForRange(LiveRange* range, |
| 1060 Vector<LifetimePosition> free_until_pos); |
| 1061 void ProcessCurrentRange(LiveRange* current); |
1051 void AllocateBlockedReg(LiveRange* range); | 1062 void AllocateBlockedReg(LiveRange* range); |
| 1063 bool TrySplitAndSpillSplinter(LiveRange* range); |
1052 | 1064 |
1053 // Spill the given life range after position pos. | 1065 // Spill the given life range after position pos. |
1054 void SpillAfter(LiveRange* range, LifetimePosition pos); | 1066 void SpillAfter(LiveRange* range, LifetimePosition pos); |
1055 | 1067 |
1056 // Spill the given life range after position [start] and up to position [end]. | 1068 // Spill the given life range after position [start] and up to position [end]. |
1057 void SpillBetween(LiveRange* range, LifetimePosition start, | 1069 void SpillBetween(LiveRange* range, LifetimePosition start, |
1058 LifetimePosition end); | 1070 LifetimePosition end); |
1059 | 1071 |
1060 // Spill the given life range after position [start] and up to position [end]. | 1072 // Spill the given life range after position [start] and up to position [end]. |
1061 // Range is guaranteed to be spilled at least until position [until]. | 1073 // Range is guaranteed to be spilled at least until position [until]. |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1168 RegisterAllocationData* const data_; | 1180 RegisterAllocationData* const data_; |
1169 | 1181 |
1170 DISALLOW_COPY_AND_ASSIGN(LiveRangeConnector); | 1182 DISALLOW_COPY_AND_ASSIGN(LiveRangeConnector); |
1171 }; | 1183 }; |
1172 | 1184 |
1173 } // namespace compiler | 1185 } // namespace compiler |
1174 } // namespace internal | 1186 } // namespace internal |
1175 } // namespace v8 | 1187 } // namespace v8 |
1176 | 1188 |
1177 #endif // V8_REGISTER_ALLOCATOR_H_ | 1189 #endif // V8_REGISTER_ALLOCATOR_H_ |
OLD | NEW |