Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: src/compiler/control-reducer.cc

Issue 828823006: [turbofan] Fix control reducer for degenerate cases of self-loop branches. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-447526.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "src/compiler/common-operator.h" 5 #include "src/compiler/common-operator.h"
6 #include "src/compiler/control-reducer.h" 6 #include "src/compiler/control-reducer.h"
7 #include "src/compiler/graph.h" 7 #include "src/compiler/graph.h"
8 #include "src/compiler/js-graph.h" 8 #include "src/compiler/js-graph.h"
9 #include "src/compiler/node-marker.h" 9 #include "src/compiler/node-marker.h"
10 #include "src/compiler/node-matchers.h" 10 #include "src/compiler/node-matchers.h"
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 void ReduceTop() { 275 void ReduceTop() {
276 size_t height = stack_.size(); 276 size_t height = stack_.size();
277 Node* node = stack_.back(); 277 Node* node = stack_.back();
278 278
279 if (node->IsDead()) return Pop(); // Node was killed while on stack. 279 if (node->IsDead()) return Pop(); // Node was killed while on stack.
280 280
281 TRACE(("ControlReduce: #%d:%s\n", node->id(), node->op()->mnemonic())); 281 TRACE(("ControlReduce: #%d:%s\n", node->id(), node->op()->mnemonic()));
282 282
283 // Recurse on an input if necessary. 283 // Recurse on an input if necessary.
284 for (Node* const input : node->inputs()) { 284 for (Node* const input : node->inputs()) {
285 CHECK_NE(NULL, input);
285 if (Recurse(input)) return; 286 if (Recurse(input)) return;
286 } 287 }
287 288
288 // All inputs should be visited or on stack. Apply reductions to node. 289 // All inputs should be visited or on stack. Apply reductions to node.
289 Node* replacement = ReduceNode(node); 290 Node* replacement = ReduceNode(node);
290 if (replacement != node) ReplaceNode(node, replacement); 291 if (replacement != node) ReplaceNode(node, replacement);
291 292
292 // After reducing the node, pop it off the stack. 293 // After reducing the node, pop it off the stack.
293 CHECK_EQ(static_cast<int>(height), static_cast<int>(stack_.size())); 294 CHECK_EQ(static_cast<int>(height), static_cast<int>(stack_.size()));
294 Pop(); 295 Pop();
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 (result == kTrue) ? "true" : "false")); 490 (result == kTrue) ? "true" : "false"));
490 491
491 // Replace IfTrue and IfFalse projections from this branch. 492 // Replace IfTrue and IfFalse projections from this branch.
492 Node* control = NodeProperties::GetControlInput(node); 493 Node* control = NodeProperties::GetControlInput(node);
493 for (Edge edge : node->use_edges()) { 494 for (Edge edge : node->use_edges()) {
494 Node* use = edge.from(); 495 Node* use = edge.from();
495 if (use->opcode() == IrOpcode::kIfTrue) { 496 if (use->opcode() == IrOpcode::kIfTrue) {
496 TRACE((" IfTrue: #%d:%s\n", use->id(), use->op()->mnemonic())); 497 TRACE((" IfTrue: #%d:%s\n", use->id(), use->op()->mnemonic()));
497 edge.UpdateTo(NULL); 498 edge.UpdateTo(NULL);
498 ReplaceNode(use, (result == kTrue) ? control : dead()); 499 ReplaceNode(use, (result == kTrue) ? control : dead());
500 control = NodeProperties::GetControlInput(node); // Could change!
499 } else if (use->opcode() == IrOpcode::kIfFalse) { 501 } else if (use->opcode() == IrOpcode::kIfFalse) {
500 TRACE((" IfFalse: #%d:%s\n", use->id(), use->op()->mnemonic())); 502 TRACE((" IfFalse: #%d:%s\n", use->id(), use->op()->mnemonic()));
501 edge.UpdateTo(NULL); 503 edge.UpdateTo(NULL);
502 ReplaceNode(use, (result == kTrue) ? dead() : control); 504 ReplaceNode(use, (result == kTrue) ? dead() : control);
505 control = NodeProperties::GetControlInput(node); // Could change!
503 } 506 }
504 } 507 }
505 return control; 508 return control;
506 } 509 }
507 510
508 // Remove inputs to {node} corresponding to the dead inputs to {merge} 511 // Remove inputs to {node} corresponding to the dead inputs to {merge}
509 // and compact the remaining inputs, updating the operator. 512 // and compact the remaining inputs, updating the operator.
510 void RemoveDeadInputs(Node* merge, Node* node) { 513 void RemoveDeadInputs(Node* merge, Node* node) {
511 int pos = 0; 514 int pos = 0;
512 for (int i = 0; i < node->InputCount(); i++) { 515 for (int i = 0; i < node->InputCount(); i++) {
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 Node* ControlReducer::ReduceBranchForTesting(JSGraph* jsgraph, 587 Node* ControlReducer::ReduceBranchForTesting(JSGraph* jsgraph,
585 CommonOperatorBuilder* common, 588 CommonOperatorBuilder* common,
586 Node* node) { 589 Node* node) {
587 Zone zone(jsgraph->graph()->zone()->isolate()); 590 Zone zone(jsgraph->graph()->zone()->isolate());
588 ControlReducerImpl impl(&zone, jsgraph, common); 591 ControlReducerImpl impl(&zone, jsgraph, common);
589 return impl.ReduceBranch(node); 592 return impl.ReduceBranch(node);
590 } 593 }
591 } 594 }
592 } 595 }
593 } // namespace v8::internal::compiler 596 } // namespace v8::internal::compiler
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-447526.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698