Repository navigation
[JSC] Optimize String.fromCharCode with multiple arguments - #80412
Merged
webkit-commit-queue merged 1 commit intoNov 25, 2026
Conversation
Collaborator
|
EWS run on previous version of this PR (hash d258bd3) Details |
sosukesuzuki
marked this pull request as ready for review
November 11, 2026 03:45
Collaborator
macOS Safer C++ Build #148131 (d258bd3)❌ Found 1 failing file with 1 issue. Please address these issues before landing. See WebKit Guidelines for Safer C++ Programming. |
Collaborator
iOS Safer C++ Build #67869 (d258bd3)❌ Found 1 failing file with 1 issue. Please address these issues before landing. See WebKit Guidelines for Safer C++ Programming. |
sosukesuzuki
force-pushed
the
eng/JSC-Optimize-String-fromCharCode-with-multiple-arguments
branch
from
November 11, 2026 05:14
d258bd3 to
7e19480
Compare
Collaborator
|
EWS run on current version of this PR (hash 7e19480) Details |
This was referenced Nov 12, 2026
Constellation
approved these changes
Nov 25, 2026
https://bugs.webkit.org/show_bug.cgi?id=331034 Reviewed by Yusuke Suzuki. String.fromCharCode with two or more arguments always goes to the host function. It optimistically allocated an 8-bit buffer, and when it found a non-Latin1 character, threw it away and allocated a 16-bit one. It also converted each argument with an out-of-line toUInt32 call followed by an exception check. Converting Int32 values has no side effects. So this patch first scans the arguments: the AND of their encodings tells whether all of them are Int32, and the OR tells whether all of the characters are Latin1. If all of them are Int32, we allocate a buffer of the right width once, and fill it by narrowing the encoded values with WTF::copyElements. Otherwise, we convert them into a temporary buffer, and create the string from it. Baseline Patched string-from-char-code-two-latin1 27.8257+-0.2125 ^ 21.8677+-0.2164 ^ definitely 1.2725x faster string-from-char-code-surrogate-pair 42.8458+-0.8424 ^ 23.2908+-0.2916 ^ definitely 1.8396x faster string-from-char-code-apply 32.1576+-0.2703 ^ 10.5591+-0.2206 ^ definitely 3.0455x faster string-from-char-code-apply-double 32.1350+-0.1259 ^ 19.7438+-0.1864 ^ definitely 1.6276x faster Tests: JSTests/microbenchmarks/string-from-char-code-apply-double.js JSTests/microbenchmarks/string-from-char-code-apply.js JSTests/microbenchmarks/string-from-char-code-surrogate-pair.js JSTests/microbenchmarks/string-from-char-code-two-latin1.js JSTests/stress/string-from-char-code-multiple-arguments.js * JSTests/microbenchmarks/string-from-char-code-apply-double.js: Added. (test): * JSTests/microbenchmarks/string-from-char-code-apply.js: Added. (test): * JSTests/microbenchmarks/string-from-char-code-surrogate-pair.js: Added. (test): * JSTests/microbenchmarks/string-from-char-code-two-latin1.js: Added. (test): * JSTests/stress/string-from-char-code-multiple-arguments.js: Added. (shouldBe): (reference): (check): (thrownBy): (two): (three): (1024.codes.1.valueOf): * Source/JavaScriptCore/runtime/StringConstructor.cpp: (JSC::classifyCharCodes): (JSC::createStringImplFromInt32CharCodes): (JSC::stringFromCharCodesSlow): (JSC::JSC_DEFINE_HOST_FUNCTION): Canonical link: https://commits.webkit.org/327767@main
webkit-commit-queue
force-pushed
the
eng/JSC-Optimize-String-fromCharCode-with-multiple-arguments
branch
from
November 25, 2026 15:15
7e19480 to
cf5b4b6
Compare
Collaborator
|
Committed 327767@main (cf5b4b6): https://commits.webkit.org/327767@main Reviewed commits have been landed. Closing PR #80412 and removing active labels. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🧪 bindings
cf5b4b6
7e19480