OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <vector> | 5 #include <vector> |
6 | 6 |
7 #include "src/hydrogen-types.h" | 7 #include "src/hydrogen-types.h" |
8 #include "src/isolate-inl.h" | 8 #include "src/isolate-inl.h" |
9 #include "src/types.h" | 9 #include "src/types.h" |
10 #include "test/cctest/cctest.h" | 10 #include "test/cctest/cctest.h" |
(...skipping 1813 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1824 TypeHandle union23 = T.Union(type2, type3); | 1824 TypeHandle union23 = T.Union(type2, type3); |
1825 TypeHandle intersect1_23 = T.Intersect(type1, union23); | 1825 TypeHandle intersect1_23 = T.Intersect(type1, union23); |
1826 TypeHandle union12_13 = T.Union(intersect12, intersect13); | 1826 TypeHandle union12_13 = T.Union(intersect12, intersect13); |
1827 CHECK(Equal(intersect1_23, union12_13)); | 1827 CHECK(Equal(intersect1_23, union12_13)); |
1828 } | 1828 } |
1829 } | 1829 } |
1830 } | 1830 } |
1831 */ | 1831 */ |
1832 } | 1832 } |
1833 | 1833 |
| 1834 void GetRange() { |
| 1835 // GetRange(Range(a, b)) = Range(a, b). |
| 1836 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { |
| 1837 TypeHandle type1 = *it1; |
| 1838 if (type1->IsRange()) { |
| 1839 typename Type::RangeType* range = type1->GetRange(); |
| 1840 CHECK(type1->Min() == range->Min()->Number()); |
| 1841 CHECK(type1->Max() == range->Max()->Number()); |
| 1842 } |
| 1843 } |
| 1844 |
| 1845 // GetRange(Union(Constant(x), Range(min,max))) == Range(min, max). |
| 1846 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { |
| 1847 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { |
| 1848 TypeHandle type1 = *it1; |
| 1849 TypeHandle type2 = *it2; |
| 1850 if (type1->IsConstant() && type2->IsRange()) { |
| 1851 TypeHandle u = T.Union(type1, type2); |
| 1852 |
| 1853 CHECK(type2->Min() == u->GetRange()->Min()->Number()); |
| 1854 CHECK(type2->Max() == u->GetRange()->Max()->Number()); |
| 1855 } |
| 1856 } |
| 1857 } |
| 1858 } |
| 1859 |
1834 template<class Type2, class TypeHandle2, class Region2, class Rep2> | 1860 template<class Type2, class TypeHandle2, class Region2, class Rep2> |
1835 void Convert() { | 1861 void Convert() { |
1836 Types<Type2, TypeHandle2, Region2> T2( | 1862 Types<Type2, TypeHandle2, Region2> T2( |
1837 Rep2::ToRegion(&zone, isolate), isolate); | 1863 Rep2::ToRegion(&zone, isolate), isolate); |
1838 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { | 1864 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { |
1839 TypeHandle type1 = *it; | 1865 TypeHandle type1 = *it; |
1840 TypeHandle2 type2 = T2.template Convert<Type>(type1); | 1866 TypeHandle2 type2 = T2.template Convert<Type>(type1); |
1841 TypeHandle type3 = T.template Convert<Type2>(type2); | 1867 TypeHandle type3 = T.template Convert<Type2>(type2); |
1842 CheckEqual(type1, type3); | 1868 CheckEqual(type1, type3); |
1843 } | 1869 } |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2023 } | 2049 } |
2024 | 2050 |
2025 | 2051 |
2026 TEST(Distributivity) { | 2052 TEST(Distributivity) { |
2027 CcTest::InitializeVM(); | 2053 CcTest::InitializeVM(); |
2028 ZoneTests().Distributivity(); | 2054 ZoneTests().Distributivity(); |
2029 HeapTests().Distributivity(); | 2055 HeapTests().Distributivity(); |
2030 } | 2056 } |
2031 | 2057 |
2032 | 2058 |
| 2059 TEST(GetRange) { |
| 2060 CcTest::InitializeVM(); |
| 2061 ZoneTests().GetRange(); |
| 2062 HeapTests().GetRange(); |
| 2063 } |
| 2064 |
| 2065 |
2033 TEST(Convert) { | 2066 TEST(Convert) { |
2034 CcTest::InitializeVM(); | 2067 CcTest::InitializeVM(); |
2035 ZoneTests().Convert<HeapType, Handle<HeapType>, Isolate, HeapRep>(); | 2068 ZoneTests().Convert<HeapType, Handle<HeapType>, Isolate, HeapRep>(); |
2036 HeapTests().Convert<Type, Type*, Zone, ZoneRep>(); | 2069 HeapTests().Convert<Type, Type*, Zone, ZoneRep>(); |
2037 } | 2070 } |
2038 | 2071 |
2039 | 2072 |
2040 TEST(HTypeFromType) { | 2073 TEST(HTypeFromType) { |
2041 CcTest::InitializeVM(); | 2074 CcTest::InitializeVM(); |
2042 ZoneTests().HTypeFromType(); | 2075 ZoneTests().HTypeFromType(); |
2043 HeapTests().HTypeFromType(); | 2076 HeapTests().HTypeFromType(); |
2044 } | 2077 } |
OLD | NEW |