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

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

Issue 15725018: Fix bug in SsaConstructionFieldTypes: handle mulitple assignments to the same field. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 6 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 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 1447 matching lines...) Expand 10 before | Expand all | Expand 10 after
1458 j++; 1458 j++;
1459 }, 1459 },
1460 includeSuperAndInjectedMembers: true); 1460 includeSuperAndInjectedMembers: true);
1461 } 1461 }
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()) return;
1469 allSetters.add(field);
1469 // Don't handle fields defined in superclasses. Given that the field is 1470 // 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 1471 // always added to the [allSetters] set, setting a field defined in a
1471 // superclass will get an inferred type of UNKNOWN. 1472 // superclass will get an inferred type of UNKNOWN.
1472 if (identical(work.element.getEnclosingClass(), field.getEnclosingClass()) & & 1473 if (work.element.getEnclosingClass() == field.getEnclosingClass()) {
1473 !value.instructionType.isUnknown()) { 1474 HType existing = currentFieldSetters[field];
1474 currentFieldSetters[field] = type; 1475 // If we have seen an assignment already, we check if
1476 // it's of the same type. If it's not, we remove the current
1477 // field type information.
1478 if (existing != null) {
1479 if (existing == type) {
1480 return;
1481 } else {
1482 currentFieldSetters.remove(field);
kasperl 2013/06/06 08:15:12 Can we then get another field type added after thi
ngeoffray 2013/06/06 08:44:00 Good catch. Done.
1483 }
1484 } else if (!type.isUnknown()) {
1485 currentFieldSetters[field] = type;
1486 }
1475 } 1487 }
1476 } 1488 }
1477 1489
1478 visitExit(HExit node) { 1490 visitExit(HExit node) {
1479 // If this has been exposed then we cannot say anything about types after 1491 // If this has been exposed then we cannot say anything about types after
1480 // construction. 1492 // construction.
1481 if (!thisExposed) { 1493 if (!thisExposed) {
1482 // Register the known field types. 1494 // Register the known field types.
1483 currentFieldSetters.forEach((Element element, HType type) { 1495 currentFieldSetters.forEach((Element element, HType type) {
1484 backend.registerFieldConstructor(element, type); 1496 backend.registerFieldConstructor(element, type);
1485 allSetters.remove(element); 1497 allSetters.remove(element);
1486 }); 1498 });
1487 } 1499 }
1488 1500
1489 // For other fields having setters in the generative constructor body, set 1501 // 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 1502 // the type to UNKNOWN to avoid relying on the type set in the initializer
1491 // list. 1503 // list.
1492 allSetters.forEach((Element element) { 1504 allSetters.forEach((Element element) {
1493 backend.registerFieldConstructor(element, HType.UNKNOWN); 1505 backend.registerFieldConstructor(element, HType.UNKNOWN);
1494 }); 1506 });
1495 } 1507 }
1496 } 1508 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698