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

Unified Diff: pkg/compiler/lib/src/ssa/builder.dart

Issue 1051223003: dartj2s: add constructor helpers for map literals with no type parameters. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Added comment. Created 5 years, 8 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: pkg/compiler/lib/src/ssa/builder.dart
diff --git a/pkg/compiler/lib/src/ssa/builder.dart b/pkg/compiler/lib/src/ssa/builder.dart
index 58904818d0e55005fe7d326daa411b915fa5e338..1dee7a854b57909b49b4586ef0f5f050f8fd2617 100644
--- a/pkg/compiler/lib/src/ssa/builder.dart
+++ b/pkg/compiler/lib/src/ssa/builder.dart
@@ -5631,7 +5631,7 @@ class SsaBuilder extends NewResolvedVisitor {
listInputs.add(pop());
}
- ConstructorElement constructor;
+ Element constructor;
List<HInstruction> inputs = <HInstruction>[];
if (listInputs.isEmpty) {
@@ -5656,12 +5656,30 @@ class SsaBuilder extends NewResolvedVisitor {
ClassElement cls = constructor.enclosingClass;
if (backend.classNeedsRti(cls)) {
+ List<HInstruction> typeInputs = <HInstruction>[];
List<DartType> typeVariable = cls.typeVariables;
expectedType.typeArguments.forEach((DartType argument) {
- inputs.add(analyzeTypeArgument(argument));
+ typeInputs.add(analyzeTypeArgument(argument));
});
+
+ // We lift this common call pattern into a helper function to save space
+ // in the output.
+ if (typeInputs.every((HInstruction input) => input.isNull())) {
+ if (listInputs.isEmpty) {
+ constructor = backend.mapLiteralUntypedEmptyMaker;
+ } else {
+ constructor = backend.mapLiteralUntypedMaker;
+ }
+ } else {
+ inputs.addAll(typeInputs);
+ }
}
+ // If rti is needed and the map literal has no type parameters,
+ // 'constructor' is a static function that forwards the call to the factory
+ // constructor without type parameters.
+ assert(constructor is ConstructorElement || constructor is FunctionElement);
+
// The instruction type will always be a subtype of the mapLiteralClass, but
// type inference might discover a more specific type, or find nothing (in
// dart2js unit tests).
« no previous file with comments | « pkg/compiler/lib/src/js_backend/backend.dart ('k') | sdk/lib/_internal/compiler/js_lib/collection_patch.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698