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 |
11 // with the distribution. | 11 // with the distribution. |
12 // * Neither the name of Google Inc. nor the names of its | 12 // * Neither the name of Google Inc. nor the names of its |
13 // contributors may be used to endorse or promote products derived | 13 // contributors may be used to endorse or promote products derived |
14 // from this software without specific prior written permission. | 14 // from this software without specific prior written permission. |
15 // | 15 // |
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 27 |
28 #include <list> | 28 #include <vector> |
29 | 29 |
30 #include "cctest.h" | 30 #include "cctest.h" |
31 #include "types.h" | 31 #include "types.h" |
32 #include "utils/random-number-generator.h" | 32 #include "utils/random-number-generator.h" |
33 | 33 |
34 using namespace v8::internal; | 34 using namespace v8::internal; |
35 | 35 |
36 template<class Type, class TypeHandle, class Region> | 36 template<class Type, class TypeHandle, class Region> |
37 class Types { | 37 class Types { |
38 public: | 38 public: |
39 Types(Region* region, Isolate* isolate) : | 39 Types(Region* region, Isolate* isolate) : region_(region) { |
40 Representation(Type::Representation(region)), | 40 static const size_t kMaxTypes = 300; |
41 Semantic(Type::Semantic(region)), | 41 types.reserve(kMaxTypes); |
42 None(Type::None(region)), | 42 |
43 Any(Type::Any(region)), | 43 #define DECLARE_TYPE(name, value) \ |
44 Boolean(Type::Boolean(region)), | 44 name = Type::name(region); \ |
45 Null(Type::Null(region)), | 45 types.push_back(name); |
46 Undefined(Type::Undefined(region)), | 46 BITSET_TYPE_LIST(DECLARE_TYPE) |
47 Number(Type::Number(region)), | 47 #undef DECLARE_TYPE |
48 SignedSmall(Type::SignedSmall(region)), | 48 |
49 Signed32(Type::Signed32(region)), | 49 object_map = isolate->factory()->NewMap(JS_OBJECT_TYPE, 3 * kPointerSize); |
50 Float(Type::Float(region)), | 50 array_map = isolate->factory()->NewMap(JS_ARRAY_TYPE, 4 * kPointerSize); |
51 Name(Type::Name(region)), | 51 ObjectClass = Type::Class(object_map, region); |
52 UniqueName(Type::UniqueName(region)), | 52 ArrayClass = Type::Class(array_map, region); |
53 String(Type::String(region)), | 53 types.push_back(ObjectClass); |
54 InternalizedString(Type::InternalizedString(region)), | 54 types.push_back(ArrayClass); |
55 Symbol(Type::Symbol(region)), | 55 |
56 Receiver(Type::Receiver(region)), | |
57 Object(Type::Object(region)), | |
58 Array(Type::Array(region)), | |
59 Function(Type::Function(region)), | |
60 Proxy(Type::Proxy(region)), | |
61 object_map(isolate->factory()->NewMap(JS_OBJECT_TYPE, 3 * kPointerSize)), | |
62 array_map(isolate->factory()->NewMap(JS_ARRAY_TYPE, 4 * kPointerSize)), | |
63 region_(region) { | |
64 smi = handle(Smi::FromInt(666), isolate); | 56 smi = handle(Smi::FromInt(666), isolate); |
65 signed32 = isolate->factory()->NewHeapNumber(0x40000000); | 57 signed32 = isolate->factory()->NewHeapNumber(0x40000000); |
66 object1 = isolate->factory()->NewJSObjectFromMap(object_map); | 58 object1 = isolate->factory()->NewJSObjectFromMap(object_map); |
67 object2 = isolate->factory()->NewJSObjectFromMap(object_map); | 59 object2 = isolate->factory()->NewJSObjectFromMap(object_map); |
68 array = isolate->factory()->NewJSArray(20); | 60 array = isolate->factory()->NewJSArray(20); |
69 ObjectClass = Type::Class(object_map, region); | 61 values.push_back(smi); |
70 ArrayClass = Type::Class(array_map, region); | 62 values.push_back(signed32); |
| 63 values.push_back(object1); |
| 64 values.push_back(object2); |
| 65 values.push_back(array); |
71 SmiConstant = Type::Constant(smi, region); | 66 SmiConstant = Type::Constant(smi, region); |
72 Signed32Constant = Type::Constant(signed32, region); | 67 Signed32Constant = Type::Constant(signed32, region); |
73 ObjectConstant1 = Type::Constant(object1, region); | 68 ObjectConstant1 = Type::Constant(object1, region); |
74 ObjectConstant2 = Type::Constant(object2, region); | 69 ObjectConstant2 = Type::Constant(object2, region); |
75 ArrayConstant1 = Type::Constant(array, region); | 70 ArrayConstant = Type::Constant(array, region); |
76 ArrayConstant2 = Type::Constant(array, region); | 71 for (ValueVector::iterator it = values.begin(); it != values.end(); ++it) { |
77 | 72 types.push_back(Type::Constant(*it, region)); |
78 types.push_back(None); | |
79 types.push_back(Any); | |
80 types.push_back(Boolean); | |
81 types.push_back(Null); | |
82 types.push_back(Undefined); | |
83 types.push_back(Number); | |
84 types.push_back(SignedSmall); | |
85 types.push_back(Signed32); | |
86 types.push_back(Float); | |
87 types.push_back(Name); | |
88 types.push_back(UniqueName); | |
89 types.push_back(String); | |
90 types.push_back(InternalizedString); | |
91 types.push_back(Symbol); | |
92 types.push_back(Receiver); | |
93 types.push_back(Object); | |
94 types.push_back(Array); | |
95 types.push_back(Function); | |
96 types.push_back(Proxy); | |
97 types.push_back(ObjectClass); | |
98 types.push_back(ArrayClass); | |
99 types.push_back(SmiConstant); | |
100 types.push_back(Signed32Constant); | |
101 types.push_back(ObjectConstant1); | |
102 types.push_back(ObjectConstant2); | |
103 types.push_back(ArrayConstant1); | |
104 types.push_back(ArrayConstant2); | |
105 for (int i = 0; i < 300; ++i) { | |
106 types.push_back(Fuzz()); | |
107 } | 73 } |
108 | 74 |
109 objects.push_back(smi); | 75 while (types.size() < kMaxTypes) { |
110 objects.push_back(signed32); | 76 size_t i = rng.NextInt(types.size()); |
111 objects.push_back(object1); | 77 size_t j = rng.NextInt(types.size()); |
112 objects.push_back(object2); | 78 if (i != j) types.push_back(Type::Union(types[i], types[j], region)); |
113 objects.push_back(array); | 79 } |
114 } | 80 } |
115 | 81 |
116 RandomNumberGenerator rng; | 82 RandomNumberGenerator rng; |
117 | 83 |
118 TypeHandle Representation; | 84 #define DECLARE_TYPE(name, value) TypeHandle name; |
119 TypeHandle Semantic; | 85 BITSET_TYPE_LIST(DECLARE_TYPE) |
120 TypeHandle None; | 86 #undef DECLARE_TYPE |
121 TypeHandle Any; | |
122 TypeHandle Boolean; | |
123 TypeHandle Null; | |
124 TypeHandle Undefined; | |
125 TypeHandle Number; | |
126 TypeHandle SignedSmall; | |
127 TypeHandle Signed32; | |
128 TypeHandle Float; | |
129 TypeHandle Name; | |
130 TypeHandle UniqueName; | |
131 TypeHandle String; | |
132 TypeHandle InternalizedString; | |
133 TypeHandle Symbol; | |
134 TypeHandle Receiver; | |
135 TypeHandle Object; | |
136 TypeHandle Array; | |
137 TypeHandle Function; | |
138 TypeHandle Proxy; | |
139 | 87 |
140 TypeHandle ObjectClass; | 88 TypeHandle ObjectClass; |
141 TypeHandle ArrayClass; | 89 TypeHandle ArrayClass; |
142 | 90 |
143 TypeHandle SmiConstant; | 91 TypeHandle SmiConstant; |
144 TypeHandle Signed32Constant; | 92 TypeHandle Signed32Constant; |
145 TypeHandle ObjectConstant1; | 93 TypeHandle ObjectConstant1; |
146 TypeHandle ObjectConstant2; | 94 TypeHandle ObjectConstant2; |
147 TypeHandle ArrayConstant1; | 95 TypeHandle ArrayConstant; |
148 TypeHandle ArrayConstant2; | |
149 | 96 |
150 Handle<i::Map> object_map; | 97 Handle<i::Map> object_map; |
151 Handle<i::Map> array_map; | 98 Handle<i::Map> array_map; |
152 | 99 |
153 Handle<i::Smi> smi; | 100 Handle<i::Smi> smi; |
154 Handle<i::HeapNumber> signed32; | 101 Handle<i::HeapNumber> signed32; |
155 Handle<i::JSObject> object1; | 102 Handle<i::JSObject> object1; |
156 Handle<i::JSObject> object2; | 103 Handle<i::JSObject> object2; |
157 Handle<i::JSArray> array; | 104 Handle<i::JSArray> array; |
158 | 105 |
159 typedef std::list<TypeHandle> TypeList; | 106 typedef std::vector<TypeHandle> TypeVector; |
160 TypeList types; | 107 TypeVector types; |
161 | 108 |
162 typedef std::list<Handle<i::Object> > ObjectList; | 109 typedef std::vector<Handle<i::Object> > ValueVector; |
163 ObjectList objects; | 110 ValueVector values; |
164 | 111 |
165 TypeHandle Of(Handle<i::Object> obj) { | 112 TypeHandle Of(Handle<i::Object> obj) { |
166 return Type::Of(obj, region_); | 113 return Type::Of(obj, region_); |
167 } | 114 } |
168 | 115 |
| 116 TypeHandle NowOf(Handle<i::Object> obj) { |
| 117 return Type::NowOf(obj, region_); |
| 118 } |
| 119 |
169 TypeHandle Constant(Handle<i::Object> obj) { | 120 TypeHandle Constant(Handle<i::Object> obj) { |
170 return Type::Constant(obj, region_); | 121 return Type::Constant(obj, region_); |
171 } | 122 } |
172 | 123 |
173 TypeHandle Union(TypeHandle t1, TypeHandle t2) { | 124 TypeHandle Union(TypeHandle t1, TypeHandle t2) { |
174 return Type::Union(t1, t2, region_); | 125 return Type::Union(t1, t2, region_); |
175 } | 126 } |
176 TypeHandle Intersect(TypeHandle t1, TypeHandle t2) { | 127 TypeHandle Intersect(TypeHandle t1, TypeHandle t2) { |
177 return Type::Intersect(t1, t2, region_); | 128 return Type::Intersect(t1, t2, region_); |
178 } | 129 } |
179 | 130 |
180 template<class Type2, class TypeHandle2> | 131 template<class Type2, class TypeHandle2> |
181 TypeHandle Convert(TypeHandle2 t) { | 132 TypeHandle Convert(TypeHandle2 t) { |
182 return Type::template Convert<Type2>(t, region_); | 133 return Type::template Convert<Type2>(t, region_); |
183 } | 134 } |
184 | 135 |
185 TypeHandle Fuzz(int depth = 5) { | |
186 switch (rng.NextInt(depth == 0 ? 3 : 20)) { | |
187 case 0: { // bitset | |
188 int n = 0 | |
189 #define COUNT_BITSET_TYPES(type, value) + 1 | |
190 BITSET_TYPE_LIST(COUNT_BITSET_TYPES) | |
191 #undef COUNT_BITSET_TYPES | |
192 ; | |
193 int i = rng.NextInt(n); | |
194 #define PICK_BITSET_TYPE(type, value) \ | |
195 if (i-- == 0) return Type::type(region_); | |
196 BITSET_TYPE_LIST(PICK_BITSET_TYPE) | |
197 #undef PICK_BITSET_TYPE | |
198 UNREACHABLE(); | |
199 } | |
200 case 1: // class | |
201 switch (rng.NextInt(2)) { | |
202 case 0: return ObjectClass; | |
203 case 1: return ArrayClass; | |
204 } | |
205 UNREACHABLE(); | |
206 case 2: // constant | |
207 switch (rng.NextInt(6)) { | |
208 case 0: return SmiConstant; | |
209 case 1: return Signed32Constant; | |
210 case 2: return ObjectConstant1; | |
211 case 3: return ObjectConstant2; | |
212 case 4: return ArrayConstant1; | |
213 case 5: return ArrayConstant2; | |
214 } | |
215 UNREACHABLE(); | |
216 default: { // union | |
217 int n = rng.NextInt(10); | |
218 TypeHandle type = None; | |
219 for (int i = 0; i < n; ++i) { | |
220 type = Type::Union(type, Fuzz(depth - 1), region_); | |
221 } | |
222 return type; | |
223 } | |
224 } | |
225 UNREACHABLE(); | |
226 } | |
227 | |
228 private: | 136 private: |
229 Region* region_; | 137 Region* region_; |
230 }; | 138 }; |
231 | 139 |
232 | 140 |
233 // Testing auxiliaries (breaking the Type abstraction). | 141 // Testing auxiliaries (breaking the Type abstraction). |
234 struct ZoneRep { | 142 struct ZoneRep { |
235 typedef void* Struct; | 143 typedef void* Struct; |
236 | 144 |
237 static bool IsStruct(Type* t, int tag) { | 145 static bool IsStruct(Type* t, int tag) { |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 } | 192 } |
285 static Struct* AsUnion(Handle<HeapType> t) { return AsStruct(t); } | 193 static Struct* AsUnion(Handle<HeapType> t) { return AsStruct(t); } |
286 static int Length(Struct* structured) { return structured->length() - 1; } | 194 static int Length(Struct* structured) { return structured->length() - 1; } |
287 | 195 |
288 static Isolate* ToRegion(Zone* zone, Isolate* isolate) { return isolate; } | 196 static Isolate* ToRegion(Zone* zone, Isolate* isolate) { return isolate; } |
289 }; | 197 }; |
290 | 198 |
291 | 199 |
292 template<class Type, class TypeHandle, class Region, class Rep> | 200 template<class Type, class TypeHandle, class Region, class Rep> |
293 struct Tests : Rep { | 201 struct Tests : Rep { |
| 202 typedef Types<Type, TypeHandle, Region> TypesInstance; |
| 203 typedef typename TypesInstance::TypeVector::iterator TypeIterator; |
| 204 typedef typename TypesInstance::ValueVector::iterator ValueIterator; |
| 205 |
294 Isolate* isolate; | 206 Isolate* isolate; |
295 HandleScope scope; | 207 HandleScope scope; |
296 Zone zone; | 208 Zone zone; |
297 Types<Type, TypeHandle, Region> T; | 209 TypesInstance T; |
298 typedef typename Types<Type, TypeHandle, Region>::TypeList::iterator | |
299 TypeIterator; | |
300 typedef typename Types<Type, TypeHandle, Region>::ObjectList::iterator | |
301 ObjectIterator; | |
302 | 210 |
303 Tests() : | 211 Tests() : |
304 isolate(CcTest::i_isolate()), | 212 isolate(CcTest::i_isolate()), |
305 scope(isolate), | 213 scope(isolate), |
306 zone(isolate), | 214 zone(isolate), |
307 T(Rep::ToRegion(&zone, isolate), isolate) { | 215 T(Rep::ToRegion(&zone, isolate), isolate) { |
308 } | 216 } |
309 | 217 |
310 void CheckEqual(TypeHandle type1, TypeHandle type2) { | 218 void CheckEqual(TypeHandle type1, TypeHandle type2) { |
311 CHECK_EQ(Rep::IsBitset(type1), Rep::IsBitset(type2)); | 219 CHECK_EQ(Rep::IsBitset(type1), Rep::IsBitset(type2)); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 CHECK(this->IsClass(T.ArrayClass)); | 295 CHECK(this->IsClass(T.ArrayClass)); |
388 | 296 |
389 CHECK(*T.object_map == this->AsClass(T.ObjectClass)); | 297 CHECK(*T.object_map == this->AsClass(T.ObjectClass)); |
390 CHECK(*T.array_map == this->AsClass(T.ArrayClass)); | 298 CHECK(*T.array_map == this->AsClass(T.ArrayClass)); |
391 } | 299 } |
392 | 300 |
393 void Constant() { | 301 void Constant() { |
394 CHECK(this->IsConstant(T.SmiConstant)); | 302 CHECK(this->IsConstant(T.SmiConstant)); |
395 CHECK(this->IsConstant(T.ObjectConstant1)); | 303 CHECK(this->IsConstant(T.ObjectConstant1)); |
396 CHECK(this->IsConstant(T.ObjectConstant2)); | 304 CHECK(this->IsConstant(T.ObjectConstant2)); |
397 CHECK(this->IsConstant(T.ArrayConstant1)); | 305 CHECK(this->IsConstant(T.ArrayConstant)); |
398 CHECK(this->IsConstant(T.ArrayConstant2)); | |
399 | 306 |
400 CHECK(*T.smi == this->AsConstant(T.SmiConstant)); | 307 CHECK(*T.smi == this->AsConstant(T.SmiConstant)); |
401 CHECK(*T.object1 == this->AsConstant(T.ObjectConstant1)); | 308 CHECK(*T.object1 == this->AsConstant(T.ObjectConstant1)); |
402 CHECK(*T.object2 == this->AsConstant(T.ObjectConstant2)); | 309 CHECK(*T.object2 == this->AsConstant(T.ObjectConstant2)); |
403 CHECK(*T.object1 != this->AsConstant(T.ObjectConstant2)); | 310 CHECK(*T.object1 != this->AsConstant(T.ObjectConstant2)); |
404 CHECK(*T.array == this->AsConstant(T.ArrayConstant1)); | 311 CHECK(*T.array == this->AsConstant(T.ArrayConstant)); |
405 CHECK(*T.array == this->AsConstant(T.ArrayConstant2)); | 312 } |
| 313 |
| 314 void Of() { |
| 315 CHECK(T.Of(T.smi)->Is(T.SignedSmall)); |
| 316 CHECK(T.Of(T.signed32)->Is(T.Signed32)); |
| 317 CHECK(T.Of(T.object1)->Is(T.Object)); |
| 318 CHECK(T.Of(T.object2)->Is(T.Object)); |
| 319 CHECK(T.Of(T.array)->Is(T.Array)); |
| 320 } |
| 321 |
| 322 void NowOf() { |
| 323 // NowOf(V)->Is(Of(V)) for all V |
| 324 for (ValueIterator vt = T.values.begin(); vt != T.values.end(); ++vt) { |
| 325 Handle<i::Object> val = *vt; |
| 326 CHECK(T.NowOf(val)->Is(T.Of(val))); |
| 327 } |
| 328 |
| 329 CHECK(T.NowOf(T.smi)->NowIs(T.SignedSmall)); |
| 330 CHECK(T.NowOf(T.signed32)->NowIs(T.Signed32)); |
| 331 CHECK(T.NowOf(T.object1)->NowIs(T.ObjectClass)); |
| 332 CHECK(T.NowOf(T.object2)->NowIs(T.ObjectClass)); |
| 333 CHECK(T.NowOf(T.array)->NowIs(T.Array)); |
406 } | 334 } |
407 | 335 |
408 void Is() { | 336 void Is() { |
409 // T->Is(None) implies T = None for all T | 337 // T->Is(None) implies T = None for all T |
410 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { | 338 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { |
411 TypeHandle type = *it; | 339 TypeHandle type = *it; |
412 if (type->Is(T.None)) CheckEqual(type, T.None); | 340 if (type->Is(T.None)) CheckEqual(type, T.None); |
413 } | 341 } |
414 | 342 |
415 // None->Is(T) for all T | 343 // None->Is(T) for all T |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
496 | 424 |
497 CheckSub(T.ObjectClass, T.Object); | 425 CheckSub(T.ObjectClass, T.Object); |
498 CheckSub(T.ArrayClass, T.Object); | 426 CheckSub(T.ArrayClass, T.Object); |
499 CheckUnordered(T.ObjectClass, T.ArrayClass); | 427 CheckUnordered(T.ObjectClass, T.ArrayClass); |
500 | 428 |
501 CheckSub(T.SmiConstant, T.SignedSmall); | 429 CheckSub(T.SmiConstant, T.SignedSmall); |
502 CheckSub(T.SmiConstant, T.Signed32); | 430 CheckSub(T.SmiConstant, T.Signed32); |
503 CheckSub(T.SmiConstant, T.Number); | 431 CheckSub(T.SmiConstant, T.Number); |
504 CheckSub(T.ObjectConstant1, T.Object); | 432 CheckSub(T.ObjectConstant1, T.Object); |
505 CheckSub(T.ObjectConstant2, T.Object); | 433 CheckSub(T.ObjectConstant2, T.Object); |
506 CheckSub(T.ArrayConstant1, T.Object); | 434 CheckSub(T.ArrayConstant, T.Object); |
507 CheckSub(T.ArrayConstant1, T.Array); | 435 CheckSub(T.ArrayConstant, T.Array); |
508 CheckUnordered(T.ObjectConstant1, T.ObjectConstant2); | 436 CheckUnordered(T.ObjectConstant1, T.ObjectConstant2); |
509 CheckUnordered(T.ObjectConstant1, T.ArrayConstant1); | 437 CheckUnordered(T.ObjectConstant1, T.ArrayConstant); |
510 | 438 |
511 CheckUnordered(T.ObjectConstant1, T.ObjectClass); | 439 CheckUnordered(T.ObjectConstant1, T.ObjectClass); |
512 CheckUnordered(T.ObjectConstant2, T.ObjectClass); | 440 CheckUnordered(T.ObjectConstant2, T.ObjectClass); |
513 CheckUnordered(T.ObjectConstant1, T.ArrayClass); | 441 CheckUnordered(T.ObjectConstant1, T.ArrayClass); |
514 CheckUnordered(T.ObjectConstant2, T.ArrayClass); | 442 CheckUnordered(T.ObjectConstant2, T.ArrayClass); |
515 CheckUnordered(T.ArrayConstant1, T.ObjectClass); | 443 CheckUnordered(T.ArrayConstant, T.ObjectClass); |
516 } | 444 } |
517 | 445 |
518 void NowIs() { | 446 void NowIs() { |
519 // T->NowIs(None) implies T = None for all T | 447 // T->NowIs(None) implies T = None for all T |
520 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { | 448 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { |
521 TypeHandle type = *it; | 449 TypeHandle type = *it; |
522 if (type->NowIs(T.None)) CheckEqual(type, T.None); | 450 if (type->NowIs(T.None)) CheckEqual(type, T.None); |
523 } | 451 } |
524 | 452 |
525 // None->NowIs(T) for all T | 453 // None->NowIs(T) for all T |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
567 TypeHandle type2 = *it2; | 495 TypeHandle type2 = *it2; |
568 CHECK(!type1->Is(type2) || type1->NowIs(type2)); | 496 CHECK(!type1->Is(type2) || type1->NowIs(type2)); |
569 } | 497 } |
570 } | 498 } |
571 | 499 |
572 CHECK(T.ObjectConstant1->NowIs(T.ObjectClass)); | 500 CHECK(T.ObjectConstant1->NowIs(T.ObjectClass)); |
573 CHECK(T.ObjectConstant2->NowIs(T.ObjectClass)); | 501 CHECK(T.ObjectConstant2->NowIs(T.ObjectClass)); |
574 } | 502 } |
575 | 503 |
576 void Contains() { | 504 void Contains() { |
577 // T->Contains(O) iff Constant(O)->Is(T) for all T,O | 505 // T->Contains(V) iff Constant(V)->Is(T) for all T,V |
578 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { | 506 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { |
579 for (ObjectIterator ot = T.objects.begin(); ot != T.objects.end(); ++ot) { | 507 for (ValueIterator vt = T.values.begin(); vt != T.values.end(); ++vt) { |
580 TypeHandle type = *it; | 508 TypeHandle type = *it; |
581 Handle<i::Object> obj = *ot; | 509 Handle<i::Object> val = *vt; |
582 CHECK(type->Contains(obj) == T.Constant(obj)->Is(type)); | 510 CHECK(type->Contains(val) == T.Constant(val)->Is(type)); |
583 } | 511 } |
584 } | 512 } |
585 | 513 |
586 // Of(O)->Is(T) implies T->Contains(O) for all T,O | 514 // Of(V)->Is(T) implies T->Contains(V) for all T,V |
587 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { | 515 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { |
588 for (ObjectIterator ot = T.objects.begin(); ot != T.objects.end(); ++ot) { | 516 for (ValueIterator vt = T.values.begin(); vt != T.values.end(); ++vt) { |
589 TypeHandle type = *it; | 517 TypeHandle type = *it; |
590 Handle<i::Object> obj = *ot; | 518 Handle<i::Object> val = *vt; |
591 CHECK(!T.Of(obj)->Is(type) || type->Contains(obj)); | 519 CHECK(!T.Of(val)->Is(type) || type->Contains(val)); |
592 } | 520 } |
593 } | 521 } |
594 } | 522 } |
| 523 |
| 524 void NowContains() { |
| 525 // T->NowContains(V) iff Constant(V)->NowIs(T) for all T,V |
| 526 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { |
| 527 for (ValueIterator vt = T.values.begin(); vt != T.values.end(); ++vt) { |
| 528 TypeHandle type = *it; |
| 529 Handle<i::Object> val = *vt; |
| 530 CHECK(type->NowContains(val) == T.Constant(val)->NowIs(type)); |
| 531 } |
| 532 } |
| 533 |
| 534 // NowOf(V)->Is(T) implies T->NowContains(V) for all T,V |
| 535 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { |
| 536 for (ValueIterator vt = T.values.begin(); vt != T.values.end(); ++vt) { |
| 537 TypeHandle type = *it; |
| 538 Handle<i::Object> value = *vt; |
| 539 CHECK(!T.NowOf(value)->NowIs(type) || type->NowContains(value)); |
| 540 } |
| 541 } |
| 542 |
| 543 // NowOf(V)->NowIs(T) implies T->NowContains(V) for all T,V |
| 544 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { |
| 545 for (ValueIterator vt = T.values.begin(); vt != T.values.end(); ++vt) { |
| 546 TypeHandle type = *it; |
| 547 Handle<i::Object> val = *vt; |
| 548 CHECK(!T.NowOf(val)->NowIs(type) || type->NowContains(val)); |
| 549 } |
| 550 } |
| 551 |
| 552 // T->Contains(V) implies T->NowContains(V) for all T,V |
| 553 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { |
| 554 for (ValueIterator vt = T.values.begin(); vt != T.values.end(); ++vt) { |
| 555 TypeHandle type = *it; |
| 556 Handle<i::Object> val = *vt; |
| 557 CHECK(!type->Contains(val) || type->NowContains(val)); |
| 558 } |
| 559 } |
| 560 } |
595 | 561 |
596 void Maybe() { | 562 void Maybe() { |
597 // T->Maybe(T) for all inhabited T | 563 // T->Maybe(T) for all inhabited T |
598 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { | 564 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { |
599 TypeHandle type = *it; | 565 TypeHandle type = *it; |
600 CHECK(type->Maybe(type) || !type->IsInhabited()); | 566 CHECK(type->Maybe(type) || !type->IsInhabited()); |
601 } | 567 } |
602 | 568 |
603 // Commutativity | 569 // Symmetry |
604 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { | 570 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { |
605 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { | 571 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { |
606 TypeHandle type1 = *it1; | 572 TypeHandle type1 = *it1; |
607 TypeHandle type2 = *it2; | 573 TypeHandle type2 = *it2; |
608 CHECK(type1->Maybe(type2) == type2->Maybe(type1)); | 574 CHECK(type1->Maybe(type2) == type2->Maybe(type1)); |
609 } | 575 } |
610 } | 576 } |
611 | 577 |
612 // T1->Is(T2) implies T1->Maybe(T2) or T1 is uninhabited for all T1,T2 | 578 // T1->Is(T2) implies T1->Maybe(T2) or T1 is uninhabited for all T1,T2 |
613 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { | 579 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
662 CheckOverlap(T.ObjectClass, T.ObjectClass, T.Semantic); | 628 CheckOverlap(T.ObjectClass, T.ObjectClass, T.Semantic); |
663 CheckOverlap(T.ArrayClass, T.ArrayClass, T.Semantic); | 629 CheckOverlap(T.ArrayClass, T.ArrayClass, T.Semantic); |
664 CheckDisjoint(T.ObjectClass, T.ArrayClass, T.Semantic); | 630 CheckDisjoint(T.ObjectClass, T.ArrayClass, T.Semantic); |
665 | 631 |
666 CheckOverlap(T.SmiConstant, T.SignedSmall, T.Semantic); | 632 CheckOverlap(T.SmiConstant, T.SignedSmall, T.Semantic); |
667 CheckOverlap(T.SmiConstant, T.Signed32, T.Semantic); | 633 CheckOverlap(T.SmiConstant, T.Signed32, T.Semantic); |
668 CheckOverlap(T.SmiConstant, T.Number, T.Semantic); | 634 CheckOverlap(T.SmiConstant, T.Number, T.Semantic); |
669 CheckDisjoint(T.SmiConstant, T.Float, T.Semantic); | 635 CheckDisjoint(T.SmiConstant, T.Float, T.Semantic); |
670 CheckOverlap(T.ObjectConstant1, T.Object, T.Semantic); | 636 CheckOverlap(T.ObjectConstant1, T.Object, T.Semantic); |
671 CheckOverlap(T.ObjectConstant2, T.Object, T.Semantic); | 637 CheckOverlap(T.ObjectConstant2, T.Object, T.Semantic); |
672 CheckOverlap(T.ArrayConstant1, T.Object, T.Semantic); | 638 CheckOverlap(T.ArrayConstant, T.Object, T.Semantic); |
673 CheckOverlap(T.ArrayConstant1, T.Array, T.Semantic); | 639 CheckOverlap(T.ArrayConstant, T.Array, T.Semantic); |
674 CheckOverlap(T.ArrayConstant1, T.ArrayConstant2, T.Semantic); | |
675 CheckOverlap(T.ObjectConstant1, T.ObjectConstant1, T.Semantic); | 640 CheckOverlap(T.ObjectConstant1, T.ObjectConstant1, T.Semantic); |
676 CheckDisjoint(T.ObjectConstant1, T.ObjectConstant2, T.Semantic); | 641 CheckDisjoint(T.ObjectConstant1, T.ObjectConstant2, T.Semantic); |
677 CheckDisjoint(T.ObjectConstant1, T.ArrayConstant1, T.Semantic); | 642 CheckDisjoint(T.ObjectConstant1, T.ArrayConstant, T.Semantic); |
678 | 643 |
679 CheckDisjoint(T.ObjectConstant1, T.ObjectClass, T.Semantic); | 644 CheckDisjoint(T.ObjectConstant1, T.ObjectClass, T.Semantic); |
680 CheckDisjoint(T.ObjectConstant2, T.ObjectClass, T.Semantic); | 645 CheckDisjoint(T.ObjectConstant2, T.ObjectClass, T.Semantic); |
681 CheckDisjoint(T.ObjectConstant1, T.ArrayClass, T.Semantic); | 646 CheckDisjoint(T.ObjectConstant1, T.ArrayClass, T.Semantic); |
682 CheckDisjoint(T.ObjectConstant2, T.ArrayClass, T.Semantic); | 647 CheckDisjoint(T.ObjectConstant2, T.ArrayClass, T.Semantic); |
683 CheckDisjoint(T.ArrayConstant1, T.ObjectClass, T.Semantic); | 648 CheckDisjoint(T.ArrayConstant, T.ObjectClass, T.Semantic); |
684 } | 649 } |
685 | 650 |
686 void Union() { | 651 void Union() { |
687 // Bitset-bitset | 652 // Bitset-bitset |
688 CHECK(this->IsBitset(T.Union(T.Object, T.Number))); | 653 CHECK(this->IsBitset(T.Union(T.Object, T.Number))); |
689 CHECK(this->IsBitset(T.Union(T.Object, T.Object))); | 654 CHECK(this->IsBitset(T.Union(T.Object, T.Object))); |
690 CHECK(this->IsBitset(T.Union(T.Any, T.None))); | 655 CHECK(this->IsBitset(T.Union(T.Any, T.None))); |
691 | 656 |
692 CheckEqual(T.Union(T.None, T.Number), T.Number); | 657 CheckEqual(T.Union(T.None, T.Number), T.Number); |
693 CheckEqual(T.Union(T.Object, T.Proxy), T.Receiver); | 658 CheckEqual(T.Union(T.Object, T.Proxy), T.Receiver); |
694 CheckEqual(T.Union(T.Number, T.String), T.Union(T.String, T.Number)); | 659 CheckEqual(T.Union(T.Number, T.String), T.Union(T.String, T.Number)); |
695 CheckSub(T.Union(T.Number, T.String), T.Any); | 660 CheckSub(T.Union(T.Number, T.String), T.Any); |
696 | 661 |
697 // Class-class | 662 // Class-class |
698 CHECK(this->IsClass(T.Union(T.ObjectClass, T.ObjectClass))); | 663 CHECK(this->IsClass(T.Union(T.ObjectClass, T.ObjectClass))); |
699 CHECK(this->IsUnion(T.Union(T.ObjectClass, T.ArrayClass))); | 664 CHECK(this->IsUnion(T.Union(T.ObjectClass, T.ArrayClass))); |
700 | 665 |
701 CheckEqual(T.Union(T.ObjectClass, T.ObjectClass), T.ObjectClass); | 666 CheckEqual(T.Union(T.ObjectClass, T.ObjectClass), T.ObjectClass); |
702 CheckSub(T.None, T.Union(T.ObjectClass, T.ArrayClass)); | 667 CheckSub(T.None, T.Union(T.ObjectClass, T.ArrayClass)); |
703 CheckSub(T.Union(T.ObjectClass, T.ArrayClass), T.Any); | 668 CheckSub(T.Union(T.ObjectClass, T.ArrayClass), T.Any); |
704 CheckSub(T.ObjectClass, T.Union(T.ObjectClass, T.ArrayClass)); | 669 CheckSub(T.ObjectClass, T.Union(T.ObjectClass, T.ArrayClass)); |
705 CheckSub(T.ArrayClass, T.Union(T.ObjectClass, T.ArrayClass)); | 670 CheckSub(T.ArrayClass, T.Union(T.ObjectClass, T.ArrayClass)); |
706 CheckSub(T.Union(T.ObjectClass, T.ArrayClass), T.Object); | 671 CheckSub(T.Union(T.ObjectClass, T.ArrayClass), T.Object); |
707 CheckUnordered(T.Union(T.ObjectClass, T.ArrayClass), T.Array); | 672 CheckUnordered(T.Union(T.ObjectClass, T.ArrayClass), T.Array); |
708 CheckOverlap(T.Union(T.ObjectClass, T.ArrayClass), T.Array, T.Semantic); | 673 CheckOverlap(T.Union(T.ObjectClass, T.ArrayClass), T.Array, T.Semantic); |
709 CheckDisjoint(T.Union(T.ObjectClass, T.ArrayClass), T.Number, T.Semantic); | 674 CheckDisjoint(T.Union(T.ObjectClass, T.ArrayClass), T.Number, T.Semantic); |
710 | 675 |
711 // Constant-constant | 676 // Constant-constant |
712 CHECK(this->IsConstant(T.Union(T.ObjectConstant1, T.ObjectConstant1))); | 677 CHECK(this->IsConstant(T.Union(T.ObjectConstant1, T.ObjectConstant1))); |
713 CHECK(this->IsConstant(T.Union(T.ArrayConstant1, T.ArrayConstant1))); | 678 CHECK(this->IsConstant(T.Union(T.ArrayConstant, T.ArrayConstant))); |
714 CHECK(this->IsUnion(T.Union(T.ObjectConstant1, T.ObjectConstant2))); | 679 CHECK(this->IsUnion(T.Union(T.ObjectConstant1, T.ObjectConstant2))); |
715 | 680 |
716 CheckEqual( | 681 CheckEqual( |
717 T.Union(T.ObjectConstant1, T.ObjectConstant1), | 682 T.Union(T.ObjectConstant1, T.ObjectConstant1), |
718 T.ObjectConstant1); | 683 T.ObjectConstant1); |
719 CheckEqual(T.Union(T.ArrayConstant1, T.ArrayConstant1), T.ArrayConstant1); | 684 CheckEqual(T.Union(T.ArrayConstant, T.ArrayConstant), T.ArrayConstant); |
720 CheckEqual(T.Union(T.ArrayConstant1, T.ArrayConstant1), T.ArrayConstant2); | |
721 CheckSub(T.None, T.Union(T.ObjectConstant1, T.ObjectConstant2)); | 685 CheckSub(T.None, T.Union(T.ObjectConstant1, T.ObjectConstant2)); |
722 CheckSub(T.Union(T.ObjectConstant1, T.ObjectConstant2), T.Any); | 686 CheckSub(T.Union(T.ObjectConstant1, T.ObjectConstant2), T.Any); |
723 CheckSub(T.ObjectConstant1, T.Union(T.ObjectConstant1, T.ObjectConstant2)); | 687 CheckSub(T.ObjectConstant1, T.Union(T.ObjectConstant1, T.ObjectConstant2)); |
724 CheckSub(T.ObjectConstant2, T.Union(T.ObjectConstant1, T.ObjectConstant2)); | 688 CheckSub(T.ObjectConstant2, T.Union(T.ObjectConstant1, T.ObjectConstant2)); |
725 CheckSub(T.ArrayConstant2, T.Union(T.ArrayConstant1, T.ObjectConstant2)); | |
726 CheckSub(T.Union(T.ObjectConstant1, T.ObjectConstant2), T.Object); | 689 CheckSub(T.Union(T.ObjectConstant1, T.ObjectConstant2), T.Object); |
727 CheckUnordered( | 690 CheckUnordered( |
728 T.Union(T.ObjectConstant1, T.ObjectConstant2), T.ObjectClass); | 691 T.Union(T.ObjectConstant1, T.ObjectConstant2), T.ObjectClass); |
729 CheckUnordered(T.Union(T.ObjectConstant1, T.ArrayConstant1), T.Array); | 692 CheckUnordered(T.Union(T.ObjectConstant1, T.ArrayConstant), T.Array); |
730 CheckOverlap( | 693 CheckOverlap( |
731 T.Union(T.ObjectConstant1, T.ArrayConstant1), T.Array, T.Semantic); | 694 T.Union(T.ObjectConstant1, T.ArrayConstant), T.Array, T.Semantic); |
732 CheckOverlap( | |
733 T.Union(T.ObjectConstant1, T.ArrayConstant1), T.ArrayConstant2, | |
734 T.Semantic); | |
735 CheckDisjoint( | 695 CheckDisjoint( |
736 T.Union(T.ObjectConstant1, T.ArrayConstant1), T.Number, T.Semantic); | 696 T.Union(T.ObjectConstant1, T.ArrayConstant), T.Number, T.Semantic); |
737 CheckDisjoint( | 697 CheckDisjoint( |
738 T.Union(T.ObjectConstant1, T.ArrayConstant1), T.ObjectClass, | 698 T.Union(T.ObjectConstant1, T.ArrayConstant), T.ObjectClass, |
739 T.Semantic); | 699 T.Semantic); |
740 | 700 |
741 // Bitset-class | 701 // Bitset-class |
742 CHECK(this->IsBitset(T.Union(T.ObjectClass, T.Object))); | 702 CHECK(this->IsBitset(T.Union(T.ObjectClass, T.Object))); |
743 CHECK(this->IsUnion(T.Union(T.ObjectClass, T.Number))); | 703 CHECK(this->IsUnion(T.Union(T.ObjectClass, T.Number))); |
744 | 704 |
745 CheckEqual(T.Union(T.ObjectClass, T.Object), T.Object); | 705 CheckEqual(T.Union(T.ObjectClass, T.Object), T.Object); |
746 CheckSub(T.None, T.Union(T.ObjectClass, T.Number)); | 706 CheckSub(T.None, T.Union(T.ObjectClass, T.Number)); |
747 CheckSub(T.Union(T.ObjectClass, T.Number), T.Any); | 707 CheckSub(T.Union(T.ObjectClass, T.Number), T.Any); |
748 CheckSub( | 708 CheckSub( |
(...skipping 25 matching lines...) Expand all Loading... |
774 CHECK(this->IsUnion(T.Union(T.ArrayClass, T.ObjectConstant2))); | 734 CHECK(this->IsUnion(T.Union(T.ArrayClass, T.ObjectConstant2))); |
775 | 735 |
776 CheckSub(T.None, T.Union(T.ObjectConstant1, T.ArrayClass)); | 736 CheckSub(T.None, T.Union(T.ObjectConstant1, T.ArrayClass)); |
777 CheckSub(T.Union(T.ObjectConstant1, T.ArrayClass), T.Any); | 737 CheckSub(T.Union(T.ObjectConstant1, T.ArrayClass), T.Any); |
778 CheckSub(T.Union(T.ObjectConstant1, T.ArrayClass), T.Object); | 738 CheckSub(T.Union(T.ObjectConstant1, T.ArrayClass), T.Object); |
779 CheckSub(T.ObjectConstant1, T.Union(T.ObjectConstant1, T.ArrayClass)); | 739 CheckSub(T.ObjectConstant1, T.Union(T.ObjectConstant1, T.ArrayClass)); |
780 CheckSub(T.ArrayClass, T.Union(T.ObjectConstant1, T.ArrayClass)); | 740 CheckSub(T.ArrayClass, T.Union(T.ObjectConstant1, T.ArrayClass)); |
781 CheckUnordered(T.ObjectClass, T.Union(T.ObjectConstant1, T.ArrayClass)); | 741 CheckUnordered(T.ObjectClass, T.Union(T.ObjectConstant1, T.ArrayClass)); |
782 CheckSub( | 742 CheckSub( |
783 T.Union(T.ObjectConstant1, T.ArrayClass), T.Union(T.Array, T.Object)); | 743 T.Union(T.ObjectConstant1, T.ArrayClass), T.Union(T.Array, T.Object)); |
784 CheckUnordered(T.Union(T.ObjectConstant1, T.ArrayClass), T.ArrayConstant1); | 744 CheckUnordered(T.Union(T.ObjectConstant1, T.ArrayClass), T.ArrayConstant); |
785 CheckDisjoint( | 745 CheckDisjoint( |
786 T.Union(T.ObjectConstant1, T.ArrayClass), T.ObjectConstant2, | 746 T.Union(T.ObjectConstant1, T.ArrayClass), T.ObjectConstant2, |
787 T.Semantic); | 747 T.Semantic); |
788 CheckDisjoint( | 748 CheckDisjoint( |
789 T.Union(T.ObjectConstant1, T.ArrayClass), T.ObjectClass, T.Semantic); | 749 T.Union(T.ObjectConstant1, T.ArrayClass), T.ObjectClass, T.Semantic); |
790 | 750 |
791 // Bitset-union | 751 // Bitset-union |
792 CHECK(this->IsBitset( | 752 CHECK(this->IsBitset( |
793 T.Union(T.Object, T.Union(T.ObjectConstant1, T.ObjectClass)))); | 753 T.Union(T.Object, T.Union(T.ObjectConstant1, T.ObjectClass)))); |
794 CHECK(this->IsUnion( | 754 CHECK(this->IsUnion( |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
835 T.Union(T.ObjectClass, T.Union(T.ObjectConstant1, T.ObjectClass)), | 795 T.Union(T.ObjectClass, T.Union(T.ObjectConstant1, T.ObjectClass)), |
836 T.Object); | 796 T.Object); |
837 CheckEqual( | 797 CheckEqual( |
838 T.Union(T.Union(T.ArrayClass, T.ObjectConstant2), T.ArrayClass), | 798 T.Union(T.Union(T.ArrayClass, T.ObjectConstant2), T.ArrayClass), |
839 T.Union(T.ArrayClass, T.ObjectConstant2)); | 799 T.Union(T.ArrayClass, T.ObjectConstant2)); |
840 | 800 |
841 // Constant-union | 801 // Constant-union |
842 CHECK(this->IsUnion(T.Union( | 802 CHECK(this->IsUnion(T.Union( |
843 T.ObjectConstant1, T.Union(T.ObjectConstant1, T.ObjectConstant2)))); | 803 T.ObjectConstant1, T.Union(T.ObjectConstant1, T.ObjectConstant2)))); |
844 CHECK(this->IsUnion(T.Union( | 804 CHECK(this->IsUnion(T.Union( |
845 T.Union(T.ArrayConstant1, T.ObjectClass), T.ObjectConstant1))); | 805 T.Union(T.ArrayConstant, T.ObjectClass), T.ObjectConstant1))); |
846 CHECK(this->IsUnion(T.Union( | 806 CHECK(this->IsUnion(T.Union( |
847 T.Union(T.ArrayConstant1, T.ObjectConstant2), T.ObjectConstant1))); | 807 T.Union(T.ArrayConstant, T.ObjectConstant2), T.ObjectConstant1))); |
848 | 808 |
849 CheckEqual( | 809 CheckEqual( |
850 T.Union( | 810 T.Union( |
851 T.ObjectConstant1, T.Union(T.ObjectConstant1, T.ObjectConstant2)), | 811 T.ObjectConstant1, T.Union(T.ObjectConstant1, T.ObjectConstant2)), |
852 T.Union(T.ObjectConstant2, T.ObjectConstant1)); | 812 T.Union(T.ObjectConstant2, T.ObjectConstant1)); |
853 CheckEqual( | 813 CheckEqual( |
854 T.Union( | 814 T.Union( |
855 T.Union(T.ArrayConstant1, T.ObjectConstant2), T.ObjectConstant1), | 815 T.Union(T.ArrayConstant, T.ObjectConstant2), T.ObjectConstant1), |
856 T.Union( | 816 T.Union( |
857 T.ObjectConstant2, T.Union(T.ArrayConstant1, T.ObjectConstant1))); | 817 T.ObjectConstant2, T.Union(T.ArrayConstant, T.ObjectConstant1))); |
858 | 818 |
859 // Union-union | 819 // Union-union |
860 CHECK(this->IsBitset(T.Union( | 820 CHECK(this->IsBitset(T.Union( |
861 T.Union(T.Number, T.ArrayClass), | 821 T.Union(T.Number, T.ArrayClass), |
862 T.Union(T.Signed32, T.Array)))); | 822 T.Union(T.Signed32, T.Array)))); |
863 CHECK(this->IsUnion(T.Union( | 823 CHECK(this->IsUnion(T.Union( |
864 T.Union(T.Number, T.ArrayClass), | 824 T.Union(T.Number, T.ArrayClass), |
865 T.Union(T.ObjectClass, T.ArrayClass)))); | 825 T.Union(T.ObjectClass, T.ArrayClass)))); |
866 | 826 |
867 CheckEqual( | 827 CheckEqual( |
868 T.Union( | 828 T.Union( |
869 T.Union(T.ObjectConstant2, T.ObjectConstant1), | 829 T.Union(T.ObjectConstant2, T.ObjectConstant1), |
870 T.Union(T.ObjectConstant1, T.ObjectConstant2)), | 830 T.Union(T.ObjectConstant1, T.ObjectConstant2)), |
871 T.Union(T.ObjectConstant2, T.ObjectConstant1)); | 831 T.Union(T.ObjectConstant2, T.ObjectConstant1)); |
872 CheckEqual( | 832 CheckEqual( |
873 T.Union( | 833 T.Union( |
874 T.Union(T.ObjectConstant2, T.ArrayConstant1), | |
875 T.Union(T.ObjectConstant1, T.ArrayConstant2)), | |
876 T.Union( | |
877 T.Union(T.ObjectConstant1, T.ObjectConstant2), | |
878 T.ArrayConstant1)); | |
879 CheckEqual( | |
880 T.Union( | |
881 T.Union(T.Number, T.ArrayClass), | 834 T.Union(T.Number, T.ArrayClass), |
882 T.Union(T.SignedSmall, T.Array)), | 835 T.Union(T.SignedSmall, T.Array)), |
883 T.Union(T.Number, T.Array)); | 836 T.Union(T.Number, T.Array)); |
884 } | 837 } |
885 | 838 |
886 void Intersect() { | 839 void Intersect() { |
887 // Bitset-bitset | 840 // Bitset-bitset |
888 CHECK(this->IsBitset(T.Intersect(T.Object, T.Number))); | 841 CHECK(this->IsBitset(T.Intersect(T.Object, T.Number))); |
889 CHECK(this->IsBitset(T.Intersect(T.Object, T.Object))); | 842 CHECK(this->IsBitset(T.Intersect(T.Object, T.Object))); |
890 CHECK(this->IsBitset(T.Intersect(T.Any, T.None))); | 843 CHECK(this->IsBitset(T.Intersect(T.Any, T.None))); |
891 | 844 |
892 CheckEqual(T.Intersect(T.None, T.Number), T.None); | 845 CheckEqual(T.Intersect(T.None, T.Number), T.None); |
893 CheckSub(T.Intersect(T.Object, T.Proxy), T.Representation); | 846 CheckSub(T.Intersect(T.Object, T.Proxy), T.Representation); |
894 CheckEqual(T.Intersect(T.Name, T.String), T.Intersect(T.String, T.Name)); | 847 CheckEqual(T.Intersect(T.Name, T.String), T.Intersect(T.String, T.Name)); |
895 CheckEqual(T.Intersect(T.UniqueName, T.String), T.InternalizedString); | 848 CheckEqual(T.Intersect(T.UniqueName, T.String), T.InternalizedString); |
896 | 849 |
897 // Class-class | 850 // Class-class |
898 CHECK(this->IsClass(T.Intersect(T.ObjectClass, T.ObjectClass))); | 851 CHECK(this->IsClass(T.Intersect(T.ObjectClass, T.ObjectClass))); |
899 CHECK(this->IsBitset(T.Intersect(T.ObjectClass, T.ArrayClass))); | 852 CHECK(this->IsBitset(T.Intersect(T.ObjectClass, T.ArrayClass))); |
900 | 853 |
901 CheckEqual(T.Intersect(T.ObjectClass, T.ObjectClass), T.ObjectClass); | 854 CheckEqual(T.Intersect(T.ObjectClass, T.ObjectClass), T.ObjectClass); |
902 CheckEqual(T.Intersect(T.ObjectClass, T.ArrayClass), T.None); | 855 CheckEqual(T.Intersect(T.ObjectClass, T.ArrayClass), T.None); |
903 | 856 |
904 // Constant-constant | 857 // Constant-constant |
905 CHECK(this->IsConstant(T.Intersect(T.ObjectConstant1, T.ObjectConstant1))); | 858 CHECK(this->IsConstant(T.Intersect(T.ObjectConstant1, T.ObjectConstant1))); |
906 CHECK(this->IsConstant(T.Intersect(T.ArrayConstant1, T.ArrayConstant2))); | |
907 CHECK(this->IsBitset(T.Intersect(T.ObjectConstant1, T.ObjectConstant2))); | 859 CHECK(this->IsBitset(T.Intersect(T.ObjectConstant1, T.ObjectConstant2))); |
908 | 860 |
909 CheckEqual( | 861 CheckEqual( |
910 T.Intersect(T.ObjectConstant1, T.ObjectConstant1), T.ObjectConstant1); | 862 T.Intersect(T.ObjectConstant1, T.ObjectConstant1), T.ObjectConstant1); |
911 CheckEqual( | |
912 T.Intersect(T.ArrayConstant1, T.ArrayConstant2), T.ArrayConstant1); | |
913 CheckEqual(T.Intersect(T.ObjectConstant1, T.ObjectConstant2), T.None); | 863 CheckEqual(T.Intersect(T.ObjectConstant1, T.ObjectConstant2), T.None); |
914 | 864 |
915 // Bitset-class | 865 // Bitset-class |
916 CHECK(this->IsClass(T.Intersect(T.ObjectClass, T.Object))); | 866 CHECK(this->IsClass(T.Intersect(T.ObjectClass, T.Object))); |
917 CHECK(this->IsBitset(T.Intersect(T.ObjectClass, T.Number))); | 867 CHECK(this->IsBitset(T.Intersect(T.ObjectClass, T.Number))); |
918 | 868 |
919 CheckEqual(T.Intersect(T.ObjectClass, T.Object), T.ObjectClass); | 869 CheckEqual(T.Intersect(T.ObjectClass, T.Object), T.ObjectClass); |
920 CheckSub(T.Intersect(T.ObjectClass, T.Array), T.Representation); | 870 CheckSub(T.Intersect(T.ObjectClass, T.Array), T.Representation); |
921 CheckSub(T.Intersect(T.ObjectClass, T.Number), T.Representation); | 871 CheckSub(T.Intersect(T.ObjectClass, T.Number), T.Representation); |
922 | 872 |
(...skipping 25 matching lines...) Expand all Loading... |
948 CheckEqual( | 898 CheckEqual( |
949 T.Intersect(T.Union(T.ArrayClass, T.ObjectConstant1), T.Number), | 899 T.Intersect(T.Union(T.ArrayClass, T.ObjectConstant1), T.Number), |
950 T.None); | 900 T.None); |
951 | 901 |
952 // Class-union | 902 // Class-union |
953 CHECK(this->IsClass( | 903 CHECK(this->IsClass( |
954 T.Intersect(T.Union(T.ArrayClass, T.ObjectConstant2), T.ArrayClass))); | 904 T.Intersect(T.Union(T.ArrayClass, T.ObjectConstant2), T.ArrayClass))); |
955 CHECK(this->IsClass( | 905 CHECK(this->IsClass( |
956 T.Intersect(T.Union(T.Object, T.SmiConstant), T.ArrayClass))); | 906 T.Intersect(T.Union(T.Object, T.SmiConstant), T.ArrayClass))); |
957 CHECK(this->IsBitset( | 907 CHECK(this->IsBitset( |
958 T.Intersect(T.Union(T.ObjectClass, T.ArrayConstant1), T.ArrayClass))); | 908 T.Intersect(T.Union(T.ObjectClass, T.ArrayConstant), T.ArrayClass))); |
959 | 909 |
960 CheckEqual( | 910 CheckEqual( |
961 T.Intersect(T.ArrayClass, T.Union(T.ObjectConstant2, T.ArrayClass)), | 911 T.Intersect(T.ArrayClass, T.Union(T.ObjectConstant2, T.ArrayClass)), |
962 T.ArrayClass); | 912 T.ArrayClass); |
963 CheckEqual( | 913 CheckEqual( |
964 T.Intersect(T.ArrayClass, T.Union(T.Object, T.SmiConstant)), | 914 T.Intersect(T.ArrayClass, T.Union(T.Object, T.SmiConstant)), |
965 T.ArrayClass); | 915 T.ArrayClass); |
966 CheckEqual( | 916 CheckEqual( |
967 T.Intersect(T.Union(T.ObjectClass, T.ArrayConstant1), T.ArrayClass), | 917 T.Intersect(T.Union(T.ObjectClass, T.ArrayConstant), T.ArrayClass), |
968 T.None); | 918 T.None); |
969 | 919 |
970 // Constant-union | 920 // Constant-union |
971 CHECK(this->IsConstant(T.Intersect( | 921 CHECK(this->IsConstant(T.Intersect( |
972 T.ObjectConstant1, T.Union(T.ObjectConstant1, T.ObjectConstant2)))); | 922 T.ObjectConstant1, T.Union(T.ObjectConstant1, T.ObjectConstant2)))); |
973 CHECK(this->IsConstant(T.Intersect( | 923 CHECK(this->IsConstant(T.Intersect( |
974 T.Union(T.Number, T.ObjectClass), T.SmiConstant))); | 924 T.Union(T.Number, T.ObjectClass), T.SmiConstant))); |
975 CHECK(this->IsBitset(T.Intersect( | 925 CHECK(this->IsBitset(T.Intersect( |
976 T.Union(T.ArrayConstant1, T.ObjectClass), T.ObjectConstant1))); | 926 T.Union(T.ArrayConstant, T.ObjectClass), T.ObjectConstant1))); |
977 | 927 |
978 CheckEqual( | 928 CheckEqual( |
979 T.Intersect( | 929 T.Intersect( |
980 T.ObjectConstant1, T.Union(T.ObjectConstant1, T.ObjectConstant2)), | 930 T.ObjectConstant1, T.Union(T.ObjectConstant1, T.ObjectConstant2)), |
981 T.ObjectConstant1); | 931 T.ObjectConstant1); |
982 CheckEqual( | 932 CheckEqual( |
983 T.Intersect(T.SmiConstant, T.Union(T.Number, T.ObjectConstant2)), | 933 T.Intersect(T.SmiConstant, T.Union(T.Number, T.ObjectConstant2)), |
984 T.SmiConstant); | 934 T.SmiConstant); |
985 CheckEqual( | 935 CheckEqual( |
986 T.Intersect( | 936 T.Intersect( |
987 T.Union(T.ArrayConstant1, T.ObjectClass), T.ObjectConstant1), | 937 T.Union(T.ArrayConstant, T.ObjectClass), T.ObjectConstant1), |
988 T.None); | 938 T.None); |
989 | 939 |
990 // Union-union | 940 // Union-union |
991 CHECK(this->IsUnion(T.Intersect( | 941 CHECK(this->IsUnion(T.Intersect( |
992 T.Union(T.Number, T.ArrayClass), T.Union(T.Signed32, T.Array)))); | 942 T.Union(T.Number, T.ArrayClass), T.Union(T.Signed32, T.Array)))); |
993 CHECK(this->IsBitset(T.Intersect( | 943 CHECK(this->IsBitset(T.Intersect( |
994 T.Union(T.Number, T.ObjectClass), T.Union(T.Signed32, T.Array)))); | 944 T.Union(T.Number, T.ObjectClass), T.Union(T.Signed32, T.Array)))); |
995 | 945 |
996 CheckEqual( | 946 CheckEqual( |
997 T.Intersect( | 947 T.Intersect( |
998 T.Union(T.Number, T.ArrayClass), | 948 T.Union(T.Number, T.ArrayClass), |
999 T.Union(T.SignedSmall, T.Array)), | 949 T.Union(T.SignedSmall, T.Array)), |
1000 T.Union(T.SignedSmall, T.ArrayClass)); | 950 T.Union(T.SignedSmall, T.ArrayClass)); |
1001 CheckEqual( | 951 CheckEqual( |
1002 T.Intersect( | 952 T.Intersect( |
1003 T.Union(T.Number, T.ObjectClass), | 953 T.Union(T.Number, T.ObjectClass), |
1004 T.Union(T.Signed32, T.Array)), | 954 T.Union(T.Signed32, T.Array)), |
1005 T.Signed32); | 955 T.Signed32); |
1006 CheckEqual( | 956 CheckEqual( |
1007 T.Intersect( | 957 T.Intersect( |
1008 T.Union(T.ObjectConstant2, T.ObjectConstant1), | 958 T.Union(T.ObjectConstant2, T.ObjectConstant1), |
1009 T.Union(T.ObjectConstant1, T.ObjectConstant2)), | 959 T.Union(T.ObjectConstant1, T.ObjectConstant2)), |
1010 T.Union(T.ObjectConstant2, T.ObjectConstant1)); | 960 T.Union(T.ObjectConstant2, T.ObjectConstant1)); |
1011 CheckEqual( | 961 CheckEqual( |
1012 T.Intersect( | 962 T.Intersect( |
1013 T.Union( | 963 T.Union( |
1014 T.Union(T.ObjectConstant2, T.ObjectConstant1), T.ArrayClass), | 964 T.Union(T.ObjectConstant2, T.ObjectConstant1), T.ArrayClass), |
1015 T.Union( | 965 T.Union( |
1016 T.ObjectConstant1, | 966 T.ObjectConstant1, |
1017 T.Union(T.ArrayConstant1, T.ObjectConstant2))), | 967 T.Union(T.ArrayConstant, T.ObjectConstant2))), |
1018 T.Union(T.ObjectConstant2, T.ObjectConstant1)); | 968 T.Union(T.ObjectConstant2, T.ObjectConstant1)); |
1019 CheckEqual( | |
1020 T.Intersect( | |
1021 T.Union(T.ObjectConstant2, T.ArrayConstant1), | |
1022 T.Union(T.ObjectConstant1, T.ArrayConstant2)), | |
1023 T.ArrayConstant1); | |
1024 } | 969 } |
1025 | 970 |
1026 template<class Type2, class TypeHandle2, class Region2, class Rep2> | 971 template<class Type2, class TypeHandle2, class Region2, class Rep2> |
1027 void Convert() { | 972 void Convert() { |
1028 Types<Type2, TypeHandle2, Region2> T2( | 973 Types<Type2, TypeHandle2, Region2> T2( |
1029 Rep2::ToRegion(&zone, isolate), isolate); | 974 Rep2::ToRegion(&zone, isolate), isolate); |
1030 for (int i = 0; i < 100; ++i) { | 975 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { |
1031 TypeHandle type = T.Fuzz(); | 976 TypeHandle type = *it; |
1032 CheckEqual(type, | 977 CheckEqual(type, |
1033 T.template Convert<Type2>(T2.template Convert<Type>(type))); | 978 T.template Convert<Type2>(T2.template Convert<Type>(type))); |
1034 } | 979 } |
1035 } | 980 } |
1036 }; | 981 }; |
1037 | 982 |
1038 typedef Tests<Type, Type*, Zone, ZoneRep> ZoneTests; | 983 typedef Tests<Type, Type*, Zone, ZoneRep> ZoneTests; |
1039 typedef Tests<HeapType, Handle<HeapType>, Isolate, HeapRep> HeapTests; | 984 typedef Tests<HeapType, Handle<HeapType>, Isolate, HeapRep> HeapTests; |
1040 | 985 |
1041 | 986 |
(...skipping 11 matching lines...) Expand all Loading... |
1053 } | 998 } |
1054 | 999 |
1055 | 1000 |
1056 TEST(Constant) { | 1001 TEST(Constant) { |
1057 CcTest::InitializeVM(); | 1002 CcTest::InitializeVM(); |
1058 ZoneTests().Constant(); | 1003 ZoneTests().Constant(); |
1059 HeapTests().Constant(); | 1004 HeapTests().Constant(); |
1060 } | 1005 } |
1061 | 1006 |
1062 | 1007 |
| 1008 TEST(Of) { |
| 1009 CcTest::InitializeVM(); |
| 1010 ZoneTests().Of(); |
| 1011 HeapTests().Of(); |
| 1012 } |
| 1013 |
| 1014 |
| 1015 TEST(NowOf) { |
| 1016 CcTest::InitializeVM(); |
| 1017 ZoneTests().NowOf(); |
| 1018 HeapTests().NowOf(); |
| 1019 } |
| 1020 |
| 1021 |
1063 TEST(Is) { | 1022 TEST(Is) { |
1064 CcTest::InitializeVM(); | 1023 CcTest::InitializeVM(); |
1065 ZoneTests().Is(); | 1024 ZoneTests().Is(); |
1066 HeapTests().Is(); | 1025 HeapTests().Is(); |
1067 } | 1026 } |
1068 | 1027 |
1069 | 1028 |
1070 TEST(NowIs) { | 1029 TEST(NowIs) { |
1071 CcTest::InitializeVM(); | 1030 CcTest::InitializeVM(); |
1072 ZoneTests().NowIs(); | 1031 ZoneTests().NowIs(); |
1073 HeapTests().NowIs(); | 1032 HeapTests().NowIs(); |
1074 } | 1033 } |
1075 | 1034 |
1076 | 1035 |
1077 TEST(Contains) { | 1036 TEST(Contains) { |
1078 CcTest::InitializeVM(); | 1037 CcTest::InitializeVM(); |
1079 ZoneTests().Contains(); | 1038 ZoneTests().Contains(); |
1080 HeapTests().Contains(); | 1039 HeapTests().Contains(); |
1081 } | 1040 } |
1082 | 1041 |
1083 | 1042 |
| 1043 TEST(NowContains) { |
| 1044 CcTest::InitializeVM(); |
| 1045 ZoneTests().NowContains(); |
| 1046 HeapTests().NowContains(); |
| 1047 } |
| 1048 |
| 1049 |
1084 TEST(Maybe) { | 1050 TEST(Maybe) { |
1085 CcTest::InitializeVM(); | 1051 CcTest::InitializeVM(); |
1086 ZoneTests().Maybe(); | 1052 ZoneTests().Maybe(); |
1087 HeapTests().Maybe(); | 1053 HeapTests().Maybe(); |
1088 } | 1054 } |
1089 | 1055 |
1090 | 1056 |
1091 TEST(Union) { | 1057 TEST(Union) { |
1092 CcTest::InitializeVM(); | 1058 CcTest::InitializeVM(); |
1093 ZoneTests().Union(); | 1059 ZoneTests().Union(); |
1094 HeapTests().Union(); | 1060 HeapTests().Union(); |
1095 } | 1061 } |
1096 | 1062 |
1097 | 1063 |
1098 TEST(Intersect) { | 1064 TEST(Intersect) { |
1099 CcTest::InitializeVM(); | 1065 CcTest::InitializeVM(); |
1100 ZoneTests().Intersect(); | 1066 ZoneTests().Intersect(); |
1101 HeapTests().Intersect(); | 1067 HeapTests().Intersect(); |
1102 } | 1068 } |
1103 | 1069 |
1104 | 1070 |
1105 TEST(Convert) { | 1071 TEST(Convert) { |
1106 CcTest::InitializeVM(); | 1072 CcTest::InitializeVM(); |
1107 ZoneTests().Convert<HeapType, Handle<HeapType>, Isolate, HeapRep>(); | 1073 ZoneTests().Convert<HeapType, Handle<HeapType>, Isolate, HeapRep>(); |
1108 HeapTests().Convert<Type, Type*, Zone, ZoneRep>(); | 1074 HeapTests().Convert<Type, Type*, Zone, ZoneRep>(); |
1109 } | 1075 } |
OLD | NEW |