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

Side by Side Diff: lib/compiler/implementation/ssa/optimize.dart

Issue 10638013: Improve tracking of the type of fields after object construction (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 interface OptimizationPhase { 5 interface OptimizationPhase {
6 String get name(); 6 String get name();
7 void visitGraph(HGraph graph); 7 void visitGraph(HGraph graph);
8 } 8 }
9 9
10 class SsaOptimizerTask extends CompilerTask { 10 class SsaOptimizerTask extends CompilerTask {
(...skipping 1170 matching lines...) Expand 10 before | Expand all | Expand 10 after
1181 HGraph graph; 1181 HGraph graph;
1182 Compiler get compiler() => backend.compiler; 1182 Compiler get compiler() => backend.compiler;
1183 1183
1184 SsaProcessRecompileCandidates(this.backend, this.work); 1184 SsaProcessRecompileCandidates(this.backend, this.work);
1185 1185
1186 void visitGraph(HGraph visitee) { 1186 void visitGraph(HGraph visitee) {
1187 graph = visitee; 1187 graph = visitee;
1188 visitDominatorTree(visitee); 1188 visitDominatorTree(visitee);
1189 } 1189 }
1190 1190
1191 void visitFieldGet(HFieldGet node) {
1192 if (!node.element.enclosingElement.isClass()) return;
1193 Element field = node.element;
1194 HType type = backend.optimisticFieldTypeAfterConstruction(field);
1195 switch (compiler.phase) {
1196 case Compiler.PHASE_COMPILING:
1197 if (!type.isConflicting()) {
1198 compiler.enqueuer.codegen.registerRecompilationCandidate(
1199 work.element);
1200 }
1201 break;
1202 case Compiler.PHASE_RECOMPILING:
1203 if (!type.isConflicting() && !type.isUnknown()) {
1204 // Check if optimistic type is based on a setter in the constructor
1205 // body.
1206 if (backend.hasConstructorBodyFieldSetter(field)) {
1207 // There is at least one field setter from the constructor.
1208 // TODO(sgjesse): Collect the type for all the field setters so that
1209 // this could be a guarenteed type if all field setters have the
1210 // same type and there are no invoked setters.
1211 node.propagatedType = type;
1212 } else {
1213 // Optimistic type is based in field initializer list.
1214 if (!compiler.codegenWorld.hasFieldSetter(field, compiler) &&
1215 !compiler.codegenWorld.hasInvokedSetter(field, compiler)) {
floitsch 2012/06/22 08:18:12 what about implicit null-initializations?
Søren Gjesse 2012/06/22 09:22:36 All the implicit null initialized fields will be i
1216 node.guaranteedType = type;
1217 } else {
1218 node.propagatedType = type;
1219 }
1220 }
1221 }
1222 break;
1223 }
1224 }
1225
1191 HInstruction visitEquals(HEquals node) { 1226 HInstruction visitEquals(HEquals node) {
1192 // Try to optimize the case where a field which is known to always be an 1227 // Try to optimize the case where a field which is known to always be an
1193 // integer is compared with a constant integer literal. 1228 // integer is compared with a constant integer literal.
1194 if (node.left is HFieldGet && 1229 if (node.left is HFieldGet &&
1195 node.right is HConstant && 1230 node.right is HConstant &&
1196 node.right.isInteger()) { 1231 node.right.isInteger()) {
1197 HFieldGet left = node.left; 1232 HFieldGet left = node.left;
1198 HConstant right = node.right; 1233 HConstant right = node.right;
1199 if (left.element != null && left.element.enclosingElement.isClass()) { 1234 if (left.element != null && left.element.enclosingElement.isClass()) {
1200 switch (compiler.phase) { 1235 switch (compiler.phase) {
(...skipping 24 matching lines...) Expand all
1225 } 1260 }
1226 } 1261 }
1227 break; 1262 break;
1228 default: 1263 default:
1229 assert(false); 1264 assert(false);
1230 break; 1265 break;
1231 } 1266 }
1232 } 1267 }
1233 } 1268 }
1234 } 1269 }
1270
1235 } 1271 }
OLDNEW
« lib/compiler/implementation/ssa/codegen.dart ('K') | « lib/compiler/implementation/ssa/codegen.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698