| 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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 | 88 |
| 89 DISALLOW_COPY_AND_ASSIGN(FlowGraphAnalyzer); | 89 DISALLOW_COPY_AND_ASSIGN(FlowGraphAnalyzer); |
| 90 }; | 90 }; |
| 91 | 91 |
| 92 | 92 |
| 93 class ParsedFunction; | 93 class ParsedFunction; |
| 94 | 94 |
| 95 | 95 |
| 96 class FlowGraphTypePropagator : public FlowGraphVisitor { | 96 class FlowGraphTypePropagator : public FlowGraphVisitor { |
| 97 public: | 97 public: |
| 98 explicit FlowGraphTypePropagator(const FlowGraph& flow_graph) | 98 explicit FlowGraphTypePropagator(FlowGraph* flow_graph) |
| 99 : FlowGraphVisitor(flow_graph.reverse_postorder()), | 99 : FlowGraphVisitor(flow_graph->reverse_postorder()), |
| 100 parsed_function_(flow_graph.parsed_function()), | 100 parsed_function_(flow_graph->parsed_function()), |
| 101 flow_graph_(flow_graph), |
| 101 still_changing_(false) { } | 102 still_changing_(false) { } |
| 102 virtual ~FlowGraphTypePropagator() { } | 103 virtual ~FlowGraphTypePropagator() { } |
| 103 | 104 |
| 104 const ParsedFunction& parsed_function() const { return parsed_function_; } | 105 const ParsedFunction& parsed_function() const { return parsed_function_; } |
| 105 | 106 |
| 106 void PropagateTypes(); | 107 void PropagateTypes(); |
| 107 | 108 |
| 108 private: | 109 private: |
| 109 virtual void VisitBlocks(); | 110 virtual void VisitBlocks(); |
| 110 | 111 |
| 111 virtual void VisitAssertAssignable(AssertAssignableInstr* instr); | 112 virtual void VisitAssertAssignable(AssertAssignableInstr* instr); |
| 112 virtual void VisitAssertBoolean(AssertBooleanInstr* instr); | 113 virtual void VisitAssertBoolean(AssertBooleanInstr* instr); |
| 113 virtual void VisitInstanceOf(InstanceOfInstr* instr); | 114 virtual void VisitInstanceOf(InstanceOfInstr* instr); |
| 114 | 115 |
| 115 virtual void VisitGraphEntry(GraphEntryInstr* graph_entry); | 116 virtual void VisitGraphEntry(GraphEntryInstr* graph_entry); |
| 116 virtual void VisitJoinEntry(JoinEntryInstr* join_entry); | 117 virtual void VisitJoinEntry(JoinEntryInstr* join_entry); |
| 117 virtual void VisitPhi(PhiInstr* phi); | 118 virtual void VisitPhi(PhiInstr* phi); |
| 118 virtual void VisitParameter(ParameterInstr* param); | 119 virtual void VisitParameter(ParameterInstr* param); |
| 119 virtual void VisitPushArgument(PushArgumentInstr* bind); | 120 virtual void VisitPushArgument(PushArgumentInstr* bind); |
| 120 | 121 |
| 121 const ParsedFunction& parsed_function_; | 122 const ParsedFunction& parsed_function_; |
| 123 FlowGraph* flow_graph_; |
| 122 bool still_changing_; | 124 bool still_changing_; |
| 123 DISALLOW_COPY_AND_ASSIGN(FlowGraphTypePropagator); | 125 DISALLOW_COPY_AND_ASSIGN(FlowGraphTypePropagator); |
| 124 }; | 126 }; |
| 125 | 127 |
| 126 | 128 |
| 127 // Loop invariant code motion. | 129 // Loop invariant code motion. |
| 128 class LICM : public AllStatic { | 130 class LICM : public AllStatic { |
| 129 public: | 131 public: |
| 130 static void Optimize(FlowGraph* flow_graph); | 132 static void Optimize(FlowGraph* flow_graph); |
| 131 | 133 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 150 private: | 152 private: |
| 151 static void OptimizeRecursive( | 153 static void OptimizeRecursive( |
| 152 BlockEntryInstr* entry, | 154 BlockEntryInstr* entry, |
| 153 DirectChainedHashMap<Definition*>* map); | 155 DirectChainedHashMap<Definition*>* map); |
| 154 }; | 156 }; |
| 155 | 157 |
| 156 | 158 |
| 157 } // namespace dart | 159 } // namespace dart |
| 158 | 160 |
| 159 #endif // VM_FLOW_GRAPH_OPTIMIZER_H_ | 161 #endif // VM_FLOW_GRAPH_OPTIMIZER_H_ |
| OLD | NEW |