OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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 #include "src/compiler/common-operator.h" | 5 #include "src/compiler/common-operator.h" |
6 #include "src/compiler/graph.h" | 6 #include "src/compiler/graph.h" |
7 #include "src/compiler/loop-peeling.h" | 7 #include "src/compiler/loop-peeling.h" |
8 #include "src/compiler/node.h" | 8 #include "src/compiler/node.h" |
9 #include "src/compiler/node-marker.h" | 9 #include "src/compiler/node-marker.h" |
10 #include "src/compiler/node-properties.h" | 10 #include "src/compiler/node-properties.h" |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 peeling.map(node), merge); | 322 peeling.map(node), merge); |
323 for (Edge edge : effect_edges) edge.UpdateTo(effect_phi); | 323 for (Edge edge : effect_edges) edge.UpdateTo(effect_phi); |
324 effect_edges.clear(); | 324 effect_edges.clear(); |
325 } | 325 } |
326 } | 326 } |
327 } | 327 } |
328 | 328 |
329 return iter; | 329 return iter; |
330 } | 330 } |
331 | 331 |
| 332 namespace { |
| 333 |
| 334 void EliminateLoopExit(Node* node) { |
| 335 DCHECK_EQ(IrOpcode::kLoopExit, node->opcode()); |
| 336 // The exit markers take the loop exit as input. We iterate over uses |
| 337 // and remove all the markers from the graph. |
| 338 for (Edge edge : node->use_edges()) { |
| 339 if (NodeProperties::IsControlEdge(edge)) { |
| 340 Node* marker = edge.from(); |
| 341 if (marker->opcode() == IrOpcode::kLoopExitValue) { |
| 342 NodeProperties::ReplaceUses(marker, marker->InputAt(0)); |
| 343 marker->Kill(); |
| 344 } else if (marker->opcode() == IrOpcode::kLoopExitEffect) { |
| 345 NodeProperties::ReplaceUses(marker, nullptr, |
| 346 NodeProperties::GetEffectInput(marker)); |
| 347 marker->Kill(); |
| 348 } |
| 349 } |
| 350 } |
| 351 NodeProperties::ReplaceUses(node, nullptr, nullptr, |
| 352 NodeProperties::GetControlInput(node, 0)); |
| 353 node->Kill(); |
| 354 } |
| 355 |
| 356 } // namespace |
| 357 |
| 358 // static |
| 359 void LoopPeeler::EliminateLoopExits(Graph* graph, Zone* temp_zone) { |
| 360 ZoneQueue<Node*> queue(temp_zone); |
| 361 ZoneVector<bool> visited(graph->NodeCount(), false, temp_zone); |
| 362 queue.push(graph->end()); |
| 363 while (!queue.empty()) { |
| 364 Node* node = queue.front(); |
| 365 queue.pop(); |
| 366 |
| 367 if (node->opcode() == IrOpcode::kLoopExit) { |
| 368 Node* control = NodeProperties::GetControlInput(node); |
| 369 EliminateLoopExit(node); |
| 370 if (!visited[control->id()]) { |
| 371 visited[control->id()] = true; |
| 372 queue.push(control); |
| 373 } |
| 374 } else { |
| 375 for (int i = 0; i < node->op()->ControlInputCount(); i++) { |
| 376 Node* control = NodeProperties::GetControlInput(node, i); |
| 377 if (!visited[control->id()]) { |
| 378 visited[control->id()] = true; |
| 379 queue.push(control); |
| 380 } |
| 381 } |
| 382 } |
| 383 } |
| 384 } |
| 385 |
332 } // namespace compiler | 386 } // namespace compiler |
333 } // namespace internal | 387 } // namespace internal |
334 } // namespace v8 | 388 } // namespace v8 |
OLD | NEW |