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 #include "src/ostreams.h" | 10 #include "src/ostreams.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
61 // However, we also define a 'temporal' variant of the subtyping relation that | 61 // However, we also define a 'temporal' variant of the subtyping relation that |
62 // considers the _current_ state only, i.e., Constant(x) <_now Class(map(x)). | 62 // considers the _current_ state only, i.e., Constant(x) <_now Class(map(x)). |
63 // | 63 // |
64 // REPRESENTATIONAL DIMENSION | 64 // REPRESENTATIONAL DIMENSION |
65 // | 65 // |
66 // For the representation axis, the following holds: | 66 // For the representation axis, the following holds: |
67 // | 67 // |
68 // None <= R | 68 // None <= R |
69 // R <= Any | 69 // R <= Any |
70 // | 70 // |
71 // UntaggedInt <= UntaggedInt8 \/ UntaggedInt16 \/ UntaggedInt32) | 71 // UntaggedInt = UntaggedInt8 \/ UntaggedInt16 \/ UntaggedInt32) |
rossberg
2014/07/23 14:53:03
Should include Int1 now. Also, spurious paren.
neis
2014/07/23 15:17:19
Done.
| |
72 // UntaggedFloat <= UntaggedFloat32 \/ UntaggedFloat64 | 72 // UntaggedFloat = UntaggedFloat32 \/ UntaggedFloat64 |
73 // UntaggedNumber <= UntaggedInt \/ UntaggedFloat | 73 // UntaggedNumber = UntaggedInt \/ UntaggedFloat |
74 // Untagged <= UntaggedNumber \/ UntaggedPtr | 74 // Untagged = UntaggedNumber \/ UntaggedPtr |
75 // Tagged <= TaggedInt \/ TaggedPtr | 75 // Tagged = TaggedInt \/ TaggedPtr |
76 // | 76 // |
77 // Subtyping relates the two dimensions, for example: | 77 // Subtyping relates the two dimensions, for example: |
78 // | 78 // |
79 // Number <= Tagged \/ UntaggedNumber | 79 // Number <= Tagged \/ UntaggedNumber |
80 // Object <= TaggedPtr \/ UntaggedPtr | 80 // Object <= TaggedPtr \/ UntaggedPtr |
81 // | 81 // |
82 // That holds because the semantic type constructors defined by the API create | 82 // That holds because the semantic type constructors defined by the API create |
83 // types that allow for all possible representations, and dually, the ones for | 83 // types that allow for all possible representations, and dually, the ones for |
84 // representation types initially include all semantic ranges. Representations | 84 // representation types initially include all semantic ranges. Representations |
85 // can then e.g. be narrowed for a given semantic type using intersection: | 85 // can then e.g. be narrowed for a given semantic type using intersection: |
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
604 ? BitsetType::New(BitsetType::Lub(*Config::as_class(this)), region) | 604 ? BitsetType::New(BitsetType::Lub(*Config::as_class(this)), region) |
605 : this->Get(0); | 605 : this->Get(0); |
606 } | 606 } |
607 i::Handle<i::Map> Map() { | 607 i::Handle<i::Map> Map() { |
608 return Config::is_class(this) | 608 return Config::is_class(this) |
609 ? Config::as_class(this) | 609 ? Config::as_class(this) |
610 : this->template GetValue<i::Map>(1); | 610 : this->template GetValue<i::Map>(1); |
611 } | 611 } |
612 | 612 |
613 static ClassHandle New( | 613 static ClassHandle New( |
614 i::Handle<i::Map> map, TypeHandle bound, Region* region) { | 614 i::Handle<i::Map> map, TypeHandle bound, Region* region) { |
rossberg
2014/07/23 14:53:03
While you're at it, can you also add assertions fo
neis
2014/07/23 15:17:19
Done.
| |
615 ClassHandle type = Config::template cast<ClassType>( | 615 ClassHandle type = Config::template cast<ClassType>( |
616 StructuralType::New(StructuralType::kClassTag, 2, region)); | 616 StructuralType::New(StructuralType::kClassTag, 2, region)); |
617 type->Set(0, bound); | 617 type->Set(0, bound); |
618 type->SetValue(1, map); | 618 type->SetValue(1, map); |
619 return type; | 619 return type; |
620 } | 620 } |
621 | 621 |
622 static ClassHandle New(i::Handle<i::Map> map, Region* region) { | 622 static ClassHandle New(i::Handle<i::Map> map, Region* region) { |
623 ClassHandle type = | 623 ClassHandle type = |
624 Config::template cast<ClassType>(Config::from_class(map, region)); | 624 Config::template cast<ClassType>(Config::from_class(map, region)); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
672 | 672 |
673 template<class Config> | 673 template<class Config> |
674 class TypeImpl<Config>::RangeType : public StructuralType { | 674 class TypeImpl<Config>::RangeType : public StructuralType { |
675 public: | 675 public: |
676 TypeHandle Bound() { return this->Get(0); } | 676 TypeHandle Bound() { return this->Get(0); } |
677 double Min() { return this->template GetValue<i::HeapNumber>(1)->value(); } | 677 double Min() { return this->template GetValue<i::HeapNumber>(1)->value(); } |
678 double Max() { return this->template GetValue<i::HeapNumber>(2)->value(); } | 678 double Max() { return this->template GetValue<i::HeapNumber>(2)->value(); } |
679 | 679 |
680 static RangeHandle New( | 680 static RangeHandle New( |
681 double min, double max, TypeHandle bound, Region* region) { | 681 double min, double max, TypeHandle bound, Region* region) { |
682 ASSERT(SEMANTIC(bound->AsBitset() | BitsetType::kNumber) | 682 ASSERT(SEMANTIC(bound->AsBitset() | BitsetType::kNumber) |
rossberg
2014/07/23 14:53:03
Make this a proper subtype check for both axes, an
neis
2014/07/23 15:17:18
Done.
| |
683 == SEMANTIC(BitsetType::kNumber)); | 683 == SEMANTIC(BitsetType::kNumber)); |
684 ASSERT(!std::isnan(min) && !std::isnan(max) && min <= max); | 684 ASSERT(!std::isnan(min) && !std::isnan(max) && min <= max); |
685 RangeHandle type = Config::template cast<RangeType>( | 685 RangeHandle type = Config::template cast<RangeType>( |
686 StructuralType::New(StructuralType::kRangeTag, 3, region)); | 686 StructuralType::New(StructuralType::kRangeTag, 3, region)); |
687 type->Set(0, bound); | 687 type->Set(0, bound); |
688 Factory* factory = Config::isolate(region)->factory(); | 688 Factory* factory = Config::isolate(region)->factory(); |
689 type->SetValue(1, factory->NewHeapNumber(min)); | 689 type->SetValue(1, factory->NewHeapNumber(min)); |
690 type->SetValue(2, factory->NewHeapNumber(max)); | 690 type->SetValue(2, factory->NewHeapNumber(max)); |
691 return type; | 691 return type; |
692 } | 692 } |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
736 // ----------------------------------------------------------------------------- | 736 // ----------------------------------------------------------------------------- |
737 // Array types. | 737 // Array types. |
738 | 738 |
739 template<class Config> | 739 template<class Config> |
740 class TypeImpl<Config>::ArrayType : public StructuralType { | 740 class TypeImpl<Config>::ArrayType : public StructuralType { |
741 public: | 741 public: |
742 TypeHandle Bound() { return this->Get(0); } | 742 TypeHandle Bound() { return this->Get(0); } |
743 TypeHandle Element() { return this->Get(1); } | 743 TypeHandle Element() { return this->Get(1); } |
744 | 744 |
745 static ArrayHandle New(TypeHandle element, TypeHandle bound, Region* region) { | 745 static ArrayHandle New(TypeHandle element, TypeHandle bound, Region* region) { |
746 ASSERT(SEMANTIC(bound->AsBitset()) == SEMANTIC(BitsetType::kArray)); | 746 ASSERT(SEMANTIC(bound->AsBitset()) == SEMANTIC(BitsetType::kArray)); |
rossberg
2014/07/23 14:53:03
Same here.
neis
2014/07/23 15:17:18
Done.
| |
747 ArrayHandle type = Config::template cast<ArrayType>( | 747 ArrayHandle type = Config::template cast<ArrayType>( |
748 StructuralType::New(StructuralType::kArrayTag, 2, region)); | 748 StructuralType::New(StructuralType::kArrayTag, 2, region)); |
749 type->Set(0, bound); | 749 type->Set(0, bound); |
750 type->Set(1, element); | 750 type->Set(1, element); |
751 return type; | 751 return type; |
752 } | 752 } |
753 | 753 |
754 static ArrayHandle New(TypeHandle element, Region* region) { | 754 static ArrayHandle New(TypeHandle element, Region* region) { |
755 TypeHandle bound = BitsetType::New(BitsetType::kArray, region); | 755 TypeHandle bound = BitsetType::New(BitsetType::kArray, region); |
756 return New(element, bound, region); | 756 return New(element, bound, region); |
(...skipping 16 matching lines...) Expand all Loading... | |
773 TypeHandle Bound() { return this->Get(0); } | 773 TypeHandle Bound() { return this->Get(0); } |
774 TypeHandle Result() { return this->Get(1); } | 774 TypeHandle Result() { return this->Get(1); } |
775 TypeHandle Receiver() { return this->Get(2); } | 775 TypeHandle Receiver() { return this->Get(2); } |
776 TypeHandle Parameter(int i) { return this->Get(3 + i); } | 776 TypeHandle Parameter(int i) { return this->Get(3 + i); } |
777 | 777 |
778 void InitParameter(int i, TypeHandle type) { this->Set(3 + i, type); } | 778 void InitParameter(int i, TypeHandle type) { this->Set(3 + i, type); } |
779 | 779 |
780 static FunctionHandle New( | 780 static FunctionHandle New( |
781 TypeHandle result, TypeHandle receiver, TypeHandle bound, | 781 TypeHandle result, TypeHandle receiver, TypeHandle bound, |
782 int arity, Region* region) { | 782 int arity, Region* region) { |
783 ASSERT(SEMANTIC(bound->AsBitset()) == SEMANTIC(BitsetType::kFunction)); | 783 ASSERT(SEMANTIC(bound->AsBitset()) == SEMANTIC(BitsetType::kFunction)); |
rossberg
2014/07/23 14:53:03
And here.
neis
2014/07/23 15:17:19
Done.
| |
784 FunctionHandle type = Config::template cast<FunctionType>( | 784 FunctionHandle type = Config::template cast<FunctionType>( |
785 StructuralType::New(StructuralType::kFunctionTag, 3 + arity, region)); | 785 StructuralType::New(StructuralType::kFunctionTag, 3 + arity, region)); |
786 type->Set(0, bound); | 786 type->Set(0, bound); |
787 type->Set(1, result); | 787 type->Set(1, result); |
788 type->Set(2, receiver); | 788 type->Set(2, receiver); |
789 return type; | 789 return type; |
790 } | 790 } |
791 | 791 |
792 static FunctionHandle New( | 792 static FunctionHandle New( |
793 TypeHandle result, TypeHandle receiver, int arity, Region* region) { | 793 TypeHandle result, TypeHandle receiver, int arity, Region* region) { |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
981 bool Narrows(BoundsImpl that) { | 981 bool Narrows(BoundsImpl that) { |
982 return that.lower->Is(this->lower) && this->upper->Is(that.upper); | 982 return that.lower->Is(this->lower) && this->upper->Is(that.upper); |
983 } | 983 } |
984 }; | 984 }; |
985 | 985 |
986 typedef BoundsImpl<ZoneTypeConfig> Bounds; | 986 typedef BoundsImpl<ZoneTypeConfig> Bounds; |
987 | 987 |
988 } } // namespace v8::internal | 988 } } // namespace v8::internal |
989 | 989 |
990 #endif // V8_TYPES_H_ | 990 #endif // V8_TYPES_H_ |
OLD | NEW |