| OLD | NEW |
| 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 1947 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1958 | 1958 |
| 1959 startBlock.setBlockFlow(info, current); | 1959 startBlock.setBlockFlow(info, current); |
| 1960 loopInfo.loopBlockInformation = info; | 1960 loopInfo.loopBlockInformation = info; |
| 1961 } else { | 1961 } else { |
| 1962 // There is no back edge for the loop, so we turn the code into: | 1962 // There is no back edge for the loop, so we turn the code into: |
| 1963 // if (condition) { | 1963 // if (condition) { |
| 1964 // body; | 1964 // body; |
| 1965 // } else { | 1965 // } else { |
| 1966 // // We always create an empty else block to avoid critical edges. | 1966 // // We always create an empty else block to avoid critical edges. |
| 1967 // } | 1967 // } |
| 1968 // | 1968 // |
| 1969 // If there is any break in the body, we attach a synthetic | 1969 // If there is any break in the body, we attach a synthetic |
| 1970 // label to the if. | 1970 // label to the if. |
| 1971 HBasicBlock elseBlock = addNewBlock(); | 1971 HBasicBlock elseBlock = addNewBlock(); |
| 1972 open(elseBlock); | 1972 open(elseBlock); |
| 1973 close(new HGoto()); | 1973 close(new HGoto()); |
| 1974 endLoop(conditionBlock, null, jumpHandler, savedLocals); | 1974 endLoop(conditionBlock, null, jumpHandler, savedLocals); |
| 1975 | 1975 |
| 1976 // [endLoop] will not create an exit block if there are no | 1976 // [endLoop] will not create an exit block if there are no |
| 1977 // breaks. | 1977 // breaks. |
| 1978 if (current == null) open(addNewBlock()); | 1978 if (current == null) open(addNewBlock()); |
| (...skipping 1133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3112 * Var # [getRuntimeType(this).Var] | 3112 * Var # [getRuntimeType(this).Var] |
| 3113 * C<int, D<Var>> 'C<int, D<' + # + '>>' [getRuntimeType(this).Var] | 3113 * C<int, D<Var>> 'C<int, D<' + # + '>>' [getRuntimeType(this).Var] |
| 3114 */ | 3114 */ |
| 3115 void buildTypeString(DartType type, {isInQuotes: false}) { | 3115 void buildTypeString(DartType type, {isInQuotes: false}) { |
| 3116 if (type is TypeVariableType) { | 3116 if (type is TypeVariableType) { |
| 3117 addTypeVariableReference(type); | 3117 addTypeVariableReference(type); |
| 3118 template.add(isInQuotes ? "' + # +'" : "#"); | 3118 template.add(isInQuotes ? "' + # +'" : "#"); |
| 3119 } else if (type is InterfaceType) { | 3119 } else if (type is InterfaceType) { |
| 3120 bool isFirstVariable = true; | 3120 bool isFirstVariable = true; |
| 3121 InterfaceType interfaceType = type; | 3121 InterfaceType interfaceType = type; |
| 3122 bool hasTypeArguments = !interfaceType.arguments.isEmpty; | 3122 bool hasTypeArguments = !interfaceType.typeArguments.isEmpty; |
| 3123 if (!isInQuotes) template.add("'"); | 3123 if (!isInQuotes) template.add("'"); |
| 3124 template.add(backend.namer.getName(type.element)); | 3124 template.add(backend.namer.getName(type.element)); |
| 3125 if (hasTypeArguments) { | 3125 if (hasTypeArguments) { |
| 3126 template.add("<"); | 3126 template.add("<"); |
| 3127 for (DartType argument in interfaceType.arguments) { | 3127 for (DartType argument in interfaceType.typeArguments) { |
| 3128 if (!isFirstVariable) { | 3128 if (!isFirstVariable) { |
| 3129 template.add(", "); | 3129 template.add(", "); |
| 3130 } else { | 3130 } else { |
| 3131 isFirstVariable = false; | 3131 isFirstVariable = false; |
| 3132 } | 3132 } |
| 3133 buildTypeString(argument, isInQuotes: true); | 3133 buildTypeString(argument, isInQuotes: true); |
| 3134 } | 3134 } |
| 3135 template.add(">"); | 3135 template.add(">"); |
| 3136 } | 3136 } |
| 3137 if (!isInQuotes) template.add("'"); | 3137 if (!isInQuotes) template.add("'"); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 3150 inputs); | 3150 inputs); |
| 3151 add(result); | 3151 add(result); |
| 3152 return result; | 3152 return result; |
| 3153 } | 3153 } |
| 3154 | 3154 |
| 3155 void handleListConstructor(InterfaceType type, | 3155 void handleListConstructor(InterfaceType type, |
| 3156 Node currentNode, | 3156 Node currentNode, |
| 3157 HInstruction newObject) { | 3157 HInstruction newObject) { |
| 3158 if (!compiler.world.needsRti(type.element)) return; | 3158 if (!compiler.world.needsRti(type.element)) return; |
| 3159 List<HInstruction> inputs = <HInstruction>[]; | 3159 List<HInstruction> inputs = <HInstruction>[]; |
| 3160 type.arguments.forEach((DartType argument) { | 3160 type.typeArguments.forEach((DartType argument) { |
| 3161 inputs.add(analyzeTypeArgument(argument, currentNode)); | 3161 inputs.add(analyzeTypeArgument(argument, currentNode)); |
| 3162 }); | 3162 }); |
| 3163 callSetRuntimeTypeInfo(type.element, inputs, newObject); | 3163 callSetRuntimeTypeInfo(type.element, inputs, newObject); |
| 3164 } | 3164 } |
| 3165 | 3165 |
| 3166 void callSetRuntimeTypeInfo(ClassElement element, | 3166 void callSetRuntimeTypeInfo(ClassElement element, |
| 3167 List<HInstruction> rtiInputs, | 3167 List<HInstruction> rtiInputs, |
| 3168 HInstruction newObject) { | 3168 HInstruction newObject) { |
| 3169 if (!compiler.world.needsRti(element) || element.typeVariables.isEmpty) { | 3169 if (!compiler.world.needsRti(element) || element.typeVariables.isEmpty) { |
| 3170 return; | 3170 return; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3222 generateWrongArgumentCountError(node, constructor, node.arguments); | 3222 generateWrongArgumentCountError(node, constructor, node.arguments); |
| 3223 return; | 3223 return; |
| 3224 } | 3224 } |
| 3225 | 3225 |
| 3226 if (constructor.getEnclosingClass().isAbstract(compiler) && | 3226 if (constructor.getEnclosingClass().isAbstract(compiler) && |
| 3227 constructor.isGenerativeConstructor()) { | 3227 constructor.isGenerativeConstructor()) { |
| 3228 generateAbstractClassInstantiationError(node, type.name.slowToString()); | 3228 generateAbstractClassInstantiationError(node, type.name.slowToString()); |
| 3229 return; | 3229 return; |
| 3230 } | 3230 } |
| 3231 if (compiler.world.needsRti(constructor.enclosingElement)) { | 3231 if (compiler.world.needsRti(constructor.enclosingElement)) { |
| 3232 if (!type.arguments.isEmpty) { | 3232 if (!type.typeArguments.isEmpty) { |
| 3233 type.arguments.forEach((DartType argument) { | 3233 type.typeArguments.forEach((DartType argument) { |
| 3234 inputs.add(analyzeTypeArgument(argument, node)); | 3234 inputs.add(analyzeTypeArgument(argument, node)); |
| 3235 }); | 3235 }); |
| 3236 } | 3236 } |
| 3237 } | 3237 } |
| 3238 | 3238 |
| 3239 HType elementType = computeType(constructor); | 3239 HType elementType = computeType(constructor); |
| 3240 HInstruction newInstance = new HInvokeStatic(inputs, elementType); | 3240 HInstruction newInstance = new HInvokeStatic(inputs, elementType); |
| 3241 pushWithPosition(newInstance, node); | 3241 pushWithPosition(newInstance, node); |
| 3242 | 3242 |
| 3243 // The List constructor forwards to a Dart static method that does | 3243 // The List constructor forwards to a Dart static method that does |
| (...skipping 1646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4890 new HSubGraphBlockInformation(elseBranch.graph)); | 4890 new HSubGraphBlockInformation(elseBranch.graph)); |
| 4891 | 4891 |
| 4892 HBasicBlock conditionStartBlock = conditionBranch.block; | 4892 HBasicBlock conditionStartBlock = conditionBranch.block; |
| 4893 conditionStartBlock.setBlockFlow(info, joinBlock); | 4893 conditionStartBlock.setBlockFlow(info, joinBlock); |
| 4894 SubGraph conditionGraph = conditionBranch.graph; | 4894 SubGraph conditionGraph = conditionBranch.graph; |
| 4895 HIf branch = conditionGraph.end.last; | 4895 HIf branch = conditionGraph.end.last; |
| 4896 assert(branch is HIf); | 4896 assert(branch is HIf); |
| 4897 branch.blockInformation = conditionStartBlock.blockFlow; | 4897 branch.blockInformation = conditionStartBlock.blockFlow; |
| 4898 } | 4898 } |
| 4899 } | 4899 } |
| OLD | NEW |