OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_COMPILER_LOOP_ANALYSIS_H_ | 5 #ifndef V8_COMPILER_LOOP_ANALYSIS_H_ |
6 #define V8_COMPILER_LOOP_ANALYSIS_H_ | 6 #define V8_COMPILER_LOOP_ANALYSIS_H_ |
7 | 7 |
8 #include "src/base/iterator.h" | 8 #include "src/base/iterator.h" |
9 #include "src/compiler/graph.h" | 9 #include "src/compiler/graph.h" |
10 #include "src/compiler/node.h" | 10 #include "src/compiler/node.h" |
11 #include "src/zone-containers.h" | 11 #include "src/zone-containers.h" |
12 | 12 |
13 namespace v8 { | 13 namespace v8 { |
14 namespace internal { | 14 namespace internal { |
15 namespace compiler { | 15 namespace compiler { |
16 | 16 |
| 17 // TODO(titzer): don't assume entry edges have a particular index. |
| 18 static const int kAssumedLoopEntryIndex = 0; // assume loops are entered here. |
| 19 |
17 class LoopFinderImpl; | 20 class LoopFinderImpl; |
18 | 21 |
19 typedef base::iterator_range<Node**> NodeRange; | 22 typedef base::iterator_range<Node**> NodeRange; |
20 | 23 |
21 // Represents a tree of loops in a graph. | 24 // Represents a tree of loops in a graph. |
22 class LoopTree : public ZoneObject { | 25 class LoopTree : public ZoneObject { |
23 public: | 26 public: |
24 LoopTree(size_t num_nodes, Zone* zone) | 27 LoopTree(size_t num_nodes, Zone* zone) |
25 : zone_(zone), | 28 : zone_(zone), |
26 outer_loops_(zone), | 29 outer_loops_(zone), |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 } | 136 } |
134 } | 137 } |
135 | 138 |
136 Zone* zone_; | 139 Zone* zone_; |
137 ZoneVector<Loop*> outer_loops_; | 140 ZoneVector<Loop*> outer_loops_; |
138 ZoneVector<Loop> all_loops_; | 141 ZoneVector<Loop> all_loops_; |
139 ZoneVector<int> node_to_loop_num_; | 142 ZoneVector<int> node_to_loop_num_; |
140 ZoneVector<Node*> loop_nodes_; | 143 ZoneVector<Node*> loop_nodes_; |
141 }; | 144 }; |
142 | 145 |
143 | |
144 class LoopFinder { | 146 class LoopFinder { |
145 public: | 147 public: |
146 // Build a loop tree for the entire graph. | 148 // Build a loop tree for the entire graph. |
147 static LoopTree* BuildLoopTree(Graph* graph, Zone* temp_zone); | 149 static LoopTree* BuildLoopTree(Graph* graph, Zone* temp_zone); |
148 }; | 150 }; |
149 | 151 |
150 | 152 |
151 } // namespace compiler | 153 } // namespace compiler |
152 } // namespace internal | 154 } // namespace internal |
153 } // namespace v8 | 155 } // namespace v8 |
154 | 156 |
155 #endif // V8_COMPILER_LOOP_ANALYSIS_H_ | 157 #endif // V8_COMPILER_LOOP_ANALYSIS_H_ |
OLD | NEW |