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

Unified Diff: src/types.cc

Issue 247273002: Collective fixes to types (Closed) Base URL: https://v8.googlecode.com/svn/branches/3.25
Patch Set: Back-merged tests Created 6 years, 8 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 | « src/types.h ('k') | test/cctest/test-types.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/types.cc
diff --git a/src/types.cc b/src/types.cc
index 98bb280b6a0cd364e6a33ffb0aef77a6aade37ba..46babd393f17898bea2814c044afaa8061ed825f 100644
--- a/src/types.cc
+++ b/src/types.cc
@@ -337,14 +337,6 @@ bool TypeImpl<Config>::IsCurrently(TypeImpl* 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()) {
UnionedHandle unioned = this->AsUnion();
@@ -366,6 +358,12 @@ 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();
}
@@ -442,12 +440,12 @@ typename TypeImpl<Config>::TypeHandle TypeImpl<Config>::Union(
size += (type2->IsUnion() ? Config::union_length(type2->AsUnion()) : 1);
}
int bitset = type1->GlbBitset() | type2->GlbBitset();
- if (IsInhabited(bitset)) ++size;
+ if (bitset != kNone) ++size;
ASSERT(size >= 1);
UnionedHandle unioned = Config::union_create(size, region);
size = 0;
- if (IsInhabited(bitset)) {
+ if (bitset != kNone) {
Config::union_set(unioned, size++, Config::from_bitset(bitset, region));
}
size = ExtendUnion(unioned, type1, size);
@@ -509,21 +507,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::union_length(type1->AsUnion()) : 1);
+ size += (type1->IsUnion() ? Config::union_length(type1->AsUnion()) : 1);
}
if (!type2->IsBitset()) {
- size = Min(size,
- type2->IsUnion() ? Config::union_length(type2->AsUnion()) : 1);
+ size += (type2->IsUnion() ? Config::union_length(type2->AsUnion()) : 1);
}
int bitset = type1->GlbBitset() & type2->GlbBitset();
- if (IsInhabited(bitset)) ++size;
+ if (bitset != kNone) ++size;
ASSERT(size >= 1);
UnionedHandle unioned = Config::union_create(size, region);
size = 0;
- if (IsInhabited(bitset)) {
+ if (bitset != kNone) {
Config::union_set(unioned, size++, Config::from_bitset(bitset, region));
}
size = ExtendIntersection(unioned, type1, type2, size);
@@ -655,11 +652,11 @@ void TypeImpl<Config>::TypePrint(FILE* out, PrintDimension dim) {
}
} else if (this->IsConstant()) {
PrintF(out, "Constant(%p : ", static_cast<void*>(*this->AsConstant()));
- Config::from_bitset(this->LubBitset())->TypePrint(out);
+ Config::from_bitset(this->LubBitset())->TypePrint(out, dim);
PrintF(out, ")");
} else if (this->IsClass()) {
PrintF(out, "Class(%p < ", static_cast<void*>(*this->AsClass()));
- Config::from_bitset(this->LubBitset())->TypePrint(out);
+ Config::from_bitset(this->LubBitset())->TypePrint(out, dim);
PrintF(out, ")");
} else if (this->IsUnion()) {
PrintF(out, "(");
« no previous file with comments | « src/types.h ('k') | test/cctest/test-types.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698