| 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 | 9 |
| 10 namespace dart { | 10 namespace dart { |
| 11 | 11 |
| 12 template <typename T> class GrowableArray; | 12 template <typename T> class GrowableArray; |
| 13 | 13 |
| 14 class FlowGraphOptimizer : public FlowGraphVisitor { | 14 class FlowGraphOptimizer : public FlowGraphVisitor { |
| 15 public: | 15 public: |
| 16 explicit FlowGraphOptimizer(const GrowableArray<BlockEntryInstr*>& blocks) | 16 explicit FlowGraphOptimizer(const GrowableArray<BlockEntryInstr*>& blocks) |
| 17 : FlowGraphVisitor(blocks) {} | 17 : FlowGraphVisitor(blocks) {} |
| 18 virtual ~FlowGraphOptimizer() {} | 18 virtual ~FlowGraphOptimizer() {} |
| 19 | 19 |
| 20 void ApplyICData(); | 20 void ApplyICData(); |
| 21 | 21 |
| 22 virtual void VisitStaticCall(StaticCallComp* comp, BindInstr* instr); | 22 virtual void VisitStaticCall(StaticCallComp* comp, BindInstr* instr); |
| 23 virtual void VisitInstanceCall(InstanceCallComp* comp, BindInstr* instr); | 23 virtual void VisitInstanceCall(InstanceCallComp* comp, BindInstr* instr); |
| 24 virtual void VisitInstanceSetter(InstanceSetterComp* comp, BindInstr* instr); | |
| 25 virtual void VisitLoadIndexed(LoadIndexedComp* comp, BindInstr* instr); | 24 virtual void VisitLoadIndexed(LoadIndexedComp* comp, BindInstr* instr); |
| 26 virtual void VisitStoreIndexed(StoreIndexedComp* comp, BindInstr* instr); | 25 virtual void VisitStoreIndexed(StoreIndexedComp* comp, BindInstr* instr); |
| 27 virtual void VisitRelationalOp(RelationalOpComp* comp, BindInstr* instr); | 26 virtual void VisitRelationalOp(RelationalOpComp* comp, BindInstr* instr); |
| 28 | 27 |
| 29 virtual void VisitEqualityCompare(EqualityCompareComp* comp, | 28 virtual void VisitEqualityCompare(EqualityCompareComp* comp, |
| 30 BindInstr* instr); | 29 BindInstr* instr); |
| 31 | 30 |
| 32 virtual void VisitBind(BindInstr* instr); | 31 virtual void VisitBind(BindInstr* instr); |
| 33 | 32 |
| 34 private: | 33 private: |
| 35 bool TryReplaceWithBinaryOp(BindInstr* instr, | 34 bool TryReplaceWithBinaryOp(BindInstr* instr, |
| 36 InstanceCallComp* comp, | 35 InstanceCallComp* comp, |
| 37 Token::Kind op_kind); | 36 Token::Kind op_kind); |
| 38 bool TryReplaceWithUnaryOp(BindInstr* instr, | 37 bool TryReplaceWithUnaryOp(BindInstr* instr, |
| 39 InstanceCallComp* comp, | 38 InstanceCallComp* comp, |
| 40 Token::Kind op_kind); | 39 Token::Kind op_kind); |
| 41 | 40 |
| 42 bool TryInlineInstanceGetter(BindInstr* instr, | 41 bool TryInlineInstanceGetter(BindInstr* instr, |
| 43 InstanceCallComp* comp); | 42 InstanceCallComp* comp); |
| 44 bool TryInlineInstanceSetter(BindInstr* instr, InstanceSetterComp* comp); | 43 bool TryInlineInstanceSetter(BindInstr* instr, InstanceCallComp* comp); |
| 45 | 44 |
| 46 bool TryInlineInstanceMethod(BindInstr* instr, InstanceCallComp* comp); | 45 bool TryInlineInstanceMethod(BindInstr* instr, InstanceCallComp* comp); |
| 47 | 46 |
| 48 DISALLOW_COPY_AND_ASSIGN(FlowGraphOptimizer); | 47 DISALLOW_COPY_AND_ASSIGN(FlowGraphOptimizer); |
| 49 }; | 48 }; |
| 50 | 49 |
| 51 | 50 |
| 52 // Analyze the generated flow graph. Currently only if it is a leaf | 51 // Analyze the generated flow graph. Currently only if it is a leaf |
| 53 // method, i.e., does not contain any calls to runtime or other Dart code. | 52 // method, i.e., does not contain any calls to runtime or other Dart code. |
| 54 class FlowGraphAnalyzer : public ValueObject { | 53 class FlowGraphAnalyzer : public ValueObject { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 virtual void VisitBind(BindInstr* instr); | 89 virtual void VisitBind(BindInstr* instr); |
| 91 | 90 |
| 92 private: | 91 private: |
| 93 const ParsedFunction& parsed_function_; | 92 const ParsedFunction& parsed_function_; |
| 94 DISALLOW_COPY_AND_ASSIGN(FlowGraphTypePropagator); | 93 DISALLOW_COPY_AND_ASSIGN(FlowGraphTypePropagator); |
| 95 }; | 94 }; |
| 96 | 95 |
| 97 } // namespace dart | 96 } // namespace dart |
| 98 | 97 |
| 99 #endif // VM_FLOW_GRAPH_OPTIMIZER_H_ | 98 #endif // VM_FLOW_GRAPH_OPTIMIZER_H_ |
| OLD | NEW |