OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "types.h" | 5 #include "types.h" |
6 | 6 |
7 #include "string-stream.h" | 7 #include "string-stream.h" |
8 #include "types-inl.h" | 8 #include "types-inl.h" |
9 | 9 |
10 namespace v8 { | 10 namespace v8 { |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 } | 299 } |
300 return false; | 300 return false; |
301 } | 301 } |
302 | 302 |
303 return false; | 303 return false; |
304 } | 304 } |
305 | 305 |
306 | 306 |
307 template<class Config> | 307 template<class Config> |
308 bool TypeImpl<Config>::NowIs(TypeImpl* that) { | 308 bool TypeImpl<Config>::NowIs(TypeImpl* that) { |
309 // TODO(rossberg): this is incorrect for | |
310 // Union(Constant(V), T)->NowIs(Class(M)) | |
311 // but fuzzing does not cover that! | |
312 DisallowHeapAllocation no_allocation; | 309 DisallowHeapAllocation no_allocation; |
313 if (this->IsConstant()) { | 310 if (this->IsConstant()) { |
314 i::Object* object = *this->AsConstant(); | 311 i::Object* object = *this->AsConstant(); |
315 if (object->IsHeapObject()) { | 312 if (object->IsHeapObject()) { |
316 i::Map* map = i::HeapObject::cast(object)->map(); | 313 i::Map* map = i::HeapObject::cast(object)->map(); |
317 for (Iterator<i::Map> it = that->Classes(); !it.Done(); it.Advance()) { | 314 for (Iterator<i::Map> it = that->Classes(); !it.Done(); it.Advance()) { |
318 if (*it.Current() == map) return true; | 315 if (*it.Current() == map) return true; |
319 } | 316 } |
320 } | 317 } |
321 } | 318 } |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 | 428 |
432 // Slow case: may need to produce a Unioned object. | 429 // Slow case: may need to produce a Unioned object. |
433 int size = 0; | 430 int size = 0; |
434 if (!type1->IsBitset()) { | 431 if (!type1->IsBitset()) { |
435 size += (type1->IsUnion() ? Config::struct_length(type1->AsUnion()) : 1); | 432 size += (type1->IsUnion() ? Config::struct_length(type1->AsUnion()) : 1); |
436 } | 433 } |
437 if (!type2->IsBitset()) { | 434 if (!type2->IsBitset()) { |
438 size += (type2->IsUnion() ? Config::struct_length(type2->AsUnion()) : 1); | 435 size += (type2->IsUnion() ? Config::struct_length(type2->AsUnion()) : 1); |
439 } | 436 } |
440 int bitset = type1->GlbBitset() | type2->GlbBitset(); | 437 int bitset = type1->GlbBitset() | type2->GlbBitset(); |
441 if (bitset != kNone) ++size; | 438 if (IsInhabited(bitset)) ++size; |
442 ASSERT(size >= 1); | 439 ASSERT(size >= 1); |
443 StructHandle unioned = Config::struct_create(kUnionTag, size, region); | 440 StructHandle unioned = Config::struct_create(kUnionTag, size, region); |
444 | 441 |
445 size = 0; | 442 size = 0; |
446 if (bitset != kNone) { | 443 if (IsInhabited(bitset)) { |
447 Config::struct_set(unioned, size++, Config::from_bitset(bitset, region)); | 444 Config::struct_set(unioned, size++, Config::from_bitset(bitset, region)); |
448 } | 445 } |
449 size = ExtendUnion(unioned, type1, size); | 446 size = ExtendUnion(unioned, type1, size); |
450 size = ExtendUnion(unioned, type2, size); | 447 size = ExtendUnion(unioned, type2, size); |
451 | 448 |
452 if (size == 1) { | 449 if (size == 1) { |
453 return Config::struct_get(unioned, 0); | 450 return Config::struct_get(unioned, 0); |
454 } else { | 451 } else { |
455 Config::struct_shrink(unioned, size); | 452 Config::struct_shrink(unioned, size); |
456 return Config::from_struct(unioned); | 453 return Config::from_struct(unioned); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
507 // Slow case: may need to produce a Unioned object. | 504 // Slow case: may need to produce a Unioned object. |
508 int size = INT_MAX; | 505 int size = INT_MAX; |
509 if (!type1->IsBitset()) { | 506 if (!type1->IsBitset()) { |
510 size = (type1->IsUnion() ? Config::struct_length(type1->AsUnion()) : 1); | 507 size = (type1->IsUnion() ? Config::struct_length(type1->AsUnion()) : 1); |
511 } | 508 } |
512 if (!type2->IsBitset()) { | 509 if (!type2->IsBitset()) { |
513 size = Min(size, | 510 size = Min(size, |
514 type2->IsUnion() ? Config::struct_length(type2->AsUnion()) : 1); | 511 type2->IsUnion() ? Config::struct_length(type2->AsUnion()) : 1); |
515 } | 512 } |
516 int bitset = type1->GlbBitset() & type2->GlbBitset(); | 513 int bitset = type1->GlbBitset() & type2->GlbBitset(); |
517 if (bitset != kNone) ++size; | 514 if (IsInhabited(bitset)) ++size; |
518 ASSERT(size >= 1); | 515 ASSERT(size >= 1); |
519 StructHandle unioned = Config::struct_create(kUnionTag, size, region); | 516 StructHandle unioned = Config::struct_create(kUnionTag, size, region); |
520 | 517 |
521 size = 0; | 518 size = 0; |
522 if (bitset != kNone) { | 519 if (IsInhabited(bitset)) { |
523 Config::struct_set(unioned, size++, Config::from_bitset(bitset, region)); | 520 Config::struct_set(unioned, size++, Config::from_bitset(bitset, region)); |
524 } | 521 } |
525 size = ExtendIntersection(unioned, type1, type2, size); | 522 size = ExtendIntersection(unioned, type1, type2, size); |
526 size = ExtendIntersection(unioned, type2, type1, size); | 523 size = ExtendIntersection(unioned, type2, type1, size); |
527 | 524 |
528 if (size == 0) { | 525 if (size == 0) { |
529 return None(region); | 526 return None(region); |
530 } else if (size == 1) { | 527 } else if (size == 1) { |
531 return Config::struct_get(unioned, 0); | 528 return Config::struct_get(unioned, 0); |
532 } else { | 529 } else { |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
678 template class TypeImpl<HeapTypeConfig>::Iterator<i::Object>; | 675 template class TypeImpl<HeapTypeConfig>::Iterator<i::Object>; |
679 | 676 |
680 template TypeImpl<ZoneTypeConfig>::TypeHandle | 677 template TypeImpl<ZoneTypeConfig>::TypeHandle |
681 TypeImpl<ZoneTypeConfig>::Convert<HeapType>( | 678 TypeImpl<ZoneTypeConfig>::Convert<HeapType>( |
682 TypeImpl<HeapTypeConfig>::TypeHandle, TypeImpl<ZoneTypeConfig>::Region*); | 679 TypeImpl<HeapTypeConfig>::TypeHandle, TypeImpl<ZoneTypeConfig>::Region*); |
683 template TypeImpl<HeapTypeConfig>::TypeHandle | 680 template TypeImpl<HeapTypeConfig>::TypeHandle |
684 TypeImpl<HeapTypeConfig>::Convert<Type>( | 681 TypeImpl<HeapTypeConfig>::Convert<Type>( |
685 TypeImpl<ZoneTypeConfig>::TypeHandle, TypeImpl<HeapTypeConfig>::Region*); | 682 TypeImpl<ZoneTypeConfig>::TypeHandle, TypeImpl<HeapTypeConfig>::Region*); |
686 | 683 |
687 } } // namespace v8::internal | 684 } } // namespace v8::internal |
OLD | NEW |