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.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@215247
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2017-04-11 Dan Bernstein <mitz@apple.com>
+
+ [Cocoa] WebKit unnecessarily soft-links CorePrediction
+ https://bugs.webkit.org/show_bug.cgi?id=170644
+
+ Reviewed by Sam Weinig.
+
+ * 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.
+
2017-04-11 David Quesada <david_quesada@apple.com>
Add SPI for handling geolocation authorization requests
FRAMEWORK_SEARCH_PATHS = $(FRAMEWORK_SEARCH_PATHS_base);
GCC_PREFIX_HEADER = WebKit2Prefix.h;
-GCC_PREPROCESSOR_DEFINITIONS = $(DEBUG_DEFINES) $(FEATURE_DEFINES) $(WK_MANUAL_SANDBOXING_DEFINES) FRAMEWORK_NAME=WebKit;
+GCC_PREPROCESSOR_DEFINITIONS = $(DEBUG_DEFINES) $(FEATURE_DEFINES) $(WK_MANUAL_SANDBOXING_DEFINES) $(WK_CORE_PREDICTION_DEFINES) FRAMEWORK_NAME=WebKit;
WEBKITADDITIONS_HEADER_SEARCH_PATHS = $(BUILT_PRODUCTS_DIR)/usr/local/include/WebKitAdditions $(SDKROOT)/usr/local/include/WebKitAdditions;
HEADER_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);
WK_OVERRIDE_FRAMEWORKS_DIR = $(WK_OVERRIDE_FRAMEWORKS_DIR_USE_STAGING_INSTALL_PATH_$(USE_STAGING_INSTALL_PATH));
WK_OVERRIDE_FRAMEWORKS_DIR_USE_STAGING_INSTALL_PATH_YES = $(SYSTEM_LIBRARY_DIR)/StagedFrameworks/Safari;
+
+WK_HAVE_CORE_PREDICTION = YES;
+WK_HAVE_CORE_PREDICTION[sdk=macosx*][arch=i386] = NO;
+
+WK_CORE_PREDICTION_DEFINES = $(WK_CORE_PREDICTION_DEFINES_$(WK_HAVE_CORE_PREDICTION));
+WK_CORE_PREDICTION_DEFINES_YES = HAVE_CORE_PREDICTION;
LIBWEBRTC_LIBRARY_DIR_USE_OVERRIDE_FRAMEWORKS_DIR_NO = $(WEBCORE_FRAMEWORKS_DIR)/WebCore.framework/Versions/A/Frameworks;
LIBWEBRTC_LIBRARY_DIR_USE_OVERRIDE_FRAMEWORKS_DIR_YES = $(WK_OVERRIDE_FRAMEWORKS_DIR);
-OTHER_LDFLAGS = $(inherited) $(UNEXPORTED_SYMBOL_LDFLAGS) $(ASAN_OTHER_LDFLAGS) $(FRAMEWORK_AND_LIBRARY_LDFLAGS) $(OTHER_LDFLAGS_PLATFORM) $(WK_RELOCATABLE_FRAMEWORK_LDFLAGS) -framework WebKitLegacy;
+OTHER_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;
OTHER_LDFLAGS_PLATFORM[sdk=macosx*] = $(LIBWEBRTC_LDFLAGS);
OTHER_LDFLAGS_PLATFORM[sdk=iphoneos*] = -lAccessibility $(LIBWEBRTC_LDFLAGS);
OTHER_LDFLAGS_PLATFORM[sdk=iphonesimulator*] = -lAccessibility $(LIBWEBRTC_LDFLAGS);
WK_RELOCATABLE_FRAMEWORK_LDFLAGS = $(WK_RELOCATABLE_FRAMEWORK_LDFLAGS_$(WK_RELOCATABLE_FRAMEWORKS));
WK_RELOCATABLE_FRAMEWORK_LDFLAGS_YES = -Wl,-not_for_dyld_shared_cache;
+
+WK_CORE_PREDICTION_LDFLAGS = $(WK_CORE_PREDICTION_LDFLAGS_$(WK_HAVE_CORE_PREDICTION));
+WK_CORE_PREDICTION_LDFLAGS_YES = -framework CorePrediction;
+WK_CORE_PREDICTION_LDFLAGS_YES[sdk=macosx*] = -weak_framework CorePrediction;
#include "config.h"
#include "ResourceLoadStatisticsClassifierCocoa.h"
+#if HAVE(CORE_PREDICTION)
+
+#include "CorePredictionSPI.h"
#include "Logging.h"
#include <wtf/NeverDestroyed.h>
-#include "CorePredictionSoftLink.h"
namespace WebKit {
return String(resourceUrlString.get());
}
+static inline bool isNullFunctionPointer(void* 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(
+ "mov %1, %0"
+ : "=r" (result)
+ : "r" (functionPointer)
+ );
+ return !result;
+}
+
bool ResourceLoadStatisticsClassifierCocoa::canUseCorePrediction()
{
if (m_haveLoadedModel)
if (!m_useCorePrediction)
return false;
- if (!CorePredictionLibrary()) {
+ if (isNullFunctionPointer(reinterpret_cast<void*>(svm_load_model))) {
m_useCorePrediction = false;
return false;
}
return nullptr;
}
}
+
+#endif
#pragma once
+#if HAVE(CORE_PREDICTION)
+
#include "ResourceLoadStatisticsClassifier.h"
#include <wtf/Platform.h>
#include <wtf/text/WTFString.h>
};
}
+
+#endif
#pragma once
-#include <WebCore/SoftLinking.h>
+#if HAVE(CORE_PREDICTION)
-struct svm_model;
-struct svm_node {
+#if USE(APPLE_INTERNAL_SDK)
+
+#import <CorePrediction/svm.h>
+
+#else
+
+struct svm_node
+{
int index;
double value;
};
-SOFT_LINK_PRIVATE_FRAMEWORK_OPTIONAL(CorePrediction)
-SOFT_LINK(CorePrediction, svm_predict_values, double, (const struct svm_model *model, const struct svm_node *x, double* dec_values), (model, x, dec_values))
-SOFT_LINK(CorePrediction, svm_load_model, svm_model*, (const char *model_file_name), (model_file_name))
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct svm_node svm_node;
+
+struct svm_model *svm_load_model(const char *model_file_name);
+double svm_predict_values(const struct svm_model *model, const struct svm_node *x, double* dec_values);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
#include <wtf/Vector.h>
#include <wtf/text/WTFString.h>
-#if PLATFORM(COCOA)
+#if HAVE(CORE_PREDICTION)
#include "ResourceLoadStatisticsClassifierCocoa.h"
#endif
std::unique_ptr<WebCore::KeyedDecoder> createDecoderFromDisk(const String& label) const;
Ref<WebCore::ResourceLoadStatisticsStore> m_resourceLoadStatisticsStore;
-#if PLATFORM(COCOA)
+#if HAVE(CORE_PREDICTION)
ResourceLoadStatisticsClassifierCocoa m_resourceLoadStatisticsClassifier;
#else
ResourceLoadStatisticsClassifier m_resourceLoadStatisticsClassifier;
37BEC4E119491486008B4286 /* CompletionHandlerCallChecker.h in Headers */ = {isa = PBXBuildFile; fileRef = 37BEC4DF19491486008B4286 /* CompletionHandlerCallChecker.h */; };
37BF2F061947DEB400723C48 /* WKNSURLRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = 37BF2F041947DEB400723C48 /* WKNSURLRequest.h */; };
37BF2F071947DEB400723C48 /* WKNSURLRequest.mm in Sources */ = {isa = PBXBuildFile; fileRef = 37BF2F051947DEB400723C48 /* WKNSURLRequest.mm */; };
+ 37C21CAE1E994C0C0029D5F9 /* CorePredictionSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 37C21CAD1E994C0C0029D5F9 /* CorePredictionSPI.h */; };
37C4C08618149C5B003688B9 /* WKBackForwardListItem.mm in Sources */ = {isa = PBXBuildFile; fileRef = 37C4C08418149C5B003688B9 /* WKBackForwardListItem.mm */; };
37C4C08718149C5B003688B9 /* WKBackForwardListItem.h in Headers */ = {isa = PBXBuildFile; fileRef = 37C4C08518149C5B003688B9 /* WKBackForwardListItem.h */; settings = {ATTRIBUTES = (Public, ); }; };
37C4C08918149F23003688B9 /* WKBackForwardListItemInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 37C4C08818149F23003688B9 /* WKBackForwardListItemInternal.h */; };
6501BD1A12F1243400E9F248 /* WKBundleInspector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 65B86F1712F11D7B00B7DD8A /* WKBundleInspector.cpp */; };
659C551E130006410025C0C2 /* InjectedBundlePageResourceLoadClient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6546A82913000164000CEB1C /* InjectedBundlePageResourceLoadClient.cpp */; };
65B86F1E12F11DE300B7DD8A /* WKBundleInspector.h in Headers */ = {isa = PBXBuildFile; fileRef = 65B86F1812F11D7B00B7DD8A /* WKBundleInspector.h */; settings = {ATTRIBUTES = (Private, ); }; };
- 6B2E09BA1E57B88100C8A8B9 /* CorePredictionSoftLink.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B2E09B91E57B88100C8A8B9 /* CorePredictionSoftLink.h */; };
6BE9699C1E43B3FF008B7483 /* WKResourceLoadStatisticsManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 6BE9699B1E43B3FF008B7483 /* WKResourceLoadStatisticsManager.h */; settings = {ATTRIBUTES = (Private, ); }; };
6BE9699E1E43B41D008B7483 /* WKResourceLoadStatisticsManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6BE9699D1E43B41D008B7483 /* WKResourceLoadStatisticsManager.cpp */; };
6BE969A01E43B86E008B7483 /* WebResourceLoadStatisticsManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 6BE9699F1E43B86E008B7483 /* WebResourceLoadStatisticsManager.h */; };
37BEC4DF19491486008B4286 /* CompletionHandlerCallChecker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CompletionHandlerCallChecker.h; sourceTree = "<group>"; };
37BF2F041947DEB400723C48 /* WKNSURLRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKNSURLRequest.h; sourceTree = "<group>"; };
37BF2F051947DEB400723C48 /* WKNSURLRequest.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKNSURLRequest.mm; sourceTree = "<group>"; };
+ 37C21CAD1E994C0C0029D5F9 /* CorePredictionSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CorePredictionSPI.h; sourceTree = "<group>"; };
37C4C08418149C5B003688B9 /* WKBackForwardListItem.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKBackForwardListItem.mm; sourceTree = "<group>"; };
37C4C08518149C5B003688B9 /* WKBackForwardListItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKBackForwardListItem.h; sourceTree = "<group>"; };
37C4C08818149F23003688B9 /* WKBackForwardListItemInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKBackForwardListItemInternal.h; sourceTree = "<group>"; };
6546A82A13000164000CEB1C /* InjectedBundlePageResourceLoadClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InjectedBundlePageResourceLoadClient.h; sourceTree = "<group>"; };
65B86F1712F11D7B00B7DD8A /* WKBundleInspector.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKBundleInspector.cpp; sourceTree = "<group>"; };
65B86F1812F11D7B00B7DD8A /* WKBundleInspector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKBundleInspector.h; sourceTree = "<group>"; };
- 6B2E09B91E57B88100C8A8B9 /* CorePredictionSoftLink.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CorePredictionSoftLink.h; sourceTree = "<group>"; };
6BE9699B1E43B3FF008B7483 /* WKResourceLoadStatisticsManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKResourceLoadStatisticsManager.h; sourceTree = "<group>"; };
6BE9699D1E43B41D008B7483 /* WKResourceLoadStatisticsManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKResourceLoadStatisticsManager.cpp; sourceTree = "<group>"; };
6BE9699F1E43B86E008B7483 /* WebResourceLoadStatisticsManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebResourceLoadStatisticsManager.h; sourceTree = "<group>"; };
isa = PBXGroup;
children = (
1A5705101BE410E500874AF1 /* BlockSPI.h */,
+ 37C21CAD1E994C0C0029D5F9 /* CorePredictionSPI.h */,
3754D5441B3A29FD003A4C7F /* NSInvocationSPI.h */,
37B47E2C1D64DB76005F4EFF /* objcSPI.h */,
);
6BE969C31E54D467008B7483 /* cocoa */ = {
isa = PBXGroup;
children = (
- 6B2E09B91E57B88100C8A8B9 /* CorePredictionSoftLink.h */,
6BE969C81E54D4CF008B7483 /* ResourceLoadStatisticsClassifierCocoa.cpp */,
6BE969C91E54D4CF008B7483 /* ResourceLoadStatisticsClassifierCocoa.h */,
);
5106D7C418BDBE73000AB166 /* ContextMenuContextData.h in Headers */,
CDC3830C17212282008A2FC3 /* CookieStorageShimLibrary.h in Headers */,
CE1A0BD31A48E6C60054EF74 /* CorePDFSPI.h in Headers */,
- 6B2E09BA1E57B88100C8A8B9 /* CorePredictionSoftLink.h in Headers */,
B878B615133428DC006888E9 /* CorrectionPanel.h in Headers */,
515E772C184008B90007203F /* DatabaseProcessCreationParameters.h in Headers */,
512A9761180E031D0039A149 /* DatabaseProcessMessages.h in Headers */,
BC032DA810F437D10058C15A /* Encoder.h in Headers */,
51B15A8513843A3900321AD8 /* EnvironmentUtilities.h in Headers */,
1AA575FB1496B52600A4EE06 /* EventDispatcher.h in Headers */,
+ 37C21CAE1E994C0C0029D5F9 /* CorePredictionSPI.h in Headers */,
00B9661A18E25AE100CE1F88 /* FindClient.h in Headers */,
1A90C1F41264FD71003E44D4 /* FindController.h in Headers */,
BCE81D8D1319F7EF00241910 /* FontInfo.h in Headers */,
+2017-04-11 Dan Bernstein <mitz@apple.com>
+
+ [Cocoa] WebKit unnecessarily soft-links CorePrediction
+ https://bugs.webkit.org/show_bug.cgi?id=170644
+
+ Reviewed by Sam Weinig.
+
+ * WebKitPrivateFrameworkStubs/iOS/10/CorePrediction.framework: Added this framework stub.
+ * WebKitPrivateFrameworkStubs/iOS/10/CorePrediction.framework/CorePrediction.tbd: Added.
+
2017-04-08 Dan Bernstein <mitz@apple.com>
Removed an empty directory left behind after r212841.
--- /dev/null
+--- !tapi-tbd-v2
+archs:
+ - armv7
+ - armv7s
+ - arm64
+exports:
+ -
+ archs:
+ - armv7
+ - armv7s
+ - arm64
+ symbols:
+ - _svm_load_model
+ - _svm_predict_values
+install-name: /System/Library/PrivateFrameworks/CorePrediction.framework
+objc-constraint: none
+platform: ios
+...