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_AOT_OPTIMIZER_H_ | 5 #ifndef VM_AOT_OPTIMIZER_H_ |
6 #define VM_AOT_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 Precompiler; | |
17 class RawBool; | 16 class RawBool; |
18 | 17 |
19 class AotOptimizer : public FlowGraphVisitor { | 18 class AotOptimizer : public FlowGraphVisitor { |
20 public: | 19 public: |
21 AotOptimizer(Precompiler* precompiler, | 20 AotOptimizer(FlowGraph* flow_graph, |
22 FlowGraph* flow_graph, | |
23 bool use_speculative_inlining, | 21 bool use_speculative_inlining, |
24 GrowableArray<intptr_t>* inlining_black_list); | 22 GrowableArray<intptr_t>* inlining_black_list); |
25 | |
26 virtual ~AotOptimizer() {} | 23 virtual ~AotOptimizer() {} |
27 | 24 |
28 FlowGraph* flow_graph() const { return flow_graph_; } | 25 FlowGraph* flow_graph() const { return flow_graph_; } |
29 | 26 |
30 // Add ICData to InstanceCalls, so that optimizations can be run on them. | 27 // Add ICData to InstanceCalls, so that optimizations can be run on them. |
31 // TODO(srdjan): StaticCals as well? | 28 // TODO(srdjan): StaticCals as well? |
32 void PopulateWithICData(); | 29 void PopulateWithICData(); |
33 | 30 |
34 // Use ICData to optimize, replace or eliminate instructions. | 31 // Use ICData to optimize, replace or eliminate instructions. |
35 void ApplyICData(); | 32 void ApplyICData(); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 Environment* deopt_environment, | 94 Environment* deopt_environment, |
98 Instruction* insert_before); | 95 Instruction* insert_before); |
99 | 96 |
100 // Add a class check for a call's first argument immediately before the | 97 // Add a class check for a call's first argument immediately before the |
101 // call, using the call's IC data to determine the check, and the call's | 98 // call, using the call's IC data to determine the check, and the call's |
102 // deopt ID and deoptimization environment if the check fails. | 99 // deopt ID and deoptimization environment if the check fails. |
103 void AddReceiverCheck(InstanceCallInstr* call); | 100 void AddReceiverCheck(InstanceCallInstr* call); |
104 | 101 |
105 void ReplaceCall(Definition* call, Definition* replacement); | 102 void ReplaceCall(Definition* call, Definition* replacement); |
106 | 103 |
107 bool RecognizeRuntimeTypeGetter(InstanceCallInstr* call); | |
108 bool TryReplaceWithHaveSameRuntimeType(InstanceCallInstr* call); | |
109 | |
110 bool InstanceCallNeedsClassCheck(InstanceCallInstr* call, | 104 bool InstanceCallNeedsClassCheck(InstanceCallInstr* call, |
111 RawFunction::Kind kind) const; | 105 RawFunction::Kind kind) const; |
112 | 106 |
113 bool InlineFloat32x4BinaryOp(InstanceCallInstr* call, | 107 bool InlineFloat32x4BinaryOp(InstanceCallInstr* call, |
114 Token::Kind op_kind); | 108 Token::Kind op_kind); |
115 bool InlineInt32x4BinaryOp(InstanceCallInstr* call, | 109 bool InlineInt32x4BinaryOp(InstanceCallInstr* call, |
116 Token::Kind op_kind); | 110 Token::Kind op_kind); |
117 bool InlineFloat64x2BinaryOp(InstanceCallInstr* call, | 111 bool InlineFloat64x2BinaryOp(InstanceCallInstr* call, |
118 Token::Kind op_kind); | 112 Token::Kind op_kind); |
119 bool InlineImplicitInstanceGetter(InstanceCallInstr* call); | 113 bool InlineImplicitInstanceGetter(InstanceCallInstr* call); |
(...skipping 10 matching lines...) Expand all Loading... |
130 RawField* GetField(intptr_t class_id, const String& field_name); | 124 RawField* GetField(intptr_t class_id, const String& field_name); |
131 | 125 |
132 Thread* thread() const { return flow_graph_->thread(); } | 126 Thread* thread() const { return flow_graph_->thread(); } |
133 Isolate* isolate() const { return flow_graph_->isolate(); } | 127 Isolate* isolate() const { return flow_graph_->isolate(); } |
134 Zone* zone() const { return flow_graph_->zone(); } | 128 Zone* zone() const { return flow_graph_->zone(); } |
135 | 129 |
136 const Function& function() const { return flow_graph_->function(); } | 130 const Function& function() const { return flow_graph_->function(); } |
137 | 131 |
138 bool IsAllowedForInlining(intptr_t deopt_id); | 132 bool IsAllowedForInlining(intptr_t deopt_id); |
139 | 133 |
140 Precompiler* precompiler_; | |
141 FlowGraph* flow_graph_; | 134 FlowGraph* flow_graph_; |
142 | 135 |
143 const bool use_speculative_inlining_; | 136 const bool use_speculative_inlining_; |
144 | 137 |
145 GrowableArray<intptr_t>* inlining_black_list_; | 138 GrowableArray<intptr_t>* inlining_black_list_; |
146 | 139 |
147 bool has_unique_no_such_method_; | 140 bool has_unique_no_such_method_; |
148 | 141 |
149 DISALLOW_COPY_AND_ASSIGN(AotOptimizer); | 142 DISALLOW_COPY_AND_ASSIGN(AotOptimizer); |
150 }; | 143 }; |
151 | 144 |
152 | 145 |
153 } // namespace dart | 146 } // namespace dart |
154 | 147 |
155 #endif // VM_AOT_OPTIMIZER_H_ | 148 #endif // VM_AOT_OPTIMIZER_H_ |
OLD | NEW |