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