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 #include "src/compiler/common-operator.h" | 5 #include "src/compiler/common-operator.h" |
6 #include "src/compiler/control-reducer.h" | 6 #include "src/compiler/control-reducer.h" |
7 #include "src/compiler/graph.h" | 7 #include "src/compiler/graph.h" |
8 #include "src/compiler/graph-reducer.h" | 8 #include "src/compiler/graph-reducer.h" |
9 #include "src/compiler/js-graph.h" | 9 #include "src/compiler/js-graph.h" |
10 #include "src/compiler/node-marker.h" | 10 #include "src/compiler/node-marker.h" |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 typedef std::pair<Node*, Node::UseEdges::iterator> FwIter; | 83 typedef std::pair<Node*, Node::UseEdges::iterator> FwIter; |
84 ZoneVector<FwIter> fw_stack(zone_); | 84 ZoneVector<FwIter> fw_stack(zone_); |
85 fw_stack.push_back(FwIter(start, start->use_edges().begin())); | 85 fw_stack.push_back(FwIter(start, start->use_edges().begin())); |
86 | 86 |
87 while (!fw_stack.empty()) { | 87 while (!fw_stack.empty()) { |
88 Node* node = fw_stack.back().first; | 88 Node* node = fw_stack.back().first; |
89 TRACE("ControlFw: #%d:%s\n", node->id(), node->op()->mnemonic()); | 89 TRACE("ControlFw: #%d:%s\n", node->id(), node->op()->mnemonic()); |
90 bool pop = true; | 90 bool pop = true; |
91 while (fw_stack.back().second != node->use_edges().end()) { | 91 while (fw_stack.back().second != node->use_edges().end()) { |
92 Edge edge = *(fw_stack.back().second); | 92 Edge edge = *(fw_stack.back().second); |
| 93 Node* succ = edge.from(); |
93 if (NodeProperties::IsControlEdge(edge) && | 94 if (NodeProperties::IsControlEdge(edge) && |
94 edge.from()->op()->ControlOutputCount() > 0) { | 95 succ->op()->ControlOutputCount() > 0) { |
95 // Only walk control edges to control nodes. | 96 // Only walk control edges to control nodes. |
96 Node* succ = edge.from(); | |
97 | |
98 if (marked.IsOnStack(succ) && !marked.IsReachableFromEnd(succ)) { | 97 if (marked.IsOnStack(succ) && !marked.IsReachableFromEnd(succ)) { |
99 // {succ} is on stack and not reachable from end. | 98 // {succ} is on stack and not reachable from end. |
100 Node* added = ConnectNTL(succ); | 99 Node* added = ConnectNTL(succ); |
101 nodes.push_back(added); | 100 nodes.push_back(added); |
102 marked.SetReachableFromEnd(added); | 101 marked.SetReachableFromEnd(added); |
103 AddBackwardsReachableNodes(marked, nodes, nodes.size() - 1); | 102 AddBackwardsReachableNodes(marked, nodes, nodes.size() - 1); |
104 | 103 |
105 // Reset the use iterators for the entire stack. | 104 // Reset the use iterators for the entire stack. |
106 for (size_t i = 0; i < fw_stack.size(); i++) { | 105 for (size_t i = 0; i < fw_stack.size(); i++) { |
107 FwIter& iter = fw_stack[i]; | 106 FwIter& iter = fw_stack[i]; |
108 fw_stack[i] = FwIter(iter.first, iter.first->use_edges().begin()); | 107 fw_stack[i] = FwIter(iter.first, iter.first->use_edges().begin()); |
109 } | 108 } |
110 pop = false; // restart traversing successors of this node. | 109 pop = false; // restart traversing successors of this node. |
111 break; | 110 break; |
112 } | 111 } |
113 if (!marked.IsReachableFromStart(succ)) { | 112 if (!marked.IsReachableFromStart(succ)) { |
114 // {succ} is not yet reached from start. | 113 // {succ} is not yet reached from start. |
115 marked.Push(succ); | |
116 marked.SetReachableFromStart(succ); | 114 marked.SetReachableFromStart(succ); |
117 fw_stack.push_back(FwIter(succ, succ->use_edges().begin())); | 115 if (succ->opcode() != IrOpcode::kOsrLoopEntry) { |
118 pop = false; // "recurse" into successor control node. | 116 // Skip OsrLoopEntry; forms a confusing irredducible loop. |
119 break; | 117 marked.Push(succ); |
| 118 fw_stack.push_back(FwIter(succ, succ->use_edges().begin())); |
| 119 pop = false; // "recurse" into successor control node. |
| 120 break; |
| 121 } |
120 } | 122 } |
121 } | 123 } |
122 ++fw_stack.back().second; | 124 ++fw_stack.back().second; |
123 } | 125 } |
124 if (pop) { | 126 if (pop) { |
125 marked.Pop(node); | 127 marked.Pop(node); |
126 fw_stack.pop_back(); | 128 fw_stack.pop_back(); |
127 } | 129 } |
128 } | 130 } |
129 | 131 |
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
592 case IrOpcode::kIfFalse: | 594 case IrOpcode::kIfFalse: |
593 return impl.ReduceIfProjection(node, kFalse); | 595 return impl.ReduceIfProjection(node, kFalse); |
594 default: | 596 default: |
595 return node; | 597 return node; |
596 } | 598 } |
597 } | 599 } |
598 | 600 |
599 } // namespace compiler | 601 } // namespace compiler |
600 } // namespace internal | 602 } // namespace internal |
601 } // namespace v8 | 603 } // namespace v8 |
OLD | NEW |