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

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

Issue 1222673002: dart2js cps: Fix bug in assignment propagation. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Rebase 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 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 Assign assign = stmt.expression; 370 Assign assign = stmt.expression;
371 // Handle constant assignments specially. 371 // Handle constant assignments specially.
372 // They are always safe to propagate (though we should avoid duplication). 372 // They are always safe to propagate (though we should avoid duplication).
373 // Moreover, they should not prevent other expressions from propagating. 373 // Moreover, they should not prevent other expressions from propagating.
374 if (assign.variable.readCount == 1) { 374 if (assign.variable.readCount == 1) {
375 // A single-use constant should always be propagated to its use site. 375 // A single-use constant should always be propagated to its use site.
376 constantEnvironment[assign.variable] = assign.value; 376 constantEnvironment[assign.variable] = assign.value;
377 Statement next = visitStatement(stmt.next); 377 Statement next = visitStatement(stmt.next);
378 popDominatingAssignment(leftHand); 378 popDominatingAssignment(leftHand);
379 if (assign.variable.readCount > 0) { 379 if (assign.variable.readCount > 0) {
380 // The assignment could not be propagated. 380 // The assignment could not be propagated into the successor, either
381 // because it has an unsafe variable use (see [hasUnsafeVariableUse])
382 // or because the use is outside the current try block, and we do
383 // not currently support constant propagation out of a try block.
384 constantEnvironment.remove(assign.variable);
381 assign.value = visitExpression(assign.value); 385 assign.value = visitExpression(assign.value);
382 stmt.next = next; 386 stmt.next = next;
383 return stmt; 387 return stmt;
384 } else { 388 } else {
385 --assign.variable.writeCount; 389 --assign.variable.writeCount;
386 return next; 390 return next;
387 } 391 }
388 } else { 392 } else {
389 // With more than one use, we cannot propagate the constant. 393 // With more than one use, we cannot propagate the constant.
390 // Visit the following statement without polluting [environment] so 394 // Visit the following statement without polluting [environment] so
(...skipping 748 matching lines...) Expand 10 before | Expand all | Expand 10 after
1139 VariableUseVisitor(this.callback); 1143 VariableUseVisitor(this.callback);
1140 1144
1141 visitVariableUse(VariableUse use) => callback(use); 1145 visitVariableUse(VariableUse use) => callback(use);
1142 1146
1143 visitInnerFunction(FunctionDefinition node) {} 1147 visitInnerFunction(FunctionDefinition node) {}
1144 1148
1145 static void visit(Expression node, VariableUseCallback callback) { 1149 static void visit(Expression node, VariableUseCallback callback) {
1146 new VariableUseVisitor(callback).visitExpression(node); 1150 new VariableUseVisitor(callback).visitExpression(node);
1147 } 1151 }
1148 } 1152 }
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