[turbofan] Avoid duplicate JSType function.

Reduce code duplication, which breaks jumbo builds. Put the StrictEqual
typing rule into the OperationTyper and share the JSType function,
which is also used by SameValue.

Bug: chromium:779531
Change-Id: If292f319217286fd1c676be04f9de3925ed56965
Reviewed-on: https://chromium-review.googlesource.com/751665
Reviewed-by: Jakob Kummerow <jkummerow@chromium.org>
Commit-Queue: Benedikt Meurer <bmeurer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#49088}
This commit is contained in:
Benedikt Meurer 2017-11-02 19:29:08 +01:00 committed by Commit Bot
parent a274fc6536
commit fd35526f36
3 changed files with 20 additions and 29 deletions

View File

@ -1094,6 +1094,24 @@ Type* OperationTyper::SameValue(Type* lhs, Type* rhs) {
return Type::Boolean();
}
Type* OperationTyper::StrictEqual(Type* lhs, Type* rhs) {
if (!JSType(lhs)->Maybe(JSType(rhs))) return singleton_false();
if (lhs->Is(Type::NaN()) || rhs->Is(Type::NaN())) return singleton_false();
if (lhs->Is(Type::Number()) && rhs->Is(Type::Number()) &&
(lhs->Max() < rhs->Min() || lhs->Min() > rhs->Max())) {
return singleton_false();
}
if ((lhs->Is(Type::Hole()) || rhs->Is(Type::Hole())) && !lhs->Maybe(rhs)) {
return singleton_false();
}
if (lhs->IsHeapConstant() && rhs->Is(lhs)) {
// Types are equal and are inhabited only by a single semantic value,
// which is not nan due to the earlier check.
return singleton_true();
}
return Type::Boolean();
}
Type* OperationTyper::CheckFloat64Hole(Type* type) {
if (type->Maybe(Type::Hole())) {
// Turn "the hole" into undefined.

View File

@ -51,6 +51,7 @@ class V8_EXPORT_PRIVATE OperationTyper {
// Comparison operators.
Type* SameValue(Type* lhs, Type* rhs);
Type* StrictEqual(Type* lhs, Type* rhs);
// Check operators.
Type* CheckFloat64Hole(Type* type);

View File

@ -915,38 +915,10 @@ Type* Typer::Visitor::JSEqualTyper(Type* lhs, Type* rhs, Typer* t) {
return Type::Boolean();
}
static Type* JSType(Type* type) {
if (type->Is(Type::Boolean())) return Type::Boolean();
if (type->Is(Type::String())) return Type::String();
if (type->Is(Type::Number())) return Type::Number();
if (type->Is(Type::Undefined())) return Type::Undefined();
if (type->Is(Type::Null())) return Type::Null();
if (type->Is(Type::Symbol())) return Type::Symbol();
if (type->Is(Type::Receiver())) return Type::Receiver(); // JS "Object"
return Type::Any();
}
Type* Typer::Visitor::JSStrictEqualTyper(Type* lhs, Type* rhs, Typer* t) {
if (!JSType(lhs)->Maybe(JSType(rhs))) return t->singleton_false_;
if (lhs->Is(Type::NaN()) || rhs->Is(Type::NaN())) return t->singleton_false_;
if (lhs->Is(Type::Number()) && rhs->Is(Type::Number()) &&
(lhs->Max() < rhs->Min() || lhs->Min() > rhs->Max())) {
return t->singleton_false_;
}
if ((lhs->Is(Type::Hole()) || rhs->Is(Type::Hole())) && !lhs->Maybe(rhs)) {
return t->singleton_false_;
}
if (lhs->IsHeapConstant() && rhs->Is(lhs)) {
// Types are equal and are inhabited only by a single semantic value,
// which is not nan due to the earlier check.
return t->singleton_true_;
}
return Type::Boolean();
return t->operation_typer()->StrictEqual(lhs, rhs);
}
// The EcmaScript specification defines the four relational comparison operators
// (<, <=, >=, >) with the help of a single abstract one. It behaves like <
// but returns undefined when the inputs cannot be compared.