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 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 354 } | 354 } |
| 355 | 355 |
| 356 /** | 356 /** |
| 357 * Returns an [HInstruction] for the given element. If the element is | 357 * Returns an [HInstruction] for the given element. If the element is |
| 358 * boxed or stored in a closure then the method generates code to retrieve | 358 * boxed or stored in a closure then the method generates code to retrieve |
| 359 * the value. | 359 * the value. |
| 360 */ | 360 */ |
| 361 HInstruction readLocal(Element element) { | 361 HInstruction readLocal(Element element) { |
| 362 if (isAccessedDirectly(element)) { | 362 if (isAccessedDirectly(element)) { |
| 363 if (directLocals[element] == null) { | 363 if (directLocals[element] == null) { |
| 364 builder.compiler.internalError("Cannot find value $element", | 364 if (element.isTypeVariable()) { |
| 365 element: element); | 365 builder.compiler.internalError( |
| 366 "Runtime type information not available for $element", | |
| 367 element: builder.compiler.currentElement); | |
| 368 } else { | |
| 369 builder.compiler.internalError( | |
| 370 "Cannot find value $element", | |
| 371 element: element); | |
| 372 } | |
| 366 } | 373 } |
| 367 return directLocals[element]; | 374 return directLocals[element]; |
| 368 } else if (isStoredInClosureField(element)) { | 375 } else if (isStoredInClosureField(element)) { |
| 369 Element redirect = redirectionMapping[element]; | 376 Element redirect = redirectionMapping[element]; |
| 370 HInstruction receiver = readLocal(closureData.closureElement); | 377 HInstruction receiver = readLocal(closureData.closureElement); |
| 371 HInstruction fieldGet = new HFieldGet(redirect, receiver); | 378 HInstruction fieldGet = new HFieldGet(redirect, receiver); |
| 372 fieldGet.instructionType = builder.getTypeOfCapturedVariable(element); | 379 fieldGet.instructionType = builder.getTypeOfCapturedVariable(element); |
| 373 builder.add(fieldGet); | 380 builder.add(fieldGet); |
| 374 return fieldGet; | 381 return fieldGet; |
| 375 } else if (isBoxed(element)) { | 382 } else if (isBoxed(element)) { |
| (...skipping 714 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1090 LocalsHandler newLocalsHandler = new LocalsHandler.from(localsHandler); | 1097 LocalsHandler newLocalsHandler = new LocalsHandler.from(localsHandler); |
| 1091 newLocalsHandler.closureData = | 1098 newLocalsHandler.closureData = |
| 1092 compiler.closureToClassMapper.computeClosureToClassMapping( | 1099 compiler.closureToClassMapper.computeClosureToClassMapping( |
| 1093 function, function.parseNode(compiler), elements); | 1100 function, function.parseNode(compiler), elements); |
| 1094 int argumentIndex = 0; | 1101 int argumentIndex = 0; |
| 1095 if (isInstanceMember) { | 1102 if (isInstanceMember) { |
| 1096 newLocalsHandler.updateLocal(newLocalsHandler.closureData.thisElement, | 1103 newLocalsHandler.updateLocal(newLocalsHandler.closureData.thisElement, |
| 1097 compiledArguments[argumentIndex++]); | 1104 compiledArguments[argumentIndex++]); |
| 1098 } | 1105 } |
| 1099 | 1106 |
| 1100 FunctionSignature signature = function.computeSignature(compiler); | |
| 1101 signature.orderedForEachParameter((Element parameter) { | |
| 1102 HInstruction argument = compiledArguments[argumentIndex++]; | |
| 1103 newLocalsHandler.updateLocal(parameter, argument); | |
| 1104 potentiallyCheckType(argument, parameter.computeType(compiler)); | |
| 1105 }); | |
| 1106 | |
| 1107 if (function.isConstructor()) { | 1107 if (function.isConstructor()) { |
| 1108 ClassElement enclosing = function.getEnclosingClass(); | 1108 ClassElement enclosing = function.getEnclosingClass(); |
| 1109 if (backend.needsRti(enclosing)) { | 1109 if (backend.needsRti(enclosing)) { |
| 1110 assert(currentNode is NewExpression); | 1110 assert(currentNode is NewExpression); |
| 1111 InterfaceType type = elements.getType(currentNode); | 1111 InterfaceType type = elements.getType(currentNode); |
| 1112 Link<DartType> typeVariable = enclosing.typeVariables; | 1112 Link<DartType> typeVariable = enclosing.typeVariables; |
| 1113 type.typeArguments.forEach((DartType argument) { | 1113 type.typeArguments.forEach((DartType argument) { |
| 1114 HInstruction instruction = | 1114 HInstruction instruction = |
| 1115 analyzeTypeArgument(argument, currentNode); | 1115 analyzeTypeArgument(argument, currentNode); |
| 1116 newLocalsHandler.updateLocal(typeVariable.head.element, instruction); | 1116 newLocalsHandler.updateLocal(typeVariable.head.element, instruction); |
| 1117 typeVariable = typeVariable.tail; | 1117 typeVariable = typeVariable.tail; |
| 1118 }); | 1118 }); |
| 1119 while (!typeVariable.isEmpty) { | 1119 while (!typeVariable.isEmpty) { |
| 1120 newLocalsHandler.updateLocal(typeVariable.head.element, | 1120 newLocalsHandler.updateLocal(typeVariable.head.element, |
| 1121 graph.addConstantNull(constantSystem)); | 1121 graph.addConstantNull(constantSystem)); |
| 1122 typeVariable = typeVariable.tail; | 1122 typeVariable = typeVariable.tail; |
| 1123 } | 1123 } |
| 1124 } | 1124 } |
| 1125 } | 1125 } |
| 1126 | 1126 |
| 1127 // Check the type of the arguments. This must be done after setting up the | |
| 1128 // type variables in the [localsHandler] because the checked types may | |
| 1129 // contain type variables. | |
| 1130 FunctionSignature signature = function.computeSignature(compiler); | |
| 1131 signature.orderedForEachParameter((Element parameter) { | |
| 1132 HInstruction argument = compiledArguments[argumentIndex++]; | |
| 1133 newLocalsHandler.updateLocal(parameter, argument); | |
| 1134 potentiallyCheckType(argument, parameter.computeType(compiler)); | |
| 1135 }); | |
| 1136 | |
| 1127 // TODO(kasperl): Bad smell. We shouldn't be constructing elements here. | 1137 // TODO(kasperl): Bad smell. We shouldn't be constructing elements here. |
| 1128 returnElement = new ElementX(const SourceString("result"), | 1138 returnElement = new ElementX(const SourceString("result"), |
| 1129 ElementKind.VARIABLE, | 1139 ElementKind.VARIABLE, |
| 1130 function); | 1140 function); |
| 1131 newLocalsHandler.updateLocal(returnElement, | 1141 newLocalsHandler.updateLocal(returnElement, |
| 1132 graph.addConstantNull(constantSystem)); | 1142 graph.addConstantNull(constantSystem)); |
| 1133 elements = compiler.enqueuer.resolution.getCachedElements(function); | 1143 elements = compiler.enqueuer.resolution.getCachedElements(function); |
| 1134 assert(elements != null); | 1144 assert(elements != null); |
| 1135 returnType = signature.returnType; | 1145 returnType = signature.returnType; |
| 1136 stack = <HInstruction>[]; | 1146 stack = <HInstruction>[]; |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1207 if (newElements == null) { | 1217 if (newElements == null) { |
| 1208 compiler.internalError("Element not resolved: $function"); | 1218 compiler.internalError("Element not resolved: $function"); |
| 1209 } | 1219 } |
| 1210 | 1220 |
| 1211 if (canBeInlined == null) { | 1221 if (canBeInlined == null) { |
| 1212 canBeInlined = InlineWeeder.canBeInlined(functionExpression, newElements); | 1222 canBeInlined = InlineWeeder.canBeInlined(functionExpression, newElements); |
| 1213 backend.canBeInlined[function] = canBeInlined; | 1223 backend.canBeInlined[function] = canBeInlined; |
| 1214 if (!canBeInlined) return false; | 1224 if (!canBeInlined) return false; |
| 1215 } | 1225 } |
| 1216 | 1226 |
| 1227 // We cannot inline methods with type variables in the signature in checked | |
| 1228 // mode, because we currently do not have access to the type variables | |
| 1229 // through the locals. | |
| 1230 // TODO(karlklose): remove this and enable inlining of these methods. | |
| 1231 if (compiler.enableTypeAssertions && | |
| 1232 element.computeType(compiler).containsTypeVariables) { | |
| 1233 return false; | |
| 1234 } | |
| 1235 | |
| 1217 assert(canBeInlined); | 1236 assert(canBeInlined); |
| 1218 InliningState state = enterInlinedMethod( | 1237 InliningState state = enterInlinedMethod( |
| 1219 function, selector, argumentsNodes, providedArguments, currentNode); | 1238 function, selector, argumentsNodes, providedArguments, currentNode); |
| 1220 inlinedFrom(element, () { | 1239 inlinedFrom(element, () { |
| 1221 functionExpression.body.accept(this); | 1240 functionExpression.body.accept(this); |
| 1222 }); | 1241 }); |
| 1223 leaveInlinedMethod(state); | 1242 leaveInlinedMethod(state); |
| 1224 return true; | 1243 return true; |
| 1225 } | 1244 } |
| 1226 | 1245 |
| (...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1661 void openFunction(Element element, Expression node) { | 1680 void openFunction(Element element, Expression node) { |
| 1662 assert(invariant(element, element.isImplementation)); | 1681 assert(invariant(element, element.isImplementation)); |
| 1663 HBasicBlock block = graph.addNewBlock(); | 1682 HBasicBlock block = graph.addNewBlock(); |
| 1664 open(graph.entry); | 1683 open(graph.entry); |
| 1665 | 1684 |
| 1666 localsHandler.startFunction(element, node); | 1685 localsHandler.startFunction(element, node); |
| 1667 close(new HGoto()).addSuccessor(block); | 1686 close(new HGoto()).addSuccessor(block); |
| 1668 | 1687 |
| 1669 open(block); | 1688 open(block); |
| 1670 | 1689 |
| 1690 // Add the type parameters of the class as parameters of this method. This | |
| 1691 // must be done before adding the normal parameters, because their types | |
| 1692 // may contain references to type variables. | |
| 1693 var enclosing = element.enclosingElement; | |
| 1694 if ((element.isConstructor() || element.isGenerativeConstructorBody()) | |
| 1695 && backend.needsRti(enclosing)) { | |
| 1696 enclosing.typeVariables.forEach((TypeVariableType typeVariable) { | |
| 1697 HParameterValue param = addParameter(typeVariable.element); | |
| 1698 localsHandler.directLocals[typeVariable.element] = param; | |
| 1699 }); | |
| 1700 } | |
| 1701 | |
| 1671 if (element is FunctionElement) { | 1702 if (element is FunctionElement) { |
| 1672 FunctionElement functionElement = element; | 1703 FunctionElement functionElement = element; |
| 1673 FunctionSignature signature = functionElement.computeSignature(compiler); | 1704 FunctionSignature signature = functionElement.computeSignature(compiler); |
| 1674 signature.orderedForEachParameter((Element parameterElement) { | 1705 signature.orderedForEachParameter((Element parameterElement) { |
| 1675 if (elements.isParameterChecked(parameterElement)) { | 1706 if (elements.isParameterChecked(parameterElement)) { |
| 1676 addParameterCheckInstruction(parameterElement); | 1707 addParameterCheckInstruction(parameterElement); |
| 1677 } | 1708 } |
| 1678 }); | 1709 }); |
| 1679 | 1710 |
| 1680 // Put the type checks in the first successor of the entry, | 1711 // Put the type checks in the first successor of the entry, |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 1697 localsHandler.directLocals[parameterElement], | 1728 localsHandler.directLocals[parameterElement], |
| 1698 parameterElement.computeType(compiler)); | 1729 parameterElement.computeType(compiler)); |
| 1699 localsHandler.directLocals[parameterElement] = newParameter; | 1730 localsHandler.directLocals[parameterElement] = newParameter; |
| 1700 }); | 1731 }); |
| 1701 | 1732 |
| 1702 returnType = signature.returnType; | 1733 returnType = signature.returnType; |
| 1703 } else { | 1734 } else { |
| 1704 // Otherwise it is a lazy initializer which does not have parameters. | 1735 // Otherwise it is a lazy initializer which does not have parameters. |
| 1705 assert(element is VariableElement); | 1736 assert(element is VariableElement); |
| 1706 } | 1737 } |
| 1738 } | |
| 1707 | 1739 |
| 1708 // Add the type parameters of the class as parameters of this | 1740 HInstruction buildTypeConversion(Compiler compiler, HInstruction original, |
| 1709 // method. | 1741 DartType type, int kind) { |
| 1710 var enclosing = element.enclosingElement; | 1742 if (type == null) return original; |
| 1711 if ((element.isConstructor() || element.isGenerativeConstructorBody()) | 1743 if (identical(type.element, compiler.dynamicClass)) return original; |
| 1712 && backend.needsRti(enclosing)) { | 1744 if (identical(type.element, compiler.objectClass)) return original; |
|
ngeoffray
2013/05/15 08:45:33
Can you remove those two checks above? They should
karlklose
2013/05/15 12:59:16
Removed. They will always end up calling convertTy
| |
| 1713 enclosing.typeVariables.forEach((TypeVariableType typeVariable) { | 1745 if (type.kind == TypeKind.INTERFACE && !type.isMalformed && !type.isRaw) { |
| 1714 HParameterValue param = addParameter(typeVariable.element); | 1746 HType subtype = new HType.subtype(type, compiler); |
| 1715 localsHandler.directLocals[typeVariable.element] = param; | 1747 if (type.isRaw) { |
| 1716 }); | 1748 return new HTypeConversion(type, kind, subtype, original); |
| 1749 } | |
| 1750 HInstruction representations = buildTypeArgumentRepresentations(type); | |
| 1751 add(representations); | |
| 1752 return new HTypeConversion.withTypeRepresentation(type, kind, subtype, | |
| 1753 original, representations); | |
| 1754 } else if (type.kind == TypeKind.TYPE_VARIABLE) { | |
| 1755 HType subtype = original.instructionType; | |
| 1756 HInstruction typeVariable = addTypeVariableReference(type); | |
| 1757 return new HTypeConversion.withTypeRepresentation(type, kind, subtype, | |
| 1758 original, typeVariable); | |
| 1759 } else { | |
| 1760 return original.convertType(compiler, type, kind); | |
| 1717 } | 1761 } |
| 1718 } | 1762 } |
| 1719 | 1763 |
| 1720 HInstruction potentiallyCheckType( | 1764 HInstruction potentiallyCheckType(HInstruction original, DartType type, |
| 1721 HInstruction original, DartType type, | |
| 1722 { int kind: HTypeConversion.CHECKED_MODE_CHECK }) { | 1765 { int kind: HTypeConversion.CHECKED_MODE_CHECK }) { |
| 1723 if (!compiler.enableTypeAssertions) return original; | 1766 if (!compiler.enableTypeAssertions) return original; |
| 1724 HInstruction other = original.convertType(compiler, type, kind); | 1767 HInstruction other = |
| 1768 buildTypeConversion(compiler, original, type, kind); | |
| 1725 if (other != original) add(other); | 1769 if (other != original) add(other); |
| 1726 return other; | 1770 return other; |
| 1727 } | 1771 } |
| 1728 | 1772 |
| 1729 HGraph closeFunction() { | 1773 HGraph closeFunction() { |
| 1730 // TODO(kasperl): Make this goto an implicit return. | 1774 // TODO(kasperl): Make this goto an implicit return. |
| 1731 if (!isAborted()) closeAndGotoExit(new HGoto()); | 1775 if (!isAborted()) closeAndGotoExit(new HGoto()); |
| 1732 graph.finalize(); | 1776 graph.finalize(); |
| 1733 return graph; | 1777 return graph; |
| 1734 } | 1778 } |
| (...skipping 847 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2582 location = send; | 2626 location = send; |
| 2583 } | 2627 } |
| 2584 if (Elements.isStaticOrTopLevelField(element)) { | 2628 if (Elements.isStaticOrTopLevelField(element)) { |
| 2585 if (element.isSetter()) { | 2629 if (element.isSetter()) { |
| 2586 HStatic target = new HStatic(element); | 2630 HStatic target = new HStatic(element); |
| 2587 add(target); | 2631 add(target); |
| 2588 var instruction = buildInvokeStatic( | 2632 var instruction = buildInvokeStatic( |
| 2589 <HInstruction>[target, value], HType.UNKNOWN); | 2633 <HInstruction>[target, value], HType.UNKNOWN); |
| 2590 addWithPosition(instruction, location); | 2634 addWithPosition(instruction, location); |
| 2591 } else { | 2635 } else { |
| 2592 value = potentiallyCheckType(value, element.computeType(compiler)); | 2636 value = |
| 2637 potentiallyCheckType(value, element.computeType(compiler)); | |
| 2593 addWithPosition(new HStaticStore(element, value), location); | 2638 addWithPosition(new HStaticStore(element, value), location); |
| 2594 } | 2639 } |
| 2595 stack.add(value); | 2640 stack.add(value); |
| 2596 } else if (Elements.isErroneousElement(element)) { | 2641 } else if (Elements.isErroneousElement(element)) { |
| 2597 // An erroneous element indicates an unresolved static setter. | 2642 // An erroneous element indicates an unresolved static setter. |
| 2598 generateThrowNoSuchMethod( | 2643 generateThrowNoSuchMethod( |
| 2599 location, | 2644 location, |
| 2600 getTargetName(element, 'set'), | 2645 getTargetName(element, 'set'), |
| 2601 argumentNodes: (send == null ? const Link<Node>() : send.arguments)); | 2646 argumentNodes: (send == null ? const Link<Node>() : send.arguments)); |
| 2602 } else { | 2647 } else { |
| 2603 stack.add(value); | 2648 stack.add(value); |
| 2604 // If the value does not already have a name, give it here. | 2649 // If the value does not already have a name, give it here. |
| 2605 if (value.sourceElement == null) { | 2650 if (value.sourceElement == null) { |
| 2606 value.sourceElement = element; | 2651 value.sourceElement = element; |
| 2607 } | 2652 } |
| 2608 HInstruction checked = potentiallyCheckType( | 2653 HInstruction checked = |
| 2609 value, element.computeType(compiler)); | 2654 potentiallyCheckType(value, element.computeType(compiler)); |
| 2610 if (!identical(checked, value)) { | 2655 if (!identical(checked, value)) { |
| 2611 pop(); | 2656 pop(); |
| 2612 stack.add(checked); | 2657 stack.add(checked); |
| 2613 } | 2658 } |
| 2614 localsHandler.updateLocal(element, checked); | 2659 localsHandler.updateLocal(element, checked); |
| 2615 } | 2660 } |
| 2616 } | 2661 } |
| 2617 | 2662 |
| 2618 HInstruction invokeInterceptor(Set<ClassElement> intercepted, | 2663 HInstruction invokeInterceptor(Set<ClassElement> intercepted, |
| 2619 HInstruction receiver) { | 2664 HInstruction receiver) { |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2764 isNot = true; | 2809 isNot = true; |
| 2765 } | 2810 } |
| 2766 DartType type = elements.getType(typeAnnotation); | 2811 DartType type = elements.getType(typeAnnotation); |
| 2767 if (type.isMalformed) { | 2812 if (type.isMalformed) { |
| 2768 String reasons = Types.fetchReasonsFromMalformedType(type); | 2813 String reasons = Types.fetchReasonsFromMalformedType(type); |
| 2769 if (compiler.enableTypeAssertions) { | 2814 if (compiler.enableTypeAssertions) { |
| 2770 generateMalformedSubtypeError(node, expression, type, reasons); | 2815 generateMalformedSubtypeError(node, expression, type, reasons); |
| 2771 } else { | 2816 } else { |
| 2772 generateRuntimeError(node, '$type is malformed: $reasons'); | 2817 generateRuntimeError(node, '$type is malformed: $reasons'); |
| 2773 } | 2818 } |
| 2774 return; | 2819 } else { |
| 2820 HInstruction instruction = buildIsNode(node, type, expression); | |
| 2821 if (isNot) { | |
| 2822 add(instruction); | |
| 2823 instruction = new HNot(instruction); | |
| 2824 } | |
| 2825 push(instruction); | |
| 2775 } | 2826 } |
| 2827 } | |
| 2776 | 2828 |
| 2777 HInstruction instruction; | 2829 HInstruction buildIsNode(Node node, DartType type, HInstruction expression) { |
| 2778 if (type.kind == TypeKind.TYPE_VARIABLE) { | 2830 if (type.kind == TypeKind.TYPE_VARIABLE) { |
| 2779 HInstruction runtimeType = addTypeVariableReference(type); | 2831 HInstruction runtimeType = addTypeVariableReference(type); |
| 2780 Element helper = backend.getGetObjectIsSubtype(); | 2832 Element helper = backend.getCheckSubtypeOfRuntimeType(); |
| 2781 HInstruction helperCall = new HStatic(helper); | 2833 HInstruction helperCall = new HStatic(helper); |
| 2782 add(helperCall); | 2834 add(helperCall); |
| 2783 List<HInstruction> inputs = <HInstruction>[helperCall, expression, | 2835 List<HInstruction> inputs = <HInstruction>[helperCall, expression, |
| 2784 runtimeType]; | 2836 runtimeType]; |
| 2785 HInstruction call = buildInvokeStatic(inputs, HType.BOOLEAN); | 2837 HInstruction call = buildInvokeStatic(inputs, HType.BOOLEAN); |
| 2786 add(call); | 2838 add(call); |
| 2787 instruction = new HIs(type, <HInstruction>[expression, call], | 2839 return new HIs(type, <HInstruction>[expression, call], |
| 2788 HIs.VARIABLE_CHECK); | 2840 HIs.VARIABLE_CHECK); |
| 2789 } else if (RuntimeTypes.hasTypeArguments(type)) { | 2841 } else if (RuntimeTypes.hasTypeArguments(type)) { |
| 2790 Element element = type.element; | 2842 Element element = type.element; |
| 2791 Element helper = backend.getCheckSubtype(); | 2843 Element helper = backend.getCheckSubtype(); |
| 2792 HInstruction helperCall = new HStatic(helper); | 2844 HInstruction helperCall = new HStatic(helper); |
| 2793 add(helperCall); | 2845 add(helperCall); |
| 2794 HInstruction representations = | 2846 HInstruction representations = |
| 2795 buildTypeArgumentRepresentations(type); | 2847 buildTypeArgumentRepresentations(type); |
| 2796 add(representations); | 2848 add(representations); |
| 2797 String operator = | 2849 String operator = |
| 2798 backend.namer.operatorIs(backend.getImplementationClass(element)); | 2850 backend.namer.operatorIs(backend.getImplementationClass(element)); |
| 2799 HInstruction isFieldName = addConstantString(node, operator); | 2851 HInstruction isFieldName = addConstantString(node, operator); |
| 2800 // TODO(karlklose): use [:null:] for [asField] if [element] does not | 2852 // TODO(karlklose): use [:null:] for [asField] if [element] does not |
| 2801 // have a subclass. | 2853 // have a subclass. |
| 2802 HInstruction asFieldName = | 2854 HInstruction asFieldName = |
| 2803 addConstantString(node, backend.namer.substitutionName(element)); | 2855 addConstantString(node, backend.namer.substitutionName(element)); |
| 2804 List<HInstruction> inputs = <HInstruction>[helperCall, | 2856 List<HInstruction> inputs = <HInstruction>[helperCall, |
| 2805 expression, | 2857 expression, |
| 2806 isFieldName, | 2858 isFieldName, |
| 2807 representations, | 2859 representations, |
| 2808 asFieldName]; | 2860 asFieldName]; |
| 2809 HInstruction call = buildInvokeStatic(inputs, HType.BOOLEAN); | 2861 HInstruction call = buildInvokeStatic(inputs, HType.BOOLEAN); |
| 2810 add(call); | 2862 add(call); |
| 2811 instruction = new HIs(type, <HInstruction>[expression, call], | 2863 return |
| 2812 HIs.COMPOUND_CHECK); | 2864 new HIs(type, <HInstruction>[expression, call], HIs.COMPOUND_CHECK); |
| 2813 } else { | 2865 } else { |
| 2814 instruction = new HIs(type, <HInstruction>[expression], HIs.RAW_CHECK); | 2866 return new HIs(type, <HInstruction>[expression], HIs.RAW_CHECK); |
| 2815 } | 2867 } |
| 2816 if (isNot) { | |
| 2817 add(instruction); | |
| 2818 instruction = new HNot(instruction); | |
| 2819 } | |
| 2820 push(instruction); | |
| 2821 } | 2868 } |
| 2822 | 2869 |
| 2823 void addDynamicSendArgumentsToList(Send node, List<HInstruction> list) { | 2870 void addDynamicSendArgumentsToList(Send node, List<HInstruction> list) { |
| 2824 Selector selector = elements.getSelector(node); | 2871 Selector selector = elements.getSelector(node); |
| 2825 if (selector.namedArgumentCount == 0) { | 2872 if (selector.namedArgumentCount == 0) { |
| 2826 addGenericSendArgumentsToList(node.arguments, list); | 2873 addGenericSendArgumentsToList(node.arguments, list); |
| 2827 } else { | 2874 } else { |
| 2828 // Visit positional arguments and add them to the list. | 2875 // Visit positional arguments and add them to the list. |
| 2829 Link<Node> arguments = node.arguments; | 2876 Link<Node> arguments = node.arguments; |
| 2830 int positionalArgumentCount = selector.positionalArgumentCount; | 2877 int positionalArgumentCount = selector.positionalArgumentCount; |
| (...skipping 1892 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4723 // TODO(aprelev@gmail.com): Once old catch syntax is removed | 4770 // TODO(aprelev@gmail.com): Once old catch syntax is removed |
| 4724 // "if" condition above and this "else" branch should be deleted as | 4771 // "if" condition above and this "else" branch should be deleted as |
| 4725 // type of declared variable won't matter for the catch | 4772 // type of declared variable won't matter for the catch |
| 4726 // condition. | 4773 // condition. |
| 4727 DartType type = elements.getType(declaration.type); | 4774 DartType type = elements.getType(declaration.type); |
| 4728 if (type == null) { | 4775 if (type == null) { |
| 4729 compiler.cancel('Catch with unresolved type', node: catchBlock); | 4776 compiler.cancel('Catch with unresolved type', node: catchBlock); |
| 4730 } | 4777 } |
| 4731 // TODO(karlkose): support type arguments here. | 4778 // TODO(karlkose): support type arguments here. |
| 4732 condition = new HIs(type, <HInstruction>[unwrappedException], | 4779 condition = new HIs(type, <HInstruction>[unwrappedException], |
| 4733 HIs.RAW_CHECK, nullOk: true); | 4780 HIs.RAW_CHECK); |
| 4734 push(condition); | 4781 push(condition); |
| 4735 } | 4782 } |
| 4736 } | 4783 } |
| 4737 } | 4784 } |
| 4738 | 4785 |
| 4739 void visitThen() { | 4786 void visitThen() { |
| 4740 CatchBlock catchBlock = link.head; | 4787 CatchBlock catchBlock = link.head; |
| 4741 link = link.tail; | 4788 link = link.tail; |
| 4742 | 4789 |
| 4743 if (compiler.enableTypeAssertions) { | 4790 if (compiler.enableTypeAssertions) { |
| (...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5291 new HSubGraphBlockInformation(elseBranch.graph)); | 5338 new HSubGraphBlockInformation(elseBranch.graph)); |
| 5292 | 5339 |
| 5293 HBasicBlock conditionStartBlock = conditionBranch.block; | 5340 HBasicBlock conditionStartBlock = conditionBranch.block; |
| 5294 conditionStartBlock.setBlockFlow(info, joinBlock); | 5341 conditionStartBlock.setBlockFlow(info, joinBlock); |
| 5295 SubGraph conditionGraph = conditionBranch.graph; | 5342 SubGraph conditionGraph = conditionBranch.graph; |
| 5296 HIf branch = conditionGraph.end.last; | 5343 HIf branch = conditionGraph.end.last; |
| 5297 assert(branch is HIf); | 5344 assert(branch is HIf); |
| 5298 branch.blockInformation = conditionStartBlock.blockFlow; | 5345 branch.blockInformation = conditionStartBlock.blockFlow; |
| 5299 } | 5346 } |
| 5300 } | 5347 } |
| OLD | NEW |