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

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

Issue 11418173: Canonicalize raw type (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 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 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 override [Element.computeType] because our 9 * methods. We need to override [Element.computeType] because our
10 * optimizers may look at its declared type. 10 * optimizers may look at its declared type.
(...skipping 3042 matching lines...) Expand 10 before | Expand all | Expand 10 after
3053 } else { 3053 } else {
3054 target = new HInvokeSuper(inputs); 3054 target = new HInvokeSuper(inputs);
3055 add(target); 3055 add(target);
3056 inputs = <HInstruction>[target]; 3056 inputs = <HInstruction>[target];
3057 addDynamicSendArgumentsToList(node, inputs); 3057 addDynamicSendArgumentsToList(node, inputs);
3058 push(new HInvokeClosure(selector, inputs)); 3058 push(new HInvokeClosure(selector, inputs));
3059 } 3059 }
3060 } 3060 }
3061 3061
3062 HInstruction analyzeTypeArgument(DartType argument, Node currentNode) { 3062 HInstruction analyzeTypeArgument(DartType argument, Node currentNode) {
3063 if (argument == compiler.types.dynamicType) {
ngeoffray 2012/11/27 12:30:15 Please add a comment here.
Johnni Winther 2012/11/28 08:18:38 Done.
3064 return graph.addConstantNull(constantSystem);
3065 }
3066
3063 // These variables are shared between invocations of the helper methods. 3067 // These variables are shared between invocations of the helper methods.
3064 HInstruction typeInfo; 3068 HInstruction typeInfo;
3065 StringBuffer template = new StringBuffer(); 3069 StringBuffer template = new StringBuffer();
3066 List<HInstruction> inputs = <HInstruction>[]; 3070 List<HInstruction> inputs = <HInstruction>[];
3067 3071
3068 /** 3072 /**
3069 * Helper to create an instruction that gets the value of a type variable. 3073 * Helper to create an instruction that gets the value of a type variable.
3070 */ 3074 */
3071 void addTypeVariableReference(TypeVariableType type) { 3075 void addTypeVariableReference(TypeVariableType type) {
3072 Element member = work.element; 3076 Element member = work.element;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
3112 * Var # [getRuntimeType(this).Var] 3116 * Var # [getRuntimeType(this).Var]
3113 * C<int, D<Var>> 'C<int, D<' + # + '>>' [getRuntimeType(this).Var] 3117 * C<int, D<Var>> 'C<int, D<' + # + '>>' [getRuntimeType(this).Var]
3114 */ 3118 */
3115 void buildTypeString(DartType type, {isInQuotes: false}) { 3119 void buildTypeString(DartType type, {isInQuotes: false}) {
3116 if (type is TypeVariableType) { 3120 if (type is TypeVariableType) {
3117 addTypeVariableReference(type); 3121 addTypeVariableReference(type);
3118 template.add(isInQuotes ? "' + # +'" : "#"); 3122 template.add(isInQuotes ? "' + # +'" : "#");
3119 } else if (type is InterfaceType) { 3123 } else if (type is InterfaceType) {
3120 bool isFirstVariable = true; 3124 bool isFirstVariable = true;
3121 InterfaceType interfaceType = type; 3125 InterfaceType interfaceType = type;
3122 bool hasTypeArguments = !interfaceType.typeArguments.isEmpty; 3126 bool hasTypeArguments = !interfaceType.isRaw;
3123 if (!isInQuotes) template.add("'"); 3127 if (!isInQuotes) template.add("'");
3124 template.add(backend.namer.getName(type.element)); 3128 template.add(backend.namer.getName(type.element));
3125 if (hasTypeArguments) { 3129 if (hasTypeArguments) {
3126 template.add("<"); 3130 template.add("<");
3127 for (DartType argument in interfaceType.typeArguments) { 3131 for (DartType argument in interfaceType.typeArguments) {
3128 if (!isFirstVariable) { 3132 if (!isFirstVariable) {
3129 template.add(", "); 3133 template.add(", ");
3130 } else { 3134 } else {
3131 isFirstVariable = false; 3135 isFirstVariable = false;
3132 } 3136 }
(...skipping 16 matching lines...) Expand all
3149 new LiteralDartString('String'), 3153 new LiteralDartString('String'),
3150 inputs); 3154 inputs);
3151 add(result); 3155 add(result);
3152 return result; 3156 return result;
3153 } 3157 }
3154 3158
3155 void handleListConstructor(InterfaceType type, 3159 void handleListConstructor(InterfaceType type,
3156 Node currentNode, 3160 Node currentNode,
3157 HInstruction newObject) { 3161 HInstruction newObject) {
3158 if (!compiler.world.needsRti(type.element)) return; 3162 if (!compiler.world.needsRti(type.element)) return;
3163 if (type.isRaw) return;
3159 List<HInstruction> inputs = <HInstruction>[]; 3164 List<HInstruction> inputs = <HInstruction>[];
3160 type.typeArguments.forEach((DartType argument) { 3165 type.typeArguments.forEach((DartType argument) {
3161 inputs.add(analyzeTypeArgument(argument, currentNode)); 3166 inputs.add(analyzeTypeArgument(argument, currentNode));
3162 }); 3167 });
3163 callSetRuntimeTypeInfo(type.element, inputs, newObject); 3168 callSetRuntimeTypeInfo(type.element, inputs, newObject);
3164 } 3169 }
3165 3170
3166 void callSetRuntimeTypeInfo(ClassElement element, 3171 void callSetRuntimeTypeInfo(ClassElement element,
3167 List<HInstruction> rtiInputs, 3172 List<HInstruction> rtiInputs,
3168 HInstruction newObject) { 3173 HInstruction newObject) {
(...skipping 18 matching lines...) Expand all
3187 Element originalElement = elements[node]; 3192 Element originalElement = elements[node];
3188 if (identical(originalElement.getEnclosingClass(), compiler.listClass)) { 3193 if (identical(originalElement.getEnclosingClass(), compiler.listClass)) {
3189 isListConstructor = true; 3194 isListConstructor = true;
3190 if (node.arguments.isEmpty) { 3195 if (node.arguments.isEmpty) {
3191 return HType.EXTENDABLE_ARRAY; 3196 return HType.EXTENDABLE_ARRAY;
3192 } else { 3197 } else {
3193 return HType.MUTABLE_ARRAY; 3198 return HType.MUTABLE_ARRAY;
3194 } 3199 }
3195 } else if (element.isGenerativeConstructor()) { 3200 } else if (element.isGenerativeConstructor()) {
3196 ClassElement cls = element.getEnclosingClass(); 3201 ClassElement cls = element.getEnclosingClass();
3197 return new HBoundedType.exact(cls.type); 3202 return new HBoundedType.exact(cls.thisType);
3198 } else { 3203 } else {
3199 return HType.UNKNOWN; 3204 return HType.UNKNOWN;
3200 } 3205 }
3201 } 3206 }
3202 3207
3203 Element constructor = elements[node]; 3208 Element constructor = elements[node];
3204 Selector selector = elements.getSelector(node); 3209 Selector selector = elements.getSelector(node);
3205 if (compiler.enqueuer.resolution.getCachedElements(constructor) == null) { 3210 if (compiler.enqueuer.resolution.getCachedElements(constructor) == null) {
3206 compiler.internalError("Unresolved element: $constructor", node: node); 3211 compiler.internalError("Unresolved element: $constructor", node: node);
3207 } 3212 }
(...skipping 14 matching lines...) Expand all
3222 generateWrongArgumentCountError(node, constructor, node.arguments); 3227 generateWrongArgumentCountError(node, constructor, node.arguments);
3223 return; 3228 return;
3224 } 3229 }
3225 3230
3226 if (constructor.getEnclosingClass().isAbstract(compiler) && 3231 if (constructor.getEnclosingClass().isAbstract(compiler) &&
3227 constructor.isGenerativeConstructor()) { 3232 constructor.isGenerativeConstructor()) {
3228 generateAbstractClassInstantiationError(node, type.name.slowToString()); 3233 generateAbstractClassInstantiationError(node, type.name.slowToString());
3229 return; 3234 return;
3230 } 3235 }
3231 if (compiler.world.needsRti(constructor.enclosingElement)) { 3236 if (compiler.world.needsRti(constructor.enclosingElement)) {
3232 if (!type.typeArguments.isEmpty) { 3237 if (!type.isRaw) {
3233 type.typeArguments.forEach((DartType argument) { 3238 type.typeArguments.forEach((DartType argument) {
3234 inputs.add(analyzeTypeArgument(argument, node)); 3239 inputs.add(analyzeTypeArgument(argument, node));
3235 }); 3240 });
3236 } 3241 }
3237 } 3242 }
3238 3243
3239 HType elementType = computeType(constructor); 3244 HType elementType = computeType(constructor);
3240 HInstruction newInstance = new HInvokeStatic(inputs, elementType); 3245 HInstruction newInstance = new HInvokeStatic(inputs, elementType);
3241 pushWithPosition(newInstance, node); 3246 pushWithPosition(newInstance, node);
3242 3247
(...skipping 1652 matching lines...) Expand 10 before | Expand all | Expand 10 after
4895 new HSubGraphBlockInformation(elseBranch.graph)); 4900 new HSubGraphBlockInformation(elseBranch.graph));
4896 4901
4897 HBasicBlock conditionStartBlock = conditionBranch.block; 4902 HBasicBlock conditionStartBlock = conditionBranch.block;
4898 conditionStartBlock.setBlockFlow(info, joinBlock); 4903 conditionStartBlock.setBlockFlow(info, joinBlock);
4899 SubGraph conditionGraph = conditionBranch.graph; 4904 SubGraph conditionGraph = conditionBranch.graph;
4900 HIf branch = conditionGraph.end.last; 4905 HIf branch = conditionGraph.end.last;
4901 assert(branch is HIf); 4906 assert(branch is HIf);
4902 branch.blockInformation = conditionStartBlock.blockFlow; 4907 branch.blockInformation = conditionStartBlock.blockFlow;
4903 } 4908 }
4904 } 4909 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698