| 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 29 matching lines...) Expand all Loading... |
| 40 virtual void VisitStaticCall(StaticCallInstr* instr); | 40 virtual void VisitStaticCall(StaticCallInstr* instr); |
| 41 virtual void VisitInstanceCall(InstanceCallInstr* instr); | 41 virtual void VisitInstanceCall(InstanceCallInstr* instr); |
| 42 virtual void VisitRelationalOp(RelationalOpInstr* instr); | 42 virtual void VisitRelationalOp(RelationalOpInstr* instr); |
| 43 virtual void VisitEqualityCompare(EqualityCompareInstr* instr); | 43 virtual void VisitEqualityCompare(EqualityCompareInstr* instr); |
| 44 virtual void VisitBranch(BranchInstr* instr); | 44 virtual void VisitBranch(BranchInstr* instr); |
| 45 virtual void VisitStrictCompare(StrictCompareInstr* instr); | 45 virtual void VisitStrictCompare(StrictCompareInstr* instr); |
| 46 | 46 |
| 47 void InsertBefore(Instruction* next, | 47 void InsertBefore(Instruction* next, |
| 48 Instruction* instr, | 48 Instruction* instr, |
| 49 Environment* env, | 49 Environment* env, |
| 50 Definition::UseKind use_kind); | 50 Definition::UseKind use_kind) { |
| 51 flow_graph_->InsertBefore(next, instr, env, use_kind); |
| 52 } |
| 51 | 53 |
| 52 private: | 54 private: |
| 53 // Attempt to build ICData for call using propagated class-ids. | 55 // Attempt to build ICData for call using propagated class-ids. |
| 54 bool TryCreateICData(InstanceCallInstr* call); | 56 bool TryCreateICData(InstanceCallInstr* call); |
| 55 | 57 |
| 56 void SpecializePolymorphicInstanceCall(PolymorphicInstanceCallInstr* call); | 58 void SpecializePolymorphicInstanceCall(PolymorphicInstanceCallInstr* call); |
| 57 | 59 |
| 58 intptr_t PrepareIndexedOp(InstanceCallInstr* call, | 60 intptr_t PrepareIndexedOp(InstanceCallInstr* call, |
| 59 intptr_t class_id, | 61 intptr_t class_id, |
| 60 Value** array, | 62 Definition** array, |
| 61 Value** index); | 63 Definition** index); |
| 62 bool TryReplaceWithStoreIndexed(InstanceCallInstr* call); | 64 bool TryReplaceWithStoreIndexed(InstanceCallInstr* call); |
| 63 bool TryReplaceWithLoadIndexed(InstanceCallInstr* call); | 65 bool TryReplaceWithLoadIndexed(InstanceCallInstr* call); |
| 64 | 66 |
| 65 bool TryReplaceWithBinaryOp(InstanceCallInstr* call, Token::Kind op_kind); | 67 bool TryReplaceWithBinaryOp(InstanceCallInstr* call, Token::Kind op_kind); |
| 66 bool TryReplaceWithUnaryOp(InstanceCallInstr* call, Token::Kind op_kind); | 68 bool TryReplaceWithUnaryOp(InstanceCallInstr* call, Token::Kind op_kind); |
| 67 | 69 |
| 68 bool TryInlineInstanceGetter(InstanceCallInstr* call); | 70 bool TryInlineInstanceGetter(InstanceCallInstr* call); |
| 69 bool TryInlineInstanceSetter(InstanceCallInstr* call, | 71 bool TryInlineInstanceSetter(InstanceCallInstr* call, |
| 70 const ICData& unary_ic_data); | 72 const ICData& unary_ic_data); |
| 71 | 73 |
| 72 bool TryInlineInstanceMethod(InstanceCallInstr* call); | 74 bool TryInlineInstanceMethod(InstanceCallInstr* call); |
| 73 void ReplaceWithInstanceOf(InstanceCallInstr* instr); | 75 void ReplaceWithInstanceOf(InstanceCallInstr* instr); |
| 74 | 76 |
| 75 LoadIndexedInstr* BuildStringCharCodeAt(InstanceCallInstr* call, | 77 LoadIndexedInstr* BuildStringCharCodeAt(InstanceCallInstr* call, |
| 76 intptr_t cid); | 78 intptr_t cid); |
| 77 | 79 |
| 78 LoadIndexedInstr* BuildByteArrayViewLoad(InstanceCallInstr* call, | 80 LoadIndexedInstr* BuildByteArrayViewLoad(InstanceCallInstr* call, |
| 79 intptr_t receiver_cid, | 81 intptr_t receiver_cid, |
| 80 intptr_t view_cid); | 82 intptr_t view_cid); |
| 81 | 83 |
| 82 void AddCheckClass(InstanceCallInstr* call, Value* value); | 84 // Insert a check of 'to_check' determined by 'unary_checks'. If the |
| 85 // check fails it will deoptimize to 'deopt_id' using the deoptimization |
| 86 // environment 'deopt_environment'. The check is inserted immediately |
| 87 // before 'insert_before'. |
| 88 void AddCheckClass(Definition* to_check, |
| 89 const ICData& unary_checks, |
| 90 intptr_t deopt_id, |
| 91 Environment* deopt_environment, |
| 92 Instruction* insert_before); |
| 83 | 93 |
| 84 void InsertAfter(Instruction* prev, | 94 // Add a class check for a call's first argument immediately before the |
| 85 Instruction* instr, | 95 // call, using the call's IC data to determine the check, and the call's |
| 86 Environment* env, | 96 // deopt ID and deoptimization environment if the check fails. |
| 87 Definition::UseKind use_kind); | 97 void AddReceiverCheck(InstanceCallInstr* call); |
| 98 |
| 99 void ReplaceCall(Definition* call, Definition* replacement); |
| 88 | 100 |
| 89 void InsertConversionsFor(Definition* def); | 101 void InsertConversionsFor(Definition* def); |
| 90 | 102 |
| 91 void InsertConversion(Representation from, | 103 void InsertConversion(Representation from, |
| 92 Representation to, | 104 Representation to, |
| 93 Value* use, | 105 Value* use, |
| 94 Instruction* insert_before, | 106 Instruction* insert_before, |
| 95 Instruction* deopt_target); | 107 Instruction* deopt_target); |
| 96 | 108 |
| 97 bool InstanceCallNeedsClassCheck(InstanceCallInstr* call) const; | 109 bool InstanceCallNeedsClassCheck(InstanceCallInstr* call) const; |
| 98 bool MethodExtractorNeedsClassCheck(InstanceCallInstr* call) const; | 110 bool MethodExtractorNeedsClassCheck(InstanceCallInstr* call) const; |
| 99 | 111 |
| 100 void InlineImplicitInstanceGetter(InstanceCallInstr* call); | 112 void InlineImplicitInstanceGetter(InstanceCallInstr* call); |
| 101 void InlineArrayLengthGetter(InstanceCallInstr* call, | 113 void InlineArrayLengthGetter(InstanceCallInstr* call, |
| 102 intptr_t length_offset, | 114 intptr_t length_offset, |
| 103 bool is_immutable, | 115 bool is_immutable, |
| 104 MethodRecognizer::Kind kind); | 116 MethodRecognizer::Kind kind); |
| 105 void InlineGrowableArrayCapacityGetter(InstanceCallInstr* call); | 117 void InlineGrowableArrayCapacityGetter(InstanceCallInstr* call); |
| 106 void InlineStringLengthGetter(InstanceCallInstr* call); | 118 void InlineStringLengthGetter(InstanceCallInstr* call); |
| 107 void InlineStringIsEmptyGetter(InstanceCallInstr* call); | 119 void InlineStringIsEmptyGetter(InstanceCallInstr* call); |
| 108 | 120 |
| 109 RawBool* InstanceOfAsBool(const ICData& ic_data, | 121 RawBool* InstanceOfAsBool(const ICData& ic_data, |
| 110 const AbstractType& type) const; | 122 const AbstractType& type) const; |
| 111 | 123 |
| 112 void ReplaceWithMathCFunction(InstanceCallInstr* call, | 124 void ReplaceWithMathCFunction(InstanceCallInstr* call, |
| 113 MethodRecognizer::Kind recognized_kind); | 125 MethodRecognizer::Kind recognized_kind); |
| 114 | 126 |
| 127 void HandleRelationalOp(RelationalOpInstr* comp); |
| 128 |
| 129 // Visit an equality compare. The current instruction can be the |
| 130 // comparison itself or a branch on the comparison. |
| 131 template <typename T> |
| 132 void HandleEqualityCompare(EqualityCompareInstr* comp, |
| 133 T current_instruction); |
| 134 |
| 115 FlowGraph* flow_graph_; | 135 FlowGraph* flow_graph_; |
| 116 | 136 |
| 117 DISALLOW_COPY_AND_ASSIGN(FlowGraphOptimizer); | 137 DISALLOW_COPY_AND_ASSIGN(FlowGraphOptimizer); |
| 118 }; | 138 }; |
| 119 | 139 |
| 120 | 140 |
| 121 class ParsedFunction; | 141 class ParsedFunction; |
| 122 | 142 |
| 123 | 143 |
| 124 // Loop invariant code motion. | 144 // Loop invariant code motion. |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 | 230 |
| 211 // Worklists of blocks and definitions. | 231 // Worklists of blocks and definitions. |
| 212 GrowableArray<BlockEntryInstr*> block_worklist_; | 232 GrowableArray<BlockEntryInstr*> block_worklist_; |
| 213 GrowableArray<Definition*> definition_worklist_; | 233 GrowableArray<Definition*> definition_worklist_; |
| 214 }; | 234 }; |
| 215 | 235 |
| 216 | 236 |
| 217 } // namespace dart | 237 } // namespace dart |
| 218 | 238 |
| 219 #endif // VM_FLOW_GRAPH_OPTIMIZER_H_ | 239 #endif // VM_FLOW_GRAPH_OPTIMIZER_H_ |
| OLD | NEW |