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

Side by Side 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, 9 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/compiler/simplified-lowering.h" 5 #include "src/compiler/simplified-lowering.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "src/base/bits.h" 9 #include "src/base/bits.h"
10 #include "src/code-factory.h" 10 #include "src/code-factory.h"
(...skipping 1142 matching lines...) Expand 10 before | Expand all | Expand 10 after
1153 jsgraph_->isolate(), jsgraph_->zone(), callable.descriptor(), 0, 1153 jsgraph_->isolate(), jsgraph_->zone(), callable.descriptor(), 0,
1154 flags, properties); 1154 flags, properties);
1155 node->InsertInput(jsgraph_->zone(), 0, 1155 node->InsertInput(jsgraph_->zone(), 0,
1156 jsgraph_->HeapConstant(callable.code())); 1156 jsgraph_->HeapConstant(callable.code()));
1157 node->InsertInput(jsgraph_->zone(), 3, jsgraph_->NoContextConstant()); 1157 node->InsertInput(jsgraph_->zone(), 3, jsgraph_->NoContextConstant());
1158 NodeProperties::ChangeOp(node, jsgraph_->common()->Call(desc)); 1158 NodeProperties::ChangeOp(node, jsgraph_->common()->Call(desc));
1159 } 1159 }
1160 break; 1160 break;
1161 } 1161 }
1162 case IrOpcode::kStringLessThan: { 1162 case IrOpcode::kStringLessThan: {
1163 VisitBinop(node, UseInfo::AnyTagged(), NodeOutputInfo::Bool()); 1163 VisitBinop(node, UseInfo::AnyTagged(), NodeOutputInfo::BoolTagged());
1164 if (lower()) lowering->DoStringLessThan(node); 1164 if (lower()) {
1165 // StringLessThan(x, y) => Call(StringLessThanStub, x, y, no-context)
1166 Operator::Properties properties = node->op()->properties();
1167 Callable callable = CodeFactory::StringLessThan(jsgraph_->isolate());
1168 CallDescriptor::Flags flags = CallDescriptor::kNoFlags;
1169 CallDescriptor* desc = Linkage::GetStubCallDescriptor(
1170 jsgraph_->isolate(), jsgraph_->zone(), callable.descriptor(), 0,
1171 flags, properties);
1172 node->InsertInput(jsgraph_->zone(), 0,
1173 jsgraph_->HeapConstant(callable.code()));
1174 node->InsertInput(jsgraph_->zone(), 3, jsgraph_->NoContextConstant());
1175 NodeProperties::ChangeOp(node, jsgraph_->common()->Call(desc));
1176 }
1165 break; 1177 break;
1166 } 1178 }
1167 case IrOpcode::kStringLessThanOrEqual: { 1179 case IrOpcode::kStringLessThanOrEqual: {
1168 VisitBinop(node, UseInfo::AnyTagged(), NodeOutputInfo::Bool()); 1180 VisitBinop(node, UseInfo::AnyTagged(), NodeOutputInfo::BoolTagged());
1169 if (lower()) lowering->DoStringLessThanOrEqual(node); 1181 if (lower()) {
1182 // StringLessThanOrEqual(x, y)
1183 // => Call(StringLessThanOrEqualStub, x, y, no-context)
1184 Operator::Properties properties = node->op()->properties();
1185 Callable callable =
1186 CodeFactory::StringLessThanOrEqual(jsgraph_->isolate());
1187 CallDescriptor::Flags flags = CallDescriptor::kNoFlags;
1188 CallDescriptor* desc = Linkage::GetStubCallDescriptor(
1189 jsgraph_->isolate(), jsgraph_->zone(), callable.descriptor(), 0,
1190 flags, properties);
1191 node->InsertInput(jsgraph_->zone(), 0,
1192 jsgraph_->HeapConstant(callable.code()));
1193 node->InsertInput(jsgraph_->zone(), 3, jsgraph_->NoContextConstant());
1194 NodeProperties::ChangeOp(node, jsgraph_->common()->Call(desc));
1195 }
1170 break; 1196 break;
1171 } 1197 }
1172 case IrOpcode::kAllocate: { 1198 case IrOpcode::kAllocate: {
1173 ProcessInput(node, 0, UseInfo::AnyTagged()); 1199 ProcessInput(node, 0, UseInfo::AnyTagged());
1174 ProcessRemainingInputs(node, 1); 1200 ProcessRemainingInputs(node, 1);
1175 SetOutput(node, NodeOutputInfo::AnyTagged()); 1201 SetOutput(node, NodeOutputInfo::AnyTagged());
1176 break; 1202 break;
1177 } 1203 }
1178 case IrOpcode::kLoadField: { 1204 case IrOpcode::kLoadField: {
1179 FieldAccess access = FieldAccessOf(node->op()); 1205 FieldAccess access = FieldAccessOf(node->op());
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
1603 } 1629 }
1604 1630
1605 1631
1606 void SimplifiedLowering::DoStoreBuffer(Node* node) { 1632 void SimplifiedLowering::DoStoreBuffer(Node* node) {
1607 DCHECK_EQ(IrOpcode::kStoreBuffer, node->opcode()); 1633 DCHECK_EQ(IrOpcode::kStoreBuffer, node->opcode());
1608 MachineRepresentation const rep = 1634 MachineRepresentation const rep =
1609 BufferAccessOf(node->op()).machine_type().representation(); 1635 BufferAccessOf(node->op()).machine_type().representation();
1610 NodeProperties::ChangeOp(node, machine()->CheckedStore(rep)); 1636 NodeProperties::ChangeOp(node, machine()->CheckedStore(rep));
1611 } 1637 }
1612 1638
1613
1614 Node* SimplifiedLowering::StringComparison(Node* node) {
1615 Operator::Properties properties = node->op()->properties();
1616 Callable callable = CodeFactory::StringCompare(isolate());
1617 CallDescriptor::Flags flags = CallDescriptor::kNoFlags;
1618 CallDescriptor* desc = Linkage::GetStubCallDescriptor(
1619 isolate(), zone(), callable.descriptor(), 0, flags, properties);
1620 return graph()->NewNode(
1621 common()->Call(desc), jsgraph()->HeapConstant(callable.code()),
1622 NodeProperties::GetValueInput(node, 0),
1623 NodeProperties::GetValueInput(node, 1), jsgraph()->NoContextConstant(),
1624 NodeProperties::GetEffectInput(node),
1625 NodeProperties::GetControlInput(node));
1626 }
1627
1628
1629 Node* SimplifiedLowering::Int32Div(Node* const node) { 1639 Node* SimplifiedLowering::Int32Div(Node* const node) {
1630 Int32BinopMatcher m(node); 1640 Int32BinopMatcher m(node);
1631 Node* const zero = jsgraph()->Int32Constant(0); 1641 Node* const zero = jsgraph()->Int32Constant(0);
1632 Node* const minus_one = jsgraph()->Int32Constant(-1); 1642 Node* const minus_one = jsgraph()->Int32Constant(-1);
1633 Node* const lhs = m.left().node(); 1643 Node* const lhs = m.left().node();
1634 Node* const rhs = m.right().node(); 1644 Node* const rhs = m.right().node();
1635 1645
1636 if (m.right().Is(-1)) { 1646 if (m.right().Is(-1)) {
1637 return graph()->NewNode(machine()->Int32Sub(), zero, lhs); 1647 return graph()->NewNode(machine()->Int32Sub(), zero, lhs);
1638 } else if (m.right().Is(0)) { 1648 } else if (m.right().Is(0)) {
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
1881 void SimplifiedLowering::DoShift(Node* node, Operator const* op, 1891 void SimplifiedLowering::DoShift(Node* node, Operator const* op,
1882 Type* rhs_type) { 1892 Type* rhs_type) {
1883 Node* const rhs = NodeProperties::GetValueInput(node, 1); 1893 Node* const rhs = NodeProperties::GetValueInput(node, 1);
1884 if (!rhs_type->Is(type_cache_.kZeroToThirtyOne)) { 1894 if (!rhs_type->Is(type_cache_.kZeroToThirtyOne)) {
1885 node->ReplaceInput(1, graph()->NewNode(machine()->Word32And(), rhs, 1895 node->ReplaceInput(1, graph()->NewNode(machine()->Word32And(), rhs,
1886 jsgraph()->Int32Constant(0x1f))); 1896 jsgraph()->Int32Constant(0x1f)));
1887 } 1897 }
1888 NodeProperties::ChangeOp(node, op); 1898 NodeProperties::ChangeOp(node, op);
1889 } 1899 }
1890 1900
1891
1892 namespace {
1893
1894 void ReplaceEffectUses(Node* node, Node* replacement) {
1895 // Requires distinguishing between value and effect edges.
1896 DCHECK(replacement->op()->EffectOutputCount() > 0);
1897 for (Edge edge : node->use_edges()) {
1898 if (NodeProperties::IsEffectEdge(edge)) {
1899 edge.UpdateTo(replacement);
1900 } else {
1901 DCHECK(NodeProperties::IsValueEdge(edge));
1902 }
1903 }
1904 }
1905
1906 } // namespace
1907
1908
1909 void SimplifiedLowering::DoStringLessThan(Node* node) {
1910 Node* comparison = StringComparison(node);
1911 ReplaceEffectUses(node, comparison);
1912 node->ReplaceInput(0, comparison);
1913 node->ReplaceInput(1, jsgraph()->SmiConstant(EQUAL));
1914 node->TrimInputCount(2);
1915 NodeProperties::ChangeOp(node, machine()->IntLessThan());
1916 }
1917
1918
1919 void SimplifiedLowering::DoStringLessThanOrEqual(Node* node) {
1920 Node* comparison = StringComparison(node);
1921 ReplaceEffectUses(node, comparison);
1922 node->ReplaceInput(0, comparison);
1923 node->ReplaceInput(1, jsgraph()->SmiConstant(EQUAL));
1924 node->TrimInputCount(2);
1925 NodeProperties::ChangeOp(node, machine()->IntLessThanOrEqual());
1926 }
1927
1928 } // namespace compiler 1901 } // namespace compiler
1929 } // namespace internal 1902 } // namespace internal
1930 } // namespace v8 1903 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698