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 1160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1171 */ | 1171 */ |
1172 void inlineSuperOrRedirect(FunctionElement constructor, | 1172 void inlineSuperOrRedirect(FunctionElement constructor, |
1173 Selector selector, | 1173 Selector selector, |
1174 Link<Node> arguments, | 1174 Link<Node> arguments, |
1175 List<FunctionElement> constructors, | 1175 List<FunctionElement> constructors, |
1176 Map<Element, HInstruction> fieldValues, | 1176 Map<Element, HInstruction> fieldValues, |
1177 FunctionElement inlinedFromElement, | 1177 FunctionElement inlinedFromElement, |
1178 Node callNode) { | 1178 Node callNode) { |
1179 compiler.withCurrentElement(constructor, () { | 1179 compiler.withCurrentElement(constructor, () { |
1180 assert(invariant(constructor, constructor.isImplementation)); | 1180 assert(invariant(constructor, constructor.isImplementation)); |
1181 constructors.addLast(constructor); | 1181 constructors.add(constructor); |
1182 | 1182 |
1183 List<HInstruction> compiledArguments = new List<HInstruction>(); | 1183 List<HInstruction> compiledArguments = new List<HInstruction>(); |
1184 bool succeeded = | 1184 bool succeeded = |
1185 inlinedFrom(inlinedFromElement, | 1185 inlinedFrom(inlinedFromElement, |
1186 () => addStaticSendArgumentsToList(selector, | 1186 () => addStaticSendArgumentsToList(selector, |
1187 arguments, | 1187 arguments, |
1188 constructor, | 1188 constructor, |
1189 compiledArguments)); | 1189 compiledArguments)); |
1190 if (!succeeded) { | 1190 if (!succeeded) { |
1191 // Non-matching super and redirects are compile-time errors and thus | 1191 // Non-matching super and redirects are compile-time errors and thus |
1192 // checked by the resolver. | 1192 // checked by the resolver. |
1193 compiler.internalError( | 1193 compiler.internalError( |
1194 "Parameters and arguments didn't match for super/redirect call", | 1194 "Parameters and arguments didn't match for super/redirect call", |
1195 element: constructor); | 1195 element: constructor); |
1196 } | 1196 } |
1197 | 1197 |
1198 ClassElement superclass = constructor.getEnclosingClass(); | 1198 ClassElement superclass = constructor.getEnclosingClass(); |
1199 if (compiler.world.needsRti(superclass)) { | 1199 if (compiler.world.needsRti(superclass)) { |
1200 // If [superclass] needs RTI, we have to give a value to its | 1200 // If [superclass] needs RTI, we have to give a value to its |
1201 // type parameters. Those values are in the [supertype] | 1201 // type parameters. Those values are in the [supertype] |
1202 // declaration of [subclass]. | 1202 // declaration of [subclass]. |
1203 ClassElement subclass = inlinedFromElement.getEnclosingClass(); | 1203 ClassElement subclass = inlinedFromElement.getEnclosingClass(); |
1204 DartType supertype = subclass.supertype; | 1204 InterfaceType supertype = subclass.supertype; |
1205 Link<DartType> typeVariables = superclass.typeVariables; | 1205 Link<DartType> typeVariables = superclass.typeVariables; |
1206 supertype.typeArguments.forEach((DartType argument) { | 1206 supertype.typeArguments.forEach((DartType argument) { |
1207 localsHandler.updateLocal(typeVariables.head.element, | 1207 localsHandler.updateLocal(typeVariables.head.element, |
1208 analyzeTypeArgument(argument, callNode)); | 1208 analyzeTypeArgument(argument, callNode)); |
1209 typeVariables = typeVariables.tail; | 1209 typeVariables = typeVariables.tail; |
1210 }); | 1210 }); |
1211 // If the supertype is a raw type, we need to set to null the | 1211 // If the supertype is a raw type, we need to set to null the |
1212 // type variables. | 1212 // type variables. |
1213 assert(typeVariables.isEmpty | 1213 assert(typeVariables.isEmpty |
1214 || superclass.typeVariables == typeVariables); | 1214 || superclass.typeVariables == typeVariables); |
(...skipping 2880 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4095 ConstantHandler handler = compiler.constantHandler; | 4095 ConstantHandler handler = compiler.constantHandler; |
4096 Constant constant = handler.compileNodeWithDefinitions(node, elements); | 4096 Constant constant = handler.compileNodeWithDefinitions(node, elements); |
4097 stack.add(graph.addConstant(constant)); | 4097 stack.add(graph.addConstant(constant)); |
4098 return; | 4098 return; |
4099 } | 4099 } |
4100 List<HInstruction> inputs = <HInstruction>[]; | 4100 List<HInstruction> inputs = <HInstruction>[]; |
4101 for (Link<Node> link = node.entries.nodes; | 4101 for (Link<Node> link = node.entries.nodes; |
4102 !link.isEmpty; | 4102 !link.isEmpty; |
4103 link = link.tail) { | 4103 link = link.tail) { |
4104 visit(link.head); | 4104 visit(link.head); |
4105 inputs.addLast(pop()); | 4105 inputs.add(pop()); |
4106 inputs.addLast(pop()); | 4106 inputs.add(pop()); |
4107 } | 4107 } |
4108 HLiteralList keyValuePairs = new HLiteralList(inputs); | 4108 HLiteralList keyValuePairs = new HLiteralList(inputs); |
4109 add(keyValuePairs); | 4109 add(keyValuePairs); |
4110 DartType mapType = compiler.mapLiteralClass.computeType(compiler); | 4110 DartType mapType = compiler.mapLiteralClass.computeType(compiler); |
4111 // TODO(ngeoffray): Use the actual implementation type of a map | 4111 // TODO(ngeoffray): Use the actual implementation type of a map |
4112 // literal. | 4112 // literal. |
4113 pushInvokeHelper1(backend.getMapMaker(), keyValuePairs, | 4113 pushInvokeHelper1(backend.getMapMaker(), keyValuePairs, |
4114 new HType.nonNullSubtype(mapType, compiler)); | 4114 new HType.nonNullSubtype(mapType, compiler)); |
4115 } | 4115 } |
4116 | 4116 |
(...skipping 978 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5095 new HSubGraphBlockInformation(elseBranch.graph)); | 5095 new HSubGraphBlockInformation(elseBranch.graph)); |
5096 | 5096 |
5097 HBasicBlock conditionStartBlock = conditionBranch.block; | 5097 HBasicBlock conditionStartBlock = conditionBranch.block; |
5098 conditionStartBlock.setBlockFlow(info, joinBlock); | 5098 conditionStartBlock.setBlockFlow(info, joinBlock); |
5099 SubGraph conditionGraph = conditionBranch.graph; | 5099 SubGraph conditionGraph = conditionBranch.graph; |
5100 HIf branch = conditionGraph.end.last; | 5100 HIf branch = conditionGraph.end.last; |
5101 assert(branch is HIf); | 5101 assert(branch is HIf); |
5102 branch.blockInformation = conditionStartBlock.blockFlow; | 5102 branch.blockInformation = conditionStartBlock.blockFlow; |
5103 } | 5103 } |
5104 } | 5104 } |
OLD | NEW |