Reviewers: Benedikt Meurer,

Message:
So what would you think about this change?

Description:
[turbofan] Normalize union of representation and range to a range.

BUG=
[email protected]

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

Base URL: https://chromium.googlesource.com/v8/v8.git@master

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


Index: src/types.cc
diff --git a/src/types.cc b/src/types.cc
index 37386cd82f6012e1ccf05caabb6e19fcd4b6664c..f1cf6204a2beacae34bdebf190c01bd7ca41264c 100644
--- a/src/types.cc
+++ b/src/types.cc
@@ -777,7 +777,7 @@ typename TypeImpl<Config>::TypeHandle TypeImpl<Config>::Intersect(
     bits &= ~number_bits;
     result->Set(0, BitsetType::New(bits, region));
   }
-  return NormalizeUnion(result, size);
+  return NormalizeUnion(result, size, region);
 }


@@ -992,7 +992,7 @@ typename TypeImpl<Config>::TypeHandle TypeImpl<Config>::Union(

   size = AddToUnion(type1, result, size, region);
   size = AddToUnion(type2, result, size, region);
-  return NormalizeUnion(result, size);
+  return NormalizeUnion(result, size, region);
 }


@@ -1016,9 +1016,9 @@ int TypeImpl<Config>::AddToUnion(
 }


-template<class Config>
+template <class Config>
 typename TypeImpl<Config>::TypeHandle TypeImpl<Config>::NormalizeUnion(
-    UnionHandle unioned, int size) {
+    UnionHandle unioned, int size, Region* region) {
   DCHECK(size >= 1);
   DCHECK(unioned->Get(0)->IsBitset());
   // If the union has just one element, return it.
@@ -1032,8 +1032,11 @@ typename TypeImpl<Config>::TypeHandle TypeImpl<Config>::NormalizeUnion(
     if (representation == unioned->Get(1)->Representation()) {
       return unioned->Get(1);
     }
-    // TODO(jarin) If the element at 1 is range of constant, slap
-    // the representation on it and return that.
+    if (unioned->Get(1)->IsRange()) {
+      return RangeType::New(unioned->Get(1)->AsRange()->Min(),
+ unioned->Get(1)->AsRange()->Max(), unioned->Get(0),
+                            region);
+    }
   }
   unioned->Shrink(size);
   SLOW_DCHECK(unioned->Wellformed());
Index: src/types.h
diff --git a/src/types.h b/src/types.h
index 0aae0641710431626ebc991fc3ebb94609248e4c..1756229f978bb917bbe2375a4f7650c2cb74e880 100644
--- a/src/types.h
+++ b/src/types.h
@@ -615,7 +615,8 @@ class TypeImpl : public Config::Base {
       TypeHandle type, UnionHandle result, int size, Region* region);
static int IntersectAux(TypeHandle type, TypeHandle other, UnionHandle result,
                           int size, Limits* limits, Region* region);
-  static TypeHandle NormalizeUnion(UnionHandle unioned, int size);
+  static TypeHandle NormalizeUnion(UnionHandle unioned, int size,
+                                   Region* region);
static TypeHandle NormalizeRangeAndBitset(RangeHandle range, bitset* bits,
                                             Region* region);
 };


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