| 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 bailout_reason_(NULL), | 23 bailout_reason_(NULL), |
| 24 postorder_() { } | 24 postorder_block_entries_() { } |
| 25 | 25 |
| 26 void BuildGraph(); | 26 void BuildGraph(); |
| 27 | 27 |
| 28 const ParsedFunction& parsed_function() const { return parsed_function_; } | 28 const ParsedFunction& parsed_function() const { return parsed_function_; } |
| 29 | 29 |
| 30 bool HasBailedOut() const { return bailout_reason_ != NULL; } | 30 bool HasBailedOut() const { return bailout_reason_ != NULL; } |
| 31 void Bailout(const char* reason) { | 31 void Bailout(const char* reason) { |
| 32 // Cannot give a NULL reason because we use it to detect bailout. | 32 // Cannot give a NULL reason because we use it to detect bailout. |
| 33 ASSERT(!HasBailedOut() && (reason != NULL)); | 33 ASSERT(!HasBailedOut() && (reason != NULL)); |
| 34 bailout_reason_ = reason; | 34 bailout_reason_ = reason; |
| 35 } | 35 } |
| 36 void TraceBailout() const; | 36 void TraceBailout() const; |
| 37 void PrintGraph() const; | 37 void PrintGraph() const; |
| 38 | 38 |
| 39 private: | 39 private: |
| 40 const ParsedFunction& parsed_function_; | 40 const ParsedFunction& parsed_function_; |
| 41 const char* bailout_reason_; | 41 const char* bailout_reason_; |
| 42 GrowableArray<Instruction*> postorder_; | 42 GrowableArray<Instruction*> postorder_block_entries_; |
| 43 }; | 43 }; |
| 44 | 44 |
| 45 | 45 |
| 46 #define DEFINE_VISIT(type, name) virtual void Visit##type(type* node); | 46 #define DEFINE_VISIT(type, name) virtual void Visit##type(type* node); |
| 47 | 47 |
| 48 class TestGraphVisitor; | 48 class TestGraphVisitor; |
| 49 | 49 |
| 50 // Translate an AstNode to a control-flow graph fragment for its effects | 50 // Translate an AstNode to a control-flow graph fragment for its effects |
| 51 // (e.g., a statement or an expression in an effect context). Implements a | 51 // (e.g., a statement or an expression in an effect context). Implements a |
| 52 // function from an AstNode and next temporary index to a graph fragment | 52 // function from an AstNode and next temporary index to a graph fragment |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 TargetEntryInstr** true_successor_address_; | 213 TargetEntryInstr** true_successor_address_; |
| 214 TargetEntryInstr** false_successor_address_; | 214 TargetEntryInstr** false_successor_address_; |
| 215 }; | 215 }; |
| 216 | 216 |
| 217 #undef DEFINE_VISIT | 217 #undef DEFINE_VISIT |
| 218 | 218 |
| 219 | 219 |
| 220 } // namespace dart | 220 } // namespace dart |
| 221 | 221 |
| 222 #endif // VM_FLOW_GRAPH_BUILDER_H_ | 222 #endif // VM_FLOW_GRAPH_BUILDER_H_ |
| OLD | NEW |