OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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_H_ | 5 #ifndef VM_FLOW_GRAPH_H_ |
6 #define VM_FLOW_GRAPH_H_ | 6 #define VM_FLOW_GRAPH_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 #include "vm/parser.h" | 10 #include "vm/parser.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 bool Done() const { return current_ >= block_order_.length(); } | 34 bool Done() const { return current_ >= block_order_.length(); } |
35 | 35 |
36 BlockEntryInstr* Current() const { return block_order_[current_]; } | 36 BlockEntryInstr* Current() const { return block_order_[current_]; } |
37 | 37 |
38 private: | 38 private: |
39 const GrowableArray<BlockEntryInstr*>& block_order_; | 39 const GrowableArray<BlockEntryInstr*>& block_order_; |
40 intptr_t current_; | 40 intptr_t current_; |
41 }; | 41 }; |
42 | 42 |
43 | 43 |
44 // Class to incapsulate the construction and manipulation of the flow graph. | 44 // Class to encapsulate the construction and manipulation of the flow graph. |
45 class FlowGraph : public ZoneAllocated { | 45 class FlowGraph : public ZoneAllocated { |
46 public: | 46 public: |
47 FlowGraph(const FlowGraphBuilder& builder, | 47 FlowGraph(const FlowGraphBuilder& builder, |
48 GraphEntryInstr* graph_entry, | 48 GraphEntryInstr* graph_entry, |
49 intptr_t max_block_id); | 49 intptr_t max_block_id); |
50 | 50 |
51 // Function properties. | 51 // Function properties. |
52 const ParsedFunction& parsed_function() const { | 52 const ParsedFunction& parsed_function() const { |
53 return parsed_function_; | 53 return parsed_function_; |
54 } | 54 } |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 | 156 |
157 // Returns true if every Goto in the graph is expected to have a | 157 // Returns true if every Goto in the graph is expected to have a |
158 // deoptimization environment and can be used as deoptimization target | 158 // deoptimization environment and can be used as deoptimization target |
159 // for hoisted instructions. | 159 // for hoisted instructions. |
160 bool is_licm_allowed() const { return licm_allowed_; } | 160 bool is_licm_allowed() const { return licm_allowed_; } |
161 | 161 |
162 // Stop preserving environments on Goto instructions. LICM is not allowed | 162 // Stop preserving environments on Goto instructions. LICM is not allowed |
163 // after this point. | 163 // after this point. |
164 void disallow_licm() { licm_allowed_ = false; } | 164 void disallow_licm() { licm_allowed_ = false; } |
165 | 165 |
| 166 bool use_far_branches() const { return use_far_branches_; } |
| 167 void set_use_far_branches(bool value) { |
| 168 use_far_branches_ = value; |
| 169 } |
| 170 |
166 const ZoneGrowableArray<BlockEntryInstr*>& loop_headers() { | 171 const ZoneGrowableArray<BlockEntryInstr*>& loop_headers() { |
167 if (loop_headers_ == NULL) { | 172 if (loop_headers_ == NULL) { |
168 loop_headers_ = ComputeLoops(); | 173 loop_headers_ = ComputeLoops(); |
169 } | 174 } |
170 return *loop_headers_; | 175 return *loop_headers_; |
171 } | 176 } |
172 | 177 |
173 // Per loop header invariant loads sets. Each set contains load id for | 178 // Per loop header invariant loads sets. Each set contains load id for |
174 // those loads that are not affected by anything in the loop and can be | 179 // those loads that are not affected by anything in the loop and can be |
175 // hoisted out. Sets are computed by LoadOptimizer. | 180 // hoisted out. Sets are computed by LoadOptimizer. |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 const intptr_t num_stack_locals_; | 247 const intptr_t num_stack_locals_; |
243 GraphEntryInstr* graph_entry_; | 248 GraphEntryInstr* graph_entry_; |
244 GrowableArray<BlockEntryInstr*> preorder_; | 249 GrowableArray<BlockEntryInstr*> preorder_; |
245 GrowableArray<BlockEntryInstr*> postorder_; | 250 GrowableArray<BlockEntryInstr*> postorder_; |
246 GrowableArray<BlockEntryInstr*> reverse_postorder_; | 251 GrowableArray<BlockEntryInstr*> reverse_postorder_; |
247 ConstantInstr* constant_null_; | 252 ConstantInstr* constant_null_; |
248 | 253 |
249 BlockEffects* block_effects_; | 254 BlockEffects* block_effects_; |
250 bool licm_allowed_; | 255 bool licm_allowed_; |
251 | 256 |
| 257 bool use_far_branches_; |
| 258 |
252 ZoneGrowableArray<BlockEntryInstr*>* loop_headers_; | 259 ZoneGrowableArray<BlockEntryInstr*>* loop_headers_; |
253 ZoneGrowableArray<BitVector*>* loop_invariant_loads_; | 260 ZoneGrowableArray<BitVector*>* loop_invariant_loads_; |
254 }; | 261 }; |
255 | 262 |
256 | 263 |
257 class LivenessAnalysis : public ValueObject { | 264 class LivenessAnalysis : public ValueObject { |
258 public: | 265 public: |
259 LivenessAnalysis(intptr_t variable_count, | 266 LivenessAnalysis(intptr_t variable_count, |
260 const GrowableArray<BlockEntryInstr*>& postorder); | 267 const GrowableArray<BlockEntryInstr*>& postorder); |
261 | 268 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 // Per block sets of available blocks. Block A is available at the block B if | 356 // Per block sets of available blocks. Block A is available at the block B if |
350 // and only if A dominates B and all paths from A to B are free of side | 357 // and only if A dominates B and all paths from A to B are free of side |
351 // effects. | 358 // effects. |
352 GrowableArray<BitVector*> available_at_; | 359 GrowableArray<BitVector*> available_at_; |
353 }; | 360 }; |
354 | 361 |
355 | 362 |
356 } // namespace dart | 363 } // namespace dart |
357 | 364 |
358 #endif // VM_FLOW_GRAPH_H_ | 365 #endif // VM_FLOW_GRAPH_H_ |
OLD | NEW |