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

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

Issue 10834243: Reduce usage of .enclosingElement to get enclosing class. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 4 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 1173 matching lines...) Expand 10 before | Expand all | Expand 10 after
1184 other = node.right; 1184 other = node.right;
1185 } else if (node.right is HFieldGet) { 1185 } else if (node.right is HFieldGet) {
1186 field = node.right; 1186 field = node.right;
1187 other = node.left; 1187 other = node.left;
1188 } 1188 }
1189 // Try to optimize the case where a field which is known to always 1189 // Try to optimize the case where a field which is known to always
1190 // be an integer is compared with a constant number. 1190 // be an integer is compared with a constant number.
1191 if (other != null && 1191 if (other != null &&
1192 other.isConstantNumber() && 1192 other.isConstantNumber() &&
1193 field.element != null && 1193 field.element != null &&
1194 field.element.enclosingElement.isClass()) { 1194 field.element.isMember()) {
1195 // Calculate the field type from the information available. If 1195 // Calculate the field type from the information available. If
1196 // we have type information for the field and it contains NUMBER 1196 // we have type information for the field and it contains NUMBER
1197 // we use it as a candidate for recompilation. 1197 // we use it as a candidate for recompilation.
1198 Element fieldElement = field.element; 1198 Element fieldElement = field.element;
1199 HType fieldSettersType = backend.fieldSettersTypeSoFar(fieldElement); 1199 HType fieldSettersType = backend.fieldSettersTypeSoFar(fieldElement);
1200 HType initializersType = backend.typeFromInitializersSoFar(fieldElement); 1200 HType initializersType = backend.typeFromInitializersSoFar(fieldElement);
1201 HType fieldType = fieldSettersType.union(initializersType); 1201 HType fieldType = fieldSettersType.union(initializersType);
1202 HType type = HType.NUMBER.union(fieldType); 1202 HType type = HType.NUMBER.union(fieldType);
1203 if (type == HType.NUMBER) { 1203 if (type == HType.NUMBER) {
1204 handleFieldNumberOperation(field, fieldType); 1204 handleFieldNumberOperation(field, fieldType);
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
1305 // this type for the field is still a strong signal 1305 // this type for the field is still a strong signal
1306 // indicating the expected type of the field. 1306 // indicating the expected type of the field.
1307 field.propagatedType = type; 1307 field.propagatedType = type;
1308 } else { 1308 } else {
1309 // If there are no invoked setters we know the type of 1309 // If there are no invoked setters we know the type of
1310 // this field for sure. 1310 // this field for sure.
1311 field.guaranteedType = type; 1311 field.guaranteedType = type;
1312 } 1312 }
1313 } 1313 }
1314 } 1314 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698