Commit 97543016 authored by bmeurer's avatar bmeurer Committed by Commit bot

[turbofan] Mark fast StringAdd as not causing side effects.

When StringAdd builtin is used to concatenate two primitive values,
we know that the operation might throw, but cannot trigger any other
observable side effect, so it shouldn't flush the LoadElimination state.

R=jarin@chromium.org
BUG=v8:5267

Review-Url: https://codereview.chromium.org/2645523002
Cr-Commit-Position: refs/heads/master@{#42489}
parent 140d4df7
...@@ -572,13 +572,20 @@ Reduction JSTypedLowering::ReduceJSAdd(Node* node) { ...@@ -572,13 +572,20 @@ Reduction JSTypedLowering::ReduceJSAdd(Node* node) {
} else if (!r.RightInputIs(Type::String())) { } else if (!r.RightInputIs(Type::String())) {
flags = STRING_ADD_CONVERT_RIGHT; flags = STRING_ADD_CONVERT_RIGHT;
} }
Operator::Properties properties = node->op()->properties();
if (r.NeitherInputCanBe(Type::Receiver())) {
// Both sides are already strings, so we know that the
// string addition will not cause any observable side
// effects; it can still throw obviously.
properties = Operator::kNoWrite | Operator::kNoDeopt;
}
// JSAdd(x:string, y) => CallStub[StringAdd](x, y) // JSAdd(x:string, y) => CallStub[StringAdd](x, y)
// JSAdd(x, y:string) => CallStub[StringAdd](x, y) // JSAdd(x, y:string) => CallStub[StringAdd](x, y)
Callable const callable = Callable const callable =
CodeFactory::StringAdd(isolate(), flags, NOT_TENURED); CodeFactory::StringAdd(isolate(), flags, NOT_TENURED);
CallDescriptor const* const desc = Linkage::GetStubCallDescriptor( CallDescriptor const* const desc = Linkage::GetStubCallDescriptor(
isolate(), graph()->zone(), callable.descriptor(), 0, isolate(), graph()->zone(), callable.descriptor(), 0,
CallDescriptor::kNeedsFrameState, node->op()->properties()); CallDescriptor::kNeedsFrameState, properties);
DCHECK_EQ(1, OperatorProperties::GetFrameStateInputCount(node->op())); DCHECK_EQ(1, OperatorProperties::GetFrameStateInputCount(node->op()));
node->InsertInput(graph()->zone(), 0, node->InsertInput(graph()->zone(), 0,
jsgraph()->HeapConstant(callable.code())); jsgraph()->HeapConstant(callable.code()));
......
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