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

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

Issue 26223006: Minor tweaks to types cctest (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 2 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 | « no previous file | 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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 Integer31(Type::Smi(), isolate), 114 Smi(Type::Smi(), isolate),
115 Integer32(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 object1 = isolate->factory()->NewJSObjectFromMap(object_map); 132 object1 = isolate->factory()->NewJSObjectFromMap(object_map);
132 object2 = isolate->factory()->NewJSObjectFromMap(object_map); 133 object2 = isolate->factory()->NewJSObjectFromMap(object_map);
133 array = isolate->factory()->NewJSArray(20); 134 array = isolate->factory()->NewJSArray(20);
134 ObjectClass = handle(Type::Class(object_map), isolate); 135 ObjectClass = Class(object_map);
135 ArrayClass = handle(Type::Class(array_map), isolate); 136 ArrayClass = Class(array_map);
136 Integer31Constant = handle(Type::Constant(smi, isolate), isolate); 137 SmiConstant = Constant(smi);
137 ObjectConstant1 = handle(Type::Constant(object1), isolate); 138 Signed32Constant = Constant(signed32);
138 ObjectConstant2 = handle(Type::Constant(object2), isolate); 139 ObjectConstant1 = Constant(object1);
139 ArrayConstant1 = handle(Type::Constant(array), isolate); 140 ObjectConstant2 = Constant(object2);
140 ArrayConstant2 = handle(Type::Constant(array), isolate); 141 ArrayConstant1 = Constant(array);
142 ArrayConstant2 = Constant(array);
141 } 143 }
142 144
143 Handle<Type> None; 145 Handle<Type> None;
144 Handle<Type> Any; 146 Handle<Type> Any;
145 Handle<Type> Oddball; 147 Handle<Type> Oddball;
146 Handle<Type> Boolean; 148 Handle<Type> Boolean;
147 Handle<Type> Null; 149 Handle<Type> Null;
148 Handle<Type> Undefined; 150 Handle<Type> Undefined;
149 Handle<Type> Number; 151 Handle<Type> Number;
150 Handle<Type> Integer31; 152 Handle<Type> Smi;
151 Handle<Type> Integer32; 153 Handle<Type> Signed32;
152 Handle<Type> Double; 154 Handle<Type> Double;
153 Handle<Type> Name; 155 Handle<Type> Name;
154 Handle<Type> UniqueName; 156 Handle<Type> UniqueName;
155 Handle<Type> String; 157 Handle<Type> String;
156 Handle<Type> InternalizedString; 158 Handle<Type> InternalizedString;
157 Handle<Type> Symbol; 159 Handle<Type> Symbol;
158 Handle<Type> Receiver; 160 Handle<Type> Receiver;
159 Handle<Type> Object; 161 Handle<Type> Object;
160 Handle<Type> Array; 162 Handle<Type> Array;
161 Handle<Type> Function; 163 Handle<Type> Function;
162 Handle<Type> Proxy; 164 Handle<Type> Proxy;
163 165
164 Handle<Type> ObjectClass; 166 Handle<Type> ObjectClass;
165 Handle<Type> ArrayClass; 167 Handle<Type> ArrayClass;
166 168
167 Handle<Type> Integer31Constant; 169 Handle<Type> SmiConstant;
170 Handle<Type> Signed32Constant;
168 Handle<Type> ObjectConstant1; 171 Handle<Type> ObjectConstant1;
169 Handle<Type> ObjectConstant2; 172 Handle<Type> ObjectConstant2;
170 Handle<Type> ArrayConstant1; 173 Handle<Type> ArrayConstant1;
171 Handle<Type> ArrayConstant2; 174 Handle<Type> ArrayConstant2;
172 175
173 Handle<Map> object_map; 176 Handle<Map> object_map;
174 Handle<Map> array_map; 177 Handle<Map> array_map;
175 178
176 Handle<v8::internal::Smi> smi; 179 Handle<i::Smi> smi;
180 Handle<HeapNumber> signed32;
177 Handle<JSObject> object1; 181 Handle<JSObject> object1;
178 Handle<JSObject> object2; 182 Handle<JSObject> object2;
179 Handle<JSArray> array; 183 Handle<JSArray> array;
180 184
185 Handle<Type> Class(Handle<Map> map) {
186 return handle(Type::Class(map), isolate_);
187 }
188 Handle<Type> Constant(Handle<i::Object> value) {
189 return handle(Type::Constant(value, isolate_), isolate_);
190 }
181 Handle<Type> Union(Handle<Type> type1, Handle<Type> type2) { 191 Handle<Type> Union(Handle<Type> type1, Handle<Type> type2) {
182 return handle(Type::Union(type1, type2), isolate_); 192 return handle(Type::Union(type1, type2), isolate_);
183 } 193 }
184 Handle<Type> Intersect(Handle<Type> type1, Handle<Type> type2) { 194 Handle<Type> Intersect(Handle<Type> type1, Handle<Type> type2) {
185 return handle(Type::Intersect(type1, type2), isolate_); 195 return handle(Type::Intersect(type1, type2), isolate_);
186 } 196 }
187 197
188 private: 198 private:
189 Isolate* isolate_; 199 Isolate* isolate_;
190 }; 200 };
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 CHECK(*T.array_map == AsClass(*T.ArrayClass)); 238 CHECK(*T.array_map == AsClass(*T.ArrayClass));
229 } 239 }
230 240
231 241
232 TEST(Constant) { 242 TEST(Constant) {
233 CcTest::InitializeVM(); 243 CcTest::InitializeVM();
234 Isolate* isolate = CcTest::i_isolate(); 244 Isolate* isolate = CcTest::i_isolate();
235 HandleScope scope(isolate); 245 HandleScope scope(isolate);
236 HandlifiedTypes T(isolate); 246 HandlifiedTypes T(isolate);
237 247
238 CHECK(IsConstant(*T.Integer31Constant)); 248 CHECK(IsConstant(*T.SmiConstant));
239 CHECK(IsConstant(*T.ObjectConstant1)); 249 CHECK(IsConstant(*T.ObjectConstant1));
240 CHECK(IsConstant(*T.ObjectConstant2)); 250 CHECK(IsConstant(*T.ObjectConstant2));
241 CHECK(IsConstant(*T.ArrayConstant1)); 251 CHECK(IsConstant(*T.ArrayConstant1));
242 CHECK(IsConstant(*T.ArrayConstant2)); 252 CHECK(IsConstant(*T.ArrayConstant2));
243 253
244 CHECK(*T.smi == AsConstant(*T.Integer31Constant)); 254 CHECK(*T.smi == AsConstant(*T.SmiConstant));
245 CHECK(*T.object1 == AsConstant(*T.ObjectConstant1)); 255 CHECK(*T.object1 == AsConstant(*T.ObjectConstant1));
246 CHECK(*T.object2 == AsConstant(*T.ObjectConstant2)); 256 CHECK(*T.object2 == AsConstant(*T.ObjectConstant2));
247 CHECK(*T.object1 != AsConstant(*T.ObjectConstant2)); 257 CHECK(*T.object1 != AsConstant(*T.ObjectConstant2));
248 CHECK(*T.array == AsConstant(*T.ArrayConstant1)); 258 CHECK(*T.array == AsConstant(*T.ArrayConstant1));
249 CHECK(*T.array == AsConstant(*T.ArrayConstant2)); 259 CHECK(*T.array == AsConstant(*T.ArrayConstant2));
250 } 260 }
251 261
252 262
253 TEST(Is) { 263 TEST(Is) {
254 CcTest::InitializeVM(); 264 CcTest::InitializeVM();
(...skipping 16 matching lines...) Expand all
271 281
272 CheckSub(T.Oddball, T.Any); 282 CheckSub(T.Oddball, T.Any);
273 CheckSub(T.Boolean, T.Oddball); 283 CheckSub(T.Boolean, T.Oddball);
274 CheckSub(T.Null, T.Oddball); 284 CheckSub(T.Null, T.Oddball);
275 CheckSub(T.Undefined, T.Oddball); 285 CheckSub(T.Undefined, T.Oddball);
276 CheckUnordered(T.Boolean, T.Null); 286 CheckUnordered(T.Boolean, T.Null);
277 CheckUnordered(T.Undefined, T.Null); 287 CheckUnordered(T.Undefined, T.Null);
278 CheckUnordered(T.Boolean, T.Undefined); 288 CheckUnordered(T.Boolean, T.Undefined);
279 289
280 CheckSub(T.Number, T.Any); 290 CheckSub(T.Number, T.Any);
281 CheckSub(T.Integer31, T.Number); 291 CheckSub(T.Smi, T.Number);
282 CheckSub(T.Integer32, T.Number); 292 CheckSub(T.Signed32, T.Number);
283 CheckSub(T.Double, T.Number); 293 CheckSub(T.Double, T.Number);
284 CheckSub(T.Integer31, T.Integer32); 294 CheckSub(T.Smi, T.Signed32);
285 CheckUnordered(T.Integer31, T.Double); 295 CheckUnordered(T.Smi, T.Double);
286 CheckUnordered(T.Integer32, T.Double); 296 CheckUnordered(T.Signed32, T.Double);
287 297
288 CheckSub(T.Name, T.Any); 298 CheckSub(T.Name, T.Any);
289 CheckSub(T.UniqueName, T.Any); 299 CheckSub(T.UniqueName, T.Any);
290 CheckSub(T.UniqueName, T.Name); 300 CheckSub(T.UniqueName, T.Name);
291 CheckSub(T.String, T.Name); 301 CheckSub(T.String, T.Name);
292 CheckSub(T.InternalizedString, T.String); 302 CheckSub(T.InternalizedString, T.String);
293 CheckSub(T.InternalizedString, T.UniqueName); 303 CheckSub(T.InternalizedString, T.UniqueName);
294 CheckSub(T.InternalizedString, T.Name); 304 CheckSub(T.InternalizedString, T.Name);
295 CheckSub(T.Symbol, T.UniqueName); 305 CheckSub(T.Symbol, T.UniqueName);
296 CheckSub(T.Symbol, T.Name); 306 CheckSub(T.Symbol, T.Name);
297 CheckUnordered(T.String, T.UniqueName); 307 CheckUnordered(T.String, T.UniqueName);
298 CheckUnordered(T.String, T.Symbol); 308 CheckUnordered(T.String, T.Symbol);
299 CheckUnordered(T.InternalizedString, T.Symbol); 309 CheckUnordered(T.InternalizedString, T.Symbol);
300 310
301 CheckSub(T.Receiver, T.Any); 311 CheckSub(T.Receiver, T.Any);
302 CheckSub(T.Object, T.Any); 312 CheckSub(T.Object, T.Any);
303 CheckSub(T.Object, T.Receiver); 313 CheckSub(T.Object, T.Receiver);
304 CheckSub(T.Array, T.Object); 314 CheckSub(T.Array, T.Object);
305 CheckSub(T.Function, T.Object); 315 CheckSub(T.Function, T.Object);
306 CheckSub(T.Proxy, T.Receiver); 316 CheckSub(T.Proxy, T.Receiver);
307 CheckUnordered(T.Object, T.Proxy); 317 CheckUnordered(T.Object, T.Proxy);
308 CheckUnordered(T.Array, T.Function); 318 CheckUnordered(T.Array, T.Function);
309 319
310 // Structured subtyping 320 // Structured subtyping
311 CheckSub(T.ObjectClass, T.Object); 321 CheckSub(T.ObjectClass, T.Object);
312 CheckSub(T.ArrayClass, T.Object); 322 CheckSub(T.ArrayClass, T.Object);
313 CheckUnordered(T.ObjectClass, T.ArrayClass); 323 CheckUnordered(T.ObjectClass, T.ArrayClass);
314 324
315 CheckSub(T.Integer31Constant, T.Integer31); 325 CheckSub(T.SmiConstant, T.Smi);
316 CheckSub(T.Integer31Constant, T.Integer32); 326 CheckSub(T.SmiConstant, T.Signed32);
317 CheckSub(T.Integer31Constant, T.Number); 327 CheckSub(T.SmiConstant, T.Number);
318 CheckSub(T.ObjectConstant1, T.Object); 328 CheckSub(T.ObjectConstant1, T.Object);
319 CheckSub(T.ObjectConstant2, T.Object); 329 CheckSub(T.ObjectConstant2, T.Object);
320 CheckSub(T.ArrayConstant1, T.Object); 330 CheckSub(T.ArrayConstant1, T.Object);
321 CheckSub(T.ArrayConstant1, T.Array); 331 CheckSub(T.ArrayConstant1, T.Array);
322 CheckUnordered(T.ObjectConstant1, T.ObjectConstant2); 332 CheckUnordered(T.ObjectConstant1, T.ObjectConstant2);
323 CheckUnordered(T.ObjectConstant1, T.ArrayConstant1); 333 CheckUnordered(T.ObjectConstant1, T.ArrayConstant1);
324 334
325 CheckUnordered(T.ObjectConstant1, T.ObjectClass); 335 CheckUnordered(T.ObjectConstant1, T.ObjectClass);
326 CheckUnordered(T.ObjectConstant2, T.ObjectClass); 336 CheckUnordered(T.ObjectConstant2, T.ObjectClass);
327 CheckUnordered(T.ObjectConstant1, T.ArrayClass); 337 CheckUnordered(T.ObjectConstant1, T.ArrayClass);
(...skipping 13 matching lines...) Expand all
341 351
342 CheckOverlap(T.Oddball, T.Any); 352 CheckOverlap(T.Oddball, T.Any);
343 CheckOverlap(T.Boolean, T.Oddball); 353 CheckOverlap(T.Boolean, T.Oddball);
344 CheckOverlap(T.Null, T.Oddball); 354 CheckOverlap(T.Null, T.Oddball);
345 CheckOverlap(T.Undefined, T.Oddball); 355 CheckOverlap(T.Undefined, T.Oddball);
346 CheckDisjoint(T.Boolean, T.Null); 356 CheckDisjoint(T.Boolean, T.Null);
347 CheckDisjoint(T.Undefined, T.Null); 357 CheckDisjoint(T.Undefined, T.Null);
348 CheckDisjoint(T.Boolean, T.Undefined); 358 CheckDisjoint(T.Boolean, T.Undefined);
349 359
350 CheckOverlap(T.Number, T.Any); 360 CheckOverlap(T.Number, T.Any);
351 CheckOverlap(T.Integer31, T.Number); 361 CheckOverlap(T.Smi, T.Number);
352 CheckOverlap(T.Double, T.Number); 362 CheckOverlap(T.Double, T.Number);
353 CheckDisjoint(T.Integer32, T.Double); 363 CheckDisjoint(T.Signed32, T.Double);
354 364
355 CheckOverlap(T.Name, T.Any); 365 CheckOverlap(T.Name, T.Any);
356 CheckOverlap(T.UniqueName, T.Any); 366 CheckOverlap(T.UniqueName, T.Any);
357 CheckOverlap(T.UniqueName, T.Name); 367 CheckOverlap(T.UniqueName, T.Name);
358 CheckOverlap(T.String, T.Name); 368 CheckOverlap(T.String, T.Name);
359 CheckOverlap(T.InternalizedString, T.String); 369 CheckOverlap(T.InternalizedString, T.String);
360 CheckOverlap(T.InternalizedString, T.UniqueName); 370 CheckOverlap(T.InternalizedString, T.UniqueName);
361 CheckOverlap(T.InternalizedString, T.Name); 371 CheckOverlap(T.InternalizedString, T.Name);
362 CheckOverlap(T.Symbol, T.UniqueName); 372 CheckOverlap(T.Symbol, T.UniqueName);
363 CheckOverlap(T.Symbol, T.Name); 373 CheckOverlap(T.Symbol, T.Name);
364 CheckOverlap(T.String, T.UniqueName); 374 CheckOverlap(T.String, T.UniqueName);
365 CheckDisjoint(T.String, T.Symbol); 375 CheckDisjoint(T.String, T.Symbol);
366 CheckDisjoint(T.InternalizedString, T.Symbol); 376 CheckDisjoint(T.InternalizedString, T.Symbol);
367 377
368 CheckOverlap(T.Receiver, T.Any); 378 CheckOverlap(T.Receiver, T.Any);
369 CheckOverlap(T.Object, T.Any); 379 CheckOverlap(T.Object, T.Any);
370 CheckOverlap(T.Object, T.Receiver); 380 CheckOverlap(T.Object, T.Receiver);
371 CheckOverlap(T.Array, T.Object); 381 CheckOverlap(T.Array, T.Object);
372 CheckOverlap(T.Function, T.Object); 382 CheckOverlap(T.Function, T.Object);
373 CheckOverlap(T.Proxy, T.Receiver); 383 CheckOverlap(T.Proxy, T.Receiver);
374 CheckDisjoint(T.Object, T.Proxy); 384 CheckDisjoint(T.Object, T.Proxy);
375 CheckDisjoint(T.Array, T.Function); 385 CheckDisjoint(T.Array, T.Function);
376 386
377 CheckOverlap(T.ObjectClass, T.Object); 387 CheckOverlap(T.ObjectClass, T.Object);
378 CheckOverlap(T.ArrayClass, T.Object); 388 CheckOverlap(T.ArrayClass, T.Object);
379 CheckOverlap(T.ObjectClass, T.ObjectClass); 389 CheckOverlap(T.ObjectClass, T.ObjectClass);
380 CheckOverlap(T.ArrayClass, T.ArrayClass); 390 CheckOverlap(T.ArrayClass, T.ArrayClass);
381 CheckDisjoint(T.ObjectClass, T.ArrayClass); 391 CheckDisjoint(T.ObjectClass, T.ArrayClass);
382 392
383 CheckOverlap(T.Integer31Constant, T.Integer31); 393 CheckOverlap(T.SmiConstant, T.Smi);
384 CheckOverlap(T.Integer31Constant, T.Integer32); 394 CheckOverlap(T.SmiConstant, T.Signed32);
385 CheckOverlap(T.Integer31Constant, T.Number); 395 CheckOverlap(T.SmiConstant, T.Number);
386 CheckDisjoint(T.Integer31Constant, T.Double); 396 CheckDisjoint(T.SmiConstant, T.Double);
387 CheckOverlap(T.ObjectConstant1, T.Object); 397 CheckOverlap(T.ObjectConstant1, T.Object);
388 CheckOverlap(T.ObjectConstant2, T.Object); 398 CheckOverlap(T.ObjectConstant2, T.Object);
389 CheckOverlap(T.ArrayConstant1, T.Object); 399 CheckOverlap(T.ArrayConstant1, T.Object);
390 CheckOverlap(T.ArrayConstant1, T.Array); 400 CheckOverlap(T.ArrayConstant1, T.Array);
391 CheckOverlap(T.ArrayConstant1, T.ArrayConstant2); 401 CheckOverlap(T.ArrayConstant1, T.ArrayConstant2);
392 CheckOverlap(T.ObjectConstant1, T.ObjectConstant1); 402 CheckOverlap(T.ObjectConstant1, T.ObjectConstant1);
393 CheckDisjoint(T.ObjectConstant1, T.ObjectConstant2); 403 CheckDisjoint(T.ObjectConstant1, T.ObjectConstant2);
394 CheckDisjoint(T.ObjectConstant1, T.ArrayConstant1); 404 CheckDisjoint(T.ObjectConstant1, T.ArrayConstant1);
395 405
396 CheckDisjoint(T.ObjectConstant1, T.ObjectClass); 406 CheckDisjoint(T.ObjectConstant1, T.ObjectClass);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 CheckOverlap(T.Union(T.ObjectConstant1, T.ArrayConstant1), T.ArrayConstant2); 457 CheckOverlap(T.Union(T.ObjectConstant1, T.ArrayConstant1), T.ArrayConstant2);
448 CheckDisjoint(T.Union(T.ObjectConstant1, T.ArrayConstant1), T.Number); 458 CheckDisjoint(T.Union(T.ObjectConstant1, T.ArrayConstant1), T.Number);
449 CheckDisjoint(T.Union(T.ObjectConstant1, T.ArrayConstant1), T.ObjectClass); 459 CheckDisjoint(T.Union(T.ObjectConstant1, T.ArrayConstant1), T.ObjectClass);
450 460
451 // Bitset-class 461 // Bitset-class
452 CHECK(IsBitset(Type::Union(T.ObjectClass, T.Object))); 462 CHECK(IsBitset(Type::Union(T.ObjectClass, T.Object)));
453 CHECK(IsUnion(Type::Union(T.ObjectClass, T.Number))); 463 CHECK(IsUnion(Type::Union(T.ObjectClass, T.Number)));
454 464
455 CheckEqual(T.Union(T.ObjectClass, T.Object), T.Object); 465 CheckEqual(T.Union(T.ObjectClass, T.Object), T.Object);
456 CheckSub(T.Union(T.ObjectClass, T.Number), T.Any); 466 CheckSub(T.Union(T.ObjectClass, T.Number), T.Any);
457 CheckSub(T.Union(T.ObjectClass, T.Integer31), T.Union(T.Object, T.Number)); 467 CheckSub(T.Union(T.ObjectClass, T.Smi), T.Union(T.Object, T.Number));
458 CheckSub(T.Union(T.ObjectClass, T.Array), T.Object); 468 CheckSub(T.Union(T.ObjectClass, T.Array), T.Object);
459 CheckUnordered(T.Union(T.ObjectClass, T.String), T.Array); 469 CheckUnordered(T.Union(T.ObjectClass, T.String), T.Array);
460 CheckOverlap(T.Union(T.ObjectClass, T.String), T.Object); 470 CheckOverlap(T.Union(T.ObjectClass, T.String), T.Object);
461 CheckDisjoint(T.Union(T.ObjectClass, T.String), T.Number); 471 CheckDisjoint(T.Union(T.ObjectClass, T.String), T.Number);
462 472
463 // Bitset-constant 473 // Bitset-constant
464 CHECK(IsBitset(Type::Union(T.Integer31Constant, T.Number))); 474 CHECK(IsBitset(Type::Union(T.SmiConstant, T.Number)));
465 CHECK(IsBitset(Type::Union(T.ObjectConstant1, T.Object))); 475 CHECK(IsBitset(Type::Union(T.ObjectConstant1, T.Object)));
466 CHECK(IsUnion(Type::Union(T.ObjectConstant2, T.Number))); 476 CHECK(IsUnion(Type::Union(T.ObjectConstant2, T.Number)));
467 477
468 CheckEqual(T.Union(T.Integer31Constant, T.Number), T.Number); 478 CheckEqual(T.Union(T.SmiConstant, T.Number), T.Number);
469 CheckEqual(T.Union(T.ObjectConstant1, T.Object), T.Object); 479 CheckEqual(T.Union(T.ObjectConstant1, T.Object), T.Object);
470 CheckSub(T.Union(T.ObjectConstant1, T.Number), T.Any); 480 CheckSub(T.Union(T.ObjectConstant1, T.Number), T.Any);
471 CheckSub( 481 CheckSub(T.Union(T.ObjectConstant1, T.Signed32), T.Union(T.Object, T.Number));
472 T.Union(T.ObjectConstant1, T.Integer32), T.Union(T.Object, T.Number));
473 CheckSub(T.Union(T.ObjectConstant1, T.Array), T.Object); 482 CheckSub(T.Union(T.ObjectConstant1, T.Array), T.Object);
474 CheckUnordered(T.Union(T.ObjectConstant1, T.String), T.Array); 483 CheckUnordered(T.Union(T.ObjectConstant1, T.String), T.Array);
475 CheckOverlap(T.Union(T.ObjectConstant1, T.String), T.Object); 484 CheckOverlap(T.Union(T.ObjectConstant1, T.String), T.Object);
476 CheckDisjoint(T.Union(T.ObjectConstant1, T.String), T.Number); 485 CheckDisjoint(T.Union(T.ObjectConstant1, T.String), T.Number);
486 CheckEqual(T.Union(T.Signed32, T.Signed32Constant), T.Signed32);
477 487
478 // Class-constant 488 // Class-constant
479 CHECK(IsUnion(Type::Union(T.ObjectConstant1, T.ObjectClass))); 489 CHECK(IsUnion(Type::Union(T.ObjectConstant1, T.ObjectClass)));
480 CHECK(IsUnion(Type::Union(T.ArrayClass, T.ObjectConstant2))); 490 CHECK(IsUnion(Type::Union(T.ArrayClass, T.ObjectConstant2)));
481 491
482 CheckSub(T.Union(T.ObjectConstant1, T.ArrayClass), T.Object); 492 CheckSub(T.Union(T.ObjectConstant1, T.ArrayClass), T.Object);
483 CheckSub(T.ObjectConstant1, T.Union(T.ObjectConstant1, T.ArrayClass)); 493 CheckSub(T.ObjectConstant1, T.Union(T.ObjectConstant1, T.ArrayClass));
484 CheckSub(T.ArrayClass, T.Union(T.ObjectConstant1, T.ArrayClass)); 494 CheckSub(T.ArrayClass, T.Union(T.ObjectConstant1, T.ArrayClass));
485 CheckUnordered(T.ObjectClass, T.Union(T.ObjectConstant1, T.ArrayClass)); 495 CheckUnordered(T.ObjectClass, T.Union(T.ObjectConstant1, T.ArrayClass));
486 CheckSub( 496 CheckSub(
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 550
541 CheckEqual( 551 CheckEqual(
542 T.Union(T.ObjectConstant1, T.Union(T.ObjectConstant1, T.ObjectConstant2)), 552 T.Union(T.ObjectConstant1, T.Union(T.ObjectConstant1, T.ObjectConstant2)),
543 T.Union(T.ObjectConstant2, T.ObjectConstant1)); 553 T.Union(T.ObjectConstant2, T.ObjectConstant1));
544 CheckEqual( 554 CheckEqual(
545 T.Union(T.Union(T.ArrayConstant1, T.ObjectConstant2), T.ObjectConstant1), 555 T.Union(T.Union(T.ArrayConstant1, T.ObjectConstant2), T.ObjectConstant1),
546 T.Union(T.ObjectConstant2, T.Union(T.ArrayConstant1, T.ObjectConstant1))); 556 T.Union(T.ObjectConstant2, T.Union(T.ArrayConstant1, T.ObjectConstant1)));
547 557
548 // Union-union 558 // Union-union
549 CHECK(IsBitset(Type::Union( 559 CHECK(IsBitset(Type::Union(
550 T.Union(T.Number, T.ArrayClass), T.Union(T.Integer32, T.Array)))); 560 T.Union(T.Number, T.ArrayClass), T.Union(T.Signed32, T.Array))));
551 CHECK(IsUnion(Type::Union( 561 CHECK(IsUnion(Type::Union(
552 T.Union(T.Number, T.ArrayClass), T.Union(T.ObjectClass, T.ArrayClass)))); 562 T.Union(T.Number, T.ArrayClass), T.Union(T.ObjectClass, T.ArrayClass))));
553 563
554 CheckEqual( 564 CheckEqual(
555 T.Union( 565 T.Union(
556 T.Union(T.ObjectConstant2, T.ObjectConstant1), 566 T.Union(T.ObjectConstant2, T.ObjectConstant1),
557 T.Union(T.ObjectConstant1, T.ObjectConstant2)), 567 T.Union(T.ObjectConstant1, T.ObjectConstant2)),
558 T.Union(T.ObjectConstant2, T.ObjectConstant1)); 568 T.Union(T.ObjectConstant2, T.ObjectConstant1));
559 CheckEqual( 569 CheckEqual(
560 T.Union( 570 T.Union(
561 T.Union(T.ObjectConstant2, T.ArrayConstant1), 571 T.Union(T.ObjectConstant2, T.ArrayConstant1),
562 T.Union(T.ObjectConstant1, T.ArrayConstant2)), 572 T.Union(T.ObjectConstant1, T.ArrayConstant2)),
563 T.Union(T.Union(T.ObjectConstant1, T.ObjectConstant2), T.ArrayConstant1)); 573 T.Union(T.Union(T.ObjectConstant1, T.ObjectConstant2), T.ArrayConstant1));
564 CheckEqual( 574 CheckEqual(
565 T.Union(T.Union(T.Number, T.ArrayClass), T.Union(T.Integer31, T.Array)), 575 T.Union(T.Union(T.Number, T.ArrayClass), T.Union(T.Smi, T.Array)),
566 T.Union(T.Number, T.Array)); 576 T.Union(T.Number, T.Array));
567 } 577 }
568 578
569 579
570 TEST(Intersect) { 580 TEST(Intersect) {
571 CcTest::InitializeVM(); 581 CcTest::InitializeVM();
572 Isolate* isolate = CcTest::i_isolate(); 582 Isolate* isolate = CcTest::i_isolate();
573 HandleScope scope(isolate); 583 HandleScope scope(isolate);
574 HandlifiedTypes T(isolate); 584 HandlifiedTypes T(isolate);
575 585
(...skipping 27 matching lines...) Expand all
603 613
604 // Bitset-class 614 // Bitset-class
605 CHECK(IsClass(Type::Intersect(T.ObjectClass, T.Object))); 615 CHECK(IsClass(Type::Intersect(T.ObjectClass, T.Object)));
606 CHECK(IsBitset(Type::Intersect(T.ObjectClass, T.Number))); 616 CHECK(IsBitset(Type::Intersect(T.ObjectClass, T.Number)));
607 617
608 CheckEqual(T.Intersect(T.ObjectClass, T.Object), T.ObjectClass); 618 CheckEqual(T.Intersect(T.ObjectClass, T.Object), T.ObjectClass);
609 CheckEqual(T.Intersect(T.ObjectClass, T.Array), T.None); 619 CheckEqual(T.Intersect(T.ObjectClass, T.Array), T.None);
610 CheckEqual(T.Intersect(T.ObjectClass, T.Number), T.None); 620 CheckEqual(T.Intersect(T.ObjectClass, T.Number), T.None);
611 621
612 // Bitset-constant 622 // Bitset-constant
613 CHECK(IsBitset(Type::Intersect(T.Integer31, T.Number))); 623 CHECK(IsBitset(Type::Intersect(T.Smi, T.Number)));
614 CHECK(IsConstant(Type::Intersect(T.Integer31Constant, T.Number))); 624 CHECK(IsConstant(Type::Intersect(T.SmiConstant, T.Number)));
615 CHECK(IsConstant(Type::Intersect(T.ObjectConstant1, T.Object))); 625 CHECK(IsConstant(Type::Intersect(T.ObjectConstant1, T.Object)));
616 626
617 CheckEqual(T.Intersect(T.Integer31, T.Number), T.Integer31); 627 CheckEqual(T.Intersect(T.Smi, T.Number), T.Smi);
618 CheckEqual(T.Intersect(T.Integer31Constant, T.Number), T.Integer31Constant); 628 CheckEqual(T.Intersect(T.SmiConstant, T.Number), T.SmiConstant);
619 CheckEqual(T.Intersect(T.ObjectConstant1, T.Object), T.ObjectConstant1); 629 CheckEqual(T.Intersect(T.ObjectConstant1, T.Object), T.ObjectConstant1);
620 630
621 // Class-constant 631 // Class-constant
622 CHECK(IsBitset(Type::Intersect(T.ObjectConstant1, T.ObjectClass))); 632 CHECK(IsBitset(Type::Intersect(T.ObjectConstant1, T.ObjectClass)));
623 CHECK(IsBitset(Type::Intersect(T.ArrayClass, T.ObjectConstant2))); 633 CHECK(IsBitset(Type::Intersect(T.ArrayClass, T.ObjectConstant2)));
624 634
625 CheckEqual(T.Intersect(T.ObjectConstant1, T.ObjectClass), T.None); 635 CheckEqual(T.Intersect(T.ObjectConstant1, T.ObjectClass), T.None);
626 CheckEqual(T.Intersect(T.ArrayClass, T.ObjectConstant2), T.None); 636 CheckEqual(T.Intersect(T.ArrayClass, T.ObjectConstant2), T.None);
627 637
628 // Bitset-union 638 // Bitset-union
629 CHECK(IsUnion( 639 CHECK(IsUnion(
630 Type::Intersect(T.Object, T.Union(T.ObjectConstant1, T.ObjectClass)))); 640 Type::Intersect(T.Object, T.Union(T.ObjectConstant1, T.ObjectClass))));
631 CHECK(IsBitset( 641 CHECK(IsBitset(
632 Type::Intersect(T.Union(T.ArrayClass, T.ObjectConstant2), T.Number))); 642 Type::Intersect(T.Union(T.ArrayClass, T.ObjectConstant2), T.Number)));
633 643
634 CheckEqual( 644 CheckEqual(
635 T.Intersect(T.Object, T.Union(T.ObjectConstant1, T.ObjectClass)), 645 T.Intersect(T.Object, T.Union(T.ObjectConstant1, T.ObjectClass)),
636 T.Union(T.ObjectConstant1, T.ObjectClass)); 646 T.Union(T.ObjectConstant1, T.ObjectClass));
637 CheckEqual( 647 CheckEqual(
638 T.Intersect(T.Union(T.ArrayClass, T.ObjectConstant1), T.Number), 648 T.Intersect(T.Union(T.ArrayClass, T.ObjectConstant1), T.Number),
639 T.None); 649 T.None);
640 650
641 // Class-union 651 // Class-union
642 CHECK(IsClass( 652 CHECK(IsClass(
643 Type::Intersect(T.Union(T.ArrayClass, T.ObjectConstant2), T.ArrayClass))); 653 Type::Intersect(T.Union(T.ArrayClass, T.ObjectConstant2), T.ArrayClass)));
644 CHECK(IsClass( 654 CHECK(IsClass(
645 Type::Intersect(T.Union(T.Object, T.Integer31Constant), T.ArrayClass))); 655 Type::Intersect(T.Union(T.Object, T.SmiConstant), T.ArrayClass)));
646 CHECK(IsBitset( 656 CHECK(IsBitset(
647 Type::Intersect(T.Union(T.ObjectClass, T.ArrayConstant1), T.ArrayClass))); 657 Type::Intersect(T.Union(T.ObjectClass, T.ArrayConstant1), T.ArrayClass)));
648 658
649 CheckEqual( 659 CheckEqual(
650 T.Intersect(T.ArrayClass, T.Union(T.ObjectConstant2, T.ArrayClass)), 660 T.Intersect(T.ArrayClass, T.Union(T.ObjectConstant2, T.ArrayClass)),
651 T.ArrayClass); 661 T.ArrayClass);
652 CheckEqual( 662 CheckEqual(
653 T.Intersect(T.ArrayClass, T.Union(T.Object, T.Integer31Constant)), 663 T.Intersect(T.ArrayClass, T.Union(T.Object, T.SmiConstant)),
654 T.ArrayClass); 664 T.ArrayClass);
655 CheckEqual( 665 CheckEqual(
656 T.Intersect(T.Union(T.ObjectClass, T.ArrayConstant1), T.ArrayClass), 666 T.Intersect(T.Union(T.ObjectClass, T.ArrayConstant1), T.ArrayClass),
657 T.None); 667 T.None);
658 668
659 // Constant-union 669 // Constant-union
660 CHECK(IsConstant(Type::Intersect( 670 CHECK(IsConstant(Type::Intersect(
661 T.ObjectConstant1, T.Union(T.ObjectConstant1, T.ObjectConstant2)))); 671 T.ObjectConstant1, T.Union(T.ObjectConstant1, T.ObjectConstant2))));
662 CHECK(IsConstant(Type::Intersect( 672 CHECK(IsConstant(Type::Intersect(
663 T.Union(T.Number, T.ObjectClass), T.Integer31Constant))); 673 T.Union(T.Number, T.ObjectClass), T.SmiConstant)));
664 CHECK(IsBitset(Type::Intersect( 674 CHECK(IsBitset(Type::Intersect(
665 T.Union(T.ArrayConstant1, T.ObjectClass), T.ObjectConstant1))); 675 T.Union(T.ArrayConstant1, T.ObjectClass), T.ObjectConstant1)));
666 676
667 CheckEqual( 677 CheckEqual(
668 T.Intersect( 678 T.Intersect(
669 T.ObjectConstant1, T.Union(T.ObjectConstant1, T.ObjectConstant2)), 679 T.ObjectConstant1, T.Union(T.ObjectConstant1, T.ObjectConstant2)),
670 T.ObjectConstant1); 680 T.ObjectConstant1);
671 CheckEqual( 681 CheckEqual(
672 T.Intersect(T.Integer31Constant, T.Union(T.Number, T.ObjectConstant2)), 682 T.Intersect(T.SmiConstant, T.Union(T.Number, T.ObjectConstant2)),
673 T.Integer31Constant); 683 T.SmiConstant);
674 CheckEqual( 684 CheckEqual(
675 T.Intersect(T.Union(T.ArrayConstant1, T.ObjectClass), T.ObjectConstant1), 685 T.Intersect(T.Union(T.ArrayConstant1, T.ObjectClass), T.ObjectConstant1),
676 T.None); 686 T.None);
677 687
678 // Union-union 688 // Union-union
679 CHECK(IsUnion(Type::Intersect( 689 CHECK(IsUnion(Type::Intersect(
680 T.Union(T.Number, T.ArrayClass), T.Union(T.Integer32, T.Array)))); 690 T.Union(T.Number, T.ArrayClass), T.Union(T.Signed32, T.Array))));
681 CHECK(IsBitset(Type::Intersect( 691 CHECK(IsBitset(Type::Intersect(
682 T.Union(T.Number, T.ObjectClass), T.Union(T.Integer32, T.Array)))); 692 T.Union(T.Number, T.ObjectClass), T.Union(T.Signed32, T.Array))));
683 693
684 CheckEqual( 694 CheckEqual(
685 T.Intersect( 695 T.Intersect(
686 T.Union(T.Number, T.ArrayClass), 696 T.Union(T.Number, T.ArrayClass),
687 T.Union(T.Integer31, T.Array)), 697 T.Union(T.Smi, T.Array)),
688 T.Union(T.Integer31, T.ArrayClass)); 698 T.Union(T.Smi, T.ArrayClass));
689 CheckEqual( 699 CheckEqual(
690 T.Intersect( 700 T.Intersect(
691 T.Union(T.Number, T.ObjectClass), 701 T.Union(T.Number, T.ObjectClass),
692 T.Union(T.Integer32, T.Array)), 702 T.Union(T.Signed32, T.Array)),
693 T.Integer32); 703 T.Signed32);
694 CheckEqual( 704 CheckEqual(
695 T.Intersect( 705 T.Intersect(
696 T.Union(T.ObjectConstant2, T.ObjectConstant1), 706 T.Union(T.ObjectConstant2, T.ObjectConstant1),
697 T.Union(T.ObjectConstant1, T.ObjectConstant2)), 707 T.Union(T.ObjectConstant1, T.ObjectConstant2)),
698 T.Union(T.ObjectConstant2, T.ObjectConstant1)); 708 T.Union(T.ObjectConstant2, T.ObjectConstant1));
699 CheckEqual( 709 CheckEqual(
700 T.Intersect( 710 T.Intersect(
701 T.Union(T.Union(T.ObjectConstant2, T.ObjectConstant1), T.ArrayClass), 711 T.Union(T.Union(T.ObjectConstant2, T.ObjectConstant1), T.ArrayClass),
702 T.Union( 712 T.Union(
703 T.ObjectConstant1, T.Union(T.ArrayConstant1, T.ObjectConstant2))), 713 T.ObjectConstant1, T.Union(T.ArrayConstant1, T.ObjectConstant2))),
704 T.Union(T.ObjectConstant2, T.ObjectConstant1)); 714 T.Union(T.ObjectConstant2, T.ObjectConstant1));
705 CheckEqual( 715 CheckEqual(
706 T.Intersect( 716 T.Intersect(
707 T.Union(T.ObjectConstant2, T.ArrayConstant1), 717 T.Union(T.ObjectConstant2, T.ArrayConstant1),
708 T.Union(T.ObjectConstant1, T.ArrayConstant2)), 718 T.Union(T.ObjectConstant1, T.ArrayConstant2)),
709 T.ArrayConstant1); 719 T.ArrayConstant1);
710 } 720 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698