| 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 if (element.isTypeVariable()) { | 364 builder.compiler.internalError("Cannot find value $element", |
| 365 builder.compiler.internalError( | 365 element: element); |
| 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 } | |
| 373 } | 366 } |
| 374 return directLocals[element]; | 367 return directLocals[element]; |
| 375 } else if (isStoredInClosureField(element)) { | 368 } else if (isStoredInClosureField(element)) { |
| 376 Element redirect = redirectionMapping[element]; | 369 Element redirect = redirectionMapping[element]; |
| 377 HInstruction receiver = readLocal(closureData.closureElement); | 370 HInstruction receiver = readLocal(closureData.closureElement); |
| 378 HInstruction fieldGet = new HFieldGet(redirect, receiver); | 371 HInstruction fieldGet = new HFieldGet(redirect, receiver); |
| 379 fieldGet.instructionType = builder.getTypeOfCapturedVariable(element); | 372 fieldGet.instructionType = builder.getTypeOfCapturedVariable(element); |
| 380 builder.add(fieldGet); | 373 builder.add(fieldGet); |
| 381 return fieldGet; | 374 return fieldGet; |
| 382 } else if (isBoxed(element)) { | 375 } else if (isBoxed(element)) { |
| (...skipping 714 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1097 LocalsHandler newLocalsHandler = new LocalsHandler.from(localsHandler); | 1090 LocalsHandler newLocalsHandler = new LocalsHandler.from(localsHandler); |
| 1098 newLocalsHandler.closureData = | 1091 newLocalsHandler.closureData = |
| 1099 compiler.closureToClassMapper.computeClosureToClassMapping( | 1092 compiler.closureToClassMapper.computeClosureToClassMapping( |
| 1100 function, function.parseNode(compiler), elements); | 1093 function, function.parseNode(compiler), elements); |
| 1101 int argumentIndex = 0; | 1094 int argumentIndex = 0; |
| 1102 if (isInstanceMember) { | 1095 if (isInstanceMember) { |
| 1103 newLocalsHandler.updateLocal(newLocalsHandler.closureData.thisElement, | 1096 newLocalsHandler.updateLocal(newLocalsHandler.closureData.thisElement, |
| 1104 compiledArguments[argumentIndex++]); | 1097 compiledArguments[argumentIndex++]); |
| 1105 } | 1098 } |
| 1106 | 1099 |
| 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 | |
| 1137 // TODO(kasperl): Bad smell. We shouldn't be constructing elements here. | 1127 // TODO(kasperl): Bad smell. We shouldn't be constructing elements here. |
| 1138 returnElement = new ElementX(const SourceString("result"), | 1128 returnElement = new ElementX(const SourceString("result"), |
| 1139 ElementKind.VARIABLE, | 1129 ElementKind.VARIABLE, |
| 1140 function); | 1130 function); |
| 1141 newLocalsHandler.updateLocal(returnElement, | 1131 newLocalsHandler.updateLocal(returnElement, |
| 1142 graph.addConstantNull(constantSystem)); | 1132 graph.addConstantNull(constantSystem)); |
| 1143 elements = compiler.enqueuer.resolution.getCachedElements(function); | 1133 elements = compiler.enqueuer.resolution.getCachedElements(function); |
| 1144 assert(elements != null); | 1134 assert(elements != null); |
| 1145 returnType = signature.returnType; | 1135 returnType = signature.returnType; |
| 1146 stack = <HInstruction>[]; | 1136 stack = <HInstruction>[]; |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1217 if (newElements == null) { | 1207 if (newElements == null) { |
| 1218 compiler.internalError("Element not resolved: $function"); | 1208 compiler.internalError("Element not resolved: $function"); |
| 1219 } | 1209 } |
| 1220 | 1210 |
| 1221 if (canBeInlined == null) { | 1211 if (canBeInlined == null) { |
| 1222 canBeInlined = InlineWeeder.canBeInlined(functionExpression, newElements); | 1212 canBeInlined = InlineWeeder.canBeInlined(functionExpression, newElements); |
| 1223 backend.canBeInlined[function] = canBeInlined; | 1213 backend.canBeInlined[function] = canBeInlined; |
| 1224 if (!canBeInlined) return false; | 1214 if (!canBeInlined) return false; |
| 1225 } | 1215 } |
| 1226 | 1216 |
| 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 | |
| 1236 assert(canBeInlined); | 1217 assert(canBeInlined); |
| 1237 InliningState state = enterInlinedMethod( | 1218 InliningState state = enterInlinedMethod( |
| 1238 function, selector, argumentsNodes, providedArguments, currentNode); | 1219 function, selector, argumentsNodes, providedArguments, currentNode); |
| 1239 // Add an explicit null check on the receiver. We use [element] | 1220 // Add an explicit null check on the receiver. We use [element] |
| 1240 // to get the same name in the NoSuchMethodError message as if we had | 1221 // to get the same name in the NoSuchMethodError message as if we had |
| 1241 // called it. | 1222 // called it. |
| 1242 if (element.isInstanceMember() | 1223 if (element.isInstanceMember() |
| 1243 && (selector.mask == null || selector.mask.isNullable)) { | 1224 && (selector.mask == null || selector.mask.isNullable)) { |
| 1244 addWithPosition( | 1225 addWithPosition( |
| 1245 new HFieldGet(element, providedArguments[0]), currentNode); | 1226 new HFieldGet(element, providedArguments[0]), currentNode); |
| (...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1688 void openFunction(Element element, Expression node) { | 1669 void openFunction(Element element, Expression node) { |
| 1689 assert(invariant(element, element.isImplementation)); | 1670 assert(invariant(element, element.isImplementation)); |
| 1690 HBasicBlock block = graph.addNewBlock(); | 1671 HBasicBlock block = graph.addNewBlock(); |
| 1691 open(graph.entry); | 1672 open(graph.entry); |
| 1692 | 1673 |
| 1693 localsHandler.startFunction(element, node); | 1674 localsHandler.startFunction(element, node); |
| 1694 close(new HGoto()).addSuccessor(block); | 1675 close(new HGoto()).addSuccessor(block); |
| 1695 | 1676 |
| 1696 open(block); | 1677 open(block); |
| 1697 | 1678 |
| 1698 // Add the type parameters of the class as parameters of this method. This | |
| 1699 // must be done before adding the normal parameters, because their types | |
| 1700 // may contain references to type variables. | |
| 1701 var enclosing = element.enclosingElement; | |
| 1702 if ((element.isConstructor() || element.isGenerativeConstructorBody()) | |
| 1703 && backend.needsRti(enclosing)) { | |
| 1704 enclosing.typeVariables.forEach((TypeVariableType typeVariable) { | |
| 1705 HParameterValue param = addParameter(typeVariable.element); | |
| 1706 localsHandler.directLocals[typeVariable.element] = param; | |
| 1707 }); | |
| 1708 } | |
| 1709 | |
| 1710 if (element is FunctionElement) { | 1679 if (element is FunctionElement) { |
| 1711 FunctionElement functionElement = element; | 1680 FunctionElement functionElement = element; |
| 1712 FunctionSignature signature = functionElement.computeSignature(compiler); | 1681 FunctionSignature signature = functionElement.computeSignature(compiler); |
| 1713 signature.orderedForEachParameter((Element parameterElement) { | 1682 signature.orderedForEachParameter((Element parameterElement) { |
| 1714 if (elements.isParameterChecked(parameterElement)) { | 1683 if (elements.isParameterChecked(parameterElement)) { |
| 1715 addParameterCheckInstruction(parameterElement); | 1684 addParameterCheckInstruction(parameterElement); |
| 1716 } | 1685 } |
| 1717 }); | 1686 }); |
| 1718 | 1687 |
| 1719 // Put the type checks in the first successor of the entry, | 1688 // Put the type checks in the first successor of the entry, |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1736 localsHandler.directLocals[parameterElement], | 1705 localsHandler.directLocals[parameterElement], |
| 1737 parameterElement.computeType(compiler)); | 1706 parameterElement.computeType(compiler)); |
| 1738 localsHandler.directLocals[parameterElement] = newParameter; | 1707 localsHandler.directLocals[parameterElement] = newParameter; |
| 1739 }); | 1708 }); |
| 1740 | 1709 |
| 1741 returnType = signature.returnType; | 1710 returnType = signature.returnType; |
| 1742 } else { | 1711 } else { |
| 1743 // Otherwise it is a lazy initializer which does not have parameters. | 1712 // Otherwise it is a lazy initializer which does not have parameters. |
| 1744 assert(element is VariableElement); | 1713 assert(element is VariableElement); |
| 1745 } | 1714 } |
| 1746 } | |
| 1747 | 1715 |
| 1748 HInstruction buildTypeConversion(Compiler compiler, HInstruction original, | 1716 // Add the type parameters of the class as parameters of this |
| 1749 DartType type, int kind) { | 1717 // method. |
| 1750 if (type == null) return original; | 1718 var enclosing = element.enclosingElement; |
| 1751 if (type.kind == TypeKind.INTERFACE && !type.isMalformed && !type.isRaw) { | 1719 if ((element.isConstructor() || element.isGenerativeConstructorBody()) |
| 1752 HType subtype = new HType.subtype(type, compiler); | 1720 && backend.needsRti(enclosing)) { |
| 1753 if (type.isRaw) { | 1721 enclosing.typeVariables.forEach((TypeVariableType typeVariable) { |
| 1754 return new HTypeConversion(type, kind, subtype, original); | 1722 HParameterValue param = addParameter(typeVariable.element); |
| 1755 } | 1723 localsHandler.directLocals[typeVariable.element] = param; |
| 1756 HInstruction representations = buildTypeArgumentRepresentations(type); | 1724 }); |
| 1757 add(representations); | |
| 1758 return new HTypeConversion.withTypeRepresentation(type, kind, subtype, | |
| 1759 original, representations); | |
| 1760 } else if (type.kind == TypeKind.TYPE_VARIABLE) { | |
| 1761 HType subtype = original.instructionType; | |
| 1762 HInstruction typeVariable = addTypeVariableReference(type); | |
| 1763 return new HTypeConversion.withTypeRepresentation(type, kind, subtype, | |
| 1764 original, typeVariable); | |
| 1765 } else { | |
| 1766 return original.convertType(compiler, type, kind); | |
| 1767 } | 1725 } |
| 1768 } | 1726 } |
| 1769 | 1727 |
| 1770 HInstruction potentiallyCheckType(HInstruction original, DartType type, | 1728 HInstruction potentiallyCheckType( |
| 1729 HInstruction original, DartType type, |
| 1771 { int kind: HTypeConversion.CHECKED_MODE_CHECK }) { | 1730 { int kind: HTypeConversion.CHECKED_MODE_CHECK }) { |
| 1772 if (!compiler.enableTypeAssertions) return original; | 1731 if (!compiler.enableTypeAssertions) return original; |
| 1773 HInstruction other = | 1732 HInstruction other = original.convertType(compiler, type, kind); |
| 1774 buildTypeConversion(compiler, original, type, kind); | |
| 1775 if (other != original) add(other); | 1733 if (other != original) add(other); |
| 1776 return other; | 1734 return other; |
| 1777 } | 1735 } |
| 1778 | 1736 |
| 1779 HGraph closeFunction() { | 1737 HGraph closeFunction() { |
| 1780 // TODO(kasperl): Make this goto an implicit return. | 1738 // TODO(kasperl): Make this goto an implicit return. |
| 1781 if (!isAborted()) closeAndGotoExit(new HGoto()); | 1739 if (!isAborted()) closeAndGotoExit(new HGoto()); |
| 1782 graph.finalize(); | 1740 graph.finalize(); |
| 1783 return graph; | 1741 return graph; |
| 1784 } | 1742 } |
| (...skipping 843 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2628 if (location == null) { | 2586 if (location == null) { |
| 2629 assert(send != null); | 2587 assert(send != null); |
| 2630 location = send; | 2588 location = send; |
| 2631 } | 2589 } |
| 2632 if (Elements.isStaticOrTopLevelField(element)) { | 2590 if (Elements.isStaticOrTopLevelField(element)) { |
| 2633 if (element.isSetter()) { | 2591 if (element.isSetter()) { |
| 2634 var instruction = buildInvokeStatic(element, | 2592 var instruction = buildInvokeStatic(element, |
| 2635 <HInstruction>[value], HType.UNKNOWN); | 2593 <HInstruction>[value], HType.UNKNOWN); |
| 2636 addWithPosition(instruction, location); | 2594 addWithPosition(instruction, location); |
| 2637 } else { | 2595 } else { |
| 2638 value = | 2596 value = potentiallyCheckType(value, element.computeType(compiler)); |
| 2639 potentiallyCheckType(value, element.computeType(compiler)); | |
| 2640 addWithPosition(new HStaticStore(element, value), location); | 2597 addWithPosition(new HStaticStore(element, value), location); |
| 2641 } | 2598 } |
| 2642 stack.add(value); | 2599 stack.add(value); |
| 2643 } else if (Elements.isErroneousElement(element)) { | 2600 } else if (Elements.isErroneousElement(element)) { |
| 2644 // An erroneous element indicates an unresolved static setter. | 2601 // An erroneous element indicates an unresolved static setter. |
| 2645 generateThrowNoSuchMethod( | 2602 generateThrowNoSuchMethod( |
| 2646 location, | 2603 location, |
| 2647 getTargetName(element, 'set'), | 2604 getTargetName(element, 'set'), |
| 2648 argumentNodes: (send == null ? const Link<Node>() : send.arguments)); | 2605 argumentNodes: (send == null ? const Link<Node>() : send.arguments)); |
| 2649 } else { | 2606 } else { |
| 2650 stack.add(value); | 2607 stack.add(value); |
| 2651 // If the value does not already have a name, give it here. | 2608 // If the value does not already have a name, give it here. |
| 2652 if (value.sourceElement == null) { | 2609 if (value.sourceElement == null) { |
| 2653 value.sourceElement = element; | 2610 value.sourceElement = element; |
| 2654 } | 2611 } |
| 2655 HInstruction checked = | 2612 HInstruction checked = potentiallyCheckType( |
| 2656 potentiallyCheckType(value, element.computeType(compiler)); | 2613 value, element.computeType(compiler)); |
| 2657 if (!identical(checked, value)) { | 2614 if (!identical(checked, value)) { |
| 2658 pop(); | 2615 pop(); |
| 2659 stack.add(checked); | 2616 stack.add(checked); |
| 2660 } | 2617 } |
| 2661 localsHandler.updateLocal(element, checked); | 2618 localsHandler.updateLocal(element, checked); |
| 2662 } | 2619 } |
| 2663 } | 2620 } |
| 2664 | 2621 |
| 2665 HInstruction invokeInterceptor(Set<ClassElement> intercepted, | 2622 HInstruction invokeInterceptor(Set<ClassElement> intercepted, |
| 2666 HInstruction receiver) { | 2623 HInstruction receiver) { |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2799 isNot = true; | 2756 isNot = true; |
| 2800 } | 2757 } |
| 2801 DartType type = elements.getType(typeAnnotation); | 2758 DartType type = elements.getType(typeAnnotation); |
| 2802 if (type.isMalformed) { | 2759 if (type.isMalformed) { |
| 2803 String reasons = Types.fetchReasonsFromMalformedType(type); | 2760 String reasons = Types.fetchReasonsFromMalformedType(type); |
| 2804 if (compiler.enableTypeAssertions) { | 2761 if (compiler.enableTypeAssertions) { |
| 2805 generateMalformedSubtypeError(node, expression, type, reasons); | 2762 generateMalformedSubtypeError(node, expression, type, reasons); |
| 2806 } else { | 2763 } else { |
| 2807 generateRuntimeError(node, '$type is malformed: $reasons'); | 2764 generateRuntimeError(node, '$type is malformed: $reasons'); |
| 2808 } | 2765 } |
| 2809 } else { | 2766 return; |
| 2810 HInstruction instruction = buildIsNode(node, type, expression); | |
| 2811 if (isNot) { | |
| 2812 add(instruction); | |
| 2813 instruction = new HNot(instruction); | |
| 2814 } | |
| 2815 push(instruction); | |
| 2816 } | 2767 } |
| 2817 } | |
| 2818 | 2768 |
| 2819 HInstruction buildIsNode(Node node, DartType type, HInstruction expression) { | 2769 HInstruction instruction; |
| 2820 if (type.kind == TypeKind.TYPE_VARIABLE) { | 2770 if (type.kind == TypeKind.TYPE_VARIABLE) { |
| 2821 HInstruction runtimeType = addTypeVariableReference(type); | 2771 HInstruction runtimeType = addTypeVariableReference(type); |
| 2822 Element helper = backend.getCheckSubtypeOfRuntimeType(); | 2772 Element helper = backend.getGetObjectIsSubtype(); |
| 2823 List<HInstruction> inputs = <HInstruction>[expression, runtimeType]; | 2773 List<HInstruction> inputs = <HInstruction>[expression, runtimeType]; |
| 2824 HInstruction call = buildInvokeStatic(helper, inputs, HType.BOOLEAN); | 2774 HInstruction call = buildInvokeStatic(helper, inputs, HType.BOOLEAN); |
| 2825 add(call); | 2775 add(call); |
| 2826 return new HIs(type, <HInstruction>[expression, call], | 2776 instruction = new HIs(type, <HInstruction>[expression, call], |
| 2827 HIs.VARIABLE_CHECK); | 2777 HIs.VARIABLE_CHECK); |
| 2828 } else if (RuntimeTypes.hasTypeArguments(type)) { | 2778 } else if (RuntimeTypes.hasTypeArguments(type)) { |
| 2829 Element element = type.element; | 2779 Element element = type.element; |
| 2830 Element helper = backend.getCheckSubtype(); | 2780 Element helper = backend.getCheckSubtype(); |
| 2831 HInstruction representations = | 2781 HInstruction representations = |
| 2832 buildTypeArgumentRepresentations(type); | 2782 buildTypeArgumentRepresentations(type); |
| 2833 add(representations); | 2783 add(representations); |
| 2834 String operator = | 2784 String operator = |
| 2835 backend.namer.operatorIs(backend.getImplementationClass(element)); | 2785 backend.namer.operatorIs(backend.getImplementationClass(element)); |
| 2836 HInstruction isFieldName = addConstantString(node, operator); | 2786 HInstruction isFieldName = addConstantString(node, operator); |
| 2837 // TODO(karlklose): use [:null:] for [asField] if [element] does not | 2787 // TODO(karlklose): use [:null:] for [asField] if [element] does not |
| 2838 // have a subclass. | 2788 // have a subclass. |
| 2839 HInstruction asFieldName = | 2789 HInstruction asFieldName = |
| 2840 addConstantString(node, backend.namer.substitutionName(element)); | 2790 addConstantString(node, backend.namer.substitutionName(element)); |
| 2841 List<HInstruction> inputs = <HInstruction>[expression, | 2791 List<HInstruction> inputs = <HInstruction>[expression, |
| 2842 isFieldName, | 2792 isFieldName, |
| 2843 representations, | 2793 representations, |
| 2844 asFieldName]; | 2794 asFieldName]; |
| 2845 HInstruction call = buildInvokeStatic(helper, inputs, HType.BOOLEAN); | 2795 HInstruction call = buildInvokeStatic(helper, inputs, HType.BOOLEAN); |
| 2846 add(call); | 2796 add(call); |
| 2847 return | 2797 instruction = new HIs(type, <HInstruction>[expression, call], |
| 2848 new HIs(type, <HInstruction>[expression, call], HIs.COMPOUND_CHECK); | 2798 HIs.COMPOUND_CHECK); |
| 2849 } else { | 2799 } else { |
| 2850 return new HIs(type, <HInstruction>[expression], HIs.RAW_CHECK); | 2800 instruction = new HIs(type, <HInstruction>[expression], HIs.RAW_CHECK); |
| 2851 } | 2801 } |
| 2802 if (isNot) { |
| 2803 add(instruction); |
| 2804 instruction = new HNot(instruction); |
| 2805 } |
| 2806 push(instruction); |
| 2852 } | 2807 } |
| 2853 | 2808 |
| 2854 void addDynamicSendArgumentsToList(Send node, List<HInstruction> list) { | 2809 void addDynamicSendArgumentsToList(Send node, List<HInstruction> list) { |
| 2855 Selector selector = elements.getSelector(node); | 2810 Selector selector = elements.getSelector(node); |
| 2856 if (selector.namedArgumentCount == 0) { | 2811 if (selector.namedArgumentCount == 0) { |
| 2857 addGenericSendArgumentsToList(node.arguments, list); | 2812 addGenericSendArgumentsToList(node.arguments, list); |
| 2858 } else { | 2813 } else { |
| 2859 // Visit positional arguments and add them to the list. | 2814 // Visit positional arguments and add them to the list. |
| 2860 Link<Node> arguments = node.arguments; | 2815 Link<Node> arguments = node.arguments; |
| 2861 int positionalArgumentCount = selector.positionalArgumentCount; | 2816 int positionalArgumentCount = selector.positionalArgumentCount; |
| (...skipping 1892 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4754 // TODO(aprelev@gmail.com): Once old catch syntax is removed | 4709 // TODO(aprelev@gmail.com): Once old catch syntax is removed |
| 4755 // "if" condition above and this "else" branch should be deleted as | 4710 // "if" condition above and this "else" branch should be deleted as |
| 4756 // type of declared variable won't matter for the catch | 4711 // type of declared variable won't matter for the catch |
| 4757 // condition. | 4712 // condition. |
| 4758 DartType type = elements.getType(declaration.type); | 4713 DartType type = elements.getType(declaration.type); |
| 4759 if (type == null) { | 4714 if (type == null) { |
| 4760 compiler.cancel('Catch with unresolved type', node: catchBlock); | 4715 compiler.cancel('Catch with unresolved type', node: catchBlock); |
| 4761 } | 4716 } |
| 4762 // TODO(karlkose): support type arguments here. | 4717 // TODO(karlkose): support type arguments here. |
| 4763 condition = new HIs(type, <HInstruction>[unwrappedException], | 4718 condition = new HIs(type, <HInstruction>[unwrappedException], |
| 4764 HIs.RAW_CHECK); | 4719 HIs.RAW_CHECK, nullOk: true); |
| 4765 push(condition); | 4720 push(condition); |
| 4766 } | 4721 } |
| 4767 } | 4722 } |
| 4768 } | 4723 } |
| 4769 | 4724 |
| 4770 void visitThen() { | 4725 void visitThen() { |
| 4771 CatchBlock catchBlock = link.head; | 4726 CatchBlock catchBlock = link.head; |
| 4772 link = link.tail; | 4727 link = link.tail; |
| 4773 | 4728 |
| 4774 if (compiler.enableTypeAssertions) { | 4729 if (compiler.enableTypeAssertions) { |
| (...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5322 new HSubGraphBlockInformation(elseBranch.graph)); | 5277 new HSubGraphBlockInformation(elseBranch.graph)); |
| 5323 | 5278 |
| 5324 HBasicBlock conditionStartBlock = conditionBranch.block; | 5279 HBasicBlock conditionStartBlock = conditionBranch.block; |
| 5325 conditionStartBlock.setBlockFlow(info, joinBlock); | 5280 conditionStartBlock.setBlockFlow(info, joinBlock); |
| 5326 SubGraph conditionGraph = conditionBranch.graph; | 5281 SubGraph conditionGraph = conditionBranch.graph; |
| 5327 HIf branch = conditionGraph.end.last; | 5282 HIf branch = conditionGraph.end.last; |
| 5328 assert(branch is HIf); | 5283 assert(branch is HIf); |
| 5329 branch.blockInformation = conditionStartBlock.blockFlow; | 5284 branch.blockInformation = conditionStartBlock.blockFlow; |
| 5330 } | 5285 } |
| 5331 } | 5286 } |
| OLD | NEW |