Reviewers: titzer,

Description:
Lower simplified StringAdd to stub call.

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

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

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

Affected files (+21, -6 lines):
  M src/compiler/js-typed-lowering.cc
  M src/compiler/simplified-lowering.h
  M src/compiler/simplified-lowering.cc
  M test/cctest/compiler/test-simplified-lowering.cc


Index: src/compiler/js-typed-lowering.cc
diff --git a/src/compiler/js-typed-lowering.cc b/src/compiler/js-typed-lowering.cc index 0cf53373f637645ce74f73cdd5a367e23c495d08..6fad5ab6033527d76d069295c7c7c8e81f95dc1f 100644
--- a/src/compiler/js-typed-lowering.cc
+++ b/src/compiler/js-typed-lowering.cc
@@ -222,7 +222,8 @@ Reduction JSTypedLowering::ReduceJSAdd(Node* node) {
   if (r.OneInputIs(Type::String())) {
     r.ConvertInputsToString();
     return r.ChangeToPureOperator(simplified()->StringAdd());
-  } else if (r.NeitherInputCanBe(Type::String())) {
+  }
+  if (r.NeitherInputCanBe(Type::String())) {
     r.ConvertInputsToNumber();
     return r.ChangeToPureOperator(simplified()->NumberAdd());
   }
Index: src/compiler/simplified-lowering.cc
diff --git a/src/compiler/simplified-lowering.cc b/src/compiler/simplified-lowering.cc index 9ccd4ed5ef7d303c156898c6aa138f952e3719ff..0d2be7eff85103731e3beabbccea190a6b7b756b 100644
--- a/src/compiler/simplified-lowering.cc
+++ b/src/compiler/simplified-lowering.cc
@@ -507,7 +507,7 @@ class RepresentationSelector {
       }
       case IrOpcode::kStringAdd: {
         VisitBinop(node, kMachAnyTagged, kMachAnyTagged);
-        // TODO(titzer): lower StringAdd to stub/runtime call.
+        if (lower()) lowering->DoStringAdd(node);
         break;
       }
       case IrOpcode::kLoadField: {
@@ -807,6 +807,19 @@ void SimplifiedLowering::DoStoreElement(Node* node) {
 }


+void SimplifiedLowering::DoStringAdd(Node* node) {
+ StringAddStub stub(zone()->isolate(), STRING_ADD_CHECK_NONE, NOT_TENURED);
+  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->InsertInput(zone(), 0, jsgraph()->HeapConstant(stub.GetCode()));
+  node->AppendInput(zone(), jsgraph()->UndefinedConstant());
+  node->AppendInput(zone(), graph()->start());
+  node->AppendInput(zone(), graph()->start());
+}
+
+
 }  // 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 29538b28605161d1134066b295cde518c040eced..881de482d6575c0358448c83f61bb5fcfd6cf23e 100644
--- a/src/compiler/simplified-lowering.h
+++ b/src/compiler/simplified-lowering.h
@@ -27,6 +27,7 @@ class SimplifiedLowering {
   void DoStoreField(Node* node);
   void DoLoadElement(Node* node);
   void DoStoreElement(Node* node);
+  void DoStringAdd(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 cce2a82ac92c716b66334b3e8f0a513222abb3be..b930094a03ddc3b836fc6a42953a451960234fd5 100644
--- a/test/cctest/compiler/test-simplified-lowering.cc
+++ b/test/cctest/compiler/test-simplified-lowering.cc
@@ -1051,15 +1051,15 @@ TEST(LowerReferenceEqual_to_wordeq) {
 }


-TEST(LowerStringOps_to_rtcalls) {
-  if (false) {  // TODO(titzer): lower StringOps to runtime calls
-    TestingGraph t(Type::String(), Type::String());
+TEST(LowerStringOps_to_calls) {
+  TestingGraph t(Type::String(), Type::String());
+  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(IrOpcode::kCall, t.simplified()->StringAdd());
   }
+  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