| 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 (type.kind == TypeKind.INTERFACE && !type.isMalformed && !type.isRaw) { |
| 1712 && backend.needsRti(enclosing)) { | 1744 HType subtype = new HType.subtype(type, compiler); |
| 1713 enclosing.typeVariables.forEach((TypeVariableType typeVariable) { | 1745 if (type.isRaw) { |
| 1714 HParameterValue param = addParameter(typeVariable.element); | 1746 return new HTypeConversion(type, kind, subtype, original); |
| 1715 localsHandler.directLocals[typeVariable.element] = param; | 1747 } |
| 1716 }); | 1748 HInstruction representations = buildTypeArgumentRepresentations(type); |
| 1749 add(representations); |
| 1750 return new HTypeConversion.withTypeRepresentation(type, kind, subtype, |
| 1751 original, representations); |
| 1752 } else if (type.kind == TypeKind.TYPE_VARIABLE) { |
| 1753 HType subtype = original.instructionType; |
| 1754 HInstruction typeVariable = addTypeVariableReference(type); |
| 1755 return new HTypeConversion.withTypeRepresentation(type, kind, subtype, |
| 1756 original, typeVariable); |
| 1757 } else { |
| 1758 return original.convertType(compiler, type, kind); |
| 1717 } | 1759 } |
| 1718 } | 1760 } |
| 1719 | 1761 |
| 1720 HInstruction potentiallyCheckType( | 1762 HInstruction potentiallyCheckType(HInstruction original, DartType type, |
| 1721 HInstruction original, DartType type, | |
| 1722 { int kind: HTypeConversion.CHECKED_MODE_CHECK }) { | 1763 { int kind: HTypeConversion.CHECKED_MODE_CHECK }) { |
| 1723 if (!compiler.enableTypeAssertions) return original; | 1764 if (!compiler.enableTypeAssertions) return original; |
| 1724 HInstruction other = original.convertType(compiler, type, kind); | 1765 HInstruction other = |
| 1766 buildTypeConversion(compiler, original, type, kind); |
| 1725 if (other != original) add(other); | 1767 if (other != original) add(other); |
| 1726 return other; | 1768 return other; |
| 1727 } | 1769 } |
| 1728 | 1770 |
| 1729 HGraph closeFunction() { | 1771 HGraph closeFunction() { |
| 1730 // TODO(kasperl): Make this goto an implicit return. | 1772 // TODO(kasperl): Make this goto an implicit return. |
| 1731 if (!isAborted()) closeAndGotoExit(new HGoto()); | 1773 if (!isAborted()) closeAndGotoExit(new HGoto()); |
| 1732 graph.finalize(); | 1774 graph.finalize(); |
| 1733 return graph; | 1775 return graph; |
| 1734 } | 1776 } |
| (...skipping 843 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2578 if (location == null) { | 2620 if (location == null) { |
| 2579 assert(send != null); | 2621 assert(send != null); |
| 2580 location = send; | 2622 location = send; |
| 2581 } | 2623 } |
| 2582 if (Elements.isStaticOrTopLevelField(element)) { | 2624 if (Elements.isStaticOrTopLevelField(element)) { |
| 2583 if (element.isSetter()) { | 2625 if (element.isSetter()) { |
| 2584 var instruction = buildInvokeStatic(element, | 2626 var instruction = buildInvokeStatic(element, |
| 2585 <HInstruction>[value], HType.UNKNOWN); | 2627 <HInstruction>[value], HType.UNKNOWN); |
| 2586 addWithPosition(instruction, location); | 2628 addWithPosition(instruction, location); |
| 2587 } else { | 2629 } else { |
| 2588 value = potentiallyCheckType(value, element.computeType(compiler)); | 2630 value = |
| 2631 potentiallyCheckType(value, element.computeType(compiler)); |
| 2589 addWithPosition(new HStaticStore(element, value), location); | 2632 addWithPosition(new HStaticStore(element, value), location); |
| 2590 } | 2633 } |
| 2591 stack.add(value); | 2634 stack.add(value); |
| 2592 } else if (Elements.isErroneousElement(element)) { | 2635 } else if (Elements.isErroneousElement(element)) { |
| 2593 // An erroneous element indicates an unresolved static setter. | 2636 // An erroneous element indicates an unresolved static setter. |
| 2594 generateThrowNoSuchMethod( | 2637 generateThrowNoSuchMethod( |
| 2595 location, | 2638 location, |
| 2596 getTargetName(element, 'set'), | 2639 getTargetName(element, 'set'), |
| 2597 argumentNodes: (send == null ? const Link<Node>() : send.arguments)); | 2640 argumentNodes: (send == null ? const Link<Node>() : send.arguments)); |
| 2598 } else { | 2641 } else { |
| 2599 stack.add(value); | 2642 stack.add(value); |
| 2600 // If the value does not already have a name, give it here. | 2643 // If the value does not already have a name, give it here. |
| 2601 if (value.sourceElement == null) { | 2644 if (value.sourceElement == null) { |
| 2602 value.sourceElement = element; | 2645 value.sourceElement = element; |
| 2603 } | 2646 } |
| 2604 HInstruction checked = potentiallyCheckType( | 2647 HInstruction checked = |
| 2605 value, element.computeType(compiler)); | 2648 potentiallyCheckType(value, element.computeType(compiler)); |
| 2606 if (!identical(checked, value)) { | 2649 if (!identical(checked, value)) { |
| 2607 pop(); | 2650 pop(); |
| 2608 stack.add(checked); | 2651 stack.add(checked); |
| 2609 } | 2652 } |
| 2610 localsHandler.updateLocal(element, checked); | 2653 localsHandler.updateLocal(element, checked); |
| 2611 } | 2654 } |
| 2612 } | 2655 } |
| 2613 | 2656 |
| 2614 HInstruction invokeInterceptor(Set<ClassElement> intercepted, | 2657 HInstruction invokeInterceptor(Set<ClassElement> intercepted, |
| 2615 HInstruction receiver) { | 2658 HInstruction receiver) { |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2748 isNot = true; | 2791 isNot = true; |
| 2749 } | 2792 } |
| 2750 DartType type = elements.getType(typeAnnotation); | 2793 DartType type = elements.getType(typeAnnotation); |
| 2751 if (type.isMalformed) { | 2794 if (type.isMalformed) { |
| 2752 String reasons = Types.fetchReasonsFromMalformedType(type); | 2795 String reasons = Types.fetchReasonsFromMalformedType(type); |
| 2753 if (compiler.enableTypeAssertions) { | 2796 if (compiler.enableTypeAssertions) { |
| 2754 generateMalformedSubtypeError(node, expression, type, reasons); | 2797 generateMalformedSubtypeError(node, expression, type, reasons); |
| 2755 } else { | 2798 } else { |
| 2756 generateRuntimeError(node, '$type is malformed: $reasons'); | 2799 generateRuntimeError(node, '$type is malformed: $reasons'); |
| 2757 } | 2800 } |
| 2758 return; | 2801 } else { |
| 2802 HInstruction instruction = buildIsNode(node, type, expression); |
| 2803 if (isNot) { |
| 2804 add(instruction); |
| 2805 instruction = new HNot(instruction); |
| 2806 } |
| 2807 push(instruction); |
| 2759 } | 2808 } |
| 2809 } |
| 2760 | 2810 |
| 2761 HInstruction instruction; | 2811 HInstruction buildIsNode(Node node, DartType type, HInstruction expression) { |
| 2762 if (type.kind == TypeKind.TYPE_VARIABLE) { | 2812 if (type.kind == TypeKind.TYPE_VARIABLE) { |
| 2763 HInstruction runtimeType = addTypeVariableReference(type); | 2813 HInstruction runtimeType = addTypeVariableReference(type); |
| 2764 Element helper = backend.getGetObjectIsSubtype(); | 2814 Element helper = backend.getCheckSubtypeOfRuntimeType(); |
| 2765 List<HInstruction> inputs = <HInstruction>[expression, runtimeType]; | 2815 List<HInstruction> inputs = <HInstruction>[expression, runtimeType]; |
| 2766 HInstruction call = buildInvokeStatic(helper, inputs, HType.BOOLEAN); | 2816 HInstruction call = buildInvokeStatic(helper, inputs, HType.BOOLEAN); |
| 2767 add(call); | 2817 add(call); |
| 2768 instruction = new HIs(type, <HInstruction>[expression, call], | 2818 return new HIs(type, <HInstruction>[expression, call], |
| 2769 HIs.VARIABLE_CHECK); | 2819 HIs.VARIABLE_CHECK); |
| 2770 } else if (RuntimeTypes.hasTypeArguments(type)) { | 2820 } else if (RuntimeTypes.hasTypeArguments(type)) { |
| 2771 Element element = type.element; | 2821 Element element = type.element; |
| 2772 Element helper = backend.getCheckSubtype(); | 2822 Element helper = backend.getCheckSubtype(); |
| 2773 HInstruction representations = | 2823 HInstruction representations = |
| 2774 buildTypeArgumentRepresentations(type); | 2824 buildTypeArgumentRepresentations(type); |
| 2775 add(representations); | 2825 add(representations); |
| 2776 String operator = | 2826 String operator = |
| 2777 backend.namer.operatorIs(backend.getImplementationClass(element)); | 2827 backend.namer.operatorIs(backend.getImplementationClass(element)); |
| 2778 HInstruction isFieldName = addConstantString(node, operator); | 2828 HInstruction isFieldName = addConstantString(node, operator); |
| 2779 // TODO(karlklose): use [:null:] for [asField] if [element] does not | 2829 // TODO(karlklose): use [:null:] for [asField] if [element] does not |
| 2780 // have a subclass. | 2830 // have a subclass. |
| 2781 HInstruction asFieldName = | 2831 HInstruction asFieldName = |
| 2782 addConstantString(node, backend.namer.substitutionName(element)); | 2832 addConstantString(node, backend.namer.substitutionName(element)); |
| 2783 List<HInstruction> inputs = <HInstruction>[expression, | 2833 List<HInstruction> inputs = <HInstruction>[expression, |
| 2784 isFieldName, | 2834 isFieldName, |
| 2785 representations, | 2835 representations, |
| 2786 asFieldName]; | 2836 asFieldName]; |
| 2787 HInstruction call = buildInvokeStatic(helper, inputs, HType.BOOLEAN); | 2837 HInstruction call = buildInvokeStatic(helper, inputs, HType.BOOLEAN); |
| 2788 add(call); | 2838 add(call); |
| 2789 instruction = new HIs(type, <HInstruction>[expression, call], | 2839 return |
| 2790 HIs.COMPOUND_CHECK); | 2840 new HIs(type, <HInstruction>[expression, call], HIs.COMPOUND_CHECK); |
| 2791 } else { | 2841 } else { |
| 2792 instruction = new HIs(type, <HInstruction>[expression], HIs.RAW_CHECK); | 2842 return new HIs(type, <HInstruction>[expression], HIs.RAW_CHECK); |
| 2793 } | 2843 } |
| 2794 if (isNot) { | |
| 2795 add(instruction); | |
| 2796 instruction = new HNot(instruction); | |
| 2797 } | |
| 2798 push(instruction); | |
| 2799 } | 2844 } |
| 2800 | 2845 |
| 2801 void addDynamicSendArgumentsToList(Send node, List<HInstruction> list) { | 2846 void addDynamicSendArgumentsToList(Send node, List<HInstruction> list) { |
| 2802 Selector selector = elements.getSelector(node); | 2847 Selector selector = elements.getSelector(node); |
| 2803 if (selector.namedArgumentCount == 0) { | 2848 if (selector.namedArgumentCount == 0) { |
| 2804 addGenericSendArgumentsToList(node.arguments, list); | 2849 addGenericSendArgumentsToList(node.arguments, list); |
| 2805 } else { | 2850 } else { |
| 2806 // Visit positional arguments and add them to the list. | 2851 // Visit positional arguments and add them to the list. |
| 2807 Link<Node> arguments = node.arguments; | 2852 Link<Node> arguments = node.arguments; |
| 2808 int positionalArgumentCount = selector.positionalArgumentCount; | 2853 int positionalArgumentCount = selector.positionalArgumentCount; |
| (...skipping 1892 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4701 // TODO(aprelev@gmail.com): Once old catch syntax is removed | 4746 // TODO(aprelev@gmail.com): Once old catch syntax is removed |
| 4702 // "if" condition above and this "else" branch should be deleted as | 4747 // "if" condition above and this "else" branch should be deleted as |
| 4703 // type of declared variable won't matter for the catch | 4748 // type of declared variable won't matter for the catch |
| 4704 // condition. | 4749 // condition. |
| 4705 DartType type = elements.getType(declaration.type); | 4750 DartType type = elements.getType(declaration.type); |
| 4706 if (type == null) { | 4751 if (type == null) { |
| 4707 compiler.cancel('Catch with unresolved type', node: catchBlock); | 4752 compiler.cancel('Catch with unresolved type', node: catchBlock); |
| 4708 } | 4753 } |
| 4709 // TODO(karlkose): support type arguments here. | 4754 // TODO(karlkose): support type arguments here. |
| 4710 condition = new HIs(type, <HInstruction>[unwrappedException], | 4755 condition = new HIs(type, <HInstruction>[unwrappedException], |
| 4711 HIs.RAW_CHECK, nullOk: true); | 4756 HIs.RAW_CHECK); |
| 4712 push(condition); | 4757 push(condition); |
| 4713 } | 4758 } |
| 4714 } | 4759 } |
| 4715 } | 4760 } |
| 4716 | 4761 |
| 4717 void visitThen() { | 4762 void visitThen() { |
| 4718 CatchBlock catchBlock = link.head; | 4763 CatchBlock catchBlock = link.head; |
| 4719 link = link.tail; | 4764 link = link.tail; |
| 4720 | 4765 |
| 4721 if (compiler.enableTypeAssertions) { | 4766 if (compiler.enableTypeAssertions) { |
| (...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5269 new HSubGraphBlockInformation(elseBranch.graph)); | 5314 new HSubGraphBlockInformation(elseBranch.graph)); |
| 5270 | 5315 |
| 5271 HBasicBlock conditionStartBlock = conditionBranch.block; | 5316 HBasicBlock conditionStartBlock = conditionBranch.block; |
| 5272 conditionStartBlock.setBlockFlow(info, joinBlock); | 5317 conditionStartBlock.setBlockFlow(info, joinBlock); |
| 5273 SubGraph conditionGraph = conditionBranch.graph; | 5318 SubGraph conditionGraph = conditionBranch.graph; |
| 5274 HIf branch = conditionGraph.end.last; | 5319 HIf branch = conditionGraph.end.last; |
| 5275 assert(branch is HIf); | 5320 assert(branch is HIf); |
| 5276 branch.blockInformation = conditionStartBlock.blockFlow; | 5321 branch.blockInformation = conditionStartBlock.blockFlow; |
| 5277 } | 5322 } |
| 5278 } | 5323 } |
| OLD | NEW |