// 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}
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);
}
// -----------------------------------------------------------------------------
+// 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