Commit e034c1ad authored by Benedikt Meurer's avatar Benedikt Meurer Committed by Commit Bot

[turbofan] ToNumeric(x) does ToNumber(x) for all non-BigInt primitives.

We can safely lower ToNumeric(x) to ToNumber(x) as long as we can
guarantee that x is any primitive except BigInt (as ToNumeric would
return that unchanged while ToNumber will throw).

Bug: v8:8015
Change-Id: I66573cc204c7c919095ca7598a027fabef7d71a8
Reviewed-on: https://chromium-review.googlesource.com/1199665Reviewed-by: 's avatarMaya Lekova <mslekova@chromium.org>
Commit-Queue: Benedikt Meurer <bmeurer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#55556}
parent 455718ed
......@@ -1026,8 +1026,8 @@ Reduction JSTypedLowering::ReduceJSToNumber(Node* node) {
Reduction JSTypedLowering::ReduceJSToNumeric(Node* node) {
Node* const input = NodeProperties::GetValueInput(node, 0);
Type const input_type = NodeProperties::GetType(input);
if (input_type.Is(Type::Number())) {
// ToNumeric(x:number) => ToNumber(x)
if (input_type.Is(Type::NonBigIntPrimitive())) {
// ToNumeric(x:primitive\bigint) => ToNumber(x)
NodeProperties::ChangeOp(node, javascript()->ToNumber());
Reduction const reduction = ReduceJSToNumber(node);
return reduction.Changed() ? reduction : Changed(node);
......
......@@ -169,7 +169,8 @@ namespace compiler {
kNumber | kNullOrUndefined | kBoolean) \
V(PlainPrimitive, kNumber | kString | kBoolean | \
kNullOrUndefined) \
V(Primitive, kSymbol | kBigInt | kPlainPrimitive) \
V(NonBigIntPrimitive, kSymbol | kPlainPrimitive) \
V(Primitive, kBigInt | kNonBigIntPrimitive) \
V(OtherUndetectableOrUndefined, kOtherUndetectable | kUndefined) \
V(Proxy, kCallableProxy | kOtherProxy) \
V(ArrayOrOtherObject, kArray | kOtherObject) \
......
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