| 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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 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 { | |
| 152 return guarded_fields_; | |
| 153 } | |
| 154 | |
| 155 void AddToGuardedFields(const Field& field) const; | |
| 156 | |
| 157 intptr_t args_pushed() const { return args_pushed_; } | 150 intptr_t args_pushed() const { return args_pushed_; } |
| 158 void add_args_pushed(intptr_t n) { args_pushed_ += n; } | 151 void add_args_pushed(intptr_t n) { args_pushed_ += n; } |
| 159 | 152 |
| 160 // When compiling for OSR, remove blocks that are not reachable from the | 153 // When compiling for OSR, remove blocks that are not reachable from the |
| 161 // OSR entry point. | 154 // OSR entry point. |
| 162 void PruneUnreachable(); | 155 void PruneUnreachable(); |
| 163 | 156 |
| 164 private: | 157 private: |
| 165 intptr_t parameter_count() const { | 158 intptr_t parameter_count() const { |
| 166 return num_copied_params_ + num_non_copied_params_; | 159 return num_copied_params_ + num_non_copied_params_; |
| 167 } | 160 } |
| 168 intptr_t variable_count() const { | 161 intptr_t variable_count() const { |
| 169 return parameter_count() + num_stack_locals_; | 162 return parameter_count() + num_stack_locals_; |
| 170 } | 163 } |
| 171 | 164 |
| 172 ParsedFunction* parsed_function_; | 165 ParsedFunction* parsed_function_; |
| 173 const Array& ic_data_array_; | 166 const Array& ic_data_array_; |
| 174 | 167 |
| 175 const intptr_t num_copied_params_; | 168 const intptr_t num_copied_params_; |
| 176 const intptr_t num_non_copied_params_; | 169 const intptr_t num_non_copied_params_; |
| 177 const intptr_t num_stack_locals_; // Does not include any parameters. | 170 const intptr_t num_stack_locals_; // Does not include any parameters. |
| 178 InlineExitCollector* const exit_collector_; | 171 InlineExitCollector* const exit_collector_; |
| 179 GrowableArray<const Field*>* guarded_fields_; | |
| 180 | 172 |
| 181 intptr_t last_used_block_id_; | 173 intptr_t last_used_block_id_; |
| 182 intptr_t context_level_; | 174 intptr_t context_level_; |
| 183 intptr_t try_index_; | 175 intptr_t try_index_; |
| 184 intptr_t catch_try_index_; | 176 intptr_t catch_try_index_; |
| 185 intptr_t loop_depth_; | 177 intptr_t loop_depth_; |
| 186 GraphEntryInstr* graph_entry_; | 178 GraphEntryInstr* graph_entry_; |
| 187 | 179 |
| 188 // Outgoing argument stack height. | 180 // Outgoing argument stack height. |
| 189 intptr_t args_pushed_; | 181 intptr_t args_pushed_; |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 530 // Output parameters. | 522 // Output parameters. |
| 531 GrowableArray<TargetEntryInstr**> true_successor_addresses_; | 523 GrowableArray<TargetEntryInstr**> true_successor_addresses_; |
| 532 GrowableArray<TargetEntryInstr**> false_successor_addresses_; | 524 GrowableArray<TargetEntryInstr**> false_successor_addresses_; |
| 533 | 525 |
| 534 intptr_t condition_token_pos_; | 526 intptr_t condition_token_pos_; |
| 535 }; | 527 }; |
| 536 | 528 |
| 537 } // namespace dart | 529 } // namespace dart |
| 538 | 530 |
| 539 #endif // VM_FLOW_GRAPH_BUILDER_H_ | 531 #endif // VM_FLOW_GRAPH_BUILDER_H_ |
| OLD | NEW |