| 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 postorder_block_entries_() { } | 23 postorder_block_entries_() { } |
| 24 | 24 |
| 25 void BuildGraph(); | 25 void BuildGraph(); |
| 26 | 26 |
| 27 const GrowableArray<BlockEntryInstr*>* blocks() const { |
| 28 return &postorder_block_entries_; |
| 29 } |
| 30 |
| 27 const ParsedFunction& parsed_function() const { return parsed_function_; } | 31 const ParsedFunction& parsed_function() const { return parsed_function_; } |
| 28 | 32 |
| 29 void Bailout(const char* reason); | 33 void Bailout(const char* reason); |
| 30 | 34 |
| 31 private: | 35 private: |
| 32 const ParsedFunction& parsed_function_; | 36 const ParsedFunction& parsed_function_; |
| 33 GrowableArray<BlockEntryInstr*> postorder_block_entries_; | 37 GrowableArray<BlockEntryInstr*> postorder_block_entries_; |
| 34 }; | 38 }; |
| 35 | 39 |
| 36 | 40 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 const EffectGraphVisitor& body_fragment); | 89 const EffectGraphVisitor& body_fragment); |
| 86 | 90 |
| 87 protected: | 91 protected: |
| 88 // Implement the core part of the translation of expression node types. | 92 // Implement the core part of the translation of expression node types. |
| 89 AssertAssignableComp* TranslateAssignable(const AssignableNode& node); | 93 AssertAssignableComp* TranslateAssignable(const AssignableNode& node); |
| 90 InstanceCallComp* TranslateBinaryOp(const BinaryOpNode& node); | 94 InstanceCallComp* TranslateBinaryOp(const BinaryOpNode& node); |
| 91 InstanceCallComp* TranslateUnaryOp(const UnaryOpNode& node); | 95 InstanceCallComp* TranslateUnaryOp(const UnaryOpNode& node); |
| 92 InstanceCallComp* TranslateComparison(const ComparisonNode& node); | 96 InstanceCallComp* TranslateComparison(const ComparisonNode& node); |
| 93 StoreLocalComp* TranslateStoreLocal(const StoreLocalNode& node); | 97 StoreLocalComp* TranslateStoreLocal(const StoreLocalNode& node); |
| 94 StaticCallComp* TranslateStaticCall(const StaticCallNode& node); | 98 StaticCallComp* TranslateStaticCall(const StaticCallNode& node); |
| 99 void TranslateArgumentList(const ArgumentListNode& node, |
| 100 ZoneGrowableArray<Value*>* values); |
| 95 | 101 |
| 96 void CloseFragment() { exit_ = NULL; } | 102 void CloseFragment() { exit_ = NULL; } |
| 97 intptr_t AllocateTempIndex() { return temp_index_++; } | 103 intptr_t AllocateTempIndex() { return temp_index_++; } |
| 98 | 104 |
| 99 private: | 105 private: |
| 100 // Helper to append a Do instruction to the graph. | 106 // Helper to append a Do instruction to the graph. |
| 101 void DoComputation(Computation* computation) { | 107 void DoComputation(Computation* computation) { |
| 102 AddInstruction(new DoInstr(computation)); | 108 AddInstruction(new DoInstr(computation)); |
| 103 } | 109 } |
| 104 | 110 |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 TargetEntryInstr** true_successor_address_; | 211 TargetEntryInstr** true_successor_address_; |
| 206 TargetEntryInstr** false_successor_address_; | 212 TargetEntryInstr** false_successor_address_; |
| 207 }; | 213 }; |
| 208 | 214 |
| 209 #undef DEFINE_VISIT | 215 #undef DEFINE_VISIT |
| 210 | 216 |
| 211 | 217 |
| 212 } // namespace dart | 218 } // namespace dart |
| 213 | 219 |
| 214 #endif // VM_FLOW_GRAPH_BUILDER_H_ | 220 #endif // VM_FLOW_GRAPH_BUILDER_H_ |
| OLD | NEW |