| 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_OPTIMIZER_H_ | 5 #ifndef VM_FLOW_GRAPH_OPTIMIZER_H_ |
| 6 #define VM_FLOW_GRAPH_OPTIMIZER_H_ | 6 #define VM_FLOW_GRAPH_OPTIMIZER_H_ |
| 7 | 7 |
| 8 #include "vm/intermediate_language.h" | 8 #include "vm/intermediate_language.h" |
| 9 #include "vm/flow_graph.h" | 9 #include "vm/flow_graph.h" |
| 10 | 10 |
| 11 namespace dart { | 11 namespace dart { |
| 12 | 12 |
| 13 template <typename T> class GrowableArray; | 13 template <typename T> class GrowableArray; |
| 14 template <typename T> class DirectChainedHashMap; | 14 template <typename T> class DirectChainedHashMap; |
| 15 | 15 |
| 16 class FlowGraphOptimizer : public FlowGraphVisitor { | 16 class FlowGraphOptimizer : public FlowGraphVisitor { |
| 17 public: | 17 public: |
| 18 explicit FlowGraphOptimizer(const FlowGraph& flow_graph) | 18 explicit FlowGraphOptimizer(FlowGraph* flow_graph) |
| 19 : FlowGraphVisitor(flow_graph.reverse_postorder()) {} | 19 : FlowGraphVisitor(flow_graph->reverse_postorder()), |
| 20 flow_graph_(flow_graph) { } |
| 20 virtual ~FlowGraphOptimizer() {} | 21 virtual ~FlowGraphOptimizer() {} |
| 21 | 22 |
| 22 void ApplyICData(); | 23 void ApplyICData(); |
| 23 | 24 |
| 24 void OptimizeComputations(); | 25 void OptimizeComputations(); |
| 25 | 26 |
| 26 virtual void VisitStaticCall(StaticCallComp* comp, BindInstr* instr); | 27 virtual void VisitStaticCall(StaticCallComp* comp, BindInstr* instr); |
| 27 virtual void VisitInstanceCall(InstanceCallComp* comp, BindInstr* instr); | 28 virtual void VisitInstanceCall(InstanceCallComp* comp, BindInstr* instr); |
| 28 virtual void VisitRelationalOp(RelationalOpComp* comp, BindInstr* instr); | 29 virtual void VisitRelationalOp(RelationalOpComp* comp, BindInstr* instr); |
| 29 virtual void VisitEqualityCompare(EqualityCompareComp* comp, | 30 virtual void VisitEqualityCompare(EqualityCompareComp* comp, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 41 bool TryReplaceWithUnaryOp(BindInstr* instr, | 42 bool TryReplaceWithUnaryOp(BindInstr* instr, |
| 42 InstanceCallComp* comp, | 43 InstanceCallComp* comp, |
| 43 Token::Kind op_kind); | 44 Token::Kind op_kind); |
| 44 | 45 |
| 45 bool TryInlineInstanceGetter(BindInstr* instr, | 46 bool TryInlineInstanceGetter(BindInstr* instr, |
| 46 InstanceCallComp* comp); | 47 InstanceCallComp* comp); |
| 47 bool TryInlineInstanceSetter(BindInstr* instr, InstanceCallComp* comp); | 48 bool TryInlineInstanceSetter(BindInstr* instr, InstanceCallComp* comp); |
| 48 | 49 |
| 49 bool TryInlineInstanceMethod(BindInstr* instr, InstanceCallComp* comp); | 50 bool TryInlineInstanceMethod(BindInstr* instr, InstanceCallComp* comp); |
| 50 | 51 |
| 52 void AddCheckClass(BindInstr* instr, InstanceCallComp* comp, Value* value); |
| 53 |
| 54 BindInstr* InsertBefore(Instruction* instr, |
| 55 Computation* comp, |
| 56 Environment* env, |
| 57 BindInstr::UseKind use_kind); |
| 58 |
| 59 BindInstr* InsertAfter(Instruction* instr, |
| 60 Computation* comp, |
| 61 Environment* env, |
| 62 BindInstr::UseKind use_kind); |
| 63 |
| 64 FlowGraph* flow_graph_; |
| 65 |
| 51 DISALLOW_COPY_AND_ASSIGN(FlowGraphOptimizer); | 66 DISALLOW_COPY_AND_ASSIGN(FlowGraphOptimizer); |
| 52 }; | 67 }; |
| 53 | 68 |
| 54 | 69 |
| 55 // Analyze the generated flow graph. Currently only if it is a leaf | 70 // Analyze the generated flow graph. Currently only if it is a leaf |
| 56 // method, i.e., does not contain any calls to runtime or other Dart code. | 71 // method, i.e., does not contain any calls to runtime or other Dart code. |
| 57 class FlowGraphAnalyzer : public ValueObject { | 72 class FlowGraphAnalyzer : public ValueObject { |
| 58 public: | 73 public: |
| 59 explicit FlowGraphAnalyzer(const FlowGraph& flow_graph) | 74 explicit FlowGraphAnalyzer(const FlowGraph& flow_graph) |
| 60 : blocks_(flow_graph.reverse_postorder()), is_leaf_(false) {} | 75 : blocks_(flow_graph.reverse_postorder()), is_leaf_(false) {} |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 private: | 130 private: |
| 116 static void OptimizeRecursive( | 131 static void OptimizeRecursive( |
| 117 BlockEntryInstr* entry, | 132 BlockEntryInstr* entry, |
| 118 DirectChainedHashMap<BindInstr*>* map); | 133 DirectChainedHashMap<BindInstr*>* map); |
| 119 }; | 134 }; |
| 120 | 135 |
| 121 | 136 |
| 122 } // namespace dart | 137 } // namespace dart |
| 123 | 138 |
| 124 #endif // VM_FLOW_GRAPH_OPTIMIZER_H_ | 139 #endif // VM_FLOW_GRAPH_OPTIMIZER_H_ |
| OLD | NEW |