| 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_CONTROL_EQUIVALENCE_H_ | 5 #ifndef V8_COMPILER_CONTROL_EQUIVALENCE_H_ |
| 6 #define V8_COMPILER_CONTROL_EQUIVALENCE_H_ | 6 #define V8_COMPILER_CONTROL_EQUIVALENCE_H_ |
| 7 | 7 |
| 8 #include "src/compiler/graph.h" | 8 #include "src/compiler/graph.h" |
| 9 #include "src/compiler/node.h" | 9 #include "src/compiler/node.h" |
| 10 #include "src/compiler/node-properties.h" | 10 #include "src/compiler/node-properties.h" |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 | 176 |
| 177 while (!stack.empty()) { // Undirected depth-first backwards traversal. | 177 while (!stack.empty()) { // Undirected depth-first backwards traversal. |
| 178 DFSStackEntry& entry = stack.top(); | 178 DFSStackEntry& entry = stack.top(); |
| 179 Node* node = entry.node; | 179 Node* node = entry.node; |
| 180 | 180 |
| 181 if (entry.direction == kInputDirection) { | 181 if (entry.direction == kInputDirection) { |
| 182 if (entry.input != node->input_edges().end()) { | 182 if (entry.input != node->input_edges().end()) { |
| 183 Edge edge = *entry.input; | 183 Edge edge = *entry.input; |
| 184 Node* input = edge.to(); | 184 Node* input = edge.to(); |
| 185 ++(entry.input); | 185 ++(entry.input); |
| 186 if (NodeProperties::IsControlEdge(edge) && | 186 if (NodeProperties::IsControlEdge(edge)) { |
| 187 NodeProperties::IsControl(input)) { | |
| 188 // Visit next control input. | 187 // Visit next control input. |
| 189 if (!GetData(input)->participates) continue; | 188 if (!GetData(input)->participates) continue; |
| 190 if (GetData(input)->visited) continue; | 189 if (GetData(input)->visited) continue; |
| 191 if (GetData(input)->on_stack) { | 190 if (GetData(input)->on_stack) { |
| 192 // Found backedge if input is on stack. | 191 // Found backedge if input is on stack. |
| 193 if (input != entry.parent_node) { | 192 if (input != entry.parent_node) { |
| 194 VisitBackedge(node, input, kInputDirection); | 193 VisitBackedge(node, input, kInputDirection); |
| 195 } | 194 } |
| 196 } else { | 195 } else { |
| 197 // Push input onto stack. | 196 // Push input onto stack. |
| 198 DFSPush(stack, input, node, kInputDirection); | 197 DFSPush(stack, input, node, kInputDirection); |
| 199 VisitPre(input); | 198 VisitPre(input); |
| 200 } | 199 } |
| 201 } | 200 } |
| 202 continue; | 201 continue; |
| 203 } | 202 } |
| 204 if (entry.use != node->use_edges().end()) { | 203 if (entry.use != node->use_edges().end()) { |
| 205 // Switch direction to uses. | 204 // Switch direction to uses. |
| 206 entry.direction = kUseDirection; | 205 entry.direction = kUseDirection; |
| 207 VisitMid(node, kInputDirection); | 206 VisitMid(node, kInputDirection); |
| 208 continue; | 207 continue; |
| 209 } | 208 } |
| 210 } | 209 } |
| 211 | 210 |
| 212 if (entry.direction == kUseDirection) { | 211 if (entry.direction == kUseDirection) { |
| 213 if (entry.use != node->use_edges().end()) { | 212 if (entry.use != node->use_edges().end()) { |
| 214 Edge edge = *entry.use; | 213 Edge edge = *entry.use; |
| 215 Node* use = edge.from(); | 214 Node* use = edge.from(); |
| 216 ++(entry.use); | 215 ++(entry.use); |
| 217 if (NodeProperties::IsControlEdge(edge) && | 216 if (NodeProperties::IsControlEdge(edge)) { |
| 218 NodeProperties::IsControl(use)) { | |
| 219 // Visit next control use. | 217 // Visit next control use. |
| 220 if (!GetData(use)->participates) continue; | 218 if (!GetData(use)->participates) continue; |
| 221 if (GetData(use)->visited) continue; | 219 if (GetData(use)->visited) continue; |
| 222 if (GetData(use)->on_stack) { | 220 if (GetData(use)->on_stack) { |
| 223 // Found backedge if use is on stack. | 221 // Found backedge if use is on stack. |
| 224 if (use != entry.parent_node) { | 222 if (use != entry.parent_node) { |
| 225 VisitBackedge(node, use, kUseDirection); | 223 VisitBackedge(node, use, kUseDirection); |
| 226 } | 224 } |
| 227 } else { | 225 } else { |
| 228 // Push use onto stack. | 226 // Push use onto stack. |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 int dfs_number_; // Generates new DFS pre-order numbers on demand. | 348 int dfs_number_; // Generates new DFS pre-order numbers on demand. |
| 351 int class_number_; // Generates new equivalence class numbers on demand. | 349 int class_number_; // Generates new equivalence class numbers on demand. |
| 352 Data node_data_; // Per-node data stored as a side-table. | 350 Data node_data_; // Per-node data stored as a side-table. |
| 353 }; | 351 }; |
| 354 | 352 |
| 355 } // namespace compiler | 353 } // namespace compiler |
| 356 } // namespace internal | 354 } // namespace internal |
| 357 } // namespace v8 | 355 } // namespace v8 |
| 358 | 356 |
| 359 #endif // V8_COMPILER_CONTROL_EQUIVALENCE_H_ | 357 #endif // V8_COMPILER_CONTROL_EQUIVALENCE_H_ |
| OLD | NEW |