Commit 4620ae5c authored by bmeurer@chromium.org's avatar bmeurer@chromium.org

Fix symmetry of Maybe() predicate. Fix bug in NowContains() predicate.

Add tests for TypeImpl::Of(), TypeImpl::NowOf() and
TypeImpl::NowContains(). Improves the implementation of
TypeImpl::NowIs() to match that of TypeImpl::NowContains().

Mark test-types with NO_VARIANTS to speedup testing, since
the variants do not affect the type system at all.

Also improve test coverage for types.

TEST=cctest/test-types
R=rossberg@chromium.org

Review URL: https://codereview.chromium.org/230673002

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@20639 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 0387b235
...@@ -306,28 +306,23 @@ bool TypeImpl<Config>::SlowIs(TypeImpl* that) { ...@@ -306,28 +306,23 @@ bool TypeImpl<Config>::SlowIs(TypeImpl* that) {
template<class Config> template<class Config>
bool TypeImpl<Config>::NowIs(TypeImpl* that) { bool TypeImpl<Config>::NowIs(TypeImpl* that) {
if (this->Is(that)) return true; if (this->IsConstant()) {
if (this->IsConstant() && this->AsConstant()->IsHeapObject()) { DisallowHeapAllocation no_allocation;
i::Handle<i::Map> map(i::HeapObject::cast(*this->AsConstant())->map()); i::Object* object = *this->AsConstant();
for (Iterator<i::Map> it = that->Classes(); !it.Done(); it.Advance()) { if (object->IsHeapObject()) {
if (*it.Current() == *map) return true; 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. // Check this overlaps that.
template<class Config> template<class Config>
bool TypeImpl<Config>::Maybe(TypeImpl* that) { 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) // (T1 \/ ... \/ Tn) overlaps T <=> (T1 overlaps T) \/ ... \/ (Tn overlaps T)
if (this->IsUnion()) { if (this->IsUnion()) {
StructHandle unioned = this->AsUnion(); StructHandle unioned = this->AsUnion();
...@@ -349,6 +344,13 @@ bool TypeImpl<Config>::Maybe(TypeImpl* that) { ...@@ -349,6 +344,13 @@ bool TypeImpl<Config>::Maybe(TypeImpl* that) {
} }
ASSERT(!this->IsUnion() && !that->IsUnion()); 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()) { if (this->IsClass()) {
return that->IsClass() && *this->AsClass() == *that->AsClass(); return that->IsClass() && *this->AsClass() == *that->AsClass();
} }
...@@ -371,9 +373,14 @@ bool TypeImpl<Config>::Contains(i::Object* value) { ...@@ -371,9 +373,14 @@ bool TypeImpl<Config>::Contains(i::Object* value) {
template<class Config> template<class Config>
bool TypeImpl<Config>::NowContains(i::Object* value) { bool TypeImpl<Config>::NowContains(i::Object* value) {
return this->Contains(value) || if (value->IsHeapObject()) {
(this->IsClass() && value->IsHeapObject() && DisallowHeapAllocation no_allocation;
*this->AsClass() == i::HeapObject::cast(value)->map()); 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);
} }
......
...@@ -65,6 +65,10 @@ ...@@ -65,6 +65,10 @@
# are actually 13 * 38 * 5 * 128 = 316160 individual tests hidden here. # are actually 13 * 38 * 5 * 128 = 316160 individual tests hidden here.
'test-parsing/ParserSync': [PASS, NO_VARIANTS], 'test-parsing/ParserSync': [PASS, NO_VARIANTS],
# This tests only the type system, so there is no point in running several
# variants.
'test-types/*': [PASS, NO_VARIANTS],
# BUG(2999). # BUG(2999).
'test-cpu-profiler/CollectCpuProfile': [PASS, FLAKY], 'test-cpu-profiler/CollectCpuProfile': [PASS, FLAKY],
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment