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

Unified Diff: sdk/lib/_internal/compiler/implementation/inferrer/simple_types_inferrer.dart

Issue 24994003: Re-apply "Move the container tracer to the call graph inferrer.". (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: sdk/lib/_internal/compiler/implementation/inferrer/simple_types_inferrer.dart
===================================================================
--- sdk/lib/_internal/compiler/implementation/inferrer/simple_types_inferrer.dart (revision 27995)
+++ sdk/lib/_internal/compiler/implementation/inferrer/simple_types_inferrer.dart (working copy)
@@ -538,38 +538,31 @@
}
T visitLiteralList(LiteralList node) {
- if (node.isConst()) {
- // We only set the type once. We don't need to re-visit the children
- // when re-analyzing the node.
- return inferrer.concreteTypes.putIfAbsent(node, () {
- T elementType;
- int length = 0;
- for (Node element in node.elements.nodes) {
- T type = visit(element);
- elementType = elementType == null
- ? types.allocatePhi(null, null, type)
- : types.addPhiInput(null, elementType, type);
- length++;
- }
+ // We only set the type once. We don't need to re-visit the children
+ // when re-analyzing the node.
+ return inferrer.concreteTypes.putIfAbsent(node, () {
+ T elementType;
+ int length = 0;
+ for (Node element in node.elements.nodes) {
+ T type = visit(element);
elementType = elementType == null
- ? types.nonNullEmpty()
- : types.simplifyPhi(null, null, elementType);
- return types.allocateContainer(
- types.constListType,
- node,
- outermostElement,
- elementType,
- length);
- });
- } else {
- node.visitChildren(this);
- return inferrer.concreteTypes.putIfAbsent(node, () {
- return types.allocateContainer(
- types.growableListType,
- node,
- outermostElement);
- });
- }
+ ? types.allocatePhi(null, null, type)
+ : types.addPhiInput(null, elementType, type);
+ length++;
+ }
+ elementType = elementType == null
+ ? types.nonNullEmpty()
+ : types.simplifyPhi(null, null, elementType);
+ T containerType = node.isConst()
+ ? types.constListType
+ : types.growableListType;
+ return types.allocateContainer(
+ containerType,
+ node,
+ outermostElement,
+ elementType,
+ length);
+ });
}
bool isThisOrSuper(Node node) => node.isThis() || node.isSuper();
@@ -826,12 +819,31 @@
if (Elements.isGrowableListConstructorCall(element, node, compiler)) {
return inferrer.concreteTypes.putIfAbsent(
node, () => types.allocateContainer(
- types.growableListType, node, outermostElement));
+ types.growableListType, node, outermostElement,
+ types.nonNullEmpty(), 0));
} else if (Elements.isFixedListConstructorCall(element, node, compiler)
|| Elements.isFilledListConstructorCall(element, node, compiler)) {
+
+ int initialLength;
+ T elementType;
+ if (Elements.isFixedListConstructorCall(element, node, compiler)) {
+ LiteralInt length = node.arguments.head.asLiteralInt();
+ if (length != null) {
+ initialLength = length.value;
+ }
+ elementType = types.nullType;
+ } else {
+ LiteralInt length = node.arguments.head.asLiteralInt();
+ if (length != null) {
+ initialLength = length.value;
+ }
+ elementType = arguments.positional[1];
+ }
+
return inferrer.concreteTypes.putIfAbsent(
node, () => types.allocateContainer(
- types.fixedListType, node, outermostElement));
+ types.fixedListType, node, outermostElement,
+ elementType, initialLength));
} else if (element.isFunction() || element.isConstructor()) {
return returnType;
} else {

Powered by Google App Engine
This is Rietveld 408576698