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 |
(...skipping 10 matching lines...) Expand all Loading... |
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(); | 27 void EliminateDeadPhis(); |
28 | 28 |
29 void SelectRepresentations(); | 29 void SelectRepresentations(); |
30 | 30 |
31 virtual void VisitStaticCall(StaticCallInstr* instr); | 31 virtual void VisitStaticCall(StaticCallComp* comp, BindInstr* instr); |
32 virtual void VisitInstanceCall(InstanceCallInstr* instr); | 32 virtual void VisitInstanceCall(InstanceCallComp* comp, BindInstr* instr); |
33 virtual void VisitRelationalOp(RelationalOpInstr* instr); | 33 virtual void VisitRelationalOp(RelationalOpComp* comp, BindInstr* instr); |
34 virtual void VisitEqualityCompare(EqualityCompareInstr* instr); | 34 virtual void VisitEqualityCompare(EqualityCompareComp* comp, |
| 35 BindInstr* instr); |
| 36 virtual void VisitBind(BindInstr* instr); |
35 virtual void VisitBranch(BranchInstr* instr); | 37 virtual void VisitBranch(BranchInstr* instr); |
36 | 38 |
37 // TODO(fschneider): Once we get rid of the distinction between Instruction | 39 // TODO(fschneider): Once we get rid of the distinction between Instruction |
38 // and computation, this can be made private again. | 40 // and computation, this can be made private again. |
39 void InsertBefore(Instruction* instr, | 41 BindInstr* InsertBefore(Instruction* instr, |
40 Definition* defn, | 42 Computation* comp, |
41 Environment* env, | 43 Environment* env, |
42 Definition::UseKind use_kind); | 44 BindInstr::UseKind use_kind); |
43 | 45 |
44 private: | 46 private: |
45 bool TryReplaceWithArrayOp(InstanceCallInstr* call, Token::Kind op_kind); | 47 bool TryReplaceWithArrayOp(BindInstr* instr, |
46 bool TryReplaceWithBinaryOp(InstanceCallInstr* call, Token::Kind op_kind); | 48 InstanceCallComp* comp, |
47 bool TryReplaceWithUnaryOp(InstanceCallInstr* call, Token::Kind op_kind); | 49 Token::Kind op_kind); |
| 50 bool TryReplaceWithBinaryOp(BindInstr* instr, |
| 51 InstanceCallComp* comp, |
| 52 Token::Kind op_kind); |
| 53 bool TryReplaceWithUnaryOp(BindInstr* instr, |
| 54 InstanceCallComp* comp, |
| 55 Token::Kind op_kind); |
48 | 56 |
49 bool TryInlineInstanceGetter(InstanceCallInstr* call); | 57 bool TryInlineInstanceGetter(BindInstr* instr, |
50 bool TryInlineInstanceSetter(InstanceCallInstr* call); | 58 InstanceCallComp* comp); |
| 59 bool TryInlineInstanceSetter(BindInstr* instr, InstanceCallComp* comp); |
51 | 60 |
52 bool TryInlineInstanceMethod(InstanceCallInstr* call); | 61 bool TryInlineInstanceMethod(BindInstr* instr, InstanceCallComp* comp); |
53 | 62 |
54 void AddCheckClass(InstanceCallInstr* call, Value* value); | 63 void AddCheckClass(BindInstr* instr, InstanceCallComp* comp, Value* value); |
55 | 64 |
56 void InsertAfter(Instruction* instr, | 65 BindInstr* InsertAfter(Instruction* instr, |
57 Definition* defn, | 66 Computation* comp, |
58 Environment* env, | 67 Environment* env, |
59 Definition::UseKind use_kind); | 68 BindInstr::UseKind use_kind); |
60 | 69 |
61 void InsertConversionsFor(Definition* def); | 70 void InsertConversionsFor(Definition* def); |
62 | 71 |
63 FlowGraph* flow_graph_; | 72 FlowGraph* flow_graph_; |
64 | 73 |
65 DISALLOW_COPY_AND_ASSIGN(FlowGraphOptimizer); | 74 DISALLOW_COPY_AND_ASSIGN(FlowGraphOptimizer); |
66 }; | 75 }; |
67 | 76 |
68 | 77 |
69 // Analyze the generated flow graph. Currently only if it is a leaf | 78 // Analyze the generated flow graph. Currently only if it is a leaf |
(...skipping 24 matching lines...) Expand all Loading... |
94 explicit FlowGraphTypePropagator(const FlowGraph& flow_graph) | 103 explicit FlowGraphTypePropagator(const FlowGraph& flow_graph) |
95 : FlowGraphVisitor(flow_graph.reverse_postorder()), | 104 : FlowGraphVisitor(flow_graph.reverse_postorder()), |
96 parsed_function_(flow_graph.parsed_function()), | 105 parsed_function_(flow_graph.parsed_function()), |
97 still_changing_(false) { } | 106 still_changing_(false) { } |
98 virtual ~FlowGraphTypePropagator() { } | 107 virtual ~FlowGraphTypePropagator() { } |
99 | 108 |
100 const ParsedFunction& parsed_function() const { return parsed_function_; } | 109 const ParsedFunction& parsed_function() const { return parsed_function_; } |
101 | 110 |
102 void PropagateTypes(); | 111 void PropagateTypes(); |
103 | 112 |
104 private: | 113 virtual void VisitAssertAssignable(AssertAssignableComp* comp, |
105 virtual void VisitBlocks(); | 114 BindInstr* instr); |
106 | 115 virtual void VisitAssertBoolean(AssertBooleanComp* comp, BindInstr* instr); |
107 virtual void VisitAssertAssignable(AssertAssignableInstr* instr); | 116 virtual void VisitInstanceOf(InstanceOfComp* comp, BindInstr* instr); |
108 virtual void VisitAssertBoolean(AssertBooleanInstr* instr); | |
109 virtual void VisitInstanceOf(InstanceOfInstr* instr); | |
110 | 117 |
111 virtual void VisitGraphEntry(GraphEntryInstr* graph_entry); | 118 virtual void VisitGraphEntry(GraphEntryInstr* graph_entry); |
112 virtual void VisitJoinEntry(JoinEntryInstr* join_entry); | 119 virtual void VisitJoinEntry(JoinEntryInstr* join_entry); |
| 120 virtual void VisitBind(BindInstr* bind); |
113 virtual void VisitPhi(PhiInstr* phi); | 121 virtual void VisitPhi(PhiInstr* phi); |
114 virtual void VisitParameter(ParameterInstr* param); | 122 virtual void VisitParameter(ParameterInstr* param); |
115 virtual void VisitPushArgument(PushArgumentInstr* bind); | 123 virtual void VisitPushArgument(PushArgumentInstr* bind); |
116 | 124 |
| 125 private: |
117 const ParsedFunction& parsed_function_; | 126 const ParsedFunction& parsed_function_; |
118 bool still_changing_; | 127 bool still_changing_; |
119 DISALLOW_COPY_AND_ASSIGN(FlowGraphTypePropagator); | 128 DISALLOW_COPY_AND_ASSIGN(FlowGraphTypePropagator); |
120 }; | 129 }; |
121 | 130 |
122 | 131 |
123 // A simple common subexpression elimination based | 132 // A simple common subexpression elimination based |
124 // on the dominator tree. | 133 // on the dominator tree. |
125 class DominatorBasedCSE : public AllStatic { | 134 class DominatorBasedCSE : public AllStatic { |
126 public: | 135 public: |
127 static void Optimize(BlockEntryInstr* graph_entry); | 136 static void Optimize(BlockEntryInstr* graph_entry); |
128 | 137 |
129 private: | 138 private: |
130 static void OptimizeRecursive( | 139 static void OptimizeRecursive( |
131 BlockEntryInstr* entry, | 140 BlockEntryInstr* entry, |
132 DirectChainedHashMap<Definition*>* map); | 141 DirectChainedHashMap<BindInstr*>* map); |
133 }; | 142 }; |
134 | 143 |
135 | 144 |
136 } // namespace dart | 145 } // namespace dart |
137 | 146 |
138 #endif // VM_FLOW_GRAPH_OPTIMIZER_H_ | 147 #endif // VM_FLOW_GRAPH_OPTIMIZER_H_ |
OLD | NEW |