Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 1236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1247 } | 1247 } |
| 1248 break; | 1248 break; |
| 1249 default: | 1249 default: |
| 1250 assert(false); | 1250 assert(false); |
| 1251 break; | 1251 break; |
| 1252 } | 1252 } |
| 1253 } | 1253 } |
| 1254 } | 1254 } |
| 1255 } | 1255 } |
| 1256 | 1256 |
| 1257 HInstruction visitBinaryArithmetic(HBinaryArithmetic node) { | |
| 1258 // Determine if one of the operands is an HFieldGet. | |
| 1259 HFieldGet field; | |
| 1260 HInstruction other; | |
|
Søren Gjesse
2012/07/06 08:38:43
Maybe we can also do like this field/other stuff i
Mads Ager (google)
2012/07/06 08:42:18
Yes, let me do that as well. I will pull the confl
| |
| 1261 if (node.left is HFieldGet) { | |
| 1262 field = node.left; | |
| 1263 other = node.right; | |
| 1264 } else if (node.right is HFieldGet) { | |
| 1265 field = node.right; | |
| 1266 other = node.left; | |
| 1267 } | |
| 1268 // Check that the other operand is a number and that we have type | |
| 1269 // information for the field get. | |
| 1270 if (other != null && | |
| 1271 other is HConstant && | |
| 1272 other.isNumber() && | |
| 1273 field.element != null && | |
| 1274 field.element.enclosingElement.isClass()) { | |
| 1275 // If we have type information for the field and it contains | |
| 1276 // NUMBER, we mark for recompilation. | |
| 1277 Element fieldElement = field.element; | |
| 1278 HType fieldSettersType = backend.fieldSettersTypeSoFar(fieldElement); | |
| 1279 HType initializersType = backend.typeFromInitializersSoFar(fieldElement); | |
| 1280 HType fieldType = fieldSettersType.union(initializersType); | |
| 1281 HType type = HType.NUMBER.union(fieldType); | |
| 1282 if (!type.isConflicting()) { | |
| 1283 switch (compiler.phase) { | |
| 1284 case Compiler.PHASE_COMPILING: | |
| 1285 compiler.enqueuer.codegen.registerRecompilationCandidate( | |
| 1286 work.element); | |
| 1287 break; | |
| 1288 case Compiler.PHASE_RECOMPILING: | |
| 1289 if (compiler.codegenWorld.hasInvokedSetter(fieldElement, | |
| 1290 compiler)) { | |
| 1291 // If there are invoked setters we don't know for sure | |
| 1292 // that the field will hold a value of the calculated | |
| 1293 // type, but the fact that the class itself sticks to | |
| 1294 // this type for the field is still a strong signal | |
| 1295 // indicating the expected type of the field. | |
| 1296 field.propagatedType = type; | |
| 1297 graph.highTypeLikelyhood = true; | |
| 1298 } else { | |
| 1299 // If there are no invoked setters we know the type of | |
| 1300 // this field for sure. | |
| 1301 field.guaranteedType = type; | |
| 1302 print(node); | |
| 1303 } | |
| 1304 break; | |
| 1305 default: | |
| 1306 assert(false); | |
| 1307 break; | |
| 1308 } | |
| 1309 } | |
| 1310 } | |
| 1311 } | |
| 1257 } | 1312 } |
| OLD | NEW |