| 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/resolution_types.dart'; | 15 import 'package:compiler/src/elements/resolution_types.dart'; |
| 15 import 'package:compiler/src/elements/elements.dart'; | |
| 16 import 'package:compiler/src/js_backend/backend.dart'; | 16 import 'package:compiler/src/js_backend/backend.dart'; |
| 17 import 'package:compiler/src/kernel/element_adapter.dart'; |
| 17 import 'package:compiler/src/kernel/world_builder.dart'; | 18 import 'package:compiler/src/kernel/world_builder.dart'; |
| 18 import 'package:compiler/src/kernel/element_adapter.dart'; | |
| 19 import 'package:compiler/src/resolution/registry.dart'; | 19 import 'package:compiler/src/resolution/registry.dart'; |
| 20 import 'package:compiler/src/resolution/tree_elements.dart'; | 20 import 'package:compiler/src/resolution/tree_elements.dart'; |
| 21 import 'package:compiler/src/ssa/kernel_impact.dart'; | 21 import 'package:compiler/src/ssa/kernel_impact.dart'; |
| 22 import 'package:compiler/src/serialization/equivalence.dart'; | 22 import 'package:compiler/src/serialization/equivalence.dart'; |
| 23 import 'package:compiler/src/universe/call_structure.dart'; | 23 import 'package:compiler/src/universe/call_structure.dart'; |
| 24 import 'package:compiler/src/universe/feature.dart'; | 24 import 'package:compiler/src/universe/feature.dart'; |
| 25 import 'package:compiler/src/universe/use.dart'; | 25 import 'package:compiler/src/universe/use.dart'; |
| 26 import 'package:expect/expect.dart'; | 26 import 'package:expect/expect.dart'; |
| 27 import 'package:kernel/ast.dart' as ir; | 27 import 'package:kernel/ast.dart' as ir; |
| 28 import '../memory_compiler.dart'; | 28 import '../memory_compiler.dart'; |
| (...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 705 return; | 705 return; |
| 706 } | 706 } |
| 707 } | 707 } |
| 708 if (!fullTest && !compiler.resolution.hasResolutionImpact(element)) { | 708 if (!fullTest && !compiler.resolution.hasResolutionImpact(element)) { |
| 709 return; | 709 return; |
| 710 } | 710 } |
| 711 compiler.reporter.withCurrentElement(element.implementation, () { | 711 compiler.reporter.withCurrentElement(element.implementation, () { |
| 712 ResolutionImpact astImpact = | 712 ResolutionImpact astImpact = |
| 713 compiler.resolution.getResolutionImpact(element); | 713 compiler.resolution.getResolutionImpact(element); |
| 714 astImpact = laxImpact(compiler, element, astImpact); | 714 astImpact = laxImpact(compiler, element, astImpact); |
| 715 ResolutionImpact kernelImpact = build(compiler, element.resolvedAst); | 715 ResolutionImpact kernelImpact1 = build(compiler, element.resolvedAst); |
| 716 ir.Member member = getIrMember(compiler, element.resolvedAst); | 716 ir.Member member = getIrMember(compiler, element.resolvedAst); |
| 717 // TODO(johnniwinther): Check equivalence for the computed impact. | 717 Expect.isNotNull(kernelImpact1, 'No impact computed for $element'); |
| 718 buildKernelImpact(member, kernelElementAdapter); | 718 ResolutionImpact kernelImpact2 = |
| 719 Expect.isNotNull(kernelImpact, 'No impact computed for $element'); | 719 buildKernelImpact(member, kernelElementAdapter); |
| 720 testResolutionImpactEquivalence( | 720 Expect.isNotNull(kernelImpact2, 'No impact computed for $member'); |
| 721 astImpact, kernelImpact, const CheckStrategy()); | 721 testResolutionImpactEquivalence(astImpact, kernelImpact1, |
| 722 strategy: const CheckStrategy()); |
| 723 KernelEquivalence equivalence = new KernelEquivalence(kernelElementAdapter); |
| 724 testResolutionImpactEquivalence(astImpact, kernelImpact2, |
| 725 strategy: new CheckStrategy( |
| 726 elementEquivalence: equivalence.entityEquivalence, |
| 727 typeEquivalence: equivalence.typeEquivalence)); |
| 722 }); | 728 }); |
| 723 } | 729 } |
| 724 | 730 |
| 725 /// Lax the precision of [impact] to meet expectancy of the corresponding impact | 731 /// Lax the precision of [impact] to meet expectancy of the corresponding impact |
| 726 /// generated from kernel. | 732 /// generated from kernel. |
| 727 ResolutionImpact laxImpact( | 733 ResolutionImpact laxImpact( |
| 728 Compiler compiler, AstElement element, ResolutionImpact impact) { | 734 Compiler compiler, AstElement element, ResolutionImpact impact) { |
| 729 ResolutionWorldImpactBuilder builder = | 735 ResolutionWorldImpactBuilder builder = |
| 730 new ResolutionWorldImpactBuilder('Lax impact of ${element}'); | 736 new ResolutionWorldImpactBuilder('Lax impact of ${element}'); |
| 731 for (StaticUse staticUse in impact.staticUses) { | 737 for (StaticUse staticUse in impact.staticUses) { |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 852 visitList(type.optionalParameterTypes), | 858 visitList(type.optionalParameterTypes), |
| 853 type.namedParameters, | 859 type.namedParameters, |
| 854 visitList(type.namedParameterTypes)); | 860 visitList(type.namedParameterTypes)); |
| 855 } | 861 } |
| 856 } | 862 } |
| 857 | 863 |
| 858 /// Perform unaliasing of all typedefs nested within a [ResolutionDartType]. | 864 /// Perform unaliasing of all typedefs nested within a [ResolutionDartType]. |
| 859 ResolutionDartType unalias(ResolutionDartType type) { | 865 ResolutionDartType unalias(ResolutionDartType type) { |
| 860 return const Unaliaser().visit(type); | 866 return const Unaliaser().visit(type); |
| 861 } | 867 } |
| OLD | NEW |