Commit b36b8395 authored by bmeurer's avatar bmeurer Committed by Commit bot

[turbofan] Optimize strict equality with unique input.

If one input to JSStrictEqual/JSNotStrictEqual is Unique (except
InternalizedString) or the hole, then we can turn that into a
direct pointer comparison, as such values are only equal to exactly
the same unique value.

BUG=v8:5267
R=jarin@chromium.org

Review-Url: https://codereview.chromium.org/2611363002
Cr-Commit-Position: refs/heads/master@{#42122}
parent b0fab645
......@@ -494,8 +494,6 @@ JSTypedLowering::JSTypedLowering(Editor* editor,
dependencies_(dependencies),
flags_(flags),
jsgraph_(jsgraph),
the_hole_type_(
Type::HeapConstant(factory()->the_hole_value(), graph()->zone())),
type_cache_(TypeCache::Get()) {
for (size_t k = 0; k < arraysize(shifted_int32_ranges_); ++k) {
double min = kMinInt / (1 << k);
......@@ -954,25 +952,10 @@ Reduction JSTypedLowering::ReduceJSStrictEqual(Node* node, bool invert) {
Reduction const reduction = ReduceJSEqualTypeOf(node, invert);
if (reduction.Changed()) return reduction;
if (r.OneInputIs(the_hole_type_)) {
return r.ChangeToPureOperator(simplified()->ReferenceEqual(), invert);
}
if (r.OneInputIs(Type::Undefined())) {
return r.ChangeToPureOperator(simplified()->ReferenceEqual(), invert);
}
if (r.OneInputIs(Type::Null())) {
return r.ChangeToPureOperator(simplified()->ReferenceEqual(), invert);
}
if (r.OneInputIs(Type::Boolean())) {
return r.ChangeToPureOperator(simplified()->ReferenceEqual(), invert);
}
if (r.OneInputIs(Type::Object())) {
return r.ChangeToPureOperator(simplified()->ReferenceEqual(), invert);
}
if (r.OneInputIs(Type::Receiver())) {
if (r.BothInputsAre(Type::Unique())) {
return r.ChangeToPureOperator(simplified()->ReferenceEqual(), invert);
}
if (r.BothInputsAre(Type::Unique())) {
if (r.OneInputIs(Type::NonStringUniqueOrHole())) {
return r.ChangeToPureOperator(simplified()->ReferenceEqual(), invert);
}
if (r.IsInternalizedStringCompareOperation()) {
......
......@@ -96,7 +96,6 @@ class V8_EXPORT_PRIVATE JSTypedLowering final
Flags flags_;
JSGraph* jsgraph_;
Type* shifted_int32_ranges_[4];
Type* const the_hole_type_;
TypeCache const& type_cache_;
};
......
......@@ -173,6 +173,8 @@ namespace compiler {
V(StringOrReceiver, kString | kReceiver) \
V(Unique, kBoolean | kUniqueName | kNull | kUndefined | \
kReceiver) \
V(NonStringUniqueOrHole, kBoolean | kHole | kNull | kReceiver | \
kSymbol | kUndefined) \
V(Internal, kHole | kExternalPointer | kOtherInternal) \
V(NonInternal, kPrimitive | kReceiver) \
V(NonNumber, kUnique | kString | kInternal) \
......
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