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 | 14 |
15 class FlowGraphOptimizer : public FlowGraphVisitor { | 15 class FlowGraphOptimizer : public FlowGraphVisitor { |
16 public: | 16 public: |
17 explicit FlowGraphOptimizer(const FlowGraph& flow_graph) | 17 explicit FlowGraphOptimizer(FlowGraph* flow_graph) |
18 : FlowGraphVisitor(flow_graph.reverse_postorder()) {} | 18 : FlowGraphVisitor(flow_graph->reverse_postorder()), |
| 19 flow_graph_(flow_graph) { } |
19 virtual ~FlowGraphOptimizer() {} | 20 virtual ~FlowGraphOptimizer() {} |
20 | 21 |
21 void ApplyICData(); | 22 void ApplyICData(); |
22 | 23 |
23 void OptimizeComputations(); | 24 void OptimizeComputations(); |
24 | 25 |
25 virtual void VisitStaticCall(StaticCallComp* comp, BindInstr* instr); | 26 virtual void VisitStaticCall(StaticCallComp* comp, BindInstr* instr); |
26 virtual void VisitInstanceCall(InstanceCallComp* comp, BindInstr* instr); | 27 virtual void VisitInstanceCall(InstanceCallComp* comp, BindInstr* instr); |
27 virtual void VisitRelationalOp(RelationalOpComp* comp, BindInstr* instr); | 28 virtual void VisitRelationalOp(RelationalOpComp* comp, BindInstr* instr); |
28 virtual void VisitEqualityCompare(EqualityCompareComp* comp, | 29 virtual void VisitEqualityCompare(EqualityCompareComp* comp, |
(...skipping 11 matching lines...) Expand all Loading... |
40 bool TryReplaceWithUnaryOp(BindInstr* instr, | 41 bool TryReplaceWithUnaryOp(BindInstr* instr, |
41 InstanceCallComp* comp, | 42 InstanceCallComp* comp, |
42 Token::Kind op_kind); | 43 Token::Kind op_kind); |
43 | 44 |
44 bool TryInlineInstanceGetter(BindInstr* instr, | 45 bool TryInlineInstanceGetter(BindInstr* instr, |
45 InstanceCallComp* comp); | 46 InstanceCallComp* comp); |
46 bool TryInlineInstanceSetter(BindInstr* instr, InstanceCallComp* comp); | 47 bool TryInlineInstanceSetter(BindInstr* instr, InstanceCallComp* comp); |
47 | 48 |
48 bool TryInlineInstanceMethod(BindInstr* instr, InstanceCallComp* comp); | 49 bool TryInlineInstanceMethod(BindInstr* instr, InstanceCallComp* comp); |
49 | 50 |
| 51 Value* InsertBefore(Instruction* instr, Computation* comp, Environment* env); |
| 52 |
| 53 BindInstr* InsertAfter(Instruction* instr, Computation* comp); |
| 54 |
| 55 FlowGraph* flow_graph_; |
| 56 |
50 DISALLOW_COPY_AND_ASSIGN(FlowGraphOptimizer); | 57 DISALLOW_COPY_AND_ASSIGN(FlowGraphOptimizer); |
51 }; | 58 }; |
52 | 59 |
53 | 60 |
54 // Analyze the generated flow graph. Currently only if it is a leaf | 61 // Analyze the generated flow graph. Currently only if it is a leaf |
55 // method, i.e., does not contain any calls to runtime or other Dart code. | 62 // method, i.e., does not contain any calls to runtime or other Dart code. |
56 class FlowGraphAnalyzer : public ValueObject { | 63 class FlowGraphAnalyzer : public ValueObject { |
57 public: | 64 public: |
58 explicit FlowGraphAnalyzer(const FlowGraph& flow_graph) | 65 explicit FlowGraphAnalyzer(const FlowGraph& flow_graph) |
59 : blocks_(flow_graph.reverse_postorder()), is_leaf_(false) {} | 66 : blocks_(flow_graph.reverse_postorder()), is_leaf_(false) {} |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 private: | 122 private: |
116 const GrowableArray<BlockEntryInstr*>& blocks_; | 123 const GrowableArray<BlockEntryInstr*>& blocks_; |
117 | 124 |
118 DISALLOW_COPY_AND_ASSIGN(LocalCSE); | 125 DISALLOW_COPY_AND_ASSIGN(LocalCSE); |
119 }; | 126 }; |
120 | 127 |
121 | 128 |
122 } // namespace dart | 129 } // namespace dart |
123 | 130 |
124 #endif // VM_FLOW_GRAPH_OPTIMIZER_H_ | 131 #endif // VM_FLOW_GRAPH_OPTIMIZER_H_ |
OLD | NEW |