Lower simplified StringAdd to stub call.

R=titzer@chromium.org
TEST=cctest/test-simplified-lowering/LowerStringOps_to_calls

Review URL: https://codereview.chromium.org/530973002

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@23610 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 2a92afe1
......@@ -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());
}
......
......@@ -521,7 +521,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: {
......@@ -821,6 +821,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
......@@ -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_;
......
......@@ -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());
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment