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

Side by Side Diff: pkg/compiler/lib/src/tree_ir/optimization/statement_rewriter.dart

Issue 1226353003: dart2js cps: Bugfix in assignment propagation into branch conditions. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 5 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 | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library tree_ir.optimization.statement_rewriter; 5 library tree_ir.optimization.statement_rewriter;
6 6
7 import 'optimization.dart' show Pass; 7 import 'optimization.dart' show Pass;
8 import '../tree_ir_nodes.dart'; 8 import '../tree_ir_nodes.dart';
9 9
10 /** 10 /**
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 // Do not propagate assignments into the successor statements, since they 577 // Do not propagate assignments into the successor statements, since they
578 // may be overwritten by assignments in the body. 578 // may be overwritten by assignments in the body.
579 inEmptyEnvironment(() { 579 inEmptyEnvironment(() {
580 node.next = visitStatement(node.next); 580 node.next = visitStatement(node.next);
581 }); 581 });
582 582
583 return node; 583 return node;
584 } 584 }
585 585
586 Statement visitIf(If node) { 586 Statement visitIf(If node) {
587 node.condition = visitExpression(node.condition); 587 // Do not propagate assignments into branches.
588
589 // Do not propagate assignments into branches. Doing so will lead to code
590 // duplication.
591 // TODO(kmillikin): Rethink this. Propagating some assignments
592 // (e.g. variables) is benign. If they can occur here, they should
593 // be handled well.
asgerf 2015/07/09 11:19:01 This comment was just outdated. It's not really re
594 inEmptyEnvironment(() { 588 inEmptyEnvironment(() {
595 node.thenStatement = visitStatement(node.thenStatement); 589 node.thenStatement = visitStatement(node.thenStatement);
596 node.elseStatement = visitStatement(node.elseStatement); 590 node.elseStatement = visitStatement(node.elseStatement);
591 });
597 592
593 node.condition = visitExpression(node.condition);
594
595 inEmptyEnvironment(() {
598 tryCollapseIf(node); 596 tryCollapseIf(node);
599 }); 597 });
600 598
601 Statement reduced = combineStatementsInBranches( 599 Statement reduced = combineStatementsInBranches(
602 node.thenStatement, 600 node.thenStatement,
603 node.elseStatement, 601 node.elseStatement,
604 node.condition); 602 node.condition);
605 if (reduced != null) { 603 if (reduced != null) {
606 return reduced; 604 return reduced;
607 } 605 }
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after
1162 VariableUseVisitor(this.callback); 1160 VariableUseVisitor(this.callback);
1163 1161
1164 visitVariableUse(VariableUse use) => callback(use); 1162 visitVariableUse(VariableUse use) => callback(use);
1165 1163
1166 visitInnerFunction(FunctionDefinition node) {} 1164 visitInnerFunction(FunctionDefinition node) {}
1167 1165
1168 static void visit(Expression node, VariableUseCallback callback) { 1166 static void visit(Expression node, VariableUseCallback callback) {
1169 new VariableUseVisitor(callback).visitExpression(node); 1167 new VariableUseVisitor(callback).visitExpression(node);
1170 } 1168 }
1171 } 1169 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698