Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(109)

Side by Side Diff: runtime/vm/flow_graph_optimizer.h

Issue 10872035: Add a simple dominator based redundancy elimination. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
11 namespace dart { 11 namespace dart {
12 12
13 template <typename T> class GrowableArray; 13 template <typename T> class GrowableArray;
14 template <typename T> class DirectChainedHashMap;
14 15
15 class FlowGraphOptimizer : public FlowGraphVisitor { 16 class FlowGraphOptimizer : public FlowGraphVisitor {
16 public: 17 public:
17 explicit FlowGraphOptimizer(const FlowGraph& flow_graph) 18 explicit FlowGraphOptimizer(const FlowGraph& flow_graph)
18 : FlowGraphVisitor(flow_graph.reverse_postorder()) {} 19 : FlowGraphVisitor(flow_graph.reverse_postorder()) {}
19 virtual ~FlowGraphOptimizer() {} 20 virtual ~FlowGraphOptimizer() {}
20 21
21 void ApplyICData(); 22 void ApplyICData();
22 23
23 void OptimizeComputations(); 24 void OptimizeComputations();
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 virtual void VisitParameter(ParameterInstr* param); 99 virtual void VisitParameter(ParameterInstr* param);
99 virtual void VisitPushArgument(PushArgumentInstr* bind); 100 virtual void VisitPushArgument(PushArgumentInstr* bind);
100 101
101 private: 102 private:
102 const ParsedFunction& parsed_function_; 103 const ParsedFunction& parsed_function_;
103 bool still_changing_; 104 bool still_changing_;
104 DISALLOW_COPY_AND_ASSIGN(FlowGraphTypePropagator); 105 DISALLOW_COPY_AND_ASSIGN(FlowGraphTypePropagator);
105 }; 106 };
106 107
107 108
108 class LocalCSE : public ValueObject { 109 // A simple common subexpression elimination based
110 // on the dominator tree.
111 class DominatorBasedCSE : public AllStatic {
109 public: 112 public:
110 explicit LocalCSE(const FlowGraph& flow_graph) 113 static void Optimize(BlockEntryInstr* graph_entry);
111 : blocks_(flow_graph.reverse_postorder()) { }
112
113 void Optimize();
114 114
115 private: 115 private:
116 const GrowableArray<BlockEntryInstr*>& blocks_; 116 static void OptimizeRecursive(
117 117 BlockEntryInstr* entry,
118 DISALLOW_COPY_AND_ASSIGN(LocalCSE); 118 DirectChainedHashMap<BindInstr*>* map);
119 }; 119 };
120 120
121 121
122 } // namespace dart 122 } // namespace dart
123 123
124 #endif // VM_FLOW_GRAPH_OPTIMIZER_H_ 124 #endif // VM_FLOW_GRAPH_OPTIMIZER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698