| 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 RUNTIME_VM_JIT_OPTIMIZER_H_ | 5 #ifndef RUNTIME_VM_JIT_OPTIMIZER_H_ |
| 6 #define RUNTIME_VM_JIT_OPTIMIZER_H_ | 6 #define RUNTIME_VM_JIT_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> |
| 15 class GrowableArray; |
| 15 class ParsedFunction; | 16 class ParsedFunction; |
| 16 | 17 |
| 17 class JitOptimizer : public FlowGraphVisitor { | 18 class JitOptimizer : public FlowGraphVisitor { |
| 18 public: | 19 public: |
| 19 explicit JitOptimizer(FlowGraph* flow_graph) | 20 explicit JitOptimizer(FlowGraph* flow_graph) |
| 20 : FlowGraphVisitor(flow_graph->reverse_postorder()), | 21 : FlowGraphVisitor(flow_graph->reverse_postorder()), |
| 21 flow_graph_(flow_graph) { } | 22 flow_graph_(flow_graph) {} |
| 22 | 23 |
| 23 virtual ~JitOptimizer() {} | 24 virtual ~JitOptimizer() {} |
| 24 | 25 |
| 25 FlowGraph* flow_graph() const { return flow_graph_; } | 26 FlowGraph* flow_graph() const { return flow_graph_; } |
| 26 | 27 |
| 27 // Use ICData to optimize, replace or eliminate instructions. | 28 // Use ICData to optimize, replace or eliminate instructions. |
| 28 void ApplyICData(); | 29 void ApplyICData(); |
| 29 | 30 |
| 30 // Use propagated class ids to optimize, replace or eliminate instructions. | 31 // Use propagated class ids to optimize, replace or eliminate instructions. |
| 31 void ApplyClassIds(); | 32 void ApplyClassIds(); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 // call, using the call's IC data to determine the check, and the call's | 95 // call, using the call's IC data to determine the check, and the call's |
| 95 // deopt ID and deoptimization environment if the check fails. | 96 // deopt ID and deoptimization environment if the check fails. |
| 96 void AddReceiverCheck(InstanceCallInstr* call); | 97 void AddReceiverCheck(InstanceCallInstr* call); |
| 97 | 98 |
| 98 void ReplaceCall(Definition* call, Definition* replacement); | 99 void ReplaceCall(Definition* call, Definition* replacement); |
| 99 | 100 |
| 100 | 101 |
| 101 bool InstanceCallNeedsClassCheck(InstanceCallInstr* call, | 102 bool InstanceCallNeedsClassCheck(InstanceCallInstr* call, |
| 102 RawFunction::Kind kind) const; | 103 RawFunction::Kind kind) const; |
| 103 | 104 |
| 104 bool InlineFloat32x4BinaryOp(InstanceCallInstr* call, | 105 bool InlineFloat32x4BinaryOp(InstanceCallInstr* call, Token::Kind op_kind); |
| 105 Token::Kind op_kind); | 106 bool InlineInt32x4BinaryOp(InstanceCallInstr* call, Token::Kind op_kind); |
| 106 bool InlineInt32x4BinaryOp(InstanceCallInstr* call, | 107 bool InlineFloat64x2BinaryOp(InstanceCallInstr* call, Token::Kind op_kind); |
| 107 Token::Kind op_kind); | |
| 108 bool InlineFloat64x2BinaryOp(InstanceCallInstr* call, | |
| 109 Token::Kind op_kind); | |
| 110 bool InlineImplicitInstanceGetter(InstanceCallInstr* call); | 108 bool InlineImplicitInstanceGetter(InstanceCallInstr* call); |
| 111 | 109 |
| 112 RawBool* InstanceOfAsBool(const ICData& ic_data, | 110 RawBool* InstanceOfAsBool(const ICData& ic_data, |
| 113 const AbstractType& type, | 111 const AbstractType& type, |
| 114 ZoneGrowableArray<intptr_t>* results) const; | 112 ZoneGrowableArray<intptr_t>* results) const; |
| 115 | 113 |
| 116 void ReplaceWithMathCFunction(InstanceCallInstr* call, | 114 void ReplaceWithMathCFunction(InstanceCallInstr* call, |
| 117 MethodRecognizer::Kind recognized_kind); | 115 MethodRecognizer::Kind recognized_kind); |
| 118 | 116 |
| 119 bool TryStringLengthOneEquality(InstanceCallInstr* call, Token::Kind op_kind); | 117 bool TryStringLengthOneEquality(InstanceCallInstr* call, Token::Kind op_kind); |
| 120 | 118 |
| 121 RawField* GetField(intptr_t class_id, const String& field_name); | 119 RawField* GetField(intptr_t class_id, const String& field_name); |
| 122 | 120 |
| 123 Thread* thread() const { return flow_graph_->thread(); } | 121 Thread* thread() const { return flow_graph_->thread(); } |
| 124 Isolate* isolate() const { return flow_graph_->isolate(); } | 122 Isolate* isolate() const { return flow_graph_->isolate(); } |
| 125 Zone* zone() const { return flow_graph_->zone(); } | 123 Zone* zone() const { return flow_graph_->zone(); } |
| 126 | 124 |
| 127 const Function& function() const { return flow_graph_->function(); } | 125 const Function& function() const { return flow_graph_->function(); } |
| 128 | 126 |
| 129 FlowGraph* flow_graph_; | 127 FlowGraph* flow_graph_; |
| 130 | 128 |
| 131 DISALLOW_COPY_AND_ASSIGN(JitOptimizer); | 129 DISALLOW_COPY_AND_ASSIGN(JitOptimizer); |
| 132 }; | 130 }; |
| 133 | 131 |
| 134 | 132 |
| 135 } // namespace dart | 133 } // namespace dart |
| 136 | 134 |
| 137 #endif // RUNTIME_VM_JIT_OPTIMIZER_H_ | 135 #endif // RUNTIME_VM_JIT_OPTIMIZER_H_ |
| OLD | NEW |