Commit 14a1a7ed authored by jarin's avatar jarin Committed by Commit bot

[turbofan] Mark side-effect-free calls to string ops as kEliminatable.

Review-Url: https://codereview.chromium.org/2063373003
Cr-Commit-Position: refs/heads/master@{#36996}
parent d21b50ad
...@@ -1290,6 +1290,7 @@ EffectControlLinearizer::LowerCheckIf(Node* node, Node* frame_state, ...@@ -1290,6 +1290,7 @@ EffectControlLinearizer::LowerCheckIf(Node* node, Node* frame_state,
Node* effect, Node* control) { Node* effect, Node* control) {
NodeProperties::ReplaceEffectInput(node, effect); NodeProperties::ReplaceEffectInput(node, effect);
NodeProperties::ReplaceControlInput(node, control); NodeProperties::ReplaceControlInput(node, control);
DCHECK_NOT_NULL(frame_state);
node->InsertInput(graph()->zone(), 1, frame_state); node->InsertInput(graph()->zone(), 1, frame_state);
NodeProperties::ChangeOp(node, common()->DeoptimizeIf()); NodeProperties::ChangeOp(node, common()->DeoptimizeIf());
return ValueEffectControl(node, node, node); return ValueEffectControl(node, node, node);
......
...@@ -1509,7 +1509,7 @@ class RepresentationSelector { ...@@ -1509,7 +1509,7 @@ class RepresentationSelector {
if (lower()) { if (lower()) {
// StringEqual(x, y) => Call(StringEqualStub, x, y, no-context) // StringEqual(x, y) => Call(StringEqualStub, x, y, no-context)
Operator::Properties properties = Operator::Properties properties =
Operator::kCommutative | Operator::kNoThrow; Operator::kCommutative | Operator::kEliminatable;
Callable callable = CodeFactory::StringEqual(jsgraph_->isolate()); Callable callable = CodeFactory::StringEqual(jsgraph_->isolate());
CallDescriptor::Flags flags = CallDescriptor::kNoFlags; CallDescriptor::Flags flags = CallDescriptor::kNoFlags;
CallDescriptor* desc = Linkage::GetStubCallDescriptor( CallDescriptor* desc = Linkage::GetStubCallDescriptor(
...@@ -1519,7 +1519,6 @@ class RepresentationSelector { ...@@ -1519,7 +1519,6 @@ class RepresentationSelector {
jsgraph_->HeapConstant(callable.code())); jsgraph_->HeapConstant(callable.code()));
node->AppendInput(jsgraph_->zone(), jsgraph_->NoContextConstant()); node->AppendInput(jsgraph_->zone(), jsgraph_->NoContextConstant());
node->AppendInput(jsgraph_->zone(), jsgraph_->graph()->start()); node->AppendInput(jsgraph_->zone(), jsgraph_->graph()->start());
node->AppendInput(jsgraph_->zone(), jsgraph_->graph()->start());
NodeProperties::ChangeOp(node, jsgraph_->common()->Call(desc)); NodeProperties::ChangeOp(node, jsgraph_->common()->Call(desc));
} }
return; return;
...@@ -1528,7 +1527,7 @@ class RepresentationSelector { ...@@ -1528,7 +1527,7 @@ class RepresentationSelector {
VisitBinop(node, UseInfo::AnyTagged(), MachineRepresentation::kTagged); VisitBinop(node, UseInfo::AnyTagged(), MachineRepresentation::kTagged);
if (lower()) { if (lower()) {
// StringLessThan(x, y) => Call(StringLessThanStub, x, y, no-context) // StringLessThan(x, y) => Call(StringLessThanStub, x, y, no-context)
Operator::Properties properties = Operator::kNoThrow; Operator::Properties properties = Operator::kEliminatable;
Callable callable = CodeFactory::StringLessThan(jsgraph_->isolate()); Callable callable = CodeFactory::StringLessThan(jsgraph_->isolate());
CallDescriptor::Flags flags = CallDescriptor::kNoFlags; CallDescriptor::Flags flags = CallDescriptor::kNoFlags;
CallDescriptor* desc = Linkage::GetStubCallDescriptor( CallDescriptor* desc = Linkage::GetStubCallDescriptor(
...@@ -1538,7 +1537,6 @@ class RepresentationSelector { ...@@ -1538,7 +1537,6 @@ class RepresentationSelector {
jsgraph_->HeapConstant(callable.code())); jsgraph_->HeapConstant(callable.code()));
node->AppendInput(jsgraph_->zone(), jsgraph_->NoContextConstant()); node->AppendInput(jsgraph_->zone(), jsgraph_->NoContextConstant());
node->AppendInput(jsgraph_->zone(), jsgraph_->graph()->start()); node->AppendInput(jsgraph_->zone(), jsgraph_->graph()->start());
node->AppendInput(jsgraph_->zone(), jsgraph_->graph()->start());
NodeProperties::ChangeOp(node, jsgraph_->common()->Call(desc)); NodeProperties::ChangeOp(node, jsgraph_->common()->Call(desc));
} }
return; return;
...@@ -1548,7 +1546,7 @@ class RepresentationSelector { ...@@ -1548,7 +1546,7 @@ class RepresentationSelector {
if (lower()) { if (lower()) {
// StringLessThanOrEqual(x, y) // StringLessThanOrEqual(x, y)
// => Call(StringLessThanOrEqualStub, x, y, no-context) // => Call(StringLessThanOrEqualStub, x, y, no-context)
Operator::Properties properties = Operator::kNoThrow; Operator::Properties properties = Operator::kEliminatable;
Callable callable = Callable callable =
CodeFactory::StringLessThanOrEqual(jsgraph_->isolate()); CodeFactory::StringLessThanOrEqual(jsgraph_->isolate());
CallDescriptor::Flags flags = CallDescriptor::kNoFlags; CallDescriptor::Flags flags = CallDescriptor::kNoFlags;
...@@ -1559,7 +1557,6 @@ class RepresentationSelector { ...@@ -1559,7 +1557,6 @@ class RepresentationSelector {
jsgraph_->HeapConstant(callable.code())); jsgraph_->HeapConstant(callable.code()));
node->AppendInput(jsgraph_->zone(), jsgraph_->NoContextConstant()); node->AppendInput(jsgraph_->zone(), jsgraph_->NoContextConstant());
node->AppendInput(jsgraph_->zone(), jsgraph_->graph()->start()); node->AppendInput(jsgraph_->zone(), jsgraph_->graph()->start());
node->AppendInput(jsgraph_->zone(), jsgraph_->graph()->start());
NodeProperties::ChangeOp(node, jsgraph_->common()->Call(desc)); NodeProperties::ChangeOp(node, jsgraph_->common()->Call(desc));
} }
return; return;
...@@ -1573,7 +1570,7 @@ class RepresentationSelector { ...@@ -1573,7 +1570,7 @@ class RepresentationSelector {
VisitUnop(node, UseInfo::AnyTagged(), MachineRepresentation::kTagged); VisitUnop(node, UseInfo::AnyTagged(), MachineRepresentation::kTagged);
if (lower()) { if (lower()) {
// StringToNumber(x) => Call(StringToNumber, x, no-context) // StringToNumber(x) => Call(StringToNumber, x, no-context)
Operator::Properties properties = Operator::kNoThrow; Operator::Properties properties = Operator::kEliminatable;
Callable callable = CodeFactory::StringToNumber(jsgraph_->isolate()); Callable callable = CodeFactory::StringToNumber(jsgraph_->isolate());
CallDescriptor::Flags flags = CallDescriptor::kNoFlags; CallDescriptor::Flags flags = CallDescriptor::kNoFlags;
CallDescriptor* desc = Linkage::GetStubCallDescriptor( CallDescriptor* desc = Linkage::GetStubCallDescriptor(
...@@ -1583,7 +1580,6 @@ class RepresentationSelector { ...@@ -1583,7 +1580,6 @@ class RepresentationSelector {
jsgraph_->HeapConstant(callable.code())); jsgraph_->HeapConstant(callable.code()));
node->AppendInput(jsgraph_->zone(), jsgraph_->NoContextConstant()); node->AppendInput(jsgraph_->zone(), jsgraph_->NoContextConstant());
node->AppendInput(jsgraph_->zone(), jsgraph_->graph()->start()); node->AppendInput(jsgraph_->zone(), jsgraph_->graph()->start());
node->AppendInput(jsgraph_->zone(), jsgraph_->graph()->start());
NodeProperties::ChangeOp(node, jsgraph_->common()->Call(desc)); NodeProperties::ChangeOp(node, jsgraph_->common()->Call(desc));
} }
return; return;
......
// Copyright 2016 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --allow-natives-syntax --turbo-type-feedback
function f(x) {
var s = x ? "0" : "1";
return 1 + Number(s);
}
f(0);
f(0);
%OptimizeFunctionOnNextCall(f);
assertEquals(2, f(0));
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