Index: src/types.cc |
diff --git a/src/types.cc b/src/types.cc |
index f6a430bbc962934128d089fb1af6baa2d1a51ab6..5a885826cf27fac0a90c85706d9e3af137504124 100644 |
--- a/src/types.cc |
+++ b/src/types.cc |
@@ -306,28 +306,23 @@ bool TypeImpl<Config>::SlowIs(TypeImpl* that) { |
template<class Config> |
bool TypeImpl<Config>::NowIs(TypeImpl* that) { |
- if (this->Is(that)) return true; |
- if (this->IsConstant() && this->AsConstant()->IsHeapObject()) { |
- i::Handle<i::Map> map(i::HeapObject::cast(*this->AsConstant())->map()); |
- for (Iterator<i::Map> it = that->Classes(); !it.Done(); it.Advance()) { |
- if (*it.Current() == *map) return true; |
+ if (this->IsConstant()) { |
+ DisallowHeapAllocation no_allocation; |
+ i::Object* object = *this->AsConstant(); |
+ if (object->IsHeapObject()) { |
+ i::Map* map = i::HeapObject::cast(object)->map(); |
+ for (Iterator<i::Map> it = that->Classes(); !it.Done(); it.Advance()) { |
+ if (*it.Current() == map) return true; |
+ } |
} |
} |
- return false; |
+ return this->Is(that); |
} |
// Check this overlaps that. |
template<class Config> |
bool TypeImpl<Config>::Maybe(TypeImpl* that) { |
- // Fast path for bitsets. |
- if (this->IsBitset()) { |
- return IsInhabited(this->AsBitset() & that->LubBitset()); |
- } |
- if (that->IsBitset()) { |
- return IsInhabited(this->LubBitset() & that->AsBitset()); |
- } |
- |
// (T1 \/ ... \/ Tn) overlaps T <=> (T1 overlaps T) \/ ... \/ (Tn overlaps T) |
if (this->IsUnion()) { |
StructHandle unioned = this->AsUnion(); |
@@ -349,6 +344,13 @@ bool TypeImpl<Config>::Maybe(TypeImpl* that) { |
} |
ASSERT(!this->IsUnion() && !that->IsUnion()); |
+ if (this->IsBitset()) { |
+ return IsInhabited(this->AsBitset() & that->LubBitset()); |
+ } |
+ if (that->IsBitset()) { |
+ return IsInhabited(this->LubBitset() & that->AsBitset()); |
+ } |
+ |
if (this->IsClass()) { |
return that->IsClass() && *this->AsClass() == *that->AsClass(); |
} |
@@ -371,9 +373,14 @@ bool TypeImpl<Config>::Contains(i::Object* value) { |
template<class Config> |
bool TypeImpl<Config>::NowContains(i::Object* value) { |
- return this->Contains(value) || |
- (this->IsClass() && value->IsHeapObject() && |
- *this->AsClass() == i::HeapObject::cast(value)->map()); |
+ if (value->IsHeapObject()) { |
+ DisallowHeapAllocation no_allocation; |
+ i::Map* map = i::HeapObject::cast(value)->map(); |
+ for (Iterator<i::Map> it = this->Classes(); !it.Done(); it.Advance()) { |
+ if (*it.Current() == map) return true; |
+ } |
+ } |
+ return this->Contains(value); |
} |