Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 8c5c8fb7bbb1259ee1d37c9d39b9cbab10bbfebf
https://github.com/WebKit/WebKit/commit/8c5c8fb7bbb1259ee1d37c9d39b9cbab10bbfebf
Author: Sosuke Suzuki <[email protected]>
Date: 2026-06-18 (Thu, 18 Jun 2026)
Changed paths:
A JSTests/microbenchmarks/parse-int-string-no-radix.js
A JSTests/microbenchmarks/parse-int-string-radix-10-slow-shapes.js
A JSTests/microbenchmarks/parse-int-string-radix-10.js
A JSTests/stress/parse-int-radix-10-int32-fast-path.js
M Source/JavaScriptCore/runtime/ParseInt.h
Log Message:
-----------
[JSC] Add int32 fast path to `parseInt` for short decimal strings
https://bugs.webkit.org/show_bug.cgi?id=317187
Reviewed by Yusuke Suzuki.
parseInt always accumulates digits in double and runs the generic
parseDigit dispatch (digit/upper/lower three-way branch) even for
radix 10. Add two layers of fast paths:
1. At the top of parseInt():
when radix is 10 or 0, length is 1..9,
and the first character is '1'..'9', skip whitespace, sign,
0x-prefix and radix-range handling entirely and accumulate the
result in int32.
2. After the generic setup, when radix resolved to 10: accumulate up
to 9 digits in int32, seeding into double only when a 10th digit
appears, and use isASCIIDigit instead of parseDigit. This also
covers leading-zero/sign/whitespace inputs that miss path 1 so
they do not regress.
The generic loop's now-unreachable radix==10 mantissa-overflow branch
is removed.
TipOfTree Patched
parse-int-string-no-radix 43.1823+-0.4470 ^
28.2848+-0.1850 ^ definitely 1.5267x faster
parse-int-string-radix-10 42.3626+-0.4482 ^
29.3662+-0.1627 ^ definitely 1.4426x faster
parse-int-string-radix-10-slow-shapes 49.1872+-0.4298 ^
44.4247+-0.5849 ^ definitely 1.1072x
faster
Tests: JSTests/microbenchmarks/parse-int-string-no-radix.js
JSTests/microbenchmarks/parse-int-string-radix-10-slow-shapes.js
JSTests/microbenchmarks/parse-int-string-radix-10.js
JSTests/stress/parse-int-radix-10-int32-fast-path.js
* JSTests/microbenchmarks/parse-int-string-no-radix.js: Added.
(test):
* JSTests/microbenchmarks/parse-int-string-radix-10-slow-shapes.js: Added.
(test):
* JSTests/microbenchmarks/parse-int-string-radix-10.js: Added.
(test):
* JSTests/stress/parse-int-radix-10-int32-fast-path.js: Added.
(shouldBe):
(test):
* Source/JavaScriptCore/runtime/ParseInt.h:
(JSC::parseInt):
Canonical link:
https://flagged.apple.com:443/proxy?t2=DG6g5p8KB7&o=aHR0cHM6Ly9jb21taXRzLndlYmtpdC5vcmcvMzE1NDUxQG1haW4=&emid=a0963157-f5ed-41b8-9e8b-ae8a6fe3fd22&c=11
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications