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

Unified Diff: pkg/compiler/lib/src/cps_ir/cps_ir_builder_task.dart

Issue 1416723008: dart2js cps: Propagate container types for lists. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Remove unreachable handling of list constructor in type propagation Created 5 years, 1 month 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
« no previous file with comments | « pkg/compiler/lib/src/cps_ir/cps_ir_builder.dart ('k') | pkg/compiler/lib/src/cps_ir/cps_ir_nodes.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/cps_ir/cps_ir_builder_task.dart
diff --git a/pkg/compiler/lib/src/cps_ir/cps_ir_builder_task.dart b/pkg/compiler/lib/src/cps_ir/cps_ir_builder_task.dart
index c1b33e0c04633c3530bdefd013d64b079d4d03fe..5a771812d4d97dfd3927c7a82bb42251393ec0ec 100644
--- a/pkg/compiler/lib/src/cps_ir/cps_ir_builder_task.dart
+++ b/pkg/compiler/lib/src/cps_ir/cps_ir_builder_task.dart
@@ -235,6 +235,16 @@ abstract class IrBuilderVisitor extends ast.Visitor<ir.Primitive>
return irBuilder.makeFunctionDefinition();
}
+ /// Returns the allocation site-specific type for a given allocation.
+ ///
+ /// Currently, it is an error to call this with anything that is not the
+ /// allocation site for a List object (a literal list or a call to one
+ /// of the List constructors).
+ TypeMask getAllocationSiteType(ast.Node node) {
+ return compiler.typesTask.getGuaranteedTypeOfNode(
+ elements.analyzedElement, node);
+ }
+
ir.Primitive visit(ast.Node node) => node.accept(this);
// ## Statements ##
@@ -634,7 +644,8 @@ abstract class IrBuilderVisitor extends ast.Visitor<ir.Primitive>
}
List<ir.Primitive> values = node.elements.nodes.mapToList(visit);
InterfaceType type = elements.getType(node);
- return irBuilder.buildListLiteral(type, values);
+ return irBuilder.buildListLiteral(type, values,
+ allocationSiteType: getAllocationSiteType(node));
}
ir.Primitive visitLiteralMap(ast.LiteralMap node) {
@@ -3278,12 +3289,21 @@ class JsIrBuilderVisitor extends IrBuilderVisitor {
// Use default values from the effective target, not the immediate target.
ConstructorElement target = constructor.effectiveTarget;
arguments = normalizeStaticArguments(callStructure, target, arguments);
+ TypeMask allocationSiteType;
+ ast.Node send = node.send;
+ if (Elements.isFixedListConstructorCall(constructor, send, compiler) ||
+ Elements.isGrowableListConstructorCall(constructor, send, compiler) ||
+ Elements.isFilledListConstructorCall(constructor, send, compiler) ||
+ Elements.isConstructorOfTypedArraySubclass(constructor, compiler)) {
+ allocationSiteType = getAllocationSiteType(send);
+ }
return irBuilder.buildConstructorInvocation(
target,
callStructure,
constructor.computeEffectiveTargetType(type),
arguments,
- sourceInformationBuilder.buildNew(node));
+ sourceInformationBuilder.buildNew(node),
+ allocationSiteType: allocationSiteType);
}
@override
« no previous file with comments | « pkg/compiler/lib/src/cps_ir/cps_ir_builder.dart ('k') | pkg/compiler/lib/src/cps_ir/cps_ir_nodes.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698