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/node-properties.h" | 7 #include "src/compiler/node-properties.h" |
8 #include "src/compiler/operator-properties.h" | 8 #include "src/compiler/operator-properties.h" |
9 | 9 |
10 namespace v8 { | 10 namespace v8 { |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 | 162 |
163 void NodeProperties::MergeControlToEnd(Graph* graph, | 163 void NodeProperties::MergeControlToEnd(Graph* graph, |
164 CommonOperatorBuilder* common, | 164 CommonOperatorBuilder* common, |
165 Node* node) { | 165 Node* node) { |
166 graph->end()->AppendInput(graph->zone(), node); | 166 graph->end()->AppendInput(graph->zone(), node); |
167 graph->end()->set_op(common->End(graph->end()->InputCount())); | 167 graph->end()->set_op(common->End(graph->end()->InputCount())); |
168 } | 168 } |
169 | 169 |
170 | 170 |
171 // static | 171 // static |
172 void NodeProperties::ReplaceWithValue(Node* node, Node* value, Node* effect, | 172 void NodeProperties::ReplaceUses(Node* node, Node* value, Node* effect, |
173 Node* control) { | 173 Node* success, Node* exception) { |
174 if (!effect && node->op()->EffectInputCount() > 0) { | |
175 effect = NodeProperties::GetEffectInput(node); | |
176 } | |
177 if (control == nullptr && node->op()->ControlInputCount() > 0) { | |
178 control = NodeProperties::GetControlInput(node); | |
179 } | |
180 | |
181 // Requires distinguishing between value, effect and control edges. | 174 // Requires distinguishing between value, effect and control edges. |
182 for (Edge edge : node->use_edges()) { | 175 for (Edge edge : node->use_edges()) { |
183 if (IsControlEdge(edge)) { | 176 if (IsControlEdge(edge)) { |
184 DCHECK_EQ(IrOpcode::kIfSuccess, edge.from()->opcode()); | 177 if (edge.from()->opcode() == IrOpcode::kIfSuccess) { |
185 DCHECK_NOT_NULL(control); | 178 DCHECK_NOT_NULL(success); |
186 edge.from()->ReplaceUses(control); | 179 edge.UpdateTo(success); |
187 edge.UpdateTo(NULL); | 180 } else if (edge.from()->opcode() == IrOpcode::kIfException) { |
| 181 DCHECK_NOT_NULL(exception); |
| 182 edge.UpdateTo(exception); |
| 183 } else { |
| 184 UNREACHABLE(); |
| 185 } |
188 } else if (IsEffectEdge(edge)) { | 186 } else if (IsEffectEdge(edge)) { |
189 DCHECK_NOT_NULL(effect); | 187 DCHECK_NOT_NULL(effect); |
190 edge.UpdateTo(effect); | 188 edge.UpdateTo(effect); |
191 } else { | 189 } else { |
| 190 DCHECK_NOT_NULL(value); |
192 edge.UpdateTo(value); | 191 edge.UpdateTo(value); |
193 } | 192 } |
194 } | 193 } |
195 } | 194 } |
196 | 195 |
197 | 196 |
198 // static | 197 // static |
199 Node* NodeProperties::FindProjection(Node* node, size_t projection_index) { | 198 Node* NodeProperties::FindProjection(Node* node, size_t projection_index) { |
200 for (auto use : node->uses()) { | 199 for (auto use : node->uses()) { |
201 if (use->opcode() == IrOpcode::kProjection && | 200 if (use->opcode() == IrOpcode::kProjection && |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 // static | 270 // static |
272 bool NodeProperties::IsInputRange(Edge edge, int first, int num) { | 271 bool NodeProperties::IsInputRange(Edge edge, int first, int num) { |
273 if (num == 0) return false; | 272 if (num == 0) return false; |
274 int const index = edge.index(); | 273 int const index = edge.index(); |
275 return first <= index && index < first + num; | 274 return first <= index && index < first + num; |
276 } | 275 } |
277 | 276 |
278 } // namespace compiler | 277 } // namespace compiler |
279 } // namespace internal | 278 } // namespace internal |
280 } // namespace v8 | 279 } // namespace v8 |
OLD | NEW |