| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef VM_FLOW_GRAPH_ALLOCATOR_H_ | 5 #ifndef VM_FLOW_GRAPH_ALLOCATOR_H_ |
| 6 #define VM_FLOW_GRAPH_ALLOCATOR_H_ | 6 #define VM_FLOW_GRAPH_ALLOCATOR_H_ |
| 7 | 7 |
| 8 #include "vm/growable_array.h" | 8 #include "vm/growable_array.h" |
| 9 #include "vm/intermediate_language.h" | 9 #include "vm/intermediate_language.h" |
| 10 | 10 |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 | 258 |
| 259 | 259 |
| 260 // UsePosition represents a single use of an SSA value by some instruction. | 260 // UsePosition represents a single use of an SSA value by some instruction. |
| 261 // It points to a location slot which either tells register allocator | 261 // It points to a location slot which either tells register allocator |
| 262 // where instruction expects the value (if slot contains a fixed location) or | 262 // where instruction expects the value (if slot contains a fixed location) or |
| 263 // asks register allocator to allocate storage (register or spill slot) for | 263 // asks register allocator to allocate storage (register or spill slot) for |
| 264 // this use with certain properties (if slot contains an unallocated location). | 264 // this use with certain properties (if slot contains an unallocated location). |
| 265 class UsePosition : public ZoneAllocated { | 265 class UsePosition : public ZoneAllocated { |
| 266 public: | 266 public: |
| 267 UsePosition(intptr_t pos, UsePosition* next, Location* location_slot) | 267 UsePosition(intptr_t pos, UsePosition* next, Location* location_slot) |
| 268 : pos_(pos), location_slot_(location_slot), next_(next) { } | 268 : pos_(pos), location_slot_(location_slot), hint_(NULL), next_(next) { } |
| 269 | 269 |
| 270 Location* location_slot() const { return location_slot_; } | 270 Location* location_slot() const { return location_slot_; } |
| 271 void set_location_slot(Location* location_slot) { | 271 void set_location_slot(Location* location_slot) { |
| 272 location_slot_ = location_slot; | 272 location_slot_ = location_slot; |
| 273 } | 273 } |
| 274 | 274 |
| 275 Location hint() const { |
| 276 ASSERT(HasHint()); |
| 277 return *hint_; |
| 278 } |
| 279 |
| 280 void set_hint(Location* hint) { |
| 281 hint_ = hint; |
| 282 } |
| 283 |
| 284 bool HasHint() const { |
| 285 return (hint_ != NULL) && !hint_->IsUnallocated(); |
| 286 } |
| 287 |
| 288 |
| 275 void set_next(UsePosition* next) { next_ = next; } | 289 void set_next(UsePosition* next) { next_ = next; } |
| 276 UsePosition* next() const { return next_; } | 290 UsePosition* next() const { return next_; } |
| 277 | 291 |
| 278 intptr_t pos() const { return pos_; } | 292 intptr_t pos() const { return pos_; } |
| 279 | 293 |
| 280 bool HasHint() const { | |
| 281 return (location_slot() != NULL) && (location_slot()->IsRegister()); | |
| 282 } | |
| 283 | |
| 284 Location hint() const { | |
| 285 ASSERT(HasHint()); | |
| 286 return *location_slot(); | |
| 287 } | |
| 288 | |
| 289 private: | 294 private: |
| 290 const intptr_t pos_; | 295 const intptr_t pos_; |
| 291 Location* location_slot_; | 296 Location* location_slot_; |
| 297 Location* hint_; |
| 292 UsePosition* next_; | 298 UsePosition* next_; |
| 293 | 299 |
| 294 DISALLOW_COPY_AND_ASSIGN(UsePosition); | 300 DISALLOW_COPY_AND_ASSIGN(UsePosition); |
| 295 }; | 301 }; |
| 296 | 302 |
| 297 | 303 |
| 298 // UseInterval represents a holeless half open interval of liveness for a given | 304 // UseInterval represents a holeless half open interval of liveness for a given |
| 299 // SSA value: [start, end) in terms of lifetime positions that | 305 // SSA value: [start, end) in terms of lifetime positions that |
| 300 // NumberInstructions assigns to instructions. Register allocator has to keep | 306 // NumberInstructions assigns to instructions. Register allocator has to keep |
| 301 // a value live in the register or in a spill slot from start position and until | 307 // a value live in the register or in a spill slot from start position and until |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 assigned_location_ = location; | 405 assigned_location_ = location; |
| 400 } | 406 } |
| 401 | 407 |
| 402 void set_spill_slot(Location spill_slot) { | 408 void set_spill_slot(Location spill_slot) { |
| 403 spill_slot_ = spill_slot; | 409 spill_slot_ = spill_slot; |
| 404 } | 410 } |
| 405 | 411 |
| 406 void DefineAt(intptr_t pos); | 412 void DefineAt(intptr_t pos); |
| 407 | 413 |
| 408 void AddUse(intptr_t pos, Location* location_slot); | 414 void AddUse(intptr_t pos, Location* location_slot); |
| 415 void AddHintedUse(intptr_t pos, Location* location_slot, Location* hint); |
| 416 |
| 409 void AddUseInterval(intptr_t start, intptr_t end); | 417 void AddUseInterval(intptr_t start, intptr_t end); |
| 410 | 418 |
| 411 void Print(); | 419 void Print(); |
| 412 | 420 |
| 413 void AssignLocation(UseInterval* use, Location loc); | 421 void AssignLocation(UseInterval* use, Location loc); |
| 414 | 422 |
| 415 LiveRange* SplitAt(intptr_t pos); | 423 LiveRange* SplitAt(intptr_t pos); |
| 416 | 424 |
| 417 bool CanCover(intptr_t pos) const { | 425 bool CanCover(intptr_t pos) const { |
| 418 return (Start() <= pos) && (pos < End()); | 426 return (Start() <= pos) && (pos < End()); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 449 | 457 |
| 450 AllocationFinger finger_; | 458 AllocationFinger finger_; |
| 451 | 459 |
| 452 DISALLOW_COPY_AND_ASSIGN(LiveRange); | 460 DISALLOW_COPY_AND_ASSIGN(LiveRange); |
| 453 }; | 461 }; |
| 454 | 462 |
| 455 | 463 |
| 456 } // namespace dart | 464 } // namespace dart |
| 457 | 465 |
| 458 #endif // VM_FLOW_GRAPH_ALLOCATOR_H_ | 466 #endif // VM_FLOW_GRAPH_ALLOCATOR_H_ |
| OLD | NEW |