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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/ssa/builder.dart

Issue 229083002: Revert "Construct literal maps using factory constructor." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of ssa; 5 part of ssa;
6 6
7 /** 7 /**
8 * A special element for the extra parameter taken by intercepted 8 * A special element for the extra parameter taken by intercepted
9 * methods. We need to implement [TypedElement.type] because our 9 * methods. We need to implement [TypedElement.type] because our
10 * optimizers may look at its declared type. 10 * optimizers may look at its declared type.
(...skipping 5021 matching lines...) Expand 10 before | Expand all | Expand 10 after
5032 joinBlock); 5032 joinBlock);
5033 } 5033 }
5034 handler.close(); 5034 handler.close();
5035 } 5035 }
5036 5036
5037 visitLiteralMap(ast.LiteralMap node) { 5037 visitLiteralMap(ast.LiteralMap node) {
5038 if (node.isConst()) { 5038 if (node.isConst()) {
5039 stack.add(addConstant(node)); 5039 stack.add(addConstant(node));
5040 return; 5040 return;
5041 } 5041 }
5042 List<HInstruction> listInputs = <HInstruction>[]; 5042 List<HInstruction> inputs = <HInstruction>[];
5043 for (Link<ast.Node> link = node.entries.nodes; 5043 for (Link<ast.Node> link = node.entries.nodes;
5044 !link.isEmpty; 5044 !link.isEmpty;
5045 link = link.tail) { 5045 link = link.tail) {
5046 visit(link.head); 5046 visit(link.head);
5047 listInputs.add(pop()); 5047 inputs.add(pop());
5048 listInputs.add(pop()); 5048 inputs.add(pop());
5049 } 5049 }
5050 5050 HLiteralList keyValuePairs = buildLiteralList(inputs);
5051 Element constructor; 5051 add(keyValuePairs);
5052 List<HInstruction> inputs = <HInstruction>[]; 5052 TypeMask mapType = new TypeMask.nonNullSubtype(backend.mapLiteralClass);
5053 5053 pushInvokeStatic(node, backend.getMapMaker(), [keyValuePairs], mapType);
5054 if (listInputs.isEmpty) { 5054 stack.add(setRtiIfNeeded(pop(), node));
5055 constructor = backend.mapLiteralConstructorEmpty;
5056 } else {
5057 constructor = backend.mapLiteralConstructor;
5058 HLiteralList keyValuePairs = buildLiteralList(listInputs);
5059 add(keyValuePairs);
5060 inputs.add(keyValuePairs);
5061 }
5062
5063 assert(constructor.isFactoryConstructor());
5064
5065 FunctionElement functionElement = constructor;
5066 constructor = functionElement.redirectionTarget;
5067
5068 InterfaceType type = elements.getType(node);
5069 InterfaceType expectedType = functionElement.computeTargetType(type);
5070
5071 if (constructor.isFactoryConstructor()) {
5072 compiler.enqueuer.codegen.registerFactoryWithTypeArguments(elements);
5073 }
5074
5075 ClassElement cls = constructor.getEnclosingClass();
5076
5077 if (backend.classNeedsRti(cls)) {
5078 Link<DartType> typeVariable = cls.typeVariables;
5079 expectedType.typeArguments.forEach((DartType argument) {
5080 inputs.add(analyzeTypeArgument(argument));
5081 typeVariable = typeVariable.tail;
5082 });
5083 assert(typeVariable.isEmpty);
5084 }
5085
5086 TypeMask returnTypeMask = TypeMaskFactory.inferredReturnTypeForElement(
5087 constructor, compiler);
5088 addInlinedInstantiation(expectedType);
5089 pushInvokeStatic(node, constructor, inputs, returnTypeMask);
5090 removeInlinedInstantiation(expectedType);
5091 } 5055 }
5092 5056
5093 visitLiteralMapEntry(ast.LiteralMapEntry node) { 5057 visitLiteralMapEntry(ast.LiteralMapEntry node) {
5094 visit(node.value); 5058 visit(node.value);
5095 visit(node.key); 5059 visit(node.key);
5096 } 5060 }
5097 5061
5098 visitNamedArgument(ast.NamedArgument node) { 5062 visitNamedArgument(ast.NamedArgument node) {
5099 visit(node.expression); 5063 visit(node.expression);
5100 } 5064 }
(...skipping 1151 matching lines...) Expand 10 before | Expand all | Expand 10 after
6252 DartType unaliased = type.unalias(builder.compiler); 6216 DartType unaliased = type.unalias(builder.compiler);
6253 if (unaliased is TypedefType) throw 'unable to unalias $type'; 6217 if (unaliased is TypedefType) throw 'unable to unalias $type';
6254 unaliased.accept(this, builder); 6218 unaliased.accept(this, builder);
6255 } 6219 }
6256 6220
6257 void visitDynamicType(DynamicType type, SsaBuilder builder) { 6221 void visitDynamicType(DynamicType type, SsaBuilder builder) {
6258 ClassElement cls = builder.compiler.findHelper('DynamicRuntimeType'); 6222 ClassElement cls = builder.compiler.findHelper('DynamicRuntimeType');
6259 builder.push(new HDynamicType(type, new TypeMask.exact(cls))); 6223 builder.push(new HDynamicType(type, new TypeMask.exact(cls)));
6260 } 6224 }
6261 } 6225 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/js_backend/backend.dart ('k') | sdk/lib/_internal/lib/collection_patch.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698