Re-reland "More tests for Union & Intersect"

R=jarin@chromium.org
BUG=

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@20733 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
rossberg@chromium.org 2014-04-14 15:35:36 +00:00
parent d42146c8b8
commit 7b7f787e3b
3 changed files with 564 additions and 386 deletions

View File

@ -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);

View File

@ -101,11 +101,11 @@ namespace internal {
// PROPERTIES
//
// Various formal properties hold for constructors, operators, and predicates
// over types. For example, constructors are injective, subtyping is a partial
// order, and union and intersection satisfy the usual algebraic properties.
// over types. For example, constructors are injective, subtyping is a complete
// partial order, union and intersection satisfy the usual algebraic properties.
//
// See test/cctest/test-types.cc for a comprehensive executable specification,
// especially with respect to the proeprties of the more exotic 'temporal'
// especially with respect to the properties of the more exotic 'temporal'
// constructors and predicates (those prefixed 'Now').
//
// IMPLEMENTATION

File diff suppressed because it is too large Load Diff