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

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

Issue 10696195: Simplify type handling for recompilation of field gets. (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 1259 matching lines...) Expand 10 before | Expand all | Expand 10 after
1270 void visitGraph(HGraph visitee) { 1270 void visitGraph(HGraph visitee) {
1271 graph = visitee; 1271 graph = visitee;
1272 if (compiler.phase == Compiler.PHASE_RECOMPILING) { 1272 if (compiler.phase == Compiler.PHASE_RECOMPILING) {
1273 visitDominatorTree(visitee); 1273 visitDominatorTree(visitee);
1274 } 1274 }
1275 } 1275 }
1276 1276
1277 void handleFieldGet(HFieldGet field, HType type) { 1277 void handleFieldGet(HFieldGet field, HType type) {
1278 assert(compiler.phase == Compiler.PHASE_RECOMPILING); 1278 assert(compiler.phase == Compiler.PHASE_RECOMPILING);
1279 if (!type.isConflicting()) { 1279 if (!type.isConflicting()) {
1280 // If there are no invoked setters with this name, the union of
1281 // the types of the initializers and the setters is guaranteed
1282 // otherwise it is only speculative.
1280 Element element = field.element; 1283 Element element = field.element;
1281 // Check if optimistic type is based on a setter in the 1284 assert(!element.isGenerativeConstructorBody());
1282 // constructor body. 1285 if (!compiler.codegenWorld.hasInvokedSetter(element, compiler)) {
1283 if (backend.hasConstructorBodyFieldSetter(element)) { 1286 field.guaranteedType =
1284 // If there are no other field setters then the one in 1287 type.union(backend.fieldSettersTypeSoFar(element));
1285 // the constructor body, the type is guaranteed for this
1286 // field after construction.
1287 assert(!element.isGenerativeConstructorBody());
1288 if (!compiler.codegenWorld.hasInvokedSetter(element, compiler)) {
1289 field.guaranteedType =
1290 type.union(backend.fieldSettersTypeSoFar(element));
1291 } else {
1292 field.propagatedType =
1293 type.union(backend.fieldSettersTypeSoFar(element));
1294 }
1295 } else { 1288 } else {
1296 // If there are no setters the initializer list type is 1289 field.propagatedType =
1297 // guaranteed to remain constant. 1290 type.union(backend.fieldSettersTypeSoFar(element));
1298 //
1299 // TODO(ager): Why is this treated differently from the
1300 // case above? It seems to me that we could/should use
1301 // the union of the types for the field setters and the
1302 // initializer list here? It would give the same when
1303 // there are none and potentially better information for
1304 // more cases.
1305 if (!compiler.codegenWorld.hasFieldSetter(element, compiler) &&
1306 !compiler.codegenWorld.hasInvokedSetter(element, compiler)) {
1307 field.guaranteedType = type;
1308 } else {
1309 field.propagatedType = type;
1310 }
1311 } 1291 }
1312 } 1292 }
1313 } 1293 }
1314 1294
1315 void handleFieldNumberOperation(HFieldGet field, HType type) { 1295 void handleFieldNumberOperation(HFieldGet field, HType type) {
1316 assert(compiler.phase == Compiler.PHASE_RECOMPILING); 1296 assert(compiler.phase == Compiler.PHASE_RECOMPILING);
1317 if (compiler.codegenWorld.hasInvokedSetter(field.element, compiler)) { 1297 if (compiler.codegenWorld.hasInvokedSetter(field.element, compiler)) {
1318 // If there are invoked setters we don't know for sure 1298 // If there are invoked setters we don't know for sure
1319 // that the field will hold a value of the calculated 1299 // that the field will hold a value of the calculated
1320 // type, but the fact that the class itself sticks to 1300 // type, but the fact that the class itself sticks to
1321 // this type for the field is still a strong signal 1301 // this type for the field is still a strong signal
1322 // indicating the expected type of the field. 1302 // indicating the expected type of the field.
1323 field.propagatedType = type; 1303 field.propagatedType = type;
1324 } else { 1304 } else {
1325 // If there are no invoked setters we know the type of 1305 // If there are no invoked setters we know the type of
1326 // this field for sure. 1306 // this field for sure.
1327 field.guaranteedType = type; 1307 field.guaranteedType = type;
1328 } 1308 }
1329 } 1309 }
1330 } 1310 }
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