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

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

Issue 1296403004: dart2js cps: Do not treat final field reads as effectively constant. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 4 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 | « pkg/compiler/lib/src/cps_ir/cps_ir_nodes.dart ('k') | 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 import '../../io/source_information.dart'; 9 import '../../io/source_information.dart';
10 10
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 /// Returns true if [exp] has no side effects and has a constant value within 348 /// Returns true if [exp] has no side effects and has a constant value within
349 /// any given activation of the enclosing method. 349 /// any given activation of the enclosing method.
350 bool isEffectivelyConstant(Expression exp) { 350 bool isEffectivelyConstant(Expression exp) {
351 // TODO(asgerf): Can be made more aggressive e.g. by checking conditional 351 // TODO(asgerf): Can be made more aggressive e.g. by checking conditional
352 // expressions recursively. Determine if that is a valuable optimization 352 // expressions recursively. Determine if that is a valuable optimization
353 // and/or if it is better handled at the CPS level. 353 // and/or if it is better handled at the CPS level.
354 return exp is Constant || 354 return exp is Constant ||
355 exp is This || 355 exp is This ||
356 exp is CreateInvocationMirror || 356 exp is CreateInvocationMirror ||
357 exp is GetStatic && exp.element.isFunction || 357 exp is GetStatic && exp.element.isFunction ||
358 exp is GetField && exp.objectIsNotNull && exp.field.isFinal ||
359 exp is Interceptor || 358 exp is Interceptor ||
360 exp is ApplyBuiltinOperator || 359 exp is ApplyBuiltinOperator ||
361 exp is VariableUse && constantEnvironment.containsKey(exp.variable); 360 exp is VariableUse && constantEnvironment.containsKey(exp.variable);
362 } 361 }
363 362
364 /// True if [node] is an assignment that can be propagated as a constant. 363 /// True if [node] is an assignment that can be propagated as a constant.
365 bool isEffectivelyConstantAssignment(Expression node) { 364 bool isEffectivelyConstantAssignment(Expression node) {
366 return node is Assign && 365 return node is Assign &&
367 node.variable.writeCount == 1 && 366 node.variable.writeCount == 1 &&
368 isEffectivelyConstant(node.value); 367 isEffectivelyConstant(node.value);
(...skipping 851 matching lines...) Expand 10 before | Expand all | Expand 10 after
1220 VariableUseVisitor(this.callback); 1219 VariableUseVisitor(this.callback);
1221 1220
1222 visitVariableUse(VariableUse use) => callback(use); 1221 visitVariableUse(VariableUse use) => callback(use);
1223 1222
1224 visitInnerFunction(FunctionDefinition node) {} 1223 visitInnerFunction(FunctionDefinition node) {}
1225 1224
1226 static void visit(Expression node, VariableUseCallback callback) { 1225 static void visit(Expression node, VariableUseCallback callback) {
1227 new VariableUseVisitor(callback).visitExpression(node); 1226 new VariableUseVisitor(callback).visitExpression(node);
1228 } 1227 }
1229 } 1228 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/cps_ir/cps_ir_nodes.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698