| 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 ValueObject { | 101 class FlowGraphBuilder: public ZoneAllocated { |
| 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, |
| 108 intptr_t osr_id); | 109 intptr_t osr_id); |
| 109 | 110 |
| 110 FlowGraph* BuildGraph(); | 111 FlowGraph* BuildGraph(); |
| 111 | 112 |
| 112 ParsedFunction* parsed_function() const { return parsed_function_; } | 113 ParsedFunction* parsed_function() const { return parsed_function_; } |
| 113 const Array& ic_data_array() const { return ic_data_array_; } | 114 const Array& ic_data_array() const { return ic_data_array_; } |
| 114 | 115 |
| 115 void Bailout(const char* reason); | 116 void Bailout(const char* reason); |
| 116 | 117 |
| 117 intptr_t AllocateBlockId() { return ++last_used_block_id_; } | 118 intptr_t AllocateBlockId() { return ++last_used_block_id_; } |
| (...skipping 22 matching lines...) Expand all Loading... |
| 140 intptr_t num_non_copied_params() const { | 141 intptr_t num_non_copied_params() const { |
| 141 return num_non_copied_params_; | 142 return num_non_copied_params_; |
| 142 } | 143 } |
| 143 intptr_t num_stack_locals() const { | 144 intptr_t num_stack_locals() const { |
| 144 return num_stack_locals_; | 145 return num_stack_locals_; |
| 145 } | 146 } |
| 146 | 147 |
| 147 bool IsInlining() const { return (exit_collector_ != NULL); } | 148 bool IsInlining() const { return (exit_collector_ != NULL); } |
| 148 InlineExitCollector* exit_collector() const { return exit_collector_; } | 149 InlineExitCollector* exit_collector() const { return exit_collector_; } |
| 149 | 150 |
| 151 GrowableArray<const Field*>* guarded_fields() const { |
| 152 return guarded_fields_; |
| 153 } |
| 154 |
| 155 void AddToGuardedFields(const Field& field) const; |
| 156 |
| 150 intptr_t args_pushed() const { return args_pushed_; } | 157 intptr_t args_pushed() const { return args_pushed_; } |
| 151 void add_args_pushed(intptr_t n) { args_pushed_ += n; } | 158 void add_args_pushed(intptr_t n) { args_pushed_ += n; } |
| 152 | 159 |
| 153 // When compiling for OSR, remove blocks that are not reachable from the | 160 // When compiling for OSR, remove blocks that are not reachable from the |
| 154 // OSR entry point. | 161 // OSR entry point. |
| 155 void PruneUnreachable(); | 162 void PruneUnreachable(); |
| 156 | 163 |
| 157 private: | 164 private: |
| 158 intptr_t parameter_count() const { | 165 intptr_t parameter_count() const { |
| 159 return num_copied_params_ + num_non_copied_params_; | 166 return num_copied_params_ + num_non_copied_params_; |
| 160 } | 167 } |
| 161 intptr_t variable_count() const { | 168 intptr_t variable_count() const { |
| 162 return parameter_count() + num_stack_locals_; | 169 return parameter_count() + num_stack_locals_; |
| 163 } | 170 } |
| 164 | 171 |
| 165 ParsedFunction* parsed_function_; | 172 ParsedFunction* parsed_function_; |
| 166 const Array& ic_data_array_; | 173 const Array& ic_data_array_; |
| 167 | 174 |
| 168 const intptr_t num_copied_params_; | 175 const intptr_t num_copied_params_; |
| 169 const intptr_t num_non_copied_params_; | 176 const intptr_t num_non_copied_params_; |
| 170 const intptr_t num_stack_locals_; // Does not include any parameters. | 177 const intptr_t num_stack_locals_; // Does not include any parameters. |
| 171 InlineExitCollector* const exit_collector_; | 178 InlineExitCollector* const exit_collector_; |
| 179 GrowableArray<const Field*>* guarded_fields_; |
| 172 | 180 |
| 173 intptr_t last_used_block_id_; | 181 intptr_t last_used_block_id_; |
| 174 intptr_t context_level_; | 182 intptr_t context_level_; |
| 175 intptr_t try_index_; | 183 intptr_t try_index_; |
| 176 intptr_t catch_try_index_; | 184 intptr_t catch_try_index_; |
| 177 intptr_t loop_depth_; | 185 intptr_t loop_depth_; |
| 178 GraphEntryInstr* graph_entry_; | 186 GraphEntryInstr* graph_entry_; |
| 179 | 187 |
| 180 // Outgoing argument stack height. | 188 // Outgoing argument stack height. |
| 181 intptr_t args_pushed_; | 189 intptr_t args_pushed_; |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 522 // Output parameters. | 530 // Output parameters. |
| 523 GrowableArray<TargetEntryInstr**> true_successor_addresses_; | 531 GrowableArray<TargetEntryInstr**> true_successor_addresses_; |
| 524 GrowableArray<TargetEntryInstr**> false_successor_addresses_; | 532 GrowableArray<TargetEntryInstr**> false_successor_addresses_; |
| 525 | 533 |
| 526 intptr_t condition_token_pos_; | 534 intptr_t condition_token_pos_; |
| 527 }; | 535 }; |
| 528 | 536 |
| 529 } // namespace dart | 537 } // namespace dart |
| 530 | 538 |
| 531 #endif // VM_FLOW_GRAPH_BUILDER_H_ | 539 #endif // VM_FLOW_GRAPH_BUILDER_H_ |
| OLD | NEW |