Commit 2089ff68 authored by Georg Neis's avatar Georg Neis Committed by Commit Bot

[turbofan] Refine typing of equality

Generalize the HeapConstant case to a Singleton case.

Change-Id: Ief8c325a4326e02c8c361f3b41fc40ca398167ad
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2096619
Commit-Queue: Georg Neis <neis@chromium.org>
Reviewed-by: 's avatarTobias Tebbi <tebbi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#66659}
parent b8eeb071
......@@ -1245,9 +1245,11 @@ Type OperationTyper::StrictEqual(Type lhs, Type rhs) {
if ((lhs.Is(Type::Hole()) || rhs.Is(Type::Hole())) && !lhs.Maybe(rhs)) {
return singleton_false();
}
if (lhs.IsHeapConstant() && rhs.Is(lhs)) {
if (lhs.IsSingleton() && rhs.Is(lhs)) {
// Types are equal and are inhabited only by a single semantic value,
// which is not nan due to the earlier check.
DCHECK(lhs.Is(rhs));
DCHECK(lhs.Is(Type::NonInternal()) || lhs.Is(Type::Hole()));
return singleton_true();
}
return Type::Boolean();
......
......@@ -1077,9 +1077,11 @@ Type Typer::Visitor::JSEqualTyper(Type lhs, Type rhs, Typer* t) {
(lhs.Max() < rhs.Min() || lhs.Min() > rhs.Max())) {
return t->singleton_false_;
}
if (lhs.IsHeapConstant() && rhs.Is(lhs)) {
if (lhs.IsSingleton() && rhs.Is(lhs)) {
// Types are equal and are inhabited only by a single semantic value,
// which is not nan due to the earlier check.
DCHECK(lhs.Is(rhs));
DCHECK(lhs.Is(Type::NonInternal()) || lhs.Is(Type::Hole()));
return t->singleton_true_;
}
return Type::Boolean();
......
......@@ -564,7 +564,7 @@ bool Type::SlowIs(Type that) const {
}
if (that.IsRange()) {
return (this->IsRange() && Contains(that.AsRange(), this->AsRange()));
return this->IsRange() && Contains(that.AsRange(), this->AsRange());
}
if (this->IsRange()) return false;
......
......@@ -412,6 +412,13 @@ class V8_EXPORT_PRIVATE Type {
}
bool IsTuple() const { return IsKind(TypeBase::kTuple); }
bool IsSingleton() const {
if (IsNone()) return false;
return Is(Type::Null()) || Is(Type::Undefined()) || Is(Type::MinusZero()) ||
Is(Type::NaN()) || Is(Type::Hole()) || IsHeapConstant() ||
(Is(Type::PlainNumber()) && Min() == Max());
}
const HeapConstantType* AsHeapConstant() const;
const OtherNumberConstantType* AsOtherNumberConstant() const;
const RangeType* AsRange() const;
......
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