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

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

Issue 1212663004: dart2js cps: Fix a couple of minor issues. (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
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 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 isEffectivelyConstant(node.value); 300 isEffectivelyConstant(node.value);
301 } 301 }
302 302
303 Statement visitExpressionStatement(ExpressionStatement stmt) { 303 Statement visitExpressionStatement(ExpressionStatement stmt) {
304 if (isEffectivelyConstantAssignment(stmt.expression) && 304 if (isEffectivelyConstantAssignment(stmt.expression) &&
305 !usesRecentlyAssignedVariable(stmt.expression)) { 305 !usesRecentlyAssignedVariable(stmt.expression)) {
306 Assign assign = stmt.expression; 306 Assign assign = stmt.expression;
307 // Handle constant assignments specially. 307 // Handle constant assignments specially.
308 // They are always safe to propagate (though we should avoid duplication). 308 // They are always safe to propagate (though we should avoid duplication).
309 // Moreover, they should not prevent other expressions from propagating. 309 // Moreover, they should not prevent other expressions from propagating.
310 if (assign.variable.readCount <= 1) { 310 if (assign.variable.readCount == 1) {
asgerf 2015/06/29 14:09:12 This matters when there is a dead variable due to
311 // A single-use constant should always be propagted to its use site. 311 // A single-use constant should always be propagted to its use site.
312 constantEnvironment[assign.variable] = assign.value; 312 constantEnvironment[assign.variable] = assign.value;
313 --assign.variable.writeCount; 313 --assign.variable.writeCount;
314 return visitStatement(stmt.next); 314 return visitStatement(stmt.next);
315 } else { 315 } else {
316 // With more than one use, we cannot propagate the constant. 316 // With more than one use, we cannot propagate the constant.
317 // Visit the following statement without polluting [environment] so 317 // Visit the following statement without polluting [environment] so
318 // that any preceding non-constant assignments might still propagate. 318 // that any preceding non-constant assignments might still propagate.
319 stmt.next = visitStatement(stmt.next); 319 stmt.next = visitStatement(stmt.next);
320 assign.value = visitExpression(assign.value); 320 assign.value = visitExpression(assign.value);
(...skipping 718 matching lines...) Expand 10 before | Expand all | Expand 10 after
1039 IsVariableUsedVisitor(this.variable); 1039 IsVariableUsedVisitor(this.variable);
1040 1040
1041 visitVariableUse(VariableUse node) { 1041 visitVariableUse(VariableUse node) {
1042 if (node.variable == variable) { 1042 if (node.variable == variable) {
1043 wasFound = true; 1043 wasFound = true;
1044 } 1044 }
1045 } 1045 }
1046 1046
1047 visitInnerFunction(FunctionDefinition node) {} 1047 visitInnerFunction(FunctionDefinition node) {}
1048 } 1048 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698