Changeset 261651 in webkit


Ignore:
Timestamp:
May 13, 2020 1:49:24 PM (4 years ago)
Author:
jer.noble@apple.com
Message:

Replace isNullFunctionPointer with real weak-linking support
https://bugs.webkit.org/show_bug.cgi?id=211751

Reviewed by Sam Weinig.

Source/ThirdParty/libwebrtc:

  • Source/webrtc/sdk/WebKit/WebKitUtilities.h:

Source/WebCore:

Use the new WTF_WEAK_LINK_FORCE_IMPORT macro.

  • platform/mediastream/libwebrtc/LibWebRTCProviderCocoa.cpp:

(WebCore::LibWebRTCProvider::webRTCAvailable):

Source/WebKit:

Use the new WTF_WEAK_LINK_FORCE_IMPORT macro.

  • Platform/classifier/cocoa/ResourceLoadStatisticsClassifierCocoa.cpp:

(WebKit::ResourceLoadStatisticsClassifierCocoa::canUseCorePrediction):

Source/WTF:

Replace isNullFunctionPointer with a macro which explicitly marks symbols as weakly imported.

  • wtf/darwin/WeakLinking.h:

(WTF::isNullFunctionPointer): Deleted.

Tools:

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

(TestWebKitAPI::TEST):

  • TestWebKitAPI/Tests/WTF/darwin/libTestWTFAlwaysMissing-iOS-v2.tbd:
  • TestWebKitAPI/Tests/WTF/darwin/libTestWTFAlwaysMissing-iOS.tbd:
  • TestWebKitAPI/Tests/WTF/darwin/libTestWTFAlwaysMissing-macOS-v2.tbd:
  • TestWebKitAPI/Tests/WTF/darwin/libTestWTFAlwaysMissing-macOS.tbd:
Location:
trunk
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/ThirdParty/libwebrtc/ChangeLog

    r261534 r261651  
     12020-05-13  Jer Noble  <jer.noble@apple.com>
     2
     3        Replace isNullFunctionPointer with real weak-linking support
     4        https://bugs.webkit.org/show_bug.cgi?id=211751
     5
     6        Reviewed by Sam Weinig.
     7
     8        * Source/webrtc/sdk/WebKit/WebKitUtilities.h:
     9
    1102020-05-11  Saam Barati  <sbarati@apple.com>
    211
  • trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/WebKitUtilities.h

    r260129 r261651  
    4545std::unique_ptr<webrtc::VideoDecoderFactory> createWebKitDecoderFactory(WebKitCodecSupport);
    4646
    47 void setApplicationStatus(bool isActive) __attribute__((weak_import));
     47void setApplicationStatus(bool isActive);
    4848
    4949void setH264HardwareEncoderAllowed(bool);
  • trunk/Source/WTF/ChangeLog

    r261598 r261651  
     12020-05-13  Jer Noble  <jer.noble@apple.com>
     2
     3        Replace isNullFunctionPointer with real weak-linking support
     4        https://bugs.webkit.org/show_bug.cgi?id=211751
     5
     6        Reviewed by Sam Weinig.
     7
     8        Replace isNullFunctionPointer with a macro which explicitly marks symbols as weakly imported.
     9
     10        * wtf/darwin/WeakLinking.h:
     11        (WTF::isNullFunctionPointer): Deleted.
     12
    1132020-05-12  Mark Lam  <mark.lam@apple.com>
    214
  • trunk/Source/WTF/wtf/darwin/WeakLinking.h

    r225552 r261651  
    2626#pragma once
    2727
    28 #include <type_traits>
    29 
    30 namespace WTF {
    31 
    32 template<typename T, typename = std::enable_if_t<std::is_function<T>::value>>
    33 inline bool isNullFunctionPointer(T* functionPointer)
    34 {
    35     void* result;
    36     // The C compiler may take advantage of the fact that by definition, function pointers cannot be
    37     // null. When weak-linking a library, function pointers can be null. We use non-C code to
    38     // prevent the C compiler from using the definition to optimize out the null check.
    39     asm(
    40 #if CPU(ARM64) && defined(__ILP32__)
    41         "mov %w1, %w0"
    42 #else
    43         "mov %1, %0"
    44 #endif
    45         : "=r" (result)
    46         : "r" (functionPointer)
    47     );
    48     return !result;
    49 }
    50 
    51 }
    52 
    53 using WTF::isNullFunctionPointer;
     28#define WTF_WEAK_LINK_FORCE_IMPORT(sym) extern __attribute__((weak_import)) __typeof__(sym) sym
  • trunk/Source/WebCore/ChangeLog

    r261644 r261651  
     12020-05-13  Jer Noble  <jer.noble@apple.com>
     2
     3        Replace isNullFunctionPointer with real weak-linking support
     4        https://bugs.webkit.org/show_bug.cgi?id=211751
     5
     6        Reviewed by Sam Weinig.
     7
     8        Use the new WTF_WEAK_LINK_FORCE_IMPORT macro.
     9
     10        * platform/mediastream/libwebrtc/LibWebRTCProviderCocoa.cpp:
     11        (WebCore::LibWebRTCProvider::webRTCAvailable):
     12
    1132020-05-13  Andres Gonzalez  <andresg_22@apple.com>
    214
  • trunk/Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCProviderCocoa.cpp

    r260129 r261651  
    3434#include <wtf/MainThread.h>
    3535#include <wtf/darwin/WeakLinking.h>
     36
     37WTF_WEAK_LINK_FORCE_IMPORT(webrtc::setApplicationStatus);
    3638
    3739namespace WebCore {
     
    7779    return true;
    7880#else
    79     return !isNullFunctionPointer(webrtc::setApplicationStatus);
     81    return !!webrtc::setApplicationStatus;
    8082#endif
    8183}
  • trunk/Source/WebKit/ChangeLog

    r261640 r261651  
     12020-05-13  Jer Noble  <jer.noble@apple.com>
     2
     3        Replace isNullFunctionPointer with real weak-linking support
     4        https://bugs.webkit.org/show_bug.cgi?id=211751
     5
     6        Reviewed by Sam Weinig.
     7
     8        Use the new WTF_WEAK_LINK_FORCE_IMPORT macro.
     9
     10        * Platform/classifier/cocoa/ResourceLoadStatisticsClassifierCocoa.cpp:
     11        (WebKit::ResourceLoadStatisticsClassifierCocoa::canUseCorePrediction):
     12
    1132020-05-13  Tim Horton  <timothy_horton@apple.com>
    214
  • trunk/Source/WebKit/Platform/classifier/cocoa/ResourceLoadStatisticsClassifierCocoa.cpp

    r242406 r261651  
    3333#include <wtf/NeverDestroyed.h>
    3434#include <wtf/darwin/WeakLinking.h>
     35
     36WTF_WEAK_LINK_FORCE_IMPORT(svm_load_model);
    3537
    3638namespace WebKit {
     
    8284        return false;
    8385
    84     if (isNullFunctionPointer(svm_load_model)) {
     86    if (svm_load_model) {
    8587        m_useCorePrediction = false;
    8688        return false;
  • trunk/Tools/ChangeLog

    r261640 r261651  
     12020-05-13  Jer Noble  <jer.noble@apple.com>
     2
     3        Replace isNullFunctionPointer with real weak-linking support
     4        https://bugs.webkit.org/show_bug.cgi?id=211751
     5
     6        Reviewed by Sam Weinig.
     7
     8        * TestWebKitAPI/Tests/WTF/darwin/WeakLinking.cpp:
     9        (TestWebKitAPI::TEST):
     10        * TestWebKitAPI/Tests/WTF/darwin/libTestWTFAlwaysMissing-iOS-v2.tbd:
     11        * TestWebKitAPI/Tests/WTF/darwin/libTestWTFAlwaysMissing-iOS.tbd:
     12        * TestWebKitAPI/Tests/WTF/darwin/libTestWTFAlwaysMissing-macOS-v2.tbd:
     13        * TestWebKitAPI/Tests/WTF/darwin/libTestWTFAlwaysMissing-macOS.tbd:
     14
    1152020-05-13  Tim Horton  <timothy_horton@apple.com>
    216
  • trunk/Tools/TestWebKitAPI/Tests/WTF/darwin/WeakLinking.cpp

    r237607 r261651  
    4343extern "C" {
    4444    extern void TestWTFAlwaysMissing(void) __attribute__((weak_import));
     45    extern void TestWTFAlwaysMissingWithoutAttributeWeakImport(void);
    4546}
     47
     48WTF_WEAK_LINK_FORCE_IMPORT(TestWTFAlwaysMissingWithoutAttributeWeakImport);
     49WTF_WEAK_LINK_FORCE_IMPORT(close);
    4650
    4751namespace TestWebKitAPI {
    4852
    49 TEST(WeakLinking, IsNullFunctionPointer)
     53TEST(WeakLinking, WeakImport)
    5054{
    51     EXPECT_TRUE(isNullFunctionPointer(TestWTFAlwaysMissing));
    52     EXPECT_FALSE(isNullFunctionPointer(close));
     55    EXPECT_FALSE(TestWTFAlwaysMissing);
     56    EXPECT_FALSE(TestWTFAlwaysMissingWithoutAttributeWeakImport);
     57    EXPECT_TRUE(close);
    5358}
    5459
  • trunk/Tools/TestWebKitAPI/Tests/WTF/darwin/libTestWTFAlwaysMissing-iOS-v2.tbd

    r225552 r261651  
    77exports:
    88  - archs: [ i386, x86_64, armv7, armv7s, arm64, arm64_32 ]
    9     symbols: [ _TestWTFAlwaysMissing ]
     9    symbols: [ _TestWTFAlwaysMissing, _TestWTFAlwaysMissingWithoutAttributeWeakImport ]
    1010...
  • trunk/Tools/TestWebKitAPI/Tests/WTF/darwin/libTestWTFAlwaysMissing-iOS.tbd

    r215424 r261651  
    66exports:
    77  - archs: [ i386, x86_64, armv7, armv7s, arm64 ]
    8     symbols: [ _TestWTFAlwaysMissing ]
     8    symbols: [ _TestWTFAlwaysMissing, _TestWTFAlwaysMissingWithoutAttributeWeakImport ]
    99...
  • trunk/Tools/TestWebKitAPI/Tests/WTF/darwin/libTestWTFAlwaysMissing-macOS-v2.tbd

    r215424 r261651  
    77exports:
    88  - archs: [ i386, x86_64 ]
    9     symbols: [ _TestWTFAlwaysMissing ]
     9    symbols: [ _TestWTFAlwaysMissing, _TestWTFAlwaysMissingWithoutAttributeWeakImport ]
    1010...
  • trunk/Tools/TestWebKitAPI/Tests/WTF/darwin/libTestWTFAlwaysMissing-macOS.tbd

    r215424 r261651  
    66exports:
    77  - archs: [ i386, x86_64 ]
    8     symbols: [ _TestWTFAlwaysMissing ]
     8    symbols: [ _TestWTFAlwaysMissing, _TestWTFAlwaysMissingWithoutAttributeWeakImport ]
    99...
Note: See TracChangeset for help on using the changeset viewer.