| 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 #include "src/compiler/verifier.h" | 12 #include "src/compiler/verifier.h" |
| 13 | 13 |
| 14 namespace v8 { | 14 namespace v8 { |
| 15 namespace internal { | 15 namespace internal { |
| 16 namespace compiler { | 16 namespace compiler { |
| 17 | 17 |
| 18 enum class GraphReducer::State : uint8_t { | 18 enum class GraphReducer::State : uint8_t { |
| 19 kUnvisited, | 19 kUnvisited, |
| 20 kRevisit, | 20 kRevisit, |
| 21 kOnStack, | 21 kOnStack, |
| 22 kVisited | 22 kVisited |
| 23 }; | 23 }; |
| 24 | 24 |
| 25 | 25 |
| 26 void Reducer::Finalize() {} | 26 void Reducer::Finalize() {} |
| 27 | 27 |
| 28 | |
| 29 GraphReducer::GraphReducer(Zone* zone, Graph* graph, Node* dead) | 28 GraphReducer::GraphReducer(Zone* zone, Graph* graph, Node* dead) |
| 30 : graph_(graph), | 29 : graph_(graph), |
| 31 dead_(dead), | 30 dead_(dead), |
| 32 state_(graph, 4), | 31 state_(graph, 4), |
| 33 reducers_(zone), | 32 reducers_(zone), |
| 34 revisit_(zone), | 33 revisit_(zone), |
| 35 stack_(zone) {} | 34 stack_(zone) { |
| 36 | 35 if (dead != nullptr) { |
| 36 NodeProperties::SetType(dead_, Type::None()); |
| 37 } |
| 38 } |
| 37 | 39 |
| 38 GraphReducer::~GraphReducer() {} | 40 GraphReducer::~GraphReducer() {} |
| 39 | 41 |
| 40 | 42 |
| 41 void GraphReducer::AddReducer(Reducer* reducer) { | 43 void GraphReducer::AddReducer(Reducer* reducer) { |
| 42 reducers_.push_back(reducer); | 44 reducers_.push_back(reducer); |
| 43 } | 45 } |
| 44 | 46 |
| 45 | 47 |
| 46 void GraphReducer::ReduceNode(Node* node) { | 48 void GraphReducer::ReduceNode(Node* node) { |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 void GraphReducer::Revisit(Node* node) { | 286 void GraphReducer::Revisit(Node* node) { |
| 285 if (state_.Get(node) == State::kVisited) { | 287 if (state_.Get(node) == State::kVisited) { |
| 286 state_.Set(node, State::kRevisit); | 288 state_.Set(node, State::kRevisit); |
| 287 revisit_.push(node); | 289 revisit_.push(node); |
| 288 } | 290 } |
| 289 } | 291 } |
| 290 | 292 |
| 291 } // namespace compiler | 293 } // namespace compiler |
| 292 } // namespace internal | 294 } // namespace internal |
| 293 } // namespace v8 | 295 } // namespace v8 |
| OLD | NEW |