diff options
Diffstat (limited to 'deps/v8/src/compiler/graph-reducer.cc')
-rw-r--r-- | deps/v8/src/compiler/graph-reducer.cc | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/deps/v8/src/compiler/graph-reducer.cc b/deps/v8/src/compiler/graph-reducer.cc index f062d4bea9..07e8923b18 100644 --- a/deps/v8/src/compiler/graph-reducer.cc +++ b/deps/v8/src/compiler/graph-reducer.cc @@ -13,7 +13,7 @@ namespace internal { namespace compiler { GraphReducer::GraphReducer(Graph* graph) - : graph_(graph), reducers_(Reducers::allocator_type(graph->zone())) {} + : graph_(graph), reducers_(graph->zone()) {} static bool NodeIdIsLessThan(const Node* node, NodeId id) { @@ -22,25 +22,23 @@ static bool NodeIdIsLessThan(const Node* node, NodeId id) { void GraphReducer::ReduceNode(Node* node) { - Reducers::iterator skip = reducers_.end(); static const unsigned kMaxAttempts = 16; bool reduce = true; for (unsigned attempts = 0; attempts <= kMaxAttempts; ++attempts) { if (!reduce) return; reduce = false; // Assume we don't need to rerun any reducers. int before = graph_->NodeCount(); - for (Reducers::iterator i = reducers_.begin(); i != reducers_.end(); ++i) { - if (i == skip) continue; // Skip this reducer. + for (ZoneVector<Reducer*>::iterator i = reducers_.begin(); + i != reducers_.end(); ++i) { Reduction reduction = (*i)->Reduce(node); Node* replacement = reduction.replacement(); if (replacement == NULL) { // No change from this reducer. } else if (replacement == node) { // {replacement == node} represents an in-place reduction. - // Rerun all the reducers except the current one for this node, - // as now there may be more opportunities for reduction. + // Rerun all the reducers for this node, as now there may be more + // opportunities for reduction. reduce = true; - skip = i; break; } else { if (node == graph_->start()) graph_->SetStart(replacement); @@ -48,8 +46,8 @@ void GraphReducer::ReduceNode(Node* node) { // If {node} was replaced by an old node, unlink {node} and assume that // {replacement} was already reduced and finish. if (replacement->id() < before) { - node->RemoveAllInputs(); node->ReplaceUses(replacement); + node->Kill(); return; } // Otherwise, {node} was replaced by a new node. Replace all old uses of @@ -58,9 +56,10 @@ void GraphReducer::ReduceNode(Node* node) { node->ReplaceUsesIf( std::bind2nd(std::ptr_fun(&NodeIdIsLessThan), before), replacement); // Unlink {node} if it's no longer used. - if (node->uses().empty()) node->RemoveAllInputs(); + if (node->uses().empty()) { + node->Kill(); + } // Rerun all the reductions on the {replacement}. - skip = reducers_.end(); node = replacement; reduce = true; break; @@ -71,7 +70,7 @@ void GraphReducer::ReduceNode(Node* node) { // A helper class to reuse the node traversal algorithm. -struct GraphReducerVisitor V8_FINAL : public NullNodeVisitor { +struct GraphReducerVisitor FINAL : public NullNodeVisitor { explicit GraphReducerVisitor(GraphReducer* reducer) : reducer_(reducer) {} GenericGraphVisit::Control Post(Node* node) { reducer_->ReduceNode(node); @@ -89,6 +88,7 @@ void GraphReducer::ReduceGraph() { // TODO(titzer): partial graph reductions. -} -} -} // namespace v8::internal::compiler + +} // namespace compiler +} // namespace internal +} // namespace v8 |