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

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

Issue 10704156: Bring back most of the performance lost when fixing union on types. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 8 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | 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) 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 1157 matching lines...) Expand 10 before | Expand all | Expand 10 after
1168 1168
1169 void visitGraph(HGraph visitee) { 1169 void visitGraph(HGraph visitee) {
1170 graph = visitee; 1170 graph = visitee;
1171 visitDominatorTree(visitee); 1171 visitDominatorTree(visitee);
1172 } 1172 }
1173 1173
1174 void visitFieldGet(HFieldGet node) { 1174 void visitFieldGet(HFieldGet node) {
1175 if (!node.element.enclosingElement.isClass()) return; 1175 if (!node.element.enclosingElement.isClass()) return;
1176 Element field = node.element; 1176 Element field = node.element;
1177 HType type = backend.optimisticFieldTypeAfterConstruction(field); 1177 HType type = backend.optimisticFieldTypeAfterConstruction(field);
1178 if (!type.isConflicting() && !type.isUnknown()) { 1178 if (!type.isUnknown()) {
1179 switch (compiler.phase) { 1179 switch (compiler.phase) {
1180 case Compiler.PHASE_COMPILING: 1180 case Compiler.PHASE_COMPILING:
1181 // Recompile even if we haven't seen any types for this
1182 // field yet. There might still be only one setter in an
1183 // initializer list or constructor body.
1181 compiler.enqueuer.codegen.registerRecompilationCandidate( 1184 compiler.enqueuer.codegen.registerRecompilationCandidate(
1182 work.element); 1185 work.element);
1183 break; 1186 break;
1184 case Compiler.PHASE_RECOMPILING: 1187 case Compiler.PHASE_RECOMPILING:
1185 // Check if optimistic type is based on a setter in the constructor 1188 if (!type.isConflicting()) {
1186 // body. 1189 // Check if optimistic type is based on a setter in the
1187 if (backend.hasConstructorBodyFieldSetter(field)) { 1190 // constructor body.
1188 // There is at least one field setter from the constructor. 1191 if (backend.hasConstructorBodyFieldSetter(field)) {
1189 if (!compiler.codegenWorld.hasInvokedSetter(field, compiler)) { 1192 // If there are no other field setters then the one in
1190 node.guaranteedType = 1193 // the constructor body, the type is guaranteed for this
1191 type.union(backend.fieldSettersTypeSoFar(node.element)); 1194 // field after construction.
1195 assert(!node.element.isGenerativeConstructorBody());
1196 if (!compiler.codegenWorld.hasInvokedSetter(field, compiler)) {
1197 node.guaranteedType =
1198 type.union(backend.fieldSettersTypeSoFar(node.element));
1199 } else {
1200 node.propagatedType =
1201 type.union(backend.fieldSettersTypeSoFar(node.element));
1202 }
1192 } else { 1203 } else {
1193 node.propagatedType = 1204 // If there are no setters the initializer list type is
1194 type.union(backend.fieldSettersTypeSoFar(node.element)); 1205 // guaranteed to remain constant.
1195 } 1206 //
1196 } else { 1207 // TODO(ager): Why is this treated differently from the
1197 // Optimistic type is based on field initializer list. 1208 // case above? It seems to me that we could/should use
1198 if (!compiler.codegenWorld.hasFieldSetter(field, compiler) && 1209 // the union of the types for the field setters and the
1199 !compiler.codegenWorld.hasInvokedSetter(field, compiler)) { 1210 // initializer list here? It would give the same when
1200 node.guaranteedType = type; 1211 // there are none and potentially better information for
1201 } else { 1212 // more cases.
1202 node.propagatedType = type; 1213 if (!compiler.codegenWorld.hasFieldSetter(field, compiler) &&
1214 !compiler.codegenWorld.hasInvokedSetter(field, compiler)) {
1215 node.guaranteedType = type;
1216 } else {
1217 node.propagatedType = type;
1218 }
1203 } 1219 }
1204 } 1220 }
1205 break; 1221 break;
1206 } 1222 }
1207 } 1223 }
1208 } 1224 }
1209 1225
1210 HInstruction visitEquals(HEquals node) { 1226 HInstruction visitEquals(HEquals node) {
1211 // Determine if one of the operands is an HFieldGet. 1227 // Determine if one of the operands is an HFieldGet.
1212 HFieldGet field; 1228 HFieldGet field;
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
1304 } 1320 }
1305 break; 1321 break;
1306 default: 1322 default:
1307 assert(false); 1323 assert(false);
1308 break; 1324 break;
1309 } 1325 }
1310 } 1326 }
1311 } 1327 }
1312 } 1328 }
1313 } 1329 }
OLDNEW
« 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