| 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 postorder_block_entries_() { } | 24 postorder_block_entries_() { } |
| 24 | 25 |
| 25 void BuildGraph(); | 26 void BuildGraph(); |
| 26 | 27 |
| 27 const ParsedFunction& parsed_function() const { return parsed_function_; } | 28 const ParsedFunction& parsed_function() const { return parsed_function_; } |
| 28 | 29 |
| 29 const GrowableArray<BlockEntryInstr*>* blocks() const { | 30 const GrowableArray<BlockEntryInstr*>& postorder_block_entries() const { |
| 30 return &postorder_block_entries_; | 31 return postorder_block_entries_; |
| 31 } | 32 } |
| 32 | 33 |
| 33 void Bailout(const char* reason); | 34 void Bailout(const char* reason); |
| 34 | 35 |
| 35 void set_context_level(intptr_t value) { context_level_ = value; } | 36 void set_context_level(intptr_t value) { context_level_ = value; } |
| 36 intptr_t context_level() const { return context_level_; } | 37 intptr_t context_level() const { return context_level_; } |
| 37 | 38 |
| 38 private: | 39 private: |
| 39 const ParsedFunction& parsed_function_; | 40 const ParsedFunction& parsed_function_; |
| 41 GrowableArray<BlockEntryInstr*> preorder_block_entries_; |
| 40 GrowableArray<BlockEntryInstr*> postorder_block_entries_; | 42 GrowableArray<BlockEntryInstr*> postorder_block_entries_; |
| 41 intptr_t context_level_; | 43 intptr_t context_level_; |
| 42 }; | 44 }; |
| 43 | 45 |
| 44 | 46 |
| 45 class TestGraphVisitor; | 47 class TestGraphVisitor; |
| 46 | 48 |
| 47 // Translate an AstNode to a control-flow graph fragment for its effects | 49 // Translate an AstNode to a control-flow graph fragment for its effects |
| 48 // (e.g., a statement or an expression in an effect context). Implements a | 50 // (e.g., a statement or an expression in an effect context). Implements a |
| 49 // function from an AstNode and next temporary index to a graph fragment | 51 // function from an AstNode and next temporary index to a graph fragment |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 } | 264 } |
| 263 | 265 |
| 264 // Output parameters. | 266 // Output parameters. |
| 265 BlockEntryInstr** true_successor_address_; | 267 BlockEntryInstr** true_successor_address_; |
| 266 BlockEntryInstr** false_successor_address_; | 268 BlockEntryInstr** false_successor_address_; |
| 267 }; | 269 }; |
| 268 | 270 |
| 269 } // namespace dart | 271 } // namespace dart |
| 270 | 272 |
| 271 #endif // VM_FLOW_GRAPH_BUILDER_H_ | 273 #endif // VM_FLOW_GRAPH_BUILDER_H_ |
| OLD | NEW |