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

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

Issue 1218843003: dart2js cps: Cleanup. (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
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 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 343
344 /// Returns true if [exp] has no side effects and has a constant value within 344 /// Returns true if [exp] has no side effects and has a constant value within
345 /// any given activation of the enclosing method. 345 /// any given activation of the enclosing method.
346 bool isEffectivelyConstant(Expression exp) { 346 bool isEffectivelyConstant(Expression exp) {
347 // TODO(asgerf): Can be made more aggressive e.g. by checking conditional 347 // TODO(asgerf): Can be made more aggressive e.g. by checking conditional
348 // expressions recursively. Determine if that is a valuable optimization 348 // expressions recursively. Determine if that is a valuable optimization
349 // and/or if it is better handled at the CPS level. 349 // and/or if it is better handled at the CPS level.
350 return exp is Constant || 350 return exp is Constant ||
351 exp is This || 351 exp is This ||
352 exp is CreateInvocationMirror || 352 exp is CreateInvocationMirror ||
353 exp is InvokeStatic && exp.isEffectivelyConstant ||
354 exp is Interceptor || 353 exp is Interceptor ||
355 exp is ApplyBuiltinOperator || 354 exp is ApplyBuiltinOperator ||
356 exp is VariableUse && constantEnvironment.containsKey(exp.variable); 355 exp is VariableUse && constantEnvironment.containsKey(exp.variable);
357 } 356 }
358 357
359 /// True if [node] is an assignment that can be propagated as a constant. 358 /// True if [node] is an assignment that can be propagated as a constant.
360 bool isEffectivelyConstantAssignment(Expression node) { 359 bool isEffectivelyConstantAssignment(Expression node) {
361 return node is Assign && 360 return node is Assign &&
362 node.variable.writeCount == 1 && 361 node.variable.writeCount == 1 &&
363 isEffectivelyConstant(node.value); 362 isEffectivelyConstant(node.value);
(...skipping 776 matching lines...) Expand 10 before | Expand all | Expand 10 after
1140 VariableUseVisitor(this.callback); 1139 VariableUseVisitor(this.callback);
1141 1140
1142 visitVariableUse(VariableUse use) => callback(use); 1141 visitVariableUse(VariableUse use) => callback(use);
1143 1142
1144 visitInnerFunction(FunctionDefinition node) {} 1143 visitInnerFunction(FunctionDefinition node) {}
1145 1144
1146 static void visit(Expression node, VariableUseCallback callback) { 1145 static void visit(Expression node, VariableUseCallback callback) {
1147 new VariableUseVisitor(callback).visitExpression(node); 1146 new VariableUseVisitor(callback).visitExpression(node);
1148 } 1147 }
1149 } 1148 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_backend/codegen/codegen.dart ('k') | pkg/compiler/lib/src/tree_ir/tree_ir_builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698