Chromium Code Reviews| 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 3213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3224 } else { | 3224 } else { |
| 3225 return HType.UNKNOWN; | 3225 return HType.UNKNOWN; |
| 3226 } | 3226 } |
| 3227 } | 3227 } |
| 3228 | 3228 |
| 3229 Element constructor = elements[node]; | 3229 Element constructor = elements[node]; |
| 3230 Selector selector = elements.getSelector(node); | 3230 Selector selector = elements.getSelector(node); |
| 3231 if (compiler.enqueuer.resolution.getCachedElements(constructor) == null) { | 3231 if (compiler.enqueuer.resolution.getCachedElements(constructor) == null) { |
| 3232 compiler.internalError("Unresolved element: $constructor", node: node); | 3232 compiler.internalError("Unresolved element: $constructor", node: node); |
| 3233 } | 3233 } |
| 3234 | |
| 3235 // Compute the right target and type for redirecting generative and | |
| 3236 // factory constructors. | |
|
ahe
2013/01/29 09:30:58
This should be done by the resolver. At least add
ngeoffray
2013/01/29 09:37:22
What would it take to move it to the resolver? Kar
karlklose
2013/01/29 12:37:00
Why do you think this belongs in the resolver (and
| |
| 3234 FunctionElement functionElement = constructor; | 3237 FunctionElement functionElement = constructor; |
| 3235 constructor = functionElement.redirectionTarget; | 3238 if (functionElement.redirectionTarget != functionElement) { |
|
ngeoffray
2013/01/29 10:23:35
@Peter: Why are we changing constructor here? The
ahe
2013/01/29 10:57:48
Because I didn't know better.
ngeoffray
2013/01/29 11:03:20
After talking to Karl, it looks like we would stil
| |
| 3239 FunctionExpression functionNode = constructor.parseNode(compiler); | |
| 3240 Node body = functionNode.body; | |
| 3241 if (body != null && body.asReturn() != null && | |
| 3242 body.asReturn().isRedirectingFactoryBody) { | |
| 3243 // Lookup the type expression used in the body and substitute the type | |
| 3244 // variables with the call's type arguments in it. | |
| 3245 Return redirectionNode = body; | |
| 3246 TreeElements treeElements = | |
| 3247 compiler.enqueuer.resolution.getCachedElements( | |
| 3248 constructor.declaration); | |
| 3249 ClassElement targetClass = constructor.getEnclosingClass(); | |
| 3250 DartType targetType = treeElements.getType(redirectionNode.expression); | |
| 3251 Link<DartType> typeVariables = targetClass.typeVariables; | |
| 3252 Link<DartType> typeArguments = type.typeArguments; | |
| 3253 type = targetType.subst(typeArguments, typeVariables); | |
| 3254 } | |
| 3255 constructor = functionElement.redirectionTarget; | |
| 3256 } | |
| 3257 | |
| 3258 // TODO(karlklose): move this type registration to the codegen. | |
| 3259 compiler.codegenWorld.instantiatedTypes.add(type); | |
| 3260 | |
| 3236 // TODO(5346): Try to avoid the need for calling [declaration] before | 3261 // TODO(5346): Try to avoid the need for calling [declaration] before |
| 3237 // creating an [HStatic]. | 3262 // creating an [HStatic]. |
| 3238 HInstruction target = new HStatic(constructor.declaration); | 3263 HInstruction target = new HStatic(constructor.declaration); |
| 3239 add(target); | 3264 add(target); |
| 3240 var inputs = <HInstruction>[]; | 3265 var inputs = <HInstruction>[]; |
| 3241 inputs.add(target); | 3266 inputs.add(target); |
| 3242 // TODO(5347): Try to avoid the need for calling [implementation] before | 3267 // TODO(5347): Try to avoid the need for calling [implementation] before |
| 3243 // calling [addStaticSendArgumentsToList]. | 3268 // calling [addStaticSendArgumentsToList]. |
| 3244 bool succeeded = addStaticSendArgumentsToList(selector, node.arguments, | 3269 bool succeeded = addStaticSendArgumentsToList(selector, node.arguments, |
| 3245 constructor.implementation, | 3270 constructor.implementation, |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3484 Constant constant = handler.compileNodeWithDefinitions(node, elements); | 3509 Constant constant = handler.compileNodeWithDefinitions(node, elements); |
| 3485 stack.add(graph.addConstant(constant)); | 3510 stack.add(graph.addConstant(constant)); |
| 3486 } else { | 3511 } else { |
| 3487 DartType type = elements.getType(node); | 3512 DartType type = elements.getType(node); |
| 3488 if (compiler.enableTypeAssertions && type.isMalformed) { | 3513 if (compiler.enableTypeAssertions && type.isMalformed) { |
| 3489 String reasons = Types.fetchReasonsFromMalformedType(type); | 3514 String reasons = Types.fetchReasonsFromMalformedType(type); |
| 3490 // TODO(johnniwinther): Change to resemble type errors from bounds check | 3515 // TODO(johnniwinther): Change to resemble type errors from bounds check |
| 3491 // on type arguments. | 3516 // on type arguments. |
| 3492 generateRuntimeError(node, '$type is malformed: $reasons'); | 3517 generateRuntimeError(node, '$type is malformed: $reasons'); |
| 3493 } else { | 3518 } else { |
| 3494 // TODO(karlklose): move this type registration to the codegen. | |
| 3495 compiler.codegenWorld.instantiatedTypes.add(type); | |
| 3496 visitNewSend(node.send, type); | 3519 visitNewSend(node.send, type); |
| 3497 } | 3520 } |
| 3498 } | 3521 } |
| 3499 } | 3522 } |
| 3500 | 3523 |
| 3501 HInvokeDynamicMethod buildInvokeDynamic(Node node, | 3524 HInvokeDynamicMethod buildInvokeDynamic(Node node, |
| 3502 Selector selector, | 3525 Selector selector, |
| 3503 HInstruction receiver, | 3526 HInstruction receiver, |
| 3504 List<HInstruction> arguments) { | 3527 List<HInstruction> arguments) { |
| 3505 Set<ClassElement> interceptedClasses = getInterceptedClassesOn(selector); | 3528 Set<ClassElement> interceptedClasses = getInterceptedClassesOn(selector); |
| (...skipping 1445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4951 new HSubGraphBlockInformation(elseBranch.graph)); | 4974 new HSubGraphBlockInformation(elseBranch.graph)); |
| 4952 | 4975 |
| 4953 HBasicBlock conditionStartBlock = conditionBranch.block; | 4976 HBasicBlock conditionStartBlock = conditionBranch.block; |
| 4954 conditionStartBlock.setBlockFlow(info, joinBlock); | 4977 conditionStartBlock.setBlockFlow(info, joinBlock); |
| 4955 SubGraph conditionGraph = conditionBranch.graph; | 4978 SubGraph conditionGraph = conditionBranch.graph; |
| 4956 HIf branch = conditionGraph.end.last; | 4979 HIf branch = conditionGraph.end.last; |
| 4957 assert(branch is HIf); | 4980 assert(branch is HIf); |
| 4958 branch.blockInformation = conditionStartBlock.blockFlow; | 4981 branch.blockInformation = conditionStartBlock.blockFlow; |
| 4959 } | 4982 } |
| 4960 } | 4983 } |
| OLD | NEW |