| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 // for blocks until they stop changing. | 45 // for blocks until they stop changing. |
| 46 void ComputeLiveInAndLiveOutSets(); | 46 void ComputeLiveInAndLiveOutSets(); |
| 47 | 47 |
| 48 // Print results of liveness analysis. | 48 // Print results of liveness analysis. |
| 49 void DumpLiveness(); | 49 void DumpLiveness(); |
| 50 | 50 |
| 51 // Visit blocks in the code generation order (reverse post order) and | 51 // Visit blocks in the code generation order (reverse post order) and |
| 52 // linearly assign consequent lifetime positions to every instruction. | 52 // linearly assign consequent lifetime positions to every instruction. |
| 53 // We assign position as follows: | 53 // We assign position as follows: |
| 54 // | 54 // |
| 55 // 2 * n - even position corresponding to an implicit parallel move | 55 // 2 * n - even position corresponding to instruction's start; |
| 56 // preceding the instruction; | |
| 57 // | 56 // |
| 58 // 2 * n + 1 - odd position corresponding to instruction itself; | 57 // 2 * n + 1 - odd position corresponding to instruction's end; |
| 59 // | 58 // |
| 60 // Having positions corresponding to parallel moves between every two | 59 // Having two positions per instruction allows us to capture non-trivial |
| 61 // instructions allows us to capture non-trivial shapes of use intervals. | 60 // shapes of use intervals: e.g. by placing a use at the start or the |
| 61 // end position we can distinguish between instructions that need value |
| 62 // at the register only at their start and those instructions that |
| 63 // need value in the register until the end of instruction's body. |
| 64 // Register allocator can perform splitting of live ranges at any position. |
| 65 // An implicit ParallelMove will be inserted by ConnectSplitSiblings where |
| 66 // required to resolve data flow between split siblings when allocation |
| 67 // is finished. |
| 62 // For specific examples see comments inside ProcessOneInstruction. | 68 // For specific examples see comments inside ProcessOneInstruction. |
| 63 // Additionally creates parallel moves at the joins' predecessors | 69 // Additionally creates parallel moves at the joins' predecessors |
| 64 // that will be used for phi resolution. | 70 // that will be used for phi resolution. |
| 65 void NumberInstructions(); | 71 void NumberInstructions(); |
| 66 Instruction* InstructionAt(intptr_t pos) const; | 72 Instruction* InstructionAt(intptr_t pos) const; |
| 67 bool IsBlockEntry(intptr_t pos) const; | 73 bool IsBlockEntry(intptr_t pos) const; |
| 68 | 74 |
| 69 LiveRange* GetLiveRange(intptr_t vreg); | 75 LiveRange* GetLiveRange(intptr_t vreg); |
| 70 | 76 |
| 71 // Visit instructions in the postorder and build live ranges for | 77 // Visit instructions in the postorder and build live ranges for |
| 72 // all SSA values. | 78 // all SSA values. |
| 73 void BuildLiveRanges(); | 79 void BuildLiveRanges(); |
| 74 Instruction* ConnectOutgoingPhiMoves(BlockEntryInstr* block); | 80 Instruction* ConnectOutgoingPhiMoves(BlockEntryInstr* block); |
| 75 void ProcessOneInstruction(BlockEntryInstr* block, Instruction* instr); | 81 void ProcessOneInstruction(BlockEntryInstr* block, Instruction* instr); |
| 76 void ConnectIncomingPhiMoves(BlockEntryInstr* block); | 82 void ConnectIncomingPhiMoves(BlockEntryInstr* block); |
| 77 void BlockLocation(Location loc, intptr_t from, intptr_t to); | 83 void BlockLocation(Location loc, intptr_t pos); |
| 78 | 84 |
| 79 // Process live ranges sorted by their start and assign registers | 85 // Process live ranges sorted by their start and assign registers |
| 80 // to them | 86 // to them |
| 81 void AllocateCPURegisters(); | 87 void AllocateCPURegisters(); |
| 82 void AdvanceActiveIntervals(const intptr_t start); | 88 void AdvanceActiveIntervals(const intptr_t start); |
| 83 | 89 |
| 84 // Connect split siblings over non-linear control flow edges. | 90 // Connect split siblings over non-linear control flow edges. |
| 85 void ResolveControlFlow(); | 91 void ResolveControlFlow(); |
| 86 void ConnectSplitSiblings(LiveRange* range, | 92 void ConnectSplitSiblings(LiveRange* range, |
| 87 BlockEntryInstr* source_block, | 93 BlockEntryInstr* source_block, |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 | 384 |
| 379 AllocationFinger finger_; | 385 AllocationFinger finger_; |
| 380 | 386 |
| 381 DISALLOW_COPY_AND_ASSIGN(LiveRange); | 387 DISALLOW_COPY_AND_ASSIGN(LiveRange); |
| 382 }; | 388 }; |
| 383 | 389 |
| 384 | 390 |
| 385 } // namespace dart | 391 } // namespace dart |
| 386 | 392 |
| 387 #endif // VM_FLOW_GRAPH_ALLOCATOR_H_ | 393 #endif // VM_FLOW_GRAPH_ALLOCATOR_H_ |
| OLD | NEW |