| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 import 'package:kernel/ast.dart' as ir; | 5 import 'package:kernel/ast.dart' as ir; |
| 6 | 6 |
| 7 import '../closure.dart'; | 7 import '../closure.dart'; |
| 8 import '../common.dart'; | 8 import '../common.dart'; |
| 9 import '../common/codegen.dart' show CodegenRegistry; | 9 import '../common/codegen.dart' show CodegenRegistry; |
| 10 import '../common/names.dart'; | 10 import '../common/names.dart'; |
| (...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 643 visitElse: null, | 643 visitElse: null, |
| 644 // TODO(27394): Add sourceInformation via | 644 // TODO(27394): Add sourceInformation via |
| 645 // `sourceInformationBuilder.buildIf(?)`. | 645 // `sourceInformationBuilder.buildIf(?)`. |
| 646 ); | 646 ); |
| 647 } | 647 } |
| 648 } | 648 } |
| 649 functionNode.body.accept(this); | 649 functionNode.body.accept(this); |
| 650 closeFunction(); | 650 closeFunction(); |
| 651 } | 651 } |
| 652 | 652 |
| 653 void addImplicitInstantiation(ResolutionDartType type) { | 653 void addImplicitInstantiation(DartType type) { |
| 654 if (type != null) { | 654 if (type != null) { |
| 655 currentImplicitInstantiations.add(type); | 655 currentImplicitInstantiations.add(type); |
| 656 } | 656 } |
| 657 } | 657 } |
| 658 | 658 |
| 659 void removeImplicitInstantiation(ResolutionDartType type) { | 659 void removeImplicitInstantiation(DartType type) { |
| 660 if (type != null) { | 660 if (type != null) { |
| 661 currentImplicitInstantiations.removeLast(); | 661 currentImplicitInstantiations.removeLast(); |
| 662 } | 662 } |
| 663 } | 663 } |
| 664 | 664 |
| 665 void openFunction() { | 665 void openFunction() { |
| 666 HBasicBlock block = graph.addNewBlock(); | 666 HBasicBlock block = graph.addNewBlock(); |
| 667 open(graph.entry); | 667 open(graph.entry); |
| 668 | 668 |
| 669 localsHandler.startFunction(targetElement, functionNode, | 669 localsHandler.startFunction(targetElement, functionNode, |
| (...skipping 1153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1823 astAdapter.getConstantForSymbol(symbolLiteral), closedWorld)); | 1823 astAdapter.getConstantForSymbol(symbolLiteral), closedWorld)); |
| 1824 registry?.registerConstSymbol(symbolLiteral.value); | 1824 registry?.registerConstSymbol(symbolLiteral.value); |
| 1825 } | 1825 } |
| 1826 | 1826 |
| 1827 @override | 1827 @override |
| 1828 void visitNullLiteral(ir.NullLiteral nullLiteral) { | 1828 void visitNullLiteral(ir.NullLiteral nullLiteral) { |
| 1829 stack.add(graph.addConstantNull(closedWorld)); | 1829 stack.add(graph.addConstantNull(closedWorld)); |
| 1830 } | 1830 } |
| 1831 | 1831 |
| 1832 /// Set the runtime type information if necessary. | 1832 /// Set the runtime type information if necessary. |
| 1833 HInstruction setListRuntimeTypeInfoIfNeeded( | 1833 HInstruction _setListRuntimeTypeInfoIfNeeded( |
| 1834 HInstruction object, ir.ListLiteral listLiteral) { | 1834 HInstruction object, ir.ListLiteral listLiteral) { |
| 1835 ResolutionInterfaceType type = localsHandler | 1835 InterfaceType type = localsHandler.substInContext(_commonElements |
| 1836 .substInContext(astAdapter.getDartTypeOfListLiteral(listLiteral)); | 1836 .listType(_elementMap.getDartType(listLiteral.typeArgument))); |
| 1837 if (!rtiNeed.classNeedsRti(type.element) || type.treatAsRaw) { | 1837 if (!rtiNeed.classNeedsRti(type.element) || type.treatAsRaw) { |
| 1838 return object; | 1838 return object; |
| 1839 } | 1839 } |
| 1840 List<HInstruction> arguments = <HInstruction>[]; | 1840 List<HInstruction> arguments = <HInstruction>[]; |
| 1841 for (ResolutionDartType argument in type.typeArguments) { | 1841 for (DartType argument in type.typeArguments) { |
| 1842 arguments.add(typeBuilder.analyzeTypeArgument(argument, sourceElement)); | 1842 arguments.add(typeBuilder.analyzeTypeArgument(argument, sourceElement)); |
| 1843 } | 1843 } |
| 1844 // TODO(15489): Register at codegen. | 1844 // TODO(15489): Register at codegen. |
| 1845 registry?.registerInstantiation(type); | 1845 registry?.registerInstantiation(type); |
| 1846 return callSetRuntimeTypeInfoWithTypeArguments(type, arguments, object); | 1846 return callSetRuntimeTypeInfoWithTypeArguments(type, arguments, object); |
| 1847 } | 1847 } |
| 1848 | 1848 |
| 1849 @override | 1849 @override |
| 1850 void visitListLiteral(ir.ListLiteral listLiteral) { | 1850 void visitListLiteral(ir.ListLiteral listLiteral) { |
| 1851 HInstruction listInstruction; | 1851 HInstruction listInstruction; |
| 1852 if (listLiteral.isConst) { | 1852 if (listLiteral.isConst) { |
| 1853 listInstruction = graph.addConstant( | 1853 listInstruction = graph.addConstant( |
| 1854 astAdapter.getConstantFor(listLiteral), closedWorld); | 1854 astAdapter.getConstantFor(listLiteral), closedWorld); |
| 1855 } else { | 1855 } else { |
| 1856 List<HInstruction> elements = <HInstruction>[]; | 1856 List<HInstruction> elements = <HInstruction>[]; |
| 1857 for (ir.Expression element in listLiteral.expressions) { | 1857 for (ir.Expression element in listLiteral.expressions) { |
| 1858 element.accept(this); | 1858 element.accept(this); |
| 1859 elements.add(pop()); | 1859 elements.add(pop()); |
| 1860 } | 1860 } |
| 1861 listInstruction = | 1861 listInstruction = |
| 1862 new HLiteralList(elements, commonMasks.extendableArrayType); | 1862 new HLiteralList(elements, commonMasks.extendableArrayType); |
| 1863 add(listInstruction); | 1863 add(listInstruction); |
| 1864 listInstruction = | 1864 listInstruction = |
| 1865 setListRuntimeTypeInfoIfNeeded(listInstruction, listLiteral); | 1865 _setListRuntimeTypeInfoIfNeeded(listInstruction, listLiteral); |
| 1866 } | 1866 } |
| 1867 | 1867 |
| 1868 TypeMask type = _typeInferenceMap.typeOfListLiteral( | 1868 TypeMask type = _typeInferenceMap.typeOfListLiteral( |
| 1869 targetElement, listLiteral, closedWorld); | 1869 targetElement, listLiteral, closedWorld); |
| 1870 if (!type.containsAll(closedWorld)) { | 1870 if (!type.containsAll(closedWorld)) { |
| 1871 listInstruction.instructionType = type; | 1871 listInstruction.instructionType = type; |
| 1872 } | 1872 } |
| 1873 stack.add(listInstruction); | 1873 stack.add(listInstruction); |
| 1874 } | 1874 } |
| 1875 | 1875 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1898 constructor = _commonElements.mapLiteralConstructor; | 1898 constructor = _commonElements.mapLiteralConstructor; |
| 1899 HLiteralList argList = | 1899 HLiteralList argList = |
| 1900 new HLiteralList(constructorArgs, commonMasks.extendableArrayType); | 1900 new HLiteralList(constructorArgs, commonMasks.extendableArrayType); |
| 1901 add(argList); | 1901 add(argList); |
| 1902 inputs.add(argList); | 1902 inputs.add(argList); |
| 1903 } | 1903 } |
| 1904 | 1904 |
| 1905 assert( | 1905 assert( |
| 1906 constructor is ConstructorEntity && constructor.isFactoryConstructor); | 1906 constructor is ConstructorEntity && constructor.isFactoryConstructor); |
| 1907 | 1907 |
| 1908 ResolutionInterfaceType type = localsHandler | 1908 InterfaceType type = localsHandler.substInContext(_commonElements.mapType( |
| 1909 .substInContext(astAdapter.getDartTypeOfMapLiteral(mapLiteral)); | 1909 _elementMap.getDartType(mapLiteral.keyType), |
| 1910 | 1910 _elementMap.getDartType(mapLiteral.valueType))); |
| 1911 ClassEntity cls = constructor.enclosingClass; | 1911 ClassEntity cls = constructor.enclosingClass; |
| 1912 | 1912 |
| 1913 if (rtiNeed.classNeedsRti(cls)) { | 1913 if (rtiNeed.classNeedsRti(cls)) { |
| 1914 List<HInstruction> typeInputs = <HInstruction>[]; | 1914 List<HInstruction> typeInputs = <HInstruction>[]; |
| 1915 type.typeArguments.forEach((ResolutionDartType argument) { | 1915 type.typeArguments.forEach((DartType argument) { |
| 1916 typeInputs | 1916 typeInputs |
| 1917 .add(typeBuilder.analyzeTypeArgument(argument, sourceElement)); | 1917 .add(typeBuilder.analyzeTypeArgument(argument, sourceElement)); |
| 1918 }); | 1918 }); |
| 1919 | 1919 |
| 1920 // We lift this common call pattern into a helper function to save space | 1920 // We lift this common call pattern into a helper function to save space |
| 1921 // in the output. | 1921 // in the output. |
| 1922 if (typeInputs.every((HInstruction input) => input.isNull())) { | 1922 if (typeInputs.every((HInstruction input) => input.isNull())) { |
| 1923 if (constructorArgs.isEmpty) { | 1923 if (constructorArgs.isEmpty) { |
| 1924 constructor = _commonElements.mapLiteralUntypedEmptyMaker; | 1924 constructor = _commonElements.mapLiteralUntypedEmptyMaker; |
| 1925 } else { | 1925 } else { |
| (...skipping 1480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3406 enterBlock.setBlockFlow( | 3406 enterBlock.setBlockFlow( |
| 3407 new HTryBlockInformation( | 3407 new HTryBlockInformation( |
| 3408 kernelBuilder.wrapStatementGraph(bodyGraph), | 3408 kernelBuilder.wrapStatementGraph(bodyGraph), |
| 3409 exception, | 3409 exception, |
| 3410 kernelBuilder.wrapStatementGraph(catchGraph), | 3410 kernelBuilder.wrapStatementGraph(catchGraph), |
| 3411 kernelBuilder.wrapStatementGraph(finallyGraph)), | 3411 kernelBuilder.wrapStatementGraph(finallyGraph)), |
| 3412 exitBlock); | 3412 exitBlock); |
| 3413 kernelBuilder.inTryStatement = previouslyInTryStatement; | 3413 kernelBuilder.inTryStatement = previouslyInTryStatement; |
| 3414 } | 3414 } |
| 3415 } | 3415 } |
| OLD | NEW |