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

Unified Diff: src/compiler/simplified-lowering.cc

Issue 1765823002: [compiler] Introduce code stubs for string relational comparisons. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 10 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
Index: src/compiler/simplified-lowering.cc
diff --git a/src/compiler/simplified-lowering.cc b/src/compiler/simplified-lowering.cc
index e4251acceb7e4979e04bfc53aced6a08b0a4f96d..0c01b1442a8b173e4e29ae94f865e6e1fac0ee16 100644
--- a/src/compiler/simplified-lowering.cc
+++ b/src/compiler/simplified-lowering.cc
@@ -1160,13 +1160,39 @@ class RepresentationSelector {
break;
}
case IrOpcode::kStringLessThan: {
- VisitBinop(node, UseInfo::AnyTagged(), NodeOutputInfo::Bool());
- if (lower()) lowering->DoStringLessThan(node);
+ VisitBinop(node, UseInfo::AnyTagged(), NodeOutputInfo::BoolTagged());
+ if (lower()) {
+ // StringLessThan(x, y) => Call(StringLessThanStub, x, y, no-context)
+ Operator::Properties properties = node->op()->properties();
+ Callable callable = CodeFactory::StringLessThan(jsgraph_->isolate());
+ CallDescriptor::Flags flags = CallDescriptor::kNoFlags;
+ CallDescriptor* desc = Linkage::GetStubCallDescriptor(
+ jsgraph_->isolate(), jsgraph_->zone(), callable.descriptor(), 0,
+ flags, properties);
+ node->InsertInput(jsgraph_->zone(), 0,
+ jsgraph_->HeapConstant(callable.code()));
+ node->InsertInput(jsgraph_->zone(), 3, jsgraph_->NoContextConstant());
+ NodeProperties::ChangeOp(node, jsgraph_->common()->Call(desc));
+ }
break;
}
case IrOpcode::kStringLessThanOrEqual: {
- VisitBinop(node, UseInfo::AnyTagged(), NodeOutputInfo::Bool());
- if (lower()) lowering->DoStringLessThanOrEqual(node);
+ VisitBinop(node, UseInfo::AnyTagged(), NodeOutputInfo::BoolTagged());
+ if (lower()) {
+ // StringLessThanOrEqual(x, y)
+ // => Call(StringLessThanOrEqualStub, x, y, no-context)
+ Operator::Properties properties = node->op()->properties();
+ Callable callable =
+ CodeFactory::StringLessThanOrEqual(jsgraph_->isolate());
+ CallDescriptor::Flags flags = CallDescriptor::kNoFlags;
+ CallDescriptor* desc = Linkage::GetStubCallDescriptor(
+ jsgraph_->isolate(), jsgraph_->zone(), callable.descriptor(), 0,
+ flags, properties);
+ node->InsertInput(jsgraph_->zone(), 0,
+ jsgraph_->HeapConstant(callable.code()));
+ node->InsertInput(jsgraph_->zone(), 3, jsgraph_->NoContextConstant());
+ NodeProperties::ChangeOp(node, jsgraph_->common()->Call(desc));
+ }
break;
}
case IrOpcode::kAllocate: {
@@ -1610,22 +1636,6 @@ void SimplifiedLowering::DoStoreBuffer(Node* node) {
NodeProperties::ChangeOp(node, machine()->CheckedStore(rep));
}
-
-Node* SimplifiedLowering::StringComparison(Node* node) {
- Operator::Properties properties = node->op()->properties();
- Callable callable = CodeFactory::StringCompare(isolate());
- CallDescriptor::Flags flags = CallDescriptor::kNoFlags;
- CallDescriptor* desc = Linkage::GetStubCallDescriptor(
- isolate(), zone(), callable.descriptor(), 0, flags, properties);
- return graph()->NewNode(
- common()->Call(desc), jsgraph()->HeapConstant(callable.code()),
- NodeProperties::GetValueInput(node, 0),
- NodeProperties::GetValueInput(node, 1), jsgraph()->NoContextConstant(),
- NodeProperties::GetEffectInput(node),
- NodeProperties::GetControlInput(node));
-}
-
-
Node* SimplifiedLowering::Int32Div(Node* const node) {
Int32BinopMatcher m(node);
Node* const zero = jsgraph()->Int32Constant(0);
@@ -1888,43 +1898,6 @@ void SimplifiedLowering::DoShift(Node* node, Operator const* op,
NodeProperties::ChangeOp(node, op);
}
-
-namespace {
-
-void ReplaceEffectUses(Node* node, Node* replacement) {
- // Requires distinguishing between value and effect edges.
- DCHECK(replacement->op()->EffectOutputCount() > 0);
- for (Edge edge : node->use_edges()) {
- if (NodeProperties::IsEffectEdge(edge)) {
- edge.UpdateTo(replacement);
- } else {
- DCHECK(NodeProperties::IsValueEdge(edge));
- }
- }
-}
-
-} // namespace
-
-
-void SimplifiedLowering::DoStringLessThan(Node* node) {
- Node* comparison = StringComparison(node);
- ReplaceEffectUses(node, comparison);
- node->ReplaceInput(0, comparison);
- node->ReplaceInput(1, jsgraph()->SmiConstant(EQUAL));
- node->TrimInputCount(2);
- NodeProperties::ChangeOp(node, machine()->IntLessThan());
-}
-
-
-void SimplifiedLowering::DoStringLessThanOrEqual(Node* node) {
- Node* comparison = StringComparison(node);
- ReplaceEffectUses(node, comparison);
- node->ReplaceInput(0, comparison);
- node->ReplaceInput(1, jsgraph()->SmiConstant(EQUAL));
- node->TrimInputCount(2);
- NodeProperties::ChangeOp(node, machine()->IntLessThanOrEqual());
-}
-
} // namespace compiler
} // namespace internal
} // namespace v8

Powered by Google App Engine
This is Rietveld 408576698