| Index: src/ast/ast-types.cc
|
| diff --git a/src/types.cc b/src/ast/ast-types.cc
|
| similarity index 70%
|
| copy from src/types.cc
|
| copy to src/ast/ast-types.cc
|
| index fae460757c73ee60d3e3af9db7ebbdb0a0e23406..aa861af035c3ce8521430ba07a7b60aabc4237b4 100644
|
| --- a/src/types.cc
|
| +++ b/src/ast/ast-types.cc
|
| @@ -4,7 +4,7 @@
|
|
|
| #include <iomanip>
|
|
|
| -#include "src/types.h"
|
| +#include "src/ast/ast-types.h"
|
|
|
| #include "src/handles-inl.h"
|
| #include "src/ostreams.h"
|
| @@ -12,21 +12,20 @@
|
| namespace v8 {
|
| namespace internal {
|
|
|
| -
|
| // NOTE: If code is marked as being a "shortcut", this means that removing
|
| // the code won't affect the semantics of the surrounding function definition.
|
|
|
| // static
|
| -bool Type::IsInteger(i::Object* x) {
|
| - return x->IsNumber() && Type::IsInteger(x->Number());
|
| +bool AstType::IsInteger(i::Object* x) {
|
| + return x->IsNumber() && AstType::IsInteger(x->Number());
|
| }
|
|
|
| // -----------------------------------------------------------------------------
|
| // Range-related helper functions.
|
|
|
| -bool RangeType::Limits::IsEmpty() { return this->min > this->max; }
|
| +bool AstRangeType::Limits::IsEmpty() { return this->min > this->max; }
|
|
|
| -RangeType::Limits RangeType::Limits::Intersect(Limits lhs, Limits rhs) {
|
| +AstRangeType::Limits AstRangeType::Limits::Intersect(Limits lhs, Limits rhs) {
|
| DisallowHeapAllocation no_allocation;
|
| Limits result(lhs);
|
| if (lhs.min < rhs.min) result.min = rhs.min;
|
| @@ -34,7 +33,7 @@ RangeType::Limits RangeType::Limits::Intersect(Limits lhs, Limits rhs) {
|
| return result;
|
| }
|
|
|
| -RangeType::Limits RangeType::Limits::Union(Limits lhs, Limits rhs) {
|
| +AstRangeType::Limits AstRangeType::Limits::Union(Limits lhs, Limits rhs) {
|
| DisallowHeapAllocation no_allocation;
|
| if (lhs.IsEmpty()) return rhs;
|
| if (rhs.IsEmpty()) return lhs;
|
| @@ -44,38 +43,36 @@ RangeType::Limits RangeType::Limits::Union(Limits lhs, Limits rhs) {
|
| return result;
|
| }
|
|
|
| -bool Type::Overlap(RangeType* lhs, RangeType* rhs) {
|
| +bool AstType::Overlap(AstRangeType* lhs, AstRangeType* rhs) {
|
| DisallowHeapAllocation no_allocation;
|
| - return !RangeType::Limits::Intersect(RangeType::Limits(lhs),
|
| - RangeType::Limits(rhs))
|
| + return !AstRangeType::Limits::Intersect(AstRangeType::Limits(lhs),
|
| + AstRangeType::Limits(rhs))
|
| .IsEmpty();
|
| }
|
|
|
| -bool Type::Contains(RangeType* lhs, RangeType* rhs) {
|
| +bool AstType::Contains(AstRangeType* lhs, AstRangeType* rhs) {
|
| DisallowHeapAllocation no_allocation;
|
| return lhs->Min() <= rhs->Min() && rhs->Max() <= lhs->Max();
|
| }
|
|
|
| -bool Type::Contains(RangeType* lhs, ConstantType* rhs) {
|
| +bool AstType::Contains(AstRangeType* lhs, AstConstantType* rhs) {
|
| DisallowHeapAllocation no_allocation;
|
| - return IsInteger(*rhs->Value()) &&
|
| - lhs->Min() <= rhs->Value()->Number() &&
|
| + return IsInteger(*rhs->Value()) && lhs->Min() <= rhs->Value()->Number() &&
|
| rhs->Value()->Number() <= lhs->Max();
|
| }
|
|
|
| -bool Type::Contains(RangeType* range, i::Object* val) {
|
| +bool AstType::Contains(AstRangeType* range, i::Object* val) {
|
| DisallowHeapAllocation no_allocation;
|
| - return IsInteger(val) &&
|
| - range->Min() <= val->Number() && val->Number() <= range->Max();
|
| + return IsInteger(val) && range->Min() <= val->Number() &&
|
| + val->Number() <= range->Max();
|
| }
|
|
|
| -
|
| // -----------------------------------------------------------------------------
|
| // Min and Max computation.
|
|
|
| -double Type::Min() {
|
| +double AstType::Min() {
|
| DCHECK(this->SemanticIs(Number()));
|
| - if (this->IsBitset()) return BitsetType::Min(this->AsBitset());
|
| + if (this->IsBitset()) return AstBitsetType::Min(this->AsBitset());
|
| if (this->IsUnion()) {
|
| double min = +V8_INFINITY;
|
| for (int i = 0, n = this->AsUnion()->Length(); i < n; ++i) {
|
| @@ -89,9 +86,9 @@ double Type::Min() {
|
| return 0;
|
| }
|
|
|
| -double Type::Max() {
|
| +double AstType::Max() {
|
| DCHECK(this->SemanticIs(Number()));
|
| - if (this->IsBitset()) return BitsetType::Max(this->AsBitset());
|
| + if (this->IsBitset()) return AstBitsetType::Max(this->AsBitset());
|
| if (this->IsUnion()) {
|
| double max = -V8_INFINITY;
|
| for (int i = 0, n = this->AsUnion()->Length(); i < n; ++i) {
|
| @@ -105,13 +102,11 @@ double Type::Max() {
|
| return 0;
|
| }
|
|
|
| -
|
| // -----------------------------------------------------------------------------
|
| // Glb and lub computation.
|
|
|
| -
|
| // The largest bitset subsumed by this type.
|
| -Type::bitset BitsetType::Glb(Type* type) {
|
| +AstType::bitset AstBitsetType::Glb(AstType* type) {
|
| DisallowHeapAllocation no_allocation;
|
| // Fast case.
|
| if (IsBitset(type)) {
|
| @@ -119,19 +114,18 @@ Type::bitset BitsetType::Glb(Type* type) {
|
| } else if (type->IsUnion()) {
|
| SLOW_DCHECK(type->AsUnion()->Wellformed());
|
| return type->AsUnion()->Get(0)->BitsetGlb() |
|
| - SEMANTIC(type->AsUnion()->Get(1)->BitsetGlb()); // Shortcut.
|
| + AST_SEMANTIC(type->AsUnion()->Get(1)->BitsetGlb()); // Shortcut.
|
| } else if (type->IsRange()) {
|
| - bitset glb = SEMANTIC(
|
| - BitsetType::Glb(type->AsRange()->Min(), type->AsRange()->Max()));
|
| - return glb | REPRESENTATION(type->BitsetLub());
|
| + bitset glb = AST_SEMANTIC(
|
| + AstBitsetType::Glb(type->AsRange()->Min(), type->AsRange()->Max()));
|
| + return glb | AST_REPRESENTATION(type->BitsetLub());
|
| } else {
|
| return type->Representation();
|
| }
|
| }
|
|
|
| -
|
| // The smallest bitset subsuming this type, possibly not a proper one.
|
| -Type::bitset BitsetType::Lub(Type* type) {
|
| +AstType::bitset AstBitsetType::Lub(AstType* type) {
|
| DisallowHeapAllocation no_allocation;
|
| if (IsBitset(type)) return type->AsBitset();
|
| if (type->IsUnion()) {
|
| @@ -140,7 +134,7 @@ Type::bitset BitsetType::Lub(Type* type) {
|
| int bitset = type->AsUnion()->Get(0)->BitsetLub();
|
| for (int i = 0, n = type->AsUnion()->Length(); i < n; ++i) {
|
| // Other elements only contribute their semantic part.
|
| - bitset |= SEMANTIC(type->AsUnion()->Get(i)->BitsetLub());
|
| + bitset |= AST_SEMANTIC(type->AsUnion()->Get(i)->BitsetLub());
|
| }
|
| return bitset;
|
| }
|
| @@ -155,7 +149,7 @@ Type::bitset BitsetType::Lub(Type* type) {
|
| return kNone;
|
| }
|
|
|
| -Type::bitset BitsetType::Lub(i::Map* map) {
|
| +AstType::bitset AstBitsetType::Lub(i::Map* map) {
|
| DisallowHeapAllocation no_allocation;
|
| switch (map->instance_type()) {
|
| case STRING_TYPE:
|
| @@ -286,16 +280,16 @@ Type::bitset BitsetType::Lub(i::Map* map) {
|
| return kNone;
|
| }
|
|
|
| -Type::bitset BitsetType::Lub(i::Object* value) {
|
| +AstType::bitset AstBitsetType::Lub(i::Object* value) {
|
| DisallowHeapAllocation no_allocation;
|
| if (value->IsNumber()) {
|
| return Lub(value->Number()) &
|
| - (value->IsSmi() ? kTaggedSigned : kTaggedPointer);
|
| + (value->IsSmi() ? kTaggedSigned : kTaggedPointer);
|
| }
|
| return Lub(i::HeapObject::cast(value)->map());
|
| }
|
|
|
| -Type::bitset BitsetType::Lub(double value) {
|
| +AstType::bitset AstBitsetType::Lub(double value) {
|
| DisallowHeapAllocation no_allocation;
|
| if (i::IsMinusZero(value)) return kMinusZero;
|
| if (std::isnan(value)) return kNaN;
|
| @@ -303,9 +297,8 @@ Type::bitset BitsetType::Lub(double value) {
|
| return kOtherNumber;
|
| }
|
|
|
| -
|
| // Minimum values of plain numeric bitsets.
|
| -const BitsetType::Boundary BitsetType::BoundariesArray[] = {
|
| +const AstBitsetType::Boundary AstBitsetType::BoundariesArray[] = {
|
| {kOtherNumber, kPlainNumber, -V8_INFINITY},
|
| {kOtherSigned32, kNegative32, kMinInt},
|
| {kNegative31, kNegative31, -0x40000000},
|
| @@ -314,45 +307,47 @@ const BitsetType::Boundary BitsetType::BoundariesArray[] = {
|
| {kOtherUnsigned32, kUnsigned32, 0x80000000},
|
| {kOtherNumber, kPlainNumber, static_cast<double>(kMaxUInt32) + 1}};
|
|
|
| -const BitsetType::Boundary* BitsetType::Boundaries() { return BoundariesArray; }
|
| +const AstBitsetType::Boundary* AstBitsetType::Boundaries() {
|
| + return BoundariesArray;
|
| +}
|
|
|
| -size_t BitsetType::BoundariesSize() {
|
| +size_t AstBitsetType::BoundariesSize() {
|
| // Windows doesn't like arraysize here.
|
| // return arraysize(BoundariesArray);
|
| return 7;
|
| }
|
|
|
| -Type::bitset BitsetType::ExpandInternals(Type::bitset bits) {
|
| +AstType::bitset AstBitsetType::ExpandInternals(AstType::bitset bits) {
|
| DisallowHeapAllocation no_allocation;
|
| - if (!(bits & SEMANTIC(kPlainNumber))) return bits; // Shortcut.
|
| + if (!(bits & AST_SEMANTIC(kPlainNumber))) return bits; // Shortcut.
|
| const Boundary* boundaries = Boundaries();
|
| for (size_t i = 0; i < BoundariesSize(); ++i) {
|
| - DCHECK(BitsetType::Is(boundaries[i].internal, boundaries[i].external));
|
| - if (bits & SEMANTIC(boundaries[i].internal))
|
| - bits |= SEMANTIC(boundaries[i].external);
|
| + DCHECK(AstBitsetType::Is(boundaries[i].internal, boundaries[i].external));
|
| + if (bits & AST_SEMANTIC(boundaries[i].internal))
|
| + bits |= AST_SEMANTIC(boundaries[i].external);
|
| }
|
| return bits;
|
| }
|
|
|
| -Type::bitset BitsetType::Lub(double min, double max) {
|
| +AstType::bitset AstBitsetType::Lub(double min, double max) {
|
| DisallowHeapAllocation no_allocation;
|
| int lub = kNone;
|
| const Boundary* mins = Boundaries();
|
|
|
| for (size_t i = 1; i < BoundariesSize(); ++i) {
|
| if (min < mins[i].min) {
|
| - lub |= mins[i-1].internal;
|
| + lub |= mins[i - 1].internal;
|
| if (max < mins[i].min) return lub;
|
| }
|
| }
|
| return lub | mins[BoundariesSize() - 1].internal;
|
| }
|
|
|
| -Type::bitset BitsetType::NumberBits(bitset bits) {
|
| - return SEMANTIC(bits & kPlainNumber);
|
| +AstType::bitset AstBitsetType::NumberBits(bitset bits) {
|
| + return AST_SEMANTIC(bits & kPlainNumber);
|
| }
|
|
|
| -Type::bitset BitsetType::Glb(double min, double max) {
|
| +AstType::bitset AstBitsetType::Glb(double min, double max) {
|
| DisallowHeapAllocation no_allocation;
|
| int glb = kNone;
|
| const Boundary* mins = Boundaries();
|
| @@ -368,16 +363,16 @@ Type::bitset BitsetType::Glb(double min, double max) {
|
| }
|
| // OtherNumber also contains float numbers, so it can never be
|
| // in the greatest lower bound.
|
| - return glb & ~(SEMANTIC(kOtherNumber));
|
| + return glb & ~(AST_SEMANTIC(kOtherNumber));
|
| }
|
|
|
| -double BitsetType::Min(bitset bits) {
|
| +double AstBitsetType::Min(bitset bits) {
|
| DisallowHeapAllocation no_allocation;
|
| - DCHECK(Is(SEMANTIC(bits), kNumber));
|
| + DCHECK(Is(AST_SEMANTIC(bits), kNumber));
|
| const Boundary* mins = Boundaries();
|
| - bool mz = SEMANTIC(bits & kMinusZero);
|
| + bool mz = AST_SEMANTIC(bits & kMinusZero);
|
| for (size_t i = 0; i < BoundariesSize(); ++i) {
|
| - if (Is(SEMANTIC(mins[i].internal), bits)) {
|
| + if (Is(AST_SEMANTIC(mins[i].internal), bits)) {
|
| return mz ? std::min(0.0, mins[i].min) : mins[i].min;
|
| }
|
| }
|
| @@ -385,50 +380,49 @@ double BitsetType::Min(bitset bits) {
|
| return std::numeric_limits<double>::quiet_NaN();
|
| }
|
|
|
| -double BitsetType::Max(bitset bits) {
|
| +double AstBitsetType::Max(bitset bits) {
|
| DisallowHeapAllocation no_allocation;
|
| - DCHECK(Is(SEMANTIC(bits), kNumber));
|
| + DCHECK(Is(AST_SEMANTIC(bits), kNumber));
|
| const Boundary* mins = Boundaries();
|
| - bool mz = SEMANTIC(bits & kMinusZero);
|
| - if (BitsetType::Is(SEMANTIC(mins[BoundariesSize() - 1].internal), bits)) {
|
| + bool mz = AST_SEMANTIC(bits & kMinusZero);
|
| + if (AstBitsetType::Is(AST_SEMANTIC(mins[BoundariesSize() - 1].internal),
|
| + bits)) {
|
| return +V8_INFINITY;
|
| }
|
| for (size_t i = BoundariesSize() - 1; i-- > 0;) {
|
| - if (Is(SEMANTIC(mins[i].internal), bits)) {
|
| - return mz ?
|
| - std::max(0.0, mins[i+1].min - 1) : mins[i+1].min - 1;
|
| + if (Is(AST_SEMANTIC(mins[i].internal), bits)) {
|
| + return mz ? std::max(0.0, mins[i + 1].min - 1) : mins[i + 1].min - 1;
|
| }
|
| }
|
| if (mz) return 0;
|
| return std::numeric_limits<double>::quiet_NaN();
|
| }
|
|
|
| -
|
| // -----------------------------------------------------------------------------
|
| // Predicates.
|
|
|
| -bool Type::SimplyEquals(Type* that) {
|
| +bool AstType::SimplyEquals(AstType* that) {
|
| DisallowHeapAllocation no_allocation;
|
| if (this->IsClass()) {
|
| - return that->IsClass()
|
| - && *this->AsClass()->Map() == *that->AsClass()->Map();
|
| + return that->IsClass() &&
|
| + *this->AsClass()->Map() == *that->AsClass()->Map();
|
| }
|
| if (this->IsConstant()) {
|
| - return that->IsConstant()
|
| - && *this->AsConstant()->Value() == *that->AsConstant()->Value();
|
| + return that->IsConstant() &&
|
| + *this->AsConstant()->Value() == *that->AsConstant()->Value();
|
| }
|
| if (this->IsContext()) {
|
| - return that->IsContext()
|
| - && this->AsContext()->Outer()->Equals(that->AsContext()->Outer());
|
| + return that->IsContext() &&
|
| + this->AsContext()->Outer()->Equals(that->AsContext()->Outer());
|
| }
|
| if (this->IsArray()) {
|
| - return that->IsArray()
|
| - && this->AsArray()->Element()->Equals(that->AsArray()->Element());
|
| + return that->IsArray() &&
|
| + this->AsArray()->Element()->Equals(that->AsArray()->Element());
|
| }
|
| if (this->IsFunction()) {
|
| if (!that->IsFunction()) return false;
|
| - FunctionType* this_fun = this->AsFunction();
|
| - FunctionType* that_fun = that->AsFunction();
|
| + AstFunctionType* this_fun = this->AsFunction();
|
| + AstFunctionType* that_fun = that->AsFunction();
|
| if (this_fun->Arity() != that_fun->Arity() ||
|
| !this_fun->Result()->Equals(that_fun->Result()) ||
|
| !this_fun->Receiver()->Equals(that_fun->Receiver())) {
|
| @@ -441,8 +435,8 @@ bool Type::SimplyEquals(Type* that) {
|
| }
|
| if (this->IsTuple()) {
|
| if (!that->IsTuple()) return false;
|
| - TupleType* this_tuple = this->AsTuple();
|
| - TupleType* that_tuple = that->AsTuple();
|
| + AstTupleType* this_tuple = this->AsTuple();
|
| + AstTupleType* that_tuple = that->AsTuple();
|
| if (this_tuple->Arity() != that_tuple->Arity()) {
|
| return false;
|
| }
|
| @@ -455,26 +449,25 @@ bool Type::SimplyEquals(Type* that) {
|
| return false;
|
| }
|
|
|
| -Type::bitset Type::Representation() {
|
| - return REPRESENTATION(this->BitsetLub());
|
| +AstType::bitset AstType::Representation() {
|
| + return AST_REPRESENTATION(this->BitsetLub());
|
| }
|
|
|
| -
|
| // Check if [this] <= [that].
|
| -bool Type::SlowIs(Type* that) {
|
| +bool AstType::SlowIs(AstType* that) {
|
| DisallowHeapAllocation no_allocation;
|
|
|
| // Fast bitset cases
|
| if (that->IsBitset()) {
|
| - return BitsetType::Is(this->BitsetLub(), that->AsBitset());
|
| + return AstBitsetType::Is(this->BitsetLub(), that->AsBitset());
|
| }
|
|
|
| if (this->IsBitset()) {
|
| - return BitsetType::Is(this->AsBitset(), that->BitsetGlb());
|
| + return AstBitsetType::Is(this->AsBitset(), that->BitsetGlb());
|
| }
|
|
|
| // Check the representations.
|
| - if (!BitsetType::Is(Representation(), that->Representation())) {
|
| + if (!AstBitsetType::Is(Representation(), that->Representation())) {
|
| return false;
|
| }
|
|
|
| @@ -482,19 +475,19 @@ bool Type::SlowIs(Type* that) {
|
| return SemanticIs(that);
|
| }
|
|
|
| -
|
| -// Check if SEMANTIC([this]) <= SEMANTIC([that]). The result of the method
|
| +// Check if AST_SEMANTIC([this]) <= AST_SEMANTIC([that]). The result of the
|
| +// method
|
| // should be independent of the representation axis of the types.
|
| -bool Type::SemanticIs(Type* that) {
|
| +bool AstType::SemanticIs(AstType* that) {
|
| DisallowHeapAllocation no_allocation;
|
|
|
| if (this == that) return true;
|
|
|
| if (that->IsBitset()) {
|
| - return BitsetType::Is(SEMANTIC(this->BitsetLub()), that->AsBitset());
|
| + return AstBitsetType::Is(AST_SEMANTIC(this->BitsetLub()), that->AsBitset());
|
| }
|
| if (this->IsBitset()) {
|
| - return BitsetType::Is(SEMANTIC(this->AsBitset()), that->BitsetGlb());
|
| + return AstBitsetType::Is(AST_SEMANTIC(this->AsBitset()), that->BitsetGlb());
|
| }
|
|
|
| // (T1 \/ ... \/ Tn) <= T if (T1 <= T) /\ ... /\ (Tn <= T)
|
| @@ -525,7 +518,7 @@ bool Type::SemanticIs(Type* that) {
|
| }
|
|
|
| // Most precise _current_ type of a value (usually its class).
|
| -Type* Type::NowOf(i::Object* value, Zone* zone) {
|
| +AstType* AstType::NowOf(i::Object* value, Zone* zone) {
|
| if (value->IsSmi() ||
|
| i::HeapObject::cast(value)->map()->instance_type() == HEAP_NUMBER_TYPE) {
|
| return Of(value, zone);
|
| @@ -533,7 +526,7 @@ Type* Type::NowOf(i::Object* value, Zone* zone) {
|
| return Class(i::handle(i::HeapObject::cast(value)->map()), zone);
|
| }
|
|
|
| -bool Type::NowContains(i::Object* value) {
|
| +bool AstType::NowContains(i::Object* value) {
|
| DisallowHeapAllocation no_allocation;
|
| if (this->IsAny()) return true;
|
| if (value->IsHeapObject()) {
|
| @@ -545,7 +538,7 @@ bool Type::NowContains(i::Object* value) {
|
| return this->Contains(value);
|
| }
|
|
|
| -bool Type::NowIs(Type* that) {
|
| +bool AstType::NowIs(AstType* that) {
|
| DisallowHeapAllocation no_allocation;
|
|
|
| // TODO(rossberg): this is incorrect for
|
| @@ -563,27 +556,25 @@ bool Type::NowIs(Type* that) {
|
| return this->Is(that);
|
| }
|
|
|
| -
|
| // Check if [this] contains only (currently) stable classes.
|
| -bool Type::NowStable() {
|
| +bool AstType::NowStable() {
|
| DisallowHeapAllocation no_allocation;
|
| return !this->IsClass() || this->AsClass()->Map()->is_stable();
|
| }
|
|
|
| -
|
| // Check if [this] and [that] overlap.
|
| -bool Type::Maybe(Type* that) {
|
| +bool AstType::Maybe(AstType* that) {
|
| DisallowHeapAllocation no_allocation;
|
|
|
| // Take care of the representation part (and also approximate
|
| // the semantic part).
|
| - if (!BitsetType::IsInhabited(this->BitsetLub() & that->BitsetLub()))
|
| + if (!AstBitsetType::IsInhabited(this->BitsetLub() & that->BitsetLub()))
|
| return false;
|
|
|
| return SemanticMaybe(that);
|
| }
|
|
|
| -bool Type::SemanticMaybe(Type* that) {
|
| +bool AstType::SemanticMaybe(AstType* that) {
|
| DisallowHeapAllocation no_allocation;
|
|
|
| // (T1 \/ ... \/ Tn) overlaps T if (T1 overlaps T) \/ ... \/ (Tn overlaps T)
|
| @@ -602,7 +593,8 @@ bool Type::SemanticMaybe(Type* that) {
|
| return false;
|
| }
|
|
|
| - if (!BitsetType::SemanticIsInhabited(this->BitsetLub() & that->BitsetLub()))
|
| + if (!AstBitsetType::SemanticIsInhabited(this->BitsetLub() &
|
| + that->BitsetLub()))
|
| return false;
|
|
|
| if (this->IsBitset() && that->IsBitset()) return true;
|
| @@ -617,12 +609,12 @@ bool Type::SemanticMaybe(Type* that) {
|
| return Overlap(this->AsRange(), that->AsRange());
|
| }
|
| if (that->IsBitset()) {
|
| - bitset number_bits = BitsetType::NumberBits(that->AsBitset());
|
| - if (number_bits == BitsetType::kNone) {
|
| + bitset number_bits = AstBitsetType::NumberBits(that->AsBitset());
|
| + if (number_bits == AstBitsetType::kNone) {
|
| return false;
|
| }
|
| - double min = std::max(BitsetType::Min(number_bits), this->Min());
|
| - double max = std::min(BitsetType::Max(number_bits), this->Max());
|
| + double min = std::max(AstBitsetType::Min(number_bits), this->Min());
|
| + double max = std::min(AstBitsetType::Max(number_bits), this->Max());
|
| return min <= max;
|
| }
|
| }
|
| @@ -635,9 +627,8 @@ bool Type::SemanticMaybe(Type* that) {
|
| return this->SimplyEquals(that);
|
| }
|
|
|
| -
|
| // Return the range in [this], or [NULL].
|
| -Type* Type::GetRange() {
|
| +AstType* AstType::GetRange() {
|
| DisallowHeapAllocation no_allocation;
|
| if (this->IsRange()) return this;
|
| if (this->IsUnion() && this->AsUnion()->Get(1)->IsRange()) {
|
| @@ -646,19 +637,19 @@ Type* Type::GetRange() {
|
| return NULL;
|
| }
|
|
|
| -bool Type::Contains(i::Object* value) {
|
| +bool AstType::Contains(i::Object* value) {
|
| DisallowHeapAllocation no_allocation;
|
| for (Iterator<i::Object> it = this->Constants(); !it.Done(); it.Advance()) {
|
| if (*it.Current() == value) return true;
|
| }
|
| if (IsInteger(value)) {
|
| - Type* range = this->GetRange();
|
| + AstType* range = this->GetRange();
|
| if (range != NULL && Contains(range->AsRange(), value)) return true;
|
| }
|
| - return BitsetType::New(BitsetType::Lub(value))->Is(this);
|
| + return AstBitsetType::New(AstBitsetType::Lub(value))->Is(this);
|
| }
|
|
|
| -bool UnionType::Wellformed() {
|
| +bool AstUnionType::Wellformed() {
|
| DisallowHeapAllocation no_allocation;
|
| // This checks the invariants of the union representation:
|
| // 1. There are at least two elements.
|
| @@ -668,7 +659,7 @@ bool UnionType::Wellformed() {
|
| // 5. No element (except the bitset) is a subtype of any other.
|
| // 6. If there is a range, then the bitset type does not contain
|
| // plain number bits.
|
| - DCHECK(this->Length() >= 2); // (1)
|
| + DCHECK(this->Length() >= 2); // (1)
|
| DCHECK(this->Get(0)->IsBitset()); // (2a)
|
|
|
| for (int i = 0; i < this->Length(); ++i) {
|
| @@ -681,26 +672,23 @@ bool UnionType::Wellformed() {
|
| }
|
| }
|
| DCHECK(!this->Get(1)->IsRange() ||
|
| - (BitsetType::NumberBits(this->Get(0)->AsBitset()) ==
|
| - BitsetType::kNone)); // (6)
|
| + (AstBitsetType::NumberBits(this->Get(0)->AsBitset()) ==
|
| + AstBitsetType::kNone)); // (6)
|
| return true;
|
| }
|
|
|
| -
|
| // -----------------------------------------------------------------------------
|
| // Union and intersection
|
|
|
| -
|
| static bool AddIsSafe(int x, int y) {
|
| - return x >= 0 ?
|
| - y <= std::numeric_limits<int>::max() - x :
|
| - y >= std::numeric_limits<int>::min() - x;
|
| + return x >= 0 ? y <= std::numeric_limits<int>::max() - x
|
| + : y >= std::numeric_limits<int>::min() - x;
|
| }
|
|
|
| -Type* Type::Intersect(Type* type1, Type* type2, Zone* zone) {
|
| +AstType* AstType::Intersect(AstType* type1, AstType* type2, Zone* zone) {
|
| // Fast case: bit sets.
|
| if (type1->IsBitset() && type2->IsBitset()) {
|
| - return BitsetType::New(type1->AsBitset() & type2->AsBitset());
|
| + return AstBitsetType::New(type1->AsBitset() & type2->AsBitset());
|
| }
|
|
|
| // Fast case: top or bottom types.
|
| @@ -731,38 +719,39 @@ Type* Type::Intersect(Type* type1, Type* type2, Zone* zone) {
|
| }
|
|
|
| bitset bits =
|
| - SEMANTIC(type1->BitsetGlb() & type2->BitsetGlb()) | representation;
|
| + AST_SEMANTIC(type1->BitsetGlb() & type2->BitsetGlb()) | representation;
|
| int size1 = type1->IsUnion() ? type1->AsUnion()->Length() : 1;
|
| int size2 = type2->IsUnion() ? type2->AsUnion()->Length() : 1;
|
| if (!AddIsSafe(size1, size2)) return Any();
|
| int size = size1 + size2;
|
| if (!AddIsSafe(size, 2)) return Any();
|
| size += 2;
|
| - Type* result_type = UnionType::New(size, zone);
|
| - UnionType* result = result_type->AsUnion();
|
| + AstType* result_type = AstUnionType::New(size, zone);
|
| + AstUnionType* result = result_type->AsUnion();
|
| size = 0;
|
|
|
| // Deal with bitsets.
|
| - result->Set(size++, BitsetType::New(bits));
|
| + result->Set(size++, AstBitsetType::New(bits));
|
|
|
| - RangeType::Limits lims = RangeType::Limits::Empty();
|
| + AstRangeType::Limits lims = AstRangeType::Limits::Empty();
|
| size = IntersectAux(type1, type2, result, size, &lims, zone);
|
|
|
| // If the range is not empty, then insert it into the union and
|
| // remove the number bits from the bitset.
|
| if (!lims.IsEmpty()) {
|
| - size = UpdateRange(RangeType::New(lims, representation, zone), result, size,
|
| - zone);
|
| + size = UpdateRange(AstRangeType::New(lims, representation, zone), result,
|
| + size, zone);
|
|
|
| // Remove the number bits.
|
| - bitset number_bits = BitsetType::NumberBits(bits);
|
| + bitset number_bits = AstBitsetType::NumberBits(bits);
|
| bits &= ~number_bits;
|
| - result->Set(0, BitsetType::New(bits));
|
| + result->Set(0, AstBitsetType::New(bits));
|
| }
|
| return NormalizeUnion(result_type, size, zone);
|
| }
|
|
|
| -int Type::UpdateRange(Type* range, UnionType* result, int size, Zone* zone) {
|
| +int AstType::UpdateRange(AstType* range, AstUnionType* result, int size,
|
| + Zone* zone) {
|
| if (size == 1) {
|
| result->Set(size++, range);
|
| } else {
|
| @@ -772,7 +761,7 @@ int Type::UpdateRange(Type* range, UnionType* result, int size, Zone* zone) {
|
| }
|
|
|
| // Remove any components that just got subsumed.
|
| - for (int i = 2; i < size; ) {
|
| + for (int i = 2; i < size;) {
|
| if (result->Get(i)->SemanticIs(range)) {
|
| result->Set(i, result->Get(--size));
|
| } else {
|
| @@ -782,26 +771,27 @@ int Type::UpdateRange(Type* range, UnionType* result, int size, Zone* zone) {
|
| return size;
|
| }
|
|
|
| -RangeType::Limits Type::ToLimits(bitset bits, Zone* zone) {
|
| - bitset number_bits = BitsetType::NumberBits(bits);
|
| +AstRangeType::Limits AstType::ToLimits(bitset bits, Zone* zone) {
|
| + bitset number_bits = AstBitsetType::NumberBits(bits);
|
|
|
| - if (number_bits == BitsetType::kNone) {
|
| - return RangeType::Limits::Empty();
|
| + if (number_bits == AstBitsetType::kNone) {
|
| + return AstRangeType::Limits::Empty();
|
| }
|
|
|
| - return RangeType::Limits(BitsetType::Min(number_bits),
|
| - BitsetType::Max(number_bits));
|
| + return AstRangeType::Limits(AstBitsetType::Min(number_bits),
|
| + AstBitsetType::Max(number_bits));
|
| }
|
|
|
| -RangeType::Limits Type::IntersectRangeAndBitset(Type* range, Type* bitset,
|
| - Zone* zone) {
|
| - RangeType::Limits range_lims(range->AsRange());
|
| - RangeType::Limits bitset_lims = ToLimits(bitset->AsBitset(), zone);
|
| - return RangeType::Limits::Intersect(range_lims, bitset_lims);
|
| +AstRangeType::Limits AstType::IntersectRangeAndBitset(AstType* range,
|
| + AstType* bitset,
|
| + Zone* zone) {
|
| + AstRangeType::Limits range_lims(range->AsRange());
|
| + AstRangeType::Limits bitset_lims = ToLimits(bitset->AsBitset(), zone);
|
| + return AstRangeType::Limits::Intersect(range_lims, bitset_lims);
|
| }
|
|
|
| -int Type::IntersectAux(Type* lhs, Type* rhs, UnionType* result, int size,
|
| - RangeType::Limits* lims, Zone* zone) {
|
| +int AstType::IntersectAux(AstType* lhs, AstType* rhs, AstUnionType* result,
|
| + int size, AstRangeType::Limits* lims, Zone* zone) {
|
| if (lhs->IsUnion()) {
|
| for (int i = 0, n = lhs->AsUnion()->Length(); i < n; ++i) {
|
| size =
|
| @@ -817,31 +807,33 @@ int Type::IntersectAux(Type* lhs, Type* rhs, UnionType* result, int size,
|
| return size;
|
| }
|
|
|
| - if (!BitsetType::SemanticIsInhabited(lhs->BitsetLub() & rhs->BitsetLub())) {
|
| + if (!AstBitsetType::SemanticIsInhabited(lhs->BitsetLub() &
|
| + rhs->BitsetLub())) {
|
| return size;
|
| }
|
|
|
| if (lhs->IsRange()) {
|
| if (rhs->IsBitset()) {
|
| - RangeType::Limits lim = IntersectRangeAndBitset(lhs, rhs, zone);
|
| + AstRangeType::Limits lim = IntersectRangeAndBitset(lhs, rhs, zone);
|
|
|
| if (!lim.IsEmpty()) {
|
| - *lims = RangeType::Limits::Union(lim, *lims);
|
| + *lims = AstRangeType::Limits::Union(lim, *lims);
|
| }
|
| return size;
|
| }
|
| if (rhs->IsClass()) {
|
| - *lims =
|
| - RangeType::Limits::Union(RangeType::Limits(lhs->AsRange()), *lims);
|
| + *lims = AstRangeType::Limits::Union(AstRangeType::Limits(lhs->AsRange()),
|
| + *lims);
|
| }
|
| if (rhs->IsConstant() && Contains(lhs->AsRange(), rhs->AsConstant())) {
|
| return AddToUnion(rhs, result, size, zone);
|
| }
|
| if (rhs->IsRange()) {
|
| - RangeType::Limits lim = RangeType::Limits::Intersect(
|
| - RangeType::Limits(lhs->AsRange()), RangeType::Limits(rhs->AsRange()));
|
| + AstRangeType::Limits lim =
|
| + AstRangeType::Limits::Intersect(AstRangeType::Limits(lhs->AsRange()),
|
| + AstRangeType::Limits(rhs->AsRange()));
|
| if (!lim.IsEmpty()) {
|
| - *lims = RangeType::Limits::Union(lim, *lims);
|
| + *lims = AstRangeType::Limits::Union(lim, *lims);
|
| }
|
| }
|
| return size;
|
| @@ -862,29 +854,29 @@ int Type::IntersectAux(Type* lhs, Type* rhs, UnionType* result, int size,
|
| return size;
|
| }
|
|
|
| -
|
| // Make sure that we produce a well-formed range and bitset:
|
| // If the range is non-empty, the number bits in the bitset should be
|
| // clear. Moreover, if we have a canonical range (such as Signed32),
|
| // we want to produce a bitset rather than a range.
|
| -Type* Type::NormalizeRangeAndBitset(Type* range, bitset* bits, Zone* zone) {
|
| +AstType* AstType::NormalizeRangeAndBitset(AstType* range, bitset* bits,
|
| + Zone* zone) {
|
| // Fast path: If the bitset does not mention numbers, we can just keep the
|
| // range.
|
| - bitset number_bits = BitsetType::NumberBits(*bits);
|
| + bitset number_bits = AstBitsetType::NumberBits(*bits);
|
| if (number_bits == 0) {
|
| return range;
|
| }
|
|
|
| // If the range is semantically contained within the bitset, return None and
|
| // leave the bitset untouched.
|
| - bitset range_lub = SEMANTIC(range->BitsetLub());
|
| - if (BitsetType::Is(range_lub, *bits)) {
|
| + bitset range_lub = AST_SEMANTIC(range->BitsetLub());
|
| + if (AstBitsetType::Is(range_lub, *bits)) {
|
| return None();
|
| }
|
|
|
| // Slow path: reconcile the bitset range and the range.
|
| - double bitset_min = BitsetType::Min(number_bits);
|
| - double bitset_max = BitsetType::Max(number_bits);
|
| + double bitset_min = AstBitsetType::Min(number_bits);
|
| + double bitset_max = AstBitsetType::Max(number_bits);
|
|
|
| double range_min = range->Min();
|
| double range_max = range->Max();
|
| @@ -905,13 +897,13 @@ Type* Type::NormalizeRangeAndBitset(Type* range, bitset* bits, Zone* zone) {
|
| if (bitset_max > range_max) {
|
| range_max = bitset_max;
|
| }
|
| - return RangeType::New(range_min, range_max, BitsetType::kNone, zone);
|
| + return AstRangeType::New(range_min, range_max, AstBitsetType::kNone, zone);
|
| }
|
|
|
| -Type* Type::Union(Type* type1, Type* type2, Zone* zone) {
|
| +AstType* AstType::Union(AstType* type1, AstType* type2, Zone* zone) {
|
| // Fast case: bit sets.
|
| if (type1->IsBitset() && type2->IsBitset()) {
|
| - return BitsetType::New(type1->AsBitset() | type2->AsBitset());
|
| + return AstBitsetType::New(type1->AsBitset() | type2->AsBitset());
|
| }
|
|
|
| // Fast case: top or bottom types.
|
| @@ -936,30 +928,30 @@ Type* Type::Union(Type* type1, Type* type2, Zone* zone) {
|
| int size = size1 + size2;
|
| if (!AddIsSafe(size, 2)) return Any();
|
| size += 2;
|
| - Type* result_type = UnionType::New(size, zone);
|
| - UnionType* result = result_type->AsUnion();
|
| + AstType* result_type = AstUnionType::New(size, zone);
|
| + AstUnionType* result = result_type->AsUnion();
|
| size = 0;
|
|
|
| // Compute the new bitset.
|
| - bitset new_bitset = SEMANTIC(type1->BitsetGlb() | type2->BitsetGlb());
|
| + bitset new_bitset = AST_SEMANTIC(type1->BitsetGlb() | type2->BitsetGlb());
|
|
|
| // Deal with ranges.
|
| - Type* range = None();
|
| - Type* range1 = type1->GetRange();
|
| - Type* range2 = type2->GetRange();
|
| + AstType* range = None();
|
| + AstType* range1 = type1->GetRange();
|
| + AstType* range2 = type2->GetRange();
|
| if (range1 != NULL && range2 != NULL) {
|
| - RangeType::Limits lims =
|
| - RangeType::Limits::Union(RangeType::Limits(range1->AsRange()),
|
| - RangeType::Limits(range2->AsRange()));
|
| - Type* union_range = RangeType::New(lims, representation, zone);
|
| + AstRangeType::Limits lims =
|
| + AstRangeType::Limits::Union(AstRangeType::Limits(range1->AsRange()),
|
| + AstRangeType::Limits(range2->AsRange()));
|
| + AstType* union_range = AstRangeType::New(lims, representation, zone);
|
| range = NormalizeRangeAndBitset(union_range, &new_bitset, zone);
|
| } else if (range1 != NULL) {
|
| range = NormalizeRangeAndBitset(range1, &new_bitset, zone);
|
| } else if (range2 != NULL) {
|
| range = NormalizeRangeAndBitset(range2, &new_bitset, zone);
|
| }
|
| - new_bitset = SEMANTIC(new_bitset) | representation;
|
| - Type* bits = BitsetType::New(new_bitset);
|
| + new_bitset = AST_SEMANTIC(new_bitset) | representation;
|
| + AstType* bits = AstBitsetType::New(new_bitset);
|
| result->Set(size++, bits);
|
| if (!range->IsNone()) result->Set(size++, range);
|
|
|
| @@ -968,10 +960,10 @@ Type* Type::Union(Type* type1, Type* type2, Zone* zone) {
|
| return NormalizeUnion(result_type, size, zone);
|
| }
|
|
|
| -
|
| // Add [type] to [result] unless [type] is bitset, range, or already subsumed.
|
| // Return new size of [result].
|
| -int Type::AddToUnion(Type* type, UnionType* result, int size, Zone* zone) {
|
| +int AstType::AddToUnion(AstType* type, AstUnionType* result, int size,
|
| + Zone* zone) {
|
| if (type->IsBitset() || type->IsRange()) return size;
|
| if (type->IsUnion()) {
|
| for (int i = 0, n = type->AsUnion()->Length(); i < n; ++i) {
|
| @@ -986,8 +978,8 @@ int Type::AddToUnion(Type* type, UnionType* result, int size, Zone* zone) {
|
| return size;
|
| }
|
|
|
| -Type* Type::NormalizeUnion(Type* union_type, int size, Zone* zone) {
|
| - UnionType* unioned = union_type->AsUnion();
|
| +AstType* AstType::NormalizeUnion(AstType* union_type, int size, Zone* zone) {
|
| + AstUnionType* unioned = union_type->AsUnion();
|
| DCHECK(size >= 1);
|
| DCHECK(unioned->Get(0)->IsBitset());
|
| // If the union has just one element, return it.
|
| @@ -996,15 +988,15 @@ Type* Type::NormalizeUnion(Type* union_type, int size, Zone* zone) {
|
| }
|
| bitset bits = unioned->Get(0)->AsBitset();
|
| // If the union only consists of a range, we can get rid of the union.
|
| - if (size == 2 && SEMANTIC(bits) == BitsetType::kNone) {
|
| - bitset representation = REPRESENTATION(bits);
|
| + if (size == 2 && AST_SEMANTIC(bits) == AstBitsetType::kNone) {
|
| + bitset representation = AST_REPRESENTATION(bits);
|
| if (representation == unioned->Get(1)->Representation()) {
|
| return unioned->Get(1);
|
| }
|
| if (unioned->Get(1)->IsRange()) {
|
| - return RangeType::New(unioned->Get(1)->AsRange()->Min(),
|
| - unioned->Get(1)->AsRange()->Max(),
|
| - unioned->Get(0)->AsBitset(), zone);
|
| + return AstRangeType::New(unioned->Get(1)->AsRange()->Min(),
|
| + unioned->Get(1)->AsRange()->Max(),
|
| + unioned->Get(0)->AsBitset(), zone);
|
| }
|
| }
|
| unioned->Shrink(size);
|
| @@ -1012,26 +1004,23 @@ Type* Type::NormalizeUnion(Type* union_type, int size, Zone* zone) {
|
| return union_type;
|
| }
|
|
|
| -
|
| // -----------------------------------------------------------------------------
|
| // Component extraction
|
|
|
| // static
|
| -Type* Type::Representation(Type* t, Zone* zone) {
|
| - return BitsetType::New(t->Representation());
|
| +AstType* AstType::Representation(AstType* t, Zone* zone) {
|
| + return AstBitsetType::New(t->Representation());
|
| }
|
|
|
| -
|
| // static
|
| -Type* Type::Semantic(Type* t, Zone* zone) {
|
| - return Intersect(t, BitsetType::New(BitsetType::kSemantic), zone);
|
| +AstType* AstType::Semantic(AstType* t, Zone* zone) {
|
| + return Intersect(t, AstBitsetType::New(AstBitsetType::kSemantic), zone);
|
| }
|
|
|
| -
|
| // -----------------------------------------------------------------------------
|
| // Iteration.
|
|
|
| -int Type::NumClasses() {
|
| +int AstType::NumClasses() {
|
| DisallowHeapAllocation no_allocation;
|
| if (this->IsClass()) {
|
| return 1;
|
| @@ -1046,7 +1035,7 @@ int Type::NumClasses() {
|
| }
|
| }
|
|
|
| -int Type::NumConstants() {
|
| +int AstType::NumConstants() {
|
| DisallowHeapAllocation no_allocation;
|
| if (this->IsConstant()) {
|
| return 1;
|
| @@ -1062,48 +1051,47 @@ int Type::NumConstants() {
|
| }
|
|
|
| template <class T>
|
| -Type* Type::Iterator<T>::get_type() {
|
| +AstType* AstType::Iterator<T>::get_type() {
|
| DCHECK(!Done());
|
| return type_->IsUnion() ? type_->AsUnion()->Get(index_) : type_;
|
| }
|
|
|
| -
|
| // C++ cannot specialise nested templates, so we have to go through this
|
| // contortion with an auxiliary template to simulate it.
|
| template <class T>
|
| struct TypeImplIteratorAux {
|
| - static bool matches(Type* type);
|
| - static i::Handle<T> current(Type* type);
|
| + static bool matches(AstType* type);
|
| + static i::Handle<T> current(AstType* type);
|
| };
|
|
|
| template <>
|
| struct TypeImplIteratorAux<i::Map> {
|
| - static bool matches(Type* type) { return type->IsClass(); }
|
| - static i::Handle<i::Map> current(Type* type) {
|
| + static bool matches(AstType* type) { return type->IsClass(); }
|
| + static i::Handle<i::Map> current(AstType* type) {
|
| return type->AsClass()->Map();
|
| }
|
| };
|
|
|
| template <>
|
| struct TypeImplIteratorAux<i::Object> {
|
| - static bool matches(Type* type) { return type->IsConstant(); }
|
| - static i::Handle<i::Object> current(Type* type) {
|
| + static bool matches(AstType* type) { return type->IsConstant(); }
|
| + static i::Handle<i::Object> current(AstType* type) {
|
| return type->AsConstant()->Value();
|
| }
|
| };
|
|
|
| template <class T>
|
| -bool Type::Iterator<T>::matches(Type* type) {
|
| +bool AstType::Iterator<T>::matches(AstType* type) {
|
| return TypeImplIteratorAux<T>::matches(type);
|
| }
|
|
|
| template <class T>
|
| -i::Handle<T> Type::Iterator<T>::Current() {
|
| +i::Handle<T> AstType::Iterator<T>::Current() {
|
| return TypeImplIteratorAux<T>::current(get_type());
|
| }
|
|
|
| template <class T>
|
| -void Type::Iterator<T>::Advance() {
|
| +void AstType::Iterator<T>::Advance() {
|
| DisallowHeapAllocation no_allocation;
|
| ++index_;
|
| if (type_->IsUnion()) {
|
| @@ -1116,31 +1104,33 @@ void Type::Iterator<T>::Advance() {
|
| index_ = -1;
|
| }
|
|
|
| -
|
| // -----------------------------------------------------------------------------
|
| // Printing.
|
|
|
| -const char* BitsetType::Name(bitset bits) {
|
| +const char* AstBitsetType::Name(bitset bits) {
|
| switch (bits) {
|
| - case REPRESENTATION(kAny): return "Any";
|
| - #define RETURN_NAMED_REPRESENTATION_TYPE(type, value) \
|
| - case REPRESENTATION(k##type): return #type;
|
| - REPRESENTATION_BITSET_TYPE_LIST(RETURN_NAMED_REPRESENTATION_TYPE)
|
| - #undef RETURN_NAMED_REPRESENTATION_TYPE
|
| -
|
| - #define RETURN_NAMED_SEMANTIC_TYPE(type, value) \
|
| - case SEMANTIC(k##type): return #type;
|
| - SEMANTIC_BITSET_TYPE_LIST(RETURN_NAMED_SEMANTIC_TYPE)
|
| - INTERNAL_BITSET_TYPE_LIST(RETURN_NAMED_SEMANTIC_TYPE)
|
| - #undef RETURN_NAMED_SEMANTIC_TYPE
|
| + case AST_REPRESENTATION(kAny):
|
| + return "Any";
|
| +#define RETURN_NAMED_REPRESENTATION_TYPE(type, value) \
|
| + case AST_REPRESENTATION(k##type): \
|
| + return #type;
|
| + AST_REPRESENTATION_BITSET_TYPE_LIST(RETURN_NAMED_REPRESENTATION_TYPE)
|
| +#undef RETURN_NAMED_REPRESENTATION_TYPE
|
| +
|
| +#define RETURN_NAMED_SEMANTIC_TYPE(type, value) \
|
| + case AST_SEMANTIC(k##type): \
|
| + return #type;
|
| + AST_SEMANTIC_BITSET_TYPE_LIST(RETURN_NAMED_SEMANTIC_TYPE)
|
| + AST_INTERNAL_BITSET_TYPE_LIST(RETURN_NAMED_SEMANTIC_TYPE)
|
| +#undef RETURN_NAMED_SEMANTIC_TYPE
|
|
|
| default:
|
| return NULL;
|
| }
|
| }
|
|
|
| -void BitsetType::Print(std::ostream& os, // NOLINT
|
| - bitset bits) {
|
| +void AstBitsetType::Print(std::ostream& os, // NOLINT
|
| + bitset bits) {
|
| DisallowHeapAllocation no_allocation;
|
| const char* name = Name(bits);
|
| if (name != NULL) {
|
| @@ -1150,13 +1140,13 @@ void BitsetType::Print(std::ostream& os, // NOLINT
|
|
|
| // clang-format off
|
| static const bitset named_bitsets[] = {
|
| -#define BITSET_CONSTANT(type, value) REPRESENTATION(k##type),
|
| - REPRESENTATION_BITSET_TYPE_LIST(BITSET_CONSTANT)
|
| +#define BITSET_CONSTANT(type, value) AST_REPRESENTATION(k##type),
|
| + AST_REPRESENTATION_BITSET_TYPE_LIST(BITSET_CONSTANT)
|
| #undef BITSET_CONSTANT
|
|
|
| -#define BITSET_CONSTANT(type, value) SEMANTIC(k##type),
|
| - INTERNAL_BITSET_TYPE_LIST(BITSET_CONSTANT)
|
| - SEMANTIC_BITSET_TYPE_LIST(BITSET_CONSTANT)
|
| +#define BITSET_CONSTANT(type, value) AST_SEMANTIC(k##type),
|
| + AST_INTERNAL_BITSET_TYPE_LIST(BITSET_CONSTANT)
|
| + AST_SEMANTIC_BITSET_TYPE_LIST(BITSET_CONSTANT)
|
| #undef BITSET_CONSTANT
|
| };
|
| // clang-format on
|
| @@ -1176,14 +1166,14 @@ void BitsetType::Print(std::ostream& os, // NOLINT
|
| os << ")";
|
| }
|
|
|
| -void Type::PrintTo(std::ostream& os, PrintDimension dim) {
|
| +void AstType::PrintTo(std::ostream& os, PrintDimension dim) {
|
| DisallowHeapAllocation no_allocation;
|
| if (dim != REPRESENTATION_DIM) {
|
| if (this->IsBitset()) {
|
| - BitsetType::Print(os, SEMANTIC(this->AsBitset()));
|
| + AstBitsetType::Print(os, AST_SEMANTIC(this->AsBitset()));
|
| } else if (this->IsClass()) {
|
| os << "Class(" << static_cast<void*>(*this->AsClass()->Map()) << " < ";
|
| - BitsetType::New(BitsetType::Lub(this))->PrintTo(os, dim);
|
| + AstBitsetType::New(AstBitsetType::Lub(this))->PrintTo(os, dim);
|
| os << ")";
|
| } else if (this->IsConstant()) {
|
| os << "Constant(" << Brief(*this->AsConstant()->Value()) << ")";
|
| @@ -1201,7 +1191,7 @@ void Type::PrintTo(std::ostream& os, PrintDimension dim) {
|
| } else if (this->IsUnion()) {
|
| os << "(";
|
| for (int i = 0, n = this->AsUnion()->Length(); i < n; ++i) {
|
| - Type* type_i = this->AsUnion()->Get(i);
|
| + AstType* type_i = this->AsUnion()->Get(i);
|
| if (i > 0) os << " | ";
|
| type_i->PrintTo(os, dim);
|
| }
|
| @@ -1225,7 +1215,7 @@ void Type::PrintTo(std::ostream& os, PrintDimension dim) {
|
| } else if (this->IsTuple()) {
|
| os << "<";
|
| for (int i = 0, n = this->AsTuple()->Arity(); i < n; ++i) {
|
| - Type* type_i = this->AsTuple()->Element(i);
|
| + AstType* type_i = this->AsTuple()->Element(i);
|
| if (i > 0) os << ", ";
|
| type_i->PrintTo(os, dim);
|
| }
|
| @@ -1236,34 +1226,33 @@ void Type::PrintTo(std::ostream& os, PrintDimension dim) {
|
| }
|
| if (dim == BOTH_DIMS) os << "/";
|
| if (dim != SEMANTIC_DIM) {
|
| - BitsetType::Print(os, REPRESENTATION(this->BitsetLub()));
|
| + AstBitsetType::Print(os, AST_REPRESENTATION(this->BitsetLub()));
|
| }
|
| }
|
|
|
| -
|
| #ifdef DEBUG
|
| -void Type::Print() {
|
| +void AstType::Print() {
|
| OFStream os(stdout);
|
| PrintTo(os);
|
| os << std::endl;
|
| }
|
| -void BitsetType::Print(bitset bits) {
|
| +void AstBitsetType::Print(bitset bits) {
|
| OFStream os(stdout);
|
| Print(os, bits);
|
| os << std::endl;
|
| }
|
| #endif
|
|
|
| -BitsetType::bitset BitsetType::SignedSmall() {
|
| +AstBitsetType::bitset AstBitsetType::SignedSmall() {
|
| return i::SmiValuesAre31Bits() ? kSigned31 : kSigned32;
|
| }
|
|
|
| -BitsetType::bitset BitsetType::UnsignedSmall() {
|
| +AstBitsetType::bitset AstBitsetType::UnsignedSmall() {
|
| return i::SmiValuesAre31Bits() ? kUnsigned30 : kUnsigned31;
|
| }
|
|
|
| #define CONSTRUCT_SIMD_TYPE(NAME, Name, name, lane_count, lane_type) \
|
| - Type* Type::Name(Isolate* isolate, Zone* zone) { \
|
| + AstType* AstType::Name(Isolate* isolate, Zone* zone) { \
|
| return Class(i::handle(isolate->heap()->name##_map()), zone); \
|
| }
|
| SIMD128_TYPES(CONSTRUCT_SIMD_TYPE)
|
| @@ -1272,8 +1261,8 @@ SIMD128_TYPES(CONSTRUCT_SIMD_TYPE)
|
| // -----------------------------------------------------------------------------
|
| // Instantiations.
|
|
|
| -template class Type::Iterator<i::Map>;
|
| -template class Type::Iterator<i::Object>;
|
| +template class AstType::Iterator<i::Map>;
|
| +template class AstType::Iterator<i::Object>;
|
|
|
| } // namespace internal
|
| } // namespace v8
|
|
|