| 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 1419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1430 // Collect all users of this in a set to make the this exposed check simple | 1430 // Collect all users of this in a set to make the this exposed check simple |
| 1431 // and cheap. | 1431 // and cheap. |
| 1432 thisUsers.addAll(instruction.usedBy); | 1432 thisUsers.addAll(instruction.usedBy); |
| 1433 } | 1433 } |
| 1434 | 1434 |
| 1435 visitFieldGet(HInstruction _) { | 1435 visitFieldGet(HInstruction _) { |
| 1436 // The field get instruction is allowed to use this. | 1436 // The field get instruction is allowed to use this. |
| 1437 } | 1437 } |
| 1438 | 1438 |
| 1439 visitForeignNew(HForeignNew node) { | 1439 visitForeignNew(HForeignNew node) { |
| 1440 if (!work.element.isGenerativeConstructor()) return; |
| 1441 // Check if this is the new object allocated by this generative |
| 1442 // constructor. Inlining might add other [HForeignNew] |
| 1443 // instructions in the graph. |
| 1444 if (!node.usedBy.any((user) => user is HReturn)) return; |
| 1440 // The HForeignNew instruction is used in the generative constructor to | 1445 // The HForeignNew instruction is used in the generative constructor to |
| 1441 // initialize all fields in newly created objects. The fields are | 1446 // initialize all fields in newly created objects. The fields are |
| 1442 // initialized to the value present in the initializer list or set to null | 1447 // initialized to the value present in the initializer list or set to null |
| 1443 // if not otherwise initialized. | 1448 // if not otherwise initialized. |
| 1444 // Here we handle members in superclasses as well, as the handling of | 1449 // Here we handle members in superclasses as well, as the handling of |
| 1445 // the generative constructor bodies will ensure, that the initializer | 1450 // the generative constructor bodies will ensure, that the initializer |
| 1446 // type will not be used if the field is in any of these. | 1451 // type will not be used if the field is in any of these. |
| 1447 int j = 0; | 1452 int j = 0; |
| 1448 node.element.forEachInstanceField( | 1453 node.element.forEachInstanceField( |
| 1449 (ClassElement enclosingClass, Element element) { | 1454 (ClassElement enclosingClass, Element element) { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1481 } | 1486 } |
| 1482 | 1487 |
| 1483 // For other fields having setters in the generative constructor body, set | 1488 // For other fields having setters in the generative constructor body, set |
| 1484 // the type to UNKNOWN to avoid relying on the type set in the initializer | 1489 // the type to UNKNOWN to avoid relying on the type set in the initializer |
| 1485 // list. | 1490 // list. |
| 1486 allSetters.forEach((Element element) { | 1491 allSetters.forEach((Element element) { |
| 1487 backend.registerFieldConstructor(element, HType.UNKNOWN); | 1492 backend.registerFieldConstructor(element, HType.UNKNOWN); |
| 1488 }); | 1493 }); |
| 1489 } | 1494 } |
| 1490 } | 1495 } |
| OLD | NEW |