if (this->IsBitset()) return BitsetType::Min(this->AsBitset());
if (this->IsUnion()) {
double min = +V8_INFINITY;
- for (int i = 0; i < this->AsUnion()->Length(); ++i) {
+ for (int i = 0, n = this->AsUnion()->Length(); i < n; ++i) {
min = std::min(min, this->AsUnion()->Get(i)->Min());
}
return min;
if (this->IsBitset()) return BitsetType::Max(this->AsBitset());
if (this->IsUnion()) {
double max = -V8_INFINITY;
- for (int i = 0; i < this->AsUnion()->Length(); ++i) {
+ for (int i = 0, n = this->AsUnion()->Length(); i < n; ++i) {
max = std::max(max, this->AsUnion()->Get(i)->Max());
}
return max;
if (type->IsBitset()) return type->AsBitset();
if (type->IsUnion()) {
int bitset = kNone;
- for (int i = 0; i < type->AsUnion()->Length(); ++i) {
+ for (int i = 0, n = type->AsUnion()->Length(); i < n; ++i) {
bitset |= type->AsUnion()->Get(i)->BitsetLub();
}
return bitset;
case SHARED_FUNCTION_INFO_TYPE:
case ACCESSOR_PAIR_TYPE:
case FIXED_ARRAY_TYPE:
+ case BYTE_ARRAY_TYPE:
case FOREIGN_TYPE:
case CODE_TYPE:
return kInternal & kTaggedPtr;
DisallowHeapAllocation no_allocation;
if (i::IsMinusZero(value)) return kMinusZero;
if (std::isnan(value)) return kNaN;
- if (IsUint32Double(value)) return Lub(FastD2UI(value));
- if (IsInt32Double(value)) return Lub(FastD2I(value));
+ if (IsUint32Double(value) || IsInt32Double(value)) return Lub(value, value);
return kOtherNumber;
}
-template<class Config>
-typename TypeImpl<Config>::bitset
-TypeImpl<Config>::BitsetType::Lub(int32_t value) {
- DisallowHeapAllocation no_allocation;
- if (value >= 0x40000000) {
- return i::SmiValuesAre31Bits() ? kOtherUnsigned31 : kUnsignedSmall;
- }
- if (value >= 0) return kUnsignedSmall;
- if (value >= -0x40000000) return kOtherSignedSmall;
- return i::SmiValuesAre31Bits() ? kOtherSigned32 : kOtherSignedSmall;
-}
-
-
-template<class Config>
-typename TypeImpl<Config>::bitset
-TypeImpl<Config>::BitsetType::Lub(uint32_t value) {
- DisallowHeapAllocation no_allocation;
- if (value >= 0x80000000u) return kOtherUnsigned32;
- if (value >= 0x40000000u) {
- return i::SmiValuesAre31Bits() ? kOtherUnsigned31 : kUnsignedSmall;
- }
- return kUnsignedSmall;
-}
-
-
// Minimum values of regular numeric bitsets when SmiValuesAre31Bits.
template<class Config>
const typename TypeImpl<Config>::BitsetType::BitsetMin
template<class Config>
typename TypeImpl<Config>::bitset
-TypeImpl<Config>::BitsetType::Lub(Limits lim) {
+TypeImpl<Config>::BitsetType::Lub(double min, double max) {
DisallowHeapAllocation no_allocation;
- double min = lim.min->Number();
- double max = lim.max->Number();
int lub = kNone;
const BitsetMin* mins = BitsetMins();
DisallowHeapAllocation no_allocation;
DCHECK(Is(bits, kNumber));
const BitsetMin* mins = BitsetMins();
- bool mz = bits & kMinusZero;
+ bool mz = SEMANTIC(bits & kMinusZero);
if (BitsetType::Is(mins[BitsetMinsSize()-1].bits, bits)) {
return +V8_INFINITY;
}
!this_fun->Receiver()->Equals(that_fun->Receiver())) {
return false;
}
- for (int i = 0; i < this_fun->Arity(); ++i) {
+ for (int i = 0, n = this_fun->Arity(); i < n; ++i) {
if (!this_fun->Parameter(i)->Equals(that_fun->Parameter(i))) return false;
}
return true;
// (T1 \/ ... \/ Tn) <= T if (T1 <= T) /\ ... /\ (Tn <= T)
if (this->IsUnion()) {
- UnionHandle unioned = handle(this->AsUnion());
- for (int i = 0; i < unioned->Length(); ++i) {
- if (!unioned->Get(i)->Is(that)) return false;
+ for (int i = 0, n = this->AsUnion()->Length(); i < n; ++i) {
+ if (!this->AsUnion()->Get(i)->Is(that)) return false;
}
return true;
}
// T <= (T1 \/ ... \/ Tn) if (T <= T1) \/ ... \/ (T <= Tn)
if (that->IsUnion()) {
- for (int i = 0; i < that->AsUnion()->Length(); ++i) {
+ for (int i = 0, n = that->AsUnion()->Length(); i < n; ++i) {
if (this->Is(that->AsUnion()->Get(i))) return true;
if (i > 1 && this->IsRange()) return false; // Shortcut.
}
Contains(that->AsRange(), *this->AsConstant()->Value()));
}
if (this->IsRange()) return false;
+
return this->SimplyEquals(that);
}
// (T1 \/ ... \/ Tn) overlaps T if (T1 overlaps T) \/ ... \/ (Tn overlaps T)
if (this->IsUnion()) {
- UnionHandle unioned = handle(this->AsUnion());
- for (int i = 0; i < unioned->Length(); ++i) {
- if (unioned->Get(i)->Maybe(that)) return true;
+ for (int i = 0, n = this->AsUnion()->Length(); i < n; ++i) {
+ if (this->AsUnion()->Get(i)->Maybe(that)) return true;
}
return false;
}
// T overlaps (T1 \/ ... \/ Tn) if (T overlaps T1) \/ ... \/ (T overlaps Tn)
if (that->IsUnion()) {
- for (int i = 0; i < that->AsUnion()->Length(); ++i) {
+ for (int i = 0, n = that->AsUnion()->Length(); i < n; ++i) {
if (this->Maybe(that->AsUnion()->Get(i))) return true;
}
return false;
TypeHandle lhs, TypeHandle rhs,
UnionHandle result, int size, Region* region) {
if (lhs->IsUnion()) {
- for (int i = 0; i < lhs->AsUnion()->Length(); ++i) {
+ for (int i = 0, n = lhs->AsUnion()->Length(); i < n; ++i) {
size = IntersectAux(lhs->AsUnion()->Get(i), rhs, result, size, region);
}
return size;
}
if (rhs->IsUnion()) {
- for (int i = 0; i < rhs->AsUnion()->Length(); ++i) {
+ for (int i = 0, n = rhs->AsUnion()->Length(); i < n; ++i) {
size = IntersectAux(lhs, rhs->AsUnion()->Get(i), result, size, region);
}
return size;
TypeHandle type, UnionHandle result, int size, Region* region) {
if (type->IsBitset() || type->IsRange()) return size;
if (type->IsUnion()) {
- for (int i = 0; i < type->AsUnion()->Length(); ++i) {
+ for (int i = 0, n = type->AsUnion()->Length(); i < n; ++i) {
size = AddToUnion(type->AsUnion()->Get(i), result, size, region);
}
return size;
if (this->IsClass()) {
return 1;
} else if (this->IsUnion()) {
- UnionHandle unioned = handle(this->AsUnion());
int result = 0;
- for (int i = 0; i < unioned->Length(); ++i) {
- if (unioned->Get(i)->IsClass()) ++result;
+ for (int i = 0, n = this->AsUnion()->Length(); i < n; ++i) {
+ if (this->AsUnion()->Get(i)->IsClass()) ++result;
}
return result;
} else {
if (this->IsConstant()) {
return 1;
} else if (this->IsUnion()) {
- UnionHandle unioned = handle(this->AsUnion());
int result = 0;
- for (int i = 0; i < unioned->Length(); ++i) {
- if (unioned->Get(i)->IsConstant()) ++result;
+ for (int i = 0, n = this->AsUnion()->Length(); i < n; ++i) {
+ if (this->AsUnion()->Get(i)->IsConstant()) ++result;
}
return result;
} else {
DisallowHeapAllocation no_allocation;
++index_;
if (type_->IsUnion()) {
- UnionHandle unioned = Config::template cast<UnionType>(type_);
- for (; index_ < unioned->Length(); ++index_) {
- if (matches(unioned->Get(index_))) return;
+ for (int n = type_->AsUnion()->Length(); index_ < n; ++index_) {
+ if (matches(type_->AsUnion()->Get(index_))) return;
}
} else if (index_ == 0 && matches(type_)) {
return;
template <class Config>
-void TypeImpl<Config>::BitsetType::Print(OStream& os, // NOLINT
+void TypeImpl<Config>::BitsetType::Print(std::ostream& os, // NOLINT
bitset bits) {
DisallowHeapAllocation no_allocation;
const char* name = Name(bits);
template <class Config>
-void TypeImpl<Config>::PrintTo(OStream& os, PrintDimension dim) { // NOLINT
+void TypeImpl<Config>::PrintTo(std::ostream& os, PrintDimension dim) {
DisallowHeapAllocation no_allocation;
if (dim != REPRESENTATION_DIM) {
if (this->IsBitset()) {
BitsetType::New(BitsetType::Lub(this))->PrintTo(os, dim);
os << ")";
} else if (this->IsConstant()) {
- os << "Constant(" << static_cast<void*>(*this->AsConstant()->Value())
- << ")";
+ os << "Constant(" << Brief(*this->AsConstant()->Value()) << ")";
} else if (this->IsRange()) {
os << "Range(" << this->AsRange()->Min()->Number()
<< ", " << this->AsRange()->Max()->Number() << ")";
os << ")";
} else if (this->IsUnion()) {
os << "(";
- UnionHandle unioned = handle(this->AsUnion());
- for (int i = 0; i < unioned->Length(); ++i) {
- TypeHandle type_i = unioned->Get(i);
+ for (int i = 0, n = this->AsUnion()->Length(); i < n; ++i) {
+ TypeHandle type_i = this->AsUnion()->Get(i);
if (i > 0) os << " | ";
type_i->PrintTo(os, dim);
}
void TypeImpl<Config>::Print() {
OFStream os(stdout);
PrintTo(os);
- os << endl;
+ os << std::endl;
}
template <class Config>
void TypeImpl<Config>::BitsetType::Print(bitset bits) {
OFStream os(stdout);
Print(os, bits);
- os << endl;
+ os << std::endl;
}
#endif