Changeset 215424 in webkit


Ignore:
Timestamp:
Apr 17, 2017 1:22:24 PM (7 years ago)
Author:
mitz@apple.com
Message:

[Cocoa] Move isNullFunctionPointer down into WTF
https://bugs.webkit.org/show_bug.cgi?id=170892

Reviewed by Sam Weinig.

Source/WebCore:

  • platform/mediastream/libwebrtc/LibWebRTCProvider.cpp:

(WebCore::LibWebRTCProvider::webRTCAvailable): Changed to use WTF::isNullFunctionPointer,

and removed the static variable, so instead of loading from the initialization guard,
branching, then loading from the variable itself, we just load from the function pointer.

(WebCore::isNullFunctionPointer): Deleted.

Source/WebKit2:

  • Platform/classifier/cocoa/ResourceLoadStatisticsClassifierCocoa.cpp:

(WebKit::ResourceLoadStatisticsClassifierCocoa::canUseCorePrediction): Changed to use

WTF::isNullFunctionPointer.

(WebKit::isNullFunctionPointer): Deleted.

Source/WTF:

Test: TestWebKitAPI/Tests/WTF/darwin/WeakLinking.cpp

  • WTF.xcodeproj/project.pbxproj: Added reference to new file.
  • wtf/darwin: Added.
  • wtf/darwin/WeakLinking.h: Added.

(WTF::isNullFunctionPointer): Copied from ResourceLoadStatisticsClassifierCocoa.cpp in

WebKit2 and changed into a function template that works with any function pointer.

Tools:

  • TestWebKitAPI/Configurations/TestWTF.xcconfig:
  • TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
  • TestWebKitAPI/Tests/WTF/darwin/WeakLinking.cpp: Added.

(TestWebKitAPI::TEST):

  • TestWebKitAPI/Tests/WTF/darwin/libTestWTFAlwaysMissing-iOS-v2.tbd: Added.
  • TestWebKitAPI/Tests/WTF/darwin/libTestWTFAlwaysMissing-iOS.tbd: Added.
  • TestWebKitAPI/Tests/WTF/darwin/libTestWTFAlwaysMissing-macOS-v2.tbd: Added.
  • TestWebKitAPI/Tests/WTF/darwin/libTestWTFAlwaysMissing-macOS.tbd: Added.
Location:
trunk
Files:
7 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/ChangeLog

    r215417 r215424  
     12017-04-17  Dan Bernstein  <mitz@apple.com>
     2
     3        [Cocoa] Move isNullFunctionPointer down into WTF
     4        https://bugs.webkit.org/show_bug.cgi?id=170892
     5
     6        Reviewed by Sam Weinig.
     7
     8        Test: TestWebKitAPI/Tests/WTF/darwin/WeakLinking.cpp
     9
     10        * WTF.xcodeproj/project.pbxproj: Added reference to new file.
     11        * wtf/darwin: Added.
     12        * wtf/darwin/WeakLinking.h: Added.
     13        (WTF::isNullFunctionPointer): Copied from ResourceLoadStatisticsClassifierCocoa.cpp in
     14          WebKit2 and changed into a function template that works with any function pointer.
     15
    1162017-04-17  Ryan Haddad  <ryanhaddad@apple.com>
    217
  • trunk/Source/WTF/WTF.xcodeproj/project.pbxproj

    r215354 r215424  
    141141                2CDED0F318115C85004DBA70 /* RunLoop.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2CDED0F118115C85004DBA70 /* RunLoop.cpp */; };
    142142                2CDED0F418115C85004DBA70 /* RunLoop.h in Headers */ = {isa = PBXBuildFile; fileRef = 2CDED0F218115C85004DBA70 /* RunLoop.h */; };
     143                37C7CC2A1EA40A73007BD956 /* WeakLinking.h in Headers */ = {isa = PBXBuildFile; fileRef = 37C7CC291EA40A73007BD956 /* WeakLinking.h */; };
    143144                430B47891AAAAC1A001223DA /* StringCommon.h in Headers */ = {isa = PBXBuildFile; fileRef = 430B47871AAAAC1A001223DA /* StringCommon.h */; };
    144145                4B2680DD9B974402899ED572 /* IndexedContainerIterator.h in Headers */ = {isa = PBXBuildFile; fileRef = 9C67C542589348E285B49699 /* IndexedContainerIterator.h */; };
     
    540541                2CDED0F218115C85004DBA70 /* RunLoop.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RunLoop.h; sourceTree = "<group>"; };
    541542                3137E1D7DBD84AC38FAE4D34 /* IndexSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IndexSet.h; sourceTree = "<group>"; };
     543                37C7CC291EA40A73007BD956 /* WeakLinking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WeakLinking.h; sourceTree = "<group>"; };
    542544                430B47871AAAAC1A001223DA /* StringCommon.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StringCommon.h; sourceTree = "<group>"; };
    543545                513E170A1CD7D5BF00E3650B /* LoggingAccumulator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LoggingAccumulator.h; sourceTree = "<group>"; };
     
    863865                        sourceTree = "<group>";
    864866                };
     867                37C7CC281EA40A54007BD956 /* darwin */ = {
     868                        isa = PBXGroup;
     869                        children = (
     870                                37C7CC291EA40A73007BD956 /* WeakLinking.h */,
     871                        );
     872                        path = darwin;
     873                        sourceTree = "<group>";
     874                };
    865875                5D247B5714689B8600E78B76 = {
    866876                        isa = PBXGroup;
     
    933943                                2CDED0F018115C3F004DBA70 /* cf */,
    934944                                E4A0AD3B1A96251900536DF6 /* cocoa */,
     945                                37C7CC281EA40A54007BD956 /* darwin */,
    935946                                A8A47281151A825A004123FF /* dtoa */,
    936947                                1FA47C87152502DA00568D1B /* ios */,
     
    14671478                                A8A473A6151A825B004123FF /* DisallowCType.h in Headers */,
    14681479                                A8A473AF151A825B004123FF /* diy-fp.h in Headers */,
     1480                                37C7CC2A1EA40A73007BD956 /* WeakLinking.h in Headers */,
    14691481                                0F4570431BE5B58F0062A629 /* Dominators.h in Headers */,
    14701482                                A8A473B1151A825B004123FF /* double-conversion.h in Headers */,
  • trunk/Source/WebCore/ChangeLog

    r215423 r215424  
     12017-04-17  Dan Bernstein  <mitz@apple.com>
     2
     3        [Cocoa] Move isNullFunctionPointer down into WTF
     4        https://bugs.webkit.org/show_bug.cgi?id=170892
     5
     6        Reviewed by Sam Weinig.
     7
     8        * platform/mediastream/libwebrtc/LibWebRTCProvider.cpp:
     9        (WebCore::LibWebRTCProvider::webRTCAvailable): Changed to use WTF::isNullFunctionPointer,
     10          and removed the static variable, so instead of loading from the initialization guard,
     11          branching, then loading from the variable itself, we just load from the function pointer.
     12        (WebCore::isNullFunctionPointer): Deleted.
     13
    1142017-04-14  Jiewen Tan  <jiewen_tan@apple.com>
    215
  • trunk/Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCProvider.cpp

    r215411 r215424  
    3939#include <wtf/Function.h>
    4040#include <wtf/NeverDestroyed.h>
     41#include <wtf/darwin/WeakLinking.h>
    4142#endif
    4243
     
    205206}
    206207
    207 static inline bool isNullFunctionPointer(void* functionPointer)
    208 {
    209     void* result;
    210     asm(
    211         "mov %1, %0"
    212         : "=r" (result)
    213         : "r" (functionPointer)
    214     );
    215     return !result;
    216 }
    217 
    218208#endif // USE(LIBWEBRTC)
    219209
     
    221211{
    222212#if USE(LIBWEBRTC)
    223     static bool available = [] {
    224         return !isNullFunctionPointer(reinterpret_cast<void*>(rtc::LogMessage::LogToDebug));
    225     }();
    226     return available;
     213    return !isNullFunctionPointer(rtc::LogMessage::LogToDebug);
    227214#else
    228215    return true;
  • trunk/Source/WebKit2/ChangeLog

    r215421 r215424  
     12017-04-17  Dan Bernstein  <mitz@apple.com>
     2
     3        [Cocoa] Move isNullFunctionPointer down into WTF
     4        https://bugs.webkit.org/show_bug.cgi?id=170892
     5
     6        Reviewed by Sam Weinig.
     7
     8        * Platform/classifier/cocoa/ResourceLoadStatisticsClassifierCocoa.cpp:
     9        (WebKit::ResourceLoadStatisticsClassifierCocoa::canUseCorePrediction): Changed to use
     10          WTF::isNullFunctionPointer.
     11        (WebKit::isNullFunctionPointer): Deleted.
     12
    1132017-04-17  Wenson Hsieh  <wenson_hsieh@apple.com>
    214
  • trunk/Source/WebKit2/Platform/classifier/cocoa/ResourceLoadStatisticsClassifierCocoa.cpp

    r215247 r215424  
    3232#include "Logging.h"
    3333#include <wtf/NeverDestroyed.h>
     34#include <wtf/darwin/WeakLinking.h>
    3435
    3536namespace WebKit {
     
    7374}
    7475
    75 static inline bool isNullFunctionPointer(void* functionPointer)
    76 {
    77     void* result;
    78     // The C compiler may take advantage of the fact that by definition, function pointers cannot be
    79     // null. When weak-linking a library, function pointers can be null. We use non-C code to
    80     // prevent the C compiler from using the definition to optimize out the null check.
    81     asm(
    82         "mov %1, %0"
    83         : "=r" (result)
    84         : "r" (functionPointer)
    85     );
    86     return !result;
    87 }
    88 
    8976bool ResourceLoadStatisticsClassifierCocoa::canUseCorePrediction()
    9077{
     
    9582        return false;
    9683
    97     if (isNullFunctionPointer(reinterpret_cast<void*>(svm_load_model))) {
     84    if (isNullFunctionPointer(svm_load_model)) {
    9885        m_useCorePrediction = false;
    9986        return false;
  • trunk/Tools/ChangeLog

    r215416 r215424  
     12017-04-17  Dan Bernstein  <mitz@apple.com>
     2
     3        [Cocoa] Move isNullFunctionPointer down into WTF
     4        https://bugs.webkit.org/show_bug.cgi?id=170892
     5
     6        Reviewed by Sam Weinig.
     7
     8        * TestWebKitAPI/Configurations/TestWTF.xcconfig:
     9        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
     10        * TestWebKitAPI/Tests/WTF/darwin/WeakLinking.cpp: Added.
     11        (TestWebKitAPI::TEST):
     12        * TestWebKitAPI/Tests/WTF/darwin/libTestWTFAlwaysMissing-iOS-v2.tbd: Added.
     13        * TestWebKitAPI/Tests/WTF/darwin/libTestWTFAlwaysMissing-iOS.tbd: Added.
     14        * TestWebKitAPI/Tests/WTF/darwin/libTestWTFAlwaysMissing-macOS-v2.tbd: Added.
     15        * TestWebKitAPI/Tests/WTF/darwin/libTestWTFAlwaysMissing-macOS.tbd: Added.
     16
    1172017-04-17  Jonathan Bedard  <jbedard@apple.com>
    218
  • trunk/Tools/TestWebKitAPI/Configurations/TestWTF.xcconfig

    r201938 r215424  
    2525
    2626PRODUCT_NAME = TestWTF;
     27
     28LIBRARY_SEARCH_PATHS = $(PROJECT_DIR)/Tests/WTF/darwin $(inhertied);
     29
    2730GCC_ENABLE_OBJC_EXCEPTIONS = YES;
    2831
  • trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj

    r215413 r215424  
    116116                37B47E301D64E7CA005F4EFF /* WKObject.mm in Sources */ = {isa = PBXBuildFile; fileRef = 37B47E2E1D64E7CA005F4EFF /* WKObject.mm */; };
    117117                37BCA61C1B596BA9002012CA /* ShouldOpenExternalURLsInNewWindowActions.mm in Sources */ = {isa = PBXBuildFile; fileRef = 37BCA61B1B596BA9002012CA /* ShouldOpenExternalURLsInNewWindowActions.mm */; };
     118                37C7CC2D1EA4146B007BD956 /* WeakLinking.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37C7CC2B1EA4146B007BD956 /* WeakLinking.cpp */; };
    118119                37D36ED71AF42ECD00BAF5D9 /* LoadAlternateHTMLString.mm in Sources */ = {isa = PBXBuildFile; fileRef = 37D36ED61AF42ECD00BAF5D9 /* LoadAlternateHTMLString.mm */; };
    119120                37DC6791140D7D7600ABCCDB /* DOMRangeOfString.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 37DC678F140D7D3A00ABCCDB /* DOMRangeOfString.html */; };
     
    10181019                37BCA61B1B596BA9002012CA /* ShouldOpenExternalURLsInNewWindowActions.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ShouldOpenExternalURLsInNewWindowActions.mm; sourceTree = "<group>"; };
    10191020                37C784DE197C8F2E0010A496 /* RenderedImageFromDOMNode.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RenderedImageFromDOMNode.mm; sourceTree = "<group>"; };
     1021                37C7CC2B1EA4146B007BD956 /* WeakLinking.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WeakLinking.cpp; sourceTree = "<group>"; };
     1022                37C7CC2E1EA41702007BD956 /* libTestWTFAlwaysMissing-macOS-v2.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; path = "libTestWTFAlwaysMissing-macOS-v2.tbd"; sourceTree = "<group>"; };
     1023                37C7CC331EA41EC8007BD956 /* libTestWTFAlwaysMissing-iOS-v2.tbd */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = "sourcecode.text-based-dylib-definition"; path = "libTestWTFAlwaysMissing-iOS-v2.tbd"; sourceTree = "<group>"; };
     1024                37C7CC341EA41EC8007BD956 /* libTestWTFAlwaysMissing-iOS.tbd */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = "sourcecode.text-based-dylib-definition"; path = "libTestWTFAlwaysMissing-iOS.tbd"; sourceTree = "<group>"; };
     1025                37C7CC351EA41EC8007BD956 /* libTestWTFAlwaysMissing-macOS.tbd */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = "sourcecode.text-based-dylib-definition"; path = "libTestWTFAlwaysMissing-macOS.tbd"; sourceTree = "<group>"; };
    10201026                37D36ED61AF42ECD00BAF5D9 /* LoadAlternateHTMLString.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = LoadAlternateHTMLString.mm; sourceTree = "<group>"; };
    10211027                37DC678B140D7C5000ABCCDB /* DOMRangeOfString.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DOMRangeOfString.mm; sourceTree = "<group>"; };
     
    18221828                        isa = PBXGroup;
    18231829                        children = (
     1830                                37C7CC331EA41EC8007BD956 /* libTestWTFAlwaysMissing-iOS-v2.tbd */,
     1831                                37C7CC341EA41EC8007BD956 /* libTestWTFAlwaysMissing-iOS.tbd */,
     1832                                37C7CC2E1EA41702007BD956 /* libTestWTFAlwaysMissing-macOS-v2.tbd */,
     1833                                37C7CC351EA41EC8007BD956 /* libTestWTFAlwaysMissing-macOS.tbd */,
    18241834                                7CBBA07619BB8A9100BBF025 /* OSObjectPtr.cpp */,
     1835                                37C7CC2B1EA4146B007BD956 /* WeakLinking.cpp */,
    18251836                        );
    18261837                        path = darwin;
     
    26972708                                7C83DF121D0A590C00FEBCF3 /* ScopedLambda.cpp in Sources */,
    26982709                                7C83DF3D1D0A590C00FEBCF3 /* SetForScope.cpp in Sources */,
     2710                                37C7CC2D1EA4146B007BD956 /* WeakLinking.cpp in Sources */,
    26992711                                7C83DF2A1D0A590C00FEBCF3 /* SHA1.cpp in Sources */,
    27002712                                7C83DF321D0A590C00FEBCF3 /* StringBuilder.cpp in Sources */,
Note: See TracChangeset for help on using the changeset viewer.