| 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 | 76 |
| 77 final Compiler compiler; | 77 final Compiler compiler; |
| 78 | 78 |
| 79 @override | 79 @override |
| 80 JavaScriptBackend get backend => compiler.backend; | 80 JavaScriptBackend get backend => compiler.backend; |
| 81 | 81 |
| 82 @override | 82 @override |
| 83 TreeElements get elements => astAdapter.elements; | 83 TreeElements get elements => astAdapter.elements; |
| 84 | 84 |
| 85 SourceInformationBuilder sourceInformationBuilder; | 85 SourceInformationBuilder sourceInformationBuilder; |
| 86 KernelToElementMap _elementMap; | 86 final KernelToElementMap _elementMap; |
| 87 final KernelToTypeInferenceMap _typeInferenceMap; |
| 87 LoopHandler<ir.Node> loopHandler; | 88 LoopHandler<ir.Node> loopHandler; |
| 88 TypeBuilder typeBuilder; | 89 TypeBuilder typeBuilder; |
| 89 | 90 |
| 90 final Map<ir.VariableDeclaration, HInstruction> letBindings = | 91 final Map<ir.VariableDeclaration, HInstruction> letBindings = |
| 91 <ir.VariableDeclaration, HInstruction>{}; | 92 <ir.VariableDeclaration, HInstruction>{}; |
| 92 | 93 |
| 93 /// True if we are visiting the expression of a throw statement; we assume | 94 /// True if we are visiting the expression of a throw statement; we assume |
| 94 /// this is a slow path. | 95 /// this is a slow path. |
| 95 bool _inExpressionOfThrow = false; | 96 bool _inExpressionOfThrow = false; |
| 96 | 97 |
| 97 KernelSsaBuilder( | 98 KernelSsaBuilder( |
| 98 this.targetElement, | 99 this.targetElement, |
| 99 this.compiler, | 100 this.compiler, |
| 100 this._elementMap, | 101 this._elementMap, |
| 102 this._typeInferenceMap, |
| 101 this.closedWorld, | 103 this.closedWorld, |
| 102 this.registry, | 104 this.registry, |
| 103 // TODO(het): Should sourceInformationBuilder be in GraphBuilder? | 105 // TODO(het): Should sourceInformationBuilder be in GraphBuilder? |
| 104 this.sourceInformationBuilder, | 106 this.sourceInformationBuilder, |
| 105 this.functionNode) { | 107 this.functionNode) { |
| 106 this.loopHandler = new KernelLoopHandler(this); | 108 this.loopHandler = new KernelLoopHandler(this); |
| 107 typeBuilder = new TypeBuilder(this); | 109 typeBuilder = new TypeBuilder(this); |
| 108 graph.element = targetElement; | 110 graph.element = targetElement; |
| 109 graph.sourceInformation = | 111 graph.sourceInformation = |
| 110 sourceInformationBuilder.buildVariableDeclaration(); | 112 sourceInformationBuilder.buildVariableDeclaration(); |
| (...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 735 @override | 737 @override |
| 736 void visitCheckLibraryIsLoaded(ir.CheckLibraryIsLoaded checkLoad) { | 738 void visitCheckLibraryIsLoaded(ir.CheckLibraryIsLoaded checkLoad) { |
| 737 HInstruction prefixConstant = | 739 HInstruction prefixConstant = |
| 738 graph.addConstantString(checkLoad.import.name, closedWorld); | 740 graph.addConstantString(checkLoad.import.name, closedWorld); |
| 739 var prefixElement = astAdapter.getElement(checkLoad.import); | 741 var prefixElement = astAdapter.getElement(checkLoad.import); |
| 740 HInstruction uriConstant = graph.addConstantString( | 742 HInstruction uriConstant = graph.addConstantString( |
| 741 prefixElement.deferredImport.uri.toString(), closedWorld); | 743 prefixElement.deferredImport.uri.toString(), closedWorld); |
| 742 _pushStaticInvocation( | 744 _pushStaticInvocation( |
| 743 _commonElements.checkDeferredIsLoaded, | 745 _commonElements.checkDeferredIsLoaded, |
| 744 [prefixConstant, uriConstant], | 746 [prefixConstant, uriConstant], |
| 745 astAdapter.getReturnTypeOf(_commonElements.checkDeferredIsLoaded)); | 747 _typeInferenceMap |
| 748 .getReturnTypeOf(_commonElements.checkDeferredIsLoaded)); |
| 746 } | 749 } |
| 747 | 750 |
| 748 @override | 751 @override |
| 749 void visitLoadLibrary(ir.LoadLibrary loadLibrary) { | 752 void visitLoadLibrary(ir.LoadLibrary loadLibrary) { |
| 750 // TODO(efortuna): Source information! | 753 // TODO(efortuna): Source information! |
| 751 push(new HInvokeStatic( | 754 push(new HInvokeStatic( |
| 752 commonElements.loadLibraryWrapper, | 755 commonElements.loadLibraryWrapper, |
| 753 [graph.addConstantString(loadLibrary.import.name, closedWorld)], | 756 [graph.addConstantString(loadLibrary.import.name, closedWorld)], |
| 754 commonMasks.nonNullType, | 757 commonMasks.nonNullType, |
| 755 targetCanThrow: false)); | 758 targetCanThrow: false)); |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 883 forStatement, buildInitializer, buildCondition, buildUpdate, buildBody); | 886 forStatement, buildInitializer, buildCondition, buildUpdate, buildBody); |
| 884 } | 887 } |
| 885 | 888 |
| 886 @override | 889 @override |
| 887 void visitForInStatement(ir.ForInStatement forInStatement) { | 890 void visitForInStatement(ir.ForInStatement forInStatement) { |
| 888 if (forInStatement.isAsync) { | 891 if (forInStatement.isAsync) { |
| 889 _buildAsyncForIn(forInStatement); | 892 _buildAsyncForIn(forInStatement); |
| 890 } | 893 } |
| 891 // If the expression being iterated over is a JS indexable type, we can | 894 // If the expression being iterated over is a JS indexable type, we can |
| 892 // generate an optimized version of for-in that uses indexing. | 895 // generate an optimized version of for-in that uses indexing. |
| 893 if (astAdapter.isJsIndexableIterator(forInStatement, closedWorld)) { | 896 if (_typeInferenceMap.isJsIndexableIterator(forInStatement, closedWorld)) { |
| 894 _buildForInIndexable(forInStatement); | 897 _buildForInIndexable(forInStatement); |
| 895 } else { | 898 } else { |
| 896 _buildForInIterator(forInStatement); | 899 _buildForInIterator(forInStatement); |
| 897 } | 900 } |
| 898 } | 901 } |
| 899 | 902 |
| 900 /// Builds the graph for a for-in node with an indexable expression. | 903 /// Builds the graph for a for-in node with an indexable expression. |
| 901 /// | 904 /// |
| 902 /// In this case we build: | 905 /// In this case we build: |
| 903 /// | 906 /// |
| (...skipping 24 matching lines...) Expand all Loading... |
| 928 // The static call checkConcurrentModificationError() is expanded in | 931 // The static call checkConcurrentModificationError() is expanded in |
| 929 // codegen to: | 932 // codegen to: |
| 930 // | 933 // |
| 931 // array.length == _end || throwConcurrentModificationError(array) | 934 // array.length == _end || throwConcurrentModificationError(array) |
| 932 // | 935 // |
| 933 HInstruction length = buildGetLength(); | 936 HInstruction length = buildGetLength(); |
| 934 push(new HIdentity(length, originalLength, null, commonMasks.boolType)); | 937 push(new HIdentity(length, originalLength, null, commonMasks.boolType)); |
| 935 _pushStaticInvocation( | 938 _pushStaticInvocation( |
| 936 _commonElements.checkConcurrentModificationError, | 939 _commonElements.checkConcurrentModificationError, |
| 937 [pop(), array], | 940 [pop(), array], |
| 938 astAdapter.getReturnTypeOf( | 941 _typeInferenceMap.getReturnTypeOf( |
| 939 _commonElements.checkConcurrentModificationError)); | 942 _commonElements.checkConcurrentModificationError)); |
| 940 pop(); | 943 pop(); |
| 941 } | 944 } |
| 942 | 945 |
| 943 void buildInitializer() { | 946 void buildInitializer() { |
| 944 forInStatement.iterable.accept(this); | 947 forInStatement.iterable.accept(this); |
| 945 array = pop(); | 948 array = pop(); |
| 946 isFixed = astAdapter.isFixedLength(array.instructionType, closedWorld); | 949 isFixed = astAdapter.isFixedLength(array.instructionType, closedWorld); |
| 947 localsHandler.updateLocal( | 950 localsHandler.updateLocal( |
| 948 indexVariable, graph.addConstantInt(0, closedWorld)); | 951 indexVariable, graph.addConstantInt(0, closedWorld)); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 962 // If we had mechanically inlined ArrayIterator.moveNext(), it would have | 965 // If we had mechanically inlined ArrayIterator.moveNext(), it would have |
| 963 // inserted the ConcurrentModificationError check as part of the | 966 // inserted the ConcurrentModificationError check as part of the |
| 964 // condition. It is not necessary on the first iteration since there is | 967 // condition. It is not necessary on the first iteration since there is |
| 965 // no code between calls to `get iterator` and `moveNext`, so the test is | 968 // no code between calls to `get iterator` and `moveNext`, so the test is |
| 966 // moved to the loop update. | 969 // moved to the loop update. |
| 967 | 970 |
| 968 // Find a type for the element. Use the element type of the indexer of the | 971 // Find a type for the element. Use the element type of the indexer of the |
| 969 // array, as this is stronger than the iterator's `get current` type, for | 972 // array, as this is stronger than the iterator's `get current` type, for |
| 970 // example, `get current` includes null. | 973 // example, `get current` includes null. |
| 971 // TODO(sra): The element type of a container type mask might be better. | 974 // TODO(sra): The element type of a container type mask might be better. |
| 972 TypeMask type = astAdapter.inferredIndexType(forInStatement); | 975 TypeMask type = _typeInferenceMap.inferredIndexType(forInStatement); |
| 973 | 976 |
| 974 HInstruction index = localsHandler.readLocal(indexVariable); | 977 HInstruction index = localsHandler.readLocal(indexVariable); |
| 975 HInstruction value = new HIndex(array, index, null, type); | 978 HInstruction value = new HIndex(array, index, null, type); |
| 976 add(value); | 979 add(value); |
| 977 | 980 |
| 978 Local loopVariableLocal = astAdapter.getLocal(forInStatement.variable); | 981 Local loopVariableLocal = astAdapter.getLocal(forInStatement.variable); |
| 979 localsHandler.updateLocal(loopVariableLocal, value); | 982 localsHandler.updateLocal(loopVariableLocal, value); |
| 980 // Hint to name loop value after name of loop variable. | 983 // Hint to name loop value after name of loop variable. |
| 981 if (loopVariableLocal is! SyntheticLocal) { | 984 if (loopVariableLocal is! SyntheticLocal) { |
| 982 value.sourceElement ??= loopVariableLocal; | 985 value.sourceElement ??= loopVariableLocal; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1010 // Iterator<E> $iter = <iterable>.iterator; | 1013 // Iterator<E> $iter = <iterable>.iterator; |
| 1011 // while ($iter.moveNext()) { | 1014 // while ($iter.moveNext()) { |
| 1012 // <variable> = $iter.current; | 1015 // <variable> = $iter.current; |
| 1013 // <body> | 1016 // <body> |
| 1014 // } | 1017 // } |
| 1015 | 1018 |
| 1016 // The iterator is shared between initializer, condition and body. | 1019 // The iterator is shared between initializer, condition and body. |
| 1017 HInstruction iterator; | 1020 HInstruction iterator; |
| 1018 | 1021 |
| 1019 void buildInitializer() { | 1022 void buildInitializer() { |
| 1020 TypeMask mask = astAdapter.typeOfIterator(forInStatement); | 1023 TypeMask mask = _typeInferenceMap.typeOfIterator(forInStatement); |
| 1021 forInStatement.iterable.accept(this); | 1024 forInStatement.iterable.accept(this); |
| 1022 HInstruction receiver = pop(); | 1025 HInstruction receiver = pop(); |
| 1023 _pushDynamicInvocation(forInStatement, mask, <HInstruction>[receiver], | 1026 _pushDynamicInvocation(forInStatement, mask, <HInstruction>[receiver], |
| 1024 selector: Selectors.iterator); | 1027 selector: Selectors.iterator); |
| 1025 iterator = pop(); | 1028 iterator = pop(); |
| 1026 } | 1029 } |
| 1027 | 1030 |
| 1028 HInstruction buildCondition() { | 1031 HInstruction buildCondition() { |
| 1029 TypeMask mask = astAdapter.typeOfIteratorMoveNext(forInStatement); | 1032 TypeMask mask = _typeInferenceMap.typeOfIteratorMoveNext(forInStatement); |
| 1030 _pushDynamicInvocation(forInStatement, mask, <HInstruction>[iterator], | 1033 _pushDynamicInvocation(forInStatement, mask, <HInstruction>[iterator], |
| 1031 selector: Selectors.moveNext); | 1034 selector: Selectors.moveNext); |
| 1032 return popBoolified(); | 1035 return popBoolified(); |
| 1033 } | 1036 } |
| 1034 | 1037 |
| 1035 void buildBody() { | 1038 void buildBody() { |
| 1036 TypeMask mask = astAdapter.typeOfIteratorCurrent(forInStatement); | 1039 TypeMask mask = _typeInferenceMap.typeOfIteratorCurrent(forInStatement); |
| 1037 _pushDynamicInvocation(forInStatement, mask, [iterator], | 1040 _pushDynamicInvocation(forInStatement, mask, [iterator], |
| 1038 selector: Selectors.current); | 1041 selector: Selectors.current); |
| 1039 Local loopVariableLocal = astAdapter.getLocal(forInStatement.variable); | 1042 Local loopVariableLocal = astAdapter.getLocal(forInStatement.variable); |
| 1040 HInstruction value = pop(); | 1043 HInstruction value = pop(); |
| 1041 localsHandler.updateLocal(loopVariableLocal, value); | 1044 localsHandler.updateLocal(loopVariableLocal, value); |
| 1042 // Hint to name loop value after name of loop variable. | 1045 // Hint to name loop value after name of loop variable. |
| 1043 if (loopVariableLocal is! SyntheticLocal) { | 1046 if (loopVariableLocal is! SyntheticLocal) { |
| 1044 value.sourceElement ??= loopVariableLocal; | 1047 value.sourceElement ??= loopVariableLocal; |
| 1045 } | 1048 } |
| 1046 forInStatement.body.accept(this); | 1049 forInStatement.body.accept(this); |
| 1047 } | 1050 } |
| 1048 | 1051 |
| 1049 loopHandler.handleLoop( | 1052 loopHandler.handleLoop( |
| 1050 forInStatement, buildInitializer, buildCondition, () {}, buildBody); | 1053 forInStatement, buildInitializer, buildCondition, () {}, buildBody); |
| 1051 } | 1054 } |
| 1052 | 1055 |
| 1053 void _buildAsyncForIn(ir.ForInStatement forInStatement) { | 1056 void _buildAsyncForIn(ir.ForInStatement forInStatement) { |
| 1054 // The async-for is implemented with a StreamIterator. | 1057 // The async-for is implemented with a StreamIterator. |
| 1055 HInstruction streamIterator; | 1058 HInstruction streamIterator; |
| 1056 | 1059 |
| 1057 forInStatement.iterable.accept(this); | 1060 forInStatement.iterable.accept(this); |
| 1058 _pushStaticInvocation( | 1061 _pushStaticInvocation( |
| 1059 _commonElements.streamIteratorConstructor, | 1062 _commonElements.streamIteratorConstructor, |
| 1060 [pop(), graph.addConstantNull(closedWorld)], | 1063 [pop(), graph.addConstantNull(closedWorld)], |
| 1061 astAdapter.getReturnTypeOf(_commonElements.streamIteratorConstructor)); | 1064 _typeInferenceMap |
| 1065 .getReturnTypeOf(_commonElements.streamIteratorConstructor)); |
| 1062 streamIterator = pop(); | 1066 streamIterator = pop(); |
| 1063 | 1067 |
| 1064 void buildInitializer() {} | 1068 void buildInitializer() {} |
| 1065 | 1069 |
| 1066 HInstruction buildCondition() { | 1070 HInstruction buildCondition() { |
| 1067 TypeMask mask = astAdapter.typeOfIteratorMoveNext(forInStatement); | 1071 TypeMask mask = _typeInferenceMap.typeOfIteratorMoveNext(forInStatement); |
| 1068 _pushDynamicInvocation(forInStatement, mask, [streamIterator], | 1072 _pushDynamicInvocation(forInStatement, mask, [streamIterator], |
| 1069 selector: Selectors.moveNext); | 1073 selector: Selectors.moveNext); |
| 1070 HInstruction future = pop(); | 1074 HInstruction future = pop(); |
| 1071 push(new HAwait(future, closedWorld.commonMasks.dynamicType)); | 1075 push(new HAwait(future, closedWorld.commonMasks.dynamicType)); |
| 1072 return popBoolified(); | 1076 return popBoolified(); |
| 1073 } | 1077 } |
| 1074 | 1078 |
| 1075 void buildBody() { | 1079 void buildBody() { |
| 1076 TypeMask mask = astAdapter.typeOfIteratorCurrent(forInStatement); | 1080 TypeMask mask = _typeInferenceMap.typeOfIteratorCurrent(forInStatement); |
| 1077 _pushDynamicInvocation(forInStatement, mask, [streamIterator], | 1081 _pushDynamicInvocation(forInStatement, mask, [streamIterator], |
| 1078 selector: Selectors.current); | 1082 selector: Selectors.current); |
| 1079 localsHandler.updateLocal( | 1083 localsHandler.updateLocal( |
| 1080 astAdapter.getLocal(forInStatement.variable), pop()); | 1084 astAdapter.getLocal(forInStatement.variable), pop()); |
| 1081 forInStatement.body.accept(this); | 1085 forInStatement.body.accept(this); |
| 1082 } | 1086 } |
| 1083 | 1087 |
| 1084 void buildUpdate() {} | 1088 void buildUpdate() {} |
| 1085 | 1089 |
| 1086 // Creates a synthetic try/finally block in case anything async goes amiss. | 1090 // Creates a synthetic try/finally block in case anything async goes amiss. |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1326 | 1330 |
| 1327 void generateError(ir.Node node, FunctionEntity function, String message, | 1331 void generateError(ir.Node node, FunctionEntity function, String message, |
| 1328 TypeMask typeMask) { | 1332 TypeMask typeMask) { |
| 1329 HInstruction errorMessage = graph.addConstantString(message, closedWorld); | 1333 HInstruction errorMessage = graph.addConstantString(message, closedWorld); |
| 1330 // TODO(sra): Associate source info from [node]. | 1334 // TODO(sra): Associate source info from [node]. |
| 1331 _pushStaticInvocation(function, [errorMessage], typeMask); | 1335 _pushStaticInvocation(function, [errorMessage], typeMask); |
| 1332 } | 1336 } |
| 1333 | 1337 |
| 1334 void generateTypeError(ir.Node node, String message) { | 1338 void generateTypeError(ir.Node node, String message) { |
| 1335 generateError(node, _commonElements.throwTypeError, message, | 1339 generateError(node, _commonElements.throwTypeError, message, |
| 1336 astAdapter.getReturnTypeOf(_commonElements.throwTypeError)); | 1340 _typeInferenceMap.getReturnTypeOf(_commonElements.throwTypeError)); |
| 1337 } | 1341 } |
| 1338 | 1342 |
| 1339 @override | 1343 @override |
| 1340 void visitAssertStatement(ir.AssertStatement assertStatement) { | 1344 void visitAssertStatement(ir.AssertStatement assertStatement) { |
| 1341 if (!options.enableUserAssertions) return; | 1345 if (!options.enableUserAssertions) return; |
| 1342 if (assertStatement.message == null) { | 1346 if (assertStatement.message == null) { |
| 1343 assertStatement.condition.accept(this); | 1347 assertStatement.condition.accept(this); |
| 1344 _pushStaticInvocation(_commonElements.assertHelper, <HInstruction>[pop()], | 1348 _pushStaticInvocation(_commonElements.assertHelper, <HInstruction>[pop()], |
| 1345 astAdapter.getReturnTypeOf(_commonElements.assertHelper)); | 1349 _typeInferenceMap.getReturnTypeOf(_commonElements.assertHelper)); |
| 1346 pop(); | 1350 pop(); |
| 1347 return; | 1351 return; |
| 1348 } | 1352 } |
| 1349 | 1353 |
| 1350 // if (assertTest(condition)) assertThrow(message); | 1354 // if (assertTest(condition)) assertThrow(message); |
| 1351 void buildCondition() { | 1355 void buildCondition() { |
| 1352 assertStatement.condition.accept(this); | 1356 assertStatement.condition.accept(this); |
| 1353 _pushStaticInvocation(_commonElements.assertTest, <HInstruction>[pop()], | 1357 _pushStaticInvocation(_commonElements.assertTest, <HInstruction>[pop()], |
| 1354 astAdapter.getReturnTypeOf(_commonElements.assertTest)); | 1358 _typeInferenceMap.getReturnTypeOf(_commonElements.assertTest)); |
| 1355 } | 1359 } |
| 1356 | 1360 |
| 1357 void fail() { | 1361 void fail() { |
| 1358 assertStatement.message.accept(this); | 1362 assertStatement.message.accept(this); |
| 1359 _pushStaticInvocation(_commonElements.assertThrow, <HInstruction>[pop()], | 1363 _pushStaticInvocation(_commonElements.assertThrow, <HInstruction>[pop()], |
| 1360 astAdapter.getReturnTypeOf(_commonElements.assertThrow)); | 1364 _typeInferenceMap.getReturnTypeOf(_commonElements.assertThrow)); |
| 1361 pop(); | 1365 pop(); |
| 1362 } | 1366 } |
| 1363 | 1367 |
| 1364 handleIf(visitCondition: buildCondition, visitThen: fail); | 1368 handleIf(visitCondition: buildCondition, visitThen: fail); |
| 1365 } | 1369 } |
| 1366 | 1370 |
| 1367 /// Creates a [JumpHandler] for a statement. The node must be a jump | 1371 /// Creates a [JumpHandler] for a statement. The node must be a jump |
| 1368 /// target. If there are no breaks or continues targeting the statement, | 1372 /// target. If there are no breaks or continues targeting the statement, |
| 1369 /// a special "null handler" is returned. | 1373 /// a special "null handler" is returned. |
| 1370 /// | 1374 /// |
| (...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1859 element.accept(this); | 1863 element.accept(this); |
| 1860 elements.add(pop()); | 1864 elements.add(pop()); |
| 1861 } | 1865 } |
| 1862 listInstruction = | 1866 listInstruction = |
| 1863 new HLiteralList(elements, commonMasks.extendableArrayType); | 1867 new HLiteralList(elements, commonMasks.extendableArrayType); |
| 1864 add(listInstruction); | 1868 add(listInstruction); |
| 1865 listInstruction = | 1869 listInstruction = |
| 1866 setListRuntimeTypeInfoIfNeeded(listInstruction, listLiteral); | 1870 setListRuntimeTypeInfoIfNeeded(listInstruction, listLiteral); |
| 1867 } | 1871 } |
| 1868 | 1872 |
| 1869 TypeMask type = | 1873 TypeMask type = _typeInferenceMap.typeOfListLiteral( |
| 1870 astAdapter.typeOfListLiteral(targetElement, listLiteral, closedWorld); | 1874 targetElement, listLiteral, closedWorld); |
| 1871 if (!type.containsAll(closedWorld)) { | 1875 if (!type.containsAll(closedWorld)) { |
| 1872 listInstruction.instructionType = type; | 1876 listInstruction.instructionType = type; |
| 1873 } | 1877 } |
| 1874 stack.add(listInstruction); | 1878 stack.add(listInstruction); |
| 1875 } | 1879 } |
| 1876 | 1880 |
| 1877 @override | 1881 @override |
| 1878 void visitMapLiteral(ir.MapLiteral mapLiteral) { | 1882 void visitMapLiteral(ir.MapLiteral mapLiteral) { |
| 1879 if (mapLiteral.isConst) { | 1883 if (mapLiteral.isConst) { |
| 1880 stack.add(graph.addConstant( | 1884 stack.add(graph.addConstant( |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1975 // TODO(sra): Convert the type logic here to use ir.DartType. | 1979 // TODO(sra): Convert the type logic here to use ir.DartType. |
| 1976 ResolutionDartType dartType = _elementMap.getDartType(type); | 1980 ResolutionDartType dartType = _elementMap.getDartType(type); |
| 1977 dartType = localsHandler.substInContext(dartType); | 1981 dartType = localsHandler.substInContext(dartType); |
| 1978 HInstruction value = typeBuilder | 1982 HInstruction value = typeBuilder |
| 1979 .analyzeTypeArgument(dartType, sourceElement, sourceInformation: null); | 1983 .analyzeTypeArgument(dartType, sourceElement, sourceInformation: null); |
| 1980 _pushStaticInvocation(_commonElements.runtimeTypeToString, | 1984 _pushStaticInvocation(_commonElements.runtimeTypeToString, |
| 1981 <HInstruction>[value], commonMasks.stringType); | 1985 <HInstruction>[value], commonMasks.stringType); |
| 1982 _pushStaticInvocation( | 1986 _pushStaticInvocation( |
| 1983 _commonElements.createRuntimeType, | 1987 _commonElements.createRuntimeType, |
| 1984 <HInstruction>[pop()], | 1988 <HInstruction>[pop()], |
| 1985 astAdapter.getReturnTypeOf(_commonElements.createRuntimeType)); | 1989 _typeInferenceMap.getReturnTypeOf(_commonElements.createRuntimeType)); |
| 1986 } | 1990 } |
| 1987 | 1991 |
| 1988 @override | 1992 @override |
| 1989 void visitStaticGet(ir.StaticGet staticGet) { | 1993 void visitStaticGet(ir.StaticGet staticGet) { |
| 1990 ir.Member staticTarget = staticGet.target; | 1994 ir.Member staticTarget = staticGet.target; |
| 1991 if (staticTarget is ir.Procedure && | 1995 if (staticTarget is ir.Procedure && |
| 1992 staticTarget.kind == ir.ProcedureKind.Getter) { | 1996 staticTarget.kind == ir.ProcedureKind.Getter) { |
| 1993 FunctionEntity getter = _elementMap.getMember(staticTarget); | 1997 FunctionEntity getter = _elementMap.getMember(staticTarget); |
| 1994 // Invoke the getter | 1998 // Invoke the getter |
| 1995 _pushStaticInvocation( | 1999 _pushStaticInvocation(getter, const <HInstruction>[], |
| 1996 getter, const <HInstruction>[], astAdapter.getReturnTypeOf(getter)); | 2000 _typeInferenceMap.getReturnTypeOf(getter)); |
| 1997 } else if (staticTarget is ir.Field && | 2001 } else if (staticTarget is ir.Field && |
| 1998 (staticTarget.isConst || | 2002 (staticTarget.isConst || |
| 1999 staticTarget.isFinal && !_isLazyStatic(staticTarget))) { | 2003 staticTarget.isFinal && !_isLazyStatic(staticTarget))) { |
| 2000 stack.add(graph.addConstant( | 2004 stack.add(graph.addConstant( |
| 2001 astAdapter.getConstantFor(staticTarget.initializer), closedWorld)); | 2005 astAdapter.getConstantFor(staticTarget.initializer), closedWorld)); |
| 2002 } else { | 2006 } else { |
| 2003 if (_isLazyStatic(staticTarget)) { | 2007 if (_isLazyStatic(staticTarget)) { |
| 2004 FieldEntity field = _elementMap.getField(staticTarget); | 2008 FieldEntity field = _elementMap.getField(staticTarget); |
| 2005 push(new HLazyStatic(field, astAdapter.getInferredTypeOf(field))); | 2009 push( |
| 2010 new HLazyStatic(field, _typeInferenceMap.getInferredTypeOf(field))); |
| 2006 } else { | 2011 } else { |
| 2007 MemberEntity member = _elementMap.getMember(staticTarget); | 2012 MemberEntity member = _elementMap.getMember(staticTarget); |
| 2008 push(new HStatic(member, astAdapter.getInferredTypeOf(member))); | 2013 push(new HStatic(member, _typeInferenceMap.getInferredTypeOf(member))); |
| 2009 } | 2014 } |
| 2010 } | 2015 } |
| 2011 } | 2016 } |
| 2012 | 2017 |
| 2013 bool _isLazyStatic(ir.Member target) { | 2018 bool _isLazyStatic(ir.Member target) { |
| 2014 return astAdapter.isLazyStatic(target); | 2019 return astAdapter.isLazyStatic(target); |
| 2015 } | 2020 } |
| 2016 | 2021 |
| 2017 @override | 2022 @override |
| 2018 void visitStaticSet(ir.StaticSet staticSet) { | 2023 void visitStaticSet(ir.StaticSet staticSet) { |
| 2019 staticSet.value.accept(this); | 2024 staticSet.value.accept(this); |
| 2020 HInstruction value = pop(); | 2025 HInstruction value = pop(); |
| 2021 | 2026 |
| 2022 ir.Member staticTarget = staticSet.target; | 2027 ir.Member staticTarget = staticSet.target; |
| 2023 if (staticTarget is ir.Procedure) { | 2028 if (staticTarget is ir.Procedure) { |
| 2024 FunctionEntity setter = _elementMap.getMember(staticTarget); | 2029 FunctionEntity setter = _elementMap.getMember(staticTarget); |
| 2025 // Invoke the setter | 2030 // Invoke the setter |
| 2026 _pushStaticInvocation( | 2031 _pushStaticInvocation(setter, <HInstruction>[value], |
| 2027 setter, <HInstruction>[value], astAdapter.getReturnTypeOf(setter)); | 2032 _typeInferenceMap.getReturnTypeOf(setter)); |
| 2028 pop(); | 2033 pop(); |
| 2029 } else { | 2034 } else { |
| 2030 add(new HStaticStore( | 2035 add(new HStaticStore( |
| 2031 _elementMap.getMember(staticTarget), | 2036 _elementMap.getMember(staticTarget), |
| 2032 typeBuilder.potentiallyCheckOrTrustType( | 2037 typeBuilder.potentiallyCheckOrTrustType( |
| 2033 value, astAdapter.getDartTypeIfValid(staticTarget.setterType)))); | 2038 value, astAdapter.getDartTypeIfValid(staticTarget.setterType)))); |
| 2034 } | 2039 } |
| 2035 stack.add(value); | 2040 stack.add(value); |
| 2036 } | 2041 } |
| 2037 | 2042 |
| 2038 @override | 2043 @override |
| 2039 void visitPropertyGet(ir.PropertyGet propertyGet) { | 2044 void visitPropertyGet(ir.PropertyGet propertyGet) { |
| 2040 propertyGet.receiver.accept(this); | 2045 propertyGet.receiver.accept(this); |
| 2041 HInstruction receiver = pop(); | 2046 HInstruction receiver = pop(); |
| 2042 | 2047 |
| 2043 _pushDynamicInvocation(propertyGet, astAdapter.typeOfGet(propertyGet), | 2048 _pushDynamicInvocation(propertyGet, |
| 2044 <HInstruction>[receiver]); | 2049 _typeInferenceMap.typeOfGet(propertyGet), <HInstruction>[receiver]); |
| 2045 } | 2050 } |
| 2046 | 2051 |
| 2047 @override | 2052 @override |
| 2048 void visitVariableGet(ir.VariableGet variableGet) { | 2053 void visitVariableGet(ir.VariableGet variableGet) { |
| 2049 ir.VariableDeclaration variable = variableGet.variable; | 2054 ir.VariableDeclaration variable = variableGet.variable; |
| 2050 HInstruction letBinding = letBindings[variable]; | 2055 HInstruction letBinding = letBindings[variable]; |
| 2051 if (letBinding != null) { | 2056 if (letBinding != null) { |
| 2052 stack.add(letBinding); | 2057 stack.add(letBinding); |
| 2053 return; | 2058 return; |
| 2054 } | 2059 } |
| 2055 | 2060 |
| 2056 Local local = astAdapter.getLocal(variableGet.variable); | 2061 Local local = astAdapter.getLocal(variableGet.variable); |
| 2057 stack.add(localsHandler.readLocal(local)); | 2062 stack.add(localsHandler.readLocal(local)); |
| 2058 } | 2063 } |
| 2059 | 2064 |
| 2060 @override | 2065 @override |
| 2061 void visitPropertySet(ir.PropertySet propertySet) { | 2066 void visitPropertySet(ir.PropertySet propertySet) { |
| 2062 propertySet.receiver.accept(this); | 2067 propertySet.receiver.accept(this); |
| 2063 HInstruction receiver = pop(); | 2068 HInstruction receiver = pop(); |
| 2064 propertySet.value.accept(this); | 2069 propertySet.value.accept(this); |
| 2065 HInstruction value = pop(); | 2070 HInstruction value = pop(); |
| 2066 | 2071 |
| 2067 _pushDynamicInvocation( | 2072 _pushDynamicInvocation( |
| 2068 propertySet, | 2073 propertySet, |
| 2069 astAdapter.typeOfSet(propertySet, closedWorld), | 2074 _typeInferenceMap.typeOfSet(propertySet, closedWorld), |
| 2070 <HInstruction>[receiver, value]); | 2075 <HInstruction>[receiver, value]); |
| 2071 | 2076 |
| 2072 pop(); | 2077 pop(); |
| 2073 stack.add(value); | 2078 stack.add(value); |
| 2074 } | 2079 } |
| 2075 | 2080 |
| 2076 @override | 2081 @override |
| 2077 void visitSuperPropertySet(ir.SuperPropertySet propertySet) { | 2082 void visitSuperPropertySet(ir.SuperPropertySet propertySet) { |
| 2078 propertySet.value.accept(this); | 2083 propertySet.value.accept(this); |
| 2079 HInstruction value = pop(); | 2084 HInstruction value = pop(); |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2235 } | 2240 } |
| 2236 | 2241 |
| 2237 @override | 2242 @override |
| 2238 void visitStaticInvocation(ir.StaticInvocation invocation) { | 2243 void visitStaticInvocation(ir.StaticInvocation invocation) { |
| 2239 ir.Procedure target = invocation.target; | 2244 ir.Procedure target = invocation.target; |
| 2240 if (astAdapter.isForeignLibrary(target.enclosingLibrary)) { | 2245 if (astAdapter.isForeignLibrary(target.enclosingLibrary)) { |
| 2241 handleInvokeStaticForeign(invocation, target); | 2246 handleInvokeStaticForeign(invocation, target); |
| 2242 return; | 2247 return; |
| 2243 } | 2248 } |
| 2244 FunctionEntity function = _elementMap.getMember(target); | 2249 FunctionEntity function = _elementMap.getMember(target); |
| 2245 TypeMask typeMask = astAdapter.getReturnTypeOf(function); | 2250 TypeMask typeMask = _typeInferenceMap.getReturnTypeOf(function); |
| 2246 | 2251 |
| 2247 // TODO(sra): For JS interop external functions, use a different function to | 2252 // TODO(sra): For JS interop external functions, use a different function to |
| 2248 // build arguments. | 2253 // build arguments. |
| 2249 List<HInstruction> arguments = | 2254 List<HInstruction> arguments = |
| 2250 _visitArgumentsForStaticTarget(target.function, invocation.arguments); | 2255 _visitArgumentsForStaticTarget(target.function, invocation.arguments); |
| 2251 | 2256 |
| 2252 // Factory constructors take type parameters; other static methods ignore | 2257 // Factory constructors take type parameters; other static methods ignore |
| 2253 // them. | 2258 // them. |
| 2254 if (function is ConstructorEntity && function.isFactoryConstructor) { | 2259 if (function is ConstructorEntity && function.isFactoryConstructor) { |
| 2255 if (backend.rtiNeed.classNeedsRti(function.enclosingClass)) { | 2260 if (backend.rtiNeed.classNeedsRti(function.enclosingClass)) { |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2534 invocation, 1, 'JS_EMBEDDED_GLOBAL', 'second '); | 2539 invocation, 1, 'JS_EMBEDDED_GLOBAL', 'second '); |
| 2535 js.Template expr = js.js.expressionTemplateYielding( | 2540 js.Template expr = js.js.expressionTemplateYielding( |
| 2536 emitter.generateEmbeddedGlobalAccess(globalName)); | 2541 emitter.generateEmbeddedGlobalAccess(globalName)); |
| 2537 | 2542 |
| 2538 native.NativeBehavior nativeBehavior = | 2543 native.NativeBehavior nativeBehavior = |
| 2539 astAdapter.getNativeBehavior(invocation); | 2544 astAdapter.getNativeBehavior(invocation); |
| 2540 assert(invariant(astAdapter.getNode(invocation), nativeBehavior != null, | 2545 assert(invariant(astAdapter.getNode(invocation), nativeBehavior != null, |
| 2541 message: "No NativeBehavior for $invocation")); | 2546 message: "No NativeBehavior for $invocation")); |
| 2542 | 2547 |
| 2543 TypeMask ssaType = | 2548 TypeMask ssaType = |
| 2544 astAdapter.typeFromNativeBehavior(nativeBehavior, closedWorld); | 2549 _typeInferenceMap.typeFromNativeBehavior(nativeBehavior, closedWorld); |
| 2545 push(new HForeignCode(expr, ssaType, const <HInstruction>[], | 2550 push(new HForeignCode(expr, ssaType, const <HInstruction>[], |
| 2546 nativeBehavior: nativeBehavior)); | 2551 nativeBehavior: nativeBehavior)); |
| 2547 } | 2552 } |
| 2548 | 2553 |
| 2549 void handleForeignJsBuiltin(ir.StaticInvocation invocation) { | 2554 void handleForeignJsBuiltin(ir.StaticInvocation invocation) { |
| 2550 if (_unexpectedForeignArguments(invocation, 2)) { | 2555 if (_unexpectedForeignArguments(invocation, 2)) { |
| 2551 // Result expected on stack. | 2556 // Result expected on stack. |
| 2552 stack.add(graph.addConstantNull(closedWorld)); | 2557 stack.add(graph.addConstantNull(closedWorld)); |
| 2553 return; | 2558 return; |
| 2554 } | 2559 } |
| (...skipping 23 matching lines...) Expand all Loading... |
| 2578 argument.accept(this); | 2583 argument.accept(this); |
| 2579 inputs.add(pop()); | 2584 inputs.add(pop()); |
| 2580 } | 2585 } |
| 2581 | 2586 |
| 2582 native.NativeBehavior nativeBehavior = | 2587 native.NativeBehavior nativeBehavior = |
| 2583 astAdapter.getNativeBehavior(invocation); | 2588 astAdapter.getNativeBehavior(invocation); |
| 2584 assert(invariant(astAdapter.getNode(invocation), nativeBehavior != null, | 2589 assert(invariant(astAdapter.getNode(invocation), nativeBehavior != null, |
| 2585 message: "No NativeBehavior for $invocation")); | 2590 message: "No NativeBehavior for $invocation")); |
| 2586 | 2591 |
| 2587 TypeMask ssaType = | 2592 TypeMask ssaType = |
| 2588 astAdapter.typeFromNativeBehavior(nativeBehavior, closedWorld); | 2593 _typeInferenceMap.typeFromNativeBehavior(nativeBehavior, closedWorld); |
| 2589 push(new HForeignCode(template, ssaType, inputs, | 2594 push(new HForeignCode(template, ssaType, inputs, |
| 2590 nativeBehavior: nativeBehavior)); | 2595 nativeBehavior: nativeBehavior)); |
| 2591 } | 2596 } |
| 2592 | 2597 |
| 2593 void handleForeignJsGetFlag(ir.StaticInvocation invocation) { | 2598 void handleForeignJsGetFlag(ir.StaticInvocation invocation) { |
| 2594 if (_unexpectedForeignArguments(invocation, 1, 1)) { | 2599 if (_unexpectedForeignArguments(invocation, 1, 1)) { |
| 2595 stack.add( | 2600 stack.add( |
| 2596 // Result expected on stack. | 2601 // Result expected on stack. |
| 2597 graph.addConstantBool(false, closedWorld)); | 2602 graph.addConstantBool(false, closedWorld)); |
| 2598 return; | 2603 return; |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2666 stack.add(graph.addConstantNull(closedWorld)); | 2671 stack.add(graph.addConstantNull(closedWorld)); |
| 2667 return; | 2672 return; |
| 2668 } | 2673 } |
| 2669 | 2674 |
| 2670 if (native.HasCapturedPlaceholders.check(nativeBehavior.codeTemplate.ast)) { | 2675 if (native.HasCapturedPlaceholders.check(nativeBehavior.codeTemplate.ast)) { |
| 2671 reporter.reportErrorMessage( | 2676 reporter.reportErrorMessage( |
| 2672 astAdapter.getNode(invocation), MessageKind.JS_PLACEHOLDER_CAPTURE); | 2677 astAdapter.getNode(invocation), MessageKind.JS_PLACEHOLDER_CAPTURE); |
| 2673 } | 2678 } |
| 2674 | 2679 |
| 2675 TypeMask ssaType = | 2680 TypeMask ssaType = |
| 2676 astAdapter.typeFromNativeBehavior(nativeBehavior, closedWorld); | 2681 _typeInferenceMap.typeFromNativeBehavior(nativeBehavior, closedWorld); |
| 2677 | 2682 |
| 2678 SourceInformation sourceInformation = null; | 2683 SourceInformation sourceInformation = null; |
| 2679 push(new HForeignCode(nativeBehavior.codeTemplate, ssaType, inputs, | 2684 push(new HForeignCode(nativeBehavior.codeTemplate, ssaType, inputs, |
| 2680 isStatement: !nativeBehavior.codeTemplate.isExpression, | 2685 isStatement: !nativeBehavior.codeTemplate.isExpression, |
| 2681 effects: nativeBehavior.sideEffects, | 2686 effects: nativeBehavior.sideEffects, |
| 2682 nativeBehavior: nativeBehavior) | 2687 nativeBehavior: nativeBehavior) |
| 2683 ..sourceInformation = sourceInformation); | 2688 ..sourceInformation = sourceInformation); |
| 2684 } | 2689 } |
| 2685 | 2690 |
| 2686 void handleJsStringConcat(ir.StaticInvocation invocation) { | 2691 void handleJsStringConcat(ir.StaticInvocation invocation) { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 2716 | 2721 |
| 2717 bool isIntercepted = | 2722 bool isIntercepted = |
| 2718 closedWorld.interceptorData.isInterceptedSelector(selector); | 2723 closedWorld.interceptorData.isInterceptedSelector(selector); |
| 2719 | 2724 |
| 2720 if (isIntercepted) { | 2725 if (isIntercepted) { |
| 2721 HInterceptor interceptor = _interceptorFor(receiver); | 2726 HInterceptor interceptor = _interceptorFor(receiver); |
| 2722 inputs.add(interceptor); | 2727 inputs.add(interceptor); |
| 2723 } | 2728 } |
| 2724 inputs.addAll(arguments); | 2729 inputs.addAll(arguments); |
| 2725 | 2730 |
| 2726 TypeMask type = astAdapter.selectorTypeOf(selector, mask); | 2731 TypeMask type = _typeInferenceMap.selectorTypeOf(selector, mask); |
| 2727 if (selector.isGetter) { | 2732 if (selector.isGetter) { |
| 2728 push(new HInvokeDynamicGetter(selector, mask, null, inputs, type)); | 2733 push(new HInvokeDynamicGetter(selector, mask, null, inputs, type)); |
| 2729 } else if (selector.isSetter) { | 2734 } else if (selector.isSetter) { |
| 2730 push(new HInvokeDynamicSetter(selector, mask, null, inputs, type)); | 2735 push(new HInvokeDynamicSetter(selector, mask, null, inputs, type)); |
| 2731 } else { | 2736 } else { |
| 2732 push(new HInvokeDynamicMethod( | 2737 push(new HInvokeDynamicMethod( |
| 2733 selector, mask, inputs, type, isIntercepted)); | 2738 selector, mask, inputs, type, isIntercepted)); |
| 2734 } | 2739 } |
| 2735 } | 2740 } |
| 2736 | 2741 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2777 @override | 2782 @override |
| 2778 void visitMethodInvocation(ir.MethodInvocation invocation) { | 2783 void visitMethodInvocation(ir.MethodInvocation invocation) { |
| 2779 // Handle `x == null` specially. When these come from null-aware operators, | 2784 // Handle `x == null` specially. When these come from null-aware operators, |
| 2780 // there is no mapping in the astAdapter. | 2785 // there is no mapping in the astAdapter. |
| 2781 if (_handleEqualsNull(invocation)) return; | 2786 if (_handleEqualsNull(invocation)) return; |
| 2782 invocation.receiver.accept(this); | 2787 invocation.receiver.accept(this); |
| 2783 HInstruction receiver = pop(); | 2788 HInstruction receiver = pop(); |
| 2784 Selector selector = _elementMap.getSelector(invocation); | 2789 Selector selector = _elementMap.getSelector(invocation); |
| 2785 _pushDynamicInvocation( | 2790 _pushDynamicInvocation( |
| 2786 invocation, | 2791 invocation, |
| 2787 astAdapter.typeOfInvocation(invocation, closedWorld), | 2792 _typeInferenceMap.typeOfInvocation(invocation, closedWorld), |
| 2788 <HInstruction>[receiver]..addAll( | 2793 <HInstruction>[receiver]..addAll( |
| 2789 _visitArgumentsForDynamicTarget(selector, invocation.arguments))); | 2794 _visitArgumentsForDynamicTarget(selector, invocation.arguments))); |
| 2790 } | 2795 } |
| 2791 | 2796 |
| 2792 bool _handleEqualsNull(ir.MethodInvocation invocation) { | 2797 bool _handleEqualsNull(ir.MethodInvocation invocation) { |
| 2793 if (invocation.name.name == '==') { | 2798 if (invocation.name.name == '==') { |
| 2794 ir.Arguments arguments = invocation.arguments; | 2799 ir.Arguments arguments = invocation.arguments; |
| 2795 if (arguments.types.isEmpty && | 2800 if (arguments.types.isEmpty && |
| 2796 arguments.positional.length == 1 && | 2801 arguments.positional.length == 1 && |
| 2797 arguments.named.isEmpty) { | 2802 arguments.named.isEmpty) { |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2886 | 2891 |
| 2887 List<HInstruction> inputs = <HInstruction>[]; | 2892 List<HInstruction> inputs = <HInstruction>[]; |
| 2888 if (closedWorld.interceptorData.isInterceptedSelector(selector)) { | 2893 if (closedWorld.interceptorData.isInterceptedSelector(selector)) { |
| 2889 inputs.add(_interceptorFor(receiver)); | 2894 inputs.add(_interceptorFor(receiver)); |
| 2890 } | 2895 } |
| 2891 inputs.add(receiver); | 2896 inputs.add(receiver); |
| 2892 inputs.addAll(arguments); | 2897 inputs.addAll(arguments); |
| 2893 | 2898 |
| 2894 TypeMask typeMask; | 2899 TypeMask typeMask; |
| 2895 if (target is FunctionEntity) { | 2900 if (target is FunctionEntity) { |
| 2896 typeMask = astAdapter.getReturnTypeOf(target); | 2901 typeMask = _typeInferenceMap.getReturnTypeOf(target); |
| 2897 } else { | 2902 } else { |
| 2898 typeMask = closedWorld.commonMasks.dynamicType; | 2903 typeMask = closedWorld.commonMasks.dynamicType; |
| 2899 } | 2904 } |
| 2900 HInstruction instruction = new HInvokeSuper( | 2905 HInstruction instruction = new HInvokeSuper( |
| 2901 target, containingClass, selector, inputs, typeMask, null, | 2906 target, containingClass, selector, inputs, typeMask, null, |
| 2902 isSetter: selector.isSetter || selector.isIndexSet); | 2907 isSetter: selector.isSetter || selector.isIndexSet); |
| 2903 instruction.sideEffects = | 2908 instruction.sideEffects = |
| 2904 closedWorld.getSideEffectsOfSelector(selector, null); | 2909 closedWorld.getSideEffectsOfSelector(selector, null); |
| 2905 push(instruction); | 2910 push(instruction); |
| 2906 return instruction; | 2911 return instruction; |
| (...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3291 // Note that the name of this local is irrelevant. | 3296 // Note that the name of this local is irrelevant. |
| 3292 SyntheticLocal local = kernelBuilder.localsHandler.createLocal('exception'); | 3297 SyntheticLocal local = kernelBuilder.localsHandler.createLocal('exception'); |
| 3293 exception = new HLocalValue(local, kernelBuilder.commonMasks.nonNullType); | 3298 exception = new HLocalValue(local, kernelBuilder.commonMasks.nonNullType); |
| 3294 kernelBuilder.add(exception); | 3299 kernelBuilder.add(exception); |
| 3295 HInstruction oldRethrowableException = kernelBuilder.rethrowableException; | 3300 HInstruction oldRethrowableException = kernelBuilder.rethrowableException; |
| 3296 kernelBuilder.rethrowableException = exception; | 3301 kernelBuilder.rethrowableException = exception; |
| 3297 | 3302 |
| 3298 kernelBuilder._pushStaticInvocation( | 3303 kernelBuilder._pushStaticInvocation( |
| 3299 kernelBuilder._commonElements.exceptionUnwrapper, | 3304 kernelBuilder._commonElements.exceptionUnwrapper, |
| 3300 [exception], | 3305 [exception], |
| 3301 kernelBuilder.astAdapter | 3306 kernelBuilder._typeInferenceMap |
| 3302 .getReturnTypeOf(kernelBuilder._commonElements.exceptionUnwrapper)); | 3307 .getReturnTypeOf(kernelBuilder._commonElements.exceptionUnwrapper)); |
| 3303 HInvokeStatic unwrappedException = kernelBuilder.pop(); | 3308 HInvokeStatic unwrappedException = kernelBuilder.pop(); |
| 3304 tryInstruction.exception = exception; | 3309 tryInstruction.exception = exception; |
| 3305 int catchesIndex = 0; | 3310 int catchesIndex = 0; |
| 3306 | 3311 |
| 3307 void pushCondition(ir.Catch catchBlock) { | 3312 void pushCondition(ir.Catch catchBlock) { |
| 3308 // `guard` is often `dynamic`, which generates `true`. | 3313 // `guard` is often `dynamic`, which generates `true`. |
| 3309 kernelBuilder.pushIsTest( | 3314 kernelBuilder.pushIsTest( |
| 3310 catchBlock.exception, catchBlock.guard, unwrappedException); | 3315 catchBlock.exception, catchBlock.guard, unwrappedException); |
| 3311 } | 3316 } |
| 3312 | 3317 |
| 3313 void visitThen() { | 3318 void visitThen() { |
| 3314 ir.Catch catchBlock = tryCatch.catches[catchesIndex]; | 3319 ir.Catch catchBlock = tryCatch.catches[catchesIndex]; |
| 3315 catchesIndex++; | 3320 catchesIndex++; |
| 3316 if (catchBlock.exception != null) { | 3321 if (catchBlock.exception != null) { |
| 3317 LocalVariableElement exceptionVariable = | 3322 LocalVariableElement exceptionVariable = |
| 3318 kernelBuilder.astAdapter.getElement(catchBlock.exception); | 3323 kernelBuilder.astAdapter.getElement(catchBlock.exception); |
| 3319 kernelBuilder.localsHandler | 3324 kernelBuilder.localsHandler |
| 3320 .updateLocal(exceptionVariable, unwrappedException); | 3325 .updateLocal(exceptionVariable, unwrappedException); |
| 3321 } | 3326 } |
| 3322 if (catchBlock.stackTrace != null) { | 3327 if (catchBlock.stackTrace != null) { |
| 3323 kernelBuilder._pushStaticInvocation( | 3328 kernelBuilder._pushStaticInvocation( |
| 3324 kernelBuilder._commonElements.traceFromException, | 3329 kernelBuilder._commonElements.traceFromException, |
| 3325 [exception], | 3330 [exception], |
| 3326 kernelBuilder.astAdapter.getReturnTypeOf( | 3331 kernelBuilder._typeInferenceMap.getReturnTypeOf( |
| 3327 kernelBuilder._commonElements.traceFromException)); | 3332 kernelBuilder._commonElements.traceFromException)); |
| 3328 HInstruction traceInstruction = kernelBuilder.pop(); | 3333 HInstruction traceInstruction = kernelBuilder.pop(); |
| 3329 LocalVariableElement traceVariable = | 3334 LocalVariableElement traceVariable = |
| 3330 kernelBuilder.astAdapter.getElement(catchBlock.stackTrace); | 3335 kernelBuilder.astAdapter.getElement(catchBlock.stackTrace); |
| 3331 kernelBuilder.localsHandler | 3336 kernelBuilder.localsHandler |
| 3332 .updateLocal(traceVariable, traceInstruction); | 3337 .updateLocal(traceVariable, traceInstruction); |
| 3333 } | 3338 } |
| 3334 catchBlock.body.accept(kernelBuilder); | 3339 catchBlock.body.accept(kernelBuilder); |
| 3335 } | 3340 } |
| 3336 | 3341 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3380 enterBlock.setBlockFlow( | 3385 enterBlock.setBlockFlow( |
| 3381 new HTryBlockInformation( | 3386 new HTryBlockInformation( |
| 3382 kernelBuilder.wrapStatementGraph(bodyGraph), | 3387 kernelBuilder.wrapStatementGraph(bodyGraph), |
| 3383 exception, | 3388 exception, |
| 3384 kernelBuilder.wrapStatementGraph(catchGraph), | 3389 kernelBuilder.wrapStatementGraph(catchGraph), |
| 3385 kernelBuilder.wrapStatementGraph(finallyGraph)), | 3390 kernelBuilder.wrapStatementGraph(finallyGraph)), |
| 3386 exitBlock); | 3391 exitBlock); |
| 3387 kernelBuilder.inTryStatement = previouslyInTryStatement; | 3392 kernelBuilder.inTryStatement = previouslyInTryStatement; |
| 3388 } | 3393 } |
| 3389 } | 3394 } |
| OLD | NEW |