| 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 | |
| 256 void Constant() { | 190 void Constant() { |
| 257 // Constructor | 191 // Constructor |
| 258 for (ValueIterator vt = T.values.begin(); vt != T.values.end(); ++vt) { | 192 for (ValueIterator vt = T.values.begin(); vt != T.values.end(); ++vt) { |
| 259 Handle<i::Object> value = *vt; | 193 Handle<i::Object> value = *vt; |
| 260 Type* type = T.Constant(value); | 194 Type* type = T.Constant(value); |
| 261 CHECK(type->IsConstant()); | 195 CHECK(type->IsConstant()); |
| 262 } | 196 } |
| 263 | 197 |
| 264 // Value attribute | 198 // Value attribute |
| 265 for (ValueIterator vt = T.values.begin(); vt != T.values.end(); ++vt) { | 199 for (ValueIterator vt = T.values.begin(); vt != T.values.end(); ++vt) { |
| (...skipping 880 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1146 } | 1080 } |
| 1147 } | 1081 } |
| 1148 } | 1082 } |
| 1149 } | 1083 } |
| 1150 }; | 1084 }; |
| 1151 | 1085 |
| 1152 } // namespace | 1086 } // namespace |
| 1153 | 1087 |
| 1154 TEST(IsSomeType) { Tests().IsSomeType(); } | 1088 TEST(IsSomeType) { Tests().IsSomeType(); } |
| 1155 | 1089 |
| 1156 TEST(PointwiseRepresentation) { Tests().PointwiseRepresentation(); } | |
| 1157 | |
| 1158 TEST(BitsetType) { Tests().Bitset(); } | 1090 TEST(BitsetType) { Tests().Bitset(); } |
| 1159 | 1091 |
| 1160 TEST(ConstantType) { Tests().Constant(); } | 1092 TEST(ConstantType) { Tests().Constant(); } |
| 1161 | 1093 |
| 1162 TEST(RangeType) { Tests().Range(); } | 1094 TEST(RangeType) { Tests().Range(); } |
| 1163 | 1095 |
| 1164 TEST(Of) { Tests().Of(); } | 1096 TEST(Of) { Tests().Of(); } |
| 1165 | 1097 |
| 1166 TEST(MinMax) { Tests().MinMax(); } | 1098 TEST(MinMax) { Tests().MinMax(); } |
| 1167 | 1099 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1183 | 1115 |
| 1184 TEST(Union3) { Tests().Union3(); } | 1116 TEST(Union3) { Tests().Union3(); } |
| 1185 | 1117 |
| 1186 TEST(Union4) { Tests().Union4(); } | 1118 TEST(Union4) { Tests().Union4(); } |
| 1187 | 1119 |
| 1188 TEST(Intersect) { Tests().Intersect(); } | 1120 TEST(Intersect) { Tests().Intersect(); } |
| 1189 | 1121 |
| 1190 TEST(Distributivity) { Tests().Distributivity(); } | 1122 TEST(Distributivity) { Tests().Distributivity(); } |
| 1191 | 1123 |
| 1192 TEST(GetRange) { Tests().GetRange(); } | 1124 TEST(GetRange) { Tests().GetRange(); } |
| OLD | NEW |