| 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 part of ssa; | 5 part of ssa; |
| 6 | 6 |
| 7 abstract class OptimizationPhase { | 7 abstract class OptimizationPhase { |
| 8 String get name; | 8 String get name; |
| 9 void visitGraph(HGraph graph); | 9 void visitGraph(HGraph graph); |
| 10 } | 10 } |
| (...skipping 1451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1462 | 1462 |
| 1463 visitFieldSet(HFieldSet node) { | 1463 visitFieldSet(HFieldSet node) { |
| 1464 Element field = node.element; | 1464 Element field = node.element; |
| 1465 HInstruction value = node.value; | 1465 HInstruction value = node.value; |
| 1466 HType type = value.instructionType; | 1466 HType type = value.instructionType; |
| 1467 // [HFieldSet] is also used for variables in try/catch. | 1467 // [HFieldSet] is also used for variables in try/catch. |
| 1468 if (field.isField()) allSetters.add(field); | 1468 if (field.isField()) allSetters.add(field); |
| 1469 // Don't handle fields defined in superclasses. Given that the field is | 1469 // Don't handle fields defined in superclasses. Given that the field is |
| 1470 // always added to the [allSetters] set, setting a field defined in a | 1470 // always added to the [allSetters] set, setting a field defined in a |
| 1471 // superclass will get an inferred type of UNKNOWN. | 1471 // superclass will get an inferred type of UNKNOWN. |
| 1472 if (identical(work.element.getEnclosingClass(), field.getEnclosingClass()) &
& | 1472 if (work.element.getEnclosingClass() == field.getEnclosingClass()) { |
| 1473 !value.instructionType.isUnknown()) { | 1473 HType existing = currentFieldSetters[field]; |
| 1474 if (existing != null) { |
| 1475 type = existing.union(type, backend.compiler); |
| 1476 } |
| 1474 currentFieldSetters[field] = type; | 1477 currentFieldSetters[field] = type; |
| 1475 } | 1478 } |
| 1476 } | 1479 } |
| 1477 | 1480 |
| 1478 visitExit(HExit node) { | 1481 visitExit(HExit node) { |
| 1479 // If this has been exposed then we cannot say anything about types after | 1482 // If this has been exposed then we cannot say anything about types after |
| 1480 // construction. | 1483 // construction. |
| 1481 if (!thisExposed) { | 1484 if (!thisExposed) { |
| 1482 // Register the known field types. | 1485 // Register the known field types. |
| 1483 currentFieldSetters.forEach((Element element, HType type) { | 1486 currentFieldSetters.forEach((Element element, HType type) { |
| 1487 if (type.isUnknown()) return; |
| 1484 backend.registerFieldConstructor(element, type); | 1488 backend.registerFieldConstructor(element, type); |
| 1485 allSetters.remove(element); | 1489 allSetters.remove(element); |
| 1486 }); | 1490 }); |
| 1487 } | 1491 } |
| 1488 | 1492 |
| 1489 // For other fields having setters in the generative constructor body, set | 1493 // For other fields having setters in the generative constructor body, set |
| 1490 // the type to UNKNOWN to avoid relying on the type set in the initializer | 1494 // the type to UNKNOWN to avoid relying on the type set in the initializer |
| 1491 // list. | 1495 // list. |
| 1492 allSetters.forEach((Element element) { | 1496 allSetters.forEach((Element element) { |
| 1493 backend.registerFieldConstructor(element, HType.UNKNOWN); | 1497 backend.registerFieldConstructor(element, HType.UNKNOWN); |
| 1494 }); | 1498 }); |
| 1495 } | 1499 } |
| 1496 } | 1500 } |
| OLD | NEW |