Commit 2209d169 authored by Tobias Tebbi's avatar Tobias Tebbi Committed by Commit Bot

[builtins] fix Torque-implemented ToString performance regression

The order of the typeswitch branches causes repeated Smi-checks.
This CL fixes this by putting the Number case first.
However, the generated code is still worse due to repeated Map and
InstanceType loads. This will be fixed by a future load elimination for
Torque/CSA.

Bug: chromium:955976
Change-Id: I0f59ef795878f65b3cb11246626738bc33f8aff5
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1581644
Commit-Queue: Tobias Tebbi <tebbi@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60986}
parent 74341301
......@@ -2536,26 +2536,26 @@ transitioning macro ToStringImpl(context: Context, o: Object): String {
let result: Object = o;
while (true) {
typeswitch (result) {
case (str: String): {
return str;
}
case (num: Number): {
return NumberToString(num);
}
case (str: String): {
return str;
}
case (oddball: Oddball): {
return oddball.to_string;
}
case (Symbol): {
ThrowTypeError(kSymbolToString);
}
case (JSReceiver): {
result = NonPrimitiveToPrimitive_String(context, result);
continue;
}
case (Symbol): {
ThrowTypeError(kSymbolToString);
}
case (Object): {
return ToStringRT(context, o);
}
}
}
return ToStringRT(context, o);
unreachable;
}
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