Bug 239054

Summary: Adopt "version set"-based linked-on-or-after checks instead of platform-specific ones
Product: WebKit Reporter: Tim Horton <thorton>
Component: New BugsAssignee: Tim Horton <thorton>
Status: RESOLVED FIXED    
Severity: Normal CC: ap, beidson, benjamin, cdumez, changseok, cmarcelo, dino, eric.carlson, esprehn+autocc, ews-watchlist, glenn, gyuyoung.kim, hi, japhet, jer.noble, joepeck, keith_miller, mark.lam, mmaxfield, msaboff, pangle, philipj, saam, sergio, simon.fraser, tzagallo, webkit-bug-importer, wenson_hsieh
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
ews-feeder: commit-queue-
Patch
ews-feeder: commit-queue-
Patch
ews-feeder: commit-queue-
Patch
ews-feeder: commit-queue-
Patch
ews-feeder: commit-queue-
Patch
none
Patch
none
Patch none

Description Tim Horton 2022-04-10 14:50:50 PDT
Adopt "version set"-based linked-on-or-after checks instead of platform-specific ones
Comment 1 Tim Horton 2022-04-10 14:52:05 PDT
Created attachment 457212 [details]
Patch
Comment 2 Tim Horton 2022-04-10 14:52:08 PDT
<rdar://problem/83436715>
Comment 3 Tim Horton 2022-04-10 14:54:02 PDT
Comment on attachment 457212 [details]
Patch

Oh dear, I forgot about the SPI headers.
Comment 4 Tim Horton 2022-04-10 15:01:25 PDT
Actually, not sure we can make SPI headers because of how dyld_build_version_t values are constructed. We might just have to always-be-linked-on-or-after-everything in the open source build? Though I can imagine folks objecting to that. Will ask around!
Comment 5 Tim Horton 2022-04-10 15:05:26 PDT
Or we could fall back to the old mechanism if the SDK we're building against doesn't have the requisite dyld_build_version_t defines... that would solve both the open source build and back-deployment problems. I will try to hack that up.
Comment 6 Tim Horton 2022-04-10 18:42:57 PDT
Created attachment 457220 [details]
Patch
Comment 7 Tim Horton 2022-04-10 18:46:50 PDT
Created attachment 457221 [details]
Patch
Comment 8 Tim Horton 2022-04-10 19:03:22 PDT
Created attachment 457222 [details]
Patch
Comment 9 Tim Horton 2022-04-10 19:08:41 PDT
Created attachment 457223 [details]
Patch
Comment 10 Tim Horton 2022-04-10 19:14:03 PDT
Created attachment 457224 [details]
Patch
Comment 11 Simon Fraser (smfr) 2022-04-11 11:41:59 PDT
Comment on attachment 457224 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=457224&action=review

> Source/WTF/wtf/cocoa/RuntimeApplicationChecksCocoa.cpp:75
> +    if (linkedBefore(dyld_fall_2015_os_versions, DYLD_IOS_VERSION_9_0, DYLD_MACOSX_VERSION_10_11))
> +        disableBehavior(SDKAlignedBehavior::PictureInPictureMediaPlayback);
> +
> +    if (linkedBefore(dyld_fall_2016_os_versions, DYLD_IOS_VERSION_10_0, DYLD_MACOSX_VERSION_10_12)) {

This code could make use of the fact that if 'linkedBefore(dyld_fall_2015_os_versions ' is true, then 'linkedBefore(dyld_fall_2016_os_versions' must also be true.
Comment 12 Wenson Hsieh 2022-04-11 11:49:19 PDT
Comment on attachment 457224 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=457224&action=review

> Source/WTF/wtf/Bitmap.h:249
> +    memset(bits.data(), 0xFF, sizeof(bits));

We chatted about this on Slack — it seems this might not work well with the implementation of `Bitmap::count()`, since it would end up counting bits after the last (valid) bit in the map.

(Though, that shouldn't trigger any bugs, since we only use `setAll()` for the linked-on behaviors map below)
Comment 13 Simon Fraser (smfr) 2022-04-11 11:53:51 PDT
Can this use a big OptionSet<> instead?
Comment 14 Tim Horton 2022-04-11 13:12:06 PDT
(In reply to Simon Fraser (smfr) from comment #13)
> Can this use a big OptionSet<> instead?

We're already at 60 bits, IDK if uint128_t is a thing I can use, and since we almost never remove things from this list and add them at a greater frequency now, I think using something flexible makes the most sense.
Comment 15 Tim Horton 2022-04-11 13:14:27 PDT
(In reply to Simon Fraser (smfr) from comment #11)
> Comment on attachment 457224 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=457224&action=review
> 
> > Source/WTF/wtf/cocoa/RuntimeApplicationChecksCocoa.cpp:75
> > +    if (linkedBefore(dyld_fall_2015_os_versions, DYLD_IOS_VERSION_9_0, DYLD_MACOSX_VERSION_10_11))
> > +        disableBehavior(SDKAlignedBehavior::PictureInPictureMediaPlayback);
> > +
> > +    if (linkedBefore(dyld_fall_2016_os_versions, DYLD_IOS_VERSION_10_0, DYLD_MACOSX_VERSION_10_12)) {
> 
> This code could make use of the fact that if
> 'linkedBefore(dyld_fall_2015_os_versions ' is true, then
> 'linkedBefore(dyld_fall_2016_os_versions' must also be true.

It is true, though dyld_program_sdk_at_least is very cheap, and it's likely not worth the decreased ergonomics within this function that people have to frequently add to (and also might confuse the weird one-off one where the versions are different).
Comment 16 Tim Horton 2022-04-11 13:14:51 PDT
(In reply to Wenson Hsieh from comment #12)
> Comment on attachment 457224 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=457224&action=review
> 
> > Source/WTF/wtf/Bitmap.h:249
> > +    memset(bits.data(), 0xFF, sizeof(bits));
> 
> We chatted about this on Slack — it seems this might not work well with the
> implementation of `Bitmap::count()`, since it would end up counting bits
> after the last (valid) bit in the map.
> 
> (Though, that shouldn't trigger any bugs, since we only use `setAll()` for
> the linked-on behaviors map below)

I will fix this.
Comment 17 Tim Horton 2022-04-11 23:46:03 PDT
Created attachment 457312 [details]
Patch
Comment 18 Tim Horton 2022-04-11 23:48:34 PDT
Created attachment 457313 [details]
Patch
Comment 19 Myles C. Maxfield 2022-04-12 00:25:40 PDT
Holy moly we have a lot of linkedOnOrAfter checks!
Comment 20 Wenson Hsieh 2022-04-12 11:59:54 PDT
Comment on attachment 457313 [details]
Patch

r=mews
Comment 21 EWS 2022-04-12 17:39:36 PDT
Committed r292793 (249576@main): <https://commits.webkit.org/249576@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 457313 [details].