OLD | NEW |
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 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 | 287 |
288 static NodeOutputInfo Uint64() { | 288 static NodeOutputInfo Uint64() { |
289 // TODO(jarin) Fix once we have a real uint64 type. | 289 // TODO(jarin) Fix once we have a real uint64 type. |
290 return NodeOutputInfo(MachineRepresentation::kWord64, Type::Internal()); | 290 return NodeOutputInfo(MachineRepresentation::kWord64, Type::Internal()); |
291 } | 291 } |
292 | 292 |
293 static NodeOutputInfo AnyTagged() { | 293 static NodeOutputInfo AnyTagged() { |
294 return NodeOutputInfo(MachineRepresentation::kTagged, Type::Any()); | 294 return NodeOutputInfo(MachineRepresentation::kTagged, Type::Any()); |
295 } | 295 } |
296 | 296 |
| 297 static NodeOutputInfo BoolTagged() { |
| 298 return NodeOutputInfo(MachineRepresentation::kTagged, Type::Boolean()); |
| 299 } |
| 300 |
297 static NodeOutputInfo NumberTagged() { | 301 static NodeOutputInfo NumberTagged() { |
298 return NodeOutputInfo(MachineRepresentation::kTagged, Type::Number()); | 302 return NodeOutputInfo(MachineRepresentation::kTagged, Type::Number()); |
299 } | 303 } |
300 | 304 |
301 static NodeOutputInfo Pointer() { | 305 static NodeOutputInfo Pointer() { |
302 return NodeOutputInfo(MachineType::PointerRepresentation(), Type::Any()); | 306 return NodeOutputInfo(MachineType::PointerRepresentation(), Type::Any()); |
303 } | 307 } |
304 | 308 |
305 private: | 309 private: |
306 Type* type_; | 310 Type* type_; |
(...skipping 825 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1132 break; | 1136 break; |
1133 } | 1137 } |
1134 case IrOpcode::kReferenceEqual: { | 1138 case IrOpcode::kReferenceEqual: { |
1135 VisitBinop(node, UseInfo::AnyTagged(), NodeOutputInfo::Bool()); | 1139 VisitBinop(node, UseInfo::AnyTagged(), NodeOutputInfo::Bool()); |
1136 if (lower()) { | 1140 if (lower()) { |
1137 NodeProperties::ChangeOp(node, lowering->machine()->WordEqual()); | 1141 NodeProperties::ChangeOp(node, lowering->machine()->WordEqual()); |
1138 } | 1142 } |
1139 break; | 1143 break; |
1140 } | 1144 } |
1141 case IrOpcode::kStringEqual: { | 1145 case IrOpcode::kStringEqual: { |
1142 VisitBinop(node, UseInfo::AnyTagged(), NodeOutputInfo::Bool()); | 1146 VisitBinop(node, UseInfo::AnyTagged(), NodeOutputInfo::BoolTagged()); |
1143 if (lower()) lowering->DoStringEqual(node); | 1147 if (lower()) { |
| 1148 // StringEqual(x, y) => Call(StringEqualStub, x, y, no-context) |
| 1149 Operator::Properties properties = node->op()->properties(); |
| 1150 Callable callable = CodeFactory::StringEqual(jsgraph_->isolate()); |
| 1151 CallDescriptor::Flags flags = CallDescriptor::kNoFlags; |
| 1152 CallDescriptor* desc = Linkage::GetStubCallDescriptor( |
| 1153 jsgraph_->isolate(), jsgraph_->zone(), callable.descriptor(), 0, |
| 1154 flags, properties); |
| 1155 node->InsertInput(jsgraph_->zone(), 0, |
| 1156 jsgraph_->HeapConstant(callable.code())); |
| 1157 node->InsertInput(jsgraph_->zone(), 3, jsgraph_->NoContextConstant()); |
| 1158 NodeProperties::ChangeOp(node, jsgraph_->common()->Call(desc)); |
| 1159 } |
1144 break; | 1160 break; |
1145 } | 1161 } |
1146 case IrOpcode::kStringLessThan: { | 1162 case IrOpcode::kStringLessThan: { |
1147 VisitBinop(node, UseInfo::AnyTagged(), NodeOutputInfo::Bool()); | 1163 VisitBinop(node, UseInfo::AnyTagged(), NodeOutputInfo::Bool()); |
1148 if (lower()) lowering->DoStringLessThan(node); | 1164 if (lower()) lowering->DoStringLessThan(node); |
1149 break; | 1165 break; |
1150 } | 1166 } |
1151 case IrOpcode::kStringLessThanOrEqual: { | 1167 case IrOpcode::kStringLessThanOrEqual: { |
1152 VisitBinop(node, UseInfo::AnyTagged(), NodeOutputInfo::Bool()); | 1168 VisitBinop(node, UseInfo::AnyTagged(), NodeOutputInfo::Bool()); |
1153 if (lower()) lowering->DoStringLessThanOrEqual(node); | 1169 if (lower()) lowering->DoStringLessThanOrEqual(node); |
(...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1883 edge.UpdateTo(replacement); | 1899 edge.UpdateTo(replacement); |
1884 } else { | 1900 } else { |
1885 DCHECK(NodeProperties::IsValueEdge(edge)); | 1901 DCHECK(NodeProperties::IsValueEdge(edge)); |
1886 } | 1902 } |
1887 } | 1903 } |
1888 } | 1904 } |
1889 | 1905 |
1890 } // namespace | 1906 } // namespace |
1891 | 1907 |
1892 | 1908 |
1893 void SimplifiedLowering::DoStringEqual(Node* node) { | |
1894 Node* comparison = StringComparison(node); | |
1895 ReplaceEffectUses(node, comparison); | |
1896 node->ReplaceInput(0, comparison); | |
1897 node->ReplaceInput(1, jsgraph()->SmiConstant(EQUAL)); | |
1898 node->TrimInputCount(2); | |
1899 NodeProperties::ChangeOp(node, machine()->WordEqual()); | |
1900 } | |
1901 | |
1902 | |
1903 void SimplifiedLowering::DoStringLessThan(Node* node) { | 1909 void SimplifiedLowering::DoStringLessThan(Node* node) { |
1904 Node* comparison = StringComparison(node); | 1910 Node* comparison = StringComparison(node); |
1905 ReplaceEffectUses(node, comparison); | 1911 ReplaceEffectUses(node, comparison); |
1906 node->ReplaceInput(0, comparison); | 1912 node->ReplaceInput(0, comparison); |
1907 node->ReplaceInput(1, jsgraph()->SmiConstant(EQUAL)); | 1913 node->ReplaceInput(1, jsgraph()->SmiConstant(EQUAL)); |
1908 node->TrimInputCount(2); | 1914 node->TrimInputCount(2); |
1909 NodeProperties::ChangeOp(node, machine()->IntLessThan()); | 1915 NodeProperties::ChangeOp(node, machine()->IntLessThan()); |
1910 } | 1916 } |
1911 | 1917 |
1912 | 1918 |
1913 void SimplifiedLowering::DoStringLessThanOrEqual(Node* node) { | 1919 void SimplifiedLowering::DoStringLessThanOrEqual(Node* node) { |
1914 Node* comparison = StringComparison(node); | 1920 Node* comparison = StringComparison(node); |
1915 ReplaceEffectUses(node, comparison); | 1921 ReplaceEffectUses(node, comparison); |
1916 node->ReplaceInput(0, comparison); | 1922 node->ReplaceInput(0, comparison); |
1917 node->ReplaceInput(1, jsgraph()->SmiConstant(EQUAL)); | 1923 node->ReplaceInput(1, jsgraph()->SmiConstant(EQUAL)); |
1918 node->TrimInputCount(2); | 1924 node->TrimInputCount(2); |
1919 NodeProperties::ChangeOp(node, machine()->IntLessThanOrEqual()); | 1925 NodeProperties::ChangeOp(node, machine()->IntLessThanOrEqual()); |
1920 } | 1926 } |
1921 | 1927 |
1922 } // namespace compiler | 1928 } // namespace compiler |
1923 } // namespace internal | 1929 } // namespace internal |
1924 } // namespace v8 | 1930 } // namespace v8 |
OLD | NEW |