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_AOT_OPTIMIZER_H_ |
6 #define VM_FLOW_GRAPH_OPTIMIZER_H_ | 6 #define VM_AOT_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 class CSEInstructionMap; | 13 class CSEInstructionMap; |
14 template <typename T> class GrowableArray; | 14 template <typename T> class GrowableArray; |
15 class ParsedFunction; | 15 class ParsedFunction; |
| 16 class RawBool; |
16 | 17 |
17 class FlowGraphOptimizer : public FlowGraphVisitor { | 18 class AotOptimizer : public FlowGraphVisitor { |
18 public: | 19 public: |
19 FlowGraphOptimizer( | 20 AotOptimizer( |
20 FlowGraph* flow_graph, | 21 FlowGraph* flow_graph, |
21 bool use_speculative_inlining, | 22 bool use_speculative_inlining, |
22 GrowableArray<intptr_t>* inlining_black_list) | 23 GrowableArray<intptr_t>* inlining_black_list) |
23 : FlowGraphVisitor(flow_graph->reverse_postorder()), | 24 : FlowGraphVisitor(flow_graph->reverse_postorder()), |
24 flow_graph_(flow_graph), | 25 flow_graph_(flow_graph), |
25 use_speculative_inlining_(use_speculative_inlining), | 26 use_speculative_inlining_(use_speculative_inlining), |
26 inlining_black_list_(inlining_black_list) { | 27 inlining_black_list_(inlining_black_list) { |
27 ASSERT(!use_speculative_inlining || (inlining_black_list != NULL)); | 28 ASSERT(!use_speculative_inlining || (inlining_black_list != NULL)); |
28 } | 29 } |
29 virtual ~FlowGraphOptimizer() {} | 30 virtual ~AotOptimizer() {} |
30 | 31 |
31 FlowGraph* flow_graph() const { return flow_graph_; } | 32 FlowGraph* flow_graph() const { return flow_graph_; } |
32 | 33 |
33 // Add ICData to InstanceCalls, so that optimizations can be run on them. | 34 // Add ICData to InstanceCalls, so that optimizations can be run on them. |
34 // TODO(srdjan): StaticCals as well? | 35 // TODO(srdjan): StaticCals as well? |
35 void PopulateWithICData(); | 36 void PopulateWithICData(); |
36 | 37 |
37 // Use ICData to optimize, replace or eliminate instructions. | 38 // Use ICData to optimize, replace or eliminate instructions. |
38 void ApplyICData(); | 39 void ApplyICData(); |
39 | 40 |
40 // Use propagated class ids to optimize, replace or eliminate instructions. | 41 // Use propagated class ids to optimize, replace or eliminate instructions. |
41 void ApplyClassIds(); | 42 void ApplyClassIds(); |
42 | 43 |
43 // Optimize (a << b) & c pattern: if c is a positive Smi or zero, then the | 44 // Optimize (a << b) & c pattern: if c is a positive Smi or zero, then the |
44 // shift can be a truncating Smi shift-left and result is always Smi. | 45 // shift can be a truncating Smi shift-left and result is always Smi. |
45 // Merge instructions (only per basic-block). | 46 // Merge instructions (only per basic-block). |
46 void TryOptimizePatterns(); | 47 void TryOptimizePatterns(); |
47 | 48 |
48 virtual void VisitStaticCall(StaticCallInstr* instr); | 49 virtual void VisitStaticCall(StaticCallInstr* instr); |
49 virtual void VisitInstanceCall(InstanceCallInstr* instr); | 50 virtual void VisitInstanceCall(InstanceCallInstr* instr); |
50 virtual void VisitStoreInstanceField(StoreInstanceFieldInstr* instr); | |
51 virtual void VisitAllocateContext(AllocateContextInstr* instr); | 51 virtual void VisitAllocateContext(AllocateContextInstr* instr); |
52 virtual void VisitLoadCodeUnits(LoadCodeUnitsInstr* instr); | 52 virtual void VisitLoadCodeUnits(LoadCodeUnitsInstr* instr); |
53 | 53 |
54 void InsertBefore(Instruction* next, | 54 void InsertBefore(Instruction* next, |
55 Instruction* instr, | 55 Instruction* instr, |
56 Environment* env, | 56 Environment* env, |
57 FlowGraph::UseKind use_kind) { | 57 FlowGraph::UseKind use_kind) { |
58 flow_graph_->InsertBefore(next, instr, env, use_kind); | 58 flow_graph_->InsertBefore(next, instr, env, use_kind); |
59 } | 59 } |
60 | 60 |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 const Function& function() const { return flow_graph_->function(); } | 172 const Function& function() const { return flow_graph_->function(); } |
173 | 173 |
174 bool IsBlackListedForInlining(intptr_t deopt_id); | 174 bool IsBlackListedForInlining(intptr_t deopt_id); |
175 | 175 |
176 FlowGraph* flow_graph_; | 176 FlowGraph* flow_graph_; |
177 | 177 |
178 const bool use_speculative_inlining_; | 178 const bool use_speculative_inlining_; |
179 | 179 |
180 GrowableArray<intptr_t>* inlining_black_list_; | 180 GrowableArray<intptr_t>* inlining_black_list_; |
181 | 181 |
182 DISALLOW_COPY_AND_ASSIGN(FlowGraphOptimizer); | 182 DISALLOW_COPY_AND_ASSIGN(AotOptimizer); |
183 }; | 183 }; |
184 | 184 |
185 | 185 |
186 } // namespace dart | 186 } // namespace dart |
187 | 187 |
188 #endif // VM_FLOW_GRAPH_OPTIMIZER_H_ | 188 #endif // VM_AOT_OPTIMIZER_H_ |
OLD | NEW |