- Revision
- 142163
- Author
- [email protected]
- Date
- 2013-02-07 12:35:09 -0800 (Thu, 07 Feb 2013)
Log Message
Upstream iOS isWebThread() and isUIThread()
https://bugs.webkit.org/show_bug.cgi?id=109130
Patch by Benjamin Poulain <[email protected]> on 2013-02-07
Reviewed by Sam Weinig.
Source/WebCore:
* bindings/objc/WebScriptObject.mm:
(+[WebScriptObject initialize]):
* platform/mac/SharedBufferMac.mm:
(+[WebCoreSharedBufferData initialize]):
#ifdef out the legacy initialization as it is not correct when
using a WebThread.
Source/WTF:
On iOS, it is sometimes necessary to differenciate the thread running WebCore,
and the thread running the UI. This patch upstream those functions.
* wtf/MainThread.cpp:
* wtf/MainThread.h:
Disable the legacy initializer as it is incorrect when using the WebThread to run WebCore.
(WTF::isWebThread):
(WTF::isUIThread):
Return true when the current thread is the Web/UI thread.
* wtf/mac/MainThreadMac.mm:
(WTF::isUIThread):
(WTF::isWebThread):
* wtf/text/AtomicString.cpp:
(WTF::AtomicStringTable::create):
Use the newly added methods.
Modified Paths
Diff
Modified: trunk/Source/WTF/ChangeLog (142162 => 142163)
--- trunk/Source/WTF/ChangeLog 2013-02-07 20:22:26 UTC (rev 142162)
+++ trunk/Source/WTF/ChangeLog 2013-02-07 20:35:09 UTC (rev 142163)
@@ -1,3 +1,28 @@
+2013-02-07 Benjamin Poulain <[email protected]>
+
+ Upstream iOS isWebThread() and isUIThread()
+ https://bugs.webkit.org/show_bug.cgi?id=109130
+
+ Reviewed by Sam Weinig.
+
+ On iOS, it is sometimes necessary to differenciate the thread running WebCore,
+ and the thread running the UI. This patch upstream those functions.
+
+ * wtf/MainThread.cpp:
+ * wtf/MainThread.h:
+ Disable the legacy initializer as it is incorrect when using the WebThread to run WebCore.
+ (WTF::isWebThread):
+ (WTF::isUIThread):
+ Return true when the current thread is the Web/UI thread.
+
+ * wtf/mac/MainThreadMac.mm:
+ (WTF::isUIThread):
+ (WTF::isWebThread):
+
+ * wtf/text/AtomicString.cpp:
+ (WTF::AtomicStringTable::create):
+ Use the newly added methods.
+
2013-02-07 Caio Marcelo de Oliveira Filho <[email protected]>
[Qt] Fix build without 3D_GRAPHICS
Modified: trunk/Source/WTF/wtf/MainThread.cpp (142162 => 142163)
--- trunk/Source/WTF/wtf/MainThread.cpp 2013-02-07 20:22:26 UTC (rev 142162)
+++ trunk/Source/WTF/wtf/MainThread.cpp 2013-02-07 20:35:09 UTC (rev 142163)
@@ -120,6 +120,7 @@
pthread_once(&initializeMainThreadKeyOnce, initializeMainThreadOnce);
}
+#if !USE(WEB_THREAD)
static void initializeMainThreadToProcessMainThreadOnce()
{
mainThreadFunctionQueueMutex();
@@ -130,6 +131,8 @@
{
pthread_once(&initializeMainThreadKeyOnce, initializeMainThreadToProcessMainThreadOnce);
}
+#endif // !USE(WEB_THREAD)
+
#endif
// 0.1 sec delays in UI is approximate threshold when they become noticeable. Have a limit that's half of that.
Modified: trunk/Source/WTF/wtf/MainThread.h (142162 => 142163)
--- trunk/Source/WTF/wtf/MainThread.h 2013-02-07 20:22:26 UTC (rev 142162)
+++ trunk/Source/WTF/wtf/MainThread.h 2013-02-07 20:35:09 UTC (rev 142163)
@@ -51,6 +51,15 @@
WTF_EXPORT_PRIVATE bool isMainThread();
+#if USE(WEB_THREAD)
+WTF_EXPORT_PRIVATE bool isWebThread();
+WTF_EXPORT_PRIVATE bool isUIThread();
+#else
+inline bool isWebThread() { return isMainThread(); }
+inline bool isUIThread() { return isMainThread(); }
+#endif // PLATFORM(IOS)
+
+
void initializeGCThreads();
#if ENABLE(PARALLEL_GC)
@@ -68,10 +77,12 @@
void dispatchFunctionsFromMainThread();
#if PLATFORM(MAC)
+#if !USE(WEB_THREAD)
// This version of initializeMainThread sets up the main thread as corresponding
// to the process's main thread, and not necessarily the thread that calls this
// function. It should only be used as a legacy aid for Mac WebKit.
WTF_EXPORT_PRIVATE void initializeMainThreadToProcessMainThread();
+#endif // !USE(WEB_THREAD)
void initializeMainThreadToProcessMainThreadPlatform();
#endif
Modified: trunk/Source/WTF/wtf/mac/MainThreadMac.mm (142162 => 142163)
--- trunk/Source/WTF/wtf/mac/MainThreadMac.mm 2013-02-07 20:22:26 UTC (rev 142162)
+++ trunk/Source/WTF/wtf/mac/MainThreadMac.mm 2013-02-07 20:35:09 UTC (rev 142163)
@@ -70,6 +70,7 @@
initializeGCThreads();
}
+#if !USE(WEB_THREAD)
void initializeMainThreadToProcessMainThreadPlatform()
{
if (!pthread_main_np())
@@ -84,6 +85,7 @@
initializeGCThreads();
}
+#endif // !USE(WEB_THREAD)
static void timerFired(CFRunLoopTimerRef timer, void*)
{
@@ -133,4 +135,16 @@
return pthread_equal(pthread_self(), mainThreadPthread);
}
+#if USE(WEB_THREAD)
+bool isUIThread()
+{
+ return pthread_main_np();
+}
+
+bool isWebThread()
+{
+ return pthread_equal(pthread_self(), mainThreadPthread);
+}
+#endif // USE(WEB_THREAD)
+
} // namespace WTF
Modified: trunk/Source/WTF/wtf/text/AtomicString.cpp (142162 => 142163)
--- trunk/Source/WTF/wtf/text/AtomicString.cpp 2013-02-07 20:22:26 UTC (rev 142162)
+++ trunk/Source/WTF/wtf/text/AtomicString.cpp 2013-02-07 20:35:09 UTC (rev 142163)
@@ -74,7 +74,7 @@
static AtomicStringTable* sharedStringTable = new AtomicStringTable;
bool currentThreadIsWebThread = isWebThread();
- if (currentThreadIsWebThread || pthread_main_np())
+ if (currentThreadIsWebThread || isUIThread())
data.m_atomicStringTable = sharedStringTable;
else
data.m_atomicStringTable = new AtomicStringTable;
Modified: trunk/Source/WebCore/ChangeLog (142162 => 142163)
--- trunk/Source/WebCore/ChangeLog 2013-02-07 20:22:26 UTC (rev 142162)
+++ trunk/Source/WebCore/ChangeLog 2013-02-07 20:35:09 UTC (rev 142163)
@@ -1,3 +1,17 @@
+2013-02-07 Benjamin Poulain <[email protected]>
+
+ Upstream iOS isWebThread() and isUIThread()
+ https://bugs.webkit.org/show_bug.cgi?id=109130
+
+ Reviewed by Sam Weinig.
+
+ * bindings/objc/WebScriptObject.mm:
+ (+[WebScriptObject initialize]):
+ * platform/mac/SharedBufferMac.mm:
+ (+[WebCoreSharedBufferData initialize]):
+ #ifdef out the legacy initialization as it is not correct when
+ using a WebThread.
+
2013-02-07 Vivek Galatage <[email protected]>
Web Inspector: CPU pegged when inspecting LocalStorage that mutates.
Modified: trunk/Source/WebCore/bindings/objc/WebScriptObject.mm (142162 => 142163)
--- trunk/Source/WebCore/bindings/objc/WebScriptObject.mm 2013-02-07 20:22:26 UTC (rev 142162)
+++ trunk/Source/WebCore/bindings/objc/WebScriptObject.mm 2013-02-07 20:35:09 UTC (rev 142163)
@@ -127,8 +127,10 @@
+ (void)initialize
{
+#if !USE(WEB_THREAD)
JSC::initializeThreading();
WTF::initializeMainThreadToProcessMainThread();
+#endif // !USE(WEB_THREAD)
WebCoreObjCFinalizeOnMainThread(self);
}
Modified: trunk/Source/WebCore/platform/mac/SharedBufferMac.mm (142162 => 142163)
--- trunk/Source/WebCore/platform/mac/SharedBufferMac.mm 2013-02-07 20:22:26 UTC (rev 142162)
+++ trunk/Source/WebCore/platform/mac/SharedBufferMac.mm 2013-02-07 20:35:09 UTC (rev 142163)
@@ -47,12 +47,14 @@
+ (void)initialize
{
+#if !USE(WEB_THREAD)
JSC::initializeThreading();
#if PLATFORM(QT) && USE(QTKIT)
WTF::initializeMainThread();
#else
WTF::initializeMainThreadToProcessMainThread();
#endif
+#endif // !USE(WEB_THREAD)
WebCoreObjCFinalizeOnMainThread(self);
}