| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 return this->Is(that) || | 330 return this->Is(that) || |
| 331 (this->IsConstant() && that->IsClass() && | 331 (this->IsConstant() && that->IsClass() && |
| 332 this->AsConstant()->IsHeapObject() && | 332 this->AsConstant()->IsHeapObject() && |
| 333 i::HeapObject::cast(*this->AsConstant())->map() == *that->AsClass()); | 333 i::HeapObject::cast(*this->AsConstant())->map() == *that->AsClass()); |
| 334 } | 334 } |
| 335 | 335 |
| 336 | 336 |
| 337 // Check this overlaps that. | 337 // Check this overlaps that. |
| 338 template<class Config> | 338 template<class Config> |
| 339 bool TypeImpl<Config>::Maybe(TypeImpl* that) { | 339 bool TypeImpl<Config>::Maybe(TypeImpl* that) { |
| 340 // Fast path for bitsets. | |
| 341 if (this->IsBitset()) { | |
| 342 return IsInhabited(this->AsBitset() & that->LubBitset()); | |
| 343 } | |
| 344 if (that->IsBitset()) { | |
| 345 return IsInhabited(this->LubBitset() & that->AsBitset()); | |
| 346 } | |
| 347 | |
| 348 // (T1 \/ ... \/ Tn) overlaps T <=> (T1 overlaps T) \/ ... \/ (Tn overlaps T) | 340 // (T1 \/ ... \/ Tn) overlaps T <=> (T1 overlaps T) \/ ... \/ (Tn overlaps T) |
| 349 if (this->IsUnion()) { | 341 if (this->IsUnion()) { |
| 350 UnionedHandle unioned = this->AsUnion(); | 342 UnionedHandle unioned = this->AsUnion(); |
| 351 for (int i = 0; i < Config::union_length(unioned); ++i) { | 343 for (int i = 0; i < Config::union_length(unioned); ++i) { |
| 352 TypeHandle this_i = Config::union_get(unioned, i); | 344 TypeHandle this_i = Config::union_get(unioned, i); |
| 353 if (this_i->Maybe(that)) return true; | 345 if (this_i->Maybe(that)) return true; |
| 354 } | 346 } |
| 355 return false; | 347 return false; |
| 356 } | 348 } |
| 357 | 349 |
| 358 // T overlaps (T1 \/ ... \/ Tn) <=> (T overlaps T1) \/ ... \/ (T overlaps Tn) | 350 // T overlaps (T1 \/ ... \/ Tn) <=> (T overlaps T1) \/ ... \/ (T overlaps Tn) |
| 359 if (that->IsUnion()) { | 351 if (that->IsUnion()) { |
| 360 UnionedHandle unioned = that->AsUnion(); | 352 UnionedHandle unioned = that->AsUnion(); |
| 361 for (int i = 0; i < Config::union_length(unioned); ++i) { | 353 for (int i = 0; i < Config::union_length(unioned); ++i) { |
| 362 TypeHandle that_i = Config::union_get(unioned, i); | 354 TypeHandle that_i = Config::union_get(unioned, i); |
| 363 if (this->Maybe(that_i)) return true; | 355 if (this->Maybe(that_i)) return true; |
| 364 } | 356 } |
| 365 return false; | 357 return false; |
| 366 } | 358 } |
| 367 | 359 |
| 368 ASSERT(!this->IsUnion() && !that->IsUnion()); | 360 ASSERT(!this->IsUnion() && !that->IsUnion()); |
| 361 if (this->IsBitset()) { |
| 362 return IsInhabited(this->AsBitset() & that->LubBitset()); |
| 363 } |
| 364 if (that->IsBitset()) { |
| 365 return IsInhabited(this->LubBitset() & that->AsBitset()); |
| 366 } |
| 369 if (this->IsClass()) { | 367 if (this->IsClass()) { |
| 370 return that->IsClass() && *this->AsClass() == *that->AsClass(); | 368 return that->IsClass() && *this->AsClass() == *that->AsClass(); |
| 371 } | 369 } |
| 372 if (this->IsConstant()) { | 370 if (this->IsConstant()) { |
| 373 return that->IsConstant() && *this->AsConstant() == *that->AsConstant(); | 371 return that->IsConstant() && *this->AsConstant() == *that->AsConstant(); |
| 374 } | 372 } |
| 375 | 373 |
| 376 return false; | 374 return false; |
| 377 } | 375 } |
| 378 | 376 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 435 | 433 |
| 436 // Slow case: may need to produce a Unioned object. | 434 // Slow case: may need to produce a Unioned object. |
| 437 int size = 0; | 435 int size = 0; |
| 438 if (!type1->IsBitset()) { | 436 if (!type1->IsBitset()) { |
| 439 size += (type1->IsUnion() ? Config::union_length(type1->AsUnion()) : 1); | 437 size += (type1->IsUnion() ? Config::union_length(type1->AsUnion()) : 1); |
| 440 } | 438 } |
| 441 if (!type2->IsBitset()) { | 439 if (!type2->IsBitset()) { |
| 442 size += (type2->IsUnion() ? Config::union_length(type2->AsUnion()) : 1); | 440 size += (type2->IsUnion() ? Config::union_length(type2->AsUnion()) : 1); |
| 443 } | 441 } |
| 444 int bitset = type1->GlbBitset() | type2->GlbBitset(); | 442 int bitset = type1->GlbBitset() | type2->GlbBitset(); |
| 445 if (IsInhabited(bitset)) ++size; | 443 if (bitset != kNone) ++size; |
| 446 ASSERT(size >= 1); | 444 ASSERT(size >= 1); |
| 447 UnionedHandle unioned = Config::union_create(size, region); | 445 UnionedHandle unioned = Config::union_create(size, region); |
| 448 | 446 |
| 449 size = 0; | 447 size = 0; |
| 450 if (IsInhabited(bitset)) { | 448 if (bitset != kNone) { |
| 451 Config::union_set(unioned, size++, Config::from_bitset(bitset, region)); | 449 Config::union_set(unioned, size++, Config::from_bitset(bitset, region)); |
| 452 } | 450 } |
| 453 size = ExtendUnion(unioned, type1, size); | 451 size = ExtendUnion(unioned, type1, size); |
| 454 size = ExtendUnion(unioned, type2, size); | 452 size = ExtendUnion(unioned, type2, size); |
| 455 | 453 |
| 456 if (size == 1) { | 454 if (size == 1) { |
| 457 return Config::union_get(unioned, 0); | 455 return Config::union_get(unioned, 0); |
| 458 } else { | 456 } else { |
| 459 Config::union_shrink(unioned, size); | 457 Config::union_shrink(unioned, size); |
| 460 return Config::from_union(unioned); | 458 return Config::from_union(unioned); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 502 if (type1->IsNone() || type2->IsAny()) return type1; | 500 if (type1->IsNone() || type2->IsAny()) return type1; |
| 503 if (type2->IsNone() || type1->IsAny()) return type2; | 501 if (type2->IsNone() || type1->IsAny()) return type2; |
| 504 | 502 |
| 505 // Semi-fast case: Unioned objects are neither involved nor produced. | 503 // Semi-fast case: Unioned objects are neither involved nor produced. |
| 506 if (!(type1->IsUnion() || type2->IsUnion())) { | 504 if (!(type1->IsUnion() || type2->IsUnion())) { |
| 507 if (type1->Is(type2)) return type1; | 505 if (type1->Is(type2)) return type1; |
| 508 if (type2->Is(type1)) return type2; | 506 if (type2->Is(type1)) return type2; |
| 509 } | 507 } |
| 510 | 508 |
| 511 // Slow case: may need to produce a Unioned object. | 509 // Slow case: may need to produce a Unioned object. |
| 512 int size = INT_MAX; | 510 int size = 0; |
| 513 if (!type1->IsBitset()) { | 511 if (!type1->IsBitset()) { |
| 514 size = (type1->IsUnion() ? Config::union_length(type1->AsUnion()) : 1); | 512 size += (type1->IsUnion() ? Config::union_length(type1->AsUnion()) : 1); |
| 515 } | 513 } |
| 516 if (!type2->IsBitset()) { | 514 if (!type2->IsBitset()) { |
| 517 size = Min(size, | 515 size += (type2->IsUnion() ? Config::union_length(type2->AsUnion()) : 1); |
| 518 type2->IsUnion() ? Config::union_length(type2->AsUnion()) : 1); | |
| 519 } | 516 } |
| 520 int bitset = type1->GlbBitset() & type2->GlbBitset(); | 517 int bitset = type1->GlbBitset() & type2->GlbBitset(); |
| 521 if (IsInhabited(bitset)) ++size; | 518 if (bitset != kNone) ++size; |
| 522 ASSERT(size >= 1); | 519 ASSERT(size >= 1); |
| 523 UnionedHandle unioned = Config::union_create(size, region); | 520 UnionedHandle unioned = Config::union_create(size, region); |
| 524 | 521 |
| 525 size = 0; | 522 size = 0; |
| 526 if (IsInhabited(bitset)) { | 523 if (bitset != kNone) { |
| 527 Config::union_set(unioned, size++, Config::from_bitset(bitset, region)); | 524 Config::union_set(unioned, size++, Config::from_bitset(bitset, region)); |
| 528 } | 525 } |
| 529 size = ExtendIntersection(unioned, type1, type2, size); | 526 size = ExtendIntersection(unioned, type1, type2, size); |
| 530 size = ExtendIntersection(unioned, type2, type1, size); | 527 size = ExtendIntersection(unioned, type2, type1, size); |
| 531 | 528 |
| 532 if (size == 0) { | 529 if (size == 0) { |
| 533 return None(region); | 530 return None(region); |
| 534 } else if (size == 1) { | 531 } else if (size == 1) { |
| 535 return Config::union_get(unioned, 0); | 532 return Config::union_get(unioned, 0); |
| 536 } else { | 533 } else { |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 648 break; | 645 break; |
| 649 case SEMANTIC_DIM: | 646 case SEMANTIC_DIM: |
| 650 BitsetTypePrint(out, bitset & kSemantic); | 647 BitsetTypePrint(out, bitset & kSemantic); |
| 651 break; | 648 break; |
| 652 case REPRESENTATION_DIM: | 649 case REPRESENTATION_DIM: |
| 653 BitsetTypePrint(out, bitset & kRepresentation); | 650 BitsetTypePrint(out, bitset & kRepresentation); |
| 654 break; | 651 break; |
| 655 } | 652 } |
| 656 } else if (this->IsConstant()) { | 653 } else if (this->IsConstant()) { |
| 657 PrintF(out, "Constant(%p : ", static_cast<void*>(*this->AsConstant())); | 654 PrintF(out, "Constant(%p : ", static_cast<void*>(*this->AsConstant())); |
| 658 Config::from_bitset(this->LubBitset())->TypePrint(out); | 655 Config::from_bitset(this->LubBitset())->TypePrint(out, dim); |
| 659 PrintF(out, ")"); | 656 PrintF(out, ")"); |
| 660 } else if (this->IsClass()) { | 657 } else if (this->IsClass()) { |
| 661 PrintF(out, "Class(%p < ", static_cast<void*>(*this->AsClass())); | 658 PrintF(out, "Class(%p < ", static_cast<void*>(*this->AsClass())); |
| 662 Config::from_bitset(this->LubBitset())->TypePrint(out); | 659 Config::from_bitset(this->LubBitset())->TypePrint(out, dim); |
| 663 PrintF(out, ")"); | 660 PrintF(out, ")"); |
| 664 } else if (this->IsUnion()) { | 661 } else if (this->IsUnion()) { |
| 665 PrintF(out, "("); | 662 PrintF(out, "("); |
| 666 UnionedHandle unioned = this->AsUnion(); | 663 UnionedHandle unioned = this->AsUnion(); |
| 667 for (int i = 0; i < Config::union_length(unioned); ++i) { | 664 for (int i = 0; i < Config::union_length(unioned); ++i) { |
| 668 TypeHandle type_i = Config::union_get(unioned, i); | 665 TypeHandle type_i = Config::union_get(unioned, i); |
| 669 if (i > 0) PrintF(out, " | "); | 666 if (i > 0) PrintF(out, " | "); |
| 670 type_i->TypePrint(out, dim); | 667 type_i->TypePrint(out, dim); |
| 671 } | 668 } |
| 672 PrintF(out, ")"); | 669 PrintF(out, ")"); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 685 | 682 |
| 686 template TypeImpl<ZoneTypeConfig>::TypeHandle | 683 template TypeImpl<ZoneTypeConfig>::TypeHandle |
| 687 TypeImpl<ZoneTypeConfig>::Convert<HeapType>( | 684 TypeImpl<ZoneTypeConfig>::Convert<HeapType>( |
| 688 TypeImpl<HeapTypeConfig>::TypeHandle, TypeImpl<ZoneTypeConfig>::Region*); | 685 TypeImpl<HeapTypeConfig>::TypeHandle, TypeImpl<ZoneTypeConfig>::Region*); |
| 689 template TypeImpl<HeapTypeConfig>::TypeHandle | 686 template TypeImpl<HeapTypeConfig>::TypeHandle |
| 690 TypeImpl<HeapTypeConfig>::Convert<Type>( | 687 TypeImpl<HeapTypeConfig>::Convert<Type>( |
| 691 TypeImpl<ZoneTypeConfig>::TypeHandle, TypeImpl<HeapTypeConfig>::Region*); | 688 TypeImpl<ZoneTypeConfig>::TypeHandle, TypeImpl<HeapTypeConfig>::Region*); |
| 692 | 689 |
| 693 | 690 |
| 694 } } // namespace v8::internal | 691 } } // namespace v8::internal |
| OLD | NEW |