Index: src/compiler/js-typed-lowering.cc |
diff --git a/src/compiler/js-typed-lowering.cc b/src/compiler/js-typed-lowering.cc |
index 64838a1f839c8d2d2d1ba4c8fb55a298c8b0b563..4539be6e80b52a31fb1a43e19227f0c2498b6964 100644 |
--- a/src/compiler/js-typed-lowering.cc |
+++ b/src/compiler/js-typed-lowering.cc |
@@ -47,6 +47,7 @@ class JSBinopReduction final { |
case CompareOperationHint::kAny: |
case CompareOperationHint::kNone: |
case CompareOperationHint::kString: |
+ case CompareOperationHint::kSymbol: |
case CompareOperationHint::kReceiver: |
case CompareOperationHint::kInternalizedString: |
break; |
@@ -85,6 +86,16 @@ class JSBinopReduction final { |
return false; |
} |
+ bool IsSymbolCompareOperation() { |
+ if (lowering_->flags() & JSTypedLowering::kDeoptimizationEnabled) { |
+ DCHECK_EQ(1, node_->op()->EffectOutputCount()); |
+ return (CompareOperationHintOf(node_->op()) == |
+ CompareOperationHint::kSymbol) && |
+ BothInputsMaybe(Type::Symbol()); |
+ } |
+ return false; |
+ } |
+ |
// Check if a string addition will definitely result in creating a ConsString, |
// i.e. if the combined length of the resulting string exceeds the ConsString |
// minimum length. |
@@ -137,6 +148,24 @@ class JSBinopReduction final { |
} |
} |
+ // Checks that both inputs are Symbol, and if we don't know |
+ // statically that one side is already a Symbol, insert a |
+ // CheckSymbol node. |
+ void CheckInputsToSymbol() { |
+ if (!left_type()->Is(Type::Symbol())) { |
+ Node* left_input = graph()->NewNode(simplified()->CheckSymbol(), left(), |
+ effect(), control()); |
+ node_->ReplaceInput(0, left_input); |
+ update_effect(left_input); |
+ } |
+ if (!right_type()->Is(Type::Symbol())) { |
+ Node* right_input = graph()->NewNode(simplified()->CheckSymbol(), right(), |
+ effect(), control()); |
+ node_->ReplaceInput(1, right_input); |
+ update_effect(right_input); |
+ } |
+ } |
+ |
// Checks that both inputs are String, and if we don't know |
// statically that one side is already a String, insert a |
// CheckString node. |
@@ -896,6 +925,9 @@ Reduction JSTypedLowering::ReduceJSEqual(Node* node) { |
} else if (r.IsStringCompareOperation()) { |
r.CheckInputsToString(); |
return r.ChangeToPureOperator(simplified()->StringEqual()); |
+ } else if (r.IsSymbolCompareOperation()) { |
+ r.CheckInputsToSymbol(); |
+ return r.ChangeToPureOperator(simplified()->ReferenceEqual()); |
} |
return NoChange(); |
} |
@@ -953,6 +985,9 @@ Reduction JSTypedLowering::ReduceJSStrictEqual(Node* node) { |
} else if (r.IsStringCompareOperation()) { |
r.CheckInputsToString(); |
return r.ChangeToPureOperator(simplified()->StringEqual()); |
+ } else if (r.IsSymbolCompareOperation()) { |
+ r.CheckInputsToSymbol(); |
+ return r.ChangeToPureOperator(simplified()->ReferenceEqual()); |
} |
return NoChange(); |
} |