Changeset 215247 in webkit


Ignore:
Timestamp:
Apr 11, 2017 12:13:23 PM (7 years ago)
Author:
mitz@apple.com
Message:

[Cocoa] WebKit unnecessarily soft-links CorePrediction
https://bugs.webkit.org/show_bug.cgi?id=170644

Reviewed by Sam Weinig.

Source/WebKit2:

  • Configurations/BaseTarget.xcconfig: Defined HAVE_CORE_PREDICTION and added HAVE_CORE_PREDICTION to the preprocessor defintions when the former is YES.
  • Configurations/WebKit.xcconfig: Have the linker link against CorePrediction where available. On macOS, use weak linking, because CorePrediction is not available in the Base System.
  • Platform/classifier/cocoa/CorePredictionSoftLink.h: Removed.
  • Platform/classifier/cocoa/ResourceLoadStatisticsClassifierCocoa.cpp: Guarded with #if HAVE(CORE_PREDICTION).

(WebKit::isNullFunctionPointer): Added this helper.
(WebKit::ResourceLoadStatisticsClassifierCocoa::canUseCorePrediction): Replaced

dlopen()-based runtime check with a null check.

  • Platform/classifier/cocoa/ResourceLoadStatisticsClassifierCocoa.h: Guarded with #if HAVE(CORE_PREDICTION).
  • Platform/spi/Cocoa/CorePredictionSPI.h: Added.
  • UIProcess/WebResourceLoadStatisticsStore.h: Updated guards to include HAVE(CORE_PREDICTION).
  • WebKit2.xcodeproj/project.pbxproj: pdated file references for removal and addition.

WebKitLibraries:

  • WebKitPrivateFrameworkStubs/iOS/10/CorePrediction.framework: Added this framework stub.
  • WebKitPrivateFrameworkStubs/iOS/10/CorePrediction.framework/CorePrediction.tbd: Added.
Location:
trunk
Files:
3 added
1 deleted
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r215246 r215247  
     12017-04-11  Dan Bernstein  <mitz@apple.com>
     2
     3        [Cocoa] WebKit unnecessarily soft-links CorePrediction
     4        https://bugs.webkit.org/show_bug.cgi?id=170644
     5
     6        Reviewed by Sam Weinig.
     7
     8        * Configurations/BaseTarget.xcconfig: Defined HAVE_CORE_PREDICTION and added
     9          HAVE_CORE_PREDICTION to the preprocessor defintions when the former is YES.
     10
     11        * Configurations/WebKit.xcconfig: Have the linker link against CorePrediction where
     12          available. On macOS, use weak linking, because CorePrediction is not available in the
     13          Base System.
     14
     15        * Platform/classifier/cocoa/CorePredictionSoftLink.h: Removed.
     16
     17        * Platform/classifier/cocoa/ResourceLoadStatisticsClassifierCocoa.cpp: Guarded with
     18          #if HAVE(CORE_PREDICTION).
     19        (WebKit::isNullFunctionPointer): Added this helper.
     20        (WebKit::ResourceLoadStatisticsClassifierCocoa::canUseCorePrediction): Replaced
     21          dlopen()-based runtime check with a null check.
     22
     23        * Platform/classifier/cocoa/ResourceLoadStatisticsClassifierCocoa.h: Guarded with #if
     24          HAVE(CORE_PREDICTION).
     25
     26        * Platform/spi/Cocoa/CorePredictionSPI.h: Added.
     27
     28        * UIProcess/WebResourceLoadStatisticsStore.h: Updated guards to include HAVE(CORE_PREDICTION).
     29
     30        * WebKit2.xcodeproj/project.pbxproj: pdated file references for removal and addition.
     31
    1322017-04-11  David Quesada  <david_quesada@apple.com>
    233
  • trunk/Source/WebKit2/Configurations/BaseTarget.xcconfig

    r213496 r215247  
    3838
    3939GCC_PREFIX_HEADER = WebKit2Prefix.h;
    40 GCC_PREPROCESSOR_DEFINITIONS = $(DEBUG_DEFINES) $(FEATURE_DEFINES) $(WK_MANUAL_SANDBOXING_DEFINES) FRAMEWORK_NAME=WebKit;
     40GCC_PREPROCESSOR_DEFINITIONS = $(DEBUG_DEFINES) $(FEATURE_DEFINES) $(WK_MANUAL_SANDBOXING_DEFINES) $(WK_CORE_PREDICTION_DEFINES) FRAMEWORK_NAME=WebKit;
    4141WEBKITADDITIONS_HEADER_SEARCH_PATHS = $(BUILT_PRODUCTS_DIR)/usr/local/include/WebKitAdditions $(SDKROOT)/usr/local/include/WebKitAdditions;
    4242HEADER_SEARCH_PATHS = $(BUILT_PRODUCTS_DIR)/usr/local/include "$(WEBCORE_PRIVATE_HEADERS_DIR)/ForwardingHeaders" "$(WEBCORE_PRIVATE_HEADERS_DIR)/icu" $(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2 $(WEBKITADDITIONS_HEADER_SEARCH_PATHS) $(HEADER_SEARCH_PATHS);
     
    106106WK_OVERRIDE_FRAMEWORKS_DIR = $(WK_OVERRIDE_FRAMEWORKS_DIR_USE_STAGING_INSTALL_PATH_$(USE_STAGING_INSTALL_PATH));
    107107WK_OVERRIDE_FRAMEWORKS_DIR_USE_STAGING_INSTALL_PATH_YES = $(SYSTEM_LIBRARY_DIR)/StagedFrameworks/Safari;
     108
     109WK_HAVE_CORE_PREDICTION = YES;
     110WK_HAVE_CORE_PREDICTION[sdk=macosx*][arch=i386] = NO;
     111
     112WK_CORE_PREDICTION_DEFINES = $(WK_CORE_PREDICTION_DEFINES_$(WK_HAVE_CORE_PREDICTION));
     113WK_CORE_PREDICTION_DEFINES_YES = HAVE_CORE_PREDICTION;
  • trunk/Source/WebKit2/Configurations/WebKit.xcconfig

    r214718 r215247  
    5656LIBWEBRTC_LIBRARY_DIR_USE_OVERRIDE_FRAMEWORKS_DIR_YES = $(WK_OVERRIDE_FRAMEWORKS_DIR);
    5757
    58 OTHER_LDFLAGS = $(inherited) $(UNEXPORTED_SYMBOL_LDFLAGS) $(ASAN_OTHER_LDFLAGS) $(FRAMEWORK_AND_LIBRARY_LDFLAGS) $(OTHER_LDFLAGS_PLATFORM) $(WK_RELOCATABLE_FRAMEWORK_LDFLAGS) -framework WebKitLegacy;
     58OTHER_LDFLAGS = $(inherited) -F"$(SDK_DIR)$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks" $(UNEXPORTED_SYMBOL_LDFLAGS) $(ASAN_OTHER_LDFLAGS) $(FRAMEWORK_AND_LIBRARY_LDFLAGS) $(OTHER_LDFLAGS_PLATFORM) $(WK_RELOCATABLE_FRAMEWORK_LDFLAGS) $(WK_CORE_PREDICTION_LDFLAGS) -framework WebKitLegacy;
    5959OTHER_LDFLAGS_PLATFORM[sdk=macosx*] = $(LIBWEBRTC_LDFLAGS);
    6060OTHER_LDFLAGS_PLATFORM[sdk=iphoneos*] = -lAccessibility $(LIBWEBRTC_LDFLAGS);
     
    8484WK_RELOCATABLE_FRAMEWORK_LDFLAGS = $(WK_RELOCATABLE_FRAMEWORK_LDFLAGS_$(WK_RELOCATABLE_FRAMEWORKS));
    8585WK_RELOCATABLE_FRAMEWORK_LDFLAGS_YES = -Wl,-not_for_dyld_shared_cache;
     86
     87WK_CORE_PREDICTION_LDFLAGS = $(WK_CORE_PREDICTION_LDFLAGS_$(WK_HAVE_CORE_PREDICTION));
     88WK_CORE_PREDICTION_LDFLAGS_YES = -framework CorePrediction;
     89WK_CORE_PREDICTION_LDFLAGS_YES[sdk=macosx*] = -weak_framework CorePrediction;
  • trunk/Source/WebKit2/Platform/classifier/cocoa/ResourceLoadStatisticsClassifierCocoa.cpp

    r212949 r215247  
    2727#include "ResourceLoadStatisticsClassifierCocoa.h"
    2828
     29#if HAVE(CORE_PREDICTION)
     30
     31#include "CorePredictionSPI.h"
    2932#include "Logging.h"
    3033#include <wtf/NeverDestroyed.h>
    31 #include "CorePredictionSoftLink.h"
    3234
    3335namespace WebKit {
     
    7173}
    7274
     75static 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
    7389bool ResourceLoadStatisticsClassifierCocoa::canUseCorePrediction()
    7490{
     
    7995        return false;
    8096
    81     if (!CorePredictionLibrary()) {
     97    if (isNullFunctionPointer(reinterpret_cast<void*>(svm_load_model))) {
    8298        m_useCorePrediction = false;
    8399        return false;
     
    111127}
    112128}
     129
     130#endif
  • trunk/Source/WebKit2/Platform/classifier/cocoa/ResourceLoadStatisticsClassifierCocoa.h

    r212949 r215247  
    2626#pragma once
    2727
     28#if HAVE(CORE_PREDICTION)
     29
    2830#include "ResourceLoadStatisticsClassifier.h"
    2931#include <wtf/Platform.h>
     
    4547   
    4648}
     49
     50#endif
  • trunk/Source/WebKit2/UIProcess/WebResourceLoadStatisticsStore.h

    r213871 r215247  
    3434#include <wtf/text/WTFString.h>
    3535
    36 #if PLATFORM(COCOA)
     36#if HAVE(CORE_PREDICTION)
    3737#include "ResourceLoadStatisticsClassifierCocoa.h"
    3838#endif
     
    9595
    9696    Ref<WebCore::ResourceLoadStatisticsStore> m_resourceLoadStatisticsStore;
    97 #if PLATFORM(COCOA)
     97#if HAVE(CORE_PREDICTION)
    9898    ResourceLoadStatisticsClassifierCocoa m_resourceLoadStatisticsClassifier;
    9999#else
  • trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj

    r215246 r215247  
    851851                37BF2F061947DEB400723C48 /* WKNSURLRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = 37BF2F041947DEB400723C48 /* WKNSURLRequest.h */; };
    852852                37BF2F071947DEB400723C48 /* WKNSURLRequest.mm in Sources */ = {isa = PBXBuildFile; fileRef = 37BF2F051947DEB400723C48 /* WKNSURLRequest.mm */; };
     853                37C21CAE1E994C0C0029D5F9 /* CorePredictionSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 37C21CAD1E994C0C0029D5F9 /* CorePredictionSPI.h */; };
    853854                37C4C08618149C5B003688B9 /* WKBackForwardListItem.mm in Sources */ = {isa = PBXBuildFile; fileRef = 37C4C08418149C5B003688B9 /* WKBackForwardListItem.mm */; };
    854855                37C4C08718149C5B003688B9 /* WKBackForwardListItem.h in Headers */ = {isa = PBXBuildFile; fileRef = 37C4C08518149C5B003688B9 /* WKBackForwardListItem.h */; settings = {ATTRIBUTES = (Public, ); }; };
     
    11791180                659C551E130006410025C0C2 /* InjectedBundlePageResourceLoadClient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6546A82913000164000CEB1C /* InjectedBundlePageResourceLoadClient.cpp */; };
    11801181                65B86F1E12F11DE300B7DD8A /* WKBundleInspector.h in Headers */ = {isa = PBXBuildFile; fileRef = 65B86F1812F11D7B00B7DD8A /* WKBundleInspector.h */; settings = {ATTRIBUTES = (Private, ); }; };
    1181                 6B2E09BA1E57B88100C8A8B9 /* CorePredictionSoftLink.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B2E09B91E57B88100C8A8B9 /* CorePredictionSoftLink.h */; };
    11821182                6BE9699C1E43B3FF008B7483 /* WKResourceLoadStatisticsManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 6BE9699B1E43B3FF008B7483 /* WKResourceLoadStatisticsManager.h */; settings = {ATTRIBUTES = (Private, ); }; };
    11831183                6BE9699E1E43B41D008B7483 /* WKResourceLoadStatisticsManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6BE9699D1E43B41D008B7483 /* WKResourceLoadStatisticsManager.cpp */; };
     
    30573057                37BF2F041947DEB400723C48 /* WKNSURLRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKNSURLRequest.h; sourceTree = "<group>"; };
    30583058                37BF2F051947DEB400723C48 /* WKNSURLRequest.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKNSURLRequest.mm; sourceTree = "<group>"; };
     3059                37C21CAD1E994C0C0029D5F9 /* CorePredictionSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CorePredictionSPI.h; sourceTree = "<group>"; };
    30593060                37C4C08418149C5B003688B9 /* WKBackForwardListItem.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKBackForwardListItem.mm; sourceTree = "<group>"; };
    30603061                37C4C08518149C5B003688B9 /* WKBackForwardListItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKBackForwardListItem.h; sourceTree = "<group>"; };
     
    34443445                65B86F1712F11D7B00B7DD8A /* WKBundleInspector.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKBundleInspector.cpp; sourceTree = "<group>"; };
    34453446                65B86F1812F11D7B00B7DD8A /* WKBundleInspector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKBundleInspector.h; sourceTree = "<group>"; };
    3446                 6B2E09B91E57B88100C8A8B9 /* CorePredictionSoftLink.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CorePredictionSoftLink.h; sourceTree = "<group>"; };
    34473447                6BE9699B1E43B3FF008B7483 /* WKResourceLoadStatisticsManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKResourceLoadStatisticsManager.h; sourceTree = "<group>"; };
    34483448                6BE9699D1E43B41D008B7483 /* WKResourceLoadStatisticsManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKResourceLoadStatisticsManager.cpp; sourceTree = "<group>"; };
     
    54935493                        children = (
    54945494                                1A5705101BE410E500874AF1 /* BlockSPI.h */,
     5495                                37C21CAD1E994C0C0029D5F9 /* CorePredictionSPI.h */,
    54955496                                3754D5441B3A29FD003A4C7F /* NSInvocationSPI.h */,
    54965497                                37B47E2C1D64DB76005F4EFF /* objcSPI.h */,
     
    63126313                        isa = PBXGroup;
    63136314                        children = (
    6314                                 6B2E09B91E57B88100C8A8B9 /* CorePredictionSoftLink.h */,
    63156315                                6BE969C81E54D4CF008B7483 /* ResourceLoadStatisticsClassifierCocoa.cpp */,
    63166316                                6BE969C91E54D4CF008B7483 /* ResourceLoadStatisticsClassifierCocoa.h */,
     
    82408240                                CDC3830C17212282008A2FC3 /* CookieStorageShimLibrary.h in Headers */,
    82418241                                CE1A0BD31A48E6C60054EF74 /* CorePDFSPI.h in Headers */,
    8242                                 6B2E09BA1E57B88100C8A8B9 /* CorePredictionSoftLink.h in Headers */,
    82438242                                B878B615133428DC006888E9 /* CorrectionPanel.h in Headers */,
    82448243                                515E772C184008B90007203F /* DatabaseProcessCreationParameters.h in Headers */,
     
    82698268                                51B15A8513843A3900321AD8 /* EnvironmentUtilities.h in Headers */,
    82708269                                1AA575FB1496B52600A4EE06 /* EventDispatcher.h in Headers */,
     8270                                37C21CAE1E994C0C0029D5F9 /* CorePredictionSPI.h in Headers */,
    82718271                                00B9661A18E25AE100CE1F88 /* FindClient.h in Headers */,
    82728272                                1A90C1F41264FD71003E44D4 /* FindController.h in Headers */,
  • trunk/WebKitLibraries/ChangeLog

    r215148 r215247  
     12017-04-11  Dan Bernstein  <mitz@apple.com>
     2
     3        [Cocoa] WebKit unnecessarily soft-links CorePrediction
     4        https://bugs.webkit.org/show_bug.cgi?id=170644
     5
     6        Reviewed by Sam Weinig.
     7
     8        * WebKitPrivateFrameworkStubs/iOS/10/CorePrediction.framework: Added this framework stub.
     9        * WebKitPrivateFrameworkStubs/iOS/10/CorePrediction.framework/CorePrediction.tbd: Added.
     10
    1112017-04-08  Dan Bernstein  <mitz@apple.com>
    212
Note: See TracChangeset for help on using the changeset viewer.