[compiler] Don't call Type::Min/Max on the empty type.
This is a cleanup. R=jarin@chromium.org Bug: Change-Id: I1621fde3f2a7da03ceca781b96d5ffec44eb8168 Reviewed-on: https://chromium-review.googlesource.com/758373 Reviewed-by: Jaroslav Sevcik <jarin@chromium.org> Commit-Queue: Georg Neis <neis@chromium.org> Cr-Commit-Position: refs/heads/master@{#49225}
This commit is contained in:
parent
7223024658
commit
9d557e0ec4
@ -287,22 +287,24 @@ Type* OperationTyper::NumberAbs(Type* type) {
|
|||||||
return Type::None();
|
return Type::None();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool const maybe_nan = type->Maybe(Type::NaN());
|
|
||||||
bool const maybe_minuszero = type->Maybe(Type::MinusZero());
|
|
||||||
type = Type::Intersect(type, Type::PlainNumber(), zone());
|
type = Type::Intersect(type, Type::PlainNumber(), zone());
|
||||||
double const max = type->Max();
|
if (type->IsInhabited()) {
|
||||||
double const min = type->Min();
|
double const max = type->Max();
|
||||||
if (min < 0) {
|
double const min = type->Min();
|
||||||
if (type->Is(cache_.kInteger)) {
|
if (min < 0) {
|
||||||
type = Type::Range(0.0, std::max(std::fabs(min), std::fabs(max)), zone());
|
if (type->Is(cache_.kInteger)) {
|
||||||
} else {
|
type =
|
||||||
type = Type::PlainNumber();
|
Type::Range(0.0, std::max(std::fabs(min), std::fabs(max)), zone());
|
||||||
|
} else {
|
||||||
|
type = Type::PlainNumber();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (maybe_minuszero) {
|
|
||||||
|
if (type->Maybe(Type::NaN())) {
|
||||||
type = Type::Union(type, cache_.kSingletonZero, zone());
|
type = Type::Union(type, cache_.kSingletonZero, zone());
|
||||||
}
|
}
|
||||||
if (maybe_nan) {
|
if (type->Maybe(Type::MinusZero())) {
|
||||||
type = Type::Union(type, Type::NaN(), zone());
|
type = Type::Union(type, Type::NaN(), zone());
|
||||||
}
|
}
|
||||||
return type;
|
return type;
|
||||||
@ -683,6 +685,8 @@ Type* OperationTyper::NumberModulus(Type* lhs, Type* rhs) {
|
|||||||
DCHECK(lhs->Is(Type::Number()));
|
DCHECK(lhs->Is(Type::Number()));
|
||||||
DCHECK(rhs->Is(Type::Number()));
|
DCHECK(rhs->Is(Type::Number()));
|
||||||
|
|
||||||
|
if (!lhs->IsInhabited() || !rhs->IsInhabited()) return Type::None();
|
||||||
|
|
||||||
// Modulus can yield NaN if either {lhs} or {rhs} are NaN, or
|
// Modulus can yield NaN if either {lhs} or {rhs} are NaN, or
|
||||||
// {lhs} is not finite, or the {rhs} is a zero value.
|
// {lhs} is not finite, or the {rhs} is a zero value.
|
||||||
bool maybe_nan = lhs->Maybe(Type::NaN()) || rhs->Maybe(cache_.kZeroish) ||
|
bool maybe_nan = lhs->Maybe(Type::NaN()) || rhs->Maybe(cache_.kZeroish) ||
|
||||||
|
@ -461,6 +461,7 @@ Type* Typer::Visitor::ToInteger(Type* type, Typer* t) {
|
|||||||
Type* Typer::Visitor::ToLength(Type* type, Typer* t) {
|
Type* Typer::Visitor::ToLength(Type* type, Typer* t) {
|
||||||
// ES6 section 7.1.15 ToLength ( argument )
|
// ES6 section 7.1.15 ToLength ( argument )
|
||||||
type = ToInteger(type, t);
|
type = ToInteger(type, t);
|
||||||
|
if (!type->IsInhabited()) return Type::None();
|
||||||
double min = type->Min();
|
double min = type->Min();
|
||||||
double max = type->Max();
|
double max = type->Max();
|
||||||
if (max <= 0.0) {
|
if (max <= 0.0) {
|
||||||
|
@ -67,13 +67,16 @@ bool Type::Contains(RangeType* range, i::Object* val) {
|
|||||||
// Min and Max computation.
|
// Min and Max computation.
|
||||||
|
|
||||||
double Type::Min() {
|
double Type::Min() {
|
||||||
|
DCHECK(this->IsInhabited());
|
||||||
DCHECK(this->Is(Number()));
|
DCHECK(this->Is(Number()));
|
||||||
if (this->IsBitset()) return BitsetType::Min(this->AsBitset());
|
if (this->IsBitset()) return BitsetType::Min(this->AsBitset());
|
||||||
if (this->IsUnion()) {
|
if (this->IsUnion()) {
|
||||||
double min = +V8_INFINITY;
|
double min = +V8_INFINITY;
|
||||||
for (int i = 0, n = this->AsUnion()->Length(); i < n; ++i) {
|
for (int i = 1, n = this->AsUnion()->Length(); i < n; ++i) {
|
||||||
min = std::min(min, this->AsUnion()->Get(i)->Min());
|
min = std::min(min, this->AsUnion()->Get(i)->Min());
|
||||||
}
|
}
|
||||||
|
Type* bitset = this->AsUnion()->Get(0);
|
||||||
|
if (bitset->IsInhabited()) min = std::min(min, bitset->Min());
|
||||||
return min;
|
return min;
|
||||||
}
|
}
|
||||||
if (this->IsRange()) return this->AsRange()->Min();
|
if (this->IsRange()) return this->AsRange()->Min();
|
||||||
@ -83,13 +86,16 @@ double Type::Min() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
double Type::Max() {
|
double Type::Max() {
|
||||||
|
DCHECK(this->IsInhabited());
|
||||||
DCHECK(this->Is(Number()));
|
DCHECK(this->Is(Number()));
|
||||||
if (this->IsBitset()) return BitsetType::Max(this->AsBitset());
|
if (this->IsBitset()) return BitsetType::Max(this->AsBitset());
|
||||||
if (this->IsUnion()) {
|
if (this->IsUnion()) {
|
||||||
double max = -V8_INFINITY;
|
double max = -V8_INFINITY;
|
||||||
for (int i = 0, n = this->AsUnion()->Length(); i < n; ++i) {
|
for (int i = 1, n = this->AsUnion()->Length(); i < n; ++i) {
|
||||||
max = std::max(max, this->AsUnion()->Get(i)->Max());
|
max = std::max(max, this->AsUnion()->Get(i)->Max());
|
||||||
}
|
}
|
||||||
|
Type* bitset = this->AsUnion()->Get(0);
|
||||||
|
if (bitset->IsInhabited()) max = std::max(max, bitset->Max());
|
||||||
return max;
|
return max;
|
||||||
}
|
}
|
||||||
if (this->IsRange()) return this->AsRange()->Max();
|
if (this->IsRange()) return this->AsRange()->Max();
|
||||||
|
Loading…
Reference in New Issue
Block a user