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 implement [TypedElement.type] because our | 9 * methods. We need to implement [TypedElement.type] because our |
| 10 * optimizers may look at its declared type. | 10 * optimizers may look at its declared type. |
| (...skipping 1596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1607 * arguments are used. See invocations of [pushInvokeDynamic] in | 1607 * arguments are used. See invocations of [pushInvokeDynamic] in |
| 1608 * [visitForIn]. | 1608 * [visitForIn]. |
| 1609 */ | 1609 */ |
| 1610 return currentNode.asForIn() != null; | 1610 return currentNode.asForIn() != null; |
| 1611 } | 1611 } |
| 1612 | 1612 |
| 1613 /** | 1613 /** |
| 1614 * In checked mode, generate type tests for the parameters of the inlined | 1614 * In checked mode, generate type tests for the parameters of the inlined |
| 1615 * function. | 1615 * function. |
| 1616 */ | 1616 */ |
| 1617 void potentiallyCheckInlinedParameterTypes(FunctionElement function) { | 1617 void potentiallyCheckInlinedParameterTypes(FunctionElement function) { |
|
floitsch
2014/04/23 17:43:34
Should we bail out immediately if checked mode is
Johnni Winther
2014/04/24 08:32:28
Done.
| |
| 1618 FunctionSignature signature = function.functionSignature; | 1618 FunctionSignature signature = function.functionSignature; |
| 1619 | |
| 1620 InterfaceType contextType; | |
| 1621 if (function.isSynthesized && function.isGenerativeConstructor()) { | |
| 1622 // Synthesized constructors reuse the parameters from the | |
| 1623 // [targetConstructor]. In face of generic types, the type variables | |
| 1624 // occurring in the parameter types must be substituted by the type | |
| 1625 // arguments of the enclosing class. | |
| 1626 FunctionElement target = function; | |
| 1627 while (target.targetConstructor != null) { | |
| 1628 target = target.targetConstructor; | |
| 1629 } | |
| 1630 if (target != function) { | |
| 1631 ClassElement functionClass = function.getEnclosingClass(); | |
| 1632 ClassElement targetClass = target.getEnclosingClass(); | |
| 1633 contextType = functionClass.thisType.asInstanceOf(targetClass); | |
| 1634 } | |
| 1635 } | |
| 1636 | |
| 1619 signature.orderedForEachParameter((ParameterElement parameter) { | 1637 signature.orderedForEachParameter((ParameterElement parameter) { |
| 1620 HInstruction argument = localsHandler.readLocal(parameter); | 1638 HInstruction argument = localsHandler.readLocal(parameter); |
| 1621 potentiallyCheckType(argument, parameter.type); | 1639 DartType parameterType = parameter.type; |
| 1640 if (contextType != null) { | |
| 1641 parameterType = parameterType.substByContext(contextType); | |
| 1642 } | |
| 1643 potentiallyCheckType(argument, parameterType); | |
| 1622 }); | 1644 }); |
| 1623 } | 1645 } |
| 1624 | 1646 |
| 1625 /** | 1647 /** |
| 1626 * Documentation wanted -- johnniwinther | 1648 * Documentation wanted -- johnniwinther |
| 1627 * | 1649 * |
| 1628 * Invariant: [constructors] must contain only implementation elements. | 1650 * Invariant: [constructors] must contain only implementation elements. |
| 1629 */ | 1651 */ |
| 1630 void inlineSuperOrRedirect(FunctionElement callee, | 1652 void inlineSuperOrRedirect(FunctionElement callee, |
| 1631 List<HInstruction> compiledArguments, | 1653 List<HInstruction> compiledArguments, |
| (...skipping 4660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6292 DartType unaliased = type.unalias(builder.compiler); | 6314 DartType unaliased = type.unalias(builder.compiler); |
| 6293 if (unaliased is TypedefType) throw 'unable to unalias $type'; | 6315 if (unaliased is TypedefType) throw 'unable to unalias $type'; |
| 6294 unaliased.accept(this, builder); | 6316 unaliased.accept(this, builder); |
| 6295 } | 6317 } |
| 6296 | 6318 |
| 6297 void visitDynamicType(DynamicType type, SsaBuilder builder) { | 6319 void visitDynamicType(DynamicType type, SsaBuilder builder) { |
| 6298 ClassElement cls = builder.compiler.findHelper('DynamicRuntimeType'); | 6320 ClassElement cls = builder.compiler.findHelper('DynamicRuntimeType'); |
| 6299 builder.push(new HDynamicType(type, new TypeMask.exact(cls))); | 6321 builder.push(new HDynamicType(type, new TypeMask.exact(cls))); |
| 6300 } | 6322 } |
| 6301 } | 6323 } |
| OLD | NEW |