| 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_BUILDER_H_ | 5 #ifndef VM_FLOW_GRAPH_BUILDER_H_ |
| 6 #define VM_FLOW_GRAPH_BUILDER_H_ | 6 #define VM_FLOW_GRAPH_BUILDER_H_ |
| 7 | 7 |
| 8 #include "vm/allocation.h" | 8 #include "vm/allocation.h" |
| 9 #include "vm/ast.h" | 9 #include "vm/ast.h" |
| 10 #include "vm/growable_array.h" | 10 #include "vm/growable_array.h" |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 Definition* JoinReturns(BlockEntryInstr** exit_block, | 91 Definition* JoinReturns(BlockEntryInstr** exit_block, |
| 92 Instruction** last_instruction); | 92 Instruction** last_instruction); |
| 93 | 93 |
| 94 FlowGraph* caller_graph_; | 94 FlowGraph* caller_graph_; |
| 95 Definition* call_; | 95 Definition* call_; |
| 96 GrowableArray<Data> exits_; | 96 GrowableArray<Data> exits_; |
| 97 }; | 97 }; |
| 98 | 98 |
| 99 | 99 |
| 100 // Build a flow graph from a parsed function's AST. | 100 // Build a flow graph from a parsed function's AST. |
| 101 class FlowGraphBuilder: public ZoneAllocated { | 101 class FlowGraphBuilder: public ValueObject { |
| 102 public: | 102 public: |
| 103 // The inlining context is NULL if not inlining. The osr_id is the deopt | 103 // The inlining context is NULL if not inlining. The osr_id is the deopt |
| 104 // id of the OSR entry or Isolate::kNoDeoptId if not compiling for OSR. | 104 // id of the OSR entry or Isolate::kNoDeoptId if not compiling for OSR. |
| 105 FlowGraphBuilder(ParsedFunction* parsed_function, | 105 FlowGraphBuilder(ParsedFunction* parsed_function, |
| 106 const Array& ic_data_array, | 106 const Array& ic_data_array, |
| 107 InlineExitCollector* exit_collector, | 107 InlineExitCollector* exit_collector, |
| 108 GrowableArray<const Field*>* guarded_fields, | |
| 109 intptr_t osr_id); | 108 intptr_t osr_id); |
| 110 | 109 |
| 111 FlowGraph* BuildGraph(); | 110 FlowGraph* BuildGraph(); |
| 112 | 111 |
| 113 ParsedFunction* parsed_function() const { return parsed_function_; } | 112 ParsedFunction* parsed_function() const { return parsed_function_; } |
| 114 const Array& ic_data_array() const { return ic_data_array_; } | 113 const Array& ic_data_array() const { return ic_data_array_; } |
| 115 | 114 |
| 116 void Bailout(const char* reason); | 115 void Bailout(const char* reason); |
| 117 | 116 |
| 118 intptr_t AllocateBlockId() { return ++last_used_block_id_; } | 117 intptr_t AllocateBlockId() { return ++last_used_block_id_; } |
| (...skipping 22 matching lines...) Expand all Loading... |
| 141 intptr_t num_non_copied_params() const { | 140 intptr_t num_non_copied_params() const { |
| 142 return num_non_copied_params_; | 141 return num_non_copied_params_; |
| 143 } | 142 } |
| 144 intptr_t num_stack_locals() const { | 143 intptr_t num_stack_locals() const { |
| 145 return num_stack_locals_; | 144 return num_stack_locals_; |
| 146 } | 145 } |
| 147 | 146 |
| 148 bool IsInlining() const { return (exit_collector_ != NULL); } | 147 bool IsInlining() const { return (exit_collector_ != NULL); } |
| 149 InlineExitCollector* exit_collector() const { return exit_collector_; } | 148 InlineExitCollector* exit_collector() const { return exit_collector_; } |
| 150 | 149 |
| 151 GrowableArray<const Field*>* guarded_fields() const { | 150 ZoneGrowableArray<const Field*>* guarded_fields() const { |
| 152 return guarded_fields_; | 151 return guarded_fields_; |
| 153 } | 152 } |
| 154 | 153 |
| 155 void AddToGuardedFields(const Field& field) const; | |
| 156 | |
| 157 intptr_t args_pushed() const { return args_pushed_; } | 154 intptr_t args_pushed() const { return args_pushed_; } |
| 158 void add_args_pushed(intptr_t n) { args_pushed_ += n; } | 155 void add_args_pushed(intptr_t n) { args_pushed_ += n; } |
| 159 | 156 |
| 160 // When compiling for OSR, remove blocks that are not reachable from the | 157 // When compiling for OSR, remove blocks that are not reachable from the |
| 161 // OSR entry point. | 158 // OSR entry point. |
| 162 void PruneUnreachable(); | 159 void PruneUnreachable(); |
| 163 | 160 |
| 164 private: | 161 private: |
| 165 intptr_t parameter_count() const { | 162 intptr_t parameter_count() const { |
| 166 return num_copied_params_ + num_non_copied_params_; | 163 return num_copied_params_ + num_non_copied_params_; |
| 167 } | 164 } |
| 168 intptr_t variable_count() const { | 165 intptr_t variable_count() const { |
| 169 return parameter_count() + num_stack_locals_; | 166 return parameter_count() + num_stack_locals_; |
| 170 } | 167 } |
| 171 | 168 |
| 172 ParsedFunction* parsed_function_; | 169 ParsedFunction* parsed_function_; |
| 173 const Array& ic_data_array_; | 170 const Array& ic_data_array_; |
| 174 | 171 |
| 175 const intptr_t num_copied_params_; | 172 const intptr_t num_copied_params_; |
| 176 const intptr_t num_non_copied_params_; | 173 const intptr_t num_non_copied_params_; |
| 177 const intptr_t num_stack_locals_; // Does not include any parameters. | 174 const intptr_t num_stack_locals_; // Does not include any parameters. |
| 178 InlineExitCollector* const exit_collector_; | 175 InlineExitCollector* const exit_collector_; |
| 179 GrowableArray<const Field*>* guarded_fields_; | 176 ZoneGrowableArray<const Field*>* guarded_fields_; |
| 180 | 177 |
| 181 intptr_t last_used_block_id_; | 178 intptr_t last_used_block_id_; |
| 182 intptr_t context_level_; | 179 intptr_t context_level_; |
| 183 intptr_t try_index_; | 180 intptr_t try_index_; |
| 184 intptr_t catch_try_index_; | 181 intptr_t catch_try_index_; |
| 185 intptr_t loop_depth_; | 182 intptr_t loop_depth_; |
| 186 GraphEntryInstr* graph_entry_; | 183 GraphEntryInstr* graph_entry_; |
| 187 | 184 |
| 188 // Outgoing argument stack height. | 185 // Outgoing argument stack height. |
| 189 intptr_t args_pushed_; | 186 intptr_t args_pushed_; |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 530 // Output parameters. | 527 // Output parameters. |
| 531 GrowableArray<TargetEntryInstr**> true_successor_addresses_; | 528 GrowableArray<TargetEntryInstr**> true_successor_addresses_; |
| 532 GrowableArray<TargetEntryInstr**> false_successor_addresses_; | 529 GrowableArray<TargetEntryInstr**> false_successor_addresses_; |
| 533 | 530 |
| 534 intptr_t condition_token_pos_; | 531 intptr_t condition_token_pos_; |
| 535 }; | 532 }; |
| 536 | 533 |
| 537 } // namespace dart | 534 } // namespace dart |
| 538 | 535 |
| 539 #endif // VM_FLOW_GRAPH_BUILDER_H_ | 536 #endif // VM_FLOW_GRAPH_BUILDER_H_ |
| OLD | NEW |