Reviewers: titzer,

Description:
Lower simplified StringEqual to runtime call.

[email protected]
TEST=cctest/test-simplified-lowering/LowerStringOps_to_call_and_wordeq

Please review this at https://codereview.chromium.org/531763002/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files (+31, -7 lines):
  M src/compiler/simplified-lowering.h
  M src/compiler/simplified-lowering.cc
  M test/cctest/compiler/test-simplified-lowering.cc


Index: src/compiler/simplified-lowering.cc
diff --git a/src/compiler/simplified-lowering.cc b/src/compiler/simplified-lowering.cc index 0d2be7eff85103731e3beabbccea190a6b7b756b..199ae97e875eae7bff51cb62f18e9a0124942bd9 100644
--- a/src/compiler/simplified-lowering.cc
+++ b/src/compiler/simplified-lowering.cc
@@ -492,7 +492,7 @@ class RepresentationSelector {
       }
       case IrOpcode::kStringEqual: {
         VisitBinop(node, kMachAnyTagged, kRepBit);
-        // TODO(titzer): lower StringEqual to stub/runtime call.
+        if (lower()) lowering->DoStringEqual(node);
         break;
       }
       case IrOpcode::kStringLessThan: {
@@ -812,7 +812,7 @@ void SimplifiedLowering::DoStringAdd(Node* node) {
   CodeStubInterfaceDescriptor* d = stub.GetInterfaceDescriptor();
   CallDescriptor::Flags flags = CallDescriptor::kNoFlags;
CallDescriptor* desc = Linkage::GetStubCallDescriptor(d, 0, flags, zone());
-  node->set_op(jsgraph()->common()->Call(desc));
+  node->set_op(common()->Call(desc));
   node->InsertInput(zone(), 0, jsgraph()->HeapConstant(stub.GetCode()));
   node->AppendInput(zone(), jsgraph()->UndefinedConstant());
   node->AppendInput(zone(), graph()->start());
@@ -820,6 +820,28 @@ void SimplifiedLowering::DoStringAdd(Node* node) {
 }


+void SimplifiedLowering::DoStringEqual(Node* node) {
+  CEntryStub stub(zone()->isolate(), 1);
+  ExternalReference ref(Runtime::kStringEquals, zone()->isolate());
+  Operator::Property props = node->op()->properties();
+ // TODO(mstarzinger): We should call StringCompareStub here instead, once an
+  // interface descriptor is available for it.
+  CallDescriptor::Flags flags = CallDescriptor::kNoFlags;
+  CallDescriptor* desc = Linkage::GetRuntimeCallDescriptor(
+      Runtime::kStringEquals, 2, props, flags, zone());
+  Node* call = graph()->NewNode(common()->Call(desc),
+                                jsgraph()->HeapConstant(stub.GetCode()),
+                                NodeProperties::GetValueInput(node, 0),
+                                NodeProperties::GetValueInput(node, 1),
+                                jsgraph()->ExternalConstant(ref),
+                                jsgraph()->Int32Constant(2),
+                                jsgraph()->UndefinedConstant());
+  node->set_op(machine()->WordEqual());
+  node->ReplaceInput(0, call);
+  node->ReplaceInput(1, jsgraph()->SmiConstant(EQUAL));
+}
+
+
 }  // namespace compiler
 }  // namespace internal
 }  // namespace v8
Index: src/compiler/simplified-lowering.h
diff --git a/src/compiler/simplified-lowering.h b/src/compiler/simplified-lowering.h index 881de482d6575c0358448c83f61bb5fcfd6cf23e..715bb40013693f62efd35f70bc00547880ffd8c1 100644
--- a/src/compiler/simplified-lowering.h
+++ b/src/compiler/simplified-lowering.h
@@ -28,6 +28,7 @@ class SimplifiedLowering {
   void DoLoadElement(Node* node);
   void DoStoreElement(Node* node);
   void DoStringAdd(Node* node);
+  void DoStringEqual(Node* node);

  private:
   JSGraph* jsgraph_;
Index: test/cctest/compiler/test-simplified-lowering.cc
diff --git a/test/cctest/compiler/test-simplified-lowering.cc b/test/cctest/compiler/test-simplified-lowering.cc index b930094a03ddc3b836fc6a42953a451960234fd5..ed0abe05db48775e1f12a906dea9b0639e988053 100644
--- a/test/cctest/compiler/test-simplified-lowering.cc
+++ b/test/cctest/compiler/test-simplified-lowering.cc
@@ -1051,13 +1051,14 @@ TEST(LowerReferenceEqual_to_wordeq) {
 }


-TEST(LowerStringOps_to_calls) {
+TEST(LowerStringOps_to_call_and_wordeq) {
   TestingGraph t(Type::String(), Type::String());
+  IrOpcode::Value opcode =
+      static_cast<IrOpcode::Value>(t.machine()->WordEqual()->opcode());
+  t.CheckLoweringBinop(opcode, t.simplified()->StringEqual());
   if (false) {  // TODO(titzer): lower StringOps to stub/runtime calls
-    t.CheckLoweringBinop(IrOpcode::kCall, t.simplified()->StringEqual());
- t.CheckLoweringBinop(IrOpcode::kCall, t.simplified()->StringLessThan());
-    t.CheckLoweringBinop(IrOpcode::kCall,
-                         t.simplified()->StringLessThanOrEqual());
+    t.CheckLoweringBinop(opcode, t.simplified()->StringLessThan());
+    t.CheckLoweringBinop(opcode, t.simplified()->StringLessThanOrEqual());
   }
   t.CheckLoweringBinop(IrOpcode::kCall, t.simplified()->StringAdd());
 }


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to