| 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 "platform/assert.h" | 8 #include "platform/assert.h" |
| 9 #include "platform/globals.h" | 9 #include "platform/globals.h" |
| 10 #include "vm/allocation.h" | 10 #include "vm/allocation.h" |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 | 136 |
| 137 | 137 |
| 138 // Build a flow graph from a parsed function's AST. | 138 // Build a flow graph from a parsed function's AST. |
| 139 class FlowGraphBuilder: public ValueObject { | 139 class FlowGraphBuilder: public ValueObject { |
| 140 public: | 140 public: |
| 141 // The inlining context is NULL if not inlining. The osr_id is the deopt | 141 // The inlining context is NULL if not inlining. The osr_id is the deopt |
| 142 // id of the OSR entry or Isolate::kNoDeoptId if not compiling for OSR. | 142 // id of the OSR entry or Isolate::kNoDeoptId if not compiling for OSR. |
| 143 FlowGraphBuilder(ParsedFunction* parsed_function, | 143 FlowGraphBuilder(ParsedFunction* parsed_function, |
| 144 const Array& ic_data_array, | 144 const Array& ic_data_array, |
| 145 InlineExitCollector* exit_collector, | 145 InlineExitCollector* exit_collector, |
| 146 intptr_t osr_id); | 146 intptr_t osr_id, |
| 147 bool is_optimizing); |
| 147 | 148 |
| 148 FlowGraph* BuildGraph(); | 149 FlowGraph* BuildGraph(); |
| 149 | 150 |
| 150 ParsedFunction* parsed_function() const { return parsed_function_; } | 151 ParsedFunction* parsed_function() const { return parsed_function_; } |
| 151 const Array& ic_data_array() const { return ic_data_array_; } | 152 const Array& ic_data_array() const { return ic_data_array_; } |
| 152 | 153 |
| 153 void Bailout(const char* reason); | 154 void Bailout(const char* reason) const; |
| 154 | 155 |
| 155 intptr_t AllocateBlockId() { return ++last_used_block_id_; } | 156 intptr_t AllocateBlockId() { return ++last_used_block_id_; } |
| 156 void SetInitialBlockId(intptr_t id) { last_used_block_id_ = id; } | 157 void SetInitialBlockId(intptr_t id) { last_used_block_id_ = id; } |
| 157 | 158 |
| 158 intptr_t context_level() const; | 159 intptr_t context_level() const; |
| 159 | 160 |
| 160 void IncrementLoopDepth() { ++loop_depth_; } | 161 void IncrementLoopDepth() { ++loop_depth_; } |
| 161 void DecrementLoopDepth() { --loop_depth_; } | 162 void DecrementLoopDepth() { --loop_depth_; } |
| 162 intptr_t loop_depth() const { return loop_depth_; } | 163 intptr_t loop_depth() const { return loop_depth_; } |
| 163 | 164 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 177 intptr_t num_non_copied_params() const { | 178 intptr_t num_non_copied_params() const { |
| 178 return num_non_copied_params_; | 179 return num_non_copied_params_; |
| 179 } | 180 } |
| 180 intptr_t num_stack_locals() const { | 181 intptr_t num_stack_locals() const { |
| 181 return num_stack_locals_; | 182 return num_stack_locals_; |
| 182 } | 183 } |
| 183 | 184 |
| 184 bool IsInlining() const { return (exit_collector_ != NULL); } | 185 bool IsInlining() const { return (exit_collector_ != NULL); } |
| 185 InlineExitCollector* exit_collector() const { return exit_collector_; } | 186 InlineExitCollector* exit_collector() const { return exit_collector_; } |
| 186 | 187 |
| 188 bool is_optimizing() const { return is_optimizing_; } |
| 189 |
| 187 ZoneGrowableArray<const Field*>* guarded_fields() const { | 190 ZoneGrowableArray<const Field*>* guarded_fields() const { |
| 188 return guarded_fields_; | 191 return guarded_fields_; |
| 189 } | 192 } |
| 190 | 193 |
| 191 intptr_t temp_count() const { return temp_count_; } | 194 intptr_t temp_count() const { return temp_count_; } |
| 192 intptr_t AllocateTemp() { return temp_count_++; } | 195 intptr_t AllocateTemp() { return temp_count_++; } |
| 193 void DeallocateTemps(intptr_t count) { | 196 void DeallocateTemps(intptr_t count) { |
| 194 ASSERT(temp_count_ >= count); | 197 ASSERT(temp_count_ >= count); |
| 195 temp_count_ -= count; | 198 temp_count_ -= count; |
| 196 } | 199 } |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 // Outgoing argument stack height. | 238 // Outgoing argument stack height. |
| 236 intptr_t args_pushed_; | 239 intptr_t args_pushed_; |
| 237 | 240 |
| 238 // A stack of enclosing nested statements. | 241 // A stack of enclosing nested statements. |
| 239 NestedStatement* nesting_stack_; | 242 NestedStatement* nesting_stack_; |
| 240 | 243 |
| 241 // The deopt id of the OSR entry or Isolate::kNoDeoptId if not compiling | 244 // The deopt id of the OSR entry or Isolate::kNoDeoptId if not compiling |
| 242 // for OSR. | 245 // for OSR. |
| 243 const intptr_t osr_id_; | 246 const intptr_t osr_id_; |
| 244 | 247 |
| 248 // The graph is being rebuilt for the optimizing compiler. |
| 249 // Do not generate a different graph based on this flag. |
| 250 const bool is_optimizing_; |
| 251 |
| 245 DISALLOW_IMPLICIT_CONSTRUCTORS(FlowGraphBuilder); | 252 DISALLOW_IMPLICIT_CONSTRUCTORS(FlowGraphBuilder); |
| 246 }; | 253 }; |
| 247 | 254 |
| 248 | 255 |
| 249 // Translate an AstNode to a control-flow graph fragment for its effects | 256 // Translate an AstNode to a control-flow graph fragment for its effects |
| 250 // (e.g., a statement or an expression in an effect context). Implements a | 257 // (e.g., a statement or an expression in an effect context). Implements a |
| 251 // function from an AstNode and next temporary index to a graph fragment | 258 // function from an AstNode and next temporary index to a graph fragment |
| 252 // with a single entry and at most one exit. The fragment is represented by | 259 // with a single entry and at most one exit. The fragment is represented by |
| 253 // an (entry, exit) pair of Instruction pointers: | 260 // an (entry, exit) pair of Instruction pointers: |
| 254 // | 261 // |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 557 // Output parameters. | 564 // Output parameters. |
| 558 GrowableArray<TargetEntryInstr**> true_successor_addresses_; | 565 GrowableArray<TargetEntryInstr**> true_successor_addresses_; |
| 559 GrowableArray<TargetEntryInstr**> false_successor_addresses_; | 566 GrowableArray<TargetEntryInstr**> false_successor_addresses_; |
| 560 | 567 |
| 561 intptr_t condition_token_pos_; | 568 intptr_t condition_token_pos_; |
| 562 }; | 569 }; |
| 563 | 570 |
| 564 } // namespace dart | 571 } // namespace dart |
| 565 | 572 |
| 566 #endif // VM_FLOW_GRAPH_BUILDER_H_ | 573 #endif // VM_FLOW_GRAPH_BUILDER_H_ |
| OLD | NEW |