| Index: src/types.h
|
| diff --git a/src/types.h b/src/types.h
|
| index 72a78ca170c55f95b5bb639d071ab6aaa9485e66..4b7d8ba9795b9919a6733a299a82d66cb6a11165 100644
|
| --- a/src/types.h
|
| +++ b/src/types.h
|
| @@ -152,8 +152,6 @@
|
|
|
| // -----------------------------------------------------------------------------
|
| // Values for bitset types
|
| -
|
| -// clang-format off
|
|
|
| #define MASK_BITSET_TYPE_LIST(V) \
|
| V(Representation, 0xfff00000u) \
|
| @@ -197,11 +195,11 @@
|
| V(OtherNumber, 1u << 4 | REPRESENTATION(kTagged | kUntaggedNumber))
|
|
|
| #define SEMANTIC_BITSET_TYPE_LIST(V) \
|
| - V(Negative31, 1u << 5 | REPRESENTATION(kTagged | kUntaggedNumber)) \
|
| + V(NegativeSignedSmall, 1u << 5 | REPRESENTATION(kTagged | kUntaggedNumber)) \
|
| V(Null, 1u << 6 | REPRESENTATION(kTaggedPointer)) \
|
| V(Undefined, 1u << 7 | REPRESENTATION(kTaggedPointer)) \
|
| V(Boolean, 1u << 8 | REPRESENTATION(kTaggedPointer)) \
|
| - V(Unsigned30, 1u << 9 | REPRESENTATION(kTagged | kUntaggedNumber)) \
|
| + V(UnsignedSmall, 1u << 9 | REPRESENTATION(kTagged | kUntaggedNumber)) \
|
| V(MinusZero, 1u << 10 | REPRESENTATION(kTagged | kUntaggedNumber)) \
|
| V(NaN, 1u << 11 | REPRESENTATION(kTagged | kUntaggedNumber)) \
|
| V(Symbol, 1u << 12 | REPRESENTATION(kTaggedPointer)) \
|
| @@ -213,11 +211,11 @@
|
| V(Proxy, 1u << 18 | REPRESENTATION(kTaggedPointer)) \
|
| V(Internal, 1u << 19 | REPRESENTATION(kTagged | kUntagged)) \
|
| \
|
| - V(Signed31, kUnsigned30 | kNegative31) \
|
| - V(Signed32, kSigned31 | kOtherUnsigned31 | kOtherSigned32) \
|
| - V(Negative32, kNegative31 | kOtherSigned32) \
|
| - V(Unsigned31, kUnsigned30 | kOtherUnsigned31) \
|
| - V(Unsigned32, kUnsigned30 | kOtherUnsigned31 | kOtherUnsigned32) \
|
| + V(SignedSmall, kUnsignedSmall | kNegativeSignedSmall) \
|
| + V(Signed32, kSignedSmall | kOtherUnsigned31 | kOtherSigned32) \
|
| + V(NegativeSigned32, kNegativeSignedSmall | kOtherSigned32) \
|
| + V(NonNegativeSigned32, kUnsignedSmall | kOtherUnsigned31) \
|
| + V(Unsigned32, kUnsignedSmall | kOtherUnsigned31 | kOtherUnsigned32) \
|
| V(Integral32, kSigned32 | kUnsigned32) \
|
| V(PlainNumber, kIntegral32 | kOtherNumber) \
|
| V(OrderedNumber, kPlainNumber | kMinusZero) \
|
| @@ -239,17 +237,29 @@
|
| V(NonNumber, kUnique | kString | kInternal) \
|
| V(Any, 0xfffffffeu)
|
|
|
| -// clang-format on
|
|
|
| /*
|
| * The following diagrams show how integers (in the mathematical sense) are
|
| * divided among the different atomic numerical types.
|
| *
|
| - * ON OS32 N31 U30 OU31 OU32 ON
|
| + * If SmiValuesAre31Bits():
|
| + *
|
| + * ON OS32 OSS US OU31 OU32 ON
|
| * ______[_______[_______[_______[_______[_______[_______
|
| * -2^31 -2^30 0 2^30 2^31 2^32
|
| *
|
| + * Otherwise:
|
| + *
|
| + * ON OSS US OU32 ON
|
| + * ______[_______________[_______________[_______[_______
|
| + * -2^31 0 2^31 2^32
|
| + *
|
| + *
|
| * E.g., OtherUnsigned32 (OU32) covers all integers from 2^31 to 2^32-1.
|
| + *
|
| + * NOTE: OtherSigned32 (OS32) and OU31 (OtherUnsigned31) are empty if Smis are
|
| + * 32-bit wide. They should thus never be used directly, only indirectly
|
| + * via e.g. Number.
|
| */
|
|
|
| #define PROPER_BITSET_TYPE_LIST(V) \
|
| @@ -295,7 +305,6 @@
|
| // static i::Handle<V> struct_get_value(Handle<Struct>::type, int);
|
| // template<class V>
|
| // static void struct_set_value(Handle<Struct>::type, int, i::Handle<V>);
|
| -// static i::Isolate* isolate(Region* region);
|
| // }
|
| template<class Config>
|
| class TypeImpl : public Config::Base {
|
| @@ -336,19 +345,6 @@
|
| PROPER_BITSET_TYPE_LIST(DEFINE_TYPE_CONSTRUCTOR)
|
| #undef DEFINE_TYPE_CONSTRUCTOR
|
|
|
| - static TypeImpl* SignedSmall() {
|
| - return BitsetType::New(BitsetType::SignedSmall());
|
| - }
|
| - static TypeHandle SignedSmall(Region* region) {
|
| - return BitsetType::New(BitsetType::SignedSmall(), region);
|
| - }
|
| - static TypeImpl* UnsignedSmall() {
|
| - return BitsetType::New(BitsetType::UnsignedSmall());
|
| - }
|
| - static TypeHandle UnsignedSmall(Region* region) {
|
| - return BitsetType::New(BitsetType::UnsignedSmall(), region);
|
| - }
|
| -
|
| static TypeHandle Class(i::Handle<i::Map> map, Region* region) {
|
| return ClassType::New(map, region);
|
| }
|
| @@ -357,11 +353,7 @@
|
| }
|
| static TypeHandle Range(
|
| i::Handle<i::Object> min, i::Handle<i::Object> max, Region* region) {
|
| - return RangeType::New(
|
| - min, max, BitsetType::New(REPRESENTATION(BitsetType::kTagged |
|
| - BitsetType::kUntaggedNumber),
|
| - region),
|
| - region);
|
| + return RangeType::New(min, max, region);
|
| }
|
| static TypeHandle Context(TypeHandle outer, Region* region) {
|
| return ContextType::New(outer, region);
|
| @@ -568,36 +560,20 @@
|
| struct Limits {
|
| i::Handle<i::Object> min;
|
| i::Handle<i::Object> max;
|
| - bitset representation;
|
| - Limits(i::Handle<i::Object> min, i::Handle<i::Object> max,
|
| - bitset representation)
|
| - : min(min), max(max), representation(representation) {}
|
| - explicit Limits(RangeType* range)
|
| - : min(range->Min()),
|
| - max(range->Max()),
|
| - representation(REPRESENTATION(range->Bound()->AsBitset())) {}
|
| - static Limits Empty(Region* region) {
|
| - i::Factory* f = Config::isolate(region)->factory();
|
| - i::Handle<i::Object> min = f->NewNumber(1);
|
| - i::Handle<i::Object> max = f->NewNumber(0);
|
| - return Limits(min, max, BitsetType::kNone);
|
| - }
|
| + Limits(i::Handle<i::Object> min, i::Handle<i::Object> max) :
|
| + min(min), max(max) {}
|
| + explicit Limits(RangeType* range) :
|
| + min(range->Min()), max(range->Max()) {}
|
| };
|
|
|
| - static bool IsEmpty(Limits lim);
|
| static Limits Intersect(Limits lhs, Limits rhs);
|
| static Limits Union(Limits lhs, Limits rhs);
|
| static bool Overlap(RangeType* lhs, RangeType* rhs);
|
| static bool Contains(RangeType* lhs, RangeType* rhs);
|
| - static bool Contains(RangeType* range, ConstantType* constant);
|
| static bool Contains(RangeType* range, i::Object* val);
|
|
|
| static int UpdateRange(
|
| RangeHandle type, UnionHandle result, int size, Region* region);
|
| -
|
| - static Limits IntersectRangeAndBitset(TypeHandle range, TypeHandle bits,
|
| - Region* region);
|
| - static Limits ToLimits(bitset bits, Region* region);
|
|
|
| bool SimplyEquals(TypeImpl* that);
|
| template<class TypeHandle>
|
| @@ -605,11 +581,10 @@
|
|
|
| static int AddToUnion(
|
| TypeHandle type, UnionHandle result, int size, Region* region);
|
| - static int IntersectAux(TypeHandle type, TypeHandle other, UnionHandle result,
|
| - int size, Limits* limits, Region* region);
|
| + static int IntersectAux(
|
| + TypeHandle type, TypeHandle other,
|
| + UnionHandle result, int size, Region* region);
|
| static TypeHandle NormalizeUnion(UnionHandle unioned, int size);
|
| - static TypeHandle NormalizeRangeAndBitset(RangeHandle range, bitset* bits,
|
| - Region* region);
|
| };
|
|
|
|
|
| @@ -628,17 +603,28 @@
|
| kUnusedEOL = 0
|
| };
|
|
|
| - static bitset SignedSmall();
|
| - static bitset UnsignedSmall();
|
| -
|
| bitset Bitset() { return Config::as_bitset(this); }
|
|
|
| static TypeImpl* New(bitset bits) {
|
| - if (FLAG_enable_slow_asserts) CheckNumberBits(bits);
|
| + DCHECK(bits == kNone || IsInhabited(bits));
|
| +
|
| + if (FLAG_enable_slow_asserts) {
|
| + // Check that the bitset does not contain any holes in number ranges.
|
| + bitset mask = kSemantic;
|
| + if (!i::SmiValuesAre31Bits()) {
|
| + mask &= ~(kOtherUnsigned31 | kOtherSigned32);
|
| + }
|
| + bitset number_bits = bits & kPlainNumber & mask;
|
| + if (number_bits != 0) {
|
| + bitset lub = Lub(Min(number_bits), Max(number_bits)) & mask;
|
| + CHECK(lub == number_bits);
|
| + }
|
| + }
|
| +
|
| return Config::from_bitset(bits);
|
| }
|
| static TypeHandle New(bitset bits, Region* region) {
|
| - if (FLAG_enable_slow_asserts) CheckNumberBits(bits);
|
| + DCHECK(bits == kNone || IsInhabited(bits));
|
| return Config::from_bitset(bits, region);
|
| }
|
| // TODO(neis): Eventually allow again for types with empty semantics
|
| @@ -656,7 +642,6 @@
|
| static double Max(bitset);
|
|
|
| static bitset Glb(TypeImpl* type); // greatest lower bound that's a bitset
|
| - static bitset Glb(double min, double max);
|
| static bitset Lub(TypeImpl* type); // least upper bound that's a bitset
|
| static bitset Lub(i::Map* map);
|
| static bitset Lub(i::Object* value);
|
| @@ -669,18 +654,21 @@
|
| static void Print(bitset);
|
| #endif
|
|
|
| - static bitset NumberBits(bitset bits);
|
| -
|
| private:
|
| - struct Boundary {
|
| + struct BitsetMin{
|
| bitset bits;
|
| double min;
|
| };
|
| - static const Boundary BoundariesArray[];
|
| - static inline const Boundary* Boundaries();
|
| - static inline size_t BoundariesSize();
|
| -
|
| - static void CheckNumberBits(bitset bits);
|
| + static const BitsetMin BitsetMins31[];
|
| + static const BitsetMin BitsetMins32[];
|
| + static const BitsetMin* BitsetMins() {
|
| + return i::SmiValuesAre31Bits() ? BitsetMins31 : BitsetMins32;
|
| + }
|
| + static size_t BitsetMinsSize() {
|
| + return i::SmiValuesAre31Bits() ? 7 : 5;
|
| + /* arraysize(BitsetMins31) : arraysize(BitsetMins32); */
|
| + // Using arraysize here doesn't compile on Windows.
|
| + }
|
| };
|
|
|
|
|
| @@ -827,31 +815,25 @@
|
| template<class Config>
|
| class TypeImpl<Config>::RangeType : public StructuralType {
|
| public:
|
| - TypeHandle Bound() { return this->Get(0); }
|
| + int BitsetLub() { return this->Get(0)->AsBitset(); }
|
| i::Handle<i::Object> Min() { return this->template GetValue<i::Object>(1); }
|
| i::Handle<i::Object> Max() { return this->template GetValue<i::Object>(2); }
|
|
|
| - static RangeHandle New(i::Handle<i::Object> min, i::Handle<i::Object> max,
|
| - TypeHandle representation, Region* region) {
|
| + static RangeHandle New(
|
| + i::Handle<i::Object> min, i::Handle<i::Object> max, Region* region) {
|
| DCHECK(IsInteger(min->Number()) && IsInteger(max->Number()));
|
| DCHECK(min->Number() <= max->Number());
|
| - bitset representation_bits = representation->AsBitset();
|
| - DCHECK(REPRESENTATION(representation_bits) == representation_bits);
|
| -
|
| RangeHandle type = Config::template cast<RangeType>(
|
| StructuralType::New(StructuralType::kRangeTag, 3, region));
|
| -
|
| - bitset bits = SEMANTIC(BitsetType::Lub(min->Number(), max->Number())) |
|
| - representation_bits;
|
| - type->Set(0, BitsetType::New(bits, region));
|
| + type->Set(0, BitsetType::New(
|
| + BitsetType::Lub(min->Number(), max->Number()), region));
|
| type->SetValue(1, min);
|
| type->SetValue(2, max);
|
| return type;
|
| }
|
|
|
| static RangeHandle New(Limits lim, Region* region) {
|
| - return New(lim.min, lim.max, BitsetType::New(lim.representation, region),
|
| - region);
|
| + return New(lim.min, lim.max, region);
|
| }
|
|
|
| static RangeType* cast(TypeImpl* type) {
|
| @@ -1000,7 +982,6 @@
|
| static inline i::Handle<V> struct_get_value(Struct* structure, int i);
|
| template<class V> static inline void struct_set_value(
|
| Struct* structure, int i, i::Handle<V> x);
|
| - static inline i::Isolate* isolate(Zone* zone);
|
| };
|
|
|
| typedef TypeImpl<ZoneTypeConfig> Type;
|
| @@ -1049,7 +1030,6 @@
|
| template<class V>
|
| static inline void struct_set_value(
|
| i::Handle<Struct> structure, int i, i::Handle<V> x);
|
| - static inline i::Isolate* isolate(Isolate* isolate);
|
| };
|
|
|
| typedef TypeImpl<HeapTypeConfig> HeapType;
|
|
|