OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 25 matching lines...) Expand all Loading... |
36 // Testing auxiliaries (breaking the Type abstraction). | 36 // Testing auxiliaries (breaking the Type abstraction). |
37 struct ZoneRep { | 37 struct ZoneRep { |
38 typedef void* Struct; | 38 typedef void* Struct; |
39 | 39 |
40 static bool IsStruct(Type* t, int tag) { | 40 static bool IsStruct(Type* t, int tag) { |
41 return !IsBitset(t) && reinterpret_cast<intptr_t>(AsStruct(t)[0]) == tag; | 41 return !IsBitset(t) && reinterpret_cast<intptr_t>(AsStruct(t)[0]) == tag; |
42 } | 42 } |
43 static bool IsBitset(Type* t) { return reinterpret_cast<intptr_t>(t) & 1; } | 43 static bool IsBitset(Type* t) { return reinterpret_cast<intptr_t>(t) & 1; } |
44 static bool IsClass(Type* t) { return IsStruct(t, 0); } | 44 static bool IsClass(Type* t) { return IsStruct(t, 0); } |
45 static bool IsConstant(Type* t) { return IsStruct(t, 1); } | 45 static bool IsConstant(Type* t) { return IsStruct(t, 1); } |
46 static bool IsArray(Type* t) { return IsStruct(t, 2); } | 46 static bool IsUnion(Type* t) { return IsStruct(t, 2); } |
47 static bool IsFunction(Type* t) { return IsStruct(t, 3); } | |
48 static bool IsUnion(Type* t) { return IsStruct(t, 4); } | |
49 | 47 |
50 static Struct* AsStruct(Type* t) { | 48 static Struct* AsStruct(Type* t) { |
51 return reinterpret_cast<Struct*>(t); | 49 return reinterpret_cast<Struct*>(t); |
52 } | 50 } |
53 static int AsBitset(Type* t) { | 51 static int AsBitset(Type* t) { |
54 return static_cast<int>(reinterpret_cast<intptr_t>(t) >> 1); | 52 return static_cast<int>(reinterpret_cast<intptr_t>(t) >> 1); |
55 } | 53 } |
56 static Map* AsClass(Type* t) { | 54 static Map* AsClass(Type* t) { |
57 return *static_cast<Map**>(AsStruct(t)[3]); | 55 return *static_cast<Map**>(AsStruct(t)[3]); |
58 } | 56 } |
(...skipping 13 matching lines...) Expand all Loading... |
72 | 70 |
73 struct HeapRep { | 71 struct HeapRep { |
74 typedef FixedArray Struct; | 72 typedef FixedArray Struct; |
75 | 73 |
76 static bool IsStruct(Handle<HeapType> t, int tag) { | 74 static bool IsStruct(Handle<HeapType> t, int tag) { |
77 return t->IsFixedArray() && Smi::cast(AsStruct(t)->get(0))->value() == tag; | 75 return t->IsFixedArray() && Smi::cast(AsStruct(t)->get(0))->value() == tag; |
78 } | 76 } |
79 static bool IsBitset(Handle<HeapType> t) { return t->IsSmi(); } | 77 static bool IsBitset(Handle<HeapType> t) { return t->IsSmi(); } |
80 static bool IsClass(Handle<HeapType> t) { return t->IsMap(); } | 78 static bool IsClass(Handle<HeapType> t) { return t->IsMap(); } |
81 static bool IsConstant(Handle<HeapType> t) { return t->IsBox(); } | 79 static bool IsConstant(Handle<HeapType> t) { return t->IsBox(); } |
82 static bool IsArray(Handle<HeapType> t) { return IsStruct(t, 2); } | 80 static bool IsUnion(Handle<HeapType> t) { return IsStruct(t, 2); } |
83 static bool IsFunction(Handle<HeapType> t) { return IsStruct(t, 3); } | |
84 static bool IsUnion(Handle<HeapType> t) { return IsStruct(t, 4); } | |
85 | 81 |
86 static Struct* AsStruct(Handle<HeapType> t) { return FixedArray::cast(*t); } | 82 static Struct* AsStruct(Handle<HeapType> t) { return FixedArray::cast(*t); } |
87 static int AsBitset(Handle<HeapType> t) { return Smi::cast(*t)->value(); } | 83 static int AsBitset(Handle<HeapType> t) { return Smi::cast(*t)->value(); } |
88 static Map* AsClass(Handle<HeapType> t) { return Map::cast(*t); } | 84 static Map* AsClass(Handle<HeapType> t) { return Map::cast(*t); } |
89 static Object* AsConstant(Handle<HeapType> t) { | 85 static Object* AsConstant(Handle<HeapType> t) { |
90 return Box::cast(*t)->value(); | 86 return Box::cast(*t)->value(); |
91 } | 87 } |
92 static Struct* AsUnion(Handle<HeapType> t) { return AsStruct(t); } | 88 static Struct* AsUnion(Handle<HeapType> t) { return AsStruct(t); } |
93 static int Length(Struct* structured) { return structured->length() - 1; } | 89 static int Length(Struct* structured) { return structured->length() - 1; } |
94 | 90 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 values.push_back(smi); | 132 values.push_back(smi); |
137 values.push_back(signed32); | 133 values.push_back(signed32); |
138 values.push_back(object1); | 134 values.push_back(object1); |
139 values.push_back(object2); | 135 values.push_back(object2); |
140 values.push_back(array); | 136 values.push_back(array); |
141 values.push_back(uninitialized); | 137 values.push_back(uninitialized); |
142 for (ValueVector::iterator it = values.begin(); it != values.end(); ++it) { | 138 for (ValueVector::iterator it = values.begin(); it != values.end(); ++it) { |
143 types.push_back(Type::Constant(*it, region)); | 139 types.push_back(Type::Constant(*it, region)); |
144 } | 140 } |
145 | 141 |
146 FloatArray = Type::Array(Float, region); | |
147 StringArray = Type::Array(String, region); | |
148 AnyArray = Type::Array(Any, region); | |
149 | |
150 SignedFunction1 = Type::Function(SignedSmall, SignedSmall, region); | |
151 NumberFunction1 = Type::Function(Number, Number, region); | |
152 NumberFunction2 = Type::Function(Number, Number, Number, region); | |
153 MethodFunction = Type::Function(String, Object, 0, region); | |
154 | |
155 for (int i = 0; i < 50; ++i) { | 142 for (int i = 0; i < 50; ++i) { |
156 types.push_back(Fuzz()); | 143 types.push_back(Fuzz()); |
157 } | 144 } |
158 } | 145 } |
159 | 146 |
160 Handle<i::Map> object_map; | |
161 Handle<i::Map> array_map; | |
162 Handle<i::Map> uninitialized_map; | |
163 | |
164 Handle<i::Smi> smi; | |
165 Handle<i::HeapNumber> signed32; | |
166 Handle<i::JSObject> object1; | |
167 Handle<i::JSObject> object2; | |
168 Handle<i::JSArray> array; | |
169 Handle<i::Oddball> uninitialized; | |
170 | |
171 #define DECLARE_TYPE(name, value) TypeHandle name; | 147 #define DECLARE_TYPE(name, value) TypeHandle name; |
172 BITSET_TYPE_LIST(DECLARE_TYPE) | 148 BITSET_TYPE_LIST(DECLARE_TYPE) |
173 #undef DECLARE_TYPE | 149 #undef DECLARE_TYPE |
174 | 150 |
175 TypeHandle ObjectClass; | 151 TypeHandle ObjectClass; |
176 TypeHandle ArrayClass; | 152 TypeHandle ArrayClass; |
177 TypeHandle UninitializedClass; | 153 TypeHandle UninitializedClass; |
178 | 154 |
179 TypeHandle SmiConstant; | 155 TypeHandle SmiConstant; |
180 TypeHandle Signed32Constant; | 156 TypeHandle Signed32Constant; |
181 TypeHandle ObjectConstant1; | 157 TypeHandle ObjectConstant1; |
182 TypeHandle ObjectConstant2; | 158 TypeHandle ObjectConstant2; |
183 TypeHandle ArrayConstant; | 159 TypeHandle ArrayConstant; |
184 TypeHandle UninitializedConstant; | 160 TypeHandle UninitializedConstant; |
185 | 161 |
186 TypeHandle FloatArray; | 162 Handle<i::Map> object_map; |
187 TypeHandle StringArray; | 163 Handle<i::Map> array_map; |
188 TypeHandle AnyArray; | 164 Handle<i::Map> uninitialized_map; |
189 | 165 |
190 TypeHandle SignedFunction1; | 166 Handle<i::Smi> smi; |
191 TypeHandle NumberFunction1; | 167 Handle<i::HeapNumber> signed32; |
192 TypeHandle NumberFunction2; | 168 Handle<i::JSObject> object1; |
193 TypeHandle MethodFunction; | 169 Handle<i::JSObject> object2; |
| 170 Handle<i::JSArray> array; |
| 171 Handle<i::Oddball> uninitialized; |
194 | 172 |
195 typedef std::vector<TypeHandle> TypeVector; | 173 typedef std::vector<TypeHandle> TypeVector; |
196 typedef std::vector<Handle<i::Map> > MapVector; | 174 typedef std::vector<Handle<i::Map> > MapVector; |
197 typedef std::vector<Handle<i::Object> > ValueVector; | 175 typedef std::vector<Handle<i::Object> > ValueVector; |
198 TypeVector types; | 176 TypeVector types; |
199 MapVector maps; | 177 MapVector maps; |
200 ValueVector values; | 178 ValueVector values; |
201 | 179 |
202 TypeHandle Of(Handle<i::Object> value) { | 180 TypeHandle Of(Handle<i::Object> value) { |
203 return Type::Of(value, region_); | 181 return Type::Of(value, region_); |
204 } | 182 } |
205 | 183 |
206 TypeHandle NowOf(Handle<i::Object> value) { | 184 TypeHandle NowOf(Handle<i::Object> value) { |
207 return Type::NowOf(value, region_); | 185 return Type::NowOf(value, region_); |
208 } | 186 } |
209 | 187 |
210 TypeHandle Constant(Handle<i::Object> value) { | 188 TypeHandle Constant(Handle<i::Object> value) { |
211 return Type::Constant(value, region_); | 189 return Type::Constant(value, region_); |
212 } | 190 } |
213 | 191 |
214 TypeHandle Class(Handle<i::Map> map) { | 192 TypeHandle Class(Handle<i::Map> map) { |
215 return Type::Class(map, region_); | 193 return Type::Class(map, region_); |
216 } | 194 } |
217 | 195 |
218 TypeHandle Array1(TypeHandle element) { | |
219 return Type::Array(element, region_); | |
220 } | |
221 | |
222 TypeHandle Function0(TypeHandle result, TypeHandle receiver) { | |
223 return Type::Function(result, receiver, 0, region_); | |
224 } | |
225 | |
226 TypeHandle Function1(TypeHandle result, TypeHandle receiver, TypeHandle arg) { | |
227 TypeHandle type = Type::Function(result, receiver, 1, region_); | |
228 type->AsFunction()->InitParameter(0, arg); | |
229 return type; | |
230 } | |
231 | |
232 TypeHandle Function2(TypeHandle result, TypeHandle arg1, TypeHandle arg2) { | |
233 return Type::Function(result, arg1, arg2, region_); | |
234 } | |
235 | |
236 TypeHandle Union(TypeHandle t1, TypeHandle t2) { | 196 TypeHandle Union(TypeHandle t1, TypeHandle t2) { |
237 return Type::Union(t1, t2, region_); | 197 return Type::Union(t1, t2, region_); |
238 } | 198 } |
239 TypeHandle Intersect(TypeHandle t1, TypeHandle t2) { | 199 TypeHandle Intersect(TypeHandle t1, TypeHandle t2) { |
240 return Type::Intersect(t1, t2, region_); | 200 return Type::Intersect(t1, t2, region_); |
241 } | 201 } |
242 | 202 |
243 template<class Type2, class TypeHandle2> | 203 template<class Type2, class TypeHandle2> |
244 TypeHandle Convert(TypeHandle2 t) { | 204 TypeHandle Convert(TypeHandle2 t) { |
245 return Type::template Convert<Type2>(t, region_); | 205 return Type::template Convert<Type2>(t, region_); |
246 } | 206 } |
247 | 207 |
248 TypeHandle Random() { | |
249 return types[rng_.NextInt(static_cast<int>(types.size()))]; | |
250 } | |
251 | |
252 TypeHandle Fuzz(int depth = 5) { | 208 TypeHandle Fuzz(int depth = 5) { |
253 switch (rng_.NextInt(depth == 0 ? 3 : 20)) { | 209 switch (rng_.NextInt(depth == 0 ? 3 : 20)) { |
254 case 0: { // bitset | 210 case 0: { // bitset |
255 int n = 0 | 211 int n = 0 |
256 #define COUNT_BITSET_TYPES(type, value) + 1 | 212 #define COUNT_BITSET_TYPES(type, value) + 1 |
257 BITSET_TYPE_LIST(COUNT_BITSET_TYPES) | 213 BITSET_TYPE_LIST(COUNT_BITSET_TYPES) |
258 #undef COUNT_BITSET_TYPES | 214 #undef COUNT_BITSET_TYPES |
259 ; | 215 ; |
260 int i = rng_.NextInt(n); | 216 int i = rng_.NextInt(n); |
261 #define PICK_BITSET_TYPE(type, value) \ | 217 #define PICK_BITSET_TYPE(type, value) \ |
262 if (i-- == 0) return Type::type(region_); | 218 if (i-- == 0) return Type::type(region_); |
263 BITSET_TYPE_LIST(PICK_BITSET_TYPE) | 219 BITSET_TYPE_LIST(PICK_BITSET_TYPE) |
264 #undef PICK_BITSET_TYPE | 220 #undef PICK_BITSET_TYPE |
265 UNREACHABLE(); | 221 UNREACHABLE(); |
266 } | 222 } |
267 case 1: { // class | 223 case 1: { // class |
268 int i = rng_.NextInt(static_cast<int>(maps.size())); | 224 int i = rng_.NextInt(static_cast<int>(maps.size())); |
269 return Type::Class(maps[i], region_); | 225 return Type::Class(maps[i], region_); |
270 } | 226 } |
271 case 2: { // constant | 227 case 2: { // constant |
272 int i = rng_.NextInt(static_cast<int>(values.size())); | 228 int i = rng_.NextInt(static_cast<int>(values.size())); |
273 return Type::Constant(values[i], region_); | 229 return Type::Constant(values[i], region_); |
274 } | 230 } |
275 case 3: // array | |
276 return Type::Array(Fuzz(depth / 2), region_); | |
277 case 4: | |
278 case 5: | |
279 case 6: { // function | |
280 TypeHandle type = Type::Function( | |
281 Fuzz(depth / 2), Fuzz(depth / 2), rand() % 3, region_); | |
282 for (int i = 0; i < type->AsFunction()->Arity(); ++i) { | |
283 type->AsFunction()->InitParameter(i, Fuzz(depth - 1)); | |
284 } | |
285 } | |
286 default: { // union | 231 default: { // union |
287 int n = rng_.NextInt(10); | 232 int n = rng_.NextInt(10); |
288 TypeHandle type = None; | 233 TypeHandle type = None; |
289 for (int i = 0; i < n; ++i) { | 234 for (int i = 0; i < n; ++i) { |
290 type = Type::Union(type, Fuzz(depth - 1), region_); | 235 type = Type::Union(type, Fuzz(depth - 1), region_); |
291 } | 236 } |
292 return type; | 237 return type; |
293 } | 238 } |
294 } | 239 } |
295 UNREACHABLE(); | 240 UNREACHABLE(); |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
454 for (MapIterator mt = T.maps.begin(); mt != T.maps.end(); ++mt) { | 399 for (MapIterator mt = T.maps.begin(); mt != T.maps.end(); ++mt) { |
455 Handle<i::Map> map = *mt; | 400 Handle<i::Map> map = *mt; |
456 TypeHandle type = T.Class(map); | 401 TypeHandle type = T.Class(map); |
457 CHECK(this->IsClass(type)); | 402 CHECK(this->IsClass(type)); |
458 } | 403 } |
459 | 404 |
460 // Map attribute | 405 // Map attribute |
461 for (MapIterator mt = T.maps.begin(); mt != T.maps.end(); ++mt) { | 406 for (MapIterator mt = T.maps.begin(); mt != T.maps.end(); ++mt) { |
462 Handle<i::Map> map = *mt; | 407 Handle<i::Map> map = *mt; |
463 TypeHandle type = T.Class(map); | 408 TypeHandle type = T.Class(map); |
464 CHECK(*map == *type->AsClass()->Map()); | 409 CHECK(*map == *type->AsClass()); |
465 } | 410 } |
466 | 411 |
467 // Functionality & Injectivity: Class(M1) = Class(M2) iff M1 = M2 | 412 // Functionality & Injectivity: Class(M1) = Class(M2) iff M1 = M2 |
468 for (MapIterator mt1 = T.maps.begin(); mt1 != T.maps.end(); ++mt1) { | 413 for (MapIterator mt1 = T.maps.begin(); mt1 != T.maps.end(); ++mt1) { |
469 for (MapIterator mt2 = T.maps.begin(); mt2 != T.maps.end(); ++mt2) { | 414 for (MapIterator mt2 = T.maps.begin(); mt2 != T.maps.end(); ++mt2) { |
470 Handle<i::Map> map1 = *mt1; | 415 Handle<i::Map> map1 = *mt1; |
471 Handle<i::Map> map2 = *mt2; | 416 Handle<i::Map> map2 = *mt2; |
472 TypeHandle type1 = T.Class(map1); | 417 TypeHandle type1 = T.Class(map1); |
473 TypeHandle type2 = T.Class(map2); | 418 TypeHandle type2 = T.Class(map2); |
474 CHECK(Equal(type1, type2) == (*map1 == *map2)); | 419 CHECK(Equal(type1, type2) == (*map1 == *map2)); |
475 } | 420 } |
476 } | 421 } |
477 } | 422 } |
478 | 423 |
479 void Constant() { | 424 void Constant() { |
480 // Constructor | 425 // Constructor |
481 for (ValueIterator vt = T.values.begin(); vt != T.values.end(); ++vt) { | 426 for (ValueIterator vt = T.values.begin(); vt != T.values.end(); ++vt) { |
482 Handle<i::Object> value = *vt; | 427 Handle<i::Object> value = *vt; |
483 TypeHandle type = T.Constant(value); | 428 TypeHandle type = T.Constant(value); |
484 CHECK(this->IsConstant(type)); | 429 CHECK(this->IsConstant(type)); |
485 } | 430 } |
486 | 431 |
487 // Value attribute | 432 // Value attribute |
488 for (ValueIterator vt = T.values.begin(); vt != T.values.end(); ++vt) { | 433 for (ValueIterator vt = T.values.begin(); vt != T.values.end(); ++vt) { |
489 Handle<i::Object> value = *vt; | 434 Handle<i::Object> value = *vt; |
490 TypeHandle type = T.Constant(value); | 435 TypeHandle type = T.Constant(value); |
491 CHECK(*value == *type->AsConstant()->Value()); | 436 CHECK(*value == *type->AsConstant()); |
492 } | 437 } |
493 | 438 |
494 // Functionality & Injectivity: Constant(V1) = Constant(V2) iff V1 = V2 | 439 // Functionality & Injectivity: Constant(V1) = Constant(v2) iff V1 = V2 |
495 for (ValueIterator vt1 = T.values.begin(); vt1 != T.values.end(); ++vt1) { | 440 for (ValueIterator vt1 = T.values.begin(); vt1 != T.values.end(); ++vt1) { |
496 for (ValueIterator vt2 = T.values.begin(); vt2 != T.values.end(); ++vt2) { | 441 for (ValueIterator vt2 = T.values.begin(); vt2 != T.values.end(); ++vt2) { |
497 Handle<i::Object> value1 = *vt1; | 442 Handle<i::Object> value1 = *vt1; |
498 Handle<i::Object> value2 = *vt2; | 443 Handle<i::Object> value2 = *vt2; |
499 TypeHandle type1 = T.Constant(value1); | 444 TypeHandle type1 = T.Constant(value1); |
500 TypeHandle type2 = T.Constant(value2); | 445 TypeHandle type2 = T.Constant(value2); |
501 CHECK(Equal(type1, type2) == (*value1 == *value2)); | 446 CHECK(Equal(type1, type2) == (*value1 == *value2)); |
502 } | 447 } |
503 } | 448 } |
504 } | 449 } |
505 | 450 |
506 void Array() { | |
507 // Constructor | |
508 for (int i = 0; i < 20; ++i) { | |
509 TypeHandle type = T.Random(); | |
510 TypeHandle array = T.Array1(type); | |
511 CHECK(this->IsArray(array)); | |
512 } | |
513 | |
514 // Attributes | |
515 for (int i = 0; i < 20; ++i) { | |
516 TypeHandle type = T.Random(); | |
517 TypeHandle array = T.Array1(type); | |
518 CheckEqual(type, array->AsArray()->Element()); | |
519 } | |
520 | |
521 // Functionality & Injectivity: Array(T1) = Array(T2) iff T1 = T2 | |
522 for (int i = 0; i < 20; ++i) { | |
523 for (int j = 0; j < 20; ++j) { | |
524 TypeHandle type1 = T.Random(); | |
525 TypeHandle type2 = T.Random(); | |
526 TypeHandle array1 = T.Array1(type1); | |
527 TypeHandle array2 = T.Array1(type2); | |
528 CHECK(Equal(array1, array2) == Equal(type1, type2)); | |
529 } | |
530 } | |
531 } | |
532 | |
533 void Function() { | |
534 // Constructors | |
535 for (int i = 0; i < 20; ++i) { | |
536 for (int j = 0; j < 20; ++j) { | |
537 for (int k = 0; k < 20; ++k) { | |
538 TypeHandle type1 = T.Random(); | |
539 TypeHandle type2 = T.Random(); | |
540 TypeHandle type3 = T.Random(); | |
541 TypeHandle function0 = T.Function0(type1, type2); | |
542 TypeHandle function1 = T.Function1(type1, type2, type3); | |
543 TypeHandle function2 = T.Function2(type1, type2, type3); | |
544 CHECK(function0->IsFunction()); | |
545 CHECK(function1->IsFunction()); | |
546 CHECK(function2->IsFunction()); | |
547 } | |
548 } | |
549 } | |
550 | |
551 // Attributes | |
552 for (int i = 0; i < 20; ++i) { | |
553 for (int j = 0; j < 20; ++j) { | |
554 for (int k = 0; k < 20; ++k) { | |
555 TypeHandle type1 = T.Random(); | |
556 TypeHandle type2 = T.Random(); | |
557 TypeHandle type3 = T.Random(); | |
558 TypeHandle function0 = T.Function0(type1, type2); | |
559 TypeHandle function1 = T.Function1(type1, type2, type3); | |
560 TypeHandle function2 = T.Function2(type1, type2, type3); | |
561 CHECK_EQ(0, function0->AsFunction()->Arity()); | |
562 CHECK_EQ(1, function1->AsFunction()->Arity()); | |
563 CHECK_EQ(2, function2->AsFunction()->Arity()); | |
564 CheckEqual(type1, function0->AsFunction()->Result()); | |
565 CheckEqual(type1, function1->AsFunction()->Result()); | |
566 CheckEqual(type1, function2->AsFunction()->Result()); | |
567 CheckEqual(type2, function0->AsFunction()->Receiver()); | |
568 CheckEqual(type2, function1->AsFunction()->Receiver()); | |
569 CheckEqual(T.Any, function2->AsFunction()->Receiver()); | |
570 CheckEqual(type3, function1->AsFunction()->Parameter(0)); | |
571 CheckEqual(type2, function2->AsFunction()->Parameter(0)); | |
572 CheckEqual(type3, function2->AsFunction()->Parameter(1)); | |
573 } | |
574 } | |
575 } | |
576 | |
577 // Functionality & Injectivity: Function(Ts1) = Function(Ts2) iff Ts1 = Ts2 | |
578 for (int i = 0; i < 20; ++i) { | |
579 for (int j = 0; j < 20; ++j) { | |
580 for (int k = 0; k < 20; ++k) { | |
581 TypeHandle type1 = T.Random(); | |
582 TypeHandle type2 = T.Random(); | |
583 TypeHandle type3 = T.Random(); | |
584 TypeHandle function01 = T.Function0(type1, type2); | |
585 TypeHandle function02 = T.Function0(type1, type3); | |
586 TypeHandle function03 = T.Function0(type3, type2); | |
587 TypeHandle function11 = T.Function1(type1, type2, type2); | |
588 TypeHandle function12 = T.Function1(type1, type2, type3); | |
589 TypeHandle function21 = T.Function2(type1, type2, type2); | |
590 TypeHandle function22 = T.Function2(type1, type2, type3); | |
591 TypeHandle function23 = T.Function2(type1, type3, type2); | |
592 CHECK(Equal(function01, function02) == Equal(type2, type3)); | |
593 CHECK(Equal(function01, function03) == Equal(type1, type3)); | |
594 CHECK(Equal(function11, function12) == Equal(type2, type3)); | |
595 CHECK(Equal(function21, function22) == Equal(type2, type3)); | |
596 CHECK(Equal(function21, function23) == Equal(type2, type3)); | |
597 } | |
598 } | |
599 } | |
600 } | |
601 | |
602 void Of() { | 451 void Of() { |
603 // Constant(V)->Is(Of(V)) | 452 // Constant(V)->Is(Of(V)) |
604 for (ValueIterator vt = T.values.begin(); vt != T.values.end(); ++vt) { | 453 for (ValueIterator vt = T.values.begin(); vt != T.values.end(); ++vt) { |
605 Handle<i::Object> value = *vt; | 454 Handle<i::Object> value = *vt; |
606 TypeHandle const_type = T.Constant(value); | 455 TypeHandle const_type = T.Constant(value); |
607 TypeHandle of_type = T.Of(value); | 456 TypeHandle of_type = T.Of(value); |
608 CHECK(const_type->Is(of_type)); | 457 CHECK(const_type->Is(of_type)); |
609 } | 458 } |
610 | 459 |
611 // Constant(V)->Is(T) iff Of(V)->Is(T) or T->Maybe(Constant(V)) | 460 // Constant(V)->Is(T) iff Of(V)->Is(T) or T->Maybe(Constant(V)) |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
785 CheckSub(T.Object, T.Receiver); | 634 CheckSub(T.Object, T.Receiver); |
786 CheckSub(T.Array, T.Object); | 635 CheckSub(T.Array, T.Object); |
787 CheckSub(T.Function, T.Object); | 636 CheckSub(T.Function, T.Object); |
788 CheckSub(T.Proxy, T.Receiver); | 637 CheckSub(T.Proxy, T.Receiver); |
789 CheckUnordered(T.Object, T.Proxy); | 638 CheckUnordered(T.Object, T.Proxy); |
790 CheckUnordered(T.Array, T.Function); | 639 CheckUnordered(T.Array, T.Function); |
791 | 640 |
792 // Structural types | 641 // Structural types |
793 CheckSub(T.ObjectClass, T.Object); | 642 CheckSub(T.ObjectClass, T.Object); |
794 CheckSub(T.ArrayClass, T.Object); | 643 CheckSub(T.ArrayClass, T.Object); |
795 CheckSub(T.ArrayClass, T.Array); | |
796 CheckSub(T.UninitializedClass, T.Internal); | 644 CheckSub(T.UninitializedClass, T.Internal); |
797 CheckUnordered(T.ObjectClass, T.ArrayClass); | 645 CheckUnordered(T.ObjectClass, T.ArrayClass); |
798 CheckUnordered(T.UninitializedClass, T.Null); | 646 CheckUnordered(T.UninitializedClass, T.Null); |
799 CheckUnordered(T.UninitializedClass, T.Undefined); | 647 CheckUnordered(T.UninitializedClass, T.Undefined); |
800 | 648 |
801 CheckSub(T.SmiConstant, T.SignedSmall); | 649 CheckSub(T.SmiConstant, T.SignedSmall); |
802 CheckSub(T.SmiConstant, T.Signed32); | 650 CheckSub(T.SmiConstant, T.Signed32); |
803 CheckSub(T.SmiConstant, T.Number); | 651 CheckSub(T.SmiConstant, T.Number); |
804 CheckSub(T.ObjectConstant1, T.Object); | 652 CheckSub(T.ObjectConstant1, T.Object); |
805 CheckSub(T.ObjectConstant2, T.Object); | 653 CheckSub(T.ObjectConstant2, T.Object); |
806 CheckSub(T.ArrayConstant, T.Object); | 654 CheckSub(T.ArrayConstant, T.Object); |
807 CheckSub(T.ArrayConstant, T.Array); | 655 CheckSub(T.ArrayConstant, T.Array); |
808 CheckSub(T.UninitializedConstant, T.Internal); | 656 CheckSub(T.UninitializedConstant, T.Internal); |
809 CheckUnordered(T.ObjectConstant1, T.ObjectConstant2); | 657 CheckUnordered(T.ObjectConstant1, T.ObjectConstant2); |
810 CheckUnordered(T.ObjectConstant1, T.ArrayConstant); | 658 CheckUnordered(T.ObjectConstant1, T.ArrayConstant); |
811 CheckUnordered(T.UninitializedConstant, T.Null); | 659 CheckUnordered(T.UninitializedConstant, T.Null); |
812 CheckUnordered(T.UninitializedConstant, T.Undefined); | 660 CheckUnordered(T.UninitializedConstant, T.Undefined); |
813 | 661 |
814 CheckUnordered(T.ObjectConstant1, T.ObjectClass); | 662 CheckUnordered(T.ObjectConstant1, T.ObjectClass); |
815 CheckUnordered(T.ObjectConstant2, T.ObjectClass); | 663 CheckUnordered(T.ObjectConstant2, T.ObjectClass); |
816 CheckUnordered(T.ObjectConstant1, T.ArrayClass); | 664 CheckUnordered(T.ObjectConstant1, T.ArrayClass); |
817 CheckUnordered(T.ObjectConstant2, T.ArrayClass); | 665 CheckUnordered(T.ObjectConstant2, T.ArrayClass); |
818 CheckUnordered(T.ArrayConstant, T.ObjectClass); | 666 CheckUnordered(T.ArrayConstant, T.ObjectClass); |
819 | |
820 CheckSub(T.FloatArray, T.Array); | |
821 CheckSub(T.FloatArray, T.Object); | |
822 CheckUnordered(T.StringArray, T.AnyArray); | |
823 | |
824 CheckSub(T.MethodFunction, T.Function); | |
825 CheckSub(T.NumberFunction1, T.Object); | |
826 CheckUnordered(T.SignedFunction1, T.NumberFunction1); | |
827 CheckUnordered(T.NumberFunction1, T.NumberFunction2); | |
828 } | 667 } |
829 | 668 |
830 void NowIs() { | 669 void NowIs() { |
831 // Least Element (Bottom): None->NowIs(T) | 670 // Least Element (Bottom): None->NowIs(T) |
832 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { | 671 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { |
833 TypeHandle type = *it; | 672 TypeHandle type = *it; |
834 CHECK(T.None->NowIs(type)); | 673 CHECK(T.None->NowIs(type)); |
835 } | 674 } |
836 | 675 |
837 // Greatest Element (Top): T->NowIs(Any) | 676 // Greatest Element (Top): T->NowIs(Any) |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1146 CheckOverlap(T.ArrayConstant, T.Array, T.Semantic); | 985 CheckOverlap(T.ArrayConstant, T.Array, T.Semantic); |
1147 CheckOverlap(T.ObjectConstant1, T.ObjectConstant1, T.Semantic); | 986 CheckOverlap(T.ObjectConstant1, T.ObjectConstant1, T.Semantic); |
1148 CheckDisjoint(T.ObjectConstant1, T.ObjectConstant2, T.Semantic); | 987 CheckDisjoint(T.ObjectConstant1, T.ObjectConstant2, T.Semantic); |
1149 CheckDisjoint(T.ObjectConstant1, T.ArrayConstant, T.Semantic); | 988 CheckDisjoint(T.ObjectConstant1, T.ArrayConstant, T.Semantic); |
1150 | 989 |
1151 CheckDisjoint(T.ObjectConstant1, T.ObjectClass, T.Semantic); | 990 CheckDisjoint(T.ObjectConstant1, T.ObjectClass, T.Semantic); |
1152 CheckDisjoint(T.ObjectConstant2, T.ObjectClass, T.Semantic); | 991 CheckDisjoint(T.ObjectConstant2, T.ObjectClass, T.Semantic); |
1153 CheckDisjoint(T.ObjectConstant1, T.ArrayClass, T.Semantic); | 992 CheckDisjoint(T.ObjectConstant1, T.ArrayClass, T.Semantic); |
1154 CheckDisjoint(T.ObjectConstant2, T.ArrayClass, T.Semantic); | 993 CheckDisjoint(T.ObjectConstant2, T.ArrayClass, T.Semantic); |
1155 CheckDisjoint(T.ArrayConstant, T.ObjectClass, T.Semantic); | 994 CheckDisjoint(T.ArrayConstant, T.ObjectClass, T.Semantic); |
1156 | |
1157 CheckOverlap(T.FloatArray, T.Array, T.Semantic); | |
1158 CheckDisjoint(T.FloatArray, T.AnyArray, T.Semantic); | |
1159 CheckDisjoint(T.FloatArray, T.StringArray, T.Semantic); | |
1160 | |
1161 CheckOverlap(T.MethodFunction, T.Function, T.Semantic); | |
1162 CheckDisjoint(T.SignedFunction1, T.NumberFunction1, T.Semantic); | |
1163 CheckDisjoint(T.SignedFunction1, T.NumberFunction2, T.Semantic); | |
1164 CheckDisjoint(T.NumberFunction1, T.NumberFunction2, T.Semantic); | |
1165 CheckDisjoint(T.SignedFunction1, T.MethodFunction, T.Semantic); | |
1166 } | 995 } |
1167 | 996 |
1168 void Union1() { | 997 void Union() { |
1169 // Identity: Union(T, None) = T | 998 // Identity: Union(T, None) = T |
1170 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { | 999 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { |
1171 TypeHandle type = *it; | 1000 TypeHandle type = *it; |
1172 TypeHandle union_type = T.Union(type, T.None); | 1001 TypeHandle union_type = T.Union(type, T.None); |
1173 CheckEqual(union_type, type); | 1002 CheckEqual(union_type, type); |
1174 } | 1003 } |
1175 | 1004 |
1176 // Domination: Union(T, Any) = Any | 1005 // Domination: Union(T, Any) = Any |
1177 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { | 1006 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { |
1178 TypeHandle type = *it; | 1007 TypeHandle type = *it; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1227 | 1056 |
1228 // Upper Boundedness: T1->Is(T2) implies Union(T1, T2) = T2 | 1057 // Upper Boundedness: T1->Is(T2) implies Union(T1, T2) = T2 |
1229 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { | 1058 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { |
1230 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { | 1059 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { |
1231 TypeHandle type1 = *it1; | 1060 TypeHandle type1 = *it1; |
1232 TypeHandle type2 = *it2; | 1061 TypeHandle type2 = *it2; |
1233 TypeHandle union12 = T.Union(type1, type2); | 1062 TypeHandle union12 = T.Union(type1, type2); |
1234 if (type1->Is(type2)) CheckEqual(union12, type2); | 1063 if (type1->Is(type2)) CheckEqual(union12, type2); |
1235 } | 1064 } |
1236 } | 1065 } |
1237 } | |
1238 | 1066 |
1239 void Union2() { | |
1240 // Monotonicity: T1->Is(T2) implies Union(T1, T3)->Is(Union(T2, T3)) | 1067 // Monotonicity: T1->Is(T2) implies Union(T1, T3)->Is(Union(T2, T3)) |
1241 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { | 1068 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { |
1242 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { | 1069 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { |
1243 for (TypeIterator it3 = T.types.begin(); it3 != T.types.end(); ++it3) { | 1070 for (TypeIterator it3 = T.types.begin(); it3 != T.types.end(); ++it3) { |
1244 TypeHandle type1 = *it1; | 1071 TypeHandle type1 = *it1; |
1245 TypeHandle type2 = *it2; | 1072 TypeHandle type2 = *it2; |
1246 TypeHandle type3 = *it3; | 1073 TypeHandle type3 = *it3; |
1247 TypeHandle union13 = T.Union(type1, type3); | 1074 TypeHandle union13 = T.Union(type1, type3); |
1248 TypeHandle union23 = T.Union(type2, type3); | 1075 TypeHandle union23 = T.Union(type2, type3); |
1249 CHECK(!type1->Is(type2) || union13->Is(union23)); | 1076 CHECK(!type1->Is(type2) || union13->Is(union23)); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1288 CheckUnordered(T.Union(T.ObjectConstant1, T.ArrayConstant), T.Array); | 1115 CheckUnordered(T.Union(T.ObjectConstant1, T.ArrayConstant), T.Array); |
1289 CheckUnordered( | 1116 CheckUnordered( |
1290 T.Union(T.ObjectConstant1, T.ObjectConstant2), T.ObjectClass); | 1117 T.Union(T.ObjectConstant1, T.ObjectConstant2), T.ObjectClass); |
1291 CheckOverlap( | 1118 CheckOverlap( |
1292 T.Union(T.ObjectConstant1, T.ArrayConstant), T.Array, T.Semantic); | 1119 T.Union(T.ObjectConstant1, T.ArrayConstant), T.Array, T.Semantic); |
1293 CheckDisjoint( | 1120 CheckDisjoint( |
1294 T.Union(T.ObjectConstant1, T.ArrayConstant), T.Number, T.Semantic); | 1121 T.Union(T.ObjectConstant1, T.ArrayConstant), T.Number, T.Semantic); |
1295 CheckDisjoint( | 1122 CheckDisjoint( |
1296 T.Union(T.ObjectConstant1, T.ArrayConstant), T.ObjectClass, T.Semantic); | 1123 T.Union(T.ObjectConstant1, T.ArrayConstant), T.ObjectClass, T.Semantic); |
1297 | 1124 |
1298 // Bitset-array | |
1299 CHECK(this->IsBitset(T.Union(T.AnyArray, T.Array))); | |
1300 CHECK(this->IsUnion(T.Union(T.FloatArray, T.Number))); | |
1301 | |
1302 CheckEqual(T.Union(T.AnyArray, T.Array), T.Array); | |
1303 CheckSub(T.None, T.Union(T.FloatArray, T.Number)); | |
1304 CheckSub(T.Union(T.FloatArray, T.Number), T.Any); | |
1305 CheckUnordered(T.Union(T.AnyArray, T.String), T.Array); | |
1306 CheckOverlap(T.Union(T.FloatArray, T.String), T.Object, T.Semantic); | |
1307 CheckDisjoint(T.Union(T.FloatArray, T.String), T.Number, T.Semantic); | |
1308 | |
1309 // Bitset-function | |
1310 CHECK(this->IsBitset(T.Union(T.MethodFunction, T.Function))); | |
1311 CHECK(this->IsUnion(T.Union(T.NumberFunction1, T.Number))); | |
1312 | |
1313 CheckEqual(T.Union(T.MethodFunction, T.Function), T.Function); | |
1314 CheckSub(T.None, T.Union(T.MethodFunction, T.Number)); | |
1315 CheckSub(T.Union(T.MethodFunction, T.Number), T.Any); | |
1316 CheckUnordered(T.Union(T.NumberFunction1, T.String), T.Function); | |
1317 CheckOverlap(T.Union(T.NumberFunction2, T.String), T.Object, T.Semantic); | |
1318 CheckDisjoint(T.Union(T.NumberFunction1, T.String), T.Number, T.Semantic); | |
1319 | |
1320 // Bitset-class | 1125 // Bitset-class |
1321 CheckSub( | 1126 CheckSub( |
1322 T.Union(T.ObjectClass, T.SignedSmall), T.Union(T.Object, T.Number)); | 1127 T.Union(T.ObjectClass, T.SignedSmall), T.Union(T.Object, T.Number)); |
1323 CheckSub(T.Union(T.ObjectClass, T.Array), T.Object); | 1128 CheckSub(T.Union(T.ObjectClass, T.Array), T.Object); |
1324 CheckUnordered(T.Union(T.ObjectClass, T.String), T.Array); | 1129 CheckUnordered(T.Union(T.ObjectClass, T.String), T.Array); |
1325 CheckOverlap(T.Union(T.ObjectClass, T.String), T.Object, T.Semantic); | 1130 CheckOverlap(T.Union(T.ObjectClass, T.String), T.Object, T.Semantic); |
1326 CheckDisjoint(T.Union(T.ObjectClass, T.String), T.Number, T.Semantic); | 1131 CheckDisjoint(T.Union(T.ObjectClass, T.String), T.Number, T.Semantic); |
1327 | 1132 |
1328 // Bitset-constant | 1133 // Bitset-constant |
1329 CheckSub( | 1134 CheckSub( |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1365 CheckEqual( | 1170 CheckEqual( |
1366 T.Union( | 1171 T.Union( |
1367 T.ObjectConstant1, T.Union(T.ObjectConstant1, T.ObjectConstant2)), | 1172 T.ObjectConstant1, T.Union(T.ObjectConstant1, T.ObjectConstant2)), |
1368 T.Union(T.ObjectConstant2, T.ObjectConstant1)); | 1173 T.Union(T.ObjectConstant2, T.ObjectConstant1)); |
1369 CheckEqual( | 1174 CheckEqual( |
1370 T.Union( | 1175 T.Union( |
1371 T.Union(T.ArrayConstant, T.ObjectConstant2), T.ObjectConstant1), | 1176 T.Union(T.ArrayConstant, T.ObjectConstant2), T.ObjectConstant1), |
1372 T.Union( | 1177 T.Union( |
1373 T.ObjectConstant2, T.Union(T.ArrayConstant, T.ObjectConstant1))); | 1178 T.ObjectConstant2, T.Union(T.ArrayConstant, T.ObjectConstant1))); |
1374 | 1179 |
1375 // Array-union | |
1376 CheckEqual( | |
1377 T.Union(T.AnyArray, T.Union(T.FloatArray, T.AnyArray)), | |
1378 T.Union(T.AnyArray, T.FloatArray)); | |
1379 CheckSub(T.Union(T.AnyArray, T.FloatArray), T.Array); | |
1380 | |
1381 // Function-union | |
1382 CheckEqual( | |
1383 T.Union(T.NumberFunction1, T.NumberFunction2), | |
1384 T.Union(T.NumberFunction2, T.NumberFunction1)); | |
1385 CheckSub(T.Union(T.SignedFunction1, T.MethodFunction), T.Function); | |
1386 | |
1387 // Union-union | 1180 // Union-union |
1388 CheckEqual( | 1181 CheckEqual( |
1389 T.Union( | 1182 T.Union( |
1390 T.Union(T.ObjectConstant2, T.ObjectConstant1), | 1183 T.Union(T.ObjectConstant2, T.ObjectConstant1), |
1391 T.Union(T.ObjectConstant1, T.ObjectConstant2)), | 1184 T.Union(T.ObjectConstant1, T.ObjectConstant2)), |
1392 T.Union(T.ObjectConstant2, T.ObjectConstant1)); | 1185 T.Union(T.ObjectConstant2, T.ObjectConstant1)); |
1393 CheckEqual( | 1186 CheckEqual( |
1394 T.Union( | 1187 T.Union( |
1395 T.Union(T.Number, T.ArrayClass), | 1188 T.Union(T.Number, T.ArrayClass), |
1396 T.Union(T.SignedSmall, T.Array)), | 1189 T.Union(T.SignedSmall, T.Array)), |
1397 T.Union(T.Number, T.Array)); | 1190 T.Union(T.Number, T.Array)); |
1398 } | 1191 } |
1399 | 1192 |
1400 void Intersect1() { | 1193 void Intersect() { |
1401 // Identity: Intersect(T, Any) = T | 1194 // Identity: Intersect(T, Any) = T |
1402 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { | 1195 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { |
1403 TypeHandle type = *it; | 1196 TypeHandle type = *it; |
1404 TypeHandle intersect_type = T.Intersect(type, T.Any); | 1197 TypeHandle intersect_type = T.Intersect(type, T.Any); |
1405 CheckEqual(intersect_type, type); | 1198 CheckEqual(intersect_type, type); |
1406 } | 1199 } |
1407 | 1200 |
1408 // Domination: Intersect(T, None) = None | 1201 // Domination: Intersect(T, None) = None |
1409 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { | 1202 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { |
1410 TypeHandle type = *it; | 1203 TypeHandle type = *it; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1460 | 1253 |
1461 // Lower Boundedness: T1->Is(T2) implies Intersect(T1, T2) = T1 | 1254 // Lower Boundedness: T1->Is(T2) implies Intersect(T1, T2) = T1 |
1462 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { | 1255 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { |
1463 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { | 1256 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { |
1464 TypeHandle type1 = *it1; | 1257 TypeHandle type1 = *it1; |
1465 TypeHandle type2 = *it2; | 1258 TypeHandle type2 = *it2; |
1466 TypeHandle intersect12 = T.Intersect(type1, type2); | 1259 TypeHandle intersect12 = T.Intersect(type1, type2); |
1467 if (type1->Is(type2)) CheckEqual(intersect12, type1); | 1260 if (type1->Is(type2)) CheckEqual(intersect12, type1); |
1468 } | 1261 } |
1469 } | 1262 } |
1470 } | |
1471 | 1263 |
1472 void Intersect2() { | |
1473 // Monotonicity: T1->Is(T2) implies Intersect(T1, T3)->Is(Intersect(T2, T3)) | 1264 // Monotonicity: T1->Is(T2) implies Intersect(T1, T3)->Is(Intersect(T2, T3)) |
1474 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { | 1265 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { |
1475 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { | 1266 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { |
1476 for (TypeIterator it3 = T.types.begin(); it3 != T.types.end(); ++it3) { | 1267 for (TypeIterator it3 = T.types.begin(); it3 != T.types.end(); ++it3) { |
1477 TypeHandle type1 = *it1; | 1268 TypeHandle type1 = *it1; |
1478 TypeHandle type2 = *it2; | 1269 TypeHandle type2 = *it2; |
1479 TypeHandle type3 = *it3; | 1270 TypeHandle type3 = *it3; |
1480 TypeHandle intersect13 = T.Intersect(type1, type3); | 1271 TypeHandle intersect13 = T.Intersect(type1, type3); |
1481 TypeHandle intersect23 = T.Intersect(type2, type3); | 1272 TypeHandle intersect23 = T.Intersect(type2, type3); |
1482 CHECK(!type1->Is(type2) || intersect13->Is(intersect23)); | 1273 CHECK(!type1->Is(type2) || intersect13->Is(intersect23)); |
(...skipping 27 matching lines...) Expand all Loading... |
1510 type1->Is(intersect23)); | 1301 type1->Is(intersect23)); |
1511 } | 1302 } |
1512 } | 1303 } |
1513 } | 1304 } |
1514 | 1305 |
1515 // Bitset-class | 1306 // Bitset-class |
1516 CheckEqual(T.Intersect(T.ObjectClass, T.Object), T.ObjectClass); | 1307 CheckEqual(T.Intersect(T.ObjectClass, T.Object), T.ObjectClass); |
1517 CheckSub(T.Intersect(T.ObjectClass, T.Array), T.Representation); | 1308 CheckSub(T.Intersect(T.ObjectClass, T.Array), T.Representation); |
1518 CheckSub(T.Intersect(T.ObjectClass, T.Number), T.Representation); | 1309 CheckSub(T.Intersect(T.ObjectClass, T.Number), T.Representation); |
1519 | 1310 |
1520 // Bitset-array | 1311 // Class-constant |
1521 CheckEqual(T.Intersect(T.FloatArray, T.Object), T.FloatArray); | 1312 CheckEqual(T.Intersect(T.ObjectConstant1, T.ObjectClass), T.None); |
1522 CheckSub(T.Intersect(T.AnyArray, T.Function), T.Representation); | 1313 CheckEqual(T.Intersect(T.ArrayClass, T.ObjectConstant2), T.None); |
1523 | |
1524 // Bitset-function | |
1525 CheckEqual(T.Intersect(T.MethodFunction, T.Object), T.MethodFunction); | |
1526 CheckSub(T.Intersect(T.NumberFunction1, T.Array), T.Representation); | |
1527 | 1314 |
1528 // Bitset-union | 1315 // Bitset-union |
1529 CheckEqual( | 1316 CheckEqual( |
1530 T.Intersect(T.Object, T.Union(T.ObjectConstant1, T.ObjectClass)), | 1317 T.Intersect(T.Object, T.Union(T.ObjectConstant1, T.ObjectClass)), |
1531 T.Union(T.ObjectConstant1, T.ObjectClass)); | 1318 T.Union(T.ObjectConstant1, T.ObjectClass)); |
1532 CheckEqual( | 1319 CheckEqual( |
1533 T.Intersect(T.Union(T.ArrayClass, T.ObjectConstant1), T.Number), | 1320 T.Intersect(T.Union(T.ArrayClass, T.ObjectConstant1), T.Number), |
1534 T.None); | 1321 T.None); |
1535 | 1322 |
1536 // Class-constant | |
1537 CheckEqual(T.Intersect(T.ObjectConstant1, T.ObjectClass), T.None); | |
1538 CheckEqual(T.Intersect(T.ArrayClass, T.ObjectConstant2), T.None); | |
1539 | |
1540 // Array-union | |
1541 CheckEqual( | |
1542 T.Intersect(T.FloatArray, T.Union(T.FloatArray, T.ArrayClass)), | |
1543 T.FloatArray); | |
1544 CheckEqual( | |
1545 T.Intersect(T.AnyArray, T.Union(T.Object, T.SmiConstant)), | |
1546 T.AnyArray); | |
1547 CheckEqual( | |
1548 T.Intersect(T.Union(T.AnyArray, T.ArrayConstant), T.FloatArray), | |
1549 T.None); | |
1550 | |
1551 // Function-union | |
1552 CheckEqual( | |
1553 T.Intersect(T.MethodFunction, T.Union(T.String, T.MethodFunction)), | |
1554 T.MethodFunction); | |
1555 CheckEqual( | |
1556 T.Intersect(T.NumberFunction1, T.Union(T.Object, T.SmiConstant)), | |
1557 T.NumberFunction1); | |
1558 CheckEqual( | |
1559 T.Intersect(T.Union(T.MethodFunction, T.Name), T.NumberFunction2), | |
1560 T.None); | |
1561 | |
1562 // Class-union | 1323 // Class-union |
1563 CheckEqual( | 1324 CheckEqual( |
1564 T.Intersect(T.ArrayClass, T.Union(T.ObjectConstant2, T.ArrayClass)), | 1325 T.Intersect(T.ArrayClass, T.Union(T.ObjectConstant2, T.ArrayClass)), |
1565 T.ArrayClass); | 1326 T.ArrayClass); |
1566 CheckEqual( | 1327 CheckEqual( |
1567 T.Intersect(T.ArrayClass, T.Union(T.Object, T.SmiConstant)), | 1328 T.Intersect(T.ArrayClass, T.Union(T.Object, T.SmiConstant)), |
1568 T.ArrayClass); | 1329 T.ArrayClass); |
1569 CheckEqual( | 1330 CheckEqual( |
1570 T.Intersect(T.Union(T.ObjectClass, T.ArrayConstant), T.ArrayClass), | 1331 T.Intersect(T.Union(T.ObjectClass, T.ArrayConstant), T.ArrayClass), |
1571 T.None); | 1332 T.None); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1619 TypeHandle type3 = T.template Convert<Type2>(type2); | 1380 TypeHandle type3 = T.template Convert<Type2>(type2); |
1620 CheckEqual(type1, type3); | 1381 CheckEqual(type1, type3); |
1621 } | 1382 } |
1622 } | 1383 } |
1623 }; | 1384 }; |
1624 | 1385 |
1625 typedef Tests<Type, Type*, Zone, ZoneRep> ZoneTests; | 1386 typedef Tests<Type, Type*, Zone, ZoneRep> ZoneTests; |
1626 typedef Tests<HeapType, Handle<HeapType>, Isolate, HeapRep> HeapTests; | 1387 typedef Tests<HeapType, Handle<HeapType>, Isolate, HeapRep> HeapTests; |
1627 | 1388 |
1628 | 1389 |
1629 TEST(BitsetType) { | 1390 TEST(Bitset) { |
1630 CcTest::InitializeVM(); | 1391 CcTest::InitializeVM(); |
1631 ZoneTests().Bitset(); | 1392 ZoneTests().Bitset(); |
1632 HeapTests().Bitset(); | 1393 HeapTests().Bitset(); |
1633 } | 1394 } |
1634 | 1395 |
1635 | 1396 |
1636 TEST(ClassType) { | 1397 TEST(Class) { |
1637 CcTest::InitializeVM(); | 1398 CcTest::InitializeVM(); |
1638 ZoneTests().Class(); | 1399 ZoneTests().Class(); |
1639 HeapTests().Class(); | 1400 HeapTests().Class(); |
1640 } | 1401 } |
1641 | 1402 |
1642 | 1403 |
1643 TEST(ConstantType) { | 1404 TEST(Constant) { |
1644 CcTest::InitializeVM(); | 1405 CcTest::InitializeVM(); |
1645 ZoneTests().Constant(); | 1406 ZoneTests().Constant(); |
1646 HeapTests().Constant(); | 1407 HeapTests().Constant(); |
1647 } | 1408 } |
1648 | 1409 |
1649 | 1410 |
1650 TEST(ArrayType) { | |
1651 CcTest::InitializeVM(); | |
1652 ZoneTests().Array(); | |
1653 HeapTests().Array(); | |
1654 } | |
1655 | |
1656 | |
1657 TEST(FunctionType) { | |
1658 CcTest::InitializeVM(); | |
1659 ZoneTests().Function(); | |
1660 HeapTests().Function(); | |
1661 } | |
1662 | |
1663 | |
1664 TEST(Of) { | 1411 TEST(Of) { |
1665 CcTest::InitializeVM(); | 1412 CcTest::InitializeVM(); |
1666 ZoneTests().Of(); | 1413 ZoneTests().Of(); |
1667 HeapTests().Of(); | 1414 HeapTests().Of(); |
1668 } | 1415 } |
1669 | 1416 |
1670 | 1417 |
1671 TEST(NowOf) { | 1418 TEST(NowOf) { |
1672 CcTest::InitializeVM(); | 1419 CcTest::InitializeVM(); |
1673 ZoneTests().NowOf(); | 1420 ZoneTests().NowOf(); |
(...skipping 29 matching lines...) Expand all Loading... |
1703 } | 1450 } |
1704 | 1451 |
1705 | 1452 |
1706 TEST(Maybe) { | 1453 TEST(Maybe) { |
1707 CcTest::InitializeVM(); | 1454 CcTest::InitializeVM(); |
1708 ZoneTests().Maybe(); | 1455 ZoneTests().Maybe(); |
1709 HeapTests().Maybe(); | 1456 HeapTests().Maybe(); |
1710 } | 1457 } |
1711 | 1458 |
1712 | 1459 |
1713 TEST(Union1) { | 1460 TEST(Union) { |
1714 CcTest::InitializeVM(); | 1461 CcTest::InitializeVM(); |
1715 ZoneTests().Union1(); | 1462 ZoneTests().Union(); |
1716 HeapTests().Union1(); | 1463 HeapTests().Union(); |
1717 } | 1464 } |
1718 | 1465 |
1719 | 1466 |
1720 TEST(Union2) { | 1467 TEST(Intersect) { |
1721 CcTest::InitializeVM(); | 1468 CcTest::InitializeVM(); |
1722 ZoneTests().Union2(); | 1469 ZoneTests().Intersect(); |
1723 HeapTests().Union2(); | 1470 HeapTests().Intersect(); |
1724 } | 1471 } |
1725 | 1472 |
1726 | 1473 |
1727 TEST(Intersect1) { | |
1728 CcTest::InitializeVM(); | |
1729 ZoneTests().Intersect1(); | |
1730 HeapTests().Intersect1(); | |
1731 } | |
1732 | |
1733 | |
1734 TEST(Intersect2) { | |
1735 CcTest::InitializeVM(); | |
1736 ZoneTests().Intersect2(); | |
1737 HeapTests().Intersect2(); | |
1738 } | |
1739 | |
1740 | |
1741 TEST(Convert) { | 1474 TEST(Convert) { |
1742 CcTest::InitializeVM(); | 1475 CcTest::InitializeVM(); |
1743 ZoneTests().Convert<HeapType, Handle<HeapType>, Isolate, HeapRep>(); | 1476 ZoneTests().Convert<HeapType, Handle<HeapType>, Isolate, HeapRep>(); |
1744 HeapTests().Convert<Type, Type*, Zone, ZoneRep>(); | 1477 HeapTests().Convert<Type, Type*, Zone, ZoneRep>(); |
1745 } | 1478 } |
OLD | NEW |