Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: f5716f6401ed2ce8769c42fa2aa33f7c4a4dd39b
https://github.com/WebKit/WebKit/commit/f5716f6401ed2ce8769c42fa2aa33f7c4a4dd39b
Author: Keith Miller <[email protected]>
Date: 2026-07-30 (Thu, 30 Jul 2026)
Changed paths:
M Configurations/CommonBase.xcconfig
M Source/JavaScriptCore/API/glib/JSCValue.cpp
M Source/WTF/wtf/Compiler.h
M Source/WTF/wtf/FastMalloc.cpp
M Source/WTF/wtf/FastMalloc.h
M Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.cpp
M Source/WebCore/platform/sql/SQLiteDatabase.cpp
M Source/WebKit/NetworkProcess/cache/NetworkCacheDataGLib.cpp
M Source/WebKit/NetworkProcess/cache/NetworkCacheIOChannelGLib.cpp
M Source/WebKit/UIProcess/API/glib/WebKitWebView.cpp
M Source/bmalloc/libpas/src/libpas/bmalloc_heap.c
M Source/bmalloc/libpas/src/libpas/bmalloc_heap_inlines.h
M Source/bmalloc/libpas/src/libpas/pas_mar_registry.c
M Source/bmalloc/libpas/src/libpas/pas_mar_registry.h
M Source/bmalloc/libpas/src/libpas/pas_thread_local_cache.c
M Source/bmalloc/libpas/src/libpas/pas_thread_local_cache.h
M Source/bmalloc/libpas/src/libpas/pas_try_allocate_intrinsic.h
M Source/bmalloc/libpas/src/libpas/pas_try_allocate_primitive.h
M Source/bmalloc/libpas/src/libpas/pas_utils.h
M Source/bmalloc/libpas/src/libpas/pas_utils_prefix.h
M Source/cmake/WebKitCompilerFlags.cmake
Log Message:
-----------
Add preserve_most to most fastMalloc APIs on ARM64
https://bugs.webkit.org/show_bug.cgi?id=320661
rdar://183640618
Reviewed by Mark Lam, Yusuke Suzuki, and Marcus Plutowski.
This patch adds Clang's preserve_most attribute to most fastMalloc APIs.
The preserve_most attribute on ARM64 turns `x9-x15` into callee saves.
See: https://clang.llvm.org/docs/AttributeReference.html#preserve-most
For functions that are leaf functions this can be beneficial as the
caller has more scratch registers to work with that they don't have to
save. AI helped me gather the following analysis of a production build.
Counting every stp/str that writes a callee-saved register to the stack.
```
┌───────────┬─────────┬──────────┬─────────┬─────────┬────────┐
│ framework │ bucket │ baseline │ patched │ delta │ % │
├───────────┼─────────┼──────────┼─────────┼─────────┼────────┤
│ JSC │ x19-x28 │ 163,270 │ 153,920 │ -9,350 │ -5.73% │
├───────────┼─────────┼──────────┼─────────┼─────────┼────────┤
│ │ x9-x15 │ 23,459 │ 24,647 │ +1,188 │ +5.06% │
├───────────┼─────────┼──────────┼─────────┼─────────┼────────┤
│ │ d8-d15 │ 3,290 │ 3,290 │ 0 │ — │
├───────────┼─────────┼──────────┼─────────┼─────────┼────────┤
│ │ fp/lr │ 49,488 │ 49,507 │ +19 │ +0.04% │
├───────────┼─────────┼──────────┼─────────┼─────────┼────────┤
│ │ total │ 239,507 │ 231,364 │ -8,143 │ -3.40% │
├───────────┼─────────┼──────────┼─────────┼─────────┼────────┤
│ WebCore │ x19-x28 │ 412,378 │ 395,350 │ -17,028 │ -4.13% │
├───────────┼─────────┼──────────┼─────────┼─────────┼────────┤
│ │ x9-x15 │ 28,562 │ 30,434 │ +1,872 │ +6.55% │
├───────────┼─────────┼──────────┼─────────┼─────────┼────────┤
│ │ d8-d15 │ 16,426 │ 16,427 │ +1 │ — │
├───────────┼─────────┼──────────┼─────────┼─────────┼────────┤
│ │ fp/lr │ 178,373 │ 178,362 │ -11 │ -0.01% │
├───────────┼─────────┼──────────┼─────────┼─────────┼────────┤
│ │ total │ 635,739 │ 620,573 │ -15,166 │ -2.39% │
├───────────┼─────────┼──────────┼─────────┼─────────┼────────┤
│ WebKit │ x19-x28 │ 209,816 │ 203,697 │ -6,119 │ -2.92% │
├───────────┼─────────┼──────────┼─────────┼─────────┼────────┤
│ │ x9-x15 │ 7,672 │ 8,360 │ +688 │ +8.97% │
├───────────┼─────────┼──────────┼─────────┼─────────┼────────┤
│ │ d8-d15 │ 5,472 │ 5,472 │ 0 │ — │
├───────────┼─────────┼──────────┼─────────┼─────────┼────────┤
│ │ fp/lr │ 117,244 │ 117,242 │ -2 │ — │
├───────────┼─────────┼──────────┼─────────┼─────────┼────────┤
│ │ total │ 340,204 │ 334,771 │ -5,433 │ -1.60% │
└───────────┴─────────┴──────────┴─────────┴─────────┴────────┘
```
Combined: 1,215,450 → 1,186,708, a net -28,742 (-2.36%).
Text size shrinks in step: -15,142 / -17,215 / -6,438 instructions.
I only applied preserve_most to ARM64 since on X86 it leaves only one
scratch free, which doesn't seem worth it. Additionally, there seems to
be a "bug" in LLVM's hot-cold outlining where the cold function doesn't
inherit the hot function's calling convention. I filed rdar://183555125
to track this. That said, LTO seems to undo this problem (even without
PGO data) so it's still worth enabling when LTO is on.
No new tests, no observable behavior change.
Canonical link: https://commits.webkit.org/318270@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications