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

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

Issue 1507313006: dart2js cps: Add instruction for null checks. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Fix true/false misdocumentation about condition and do not emit call Created 5 years 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) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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.pull_into_initializers; 5 library tree_ir.optimization.pull_into_initializers;
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 /// Where a variable has been assigned. 10 /// Where a variable has been assigned.
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 } 161 }
162 162
163 Statement visitFor(For node) { 163 Statement visitFor(For node) {
164 return node; 164 return node;
165 } 165 }
166 166
167 Statement visitTry(Try node) { 167 Statement visitTry(Try node) {
168 return node; 168 return node;
169 } 169 }
170 170
171 Statement visitNullCheck(NullCheck node) {
172 if (node.condition != null) {
173 node.condition = visitExpression(node.condition);
174 // The value occurs in conditional context, so don't pull from that.
175 } else {
176 node.value = visitExpression(node.value);
177 }
178 return node;
179 }
180
171 Expression visitAssign(Assign node) { 181 Expression visitAssign(Assign node) {
172 bool inImpureContext = impureCounter > 0; 182 bool inImpureContext = impureCounter > 0;
173 bool inBranch = branchCounter > 0; 183 bool inBranch = branchCounter > 0;
174 184
175 // Remember the number of impure expression seen yet, so we can tell if 185 // Remember the number of impure expression seen yet, so we can tell if
176 // there are any impure expressions on the right-hand side. 186 // there are any impure expressions on the right-hand side.
177 int impureBefore = impureCounter; 187 int impureBefore = impureCounter;
178 int assignmentsBefore = assignCounter; 188 int assignmentsBefore = assignCounter;
179 node.value = visitExpression(node.value); 189 node.value = visitExpression(node.value);
180 bool rightHandSideIsImpure = (impureCounter > impureBefore); 190 bool rightHandSideIsImpure = (impureCounter > impureBefore);
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 366
357 @override 367 @override
358 Expression visitForeignExpression(ForeignExpression node) { 368 Expression visitForeignExpression(ForeignExpression node) {
359 rewriteList(node.arguments); 369 rewriteList(node.arguments);
360 if (node.nativeBehavior.sideEffects.hasSideEffects()) { 370 if (node.nativeBehavior.sideEffects.hasSideEffects()) {
361 ++impureCounter; 371 ++impureCounter;
362 } 372 }
363 return node; 373 return node;
364 } 374 }
365 } 375 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698