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(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 flow_graph_(flow_graph) { } |
21 virtual ~FlowGraphOptimizer() {} | 21 virtual ~FlowGraphOptimizer() {} |
22 | 22 |
23 void ApplyICData(); | 23 void ApplyICData(); |
24 | 24 |
25 void OptimizeComputations(); | 25 void OptimizeComputations(); |
26 | 26 |
| 27 void EliminateDeadPhis(); |
| 28 |
| 29 void SelectRepresentations(); |
| 30 |
27 virtual void VisitStaticCall(StaticCallComp* comp, BindInstr* instr); | 31 virtual void VisitStaticCall(StaticCallComp* comp, BindInstr* instr); |
28 virtual void VisitInstanceCall(InstanceCallComp* comp, BindInstr* instr); | 32 virtual void VisitInstanceCall(InstanceCallComp* comp, BindInstr* instr); |
29 virtual void VisitRelationalOp(RelationalOpComp* comp, BindInstr* instr); | 33 virtual void VisitRelationalOp(RelationalOpComp* comp, BindInstr* instr); |
30 virtual void VisitEqualityCompare(EqualityCompareComp* comp, | 34 virtual void VisitEqualityCompare(EqualityCompareComp* comp, |
31 BindInstr* instr); | 35 BindInstr* instr); |
32 virtual void VisitBind(BindInstr* instr); | 36 virtual void VisitBind(BindInstr* instr); |
33 virtual void VisitBranch(BranchInstr* instr); | 37 virtual void VisitBranch(BranchInstr* instr); |
34 | 38 |
35 private: | 39 private: |
36 bool TryReplaceWithArrayOp(BindInstr* instr, | 40 bool TryReplaceWithArrayOp(BindInstr* instr, |
(...skipping 17 matching lines...) Expand all Loading... |
54 BindInstr* InsertBefore(Instruction* instr, | 58 BindInstr* InsertBefore(Instruction* instr, |
55 Computation* comp, | 59 Computation* comp, |
56 Environment* env, | 60 Environment* env, |
57 BindInstr::UseKind use_kind); | 61 BindInstr::UseKind use_kind); |
58 | 62 |
59 BindInstr* InsertAfter(Instruction* instr, | 63 BindInstr* InsertAfter(Instruction* instr, |
60 Computation* comp, | 64 Computation* comp, |
61 Environment* env, | 65 Environment* env, |
62 BindInstr::UseKind use_kind); | 66 BindInstr::UseKind use_kind); |
63 | 67 |
| 68 void InsertConversionsFor(Definition* def); |
| 69 |
64 FlowGraph* flow_graph_; | 70 FlowGraph* flow_graph_; |
65 | 71 |
66 DISALLOW_COPY_AND_ASSIGN(FlowGraphOptimizer); | 72 DISALLOW_COPY_AND_ASSIGN(FlowGraphOptimizer); |
67 }; | 73 }; |
68 | 74 |
69 | 75 |
70 // Analyze the generated flow graph. Currently only if it is a leaf | 76 // Analyze the generated flow graph. Currently only if it is a leaf |
71 // method, i.e., does not contain any calls to runtime or other Dart code. | 77 // method, i.e., does not contain any calls to runtime or other Dart code. |
72 class FlowGraphAnalyzer : public ValueObject { | 78 class FlowGraphAnalyzer : public ValueObject { |
73 public: | 79 public: |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 private: | 136 private: |
131 static void OptimizeRecursive( | 137 static void OptimizeRecursive( |
132 BlockEntryInstr* entry, | 138 BlockEntryInstr* entry, |
133 DirectChainedHashMap<BindInstr*>* map); | 139 DirectChainedHashMap<BindInstr*>* map); |
134 }; | 140 }; |
135 | 141 |
136 | 142 |
137 } // namespace dart | 143 } // namespace dart |
138 | 144 |
139 #endif // VM_FLOW_GRAPH_OPTIMIZER_H_ | 145 #endif // VM_FLOW_GRAPH_OPTIMIZER_H_ |
OLD | NEW |