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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 intptr_t token_pos, | 50 intptr_t token_pos, |
51 const ICData& ic_data, | 51 const ICData& ic_data, |
52 TargetEntryInstr** entry, | 52 TargetEntryInstr** entry, |
53 Definition** last); | 53 Definition** last); |
54 | 54 |
55 // Remove environments from the instructions which do not deoptimize. | 55 // Remove environments from the instructions which do not deoptimize. |
56 void EliminateEnvironments(); | 56 void EliminateEnvironments(); |
57 | 57 |
58 virtual void VisitStaticCall(StaticCallInstr* instr); | 58 virtual void VisitStaticCall(StaticCallInstr* instr); |
59 virtual void VisitInstanceCall(InstanceCallInstr* instr); | 59 virtual void VisitInstanceCall(InstanceCallInstr* instr); |
60 virtual void VisitEqualityCompare(EqualityCompareInstr* instr); | |
61 virtual void VisitBranch(BranchInstr* instr); | |
62 | 60 |
63 void InsertBefore(Instruction* next, | 61 void InsertBefore(Instruction* next, |
64 Instruction* instr, | 62 Instruction* instr, |
65 Environment* env, | 63 Environment* env, |
66 Definition::UseKind use_kind) { | 64 Definition::UseKind use_kind) { |
67 flow_graph_->InsertBefore(next, instr, env, use_kind); | 65 flow_graph_->InsertBefore(next, instr, env, use_kind); |
68 } | 66 } |
69 | 67 |
70 private: | 68 private: |
71 // Attempt to build ICData for call using propagated class-ids. | 69 // Attempt to build ICData for call using propagated class-ids. |
(...skipping 19 matching lines...) Expand all Loading... |
91 intptr_t PrepareInlineIndexedOp(Instruction* call, | 89 intptr_t PrepareInlineIndexedOp(Instruction* call, |
92 intptr_t array_cid, | 90 intptr_t array_cid, |
93 Definition** array, | 91 Definition** array, |
94 Definition* index, | 92 Definition* index, |
95 Instruction** cursor); | 93 Instruction** cursor); |
96 | 94 |
97 | 95 |
98 bool TryReplaceWithBinaryOp(InstanceCallInstr* call, Token::Kind op_kind); | 96 bool TryReplaceWithBinaryOp(InstanceCallInstr* call, Token::Kind op_kind); |
99 bool TryReplaceWithUnaryOp(InstanceCallInstr* call, Token::Kind op_kind); | 97 bool TryReplaceWithUnaryOp(InstanceCallInstr* call, Token::Kind op_kind); |
100 | 98 |
| 99 bool TryReplaceWithEqualityOp(InstanceCallInstr* call, Token::Kind op_kind); |
101 bool TryReplaceWithRelationalOp(InstanceCallInstr* call, Token::Kind op_kind); | 100 bool TryReplaceWithRelationalOp(InstanceCallInstr* call, Token::Kind op_kind); |
102 | 101 |
103 bool TryInlineInstanceGetter(InstanceCallInstr* call); | 102 bool TryInlineInstanceGetter(InstanceCallInstr* call); |
104 bool TryInlineInstanceSetter(InstanceCallInstr* call, | 103 bool TryInlineInstanceSetter(InstanceCallInstr* call, |
105 const ICData& unary_ic_data); | 104 const ICData& unary_ic_data); |
106 | 105 |
107 bool TryInlineInstanceMethod(InstanceCallInstr* call); | 106 bool TryInlineInstanceMethod(InstanceCallInstr* call); |
108 bool TryInlineFloat32x4Constructor(StaticCallInstr* call, | 107 bool TryInlineFloat32x4Constructor(StaticCallInstr* call, |
109 MethodRecognizer::Kind recognized_kind); | 108 MethodRecognizer::Kind recognized_kind); |
110 bool TryInlineUint32x4Constructor(StaticCallInstr* call, | 109 bool TryInlineUint32x4Constructor(StaticCallInstr* call, |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 bool InlineUint32x4BinaryOp(InstanceCallInstr* call, | 189 bool InlineUint32x4BinaryOp(InstanceCallInstr* call, |
191 Token::Kind op_kind); | 190 Token::Kind op_kind); |
192 void InlineImplicitInstanceGetter(InstanceCallInstr* call); | 191 void InlineImplicitInstanceGetter(InstanceCallInstr* call); |
193 | 192 |
194 RawBool* InstanceOfAsBool(const ICData& ic_data, | 193 RawBool* InstanceOfAsBool(const ICData& ic_data, |
195 const AbstractType& type) const; | 194 const AbstractType& type) const; |
196 | 195 |
197 void ReplaceWithMathCFunction(InstanceCallInstr* call, | 196 void ReplaceWithMathCFunction(InstanceCallInstr* call, |
198 MethodRecognizer::Kind recognized_kind); | 197 MethodRecognizer::Kind recognized_kind); |
199 | 198 |
200 // Visit an equality compare. The current instruction can be the | |
201 // comparison itself or a branch on the comparison. | |
202 template <typename T> | |
203 void HandleEqualityCompare(EqualityCompareInstr* comp, | |
204 T current_instruction); | |
205 | |
206 static bool CanStrictifyEqualityCompare(EqualityCompareInstr* call); | |
207 | |
208 template <typename T> | |
209 bool StrictifyEqualityCompare(EqualityCompareInstr* compare, | |
210 T current_instruction) const; | |
211 | |
212 template <typename T> | |
213 bool StrictifyEqualityCompareWithICData(EqualityCompareInstr* compare, | |
214 const ICData& unary_ic_data, | |
215 T current_instruction); | |
216 | |
217 void OptimizeLeftShiftBitAndSmiOp(Definition* bit_and_instr, | 199 void OptimizeLeftShiftBitAndSmiOp(Definition* bit_and_instr, |
218 Definition* left_instr, | 200 Definition* left_instr, |
219 Definition* right_instr); | 201 Definition* right_instr); |
220 | 202 |
221 FlowGraph* flow_graph_; | 203 FlowGraph* flow_graph_; |
222 | 204 |
223 DISALLOW_COPY_AND_ASSIGN(FlowGraphOptimizer); | 205 DISALLOW_COPY_AND_ASSIGN(FlowGraphOptimizer); |
224 }; | 206 }; |
225 | 207 |
226 | 208 |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 // Optimize spill stores inside try-blocks by identifying values that always | 377 // Optimize spill stores inside try-blocks by identifying values that always |
396 // contain a single known constant at catch block entry. | 378 // contain a single known constant at catch block entry. |
397 class TryCatchAnalyzer : public AllStatic { | 379 class TryCatchAnalyzer : public AllStatic { |
398 public: | 380 public: |
399 static void Optimize(FlowGraph* flow_graph); | 381 static void Optimize(FlowGraph* flow_graph); |
400 }; | 382 }; |
401 | 383 |
402 } // namespace dart | 384 } // namespace dart |
403 | 385 |
404 #endif // VM_FLOW_GRAPH_OPTIMIZER_H_ | 386 #endif // VM_FLOW_GRAPH_OPTIMIZER_H_ |
OLD | NEW |