| 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 RUNTIME_VM_FLOW_GRAPH_BUILDER_H_ | 5 #ifndef RUNTIME_VM_FLOW_GRAPH_BUILDER_H_ |
| 6 #define RUNTIME_VM_FLOW_GRAPH_BUILDER_H_ | 6 #define RUNTIME_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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 }; | 91 }; |
| 92 | 92 |
| 93 | 93 |
| 94 // Build a flow graph from a parsed function's AST. | 94 // Build a flow graph from a parsed function's AST. |
| 95 class FlowGraphBuilder : public ValueObject { | 95 class FlowGraphBuilder : public ValueObject { |
| 96 public: | 96 public: |
| 97 // The inlining context is NULL if not inlining. The osr_id is the deopt | 97 // The inlining context is NULL if not inlining. The osr_id is the deopt |
| 98 // id of the OSR entry or Compiler::kNoOSRDeoptId if not compiling for OSR. | 98 // id of the OSR entry or Compiler::kNoOSRDeoptId if not compiling for OSR. |
| 99 FlowGraphBuilder(const ParsedFunction& parsed_function, | 99 FlowGraphBuilder(const ParsedFunction& parsed_function, |
| 100 const ZoneGrowableArray<const ICData*>& ic_data_array, | 100 const ZoneGrowableArray<const ICData*>& ic_data_array, |
| 101 ZoneGrowableArray<intptr_t>* context_level_array, |
| 101 InlineExitCollector* exit_collector, | 102 InlineExitCollector* exit_collector, |
| 102 intptr_t osr_id); | 103 intptr_t osr_id); |
| 103 | 104 |
| 104 FlowGraph* BuildGraph(); | 105 FlowGraph* BuildGraph(); |
| 105 | 106 |
| 106 const ParsedFunction& parsed_function() const { return parsed_function_; } | 107 const ParsedFunction& parsed_function() const { return parsed_function_; } |
| 107 const Function& function() const { return parsed_function_.function(); } | 108 const Function& function() const { return parsed_function_.function(); } |
| 108 const ZoneGrowableArray<const ICData*>& ic_data_array() const { | 109 const ZoneGrowableArray<const ICData*>& ic_data_array() const { |
| 109 return ic_data_array_; | 110 return ic_data_array_; |
| 110 } | 111 } |
| 111 | 112 |
| 112 void Bailout(const char* reason) const; | 113 void Bailout(const char* reason) const; |
| 113 | 114 |
| 114 intptr_t AllocateBlockId() { return ++last_used_block_id_; } | 115 intptr_t AllocateBlockId() { return ++last_used_block_id_; } |
| 115 void SetInitialBlockId(intptr_t id) { last_used_block_id_ = id; } | 116 void SetInitialBlockId(intptr_t id) { last_used_block_id_ = id; } |
| 116 | 117 |
| 117 intptr_t GetNextDeoptId() { | 118 intptr_t GetNextDeoptId() const; |
| 118 // TODO(rmacnak): Record current scope / context level. | |
| 119 return thread()->GetNextDeoptId(); | |
| 120 } | |
| 121 | 119 |
| 122 intptr_t context_level() const; | 120 intptr_t context_level() const; |
| 123 | 121 |
| 124 void IncrementLoopDepth() { ++loop_depth_; } | 122 void IncrementLoopDepth() { ++loop_depth_; } |
| 125 void DecrementLoopDepth() { --loop_depth_; } | 123 void DecrementLoopDepth() { --loop_depth_; } |
| 126 intptr_t loop_depth() const { return loop_depth_; } | 124 intptr_t loop_depth() const { return loop_depth_; } |
| 127 | 125 |
| 128 // Manage the currently active try index. | 126 // Manage the currently active try index. |
| 129 void set_try_index(intptr_t value) { try_index_ = value; } | 127 void set_try_index(intptr_t value) { try_index_ = value; } |
| 130 intptr_t try_index() const { return try_index_; } | 128 intptr_t try_index() const { return try_index_; } |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 | 189 |
| 192 intptr_t parameter_count() const { | 190 intptr_t parameter_count() const { |
| 193 return num_copied_params_ + num_non_copied_params_; | 191 return num_copied_params_ + num_non_copied_params_; |
| 194 } | 192 } |
| 195 intptr_t variable_count() const { | 193 intptr_t variable_count() const { |
| 196 return parameter_count() + num_stack_locals_; | 194 return parameter_count() + num_stack_locals_; |
| 197 } | 195 } |
| 198 | 196 |
| 199 const ParsedFunction& parsed_function_; | 197 const ParsedFunction& parsed_function_; |
| 200 const ZoneGrowableArray<const ICData*>& ic_data_array_; | 198 const ZoneGrowableArray<const ICData*>& ic_data_array_; |
| 199 // Contains (deopt_id, context_level) pairs. |
| 200 ZoneGrowableArray<intptr_t>* context_level_array_; |
| 201 | 201 |
| 202 const intptr_t num_copied_params_; | 202 const intptr_t num_copied_params_; |
| 203 const intptr_t num_non_copied_params_; | 203 const intptr_t num_non_copied_params_; |
| 204 const intptr_t num_stack_locals_; // Does not include any parameters. | 204 const intptr_t num_stack_locals_; // Does not include any parameters. |
| 205 InlineExitCollector* const exit_collector_; | 205 InlineExitCollector* const exit_collector_; |
| 206 | 206 |
| 207 intptr_t last_used_block_id_; | 207 intptr_t last_used_block_id_; |
| 208 intptr_t try_index_; | 208 intptr_t try_index_; |
| 209 intptr_t catch_try_index_; | 209 intptr_t catch_try_index_; |
| 210 intptr_t loop_depth_; | 210 intptr_t loop_depth_; |
| (...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 571 // Output parameters. | 571 // Output parameters. |
| 572 GrowableArray<TargetEntryInstr**> true_successor_addresses_; | 572 GrowableArray<TargetEntryInstr**> true_successor_addresses_; |
| 573 GrowableArray<TargetEntryInstr**> false_successor_addresses_; | 573 GrowableArray<TargetEntryInstr**> false_successor_addresses_; |
| 574 | 574 |
| 575 TokenPosition condition_token_pos_; | 575 TokenPosition condition_token_pos_; |
| 576 }; | 576 }; |
| 577 | 577 |
| 578 } // namespace dart | 578 } // namespace dart |
| 579 | 579 |
| 580 #endif // RUNTIME_VM_FLOW_GRAPH_BUILDER_H_ | 580 #endif // RUNTIME_VM_FLOW_GRAPH_BUILDER_H_ |
| OLD | NEW |