Chromium Code Reviews

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

Issue 228263005: Implement structural function and array types (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Eps Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | | Annotate | Revision Log
« src/types.h ('K') | « src/types-inl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // 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 15 matching lines...)
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 "cctest.h" 28 #include "cctest.h"
29 #include "types.h" 29 #include "types.h"
30 30
31 using namespace v8::internal; 31 using namespace v8::internal;
32 32
33 template<class Type, class TypeHandle, class Region> 33 template<class Type, class TypeHandle, class Region>
34 class Types { 34 class Types {
35 public: 35 public:
36 Types(Region* region, Isolate* isolate) : 36 Types(Region* region, Isolate* isolate) : region_(region) {
37 Representation(Type::Representation(region)), 37 Representation = Type::Representation(region);
38 Semantic(Type::Semantic(region)), 38 Semantic = Type::Semantic(region);
39 None(Type::None(region)), 39 None = Type::None(region);
40 Any(Type::Any(region)), 40 Any = Type::Any(region);
41 Boolean(Type::Boolean(region)), 41 Boolean = Type::Boolean(region);
42 Null(Type::Null(region)), 42 Null = Type::Null(region);
43 Undefined(Type::Undefined(region)), 43 Undefined = Type::Undefined(region);
44 Number(Type::Number(region)), 44 Number = Type::Number(region);
45 SignedSmall(Type::SignedSmall(region)), 45 SignedSmall = Type::SignedSmall(region);
46 Signed32(Type::Signed32(region)), 46 Signed32 = Type::Signed32(region);
47 Float(Type::Float(region)), 47 Float = Type::Float(region);
48 Name(Type::Name(region)), 48 Name = Type::Name(region);
49 UniqueName(Type::UniqueName(region)), 49 UniqueName = Type::UniqueName(region);
50 String(Type::String(region)), 50 String = Type::String(region);
51 InternalizedString(Type::InternalizedString(region)), 51 InternalizedString = Type::InternalizedString(region);
52 Symbol(Type::Symbol(region)), 52 Symbol = Type::Symbol(region);
53 Receiver(Type::Receiver(region)), 53 Receiver = Type::Receiver(region);
54 Object(Type::Object(region)), 54 Object = Type::Object(region);
55 Array(Type::Array(region)), 55 Array = Type::Array(region);
56 Function(Type::Function(region)), 56 Function = Type::Function(region);
57 Proxy(Type::Proxy(region)), 57 Proxy = Type::Proxy(region);
58 object_map(isolate->factory()->NewMap(JS_OBJECT_TYPE, 3 * kPointerSize)), 58
59 array_map(isolate->factory()->NewMap(JS_ARRAY_TYPE, 4 * kPointerSize)), 59 FloatArray = Type::Array(Float, region);
60 region_(region) { 60 StringArray = Type::Array(String, region);
61 AnyArray = Type::Array(Any, region);
62
63 SignedFunction1 = Type::Function(SignedSmall, SignedSmall, region);
64 NumberFunction1 = Type::Function(Number, Number, region);
65 NumberFunction2 = Type::Function(Number, Number, Number, region);
66 MethodFunction = Type::Function(String, Object, 0, region);
67
68 object_map = isolate->factory()->NewMap(JS_OBJECT_TYPE, 3 * kPointerSize);
69 array_map = isolate->factory()->NewMap(JS_ARRAY_TYPE, 4 * kPointerSize);
70 ObjectClass = Type::Class(object_map, region);
71 ArrayClass = Type::Class(array_map, region);
72
61 smi = handle(Smi::FromInt(666), isolate); 73 smi = handle(Smi::FromInt(666), isolate);
62 signed32 = isolate->factory()->NewHeapNumber(0x40000000); 74 signed32 = isolate->factory()->NewHeapNumber(0x40000000);
63 object1 = isolate->factory()->NewJSObjectFromMap(object_map); 75 object1 = isolate->factory()->NewJSObjectFromMap(object_map);
64 object2 = isolate->factory()->NewJSObjectFromMap(object_map); 76 object2 = isolate->factory()->NewJSObjectFromMap(object_map);
65 array = isolate->factory()->NewJSArray(20); 77 array = isolate->factory()->NewJSArray(20);
66 ObjectClass = Type::Class(object_map, region);
67 ArrayClass = Type::Class(array_map, region);
68 SmiConstant = Type::Constant(smi, region); 78 SmiConstant = Type::Constant(smi, region);
69 Signed32Constant = Type::Constant(signed32, region); 79 Signed32Constant = Type::Constant(signed32, region);
70 ObjectConstant1 = Type::Constant(object1, region); 80 ObjectConstant1 = Type::Constant(object1, region);
71 ObjectConstant2 = Type::Constant(object2, region); 81 ObjectConstant2 = Type::Constant(object2, region);
72 ArrayConstant1 = Type::Constant(array, region); 82 ArrayConstant1 = Type::Constant(array, region);
73 ArrayConstant2 = Type::Constant(array, region); 83 ArrayConstant2 = Type::Constant(array, region);
74 } 84 }
75 85
76 TypeHandle Representation; 86 TypeHandle Representation;
77 TypeHandle Semantic; 87 TypeHandle Semantic;
(...skipping 10 matching lines...)
88 TypeHandle UniqueName; 98 TypeHandle UniqueName;
89 TypeHandle String; 99 TypeHandle String;
90 TypeHandle InternalizedString; 100 TypeHandle InternalizedString;
91 TypeHandle Symbol; 101 TypeHandle Symbol;
92 TypeHandle Receiver; 102 TypeHandle Receiver;
93 TypeHandle Object; 103 TypeHandle Object;
94 TypeHandle Array; 104 TypeHandle Array;
95 TypeHandle Function; 105 TypeHandle Function;
96 TypeHandle Proxy; 106 TypeHandle Proxy;
97 107
108 TypeHandle FloatArray;
109 TypeHandle StringArray;
110 TypeHandle AnyArray;
111
112 TypeHandle SignedFunction1;
113 TypeHandle NumberFunction1;
114 TypeHandle NumberFunction2;
115 TypeHandle MethodFunction;
116
98 TypeHandle ObjectClass; 117 TypeHandle ObjectClass;
99 TypeHandle ArrayClass; 118 TypeHandle ArrayClass;
100 119
101 TypeHandle SmiConstant; 120 TypeHandle SmiConstant;
102 TypeHandle Signed32Constant; 121 TypeHandle Signed32Constant;
103 TypeHandle ObjectConstant1; 122 TypeHandle ObjectConstant1;
104 TypeHandle ObjectConstant2; 123 TypeHandle ObjectConstant2;
105 TypeHandle ArrayConstant1; 124 TypeHandle ArrayConstant1;
106 TypeHandle ArrayConstant2; 125 TypeHandle ArrayConstant2;
107 126
(...skipping 42 matching lines...)
150 case 2: // constant 169 case 2: // constant
151 switch (rand() % 6) { 170 switch (rand() % 6) {
152 case 0: return SmiConstant; 171 case 0: return SmiConstant;
153 case 1: return Signed32Constant; 172 case 1: return Signed32Constant;
154 case 2: return ObjectConstant1; 173 case 2: return ObjectConstant1;
155 case 3: return ObjectConstant2; 174 case 3: return ObjectConstant2;
156 case 4: return ArrayConstant1; 175 case 4: return ArrayConstant1;
157 case 5: return ArrayConstant2; 176 case 5: return ArrayConstant2;
158 } 177 }
159 UNREACHABLE(); 178 UNREACHABLE();
179 case 3: // array
180 return Type::Array(Fuzz(depth / 2), region_);
181 case 4:
182 case 5:
183 case 6: { // function
184 TypeHandle type = Type::Function(
185 Fuzz(depth / 2), Fuzz(depth / 2), rand() % 3, region_);
186 for (int i = 0; i < type->AsFunction()->Arity(); ++i) {
187 type->AsFunction()->InitParameter(i, Fuzz(depth - 1));
188 }
189 }
160 default: { // union 190 default: { // union
161 int n = rand() % 10; 191 int n = rand() % 10;
162 TypeHandle type = None; 192 TypeHandle type = None;
163 for (int i = 0; i < n; ++i) { 193 for (int i = 0; i < n; ++i) {
164 type = Type::Union(type, Fuzz(depth - 1), region_); 194 type = Type::Union(type, Fuzz(depth - 1), region_);
165 } 195 }
166 return type; 196 return type;
167 } 197 }
168 } 198 }
169 UNREACHABLE(); 199 UNREACHABLE();
170 } 200 }
171 201
172 private: 202 private:
173 Region* region_; 203 Region* region_;
174 }; 204 };
175 205
176 206
177 // Testing auxiliaries (breaking the Type abstraction). 207 // Testing auxiliaries (breaking the Type abstraction).
178 struct ZoneRep { 208 struct ZoneRep {
179 typedef void* Struct; 209 typedef void* Struct;
180 210
181 static bool IsStruct(Type* t, int tag) { 211 static bool IsStruct(Type* t, int tag) {
182 return !IsBitset(t) && reinterpret_cast<intptr_t>(AsStruct(t)[0]) == tag; 212 return !IsBitset(t) && reinterpret_cast<intptr_t>(AsStruct(t)[0]) == tag;
183 } 213 }
184 static bool IsBitset(Type* t) { return reinterpret_cast<intptr_t>(t) & 1; } 214 static bool IsBitset(Type* t) { return reinterpret_cast<intptr_t>(t) & 1; }
185 static bool IsClass(Type* t) { return IsStruct(t, 0); } 215 static bool IsClass(Type* t) { return IsStruct(t, 0); }
186 static bool IsConstant(Type* t) { return IsStruct(t, 1); } 216 static bool IsConstant(Type* t) { return IsStruct(t, 1); }
187 static bool IsUnion(Type* t) { return IsStruct(t, 2); } 217 static bool IsArray(Type* t) { return IsStruct(t, 2); }
218 static bool IsFunction(Type* t) { return IsStruct(t, 3); }
219 static bool IsUnion(Type* t) { return IsStruct(t, 4); }
188 220
189 static Struct* AsStruct(Type* t) { 221 static Struct* AsStruct(Type* t) {
190 return reinterpret_cast<Struct*>(t); 222 return reinterpret_cast<Struct*>(t);
191 } 223 }
192 static int AsBitset(Type* t) { 224 static int AsBitset(Type* t) {
193 return static_cast<int>(reinterpret_cast<intptr_t>(t) >> 1); 225 return static_cast<int>(reinterpret_cast<intptr_t>(t) >> 1);
194 } 226 }
195 static Map* AsClass(Type* t) { 227 static Map* AsClass(Type* t) {
196 return *static_cast<Map**>(AsStruct(t)[3]); 228 return *static_cast<Map**>(AsStruct(t)[3]);
197 } 229 }
(...skipping 13 matching lines...)
211 243
212 struct HeapRep { 244 struct HeapRep {
213 typedef FixedArray Struct; 245 typedef FixedArray Struct;
214 246
215 static bool IsStruct(Handle<HeapType> t, int tag) { 247 static bool IsStruct(Handle<HeapType> t, int tag) {
216 return t->IsFixedArray() && Smi::cast(AsStruct(t)->get(0))->value() == tag; 248 return t->IsFixedArray() && Smi::cast(AsStruct(t)->get(0))->value() == tag;
217 } 249 }
218 static bool IsBitset(Handle<HeapType> t) { return t->IsSmi(); } 250 static bool IsBitset(Handle<HeapType> t) { return t->IsSmi(); }
219 static bool IsClass(Handle<HeapType> t) { return t->IsMap(); } 251 static bool IsClass(Handle<HeapType> t) { return t->IsMap(); }
220 static bool IsConstant(Handle<HeapType> t) { return t->IsBox(); } 252 static bool IsConstant(Handle<HeapType> t) { return t->IsBox(); }
221 static bool IsUnion(Handle<HeapType> t) { return IsStruct(t, 2); } 253 static bool IsArray(Handle<HeapType> t) { return IsStruct(t, 2); }
254 static bool IsFunction(Handle<HeapType> t) { return IsStruct(t, 3); }
255 static bool IsUnion(Handle<HeapType> t) { return IsStruct(t, 4); }
222 256
223 static Struct* AsStruct(Handle<HeapType> t) { return FixedArray::cast(*t); } 257 static Struct* AsStruct(Handle<HeapType> t) { return FixedArray::cast(*t); }
224 static int AsBitset(Handle<HeapType> t) { return Smi::cast(*t)->value(); } 258 static int AsBitset(Handle<HeapType> t) { return Smi::cast(*t)->value(); }
225 static Map* AsClass(Handle<HeapType> t) { return Map::cast(*t); } 259 static Map* AsClass(Handle<HeapType> t) { return Map::cast(*t); }
226 static Object* AsConstant(Handle<HeapType> t) { 260 static Object* AsConstant(Handle<HeapType> t) {
227 return Box::cast(*t)->value(); 261 return Box::cast(*t)->value();
228 } 262 }
229 static Struct* AsUnion(Handle<HeapType> t) { return AsStruct(t); } 263 static Struct* AsUnion(Handle<HeapType> t) { return AsStruct(t); }
230 static int Length(Struct* structured) { return structured->length() - 1; } 264 static int Length(Struct* structured) { return structured->length() - 1; }
231 265
(...skipping 83 matching lines...)
315 349
316 CHECK_EQ(0, this->AsBitset(T.None)); 350 CHECK_EQ(0, this->AsBitset(T.None));
317 CHECK_EQ( 351 CHECK_EQ(
318 this->AsBitset(T.Number) | this->AsBitset(T.String), 352 this->AsBitset(T.Number) | this->AsBitset(T.String),
319 this->AsBitset(T.Union(T.String, T.Number))); 353 this->AsBitset(T.Union(T.String, T.Number)));
320 CHECK_EQ( 354 CHECK_EQ(
321 this->AsBitset(T.Receiver), 355 this->AsBitset(T.Receiver),
322 this->AsBitset(T.Union(T.Receiver, T.Object))); 356 this->AsBitset(T.Union(T.Receiver, T.Object)));
323 } 357 }
324 358
359 void Array() {
360 CHECK(this->IsArray(T.FloatArray));
361 CHECK(this->IsArray(T.StringArray));
362 CHECK(this->IsArray(T.AnyArray));
363
364 CheckEqual(T.Float, T.FloatArray->AsArray()->Element());
365 CheckEqual(T.String, T.StringArray->AsArray()->Element());
366 CheckEqual(T.Any, T.AnyArray->AsArray()->Element());
367 }
368
369 void Function() {
370 CHECK(this->IsFunction(T.SignedFunction1));
371 CHECK(this->IsFunction(T.NumberFunction1));
372 CHECK(this->IsFunction(T.NumberFunction2));
373 CHECK(this->IsFunction(T.MethodFunction));
374
375 CHECK(1 == T.SignedFunction1->AsFunction()->Arity());
376 CheckEqual(T.SignedSmall, T.SignedFunction1->AsFunction()->Result());
377 CheckEqual(T.Any, T.SignedFunction1->AsFunction()->Receiver());
378 CheckEqual(T.SignedSmall, T.SignedFunction1->AsFunction()->Parameter(0));
379
380 CHECK(1 == T.NumberFunction1->AsFunction()->Arity());
381 CheckEqual(T.Number, T.NumberFunction1->AsFunction()->Result());
382 CheckEqual(T.Any, T.NumberFunction1->AsFunction()->Receiver());
383 CheckEqual(T.Number, T.NumberFunction1->AsFunction()->Parameter(0));
384
385 CHECK(2 == T.NumberFunction2->AsFunction()->Arity());
386 CheckEqual(T.Number, T.NumberFunction2->AsFunction()->Result());
387 CheckEqual(T.Any, T.NumberFunction2->AsFunction()->Receiver());
388 CheckEqual(T.Number, T.NumberFunction2->AsFunction()->Parameter(0));
389 CheckEqual(T.Number, T.NumberFunction2->AsFunction()->Parameter(1));
390
391 CHECK(0 == T.MethodFunction->AsFunction()->Arity());
392 CheckEqual(T.String, T.MethodFunction->AsFunction()->Result());
393 CheckEqual(T.Object, T.MethodFunction->AsFunction()->Receiver());
394 }
395
325 void Class() { 396 void Class() {
326 CHECK(this->IsClass(T.ObjectClass)); 397 CHECK(this->IsClass(T.ObjectClass));
327 CHECK(this->IsClass(T.ArrayClass)); 398 CHECK(this->IsClass(T.ArrayClass));
328 399
329 CHECK(*T.object_map == this->AsClass(T.ObjectClass)); 400 CHECK(*T.object_map == this->AsClass(T.ObjectClass));
330 CHECK(*T.array_map == this->AsClass(T.ArrayClass)); 401 CHECK(*T.array_map == this->AsClass(T.ArrayClass));
331 } 402 }
332 403
333 void Constant() { 404 void Constant() {
334 CHECK(this->IsConstant(T.SmiConstant)); 405 CHECK(this->IsConstant(T.SmiConstant));
(...skipping 52 matching lines...)
387 CheckSub(T.Receiver, T.Any); 458 CheckSub(T.Receiver, T.Any);
388 CheckSub(T.Object, T.Any); 459 CheckSub(T.Object, T.Any);
389 CheckSub(T.Object, T.Receiver); 460 CheckSub(T.Object, T.Receiver);
390 CheckSub(T.Array, T.Object); 461 CheckSub(T.Array, T.Object);
391 CheckSub(T.Function, T.Object); 462 CheckSub(T.Function, T.Object);
392 CheckSub(T.Proxy, T.Receiver); 463 CheckSub(T.Proxy, T.Receiver);
393 CheckUnordered(T.Object, T.Proxy); 464 CheckUnordered(T.Object, T.Proxy);
394 CheckUnordered(T.Array, T.Function); 465 CheckUnordered(T.Array, T.Function);
395 466
396 // Structured subtyping 467 // Structured subtyping
468 CheckSub(T.None, T.FloatArray);
469 CheckSub(T.None, T.MethodFunction);
397 CheckSub(T.None, T.ObjectClass); 470 CheckSub(T.None, T.ObjectClass);
398 CheckSub(T.None, T.ObjectConstant1); 471 CheckSub(T.None, T.ObjectConstant1);
472 CheckSub(T.FloatArray, T.Any);
473 CheckSub(T.NumberFunction1, T.Any);
399 CheckSub(T.ObjectClass, T.Any); 474 CheckSub(T.ObjectClass, T.Any);
400 CheckSub(T.ObjectConstant1, T.Any); 475 CheckSub(T.ObjectConstant1, T.Any);
401 476
477 CheckSub(T.FloatArray, T.Array);
478 CheckSub(T.AnyArray, T.Array);
479 CheckUnordered(T.FloatArray, T.AnyArray);
480 CheckUnordered(T.StringArray, T.AnyArray);
481
482 CheckSub(T.SignedFunction1, T.Function);
483 CheckSub(T.NumberFunction2, T.Function);
484 CheckSub(T.MethodFunction, T.Function);
485 CheckUnordered(T.SignedFunction1, T.NumberFunction1);
486 CheckUnordered(T.NumberFunction1, T.NumberFunction2);
487
402 CheckSub(T.ObjectClass, T.Object); 488 CheckSub(T.ObjectClass, T.Object);
403 CheckSub(T.ArrayClass, T.Object); 489 CheckSub(T.ArrayClass, T.Object);
490 CheckSub(T.ArrayClass, T.Array);
404 CheckUnordered(T.ObjectClass, T.ArrayClass); 491 CheckUnordered(T.ObjectClass, T.ArrayClass);
405 492
406 CheckSub(T.SmiConstant, T.SignedSmall); 493 CheckSub(T.SmiConstant, T.SignedSmall);
407 CheckSub(T.SmiConstant, T.Signed32); 494 CheckSub(T.SmiConstant, T.Signed32);
408 CheckSub(T.SmiConstant, T.Number); 495 CheckSub(T.SmiConstant, T.Number);
409 CheckSub(T.ObjectConstant1, T.Object); 496 CheckSub(T.ObjectConstant1, T.Object);
410 CheckSub(T.ObjectConstant2, T.Object); 497 CheckSub(T.ObjectConstant2, T.Object);
411 CheckSub(T.ArrayConstant1, T.Object); 498 CheckSub(T.ArrayConstant1, T.Object);
412 CheckSub(T.ArrayConstant1, T.Array); 499 CheckSub(T.ArrayConstant1, T.Array);
413 CheckUnordered(T.ObjectConstant1, T.ObjectConstant2); 500 CheckUnordered(T.ObjectConstant1, T.ObjectConstant2);
(...skipping 34 matching lines...)
448 535
449 CheckOverlap(T.Receiver, T.Any, T.Semantic); 536 CheckOverlap(T.Receiver, T.Any, T.Semantic);
450 CheckOverlap(T.Object, T.Any, T.Semantic); 537 CheckOverlap(T.Object, T.Any, T.Semantic);
451 CheckOverlap(T.Object, T.Receiver, T.Semantic); 538 CheckOverlap(T.Object, T.Receiver, T.Semantic);
452 CheckOverlap(T.Array, T.Object, T.Semantic); 539 CheckOverlap(T.Array, T.Object, T.Semantic);
453 CheckOverlap(T.Function, T.Object, T.Semantic); 540 CheckOverlap(T.Function, T.Object, T.Semantic);
454 CheckOverlap(T.Proxy, T.Receiver, T.Semantic); 541 CheckOverlap(T.Proxy, T.Receiver, T.Semantic);
455 CheckDisjoint(T.Object, T.Proxy, T.Semantic); 542 CheckDisjoint(T.Object, T.Proxy, T.Semantic);
456 CheckDisjoint(T.Array, T.Function, T.Semantic); 543 CheckDisjoint(T.Array, T.Function, T.Semantic);
457 544
545 CheckOverlap(T.FloatArray, T.Any, T.Semantic);
546 CheckOverlap(T.MethodFunction, T.Any, T.Semantic);
458 CheckOverlap(T.ObjectClass, T.Any, T.Semantic); 547 CheckOverlap(T.ObjectClass, T.Any, T.Semantic);
459 CheckOverlap(T.ObjectConstant1, T.Any, T.Semantic); 548 CheckOverlap(T.ObjectConstant1, T.Any, T.Semantic);
460 549
550 CheckOverlap(T.FloatArray, T.AnyArray, T.Semantic);
551 CheckDisjoint(T.FloatArray, T.StringArray, T.Semantic);
552
553 CheckOverlap(T.SignedFunction1, T.NumberFunction1, T.Semantic);
554 CheckOverlap(T.SignedFunction1, T.NumberFunction2, T.Semantic);
555 CheckOverlap(T.NumberFunction1, T.NumberFunction2, T.Semantic);
556 CheckDisjoint(T.SignedFunction1, T.MethodFunction, T.Semantic);
557
461 CheckOverlap(T.ObjectClass, T.Object, T.Semantic); 558 CheckOverlap(T.ObjectClass, T.Object, T.Semantic);
462 CheckOverlap(T.ArrayClass, T.Object, T.Semantic); 559 CheckOverlap(T.ArrayClass, T.Object, T.Semantic);
463 CheckOverlap(T.ObjectClass, T.ObjectClass, T.Semantic); 560 CheckOverlap(T.ObjectClass, T.ObjectClass, T.Semantic);
464 CheckOverlap(T.ArrayClass, T.ArrayClass, T.Semantic); 561 CheckOverlap(T.ArrayClass, T.ArrayClass, T.Semantic);
465 CheckDisjoint(T.ObjectClass, T.ArrayClass, T.Semantic); 562 CheckDisjoint(T.ObjectClass, T.ArrayClass, T.Semantic);
466 563
467 CheckOverlap(T.SmiConstant, T.SignedSmall, T.Semantic); 564 CheckOverlap(T.SmiConstant, T.SignedSmall, T.Semantic);
468 CheckOverlap(T.SmiConstant, T.Signed32, T.Semantic); 565 CheckOverlap(T.SmiConstant, T.Signed32, T.Semantic);
469 CheckOverlap(T.SmiConstant, T.Number, T.Semantic); 566 CheckOverlap(T.SmiConstant, T.Number, T.Semantic);
470 CheckDisjoint(T.SmiConstant, T.Float, T.Semantic); 567 CheckDisjoint(T.SmiConstant, T.Float, T.Semantic);
(...skipping 61 matching lines...)
532 T.Union(T.ObjectConstant1, T.ArrayConstant1), T.Array, T.Semantic); 629 T.Union(T.ObjectConstant1, T.ArrayConstant1), T.Array, T.Semantic);
533 CheckOverlap( 630 CheckOverlap(
534 T.Union(T.ObjectConstant1, T.ArrayConstant1), T.ArrayConstant2, 631 T.Union(T.ObjectConstant1, T.ArrayConstant1), T.ArrayConstant2,
535 T.Semantic); 632 T.Semantic);
536 CheckDisjoint( 633 CheckDisjoint(
537 T.Union(T.ObjectConstant1, T.ArrayConstant1), T.Number, T.Semantic); 634 T.Union(T.ObjectConstant1, T.ArrayConstant1), T.Number, T.Semantic);
538 CheckDisjoint( 635 CheckDisjoint(
539 T.Union(T.ObjectConstant1, T.ArrayConstant1), T.ObjectClass, 636 T.Union(T.ObjectConstant1, T.ArrayConstant1), T.ObjectClass,
540 T.Semantic); 637 T.Semantic);
541 638
639 // Bitset-array
640 CHECK(this->IsBitset(T.Union(T.AnyArray, T.Array)));
641 CHECK(this->IsUnion(T.Union(T.FloatArray, T.Number)));
642
643 CheckEqual(T.Union(T.AnyArray, T.Array), T.Array);
644 CheckSub(T.None, T.Union(T.FloatArray, T.Number));
645 CheckSub(T.Union(T.FloatArray, T.Number), T.Any);
646 CheckUnordered(T.Union(T.AnyArray, T.String), T.Array);
647 CheckOverlap(T.Union(T.FloatArray, T.String), T.Object, T.Semantic);
648 CheckDisjoint(T.Union(T.FloatArray, T.String), T.Number, T.Semantic);
649
650 // Bitset-function
651 CHECK(this->IsBitset(T.Union(T.MethodFunction, T.Function)));
652 CHECK(this->IsUnion(T.Union(T.NumberFunction1, T.Number)));
653
654 CheckEqual(T.Union(T.MethodFunction, T.Function), T.Function);
655 CheckSub(T.None, T.Union(T.MethodFunction, T.Number));
656 CheckSub(T.Union(T.MethodFunction, T.Number), T.Any);
657 CheckUnordered(T.Union(T.NumberFunction1, T.String), T.Function);
658 CheckOverlap(T.Union(T.NumberFunction2, T.String), T.Object, T.Semantic);
659 CheckDisjoint(T.Union(T.NumberFunction1, T.String), T.Number, T.Semantic);
660
542 // Bitset-class 661 // Bitset-class
543 CHECK(this->IsBitset(T.Union(T.ObjectClass, T.Object))); 662 CHECK(this->IsBitset(T.Union(T.ObjectClass, T.Object)));
544 CHECK(this->IsUnion(T.Union(T.ObjectClass, T.Number))); 663 CHECK(this->IsUnion(T.Union(T.ObjectClass, T.Number)));
545 664
546 CheckEqual(T.Union(T.ObjectClass, T.Object), T.Object); 665 CheckEqual(T.Union(T.ObjectClass, T.Object), T.Object);
547 CheckSub(T.None, T.Union(T.ObjectClass, T.Number)); 666 CheckSub(T.None, T.Union(T.ObjectClass, T.Number));
548 CheckSub(T.Union(T.ObjectClass, T.Number), T.Any); 667 CheckSub(T.Union(T.ObjectClass, T.Number), T.Any);
549 CheckSub( 668 CheckSub(
550 T.Union(T.ObjectClass, T.SignedSmall), T.Union(T.Object, T.Number)); 669 T.Union(T.ObjectClass, T.SignedSmall), T.Union(T.Object, T.Number));
551 CheckSub(T.Union(T.ObjectClass, T.Array), T.Object); 670 CheckSub(T.Union(T.ObjectClass, T.Array), T.Object);
(...skipping 58 matching lines...)
610 CheckSub( 729 CheckSub(
611 T.None, 730 T.None,
612 T.Union(T.Union(T.ArrayClass, T.ObjectConstant1), T.Float)); 731 T.Union(T.Union(T.ArrayClass, T.ObjectConstant1), T.Float));
613 CheckSub( 732 CheckSub(
614 T.Union(T.Union(T.ArrayClass, T.ObjectConstant1), T.Float), 733 T.Union(T.Union(T.ArrayClass, T.ObjectConstant1), T.Float),
615 T.Any); 734 T.Any);
616 CheckSub( 735 CheckSub(
617 T.Union(T.Union(T.ArrayClass, T.ObjectConstant1), T.Float), 736 T.Union(T.Union(T.ArrayClass, T.ObjectConstant1), T.Float),
618 T.Union(T.ObjectConstant1, T.Union(T.Number, T.ArrayClass))); 737 T.Union(T.ObjectConstant1, T.Union(T.Number, T.ArrayClass)));
619 738
739 // Array-union
740 CHECK(this->IsUnion(
741 T.Union(T.Union(T.AnyArray, T.FloatArray), T.ArrayClass)));
742 CHECK(this->IsUnion(
743 T.Union(T.Union(T.ArrayClass, T.AnyArray), T.FloatArray)));
744
745 CheckEqual(
746 T.Union(T.AnyArray, T.Union(T.FloatArray, T.AnyArray)),
747 T.Union(T.AnyArray, T.FloatArray));
748 CheckSub(T.None, T.Union(T.AnyArray, T.FloatArray));
749 CheckSub(T.Union(T.AnyArray, T.FloatArray), T.Any);
750 CheckSub(T.Union(T.AnyArray, T.FloatArray), T.Array);
751
752 // Funtion-union
753 CHECK(this->IsUnion(T.Union(T.NumberFunction1, T.NumberFunction2)));
754 CHECK(this->IsUnion(T.Union(T.SignedFunction1, T.NumberFunction1)));
755
756 CheckEqual(
757 T.Union(T.NumberFunction1, T.NumberFunction2),
758 T.Union(T.NumberFunction2, T.NumberFunction1));
759 CheckSub(T.None, T.Union(T.NumberFunction2, T.MethodFunction));
760 CheckSub(T.Union(T.SignedFunction1, T.MethodFunction), T.Any);
761 CheckSub(T.Union(T.SignedFunction1, T.MethodFunction), T.Function);
762
620 // Class-union 763 // Class-union
621 CHECK(this->IsUnion( 764 CHECK(this->IsUnion(
622 T.Union(T.Union(T.ArrayClass, T.ObjectConstant2), T.ArrayClass))); 765 T.Union(T.Union(T.ArrayClass, T.ObjectConstant2), T.ArrayClass)));
623 CHECK(this->IsUnion( 766 CHECK(this->IsUnion(
624 T.Union(T.Union(T.ArrayClass, T.ObjectConstant2), T.ObjectClass))); 767 T.Union(T.Union(T.ArrayClass, T.ObjectConstant2), T.ObjectClass)));
625 768
626 CheckEqual( 769 CheckEqual(
627 T.Union(T.ObjectClass, T.Union(T.ObjectConstant1, T.ObjectClass)), 770 T.Union(T.ObjectClass, T.Union(T.ObjectConstant1, T.ObjectClass)),
628 T.Union(T.ObjectClass, T.ObjectConstant1)); 771 T.Union(T.ObjectClass, T.ObjectConstant1));
629 CheckSub( 772 CheckSub(
(...skipping 76 matching lines...)
706 CHECK(this->IsConstant(T.Intersect(T.ObjectConstant1, T.ObjectConstant1))); 849 CHECK(this->IsConstant(T.Intersect(T.ObjectConstant1, T.ObjectConstant1)));
707 CHECK(this->IsConstant(T.Intersect(T.ArrayConstant1, T.ArrayConstant2))); 850 CHECK(this->IsConstant(T.Intersect(T.ArrayConstant1, T.ArrayConstant2)));
708 CHECK(this->IsBitset(T.Intersect(T.ObjectConstant1, T.ObjectConstant2))); 851 CHECK(this->IsBitset(T.Intersect(T.ObjectConstant1, T.ObjectConstant2)));
709 852
710 CheckEqual( 853 CheckEqual(
711 T.Intersect(T.ObjectConstant1, T.ObjectConstant1), T.ObjectConstant1); 854 T.Intersect(T.ObjectConstant1, T.ObjectConstant1), T.ObjectConstant1);
712 CheckEqual( 855 CheckEqual(
713 T.Intersect(T.ArrayConstant1, T.ArrayConstant2), T.ArrayConstant1); 856 T.Intersect(T.ArrayConstant1, T.ArrayConstant2), T.ArrayConstant1);
714 CheckEqual(T.Intersect(T.ObjectConstant1, T.ObjectConstant2), T.None); 857 CheckEqual(T.Intersect(T.ObjectConstant1, T.ObjectConstant2), T.None);
715 858
859 // Bitset-array
860 CHECK(this->IsArray(T.Intersect(T.FloatArray, T.Object)));
861 CHECK(this->IsBitset(T.Intersect(T.FloatArray, T.Number)));
862
863 CheckEqual(T.Intersect(T.FloatArray, T.Object), T.FloatArray);
864 CheckSub(T.Intersect(T.AnyArray, T.Function), T.Representation);
865
866 // Bitset-function
867 CHECK(this->IsFunction(T.Intersect(T.MethodFunction, T.Object)));
868 CHECK(this->IsBitset(T.Intersect(T.MethodFunction, T.Number)));
869
870 CheckEqual(T.Intersect(T.MethodFunction, T.Object), T.MethodFunction);
871 CheckSub(T.Intersect(T.NumberFunction1, T.Array), T.Representation);
872
716 // Bitset-class 873 // Bitset-class
717 CHECK(this->IsClass(T.Intersect(T.ObjectClass, T.Object))); 874 CHECK(this->IsClass(T.Intersect(T.ObjectClass, T.Object)));
718 CHECK(this->IsBitset(T.Intersect(T.ObjectClass, T.Number))); 875 CHECK(this->IsBitset(T.Intersect(T.ObjectClass, T.Number)));
719 876
720 CheckEqual(T.Intersect(T.ObjectClass, T.Object), T.ObjectClass); 877 CheckEqual(T.Intersect(T.ObjectClass, T.Object), T.ObjectClass);
721 CheckSub(T.Intersect(T.ObjectClass, T.Array), T.Representation); 878 CheckSub(T.Intersect(T.ObjectClass, T.Array), T.Representation);
722 CheckSub(T.Intersect(T.ObjectClass, T.Number), T.Representation); 879 CheckSub(T.Intersect(T.ObjectClass, T.Number), T.Representation);
723 880
724 // Bitset-constant 881 // Bitset-constant
725 CHECK(this->IsBitset(T.Intersect(T.SignedSmall, T.Number))); 882 CHECK(this->IsBitset(T.Intersect(T.SignedSmall, T.Number)));
(...skipping 17 matching lines...)
743 CHECK(this->IsBitset( 900 CHECK(this->IsBitset(
744 T.Intersect(T.Union(T.ArrayClass, T.ObjectConstant2), T.Number))); 901 T.Intersect(T.Union(T.ArrayClass, T.ObjectConstant2), T.Number)));
745 902
746 CheckEqual( 903 CheckEqual(
747 T.Intersect(T.Object, T.Union(T.ObjectConstant1, T.ObjectClass)), 904 T.Intersect(T.Object, T.Union(T.ObjectConstant1, T.ObjectClass)),
748 T.Union(T.ObjectConstant1, T.ObjectClass)); 905 T.Union(T.ObjectConstant1, T.ObjectClass));
749 CheckEqual( 906 CheckEqual(
750 T.Intersect(T.Union(T.ArrayClass, T.ObjectConstant1), T.Number), 907 T.Intersect(T.Union(T.ArrayClass, T.ObjectConstant1), T.Number),
751 T.None); 908 T.None);
752 909
910 // Array-union
911 CHECK(this->IsArray(
912 T.Intersect(T.Union(T.FloatArray, T.ArrayClass), T.FloatArray)));
913 CHECK(this->IsArray(
914 T.Intersect(T.Union(T.Object, T.SmiConstant), T.AnyArray)));
915 CHECK(this->IsBitset(
916 T.Intersect(T.Union(T.AnyArray, T.ArrayConstant1), T.FloatArray)));
917
918 CheckEqual(
919 T.Intersect(T.FloatArray, T.Union(T.FloatArray, T.ArrayClass)),
920 T.FloatArray);
921 CheckEqual(
922 T.Intersect(T.AnyArray, T.Union(T.Object, T.SmiConstant)),
923 T.AnyArray);
924 CheckEqual(
925 T.Intersect(T.Union(T.AnyArray, T.ArrayConstant1), T.FloatArray),
926 T.None);
927
928 // Function-union
929 CHECK(this->IsFunction(
930 T.Intersect(T.Union(T.MethodFunction, T.String), T.MethodFunction)));
931 CHECK(this->IsFunction(
932 T.Intersect(T.Union(T.Object, T.SmiConstant), T.NumberFunction1)));
933 CHECK(this->IsBitset(
934 T.Intersect(T.Union(T.MethodFunction, T.Name), T.NumberFunction1)));
935
936 CheckEqual(
937 T.Intersect(T.MethodFunction, T.Union(T.String, T.MethodFunction)),
938 T.MethodFunction);
939 CheckEqual(
940 T.Intersect(T.NumberFunction1, T.Union(T.Object, T.SmiConstant)),
941 T.NumberFunction1);
942 CheckEqual(
943 T.Intersect(T.Union(T.MethodFunction, T.Name), T.NumberFunction2),
944 T.None);
945
753 // Class-union 946 // Class-union
754 CHECK(this->IsClass( 947 CHECK(this->IsClass(
755 T.Intersect(T.Union(T.ArrayClass, T.ObjectConstant2), T.ArrayClass))); 948 T.Intersect(T.Union(T.ArrayClass, T.ObjectConstant2), T.ArrayClass)));
756 CHECK(this->IsClass( 949 CHECK(this->IsClass(
757 T.Intersect(T.Union(T.Object, T.SmiConstant), T.ArrayClass))); 950 T.Intersect(T.Union(T.Object, T.SmiConstant), T.ArrayClass)));
758 CHECK(this->IsBitset( 951 CHECK(this->IsBitset(
759 T.Intersect(T.Union(T.ObjectClass, T.ArrayConstant1), T.ArrayClass))); 952 T.Intersect(T.Union(T.ObjectClass, T.ArrayConstant1), T.ArrayClass)));
760 953
761 CheckEqual( 954 CheckEqual(
762 T.Intersect(T.ArrayClass, T.Union(T.ObjectConstant2, T.ArrayClass)), 955 T.Intersect(T.ArrayClass, T.Union(T.ObjectConstant2, T.ArrayClass)),
(...skipping 70 matching lines...)
833 CheckEqual(type, 1026 CheckEqual(type,
834 T.template Convert<Type2>(T2.template Convert<Type>(type))); 1027 T.template Convert<Type2>(T2.template Convert<Type>(type)));
835 } 1028 }
836 } 1029 }
837 }; 1030 };
838 1031
839 typedef Tests<Type, Type*, Zone, ZoneRep> ZoneTests; 1032 typedef Tests<Type, Type*, Zone, ZoneRep> ZoneTests;
840 typedef Tests<HeapType, Handle<HeapType>, Isolate, HeapRep> HeapTests; 1033 typedef Tests<HeapType, Handle<HeapType>, Isolate, HeapRep> HeapTests;
841 1034
842 1035
843 TEST(Bitset) { 1036 TEST(BitsetType) {
844 CcTest::InitializeVM(); 1037 CcTest::InitializeVM();
845 ZoneTests().Bitset(); 1038 ZoneTests().Bitset();
846 HeapTests().Bitset(); 1039 HeapTests().Bitset();
847 } 1040 }
848 1041
849 1042
850 TEST(Class) { 1043 TEST(ClassType) {
851 CcTest::InitializeVM(); 1044 CcTest::InitializeVM();
852 ZoneTests().Class(); 1045 ZoneTests().Class();
853 HeapTests().Class(); 1046 HeapTests().Class();
854 } 1047 }
855 1048
856 1049
857 TEST(Constant) { 1050 TEST(ConstantType) {
858 CcTest::InitializeVM(); 1051 CcTest::InitializeVM();
859 ZoneTests().Constant(); 1052 ZoneTests().Constant();
860 HeapTests().Constant(); 1053 HeapTests().Constant();
861 } 1054 }
862 1055
863 1056
1057 TEST(ArrayType) {
1058 CcTest::InitializeVM();
1059 ZoneTests().Array();
1060 HeapTests().Array();
1061 }
1062
1063
1064 TEST(FunctionType) {
1065 CcTest::InitializeVM();
1066 ZoneTests().Function();
1067 HeapTests().Function();
1068 }
1069
1070
864 TEST(Is) { 1071 TEST(Is) {
865 CcTest::InitializeVM(); 1072 CcTest::InitializeVM();
866 ZoneTests().Is(); 1073 ZoneTests().Is();
867 HeapTests().Is(); 1074 HeapTests().Is();
868 } 1075 }
869 1076
870 1077
871 TEST(Maybe) { 1078 TEST(Maybe) {
872 CcTest::InitializeVM(); 1079 CcTest::InitializeVM();
873 ZoneTests().Maybe(); 1080 ZoneTests().Maybe();
(...skipping 13 matching lines...)
887 ZoneTests().Intersect(); 1094 ZoneTests().Intersect();
888 HeapTests().Intersect(); 1095 HeapTests().Intersect();
889 } 1096 }
890 1097
891 1098
892 TEST(Convert) { 1099 TEST(Convert) {
893 CcTest::InitializeVM(); 1100 CcTest::InitializeVM();
894 ZoneTests().Convert<HeapType, Handle<HeapType>, Isolate, HeapRep>(); 1101 ZoneTests().Convert<HeapType, Handle<HeapType>, Isolate, HeapRep>();
895 HeapTests().Convert<Type, Type*, Zone, ZoneRep>(); 1102 HeapTests().Convert<Type, Type*, Zone, ZoneRep>();
896 } 1103 }
OLDNEW
« src/types.h ('K') | « src/types-inl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine