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

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

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

Powered by Google App Engine
This is Rietveld 408576698