Title: [238388] trunk
Revision
238388
Author
achristen...@apple.com
Date
2018-11-19 18:16:31 -0800 (Mon, 19 Nov 2018)

Log Message

Add SPI to disable JIT in a WKWebView
https://bugs.webkit.org/show_bug.cgi?id=191822
<rdar://problem/28119360>

Reviewed by Geoffrey Garen.

Source/_javascript_Core:

* jit/ExecutableAllocator.cpp:
(JSC::jitDisabled):
(JSC::allowJIT):
(JSC::ExecutableAllocator::setJITEnabled):
* jit/ExecutableAllocator.h:
(JSC::ExecutableAllocator::setJITEnabled):

Source/WebKit:

* Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.h:
(WebKit::XPCServiceInitializer):
* UIProcess/API/APIProcessPoolConfiguration.h:
* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _canUseJIT:]):
* UIProcess/API/Cocoa/WKWebViewPrivate.h:
* UIProcess/API/Cocoa/_WKProcessPoolConfiguration.h:
* UIProcess/API/Cocoa/_WKProcessPoolConfiguration.mm:
(-[_WKProcessPoolConfiguration enableJIT]):
(-[_WKProcessPoolConfiguration setEnableJIT:]):
* UIProcess/Launcher/ProcessLauncher.h:
(WebKit::ProcessLauncher::Client::enableJIT const):
* UIProcess/Launcher/mac/ProcessLauncherMac.mm:
(WebKit::ProcessLauncher::launchProcess):
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::canUseJIT):
* UIProcess/WebPageProxy.h:
* UIProcess/WebProcessProxy.cpp:
(WebKit::WebProcessProxy::enableJIT const):
* UIProcess/WebProcessProxy.h:
(WebKit::WebProcessProxy::processPool const):
(WebKit::WebProcessProxy::processPool): Deleted.
* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::canUseJIT):
* WebProcess/WebProcess.h:
* WebProcess/WebProcess.messages.in:

Tools:

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKitCocoa/DisableJIT.mm: Added.
(TEST):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (238387 => 238388)


--- trunk/Source/_javascript_Core/ChangeLog	2018-11-20 02:02:36 UTC (rev 238387)
+++ trunk/Source/_javascript_Core/ChangeLog	2018-11-20 02:16:31 UTC (rev 238388)
@@ -1,3 +1,18 @@
+2018-11-19  Alex Christensen  <achristen...@webkit.org>
+
+        Add SPI to disable JIT in a WKWebView
+        https://bugs.webkit.org/show_bug.cgi?id=191822
+        <rdar://problem/28119360>
+
+        Reviewed by Geoffrey Garen.
+
+        * jit/ExecutableAllocator.cpp:
+        (JSC::jitDisabled):
+        (JSC::allowJIT):
+        (JSC::ExecutableAllocator::setJITEnabled):
+        * jit/ExecutableAllocator.h:
+        (JSC::ExecutableAllocator::setJITEnabled):
+
 2018-11-19  Fujii Hironori  <hironori.fu...@sony.com>
 
         [MSVC] X86Assembler.h(108): error C2666: 'WebCore::operator -': 7 overloads have similar conversions

Modified: trunk/Source/_javascript_Core/jit/ExecutableAllocator.cpp (238387 => 238388)


--- trunk/Source/_javascript_Core/jit/ExecutableAllocator.cpp	2018-11-20 02:02:36 UTC (rev 238387)
+++ trunk/Source/_javascript_Core/jit/ExecutableAllocator.cpp	2018-11-20 02:16:31 UTC (rev 238388)
@@ -113,15 +113,43 @@
 static uintptr_t startOfFixedWritableMemoryPool;
 #endif
 
-static bool allowJIT()
+class FixedVMPoolExecutableAllocator;
+static FixedVMPoolExecutableAllocator* allocator = nullptr;
+static ExecutableAllocator* executableAllocator = nullptr;
+
+static bool s_isJITEnabled = true;
+static bool isJITEnabled()
 {
 #if PLATFORM(IOS_FAMILY) && (CPU(ARM64) || CPU(ARM))
-    return processHasEntitlement("dynamic-codesigning");
+    return processHasEntitlement("dynamic-codesigning") && s_isJITEnabled;
 #else
-    return true;
+    return s_isJITEnabled;
 #endif
 }
 
+void ExecutableAllocator::setJITEnabled(bool enabled)
+{
+    ASSERT(!allocator);
+    if (s_isJITEnabled == enabled)
+        return;
+
+    s_isJITEnabled = enabled;
+
+#if PLATFORM(IOS_FAMILY) && (CPU(ARM64) || CPU(ARM))
+    if (!enabled) {
+        constexpr size_t size = 1;
+        constexpr int protection = PROT_READ | PROT_WRITE | PROT_EXEC;
+        constexpr int flags = MAP_PRIVATE | MAP_ANON | MAP_JIT;
+        constexpr int fd = OSAllocator::JSJITCodePages;
+        void* allocation = mmap(nullptr, size, protection, flags, fd, 0);
+        const void* executableMemoryAllocationFailure = reinterpret_cast<void*>(-1);
+        RELEASE_ASSERT_WITH_MESSAGE(allocation && allocation != executableMemoryAllocationFailure, "We should not have allocated executable memory before disabling the JIT.");
+        RELEASE_ASSERT_WITH_MESSAGE(!munmap(allocation, size), "Unmapping executable memory should succeed so we do not have any executable memory in the address space");
+        RELEASE_ASSERT_WITH_MESSAGE(mmap(nullptr, size, protection, flags, fd, 0) == executableMemoryAllocationFailure, "Allocating executable memory should fail after setJITEnabled(false) is called.");
+    }
+#endif
+}
+
 class FixedVMPoolExecutableAllocator : public MetaAllocator {
     WTF_MAKE_FAST_ALLOCATED;
 public:
@@ -128,7 +156,7 @@
     FixedVMPoolExecutableAllocator()
         : MetaAllocator(jitAllocationGranule) // round up all allocations to 32 bytes
     {
-        if (!allowJIT())
+        if (!isJITEnabled())
             return;
 
         size_t reservationSize;
@@ -376,9 +404,6 @@
     MacroAssemblerCodePtr<ExecutableMemoryPtrTag> m_memoryEnd;
 };
 
-static FixedVMPoolExecutableAllocator* allocator;
-static ExecutableAllocator* executableAllocator;
-
 void ExecutableAllocator::initializeAllocator()
 {
     ASSERT(!allocator);

Modified: trunk/Source/_javascript_Core/jit/ExecutableAllocator.h (238387 => 238388)


--- trunk/Source/_javascript_Core/jit/ExecutableAllocator.h	2018-11-20 02:02:36 UTC (rev 238387)
+++ trunk/Source/_javascript_Core/jit/ExecutableAllocator.h	2018-11-20 02:16:31 UTC (rev 238388)
@@ -140,6 +140,8 @@
 #else
     static void dumpProfile() { }
 #endif
+    
+    JS_EXPORT_PRIVATE static void setJITEnabled(bool);
 
     RefPtr<ExecutableMemoryHandle> allocate(size_t sizeInBytes, void* ownerUID, JITCompilationEffort);
 
@@ -173,6 +175,8 @@
 
     RefPtr<ExecutableMemoryHandle> allocate(size_t, void*, JITCompilationEffort) { return nullptr; }
 
+    static void setJITEnabled(bool) { };
+    
     bool isValidExecutableMemory(const AbstractLocker&, void*) { return false; }
 
     static size_t committedByteCount() { return 0; }

Modified: trunk/Source/WebKit/ChangeLog (238387 => 238388)


--- trunk/Source/WebKit/ChangeLog	2018-11-20 02:02:36 UTC (rev 238387)
+++ trunk/Source/WebKit/ChangeLog	2018-11-20 02:16:31 UTC (rev 238388)
@@ -1,3 +1,38 @@
+2018-11-19  Alex Christensen  <achristen...@webkit.org>
+
+        Add SPI to disable JIT in a WKWebView
+        https://bugs.webkit.org/show_bug.cgi?id=191822
+        <rdar://problem/28119360>
+
+        Reviewed by Geoffrey Garen.
+
+        * Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.h:
+        (WebKit::XPCServiceInitializer):
+        * UIProcess/API/APIProcessPoolConfiguration.h:
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView _canUseJIT:]):
+        * UIProcess/API/Cocoa/WKWebViewPrivate.h:
+        * UIProcess/API/Cocoa/_WKProcessPoolConfiguration.h:
+        * UIProcess/API/Cocoa/_WKProcessPoolConfiguration.mm:
+        (-[_WKProcessPoolConfiguration enableJIT]):
+        (-[_WKProcessPoolConfiguration setEnableJIT:]):
+        * UIProcess/Launcher/ProcessLauncher.h:
+        (WebKit::ProcessLauncher::Client::enableJIT const):
+        * UIProcess/Launcher/mac/ProcessLauncherMac.mm:
+        (WebKit::ProcessLauncher::launchProcess):
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::canUseJIT):
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/WebProcessProxy.cpp:
+        (WebKit::WebProcessProxy::enableJIT const):
+        * UIProcess/WebProcessProxy.h:
+        (WebKit::WebProcessProxy::processPool const):
+        (WebKit::WebProcessProxy::processPool): Deleted.
+        * WebProcess/WebProcess.cpp:
+        (WebKit::WebProcess::canUseJIT):
+        * WebProcess/WebProcess.h:
+        * WebProcess/WebProcess.messages.in:
+
 2018-11-19  Basuke Suzuki  <basuke.suz...@sony.com>
 
         [Curl] Add API for CertificateInfo.

Modified: trunk/Source/WebKit/Scripts/webkit/messages.py (238387 => 238388)


--- trunk/Source/WebKit/Scripts/webkit/messages.py	2018-11-20 02:02:36 UTC (rev 238387)
+++ trunk/Source/WebKit/Scripts/webkit/messages.py	2018-11-20 02:16:31 UTC (rev 238388)
@@ -190,7 +190,7 @@
     ])
 
     for message in receiver.messages:
-        if message.reply_parameters != None and message.has_attribute(DELAYED_ATTRIBUTE):
+        if message.reply_parameters != None:
             headers.add('<wtf/ThreadSafeRefCounted.h>')
             types_by_namespace['IPC'].update([('class', 'Connection')])
 

Modified: trunk/Source/WebKit/Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.h (238387 => 238388)


--- trunk/Source/WebKit/Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.h	2018-11-20 02:02:36 UTC (rev 238387)
+++ trunk/Source/WebKit/Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.h	2018-11-20 02:16:31 UTC (rev 238388)
@@ -23,11 +23,11 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef XPCServiceEntryPoint_h
-#define XPCServiceEntryPoint_h
+#pragma once
 
 #import "ChildProcess.h"
 #import "WebKit2Initialize.h"
+#import <_javascript_Core/ExecutableAllocator.h>
 #import <wtf/OSObjectPtr.h>
 #import <wtf/spi/darwin/XPCSPI.h>
 
@@ -70,6 +70,9 @@
 template<typename XPCServiceType, typename XPCServiceInitializerDelegateType>
 void XPCServiceInitializer(OSObjectPtr<xpc_connection_t> connection, xpc_object_t initializerMessage, xpc_object_t priorityBoostMessage)
 {
+    if (initializerMessage && xpc_dictionary_get_bool(initializerMessage, "disable-jit"))
+        JSC::ExecutableAllocator::setJITEnabled(false);
+
     XPCServiceInitializerDelegateType delegate(WTFMove(connection), initializerMessage);
 
     // We don't want XPC to be in charge of whether the process should be terminated or not,
@@ -124,5 +127,3 @@
 void XPCServiceExit(OSObjectPtr<xpc_object_t>&& priorityBoostMessage);
 
 } // namespace WebKit
-
-#endif // XPCServiceEntryPoint_h

Modified: trunk/Source/WebKit/UIProcess/API/APIProcessPoolConfiguration.cpp (238387 => 238388)


--- trunk/Source/WebKit/UIProcess/API/APIProcessPoolConfiguration.cpp	2018-11-20 02:02:36 UTC (rev 238387)
+++ trunk/Source/WebKit/UIProcess/API/APIProcessPoolConfiguration.cpp	2018-11-20 02:16:31 UTC (rev 238388)
@@ -116,6 +116,7 @@
     copy->m_shouldTakeUIBackgroundAssertion = this->m_shouldTakeUIBackgroundAssertion;
     copy->m_shouldCaptureAudioInUIProcess = this->m_shouldCaptureAudioInUIProcess;
     copy->m_shouldCaptureDisplayInUIProcess = this->m_shouldCaptureDisplayInUIProcess;
+    copy->m_isJITEnabled = this->m_isJITEnabled;
 #if PLATFORM(IOS_FAMILY)
     copy->m_ctDataConnectionServiceType = this->m_ctDataConnectionServiceType;
 #endif

Modified: trunk/Source/WebKit/UIProcess/API/APIProcessPoolConfiguration.h (238387 => 238388)


--- trunk/Source/WebKit/UIProcess/API/APIProcessPoolConfiguration.h	2018-11-20 02:02:36 UTC (rev 238387)
+++ trunk/Source/WebKit/UIProcess/API/APIProcessPoolConfiguration.h	2018-11-20 02:16:31 UTC (rev 238388)
@@ -147,6 +147,9 @@
     bool shouldCaptureDisplayInUIProcess() const { return m_shouldCaptureDisplayInUIProcess; }
     void setShouldCaptureDisplayInUIProcess(bool shouldCaptureDisplayInUIProcess) { m_shouldCaptureDisplayInUIProcess = shouldCaptureDisplayInUIProcess; }
 
+    bool isJITEnabled() const { return m_isJITEnabled; }
+    void setJITEnabled(bool enabled) { m_isJITEnabled = enabled; }
+    
 #if PLATFORM(IOS_FAMILY)
     const WTF::String& ctDataConnectionServiceType() const { return m_ctDataConnectionServiceType; }
     void setCTDataConnectionServiceType(const WTF::String& ctDataConnectionServiceType) { m_ctDataConnectionServiceType = ctDataConnectionServiceType; }
@@ -220,6 +223,7 @@
     bool m_processSwapsOnWindowOpenWithOpener { false };
     std::optional<bool> m_isAutomaticProcessWarmingEnabledByClient;
     WTF::String m_customWebContentServiceBundleIdentifier;
+    bool m_isJITEnabled { true };
 
 #if PLATFORM(IOS_FAMILY)
     WTF::String m_ctDataConnectionServiceType;

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm (238387 => 238388)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm	2018-11-20 02:02:36 UTC (rev 238387)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm	2018-11-20 02:16:31 UTC (rev 238388)
@@ -4768,6 +4768,13 @@
     return WebKit::SafeBrowsingWarning::visitUnsafeWebsiteSentinel();
 }
 
+- (void)_isJITEnabled:(void(^)(BOOL))completionHandler
+{
+    _page->isJITEnabled([completionHandler = makeBlockPtr(completionHandler)] (bool enabled) {
+        completionHandler(enabled);
+    });
+}
+
 - (void)_evaluateJavaScriptWithoutUserGesture:(NSString *)_javascript_String completionHandler:(void (^)(id, NSError *))completionHandler
 {
     [self _evaluateJavaScript:_javascript_String forceUserGesture:NO completionHandler:completionHandler];

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h (238387 => 238388)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h	2018-11-20 02:02:36 UTC (rev 238387)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h	2018-11-20 02:16:31 UTC (rev 238388)
@@ -192,6 +192,7 @@
 + (NSURL *)_visitUnsafeWebsiteSentinel WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
 - (void)_showSafeBrowsingWarningWithTitle:(NSString *)title warning:(NSString *)warning details:(NSAttributedString *)details completionHandler:(void(^)(BOOL))completionHandler WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
 
+- (void)_isJITEnabled:(void(^)(BOOL))completionHandler WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
 - (IBAction)_alignCenter:(id)sender WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
 - (IBAction)_alignJustified:(id)sender WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
 - (IBAction)_alignLeft:(id)sender WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKProcessPoolConfiguration.h (238387 => 238388)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKProcessPoolConfiguration.h	2018-11-20 02:02:36 UTC (rev 238387)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKProcessPoolConfiguration.h	2018-11-20 02:16:31 UTC (rev 238388)
@@ -68,6 +68,7 @@
 @property (nonatomic) BOOL prewarmsProcessesAutomatically WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
 @property (nonatomic) BOOL pageCacheEnabled WK_API_AVAILABLE(macosx(10.14), ios(12.0));
 @property (nonatomic) BOOL suppressesConnectionTerminationOnSystemChange WK_API_AVAILABLE(macosx(10.14), ios(12.0));
+@property (nonatomic, getter=isJITEnabled) BOOL JITEnabled WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
 
 @end
 

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKProcessPoolConfiguration.mm (238387 => 238388)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKProcessPoolConfiguration.mm	2018-11-20 02:02:36 UTC (rev 238387)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKProcessPoolConfiguration.mm	2018-11-20 02:16:31 UTC (rev 238388)
@@ -298,6 +298,16 @@
     return _processPoolConfiguration->suppressesConnectionTerminationOnSystemChange();
 }
 
+- (BOOL)isJITEnabled
+{
+    return _processPoolConfiguration->isJITEnabled();
+}
+
+- (void)setJITEnabled:(BOOL)enabled
+{
+    _processPoolConfiguration->setJITEnabled(enabled);
+}
+
 - (void)setSuppressesConnectionTerminationOnSystemChange:(BOOL)suppressesConnectionTerminationOnSystemChange
 {
     _processPoolConfiguration->setSuppressesConnectionTerminationOnSystemChange(suppressesConnectionTerminationOnSystemChange);

Modified: trunk/Source/WebKit/UIProcess/Launcher/ProcessLauncher.h (238387 => 238388)


--- trunk/Source/WebKit/UIProcess/Launcher/ProcessLauncher.h	2018-11-20 02:02:36 UTC (rev 238387)
+++ trunk/Source/WebKit/UIProcess/Launcher/ProcessLauncher.h	2018-11-20 02:16:31 UTC (rev 238388)
@@ -48,6 +48,7 @@
         virtual ~Client() { }
         
         virtual void didFinishLaunching(ProcessLauncher*, IPC::Connection::Identifier) = 0;
+        virtual bool isJITEnabled() const { return true; }
     };
     
     enum class ProcessType {

Modified: trunk/Source/WebKit/UIProcess/Launcher/mac/ProcessLauncherMac.mm (238387 => 238388)


--- trunk/Source/WebKit/UIProcess/Launcher/mac/ProcessLauncherMac.mm	2018-11-20 02:02:36 UTC (rev 238387)
+++ trunk/Source/WebKit/UIProcess/Launcher/mac/ProcessLauncherMac.mm	2018-11-20 02:16:31 UTC (rev 238388)
@@ -173,6 +173,10 @@
 
     // FIXME: Switch to xpc_connection_set_bootstrap once it's available everywhere we need.
     auto bootstrapMessage = adoptOSObject(xpc_dictionary_create(nullptr, nullptr, 0));
+    
+    if (m_client && !m_client->isJITEnabled())
+        xpc_dictionary_set_bool(bootstrapMessage.get(), "disable-jit", true);
+
     xpc_dictionary_set_string(bootstrapMessage.get(), "message-name", "bootstrap");
 
     xpc_dictionary_set_mach_send(bootstrapMessage.get(), "server-port", listeningPort);

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (238387 => 238388)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2018-11-20 02:02:36 UTC (rev 238387)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2018-11-20 02:16:31 UTC (rev 238388)
@@ -6533,6 +6533,11 @@
     return parameters;
 }
 
+void WebPageProxy::isJITEnabled(CompletionHandler<void(bool)>&& completionHandler)
+{
+    m_process->connection()->sendWithAsyncReply(Messages::WebProcess::IsJITEnabled(), WTFMove(completionHandler));
+}
+
 void WebPageProxy::enterAcceleratedCompositingMode(const LayerTreeContext& layerTreeContext)
 {
     pageClient().enterAcceleratedCompositingMode(layerTreeContext);

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (238387 => 238388)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.h	2018-11-20 02:02:36 UTC (rev 238387)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h	2018-11-20 02:16:31 UTC (rev 238388)
@@ -873,7 +873,9 @@
     void setPaginationLineGridEnabled(bool);
     bool paginationLineGridEnabled() const { return m_paginationLineGridEnabled; }
     unsigned pageCount() const { return m_pageCount; }
-        
+
+    void isJITEnabled(CompletionHandler<void(bool)>&&);
+
 #if PLATFORM(MAC)
     void setUseSystemAppearance(bool);
     bool useSystemAppearance() const { return m_useSystemAppearance; }

Modified: trunk/Source/WebKit/UIProcess/WebProcessProxy.cpp (238387 => 238388)


--- trunk/Source/WebKit/UIProcess/WebProcessProxy.cpp	2018-11-20 02:02:36 UTC (rev 238387)
+++ trunk/Source/WebKit/UIProcess/WebProcessProxy.cpp	2018-11-20 02:16:31 UTC (rev 238388)
@@ -1221,6 +1221,11 @@
     send(Messages::WebProcess::MainThreadPing(), 0);
 }
 
+bool WebProcessProxy::isJITEnabled() const
+{
+    return processPool().configuration().isJITEnabled();
+}
+
 void WebProcessProxy::didReceiveMainThreadPing()
 {
     responsivenessTimer().stop();

Modified: trunk/Source/WebKit/UIProcess/WebProcessProxy.h (238387 => 238388)


--- trunk/Source/WebKit/UIProcess/WebProcessProxy.h	2018-11-20 02:02:36 UTC (rev 238387)
+++ trunk/Source/WebKit/UIProcess/WebProcessProxy.h	2018-11-20 02:16:31 UTC (rev 238388)
@@ -110,7 +110,7 @@
 
     WebConnection* webConnection() const { return m_webConnection.get(); }
 
-    WebProcessPool& processPool() { ASSERT(m_processPool); return *m_processPool.get(); }
+    WebProcessPool& processPool() const { ASSERT(m_processPool); return *m_processPool.get(); }
 
     // FIXME: WebsiteDataStores should be made per-WebPageProxy throughout WebKit2
     WebsiteDataStore& websiteDataStore() const { return m_websiteDataStore.get(); }
@@ -258,6 +258,8 @@
     void cacheMediaMIMETypesInternal(const Vector<String>&);
 #endif
 
+    bool isJITEnabled() const final;
+    
 private:
     // IPC message handlers.
     void updateBackForwardItem(const BackForwardListItemState&);

Modified: trunk/Source/WebKit/WebProcess/WebProcess.cpp (238387 => 238388)


--- trunk/Source/WebKit/WebProcess/WebProcess.cpp	2018-11-20 02:02:36 UTC (rev 238387)
+++ trunk/Source/WebKit/WebProcess/WebProcess.cpp	2018-11-20 02:16:31 UTC (rev 238388)
@@ -930,6 +930,11 @@
 #endif
 }
 
+void WebProcess::isJITEnabled(CompletionHandler<void(bool)>&& completionHandler)
+{
+    completionHandler(JSC::VM::canUseJIT());
+}
+
 void WebProcess::clearPluginClientPolicies()
 {
 #if ENABLE(NETSCAPE_PLUGIN_API) && PLATFORM(MAC)

Modified: trunk/Source/WebKit/WebProcess/WebProcess.h (238387 => 238388)


--- trunk/Source/WebKit/WebProcess/WebProcess.h	2018-11-20 02:02:36 UTC (rev 238387)
+++ trunk/Source/WebKit/WebProcess/WebProcess.h	2018-11-20 02:16:31 UTC (rev 238388)
@@ -204,6 +204,8 @@
 
     void sendPrewarmInformation(const WebCore::URL&);
 
+    void isJITEnabled(CompletionHandler<void(bool)>&&);
+
 #if PLATFORM(IOS_FAMILY)
     void resetAllGeolocationPermissions();
 #endif

Modified: trunk/Source/WebKit/WebProcess/WebProcess.messages.in (238387 => 238388)


--- trunk/Source/WebKit/WebProcess/WebProcess.messages.in	2018-11-20 02:02:36 UTC (rev 238387)
+++ trunk/Source/WebKit/WebProcess/WebProcess.messages.in	2018-11-20 02:16:31 UTC (rev 238388)
@@ -141,6 +141,8 @@
 #endif
 #endif
 
+    IsJITEnabled() -> (bool enabled) Async
+
 #if PLATFORM(COCOA)
     SetMediaMIMETypes(Vector<String> types)
 #endif

Modified: trunk/Tools/ChangeLog (238387 => 238388)


--- trunk/Tools/ChangeLog	2018-11-20 02:02:36 UTC (rev 238387)
+++ trunk/Tools/ChangeLog	2018-11-20 02:16:31 UTC (rev 238388)
@@ -1,3 +1,15 @@
+2018-11-19  Alex Christensen  <achristen...@webkit.org>
+
+        Add SPI to disable JIT in a WKWebView
+        https://bugs.webkit.org/show_bug.cgi?id=191822
+        <rdar://problem/28119360>
+
+        Reviewed by Geoffrey Garen.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/WebKitCocoa/DisableJIT.mm: Added.
+        (TEST):
+
 2018-11-19  Basuke Suzuki  <basuke.suz...@sony.com>
 
         [Curl] Add API for CertificateInfo.

Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (238387 => 238388)


--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2018-11-20 02:02:36 UTC (rev 238387)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2018-11-20 02:16:31 UTC (rev 238388)
@@ -272,6 +272,7 @@
 		57C3FA661F7C248F009D4B80 /* WeakPtr.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1CB9BC371A67482300FE5678 /* WeakPtr.cpp */; };
 		57F4AAA0208FAEF000A68E9E /* SSLKeyGenerator.mm in Sources */ = {isa = PBXBuildFile; fileRef = 57F4AA9F208FA83D00A68E9E /* SSLKeyGenerator.mm */; };
 		57F56A5C1C7F8CC100F31D7E /* IsNavigationActionTrusted.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 57F56A5B1C7F8A4000F31D7E /* IsNavigationActionTrusted.html */; };
+		5C0160C121A132460077FA32 /* JITEnabled.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5C0160C021A132320077FA32 /* JITEnabled.mm */; };
 		5C0BF88D1DD5964D00B00328 /* MemoryPressureHandler.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5C0BF88C1DD5957400B00328 /* MemoryPressureHandler.mm */; };
 		5C0BF8911DD599A900B00328 /* WebViewCanPasteZeroPng.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5C0BF88F1DD5999B00B00328 /* WebViewCanPasteZeroPng.mm */; };
 		5C0BF8921DD599B600B00328 /* EarlyKVOCrash.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1A9FB6CC1CA34BE500966124 /* EarlyKVOCrash.mm */; };
@@ -1606,6 +1607,7 @@
 		57F10D921C7E7B3800ECDF30 /* IsNavigationActionTrusted.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = IsNavigationActionTrusted.mm; sourceTree = "<group>"; };
 		57F4AA9F208FA83D00A68E9E /* SSLKeyGenerator.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = SSLKeyGenerator.mm; sourceTree = "<group>"; };
 		57F56A5B1C7F8A4000F31D7E /* IsNavigationActionTrusted.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = IsNavigationActionTrusted.html; sourceTree = "<group>"; };
+		5C0160C021A132320077FA32 /* JITEnabled.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = JITEnabled.mm; sourceTree = "<group>"; };
 		5C0BF88C1DD5957400B00328 /* MemoryPressureHandler.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MemoryPressureHandler.mm; sourceTree = "<group>"; };
 		5C0BF88F1DD5999B00B00328 /* WebViewCanPasteZeroPng.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebViewCanPasteZeroPng.mm; sourceTree = "<group>"; };
 		5C19A5231FD0F32600EEA323 /* CookiePrivateBrowsing.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CookiePrivateBrowsing.mm; sourceTree = "<group>"; };
@@ -2424,6 +2426,7 @@
 				79C5D430209D768300F1E7CA /* InjectedBundleNodeHandleIsTextField.mm */,
 				2DB0232E1E4E871800707123 /* InteractionDeadlockAfterCrash.mm */,
 				5C69BDD41F82A7EB000F4F4B /* _javascript_DuringNavigation.mm */,
+				5C0160C021A132320077FA32 /* JITEnabled.mm */,
 				C25CCA051E51380B0026CB8A /* LineBreaking.mm */,
 				37D36ED61AF42ECD00BAF5D9 /* LoadAlternateHTMLString.mm */,
 				A125478D1DB18B9400358564 /* LoadDataWithNilMIMEType.mm */,
@@ -3952,6 +3955,7 @@
 				5C69BDD51F82A7EF000F4F4B /* _javascript_DuringNavigation.mm in Sources */,
 				7CCE7EAD1A411A3400447C4C /* _javascript_Test.cpp in Sources */,
 				7CCE7EA51A411A0800447C4C /* _javascript_TestMac.mm in Sources */,
+				5C0160C121A132460077FA32 /* JITEnabled.mm in Sources */,
 				7CCE7EC41A411A7E00447C4C /* JSWrapperForNodeInWebFrame.mm in Sources */,
 				F45E15732112CE2900307E82 /* KeyboardInputTestsIOS.mm in Sources */,
 				7CCE7F061A411AE600447C4C /* LayoutMilestonesWithAllContentInFrame.cpp in Sources */,

Added: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/JITEnabled.mm (0 => 238388)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/JITEnabled.mm	                        (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/JITEnabled.mm	2018-11-20 02:16:31 UTC (rev 238388)
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2018 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+
+#if WK_API_ENABLED
+
+#import "PlatformUtilities.h"
+#import <WebKit/WKProcessPoolPrivate.h>
+#import <WebKit/WKWebViewPrivate.h>
+#import <WebKit/_WKProcessPoolConfiguration.h>
+#import <wtf/RetainPtr.h>
+
+TEST(WebKit, JITEnabled)
+{
+    auto checkJITEnabled = [] (RetainPtr<WKWebView>&& webView, BOOL expectedValue) {
+        __block bool done = false;
+        [webView evaluateJavaScript:@"for(i=0;i<100000;++i);'abc'" completionHandler:^(id result, NSError *error) {
+            EXPECT_TRUE(error == nil);
+            EXPECT_STREQ([result UTF8String], "abc");
+            [webView _isJITEnabled:^(BOOL enabled) {
+                EXPECT_TRUE(enabled == expectedValue);
+                done = true;
+            }];
+        }];
+        TestWebKitAPI::Util::run(&done);
+    };
+
+    auto processPoolConfiguration = adoptNS([_WKProcessPoolConfiguration new]);
+    [processPoolConfiguration setJITEnabled:NO];
+    auto configuration = adoptNS([WKWebViewConfiguration new]);
+    [configuration setProcessPool:[[[WKProcessPool alloc] _initWithConfiguration:processPoolConfiguration.get()] autorelease]];
+    auto webViewNoJIT = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
+    checkJITEnabled(webViewNoJIT, NO);
+    checkJITEnabled(adoptNS([WKWebView new]), YES);
+}
+
+#endif
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to