Index: src/types.cc |
diff --git a/src/types.cc b/src/types.cc |
index 4526b6fe4470866c27a5fb6c3a208c301f3b4c7c..4ddc14bb32f3410812f6d533477fb3fb462bb790 100644 |
--- a/src/types.cc |
+++ b/src/types.cc |
@@ -306,6 +306,9 @@ bool TypeImpl<Config>::SlowIs(TypeImpl* that) { |
template<class Config> |
bool TypeImpl<Config>::NowIs(TypeImpl* that) { |
+ // TODO(rossberg): this is incorrect for |
+ // Union(Constant(V), T)->NowIs(Class(M)) |
+ // but fuzzing does not cover that! |
DisallowHeapAllocation no_allocation; |
if (this->IsConstant()) { |
i::Object* object = *this->AsConstant(); |
@@ -435,12 +438,12 @@ typename TypeImpl<Config>::TypeHandle TypeImpl<Config>::Union( |
size += (type2->IsUnion() ? Config::struct_length(type2->AsUnion()) : 1); |
} |
int bitset = type1->GlbBitset() | type2->GlbBitset(); |
- if (IsInhabited(bitset)) ++size; |
+ if (bitset != kNone) ++size; |
ASSERT(size >= 1); |
StructHandle unioned = Config::struct_create(kUnionTag, size, region); |
size = 0; |
- if (IsInhabited(bitset)) { |
+ if (bitset != kNone) { |
Config::struct_set(unioned, size++, Config::from_bitset(bitset, region)); |
} |
size = ExtendUnion(unioned, type1, size); |
@@ -502,21 +505,20 @@ typename TypeImpl<Config>::TypeHandle TypeImpl<Config>::Intersect( |
} |
// Slow case: may need to produce a Unioned object. |
- int size = INT_MAX; |
+ int size = 0; |
if (!type1->IsBitset()) { |
- size = (type1->IsUnion() ? Config::struct_length(type1->AsUnion()) : 1); |
+ size += (type1->IsUnion() ? Config::struct_length(type1->AsUnion()) : 1); |
} |
if (!type2->IsBitset()) { |
- size = Min(size, |
- type2->IsUnion() ? Config::struct_length(type2->AsUnion()) : 1); |
+ size += (type2->IsUnion() ? Config::struct_length(type2->AsUnion()) : 1); |
} |
int bitset = type1->GlbBitset() & type2->GlbBitset(); |
- if (IsInhabited(bitset)) ++size; |
+ if (bitset != kNone) ++size; |
ASSERT(size >= 1); |
StructHandle unioned = Config::struct_create(kUnionTag, size, region); |
size = 0; |
- if (IsInhabited(bitset)) { |
+ if (bitset != kNone) { |
Config::struct_set(unioned, size++, Config::from_bitset(bitset, region)); |
} |
size = ExtendIntersection(unioned, type1, type2, size); |