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

Side by Side Diff: test/cctest/test-types.cc

Issue 602613002: Add some tests about range types. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 2 months 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') | no next file » | 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"
11 11
12 using namespace v8::internal; 12 using namespace v8::internal;
13 13
14
14 // Testing auxiliaries (breaking the Type abstraction). 15 // Testing auxiliaries (breaking the Type abstraction).
16
17
18 static bool IsInteger(double x) {
19 return nearbyint(x) == x && !i::IsMinusZero(x); // Allows for infinities.
20 }
21
22
23 static bool IsInteger(i::Object* x) {
24 return x->IsNumber() && IsInteger(x->Number());
25 }
26
27
15 typedef uint32_t bitset; 28 typedef uint32_t bitset;
16 29
30
17 struct ZoneRep { 31 struct ZoneRep {
18 typedef void* Struct; 32 typedef void* Struct;
19 33
20 static bool IsStruct(Type* t, int tag) { 34 static bool IsStruct(Type* t, int tag) {
21 return !IsBitset(t) && reinterpret_cast<intptr_t>(AsStruct(t)[0]) == tag; 35 return !IsBitset(t) && reinterpret_cast<intptr_t>(AsStruct(t)[0]) == tag;
22 } 36 }
23 static bool IsBitset(Type* t) { return reinterpret_cast<uintptr_t>(t) & 1; } 37 static bool IsBitset(Type* t) { return reinterpret_cast<uintptr_t>(t) & 1; }
24 static bool IsUnion(Type* t) { return IsStruct(t, 6); } 38 static bool IsUnion(Type* t) { return IsStruct(t, 6); }
25 39
26 static Struct* AsStruct(Type* t) { 40 static Struct* AsStruct(Type* t) {
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 if (min2->Number() > max2->Number()) std::swap(min2, max2); 626 if (min2->Number() > max2->Number()) std::swap(min2, max2);
613 TypeHandle type1 = T.Range(min1, max1); 627 TypeHandle type1 = T.Range(min1, max1);
614 TypeHandle type2 = T.Range(min2, max2); 628 TypeHandle type2 = T.Range(min2, max2);
615 CHECK(Equal(type1, type2) == (*min1 == *min2 && *max1 == *max2)); 629 CHECK(Equal(type1, type2) == (*min1 == *min2 && *max1 == *max2));
616 } 630 }
617 } 631 }
618 } 632 }
619 } 633 }
620 } 634 }
621 635
636 void Context() {
637 // Constructor
638 for (int i = 0; i < 20; ++i) {
639 TypeHandle type = T.Random();
640 TypeHandle context = T.Context(type);
641 CHECK(context->Iscontext());
642 }
643
644 // Attributes
645 for (int i = 0; i < 20; ++i) {
646 TypeHandle type = T.Random();
647 TypeHandle context = T.Context(type);
648 CheckEqual(type, context->AsContext()->Outer());
649 }
650
651 // Functionality & Injectivity: Context(T1) = Context(T2) iff T1 = T2
652 for (int i = 0; i < 20; ++i) {
653 for (int j = 0; j < 20; ++j) {
654 TypeHandle type1 = T.Random();
655 TypeHandle type2 = T.Random();
656 TypeHandle context1 = T.Context(type1);
657 TypeHandle context2 = T.Context(type2);
658 CHECK(Equal(context1, context2) == Equal(type1, type2));
659 }
660 }
661 }
662
622 void Array() { 663 void Array() {
623 // Constructor 664 // Constructor
624 for (int i = 0; i < 20; ++i) { 665 for (int i = 0; i < 20; ++i) {
625 TypeHandle type = T.Random(); 666 TypeHandle type = T.Random();
626 TypeHandle array = T.Array1(type); 667 TypeHandle array = T.Array1(type);
627 CHECK(array->IsArray()); 668 CHECK(array->IsArray());
628 } 669 }
629 670
630 // Attributes 671 // Attributes
631 for (int i = 0; i < 20; ++i) { 672 for (int i = 0; i < 20; ++i) {
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
796 Handle<i::Object> value = *vt; 837 Handle<i::Object> value = *vt;
797 TypeHandle type = *it; 838 TypeHandle type = *it;
798 TypeHandle const_type = T.Constant(value); 839 TypeHandle const_type = T.Constant(value);
799 TypeHandle nowof_type = T.NowOf(value); 840 TypeHandle nowof_type = T.NowOf(value);
800 CHECK(!const_type->Is(type) || 841 CHECK(!const_type->Is(type) ||
801 nowof_type->Is(type) || type->Maybe(const_type)); 842 nowof_type->Is(type) || type->Maybe(const_type));
802 } 843 }
803 } 844 }
804 } 845 }
805 846
847 void MinMax() {
848 // If b is regular numeric bitset, then Range(b->Min(), b->Max())->Is(b).
849 // TODO(neis): Need to ignore representation for this to be true.
850 /*
851 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) {
852 TypeHandle type = *it;
853 if (this->IsBitset(type) && type->Is(T.Number) &&
854 !type->Is(T.None) && !type->Is(T.NaN)) {
855 TypeHandle range = T.Range(
856 isolate->factory()->NewNumber(type->Min()),
857 isolate->factory()->NewNumber(type->Max()));
858 CHECK(range->Is(type));
859 }
860 }
861 */
862
863 // If b is regular numeric bitset, then b->Min() and b->Max() are integers.
864 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) {
865 TypeHandle type = *it;
866 if (this->IsBitset(type) && type->Is(T.Number) &&
867 !type->Is(T.None) && !type->Is(T.NaN)) {
868 CHECK(IsInteger(type->Min()) && IsInteger(type->Max()));
869 }
870 }
871
872 // If b1 and b2 are regular numeric bitsets with b1->Is(b2), then
873 // b1->Min() >= b2->Min() and b1->Max() <= b2->Max().
874 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) {
875 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) {
876 TypeHandle type1 = *it1;
877 TypeHandle type2 = *it2;
878 if (this->IsBitset(type1) && type1->Is(type2) && type2->Is(T.Number) &&
879 !type1->Is(T.NaN) && !type2->Is(T.NaN)) {
880 CHECK(type1->Min() >= type2->Min());
881 CHECK(type1->Max() <= type2->Max());
882 }
883 }
884 }
885
886 // Lub(Range(x,y))->Min() <= x and y <= Lub(Range(x,y))->Max()
887 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) {
888 TypeHandle type = *it;
889 if (type->IsRange()) {
890 TypeHandle lub = Rep::BitsetType::New(
891 Rep::BitsetType::Lub(type), T.region());
892 CHECK(lub->Min() <= type->Min() && type->Max() <= lub->Max());
893 }
894 }
895 }
896
806 void BitsetGlb() { 897 void BitsetGlb() {
807 // Lower: (T->BitsetGlb())->Is(T) 898 // Lower: (T->BitsetGlb())->Is(T)
808 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { 899 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) {
809 TypeHandle type = *it; 900 TypeHandle type = *it;
810 TypeHandle glb = 901 TypeHandle glb =
811 Rep::BitsetType::New(Rep::BitsetType::Glb(type), T.region()); 902 Rep::BitsetType::New(Rep::BitsetType::Glb(type), T.region());
812 CHECK(glb->Is(type)); 903 CHECK(glb->Is(type));
813 } 904 }
814 905
815 // Greatest: If T1->IsBitset() and T1->Is(T2), then T1->Is(T2->BitsetGlb()) 906 // Greatest: If T1->IsBitset() and T1->Is(T2), then T1->Is(T2->BitsetGlb())
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
864 TypeHandle type2 = *it2; 955 TypeHandle type2 = *it2;
865 TypeHandle lub1 = 956 TypeHandle lub1 =
866 Rep::BitsetType::New(Rep::BitsetType::Lub(type1), T.region()); 957 Rep::BitsetType::New(Rep::BitsetType::Lub(type1), T.region());
867 TypeHandle lub2 = 958 TypeHandle lub2 =
868 Rep::BitsetType::New(Rep::BitsetType::Lub(type2), T.region()); 959 Rep::BitsetType::New(Rep::BitsetType::Lub(type2), T.region());
869 CHECK(!type1->Is(type2) || lub1->Is(lub2)); 960 CHECK(!type1->Is(type2) || lub1->Is(lub2));
870 } 961 }
871 } 962 }
872 } 963 }
873 964
874 void Is() { 965 void Is1() {
875 // Least Element (Bottom): None->Is(T) 966 // Least Element (Bottom): None->Is(T)
876 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { 967 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) {
877 TypeHandle type = *it; 968 TypeHandle type = *it;
878 CHECK(T.None->Is(type)); 969 CHECK(T.None->Is(type));
879 } 970 }
880 971
881 // Greatest Element (Top): T->Is(Any) 972 // Greatest Element (Top): T->Is(Any)
882 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { 973 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) {
883 TypeHandle type = *it; 974 TypeHandle type = *it;
884 CHECK(type->Is(T.Any)); 975 CHECK(type->Is(T.Any));
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
916 1007
917 // Antisymmetry: T1->Is(T2) and T2->Is(T1) iff T1 = T2 1008 // Antisymmetry: T1->Is(T2) and T2->Is(T1) iff T1 = T2
918 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { 1009 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) {
919 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { 1010 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) {
920 TypeHandle type1 = *it1; 1011 TypeHandle type1 = *it1;
921 TypeHandle type2 = *it2; 1012 TypeHandle type2 = *it2;
922 CHECK((type1->Is(type2) && type2->Is(type1)) == Equal(type1, type2)); 1013 CHECK((type1->Is(type2) && type2->Is(type1)) == Equal(type1, type2));
923 } 1014 }
924 } 1015 }
925 1016
1017 // (In-)Compatibilities.
1018 for (TypeIterator i = T.types.begin(); i != T.types.end(); ++i) {
1019 for (TypeIterator j = T.types.begin(); j != T.types.end(); ++j) {
1020 TypeHandle type1 = *i;
1021 TypeHandle type2 = *j;
1022 CHECK(!type1->Is(type2) || this->IsBitset(type2) ||
1023 this->IsUnion(type2) || this->IsUnion(type1) ||
1024 (type1->IsClass() && type2->IsClass()) ||
1025 (type1->IsConstant() && type2->IsConstant()) ||
1026 (type1->IsConstant() && type2->IsRange()) ||
1027 (type1->IsRange() && type2->IsRange()) ||
1028 (type1->IsContext() && type2->IsContext()) ||
1029 (type1->IsArray() && type2->IsArray()) ||
1030 (type1->IsFunction() && type2->IsFunction()) ||
1031 type1->Equals(T.None));
1032 }
1033 }
1034 }
1035
1036 void Is2() {
926 // Class(M1)->Is(Class(M2)) iff M1 = M2 1037 // Class(M1)->Is(Class(M2)) iff M1 = M2
927 for (MapIterator mt1 = T.maps.begin(); mt1 != T.maps.end(); ++mt1) { 1038 for (MapIterator mt1 = T.maps.begin(); mt1 != T.maps.end(); ++mt1) {
928 for (MapIterator mt2 = T.maps.begin(); mt2 != T.maps.end(); ++mt2) { 1039 for (MapIterator mt2 = T.maps.begin(); mt2 != T.maps.end(); ++mt2) {
929 Handle<i::Map> map1 = *mt1; 1040 Handle<i::Map> map1 = *mt1;
930 Handle<i::Map> map2 = *mt2; 1041 Handle<i::Map> map2 = *mt2;
931 TypeHandle class_type1 = T.Class(map1); 1042 TypeHandle class_type1 = T.Class(map1);
932 TypeHandle class_type2 = T.Class(map2); 1043 TypeHandle class_type2 = T.Class(map2);
933 CHECK(class_type1->Is(class_type2) == (*map1 == *map2)); 1044 CHECK(class_type1->Is(class_type2) == (*map1 == *map2));
934 } 1045 }
935 } 1046 }
936 1047
937 // Constant(V1)->Is(Constant(V2)) iff V1 = V2 1048 // Range(X1, Y1)->Is(Range(X2, Y2)) iff X1 >= X2 /\ Y1 <= Y2
938 for (ValueIterator vt1 = T.values.begin(); vt1 != T.values.end(); ++vt1) {
939 for (ValueIterator vt2 = T.values.begin(); vt2 != T.values.end(); ++vt2) {
940 Handle<i::Object> value1 = *vt1;
941 Handle<i::Object> value2 = *vt2;
942 TypeHandle const_type1 = T.Constant(value1);
943 TypeHandle const_type2 = T.Constant(value2);
944 CHECK(const_type1->Is(const_type2) == (*value1 == *value2));
945 }
946 }
947
948 // Range(min1, max1)->Is(Range(min2, max2)) iff
949 // min1 >= min2 /\ max1 <= max2
950 for (ValueIterator i1 = T.integers.begin(); 1049 for (ValueIterator i1 = T.integers.begin();
951 i1 != T.integers.end(); ++i1) { 1050 i1 != T.integers.end(); ++i1) {
952 for (ValueIterator j1 = T.integers.begin(); 1051 for (ValueIterator j1 = i1;
953 j1 != T.integers.end(); ++j1) { 1052 j1 != T.integers.end(); ++j1) {
954 for (ValueIterator i2 = T.integers.begin(); 1053 for (ValueIterator i2 = T.integers.begin();
955 i2 != T.integers.end(); ++i2) { 1054 i2 != T.integers.end(); ++i2) {
956 for (ValueIterator j2 = T.integers.begin(); 1055 for (ValueIterator j2 = i2;
957 j2 != T.integers.end(); ++j2) { 1056 j2 != T.integers.end(); ++j2) {
958 i::Handle<i::Object> min1 = *i1; 1057 i::Handle<i::Object> min1 = *i1;
959 i::Handle<i::Object> max1 = *j1; 1058 i::Handle<i::Object> max1 = *j1;
960 i::Handle<i::Object> min2 = *i2; 1059 i::Handle<i::Object> min2 = *i2;
961 i::Handle<i::Object> max2 = *j2; 1060 i::Handle<i::Object> max2 = *j2;
962 if (min1->Number() > max1->Number()) std::swap(min1, max1); 1061 if (min1->Number() > max1->Number()) std::swap(min1, max1);
963 if (min2->Number() > max2->Number()) std::swap(min2, max2); 1062 if (min2->Number() > max2->Number()) std::swap(min2, max2);
964 TypeHandle type1 = T.Range(min1, max1); 1063 TypeHandle type1 = T.Range(min1, max1);
965 TypeHandle type2 = T.Range(min2, max2); 1064 TypeHandle type2 = T.Range(min2, max2);
966 CHECK(type1->Is(type2) == 1065 CHECK(type1->Is(type2) ==
967 (min2->Number() <= min1->Number() && 1066 (min1->Number() >= min2->Number() &&
968 max1->Number() <= max2->Number())); 1067 max1->Number() <= max2->Number()));
969 } 1068 }
970 } 1069 }
971 } 1070 }
972 } 1071 }
973 1072
1073 // Constant(V1)->Is(Constant(V2)) iff V1 = V2
1074 for (ValueIterator vt1 = T.values.begin(); vt1 != T.values.end(); ++vt1) {
1075 for (ValueIterator vt2 = T.values.begin(); vt2 != T.values.end(); ++vt2) {
1076 Handle<i::Object> value1 = *vt1;
1077 Handle<i::Object> value2 = *vt2;
1078 TypeHandle const_type1 = T.Constant(value1);
1079 TypeHandle const_type2 = T.Constant(value2);
1080 CHECK(const_type1->Is(const_type2) == (*value1 == *value2));
1081 }
1082 }
1083
974 // Context(T1)->Is(Context(T2)) iff T1 = T2 1084 // Context(T1)->Is(Context(T2)) iff T1 = T2
975 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { 1085 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) {
976 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { 1086 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) {
977 TypeHandle outer1 = *it1; 1087 TypeHandle outer1 = *it1;
978 TypeHandle outer2 = *it2; 1088 TypeHandle outer2 = *it2;
979 TypeHandle type1 = T.Context(outer1); 1089 TypeHandle type1 = T.Context(outer1);
980 TypeHandle type2 = T.Context(outer2); 1090 TypeHandle type2 = T.Context(outer2);
981 CHECK(type1->Is(type2) == outer1->Equals(outer2)); 1091 CHECK(type1->Is(type2) == outer1->Equals(outer2));
982 } 1092 }
983 } 1093 }
(...skipping 16 matching lines...) Expand all
1000 TypeHandle receiver1 = *j; 1110 TypeHandle receiver1 = *j;
1001 TypeHandle type1 = T.Function0(result1, receiver1); 1111 TypeHandle type1 = T.Function0(result1, receiver1);
1002 TypeHandle result2 = T.Random(); 1112 TypeHandle result2 = T.Random();
1003 TypeHandle receiver2 = T.Random(); 1113 TypeHandle receiver2 = T.Random();
1004 TypeHandle type2 = T.Function0(result2, receiver2); 1114 TypeHandle type2 = T.Function0(result2, receiver2);
1005 CHECK(type1->Is(type2) == 1115 CHECK(type1->Is(type2) ==
1006 (result1->Equals(result2) && receiver1->Equals(receiver2))); 1116 (result1->Equals(result2) && receiver1->Equals(receiver2)));
1007 } 1117 }
1008 } 1118 }
1009 1119
1010 // (In-)Compatibilities. 1120
1011 for (TypeIterator i = T.types.begin(); i != T.types.end(); ++i) { 1121 // Range-specific subtyping
1012 for (TypeIterator j = T.types.begin(); j != T.types.end(); ++j) { 1122
1013 TypeHandle type1 = *i; 1123 // If IsInteger(v) then Constant(v)->Is(Range(v, v)).
1014 TypeHandle type2 = *j; 1124 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) {
1015 CHECK(!type1->Is(type2) || this->IsBitset(type2) || 1125 TypeHandle type = *it;
1016 this->IsUnion(type2) || this->IsUnion(type1) || 1126 if (type->IsConstant() && IsInteger(*type->AsConstant()->Value())) {
1017 (type1->IsClass() && type2->IsClass()) || 1127 CHECK(type->Is(
1018 (type1->IsConstant() && type2->IsConstant()) || 1128 T.Range(type->AsConstant()->Value(), type->AsConstant()->Value())));
1019 (type1->IsConstant() && type2->IsRange()) ||
1020 (type1->IsRange() && type2->IsRange()) ||
1021 (type1->IsContext() && type2->IsContext()) ||
1022 (type1->IsArray() && type2->IsArray()) ||
1023 (type1->IsFunction() && type2->IsFunction()) ||
1024 type1->Equals(T.None));
1025 } 1129 }
1026 } 1130 }
1027 1131
1028 // Basic types 1132 // If Constant(x)->Is(Range(min,max)) then IsInteger(v) and min <= x <= max.
1133 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) {
1134 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) {
1135 TypeHandle type1 = *it1;
1136 TypeHandle type2 = *it2;
1137 if (type1->IsConstant() && type2->IsRange() && type1->Is(type2)) {
1138 double x = type1->AsConstant()->Value()->Number();
1139 double min = type2->AsRange()->Min()->Number();
1140 double max = type2->AsRange()->Max()->Number();
1141 CHECK(IsInteger(x) && min <= x && x <= max);
1142 }
1143 }
1144 }
1145
1146 // Lub(Range(x,y))->Is(T.Union(T.Integral32, T.OtherNumber))
1147 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) {
1148 TypeHandle type = *it;
1149 if (type->IsRange()) {
1150 TypeHandle lub = Rep::BitsetType::New(
1151 Rep::BitsetType::Lub(type), T.region());
1152 CHECK(lub->Is(T.Union(T.Integral32, T.OtherNumber)));
1153 }
1154 }
1155
1156
1157 // Subtyping between concrete basic types
1158
1029 CheckUnordered(T.Boolean, T.Null); 1159 CheckUnordered(T.Boolean, T.Null);
1030 CheckUnordered(T.Undefined, T.Null); 1160 CheckUnordered(T.Undefined, T.Null);
1031 CheckUnordered(T.Boolean, T.Undefined); 1161 CheckUnordered(T.Boolean, T.Undefined);
1032 1162
1033 CheckSub(T.SignedSmall, T.Number); 1163 CheckSub(T.SignedSmall, T.Number);
1034 CheckSub(T.Signed32, T.Number); 1164 CheckSub(T.Signed32, T.Number);
1035 CheckSub(T.SignedSmall, T.Signed32); 1165 CheckSub(T.SignedSmall, T.Signed32);
1036 CheckUnordered(T.SignedSmall, T.MinusZero); 1166 CheckUnordered(T.SignedSmall, T.MinusZero);
1037 CheckUnordered(T.Signed32, T.Unsigned32); 1167 CheckUnordered(T.Signed32, T.Unsigned32);
1038 1168
1039 CheckSub(T.UniqueName, T.Name); 1169 CheckSub(T.UniqueName, T.Name);
1040 CheckSub(T.String, T.Name); 1170 CheckSub(T.String, T.Name);
1041 CheckSub(T.InternalizedString, T.String); 1171 CheckSub(T.InternalizedString, T.String);
1042 CheckSub(T.InternalizedString, T.UniqueName); 1172 CheckSub(T.InternalizedString, T.UniqueName);
1043 CheckSub(T.InternalizedString, T.Name); 1173 CheckSub(T.InternalizedString, T.Name);
1044 CheckSub(T.Symbol, T.UniqueName); 1174 CheckSub(T.Symbol, T.UniqueName);
1045 CheckSub(T.Symbol, T.Name); 1175 CheckSub(T.Symbol, T.Name);
1046 CheckUnordered(T.String, T.UniqueName); 1176 CheckUnordered(T.String, T.UniqueName);
1047 CheckUnordered(T.String, T.Symbol); 1177 CheckUnordered(T.String, T.Symbol);
1048 CheckUnordered(T.InternalizedString, T.Symbol); 1178 CheckUnordered(T.InternalizedString, T.Symbol);
1049 1179
1050 CheckSub(T.Object, T.Receiver); 1180 CheckSub(T.Object, T.Receiver);
1051 CheckSub(T.Array, T.Object); 1181 CheckSub(T.Array, T.Object);
1052 CheckSub(T.Function, T.Object); 1182 CheckSub(T.Function, T.Object);
1053 CheckSub(T.Proxy, T.Receiver); 1183 CheckSub(T.Proxy, T.Receiver);
1054 CheckUnordered(T.Object, T.Proxy); 1184 CheckUnordered(T.Object, T.Proxy);
1055 CheckUnordered(T.Array, T.Function); 1185 CheckUnordered(T.Array, T.Function);
1056 1186
1057 // Structural types 1187
1188 // Subtyping between concrete structural types
1189
1058 CheckSub(T.ObjectClass, T.Object); 1190 CheckSub(T.ObjectClass, T.Object);
1059 CheckSub(T.ArrayClass, T.Object); 1191 CheckSub(T.ArrayClass, T.Object);
1060 CheckSub(T.ArrayClass, T.Array); 1192 CheckSub(T.ArrayClass, T.Array);
1061 CheckSub(T.UninitializedClass, T.Internal); 1193 CheckSub(T.UninitializedClass, T.Internal);
1062 CheckUnordered(T.ObjectClass, T.ArrayClass); 1194 CheckUnordered(T.ObjectClass, T.ArrayClass);
1063 CheckUnordered(T.UninitializedClass, T.Null); 1195 CheckUnordered(T.UninitializedClass, T.Null);
1064 CheckUnordered(T.UninitializedClass, T.Undefined); 1196 CheckUnordered(T.UninitializedClass, T.Undefined);
1065 1197
1066 CheckSub(T.SmiConstant, T.SignedSmall); 1198 CheckSub(T.SmiConstant, T.SignedSmall);
1067 CheckSub(T.SmiConstant, T.Signed32); 1199 CheckSub(T.SmiConstant, T.Signed32);
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
1436 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { 1568 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) {
1437 TypeHandle type1 = *it1; 1569 TypeHandle type1 = *it1;
1438 TypeHandle type2 = *it2; 1570 TypeHandle type2 = *it2;
1439 TypeHandle union12 = T.Union(type1, type2); 1571 TypeHandle union12 = T.Union(type1, type2);
1440 TypeHandle union21 = T.Union(type2, type1); 1572 TypeHandle union21 = T.Union(type2, type1);
1441 CheckEqual(union12, union21); 1573 CheckEqual(union12, union21);
1442 } 1574 }
1443 } 1575 }
1444 1576
1445 // Associativity: Union(T1, Union(T2, T3)) = Union(Union(T1, T2), T3) 1577 // Associativity: Union(T1, Union(T2, T3)) = Union(Union(T1, T2), T3)
1446 // This does NOT hold! 1578 // This does NOT hold! For example:
1579 // (Unsigned32 \/ Range(0,5)) \/ Range(-5,0) = Unsigned32 \/ Range(-5,0)
1580 // Unsigned32 \/ (Range(0,5) \/ Range(-5,0)) = Unsigned32 \/ Range(-5,5)
1447 /* 1581 /*
1448 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { 1582 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) {
1449 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { 1583 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) {
1450 for (TypeIterator it3 = T.types.begin(); it3 != T.types.end(); ++it3) { 1584 for (TypeIterator it3 = T.types.begin(); it3 != T.types.end(); ++it3) {
1451 TypeHandle type1 = *it1; 1585 TypeHandle type1 = *it1;
1452 TypeHandle type2 = *it2; 1586 TypeHandle type2 = *it2;
1453 TypeHandle type3 = *it3; 1587 TypeHandle type3 = *it3;
1454 TypeHandle union12 = T.Union(type1, type2); 1588 TypeHandle union12 = T.Union(type1, type2);
1455 TypeHandle union23 = T.Union(type2, type3); 1589 TypeHandle union23 = T.Union(type2, type3);
1456 TypeHandle union1_23 = T.Union(type1, union23); 1590 TypeHandle union1_23 = T.Union(type1, union23);
(...skipping 19 matching lines...) Expand all
1476 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { 1610 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) {
1477 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { 1611 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) {
1478 TypeHandle type1 = *it1; 1612 TypeHandle type1 = *it1;
1479 TypeHandle type2 = *it2; 1613 TypeHandle type2 = *it2;
1480 TypeHandle union12 = T.Union(type1, type2); 1614 TypeHandle union12 = T.Union(type1, type2);
1481 if (type1->Is(type2)) CheckEqual(union12, type2); 1615 if (type1->Is(type2)) CheckEqual(union12, type2);
1482 } 1616 }
1483 } 1617 }
1484 1618
1485 // Monotonicity: T1->Is(T2) implies Union(T1, T3)->Is(Union(T2, T3)) 1619 // Monotonicity: T1->Is(T2) implies Union(T1, T3)->Is(Union(T2, T3))
1486 // This does NOT hold. 1620 // This does NOT hold. For example:
1621 // Range(-5,-1) <= Signed32
1622 // Range(-5,-1) \/ Range(1,5) = Range(-5,5) </= Signed32 \/ Range(1,5)
1487 /* 1623 /*
1488 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { 1624 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) {
1489 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { 1625 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) {
1490 for (TypeIterator it3 = T.types.begin(); it3 != T.types.end(); ++it3) { 1626 for (TypeIterator it3 = T.types.begin(); it3 != T.types.end(); ++it3) {
1491 TypeHandle type1 = *it1; 1627 TypeHandle type1 = *it1;
1492 TypeHandle type2 = *it2; 1628 TypeHandle type2 = *it2;
1493 TypeHandle type3 = *it3; 1629 TypeHandle type3 = *it3;
1494 TypeHandle union13 = T.Union(type1, type3); 1630 TypeHandle union13 = T.Union(type1, type3);
1495 TypeHandle union23 = T.Union(type2, type3); 1631 TypeHandle union23 = T.Union(type2, type3);
1496 CHECK(!type1->Is(type2) || union13->Is(union23)); 1632 CHECK(!type1->Is(type2) || union13->Is(union23));
1497 } 1633 }
1498 } 1634 }
1499 } 1635 }
1500 */ 1636 */
1501 } 1637 }
1502 1638
1503 void Union2() { 1639 void Union2() {
1504 // Monotonicity: T1->Is(T3) and T2->Is(T3) implies Union(T1, T2)->Is(T3) 1640 // Monotonicity: T1->Is(T3) and T2->Is(T3) implies Union(T1, T2)->Is(T3)
1505 // This does NOT hold. TODO(neis): Could fix this by splitting 1641 // This does NOT hold. For example:
1506 // OtherNumber into a negative and a positive part. 1642 // Range(-2^33, -2^33) <= OtherNumber
1643 // Range(2^33, 2^33) <= OtherNumber
1644 // Range(-2^33, 2^33) </= OtherNumber
1507 /* 1645 /*
1508 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { 1646 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) {
1509 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { 1647 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) {
1510 for (TypeIterator it3 = T.types.begin(); it3 != T.types.end(); ++it3) { 1648 for (TypeIterator it3 = T.types.begin(); it3 != T.types.end(); ++it3) {
1511 TypeHandle type1 = *it1; 1649 TypeHandle type1 = *it1;
1512 TypeHandle type2 = *it2; 1650 TypeHandle type2 = *it2;
1513 TypeHandle type3 = *it3; 1651 TypeHandle type3 = *it3;
1514 TypeHandle union12 = T.Union(type1, type2); 1652 TypeHandle union12 = T.Union(type1, type2);
1515 CHECK(!(type1->Is(type3) && type2->Is(type3)) || union12->Is(type3)); 1653 CHECK(!(type1->Is(type3) && type2->Is(type3)) || union12->Is(type3));
1516 } 1654 }
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
1678 TypeHandle type1 = *it1; 1816 TypeHandle type1 = *it1;
1679 TypeHandle type2 = *it2; 1817 TypeHandle type2 = *it2;
1680 TypeHandle intersect12 = T.Intersect(type1, type2); 1818 TypeHandle intersect12 = T.Intersect(type1, type2);
1681 TypeHandle intersect21 = T.Intersect(type2, type1); 1819 TypeHandle intersect21 = T.Intersect(type2, type1);
1682 CheckEqual(intersect12, intersect21); 1820 CheckEqual(intersect12, intersect21);
1683 } 1821 }
1684 } 1822 }
1685 1823
1686 // Associativity: 1824 // Associativity:
1687 // Intersect(T1, Intersect(T2, T3)) = Intersect(Intersect(T1, T2), T3) 1825 // Intersect(T1, Intersect(T2, T3)) = Intersect(Intersect(T1, T2), T3)
1688 // This does NOT hold. 1826 // This does NOT hold. For example:
1827 // (Class(..stringy1..) /\ Class(..stringy2..)) /\ Constant(..string..) =
1828 // None
1829 // Class(..stringy1..) /\ (Class(..stringy2..) /\ Constant(..string..)) =
1830 // Constant(..string..)
1689 /* 1831 /*
1690 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { 1832 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) {
1691 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { 1833 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) {
1692 for (TypeIterator it3 = T.types.begin(); it3 != T.types.end(); ++it3) { 1834 for (TypeIterator it3 = T.types.begin(); it3 != T.types.end(); ++it3) {
1693 TypeHandle type1 = *it1; 1835 TypeHandle type1 = *it1;
1694 TypeHandle type2 = *it2; 1836 TypeHandle type2 = *it2;
1695 TypeHandle type3 = *it3; 1837 TypeHandle type3 = *it3;
1696 TypeHandle intersect12 = T.Intersect(type1, type2); 1838 TypeHandle intersect12 = T.Intersect(type1, type2);
1697 TypeHandle intersect23 = T.Intersect(type2, type3); 1839 TypeHandle intersect23 = T.Intersect(type2, type3);
1698 TypeHandle intersect1_23 = T.Intersect(type1, intersect23); 1840 TypeHandle intersect1_23 = T.Intersect(type1, intersect23);
1699 TypeHandle intersect12_3 = T.Intersect(intersect12, type3); 1841 TypeHandle intersect12_3 = T.Intersect(intersect12, type3);
1700 CheckEqual(intersect1_23, intersect12_3); 1842 CheckEqual(intersect1_23, intersect12_3);
1701 } 1843 }
1702 } 1844 }
1703 } 1845 }
1704 */ 1846 */
1705 1847
1706 // Join: Intersect(T1, T2)->Is(T1) and Intersect(T1, T2)->Is(T2) 1848 // Join: Intersect(T1, T2)->Is(T1) and Intersect(T1, T2)->Is(T2)
1707 // This does NOT hold. Not even the disjunction. 1849 // This does NOT hold. For example:
1850 // Class(..stringy..) /\ Constant(..string..) = Constant(..string..)
1851 // Currently, not even the disjunction holds:
1852 // Class(Internal/TaggedPtr) /\ (Any/Untagged \/ Context(..)) =
1853 // Class(Internal/TaggedPtr) \/ Context(..)
1708 /* 1854 /*
1709 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { 1855 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) {
1710 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { 1856 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) {
1711 TypeHandle type1 = *it1; 1857 TypeHandle type1 = *it1;
1712 TypeHandle type2 = *it2; 1858 TypeHandle type2 = *it2;
1713 TypeHandle intersect12 = T.Intersect(type1, type2); 1859 TypeHandle intersect12 = T.Intersect(type1, type2);
1714 CHECK(intersect12->Is(type1)); 1860 CHECK(intersect12->Is(type1));
1715 CHECK(intersect12->Is(type2)); 1861 CHECK(intersect12->Is(type2));
1716 } 1862 }
1717 } 1863 }
1718 */ 1864 */
1719 1865
1720 // Lower Boundedness: T1->Is(T2) implies Intersect(T1, T2) = T1 1866 // Lower Boundedness: T1->Is(T2) implies Intersect(T1, T2) = T1
1721 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { 1867 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) {
1722 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { 1868 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) {
1723 TypeHandle type1 = *it1; 1869 TypeHandle type1 = *it1;
1724 TypeHandle type2 = *it2; 1870 TypeHandle type2 = *it2;
1725 TypeHandle intersect12 = T.Intersect(type1, type2); 1871 TypeHandle intersect12 = T.Intersect(type1, type2);
1726 if (type1->Is(type2)) CheckEqual(intersect12, type1); 1872 if (type1->Is(type2)) CheckEqual(intersect12, type1);
1727 } 1873 }
1728 } 1874 }
1729 1875
1730 // Monotonicity: T1->Is(T2) implies Intersect(T1, T3)->Is(Intersect(T2, T3)) 1876 // Monotonicity: T1->Is(T2) implies Intersect(T1, T3)->Is(Intersect(T2, T3))
1731 // This does NOT hold. 1877 // This does NOT hold. For example:
1878 // Class(OtherObject/TaggedPtr) <= Any/TaggedPtr
1879 // Class(OtherObject/TaggedPtr) /\ Any/UntaggedInt1 = Class(..)
1880 // Any/TaggedPtr /\ Any/UntaggedInt1 = None
1732 /* 1881 /*
1733 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { 1882 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) {
1734 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { 1883 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) {
1735 for (TypeIterator it3 = T.types.begin(); it3 != T.types.end(); ++it3) { 1884 for (TypeIterator it3 = T.types.begin(); it3 != T.types.end(); ++it3) {
1736 TypeHandle type1 = *it1; 1885 TypeHandle type1 = *it1;
1737 TypeHandle type2 = *it2; 1886 TypeHandle type2 = *it2;
1738 TypeHandle type3 = *it3; 1887 TypeHandle type3 = *it3;
1739 TypeHandle intersect13 = T.Intersect(type1, type3); 1888 TypeHandle intersect13 = T.Intersect(type1, type3);
1740 TypeHandle intersect23 = T.Intersect(type2, type3); 1889 TypeHandle intersect23 = T.Intersect(type2, type3);
1741 CHECK(!type1->Is(type2) || intersect13->Is(intersect23)); 1890 CHECK(!type1->Is(type2) || intersect13->Is(intersect23));
1742 } 1891 }
1743 } 1892 }
1744 } 1893 }
1745 */ 1894 */
1746 1895
1747 // Monotonicity: T1->Is(T3) or T2->Is(T3) implies Intersect(T1, T2)->Is(T3) 1896 // Monotonicity: T1->Is(T3) or T2->Is(T3) implies Intersect(T1, T2)->Is(T3)
1748 // This does NOT hold. 1897 // This does NOT hold. For example:
1898 // Class(..stringy..) <= Class(..stringy..)
1899 // Class(..stringy..) /\ Constant(..string..) = Constant(..string..)
1900 // Constant(..string..) </= Class(..stringy..)
1749 /* 1901 /*
1750 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { 1902 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) {
1751 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { 1903 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) {
1752 for (TypeIterator it3 = T.types.begin(); it3 != T.types.end(); ++it3) { 1904 for (TypeIterator it3 = T.types.begin(); it3 != T.types.end(); ++it3) {
1753 TypeHandle type1 = *it1; 1905 TypeHandle type1 = *it1;
1754 TypeHandle type2 = *it2; 1906 TypeHandle type2 = *it2;
1755 TypeHandle type3 = *it3; 1907 TypeHandle type3 = *it3;
1756 TypeHandle intersect12 = T.Intersect(type1, type2); 1908 TypeHandle intersect12 = T.Intersect(type1, type2);
1757 CHECK(!(type1->Is(type3) || type2->Is(type3)) || 1909 CHECK(!(type1->Is(type3) || type2->Is(type3)) ||
1758 intersect12->Is(type3)); 1910 intersect12->Is(type3));
1759 } 1911 }
1760 } 1912 }
1761 } 1913 }
1762 */ 1914 */
1763 1915
1764 // Monotonicity: T1->Is(T2) and T1->Is(T3) implies T1->Is(Intersect(T2, T3)) 1916 // Monotonicity: T1->Is(T2) and T1->Is(T3) implies T1->Is(Intersect(T2, T3))
1765 // This does NOT hold.
1766 /*
1767 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { 1917 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) {
1768 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { 1918 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) {
1769 for (TypeIterator it3 = T.types.begin(); it3 != T.types.end(); ++it3) { 1919 for (TypeIterator it3 = T.types.begin(); it3 != T.types.end(); ++it3) {
1770 TypeHandle type1 = *it1; 1920 TypeHandle type1 = *it1;
1771 TypeHandle type2 = *it2; 1921 TypeHandle type2 = *it2;
1772 TypeHandle type3 = *it3; 1922 TypeHandle type3 = *it3;
1773 TypeHandle intersect23 = T.Intersect(type2, type3); 1923 TypeHandle intersect23 = T.Intersect(type2, type3);
1774 CHECK(!(type1->Is(type2) && type1->Is(type3)) || 1924 CHECK(!(type1->Is(type2) && type1->Is(type3)) ||
1775 type1->Is(intersect23)); 1925 type1->Is(intersect23));
1776 } 1926 }
1777 } 1927 }
1778 } 1928 }
1779 */
1780 1929
1781 // Bitset-class 1930 // Bitset-class
1782 CheckEqual(T.Intersect(T.ObjectClass, T.Object), T.ObjectClass); 1931 CheckEqual(T.Intersect(T.ObjectClass, T.Object), T.ObjectClass);
1783 CheckEqual(T.Intersect(T.ObjectClass, T.Array), T.None); 1932 CheckEqual(T.Intersect(T.ObjectClass, T.Array), T.None);
1784 CheckEqual(T.Intersect(T.ObjectClass, T.Number), T.None); 1933 CheckEqual(T.Intersect(T.ObjectClass, T.Number), T.None);
1785 1934
1786 // Bitset-array 1935 // Bitset-array
1787 CheckEqual(T.Intersect(T.NumberArray, T.Object), T.NumberArray); 1936 CheckEqual(T.Intersect(T.NumberArray, T.Object), T.NumberArray);
1788 CheckEqual(T.Intersect(T.AnyArray, T.Function), T.None); 1937 CheckEqual(T.Intersect(T.AnyArray, T.Function), T.None);
1789 1938
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
1873 T.Union( 2022 T.Union(
1874 T.ObjectConstant1, 2023 T.ObjectConstant1,
1875 T.Union(T.ArrayConstant, T.ObjectConstant2))), 2024 T.Union(T.ArrayConstant, T.ObjectConstant2))),
1876 T.Union( 2025 T.Union(
1877 T.ArrayConstant, 2026 T.ArrayConstant,
1878 T.Union(T.ObjectConstant2, T.ObjectConstant1))); // !!! 2027 T.Union(T.ObjectConstant2, T.ObjectConstant1))); // !!!
1879 } 2028 }
1880 2029
1881 void Distributivity() { 2030 void Distributivity() {
1882 // Union(T1, Intersect(T2, T3)) = Intersect(Union(T1, T2), Union(T1, T3)) 2031 // Union(T1, Intersect(T2, T3)) = Intersect(Union(T1, T2), Union(T1, T3))
1883 // This does NOT hold. 2032 // This does NOT hold. For example:
2033 // Untagged \/ (Untagged /\ Class(../Tagged)) = Untagged \/ Class(../Tagged)
2034 // (Untagged \/ Untagged) /\ (Untagged \/ Class(../Tagged)) =
2035 // Untagged /\ (Untagged \/ Class(../Tagged)) = Untagged
2036 // because Untagged <= Untagged \/ Class(../Tagged)
1884 /* 2037 /*
1885 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { 2038 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) {
1886 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { 2039 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) {
1887 for (TypeIterator it3 = T.types.begin(); it3 != T.types.end(); ++it3) { 2040 for (TypeIterator it3 = T.types.begin(); it3 != T.types.end(); ++it3) {
1888 TypeHandle type1 = *it1; 2041 TypeHandle type1 = *it1;
1889 TypeHandle type2 = *it2; 2042 TypeHandle type2 = *it2;
1890 TypeHandle type3 = *it3; 2043 TypeHandle type3 = *it3;
1891 TypeHandle union12 = T.Union(type1, type2); 2044 TypeHandle union12 = T.Union(type1, type2);
1892 TypeHandle union13 = T.Union(type1, type3); 2045 TypeHandle union13 = T.Union(type1, type3);
1893 TypeHandle intersect23 = T.Intersect(type2, type3); 2046 TypeHandle intersect23 = T.Intersect(type2, type3);
1894 TypeHandle union1_23 = T.Union(type1, intersect23); 2047 TypeHandle union1_23 = T.Union(type1, intersect23);
1895 TypeHandle intersect12_13 = T.Intersect(union12, union13); 2048 TypeHandle intersect12_13 = T.Intersect(union12, union13);
1896 CHECK(Equal(union1_23, intersect12_13)); 2049 CHECK(Equal(union1_23, intersect12_13));
1897 } 2050 }
1898 } 2051 }
1899 } 2052 }
1900 */ 2053 */
1901 2054
1902 // Intersect(T1, Union(T2, T3)) = Union(Intersect(T1, T2), Intersect(T1,T3)) 2055 // Intersect(T1, Union(T2, T3)) = Union(Intersect(T1, T2), Intersect(T1,T3))
1903 // This does NOT hold. 2056 // This does NOT hold. For example:
2057 // Untagged /\ (Untagged \/ Class(../Tagged)) = Untagged
2058 // (Untagged /\ Untagged) \/ (Untagged /\ Class(../Tagged)) =
2059 // Untagged \/ Class(../Tagged)
1904 /* 2060 /*
1905 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { 2061 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) {
1906 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { 2062 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) {
1907 for (TypeIterator it3 = T.types.begin(); it3 != T.types.end(); ++it3) { 2063 for (TypeIterator it3 = T.types.begin(); it3 != T.types.end(); ++it3) {
1908 TypeHandle type1 = *it1; 2064 TypeHandle type1 = *it1;
1909 TypeHandle type2 = *it2; 2065 TypeHandle type2 = *it2;
1910 TypeHandle type3 = *it3; 2066 TypeHandle type3 = *it3;
1911 TypeHandle intersect12 = T.Intersect(type1, type2); 2067 TypeHandle intersect12 = T.Intersect(type1, type2);
1912 TypeHandle intersect13 = T.Intersect(type1, type3); 2068 TypeHandle intersect13 = T.Intersect(type1, type3);
1913 TypeHandle union23 = T.Union(type2, type3); 2069 TypeHandle union23 = T.Union(type2, type3);
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
2019 } 2175 }
2020 2176
2021 2177
2022 TEST(BitsetLub) { 2178 TEST(BitsetLub) {
2023 CcTest::InitializeVM(); 2179 CcTest::InitializeVM();
2024 ZoneTests().BitsetLub(); 2180 ZoneTests().BitsetLub();
2025 HeapTests().BitsetLub(); 2181 HeapTests().BitsetLub();
2026 } 2182 }
2027 2183
2028 2184
2029 TEST(Is) { 2185 TEST(Is1) {
2030 CcTest::InitializeVM(); 2186 CcTest::InitializeVM();
2031 ZoneTests().Is(); 2187 ZoneTests().Is1();
2032 HeapTests().Is(); 2188 HeapTests().Is1();
2033 } 2189 }
2034 2190
2035 2191
2192 TEST(Is2) {
2193 CcTest::InitializeVM();
2194 ZoneTests().Is2();
2195 HeapTests().Is2();
2196 }
2197
2198
2036 TEST(NowIs) { 2199 TEST(NowIs) {
2037 CcTest::InitializeVM(); 2200 CcTest::InitializeVM();
2038 ZoneTests().NowIs(); 2201 ZoneTests().NowIs();
2039 HeapTests().NowIs(); 2202 HeapTests().NowIs();
2040 } 2203 }
2041 2204
2042 2205
2043 TEST(Contains) { 2206 TEST(Contains) {
2044 CcTest::InitializeVM(); 2207 CcTest::InitializeVM();
2045 ZoneTests().Contains(); 2208 ZoneTests().Contains();
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
2091 } 2254 }
2092 2255
2093 2256
2094 TEST(Intersect) { 2257 TEST(Intersect) {
2095 CcTest::InitializeVM(); 2258 CcTest::InitializeVM();
2096 ZoneTests().Intersect(); 2259 ZoneTests().Intersect();
2097 HeapTests().Intersect(); 2260 HeapTests().Intersect();
2098 } 2261 }
2099 2262
2100 2263
2101 /*
2102 TEST(Distributivity) { 2264 TEST(Distributivity) {
2103 CcTest::InitializeVM(); 2265 CcTest::InitializeVM();
2104 ZoneTests().Distributivity(); 2266 ZoneTests().Distributivity();
2105 HeapTests().Distributivity(); 2267 HeapTests().Distributivity();
2106 } 2268 }
2107 */
2108 2269
2109 2270
2110 TEST(Convert) { 2271 TEST(Convert) {
2111 CcTest::InitializeVM(); 2272 CcTest::InitializeVM();
2112 ZoneTests().Convert<HeapType, Handle<HeapType>, Isolate, HeapRep>(); 2273 ZoneTests().Convert<HeapType, Handle<HeapType>, Isolate, HeapRep>();
2113 HeapTests().Convert<Type, Type*, Zone, ZoneRep>(); 2274 HeapTests().Convert<Type, Type*, Zone, ZoneRep>();
2114 } 2275 }
2115 2276
2116 2277
2117 TEST(HTypeFromType) { 2278 TEST(HTypeFromType) {
2118 CcTest::InitializeVM(); 2279 CcTest::InitializeVM();
2119 ZoneTests().HTypeFromType(); 2280 ZoneTests().HTypeFromType();
2120 HeapTests().HTypeFromType(); 2281 HeapTests().HTypeFromType();
2121 } 2282 }
OLDNEW
« no previous file with comments | « src/types.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698