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

Unified Diff: pkg/compiler/lib/src/types/union_type_mask.dart

Issue 1037223002: Move set-membership based containment test behind a flag. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/compiler/lib/src/types/type_mask.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/types/union_type_mask.dart
diff --git a/pkg/compiler/lib/src/types/union_type_mask.dart b/pkg/compiler/lib/src/types/union_type_mask.dart
index 0ad1cc67095241a9ac67ed5849be6389ab535ed6..3b0f139e5ac04d353b9037e6bcc1ae621648ca24 100644
--- a/pkg/compiler/lib/src/types/union_type_mask.dart
+++ b/pkg/compiler/lib/src/types/union_type_mask.dart
@@ -9,6 +9,11 @@ class UnionTypeMask implements TypeMask {
static const int MAX_UNION_LENGTH = 4;
+ // Set this flag to `true` to perform a set-membership based containment check
+ // instead of relying on normalized types. This is quite slow but can be
+ // helpful in debugging.
+ static const bool PERFORM_EXTRA_CONTAINS_CHECK = false;
+
UnionTypeMask._internal(this.disjointMasks) {
assert(disjointMasks.length > 1);
assert(disjointMasks.every((TypeMask mask) => !mask.isUnion));
@@ -231,7 +236,11 @@ class UnionTypeMask implements TypeMask {
}
return disjointMasks.every((FlatTypeMask disjointMask) {
bool contained = containedInAnyOf(disjointMask, union.disjointMasks);
- assert(contained || !union.slowContainsCheck(disjointMask, classWorld));
+ if (PERFORM_EXTRA_CONTAINS_CHECK &&
+ !contained &&
+ union.slowContainsCheck(disjointMask, classWorld)) {
+ throw "TypeMask based containment check failed for $this and $other.";
+ }
return contained;
});
}
@@ -245,7 +254,11 @@ class UnionTypeMask implements TypeMask {
other = other.nonNullable(); // nullable is not canonicalized, so drop it.
bool contained =
disjointMasks.any((mask) => mask.containsMask(other, classWorld));
- assert(contained || !slowContainsCheck(other, classWorld));
+ if (PERFORM_EXTRA_CONTAINS_CHECK &&
+ !contained &&
+ slowContainsCheck(other, classWorld)) {
+ throw "TypeMask based containment check failed for $this and $other.";
+ }
return contained;
}
« no previous file with comments | « pkg/compiler/lib/src/types/type_mask.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698