Title: [261651] trunk
Revision
261651
Author
[email protected]
Date
2020-05-13 13:49:24 -0700 (Wed, 13 May 2020)

Log 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:

Modified Paths

Diff

Modified: trunk/Source/ThirdParty/libwebrtc/ChangeLog (261650 => 261651)


--- trunk/Source/ThirdParty/libwebrtc/ChangeLog	2020-05-13 20:47:27 UTC (rev 261650)
+++ trunk/Source/ThirdParty/libwebrtc/ChangeLog	2020-05-13 20:49:24 UTC (rev 261651)
@@ -1,3 +1,12 @@
+2020-05-13  Jer Noble  <[email protected]>
+
+        Replace isNullFunctionPointer with real weak-linking support
+        https://bugs.webkit.org/show_bug.cgi?id=211751
+
+        Reviewed by Sam Weinig.
+
+        * Source/webrtc/sdk/WebKit/WebKitUtilities.h:
+
 2020-05-11  Saam Barati  <[email protected]>
 
         Remove OTHER_CFLAGS="" in libwebrtc pbxproj

Modified: trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/WebKitUtilities.h (261650 => 261651)


--- trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/WebKitUtilities.h	2020-05-13 20:47:27 UTC (rev 261650)
+++ trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/WebKitUtilities.h	2020-05-13 20:49:24 UTC (rev 261651)
@@ -44,7 +44,7 @@
 std::unique_ptr<webrtc::VideoEncoderFactory> createWebKitEncoderFactory(WebKitCodecSupport);
 std::unique_ptr<webrtc::VideoDecoderFactory> createWebKitDecoderFactory(WebKitCodecSupport);
 
-void setApplicationStatus(bool isActive) __attribute__((weak_import));
+void setApplicationStatus(bool isActive);
 
 void setH264HardwareEncoderAllowed(bool);
 bool isH264HardwareEncoderAllowed();

Modified: trunk/Source/WTF/ChangeLog (261650 => 261651)


--- trunk/Source/WTF/ChangeLog	2020-05-13 20:47:27 UTC (rev 261650)
+++ trunk/Source/WTF/ChangeLog	2020-05-13 20:49:24 UTC (rev 261651)
@@ -1,3 +1,15 @@
+2020-05-13  Jer Noble  <[email protected]>
+
+        Replace isNullFunctionPointer with real weak-linking support
+        https://bugs.webkit.org/show_bug.cgi?id=211751
+
+        Reviewed by Sam Weinig.
+
+        Replace isNullFunctionPointer with a macro which explicitly marks symbols as weakly imported.
+
+        * wtf/darwin/WeakLinking.h:
+        (WTF::isNullFunctionPointer): Deleted.
+
 2020-05-12  Mark Lam  <[email protected]>
 
         catch_mach_exception_raise_state() should fail early if the faulting address is not of interest.

Modified: trunk/Source/WTF/wtf/darwin/WeakLinking.h (261650 => 261651)


--- trunk/Source/WTF/wtf/darwin/WeakLinking.h	2020-05-13 20:47:27 UTC (rev 261650)
+++ trunk/Source/WTF/wtf/darwin/WeakLinking.h	2020-05-13 20:49:24 UTC (rev 261651)
@@ -25,29 +25,4 @@
 
 #pragma once
 
-#include <type_traits>
-
-namespace WTF {
-
-template<typename T, typename = std::enable_if_t<std::is_function<T>::value>>
-inline bool isNullFunctionPointer(T* functionPointer)
-{
-    void* result;
-    // The C compiler may take advantage of the fact that by definition, function pointers cannot be
-    // null. When weak-linking a library, function pointers can be null. We use non-C code to
-    // prevent the C compiler from using the definition to optimize out the null check.
-    asm(
-#if CPU(ARM64) && defined(__ILP32__)
-        "mov %w1, %w0"
-#else
-        "mov %1, %0"
-#endif
-        : "=r" (result)
-        : "r" (functionPointer)
-    );
-    return !result;
-}
-
-}
-
-using WTF::isNullFunctionPointer;
+#define WTF_WEAK_LINK_FORCE_IMPORT(sym) extern __attribute__((weak_import)) __typeof__(sym) sym

Modified: trunk/Source/WebCore/ChangeLog (261650 => 261651)


--- trunk/Source/WebCore/ChangeLog	2020-05-13 20:47:27 UTC (rev 261650)
+++ trunk/Source/WebCore/ChangeLog	2020-05-13 20:49:24 UTC (rev 261651)
@@ -1,3 +1,15 @@
+2020-05-13  Jer Noble  <[email protected]>
+
+        Replace isNullFunctionPointer with real weak-linking support
+        https://bugs.webkit.org/show_bug.cgi?id=211751
+
+        Reviewed by Sam Weinig.
+
+        Use the new WTF_WEAK_LINK_FORCE_IMPORT macro.
+
+        * platform/mediastream/libwebrtc/LibWebRTCProviderCocoa.cpp:
+        (WebCore::LibWebRTCProvider::webRTCAvailable):
+
 2020-05-13  Andres Gonzalez  <[email protected]>
 
         Implementation of AXIsolatedObject::hasBoldFont and hasItalicFont.

Modified: trunk/Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCProviderCocoa.cpp (261650 => 261651)


--- trunk/Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCProviderCocoa.cpp	2020-05-13 20:47:27 UTC (rev 261650)
+++ trunk/Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCProviderCocoa.cpp	2020-05-13 20:49:24 UTC (rev 261651)
@@ -34,6 +34,8 @@
 #include <wtf/MainThread.h>
 #include <wtf/darwin/WeakLinking.h>
 
+WTF_WEAK_LINK_FORCE_IMPORT(webrtc::setApplicationStatus);
+
 namespace WebCore {
 
 UniqueRef<LibWebRTCProvider> LibWebRTCProvider::create()
@@ -76,7 +78,7 @@
 #if PLATFORM(IOS)
     return true;
 #else
-    return !isNullFunctionPointer(webrtc::setApplicationStatus);
+    return !!webrtc::setApplicationStatus;
 #endif
 }
 

Modified: trunk/Source/WebKit/ChangeLog (261650 => 261651)


--- trunk/Source/WebKit/ChangeLog	2020-05-13 20:47:27 UTC (rev 261650)
+++ trunk/Source/WebKit/ChangeLog	2020-05-13 20:49:24 UTC (rev 261651)
@@ -1,3 +1,15 @@
+2020-05-13  Jer Noble  <[email protected]>
+
+        Replace isNullFunctionPointer with real weak-linking support
+        https://bugs.webkit.org/show_bug.cgi?id=211751
+
+        Reviewed by Sam Weinig.
+
+        Use the new WTF_WEAK_LINK_FORCE_IMPORT macro.
+
+        * Platform/classifier/cocoa/ResourceLoadStatisticsClassifierCocoa.cpp:
+        (WebKit::ResourceLoadStatisticsClassifierCocoa::canUseCorePrediction):
+
 2020-05-13  Tim Horton  <[email protected]>
 
         Add SPI for reverting to touch events for iPad trackpad interactions

Modified: trunk/Source/WebKit/Platform/classifier/cocoa/ResourceLoadStatisticsClassifierCocoa.cpp (261650 => 261651)


--- trunk/Source/WebKit/Platform/classifier/cocoa/ResourceLoadStatisticsClassifierCocoa.cpp	2020-05-13 20:47:27 UTC (rev 261650)
+++ trunk/Source/WebKit/Platform/classifier/cocoa/ResourceLoadStatisticsClassifierCocoa.cpp	2020-05-13 20:49:24 UTC (rev 261651)
@@ -33,6 +33,8 @@
 #include <wtf/NeverDestroyed.h>
 #include <wtf/darwin/WeakLinking.h>
 
+WTF_WEAK_LINK_FORCE_IMPORT(svm_load_model);
+
 namespace WebKit {
 
 bool ResourceLoadStatisticsClassifierCocoa::classify(unsigned subresourceUnderTopFrameDomainsCount, unsigned subresourceUniqueRedirectsToCount, unsigned subframeUnderTopFrameOriginsCount)
@@ -81,7 +83,7 @@
     if (!m_useCorePrediction)
         return false;
 
-    if (isNullFunctionPointer(svm_load_model)) {
+    if (svm_load_model) {
         m_useCorePrediction = false;
         return false;
     }

Modified: trunk/Tools/ChangeLog (261650 => 261651)


--- trunk/Tools/ChangeLog	2020-05-13 20:47:27 UTC (rev 261650)
+++ trunk/Tools/ChangeLog	2020-05-13 20:49:24 UTC (rev 261651)
@@ -1,3 +1,17 @@
+2020-05-13  Jer Noble  <[email protected]>
+
+        Replace isNullFunctionPointer with real weak-linking support
+        https://bugs.webkit.org/show_bug.cgi?id=211751
+
+        Reviewed by Sam Weinig.
+
+        * 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:
+
 2020-05-13  Tim Horton  <[email protected]>
 
         Add SPI for reverting to touch events for iPad trackpad interactions

Modified: trunk/Tools/TestWebKitAPI/Tests/WTF/darwin/WeakLinking.cpp (261650 => 261651)


--- trunk/Tools/TestWebKitAPI/Tests/WTF/darwin/WeakLinking.cpp	2020-05-13 20:47:27 UTC (rev 261650)
+++ trunk/Tools/TestWebKitAPI/Tests/WTF/darwin/WeakLinking.cpp	2020-05-13 20:49:24 UTC (rev 261651)
@@ -42,14 +42,19 @@
 
 extern "C" {
     extern void TestWTFAlwaysMissing(void) __attribute__((weak_import));
+    extern void TestWTFAlwaysMissingWithoutAttributeWeakImport(void);
 }
 
+WTF_WEAK_LINK_FORCE_IMPORT(TestWTFAlwaysMissingWithoutAttributeWeakImport);
+WTF_WEAK_LINK_FORCE_IMPORT(close);
+
 namespace TestWebKitAPI {
 
-TEST(WeakLinking, IsNullFunctionPointer)
+TEST(WeakLinking, WeakImport)
 {
-    EXPECT_TRUE(isNullFunctionPointer(TestWTFAlwaysMissing));
-    EXPECT_FALSE(isNullFunctionPointer(close));
+    EXPECT_FALSE(TestWTFAlwaysMissing);
+    EXPECT_FALSE(TestWTFAlwaysMissingWithoutAttributeWeakImport);
+    EXPECT_TRUE(close);
 }
 
 }

Modified: trunk/Tools/TestWebKitAPI/Tests/WTF/darwin/libTestWTFAlwaysMissing-iOS-v2.tbd (261650 => 261651)


--- trunk/Tools/TestWebKitAPI/Tests/WTF/darwin/libTestWTFAlwaysMissing-iOS-v2.tbd	2020-05-13 20:47:27 UTC (rev 261650)
+++ trunk/Tools/TestWebKitAPI/Tests/WTF/darwin/libTestWTFAlwaysMissing-iOS-v2.tbd	2020-05-13 20:49:24 UTC (rev 261651)
@@ -6,5 +6,5 @@
 objc-constraint: none
 exports:
   - archs: [ i386, x86_64, armv7, armv7s, arm64, arm64_32 ]
-    symbols: [ _TestWTFAlwaysMissing ]
+    symbols: [ _TestWTFAlwaysMissing, _TestWTFAlwaysMissingWithoutAttributeWeakImport ]
 ...

Modified: trunk/Tools/TestWebKitAPI/Tests/WTF/darwin/libTestWTFAlwaysMissing-iOS.tbd (261650 => 261651)


--- trunk/Tools/TestWebKitAPI/Tests/WTF/darwin/libTestWTFAlwaysMissing-iOS.tbd	2020-05-13 20:47:27 UTC (rev 261650)
+++ trunk/Tools/TestWebKitAPI/Tests/WTF/darwin/libTestWTFAlwaysMissing-iOS.tbd	2020-05-13 20:49:24 UTC (rev 261651)
@@ -5,5 +5,5 @@
 objc-constraint: none
 exports:
   - archs: [ i386, x86_64, armv7, armv7s, arm64 ]
-    symbols: [ _TestWTFAlwaysMissing ]
+    symbols: [ _TestWTFAlwaysMissing, _TestWTFAlwaysMissingWithoutAttributeWeakImport ]
 ...

Modified: trunk/Tools/TestWebKitAPI/Tests/WTF/darwin/libTestWTFAlwaysMissing-macOS-v2.tbd (261650 => 261651)


--- trunk/Tools/TestWebKitAPI/Tests/WTF/darwin/libTestWTFAlwaysMissing-macOS-v2.tbd	2020-05-13 20:47:27 UTC (rev 261650)
+++ trunk/Tools/TestWebKitAPI/Tests/WTF/darwin/libTestWTFAlwaysMissing-macOS-v2.tbd	2020-05-13 20:49:24 UTC (rev 261651)
@@ -6,5 +6,5 @@
 objc-constraint: none
 exports:
   - archs: [ i386, x86_64 ]
-    symbols: [ _TestWTFAlwaysMissing ]
+    symbols: [ _TestWTFAlwaysMissing, _TestWTFAlwaysMissingWithoutAttributeWeakImport ]
 ...

Modified: trunk/Tools/TestWebKitAPI/Tests/WTF/darwin/libTestWTFAlwaysMissing-macOS.tbd (261650 => 261651)


--- trunk/Tools/TestWebKitAPI/Tests/WTF/darwin/libTestWTFAlwaysMissing-macOS.tbd	2020-05-13 20:47:27 UTC (rev 261650)
+++ trunk/Tools/TestWebKitAPI/Tests/WTF/darwin/libTestWTFAlwaysMissing-macOS.tbd	2020-05-13 20:49:24 UTC (rev 261651)
@@ -5,5 +5,5 @@
 objc-constraint: none
 exports:
   - archs: [ i386, x86_64 ]
-    symbols: [ _TestWTFAlwaysMissing ]
+    symbols: [ _TestWTFAlwaysMissing, _TestWTFAlwaysMissingWithoutAttributeWeakImport ]
 ...
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to