| 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 #ifndef V8_TYPES_H_ | 5 #ifndef V8_TYPES_H_ |
| 6 #define V8_TYPES_H_ | 6 #define V8_TYPES_H_ |
| 7 | 7 |
| 8 #include "src/factory.h" | 8 #include "src/factory.h" |
| 9 #include "src/handles.h" | 9 #include "src/handles.h" |
| 10 | 10 |
| (...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 446 TypeImpl* unhandle() { return this; } | 446 TypeImpl* unhandle() { return this; } |
| 447 | 447 |
| 448 // Internal inspection. | 448 // Internal inspection. |
| 449 | 449 |
| 450 bool IsNone() { return this == None(); } | 450 bool IsNone() { return this == None(); } |
| 451 bool IsAny() { return this == Any(); } | 451 bool IsAny() { return this == Any(); } |
| 452 bool IsBitset() { return Config::is_bitset(this); } | 452 bool IsBitset() { return Config::is_bitset(this); } |
| 453 bool IsUnion() { return Config::is_struct(this, StructuralType::kUnionTag); } | 453 bool IsUnion() { return Config::is_struct(this, StructuralType::kUnionTag); } |
| 454 | 454 |
| 455 int AsBitset() { | 455 int AsBitset() { |
| 456 ASSERT(this->IsBitset()); | 456 DCHECK(this->IsBitset()); |
| 457 return static_cast<BitsetType*>(this)->Bitset(); | 457 return static_cast<BitsetType*>(this)->Bitset(); |
| 458 } | 458 } |
| 459 UnionType* AsUnion() { return UnionType::cast(this); } | 459 UnionType* AsUnion() { return UnionType::cast(this); } |
| 460 | 460 |
| 461 // Auxiliary functions. | 461 // Auxiliary functions. |
| 462 | 462 |
| 463 int BitsetGlb() { return BitsetType::Glb(this); } | 463 int BitsetGlb() { return BitsetType::Glb(this); } |
| 464 int BitsetLub() { return BitsetType::Lub(this); } | 464 int BitsetLub() { return BitsetType::Lub(this); } |
| 465 int InherentBitsetLub() { return BitsetType::InherentLub(this); } | 465 int InherentBitsetLub() { return BitsetType::InherentLub(this); } |
| 466 | 466 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 539 kContextTag, | 539 kContextTag, |
| 540 kArrayTag, | 540 kArrayTag, |
| 541 kFunctionTag, | 541 kFunctionTag, |
| 542 kUnionTag | 542 kUnionTag |
| 543 }; | 543 }; |
| 544 | 544 |
| 545 int Length() { | 545 int Length() { |
| 546 return Config::struct_length(Config::as_struct(this)); | 546 return Config::struct_length(Config::as_struct(this)); |
| 547 } | 547 } |
| 548 TypeHandle Get(int i) { | 548 TypeHandle Get(int i) { |
| 549 ASSERT(0 <= i && i < this->Length()); | 549 DCHECK(0 <= i && i < this->Length()); |
| 550 return Config::struct_get(Config::as_struct(this), i); | 550 return Config::struct_get(Config::as_struct(this), i); |
| 551 } | 551 } |
| 552 void Set(int i, TypeHandle type) { | 552 void Set(int i, TypeHandle type) { |
| 553 ASSERT(0 <= i && i < this->Length()); | 553 DCHECK(0 <= i && i < this->Length()); |
| 554 Config::struct_set(Config::as_struct(this), i, type); | 554 Config::struct_set(Config::as_struct(this), i, type); |
| 555 } | 555 } |
| 556 void Shrink(int length) { | 556 void Shrink(int length) { |
| 557 ASSERT(2 <= length && length <= this->Length()); | 557 DCHECK(2 <= length && length <= this->Length()); |
| 558 Config::struct_shrink(Config::as_struct(this), length); | 558 Config::struct_shrink(Config::as_struct(this), length); |
| 559 } | 559 } |
| 560 template<class V> i::Handle<V> GetValue(int i) { | 560 template<class V> i::Handle<V> GetValue(int i) { |
| 561 ASSERT(0 <= i && i < this->Length()); | 561 DCHECK(0 <= i && i < this->Length()); |
| 562 return Config::template struct_get_value<V>(Config::as_struct(this), i); | 562 return Config::template struct_get_value<V>(Config::as_struct(this), i); |
| 563 } | 563 } |
| 564 template<class V> void SetValue(int i, i::Handle<V> x) { | 564 template<class V> void SetValue(int i, i::Handle<V> x) { |
| 565 ASSERT(0 <= i && i < this->Length()); | 565 DCHECK(0 <= i && i < this->Length()); |
| 566 Config::struct_set_value(Config::as_struct(this), i, x); | 566 Config::struct_set_value(Config::as_struct(this), i, x); |
| 567 } | 567 } |
| 568 | 568 |
| 569 static TypeHandle New(Tag tag, int length, Region* region) { | 569 static TypeHandle New(Tag tag, int length, Region* region) { |
| 570 ASSERT(1 <= length); | 570 DCHECK(1 <= length); |
| 571 return Config::from_struct(Config::struct_create(tag, length, region)); | 571 return Config::from_struct(Config::struct_create(tag, length, region)); |
| 572 } | 572 } |
| 573 }; | 573 }; |
| 574 | 574 |
| 575 | 575 |
| 576 // ----------------------------------------------------------------------------- | 576 // ----------------------------------------------------------------------------- |
| 577 // Union types (internal). | 577 // Union types (internal). |
| 578 // A union is a structured type with the following invariants: | 578 // A union is a structured type with the following invariants: |
| 579 // - its length is at least 2 | 579 // - its length is at least 2 |
| 580 // - at most one field is a bitset, and it must go into index 0 | 580 // - at most one field is a bitset, and it must go into index 0 |
| 581 // - no field is a union | 581 // - no field is a union |
| 582 // - no field is a subtype of any other field | 582 // - no field is a subtype of any other field |
| 583 template<class Config> | 583 template<class Config> |
| 584 class TypeImpl<Config>::UnionType : public StructuralType { | 584 class TypeImpl<Config>::UnionType : public StructuralType { |
| 585 public: | 585 public: |
| 586 static UnionHandle New(int length, Region* region) { | 586 static UnionHandle New(int length, Region* region) { |
| 587 return Config::template cast<UnionType>( | 587 return Config::template cast<UnionType>( |
| 588 StructuralType::New(StructuralType::kUnionTag, length, region)); | 588 StructuralType::New(StructuralType::kUnionTag, length, region)); |
| 589 } | 589 } |
| 590 | 590 |
| 591 static UnionType* cast(TypeImpl* type) { | 591 static UnionType* cast(TypeImpl* type) { |
| 592 ASSERT(type->IsUnion()); | 592 DCHECK(type->IsUnion()); |
| 593 return static_cast<UnionType*>(type); | 593 return static_cast<UnionType*>(type); |
| 594 } | 594 } |
| 595 | 595 |
| 596 bool Wellformed(); | 596 bool Wellformed(); |
| 597 }; | 597 }; |
| 598 | 598 |
| 599 | 599 |
| 600 // ----------------------------------------------------------------------------- | 600 // ----------------------------------------------------------------------------- |
| 601 // Class types. | 601 // Class types. |
| 602 | 602 |
| 603 template<class Config> | 603 template<class Config> |
| 604 class TypeImpl<Config>::ClassType : public StructuralType { | 604 class TypeImpl<Config>::ClassType : public StructuralType { |
| 605 public: | 605 public: |
| 606 TypeHandle Bound(Region* region) { | 606 TypeHandle Bound(Region* region) { |
| 607 return Config::is_class(this) | 607 return Config::is_class(this) |
| 608 ? BitsetType::New(BitsetType::Lub(*Config::as_class(this)), region) | 608 ? BitsetType::New(BitsetType::Lub(*Config::as_class(this)), region) |
| 609 : this->Get(0); | 609 : this->Get(0); |
| 610 } | 610 } |
| 611 i::Handle<i::Map> Map() { | 611 i::Handle<i::Map> Map() { |
| 612 return Config::is_class(this) | 612 return Config::is_class(this) |
| 613 ? Config::as_class(this) | 613 ? Config::as_class(this) |
| 614 : this->template GetValue<i::Map>(1); | 614 : this->template GetValue<i::Map>(1); |
| 615 } | 615 } |
| 616 | 616 |
| 617 static ClassHandle New( | 617 static ClassHandle New( |
| 618 i::Handle<i::Map> map, TypeHandle bound, Region* region) { | 618 i::Handle<i::Map> map, TypeHandle bound, Region* region) { |
| 619 ASSERT(BitsetType::Is(bound->AsBitset(), BitsetType::Lub(*map))); | 619 DCHECK(BitsetType::Is(bound->AsBitset(), BitsetType::Lub(*map))); |
| 620 ClassHandle type = Config::template cast<ClassType>( | 620 ClassHandle type = Config::template cast<ClassType>( |
| 621 StructuralType::New(StructuralType::kClassTag, 2, region)); | 621 StructuralType::New(StructuralType::kClassTag, 2, region)); |
| 622 type->Set(0, bound); | 622 type->Set(0, bound); |
| 623 type->SetValue(1, map); | 623 type->SetValue(1, map); |
| 624 return type; | 624 return type; |
| 625 } | 625 } |
| 626 | 626 |
| 627 static ClassHandle New(i::Handle<i::Map> map, Region* region) { | 627 static ClassHandle New(i::Handle<i::Map> map, Region* region) { |
| 628 ClassHandle type = | 628 ClassHandle type = |
| 629 Config::template cast<ClassType>(Config::from_class(map, region)); | 629 Config::template cast<ClassType>(Config::from_class(map, region)); |
| 630 if (type->IsClass()) { | 630 if (type->IsClass()) { |
| 631 return type; | 631 return type; |
| 632 } else { | 632 } else { |
| 633 TypeHandle bound = BitsetType::New(BitsetType::Lub(*map), region); | 633 TypeHandle bound = BitsetType::New(BitsetType::Lub(*map), region); |
| 634 return New(map, bound, region); | 634 return New(map, bound, region); |
| 635 } | 635 } |
| 636 } | 636 } |
| 637 | 637 |
| 638 static ClassType* cast(TypeImpl* type) { | 638 static ClassType* cast(TypeImpl* type) { |
| 639 ASSERT(type->IsClass()); | 639 DCHECK(type->IsClass()); |
| 640 return static_cast<ClassType*>(type); | 640 return static_cast<ClassType*>(type); |
| 641 } | 641 } |
| 642 }; | 642 }; |
| 643 | 643 |
| 644 | 644 |
| 645 // ----------------------------------------------------------------------------- | 645 // ----------------------------------------------------------------------------- |
| 646 // Constant types. | 646 // Constant types. |
| 647 | 647 |
| 648 template<class Config> | 648 template<class Config> |
| 649 class TypeImpl<Config>::ConstantType : public StructuralType { | 649 class TypeImpl<Config>::ConstantType : public StructuralType { |
| 650 public: | 650 public: |
| 651 TypeHandle Bound() { return this->Get(0); } | 651 TypeHandle Bound() { return this->Get(0); } |
| 652 i::Handle<i::Object> Value() { return this->template GetValue<i::Object>(1); } | 652 i::Handle<i::Object> Value() { return this->template GetValue<i::Object>(1); } |
| 653 | 653 |
| 654 static ConstantHandle New( | 654 static ConstantHandle New( |
| 655 i::Handle<i::Object> value, TypeHandle bound, Region* region) { | 655 i::Handle<i::Object> value, TypeHandle bound, Region* region) { |
| 656 ASSERT(BitsetType::Is(bound->AsBitset(), BitsetType::Lub(*value))); | 656 DCHECK(BitsetType::Is(bound->AsBitset(), BitsetType::Lub(*value))); |
| 657 ConstantHandle type = Config::template cast<ConstantType>( | 657 ConstantHandle type = Config::template cast<ConstantType>( |
| 658 StructuralType::New(StructuralType::kConstantTag, 2, region)); | 658 StructuralType::New(StructuralType::kConstantTag, 2, region)); |
| 659 type->Set(0, bound); | 659 type->Set(0, bound); |
| 660 type->SetValue(1, value); | 660 type->SetValue(1, value); |
| 661 return type; | 661 return type; |
| 662 } | 662 } |
| 663 | 663 |
| 664 static ConstantHandle New(i::Handle<i::Object> value, Region* region) { | 664 static ConstantHandle New(i::Handle<i::Object> value, Region* region) { |
| 665 TypeHandle bound = BitsetType::New(BitsetType::Lub(*value), region); | 665 TypeHandle bound = BitsetType::New(BitsetType::Lub(*value), region); |
| 666 return New(value, bound, region); | 666 return New(value, bound, region); |
| 667 } | 667 } |
| 668 | 668 |
| 669 static ConstantType* cast(TypeImpl* type) { | 669 static ConstantType* cast(TypeImpl* type) { |
| 670 ASSERT(type->IsConstant()); | 670 DCHECK(type->IsConstant()); |
| 671 return static_cast<ConstantType*>(type); | 671 return static_cast<ConstantType*>(type); |
| 672 } | 672 } |
| 673 }; | 673 }; |
| 674 | 674 |
| 675 | 675 |
| 676 // ----------------------------------------------------------------------------- | 676 // ----------------------------------------------------------------------------- |
| 677 // Range types. | 677 // Range types. |
| 678 | 678 |
| 679 template<class Config> | 679 template<class Config> |
| 680 class TypeImpl<Config>::RangeType : public StructuralType { | 680 class TypeImpl<Config>::RangeType : public StructuralType { |
| 681 public: | 681 public: |
| 682 TypeHandle Bound() { return this->Get(0); } | 682 TypeHandle Bound() { return this->Get(0); } |
| 683 double Min() { return this->template GetValue<i::HeapNumber>(1)->value(); } | 683 double Min() { return this->template GetValue<i::HeapNumber>(1)->value(); } |
| 684 double Max() { return this->template GetValue<i::HeapNumber>(2)->value(); } | 684 double Max() { return this->template GetValue<i::HeapNumber>(2)->value(); } |
| 685 | 685 |
| 686 static RangeHandle New( | 686 static RangeHandle New( |
| 687 double min, double max, TypeHandle bound, Region* region) { | 687 double min, double max, TypeHandle bound, Region* region) { |
| 688 ASSERT(BitsetType::Is(bound->AsBitset(), BitsetType::kNumber)); | 688 DCHECK(BitsetType::Is(bound->AsBitset(), BitsetType::kNumber)); |
| 689 ASSERT(!std::isnan(min) && !std::isnan(max) && min <= max); | 689 DCHECK(!std::isnan(min) && !std::isnan(max) && min <= max); |
| 690 RangeHandle type = Config::template cast<RangeType>( | 690 RangeHandle type = Config::template cast<RangeType>( |
| 691 StructuralType::New(StructuralType::kRangeTag, 3, region)); | 691 StructuralType::New(StructuralType::kRangeTag, 3, region)); |
| 692 type->Set(0, bound); | 692 type->Set(0, bound); |
| 693 Factory* factory = Config::isolate(region)->factory(); | 693 Factory* factory = Config::isolate(region)->factory(); |
| 694 Handle<HeapNumber> minV = factory->NewHeapNumber(min); | 694 Handle<HeapNumber> minV = factory->NewHeapNumber(min); |
| 695 Handle<HeapNumber> maxV = factory->NewHeapNumber(max); | 695 Handle<HeapNumber> maxV = factory->NewHeapNumber(max); |
| 696 type->SetValue(1, minV); | 696 type->SetValue(1, minV); |
| 697 type->SetValue(2, maxV); | 697 type->SetValue(2, maxV); |
| 698 return type; | 698 return type; |
| 699 } | 699 } |
| 700 | 700 |
| 701 static RangeHandle New(double min, double max, Region* region) { | 701 static RangeHandle New(double min, double max, Region* region) { |
| 702 TypeHandle bound = BitsetType::New(BitsetType::kNumber, region); | 702 TypeHandle bound = BitsetType::New(BitsetType::kNumber, region); |
| 703 return New(min, max, bound, region); | 703 return New(min, max, bound, region); |
| 704 } | 704 } |
| 705 | 705 |
| 706 static RangeType* cast(TypeImpl* type) { | 706 static RangeType* cast(TypeImpl* type) { |
| 707 ASSERT(type->IsRange()); | 707 DCHECK(type->IsRange()); |
| 708 return static_cast<RangeType*>(type); | 708 return static_cast<RangeType*>(type); |
| 709 } | 709 } |
| 710 }; | 710 }; |
| 711 | 711 |
| 712 | 712 |
| 713 // ----------------------------------------------------------------------------- | 713 // ----------------------------------------------------------------------------- |
| 714 // Context types. | 714 // Context types. |
| 715 | 715 |
| 716 template<class Config> | 716 template<class Config> |
| 717 class TypeImpl<Config>::ContextType : public StructuralType { | 717 class TypeImpl<Config>::ContextType : public StructuralType { |
| 718 public: | 718 public: |
| 719 TypeHandle Bound() { return this->Get(0); } | 719 TypeHandle Bound() { return this->Get(0); } |
| 720 TypeHandle Outer() { return this->Get(1); } | 720 TypeHandle Outer() { return this->Get(1); } |
| 721 | 721 |
| 722 static ContextHandle New(TypeHandle outer, TypeHandle bound, Region* region) { | 722 static ContextHandle New(TypeHandle outer, TypeHandle bound, Region* region) { |
| 723 ASSERT(BitsetType::Is( | 723 DCHECK(BitsetType::Is( |
| 724 bound->AsBitset(), BitsetType::kInternal & BitsetType::kTaggedPtr)); | 724 bound->AsBitset(), BitsetType::kInternal & BitsetType::kTaggedPtr)); |
| 725 ContextHandle type = Config::template cast<ContextType>( | 725 ContextHandle type = Config::template cast<ContextType>( |
| 726 StructuralType::New(StructuralType::kContextTag, 2, region)); | 726 StructuralType::New(StructuralType::kContextTag, 2, region)); |
| 727 type->Set(0, bound); | 727 type->Set(0, bound); |
| 728 type->Set(1, outer); | 728 type->Set(1, outer); |
| 729 return type; | 729 return type; |
| 730 } | 730 } |
| 731 | 731 |
| 732 static ContextHandle New(TypeHandle outer, Region* region) { | 732 static ContextHandle New(TypeHandle outer, Region* region) { |
| 733 TypeHandle bound = BitsetType::New( | 733 TypeHandle bound = BitsetType::New( |
| 734 BitsetType::kInternal & BitsetType::kTaggedPtr, region); | 734 BitsetType::kInternal & BitsetType::kTaggedPtr, region); |
| 735 return New(outer, bound, region); | 735 return New(outer, bound, region); |
| 736 } | 736 } |
| 737 | 737 |
| 738 static ContextType* cast(TypeImpl* type) { | 738 static ContextType* cast(TypeImpl* type) { |
| 739 ASSERT(type->IsContext()); | 739 DCHECK(type->IsContext()); |
| 740 return static_cast<ContextType*>(type); | 740 return static_cast<ContextType*>(type); |
| 741 } | 741 } |
| 742 }; | 742 }; |
| 743 | 743 |
| 744 | 744 |
| 745 // ----------------------------------------------------------------------------- | 745 // ----------------------------------------------------------------------------- |
| 746 // Array types. | 746 // Array types. |
| 747 | 747 |
| 748 template<class Config> | 748 template<class Config> |
| 749 class TypeImpl<Config>::ArrayType : public StructuralType { | 749 class TypeImpl<Config>::ArrayType : public StructuralType { |
| 750 public: | 750 public: |
| 751 TypeHandle Bound() { return this->Get(0); } | 751 TypeHandle Bound() { return this->Get(0); } |
| 752 TypeHandle Element() { return this->Get(1); } | 752 TypeHandle Element() { return this->Get(1); } |
| 753 | 753 |
| 754 static ArrayHandle New(TypeHandle element, TypeHandle bound, Region* region) { | 754 static ArrayHandle New(TypeHandle element, TypeHandle bound, Region* region) { |
| 755 ASSERT(BitsetType::Is(bound->AsBitset(), BitsetType::kArray)); | 755 DCHECK(BitsetType::Is(bound->AsBitset(), BitsetType::kArray)); |
| 756 ArrayHandle type = Config::template cast<ArrayType>( | 756 ArrayHandle type = Config::template cast<ArrayType>( |
| 757 StructuralType::New(StructuralType::kArrayTag, 2, region)); | 757 StructuralType::New(StructuralType::kArrayTag, 2, region)); |
| 758 type->Set(0, bound); | 758 type->Set(0, bound); |
| 759 type->Set(1, element); | 759 type->Set(1, element); |
| 760 return type; | 760 return type; |
| 761 } | 761 } |
| 762 | 762 |
| 763 static ArrayHandle New(TypeHandle element, Region* region) { | 763 static ArrayHandle New(TypeHandle element, Region* region) { |
| 764 TypeHandle bound = BitsetType::New(BitsetType::kArray, region); | 764 TypeHandle bound = BitsetType::New(BitsetType::kArray, region); |
| 765 return New(element, bound, region); | 765 return New(element, bound, region); |
| 766 } | 766 } |
| 767 | 767 |
| 768 static ArrayType* cast(TypeImpl* type) { | 768 static ArrayType* cast(TypeImpl* type) { |
| 769 ASSERT(type->IsArray()); | 769 DCHECK(type->IsArray()); |
| 770 return static_cast<ArrayType*>(type); | 770 return static_cast<ArrayType*>(type); |
| 771 } | 771 } |
| 772 }; | 772 }; |
| 773 | 773 |
| 774 | 774 |
| 775 // ----------------------------------------------------------------------------- | 775 // ----------------------------------------------------------------------------- |
| 776 // Function types. | 776 // Function types. |
| 777 | 777 |
| 778 template<class Config> | 778 template<class Config> |
| 779 class TypeImpl<Config>::FunctionType : public StructuralType { | 779 class TypeImpl<Config>::FunctionType : public StructuralType { |
| 780 public: | 780 public: |
| 781 int Arity() { return this->Length() - 3; } | 781 int Arity() { return this->Length() - 3; } |
| 782 TypeHandle Bound() { return this->Get(0); } | 782 TypeHandle Bound() { return this->Get(0); } |
| 783 TypeHandle Result() { return this->Get(1); } | 783 TypeHandle Result() { return this->Get(1); } |
| 784 TypeHandle Receiver() { return this->Get(2); } | 784 TypeHandle Receiver() { return this->Get(2); } |
| 785 TypeHandle Parameter(int i) { return this->Get(3 + i); } | 785 TypeHandle Parameter(int i) { return this->Get(3 + i); } |
| 786 | 786 |
| 787 void InitParameter(int i, TypeHandle type) { this->Set(3 + i, type); } | 787 void InitParameter(int i, TypeHandle type) { this->Set(3 + i, type); } |
| 788 | 788 |
| 789 static FunctionHandle New( | 789 static FunctionHandle New( |
| 790 TypeHandle result, TypeHandle receiver, TypeHandle bound, | 790 TypeHandle result, TypeHandle receiver, TypeHandle bound, |
| 791 int arity, Region* region) { | 791 int arity, Region* region) { |
| 792 ASSERT(BitsetType::Is(bound->AsBitset(), BitsetType::kFunction)); | 792 DCHECK(BitsetType::Is(bound->AsBitset(), BitsetType::kFunction)); |
| 793 FunctionHandle type = Config::template cast<FunctionType>( | 793 FunctionHandle type = Config::template cast<FunctionType>( |
| 794 StructuralType::New(StructuralType::kFunctionTag, 3 + arity, region)); | 794 StructuralType::New(StructuralType::kFunctionTag, 3 + arity, region)); |
| 795 type->Set(0, bound); | 795 type->Set(0, bound); |
| 796 type->Set(1, result); | 796 type->Set(1, result); |
| 797 type->Set(2, receiver); | 797 type->Set(2, receiver); |
| 798 return type; | 798 return type; |
| 799 } | 799 } |
| 800 | 800 |
| 801 static FunctionHandle New( | 801 static FunctionHandle New( |
| 802 TypeHandle result, TypeHandle receiver, int arity, Region* region) { | 802 TypeHandle result, TypeHandle receiver, int arity, Region* region) { |
| 803 TypeHandle bound = BitsetType::New(BitsetType::kFunction, region); | 803 TypeHandle bound = BitsetType::New(BitsetType::kFunction, region); |
| 804 return New(result, receiver, bound, arity, region); | 804 return New(result, receiver, bound, arity, region); |
| 805 } | 805 } |
| 806 | 806 |
| 807 static FunctionType* cast(TypeImpl* type) { | 807 static FunctionType* cast(TypeImpl* type) { |
| 808 ASSERT(type->IsFunction()); | 808 DCHECK(type->IsFunction()); |
| 809 return static_cast<FunctionType*>(type); | 809 return static_cast<FunctionType*>(type); |
| 810 } | 810 } |
| 811 }; | 811 }; |
| 812 | 812 |
| 813 | 813 |
| 814 // ----------------------------------------------------------------------------- | 814 // ----------------------------------------------------------------------------- |
| 815 // Type iterators. | 815 // Type iterators. |
| 816 | 816 |
| 817 template<class Config> template<class T> | 817 template<class Config> template<class T> |
| 818 class TypeImpl<Config>::Iterator { | 818 class TypeImpl<Config>::Iterator { |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 944 typedef TypeImpl<Config> Type; | 944 typedef TypeImpl<Config> Type; |
| 945 typedef typename Type::TypeHandle TypeHandle; | 945 typedef typename Type::TypeHandle TypeHandle; |
| 946 typedef typename Type::Region Region; | 946 typedef typename Type::Region Region; |
| 947 | 947 |
| 948 TypeHandle lower; | 948 TypeHandle lower; |
| 949 TypeHandle upper; | 949 TypeHandle upper; |
| 950 | 950 |
| 951 BoundsImpl() {} | 951 BoundsImpl() {} |
| 952 explicit BoundsImpl(TypeHandle t) : lower(t), upper(t) {} | 952 explicit BoundsImpl(TypeHandle t) : lower(t), upper(t) {} |
| 953 BoundsImpl(TypeHandle l, TypeHandle u) : lower(l), upper(u) { | 953 BoundsImpl(TypeHandle l, TypeHandle u) : lower(l), upper(u) { |
| 954 ASSERT(lower->Is(upper)); | 954 DCHECK(lower->Is(upper)); |
| 955 } | 955 } |
| 956 | 956 |
| 957 // Unrestricted bounds. | 957 // Unrestricted bounds. |
| 958 static BoundsImpl Unbounded(Region* region) { | 958 static BoundsImpl Unbounded(Region* region) { |
| 959 return BoundsImpl(Type::None(region), Type::Any(region)); | 959 return BoundsImpl(Type::None(region), Type::Any(region)); |
| 960 } | 960 } |
| 961 | 961 |
| 962 // Meet: both b1 and b2 are known to hold. | 962 // Meet: both b1 and b2 are known to hold. |
| 963 static BoundsImpl Both(BoundsImpl b1, BoundsImpl b2, Region* region) { | 963 static BoundsImpl Both(BoundsImpl b1, BoundsImpl b2, Region* region) { |
| 964 TypeHandle lower = Type::Union(b1.lower, b2.lower, region); | 964 TypeHandle lower = Type::Union(b1.lower, b2.lower, region); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 990 bool Narrows(BoundsImpl that) { | 990 bool Narrows(BoundsImpl that) { |
| 991 return that.lower->Is(this->lower) && this->upper->Is(that.upper); | 991 return that.lower->Is(this->lower) && this->upper->Is(that.upper); |
| 992 } | 992 } |
| 993 }; | 993 }; |
| 994 | 994 |
| 995 typedef BoundsImpl<ZoneTypeConfig> Bounds; | 995 typedef BoundsImpl<ZoneTypeConfig> Bounds; |
| 996 | 996 |
| 997 } } // namespace v8::internal | 997 } } // namespace v8::internal |
| 998 | 998 |
| 999 #endif // V8_TYPES_H_ | 999 #endif // V8_TYPES_H_ |
| OLD | NEW |