[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/1199665
Reviewed-by: Maya Lekova <mslekova@chromium.org>
Commit-Queue: Benedikt Meurer <bmeurer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#55556}
This commit is contained in:
Benedikt Meurer 2018-08-31 16:19:59 +02:00 committed by Commit Bot
parent 455718ed3e
commit e034c1ad9c
2 changed files with 4 additions and 3 deletions

View File

@ -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);

View File

@ -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) \