Reviewers: Jakob,

Description:
Collective fixes to types

[email protected]
BUG=

Please review this at https://codereview.chromium.org/247273002/

SVN Base: https://v8.googlecode.com/svn/branches/3.25

Affected files (+16, -19 lines):
  M src/types.h
  M src/types.cc


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, "(");
Index: src/types.h
diff --git a/src/types.h b/src/types.h
index 4569d131b157eb9bc7dce1ee8a01278d51c54e91..9040448963d434245a6e22a971f8abf301fdd9f2 100644
--- a/src/types.h
+++ b/src/types.h
@@ -181,7 +181,7 @@ namespace internal {
   V(Object,              kDetectableObject | kUndetectable)             \
   V(Receiver,            kObject | kProxy)                              \
   V(NonNumber,           kOddball | kName | kReceiver | kInternal)      \
-  V(Any,                 kNumber | kNonNumber)
+  V(Any,                 -1)

 #define BITSET_TYPE_LIST(V) \
   MASK_BITSET_TYPE_LIST(V) \


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to