| 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 |
| 11 namespace dart { | 11 namespace dart { |
| 12 | 12 |
| 13 class FlowGraphAllocator : public ValueObject { | 13 class FlowGraphAllocator : public ValueObject { |
| 14 public: | 14 public: |
| 15 FlowGraphAllocator(const GrowableArray<BlockEntryInstr*>& postorder, | 15 FlowGraphAllocator(const GrowableArray<BlockEntryInstr*>& postorder, |
| 16 intptr_t max_ssa_temp_index); | 16 intptr_t max_ssa_temp_index); |
| 17 | 17 |
| 18 void ResolveConstraints(); | 18 void ResolveConstraints(); |
| 19 | 19 |
| 20 // Build live-in and live-out sets for each block. |
| 20 void AnalyzeLiveness(); | 21 void AnalyzeLiveness(); |
| 21 | 22 |
| 22 private: | 23 private: |
| 23 void ComputeKillAndGenSets(); | 24 // Compute initial values for live-out, kill and live-in sets. |
| 25 void ComputeInitialSets(); |
| 26 |
| 27 // Update live-out set for the given block: live-out should contain |
| 28 // all values that are live-in for block's successors. |
| 29 // Returns true if live-out set was changed. |
| 24 bool UpdateLiveOut(BlockEntryInstr* instr); | 30 bool UpdateLiveOut(BlockEntryInstr* instr); |
| 31 |
| 32 // Update live-in set for the given block: live-in should contain |
| 33 // all values taht are live-out from the block and are not defined |
| 34 // by this block. |
| 35 // Returns true if live-in set was changed. |
| 25 bool UpdateLiveIn(BlockEntryInstr* instr); | 36 bool UpdateLiveIn(BlockEntryInstr* instr); |
| 37 |
| 38 // Perform fix-point iteration updating live-out and live-in sets |
| 39 // for blocks until they stop changing. |
| 26 void ComputeLiveInAndLiveOutSets(); | 40 void ComputeLiveInAndLiveOutSets(); |
| 41 |
| 42 // Print results of liveness analysis. |
| 27 void DumpLiveness(); | 43 void DumpLiveness(); |
| 28 | 44 |
| 45 // Live-out sets for each block. They contain indices of SSA values |
| 46 // that are live out from this block: that is values that were either |
| 47 // defined in this block or live into it and that are used in some |
| 48 // successor block. |
| 29 GrowableArray<BitVector*> live_out_; | 49 GrowableArray<BitVector*> live_out_; |
| 50 |
| 51 // Kill sets for each block. They contain indices of SSA values that |
| 52 // are defined by this block. |
| 30 GrowableArray<BitVector*> kill_; | 53 GrowableArray<BitVector*> kill_; |
| 31 GrowableArray<BitVector*> gen_; | 54 |
| 55 // Live-in sets for each block. They contain indices of SSA values |
| 56 // that are used by this block or its successors. |
| 32 GrowableArray<BitVector*> live_in_; | 57 GrowableArray<BitVector*> live_in_; |
| 58 |
| 33 const GrowableArray<BlockEntryInstr*>& postorder_; | 59 const GrowableArray<BlockEntryInstr*>& postorder_; |
| 60 |
| 61 // Number of virtual registers. Currently equal to the number of |
| 62 // SSA values. |
| 34 const intptr_t vreg_count_; | 63 const intptr_t vreg_count_; |
| 35 | 64 |
| 36 DISALLOW_COPY_AND_ASSIGN(FlowGraphAllocator); | 65 DISALLOW_COPY_AND_ASSIGN(FlowGraphAllocator); |
| 37 }; | 66 }; |
| 38 | 67 |
| 39 } // namespace dart | 68 } // namespace dart |
| 40 | 69 |
| 41 #endif // VM_FLOW_GRAPH_ALLOCATOR_H_ | 70 #endif // VM_FLOW_GRAPH_ALLOCATOR_H_ |
| OLD | NEW |