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

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

Issue 111423003: Add a new node in the inferrer to materialize literal maps. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years 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/type_graph_inferrer.dart
===================================================================
--- sdk/lib/_internal/compiler/implementation/inferrer/type_graph_inferrer.dart (revision 30992)
+++ sdk/lib/_internal/compiler/implementation/inferrer/type_graph_inferrer.dart (working copy)
@@ -50,8 +50,8 @@
final Map<Element, TypeInformation> typeInformations =
new Map<Element, TypeInformation>();
- /// [ContainerTypeInformation] for allocated containers.
- final Map<Node, TypeInformation> allocatedContainers =
+ /// [ListTypeInformation] for allocated lists.
+ final Map<Node, TypeInformation> allocatedLists =
new Map<Node, TypeInformation>();
/// Cache of [ConcreteTypeInformation].
@@ -270,10 +270,10 @@
return type == nullType;
}
- TypeInformation allocateContainer(TypeInformation type,
- Node node,
- Element enclosing,
- [TypeInformation elementType, int length]) {
+ TypeInformation allocateList(TypeInformation type,
+ Node node,
+ Element enclosing,
+ [TypeInformation elementType, int length]) {
bool isTypedArray = (compiler.typedDataClass != null)
&& type.type.satisfies(compiler.typedDataClass, compiler);
bool isConst = (type.type == compiler.typesTask.constListType);
@@ -293,10 +293,19 @@
element.inferred = isElementInferred;
allocatedTypes.add(element);
- return allocatedContainers[node] =
- new ContainerTypeInformation(mask, element, length);
+ return allocatedLists[node] =
+ new ListTypeInformation(mask, element, length);
}
+ TypeInformation allocateMap(TypeInformation keyType,
+ TypeInformation valueType,
+ ConcreteTypeInformation type) {
+ MapTypeInformation map =
+ new MapTypeInformation(keyType, valueType, type.type);
+ allocatedTypes.add(map);
+ return map;
+ }
+
Selector newTypedSelector(TypeInformation info, Selector selector) {
// Only type the selector if [info] is concrete, because the other
// kinds of [TypeInformation] have the empty type at this point of
@@ -424,7 +433,7 @@
TypeGraphInferrerEngine(Compiler compiler, this.mainElement)
: super(compiler, new TypeInformationSystem(compiler));
- void analyzeContainer(ContainerTypeInformation info) {
+ void analyzeContainer(ListTypeInformation info) {
if (info.analyzed) return;
info.analyzed = true;
ContainerTracerVisitor tracer = new ContainerTracerVisitor(info, this);
@@ -461,7 +470,7 @@
refine();
// Try to infer element types of lists.
- types.allocatedContainers.values.forEach((ContainerTypeInformation info) {
+ types.allocatedLists.values.forEach((ListTypeInformation info) {
if (info.elementType.inferred) return;
analyzeContainer(info);
if (info.bailedOut) return;
@@ -485,7 +494,7 @@
refine();
if (_VERBOSE) {
- types.allocatedContainers.values.forEach((ContainerTypeInformation info) {
+ types.allocatedLists.values.forEach((ListTypeInformation info) {
print('${info.type} '
'for ${info.originalContainerType.allocationNode} '
'at ${info.originalContainerType.allocationElement}');
@@ -520,7 +529,7 @@
// If [element] is final and has an initializer, we record
// the inferred type.
if (node.asSendSet() != null) {
- if (type is! ContainerTypeInformation) {
+ if (type is! ListTypeInformation) {
// For non-container types, the constant handler does
// constant folding that could give more precise results.
Constant value =
@@ -920,12 +929,12 @@
TypeMask getTypeOfNode(Element owner, Node node) {
if (compiler.disableTypeInference) return compiler.typesTask.dynamicType;
- return inferrer.types.allocatedContainers[node].type;
+ return inferrer.types.allocatedLists[node].type;
}
bool isFixedArrayCheckedForGrowable(Node node) {
if (compiler.disableTypeInference) return true;
- ContainerTypeInformation info = inferrer.types.allocatedContainers[node];
+ ListTypeInformation info = inferrer.types.allocatedLists[node];
return info.checksGrowable;
}
@@ -953,14 +962,6 @@
return result;
}
- Iterable<TypeMask> get containerTypes {
- if (compiler.disableTypeInference) {
- throw new UnsupportedError(
- "Cannot query the type inferrer when type inference is disabled.");
- }
- return inferrer.types.allocatedContainers.values.map((info) => info.type);
- }
-
Iterable<Element> getCallersOf(Element element) {
if (compiler.disableTypeInference) {
throw new UnsupportedError(

Powered by Google App Engine
This is Rietveld 408576698