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

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

Issue 10700122: Generalize the use of type information for setters and initializers (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 | « lib/compiler/implementation/compiler.dart ('k') | 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 1200 matching lines...) Expand 10 before | Expand all | Expand 10 after
1211 1211
1212 HInstruction visitEquals(HEquals node) { 1212 HInstruction visitEquals(HEquals node) {
1213 // Try to optimize the case where a field which is known to always be an 1213 // Try to optimize the case where a field which is known to always be an
1214 // integer is compared with a constant integer literal. 1214 // integer is compared with a constant integer literal.
1215 if (node.left is HFieldGet && 1215 if (node.left is HFieldGet &&
1216 node.right is HConstant && 1216 node.right is HConstant &&
1217 node.right.isInteger()) { 1217 node.right.isInteger()) {
1218 HFieldGet left = node.left; 1218 HFieldGet left = node.left;
1219 HConstant right = node.right; 1219 HConstant right = node.right;
1220 if (left.element != null && left.element.enclosingElement.isClass()) { 1220 if (left.element != null && left.element.enclosingElement.isClass()) {
1221 // Calculate the field type from the information available.
1222 HType type =
1223 backend.fieldSettersTypeSoFar(left.element).union(
1224 backend.typeFromInitializersSoFar(left.element));
1221 switch (compiler.phase) { 1225 switch (compiler.phase) {
1222 case Compiler.PHASE_COMPILING: 1226 case Compiler.PHASE_COMPILING:
1223 if ((backend.fieldSettersTypeSoFar(left.element).isUnknown() || 1227 if (!type.isConflicting()) {
1224 backend.fieldSettersTypeSoFar(left.element).isInteger()) &&
1225 backend.couldHaveFieldSingleTypeInitializers(
1226 left.element, HType.INTEGER)) {
1227 compiler.enqueuer.codegen.registerRecompilationCandidate( 1228 compiler.enqueuer.codegen.registerRecompilationCandidate(
1228 work.element); 1229 work.element);
1229 } 1230 }
1230 break; 1231 break;
1231 case Compiler.PHASE_RECOMPILING: 1232 case Compiler.PHASE_RECOMPILING:
1232 if (backend.fieldSettersTypeSoFar(left.element).isInteger() && 1233 if (!type.isConflicting()) {
1233 backend.hasFieldSingleTypeInitializers(
1234 left.element, HType.INTEGER)) {
1235 if (compiler.codegenWorld.hasInvokedSetter(left.element, 1234 if (compiler.codegenWorld.hasInvokedSetter(left.element,
1236 compiler)) { 1235 compiler)) {
1237 // If there are invoked setters we don't know for sure that the 1236 // If there are invoked setters we don't know for sure that the
1238 // field will hold an integer, but the fact that the class 1237 // field will hold the calculated, but the fact that the class
1239 // itself always sets an integer in the fiels is still a strong 1238 // itself stick to this type in the field is still a strong
1240 // signal to indiate the expected type of the field. 1239 // signal to indiate the expected type of the field.
floitsch 2012/07/06 09:06:51 indicate
1241 left.propagatedType = HType.INTEGER; 1240 left.propagatedType = type;
ngeoffray 2012/07/11 12:48:43 Isn't that covered by visitFieldGet already?
1242 graph.highTypeLikelyhood = true; 1241 graph.highTypeLikelyhood = true;
1243 } else { 1242 } else {
1244 // If there are no invoked setters we know the type of this 1243 // If there are no invoked setters we know the type of this
1245 // field for sure. 1244 // field for sure.
1246 left.guaranteedType = HType.INTEGER; 1245 left.guaranteedType = type;
ngeoffray 2012/07/11 12:48:43 ditto?
1247 } 1246 }
1248 } 1247 }
1249 break; 1248 break;
1250 default: 1249 default:
1251 assert(false); 1250 assert(false);
1252 break; 1251 break;
1253 } 1252 }
1254 } 1253 }
1255 } 1254 }
1256 } 1255 }
1257 1256
1258 } 1257 }
OLDNEW
« no previous file with comments | « lib/compiler/implementation/compiler.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698