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/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 1002 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1013 CheckSub(T.Symbol, T.UniqueName); | 1013 CheckSub(T.Symbol, T.UniqueName); |
1014 CheckSub(T.Symbol, T.Name); | 1014 CheckSub(T.Symbol, T.Name); |
1015 CheckUnordered(T.String, T.UniqueName); | 1015 CheckUnordered(T.String, T.UniqueName); |
1016 CheckUnordered(T.String, T.Symbol); | 1016 CheckUnordered(T.String, T.Symbol); |
1017 CheckUnordered(T.InternalizedString, T.Symbol); | 1017 CheckUnordered(T.InternalizedString, T.Symbol); |
1018 | 1018 |
1019 CheckSub(T.Object, T.Receiver); | 1019 CheckSub(T.Object, T.Receiver); |
1020 CheckSub(T.Proxy, T.Receiver); | 1020 CheckSub(T.Proxy, T.Receiver); |
1021 CheckSub(T.OtherObject, T.Object); | 1021 CheckSub(T.OtherObject, T.Object); |
1022 CheckSub(T.Undetectable, T.Object); | 1022 CheckSub(T.Undetectable, T.Object); |
1023 CheckSub(T.DetectableObject, T.Object); | 1023 CheckSub(T.OtherObject, T.Object); |
1024 CheckSub(T.GlobalObject, T.DetectableObject); | |
1025 CheckSub(T.OtherObject, T.DetectableObject); | |
1026 CheckSub(T.GlobalObject, T.Object); | |
1027 CheckSub(T.GlobalObject, T.Receiver); | |
1028 | 1024 |
1029 CheckUnordered(T.Object, T.Proxy); | 1025 CheckUnordered(T.Object, T.Proxy); |
1030 CheckUnordered(T.GlobalObject, T.OtherObject); | 1026 CheckUnordered(T.OtherObject, T.Undetectable); |
1031 CheckUnordered(T.DetectableObject, T.Undetectable); | |
1032 | 1027 |
1033 // Subtyping between concrete structural types | 1028 // Subtyping between concrete structural types |
1034 | 1029 |
1035 CheckSub(T.ObjectClass, T.Object); | 1030 CheckSub(T.ObjectClass, T.Object); |
1036 CheckSub(T.ArrayClass, T.OtherObject); | 1031 CheckSub(T.ArrayClass, T.OtherObject); |
1037 CheckSub(T.UninitializedClass, T.Internal); | 1032 CheckSub(T.UninitializedClass, T.Internal); |
1038 CheckUnordered(T.ObjectClass, T.ArrayClass); | 1033 CheckUnordered(T.ObjectClass, T.ArrayClass); |
1039 CheckUnordered(T.UninitializedClass, T.Null); | 1034 CheckUnordered(T.UninitializedClass, T.Null); |
1040 CheckUnordered(T.UninitializedClass, T.Undefined); | 1035 CheckUnordered(T.UninitializedClass, T.Undefined); |
1041 | 1036 |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1343 CheckOverlap(T.InternalizedString, T.String); | 1338 CheckOverlap(T.InternalizedString, T.String); |
1344 CheckOverlap(T.InternalizedString, T.UniqueName); | 1339 CheckOverlap(T.InternalizedString, T.UniqueName); |
1345 CheckOverlap(T.InternalizedString, T.Name); | 1340 CheckOverlap(T.InternalizedString, T.Name); |
1346 CheckOverlap(T.Symbol, T.UniqueName); | 1341 CheckOverlap(T.Symbol, T.UniqueName); |
1347 CheckOverlap(T.Symbol, T.Name); | 1342 CheckOverlap(T.Symbol, T.Name); |
1348 CheckOverlap(T.String, T.UniqueName); | 1343 CheckOverlap(T.String, T.UniqueName); |
1349 CheckDisjoint(T.String, T.Symbol); | 1344 CheckDisjoint(T.String, T.Symbol); |
1350 CheckDisjoint(T.InternalizedString, T.Symbol); | 1345 CheckDisjoint(T.InternalizedString, T.Symbol); |
1351 CheckOverlap(T.Object, T.Receiver); | 1346 CheckOverlap(T.Object, T.Receiver); |
1352 CheckOverlap(T.OtherObject, T.Object); | 1347 CheckOverlap(T.OtherObject, T.Object); |
1353 CheckOverlap(T.GlobalObject, T.Object); | |
1354 CheckOverlap(T.Proxy, T.Receiver); | 1348 CheckOverlap(T.Proxy, T.Receiver); |
1355 CheckDisjoint(T.Object, T.Proxy); | 1349 CheckDisjoint(T.Object, T.Proxy); |
1356 | 1350 |
1357 // Structural types | 1351 // Structural types |
1358 CheckOverlap(T.ObjectClass, T.Object); | 1352 CheckOverlap(T.ObjectClass, T.Object); |
1359 CheckOverlap(T.ArrayClass, T.Object); | 1353 CheckOverlap(T.ArrayClass, T.Object); |
1360 CheckOverlap(T.ObjectClass, T.ObjectClass); | 1354 CheckOverlap(T.ObjectClass, T.ObjectClass); |
1361 CheckOverlap(T.ArrayClass, T.ArrayClass); | 1355 CheckOverlap(T.ArrayClass, T.ArrayClass); |
1362 CheckDisjoint(T.ObjectClass, T.ArrayClass); | 1356 CheckDisjoint(T.ObjectClass, T.ArrayClass); |
1363 CheckOverlap(T.SmiConstant, T.SignedSmall); | 1357 CheckOverlap(T.SmiConstant, T.SignedSmall); |
(...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1956 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { | 1950 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { |
1957 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { | 1951 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { |
1958 TypeHandle type1 = *it1; | 1952 TypeHandle type1 = *it1; |
1959 TypeHandle type2 = *it2; | 1953 TypeHandle type2 = *it2; |
1960 HType htype1 = HType::FromType<Type>(type1); | 1954 HType htype1 = HType::FromType<Type>(type1); |
1961 HType htype2 = HType::FromType<Type>(type2); | 1955 HType htype2 = HType::FromType<Type>(type2); |
1962 CHECK(!type1->Is(type2) || htype1.IsSubtypeOf(htype2)); | 1956 CHECK(!type1->Is(type2) || htype1.IsSubtypeOf(htype2)); |
1963 } | 1957 } |
1964 } | 1958 } |
1965 } | 1959 } |
1966 | |
1967 void GlobalObjectType() { | |
1968 i::Handle<i::Context> context1 = v8::Utils::OpenHandle( | |
1969 *v8::Context::New(reinterpret_cast<v8::Isolate*>(isolate))); | |
1970 Handle<i::GlobalObject> global_object1(context1->global_object()); | |
1971 TypeHandle GlobalObjectConstant1 = | |
1972 Type::Constant(global_object1, Rep::ToRegion(&zone, isolate)); | |
1973 | |
1974 i::Handle<i::Context> context2 = v8::Utils::OpenHandle( | |
1975 *v8::Context::New(reinterpret_cast<v8::Isolate*>(isolate))); | |
1976 Handle<i::GlobalObject> global_object2(context2->global_object()); | |
1977 TypeHandle GlobalObjectConstant2 = | |
1978 Type::Constant(global_object2, Rep::ToRegion(&zone, isolate)); | |
1979 | |
1980 CheckSub(GlobalObjectConstant1, T.DetectableObject); | |
1981 CheckSub(GlobalObjectConstant2, T.DetectableObject); | |
1982 CheckSub(GlobalObjectConstant1, T.GlobalObject); | |
1983 CheckSub(GlobalObjectConstant2, T.GlobalObject); | |
1984 CheckSub(GlobalObjectConstant1, T.Object); | |
1985 CheckSub(GlobalObjectConstant2, T.Object); | |
1986 | |
1987 CheckUnordered(T.GlobalObject, T.OtherObject); | |
1988 CheckUnordered(GlobalObjectConstant1, T.OtherObject); | |
1989 CheckUnordered(GlobalObjectConstant2, T.OtherObject); | |
1990 CheckUnordered(GlobalObjectConstant1, GlobalObjectConstant2); | |
1991 | |
1992 CheckDisjoint(T.GlobalObject, T.ObjectClass); | |
1993 CheckDisjoint(GlobalObjectConstant1, T.ObjectClass); | |
1994 CheckDisjoint(GlobalObjectConstant2, T.ArrayClass); | |
1995 | |
1996 CheckUnordered(T.Union(T.ObjectClass, T.ArrayClass), T.GlobalObject); | |
1997 CheckUnordered(T.Union(T.ObjectClass, T.ArrayClass), GlobalObjectConstant1); | |
1998 CheckUnordered(T.Union(T.ObjectClass, T.ArrayClass), GlobalObjectConstant2); | |
1999 | |
2000 CheckUnordered(T.Union(T.ObjectConstant1, T.ArrayClass), T.GlobalObject); | |
2001 CheckUnordered(T.Union(T.ObjectConstant1, T.ArrayClass), | |
2002 GlobalObjectConstant1); | |
2003 CheckUnordered(T.Union(T.ObjectConstant1, T.ArrayClass), | |
2004 GlobalObjectConstant2); | |
2005 | |
2006 CheckUnordered(T.Union(T.ObjectClass, T.String), T.GlobalObject); | |
2007 | |
2008 CheckSub(T.Union(T.ObjectConstant1, T.ArrayClass), | |
2009 T.Union(T.GlobalObject, T.Object)); | |
2010 | |
2011 CheckDisjoint(T.Union(GlobalObjectConstant1, T.ArrayClass), | |
2012 GlobalObjectConstant2); | |
2013 | |
2014 CheckEqual(T.Union(T.Union(T.Number, GlobalObjectConstant1), | |
2015 T.Union(T.SignedSmall, T.GlobalObject)), | |
2016 T.Union(T.Number, T.GlobalObject)); | |
2017 | |
2018 CheckEqual(T.Semantic(T.Intersect(T.ObjectClass, T.GlobalObject)), T.None); | |
2019 | |
2020 CHECK(!T.Intersect(T.ArrayClass, GlobalObjectConstant2)->IsInhabited()); | |
2021 | |
2022 CheckEqual(T.Intersect(T.Union(T.Number, T.OtherObject), | |
2023 T.Union(T.Signed32, T.GlobalObject)), | |
2024 T.Signed32); | |
2025 } | |
2026 }; | 1960 }; |
2027 | 1961 |
2028 typedef Tests<Type, Type*, Zone, ZoneRep> ZoneTests; | 1962 typedef Tests<Type, Type*, Zone, ZoneRep> ZoneTests; |
2029 typedef Tests<HeapType, Handle<HeapType>, Isolate, HeapRep> HeapTests; | 1963 typedef Tests<HeapType, Handle<HeapType>, Isolate, HeapRep> HeapTests; |
2030 | 1964 |
2031 | 1965 |
2032 TEST(IsSomeType_zone) { ZoneTests().IsSomeType(); } | 1966 TEST(IsSomeType_zone) { ZoneTests().IsSomeType(); } |
2033 | 1967 |
2034 | 1968 |
2035 TEST(IsSomeType_heap) { HeapTests().IsSomeType(); } | 1969 TEST(IsSomeType_heap) { HeapTests().IsSomeType(); } |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2190 } | 2124 } |
2191 | 2125 |
2192 | 2126 |
2193 TEST(Convert_heap) { HeapTests().Convert<Type, Type*, Zone, ZoneRep>(); } | 2127 TEST(Convert_heap) { HeapTests().Convert<Type, Type*, Zone, ZoneRep>(); } |
2194 | 2128 |
2195 | 2129 |
2196 TEST(HTypeFromType_zone) { ZoneTests().HTypeFromType(); } | 2130 TEST(HTypeFromType_zone) { ZoneTests().HTypeFromType(); } |
2197 | 2131 |
2198 | 2132 |
2199 TEST(HTypeFromType_heap) { HeapTests().HTypeFromType(); } | 2133 TEST(HTypeFromType_heap) { HeapTests().HTypeFromType(); } |
2200 | |
2201 | |
2202 TEST(GlobalObjectType_zone) { ZoneTests().GlobalObjectType(); } | |
2203 | |
2204 | |
2205 TEST(GlobalObjectType_heap) { HeapTests().GlobalObjectType(); } | |
OLD | NEW |