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

Side by Side Diff: pkg/compiler/lib/src/types/union_type_mask.dart

Issue 2314703002: Split World usage into open, inference, and closed world. (Closed)
Patch Set: Updated cf. comments Created 4 years, 2 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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 part of masks; 5 part of masks;
6 6
7 class UnionTypeMask implements TypeMask { 7 class UnionTypeMask implements TypeMask {
8 final Iterable<FlatTypeMask> disjointMasks; 8 final Iterable<FlatTypeMask> disjointMasks;
9 9
10 static const int MAX_UNION_LENGTH = 4; 10 static const int MAX_UNION_LENGTH = 4;
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 * - [other] may not be a [UnionTypeMask] itself 211 * - [other] may not be a [UnionTypeMask] itself
212 * - the cheap test matching against individual members of [disjointMasks] 212 * - the cheap test matching against individual members of [disjointMasks]
213 * must have failed. 213 * must have failed.
214 */ 214 */
215 bool slowContainsCheck(TypeMask other, ClassWorld classWorld) { 215 bool slowContainsCheck(TypeMask other, ClassWorld classWorld) {
216 // Unions should never make it here. 216 // Unions should never make it here.
217 assert(!other.isUnion); 217 assert(!other.isUnion);
218 // Ensure the cheap test fails. 218 // Ensure the cheap test fails.
219 assert(!disjointMasks.any((mask) => mask.containsMask(other, classWorld))); 219 assert(!disjointMasks.any((mask) => mask.containsMask(other, classWorld)));
220 // If we cover object, we should never get here. 220 // If we cover object, we should never get here.
221 assert(!contains(classWorld.objectClass, classWorld)); 221 assert(!contains(classWorld.coreClasses.objectClass, classWorld));
222 // Likewise, nullness should be covered. 222 // Likewise, nullness should be covered.
223 assert(isNullable || !other.isNullable); 223 assert(isNullable || !other.isNullable);
224 // The fast test is precise for exact types. 224 // The fast test is precise for exact types.
225 if (other.isExact) return false; 225 if (other.isExact) return false;
226 // We cannot contain object. 226 // We cannot contain object.
227 if (other.contains(classWorld.objectClass, classWorld)) return false; 227 if (other.contains(classWorld.coreClasses.objectClass, classWorld)) {
228 return false;
229 }
228 FlatTypeMask flat = TypeMask.nonForwardingMask(other); 230 FlatTypeMask flat = TypeMask.nonForwardingMask(other);
229 // Check we cover the base class. 231 // Check we cover the base class.
230 if (!contains(flat.base, classWorld)) return false; 232 if (!contains(flat.base, classWorld)) return false;
231 // Check for other members. 233 // Check for other members.
232 Iterable<ClassElement> members; 234 Iterable<ClassElement> members;
233 if (flat.isSubclass) { 235 if (flat.isSubclass) {
234 members = classWorld.strictSubclassesOf(flat.base); 236 members = classWorld.strictSubclassesOf(flat.base);
235 } else { 237 } else {
236 assert(flat.isSubtype); 238 assert(flat.isSubtype);
237 members = classWorld.strictSubtypesOf(flat.base); 239 members = classWorld.strictSubtypesOf(flat.base);
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 int get hashCode { 374 int get hashCode {
373 int hashCode = isNullable ? 86 : 43; 375 int hashCode = isNullable ? 86 : 43;
374 // The order of the masks in [disjointMasks] must not affect the 376 // The order of the masks in [disjointMasks] must not affect the
375 // hashCode. 377 // hashCode.
376 for (var mask in disjointMasks) { 378 for (var mask in disjointMasks) {
377 hashCode = (hashCode ^ mask.nonNullable().hashCode) & 0x3fffffff; 379 hashCode = (hashCode ^ mask.nonNullable().hashCode) & 0x3fffffff;
378 } 380 }
379 return hashCode; 381 return hashCode;
380 } 382 }
381 } 383 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/types/type_mask.dart ('k') | pkg/compiler/lib/src/universe/function_set.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698