Repository navigation
[WTF] Reduce stack use and code size of Vector append slow paths - #76313
Merged
webkit-commit-queue merged 1 commit intoOct 9, 2026
Conversation
Collaborator
|
EWS run on previous version of this PR (hash 2b915f8) Details |
Achierius
approved these changes
Oct 8, 2026
ddkilzer
force-pushed
the
eng/Reduce-stack-use-and-code-size-of-Vector-append-slow-paths
branch
from
October 8, 2026 18:12
2b915f8 to
4e3fbfe
Compare
Collaborator
|
EWS run on current version of this PR (hash 4e3fbfe) Details |
Collaborator
|
Safe-Merge-Queue: Build #107037. |
<https://bugs.webkit.org/show_bug.cgi?id=326804> <rdar://189511255> Reviewed by Marcus Plutowski. Pass small trivially copyable arguments by value to the out-of-line slow paths of `Vector::append()` and `Vector::constructAndAppend()`. The `append()` slow path takes the argument's address so `expandCapacity()` can rebase it if it points into the buffer being reallocated, and taking that address forces callers to keep the value in a stack slot, even for an `int` or a pointer. Copying such a value into a parameter before the buffer grows makes the rebase unnecessary. Also move the `constructAndAppend()` slow path out of line, as 201368@main did for the `append()` reallocation in `expandCapacity()`. Without `NEVER_INLINE`, clang inlines its reallocation sequence into many call sites, which grows code at each `constructAndAppend()` caller. Make `constructAndAppendSlowCase()` `ALWAYS_INLINE` into the by-value wrapper rather than `NEVER_INLINE` itself, since its by-reference parameters would make each caller copy a small argument from a register to a stack slot just to pass the slot's address. In a macOS release build, this shrinks `__text` by about 104 KB (0.1%) across JavaScriptCore, WebCore, WebKit, WebKitLegacy, and WebGPU, and the sum of their stack frame sizes by about 9.7 KB, mostly in JavaScriptCore and WebCore. Speedometer 3 is neutral. No new tests since no change in behavior. * Source/WTF/wtf/Vector.h: (WTF::Vector::append): (WTF::Vector::constructAndAppend): (WTF::Vector::appendSlowCaseByValue): Add. (WTF::Vector::constructAndAppendSlowCaseOutOfLine): Add. (WTF::Vector::constructAndAppendSlowCase): Canonical link: https://commits.webkit.org/323213@main
webkit-commit-queue
force-pushed
the
eng/Reduce-stack-use-and-code-size-of-Vector-append-slow-paths
branch
from
October 9, 2026 10:42
4e3fbfe to
22f00b3
Compare
Collaborator
|
Committed 323213@main (22f00b3): https://commits.webkit.org/323213@main Reviewed commits have been landed. Closing PR #76313 and removing active labels. |
ddkilzer
deleted the
eng/Reduce-stack-use-and-code-size-of-Vector-append-slow-paths
branch
October 9, 2026 20:03
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.
22f00b3
4e3fbfe