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

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

Issue 10857016: Refactored FlowGraphBuilder into a separate FlowGraph representation. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Revision based on Kevin's review. 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
« no previous file with comments | « runtime/vm/flow_graph_compiler_x64.cc ('k') | runtime/vm/il_printer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 10
10 namespace dart { 11 namespace dart {
11 12
12 template <typename T> class GrowableArray; 13 template <typename T> class GrowableArray;
13 14
14 class FlowGraphOptimizer : public FlowGraphVisitor { 15 class FlowGraphOptimizer : public FlowGraphVisitor {
15 public: 16 public:
16 explicit FlowGraphOptimizer(const GrowableArray<BlockEntryInstr*>& blocks) 17 explicit FlowGraphOptimizer(const FlowGraph& flow_graph)
17 : FlowGraphVisitor(blocks) {} 18 : FlowGraphVisitor(flow_graph.reverse_postorder()) {}
18 virtual ~FlowGraphOptimizer() {} 19 virtual ~FlowGraphOptimizer() {}
19 20
20 void ApplyICData(); 21 void ApplyICData();
21 22
22 void OptimizeComputations(); 23 void OptimizeComputations();
23 24
24 virtual void VisitStaticCall(StaticCallComp* comp, BindInstr* instr); 25 virtual void VisitStaticCall(StaticCallComp* comp, BindInstr* instr);
25 virtual void VisitInstanceCall(InstanceCallComp* comp, BindInstr* instr); 26 virtual void VisitInstanceCall(InstanceCallComp* comp, BindInstr* instr);
26 virtual void VisitRelationalOp(RelationalOpComp* comp, BindInstr* instr); 27 virtual void VisitRelationalOp(RelationalOpComp* comp, BindInstr* instr);
27 virtual void VisitEqualityCompare(EqualityCompareComp* comp, 28 virtual void VisitEqualityCompare(EqualityCompareComp* comp,
(...skipping 18 matching lines...) Expand all
46 bool TryInlineInstanceMethod(BindInstr* instr, InstanceCallComp* comp); 47 bool TryInlineInstanceMethod(BindInstr* instr, InstanceCallComp* comp);
47 48
48 DISALLOW_COPY_AND_ASSIGN(FlowGraphOptimizer); 49 DISALLOW_COPY_AND_ASSIGN(FlowGraphOptimizer);
49 }; 50 };
50 51
51 52
52 // Analyze the generated flow graph. Currently only if it is a leaf 53 // 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. 54 // method, i.e., does not contain any calls to runtime or other Dart code.
54 class FlowGraphAnalyzer : public ValueObject { 55 class FlowGraphAnalyzer : public ValueObject {
55 public: 56 public:
56 explicit FlowGraphAnalyzer(const GrowableArray<BlockEntryInstr*>& blocks) 57 explicit FlowGraphAnalyzer(const FlowGraph& flow_graph)
57 : blocks_(blocks), is_leaf_(false) {} 58 : blocks_(flow_graph.reverse_postorder()), is_leaf_(false) {}
58 virtual ~FlowGraphAnalyzer() {} 59 virtual ~FlowGraphAnalyzer() {}
59 60
60 void Analyze(); 61 void Analyze();
61 62
62 bool is_leaf() const { return is_leaf_; } 63 bool is_leaf() const { return is_leaf_; }
63 64
64 private: 65 private:
65 const GrowableArray<BlockEntryInstr*>& blocks_; 66 const GrowableArray<BlockEntryInstr*>& blocks_;
66 bool is_leaf_; 67 bool is_leaf_;
67 68
68 DISALLOW_COPY_AND_ASSIGN(FlowGraphAnalyzer); 69 DISALLOW_COPY_AND_ASSIGN(FlowGraphAnalyzer);
69 }; 70 };
70 71
71 72
72 class ParsedFunction; 73 class ParsedFunction;
73 74
74 75
75 class FlowGraphTypePropagator : public FlowGraphVisitor { 76 class FlowGraphTypePropagator : public FlowGraphVisitor {
76 public: 77 public:
77 FlowGraphTypePropagator(const ParsedFunction& parsed_function, 78 explicit FlowGraphTypePropagator(const FlowGraph& flow_graph)
78 const GrowableArray<BlockEntryInstr*>& blocks) 79 : FlowGraphVisitor(flow_graph.reverse_postorder()),
79 : FlowGraphVisitor(blocks), 80 parsed_function_(flow_graph.parsed_function()),
80 parsed_function_(parsed_function),
81 still_changing_(false) { } 81 still_changing_(false) { }
82 virtual ~FlowGraphTypePropagator() { } 82 virtual ~FlowGraphTypePropagator() { }
83 83
84 const ParsedFunction& parsed_function() const { return parsed_function_; } 84 const ParsedFunction& parsed_function() const { return parsed_function_; }
85 85
86 void PropagateTypes(); 86 void PropagateTypes();
87 87
88 virtual void VisitAssertAssignable(AssertAssignableComp* comp, 88 virtual void VisitAssertAssignable(AssertAssignableComp* comp,
89 BindInstr* instr); 89 BindInstr* instr);
90 virtual void VisitAssertBoolean(AssertBooleanComp* comp, 90 virtual void VisitAssertBoolean(AssertBooleanComp* comp,
91 BindInstr* instr); 91 BindInstr* instr);
92 92
93 virtual void VisitGraphEntry(GraphEntryInstr* graph_entry); 93 virtual void VisitGraphEntry(GraphEntryInstr* graph_entry);
94 virtual void VisitJoinEntry(JoinEntryInstr* join_entry); 94 virtual void VisitJoinEntry(JoinEntryInstr* join_entry);
95 virtual void VisitBind(BindInstr* bind); 95 virtual void VisitBind(BindInstr* bind);
96 virtual void VisitPhi(PhiInstr* phi); 96 virtual void VisitPhi(PhiInstr* phi);
97 virtual void VisitParameter(ParameterInstr* param); 97 virtual void VisitParameter(ParameterInstr* param);
98 98
99 private: 99 private:
100 const ParsedFunction& parsed_function_; 100 const ParsedFunction& parsed_function_;
101 bool still_changing_; 101 bool still_changing_;
102 DISALLOW_COPY_AND_ASSIGN(FlowGraphTypePropagator); 102 DISALLOW_COPY_AND_ASSIGN(FlowGraphTypePropagator);
103 }; 103 };
104 104
105 } // namespace dart 105 } // namespace dart
106 106
107 #endif // VM_FLOW_GRAPH_OPTIMIZER_H_ 107 #endif // VM_FLOW_GRAPH_OPTIMIZER_H_
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_compiler_x64.cc ('k') | runtime/vm/il_printer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698