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

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

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

Powered by Google App Engine
This is Rietveld 408576698