Commit d98ef522 authored by Georg Neis's avatar Georg Neis Committed by Commit Bot

[compiler] Replace type->IsInhabited() by !type->IsNone().

They have been meaning the same thing for a while now.

R=jarin@chromium.org

Bug: 
Change-Id: Ie5988e6429b795babfa1e1f79841a9f03b8362dc
Reviewed-on: https://chromium-review.googlesource.com/758268
Commit-Queue: Georg Neis <neis@chromium.org>
Reviewed-by: 's avatarJaroslav Sevcik <jarin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#49228}
parent df15c60e
......@@ -35,7 +35,7 @@ bool NoReturn(Node* node) {
return node->opcode() == IrOpcode::kDead ||
node->opcode() == IrOpcode::kUnreachable ||
node->opcode() == IrOpcode::kDeadValue ||
!NodeProperties::GetTypeOrAny(node)->IsInhabited();
NodeProperties::GetTypeOrAny(node)->IsNone();
}
bool HasDeadInput(Node* node) {
......@@ -210,7 +210,7 @@ Reduction DeadCodeElimination::ReducePhi(Node* node) {
Reduction reduction = PropagateDeadControl(node);
if (reduction.Changed()) return reduction;
if (PhiRepresentationOf(node->op()) == MachineRepresentation::kNone ||
!NodeProperties::GetTypeOrAny(node)->IsInhabited()) {
NodeProperties::GetTypeOrAny(node)->IsNone()) {
return Replace(dead_value());
}
return NoChange();
......
......@@ -641,8 +641,8 @@ void ReduceNode(const Operator* op, EscapeAnalysisTracker::Scope* current,
// types (which might confuse representation selection). We get
// around this by refusing to constant-fold and escape-analyze
// if the type is not inhabited.
if (NodeProperties::GetType(left)->IsInhabited() &&
NodeProperties::GetType(right)->IsInhabited()) {
if (!NodeProperties::GetType(left)->IsNone() &&
!NodeProperties::GetType(right)->IsNone()) {
current->SetReplacement(replacement);
} else {
current->SetEscaped(left);
......
......@@ -282,13 +282,10 @@ Type* OperationTyper::ToNumber(Type* type) {
Type* OperationTyper::NumberAbs(Type* type) {
DCHECK(type->Is(Type::Number()));
if (!type->IsInhabited()) {
return Type::None();
}
if (type->IsNone()) return type;
type = Type::Intersect(type, Type::PlainNumber(), zone());
if (type->IsInhabited()) {
if (!type->IsNone()) {
double const max = type->Max();
double const min = type->Min();
if (min < 0) {
......@@ -473,7 +470,7 @@ Type* OperationTyper::NumberTrunc(Type* type) {
Type* OperationTyper::NumberToBoolean(Type* type) {
DCHECK(type->Is(Type::Number()));
if (!type->IsInhabited()) return Type::None();
if (type->IsNone()) return type;
if (type->Is(cache_.kZeroish)) return singleton_false_;
if (type->Is(Type::PlainNumber()) && (type->Max() < 0 || 0 < type->Min())) {
return singleton_true_; // Ruled out nan, -0 and +0.
......@@ -525,9 +522,7 @@ Type* OperationTyper::NumberAdd(Type* lhs, Type* rhs) {
DCHECK(lhs->Is(Type::Number()));
DCHECK(rhs->Is(Type::Number()));
if (!lhs->IsInhabited() || !rhs->IsInhabited()) {
return Type::None();
}
if (lhs->IsNone() || rhs->IsNone()) return Type::None();
// Addition can return NaN if either input can be NaN or we try to compute
// the sum of two infinities of opposite sign.
......@@ -550,7 +545,7 @@ Type* OperationTyper::NumberAdd(Type* lhs, Type* rhs) {
Type* type = Type::None();
lhs = Type::Intersect(lhs, Type::PlainNumber(), zone());
rhs = Type::Intersect(rhs, Type::PlainNumber(), zone());
if (lhs->IsInhabited() && rhs->IsInhabited()) {
if (!lhs->IsNone() && !rhs->IsNone()) {
if (lhs->Is(cache_.kInteger) && rhs->Is(cache_.kInteger)) {
type = AddRanger(lhs->Min(), lhs->Max(), rhs->Min(), rhs->Max());
} else {
......@@ -572,9 +567,7 @@ Type* OperationTyper::NumberSubtract(Type* lhs, Type* rhs) {
DCHECK(lhs->Is(Type::Number()));
DCHECK(rhs->Is(Type::Number()));
if (!lhs->IsInhabited() || !rhs->IsInhabited()) {
return Type::None();
}
if (lhs->IsNone() || rhs->IsNone()) return Type::None();
// Subtraction can return NaN if either input can be NaN or we try to
// compute the sum of two infinities of opposite sign.
......@@ -595,7 +588,7 @@ Type* OperationTyper::NumberSubtract(Type* lhs, Type* rhs) {
Type* type = Type::None();
lhs = Type::Intersect(lhs, Type::PlainNumber(), zone());
rhs = Type::Intersect(rhs, Type::PlainNumber(), zone());
if (lhs->IsInhabited() && rhs->IsInhabited()) {
if (!lhs->IsNone() && !rhs->IsNone()) {
if (lhs->Is(cache_.kInteger) && rhs->Is(cache_.kInteger)) {
type = SubtractRanger(lhs->Min(), lhs->Max(), rhs->Min(), rhs->Max());
} else {
......@@ -637,9 +630,7 @@ Type* OperationTyper::NumberMultiply(Type* lhs, Type* rhs) {
DCHECK(lhs->Is(Type::Number()));
DCHECK(rhs->Is(Type::Number()));
if (!lhs->IsInhabited() || !rhs->IsInhabited()) {
return Type::None();
}
if (lhs->IsNone() || rhs->IsNone()) return Type::None();
lhs = Rangify(lhs);
rhs = Rangify(rhs);
......@@ -654,10 +645,7 @@ Type* OperationTyper::NumberDivide(Type* lhs, Type* rhs) {
DCHECK(lhs->Is(Type::Number()));
DCHECK(rhs->Is(Type::Number()));
if (!lhs->IsInhabited() || !rhs->IsInhabited()) {
return Type::None();
}
if (lhs->IsNone() || rhs->IsNone()) return Type::None();
if (lhs->Is(Type::NaN()) || rhs->Is(Type::NaN())) return Type::NaN();
// Division is tricky, so all we do is try ruling out -0 and NaN.
......@@ -685,7 +673,7 @@ Type* OperationTyper::NumberModulus(Type* lhs, Type* rhs) {
DCHECK(lhs->Is(Type::Number()));
DCHECK(rhs->Is(Type::Number()));
if (!lhs->IsInhabited() || !rhs->IsInhabited()) return Type::None();
if (lhs->IsNone() || rhs->IsNone()) return Type::None();
// Modulus can yield NaN if either {lhs} or {rhs} are NaN, or
// {lhs} is not finite, or the {rhs} is a zero value.
......@@ -709,7 +697,7 @@ Type* OperationTyper::NumberModulus(Type* lhs, Type* rhs) {
// We can only derive a meaningful type if both {lhs} and {rhs} are inhabited,
// and the {rhs} is not 0, otherwise the result is NaN independent of {lhs}.
if (lhs->IsInhabited() && !rhs->Is(cache_.kSingletonZero)) {
if (!lhs->IsNone() && !rhs->Is(cache_.kSingletonZero)) {
// Determine the bounds of {lhs} and {rhs}.
double const lmin = lhs->Min();
double const lmax = lhs->Max();
......@@ -754,7 +742,7 @@ Type* OperationTyper::NumberBitwiseOr(Type* lhs, Type* rhs) {
DCHECK(lhs->Is(Type::Number()));
DCHECK(rhs->Is(Type::Number()));
if (!lhs->IsInhabited() || !rhs->IsInhabited()) return Type::None();
if (lhs->IsNone() || rhs->IsNone()) return Type::None();
lhs = NumberToInt32(lhs);
rhs = NumberToInt32(rhs);
......@@ -791,7 +779,7 @@ Type* OperationTyper::NumberBitwiseAnd(Type* lhs, Type* rhs) {
DCHECK(lhs->Is(Type::Number()));
DCHECK(rhs->Is(Type::Number()));
if (!lhs->IsInhabited() || !rhs->IsInhabited()) return Type::None();
if (lhs->IsNone() || rhs->IsNone()) return Type::None();
lhs = NumberToInt32(lhs);
rhs = NumberToInt32(rhs);
......@@ -822,7 +810,7 @@ Type* OperationTyper::NumberBitwiseXor(Type* lhs, Type* rhs) {
DCHECK(lhs->Is(Type::Number()));
DCHECK(rhs->Is(Type::Number()));
if (!lhs->IsInhabited() || !rhs->IsInhabited()) return Type::None();
if (lhs->IsNone() || rhs->IsNone()) return Type::None();
lhs = NumberToInt32(lhs);
rhs = NumberToInt32(rhs);
......@@ -847,7 +835,7 @@ Type* OperationTyper::NumberShiftLeft(Type* lhs, Type* rhs) {
DCHECK(lhs->Is(Type::Number()));
DCHECK(rhs->Is(Type::Number()));
if (!lhs->IsInhabited() || !rhs->IsInhabited()) return Type::None();
if (lhs->IsNone() || rhs->IsNone()) return Type::None();
lhs = NumberToInt32(lhs);
rhs = NumberToUint32(rhs);
......@@ -882,7 +870,7 @@ Type* OperationTyper::NumberShiftRight(Type* lhs, Type* rhs) {
DCHECK(lhs->Is(Type::Number()));
DCHECK(rhs->Is(Type::Number()));
if (!lhs->IsInhabited() || !rhs->IsInhabited()) return Type::None();
if (lhs->IsNone() || rhs->IsNone()) return Type::None();
lhs = NumberToInt32(lhs);
rhs = NumberToUint32(rhs);
......@@ -907,7 +895,7 @@ Type* OperationTyper::NumberShiftRightLogical(Type* lhs, Type* rhs) {
DCHECK(lhs->Is(Type::Number()));
DCHECK(rhs->Is(Type::Number()));
if (!lhs->IsInhabited() || !rhs->IsInhabited()) return Type::None();
if (lhs->IsNone() || rhs->IsNone()) return Type::None();
lhs = NumberToUint32(lhs);
rhs = NumberToUint32(rhs);
......@@ -948,12 +936,10 @@ Type* OperationTyper::NumberImul(Type* lhs, Type* rhs) {
Type* OperationTyper::NumberMax(Type* lhs, Type* rhs) {
DCHECK(lhs->Is(Type::Number()));
DCHECK(rhs->Is(Type::Number()));
if (!lhs->IsInhabited() || !rhs->IsInhabited()) {
return Type::None();
}
if (lhs->Is(Type::NaN()) || rhs->Is(Type::NaN())) {
return Type::NaN();
}
if (lhs->IsNone() || rhs->IsNone()) return Type::None();
if (lhs->Is(Type::NaN()) || rhs->Is(Type::NaN())) return Type::NaN();
Type* type = Type::None();
// TODO(turbofan): Improve minus zero handling here.
if (lhs->Maybe(Type::NaN()) || rhs->Maybe(Type::NaN())) {
......@@ -974,12 +960,10 @@ Type* OperationTyper::NumberMax(Type* lhs, Type* rhs) {
Type* OperationTyper::NumberMin(Type* lhs, Type* rhs) {
DCHECK(lhs->Is(Type::Number()));
DCHECK(rhs->Is(Type::Number()));
if (!lhs->IsInhabited() || !rhs->IsInhabited()) {
return Type::None();
}
if (lhs->Is(Type::NaN()) || rhs->Is(Type::NaN())) {
return Type::NaN();
}
if (lhs->IsNone() || rhs->IsNone()) return Type::None();
if (lhs->Is(Type::NaN()) || rhs->Is(Type::NaN())) return Type::NaN();
Type* type = Type::None();
// TODO(turbofan): Improve minus zero handling here.
if (lhs->Maybe(Type::NaN()) || rhs->Maybe(Type::NaN())) {
......@@ -1036,7 +1020,7 @@ Type* OperationTyper::ToPrimitive(Type* type) {
Type* OperationTyper::Invert(Type* type) {
DCHECK(type->Is(Type::Boolean()));
DCHECK(type->IsInhabited());
DCHECK(!type->IsNone());
if (type->Is(singleton_false())) return singleton_true();
if (type->Is(singleton_true())) return singleton_false();
return type;
......
......@@ -137,8 +137,7 @@ bool IsWord(MachineRepresentation rep) {
Node* RepresentationChanger::GetRepresentationFor(
Node* node, MachineRepresentation output_rep, Type* output_type,
Node* use_node, UseInfo use_info) {
if (output_rep == MachineRepresentation::kNone &&
output_type->IsInhabited()) {
if (output_rep == MachineRepresentation::kNone && !output_type->IsNone()) {
// The output representation should be set if the type is inhabited (i.e.,
// if the value is possible).
return TypeError(node, output_rep, output_type, use_info.representation());
......
......@@ -213,7 +213,7 @@ bool CanOverflowSigned32(const Operator* op, Type* left, Type* right,
// that cannot cause overflow.
left = Type::Intersect(left, Type::Signed32(), type_zone);
right = Type::Intersect(right, Type::Signed32(), type_zone);
if (!left->IsInhabited() || !right->IsInhabited()) return false;
if (left->IsNone() || right->IsNone()) return false;
switch (op->opcode()) {
case IrOpcode::kSpeculativeSafeIntegerAdd:
return (left->Max() + right->Max() > kMaxInt) ||
......@@ -1052,7 +1052,7 @@ class RepresentationSelector {
}
static MachineType DeoptMachineTypeOf(MachineRepresentation rep, Type* type) {
if (!type->IsInhabited()) {
if (type->IsNone()) {
return MachineType::None();
}
// TODO(turbofan): Special treatment for ExternalPointer here,
......@@ -1587,7 +1587,7 @@ class RepresentationSelector {
node->AppendInput(jsgraph_->zone(), jsgraph_->FalseConstant());
NodeProperties::ChangeOp(node, lowering->machine()->WordEqual());
} else {
DCHECK(!TypeOf(node->InputAt(0))->IsInhabited());
DCHECK(TypeOf(node->InputAt(0))->IsNone());
DeferReplacement(node, lowering->jsgraph()->Int32Constant(0));
}
} else {
......
......@@ -42,7 +42,7 @@ Reduction TypedOptimization::Reduce(Node* node) {
// eager deoptimization exit (i.e. {node} has an operator that doesn't have
// the Operator::kNoDeopt property).
Type* upper = NodeProperties::GetType(node);
if (upper->IsInhabited()) {
if (!upper->IsNone()) {
if (upper->IsHeapConstant()) {
Node* replacement =
jsgraph()->Constant(upper->AsHeapConstant()->Value());
......
......@@ -389,15 +389,15 @@ void Typer::Decorator::Decorate(Node* node) {
Type* Typer::Visitor::TypeUnaryOp(Node* node, UnaryTyperFun f) {
Type* input = Operand(node, 0);
return input->IsInhabited() ? f(input, typer_) : Type::None();
return input->IsNone() ? Type::None() : f(input, typer_);
}
Type* Typer::Visitor::TypeBinaryOp(Node* node, BinaryTyperFun f) {
Type* left = Operand(node, 0);
Type* right = Operand(node, 1);
return left->IsInhabited() && right->IsInhabited() ? f(left, right, typer_)
: Type::None();
return left->IsNone() || right->IsNone() ? Type::None()
: f(left, right, typer_);
}
......@@ -461,7 +461,7 @@ Type* Typer::Visitor::ToInteger(Type* type, Typer* t) {
Type* Typer::Visitor::ToLength(Type* type, Typer* t) {
// ES6 section 7.1.15 ToLength ( argument )
type = ToInteger(type, t);
if (!type->IsInhabited()) return Type::None();
if (type->IsNone()) return type;
double min = type->Min();
double max = type->Max();
if (max <= 0.0) {
......@@ -722,7 +722,7 @@ Type* Typer::Visitor::TypeInductionVariablePhi(Node* node) {
}
// If we do not have enough type information for the initial value or
// the increment, just return the initial value's type.
if (!initial_type->IsInhabited() ||
if (initial_type->IsNone() ||
increment_type->Is(typer_->cache_.kSingletonZero)) {
return initial_type;
}
......@@ -756,7 +756,7 @@ Type* Typer::Visitor::TypeInductionVariablePhi(Node* node) {
// If the type is not an integer, just skip the bound.
if (!bound_type->Is(typer_->cache_.kInteger)) continue;
// If the type is not inhabited, then we can take the initial value.
if (!bound_type->IsInhabited()) {
if (bound_type->IsNone()) {
max = initial_type->Max();
break;
}
......@@ -776,7 +776,7 @@ Type* Typer::Visitor::TypeInductionVariablePhi(Node* node) {
// If the type is not an integer, just skip the bound.
if (!bound_type->Is(typer_->cache_.kInteger)) continue;
// If the type is not inhabited, then we can take the initial value.
if (!bound_type->IsInhabited()) {
if (bound_type->IsNone()) {
min = initial_type->Min();
break;
}
......@@ -1856,7 +1856,7 @@ Type* Typer::Visitor::TypeCheckBounds(Node* node) {
index = Type::Union(index, typer_->cache_.kSingletonZero, zone());
}
index = Type::Intersect(index, Type::Integral32(), zone());
if (!index->IsInhabited() || !length->IsInhabited()) return Type::None();
if (index->IsNone() || length->IsNone()) return Type::None();
double min = std::max(index->Min(), 0.0);
double max = std::min(index->Max(), length->Max() - 1);
if (max < min) return Type::None();
......
......@@ -67,8 +67,8 @@ bool Type::Contains(RangeType* range, i::Object* val) {
// Min and Max computation.
double Type::Min() {
DCHECK(this->IsInhabited());
DCHECK(this->Is(Number()));
DCHECK(!this->IsNone());
if (this->IsBitset()) return BitsetType::Min(this->AsBitset());
if (this->IsUnion()) {
double min = +V8_INFINITY;
......@@ -76,7 +76,7 @@ double Type::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());
if (!bitset->IsNone()) min = std::min(min, bitset->Min());
return min;
}
if (this->IsRange()) return this->AsRange()->Min();
......@@ -86,8 +86,8 @@ double Type::Min() {
}
double Type::Max() {
DCHECK(this->IsInhabited());
DCHECK(this->Is(Number()));
DCHECK(!this->IsNone());
if (this->IsBitset()) return BitsetType::Max(this->AsBitset());
if (this->IsUnion()) {
double max = -V8_INFINITY;
......@@ -95,7 +95,7 @@ double Type::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());
if (!bitset->IsNone()) max = std::max(max, bitset->Max());
return max;
}
if (this->IsRange()) return this->AsRange()->Max();
......@@ -523,8 +523,7 @@ bool Type::SlowIs(Type* that) {
bool Type::Maybe(Type* that) {
DisallowHeapAllocation no_allocation;
if (!BitsetType::IsInhabited(this->BitsetLub() & that->BitsetLub()))
return false;
if (BitsetType::IsNone(this->BitsetLub() & that->BitsetLub())) return false;
// (T1 \/ ... \/ Tn) overlaps T if (T1 overlaps T) \/ ... \/ (Tn overlaps T)
if (this->IsUnion()) {
......@@ -721,9 +720,7 @@ int Type::IntersectAux(Type* lhs, Type* rhs, UnionType* result, int size,
return size;
}
if (!BitsetType::IsInhabited(lhs->BitsetLub() & rhs->BitsetLub())) {
return size;
}
if (BitsetType::IsNone(lhs->BitsetLub() & rhs->BitsetLub())) return size;
if (lhs->IsRange()) {
if (rhs->IsBitset()) {
......
......@@ -246,7 +246,7 @@ class V8_EXPORT_PRIVATE BitsetType {
return static_cast<bitset>(reinterpret_cast<uintptr_t>(this) ^ 1u);
}
static bool IsInhabited(bitset bits) { return bits != kNone; }
static bool IsNone(bitset bits) { return bits == kNone; }
static bool Is(bitset bits1, bitset bits2) {
return (bits1 | bits2) == bits2;
......@@ -581,7 +581,7 @@ class V8_EXPORT_PRIVATE Type {
static Type* For(i::Handle<i::Map> map) { return For(*map); }
// Predicates.
bool IsInhabited() { return BitsetType::IsInhabited(this->BitsetLub()); }
bool IsNone() { return this == None(); }
bool Is(Type* that) { return this == that || this->SlowIs(that); }
bool Maybe(Type* that);
......@@ -644,7 +644,6 @@ class V8_EXPORT_PRIVATE Type {
// Internal inspection.
bool IsKind(TypeBase::Kind kind) { return TypeBase::IsKind(this, kind); }
bool IsNone() { return this == None(); }
bool IsAny() { return this == Any(); }
bool IsBitset() { return BitsetType::IsBitset(this); }
bool IsUnion() { return IsKind(TypeBase::kUnion); }
......
......@@ -413,7 +413,7 @@ struct Tests {
// T->Is(Range(T->Min(), T->Max())).
for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) {
Type* type = *it;
CHECK(!type->Is(T.Integer) || !type->IsInhabited() ||
CHECK(!type->Is(T.Integer) || type->IsNone() ||
type->Is(T.Range(type->Min(), type->Max())));
}
}
......@@ -542,7 +542,7 @@ struct Tests {
(type1->IsRange() && type2->IsRange()) ||
(type1->IsOtherNumberConstant() &&
type2->IsOtherNumberConstant()) ||
!type1->IsInhabited());
type1->IsNone());
}
}
}
......@@ -666,7 +666,7 @@ struct Tests {
// T->Maybe(Any) iff T inhabited
for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) {
Type* type = *it;
CHECK(type->Maybe(T.Any) == type->IsInhabited());
CHECK(type->Maybe(T.Any) == !type->IsNone());
}
// T->Maybe(None) never
......@@ -678,7 +678,7 @@ struct Tests {
// Reflexivity upto Inhabitation: T->Maybe(T) iff T inhabited
for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) {
Type* type = *it;
CHECK(type->Maybe(type) == type->IsInhabited());
CHECK(type->Maybe(type) == !type->IsNone());
}
// Symmetry: T1->Maybe(T2) iff T2->Maybe(T1)
......@@ -695,8 +695,7 @@ struct Tests {
for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) {
Type* type1 = *it1;
Type* type2 = *it2;
CHECK(!type1->Maybe(type2) ||
(type1->IsInhabited() && type2->IsInhabited()));
CHECK(!type1->Maybe(type2) || (!type1->IsNone() && !type2->IsNone()));
}
}
......@@ -706,7 +705,7 @@ struct Tests {
Type* type1 = *it1;
Type* type2 = *it2;
Type* intersect12 = T.Intersect(type1, type2);
CHECK(!type1->Maybe(type2) || intersect12->IsInhabited());
CHECK(!type1->Maybe(type2) || !intersect12->IsNone());
}
}
......@@ -715,8 +714,7 @@ struct Tests {
for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) {
Type* type1 = *it1;
Type* type2 = *it2;
CHECK(!(type1->Is(type2) && type1->IsInhabited()) ||
type1->Maybe(type2));
CHECK(!(type1->Is(type2) && !type1->IsNone()) || type1->Maybe(type2));
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment