Reviewers: rossberg,

Description:
Remove non-trivial subtyping between bitset and non-bitset types.

(Also add debugging output to some Types tests.)

[email protected]
BUG=

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

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

Affected files (+15, -40 lines):
  M src/types.cc
  M test/cctest/test-types.cc


Index: src/types.cc
diff --git a/src/types.cc b/src/types.cc
index c4e32f7823e6a15ac684a163c864b5de929bcc25..0925fd5da232ff67e96dbbeb136270df1a96aaf4 100644
--- a/src/types.cc
+++ b/src/types.cc
@@ -26,21 +26,7 @@ int TypeImpl<Config>::BitsetType::Glb(TypeImpl* type) {
       bitset |= unioned->Get(i)->BitsetGlb();
     }
     return bitset;
-  } else if (type->IsClass()) {
- // Little hack to avoid the need for a region for handlification here...
-    return REPRESENTATION(Config::is_class(type)
-        ? Lub(*Config::as_class(type))
-        : type->AsClass()->Bound(NULL)->AsBitset());
-  } else if (type->IsConstant()) {
-    return REPRESENTATION(type->AsConstant()->Bound()->AsBitset());
-  } else if (type->IsContext()) {
-    return REPRESENTATION(type->AsContext()->Bound()->AsBitset());
-  } else if (type->IsArray()) {
-    return REPRESENTATION(type->AsArray()->Bound()->AsBitset());
-  } else if (type->IsFunction()) {
-    return REPRESENTATION(type->AsFunction()->Bound()->AsBitset());
   } else {
-    UNREACHABLE();
     return kNone;
   }
 }
@@ -260,10 +246,6 @@ bool TypeImpl<Config>::SlowIs(TypeImpl* that) {
   if (that->IsBitset()) {
     return BitsetType::Is(BitsetType::Lub(this), that->AsBitset());
   }
- if (this->IsBitset() && SEMANTIC(this->AsBitset()) == BitsetType::kNone) { - // Bitsets only have non-bitset supertypes along the representation axis.
-    return BitsetType::Is(this->AsBitset(), that->BitsetGlb());
-  }

   if (that->IsClass()) {
     return this->IsClass()
@@ -555,26 +537,6 @@ int TypeImpl<Config>::ExtendUnion(
 }


-// If bitset is subsumed by another entry in the result, remove it.
-// (Only bitsets with empty semantic axis can be subtypes of non-bitsets.)
-template<class Config>
-int TypeImpl<Config>::NormalizeUnion(UnionHandle result, int size, int bitset) { - if (bitset != BitsetType::kNone && SEMANTIC(bitset) == BitsetType::kNone) {
-    for (int i = 1; i < size; ++i) {
-      int glb = result->Get(i)->BitsetGlb();
-      if (BitsetType::Is(bitset, glb)) {
-        for (int j = 1; j < size; ++j) {
-          result->Set(j - 1, result->Get(j));
-        }
-        --size;
-        break;
-      }
-    }
-  }
-  return size;
-}
-
-
 // Union is O(1) on simple bitsets, but O(n*m) on structured unions.
 template<class Config>
 typename TypeImpl<Config>::TypeHandle TypeImpl<Config>::Union(
@@ -613,7 +575,6 @@ typename TypeImpl<Config>::TypeHandle TypeImpl<Config>::Union(
   }
   size = ExtendUnion(unioned, size, type1, type2, false, region);
   size = ExtendUnion(unioned, size, type2, type1, false, region);
-  size = NormalizeUnion(unioned, size, bitset);

   if (size == 1) {
     return unioned->Get(0);
@@ -663,7 +624,6 @@ typename TypeImpl<Config>::TypeHandle TypeImpl<Config>::Intersect(
   }
   size = ExtendUnion(unioned, size, type1, type2, true, region);
   size = ExtendUnion(unioned, size, type2, type1, true, region);
-  size = NormalizeUnion(unioned, size, bitset);

   if (size == 0) {
     return None(region);
Index: test/cctest/test-types.cc
diff --git a/test/cctest/test-types.cc b/test/cctest/test-types.cc
index 753457366701c26be2af0c798663fac2e7a092aa..c0b9af6fef672a1a24898668c0db8af7a18433cb 100644
--- a/test/cctest/test-types.cc
+++ b/test/cctest/test-types.cc
@@ -6,6 +6,7 @@

 #include "src/hydrogen-types.h"
 #include "src/isolate-inl.h"
+#include "src/ostreams.h"
 #include "src/types.h"
 #include "test/cctest/cctest.h"

@@ -1319,6 +1320,13 @@ struct Tests : Rep {
         TypeHandle type2 = *it2;
         TypeHandle union12 = T.Union(type1, type2);
         TypeHandle union21 = T.Union(type2, type1);
+        OFStream os(stdout);
+        type1->PrintTo(os);
+        os << " \\/ ";
+        type2->PrintTo(os);
+        os << " = ";
+        union12->PrintTo(os);
+        os << "\n";
         CheckEqual(union12, union21);
       }
     }
@@ -1547,6 +1555,13 @@ struct Tests : Rep {
         TypeHandle type2 = *it2;
         TypeHandle intersect12 = T.Intersect(type1, type2);
         TypeHandle intersect21 = T.Intersect(type2, type1);
+        OFStream os(stdout);
+        type1->PrintTo(os);
+        os << " /\\ ";
+        type2->PrintTo(os);
+        os << " = ";
+        intersect12->PrintTo(os);
+        os << "\n";
         CheckEqual(intersect12, intersect21);
       }
     }


--
--
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