Title: [213129] releases/WebKitGTK/webkit-2.16
Revision
213129
Author
carlo...@webkit.org
Date
2017-02-28 01:07:22 -0800 (Tue, 28 Feb 2017)

Log Message

Merge r212878 - Better handle Thread and RunLoop initialization
https://bugs.webkit.org/show_bug.cgi?id=167828

Reviewed by Yusuke Suzuki.

Source/_javascript_Core:

* runtime/InitializeThreading.cpp:
(JSC::initializeThreading): Do not initialize double_conversion, that is already initialized by WTF, and GC
threads that will be initialized by WTF main thread when needed.

Source/WebKit/win:

Remove unnecessary call to WTF::initializeMainThread().

* WebView.cpp:
(WebView::WebView):

Source/WebKit2:

Remove unnecessary call to WTF::initializeMainThread().

* Shared/WebKit2Initialize.cpp:
(WebKit::InitializeWebKit2):

Source/WTF:

Make initialization functions more independent so that they can run in different
order. WTF::initializeMainThread initializes WTF threading, so that neither WTF nor JSC theading need to be
initialized before. RunLoop::initializeMainRunLoop() requires main thread to be initialized in some
ports, so it initializes main thread too. WebKit1 always calls WTF::initializeMainThreadToProcessMainThread()
before RunLoop::initializeMainRunLoop() so there's no problem there. GC threads are initialized alwayas by the
main thread. The rules should be simpler now:

  - JSC::initializeThreading: should always be called when JSC is used.
  - WTF::initializeThreading: only needs to be explicitly called when JSC is not used and process doesn't
    initialize a main thread or main run loop.
  - WTF::initializeMainThread: only needs to be explicitly called if process initializes a main thread but not a
    main run loop.
  - WTF::initializeMainThreadToProcessMainThread(): should always be called in WebKit1 before
    RunLoop::initializeMainRunLoop().
  - RunLoop::initializeMainRunLoop(): to initialize the main run loop. The only requirement is JSC::initializeThreading()
    to be called before if JSC is used.

* wtf/MainThread.cpp:
(WTF::initializeMainThreadOnce): Use pthread_once to initialize the main thread also in GTK+ port.
(WTF::initializeMainThreadToProcessMainThreadOnce): Call initializeThreading() before the platform
initialization and initializeGCThreads() after it.
(WTF::initializeMainThread): Ditto.
* wtf/RunLoop.cpp:
(WTF::RunLoop::initializeMainRunLoop): Call initializeMainThread().
* wtf/glib/MainThreadGLib.cpp:
(WTF::initializeMainThreadPlatform):
(WTF::isMainThread):
* wtf/mac/MainThreadMac.mm:
(WTF::initializeMainThreadPlatform): Remove call to initializeGCThreads().
(WTF::initializeMainThreadToProcessMainThreadPlatform): Ditto.

Tools:

Remove unnecessary calls to WTF::initializeMainThread().

* TestWebKitAPI/Tests/WebCore/ComplexTextController.cpp:
(TestWebKitAPI::ComplexTextControllerTest::SetUp):
* TestWebKitAPI/Tests/WebCore/ContentExtensions.cpp:
(TestWebKitAPI::ContentExtensionTest::SetUp):
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::initialize):

Modified Paths

Diff

Modified: releases/WebKitGTK/webkit-2.16/Source/_javascript_Core/ChangeLog (213128 => 213129)


--- releases/WebKitGTK/webkit-2.16/Source/_javascript_Core/ChangeLog	2017-02-28 09:05:24 UTC (rev 213128)
+++ releases/WebKitGTK/webkit-2.16/Source/_javascript_Core/ChangeLog	2017-02-28 09:07:22 UTC (rev 213129)
@@ -1,3 +1,14 @@
+2017-02-22  Carlos Garcia Campos  <cgar...@igalia.com>
+
+        Better handle Thread and RunLoop initialization
+        https://bugs.webkit.org/show_bug.cgi?id=167828
+
+        Reviewed by Yusuke Suzuki.
+
+        * runtime/InitializeThreading.cpp:
+        (JSC::initializeThreading): Do not initialize double_conversion, that is already initialized by WTF, and GC
+        threads that will be initialized by WTF main thread when needed.
+
 2017-02-22  Keith Miller  <keith_mil...@apple.com>
 
         Remove the demand executable allocator

Modified: releases/WebKitGTK/webkit-2.16/Source/_javascript_Core/runtime/InitializeThreading.cpp (213128 => 213129)


--- releases/WebKitGTK/webkit-2.16/Source/_javascript_Core/runtime/InitializeThreading.cpp	2017-02-28 09:05:24 UTC (rev 213128)
+++ releases/WebKitGTK/webkit-2.16/Source/_javascript_Core/runtime/InitializeThreading.cpp	2017-02-28 09:07:22 UTC (rev 213129)
@@ -55,9 +55,7 @@
     static std::once_flag initializeThreadingOnceFlag;
 
     std::call_once(initializeThreadingOnceFlag, []{
-        WTF::double_conversion::initialize();
         WTF::initializeThreading();
-        WTF::initializeGCThreads();
         Options::initialize();
 #if ENABLE(WRITE_BARRIER_PROFILING)
         WriteBarrierCounters::initialize();

Modified: releases/WebKitGTK/webkit-2.16/Source/WTF/ChangeLog (213128 => 213129)


--- releases/WebKitGTK/webkit-2.16/Source/WTF/ChangeLog	2017-02-28 09:05:24 UTC (rev 213128)
+++ releases/WebKitGTK/webkit-2.16/Source/WTF/ChangeLog	2017-02-28 09:07:22 UTC (rev 213129)
@@ -1,3 +1,41 @@
+2017-02-22  Carlos Garcia Campos  <cgar...@igalia.com>
+
+        Better handle Thread and RunLoop initialization
+        https://bugs.webkit.org/show_bug.cgi?id=167828
+
+        Reviewed by Yusuke Suzuki.
+
+        Make initialization functions more independent so that they can run in different
+        order. WTF::initializeMainThread initializes WTF threading, so that neither WTF nor JSC theading need to be
+        initialized before. RunLoop::initializeMainRunLoop() requires main thread to be initialized in some
+        ports, so it initializes main thread too. WebKit1 always calls WTF::initializeMainThreadToProcessMainThread()
+        before RunLoop::initializeMainRunLoop() so there's no problem there. GC threads are initialized alwayas by the
+        main thread. The rules should be simpler now:
+
+          - JSC::initializeThreading: should always be called when JSC is used.
+          - WTF::initializeThreading: only needs to be explicitly called when JSC is not used and process doesn't
+            initialize a main thread or main run loop.
+          - WTF::initializeMainThread: only needs to be explicitly called if process initializes a main thread but not a
+            main run loop.
+          - WTF::initializeMainThreadToProcessMainThread(): should always be called in WebKit1 before
+            RunLoop::initializeMainRunLoop().
+          - RunLoop::initializeMainRunLoop(): to initialize the main run loop. The only requirement is JSC::initializeThreading()
+            to be called before if JSC is used.
+
+        * wtf/MainThread.cpp:
+        (WTF::initializeMainThreadOnce): Use pthread_once to initialize the main thread also in GTK+ port.
+        (WTF::initializeMainThreadToProcessMainThreadOnce): Call initializeThreading() before the platform
+        initialization and initializeGCThreads() after it.
+        (WTF::initializeMainThread): Ditto.
+        * wtf/RunLoop.cpp:
+        (WTF::RunLoop::initializeMainRunLoop): Call initializeMainThread().
+        * wtf/glib/MainThreadGLib.cpp:
+        (WTF::initializeMainThreadPlatform):
+        (WTF::isMainThread):
+        * wtf/mac/MainThreadMac.mm:
+        (WTF::initializeMainThreadPlatform): Remove call to initializeGCThreads().
+        (WTF::initializeMainThreadToProcessMainThreadPlatform): Ditto.
+
 2017-02-22  Keith Miller  <keith_mil...@apple.com>
 
         Remove the demand executable allocator

Modified: releases/WebKitGTK/webkit-2.16/Source/WTF/wtf/MainThread.cpp (213128 => 213129)


--- releases/WebKitGTK/webkit-2.16/Source/WTF/wtf/MainThread.cpp	2017-02-28 09:05:24 UTC (rev 213128)
+++ releases/WebKitGTK/webkit-2.16/Source/WTF/wtf/MainThread.cpp	2017-02-28 09:07:22 UTC (rev 213129)
@@ -41,7 +41,7 @@
 namespace WTF {
 
 static bool callbacksPaused; // This global variable is only accessed from main thread.
-#if !OS(DARWIN) || PLATFORM(GTK)
+#if !OS(DARWIN) && !PLATFORM(GTK)
 static ThreadIdentifier mainThreadIdentifier;
 #endif
 
@@ -53,28 +53,14 @@
     return functionQueue;
 }
 
-#if !OS(DARWIN) || PLATFORM(GTK)
-
-void initializeMainThread()
-{
-    static bool initializedMainThread;
-    if (initializedMainThread)
-        return;
-    initializedMainThread = true;
-
-    mainThreadIdentifier = currentThread();
-
-    initializeMainThreadPlatform();
-    initializeGCThreads();
-}
-
-#else
-
+#if OS(DARWIN) || PLATFORM(GTK)
 static pthread_once_t initializeMainThreadKeyOnce = PTHREAD_ONCE_INIT;
 
 static void initializeMainThreadOnce()
 {
+    initializeThreading();
     initializeMainThreadPlatform();
+    initializeGCThreads();
 }
 
 void initializeMainThread()
@@ -82,10 +68,12 @@
     pthread_once(&initializeMainThreadKeyOnce, initializeMainThreadOnce);
 }
 
-#if !USE(WEB_THREAD)
+#if !USE(WEB_THREAD) && !PLATFORM(GTK)
 static void initializeMainThreadToProcessMainThreadOnce()
 {
+    initializeThreading();
     initializeMainThreadToProcessMainThreadPlatform();
+    initializeGCThreads();
 }
 
 void initializeMainThreadToProcessMainThread()
@@ -92,7 +80,7 @@
 {
     pthread_once(&initializeMainThreadKeyOnce, initializeMainThreadToProcessMainThreadOnce);
 }
-#else
+#elif !PLATFORM(GTK)
 static pthread_once_t initializeWebThreadKeyOnce = PTHREAD_ONCE_INIT;
 
 static void initializeWebThreadOnce()
@@ -106,6 +94,20 @@
 }
 #endif // !USE(WEB_THREAD)
 
+#else
+void initializeMainThread()
+{
+    static bool initializedMainThread;
+    if (initializedMainThread)
+        return;
+    initializedMainThread = true;
+
+    initializeThreading();
+    mainThreadIdentifier = currentThread();
+
+    initializeMainThreadPlatform();
+    initializeGCThreads();
+}
 #endif
 
 // 0.1 sec delays in UI is approximate threshold when they become noticeable. Have a limit that's half of that.
@@ -176,7 +178,7 @@
         scheduleDispatchFunctionsOnMainThread();
 }
 
-#if !OS(DARWIN) || PLATFORM(GTK)
+#if !OS(DARWIN) && !PLATFORM(GTK)
 bool isMainThread()
 {
     return currentThread() == mainThreadIdentifier;

Modified: releases/WebKitGTK/webkit-2.16/Source/WTF/wtf/RunLoop.cpp (213128 => 213129)


--- releases/WebKitGTK/webkit-2.16/Source/WTF/wtf/RunLoop.cpp	2017-02-28 09:05:24 UTC (rev 213128)
+++ releases/WebKitGTK/webkit-2.16/Source/WTF/wtf/RunLoop.cpp	2017-02-28 09:07:22 UTC (rev 213129)
@@ -52,6 +52,7 @@
 {
     if (s_mainRunLoop)
         return;
+    initializeMainThread();
     s_mainRunLoop = &RunLoop::current();
 }
 

Modified: releases/WebKitGTK/webkit-2.16/Source/WTF/wtf/glib/MainThreadGLib.cpp (213128 => 213129)


--- releases/WebKitGTK/webkit-2.16/Source/WTF/wtf/glib/MainThreadGLib.cpp	2017-02-28 09:05:24 UTC (rev 213128)
+++ releases/WebKitGTK/webkit-2.16/Source/WTF/wtf/glib/MainThreadGLib.cpp	2017-02-28 09:07:22 UTC (rev 213129)
@@ -33,6 +33,8 @@
 #include <glib.h>
 #include <wtf/RunLoop.h>
 
+static pthread_t mainThreadPthread;
+
 namespace WTF {
 
 class MainThreadDispatcher {
@@ -59,8 +61,15 @@
 
 void initializeMainThreadPlatform()
 {
+    mainThreadPthread = pthread_self();
 }
 
+bool isMainThread()
+{
+    ASSERT(mainThreadPthread);
+    return pthread_equal(pthread_self(), mainThreadPthread);
+}
+
 void scheduleDispatchFunctionsOnMainThread()
 {
     // Use a RunLoop::Timer instead of RunLoop::dispatch() to be able to use a different priority and

Modified: releases/WebKitGTK/webkit-2.16/Source/WTF/wtf/mac/MainThreadMac.mm (213128 => 213129)


--- releases/WebKitGTK/webkit-2.16/Source/WTF/wtf/mac/MainThreadMac.mm	2017-02-28 09:05:24 UTC (rev 213128)
+++ releases/WebKitGTK/webkit-2.16/Source/WTF/wtf/mac/MainThreadMac.mm	2017-02-28 09:07:22 UTC (rev 213129)
@@ -82,8 +82,6 @@
     ASSERT(!mainThreadPthread);
     ASSERT(!mainThreadNSThread);
 #endif
-
-    initializeGCThreads();
 }
 
 #if !USE(WEB_THREAD)
@@ -98,8 +96,6 @@
     mainThreadEstablishedAsPthreadMain = true;
     mainThreadPthread = 0;
     mainThreadNSThread = nil;
-    
-    initializeGCThreads();
 }
 #endif // !USE(WEB_THREAD)
 

Modified: releases/WebKitGTK/webkit-2.16/Source/WebKit/win/ChangeLog (213128 => 213129)


--- releases/WebKitGTK/webkit-2.16/Source/WebKit/win/ChangeLog	2017-02-28 09:05:24 UTC (rev 213128)
+++ releases/WebKitGTK/webkit-2.16/Source/WebKit/win/ChangeLog	2017-02-28 09:07:22 UTC (rev 213129)
@@ -1,3 +1,15 @@
+2017-02-22  Carlos Garcia Campos  <cgar...@igalia.com>
+
+        Better handle Thread and RunLoop initialization
+        https://bugs.webkit.org/show_bug.cgi?id=167828
+
+        Reviewed by Yusuke Suzuki.
+
+        Remove unnecessary call to WTF::initializeMainThread().
+
+        * WebView.cpp:
+        (WebView::WebView):
+
 2017-02-16  Daniel Bates  <daba...@apple.com>
 
         Remove Chromium-specific code to call FrameLoaderClient::redirectDataToPlugin(nullptr)

Modified: releases/WebKitGTK/webkit-2.16/Source/WebKit/win/WebView.cpp (213128 => 213129)


--- releases/WebKitGTK/webkit-2.16/Source/WebKit/win/WebView.cpp	2017-02-28 09:05:24 UTC (rev 213128)
+++ releases/WebKitGTK/webkit-2.16/Source/WebKit/win/WebView.cpp	2017-02-28 09:07:22 UTC (rev 213129)
@@ -409,7 +409,6 @@
 WebView::WebView()
 {
     JSC::initializeThreading();
-    WTF::initializeMainThread();
     RunLoop::initializeMainRunLoop();
 
     m_backingStoreSize.cx = m_backingStoreSize.cy = 0;

Modified: releases/WebKitGTK/webkit-2.16/Source/WebKit2/ChangeLog (213128 => 213129)


--- releases/WebKitGTK/webkit-2.16/Source/WebKit2/ChangeLog	2017-02-28 09:05:24 UTC (rev 213128)
+++ releases/WebKitGTK/webkit-2.16/Source/WebKit2/ChangeLog	2017-02-28 09:07:22 UTC (rev 213129)
@@ -1,3 +1,15 @@
+2017-02-22  Carlos Garcia Campos  <cgar...@igalia.com>
+
+        Better handle Thread and RunLoop initialization
+        https://bugs.webkit.org/show_bug.cgi?id=167828
+
+        Reviewed by Yusuke Suzuki.
+
+        Remove unnecessary call to WTF::initializeMainThread().
+
+        * Shared/WebKit2Initialize.cpp:
+        (WebKit::InitializeWebKit2):
+
 2017-02-27  Carlos Garcia Campos  <cgar...@igalia.com>
 
         [GTK] Flickering when leaving accelerated compositing mode

Modified: releases/WebKitGTK/webkit-2.16/Source/WebKit2/Shared/WebKit2Initialize.cpp (213128 => 213129)


--- releases/WebKitGTK/webkit-2.16/Source/WebKit2/Shared/WebKit2Initialize.cpp	2017-02-28 09:05:24 UTC (rev 213128)
+++ releases/WebKitGTK/webkit-2.16/Source/WebKit2/Shared/WebKit2Initialize.cpp	2017-02-28 09:07:22 UTC (rev 213129)
@@ -51,7 +51,6 @@
 #endif
 
     JSC::initializeThreading();
-    WTF::initializeMainThread();
     RunLoop::initializeMainRunLoop();
 
 #if !LOG_DISABLED || !RELEASE_LOG_DISABLED

Modified: releases/WebKitGTK/webkit-2.16/Tools/ChangeLog (213128 => 213129)


--- releases/WebKitGTK/webkit-2.16/Tools/ChangeLog	2017-02-28 09:05:24 UTC (rev 213128)
+++ releases/WebKitGTK/webkit-2.16/Tools/ChangeLog	2017-02-28 09:07:22 UTC (rev 213129)
@@ -1,5 +1,21 @@
 2017-02-22  Carlos Garcia Campos  <cgar...@igalia.com>
 
+        Better handle Thread and RunLoop initialization
+        https://bugs.webkit.org/show_bug.cgi?id=167828
+
+        Reviewed by Yusuke Suzuki.
+
+        Remove unnecessary calls to WTF::initializeMainThread().
+
+        * TestWebKitAPI/Tests/WebCore/ComplexTextController.cpp:
+        (TestWebKitAPI::ComplexTextControllerTest::SetUp):
+        * TestWebKitAPI/Tests/WebCore/ContentExtensions.cpp:
+        (TestWebKitAPI::ContentExtensionTest::SetUp):
+        * WebKitTestRunner/TestController.cpp:
+        (WTR::TestController::initialize):
+
+2017-02-22  Carlos Garcia Campos  <cgar...@igalia.com>
+
         [GTK] Do not use g_return_if_fail in EventSenderProxy::continuousMouseScrollBy
         https://bugs.webkit.org/show_bug.cgi?id=168721
 

Modified: releases/WebKitGTK/webkit-2.16/Tools/TestWebKitAPI/Tests/WebCore/ComplexTextController.cpp (213128 => 213129)


--- releases/WebKitGTK/webkit-2.16/Tools/TestWebKitAPI/Tests/WebCore/ComplexTextController.cpp	2017-02-28 09:05:24 UTC (rev 213128)
+++ releases/WebKitGTK/webkit-2.16/Tools/TestWebKitAPI/Tests/WebCore/ComplexTextController.cpp	2017-02-28 09:07:22 UTC (rev 213129)
@@ -39,7 +39,6 @@
 public:
     virtual void SetUp()
     {
-        WTF::initializeMainThread();
         JSC::initializeThreading();
         RunLoop::initializeMainRunLoop();
     }

Modified: releases/WebKitGTK/webkit-2.16/Tools/TestWebKitAPI/Tests/WebCore/ContentExtensions.cpp (213128 => 213129)


--- releases/WebKitGTK/webkit-2.16/Tools/TestWebKitAPI/Tests/WebCore/ContentExtensions.cpp	2017-02-28 09:05:24 UTC (rev 213128)
+++ releases/WebKitGTK/webkit-2.16/Tools/TestWebKitAPI/Tests/WebCore/ContentExtensions.cpp	2017-02-28 09:07:22 UTC (rev 213129)
@@ -76,7 +76,6 @@
 public:
     virtual void SetUp()
     {
-        WTF::initializeMainThread();
         JSC::initializeThreading();
         RunLoop::initializeMainRunLoop();
     }

Modified: releases/WebKitGTK/webkit-2.16/Tools/WebKitTestRunner/TestController.cpp (213128 => 213129)


--- releases/WebKitGTK/webkit-2.16/Tools/WebKitTestRunner/TestController.cpp	2017-02-28 09:05:24 UTC (rev 213128)
+++ releases/WebKitGTK/webkit-2.16/Tools/WebKitTestRunner/TestController.cpp	2017-02-28 09:07:22 UTC (rev 213129)
@@ -331,7 +331,6 @@
 void TestController::initialize(int argc, const char* argv[])
 {
     JSC::initializeThreading();
-    WTF::initializeMainThread();
     RunLoop::initializeMainRunLoop();
 
     platformInitialize();
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to