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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/types.cc ('k') | test/mjsunit/regress/regress-weakening-multiplication.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 TypeHandle RangeToHandle(typename Type::RangeType* range) {
rossberg 2014/11/12 14:51:15 That seems a bit hacky. Can we instead have a prop
1835 return T.Range(range->Min(), range->Max());
1836 }
1837
1838 void GetRange() {
1839 // GetRange(Range(a, b)) = Range(a, b).
1840 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) {
1841 TypeHandle type1 = *it1;
1842 if (type1->IsRange()) {
1843 typename Type::RangeType* range = type1->GetRange();
1844 CHECK(type1->Equals(RangeToHandle(range)));
1845 }
1846 }
1847
1848 // GetRange(Union(Constant(x), Range(min,max))) == Range(min, max).
1849 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) {
1850 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) {
1851 TypeHandle type1 = *it1;
1852 TypeHandle type2 = *it2;
1853 if (type1->IsConstant() && type2->IsRange()) {
1854 TypeHandle u = T.Union(type1, type2);
1855
1856 CHECK(type2->Equals(RangeToHandle(u->GetRange())));
1857 }
1858 }
1859 }
1860
1861 // GetRange is monotone whenever it is defined.
1862 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) {
1863 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) {
1864 TypeHandle type1 = *it1;
1865 TypeHandle type2 = *it2;
1866 if (type1->GetRange() != NULL && type2->GetRange() != NULL &&
1867 type1->Is(type2)) {
1868 TypeHandle r1 = RangeToHandle(type1->GetRange());
1869 TypeHandle r2 = RangeToHandle(type2->GetRange());
1870 CHECK(r1->Is(r2));
1871 }
1872 }
1873 }
1874 }
1875
1834 template<class Type2, class TypeHandle2, class Region2, class Rep2> 1876 template<class Type2, class TypeHandle2, class Region2, class Rep2>
1835 void Convert() { 1877 void Convert() {
1836 Types<Type2, TypeHandle2, Region2> T2( 1878 Types<Type2, TypeHandle2, Region2> T2(
1837 Rep2::ToRegion(&zone, isolate), isolate); 1879 Rep2::ToRegion(&zone, isolate), isolate);
1838 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { 1880 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) {
1839 TypeHandle type1 = *it; 1881 TypeHandle type1 = *it;
1840 TypeHandle2 type2 = T2.template Convert<Type>(type1); 1882 TypeHandle2 type2 = T2.template Convert<Type>(type1);
1841 TypeHandle type3 = T.template Convert<Type2>(type2); 1883 TypeHandle type3 = T.template Convert<Type2>(type2);
1842 CheckEqual(type1, type3); 1884 CheckEqual(type1, type3);
1843 } 1885 }
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
2023 } 2065 }
2024 2066
2025 2067
2026 TEST(Distributivity) { 2068 TEST(Distributivity) {
2027 CcTest::InitializeVM(); 2069 CcTest::InitializeVM();
2028 ZoneTests().Distributivity(); 2070 ZoneTests().Distributivity();
2029 HeapTests().Distributivity(); 2071 HeapTests().Distributivity();
2030 } 2072 }
2031 2073
2032 2074
2075 TEST(GetRange) {
2076 CcTest::InitializeVM();
2077 ZoneTests().GetRange();
2078 HeapTests().GetRange();
2079 }
2080
2081
2033 TEST(Convert) { 2082 TEST(Convert) {
2034 CcTest::InitializeVM(); 2083 CcTest::InitializeVM();
2035 ZoneTests().Convert<HeapType, Handle<HeapType>, Isolate, HeapRep>(); 2084 ZoneTests().Convert<HeapType, Handle<HeapType>, Isolate, HeapRep>();
2036 HeapTests().Convert<Type, Type*, Zone, ZoneRep>(); 2085 HeapTests().Convert<Type, Type*, Zone, ZoneRep>();
2037 } 2086 }
2038 2087
2039 2088
2040 TEST(HTypeFromType) { 2089 TEST(HTypeFromType) {
2041 CcTest::InitializeVM(); 2090 CcTest::InitializeVM();
2042 ZoneTests().HTypeFromType(); 2091 ZoneTests().HTypeFromType();
2043 HeapTests().HTypeFromType(); 2092 HeapTests().HTypeFromType();
2044 } 2093 }
OLDNEW
« 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