WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
209030
[Cocoa] Push applicationSDKVersion() down from WebCore into WTF
https://bugs.webkit.org/show_bug.cgi?id=209030
Summary
[Cocoa] Push applicationSDKVersion() down from WebCore into WTF
Myles C. Maxfield
Reported
2020-03-12 17:55:00 PDT
[Cocoa] Push applicationSDKVersion() down from WebCore into WTF
Attachments
Patch
(22.69 KB, patch)
2020-03-12 18:02 PDT
,
Myles C. Maxfield
no flags
Details
Formatted Diff
Diff
Patch
(23.11 KB, patch)
2020-03-12 18:07 PDT
,
Myles C. Maxfield
no flags
Details
Formatted Diff
Diff
Patch
(21.97 KB, patch)
2020-03-12 18:23 PDT
,
Myles C. Maxfield
no flags
Details
Formatted Diff
Diff
Patch
(21.70 KB, patch)
2020-03-13 12:30 PDT
,
Myles C. Maxfield
no flags
Details
Formatted Diff
Diff
Patch
(21.50 KB, patch)
2020-03-13 12:34 PDT
,
Myles C. Maxfield
no flags
Details
Formatted Diff
Diff
Patch
(21.83 KB, patch)
2020-03-13 13:33 PDT
,
Myles C. Maxfield
no flags
Details
Formatted Diff
Diff
Patch
(21.83 KB, patch)
2020-03-13 13:58 PDT
,
Myles C. Maxfield
no flags
Details
Formatted Diff
Diff
Patch
(21.60 KB, patch)
2020-03-13 14:15 PDT
,
Myles C. Maxfield
no flags
Details
Formatted Diff
Diff
Patch
(21.60 KB, patch)
2020-03-13 14:43 PDT
,
Myles C. Maxfield
simon.fraser
: review+
Details
Formatted Diff
Diff
Patch for committing
(21.58 KB, patch)
2020-03-13 15:36 PDT
,
Myles C. Maxfield
no flags
Details
Formatted Diff
Diff
Show Obsolete
(8)
View All
Add attachment
proposed patch, testcase, etc.
Myles C. Maxfield
Comment 1
2020-03-12 18:02:23 PDT
Created
attachment 393433
[details]
Patch
Myles C. Maxfield
Comment 2
2020-03-12 18:07:05 PDT
Created
attachment 393435
[details]
Patch
Alexey Proskuryakov
Comment 3
2020-03-12 18:15:28 PDT
Comment on
attachment 393435
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=393435&action=review
> Source/WTF/wtf/RuntimeApplicationChecks.h:40 > +WTF_EXPORT_PRIVATE void setApplicationSDKVersion(uint32_t); > +WTF_EXPORT_PRIVATE uint32_t applicationSDKVersion();
Normally, public WTF symbols get exposed to the global namespace with "using", and then used without "WTF::".
> Source/WTF/wtf/RuntimeApplicationChecks.h:42 > +}
So, using WTF::setApplicationSDKVersion; using WTF::applicationSDKVersion; here.
Myles C. Maxfield
Comment 4
2020-03-12 18:23:26 PDT
Created
attachment 393437
[details]
Patch
Sam Weinig
Comment 5
2020-03-13 06:07:37 PDT
Comment on
attachment 393437
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=393437&action=review
> Source/WTF/ChangeLog:10 > + * wtf/RuntimeApplicationChecks.h: Added.
If these are only going to be implemented on cocoa platforms and since the concept of an SDK version, at least as used here, is cocoa specific, I would put this header in wtf/cocoa/
Myles C. Maxfield
Comment 6
2020-03-13 12:30:52 PDT
Created
attachment 393517
[details]
Patch
Myles C. Maxfield
Comment 7
2020-03-13 12:34:53 PDT
Created
attachment 393518
[details]
Patch
Darin Adler
Comment 8
2020-03-13 13:06:37 PDT
Comment on
attachment 393518
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=393518&action=review
> Source/WebCore/html/MediaElementSession.cpp:52 > +#include <wtf/cocoa/RuntimeApplicationChecksCocoa.h>
To be a Cocoa-only header, this it needs to either have #if PLATFORM(COCOA) or a more specific #if around every include in any non-Cocoa-specific source file (doesn’t have it here), or have that #if in the header itself (good practice, I think but doesn’t have it in this patch), or both. Smallest change I think would be to just move this include down inside the IOS_FAMILY where the old dyldSPI.h include was before.
> Source/WebCore/platform/RuntimeApplicationChecks.h:32 > +#if PLATFORM(COCOA) > +#include <wtf/cocoa/RuntimeApplicationChecksCocoa.h> > +#endif
Why? Doesn’t seem to be used in this header.
Myles C. Maxfield
Comment 9
2020-03-13 13:33:10 PDT
Created
attachment 393522
[details]
Patch
Myles C. Maxfield
Comment 10
2020-03-13 13:58:47 PDT
Created
attachment 393526
[details]
Patch
Myles C. Maxfield
Comment 11
2020-03-13 14:15:32 PDT
Created
attachment 393528
[details]
Patch
Myles C. Maxfield
Comment 12
2020-03-13 14:43:21 PDT
Created
attachment 393532
[details]
Patch
Simon Fraser (smfr)
Comment 13
2020-03-13 14:53:05 PDT
Comment on
attachment 393532
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=393532&action=review
> Source/WTF/wtf/cocoa/RuntimeApplicationChecksCocoa.cpp:27 > +#include <wtf/cocoa/RuntimeApplicationChecksCocoa.h>
Shouldn't this be included as "RuntimeApplicationChecksCocoa.h" here?
Myles C. Maxfield
Comment 14
2020-03-13 15:36:07 PDT
Created
attachment 393541
[details]
Patch for committing
Myles C. Maxfield
Comment 15
2020-03-13 16:13:30 PDT
(In reply to Simon Fraser (smfr) from
comment #13
)
> Comment on
attachment 393532
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=393532&action=review
> > > Source/WTF/wtf/cocoa/RuntimeApplicationChecksCocoa.cpp:27 > > +#include <wtf/cocoa/RuntimeApplicationChecksCocoa.h> > > Shouldn't this be included as "RuntimeApplicationChecksCocoa.h" here?
If you grep for "include <wtf/" inside the WTF folder, you get 1476 results among 750 files. I was following what appears to be the standard way to do it.
Myles C. Maxfield
Comment 16
2020-03-13 16:33:49 PDT
Committed
r258447
: <
https://trac.webkit.org/changeset/258447
>
Radar WebKit Bug Importer
Comment 17
2020-03-13 16:34:17 PDT
<
rdar://problem/60439292
>
Keith Miller
Comment 18
2020-03-13 23:06:44 PDT
This is my kinda patch. Embrace the WTF!
Darin Adler
Comment 19
2020-03-15 15:13:54 PDT
Comment on
attachment 393541
[details]
Patch for committing View in context:
https://bugs.webkit.org/attachment.cgi?id=393541&action=review
I have some suggested refinements; no rush to do these. One thing is that we should do something so that if someone tries to use dyld_get_program_sdk_version directly in the future, a macro trick makes it a compile-time error. Or any other tempting function that will definitely do the wrong thing in the non-UI process.
> Source/JavaScriptCore/API/JSWrapperMap.mm:726 > static uint32_t programSDKVersion = 0; > if (!programSDKVersion) > - programSDKVersion = dyld_get_program_sdk_version(); > + programSDKVersion = applicationSDKVersion();
Should just be a one-liner: static uint32_t programSDKVersion = applicationSDKVersion(); But really what we should be memo-izing is the entire boolean value for supportsInitMethodConstructors, not the two different version number integers (JavaScript and SDK). static bool supportsInitMethodConstructors = [] { ... all the code here, with no caching of anything in global variables ... }(); return supportsInitMethodConstructors; I’m also wondering if this code is sufficiently thread-safe.
> Source/WTF/wtf/cocoa/RuntimeApplicationChecksCocoa.cpp:2 > + * Copyright (C) 2011-2020 Apple Inc. All rights reserved.
Is there really code dating back to 2011 in the three functions in this file?
> Source/WTF/wtf/cocoa/RuntimeApplicationChecksCocoa.cpp:36 > + static NeverDestroyed<Optional<uint32_t>> version;
NeverDestroyed should not be needed here. I believe Optional goes out of its way to not add a non-trivial destructor in a case like this. If we remove the use of NeverDestroyed, we’ll get a compilation error if I’m wrong, given the warnings we have turned on.
> Source/WTF/wtf/cocoa/RuntimeApplicationChecksCocoa.h:2 > + * Copyright (C) 2009-2020 Apple Inc. All rights reserved.
Do the two function declarations in this header really qualify as code that dates back to 2009?
> Source/WTF/wtf/cocoa/RuntimeApplicationChecksCocoa.h:28 > +#include <wtf/Forward.h>
Unneeded include. If it is needed, I don’t understand why. The export macros come from ExportMacros.h which seems to be part of config.h, so no need to include it. And uint32_t comes from <stdint.h> or <cstdint>. Neither comes rom Forward.h.
> Source/WTF/wtf/cocoa/RuntimeApplicationChecksCocoa.h:31 > +// This contains the values with which to compare the return value of applicationSDKVersion(). > +#include <wtf/spi/darwin/dyldSPI.h>
That explains why files that use this to check the SDK version will need to include this header. It does not justify including this in this header. The source file that just calls setApplicationSDKVersion ends up including this unnecessarily. I suggest adding these includes back to the .cpp files where they are used.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug