| 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 library dart2js.kernel.impact_test; | 5 library dart2js.kernel.impact_test; |
| 6 | 6 |
| 7 import 'package:async_helper/async_helper.dart'; | 7 import 'package:async_helper/async_helper.dart'; |
| 8 import 'package:compiler/src/commandline_options.dart'; | 8 import 'package:compiler/src/commandline_options.dart'; |
| 9 import 'package:compiler/src/common.dart'; | 9 import 'package:compiler/src/common.dart'; |
| 10 import 'package:compiler/src/common/names.dart'; | 10 import 'package:compiler/src/common/names.dart'; |
| 11 import 'package:compiler/src/common/resolution.dart'; | 11 import 'package:compiler/src/common/resolution.dart'; |
| 12 import 'package:compiler/src/compiler.dart'; | 12 import 'package:compiler/src/compiler.dart'; |
| 13 import 'package:compiler/src/constants/expressions.dart'; | 13 import 'package:compiler/src/constants/expressions.dart'; |
| 14 import 'package:compiler/src/elements/elements.dart'; | 14 import 'package:compiler/src/elements/elements.dart'; |
| 15 import 'package:compiler/src/elements/entities.dart'; | 15 import 'package:compiler/src/elements/entities.dart'; |
| 16 import 'package:compiler/src/elements/resolution_types.dart'; | 16 import 'package:compiler/src/elements/resolution_types.dart'; |
| 17 import 'package:compiler/src/js_backend/backend.dart'; | 17 import 'package:compiler/src/js_backend/backend.dart'; |
| 18 import 'package:compiler/src/kernel/element_map.dart'; |
| 18 import 'package:compiler/src/kernel/element_map_impl.dart'; | 19 import 'package:compiler/src/kernel/element_map_impl.dart'; |
| 19 import 'package:compiler/src/resolution/registry.dart'; | 20 import 'package:compiler/src/resolution/registry.dart'; |
| 20 import 'package:compiler/src/resolution/tree_elements.dart'; | 21 import 'package:compiler/src/resolution/tree_elements.dart'; |
| 21 import 'package:compiler/src/ssa/kernel_impact.dart'; | 22 import 'package:compiler/src/ssa/kernel_impact.dart'; |
| 22 import 'package:compiler/src/serialization/equivalence.dart'; | 23 import 'package:compiler/src/serialization/equivalence.dart'; |
| 23 import 'package:compiler/src/universe/call_structure.dart'; | 24 import 'package:compiler/src/universe/call_structure.dart'; |
| 24 import 'package:compiler/src/universe/feature.dart'; | 25 import 'package:compiler/src/universe/feature.dart'; |
| 25 import 'package:compiler/src/universe/use.dart'; | 26 import 'package:compiler/src/universe/use.dart'; |
| 26 import 'package:expect/expect.dart'; | 27 import 'package:expect/expect.dart'; |
| 27 import 'package:kernel/ast.dart' as ir; | 28 import 'package:kernel/ast.dart' as ir; |
| (...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 737 entryPoint: entryPoint, | 738 entryPoint: entryPoint, |
| 738 memorySourceFiles: SOURCE, | 739 memorySourceFiles: SOURCE, |
| 739 options: [ | 740 options: [ |
| 740 fullTest ? Flags.analyzeAll : Flags.analyzeOnly, | 741 fullTest ? Flags.analyzeAll : Flags.analyzeOnly, |
| 741 Flags.useKernel, | 742 Flags.useKernel, |
| 742 Flags.enableAssertMessage | 743 Flags.enableAssertMessage |
| 743 ]); | 744 ]); |
| 744 compiler.resolution.retainCachesForTesting = true; | 745 compiler.resolution.retainCachesForTesting = true; |
| 745 Expect.isTrue(await compiler.run(entryPoint)); | 746 Expect.isTrue(await compiler.run(entryPoint)); |
| 746 JavaScriptBackend backend = compiler.backend; | 747 JavaScriptBackend backend = compiler.backend; |
| 747 KernelToElementMapImpl kernelElementMap = | 748 KernelToElementMapForImpact kernelElementMap = |
| 748 new KernelToElementMapImpl(compiler.reporter, compiler.environment); | 749 new KernelToElementMapForImpactImpl( |
| 750 compiler.reporter, compiler.environment); |
| 749 kernelElementMap.addProgram(backend.kernelTask.program); | 751 kernelElementMap.addProgram(backend.kernelTask.program); |
| 750 | 752 |
| 751 LibraryElement mainApp = | 753 LibraryElement mainApp = |
| 752 compiler.frontendStrategy.elementEnvironment.mainLibrary; | 754 compiler.frontendStrategy.elementEnvironment.mainLibrary; |
| 753 checkLibrary(compiler, kernelElementMap, mainApp, fullTest: fullTest); | 755 checkLibrary(compiler, kernelElementMap, mainApp, fullTest: fullTest); |
| 754 compiler.libraryLoader.libraries.forEach((LibraryEntity library) { | 756 compiler.libraryLoader.libraries.forEach((LibraryEntity library) { |
| 755 if (library == mainApp) return; | 757 if (library == mainApp) return; |
| 756 checkLibrary(compiler, kernelElementMap, library, fullTest: fullTest); | 758 checkLibrary(compiler, kernelElementMap, library, fullTest: fullTest); |
| 757 }); | 759 }); |
| 758 }); | 760 }); |
| 759 } | 761 } |
| 760 | 762 |
| 761 void checkLibrary(Compiler compiler, KernelToElementMapImpl elementMap, | 763 void checkLibrary(Compiler compiler, KernelToElementMapForImpact elementMap, |
| 762 LibraryElement library, | 764 LibraryElement library, |
| 763 {bool fullTest: false}) { | 765 {bool fullTest: false}) { |
| 764 library.forEachLocalMember((_element) { | 766 library.forEachLocalMember((_element) { |
| 765 AstElement element = _element; | 767 AstElement element = _element; |
| 766 if (element.isClass) { | 768 if (element.isClass) { |
| 767 ClassElement cls = element; | 769 ClassElement cls = element; |
| 768 cls.forEachLocalMember((_member) { | 770 cls.forEachLocalMember((_member) { |
| 769 AstElement member = _member; | 771 AstElement member = _member; |
| 770 checkElement(compiler, elementMap, member, fullTest: fullTest); | 772 checkElement(compiler, elementMap, member, fullTest: fullTest); |
| 771 }); | 773 }); |
| 772 } else if (element.isTypedef) { | 774 } else if (element.isTypedef) { |
| 773 // Skip typedefs. | 775 // Skip typedefs. |
| 774 } else { | 776 } else { |
| 775 checkElement(compiler, elementMap, element, fullTest: fullTest); | 777 checkElement(compiler, elementMap, element, fullTest: fullTest); |
| 776 } | 778 } |
| 777 }); | 779 }); |
| 778 } | 780 } |
| 779 | 781 |
| 780 void checkElement( | 782 void checkElement(Compiler compiler, KernelToElementMapForImpact elementMap, |
| 781 Compiler compiler, KernelToElementMapImpl elementMap, AstElement element, | 783 AstElement element, |
| 782 {bool fullTest: false}) { | 784 {bool fullTest: false}) { |
| 783 if (!fullTest && element.library.isPlatformLibrary) { | 785 if (!fullTest && element.library.isPlatformLibrary) { |
| 784 return; | 786 return; |
| 785 } | 787 } |
| 786 if (element.isConstructor) { | 788 if (element.isConstructor) { |
| 787 ConstructorElement constructor = element; | 789 ConstructorElement constructor = element; |
| 788 if (constructor.isRedirectingFactory) { | 790 if (constructor.isRedirectingFactory) { |
| 789 // Skip redirecting constructors for now; they might not be supported. | 791 // Skip redirecting constructors for now; they might not be supported. |
| 790 return; | 792 return; |
| 791 } | 793 } |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 901 builder.registerFeature(Feature.THROW_EXPRESSION); | 903 builder.registerFeature(Feature.THROW_EXPRESSION); |
| 902 break; | 904 break; |
| 903 default: | 905 default: |
| 904 builder.registerFeature(feature); | 906 builder.registerFeature(feature); |
| 905 break; | 907 break; |
| 906 } | 908 } |
| 907 } | 909 } |
| 908 impact.nativeData.forEach(builder.registerNativeData); | 910 impact.nativeData.forEach(builder.registerNativeData); |
| 909 return builder; | 911 return builder; |
| 910 } | 912 } |
| OLD | NEW |