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

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: 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
floitsch 2012/07/11 12:15:31 maybe assert, that we are not in the constructor b
Mads Ager (google) 2012/07/11 12:31:20 Good point. Done.
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 if (!compiler.codegenWorld.hasInvokedSetter(field, compiler)) {
1196 node.guaranteedType =
1197 type.union(backend.fieldSettersTypeSoFar(node.element));
1198 } else {
1199 node.propagatedType =
1200 type.union(backend.fieldSettersTypeSoFar(node.element));
1201 }
1192 } else { 1202 } else {
1193 node.propagatedType = 1203 // If there are no setters the initializer list type is
1194 type.union(backend.fieldSettersTypeSoFar(node.element)); 1204 // guarenteed to remain constant.
floitsch 2012/07/11 12:15:31 If there are no setters then the initializer list
Mads Ager (google) 2012/07/11 12:31:20 Whooops, done!
1195 } 1205 //
1196 } else { 1206 // TODO(ager): Why is this treated differently from the
1197 // Optimistic type is based on field initializer list. 1207 // case above? It seems to me that we could/should use
1198 if (!compiler.codegenWorld.hasFieldSetter(field, compiler) && 1208 // the union of the types for the field setters and the
1199 !compiler.codegenWorld.hasInvokedSetter(field, compiler)) { 1209 // initializer list here? It would give the same when
1200 node.guaranteedType = type; 1210 // there are none and potentially better information for
1201 } else { 1211 // more cases.
1202 node.propagatedType = type; 1212 if (!compiler.codegenWorld.hasFieldSetter(field, compiler) &&
1213 !compiler.codegenWorld.hasInvokedSetter(field, compiler)) {
1214 node.guaranteedType = type;
1215 } else {
1216 node.propagatedType = type;
1217 }
1203 } 1218 }
1204 } 1219 }
1205 break; 1220 break;
1206 } 1221 }
1207 } 1222 }
1208 } 1223 }
1209 1224
1210 HInstruction visitEquals(HEquals node) { 1225 HInstruction visitEquals(HEquals node) {
1211 // Determine if one of the operands is an HFieldGet. 1226 // Determine if one of the operands is an HFieldGet.
1212 HFieldGet field; 1227 HFieldGet field;
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
1304 } 1319 }
1305 break; 1320 break;
1306 default: 1321 default:
1307 assert(false); 1322 assert(false);
1308 break; 1323 break;
1309 } 1324 }
1310 } 1325 }
1311 } 1326 }
1312 } 1327 }
1313 } 1328 }
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