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/compiler/types.h" | 7 #include "src/compiler/types.h" |
8 #include "src/crankshaft/hydrogen-types.h" | 8 #include "src/crankshaft/hydrogen-types.h" |
9 #include "src/factory.h" | 9 #include "src/factory.h" |
10 #include "src/heap/heap.h" | 10 #include "src/heap/heap.h" |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 Type* type2 = *it2; | 180 Type* type2 = *it2; |
181 if (this->IsBitset(type1) && this->IsBitset(type2)) { | 181 if (this->IsBitset(type1) && this->IsBitset(type2)) { |
182 Type* intersect12 = T.Intersect(type1, type2); | 182 Type* intersect12 = T.Intersect(type1, type2); |
183 bitset bits = this->AsBitset(type1) & this->AsBitset(type2); | 183 bitset bits = this->AsBitset(type1) & this->AsBitset(type2); |
184 CHECK(bits == this->AsBitset(intersect12)); | 184 CHECK(bits == this->AsBitset(intersect12)); |
185 } | 185 } |
186 } | 186 } |
187 } | 187 } |
188 } | 188 } |
189 | 189 |
| 190 void PointwiseRepresentation() { |
| 191 // Check we can decompose type into semantics and representation and |
| 192 // then compose it back to get an equivalent type. |
| 193 int counter = 0; |
| 194 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { |
| 195 counter++; |
| 196 Type* type1 = *it1; |
| 197 Type* representation = T.Representation(type1); |
| 198 Type* semantic = T.Semantic(type1); |
| 199 Type* composed = T.Union(representation, semantic); |
| 200 CHECK(type1->Equals(composed)); |
| 201 } |
| 202 |
| 203 // Pointwiseness of Union. |
| 204 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { |
| 205 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { |
| 206 Type* type1 = *it1; |
| 207 Type* type2 = *it2; |
| 208 Type* representation1 = T.Representation(type1); |
| 209 Type* semantic1 = T.Semantic(type1); |
| 210 Type* representation2 = T.Representation(type2); |
| 211 Type* semantic2 = T.Semantic(type2); |
| 212 Type* direct_union = T.Union(type1, type2); |
| 213 Type* representation_union = T.Union(representation1, representation2); |
| 214 Type* semantic_union = T.Union(semantic1, semantic2); |
| 215 Type* composed_union = T.Union(representation_union, semantic_union); |
| 216 CHECK(direct_union->Equals(composed_union)); |
| 217 } |
| 218 } |
| 219 |
| 220 // Pointwiseness of Intersect. |
| 221 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { |
| 222 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { |
| 223 Type* type1 = *it1; |
| 224 Type* type2 = *it2; |
| 225 Type* representation1 = T.Representation(type1); |
| 226 Type* semantic1 = T.Semantic(type1); |
| 227 Type* representation2 = T.Representation(type2); |
| 228 Type* semantic2 = T.Semantic(type2); |
| 229 Type* direct_intersection = T.Intersect(type1, type2); |
| 230 Type* representation_intersection = |
| 231 T.Intersect(representation1, representation2); |
| 232 Type* semantic_intersection = T.Intersect(semantic1, semantic2); |
| 233 Type* composed_intersection = |
| 234 T.Union(representation_intersection, semantic_intersection); |
| 235 CHECK(direct_intersection->Equals(composed_intersection)); |
| 236 } |
| 237 } |
| 238 |
| 239 // Pointwiseness of Is. |
| 240 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { |
| 241 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { |
| 242 Type* type1 = *it1; |
| 243 Type* type2 = *it2; |
| 244 Type* representation1 = T.Representation(type1); |
| 245 Type* semantic1 = T.Semantic(type1); |
| 246 Type* representation2 = T.Representation(type2); |
| 247 Type* semantic2 = T.Semantic(type2); |
| 248 bool representation_is = representation1->Is(representation2); |
| 249 bool semantic_is = semantic1->Is(semantic2); |
| 250 bool direct_is = type1->Is(type2); |
| 251 CHECK(direct_is == (semantic_is && representation_is)); |
| 252 } |
| 253 } |
| 254 } |
| 255 |
190 void Constant() { | 256 void Constant() { |
191 // Constructor | 257 // Constructor |
192 for (ValueIterator vt = T.values.begin(); vt != T.values.end(); ++vt) { | 258 for (ValueIterator vt = T.values.begin(); vt != T.values.end(); ++vt) { |
193 Handle<i::Object> value = *vt; | 259 Handle<i::Object> value = *vt; |
194 Type* type = T.Constant(value); | 260 Type* type = T.Constant(value); |
195 CHECK(type->IsConstant()); | 261 CHECK(type->IsConstant()); |
196 } | 262 } |
197 | 263 |
198 // Value attribute | 264 // Value attribute |
199 for (ValueIterator vt = T.values.begin(); vt != T.values.end(); ++vt) { | 265 for (ValueIterator vt = T.values.begin(); vt != T.values.end(); ++vt) { |
(...skipping 880 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1080 } | 1146 } |
1081 } | 1147 } |
1082 } | 1148 } |
1083 } | 1149 } |
1084 }; | 1150 }; |
1085 | 1151 |
1086 } // namespace | 1152 } // namespace |
1087 | 1153 |
1088 TEST(IsSomeType) { Tests().IsSomeType(); } | 1154 TEST(IsSomeType) { Tests().IsSomeType(); } |
1089 | 1155 |
| 1156 TEST(PointwiseRepresentation) { Tests().PointwiseRepresentation(); } |
| 1157 |
1090 TEST(BitsetType) { Tests().Bitset(); } | 1158 TEST(BitsetType) { Tests().Bitset(); } |
1091 | 1159 |
1092 TEST(ConstantType) { Tests().Constant(); } | 1160 TEST(ConstantType) { Tests().Constant(); } |
1093 | 1161 |
1094 TEST(RangeType) { Tests().Range(); } | 1162 TEST(RangeType) { Tests().Range(); } |
1095 | 1163 |
1096 TEST(Of) { Tests().Of(); } | 1164 TEST(Of) { Tests().Of(); } |
1097 | 1165 |
1098 TEST(MinMax) { Tests().MinMax(); } | 1166 TEST(MinMax) { Tests().MinMax(); } |
1099 | 1167 |
(...skipping 15 matching lines...) Expand all Loading... |
1115 | 1183 |
1116 TEST(Union3) { Tests().Union3(); } | 1184 TEST(Union3) { Tests().Union3(); } |
1117 | 1185 |
1118 TEST(Union4) { Tests().Union4(); } | 1186 TEST(Union4) { Tests().Union4(); } |
1119 | 1187 |
1120 TEST(Intersect) { Tests().Intersect(); } | 1188 TEST(Intersect) { Tests().Intersect(); } |
1121 | 1189 |
1122 TEST(Distributivity) { Tests().Distributivity(); } | 1190 TEST(Distributivity) { Tests().Distributivity(); } |
1123 | 1191 |
1124 TEST(GetRange) { Tests().GetRange(); } | 1192 TEST(GetRange) { Tests().GetRange(); } |
OLD | NEW |