Reland of "Steps towards unification of number bitset and range types."
This reverts commit 7619374979
.
BUG=
Review URL: https://codereview.chromium.org/877643002
Cr-Commit-Position: refs/heads/master@{#26301}
This commit is contained in:
parent
aa609b546d
commit
5bd8407f8c
@ -163,7 +163,7 @@ Reduction ChangeLowering::ChangeInt32ToTagged(Node* value, Node* control) {
|
|||||||
machine()->Word64Shl(),
|
machine()->Word64Shl(),
|
||||||
graph()->NewNode(machine()->ChangeInt32ToInt64(), value),
|
graph()->NewNode(machine()->ChangeInt32ToInt64(), value),
|
||||||
SmiShiftBitsConstant()));
|
SmiShiftBitsConstant()));
|
||||||
} else if (NodeProperties::GetBounds(value).upper->Is(Type::SignedSmall())) {
|
} else if (NodeProperties::GetBounds(value).upper->Is(Type::Signed31())) {
|
||||||
return Replace(
|
return Replace(
|
||||||
graph()->NewNode(machine()->WordShl(), value, SmiShiftBitsConstant()));
|
graph()->NewNode(machine()->WordShl(), value, SmiShiftBitsConstant()));
|
||||||
}
|
}
|
||||||
|
@ -895,12 +895,12 @@ Type* Typer::Visitor::JSBitwiseXorTyper(Type* lhs, Type* rhs, Typer* t) {
|
|||||||
double rmax = rhs->Max();
|
double rmax = rhs->Max();
|
||||||
if ((lmin >= 0 && rmin >= 0) || (lmax < 0 && rmax < 0)) {
|
if ((lmin >= 0 && rmin >= 0) || (lmax < 0 && rmax < 0)) {
|
||||||
// Xor-ing negative or non-negative values results in a non-negative value.
|
// Xor-ing negative or non-negative values results in a non-negative value.
|
||||||
return Type::NonNegativeSigned32();
|
return Type::Unsigned31();
|
||||||
}
|
}
|
||||||
if ((lmax < 0 && rmin >= 0) || (lmin >= 0 && rmax < 0)) {
|
if ((lmax < 0 && rmin >= 0) || (lmin >= 0 && rmax < 0)) {
|
||||||
// Xor-ing a negative and a non-negative value results in a negative value.
|
// Xor-ing a negative and a non-negative value results in a negative value.
|
||||||
// TODO(jarin) Use a range here.
|
// TODO(jarin) Use a range here.
|
||||||
return Type::NegativeSigned32();
|
return Type::Negative32();
|
||||||
}
|
}
|
||||||
return Type::Signed32();
|
return Type::Signed32();
|
||||||
}
|
}
|
||||||
@ -1271,43 +1271,54 @@ Bounds Typer::Visitor::TypeJSLoadNamed(Node* node) {
|
|||||||
// in the graph. In the current implementation, we are
|
// in the graph. In the current implementation, we are
|
||||||
// increasing the limits to the closest power of two.
|
// increasing the limits to the closest power of two.
|
||||||
Type* Typer::Visitor::Weaken(Type* current_type, Type* previous_type) {
|
Type* Typer::Visitor::Weaken(Type* current_type, Type* previous_type) {
|
||||||
Type::RangeType* previous = previous_type->GetRange();
|
// If the types have nothing to do with integers, return the types.
|
||||||
Type::RangeType* current = current_type->GetRange();
|
if (!current_type->Maybe(typer_->integer) ||
|
||||||
if (previous != NULL && current != NULL) {
|
!previous_type->Maybe(typer_->integer)) {
|
||||||
double current_min = current->Min()->Number();
|
return current_type;
|
||||||
Handle<Object> new_min = current->Min();
|
|
||||||
|
|
||||||
// Find the closest lower entry in the list of allowed
|
|
||||||
// minima (or negative infinity if there is no such entry).
|
|
||||||
if (current_min != previous->Min()->Number()) {
|
|
||||||
new_min = typer_->integer->AsRange()->Min();
|
|
||||||
for (const auto val : typer_->weaken_min_limits_) {
|
|
||||||
if (val->Number() <= current_min) {
|
|
||||||
new_min = val;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
double current_max = current->Max()->Number();
|
|
||||||
Handle<Object> new_max = current->Max();
|
|
||||||
// Find the closest greater entry in the list of allowed
|
|
||||||
// maxima (or infinity if there is no such entry).
|
|
||||||
if (current_max != previous->Max()->Number()) {
|
|
||||||
new_max = typer_->integer->AsRange()->Max();
|
|
||||||
for (const auto val : typer_->weaken_max_limits_) {
|
|
||||||
if (val->Number() >= current_max) {
|
|
||||||
new_max = val;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return Type::Union(current_type,
|
|
||||||
Type::Range(new_min, new_max, typer_->zone()),
|
|
||||||
typer_->zone());
|
|
||||||
}
|
}
|
||||||
return current_type;
|
|
||||||
|
Type* previous_number =
|
||||||
|
Type::Intersect(previous_type, typer_->integer, zone());
|
||||||
|
Type* current_number = Type::Intersect(current_type, typer_->integer, zone());
|
||||||
|
if (!current_number->IsRange() || !previous_number->IsRange()) {
|
||||||
|
return current_type;
|
||||||
|
}
|
||||||
|
|
||||||
|
Type::RangeType* previous = previous_number->AsRange();
|
||||||
|
Type::RangeType* current = current_number->AsRange();
|
||||||
|
|
||||||
|
double current_min = current->Min()->Number();
|
||||||
|
Handle<Object> new_min = current->Min();
|
||||||
|
|
||||||
|
// Find the closest lower entry in the list of allowed
|
||||||
|
// minima (or negative infinity if there is no such entry).
|
||||||
|
if (current_min != previous->Min()->Number()) {
|
||||||
|
new_min = typer_->integer->AsRange()->Min();
|
||||||
|
for (const auto val : typer_->weaken_min_limits_) {
|
||||||
|
if (val->Number() <= current_min) {
|
||||||
|
new_min = val;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
double current_max = current->Max()->Number();
|
||||||
|
Handle<Object> new_max = current->Max();
|
||||||
|
// Find the closest greater entry in the list of allowed
|
||||||
|
// maxima (or infinity if there is no such entry).
|
||||||
|
if (current_max != previous->Max()->Number()) {
|
||||||
|
new_max = typer_->integer->AsRange()->Max();
|
||||||
|
for (const auto val : typer_->weaken_max_limits_) {
|
||||||
|
if (val->Number() >= current_max) {
|
||||||
|
new_max = val;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Type::Union(current_type,
|
||||||
|
Type::Range(new_min, new_max, typer_->zone()),
|
||||||
|
typer_->zone());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -16,6 +16,19 @@ namespace internal {
|
|||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// TypeImpl
|
// TypeImpl
|
||||||
|
|
||||||
|
template <class Config>
|
||||||
|
typename TypeImpl<Config>::bitset TypeImpl<Config>::BitsetType::SignedSmall() {
|
||||||
|
return i::SmiValuesAre31Bits() ? kSigned31 : kSigned32;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <class Config>
|
||||||
|
typename TypeImpl<Config>::bitset
|
||||||
|
TypeImpl<Config>::BitsetType::UnsignedSmall() {
|
||||||
|
return i::SmiValuesAre31Bits() ? kUnsigned30 : kUnsigned31;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Config>
|
template<class Config>
|
||||||
TypeImpl<Config>* TypeImpl<Config>::cast(typename Config::Base* object) {
|
TypeImpl<Config>* TypeImpl<Config>::cast(typename Config::Base* object) {
|
||||||
TypeImpl* t = static_cast<TypeImpl*>(object);
|
TypeImpl* t = static_cast<TypeImpl*>(object);
|
||||||
|
388
src/types.cc
388
src/types.cc
@ -28,17 +28,25 @@ typename TypeImpl<Config>::Limits TypeImpl<Config>::Intersect(
|
|||||||
Limits result(lhs);
|
Limits result(lhs);
|
||||||
if (lhs.min->Number() < rhs.min->Number()) result.min = rhs.min;
|
if (lhs.min->Number() < rhs.min->Number()) result.min = rhs.min;
|
||||||
if (lhs.max->Number() > rhs.max->Number()) result.max = rhs.max;
|
if (lhs.max->Number() > rhs.max->Number()) result.max = rhs.max;
|
||||||
|
result.representation = lhs.representation & rhs.representation;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Config>
|
template <class Config>
|
||||||
typename TypeImpl<Config>::Limits TypeImpl<Config>::Union(
|
bool TypeImpl<Config>::IsEmpty(Limits lim) {
|
||||||
Limits lhs, Limits rhs) {
|
return lim.min->Number() > lim.max->Number();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <class Config>
|
||||||
|
typename TypeImpl<Config>::Limits TypeImpl<Config>::Union(Limits lhs,
|
||||||
|
Limits rhs) {
|
||||||
DisallowHeapAllocation no_allocation;
|
DisallowHeapAllocation no_allocation;
|
||||||
Limits result(lhs);
|
Limits result(lhs);
|
||||||
if (lhs.min->Number() > rhs.min->Number()) result.min = rhs.min;
|
if (lhs.min->Number() > rhs.min->Number()) result.min = rhs.min;
|
||||||
if (lhs.max->Number() < rhs.max->Number()) result.max = rhs.max;
|
if (lhs.max->Number() < rhs.max->Number()) result.max = rhs.max;
|
||||||
|
result.representation = lhs.representation | rhs.representation;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,8 +66,19 @@ bool TypeImpl<Config>::Contains(
|
|||||||
typename TypeImpl<Config>::RangeType* lhs,
|
typename TypeImpl<Config>::RangeType* lhs,
|
||||||
typename TypeImpl<Config>::RangeType* rhs) {
|
typename TypeImpl<Config>::RangeType* rhs) {
|
||||||
DisallowHeapAllocation no_allocation;
|
DisallowHeapAllocation no_allocation;
|
||||||
return lhs->Min()->Number() <= rhs->Min()->Number()
|
return rhs->Bound()->Is(lhs->Bound()) &&
|
||||||
&& rhs->Max()->Number() <= lhs->Max()->Number();
|
lhs->Min()->Number() <= rhs->Min()->Number() &&
|
||||||
|
rhs->Max()->Number() <= lhs->Max()->Number();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <class Config>
|
||||||
|
bool TypeImpl<Config>::Contains(typename TypeImpl<Config>::RangeType* lhs,
|
||||||
|
typename TypeImpl<Config>::ConstantType* rhs) {
|
||||||
|
DisallowHeapAllocation no_allocation;
|
||||||
|
return IsInteger(*rhs->Value()) && rhs->Bound()->Is(lhs->Bound()) &&
|
||||||
|
lhs->Min()->Number() <= rhs->Value()->Number() &&
|
||||||
|
rhs->Value()->Number() <= lhs->Max()->Number();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -67,9 +86,10 @@ template<class Config>
|
|||||||
bool TypeImpl<Config>::Contains(
|
bool TypeImpl<Config>::Contains(
|
||||||
typename TypeImpl<Config>::RangeType* range, i::Object* val) {
|
typename TypeImpl<Config>::RangeType* range, i::Object* val) {
|
||||||
DisallowHeapAllocation no_allocation;
|
DisallowHeapAllocation no_allocation;
|
||||||
return IsInteger(val)
|
return IsInteger(val) &&
|
||||||
&& range->Min()->Number() <= val->Number()
|
BitsetType::Is(BitsetType::Lub(val), range->Bound()->AsBitset()) &&
|
||||||
&& val->Number() <= range->Max()->Number();
|
range->Min()->Number() <= val->Number() &&
|
||||||
|
val->Number() <= range->Max()->Number();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -125,9 +145,18 @@ TypeImpl<Config>::BitsetType::Glb(TypeImpl* type) {
|
|||||||
return type->AsBitset();
|
return type->AsBitset();
|
||||||
} else if (type->IsUnion()) {
|
} else if (type->IsUnion()) {
|
||||||
SLOW_DCHECK(type->AsUnion()->Wellformed());
|
SLOW_DCHECK(type->AsUnion()->Wellformed());
|
||||||
return type->AsUnion()->Get(0)->BitsetGlb(); // Shortcut.
|
return type->AsUnion()->Get(0)->BitsetGlb() |
|
||||||
// (The remaining BitsetGlb's are None anyway).
|
type->AsUnion()->Get(1)->BitsetGlb(); // Shortcut.
|
||||||
|
} else if (type->IsRange()) {
|
||||||
|
bitset glb = SEMANTIC(BitsetType::Glb(type->AsRange()->Min()->Number(),
|
||||||
|
type->AsRange()->Max()->Number()));
|
||||||
|
if (glb == 0) {
|
||||||
|
return kNone;
|
||||||
|
} else {
|
||||||
|
return glb | REPRESENTATION(type->BitsetLub());
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
|
// (The remaining BitsetGlb's are None anyway).
|
||||||
return kNone;
|
return kNone;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -152,7 +181,7 @@ TypeImpl<Config>::BitsetType::Lub(TypeImpl* type) {
|
|||||||
type->AsClass()->Bound(NULL)->AsBitset();
|
type->AsClass()->Bound(NULL)->AsBitset();
|
||||||
}
|
}
|
||||||
if (type->IsConstant()) return type->AsConstant()->Bound()->AsBitset();
|
if (type->IsConstant()) return type->AsConstant()->Bound()->AsBitset();
|
||||||
if (type->IsRange()) return type->AsRange()->BitsetLub();
|
if (type->IsRange()) return type->AsRange()->Bound()->AsBitset();
|
||||||
if (type->IsContext()) return kInternal & kTaggedPointer;
|
if (type->IsContext()) return kInternal & kTaggedPointer;
|
||||||
if (type->IsArray()) return kArray;
|
if (type->IsArray()) return kArray;
|
||||||
if (type->IsFunction()) return kOtherObject; // TODO(rossberg): kFunction
|
if (type->IsFunction()) return kOtherObject; // TODO(rossberg): kFunction
|
||||||
@ -284,29 +313,33 @@ TypeImpl<Config>::BitsetType::Lub(double value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Minimum values of regular numeric bitsets when SmiValuesAre31Bits.
|
// Minimum values of regular numeric bitsets.
|
||||||
template <class Config>
|
template <class Config>
|
||||||
const typename TypeImpl<Config>::BitsetType::BitsetMin
|
const typename TypeImpl<Config>::BitsetType::Boundary
|
||||||
TypeImpl<Config>::BitsetType::BitsetMins31[] = {
|
TypeImpl<Config>::BitsetType::BoundariesArray[] = {
|
||||||
{kOtherNumber, -V8_INFINITY},
|
{kPlainNumber, -V8_INFINITY},
|
||||||
{kOtherSigned32, kMinInt},
|
{kNegative32, kMinInt},
|
||||||
{kNegativeSignedSmall, -0x40000000},
|
{kNegative31, -0x40000000},
|
||||||
{kUnsignedSmall, 0},
|
{kUnsigned30, 0},
|
||||||
{kOtherUnsigned31, 0x40000000},
|
{kUnsigned31, 0x40000000},
|
||||||
{kOtherUnsigned32, 0x80000000},
|
{kUnsigned32, 0x80000000},
|
||||||
{kOtherNumber, static_cast<double>(kMaxUInt32) + 1}};
|
{kPlainNumber, static_cast<double>(kMaxUInt32) + 1}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
// Minimum values of regular numeric bitsets when SmiValuesAre32Bits.
|
|
||||||
// OtherSigned32 and OtherUnsigned31 are empty (see the diagrams in types.h).
|
|
||||||
template <class Config>
|
template <class Config>
|
||||||
const typename TypeImpl<Config>::BitsetType::BitsetMin
|
const typename TypeImpl<Config>::BitsetType::Boundary*
|
||||||
TypeImpl<Config>::BitsetType::BitsetMins32[] = {
|
TypeImpl<Config>::BitsetType::Boundaries() {
|
||||||
{kOtherNumber, -V8_INFINITY},
|
return BoundariesArray;
|
||||||
{kNegativeSignedSmall, kMinInt},
|
}
|
||||||
{kUnsignedSmall, 0},
|
|
||||||
{kOtherUnsigned32, 0x80000000},
|
|
||||||
{kOtherNumber, static_cast<double>(kMaxUInt32) + 1}};
|
template <class Config>
|
||||||
|
size_t TypeImpl<Config>::BitsetType::BoundariesSize() {
|
||||||
|
// Windows doesn't like arraysize here.
|
||||||
|
// return arraysize(BoundariesArray);
|
||||||
|
return 7;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Config>
|
template<class Config>
|
||||||
@ -314,30 +347,71 @@ typename TypeImpl<Config>::bitset
|
|||||||
TypeImpl<Config>::BitsetType::Lub(double min, double max) {
|
TypeImpl<Config>::BitsetType::Lub(double min, double max) {
|
||||||
DisallowHeapAllocation no_allocation;
|
DisallowHeapAllocation no_allocation;
|
||||||
int lub = kNone;
|
int lub = kNone;
|
||||||
const BitsetMin* mins = BitsetMins();
|
const Boundary* mins = Boundaries();
|
||||||
|
|
||||||
// Make sure the min-max range touches 0, so we are guaranteed no holes
|
// Make sure the min-max range touches 0, so we are guaranteed no holes
|
||||||
// in unions of valid bitsets.
|
// in unions of valid bitsets.
|
||||||
if (max < -1) max = -1;
|
if (max < -1) max = -1;
|
||||||
if (min > 0) min = 0;
|
if (min > 0) min = 0;
|
||||||
|
|
||||||
for (size_t i = 1; i < BitsetMinsSize(); ++i) {
|
for (size_t i = 1; i < BoundariesSize(); ++i) {
|
||||||
if (min < mins[i].min) {
|
if (min < mins[i].min) {
|
||||||
lub |= mins[i-1].bits;
|
lub |= mins[i-1].bits;
|
||||||
if (max < mins[i].min) return lub;
|
if (max < mins[i].min) return lub;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return lub |= mins[BitsetMinsSize()-1].bits;
|
return lub |= mins[BoundariesSize() - 1].bits;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Config>
|
template <class Config>
|
||||||
|
typename TypeImpl<Config>::bitset TypeImpl<Config>::BitsetType::NumberBits(
|
||||||
|
bitset bits) {
|
||||||
|
return SEMANTIC(bits & kPlainNumber);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <class Config>
|
||||||
|
void TypeImpl<Config>::BitsetType::CheckNumberBits(bitset bits) {
|
||||||
|
// Check that the bitset does not contain any holes in number ranges.
|
||||||
|
bitset number_bits = NumberBits(bits);
|
||||||
|
if (number_bits != 0) {
|
||||||
|
bitset lub = SEMANTIC(Lub(Min(number_bits), Max(number_bits)));
|
||||||
|
CHECK(lub == number_bits);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class Config>
|
||||||
|
typename TypeImpl<Config>::bitset TypeImpl<Config>::BitsetType::Glb(
|
||||||
|
double min, double max) {
|
||||||
|
DisallowHeapAllocation no_allocation;
|
||||||
|
int glb = kNone;
|
||||||
|
const Boundary* mins = Boundaries();
|
||||||
|
|
||||||
|
// If the range does not touch 0, the bound is empty.
|
||||||
|
if (max < -1 || min > 0) return glb;
|
||||||
|
|
||||||
|
for (size_t i = 1; i + 1 < BoundariesSize(); ++i) {
|
||||||
|
if (min <= mins[i].min) {
|
||||||
|
if (max + 1 < mins[i + 1].min) break;
|
||||||
|
glb |= mins[i].bits;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// OtherNumber also contains float numbers, so it can never be
|
||||||
|
// in the greatest lower bound. (There is also the small trouble
|
||||||
|
// of kOtherNumber having a range hole, which we can conveniently
|
||||||
|
// ignore here.)
|
||||||
|
return glb & ~(SEMANTIC(kOtherNumber));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <class Config>
|
||||||
double TypeImpl<Config>::BitsetType::Min(bitset bits) {
|
double TypeImpl<Config>::BitsetType::Min(bitset bits) {
|
||||||
DisallowHeapAllocation no_allocation;
|
DisallowHeapAllocation no_allocation;
|
||||||
DCHECK(Is(bits, kNumber));
|
DCHECK(Is(bits, kNumber));
|
||||||
const BitsetMin* mins = BitsetMins();
|
const Boundary* mins = Boundaries();
|
||||||
bool mz = SEMANTIC(bits & kMinusZero);
|
bool mz = SEMANTIC(bits & kMinusZero);
|
||||||
for (size_t i = 0; i < BitsetMinsSize(); ++i) {
|
for (size_t i = 0; i < BoundariesSize(); ++i) {
|
||||||
if (Is(SEMANTIC(mins[i].bits), bits)) {
|
if (Is(SEMANTIC(mins[i].bits), bits)) {
|
||||||
return mz ? std::min(0.0, mins[i].min) : mins[i].min;
|
return mz ? std::min(0.0, mins[i].min) : mins[i].min;
|
||||||
}
|
}
|
||||||
@ -351,12 +425,12 @@ template<class Config>
|
|||||||
double TypeImpl<Config>::BitsetType::Max(bitset bits) {
|
double TypeImpl<Config>::BitsetType::Max(bitset bits) {
|
||||||
DisallowHeapAllocation no_allocation;
|
DisallowHeapAllocation no_allocation;
|
||||||
DCHECK(Is(bits, kNumber));
|
DCHECK(Is(bits, kNumber));
|
||||||
const BitsetMin* mins = BitsetMins();
|
const Boundary* mins = Boundaries();
|
||||||
bool mz = SEMANTIC(bits & kMinusZero);
|
bool mz = SEMANTIC(bits & kMinusZero);
|
||||||
if (BitsetType::Is(mins[BitsetMinsSize()-1].bits, bits)) {
|
if (BitsetType::Is(SEMANTIC(mins[BoundariesSize() - 1].bits), bits)) {
|
||||||
return +V8_INFINITY;
|
return +V8_INFINITY;
|
||||||
}
|
}
|
||||||
for (size_t i = BitsetMinsSize()-1; i-- > 0; ) {
|
for (size_t i = BoundariesSize() - 1; i-- > 0;) {
|
||||||
if (Is(SEMANTIC(mins[i].bits), bits)) {
|
if (Is(SEMANTIC(mins[i].bits), bits)) {
|
||||||
return mz ?
|
return mz ?
|
||||||
std::max(0.0, mins[i+1].min - 1) : mins[i+1].min - 1;
|
std::max(0.0, mins[i+1].min - 1) : mins[i+1].min - 1;
|
||||||
@ -439,9 +513,9 @@ bool TypeImpl<Config>::SlowIs(TypeImpl* that) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (that->IsRange()) {
|
if (that->IsRange()) {
|
||||||
return (this->IsRange() && Contains(that->AsRange(), this->AsRange()))
|
return (this->IsRange() && Contains(that->AsRange(), this->AsRange())) ||
|
||||||
|| (this->IsConstant() &&
|
(this->IsConstant() &&
|
||||||
Contains(that->AsRange(), *this->AsConstant()->Value()));
|
Contains(that->AsRange(), this->AsConstant()));
|
||||||
}
|
}
|
||||||
if (this->IsRange()) return false;
|
if (this->IsRange()) return false;
|
||||||
|
|
||||||
@ -503,23 +577,34 @@ bool TypeImpl<Config>::Maybe(TypeImpl* that) {
|
|||||||
|
|
||||||
if (!BitsetType::IsInhabited(this->BitsetLub() & that->BitsetLub()))
|
if (!BitsetType::IsInhabited(this->BitsetLub() & that->BitsetLub()))
|
||||||
return false;
|
return false;
|
||||||
if (this->IsBitset() || that->IsBitset()) return true;
|
|
||||||
|
if (this->IsBitset() && that->IsBitset()) return true;
|
||||||
|
|
||||||
if (this->IsClass() != that->IsClass()) return true;
|
if (this->IsClass() != that->IsClass()) return true;
|
||||||
|
|
||||||
if (this->IsRange()) {
|
if (this->IsRange()) {
|
||||||
if (that->IsConstant()) {
|
if (that->IsConstant()) {
|
||||||
return Contains(this->AsRange(), *that->AsConstant()->Value());
|
return Contains(this->AsRange(), that->AsConstant());
|
||||||
|
}
|
||||||
|
if (that->IsRange()) {
|
||||||
|
return Overlap(this->AsRange(), that->AsRange());
|
||||||
|
}
|
||||||
|
if (that->IsBitset()) {
|
||||||
|
bitset number_bits = BitsetType::NumberBits(that->AsBitset());
|
||||||
|
if (number_bits == BitsetType::kNone) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
double min = std::max(BitsetType::Min(number_bits), this->Min());
|
||||||
|
double max = std::min(BitsetType::Max(number_bits), this->Max());
|
||||||
|
return min <= max;
|
||||||
}
|
}
|
||||||
return that->IsRange() && Overlap(this->AsRange(), that->AsRange());
|
|
||||||
}
|
}
|
||||||
if (that->IsRange()) {
|
if (that->IsRange()) {
|
||||||
if (this->IsConstant()) {
|
return that->Maybe(this); // This case is handled above.
|
||||||
return Contains(that->AsRange(), *this->AsConstant()->Value());
|
|
||||||
}
|
|
||||||
return this->IsRange() && Overlap(this->AsRange(), that->AsRange());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this->IsBitset() || that->IsBitset()) return true;
|
||||||
|
|
||||||
return this->SimplyEquals(that);
|
return this->SimplyEquals(that);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -560,15 +645,23 @@ bool TypeImpl<Config>::UnionType::Wellformed() {
|
|||||||
// (even when the first element is not a bitset).
|
// (even when the first element is not a bitset).
|
||||||
// 4. No element is itself a union.
|
// 4. No element is itself a union.
|
||||||
// 5. No element is a subtype of any other.
|
// 5. No element 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)
|
||||||
|
|
||||||
|
bitset number_bits = this->Get(0)->IsBitset()
|
||||||
|
? BitsetType::NumberBits(this->Get(0)->AsBitset()) : 0;
|
||||||
|
USE(number_bits);
|
||||||
|
|
||||||
for (int i = 0; i < this->Length(); ++i) {
|
for (int i = 0; i < this->Length(); ++i) {
|
||||||
if (i != 0) DCHECK(!this->Get(i)->IsBitset()); // (2)
|
if (i != 0) DCHECK(!this->Get(i)->IsBitset()); // (2)
|
||||||
if (i != 1) DCHECK(!this->Get(i)->IsRange()); // (3)
|
if (i != 1) DCHECK(!this->Get(i)->IsRange()); // (3)
|
||||||
DCHECK(!this->Get(i)->IsUnion()); // (4)
|
DCHECK(!this->Get(i)->IsUnion()); // (4)
|
||||||
for (int j = 0; j < this->Length(); ++j) {
|
for (int j = 0; j < this->Length(); ++j) {
|
||||||
if (i != j) DCHECK(!this->Get(i)->Is(this->Get(j))); // (5)
|
if (i != j) DCHECK(!this->Get(i)->Is(this->Get(j))); // (5)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
DCHECK(!this->Get(1)->IsRange() || (number_bits == 0)); // (6)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -615,20 +708,25 @@ typename TypeImpl<Config>::TypeHandle TypeImpl<Config>::Intersect(
|
|||||||
|
|
||||||
// Deal with bitsets.
|
// Deal with bitsets.
|
||||||
result->Set(size++, BitsetType::New(bits, region));
|
result->Set(size++, BitsetType::New(bits, region));
|
||||||
|
// Insert a placeholder for the range.
|
||||||
|
result->Set(size++, None(region));
|
||||||
|
|
||||||
// Deal with ranges.
|
Limits lims = Limits::Empty(region);
|
||||||
TypeHandle range = None(region);
|
size = IntersectAux(type1, type2, result, size, &lims, region);
|
||||||
RangeType* range1 = type1->GetRange();
|
|
||||||
RangeType* range2 = type2->GetRange();
|
// If the range is not empty, then insert it into the union and
|
||||||
if (range1 != NULL && range2 != NULL) {
|
// remove the number bits from the bitset.
|
||||||
Limits lim = Intersect(Limits(range1), Limits(range2));
|
if (!IsEmpty(lims)) {
|
||||||
if (lim.min->Number() <= lim.max->Number()) {
|
size = UpdateRange(RangeType::New(lims, region), result, size, region);
|
||||||
range = RangeType::New(lim, region);
|
|
||||||
|
// Remove the number bits.
|
||||||
|
bitset number_bits = BitsetType::NumberBits(bits);
|
||||||
|
bits &= ~number_bits;
|
||||||
|
if (SEMANTIC(bits) == BitsetType::kNone) {
|
||||||
|
bits = BitsetType::kNone;
|
||||||
}
|
}
|
||||||
|
result->Set(0, BitsetType::New(bits, region));
|
||||||
}
|
}
|
||||||
result->Set(size++, range);
|
|
||||||
|
|
||||||
size = IntersectAux(type1, type2, result, size, region);
|
|
||||||
return NormalizeUnion(result, size);
|
return NormalizeUnion(result, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -657,19 +755,51 @@ int TypeImpl<Config>::UpdateRange(
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Config>
|
template <class Config>
|
||||||
int TypeImpl<Config>::IntersectAux(
|
typename TypeImpl<Config>::Limits TypeImpl<Config>::ToLimits(bitset bits,
|
||||||
TypeHandle lhs, TypeHandle rhs,
|
Region* region) {
|
||||||
UnionHandle result, int size, Region* region) {
|
bitset representation = REPRESENTATION(bits);
|
||||||
|
bitset number_bits = BitsetType::NumberBits(bits);
|
||||||
|
|
||||||
|
if (representation == BitsetType::kNone && number_bits == BitsetType::kNone) {
|
||||||
|
return Limits::Empty(region);
|
||||||
|
}
|
||||||
|
|
||||||
|
double bitset_min = BitsetType::Min(number_bits);
|
||||||
|
double bitset_max = BitsetType::Max(number_bits);
|
||||||
|
|
||||||
|
// TODO(jarin) Get rid of the heap numbers.
|
||||||
|
i::Factory* f = i::Isolate::Current()->factory();
|
||||||
|
|
||||||
|
return Limits(f->NewNumber(bitset_min), f->NewNumber(bitset_max),
|
||||||
|
representation);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <class Config>
|
||||||
|
typename TypeImpl<Config>::Limits TypeImpl<Config>::IntersectRangeAndBitset(
|
||||||
|
TypeHandle range, TypeHandle bitset, Region* region) {
|
||||||
|
Limits range_lims(range->AsRange());
|
||||||
|
Limits bitset_lims = ToLimits(bitset->AsBitset(), region);
|
||||||
|
return Intersect(range_lims, bitset_lims);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <class Config>
|
||||||
|
int TypeImpl<Config>::IntersectAux(TypeHandle lhs, TypeHandle rhs,
|
||||||
|
UnionHandle result, int size, Limits* lims,
|
||||||
|
Region* region) {
|
||||||
if (lhs->IsUnion()) {
|
if (lhs->IsUnion()) {
|
||||||
for (int i = 0, n = lhs->AsUnion()->Length(); i < n; ++i) {
|
for (int i = 0, n = lhs->AsUnion()->Length(); i < n; ++i) {
|
||||||
size = IntersectAux(lhs->AsUnion()->Get(i), rhs, result, size, region);
|
size =
|
||||||
|
IntersectAux(lhs->AsUnion()->Get(i), rhs, result, size, lims, region);
|
||||||
}
|
}
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
if (rhs->IsUnion()) {
|
if (rhs->IsUnion()) {
|
||||||
for (int i = 0, n = rhs->AsUnion()->Length(); i < n; ++i) {
|
for (int i = 0, n = rhs->AsUnion()->Length(); i < n; ++i) {
|
||||||
size = IntersectAux(lhs, rhs->AsUnion()->Get(i), result, size, region);
|
size =
|
||||||
|
IntersectAux(lhs, rhs->AsUnion()->Get(i), result, size, lims, region);
|
||||||
}
|
}
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
@ -679,28 +809,32 @@ int TypeImpl<Config>::IntersectAux(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (lhs->IsRange()) {
|
if (lhs->IsRange()) {
|
||||||
if (rhs->IsBitset() || rhs->IsClass()) {
|
if (rhs->IsBitset()) {
|
||||||
return UpdateRange(
|
Limits lim = IntersectRangeAndBitset(lhs, rhs, region);
|
||||||
Config::template cast<RangeType>(lhs), result, size, region);
|
|
||||||
|
if (!IsEmpty(lim)) {
|
||||||
|
*lims = Union(lim, *lims);
|
||||||
|
}
|
||||||
|
return size;
|
||||||
}
|
}
|
||||||
if (rhs->IsConstant() &&
|
if (rhs->IsClass()) {
|
||||||
Contains(lhs->AsRange(), *rhs->AsConstant()->Value())) {
|
*lims = Union(Limits(lhs->AsRange()), *lims);
|
||||||
|
}
|
||||||
|
if (rhs->IsConstant() && Contains(lhs->AsRange(), rhs->AsConstant())) {
|
||||||
return AddToUnion(rhs, result, size, region);
|
return AddToUnion(rhs, result, size, region);
|
||||||
}
|
}
|
||||||
|
if (rhs->IsRange()) {
|
||||||
|
Limits lim = Intersect(Limits(lhs->AsRange()), Limits(rhs->AsRange()));
|
||||||
|
if (!IsEmpty(lim)) {
|
||||||
|
*lims = Union(lim, *lims);
|
||||||
|
}
|
||||||
|
}
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
if (rhs->IsRange()) {
|
if (rhs->IsRange()) {
|
||||||
if (lhs->IsBitset() || lhs->IsClass()) {
|
// This case is handled symmetrically above.
|
||||||
return UpdateRange(
|
return IntersectAux(rhs, lhs, result, size, lims, region);
|
||||||
Config::template cast<RangeType>(rhs), result, size, region);
|
|
||||||
}
|
|
||||||
if (lhs->IsConstant() &&
|
|
||||||
Contains(rhs->AsRange(), *lhs->AsConstant()->Value())) {
|
|
||||||
return AddToUnion(lhs, result, size, region);
|
|
||||||
}
|
|
||||||
return size;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lhs->IsBitset() || rhs->IsBitset()) {
|
if (lhs->IsBitset() || rhs->IsBitset()) {
|
||||||
return AddToUnion(lhs->IsBitset() ? rhs : lhs, result, size, region);
|
return AddToUnion(lhs->IsBitset() ? rhs : lhs, result, size, region);
|
||||||
}
|
}
|
||||||
@ -714,6 +848,67 @@ int TypeImpl<Config>::IntersectAux(
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 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.
|
||||||
|
template <class Config>
|
||||||
|
typename TypeImpl<Config>::TypeHandle TypeImpl<Config>::NormalizeRangeAndBitset(
|
||||||
|
RangeHandle range, bitset* bits, Region* region) {
|
||||||
|
// Fast path: If the bitset does not mention numbers, we can just keep the
|
||||||
|
// range.
|
||||||
|
bitset number_bits = BitsetType::NumberBits(*bits);
|
||||||
|
if (number_bits == 0) {
|
||||||
|
return range;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the range is contained within the bitset, return an empty range
|
||||||
|
// (but make sure we take the representation).
|
||||||
|
bitset range_lub = range->BitsetLub();
|
||||||
|
if (BitsetType::Is(BitsetType::NumberBits(range_lub), *bits)) {
|
||||||
|
*bits |= range_lub;
|
||||||
|
return None(region);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Slow path: reconcile the bitset range and the range.
|
||||||
|
double bitset_min = BitsetType::Min(number_bits);
|
||||||
|
double bitset_max = BitsetType::Max(number_bits);
|
||||||
|
|
||||||
|
i::Handle<i::Object> range_min_obj = range->Min();
|
||||||
|
i::Handle<i::Object> range_max_obj = range->Max();
|
||||||
|
double range_min = range_min_obj->Number();
|
||||||
|
double range_max = range_max_obj->Number();
|
||||||
|
|
||||||
|
bitset range_representation = REPRESENTATION(range->BitsetLub());
|
||||||
|
bitset bits_representation = REPRESENTATION(*bits);
|
||||||
|
bitset representation =
|
||||||
|
(bits_representation | range_representation) & BitsetType::kNumber;
|
||||||
|
|
||||||
|
// Remove the number bits from the bitset, they would just confuse us now.
|
||||||
|
*bits &= ~number_bits;
|
||||||
|
if (bits_representation == *bits) {
|
||||||
|
*bits = BitsetType::kNone;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (representation == range_representation && range_min <= bitset_min &&
|
||||||
|
range_max >= bitset_max) {
|
||||||
|
// Bitset is contained within the range, just return the range.
|
||||||
|
return range;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bitset_min < range_min) {
|
||||||
|
// TODO(jarin) Get rid of the heap numbers.
|
||||||
|
range_min_obj = i::Isolate::Current()->factory()->NewNumber(bitset_min);
|
||||||
|
}
|
||||||
|
if (bitset_max > range_max) {
|
||||||
|
// TODO(jarin) Get rid of the heap numbers.
|
||||||
|
range_max_obj = i::Isolate::Current()->factory()->NewNumber(bitset_max);
|
||||||
|
}
|
||||||
|
return RangeType::New(range_min_obj, range_max_obj,
|
||||||
|
BitsetType::New(representation, region), region);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Config>
|
template<class Config>
|
||||||
typename TypeImpl<Config>::TypeHandle TypeImpl<Config>::Union(
|
typename TypeImpl<Config>::TypeHandle TypeImpl<Config>::Union(
|
||||||
TypeHandle type1, TypeHandle type2, Region* region) {
|
TypeHandle type1, TypeHandle type2, Region* region) {
|
||||||
@ -741,22 +936,24 @@ typename TypeImpl<Config>::TypeHandle TypeImpl<Config>::Union(
|
|||||||
UnionHandle result = UnionType::New(size, region);
|
UnionHandle result = UnionType::New(size, region);
|
||||||
size = 0;
|
size = 0;
|
||||||
|
|
||||||
// Deal with bitsets.
|
// Compute the new bitset.
|
||||||
TypeHandle bits = BitsetType::New(
|
bitset new_bitset = type1->BitsetGlb() | type2->BitsetGlb();
|
||||||
type1->BitsetGlb() | type2->BitsetGlb(), region);
|
|
||||||
result->Set(size++, bits);
|
|
||||||
|
|
||||||
// Deal with ranges.
|
// Deal with ranges.
|
||||||
TypeHandle range = None(region);
|
TypeHandle range = None(region);
|
||||||
RangeType* range1 = type1->GetRange();
|
RangeType* range1 = type1->GetRange();
|
||||||
RangeType* range2 = type2->GetRange();
|
RangeType* range2 = type2->GetRange();
|
||||||
if (range1 != NULL && range2 != NULL) {
|
if (range1 != NULL && range2 != NULL) {
|
||||||
range = RangeType::New(Union(Limits(range1), Limits(range2)), region);
|
Limits lims = Union(Limits(range1), Limits(range2));
|
||||||
|
RangeHandle union_range = RangeType::New(lims, region);
|
||||||
|
range = NormalizeRangeAndBitset(union_range, &new_bitset, region);
|
||||||
} else if (range1 != NULL) {
|
} else if (range1 != NULL) {
|
||||||
range = handle(range1);
|
range = NormalizeRangeAndBitset(handle(range1), &new_bitset, region);
|
||||||
} else if (range2 != NULL) {
|
} else if (range2 != NULL) {
|
||||||
range = handle(range2);
|
range = NormalizeRangeAndBitset(handle(range2), &new_bitset, region);
|
||||||
}
|
}
|
||||||
|
TypeHandle bits = BitsetType::New(new_bitset, region);
|
||||||
|
result->Set(size++, bits);
|
||||||
result->Set(size++, range);
|
result->Set(size++, range);
|
||||||
|
|
||||||
size = AddToUnion(type1, result, size, region);
|
size = AddToUnion(type1, result, size, region);
|
||||||
@ -919,7 +1116,8 @@ typename TypeImpl<Config>::TypeHandle TypeImpl<Config>::Convert(
|
|||||||
return ConstantType::New(type->AsConstant()->Value(), region);
|
return ConstantType::New(type->AsConstant()->Value(), region);
|
||||||
} else if (type->IsRange()) {
|
} else if (type->IsRange()) {
|
||||||
return RangeType::New(
|
return RangeType::New(
|
||||||
type->AsRange()->Min(), type->AsRange()->Max(), region);
|
type->AsRange()->Min(), type->AsRange()->Max(),
|
||||||
|
BitsetType::New(REPRESENTATION(type->BitsetLub()), region), region);
|
||||||
} else if (type->IsContext()) {
|
} else if (type->IsContext()) {
|
||||||
TypeHandle outer = Convert<OtherType>(type->AsContext()->Outer(), region);
|
TypeHandle outer = Convert<OtherType>(type->AsContext()->Outer(), region);
|
||||||
return ContextType::New(outer, region);
|
return ContextType::New(outer, region);
|
||||||
@ -985,16 +1183,18 @@ void TypeImpl<Config>::BitsetType::Print(std::ostream& os, // NOLINT
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// clang-format off
|
||||||
static const bitset named_bitsets[] = {
|
static const bitset named_bitsets[] = {
|
||||||
#define BITSET_CONSTANT(type, value) REPRESENTATION(k##type),
|
#define BITSET_CONSTANT(type, value) REPRESENTATION(k##type),
|
||||||
REPRESENTATION_BITSET_TYPE_LIST(BITSET_CONSTANT)
|
REPRESENTATION_BITSET_TYPE_LIST(BITSET_CONSTANT)
|
||||||
#undef BITSET_CONSTANT
|
#undef BITSET_CONSTANT
|
||||||
|
|
||||||
#define BITSET_CONSTANT(type, value) SEMANTIC(k##type),
|
#define BITSET_CONSTANT(type, value) SEMANTIC(k##type),
|
||||||
INTERNAL_BITSET_TYPE_LIST(BITSET_CONSTANT)
|
INTERNAL_BITSET_TYPE_LIST(BITSET_CONSTANT)
|
||||||
SEMANTIC_BITSET_TYPE_LIST(BITSET_CONSTANT)
|
SEMANTIC_BITSET_TYPE_LIST(BITSET_CONSTANT)
|
||||||
#undef BITSET_CONSTANT
|
#undef BITSET_CONSTANT
|
||||||
};
|
};
|
||||||
|
// clang-format on
|
||||||
|
|
||||||
bool is_first = true;
|
bool is_first = true;
|
||||||
os << "(";
|
os << "(";
|
||||||
|
142
src/types.h
142
src/types.h
@ -153,6 +153,8 @@ namespace internal {
|
|||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// Values for bitset types
|
// Values for bitset types
|
||||||
|
|
||||||
|
// clang-format off
|
||||||
|
|
||||||
#define MASK_BITSET_TYPE_LIST(V) \
|
#define MASK_BITSET_TYPE_LIST(V) \
|
||||||
V(Representation, 0xfff00000u) \
|
V(Representation, 0xfff00000u) \
|
||||||
V(Semantic, 0x000ffffeu)
|
V(Semantic, 0x000ffffeu)
|
||||||
@ -195,11 +197,11 @@ namespace internal {
|
|||||||
V(OtherNumber, 1u << 4 | REPRESENTATION(kTagged | kUntaggedNumber))
|
V(OtherNumber, 1u << 4 | REPRESENTATION(kTagged | kUntaggedNumber))
|
||||||
|
|
||||||
#define SEMANTIC_BITSET_TYPE_LIST(V) \
|
#define SEMANTIC_BITSET_TYPE_LIST(V) \
|
||||||
V(NegativeSignedSmall, 1u << 5 | REPRESENTATION(kTagged | kUntaggedNumber)) \
|
V(Negative31, 1u << 5 | REPRESENTATION(kTagged | kUntaggedNumber)) \
|
||||||
V(Null, 1u << 6 | REPRESENTATION(kTaggedPointer)) \
|
V(Null, 1u << 6 | REPRESENTATION(kTaggedPointer)) \
|
||||||
V(Undefined, 1u << 7 | REPRESENTATION(kTaggedPointer)) \
|
V(Undefined, 1u << 7 | REPRESENTATION(kTaggedPointer)) \
|
||||||
V(Boolean, 1u << 8 | REPRESENTATION(kTaggedPointer)) \
|
V(Boolean, 1u << 8 | REPRESENTATION(kTaggedPointer)) \
|
||||||
V(UnsignedSmall, 1u << 9 | REPRESENTATION(kTagged | kUntaggedNumber)) \
|
V(Unsigned30, 1u << 9 | REPRESENTATION(kTagged | kUntaggedNumber)) \
|
||||||
V(MinusZero, 1u << 10 | REPRESENTATION(kTagged | kUntaggedNumber)) \
|
V(MinusZero, 1u << 10 | REPRESENTATION(kTagged | kUntaggedNumber)) \
|
||||||
V(NaN, 1u << 11 | REPRESENTATION(kTagged | kUntaggedNumber)) \
|
V(NaN, 1u << 11 | REPRESENTATION(kTagged | kUntaggedNumber)) \
|
||||||
V(Symbol, 1u << 12 | REPRESENTATION(kTaggedPointer)) \
|
V(Symbol, 1u << 12 | REPRESENTATION(kTaggedPointer)) \
|
||||||
@ -211,11 +213,11 @@ namespace internal {
|
|||||||
V(Proxy, 1u << 18 | REPRESENTATION(kTaggedPointer)) \
|
V(Proxy, 1u << 18 | REPRESENTATION(kTaggedPointer)) \
|
||||||
V(Internal, 1u << 19 | REPRESENTATION(kTagged | kUntagged)) \
|
V(Internal, 1u << 19 | REPRESENTATION(kTagged | kUntagged)) \
|
||||||
\
|
\
|
||||||
V(SignedSmall, kUnsignedSmall | kNegativeSignedSmall) \
|
V(Signed31, kUnsigned30 | kNegative31) \
|
||||||
V(Signed32, kSignedSmall | kOtherUnsigned31 | kOtherSigned32) \
|
V(Signed32, kSigned31 | kOtherUnsigned31 | kOtherSigned32) \
|
||||||
V(NegativeSigned32, kNegativeSignedSmall | kOtherSigned32) \
|
V(Negative32, kNegative31 | kOtherSigned32) \
|
||||||
V(NonNegativeSigned32, kUnsignedSmall | kOtherUnsigned31) \
|
V(Unsigned31, kUnsigned30 | kOtherUnsigned31) \
|
||||||
V(Unsigned32, kUnsignedSmall | kOtherUnsigned31 | kOtherUnsigned32) \
|
V(Unsigned32, kUnsigned30 | kOtherUnsigned31 | kOtherUnsigned32) \
|
||||||
V(Integral32, kSigned32 | kUnsigned32) \
|
V(Integral32, kSigned32 | kUnsigned32) \
|
||||||
V(PlainNumber, kIntegral32 | kOtherNumber) \
|
V(PlainNumber, kIntegral32 | kOtherNumber) \
|
||||||
V(OrderedNumber, kPlainNumber | kMinusZero) \
|
V(OrderedNumber, kPlainNumber | kMinusZero) \
|
||||||
@ -237,29 +239,17 @@ namespace internal {
|
|||||||
V(NonNumber, kUnique | kString | kInternal) \
|
V(NonNumber, kUnique | kString | kInternal) \
|
||||||
V(Any, 0xfffffffeu)
|
V(Any, 0xfffffffeu)
|
||||||
|
|
||||||
|
// clang-format on
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The following diagrams show how integers (in the mathematical sense) are
|
* The following diagrams show how integers (in the mathematical sense) are
|
||||||
* divided among the different atomic numerical types.
|
* divided among the different atomic numerical types.
|
||||||
*
|
*
|
||||||
* If SmiValuesAre31Bits():
|
* ON OS32 N31 U30 OU31 OU32 ON
|
||||||
*
|
|
||||||
* ON OS32 OSS US OU31 OU32 ON
|
|
||||||
* ______[_______[_______[_______[_______[_______[_______
|
* ______[_______[_______[_______[_______[_______[_______
|
||||||
* -2^31 -2^30 0 2^30 2^31 2^32
|
* -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.
|
* 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) \
|
#define PROPER_BITSET_TYPE_LIST(V) \
|
||||||
@ -345,6 +335,19 @@ class TypeImpl : public Config::Base {
|
|||||||
PROPER_BITSET_TYPE_LIST(DEFINE_TYPE_CONSTRUCTOR)
|
PROPER_BITSET_TYPE_LIST(DEFINE_TYPE_CONSTRUCTOR)
|
||||||
#undef 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) {
|
static TypeHandle Class(i::Handle<i::Map> map, Region* region) {
|
||||||
return ClassType::New(map, region);
|
return ClassType::New(map, region);
|
||||||
}
|
}
|
||||||
@ -353,7 +356,11 @@ class TypeImpl : public Config::Base {
|
|||||||
}
|
}
|
||||||
static TypeHandle Range(
|
static TypeHandle Range(
|
||||||
i::Handle<i::Object> min, i::Handle<i::Object> max, Region* region) {
|
i::Handle<i::Object> min, i::Handle<i::Object> max, Region* region) {
|
||||||
return RangeType::New(min, max, region);
|
return RangeType::New(
|
||||||
|
min, max, BitsetType::New(REPRESENTATION(BitsetType::kTagged |
|
||||||
|
BitsetType::kUntaggedNumber),
|
||||||
|
region),
|
||||||
|
region);
|
||||||
}
|
}
|
||||||
static TypeHandle Context(TypeHandle outer, Region* region) {
|
static TypeHandle Context(TypeHandle outer, Region* region) {
|
||||||
return ContextType::New(outer, region);
|
return ContextType::New(outer, region);
|
||||||
@ -560,31 +567,49 @@ class TypeImpl : public Config::Base {
|
|||||||
struct Limits {
|
struct Limits {
|
||||||
i::Handle<i::Object> min;
|
i::Handle<i::Object> min;
|
||||||
i::Handle<i::Object> max;
|
i::Handle<i::Object> max;
|
||||||
Limits(i::Handle<i::Object> min, i::Handle<i::Object> max) :
|
bitset representation;
|
||||||
min(min), max(max) {}
|
Limits(i::Handle<i::Object> min, i::Handle<i::Object> max,
|
||||||
explicit Limits(RangeType* range) :
|
bitset representation)
|
||||||
min(range->Min()), max(range->Max()) {}
|
: 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) {
|
||||||
|
// TODO(jarin) Get rid of the heap numbers.
|
||||||
|
i::Factory* f = i::Isolate::Current()->factory();
|
||||||
|
i::Handle<i::Object> min = f->NewNumber(1);
|
||||||
|
i::Handle<i::Object> max = f->NewNumber(0);
|
||||||
|
return Limits(min, max, BitsetType::kNone);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static bool IsEmpty(Limits lim);
|
||||||
static Limits Intersect(Limits lhs, Limits rhs);
|
static Limits Intersect(Limits lhs, Limits rhs);
|
||||||
static Limits Union(Limits lhs, Limits rhs);
|
static Limits Union(Limits lhs, Limits rhs);
|
||||||
static bool Overlap(RangeType* lhs, RangeType* rhs);
|
static bool Overlap(RangeType* lhs, RangeType* rhs);
|
||||||
static bool Contains(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 bool Contains(RangeType* range, i::Object* val);
|
||||||
|
|
||||||
static int UpdateRange(
|
static int UpdateRange(
|
||||||
RangeHandle type, UnionHandle result, int size, Region* region);
|
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);
|
bool SimplyEquals(TypeImpl* that);
|
||||||
template<class TypeHandle>
|
template<class TypeHandle>
|
||||||
bool SimplyEquals(TypeHandle that) { return this->SimplyEquals(*that); }
|
bool SimplyEquals(TypeHandle that) { return this->SimplyEquals(*that); }
|
||||||
|
|
||||||
static int AddToUnion(
|
static int AddToUnion(
|
||||||
TypeHandle type, UnionHandle result, int size, Region* region);
|
TypeHandle type, UnionHandle result, int size, Region* region);
|
||||||
static int IntersectAux(
|
static int IntersectAux(TypeHandle type, TypeHandle other, UnionHandle result,
|
||||||
TypeHandle type, TypeHandle other,
|
int size, Limits* limits, Region* region);
|
||||||
UnionHandle result, int size, Region* region);
|
|
||||||
static TypeHandle NormalizeUnion(UnionHandle unioned, int size);
|
static TypeHandle NormalizeUnion(UnionHandle unioned, int size);
|
||||||
|
static TypeHandle NormalizeRangeAndBitset(RangeHandle range, bitset* bits,
|
||||||
|
Region* region);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -603,28 +628,17 @@ class TypeImpl<Config>::BitsetType : public TypeImpl<Config> {
|
|||||||
kUnusedEOL = 0
|
kUnusedEOL = 0
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static bitset SignedSmall();
|
||||||
|
static bitset UnsignedSmall();
|
||||||
|
|
||||||
bitset Bitset() { return Config::as_bitset(this); }
|
bitset Bitset() { return Config::as_bitset(this); }
|
||||||
|
|
||||||
static TypeImpl* New(bitset bits) {
|
static TypeImpl* New(bitset bits) {
|
||||||
DCHECK(bits == kNone || IsInhabited(bits));
|
if (FLAG_enable_slow_asserts) CheckNumberBits(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);
|
return Config::from_bitset(bits);
|
||||||
}
|
}
|
||||||
static TypeHandle New(bitset bits, Region* region) {
|
static TypeHandle New(bitset bits, Region* region) {
|
||||||
DCHECK(bits == kNone || IsInhabited(bits));
|
if (FLAG_enable_slow_asserts) CheckNumberBits(bits);
|
||||||
return Config::from_bitset(bits, region);
|
return Config::from_bitset(bits, region);
|
||||||
}
|
}
|
||||||
// TODO(neis): Eventually allow again for types with empty semantics
|
// TODO(neis): Eventually allow again for types with empty semantics
|
||||||
@ -642,6 +656,7 @@ class TypeImpl<Config>::BitsetType : public TypeImpl<Config> {
|
|||||||
static double Max(bitset);
|
static double Max(bitset);
|
||||||
|
|
||||||
static bitset Glb(TypeImpl* type); // greatest lower bound that's a 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(TypeImpl* type); // least upper bound that's a bitset
|
||||||
static bitset Lub(i::Map* map);
|
static bitset Lub(i::Map* map);
|
||||||
static bitset Lub(i::Object* value);
|
static bitset Lub(i::Object* value);
|
||||||
@ -654,21 +669,18 @@ class TypeImpl<Config>::BitsetType : public TypeImpl<Config> {
|
|||||||
static void Print(bitset);
|
static void Print(bitset);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static bitset NumberBits(bitset bits);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct BitsetMin{
|
struct Boundary {
|
||||||
bitset bits;
|
bitset bits;
|
||||||
double min;
|
double min;
|
||||||
};
|
};
|
||||||
static const BitsetMin BitsetMins31[];
|
static const Boundary BoundariesArray[];
|
||||||
static const BitsetMin BitsetMins32[];
|
static inline const Boundary* Boundaries();
|
||||||
static const BitsetMin* BitsetMins() {
|
static inline size_t BoundariesSize();
|
||||||
return i::SmiValuesAre31Bits() ? BitsetMins31 : BitsetMins32;
|
|
||||||
}
|
static void CheckNumberBits(bitset bits);
|
||||||
static size_t BitsetMinsSize() {
|
|
||||||
return i::SmiValuesAre31Bits() ? 7 : 5;
|
|
||||||
/* arraysize(BitsetMins31) : arraysize(BitsetMins32); */
|
|
||||||
// Using arraysize here doesn't compile on Windows.
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -815,25 +827,31 @@ class TypeImpl<Config>::ConstantType : public StructuralType {
|
|||||||
template<class Config>
|
template<class Config>
|
||||||
class TypeImpl<Config>::RangeType : public StructuralType {
|
class TypeImpl<Config>::RangeType : public StructuralType {
|
||||||
public:
|
public:
|
||||||
int BitsetLub() { return this->Get(0)->AsBitset(); }
|
TypeHandle Bound() { return this->Get(0); }
|
||||||
i::Handle<i::Object> Min() { return this->template GetValue<i::Object>(1); }
|
i::Handle<i::Object> Min() { return this->template GetValue<i::Object>(1); }
|
||||||
i::Handle<i::Object> Max() { return this->template GetValue<i::Object>(2); }
|
i::Handle<i::Object> Max() { return this->template GetValue<i::Object>(2); }
|
||||||
|
|
||||||
static RangeHandle New(
|
static RangeHandle New(i::Handle<i::Object> min, i::Handle<i::Object> max,
|
||||||
i::Handle<i::Object> min, i::Handle<i::Object> max, Region* region) {
|
TypeHandle representation, Region* region) {
|
||||||
DCHECK(IsInteger(min->Number()) && IsInteger(max->Number()));
|
DCHECK(IsInteger(min->Number()) && IsInteger(max->Number()));
|
||||||
DCHECK(min->Number() <= max->Number());
|
DCHECK(min->Number() <= max->Number());
|
||||||
|
bitset representation_bits = representation->AsBitset();
|
||||||
|
DCHECK(REPRESENTATION(representation_bits) == representation_bits);
|
||||||
|
|
||||||
RangeHandle type = Config::template cast<RangeType>(
|
RangeHandle type = Config::template cast<RangeType>(
|
||||||
StructuralType::New(StructuralType::kRangeTag, 3, region));
|
StructuralType::New(StructuralType::kRangeTag, 3, region));
|
||||||
type->Set(0, BitsetType::New(
|
|
||||||
BitsetType::Lub(min->Number(), max->Number()), region));
|
bitset bits = SEMANTIC(BitsetType::Lub(min->Number(), max->Number())) |
|
||||||
|
representation_bits;
|
||||||
|
type->Set(0, BitsetType::New(bits, region));
|
||||||
type->SetValue(1, min);
|
type->SetValue(1, min);
|
||||||
type->SetValue(2, max);
|
type->SetValue(2, max);
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
static RangeHandle New(Limits lim, Region* region) {
|
static RangeHandle New(Limits lim, Region* region) {
|
||||||
return New(lim.min, lim.max, region);
|
return New(lim.min, lim.max, BitsetType::New(lim.representation, region),
|
||||||
|
region);
|
||||||
}
|
}
|
||||||
|
|
||||||
static RangeType* cast(TypeImpl* type) {
|
static RangeType* cast(TypeImpl* type) {
|
||||||
|
@ -176,20 +176,17 @@ static Type* kStringTypes[] = {Type::InternalizedString(), Type::OtherString(),
|
|||||||
Type::String()};
|
Type::String()};
|
||||||
|
|
||||||
|
|
||||||
static Type* kInt32Types[] = {
|
static Type* kInt32Types[] = {Type::UnsignedSmall(), Type::Negative32(),
|
||||||
Type::UnsignedSmall(), Type::NegativeSigned32(),
|
Type::Unsigned31(), Type::SignedSmall(),
|
||||||
Type::NonNegativeSigned32(), Type::SignedSmall(),
|
Type::Signed32(), Type::Unsigned32(),
|
||||||
Type::Signed32(), Type::Unsigned32(),
|
Type::Integral32()};
|
||||||
Type::Integral32()};
|
|
||||||
|
|
||||||
|
|
||||||
static Type* kNumberTypes[] = {
|
static Type* kNumberTypes[] = {
|
||||||
Type::UnsignedSmall(), Type::NegativeSigned32(),
|
Type::UnsignedSmall(), Type::Negative32(), Type::Unsigned31(),
|
||||||
Type::NonNegativeSigned32(), Type::SignedSmall(),
|
Type::SignedSmall(), Type::Signed32(), Type::Unsigned32(),
|
||||||
Type::Signed32(), Type::Unsigned32(),
|
Type::Integral32(), Type::MinusZero(), Type::NaN(),
|
||||||
Type::Integral32(), Type::MinusZero(),
|
Type::OrderedNumber(), Type::PlainNumber(), Type::Number()};
|
||||||
Type::NaN(), Type::OrderedNumber(),
|
|
||||||
Type::PlainNumber(), Type::Number()};
|
|
||||||
|
|
||||||
|
|
||||||
static Type* kJSTypes[] = {Type::Undefined(), Type::Null(), Type::Boolean(),
|
static Type* kJSTypes[] = {Type::Undefined(), Type::Null(), Type::Boolean(),
|
||||||
@ -316,13 +313,12 @@ class JSBitwiseShiftTypedLoweringTester : public JSTypedLoweringTester {
|
|||||||
TEST(Int32BitwiseShifts) {
|
TEST(Int32BitwiseShifts) {
|
||||||
JSBitwiseShiftTypedLoweringTester R;
|
JSBitwiseShiftTypedLoweringTester R;
|
||||||
|
|
||||||
Type* types[] = {Type::SignedSmall(), Type::UnsignedSmall(),
|
Type* types[] = {
|
||||||
Type::NegativeSigned32(), Type::NonNegativeSigned32(),
|
Type::SignedSmall(), Type::UnsignedSmall(), Type::Negative32(),
|
||||||
Type::Unsigned32(), Type::Signed32(),
|
Type::Unsigned31(), Type::Unsigned32(), Type::Signed32(),
|
||||||
Type::MinusZero(), Type::NaN(),
|
Type::MinusZero(), Type::NaN(), Type::Undefined(),
|
||||||
Type::Undefined(), Type::Null(),
|
Type::Null(), Type::Boolean(), Type::Number(),
|
||||||
Type::Boolean(), Type::Number(),
|
Type::PlainNumber(), Type::String()};
|
||||||
Type::PlainNumber(), Type::String()};
|
|
||||||
|
|
||||||
for (size_t i = 0; i < arraysize(types); ++i) {
|
for (size_t i = 0; i < arraysize(types); ++i) {
|
||||||
Node* p0 = R.Parameter(types[i], 0);
|
Node* p0 = R.Parameter(types[i], 0);
|
||||||
|
@ -135,6 +135,14 @@ struct Tests : Rep {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CheckSubOrEqual(TypeHandle type1, TypeHandle type2) {
|
||||||
|
CHECK(type1->Is(type2));
|
||||||
|
if (this->IsBitset(type1) && this->IsBitset(type2)) {
|
||||||
|
CHECK((this->AsBitset(type1) | this->AsBitset(type2))
|
||||||
|
== this->AsBitset(type2));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CheckUnordered(TypeHandle type1, TypeHandle type2) {
|
void CheckUnordered(TypeHandle type1, TypeHandle type2) {
|
||||||
CHECK(!type1->Is(type2));
|
CHECK(!type1->Is(type2));
|
||||||
CHECK(!type2->Is(type1));
|
CHECK(!type2->Is(type1));
|
||||||
@ -293,39 +301,33 @@ struct Tests : Rep {
|
|||||||
CHECK(T.Constant(fac->NewNumber(0))->Is(T.UnsignedSmall));
|
CHECK(T.Constant(fac->NewNumber(0))->Is(T.UnsignedSmall));
|
||||||
CHECK(T.Constant(fac->NewNumber(1))->Is(T.UnsignedSmall));
|
CHECK(T.Constant(fac->NewNumber(1))->Is(T.UnsignedSmall));
|
||||||
CHECK(T.Constant(fac->NewNumber(0x3fffffff))->Is(T.UnsignedSmall));
|
CHECK(T.Constant(fac->NewNumber(0x3fffffff))->Is(T.UnsignedSmall));
|
||||||
CHECK(T.Constant(fac->NewNumber(-1))->Is(T.NegativeSignedSmall));
|
CHECK(T.Constant(fac->NewNumber(-1))->Is(T.Negative31));
|
||||||
CHECK(T.Constant(fac->NewNumber(-0x3fffffff))->Is(T.NegativeSignedSmall));
|
CHECK(T.Constant(fac->NewNumber(-0x3fffffff))->Is(T.Negative31));
|
||||||
CHECK(T.Constant(fac->NewNumber(-0x40000000))->Is(T.NegativeSignedSmall));
|
CHECK(T.Constant(fac->NewNumber(-0x40000000))->Is(T.Negative31));
|
||||||
|
CHECK(T.Constant(fac->NewNumber(0x40000000))->Is(T.Unsigned31));
|
||||||
|
CHECK(!T.Constant(fac->NewNumber(0x40000000))->Is(T.Unsigned30));
|
||||||
|
CHECK(T.Constant(fac->NewNumber(0x7fffffff))->Is(T.Unsigned31));
|
||||||
|
CHECK(!T.Constant(fac->NewNumber(0x7fffffff))->Is(T.Unsigned30));
|
||||||
|
CHECK(T.Constant(fac->NewNumber(-0x40000001))->Is(T.Negative32));
|
||||||
|
CHECK(!T.Constant(fac->NewNumber(-0x40000001))->Is(T.Negative31));
|
||||||
|
CHECK(T.Constant(fac->NewNumber(-0x7fffffff))->Is(T.Negative32));
|
||||||
|
CHECK(!T.Constant(fac->NewNumber(-0x7fffffff - 1))->Is(T.Negative31));
|
||||||
if (SmiValuesAre31Bits()) {
|
if (SmiValuesAre31Bits()) {
|
||||||
CHECK(T.Constant(fac->NewNumber(0x40000000))->Is(T.NonNegativeSigned32));
|
|
||||||
CHECK(!T.Constant(fac->NewNumber(0x40000000))->Is(T.UnsignedSmall));
|
CHECK(!T.Constant(fac->NewNumber(0x40000000))->Is(T.UnsignedSmall));
|
||||||
CHECK(T.Constant(fac->NewNumber(0x7fffffff))->Is(T.NonNegativeSigned32));
|
|
||||||
CHECK(!T.Constant(fac->NewNumber(0x7fffffff))->Is(T.UnsignedSmall));
|
CHECK(!T.Constant(fac->NewNumber(0x7fffffff))->Is(T.UnsignedSmall));
|
||||||
CHECK(T.Constant(fac->NewNumber(-0x40000001))->Is(T.NegativeSigned32));
|
CHECK(!T.Constant(fac->NewNumber(-0x40000001))->Is(T.SignedSmall));
|
||||||
CHECK(
|
CHECK(!T.Constant(fac->NewNumber(-0x7fffffff - 1))->Is(T.SignedSmall));
|
||||||
!T.Constant(fac->NewNumber(-0x40000001))->Is(T.NegativeSignedSmall));
|
|
||||||
CHECK(T.Constant(fac->NewNumber(-0x7fffffff))->Is(T.NegativeSigned32));
|
|
||||||
CHECK(!T.Constant(fac->NewNumber(-0x7fffffff - 1))
|
|
||||||
->Is(T.NegativeSignedSmall));
|
|
||||||
} else {
|
} else {
|
||||||
CHECK(SmiValuesAre32Bits());
|
CHECK(SmiValuesAre32Bits());
|
||||||
CHECK(T.Constant(fac->NewNumber(0x40000000))->Is(T.UnsignedSmall));
|
CHECK(T.Constant(fac->NewNumber(0x40000000))->Is(T.UnsignedSmall));
|
||||||
CHECK(T.Constant(fac->NewNumber(0x7fffffff))->Is(T.UnsignedSmall));
|
CHECK(T.Constant(fac->NewNumber(0x7fffffff))->Is(T.UnsignedSmall));
|
||||||
CHECK(T.Constant(fac->NewNumber(0x40000000))->Is(T.NonNegativeSigned32));
|
CHECK(T.Constant(fac->NewNumber(-0x40000001))->Is(T.SignedSmall));
|
||||||
CHECK(T.Constant(fac->NewNumber(0x7fffffff))->Is(T.NonNegativeSigned32));
|
CHECK(T.Constant(fac->NewNumber(-0x7fffffff - 1))->Is(T.SignedSmall));
|
||||||
CHECK(T.Constant(fac->NewNumber(-0x40000001))->Is(T.NegativeSignedSmall));
|
|
||||||
CHECK(T.Constant(fac->NewNumber(-0x7fffffff))->Is(T.NegativeSignedSmall));
|
|
||||||
CHECK(T.Constant(fac->NewNumber(-0x7fffffff - 1))
|
|
||||||
->Is(T.NegativeSignedSmall));
|
|
||||||
CHECK(T.Constant(fac->NewNumber(-0x40000001))->Is(T.NegativeSigned32));
|
|
||||||
CHECK(T.Constant(fac->NewNumber(-0x7fffffff))->Is(T.NegativeSigned32));
|
|
||||||
CHECK(
|
|
||||||
T.Constant(fac->NewNumber(-0x7fffffff - 1))->Is(T.NegativeSigned32));
|
|
||||||
}
|
}
|
||||||
CHECK(T.Constant(fac->NewNumber(0x80000000u))->Is(T.Unsigned32));
|
CHECK(T.Constant(fac->NewNumber(0x80000000u))->Is(T.Unsigned32));
|
||||||
CHECK(!T.Constant(fac->NewNumber(0x80000000u))->Is(T.NonNegativeSigned32));
|
CHECK(!T.Constant(fac->NewNumber(0x80000000u))->Is(T.Unsigned31));
|
||||||
CHECK(T.Constant(fac->NewNumber(0xffffffffu))->Is(T.Unsigned32));
|
CHECK(T.Constant(fac->NewNumber(0xffffffffu))->Is(T.Unsigned32));
|
||||||
CHECK(!T.Constant(fac->NewNumber(0xffffffffu))->Is(T.NonNegativeSigned32));
|
CHECK(!T.Constant(fac->NewNumber(0xffffffffu))->Is(T.Unsigned31));
|
||||||
CHECK(T.Constant(fac->NewNumber(0xffffffffu + 1.0))->Is(T.PlainNumber));
|
CHECK(T.Constant(fac->NewNumber(0xffffffffu + 1.0))->Is(T.PlainNumber));
|
||||||
CHECK(!T.Constant(fac->NewNumber(0xffffffffu + 1.0))->Is(T.Integral32));
|
CHECK(!T.Constant(fac->NewNumber(0xffffffffu + 1.0))->Is(T.Integral32));
|
||||||
CHECK(T.Constant(fac->NewNumber(-0x7fffffff - 2.0))->Is(T.PlainNumber));
|
CHECK(T.Constant(fac->NewNumber(-0x7fffffff - 2.0))->Is(T.PlainNumber));
|
||||||
@ -795,6 +797,7 @@ struct Tests : Rep {
|
|||||||
(type1->IsClass() && type2->IsClass()) ||
|
(type1->IsClass() && type2->IsClass()) ||
|
||||||
(type1->IsConstant() && type2->IsConstant()) ||
|
(type1->IsConstant() && type2->IsConstant()) ||
|
||||||
(type1->IsConstant() && type2->IsRange()) ||
|
(type1->IsConstant() && type2->IsRange()) ||
|
||||||
|
(this->IsBitset(type1) && type2->IsRange()) ||
|
||||||
(type1->IsRange() && type2->IsRange()) ||
|
(type1->IsRange() && type2->IsRange()) ||
|
||||||
(type1->IsContext() && type2->IsContext()) ||
|
(type1->IsContext() && type2->IsContext()) ||
|
||||||
(type1->IsArray() && type2->IsArray()) ||
|
(type1->IsArray() && type2->IsArray()) ||
|
||||||
@ -933,7 +936,7 @@ struct Tests : Rep {
|
|||||||
|
|
||||||
CheckSub(T.SignedSmall, T.Number);
|
CheckSub(T.SignedSmall, T.Number);
|
||||||
CheckSub(T.Signed32, T.Number);
|
CheckSub(T.Signed32, T.Number);
|
||||||
CheckSub(T.SignedSmall, T.Signed32);
|
CheckSubOrEqual(T.SignedSmall, T.Signed32);
|
||||||
CheckUnordered(T.SignedSmall, T.MinusZero);
|
CheckUnordered(T.SignedSmall, T.MinusZero);
|
||||||
CheckUnordered(T.Signed32, T.Unsigned32);
|
CheckUnordered(T.Signed32, T.Unsigned32);
|
||||||
|
|
||||||
@ -1477,8 +1480,8 @@ struct Tests : Rep {
|
|||||||
CheckDisjoint(T.Union(T.NumberFunction1, T.String), T.Number);
|
CheckDisjoint(T.Union(T.NumberFunction1, T.String), T.Number);
|
||||||
|
|
||||||
// Bitset-class
|
// Bitset-class
|
||||||
CheckSub(
|
CheckSub(T.Union(T.ObjectClass, T.SignedSmall),
|
||||||
T.Union(T.ObjectClass, T.SignedSmall), T.Union(T.Object, T.Number));
|
T.Union(T.Object, T.Number));
|
||||||
CheckSub(T.Union(T.ObjectClass, T.Array), T.Object);
|
CheckSub(T.Union(T.ObjectClass, T.Array), T.Object);
|
||||||
CheckUnordered(T.Union(T.ObjectClass, T.String), T.Array);
|
CheckUnordered(T.Union(T.ObjectClass, T.String), T.Array);
|
||||||
CheckOverlap(T.Union(T.ObjectClass, T.String), T.Object);
|
CheckOverlap(T.Union(T.ObjectClass, T.String), T.Object);
|
||||||
@ -1548,11 +1551,9 @@ struct Tests : Rep {
|
|||||||
T.Union(T.ObjectConstant2, T.ObjectConstant1),
|
T.Union(T.ObjectConstant2, T.ObjectConstant1),
|
||||||
T.Union(T.ObjectConstant1, T.ObjectConstant2)),
|
T.Union(T.ObjectConstant1, T.ObjectConstant2)),
|
||||||
T.Union(T.ObjectConstant2, T.ObjectConstant1));
|
T.Union(T.ObjectConstant2, T.ObjectConstant1));
|
||||||
CheckEqual(
|
CheckEqual(T.Union(T.Union(T.Number, T.ArrayClass),
|
||||||
T.Union(
|
T.Union(T.SignedSmall, T.Array)),
|
||||||
T.Union(T.Number, T.ArrayClass),
|
T.Union(T.Number, T.Array));
|
||||||
T.Union(T.SignedSmall, T.Array)),
|
|
||||||
T.Union(T.Number, T.Array));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Intersect() {
|
void Intersect() {
|
||||||
@ -1766,11 +1767,9 @@ struct Tests : Rep {
|
|||||||
->IsInhabited()); // !!!
|
->IsInhabited()); // !!!
|
||||||
|
|
||||||
// Union-union
|
// Union-union
|
||||||
CheckEqual(
|
CheckEqual(T.Intersect(T.Union(T.Number, T.ArrayClass),
|
||||||
T.Intersect(
|
T.Union(T.SignedSmall, T.Array)),
|
||||||
T.Union(T.Number, T.ArrayClass),
|
T.Union(T.SignedSmall, T.ArrayClass));
|
||||||
T.Union(T.SignedSmall, T.Array)),
|
|
||||||
T.Union(T.SignedSmall, T.ArrayClass));
|
|
||||||
CheckEqual(
|
CheckEqual(
|
||||||
T.Intersect(
|
T.Intersect(
|
||||||
T.Union(T.Number, T.ObjectClass),
|
T.Union(T.Number, T.ObjectClass),
|
||||||
|
@ -45,6 +45,9 @@ class Types {
|
|||||||
PROPER_BITSET_TYPE_LIST(DECLARE_TYPE)
|
PROPER_BITSET_TYPE_LIST(DECLARE_TYPE)
|
||||||
#undef DECLARE_TYPE
|
#undef DECLARE_TYPE
|
||||||
|
|
||||||
|
SignedSmall = Type::SignedSmall(region);
|
||||||
|
UnsignedSmall = Type::UnsignedSmall(region);
|
||||||
|
|
||||||
object_map = isolate->factory()->NewMap(
|
object_map = isolate->factory()->NewMap(
|
||||||
JS_OBJECT_TYPE, JSObject::kHeaderSize);
|
JS_OBJECT_TYPE, JSObject::kHeaderSize);
|
||||||
array_map = isolate->factory()->NewMap(
|
array_map = isolate->factory()->NewMap(
|
||||||
@ -130,6 +133,8 @@ class Types {
|
|||||||
#define DECLARE_TYPE(name, value) TypeHandle name;
|
#define DECLARE_TYPE(name, value) TypeHandle name;
|
||||||
PROPER_BITSET_TYPE_LIST(DECLARE_TYPE)
|
PROPER_BITSET_TYPE_LIST(DECLARE_TYPE)
|
||||||
#undef DECLARE_TYPE
|
#undef DECLARE_TYPE
|
||||||
|
TypeHandle SignedSmall;
|
||||||
|
TypeHandle UnsignedSmall;
|
||||||
|
|
||||||
TypeHandle ObjectClass;
|
TypeHandle ObjectClass;
|
||||||
TypeHandle ArrayClass;
|
TypeHandle ArrayClass;
|
||||||
|
@ -211,7 +211,7 @@ TARGET_TEST_F(ChangeLowering32Test, ChangeInt32ToTagged) {
|
|||||||
TARGET_TEST_F(ChangeLowering32Test, ChangeInt32ToTaggedSmall) {
|
TARGET_TEST_F(ChangeLowering32Test, ChangeInt32ToTaggedSmall) {
|
||||||
Node* val = Parameter(0);
|
Node* val = Parameter(0);
|
||||||
Node* node = graph()->NewNode(simplified()->ChangeInt32ToTagged(), val);
|
Node* node = graph()->NewNode(simplified()->ChangeInt32ToTagged(), val);
|
||||||
NodeProperties::SetBounds(val, Bounds(Type::None(), Type::SignedSmall()));
|
NodeProperties::SetBounds(val, Bounds(Type::None(), Type::Signed31()));
|
||||||
Reduction reduction = Reduce(node);
|
Reduction reduction = Reduce(node);
|
||||||
ASSERT_TRUE(reduction.Changed());
|
ASSERT_TRUE(reduction.Changed());
|
||||||
|
|
||||||
|
@ -53,12 +53,10 @@ namespace {
|
|||||||
|
|
||||||
// TODO(mstarzinger): Find a common place and unify with test-js-typed-lowering.
|
// TODO(mstarzinger): Find a common place and unify with test-js-typed-lowering.
|
||||||
Type* const kNumberTypes[] = {
|
Type* const kNumberTypes[] = {
|
||||||
Type::UnsignedSmall(), Type::NegativeSigned32(),
|
Type::UnsignedSmall(), Type::Negative32(), Type::Unsigned31(),
|
||||||
Type::NonNegativeSigned32(), Type::SignedSmall(),
|
Type::SignedSmall(), Type::Signed32(), Type::Unsigned32(),
|
||||||
Type::Signed32(), Type::Unsigned32(),
|
Type::Integral32(), Type::MinusZero(), Type::NaN(),
|
||||||
Type::Integral32(), Type::MinusZero(),
|
Type::OrderedNumber(), Type::PlainNumber(), Type::Number()};
|
||||||
Type::NaN(), Type::OrderedNumber(),
|
|
||||||
Type::PlainNumber(), Type::Number()};
|
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user