Skip to content

Conversation

@MenloDorian
Copy link

@MenloDorian MenloDorian commented Feb 1, 2026

24c117b

Remove SizeAndAlignment class in TZone code.
https://bugs.webkit.org/show_bug.cgi?id=306717
rdar://169370644

Reviewed by Keith Miller.

The SizeAndAlignment logic belongs in TZoneSpecification which defines a TZone type's
sorting algorithm / criteria.  This refactoring paves the way to add alternate TZone
categories that use different sorting algorithms for heap selection.

Also added some debugging info (file and line number) to TZoneSpecification because
classname alone is insufficient as there can be many classes with the same name.
Also enhanced TZoneHeapManager::dumpRegisteredTypes(0 to also print the pid to
distinguish between processes.

No new tests because this is a refactoring patch.  There is no behavior change..

* Source/bmalloc/bmalloc/TZoneHeap.h:
(bmalloc::api::TZoneDescriptorHashTrait::hash):
(bmalloc::api::TZoneSpecification::sizeClass const):
(bmalloc::api::TZoneSpecification::encodeSize):
(bmalloc::api::TZoneSpecification::encodeAlignment):
(bmalloc::api::TZoneSpecification::encodeDescriptor):
(bmalloc::api::SizeAndAlignment::encode): Deleted.
(bmalloc::api::SizeAndAlignment::decodeSize): Deleted.
(bmalloc::api::SizeAndAlignment::decodeAlignment): Deleted.
* Source/bmalloc/bmalloc/TZoneHeapInlines.h:
* Source/bmalloc/bmalloc/TZoneHeapManager.cpp:
(bmalloc::api::TZoneDescriptorDecoder::TZoneDescriptorDecoder):
(bmalloc::api::TZoneDescriptorDecoder::value const):
(bmalloc::api::TZoneDescriptorDecoder::sizeClass const):
(bmalloc::api::TZoneDescriptorDecoder::alignment const):
(bmalloc::api::TZoneHeapManager::dumpRegisteredTypes):
(bmalloc::api::TZoneHeapManager::bucketCountForSizeClass):
(bmalloc::api::TZoneHeapManager::bucketForKey):
(bmalloc::api::TZoneHeapManager::populateGroupBuckets):
(bmalloc::api::TZoneHeapManager::heapRefForTZoneType):
(bmalloc::api::TZoneHeapManager::TZoneHeapManager::heapRefForTZoneTypeDifferentSize):
* Source/bmalloc/bmalloc/TZoneHeapManager.h:

Canonical link: https://commits.webkit.org/306630@main

4dd3d22

Misc iOS, visionOS, tvOS & watchOS macOS Linux Windows Apple Internal
❌ 🧪 style ✅ 🛠 ios ✅ 🛠 mac ✅ 🛠 wpe ✅ 🛠 win ✅ 🛠 ios-apple
✅ 🛠 ios-sim ✅ 🛠 mac-AS-debug ✅ 🧪 wpe-wk2 ✅ 🧪 win-tests ✅ 🛠 mac-apple
✅ 🧪 webkitperl ✅ 🧪 ios-wk2 ✅ 🧪 api-mac ✅ 🧪 api-wpe ✅ 🛠 vision-apple
✅ 🧪 ios-wk2-wpt ✅ 🧪 api-mac-debug ✅ 🛠 wpe-libwebrtc
✅ 🛠 🧪 jsc ✅ 🧪 api-ios ✅ 🧪 mac-wk1 ✅ 🛠 gtk
✅ 🛠 🧪 jsc-debug-arm64 ✅ 🛠 vision ✅ 🧪 mac-wk2 ✅ 🧪 gtk-wk2
✅ 🛠 vision-sim ✅ 🧪 mac-AS-debug-wk2 ✅ 🧪 api-gtk
✅ 🧪 vision-wk2 ✅ 🧪 mac-wk2-stress ✅ 🛠 playstation
✅ 🛠 🧪 unsafe-merge ✅ 🛠 tv ✅ 🧪 mac-intel-wk2 ✅ 🛠 jsc-armv7
✅ 🛠 tv-sim ✅ 🧪 jsc-armv7-tests
✅ 🛠 watch
✅ 🛠 watch-sim

@MenloDorian MenloDorian requested a review from a team as a code owner February 1, 2026 04:07
@MenloDorian MenloDorian self-assigned this Feb 1, 2026
@MenloDorian MenloDorian added the JavaScriptCore For bugs in JavaScriptCore, the JS engine used by WebKit, other than kxmlcore issues. label Feb 1, 2026
struct TZoneSpecification {
HeapRef* addressOfHeapRef;
unsigned size;
uint16_t alignment;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not increase the size of TZoneSpecification. There's an unused padding bytes here that I'm fitting this alignment field into. Having the alignment here makes it easier to get this value later rather than always having to decode it from the descriptor.

@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Feb 1, 2026
@MenloDorian MenloDorian removed the merging-blocked Applied to prevent a change from being merged label Feb 1, 2026
Copy link
Contributor

@kmiller68 kmiller68 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r=me with minor nit.

#define BUSE_TZONE_SPEC_NAME_ARG 0
#if BUSE_TZONE_SPEC_NAME_ARG
#define TZONE_SPEC_NAME_ARG(x) , x
#define TZONE_SPEC_NAME_ARG(x) x, __FILE__, __LINE__,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: We should probably use std::source_location for new code.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll make this change in a follow up later. Gonna land this PR as is for now.

@MenloDorian MenloDorian added the unsafe-merge-queue Applied to send a pull request to merge-queue, but skip building and testing label Feb 2, 2026
https://bugs.webkit.org/show_bug.cgi?id=306717
rdar://169370644

Reviewed by Keith Miller.

The SizeAndAlignment logic belongs in TZoneSpecification which defines a TZone type's
sorting algorithm / criteria.  This refactoring paves the way to add alternate TZone
categories that use different sorting algorithms for heap selection.

Also added some debugging info (file and line number) to TZoneSpecification because
classname alone is insufficient as there can be many classes with the same name.
Also enhanced TZoneHeapManager::dumpRegisteredTypes(0 to also print the pid to
distinguish between processes.

No new tests because this is a refactoring patch.  There is no behavior change..

* Source/bmalloc/bmalloc/TZoneHeap.h:
(bmalloc::api::TZoneDescriptorHashTrait::hash):
(bmalloc::api::TZoneSpecification::sizeClass const):
(bmalloc::api::TZoneSpecification::encodeSize):
(bmalloc::api::TZoneSpecification::encodeAlignment):
(bmalloc::api::TZoneSpecification::encodeDescriptor):
(bmalloc::api::SizeAndAlignment::encode): Deleted.
(bmalloc::api::SizeAndAlignment::decodeSize): Deleted.
(bmalloc::api::SizeAndAlignment::decodeAlignment): Deleted.
* Source/bmalloc/bmalloc/TZoneHeapInlines.h:
* Source/bmalloc/bmalloc/TZoneHeapManager.cpp:
(bmalloc::api::TZoneDescriptorDecoder::TZoneDescriptorDecoder):
(bmalloc::api::TZoneDescriptorDecoder::value const):
(bmalloc::api::TZoneDescriptorDecoder::sizeClass const):
(bmalloc::api::TZoneDescriptorDecoder::alignment const):
(bmalloc::api::TZoneHeapManager::dumpRegisteredTypes):
(bmalloc::api::TZoneHeapManager::bucketCountForSizeClass):
(bmalloc::api::TZoneHeapManager::bucketForKey):
(bmalloc::api::TZoneHeapManager::populateGroupBuckets):
(bmalloc::api::TZoneHeapManager::heapRefForTZoneType):
(bmalloc::api::TZoneHeapManager::TZoneHeapManager::heapRefForTZoneTypeDifferentSize):
* Source/bmalloc/bmalloc/TZoneHeapManager.h:

Canonical link: https://commits.webkit.org/306630@main
@webkit-commit-queue webkit-commit-queue force-pushed the eng/Remove-SizeAndAlignment-class-in-TZone-code branch from 4dd3d22 to 24c117b Compare February 2, 2026 16:29
@webkit-commit-queue
Copy link
Collaborator

Committed 306630@main (24c117b): https://commits.webkit.org/306630@main

Reviewed commits have been landed. Closing PR #57649 and removing active labels.

@webkit-commit-queue webkit-commit-queue merged commit 24c117b into WebKit:main Feb 2, 2026
@webkit-commit-queue webkit-commit-queue removed the unsafe-merge-queue Applied to send a pull request to merge-queue, but skip building and testing label Feb 2, 2026
@MenloDorian MenloDorian deleted the eng/Remove-SizeAndAlignment-class-in-TZone-code branch February 2, 2026 21:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

JavaScriptCore For bugs in JavaScriptCore, the JS engine used by WebKit, other than kxmlcore issues.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants