| 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 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 // 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. |
| 35 // TODO(srdjan): StaticCals as well? | 35 // TODO(srdjan): StaticCals as well? |
| 36 void PopulateWithICData(); | 36 void PopulateWithICData(); |
| 37 | 37 |
| 38 // Use ICData to optimize, replace or eliminate instructions. | 38 // Use ICData to optimize, replace or eliminate instructions. |
| 39 void ApplyICData(); | 39 void ApplyICData(); |
| 40 | 40 |
| 41 // Use propagated class ids to optimize, replace or eliminate instructions. | 41 // Use propagated class ids to optimize, replace or eliminate instructions. |
| 42 void ApplyClassIds(); | 42 void ApplyClassIds(); |
| 43 | 43 |
| 44 // Optimize (a << b) & c pattern: if c is a positive Smi or zero, then the | |
| 45 // shift can be a truncating Smi shift-left and result is always Smi. | |
| 46 // Merge instructions (only per basic-block). | |
| 47 void TryOptimizePatterns(); | |
| 48 | |
| 49 void ReplaceArrayBoundChecks(); | 44 void ReplaceArrayBoundChecks(); |
| 50 | 45 |
| 51 virtual void VisitStaticCall(StaticCallInstr* instr); | 46 virtual void VisitStaticCall(StaticCallInstr* instr); |
| 52 virtual void VisitInstanceCall(InstanceCallInstr* instr); | 47 virtual void VisitInstanceCall(InstanceCallInstr* instr); |
| 53 virtual void VisitLoadCodeUnits(LoadCodeUnitsInstr* instr); | 48 virtual void VisitLoadCodeUnits(LoadCodeUnitsInstr* instr); |
| 54 | 49 |
| 55 void InsertBefore(Instruction* next, | 50 void InsertBefore(Instruction* next, |
| 56 Instruction* instr, | 51 Instruction* instr, |
| 57 Environment* env, | 52 Environment* env, |
| 58 FlowGraph::UseKind use_kind) { | 53 FlowGraph::UseKind use_kind) { |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 // call, using the call's IC data to determine the check, and the call's | 103 // call, using the call's IC data to determine the check, and the call's |
| 109 // deopt ID and deoptimization environment if the check fails. | 104 // deopt ID and deoptimization environment if the check fails. |
| 110 void AddReceiverCheck(InstanceCallInstr* call); | 105 void AddReceiverCheck(InstanceCallInstr* call); |
| 111 | 106 |
| 112 void ReplaceCall(Definition* call, Definition* replacement); | 107 void ReplaceCall(Definition* call, Definition* replacement); |
| 113 | 108 |
| 114 | 109 |
| 115 bool InstanceCallNeedsClassCheck(InstanceCallInstr* call, | 110 bool InstanceCallNeedsClassCheck(InstanceCallInstr* call, |
| 116 RawFunction::Kind kind) const; | 111 RawFunction::Kind kind) const; |
| 117 | 112 |
| 118 bool InlineFloat32x4Getter(InstanceCallInstr* call, | |
| 119 MethodRecognizer::Kind getter); | |
| 120 bool InlineFloat64x2Getter(InstanceCallInstr* call, | |
| 121 MethodRecognizer::Kind getter); | |
| 122 bool InlineInt32x4Getter(InstanceCallInstr* call, | |
| 123 MethodRecognizer::Kind getter); | |
| 124 bool InlineFloat32x4BinaryOp(InstanceCallInstr* call, | 113 bool InlineFloat32x4BinaryOp(InstanceCallInstr* call, |
| 125 Token::Kind op_kind); | 114 Token::Kind op_kind); |
| 126 bool InlineInt32x4BinaryOp(InstanceCallInstr* call, | 115 bool InlineInt32x4BinaryOp(InstanceCallInstr* call, |
| 127 Token::Kind op_kind); | 116 Token::Kind op_kind); |
| 128 bool InlineFloat64x2BinaryOp(InstanceCallInstr* call, | 117 bool InlineFloat64x2BinaryOp(InstanceCallInstr* call, |
| 129 Token::Kind op_kind); | 118 Token::Kind op_kind); |
| 130 bool InlineImplicitInstanceGetter(InstanceCallInstr* call); | 119 bool InlineImplicitInstanceGetter(InstanceCallInstr* call); |
| 131 | 120 |
| 132 RawBool* InstanceOfAsBool(const ICData& ic_data, | 121 RawBool* InstanceOfAsBool(const ICData& ic_data, |
| 133 const AbstractType& type, | 122 const AbstractType& type, |
| 134 ZoneGrowableArray<intptr_t>* results) const; | 123 ZoneGrowableArray<intptr_t>* results) const; |
| 135 | 124 |
| 136 void ReplaceWithMathCFunction(InstanceCallInstr* call, | 125 void ReplaceWithMathCFunction(InstanceCallInstr* call, |
| 137 MethodRecognizer::Kind recognized_kind); | 126 MethodRecognizer::Kind recognized_kind); |
| 138 | 127 |
| 139 void OptimizeLeftShiftBitAndSmiOp(Definition* bit_and_instr, | |
| 140 Definition* left_instr, | |
| 141 Definition* right_instr); | |
| 142 void TryMergeTruncDivMod(GrowableArray<BinarySmiOpInstr*>* merge_candidates); | |
| 143 void TryMergeMathUnary(GrowableArray<MathUnaryInstr*>* merge_candidates); | |
| 144 | |
| 145 void AppendExtractNthOutputForMerged(Definition* instr, intptr_t ix, | |
| 146 Representation rep, intptr_t cid); | |
| 147 bool TryStringLengthOneEquality(InstanceCallInstr* call, Token::Kind op_kind); | 128 bool TryStringLengthOneEquality(InstanceCallInstr* call, Token::Kind op_kind); |
| 148 | 129 |
| 149 RawField* GetField(intptr_t class_id, const String& field_name); | 130 RawField* GetField(intptr_t class_id, const String& field_name); |
| 150 | 131 |
| 151 Thread* thread() const { return flow_graph_->thread(); } | 132 Thread* thread() const { return flow_graph_->thread(); } |
| 152 Isolate* isolate() const { return flow_graph_->isolate(); } | 133 Isolate* isolate() const { return flow_graph_->isolate(); } |
| 153 Zone* zone() const { return flow_graph_->zone(); } | 134 Zone* zone() const { return flow_graph_->zone(); } |
| 154 | 135 |
| 155 const Function& function() const { return flow_graph_->function(); } | 136 const Function& function() const { return flow_graph_->function(); } |
| 156 | 137 |
| 157 bool IsAllowedForInlining(intptr_t deopt_id); | 138 bool IsAllowedForInlining(intptr_t deopt_id); |
| 158 | 139 |
| 159 FlowGraph* flow_graph_; | 140 FlowGraph* flow_graph_; |
| 160 | 141 |
| 161 const bool use_speculative_inlining_; | 142 const bool use_speculative_inlining_; |
| 162 | 143 |
| 163 GrowableArray<intptr_t>* inlining_black_list_; | 144 GrowableArray<intptr_t>* inlining_black_list_; |
| 164 | 145 |
| 165 DISALLOW_COPY_AND_ASSIGN(AotOptimizer); | 146 DISALLOW_COPY_AND_ASSIGN(AotOptimizer); |
| 166 }; | 147 }; |
| 167 | 148 |
| 168 | 149 |
| 169 } // namespace dart | 150 } // namespace dart |
| 170 | 151 |
| 171 #endif // VM_AOT_OPTIMIZER_H_ | 152 #endif // VM_AOT_OPTIMIZER_H_ |
| OLD | NEW |