| 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" |
| 11 #include "vm/intermediate_language.h" | 11 #include "vm/intermediate_language.h" |
| 12 | 12 |
| 13 namespace dart { | 13 namespace dart { |
| 14 | 14 |
| 15 class Instruction; | 15 class Instruction; |
| 16 class ParsedFunction; | 16 class ParsedFunction; |
| 17 | 17 |
| 18 // Build a flow graph from a parsed function's AST. | 18 // Build a flow graph from a parsed function's AST. |
| 19 class FlowGraphBuilder: public ValueObject { | 19 class FlowGraphBuilder: public ValueObject { |
| 20 public: | 20 public: |
| 21 explicit FlowGraphBuilder(const ParsedFunction& parsed_function) | 21 explicit FlowGraphBuilder(const ParsedFunction& parsed_function) |
| 22 : parsed_function_(parsed_function), | 22 : parsed_function_(parsed_function), |
| 23 preorder_block_entries_(), | 23 preorder_block_entries_(), |
| 24 postorder_block_entries_() { } | 24 postorder_block_entries_(), |
| 25 context_level_(0) { } |
| 25 | 26 |
| 26 void BuildGraph(); | 27 void BuildGraph(); |
| 27 | 28 |
| 28 const ParsedFunction& parsed_function() const { return parsed_function_; } | 29 const ParsedFunction& parsed_function() const { return parsed_function_; } |
| 29 | 30 |
| 30 const GrowableArray<BlockEntryInstr*>& postorder_block_entries() const { | 31 const GrowableArray<BlockEntryInstr*>& postorder_block_entries() const { |
| 31 return postorder_block_entries_; | 32 return postorder_block_entries_; |
| 32 } | 33 } |
| 33 | 34 |
| 34 void Bailout(const char* reason); | 35 void Bailout(const char* reason); |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 // preparation of a constructor call. | 139 // preparation of a constructor call. |
| 139 // May be called only if allocating an object of a parameterized class. | 140 // May be called only if allocating an object of a parameterized class. |
| 140 void BuildConstructorTypeArguments(ConstructorCallNode* node, | 141 void BuildConstructorTypeArguments(ConstructorCallNode* node, |
| 141 intptr_t start_index, | 142 intptr_t start_index, |
| 142 ZoneGrowableArray<Value*>* args); | 143 ZoneGrowableArray<Value*>* args); |
| 143 | 144 |
| 144 // Returns the value of the type arguments of the instantiator. | 145 // Returns the value of the type arguments of the instantiator. |
| 145 Value* BuildInstantiatorTypeArguments(intptr_t token_index, | 146 Value* BuildInstantiatorTypeArguments(intptr_t token_index, |
| 146 intptr_t start_index); | 147 intptr_t start_index); |
| 147 | 148 |
| 149 bool MustSaveRestoreContext(SequenceNode* node) const; |
| 150 |
| 151 // Moves parent context into the context register. |
| 152 void UnchainContext(); |
| 153 |
| 148 void CloseFragment() { exit_ = NULL; } | 154 void CloseFragment() { exit_ = NULL; } |
| 149 intptr_t AllocateTempIndex() { return temp_index_++; } | 155 intptr_t AllocateTempIndex() { return temp_index_++; } |
| 150 | 156 |
| 151 private: | 157 private: |
| 152 // Specify a computation as the final result. Adds a Do instruction to | 158 // Specify a computation as the final result. Adds a Do instruction to |
| 153 // the graph, but normally overridden in subclasses. | 159 // the graph, but normally overridden in subclasses. |
| 154 virtual void ReturnComputation(Computation* computation) { | 160 virtual void ReturnComputation(Computation* computation) { |
| 155 AddInstruction(new DoInstr(computation)); | 161 AddInstruction(new DoInstr(computation)); |
| 156 } | 162 } |
| 157 | 163 |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 } | 277 } |
| 272 | 278 |
| 273 // Output parameters. | 279 // Output parameters. |
| 274 TargetEntryInstr** true_successor_address_; | 280 TargetEntryInstr** true_successor_address_; |
| 275 TargetEntryInstr** false_successor_address_; | 281 TargetEntryInstr** false_successor_address_; |
| 276 }; | 282 }; |
| 277 | 283 |
| 278 } // namespace dart | 284 } // namespace dart |
| 279 | 285 |
| 280 #endif // VM_FLOW_GRAPH_BUILDER_H_ | 286 #endif // VM_FLOW_GRAPH_BUILDER_H_ |
| OLD | NEW |