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 <functional> | 5 #include <functional> |
6 #include <limits> | 6 #include <limits> |
7 | 7 |
8 #include "src/compiler/graph.h" | 8 #include "src/compiler/graph.h" |
9 #include "src/compiler/graph-reducer.h" | 9 #include "src/compiler/graph-reducer.h" |
10 #include "src/compiler/node.h" | 10 #include "src/compiler/node.h" |
11 #include "src/compiler/node-properties.h" | 11 #include "src/compiler/node-properties.h" |
12 | 12 |
13 namespace v8 { | 13 namespace v8 { |
14 namespace internal { | 14 namespace internal { |
15 namespace compiler { | 15 namespace compiler { |
16 | 16 |
17 enum class GraphReducer::State : uint8_t { | 17 enum class GraphReducer::State : uint8_t { |
18 kUnvisited, | 18 kUnvisited, |
19 kRevisit, | 19 kRevisit, |
20 kOnStack, | 20 kOnStack, |
21 kVisited | 21 kVisited |
22 }; | 22 }; |
23 | 23 |
24 | 24 |
25 GraphReducer::GraphReducer(Zone* zone, Graph* graph, Node* dead_value, | 25 GraphReducer::GraphReducer(Zone* zone, Graph* graph, Node* dead) |
26 Node* dead_control) | |
27 : graph_(graph), | 26 : graph_(graph), |
28 dead_value_(dead_value), | 27 dead_(dead), |
29 dead_control_(dead_control), | |
30 state_(graph, 4), | 28 state_(graph, 4), |
31 reducers_(zone), | 29 reducers_(zone), |
32 revisit_(zone), | 30 revisit_(zone), |
33 stack_(zone) {} | 31 stack_(zone) {} |
34 | 32 |
35 | 33 |
36 GraphReducer::~GraphReducer() {} | 34 GraphReducer::~GraphReducer() {} |
37 | 35 |
38 | 36 |
39 void GraphReducer::AddReducer(Reducer* reducer) { | 37 void GraphReducer::AddReducer(Reducer* reducer) { |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 Node* control) { | 196 Node* control) { |
199 if (effect == nullptr && node->op()->EffectInputCount() > 0) { | 197 if (effect == nullptr && node->op()->EffectInputCount() > 0) { |
200 effect = NodeProperties::GetEffectInput(node); | 198 effect = NodeProperties::GetEffectInput(node); |
201 } | 199 } |
202 if (control == nullptr && node->op()->ControlInputCount() > 0) { | 200 if (control == nullptr && node->op()->ControlInputCount() > 0) { |
203 control = NodeProperties::GetControlInput(node); | 201 control = NodeProperties::GetControlInput(node); |
204 } | 202 } |
205 | 203 |
206 // Requires distinguishing between value, effect and control edges. | 204 // Requires distinguishing between value, effect and control edges. |
207 for (Edge edge : node->use_edges()) { | 205 for (Edge edge : node->use_edges()) { |
208 Node* user = edge.from(); | 206 Node* const user = edge.from(); |
| 207 DCHECK(!user->IsDead()); |
209 if (NodeProperties::IsControlEdge(edge)) { | 208 if (NodeProperties::IsControlEdge(edge)) { |
210 if (user->opcode() == IrOpcode::kIfSuccess) { | 209 if (user->opcode() == IrOpcode::kIfSuccess) { |
211 Replace(user, control); | 210 Replace(user, control); |
212 } else if (user->opcode() == IrOpcode::kIfException) { | 211 } else if (user->opcode() == IrOpcode::kIfException) { |
213 for (Edge e : user->use_edges()) { | 212 DCHECK_NOT_NULL(dead_); |
214 if (NodeProperties::IsValueEdge(e)) e.UpdateTo(dead_value_); | 213 edge.UpdateTo(dead_); |
215 if (NodeProperties::IsEffectEdge(e)) e.UpdateTo(graph()->start()); | 214 Revisit(user); |
216 if (NodeProperties::IsControlEdge(e)) e.UpdateTo(dead_control_); | |
217 } | |
218 edge.UpdateTo(user); | |
219 } else { | 215 } else { |
220 UNREACHABLE(); | 216 UNREACHABLE(); |
221 } | 217 } |
222 } else if (NodeProperties::IsEffectEdge(edge)) { | 218 } else if (NodeProperties::IsEffectEdge(edge)) { |
223 DCHECK_NOT_NULL(effect); | 219 DCHECK_NOT_NULL(effect); |
224 edge.UpdateTo(effect); | 220 edge.UpdateTo(effect); |
225 Revisit(user); | 221 Revisit(user); |
226 } else { | 222 } else { |
227 DCHECK_NOT_NULL(value); | 223 DCHECK_NOT_NULL(value); |
228 edge.UpdateTo(value); | 224 edge.UpdateTo(value); |
(...skipping 27 matching lines...) Expand all Loading... |
256 void GraphReducer::Revisit(Node* node) { | 252 void GraphReducer::Revisit(Node* node) { |
257 if (state_.Get(node) == State::kVisited) { | 253 if (state_.Get(node) == State::kVisited) { |
258 state_.Set(node, State::kRevisit); | 254 state_.Set(node, State::kRevisit); |
259 revisit_.push(node); | 255 revisit_.push(node); |
260 } | 256 } |
261 } | 257 } |
262 | 258 |
263 } // namespace compiler | 259 } // namespace compiler |
264 } // namespace internal | 260 } // namespace internal |
265 } // namespace v8 | 261 } // namespace v8 |
OLD | NEW |