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" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 Loop* parent_; | 56 Loop* parent_; |
57 int depth_; | 57 int depth_; |
58 ZoneVector<Loop*> children_; | 58 ZoneVector<Loop*> children_; |
59 int header_start_; | 59 int header_start_; |
60 int body_start_; | 60 int body_start_; |
61 int body_end_; | 61 int body_end_; |
62 }; | 62 }; |
63 | 63 |
64 // Return the innermost nested loop, if any, that contains {node}. | 64 // Return the innermost nested loop, if any, that contains {node}. |
65 Loop* ContainingLoop(Node* node) { | 65 Loop* ContainingLoop(Node* node) { |
66 if (node->id() >= static_cast<int>(node_to_loop_num_.size())) | 66 if (node->id() >= node_to_loop_num_.size()) return nullptr; |
67 return nullptr; | |
68 int num = node_to_loop_num_[node->id()]; | 67 int num = node_to_loop_num_[node->id()]; |
69 return num > 0 ? &all_loops_[num - 1] : nullptr; | 68 return num > 0 ? &all_loops_[num - 1] : nullptr; |
70 } | 69 } |
71 | 70 |
72 // Check if the {loop} contains the {node}, either directly or by containing | 71 // Check if the {loop} contains the {node}, either directly or by containing |
73 // a nested loop that contains {node}. | 72 // a nested loop that contains {node}. |
74 bool Contains(Loop* loop, Node* node) { | 73 bool Contains(Loop* loop, Node* node) { |
75 for (Loop* c = ContainingLoop(node); c != nullptr; c = c->parent_) { | 74 for (Loop* c = ContainingLoop(node); c != nullptr; c = c->parent_) { |
76 if (c == loop) return true; | 75 if (c == loop) return true; |
77 } | 76 } |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 // Build a loop tree for the entire graph. | 147 // Build a loop tree for the entire graph. |
149 static LoopTree* BuildLoopTree(Graph* graph, Zone* temp_zone); | 148 static LoopTree* BuildLoopTree(Graph* graph, Zone* temp_zone); |
150 }; | 149 }; |
151 | 150 |
152 | 151 |
153 } // namespace compiler | 152 } // namespace compiler |
154 } // namespace internal | 153 } // namespace internal |
155 } // namespace v8 | 154 } // namespace v8 |
156 | 155 |
157 #endif // V8_COMPILER_LOOP_ANALYSIS_H_ | 156 #endif // V8_COMPILER_LOOP_ANALYSIS_H_ |
OLD | NEW |