Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 22f00b355a201fbaf7f4c504b0a88648f2cc9d46
https://github.com/WebKit/WebKit/commit/22f00b355a201fbaf7f4c504b0a88648f2cc9d46
Author: David Kilzer <[email protected]>
Date: 2026-10-09 (Fri, 09 Oct 2026)
Changed paths:
M Source/WTF/wtf/Vector.h
Log Message:
-----------
[WTF] Reduce stack use and code size of Vector append slow paths
<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
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications