| 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 15 matching lines...) Expand all Loading... |
| 26 | 26 |
| 27 void AllocateRegisters(); | 27 void AllocateRegisters(); |
| 28 | 28 |
| 29 // Build live-in and live-out sets for each block. | 29 // Build live-in and live-out sets for each block. |
| 30 void AnalyzeLiveness(); | 30 void AnalyzeLiveness(); |
| 31 | 31 |
| 32 // Map a virtual register number to its live range. | 32 // Map a virtual register number to its live range. |
| 33 LiveRange* GetLiveRange(intptr_t vreg); | 33 LiveRange* GetLiveRange(intptr_t vreg); |
| 34 | 34 |
| 35 private: | 35 private: |
| 36 void CollectRepresentations(); |
| 37 |
| 36 // Eliminate unnecessary environments from the IL. | 38 // Eliminate unnecessary environments from the IL. |
| 37 void EliminateEnvironmentUses(); | 39 void EliminateEnvironmentUses(); |
| 38 | 40 |
| 39 // Compute initial values for live-out, kill and live-in sets. | 41 // Compute initial values for live-out, kill and live-in sets. |
| 40 void ComputeInitialSets(); | 42 void ComputeInitialSets(); |
| 41 | 43 |
| 42 // Update live-out set for the given block: live-out should contain | 44 // Update live-out set for the given block: live-out should contain |
| 43 // all values that are live-in for block's successors. | 45 // all values that are live-in for block's successors. |
| 44 // Returns true if live-out set was changed. | 46 // Returns true if live-out set was changed. |
| 45 bool UpdateLiveOut(const BlockEntryInstr& instr); | 47 bool UpdateLiveOut(const BlockEntryInstr& instr); |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 // Spill the given live range from the given position until some | 186 // Spill the given live range from the given position until some |
| 185 // position preceding the to position. | 187 // position preceding the to position. |
| 186 void SpillBetween(LiveRange* range, intptr_t from, intptr_t to); | 188 void SpillBetween(LiveRange* range, intptr_t from, intptr_t to); |
| 187 | 189 |
| 188 // Mark the live range as a live object pointer at all safepoints | 190 // Mark the live range as a live object pointer at all safepoints |
| 189 // contained in the range. | 191 // contained in the range. |
| 190 void MarkAsObjectAtSafepoints(LiveRange* range); | 192 void MarkAsObjectAtSafepoints(LiveRange* range); |
| 191 | 193 |
| 192 MoveOperands* AddMoveAt(intptr_t pos, Location to, Location from); | 194 MoveOperands* AddMoveAt(intptr_t pos, Location to, Location from); |
| 193 | 195 |
| 194 Location MakeRegisterLocation(intptr_t reg) { | 196 Location MakeRegisterLocation(intptr_t reg, Location::Representation rep) { |
| 195 return Location::MachineRegisterLocation(register_kind_, reg); | 197 return Location::MachineRegisterLocation(register_kind_, reg, rep); |
| 196 } | 198 } |
| 197 | 199 |
| 198 void PrintLiveRanges(); | 200 void PrintLiveRanges(); |
| 199 | 201 |
| 200 const FlowGraph& flow_graph_; | 202 const FlowGraph& flow_graph_; |
| 203 |
| 204 // Set of SSA values that have unboxed mint representation. Indexed |
| 205 // by SSA temp index. |
| 206 BitVector* mint_values_; |
| 207 |
| 201 const GrowableArray<BlockEntryInstr*>& block_order_; | 208 const GrowableArray<BlockEntryInstr*>& block_order_; |
| 202 const GrowableArray<BlockEntryInstr*>& postorder_; | 209 const GrowableArray<BlockEntryInstr*>& postorder_; |
| 203 | 210 |
| 204 // Mapping between lifetime positions and instructions. | 211 // Mapping between lifetime positions and instructions. |
| 205 GrowableArray<Instruction*> instructions_; | 212 GrowableArray<Instruction*> instructions_; |
| 206 | 213 |
| 207 // Mapping between lifetime positions and blocks containing them. | 214 // Mapping between lifetime positions and blocks containing them. |
| 208 GrowableArray<BlockInfo*> block_info_; | 215 GrowableArray<BlockInfo*> block_info_; |
| 209 | 216 |
| 210 // Live-out sets for each block. They contain indices of SSA values | 217 // Live-out sets for each block. They contain indices of SSA values |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 442 const intptr_t pos_; | 449 const intptr_t pos_; |
| 443 LocationSummary* const locs_; | 450 LocationSummary* const locs_; |
| 444 | 451 |
| 445 SafepointPosition* next_; | 452 SafepointPosition* next_; |
| 446 }; | 453 }; |
| 447 | 454 |
| 448 | 455 |
| 449 // LiveRange represents a sequence of UseIntervals for a given SSA value. | 456 // LiveRange represents a sequence of UseIntervals for a given SSA value. |
| 450 class LiveRange : public ZoneAllocated { | 457 class LiveRange : public ZoneAllocated { |
| 451 public: | 458 public: |
| 452 explicit LiveRange(intptr_t vreg) | 459 explicit LiveRange(intptr_t vreg, Location::Representation rep) |
| 453 : vreg_(vreg), | 460 : vreg_(vreg), |
| 461 representation_(rep), |
| 454 assigned_location_(), | 462 assigned_location_(), |
| 455 spill_slot_(), | 463 spill_slot_(), |
| 456 uses_(NULL), | 464 uses_(NULL), |
| 457 first_use_interval_(NULL), | 465 first_use_interval_(NULL), |
| 458 last_use_interval_(NULL), | 466 last_use_interval_(NULL), |
| 459 first_safepoint_(NULL), | 467 first_safepoint_(NULL), |
| 460 last_safepoint_(NULL), | 468 last_safepoint_(NULL), |
| 461 next_sibling_(NULL), | 469 next_sibling_(NULL), |
| 462 finger_() { | 470 finger_() { |
| 463 } | 471 } |
| 464 | 472 |
| 465 static LiveRange* MakeTemp(intptr_t pos, Location* location_slot); | 473 static LiveRange* MakeTemp(intptr_t pos, Location* location_slot); |
| 466 | 474 |
| 467 intptr_t vreg() const { return vreg_; } | 475 intptr_t vreg() const { return vreg_; } |
| 476 Location::Representation representation() const { return representation_; } |
| 468 LiveRange* next_sibling() const { return next_sibling_; } | 477 LiveRange* next_sibling() const { return next_sibling_; } |
| 469 UsePosition* first_use() const { return uses_; } | 478 UsePosition* first_use() const { return uses_; } |
| 470 void set_first_use(UsePosition* use) { uses_ = use; } | 479 void set_first_use(UsePosition* use) { uses_ = use; } |
| 471 UseInterval* first_use_interval() const { return first_use_interval_; } | 480 UseInterval* first_use_interval() const { return first_use_interval_; } |
| 472 UseInterval* last_use_interval() const { return last_use_interval_; } | 481 UseInterval* last_use_interval() const { return last_use_interval_; } |
| 473 Location assigned_location() const { return assigned_location_; } | 482 Location assigned_location() const { return assigned_location_; } |
| 474 intptr_t Start() const { return first_use_interval()->start(); } | 483 intptr_t Start() const { return first_use_interval()->start(); } |
| 475 intptr_t End() const { return last_use_interval()->end(); } | 484 intptr_t End() const { return last_use_interval()->end(); } |
| 476 | 485 |
| 477 SafepointPosition* first_safepoint() const { return first_safepoint_; } | 486 SafepointPosition* first_safepoint() const { return first_safepoint_; } |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 510 | 519 |
| 511 // True if the range contains the given position. | 520 // True if the range contains the given position. |
| 512 bool Contains(intptr_t pos) const; | 521 bool Contains(intptr_t pos) const; |
| 513 | 522 |
| 514 Location spill_slot() const { | 523 Location spill_slot() const { |
| 515 return spill_slot_; | 524 return spill_slot_; |
| 516 } | 525 } |
| 517 | 526 |
| 518 private: | 527 private: |
| 519 LiveRange(intptr_t vreg, | 528 LiveRange(intptr_t vreg, |
| 529 Location::Representation rep, |
| 520 UsePosition* uses, | 530 UsePosition* uses, |
| 521 UseInterval* first_use_interval, | 531 UseInterval* first_use_interval, |
| 522 UseInterval* last_use_interval, | 532 UseInterval* last_use_interval, |
| 523 SafepointPosition* first_safepoint, | 533 SafepointPosition* first_safepoint, |
| 524 LiveRange* next_sibling) | 534 LiveRange* next_sibling) |
| 525 : vreg_(vreg), | 535 : vreg_(vreg), |
| 536 representation_(rep), |
| 526 assigned_location_(), | 537 assigned_location_(), |
| 527 uses_(uses), | 538 uses_(uses), |
| 528 first_use_interval_(first_use_interval), | 539 first_use_interval_(first_use_interval), |
| 529 last_use_interval_(last_use_interval), | 540 last_use_interval_(last_use_interval), |
| 530 first_safepoint_(first_safepoint), | 541 first_safepoint_(first_safepoint), |
| 531 last_safepoint_(NULL), | 542 last_safepoint_(NULL), |
| 532 next_sibling_(next_sibling), | 543 next_sibling_(next_sibling), |
| 533 finger_() { | 544 finger_() { |
| 534 } | 545 } |
| 535 | 546 |
| 536 const intptr_t vreg_; | 547 const intptr_t vreg_; |
| 548 Location::Representation representation_; |
| 537 Location assigned_location_; | 549 Location assigned_location_; |
| 538 Location spill_slot_; | 550 Location spill_slot_; |
| 539 | 551 |
| 540 UsePosition* uses_; | 552 UsePosition* uses_; |
| 541 UseInterval* first_use_interval_; | 553 UseInterval* first_use_interval_; |
| 542 UseInterval* last_use_interval_; | 554 UseInterval* last_use_interval_; |
| 543 | 555 |
| 544 SafepointPosition* first_safepoint_; | 556 SafepointPosition* first_safepoint_; |
| 545 SafepointPosition* last_safepoint_; | 557 SafepointPosition* last_safepoint_; |
| 546 | 558 |
| 547 LiveRange* next_sibling_; | 559 LiveRange* next_sibling_; |
| 548 | 560 |
| 549 AllocationFinger finger_; | 561 AllocationFinger finger_; |
| 550 | 562 |
| 551 DISALLOW_COPY_AND_ASSIGN(LiveRange); | 563 DISALLOW_COPY_AND_ASSIGN(LiveRange); |
| 552 }; | 564 }; |
| 553 | 565 |
| 554 | 566 |
| 555 } // namespace dart | 567 } // namespace dart |
| 556 | 568 |
| 557 #endif // VM_FLOW_GRAPH_ALLOCATOR_H_ | 569 #endif // VM_FLOW_GRAPH_ALLOCATOR_H_ |
| OLD | NEW |