| 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/bit_vector.h" | 8 #include "vm/bit_vector.h" |
| 9 #include "vm/growable_array.h" | 9 #include "vm/growable_array.h" |
| 10 #include "vm/hash_map.h" | 10 #include "vm/hash_map.h" |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 | 77 |
| 78 static inline bool IsKeyEqual(Pair kv, Key key) { | 78 static inline bool IsKeyEqual(Pair kv, Key key) { |
| 79 return kv->value().raw() == key.raw(); | 79 return kv->value().raw() == key.raw(); |
| 80 } | 80 } |
| 81 }; | 81 }; |
| 82 | 82 |
| 83 | 83 |
| 84 // Class to encapsulate the construction and manipulation of the flow graph. | 84 // Class to encapsulate the construction and manipulation of the flow graph. |
| 85 class FlowGraph : public ZoneAllocated { | 85 class FlowGraph : public ZoneAllocated { |
| 86 public: | 86 public: |
| 87 FlowGraph(ParsedFunction* parsed_function, | 87 FlowGraph(const ParsedFunction& parsed_function, |
| 88 GraphEntryInstr* graph_entry, | 88 GraphEntryInstr* graph_entry, |
| 89 intptr_t max_block_id); | 89 intptr_t max_block_id); |
| 90 | 90 |
| 91 // Function properties. | 91 // Function properties. |
| 92 ParsedFunction* parsed_function() const { | 92 const ParsedFunction& parsed_function() const { |
| 93 return parsed_function_; | 93 return parsed_function_; |
| 94 } | 94 } |
| 95 const Function& function() const { | 95 const Function& function() const { |
| 96 return parsed_function_->function(); | 96 return parsed_function_.function(); |
| 97 } | 97 } |
| 98 intptr_t parameter_count() const { | 98 intptr_t parameter_count() const { |
| 99 return num_copied_params_ + num_non_copied_params_; | 99 return num_copied_params_ + num_non_copied_params_; |
| 100 } | 100 } |
| 101 intptr_t variable_count() const { | 101 intptr_t variable_count() const { |
| 102 return parameter_count() + parsed_function_->num_stack_locals(); | 102 return parameter_count() + parsed_function_.num_stack_locals(); |
| 103 } | 103 } |
| 104 intptr_t num_stack_locals() const { | 104 intptr_t num_stack_locals() const { |
| 105 return parsed_function_->num_stack_locals(); | 105 return parsed_function_.num_stack_locals(); |
| 106 } | 106 } |
| 107 intptr_t num_copied_params() const { | 107 intptr_t num_copied_params() const { |
| 108 return num_copied_params_; | 108 return num_copied_params_; |
| 109 } | 109 } |
| 110 intptr_t num_non_copied_params() const { | 110 intptr_t num_non_copied_params() const { |
| 111 return num_non_copied_params_; | 111 return num_non_copied_params_; |
| 112 } | 112 } |
| 113 bool IsIrregexpFunction() const { | 113 bool IsIrregexpFunction() const { |
| 114 return function().IsIrregexpFunction(); | 114 return function().IsIrregexpFunction(); |
| 115 } | 115 } |
| 116 | 116 |
| 117 LocalVariable* CurrentContextVar() const { | 117 LocalVariable* CurrentContextVar() const { |
| 118 return parsed_function()->current_context_var(); | 118 return parsed_function().current_context_var(); |
| 119 } | 119 } |
| 120 | 120 |
| 121 intptr_t CurrentContextEnvIndex() const { | 121 intptr_t CurrentContextEnvIndex() const { |
| 122 return parsed_function()->current_context_var()->BitIndexIn( | 122 return parsed_function().current_context_var()->BitIndexIn( |
| 123 num_non_copied_params_); | 123 num_non_copied_params_); |
| 124 } | 124 } |
| 125 | 125 |
| 126 // Flow graph orders. | 126 // Flow graph orders. |
| 127 const GrowableArray<BlockEntryInstr*>& preorder() const { | 127 const GrowableArray<BlockEntryInstr*>& preorder() const { |
| 128 return preorder_; | 128 return preorder_; |
| 129 } | 129 } |
| 130 const GrowableArray<BlockEntryInstr*>& postorder() const { | 130 const GrowableArray<BlockEntryInstr*>& postorder() const { |
| 131 return postorder_; | 131 return postorder_; |
| 132 } | 132 } |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 | 335 |
| 336 // DiscoverBlocks computes parent_ and assigned_vars_ which are then used | 336 // DiscoverBlocks computes parent_ and assigned_vars_ which are then used |
| 337 // if/when computing SSA. | 337 // if/when computing SSA. |
| 338 GrowableArray<intptr_t> parent_; | 338 GrowableArray<intptr_t> parent_; |
| 339 GrowableArray<BitVector*> assigned_vars_; | 339 GrowableArray<BitVector*> assigned_vars_; |
| 340 | 340 |
| 341 intptr_t current_ssa_temp_index_; | 341 intptr_t current_ssa_temp_index_; |
| 342 intptr_t max_block_id_; | 342 intptr_t max_block_id_; |
| 343 | 343 |
| 344 // Flow graph fields. | 344 // Flow graph fields. |
| 345 ParsedFunction* parsed_function_; | 345 const ParsedFunction& parsed_function_; |
| 346 const intptr_t num_copied_params_; | 346 const intptr_t num_copied_params_; |
| 347 const intptr_t num_non_copied_params_; | 347 const intptr_t num_non_copied_params_; |
| 348 GraphEntryInstr* graph_entry_; | 348 GraphEntryInstr* graph_entry_; |
| 349 GrowableArray<BlockEntryInstr*> preorder_; | 349 GrowableArray<BlockEntryInstr*> preorder_; |
| 350 GrowableArray<BlockEntryInstr*> postorder_; | 350 GrowableArray<BlockEntryInstr*> postorder_; |
| 351 GrowableArray<BlockEntryInstr*> reverse_postorder_; | 351 GrowableArray<BlockEntryInstr*> reverse_postorder_; |
| 352 GrowableArray<BlockEntryInstr*> optimized_block_order_; | 352 GrowableArray<BlockEntryInstr*> optimized_block_order_; |
| 353 ConstantInstr* constant_null_; | 353 ConstantInstr* constant_null_; |
| 354 ConstantInstr* constant_dead_; | 354 ConstantInstr* constant_dead_; |
| 355 ConstantInstr* constant_empty_context_; | 355 ConstantInstr* constant_empty_context_; |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 511 | 511 |
| 512 private: | 512 private: |
| 513 GrowableArray<Definition*> defs_; | 513 GrowableArray<Definition*> defs_; |
| 514 BitVector* contains_vector_; | 514 BitVector* contains_vector_; |
| 515 }; | 515 }; |
| 516 | 516 |
| 517 | 517 |
| 518 } // namespace dart | 518 } // namespace dart |
| 519 | 519 |
| 520 #endif // VM_FLOW_GRAPH_H_ | 520 #endif // VM_FLOW_GRAPH_H_ |
| OLD | NEW |