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

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

Issue 1315333002: dart2js cps: Let effective constant expressions propagate further. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Improve comment 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/tree_ir/optimization/statement_rewriter.dart
diff --git a/pkg/compiler/lib/src/tree_ir/optimization/statement_rewriter.dart b/pkg/compiler/lib/src/tree_ir/optimization/statement_rewriter.dart
index 5cd7ee7f9e1fdb4605dd0641ea1a901bee7b4e07..4949bc9539bc7be5d801f8b105e475eb72de9044 100644
--- a/pkg/compiler/lib/src/tree_ir/optimization/statement_rewriter.dart
+++ b/pkg/compiler/lib/src/tree_ir/optimization/statement_rewriter.dart
@@ -207,15 +207,19 @@ class StatementRewriter extends Transformer implements Pass {
return newJump != null ? newJump : jump;
}
- void inEmptyEnvironment(void action()) {
+ void inEmptyEnvironment(void action(), {bool keepConstants: true}) {
List oldEnvironment = environment;
Map oldConstantEnvironment = constantEnvironment;
environment = <Expression>[];
- constantEnvironment = <Variable, Expression>{};
+ if (!keepConstants) {
+ constantEnvironment = <Variable, Expression>{};
+ }
action();
assert(environment.isEmpty);
environment = oldEnvironment;
- constantEnvironment = oldConstantEnvironment;
+ if (!keepConstants) {
+ constantEnvironment = oldConstantEnvironment;
+ }
}
/// Left-hand side of the given assignment, or `null` if not an assignment.
@@ -657,9 +661,11 @@ class StatementRewriter extends Transformer implements Pass {
Statement visitWhileTrue(WhileTrue node) {
// Do not propagate assignments into loops. Doing so is not safe for
// variables modified in the loop (the initial value will be propagated).
+ // Do not propagate effective constant expressions into loops, since
+ // computing them is not free (e.g. interceptors are expensive).
inEmptyEnvironment(() {
node.body = visitStatement(node.body);
- });
+ }, keepConstants: false);
return node;
}
« 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