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

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

Issue 17151007: Eagerly infer the element type of const lists in the simple inferrer. (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 side-by-side diff with in-line comments
Download patch
Index: sdk/lib/_internal/compiler/implementation/types/simple_types_inferrer.dart
===================================================================
--- sdk/lib/_internal/compiler/implementation/types/simple_types_inferrer.dart (revision 24131)
+++ sdk/lib/_internal/compiler/implementation/types/simple_types_inferrer.dart (working copy)
@@ -1443,11 +1443,25 @@
}
TypeMask visitLiteralList(LiteralList node) {
- node.visitChildren(this);
- if (node.isConst()) return inferrer.constListType;
- return inferrer.concreteTypes.putIfAbsent(
- node, () => new ContainerTypeMask(
- inferrer.growableListType, node, outermostElement));
+ 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, () {
+ ContainerTypeMask container = new ContainerTypeMask(
+ inferrer.constListType, node, outermostElement);
+ TypeMask elementType = new TypeMask.nonNullEmpty();
+ for (Node element in node.elements.nodes) {
+ elementType = computeLUB(elementType, visit(element), compiler);
+ }
+ container.elementType = elementType;
+ return container;
+ });
+ } else {
+ node.visitChildren(this);
+ return inferrer.concreteTypes.putIfAbsent(
+ node, () => new ContainerTypeMask(
+ inferrer.growableListType, node, outermostElement));
+ }
}
bool isThisOrSuper(Node node) => node.isThis() || node.isSuper();
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/types/container_tracer.dart ('k') | tests/compiler/dart2js/mock_compiler.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698