Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(118)

Unified Diff: src/compiler/js-typed-lowering.cc

Issue 1369313004: [turbofan] Make string comparisons effectful. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/compiler/simplified-lowering.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/js-typed-lowering.cc
diff --git a/src/compiler/js-typed-lowering.cc b/src/compiler/js-typed-lowering.cc
index 6c080d908527447be56dbbf0386e0cf002e99f18..c77d994c28d4319fcbbaeb13728e0276cf5fe716 100644
--- a/src/compiler/js-typed-lowering.cc
+++ b/src/compiler/js-typed-lowering.cc
@@ -181,6 +181,32 @@ class JSBinopReduction final {
return lowering_->Changed(node_);
}
+ Reduction ChangeToStringComparisonOperator(const Operator* op,
+ bool invert = false) {
+ if (node_->op()->ControlInputCount() > 0) {
+ lowering_->RelaxControls(node_);
+ }
+ // String comparison operators need effect and control inputs, so copy them
+ // over.
+ Node* effect = NodeProperties::GetEffectInput(node_);
+ Node* control = NodeProperties::GetControlInput(node_);
+ node_->ReplaceInput(2, effect);
+ node_->ReplaceInput(3, control);
+
+ node_->TrimInputCount(4);
+ NodeProperties::ChangeOp(node_, op);
+
+ if (invert) {
+ // Insert a boolean-not to invert the value.
+ Node* value = graph()->NewNode(simplified()->BooleanNot(), node_);
+ node_->ReplaceUses(value);
+ // Note: ReplaceUses() smashes all uses, so smash it back here.
+ value->ReplaceInput(0, node_);
+ return lowering_->Replace(value);
+ }
+ return lowering_->Changed(node_);
+ }
+
Reduction ChangeToPureOperator(const Operator* op, Type* type) {
return ChangeToPureOperator(op, false, type);
}
@@ -503,7 +529,8 @@ Reduction JSTypedLowering::ReduceJSComparison(Node* node) {
default:
return NoChange();
}
- return r.ChangeToPureOperator(stringOp);
+ r.ChangeToStringComparisonOperator(stringOp);
+ return Changed(node);
}
if (r.OneInputCannotBe(Type::StringOrReceiver())) {
const Operator* less_than;
@@ -557,7 +584,8 @@ Reduction JSTypedLowering::ReduceJSEqual(Node* node, bool invert) {
return r.ChangeToPureOperator(simplified()->NumberEqual(), invert);
}
if (r.BothInputsAre(Type::String())) {
- return r.ChangeToPureOperator(simplified()->StringEqual(), invert);
+ return r.ChangeToStringComparisonOperator(simplified()->StringEqual(),
+ invert);
}
if (r.BothInputsAre(Type::Receiver())) {
return r.ChangeToPureOperator(
@@ -614,7 +642,8 @@ Reduction JSTypedLowering::ReduceJSStrictEqual(Node* node, bool invert) {
invert);
}
if (r.BothInputsAre(Type::String())) {
- return r.ChangeToPureOperator(simplified()->StringEqual(), invert);
+ return r.ChangeToStringComparisonOperator(simplified()->StringEqual(),
+ invert);
}
if (r.BothInputsAre(Type::Number())) {
return r.ChangeToPureOperator(simplified()->NumberEqual(), invert);
« no previous file with comments | « no previous file | src/compiler/simplified-lowering.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698