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