Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 4d03df5acb1fcbcab2a05f510e956d3cb770d37a
https://github.com/WebKit/WebKit/commit/4d03df5acb1fcbcab2a05f510e956d3cb770d37a
Author: Mark Lam <[email protected]>
Date: 2025-12-02 (Tue, 02 Dec 2025)
Changed paths:
M Source/WTF/WTF.xcodeproj/project.pbxproj
M Source/WTF/wtf/CMakeLists.txt
A Source/WTF/wtf/CompactPtr.cpp
M Source/WTF/wtf/CompactPtr.h
M Tools/TestWebKitAPI/Tests/WTF/CompactPtr.cpp
Log Message:
-----------
Implement a fallback in CompactPtr for storing some pointers that don't fit
within 36-bits.
https://bugs.webkit.org/show_bug.cgi?id=303343
rdar://165647792
Reviewed by Dan Hecht.
The OS linker / loader (at its own discretion) may choose to locate statically
allocated
objects at addresses that are beyond the 36-bits range (unlike heap addresses
which are
always within 36-bits). As such, for robustness, CompactPtr should have a
fallback system
that allows it to encode such outsized pointers.
We observe that:
1. The OS will never allocate objects (heap or otherwise) within the __PAGEZERO
region.
2. The number of such statically allocated objects that we'll ever store in
CompactPtrs
are finite and small-ish (on the order of < 1100 instances).
Hence, we can use the addresses within __PAGEZERO to represent indexes into a
table of
OutsizedCompactPtrs where the full (> 36 bits) pointer value is actually stored.
__PAGEZERO is currently around 4G in size. However, we'll conservatively
reserve only
the first 256K of addresses for OutsizedCompactPtrs. This allows us to encode
up to 16K
outsized pointers.
Meanwhile, we should also reduce the number of statically allocated objects
that can be
stored in CompactPtrs. It would be ideal if the number of such objects reduce
to way
under 1022. With that, we would be able to encode all those pointers even if
the size of
__PAGEZERO is literally reduced to the size of 1 16K page. This will be left
as an
exercise for future patches. Until then, we'll work with the 256K heuristic.
Test: Tools/TestWebKitAPI/Tests/WTF/CompactPtr.cpp
* Source/WTF/WTF.xcodeproj/project.pbxproj:
* Source/WTF/wtf/CMakeLists.txt:
* Source/WTF/wtf/CompactPtr.cpp: Added.
(WTF::ensureOutsizedCompactPtrManager):
(WTF::OutsizedCompactPtr::encode):
(WTF::OutsizedCompactPtr::decode):
* Source/WTF/wtf/CompactPtr.h:
(WTF::CompactPtr::encode):
(WTF::CompactPtr::decode):
* Tools/TestWebKitAPI/Tests/WTF/CompactPtr.cpp:
(TestWebKitAPI::TEST(WTF_CompactPtr, Basic)):
Canonical link: https://commits.webkit.org/303809@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications