Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(174)

Side by Side Diff: pkg/compiler/lib/src/serialization/equivalence.dart

Issue 2668623003: Check equivalence on impact computed with KernelWorldBuilder. (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 /// Functions for asserting equivalence across serialization. 5 /// Functions for asserting equivalence across serialization.
6 6
7 library dart2js.serialization.equivalence; 7 library dart2js.serialization.equivalence;
8 8
9 import '../closure.dart'; 9 import '../closure.dart';
10 import '../common/resolution.dart'; 10 import '../common/resolution.dart';
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 a.isSetter == b.isSetter && 166 a.isSetter == b.isSetter &&
167 areElementsEquivalent(library1, library2); 167 areElementsEquivalent(library1, library2);
168 } 168 }
169 169
170 /// Returns `true` if the dynamic uses [a] and [b] are equivalent. 170 /// Returns `true` if the dynamic uses [a] and [b] are equivalent.
171 bool areDynamicUsesEquivalent(DynamicUse a, DynamicUse b) { 171 bool areDynamicUsesEquivalent(DynamicUse a, DynamicUse b) {
172 return areSelectorsEquivalent(a.selector, b.selector); 172 return areSelectorsEquivalent(a.selector, b.selector);
173 } 173 }
174 174
175 /// Returns `true` if the static uses [a] and [b] are equivalent. 175 /// Returns `true` if the static uses [a] and [b] are equivalent.
176 bool areStaticUsesEquivalent(StaticUse a, StaticUse b) { 176 bool areStaticUsesEquivalent(StaticUse a, StaticUse b,
177 return a.kind == b.kind && areElementsEquivalent(a.element, b.element); 177 {TestStrategy strategy: const TestStrategy()}) {
178 return a.kind == b.kind &&
179 strategy.testElements(a, b, 'element', a.element, b.element);
178 } 180 }
179 181
180 /// Returns `true` if the type uses [a] and [b] are equivalent. 182 /// Returns `true` if the type uses [a] and [b] are equivalent.
181 bool areTypeUsesEquivalent(TypeUse a, TypeUse b) { 183 bool areTypeUsesEquivalent(TypeUse a, TypeUse b,
182 return a.kind == b.kind && areTypesEquivalent(a.type, b.type); 184 {TestStrategy strategy: const TestStrategy()}) {
185 return a.kind == b.kind && strategy.testTypes(a, b, 'type', a.type, b.type);
183 } 186 }
184 187
185 /// Returns `true` if the list literal uses [a] and [b] are equivalent. 188 /// Returns `true` if the list literal uses [a] and [b] are equivalent.
186 bool areListLiteralUsesEquivalent(ListLiteralUse a, ListLiteralUse b) { 189 bool areListLiteralUsesEquivalent(ListLiteralUse a, ListLiteralUse b,
187 return areTypesEquivalent(a.type, b.type) && 190 {TestStrategy strategy: const TestStrategy()}) {
191 return strategy.testTypes(a, b, 'type', a.type, b.type) &&
188 a.isConstant == b.isConstant && 192 a.isConstant == b.isConstant &&
189 a.isEmpty == b.isEmpty; 193 a.isEmpty == b.isEmpty;
190 } 194 }
191 195
192 /// Returns `true` if the map literal uses [a] and [b] are equivalent. 196 /// Returns `true` if the map literal uses [a] and [b] are equivalent.
193 bool areMapLiteralUsesEquivalent(MapLiteralUse a, MapLiteralUse b) { 197 bool areMapLiteralUsesEquivalent(MapLiteralUse a, MapLiteralUse b,
194 return areTypesEquivalent(a.type, b.type) && 198 {TestStrategy strategy: const TestStrategy()}) {
199 return strategy.testTypes(a, b, 'type', a.type, b.type) &&
195 a.isConstant == b.isConstant && 200 a.isConstant == b.isConstant &&
196 a.isEmpty == b.isEmpty; 201 a.isEmpty == b.isEmpty;
197 } 202 }
198 203
199 /// Returns `true` if the access semantics [a] and [b] are equivalent. 204 /// Returns `true` if the access semantics [a] and [b] are equivalent.
200 bool areAccessSemanticsEquivalent(AccessSemantics a, AccessSemantics b) { 205 bool areAccessSemanticsEquivalent(AccessSemantics a, AccessSemantics b) {
201 if (a.kind != b.kind) return false; 206 if (a.kind != b.kind) return false;
202 switch (a.kind) { 207 switch (a.kind) {
203 case AccessKind.EXPRESSION: 208 case AccessKind.EXPRESSION:
204 case AccessKind.THIS: 209 case AccessKind.THIS:
(...skipping 799 matching lines...) Expand 10 before | Expand all | Expand 10 after
1004 InterceptorConstantValue value1, InterceptorConstantValue value2) { 1009 InterceptorConstantValue value1, InterceptorConstantValue value2) {
1005 ClassElement cls1 = value1.cls; 1010 ClassElement cls1 = value1.cls;
1006 ClassElement cls2 = value2.cls; 1011 ClassElement cls2 = value2.cls;
1007 return strategy.testElements(value1, value2, 'cls', cls1, cls2); 1012 return strategy.testElements(value1, value2, 'cls', cls1, cls2);
1008 } 1013 }
1009 } 1014 }
1010 1015
1011 /// Tests the equivalence of [impact1] and [impact2] using [strategy]. 1016 /// Tests the equivalence of [impact1] and [impact2] using [strategy].
1012 bool testResolutionImpactEquivalence( 1017 bool testResolutionImpactEquivalence(
1013 ResolutionImpact impact1, ResolutionImpact impact2, 1018 ResolutionImpact impact1, ResolutionImpact impact2,
1014 [TestStrategy strategy = const TestStrategy()]) { 1019 {TestStrategy strategy = const TestStrategy()}) {
1015 return strategy.testSets(impact1, impact2, 'constSymbolNames', 1020 return strategy.testSets(impact1, impact2, 'constSymbolNames',
1016 impact1.constSymbolNames, impact2.constSymbolNames) && 1021 impact1.constSymbolNames, impact2.constSymbolNames) &&
1017 strategy.testSets( 1022 strategy.testSets(
1018 impact1, 1023 impact1,
1019 impact2, 1024 impact2,
1020 'constantLiterals', 1025 'constantLiterals',
1021 impact1.constantLiterals, 1026 impact1.constantLiterals,
1022 impact2.constantLiterals, 1027 impact2.constantLiterals,
1023 areConstantsEquivalent) && 1028 areConstantsEquivalent) &&
1024 strategy.testSets(impact1, impact2, 'dynamicUses', impact1.dynamicUses, 1029 strategy.testSets(impact1, impact2, 'dynamicUses', impact1.dynamicUses,
1025 impact2.dynamicUses, areDynamicUsesEquivalent) && 1030 impact2.dynamicUses, areDynamicUsesEquivalent) &&
1026 strategy.testSets( 1031 strategy.testSets(
1027 impact1, impact2, 'features', impact1.features, impact2.features) && 1032 impact1, impact2, 'features', impact1.features, impact2.features) &&
1028 strategy.testSets(impact1, impact2, 'listLiterals', impact1.listLiterals, 1033 strategy.testSets(
1029 impact2.listLiterals, areListLiteralUsesEquivalent) && 1034 impact1,
1030 strategy.testSets(impact1, impact2, 'mapLiterals', impact1.mapLiterals, 1035 impact2,
1031 impact2.mapLiterals, areMapLiteralUsesEquivalent) && 1036 'listLiterals',
1032 strategy.testSets(impact1, impact2, 'staticUses', impact1.staticUses, 1037 impact1.listLiterals,
1033 impact2.staticUses, areStaticUsesEquivalent) && 1038 impact2.listLiterals,
1034 strategy.testSets(impact1, impact2, 'typeUses', impact1.typeUses, 1039 (a, b) => areListLiteralUsesEquivalent(a, b,
1035 impact2.typeUses, areTypeUsesEquivalent) && 1040 strategy: strategy.testOnly)) &&
1041 strategy.testSets(
1042 impact1,
1043 impact2,
1044 'mapLiterals',
1045 impact1.mapLiterals,
1046 impact2.mapLiterals,
1047 (a, b) =>
1048 areMapLiteralUsesEquivalent(a, b, strategy: strategy.testOnly)) &&
1049 strategy.testSets(
1050 impact1,
1051 impact2,
1052 'staticUses',
1053 impact1.staticUses,
1054 impact2.staticUses,
1055 (a, b) =>
1056 areStaticUsesEquivalent(a, b, strategy: strategy.testOnly)) &&
1057 strategy.testSets(
1058 impact1,
1059 impact2,
1060 'typeUses',
1061 impact1.typeUses,
1062 impact2.typeUses,
1063 (a, b) => areTypeUsesEquivalent(a, b, strategy: strategy.testOnly)) &&
1036 strategy.testSets(impact1, impact2, 'nativeData', impact1.nativeData, 1064 strategy.testSets(impact1, impact2, 'nativeData', impact1.nativeData,
1037 impact2.nativeData, testNativeBehavior); 1065 impact2.nativeData, testNativeBehavior);
1038 } 1066 }
1039 1067
1040 /// Tests the equivalence of [resolvedAst1] and [resolvedAst2] using [strategy]. 1068 /// Tests the equivalence of [resolvedAst1] and [resolvedAst2] using [strategy].
1041 bool testResolvedAstEquivalence( 1069 bool testResolvedAstEquivalence(
1042 ResolvedAst resolvedAst1, ResolvedAst resolvedAst2, 1070 ResolvedAst resolvedAst1, ResolvedAst resolvedAst2,
1043 [TestStrategy strategy = const TestStrategy()]) { 1071 [TestStrategy strategy = const TestStrategy()]) {
1044 if (!strategy.test(resolvedAst1, resolvedAst1, 'kind', resolvedAst1.kind, 1072 if (!strategy.test(resolvedAst1, resolvedAst1, 'kind', resolvedAst1.kind,
1045 resolvedAst2.kind)) { 1073 resolvedAst2.kind)) {
(...skipping 1029 matching lines...) Expand 10 before | Expand all | Expand 10 after
2075 } 2103 }
2076 2104
2077 bool areMetadataAnnotationsEquivalent( 2105 bool areMetadataAnnotationsEquivalent(
2078 MetadataAnnotation metadata1, MetadataAnnotation metadata2) { 2106 MetadataAnnotation metadata1, MetadataAnnotation metadata2) {
2079 if (metadata1 == metadata2) return true; 2107 if (metadata1 == metadata2) return true;
2080 if (metadata1 == null || metadata2 == null) return false; 2108 if (metadata1 == null || metadata2 == null) return false;
2081 return areElementsEquivalent( 2109 return areElementsEquivalent(
2082 metadata1.annotatedElement, metadata2.annotatedElement) && 2110 metadata1.annotatedElement, metadata2.annotatedElement) &&
2083 areConstantsEquivalent(metadata1.constant, metadata2.constant); 2111 areConstantsEquivalent(metadata1.constant, metadata2.constant);
2084 } 2112 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/kernel/world_builder.dart ('k') | tests/compiler/dart2js/kernel/impact_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698