Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

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

Issue 132493002: [Sheriff] Revert "Templatise type representation" and "Fix Mac warnings". (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/typing.cc ('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 13 matching lines...) Expand all
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 "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 // Testing auxiliaries (breaking the Type abstraction). 33 // Testing auxiliaries (breaking the Type abstraction).
34 static bool IsBitset(Handle<Type> t) { return t->IsSmi(); } 34 static bool IsBitset(Type* type) { return type->IsSmi(); }
35 static bool IsClass(Handle<Type> t) { return t->IsMap(); } 35 static bool IsClass(Type* type) { return type->IsMap(); }
36 static bool IsConstant(Handle<Type> t) { return t->IsBox(); } 36 static bool IsConstant(Type* type) { return type->IsBox(); }
37 static bool IsUnion(Handle<Type> t) { return t->IsFixedArray(); } 37 static bool IsUnion(Type* type) { return type->IsFixedArray(); }
38 38
39 static int AsBitset(Handle<Type> t) { return Smi::cast(*t)->value(); } 39 static int AsBitset(Type* type) { return Smi::cast(type)->value(); }
40 static Map* AsClass(Handle<Type> t) { return Map::cast(*t); } 40 static Map* AsClass(Type* type) { return Map::cast(type); }
41 static Object* AsConstant(Handle<Type> t) { return Box::cast(*t)->value(); } 41 static Object* AsConstant(Type* type) { return Box::cast(type)->value(); }
42 static FixedArray* AsUnion(Handle<Type> t) { return FixedArray::cast(*t); } 42 static FixedArray* AsUnion(Type* type) { return FixedArray::cast(type); }
43 43
44 44
45 static void CheckEqual(Handle<Type> type1, Handle<Type> type2) { 45 static void CheckEqual(Handle<Type> type1, Handle<Type> type2) {
46 CHECK_EQ(IsBitset(type1), IsBitset(type2)); 46 CHECK_EQ(IsBitset(*type1), IsBitset(*type2));
47 CHECK_EQ(IsClass(type1), IsClass(type2)); 47 CHECK_EQ(IsClass(*type1), IsClass(*type2));
48 CHECK_EQ(IsConstant(type1), IsConstant(type2)); 48 CHECK_EQ(IsConstant(*type1), IsConstant(*type2));
49 CHECK_EQ(IsUnion(type1), IsUnion(type2)); 49 CHECK_EQ(IsUnion(*type1), IsUnion(*type2));
50 CHECK_EQ(type1->NumClasses(), type2->NumClasses()); 50 CHECK_EQ(type1->NumClasses(), type2->NumClasses());
51 CHECK_EQ(type1->NumConstants(), type2->NumConstants()); 51 CHECK_EQ(type1->NumConstants(), type2->NumConstants());
52 if (IsBitset(type1)) { 52 if (IsBitset(*type1)) {
53 CHECK_EQ(AsBitset(type1), AsBitset(type2)); 53 CHECK_EQ(AsBitset(*type1), AsBitset(*type2));
54 } else if (IsClass(type1)) { 54 } else if (IsClass(*type1)) {
55 CHECK_EQ(AsClass(type1), AsClass(type2)); 55 CHECK_EQ(AsClass(*type1), AsClass(*type2));
56 } else if (IsConstant(type1)) { 56 } else if (IsConstant(*type1)) {
57 CHECK_EQ(AsConstant(type1), AsConstant(type2)); 57 CHECK_EQ(AsConstant(*type1), AsConstant(*type2));
58 } else if (IsUnion(type1)) { 58 } else if (IsUnion(*type1)) {
59 CHECK_EQ(AsUnion(type1)->length(), AsUnion(type2)->length()); 59 CHECK_EQ(AsUnion(*type1)->length(), AsUnion(*type2)->length());
60 } 60 }
61 CHECK(type1->Is(type2)); 61 CHECK(type1->Is(type2));
62 CHECK(type2->Is(type1)); 62 CHECK(type2->Is(type1));
63 } 63 }
64 64
65 65
66 static void CheckSub(Handle<Type> type1, Handle<Type> type2) { 66 static void CheckSub(Handle<Type> type1, Handle<Type> type2) {
67 CHECK(type1->Is(type2)); 67 CHECK(type1->Is(type2));
68 CHECK(!type2->Is(type1)); 68 CHECK(!type2->Is(type1));
69 if (IsBitset(type1) && IsBitset(type2)) { 69 if (IsBitset(*type1) && IsBitset(*type2)) {
70 CHECK_NE(AsBitset(type1), AsBitset(type2)); 70 CHECK_NE(AsBitset(*type1), AsBitset(*type2));
71 } 71 }
72 } 72 }
73 73
74 74
75 static void CheckUnordered(Handle<Type> type1, Handle<Type> type2) { 75 static void CheckUnordered(Handle<Type> type1, Handle<Type> type2) {
76 CHECK(!type1->Is(type2)); 76 CHECK(!type1->Is(type2));
77 CHECK(!type2->Is(type1)); 77 CHECK(!type2->Is(type1));
78 if (IsBitset(type1) && IsBitset(type2)) { 78 if (IsBitset(*type1) && IsBitset(*type2)) {
79 CHECK_NE(AsBitset(type1), AsBitset(type2)); 79 CHECK_NE(AsBitset(*type1), AsBitset(*type2));
80 } 80 }
81 } 81 }
82 82
83 83
84 static void CheckOverlap(Handle<Type> type1, Handle<Type> type2) { 84 static void CheckOverlap(Handle<Type> type1, Handle<Type> type2) {
85 CHECK(type1->Maybe(type2)); 85 CHECK(type1->Maybe(type2));
86 CHECK(type2->Maybe(type1)); 86 CHECK(type2->Maybe(type1));
87 if (IsBitset(type1) && IsBitset(type2)) { 87 if (IsBitset(*type1) && IsBitset(*type2)) {
88 CHECK_NE(0, AsBitset(type1) & AsBitset(type2)); 88 CHECK_NE(0, AsBitset(*type1) & AsBitset(*type2));
89 } 89 }
90 } 90 }
91 91
92 92
93 static void CheckDisjoint(Handle<Type> type1, Handle<Type> type2) { 93 static void CheckDisjoint(Handle<Type> type1, Handle<Type> type2) {
94 CHECK(!type1->Is(type2)); 94 CHECK(!type1->Is(type2));
95 CHECK(!type2->Is(type1)); 95 CHECK(!type2->Is(type1));
96 CHECK(!type1->Maybe(type2)); 96 CHECK(!type1->Maybe(type2));
97 CHECK(!type2->Maybe(type1)); 97 CHECK(!type2->Maybe(type1));
98 if (IsBitset(type1) && IsBitset(type2)) { 98 if (IsBitset(*type1) && IsBitset(*type2)) {
99 CHECK_EQ(0, AsBitset(type1) & AsBitset(type2)); 99 CHECK_EQ(0, AsBitset(*type1) & AsBitset(*type2));
100 } 100 }
101 } 101 }
102 102
103 103
104 class HandlifiedTypes { 104 class HandlifiedTypes {
105 public: 105 public:
106 explicit HandlifiedTypes(Isolate* isolate) : 106 explicit HandlifiedTypes(Isolate* isolate) :
107 None(Type::None(isolate)), 107 None(Type::None(), isolate),
108 Any(Type::Any(isolate)), 108 Any(Type::Any(), isolate),
109 Oddball(Type::Oddball(isolate)), 109 Oddball(Type::Oddball(), isolate),
110 Boolean(Type::Boolean(isolate)), 110 Boolean(Type::Boolean(), isolate),
111 Null(Type::Null(isolate)), 111 Null(Type::Null(), isolate),
112 Undefined(Type::Undefined(isolate)), 112 Undefined(Type::Undefined(), isolate),
113 Number(Type::Number(isolate)), 113 Number(Type::Number(), isolate),
114 Smi(Type::Smi(isolate)), 114 Smi(Type::Smi(), isolate),
115 Signed32(Type::Signed32(isolate)), 115 Signed32(Type::Signed32(), isolate),
116 Double(Type::Double(isolate)), 116 Double(Type::Double(), isolate),
117 Name(Type::Name(isolate)), 117 Name(Type::Name(), isolate),
118 UniqueName(Type::UniqueName(isolate)), 118 UniqueName(Type::UniqueName(), isolate),
119 String(Type::String(isolate)), 119 String(Type::String(), isolate),
120 InternalizedString(Type::InternalizedString(isolate)), 120 InternalizedString(Type::InternalizedString(), isolate),
121 Symbol(Type::Symbol(isolate)), 121 Symbol(Type::Symbol(), isolate),
122 Receiver(Type::Receiver(isolate)), 122 Receiver(Type::Receiver(), isolate),
123 Object(Type::Object(isolate)), 123 Object(Type::Object(), isolate),
124 Array(Type::Array(isolate)), 124 Array(Type::Array(), isolate),
125 Function(Type::Function(isolate)), 125 Function(Type::Function(), isolate),
126 Proxy(Type::Proxy(isolate)), 126 Proxy(Type::Proxy(), isolate),
127 object_map(isolate->factory()->NewMap(JS_OBJECT_TYPE, 3 * kPointerSize)), 127 object_map(isolate->factory()->NewMap(JS_OBJECT_TYPE, 3 * kPointerSize)),
128 array_map(isolate->factory()->NewMap(JS_ARRAY_TYPE, 4 * kPointerSize)), 128 array_map(isolate->factory()->NewMap(JS_ARRAY_TYPE, 4 * kPointerSize)),
129 isolate_(isolate) { 129 isolate_(isolate) {
130 smi = handle(Smi::FromInt(666), isolate); 130 smi = handle(Smi::FromInt(666), isolate);
131 signed32 = isolate->factory()->NewHeapNumber(0x40000000); 131 signed32 = isolate->factory()->NewHeapNumber(0x40000000);
132 object1 = isolate->factory()->NewJSObjectFromMap(object_map); 132 object1 = isolate->factory()->NewJSObjectFromMap(object_map);
133 object2 = isolate->factory()->NewJSObjectFromMap(object_map); 133 object2 = isolate->factory()->NewJSObjectFromMap(object_map);
134 array = isolate->factory()->NewJSArray(20); 134 array = isolate->factory()->NewJSArray(20);
135 ObjectClass = Type::Class(object_map, isolate); 135 ObjectClass = Class(object_map);
136 ArrayClass = Type::Class(array_map, isolate); 136 ArrayClass = Class(array_map);
137 SmiConstant = Type::Constant(smi, isolate); 137 SmiConstant = Constant(smi);
138 Signed32Constant = Type::Constant(signed32, isolate); 138 Signed32Constant = Constant(signed32);
139 ObjectConstant1 = Type::Constant(object1, isolate); 139 ObjectConstant1 = Constant(object1);
140 ObjectConstant2 = Type::Constant(object2, isolate); 140 ObjectConstant2 = Constant(object2);
141 ArrayConstant1 = Type::Constant(array, isolate); 141 ArrayConstant1 = Constant(array);
142 ArrayConstant2 = Type::Constant(array, isolate); 142 ArrayConstant2 = Constant(array);
143 } 143 }
144 144
145 Handle<Type> None; 145 Handle<Type> None;
146 Handle<Type> Any; 146 Handle<Type> Any;
147 Handle<Type> Oddball; 147 Handle<Type> Oddball;
148 Handle<Type> Boolean; 148 Handle<Type> Boolean;
149 Handle<Type> Null; 149 Handle<Type> Null;
150 Handle<Type> Undefined; 150 Handle<Type> Undefined;
151 Handle<Type> Number; 151 Handle<Type> Number;
152 Handle<Type> Smi; 152 Handle<Type> Smi;
(...skipping 22 matching lines...) Expand all
175 175
176 Handle<Map> object_map; 176 Handle<Map> object_map;
177 Handle<Map> array_map; 177 Handle<Map> array_map;
178 178
179 Handle<i::Smi> smi; 179 Handle<i::Smi> smi;
180 Handle<HeapNumber> signed32; 180 Handle<HeapNumber> signed32;
181 Handle<JSObject> object1; 181 Handle<JSObject> object1;
182 Handle<JSObject> object2; 182 Handle<JSObject> object2;
183 Handle<JSArray> array; 183 Handle<JSArray> array;
184 184
185 Handle<Type> Union(Handle<Type> t1, Handle<Type> t2) { 185 Handle<Type> Class(Handle<Map> map) {
186 return Type::Union(t1, t2, isolate_); 186 return handle(Type::Class(map), isolate_);
187 } 187 }
188 Handle<Type> Intersect(Handle<Type> t1, Handle<Type> t2) { 188 Handle<Type> Constant(Handle<i::Object> value) {
189 return Type::Intersect(t1, t2, isolate_); 189 return handle(Type::Constant(value, isolate_), isolate_);
190 }
191 Handle<Type> Union(Handle<Type> type1, Handle<Type> type2) {
192 return handle(Type::Union(type1, type2), isolate_);
193 }
194 Handle<Type> Intersect(Handle<Type> type1, Handle<Type> type2) {
195 return handle(Type::Intersect(type1, type2), isolate_);
190 } 196 }
191 197
192 private: 198 private:
193 Isolate* isolate_; 199 Isolate* isolate_;
194 }; 200 };
195 201
196 202
197 TEST(Bitset) { 203 TEST(Bitset) {
198 CcTest::InitializeVM(); 204 CcTest::InitializeVM();
199 Isolate* isolate = CcTest::i_isolate(); 205 Isolate* isolate = CcTest::i_isolate();
200 HandleScope scope(isolate); 206 HandleScope scope(isolate);
201 HandlifiedTypes T(isolate); 207 HandlifiedTypes T(isolate);
202 208
203 CHECK(IsBitset(T.None)); 209 CHECK(IsBitset(*T.None));
204 CHECK(IsBitset(T.Any)); 210 CHECK(IsBitset(*T.Any));
205 CHECK(IsBitset(T.String)); 211 CHECK(IsBitset(*T.String));
206 CHECK(IsBitset(T.Object)); 212 CHECK(IsBitset(*T.Object));
207 213
208 CHECK(IsBitset(T.Union(T.String, T.Number))); 214 CHECK(IsBitset(Type::Union(T.String, T.Number)));
209 CHECK(IsBitset(T.Union(T.String, T.Receiver))); 215 CHECK(IsBitset(Type::Union(T.String, T.Receiver)));
216 CHECK(IsBitset(Type::Optional(T.Object)));
210 217
211 CHECK_EQ(0, AsBitset(T.None)); 218 CHECK_EQ(0, AsBitset(*T.None));
212 CHECK_EQ(AsBitset(T.Number) | AsBitset(T.String), 219 CHECK_EQ(AsBitset(*T.Number) | AsBitset(*T.String),
213 AsBitset(T.Union(T.String, T.Number))); 220 AsBitset(Type::Union(T.String, T.Number)));
214 CHECK_EQ(AsBitset(T.Receiver), 221 CHECK_EQ(AsBitset(*T.Receiver),
215 AsBitset(T.Union(T.Receiver, T.Object))); 222 AsBitset(Type::Union(T.Receiver, T.Object)));
223 CHECK_EQ(AsBitset(*T.String) | AsBitset(*T.Undefined),
224 AsBitset(Type::Optional(T.String)));
216 } 225 }
217 226
218 227
219 TEST(Class) { 228 TEST(Class) {
220 CcTest::InitializeVM(); 229 CcTest::InitializeVM();
221 Isolate* isolate = CcTest::i_isolate(); 230 Isolate* isolate = CcTest::i_isolate();
222 HandleScope scope(isolate); 231 HandleScope scope(isolate);
223 HandlifiedTypes T(isolate); 232 HandlifiedTypes T(isolate);
224 233
225 CHECK(IsClass(T.ObjectClass)); 234 CHECK(IsClass(*T.ObjectClass));
226 CHECK(IsClass(T.ArrayClass)); 235 CHECK(IsClass(*T.ArrayClass));
227 236
228 CHECK(*T.object_map == AsClass(T.ObjectClass)); 237 CHECK(*T.object_map == AsClass(*T.ObjectClass));
229 CHECK(*T.array_map == AsClass(T.ArrayClass)); 238 CHECK(*T.array_map == AsClass(*T.ArrayClass));
230 } 239 }
231 240
232 241
233 TEST(Constant) { 242 TEST(Constant) {
234 CcTest::InitializeVM(); 243 CcTest::InitializeVM();
235 Isolate* isolate = CcTest::i_isolate(); 244 Isolate* isolate = CcTest::i_isolate();
236 HandleScope scope(isolate); 245 HandleScope scope(isolate);
237 HandlifiedTypes T(isolate); 246 HandlifiedTypes T(isolate);
238 247
239 CHECK(IsConstant(T.SmiConstant)); 248 CHECK(IsConstant(*T.SmiConstant));
240 CHECK(IsConstant(T.ObjectConstant1)); 249 CHECK(IsConstant(*T.ObjectConstant1));
241 CHECK(IsConstant(T.ObjectConstant2)); 250 CHECK(IsConstant(*T.ObjectConstant2));
242 CHECK(IsConstant(T.ArrayConstant1)); 251 CHECK(IsConstant(*T.ArrayConstant1));
243 CHECK(IsConstant(T.ArrayConstant2)); 252 CHECK(IsConstant(*T.ArrayConstant2));
244 253
245 CHECK(*T.smi == AsConstant(T.SmiConstant)); 254 CHECK(*T.smi == AsConstant(*T.SmiConstant));
246 CHECK(*T.object1 == AsConstant(T.ObjectConstant1)); 255 CHECK(*T.object1 == AsConstant(*T.ObjectConstant1));
247 CHECK(*T.object2 == AsConstant(T.ObjectConstant2)); 256 CHECK(*T.object2 == AsConstant(*T.ObjectConstant2));
248 CHECK(*T.object1 != AsConstant(T.ObjectConstant2)); 257 CHECK(*T.object1 != AsConstant(*T.ObjectConstant2));
249 CHECK(*T.array == AsConstant(T.ArrayConstant1)); 258 CHECK(*T.array == AsConstant(*T.ArrayConstant1));
250 CHECK(*T.array == AsConstant(T.ArrayConstant2)); 259 CHECK(*T.array == AsConstant(*T.ArrayConstant2));
251 } 260 }
252 261
253 262
254 TEST(Is) { 263 TEST(Is) {
255 CcTest::InitializeVM(); 264 CcTest::InitializeVM();
256 Isolate* isolate = CcTest::i_isolate(); 265 Isolate* isolate = CcTest::i_isolate();
257 HandleScope scope(isolate); 266 HandleScope scope(isolate);
258 HandlifiedTypes T(isolate); 267 HandlifiedTypes T(isolate);
259 268
260 // Reflexivity 269 // Reflexivity
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 } 419 }
411 420
412 421
413 TEST(Union) { 422 TEST(Union) {
414 CcTest::InitializeVM(); 423 CcTest::InitializeVM();
415 Isolate* isolate = CcTest::i_isolate(); 424 Isolate* isolate = CcTest::i_isolate();
416 HandleScope scope(isolate); 425 HandleScope scope(isolate);
417 HandlifiedTypes T(isolate); 426 HandlifiedTypes T(isolate);
418 427
419 // Bitset-bitset 428 // Bitset-bitset
420 CHECK(IsBitset(T.Union(T.Object, T.Number))); 429 CHECK(IsBitset(Type::Union(T.Object, T.Number)));
421 CHECK(IsBitset(T.Union(T.Object, T.Object))); 430 CHECK(IsBitset(Type::Union(T.Object, T.Object)));
422 CHECK(IsBitset(T.Union(T.Any, T.None))); 431 CHECK(IsBitset(Type::Union(T.Any, T.None)));
423 432
424 CheckEqual(T.Union(T.None, T.Number), T.Number); 433 CheckEqual(T.Union(T.None, T.Number), T.Number);
425 CheckEqual(T.Union(T.Object, T.Proxy), T.Receiver); 434 CheckEqual(T.Union(T.Object, T.Proxy), T.Receiver);
426 CheckEqual(T.Union(T.Number, T.String), T.Union(T.String, T.Number)); 435 CheckEqual(T.Union(T.Number, T.String), T.Union(T.String, T.Number));
427 CheckSub(T.Union(T.Number, T.String), T.Any); 436 CheckSub(T.Union(T.Number, T.String), T.Any);
428 437
429 // Class-class 438 // Class-class
430 CHECK(IsClass(T.Union(T.ObjectClass, T.ObjectClass))); 439 CHECK(IsClass(Type::Union(T.ObjectClass, T.ObjectClass)));
431 CHECK(IsUnion(T.Union(T.ObjectClass, T.ArrayClass))); 440 CHECK(IsUnion(Type::Union(T.ObjectClass, T.ArrayClass)));
432 441
433 CheckEqual(T.Union(T.ObjectClass, T.ObjectClass), T.ObjectClass); 442 CheckEqual(T.Union(T.ObjectClass, T.ObjectClass), T.ObjectClass);
434 CheckSub(T.None, T.Union(T.ObjectClass, T.ArrayClass)); 443 CheckSub(T.None, T.Union(T.ObjectClass, T.ArrayClass));
435 CheckSub(T.Union(T.ObjectClass, T.ArrayClass), T.Any); 444 CheckSub(T.Union(T.ObjectClass, T.ArrayClass), T.Any);
436 CheckSub(T.ObjectClass, T.Union(T.ObjectClass, T.ArrayClass)); 445 CheckSub(T.ObjectClass, T.Union(T.ObjectClass, T.ArrayClass));
437 CheckSub(T.ArrayClass, T.Union(T.ObjectClass, T.ArrayClass)); 446 CheckSub(T.ArrayClass, T.Union(T.ObjectClass, T.ArrayClass));
438 CheckSub(T.Union(T.ObjectClass, T.ArrayClass), T.Object); 447 CheckSub(T.Union(T.ObjectClass, T.ArrayClass), T.Object);
439 CheckUnordered(T.Union(T.ObjectClass, T.ArrayClass), T.Array); 448 CheckUnordered(T.Union(T.ObjectClass, T.ArrayClass), T.Array);
440 CheckOverlap(T.Union(T.ObjectClass, T.ArrayClass), T.Array); 449 CheckOverlap(T.Union(T.ObjectClass, T.ArrayClass), T.Array);
441 CheckDisjoint(T.Union(T.ObjectClass, T.ArrayClass), T.Number); 450 CheckDisjoint(T.Union(T.ObjectClass, T.ArrayClass), T.Number);
442 451
443 // Constant-constant 452 // Constant-constant
444 CHECK(IsConstant(T.Union(T.ObjectConstant1, T.ObjectConstant1))); 453 CHECK(IsConstant(Type::Union(T.ObjectConstant1, T.ObjectConstant1)));
445 CHECK(IsConstant(T.Union(T.ArrayConstant1, T.ArrayConstant1))); 454 CHECK(IsConstant(Type::Union(T.ArrayConstant1, T.ArrayConstant1)));
446 CHECK(IsUnion(T.Union(T.ObjectConstant1, T.ObjectConstant2))); 455 CHECK(IsUnion(Type::Union(T.ObjectConstant1, T.ObjectConstant2)));
447 456
448 CheckEqual(T.Union(T.ObjectConstant1, T.ObjectConstant1), T.ObjectConstant1); 457 CheckEqual(T.Union(T.ObjectConstant1, T.ObjectConstant1), T.ObjectConstant1);
449 CheckEqual(T.Union(T.ArrayConstant1, T.ArrayConstant1), T.ArrayConstant1); 458 CheckEqual(T.Union(T.ArrayConstant1, T.ArrayConstant1), T.ArrayConstant1);
450 CheckEqual(T.Union(T.ArrayConstant1, T.ArrayConstant1), T.ArrayConstant2); 459 CheckEqual(T.Union(T.ArrayConstant1, T.ArrayConstant1), T.ArrayConstant2);
451 CheckSub(T.None, T.Union(T.ObjectConstant1, T.ObjectConstant2)); 460 CheckSub(T.None, T.Union(T.ObjectConstant1, T.ObjectConstant2));
452 CheckSub(T.Union(T.ObjectConstant1, T.ObjectConstant2), T.Any); 461 CheckSub(T.Union(T.ObjectConstant1, T.ObjectConstant2), T.Any);
453 CheckSub(T.ObjectConstant1, T.Union(T.ObjectConstant1, T.ObjectConstant2)); 462 CheckSub(T.ObjectConstant1, T.Union(T.ObjectConstant1, T.ObjectConstant2));
454 CheckSub(T.ObjectConstant2, T.Union(T.ObjectConstant1, T.ObjectConstant2)); 463 CheckSub(T.ObjectConstant2, T.Union(T.ObjectConstant1, T.ObjectConstant2));
455 CheckSub(T.ArrayConstant2, T.Union(T.ArrayConstant1, T.ObjectConstant2)); 464 CheckSub(T.ArrayConstant2, T.Union(T.ArrayConstant1, T.ObjectConstant2));
456 CheckSub(T.Union(T.ObjectConstant1, T.ObjectConstant2), T.Object); 465 CheckSub(T.Union(T.ObjectConstant1, T.ObjectConstant2), T.Object);
457 CheckUnordered(T.Union(T.ObjectConstant1, T.ObjectConstant2), T.ObjectClass); 466 CheckUnordered(T.Union(T.ObjectConstant1, T.ObjectConstant2), T.ObjectClass);
458 CheckUnordered(T.Union(T.ObjectConstant1, T.ArrayConstant1), T.Array); 467 CheckUnordered(T.Union(T.ObjectConstant1, T.ArrayConstant1), T.Array);
459 CheckOverlap(T.Union(T.ObjectConstant1, T.ArrayConstant1), T.Array); 468 CheckOverlap(T.Union(T.ObjectConstant1, T.ArrayConstant1), T.Array);
460 CheckOverlap(T.Union(T.ObjectConstant1, T.ArrayConstant1), T.ArrayConstant2); 469 CheckOverlap(T.Union(T.ObjectConstant1, T.ArrayConstant1), T.ArrayConstant2);
461 CheckDisjoint(T.Union(T.ObjectConstant1, T.ArrayConstant1), T.Number); 470 CheckDisjoint(T.Union(T.ObjectConstant1, T.ArrayConstant1), T.Number);
462 CheckDisjoint(T.Union(T.ObjectConstant1, T.ArrayConstant1), T.ObjectClass); 471 CheckDisjoint(T.Union(T.ObjectConstant1, T.ArrayConstant1), T.ObjectClass);
463 472
464 // Bitset-class 473 // Bitset-class
465 CHECK(IsBitset(T.Union(T.ObjectClass, T.Object))); 474 CHECK(IsBitset(Type::Union(T.ObjectClass, T.Object)));
466 CHECK(IsUnion(T.Union(T.ObjectClass, T.Number))); 475 CHECK(IsUnion(Type::Union(T.ObjectClass, T.Number)));
467 476
468 CheckEqual(T.Union(T.ObjectClass, T.Object), T.Object); 477 CheckEqual(T.Union(T.ObjectClass, T.Object), T.Object);
469 CheckSub(T.None, T.Union(T.ObjectClass, T.Number)); 478 CheckSub(T.None, T.Union(T.ObjectClass, T.Number));
470 CheckSub(T.Union(T.ObjectClass, T.Number), T.Any); 479 CheckSub(T.Union(T.ObjectClass, T.Number), T.Any);
471 CheckSub(T.Union(T.ObjectClass, T.Smi), T.Union(T.Object, T.Number)); 480 CheckSub(T.Union(T.ObjectClass, T.Smi), T.Union(T.Object, T.Number));
472 CheckSub(T.Union(T.ObjectClass, T.Array), T.Object); 481 CheckSub(T.Union(T.ObjectClass, T.Array), T.Object);
473 CheckUnordered(T.Union(T.ObjectClass, T.String), T.Array); 482 CheckUnordered(T.Union(T.ObjectClass, T.String), T.Array);
474 CheckOverlap(T.Union(T.ObjectClass, T.String), T.Object); 483 CheckOverlap(T.Union(T.ObjectClass, T.String), T.Object);
475 CheckDisjoint(T.Union(T.ObjectClass, T.String), T.Number); 484 CheckDisjoint(T.Union(T.ObjectClass, T.String), T.Number);
476 485
477 // Bitset-constant 486 // Bitset-constant
478 CHECK(IsBitset(T.Union(T.SmiConstant, T.Number))); 487 CHECK(IsBitset(Type::Union(T.SmiConstant, T.Number)));
479 CHECK(IsBitset(T.Union(T.ObjectConstant1, T.Object))); 488 CHECK(IsBitset(Type::Union(T.ObjectConstant1, T.Object)));
480 CHECK(IsUnion(T.Union(T.ObjectConstant2, T.Number))); 489 CHECK(IsUnion(Type::Union(T.ObjectConstant2, T.Number)));
481 490
482 CheckEqual(T.Union(T.SmiConstant, T.Number), T.Number); 491 CheckEqual(T.Union(T.SmiConstant, T.Number), T.Number);
483 CheckEqual(T.Union(T.ObjectConstant1, T.Object), T.Object); 492 CheckEqual(T.Union(T.ObjectConstant1, T.Object), T.Object);
484 CheckSub(T.None, T.Union(T.ObjectConstant1, T.Number)); 493 CheckSub(T.None, T.Union(T.ObjectConstant1, T.Number));
485 CheckSub(T.Union(T.ObjectConstant1, T.Number), T.Any); 494 CheckSub(T.Union(T.ObjectConstant1, T.Number), T.Any);
486 CheckSub(T.Union(T.ObjectConstant1, T.Signed32), T.Union(T.Object, T.Number)); 495 CheckSub(T.Union(T.ObjectConstant1, T.Signed32), T.Union(T.Object, T.Number));
487 CheckSub(T.Union(T.ObjectConstant1, T.Array), T.Object); 496 CheckSub(T.Union(T.ObjectConstant1, T.Array), T.Object);
488 CheckUnordered(T.Union(T.ObjectConstant1, T.String), T.Array); 497 CheckUnordered(T.Union(T.ObjectConstant1, T.String), T.Array);
489 CheckOverlap(T.Union(T.ObjectConstant1, T.String), T.Object); 498 CheckOverlap(T.Union(T.ObjectConstant1, T.String), T.Object);
490 CheckDisjoint(T.Union(T.ObjectConstant1, T.String), T.Number); 499 CheckDisjoint(T.Union(T.ObjectConstant1, T.String), T.Number);
491 CheckEqual(T.Union(T.Signed32, T.Signed32Constant), T.Signed32); 500 CheckEqual(T.Union(T.Signed32, T.Signed32Constant), T.Signed32);
492 501
493 // Class-constant 502 // Class-constant
494 CHECK(IsUnion(T.Union(T.ObjectConstant1, T.ObjectClass))); 503 CHECK(IsUnion(Type::Union(T.ObjectConstant1, T.ObjectClass)));
495 CHECK(IsUnion(T.Union(T.ArrayClass, T.ObjectConstant2))); 504 CHECK(IsUnion(Type::Union(T.ArrayClass, T.ObjectConstant2)));
496 505
497 CheckSub(T.None, T.Union(T.ObjectConstant1, T.ArrayClass)); 506 CheckSub(T.None, T.Union(T.ObjectConstant1, T.ArrayClass));
498 CheckSub(T.Union(T.ObjectConstant1, T.ArrayClass), T.Any); 507 CheckSub(T.Union(T.ObjectConstant1, T.ArrayClass), T.Any);
499 CheckSub(T.Union(T.ObjectConstant1, T.ArrayClass), T.Object); 508 CheckSub(T.Union(T.ObjectConstant1, T.ArrayClass), T.Object);
500 CheckSub(T.ObjectConstant1, T.Union(T.ObjectConstant1, T.ArrayClass)); 509 CheckSub(T.ObjectConstant1, T.Union(T.ObjectConstant1, T.ArrayClass));
501 CheckSub(T.ArrayClass, T.Union(T.ObjectConstant1, T.ArrayClass)); 510 CheckSub(T.ArrayClass, T.Union(T.ObjectConstant1, T.ArrayClass));
502 CheckUnordered(T.ObjectClass, T.Union(T.ObjectConstant1, T.ArrayClass)); 511 CheckUnordered(T.ObjectClass, T.Union(T.ObjectConstant1, T.ArrayClass));
503 CheckSub( 512 CheckSub(
504 T.Union(T.ObjectConstant1, T.ArrayClass), T.Union(T.Array, T.Object)); 513 T.Union(T.ObjectConstant1, T.ArrayClass), T.Union(T.Array, T.Object));
505 CheckUnordered(T.Union(T.ObjectConstant1, T.ArrayClass), T.ArrayConstant1); 514 CheckUnordered(T.Union(T.ObjectConstant1, T.ArrayClass), T.ArrayConstant1);
506 CheckDisjoint(T.Union(T.ObjectConstant1, T.ArrayClass), T.ObjectConstant2); 515 CheckDisjoint(T.Union(T.ObjectConstant1, T.ArrayClass), T.ObjectConstant2);
507 CheckDisjoint(T.Union(T.ObjectConstant1, T.ArrayClass), T.ObjectClass); 516 CheckDisjoint(T.Union(T.ObjectConstant1, T.ArrayClass), T.ObjectClass);
508 517
509 // Bitset-union 518 // Bitset-union
510 CHECK(IsBitset(T.Union(T.Object, T.Union(T.ObjectConstant1, T.ObjectClass)))); 519 CHECK(IsBitset(
511 CHECK(IsUnion(T.Union(T.Union(T.ArrayClass, T.ObjectConstant2), T.Number))); 520 Type::Union(T.Object, T.Union(T.ObjectConstant1, T.ObjectClass))));
521 CHECK(IsUnion(
522 Type::Union(T.Union(T.ArrayClass, T.ObjectConstant2), T.Number)));
512 523
513 CheckEqual( 524 CheckEqual(
514 T.Union(T.Object, T.Union(T.ObjectConstant1, T.ObjectClass)), 525 T.Union(T.Object, T.Union(T.ObjectConstant1, T.ObjectClass)),
515 T.Object); 526 T.Object);
516 CheckEqual( 527 CheckEqual(
517 T.Union(T.Union(T.ArrayClass, T.ObjectConstant1), T.Number), 528 T.Union(T.Union(T.ArrayClass, T.ObjectConstant1), T.Number),
518 T.Union(T.ObjectConstant1, T.Union(T.Number, T.ArrayClass))); 529 T.Union(T.ObjectConstant1, T.Union(T.Number, T.ArrayClass)));
519 CheckSub( 530 CheckSub(
520 T.Double, 531 T.Double,
521 T.Union(T.Union(T.ArrayClass, T.ObjectConstant1), T.Number)); 532 T.Union(T.Union(T.ArrayClass, T.ObjectConstant1), T.Number));
522 CheckSub( 533 CheckSub(
523 T.ObjectConstant1, 534 T.ObjectConstant1,
524 T.Union(T.Union(T.ArrayClass, T.ObjectConstant1), T.Double)); 535 T.Union(T.Union(T.ArrayClass, T.ObjectConstant1), T.Double));
525 CheckSub( 536 CheckSub(
526 T.None, 537 T.None,
527 T.Union(T.Union(T.ArrayClass, T.ObjectConstant1), T.Double)); 538 T.Union(T.Union(T.ArrayClass, T.ObjectConstant1), T.Double));
528 CheckSub( 539 CheckSub(
529 T.Union(T.Union(T.ArrayClass, T.ObjectConstant1), T.Double), 540 T.Union(T.Union(T.ArrayClass, T.ObjectConstant1), T.Double),
530 T.Any); 541 T.Any);
531 CheckSub( 542 CheckSub(
532 T.Union(T.Union(T.ArrayClass, T.ObjectConstant1), T.Double), 543 T.Union(T.Union(T.ArrayClass, T.ObjectConstant1), T.Double),
533 T.Union(T.ObjectConstant1, T.Union(T.Number, T.ArrayClass))); 544 T.Union(T.ObjectConstant1, T.Union(T.Number, T.ArrayClass)));
534 545
535 // Class-union 546 // Class-union
536 CHECK(IsUnion( 547 CHECK(IsUnion(
537 T.Union(T.Union(T.ArrayClass, T.ObjectConstant2), T.ArrayClass))); 548 Type::Union(T.Union(T.ArrayClass, T.ObjectConstant2), T.ArrayClass)));
538 CHECK(IsUnion( 549 CHECK(IsUnion(
539 T.Union(T.Union(T.ArrayClass, T.ObjectConstant2), T.ObjectClass))); 550 Type::Union(T.Union(T.ArrayClass, T.ObjectConstant2), T.ObjectClass)));
540 551
541 CheckEqual( 552 CheckEqual(
542 T.Union(T.ObjectClass, T.Union(T.ObjectConstant1, T.ObjectClass)), 553 T.Union(T.ObjectClass, T.Union(T.ObjectConstant1, T.ObjectClass)),
543 T.Union(T.ObjectClass, T.ObjectConstant1)); 554 T.Union(T.ObjectClass, T.ObjectConstant1));
544 CheckSub( 555 CheckSub(
545 T.None, 556 T.None,
546 T.Union(T.ObjectClass, T.Union(T.ObjectConstant1, T.ObjectClass))); 557 T.Union(T.ObjectClass, T.Union(T.ObjectConstant1, T.ObjectClass)));
547 CheckSub( 558 CheckSub(
548 T.Union(T.ObjectClass, T.Union(T.ObjectConstant1, T.ObjectClass)), 559 T.Union(T.ObjectClass, T.Union(T.ObjectConstant1, T.ObjectClass)),
549 T.Any); 560 T.Any);
550 CheckSub( 561 CheckSub(
551 T.Union(T.ObjectClass, T.Union(T.ObjectConstant1, T.ObjectClass)), 562 T.Union(T.ObjectClass, T.Union(T.ObjectConstant1, T.ObjectClass)),
552 T.Object); 563 T.Object);
553 CheckEqual( 564 CheckEqual(
554 T.Union(T.Union(T.ArrayClass, T.ObjectConstant2), T.ArrayClass), 565 T.Union(T.Union(T.ArrayClass, T.ObjectConstant2), T.ArrayClass),
555 T.Union(T.ArrayClass, T.ObjectConstant2)); 566 T.Union(T.ArrayClass, T.ObjectConstant2));
556 567
557 // Constant-union 568 // Constant-union
558 CHECK(IsUnion(T.Union( 569 CHECK(IsUnion(Type::Union(
559 T.ObjectConstant1, T.Union(T.ObjectConstant1, T.ObjectConstant2)))); 570 T.ObjectConstant1, T.Union(T.ObjectConstant1, T.ObjectConstant2))));
560 CHECK(IsUnion(T.Union( 571 CHECK(IsUnion(Type::Union(
561 T.Union(T.ArrayConstant1, T.ObjectClass), T.ObjectConstant1))); 572 T.Union(T.ArrayConstant1, T.ObjectClass), T.ObjectConstant1)));
562 CHECK(IsUnion(T.Union( 573 CHECK(IsUnion(Type::Union(
563 T.Union(T.ArrayConstant1, T.ObjectConstant2), T.ObjectConstant1))); 574 T.Union(T.ArrayConstant1, T.ObjectConstant2), T.ObjectConstant1)));
564 575
565 CheckEqual( 576 CheckEqual(
566 T.Union(T.ObjectConstant1, T.Union(T.ObjectConstant1, T.ObjectConstant2)), 577 T.Union(T.ObjectConstant1, T.Union(T.ObjectConstant1, T.ObjectConstant2)),
567 T.Union(T.ObjectConstant2, T.ObjectConstant1)); 578 T.Union(T.ObjectConstant2, T.ObjectConstant1));
568 CheckEqual( 579 CheckEqual(
569 T.Union(T.Union(T.ArrayConstant1, T.ObjectConstant2), T.ObjectConstant1), 580 T.Union(T.Union(T.ArrayConstant1, T.ObjectConstant2), T.ObjectConstant1),
570 T.Union(T.ObjectConstant2, T.Union(T.ArrayConstant1, T.ObjectConstant1))); 581 T.Union(T.ObjectConstant2, T.Union(T.ArrayConstant1, T.ObjectConstant1)));
571 582
572 // Union-union 583 // Union-union
573 CHECK(IsBitset(T.Union( 584 CHECK(IsBitset(Type::Union(
574 T.Union(T.Number, T.ArrayClass), T.Union(T.Signed32, T.Array)))); 585 T.Union(T.Number, T.ArrayClass), T.Union(T.Signed32, T.Array))));
575 CHECK(IsUnion(T.Union( 586 CHECK(IsUnion(Type::Union(
576 T.Union(T.Number, T.ArrayClass), T.Union(T.ObjectClass, T.ArrayClass)))); 587 T.Union(T.Number, T.ArrayClass), T.Union(T.ObjectClass, T.ArrayClass))));
577 588
578 CheckEqual( 589 CheckEqual(
579 T.Union( 590 T.Union(
580 T.Union(T.ObjectConstant2, T.ObjectConstant1), 591 T.Union(T.ObjectConstant2, T.ObjectConstant1),
581 T.Union(T.ObjectConstant1, T.ObjectConstant2)), 592 T.Union(T.ObjectConstant1, T.ObjectConstant2)),
582 T.Union(T.ObjectConstant2, T.ObjectConstant1)); 593 T.Union(T.ObjectConstant2, T.ObjectConstant1));
583 CheckEqual( 594 CheckEqual(
584 T.Union( 595 T.Union(
585 T.Union(T.ObjectConstant2, T.ArrayConstant1), 596 T.Union(T.ObjectConstant2, T.ArrayConstant1),
586 T.Union(T.ObjectConstant1, T.ArrayConstant2)), 597 T.Union(T.ObjectConstant1, T.ArrayConstant2)),
587 T.Union(T.Union(T.ObjectConstant1, T.ObjectConstant2), T.ArrayConstant1)); 598 T.Union(T.Union(T.ObjectConstant1, T.ObjectConstant2), T.ArrayConstant1));
588 CheckEqual( 599 CheckEqual(
589 T.Union(T.Union(T.Number, T.ArrayClass), T.Union(T.Smi, T.Array)), 600 T.Union(T.Union(T.Number, T.ArrayClass), T.Union(T.Smi, T.Array)),
590 T.Union(T.Number, T.Array)); 601 T.Union(T.Number, T.Array));
591 } 602 }
592 603
593 604
594 TEST(Intersect) { 605 TEST(Intersect) {
595 CcTest::InitializeVM(); 606 CcTest::InitializeVM();
596 Isolate* isolate = CcTest::i_isolate(); 607 Isolate* isolate = CcTest::i_isolate();
597 HandleScope scope(isolate); 608 HandleScope scope(isolate);
598 HandlifiedTypes T(isolate); 609 HandlifiedTypes T(isolate);
599 610
600 // Bitset-bitset 611 // Bitset-bitset
601 CHECK(IsBitset(T.Intersect(T.Object, T.Number))); 612 CHECK(IsBitset(Type::Intersect(T.Object, T.Number)));
602 CHECK(IsBitset(T.Intersect(T.Object, T.Object))); 613 CHECK(IsBitset(Type::Intersect(T.Object, T.Object)));
603 CHECK(IsBitset(T.Intersect(T.Any, T.None))); 614 CHECK(IsBitset(Type::Intersect(T.Any, T.None)));
604 615
605 CheckEqual(T.Intersect(T.None, T.Number), T.None); 616 CheckEqual(T.Intersect(T.None, T.Number), T.None);
606 CheckEqual(T.Intersect(T.Object, T.Proxy), T.None); 617 CheckEqual(T.Intersect(T.Object, T.Proxy), T.None);
607 CheckEqual(T.Intersect(T.Name, T.String), T.Intersect(T.String, T.Name)); 618 CheckEqual(T.Intersect(T.Name, T.String), T.Intersect(T.String, T.Name));
608 CheckEqual(T.Intersect(T.UniqueName, T.String), T.InternalizedString); 619 CheckEqual(T.Intersect(T.UniqueName, T.String), T.InternalizedString);
609 620
610 // Class-class 621 // Class-class
611 CHECK(IsClass(T.Intersect(T.ObjectClass, T.ObjectClass))); 622 CHECK(IsClass(Type::Intersect(T.ObjectClass, T.ObjectClass)));
612 CHECK(IsBitset(T.Intersect(T.ObjectClass, T.ArrayClass))); 623 CHECK(IsBitset(Type::Intersect(T.ObjectClass, T.ArrayClass)));
613 624
614 CheckEqual(T.Intersect(T.ObjectClass, T.ObjectClass), T.ObjectClass); 625 CheckEqual(T.Intersect(T.ObjectClass, T.ObjectClass), T.ObjectClass);
615 CheckEqual(T.Intersect(T.ObjectClass, T.ArrayClass), T.None); 626 CheckEqual(T.Intersect(T.ObjectClass, T.ArrayClass), T.None);
616 627
617 // Constant-constant 628 // Constant-constant
618 CHECK(IsConstant(T.Intersect(T.ObjectConstant1, T.ObjectConstant1))); 629 CHECK(IsConstant(Type::Intersect(T.ObjectConstant1, T.ObjectConstant1)));
619 CHECK(IsConstant(T.Intersect(T.ArrayConstant1, T.ArrayConstant2))); 630 CHECK(IsConstant(Type::Intersect(T.ArrayConstant1, T.ArrayConstant2)));
620 CHECK(IsBitset(T.Intersect(T.ObjectConstant1, T.ObjectConstant2))); 631 CHECK(IsBitset(Type::Intersect(T.ObjectConstant1, T.ObjectConstant2)));
621 632
622 CheckEqual( 633 CheckEqual(
623 T.Intersect(T.ObjectConstant1, T.ObjectConstant1), T.ObjectConstant1); 634 T.Intersect(T.ObjectConstant1, T.ObjectConstant1), T.ObjectConstant1);
624 CheckEqual( 635 CheckEqual(
625 T.Intersect(T.ArrayConstant1, T.ArrayConstant2), T.ArrayConstant1); 636 T.Intersect(T.ArrayConstant1, T.ArrayConstant2), T.ArrayConstant1);
626 CheckEqual(T.Intersect(T.ObjectConstant1, T.ObjectConstant2), T.None); 637 CheckEqual(T.Intersect(T.ObjectConstant1, T.ObjectConstant2), T.None);
627 638
628 // Bitset-class 639 // Bitset-class
629 CHECK(IsClass(T.Intersect(T.ObjectClass, T.Object))); 640 CHECK(IsClass(Type::Intersect(T.ObjectClass, T.Object)));
630 CHECK(IsBitset(T.Intersect(T.ObjectClass, T.Number))); 641 CHECK(IsBitset(Type::Intersect(T.ObjectClass, T.Number)));
631 642
632 CheckEqual(T.Intersect(T.ObjectClass, T.Object), T.ObjectClass); 643 CheckEqual(T.Intersect(T.ObjectClass, T.Object), T.ObjectClass);
633 CheckEqual(T.Intersect(T.ObjectClass, T.Array), T.None); 644 CheckEqual(T.Intersect(T.ObjectClass, T.Array), T.None);
634 CheckEqual(T.Intersect(T.ObjectClass, T.Number), T.None); 645 CheckEqual(T.Intersect(T.ObjectClass, T.Number), T.None);
635 646
636 // Bitset-constant 647 // Bitset-constant
637 CHECK(IsBitset(T.Intersect(T.Smi, T.Number))); 648 CHECK(IsBitset(Type::Intersect(T.Smi, T.Number)));
638 CHECK(IsConstant(T.Intersect(T.SmiConstant, T.Number))); 649 CHECK(IsConstant(Type::Intersect(T.SmiConstant, T.Number)));
639 CHECK(IsConstant(T.Intersect(T.ObjectConstant1, T.Object))); 650 CHECK(IsConstant(Type::Intersect(T.ObjectConstant1, T.Object)));
640 651
641 CheckEqual(T.Intersect(T.Smi, T.Number), T.Smi); 652 CheckEqual(T.Intersect(T.Smi, T.Number), T.Smi);
642 CheckEqual(T.Intersect(T.SmiConstant, T.Number), T.SmiConstant); 653 CheckEqual(T.Intersect(T.SmiConstant, T.Number), T.SmiConstant);
643 CheckEqual(T.Intersect(T.ObjectConstant1, T.Object), T.ObjectConstant1); 654 CheckEqual(T.Intersect(T.ObjectConstant1, T.Object), T.ObjectConstant1);
644 655
645 // Class-constant 656 // Class-constant
646 CHECK(IsBitset(T.Intersect(T.ObjectConstant1, T.ObjectClass))); 657 CHECK(IsBitset(Type::Intersect(T.ObjectConstant1, T.ObjectClass)));
647 CHECK(IsBitset(T.Intersect(T.ArrayClass, T.ObjectConstant2))); 658 CHECK(IsBitset(Type::Intersect(T.ArrayClass, T.ObjectConstant2)));
648 659
649 CheckEqual(T.Intersect(T.ObjectConstant1, T.ObjectClass), T.None); 660 CheckEqual(T.Intersect(T.ObjectConstant1, T.ObjectClass), T.None);
650 CheckEqual(T.Intersect(T.ArrayClass, T.ObjectConstant2), T.None); 661 CheckEqual(T.Intersect(T.ArrayClass, T.ObjectConstant2), T.None);
651 662
652 // Bitset-union 663 // Bitset-union
653 CHECK(IsUnion( 664 CHECK(IsUnion(
654 T.Intersect(T.Object, T.Union(T.ObjectConstant1, T.ObjectClass)))); 665 Type::Intersect(T.Object, T.Union(T.ObjectConstant1, T.ObjectClass))));
655 CHECK(IsBitset( 666 CHECK(IsBitset(
656 T.Intersect(T.Union(T.ArrayClass, T.ObjectConstant2), T.Number))); 667 Type::Intersect(T.Union(T.ArrayClass, T.ObjectConstant2), T.Number)));
657 668
658 CheckEqual( 669 CheckEqual(
659 T.Intersect(T.Object, T.Union(T.ObjectConstant1, T.ObjectClass)), 670 T.Intersect(T.Object, T.Union(T.ObjectConstant1, T.ObjectClass)),
660 T.Union(T.ObjectConstant1, T.ObjectClass)); 671 T.Union(T.ObjectConstant1, T.ObjectClass));
661 CheckEqual( 672 CheckEqual(
662 T.Intersect(T.Union(T.ArrayClass, T.ObjectConstant1), T.Number), 673 T.Intersect(T.Union(T.ArrayClass, T.ObjectConstant1), T.Number),
663 T.None); 674 T.None);
664 675
665 // Class-union 676 // Class-union
666 CHECK(IsClass( 677 CHECK(IsClass(
667 T.Intersect(T.Union(T.ArrayClass, T.ObjectConstant2), T.ArrayClass))); 678 Type::Intersect(T.Union(T.ArrayClass, T.ObjectConstant2), T.ArrayClass)));
668 CHECK(IsClass( 679 CHECK(IsClass(
669 T.Intersect(T.Union(T.Object, T.SmiConstant), T.ArrayClass))); 680 Type::Intersect(T.Union(T.Object, T.SmiConstant), T.ArrayClass)));
670 CHECK(IsBitset( 681 CHECK(IsBitset(
671 T.Intersect(T.Union(T.ObjectClass, T.ArrayConstant1), T.ArrayClass))); 682 Type::Intersect(T.Union(T.ObjectClass, T.ArrayConstant1), T.ArrayClass)));
672 683
673 CheckEqual( 684 CheckEqual(
674 T.Intersect(T.ArrayClass, T.Union(T.ObjectConstant2, T.ArrayClass)), 685 T.Intersect(T.ArrayClass, T.Union(T.ObjectConstant2, T.ArrayClass)),
675 T.ArrayClass); 686 T.ArrayClass);
676 CheckEqual( 687 CheckEqual(
677 T.Intersect(T.ArrayClass, T.Union(T.Object, T.SmiConstant)), 688 T.Intersect(T.ArrayClass, T.Union(T.Object, T.SmiConstant)),
678 T.ArrayClass); 689 T.ArrayClass);
679 CheckEqual( 690 CheckEqual(
680 T.Intersect(T.Union(T.ObjectClass, T.ArrayConstant1), T.ArrayClass), 691 T.Intersect(T.Union(T.ObjectClass, T.ArrayConstant1), T.ArrayClass),
681 T.None); 692 T.None);
682 693
683 // Constant-union 694 // Constant-union
684 CHECK(IsConstant(T.Intersect( 695 CHECK(IsConstant(Type::Intersect(
685 T.ObjectConstant1, T.Union(T.ObjectConstant1, T.ObjectConstant2)))); 696 T.ObjectConstant1, T.Union(T.ObjectConstant1, T.ObjectConstant2))));
686 CHECK(IsConstant(T.Intersect( 697 CHECK(IsConstant(Type::Intersect(
687 T.Union(T.Number, T.ObjectClass), T.SmiConstant))); 698 T.Union(T.Number, T.ObjectClass), T.SmiConstant)));
688 CHECK(IsBitset(T.Intersect( 699 CHECK(IsBitset(Type::Intersect(
689 T.Union(T.ArrayConstant1, T.ObjectClass), T.ObjectConstant1))); 700 T.Union(T.ArrayConstant1, T.ObjectClass), T.ObjectConstant1)));
690 701
691 CheckEqual( 702 CheckEqual(
692 T.Intersect( 703 T.Intersect(
693 T.ObjectConstant1, T.Union(T.ObjectConstant1, T.ObjectConstant2)), 704 T.ObjectConstant1, T.Union(T.ObjectConstant1, T.ObjectConstant2)),
694 T.ObjectConstant1); 705 T.ObjectConstant1);
695 CheckEqual( 706 CheckEqual(
696 T.Intersect(T.SmiConstant, T.Union(T.Number, T.ObjectConstant2)), 707 T.Intersect(T.SmiConstant, T.Union(T.Number, T.ObjectConstant2)),
697 T.SmiConstant); 708 T.SmiConstant);
698 CheckEqual( 709 CheckEqual(
699 T.Intersect(T.Union(T.ArrayConstant1, T.ObjectClass), T.ObjectConstant1), 710 T.Intersect(T.Union(T.ArrayConstant1, T.ObjectClass), T.ObjectConstant1),
700 T.None); 711 T.None);
701 712
702 // Union-union 713 // Union-union
703 CHECK(IsUnion(T.Intersect( 714 CHECK(IsUnion(Type::Intersect(
704 T.Union(T.Number, T.ArrayClass), T.Union(T.Signed32, T.Array)))); 715 T.Union(T.Number, T.ArrayClass), T.Union(T.Signed32, T.Array))));
705 CHECK(IsBitset(T.Intersect( 716 CHECK(IsBitset(Type::Intersect(
706 T.Union(T.Number, T.ObjectClass), T.Union(T.Signed32, T.Array)))); 717 T.Union(T.Number, T.ObjectClass), T.Union(T.Signed32, T.Array))));
707 718
708 CheckEqual( 719 CheckEqual(
709 T.Intersect( 720 T.Intersect(
710 T.Union(T.Number, T.ArrayClass), 721 T.Union(T.Number, T.ArrayClass),
711 T.Union(T.Smi, T.Array)), 722 T.Union(T.Smi, T.Array)),
712 T.Union(T.Smi, T.ArrayClass)); 723 T.Union(T.Smi, T.ArrayClass));
713 CheckEqual( 724 CheckEqual(
714 T.Intersect( 725 T.Intersect(
715 T.Union(T.Number, T.ObjectClass), 726 T.Union(T.Number, T.ObjectClass),
716 T.Union(T.Signed32, T.Array)), 727 T.Union(T.Signed32, T.Array)),
717 T.Signed32); 728 T.Signed32);
718 CheckEqual( 729 CheckEqual(
719 T.Intersect( 730 T.Intersect(
720 T.Union(T.ObjectConstant2, T.ObjectConstant1), 731 T.Union(T.ObjectConstant2, T.ObjectConstant1),
721 T.Union(T.ObjectConstant1, T.ObjectConstant2)), 732 T.Union(T.ObjectConstant1, T.ObjectConstant2)),
722 T.Union(T.ObjectConstant2, T.ObjectConstant1)); 733 T.Union(T.ObjectConstant2, T.ObjectConstant1));
723 CheckEqual( 734 CheckEqual(
724 T.Intersect( 735 T.Intersect(
725 T.Union(T.Union(T.ObjectConstant2, T.ObjectConstant1), T.ArrayClass), 736 T.Union(T.Union(T.ObjectConstant2, T.ObjectConstant1), T.ArrayClass),
726 T.Union( 737 T.Union(
727 T.ObjectConstant1, T.Union(T.ArrayConstant1, T.ObjectConstant2))), 738 T.ObjectConstant1, T.Union(T.ArrayConstant1, T.ObjectConstant2))),
728 T.Union(T.ObjectConstant2, T.ObjectConstant1)); 739 T.Union(T.ObjectConstant2, T.ObjectConstant1));
729 CheckEqual( 740 CheckEqual(
730 T.Intersect( 741 T.Intersect(
731 T.Union(T.ObjectConstant2, T.ArrayConstant1), 742 T.Union(T.ObjectConstant2, T.ArrayConstant1),
732 T.Union(T.ObjectConstant1, T.ArrayConstant2)), 743 T.Union(T.ObjectConstant1, T.ArrayConstant2)),
733 T.ArrayConstant1); 744 T.ArrayConstant1);
734 } 745 }
OLDNEW
« no previous file with comments | « src/typing.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698