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

Unified Diff: test/cctest/test-types.cc

Issue 712623002: [turbofan] Weakening of types must handle ranges inside unions. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Added test Created 6 years, 1 month 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.cc ('k') | test/mjsunit/regress/regress-weakening-multiplication.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-types.cc
diff --git a/test/cctest/test-types.cc b/test/cctest/test-types.cc
index e564c6c0808ab20f29d0fde37b12380d55343dcf..ad4660735928e384b7b986d9d5f8c2f5d8e3e2f9 100644
--- a/test/cctest/test-types.cc
+++ b/test/cctest/test-types.cc
@@ -1831,6 +1831,48 @@ struct Tests : Rep {
*/
}
+ TypeHandle RangeToHandle(typename Type::RangeType* range) {
rossberg 2014/11/12 14:51:15 That seems a bit hacky. Can we instead have a prop
+ return T.Range(range->Min(), range->Max());
+ }
+
+ void GetRange() {
+ // GetRange(Range(a, b)) = Range(a, b).
+ for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) {
+ TypeHandle type1 = *it1;
+ if (type1->IsRange()) {
+ typename Type::RangeType* range = type1->GetRange();
+ CHECK(type1->Equals(RangeToHandle(range)));
+ }
+ }
+
+ // GetRange(Union(Constant(x), Range(min,max))) == Range(min, max).
+ for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) {
+ for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) {
+ TypeHandle type1 = *it1;
+ TypeHandle type2 = *it2;
+ if (type1->IsConstant() && type2->IsRange()) {
+ TypeHandle u = T.Union(type1, type2);
+
+ CHECK(type2->Equals(RangeToHandle(u->GetRange())));
+ }
+ }
+ }
+
+ // GetRange is monotone whenever it is defined.
+ for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) {
+ for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) {
+ TypeHandle type1 = *it1;
+ TypeHandle type2 = *it2;
+ if (type1->GetRange() != NULL && type2->GetRange() != NULL &&
+ type1->Is(type2)) {
+ TypeHandle r1 = RangeToHandle(type1->GetRange());
+ TypeHandle r2 = RangeToHandle(type2->GetRange());
+ CHECK(r1->Is(r2));
+ }
+ }
+ }
+ }
+
template<class Type2, class TypeHandle2, class Region2, class Rep2>
void Convert() {
Types<Type2, TypeHandle2, Region2> T2(
@@ -2030,6 +2072,13 @@ TEST(Distributivity) {
}
+TEST(GetRange) {
+ CcTest::InitializeVM();
+ ZoneTests().GetRange();
+ HeapTests().GetRange();
+}
+
+
TEST(Convert) {
CcTest::InitializeVM();
ZoneTests().Convert<HeapType, Handle<HeapType>, Isolate, HeapRep>();
« no previous file with comments | « src/types.cc ('k') | test/mjsunit/regress/regress-weakening-multiplication.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698