| 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/crankshaft/hydrogen-types.h" | 7 #include "src/crankshaft/hydrogen-types.h" |
| 8 #include "src/types.h" | 8 #include "src/types.h" |
| 9 #include "test/cctest/cctest.h" | 9 #include "test/cctest/cctest.h" |
| 10 #include "test/cctest/types-fuzz.h" | 10 #include "test/cctest/types-fuzz.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 | 55 |
| 56 struct BitsetType : Type::BitsetType { | 56 struct BitsetType : Type::BitsetType { |
| 57 using Type::BitsetType::New; | 57 using Type::BitsetType::New; |
| 58 using Type::BitsetType::Glb; | 58 using Type::BitsetType::Glb; |
| 59 using Type::BitsetType::Lub; | 59 using Type::BitsetType::Lub; |
| 60 using Type::BitsetType::IsInhabited; | 60 using Type::BitsetType::IsInhabited; |
| 61 }; | 61 }; |
| 62 }; | 62 }; |
| 63 | 63 |
| 64 | 64 |
| 65 struct HeapRep { | |
| 66 typedef FixedArray Struct; | |
| 67 | |
| 68 static bool IsStruct(Handle<HeapType> t, int tag) { | |
| 69 return t->IsFixedArray() && Smi::cast(AsStruct(t)->get(0))->value() == tag; | |
| 70 } | |
| 71 static bool IsBitset(Handle<HeapType> t) { return t->IsSmi(); } | |
| 72 // HACK: the number 5 below is the value of StructuralType::kUnionTag. | |
| 73 static bool IsUnion(Handle<HeapType> t) { return t->IsUnionForTesting(); } | |
| 74 | |
| 75 static Struct* AsStruct(Handle<HeapType> t) { return FixedArray::cast(*t); } | |
| 76 static bitset AsBitset(Handle<HeapType> t) { | |
| 77 return static_cast<bitset>(reinterpret_cast<uintptr_t>(*t)); | |
| 78 } | |
| 79 static Struct* AsUnion(Handle<HeapType> t) { return AsStruct(t); } | |
| 80 static int Length(Struct* structured) { return structured->length() - 1; } | |
| 81 | |
| 82 static Isolate* ToRegion(Zone* zone, Isolate* isolate) { return isolate; } | |
| 83 | |
| 84 struct BitsetType : HeapType::BitsetType { | |
| 85 using HeapType::BitsetType::New; | |
| 86 using HeapType::BitsetType::Glb; | |
| 87 using HeapType::BitsetType::Lub; | |
| 88 using HeapType::BitsetType::IsInhabited; | |
| 89 static bitset Glb(Handle<HeapType> type) { return Glb(*type); } | |
| 90 static bitset Lub(Handle<HeapType> type) { return Lub(*type); } | |
| 91 }; | |
| 92 }; | |
| 93 | |
| 94 | |
| 95 template<class Type, class TypeHandle, class Region, class Rep> | 65 template<class Type, class TypeHandle, class Region, class Rep> |
| 96 struct Tests : Rep { | 66 struct Tests : Rep { |
| 97 typedef Types<Type, TypeHandle, Region> TypesInstance; | 67 typedef Types<Type, TypeHandle, Region> TypesInstance; |
| 98 typedef typename TypesInstance::TypeVector::iterator TypeIterator; | 68 typedef typename TypesInstance::TypeVector::iterator TypeIterator; |
| 99 typedef typename TypesInstance::MapVector::iterator MapIterator; | 69 typedef typename TypesInstance::MapVector::iterator MapIterator; |
| 100 typedef typename TypesInstance::ValueVector::iterator ValueIterator; | 70 typedef typename TypesInstance::ValueVector::iterator ValueIterator; |
| 101 | 71 |
| 102 Isolate* isolate; | 72 Isolate* isolate; |
| 103 HandleScope scope; | 73 HandleScope scope; |
| 104 Zone zone; | 74 Zone zone; |
| (...skipping 1841 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1946 TypeHandle type3 = T.template Convert<Type2>(type2); | 1916 TypeHandle type3 = T.template Convert<Type2>(type2); |
| 1947 CheckEqual(type1, type3); | 1917 CheckEqual(type1, type3); |
| 1948 } | 1918 } |
| 1949 } | 1919 } |
| 1950 | 1920 |
| 1951 void HTypeFromType() { | 1921 void HTypeFromType() { |
| 1952 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { | 1922 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { |
| 1953 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { | 1923 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { |
| 1954 TypeHandle type1 = *it1; | 1924 TypeHandle type1 = *it1; |
| 1955 TypeHandle type2 = *it2; | 1925 TypeHandle type2 = *it2; |
| 1956 HType htype1 = HType::FromType<Type>(type1); | 1926 HType htype1 = HType::FromType(type1); |
| 1957 HType htype2 = HType::FromType<Type>(type2); | 1927 HType htype2 = HType::FromType(type2); |
| 1958 CHECK(!type1->Is(type2) || htype1.IsSubtypeOf(htype2)); | 1928 CHECK(!type1->Is(type2) || htype1.IsSubtypeOf(htype2)); |
| 1959 } | 1929 } |
| 1960 } | 1930 } |
| 1961 } | 1931 } |
| 1962 }; | 1932 }; |
| 1963 | 1933 |
| 1964 typedef Tests<Type, Type*, Zone, ZoneRep> ZoneTests; | 1934 typedef Tests<Type, Type*, Zone, ZoneRep> ZoneTests; |
| 1965 typedef Tests<HeapType, Handle<HeapType>, Isolate, HeapRep> HeapTests; | |
| 1966 | 1935 |
| 1967 | 1936 |
| 1968 TEST(IsSomeType_zone) { ZoneTests().IsSomeType(); } | 1937 TEST(IsSomeType_zone) { ZoneTests().IsSomeType(); } |
| 1969 | 1938 |
| 1970 | 1939 |
| 1971 TEST(IsSomeType_heap) { HeapTests().IsSomeType(); } | |
| 1972 | |
| 1973 | |
| 1974 TEST(PointwiseRepresentation_zone) { ZoneTests().PointwiseRepresentation(); } | 1940 TEST(PointwiseRepresentation_zone) { ZoneTests().PointwiseRepresentation(); } |
| 1975 | 1941 |
| 1976 | 1942 |
| 1977 TEST(PointwiseRepresentation_heap) { HeapTests().PointwiseRepresentation(); } | |
| 1978 | |
| 1979 | |
| 1980 TEST(BitsetType_zone) { ZoneTests().Bitset(); } | 1943 TEST(BitsetType_zone) { ZoneTests().Bitset(); } |
| 1981 | 1944 |
| 1982 | 1945 |
| 1983 TEST(BitsetType_heap) { HeapTests().Bitset(); } | |
| 1984 | |
| 1985 | |
| 1986 TEST(ClassType_zone) { ZoneTests().Class(); } | 1946 TEST(ClassType_zone) { ZoneTests().Class(); } |
| 1987 | 1947 |
| 1988 | 1948 |
| 1989 TEST(ClassType_heap) { HeapTests().Class(); } | |
| 1990 | |
| 1991 | |
| 1992 TEST(ConstantType_zone) { ZoneTests().Constant(); } | 1949 TEST(ConstantType_zone) { ZoneTests().Constant(); } |
| 1993 | 1950 |
| 1994 | 1951 |
| 1995 TEST(ConstantType_heap) { HeapTests().Constant(); } | |
| 1996 | |
| 1997 | |
| 1998 TEST(RangeType_zone) { ZoneTests().Range(); } | 1952 TEST(RangeType_zone) { ZoneTests().Range(); } |
| 1999 | 1953 |
| 2000 | 1954 |
| 2001 TEST(RangeType_heap) { HeapTests().Range(); } | |
| 2002 | |
| 2003 | |
| 2004 TEST(ArrayType_zone) { ZoneTests().Array(); } | 1955 TEST(ArrayType_zone) { ZoneTests().Array(); } |
| 2005 | 1956 |
| 2006 | 1957 |
| 2007 TEST(ArrayType_heap) { HeapTests().Array(); } | |
| 2008 | |
| 2009 | |
| 2010 TEST(FunctionType_zone) { ZoneTests().Function(); } | 1958 TEST(FunctionType_zone) { ZoneTests().Function(); } |
| 2011 | 1959 |
| 2012 | 1960 |
| 2013 TEST(FunctionType_heap) { HeapTests().Function(); } | |
| 2014 | |
| 2015 | |
| 2016 TEST(Of_zone) { ZoneTests().Of(); } | 1961 TEST(Of_zone) { ZoneTests().Of(); } |
| 2017 | 1962 |
| 2018 | 1963 |
| 2019 TEST(Of_heap) { HeapTests().Of(); } | |
| 2020 | |
| 2021 | |
| 2022 TEST(NowOf_zone) { ZoneTests().NowOf(); } | 1964 TEST(NowOf_zone) { ZoneTests().NowOf(); } |
| 2023 | 1965 |
| 2024 | 1966 |
| 2025 TEST(NowOf_heap) { HeapTests().NowOf(); } | |
| 2026 | |
| 2027 | |
| 2028 TEST(MinMax_zone) { ZoneTests().MinMax(); } | 1967 TEST(MinMax_zone) { ZoneTests().MinMax(); } |
| 2029 | 1968 |
| 2030 | 1969 |
| 2031 TEST(MinMax_heap) { HeapTests().MinMax(); } | |
| 2032 | |
| 2033 | |
| 2034 TEST(BitsetGlb_zone) { ZoneTests().BitsetGlb(); } | 1970 TEST(BitsetGlb_zone) { ZoneTests().BitsetGlb(); } |
| 2035 | 1971 |
| 2036 | 1972 |
| 2037 TEST(BitsetGlb_heap) { HeapTests().BitsetGlb(); } | |
| 2038 | |
| 2039 | |
| 2040 TEST(BitsetLub_zone) { ZoneTests().BitsetLub(); } | 1973 TEST(BitsetLub_zone) { ZoneTests().BitsetLub(); } |
| 2041 | 1974 |
| 2042 | 1975 |
| 2043 TEST(BitsetLub_heap) { HeapTests().BitsetLub(); } | |
| 2044 | |
| 2045 | |
| 2046 TEST(Is1_zone) { ZoneTests().Is1(); } | 1976 TEST(Is1_zone) { ZoneTests().Is1(); } |
| 2047 | 1977 |
| 2048 | 1978 |
| 2049 TEST(Is1_heap) { HeapTests().Is1(); } | |
| 2050 | |
| 2051 | |
| 2052 TEST(Is2_zone) { ZoneTests().Is2(); } | 1979 TEST(Is2_zone) { ZoneTests().Is2(); } |
| 2053 | 1980 |
| 2054 | 1981 |
| 2055 TEST(Is2_heap) { HeapTests().Is2(); } | |
| 2056 | |
| 2057 | |
| 2058 TEST(NowIs_zone) { ZoneTests().NowIs(); } | 1982 TEST(NowIs_zone) { ZoneTests().NowIs(); } |
| 2059 | 1983 |
| 2060 | 1984 |
| 2061 TEST(NowIs_heap) { HeapTests().NowIs(); } | |
| 2062 | |
| 2063 | |
| 2064 TEST(Contains_zone) { ZoneTests().Contains(); } | 1985 TEST(Contains_zone) { ZoneTests().Contains(); } |
| 2065 | 1986 |
| 2066 | 1987 |
| 2067 TEST(Contains_heap) { HeapTests().Contains(); } | |
| 2068 | |
| 2069 | |
| 2070 TEST(NowContains_zone) { ZoneTests().NowContains(); } | 1988 TEST(NowContains_zone) { ZoneTests().NowContains(); } |
| 2071 | 1989 |
| 2072 | 1990 |
| 2073 TEST(NowContains_heap) { HeapTests().NowContains(); } | |
| 2074 | |
| 2075 | |
| 2076 TEST(Maybe_zone) { ZoneTests().Maybe(); } | 1991 TEST(Maybe_zone) { ZoneTests().Maybe(); } |
| 2077 | 1992 |
| 2078 | 1993 |
| 2079 TEST(Maybe_heap) { HeapTests().Maybe(); } | |
| 2080 | |
| 2081 | |
| 2082 TEST(Union1_zone) { ZoneTests().Union1(); } | 1994 TEST(Union1_zone) { ZoneTests().Union1(); } |
| 2083 | 1995 |
| 2084 | 1996 |
| 2085 TEST(Union1_heap) { HeapTests().Union1(); } | |
| 2086 | |
| 2087 | |
| 2088 TEST(Union2_zone) { ZoneTests().Union2(); } | 1997 TEST(Union2_zone) { ZoneTests().Union2(); } |
| 2089 | 1998 |
| 2090 | 1999 |
| 2091 TEST(Union2_heap) { HeapTests().Union2(); } | |
| 2092 | |
| 2093 | |
| 2094 TEST(Union3_zone) { ZoneTests().Union3(); } | 2000 TEST(Union3_zone) { ZoneTests().Union3(); } |
| 2095 | 2001 |
| 2096 | 2002 |
| 2097 TEST(Union3_heap) { HeapTests().Union3(); } | |
| 2098 | |
| 2099 | |
| 2100 TEST(Union4_zone) { ZoneTests().Union4(); } | 2003 TEST(Union4_zone) { ZoneTests().Union4(); } |
| 2101 | 2004 |
| 2102 | 2005 |
| 2103 TEST(Union4_heap) { HeapTests().Union4(); } | |
| 2104 | |
| 2105 | |
| 2106 TEST(Intersect_zone) { ZoneTests().Intersect(); } | 2006 TEST(Intersect_zone) { ZoneTests().Intersect(); } |
| 2107 | 2007 |
| 2108 | 2008 |
| 2109 TEST(Intersect_heap) { HeapTests().Intersect(); } | |
| 2110 | |
| 2111 | |
| 2112 TEST(Distributivity_zone) { ZoneTests().Distributivity(); } | 2009 TEST(Distributivity_zone) { ZoneTests().Distributivity(); } |
| 2113 | 2010 |
| 2114 | 2011 |
| 2115 TEST(Distributivity_heap) { HeapTests().Distributivity(); } | |
| 2116 | |
| 2117 | |
| 2118 TEST(GetRange_zone) { ZoneTests().GetRange(); } | 2012 TEST(GetRange_zone) { ZoneTests().GetRange(); } |
| 2119 | 2013 |
| 2120 | 2014 |
| 2121 TEST(GetRange_heap) { HeapTests().GetRange(); } | |
| 2122 | |
| 2123 | |
| 2124 TEST(Convert_zone) { | |
| 2125 ZoneTests().Convert<HeapType, Handle<HeapType>, Isolate, HeapRep>(); | |
| 2126 } | |
| 2127 | |
| 2128 | |
| 2129 TEST(Convert_heap) { HeapTests().Convert<Type, Type*, Zone, ZoneRep>(); } | |
| 2130 | |
| 2131 | |
| 2132 TEST(HTypeFromType_zone) { ZoneTests().HTypeFromType(); } | 2015 TEST(HTypeFromType_zone) { ZoneTests().HTypeFromType(); } |
| 2133 | |
| 2134 | |
| 2135 TEST(HTypeFromType_heap) { HeapTests().HTypeFromType(); } | |
| OLD | NEW |