Commit 75484e8d authored by Benedikt Meurer's avatar Benedikt Meurer

[turbofan] Relax effects and context for JSToNumber(x:plain-primitive).

TEST=unittests
R=svenpanne@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#25818}
parent f6e68d2c
......@@ -18,7 +18,6 @@ namespace compiler {
// TODO(turbofan): js-typed-lowering improvements possible
// - immediately put in type bounds for all new nodes
// - relax effects from generic but not-side-effecting operations
// - relax effects for ToNumber(mixed)
// Relax the effects of {node} by immediately replacing effect uses of {node}
......@@ -731,6 +730,9 @@ Reduction JSTypedLowering::ReduceJSToNumber(Node* node) {
node->ReplaceInput(i, value);
}
node->TrimInputCount(input_count);
} else {
// JSToNumber(x:plain-primitive,context) => JSToNumber(x,no-context)
node->ReplaceInput(1, jsgraph()->NoContextConstant());
}
return Changed(node);
}
......
......@@ -196,6 +196,23 @@ TEST_F(JSTypedLoweringTest, JSToBooleanWithSelect) {
}
// -----------------------------------------------------------------------------
// JSToNumber
TEST_F(JSTypedLoweringTest, JSToNumberWithPlainPrimitive) {
Node* const input = Parameter(Type::PlainPrimitive(), 0);
Node* const context = Parameter(Type::Any(), 1);
Node* const effect = graph()->start();
Node* const control = graph()->start();
Reduction r = Reduce(graph()->NewNode(javascript()->ToNumber(), input,
context, effect, control));
ASSERT_TRUE(r.Changed());
EXPECT_THAT(r.replacement(), IsToNumber(input, IsNumberConstant(0),
graph()->start(), control));
}
// -----------------------------------------------------------------------------
// JSStrictEqual
......
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