Title: [214489] trunk/Source
Revision
214489
Author
utatane....@gmail.com
Date
2017-03-28 13:08:49 -0700 (Tue, 28 Mar 2017)

Log Message

[JSC] Move platformThreadSignal to WTF
https://bugs.webkit.org/show_bug.cgi?id=170097

Reviewed by Mark Lam.

Source/_javascript_Core:

It is a small clean up towards https://bugs.webkit.org/show_bug.cgi?id=170027.
platformThreadSignal uses PlatformThread in JSC, but it can be implemented in
WTF ThreadIdentifier.

* runtime/JSLock.cpp:
(JSC::JSLock::lock):
* runtime/JSLock.h:
(JSC::JSLock::ownerThread):
(JSC::JSLock::currentThreadIsHoldingLock):
* runtime/PlatformThread.h:
(JSC::platformThreadSignal): Deleted.
* runtime/VM.h:
(JSC::VM::ownerThread):
* runtime/VMTraps.cpp:
(JSC::VMTraps::SignalSender::send):

Source/WTF:

* wtf/Threading.h:
* wtf/ThreadingPthreads.cpp:
(WTF::signalThread):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (214488 => 214489)


--- trunk/Source/_javascript_Core/ChangeLog	2017-03-28 20:02:10 UTC (rev 214488)
+++ trunk/Source/_javascript_Core/ChangeLog	2017-03-28 20:08:49 UTC (rev 214489)
@@ -1,3 +1,26 @@
+2017-03-25  Yusuke Suzuki  <utatane....@gmail.com>
+
+        [JSC] Move platformThreadSignal to WTF
+        https://bugs.webkit.org/show_bug.cgi?id=170097
+
+        Reviewed by Mark Lam.
+
+        It is a small clean up towards https://bugs.webkit.org/show_bug.cgi?id=170027.
+        platformThreadSignal uses PlatformThread in JSC, but it can be implemented in
+        WTF ThreadIdentifier.
+
+        * runtime/JSLock.cpp:
+        (JSC::JSLock::lock):
+        * runtime/JSLock.h:
+        (JSC::JSLock::ownerThread):
+        (JSC::JSLock::currentThreadIsHoldingLock):
+        * runtime/PlatformThread.h:
+        (JSC::platformThreadSignal): Deleted.
+        * runtime/VM.h:
+        (JSC::VM::ownerThread):
+        * runtime/VMTraps.cpp:
+        (JSC::VMTraps::SignalSender::send):
+
 2017-03-28  JF Bastien  <jfbast...@apple.com>
 
         WebAssembly: implement Module imports/exports

Modified: trunk/Source/_javascript_Core/runtime/JSLock.cpp (214488 => 214489)


--- trunk/Source/_javascript_Core/runtime/JSLock.cpp	2017-03-28 20:02:10 UTC (rev 214488)
+++ trunk/Source/_javascript_Core/runtime/JSLock.cpp	2017-03-28 20:08:49 UTC (rev 214489)
@@ -109,7 +109,7 @@
         m_lock.lock();
     }
 
-    m_ownerThread = currentPlatformThread();
+    m_ownerThread = currentThread();
     WTF::storeStoreFence();
     m_hasOwnerThread = true;
     ASSERT(!m_lockCount);

Modified: trunk/Source/_javascript_Core/runtime/JSLock.h (214488 => 214489)


--- trunk/Source/_javascript_Core/runtime/JSLock.h	2017-03-28 20:02:10 UTC (rev 214488)
+++ trunk/Source/_javascript_Core/runtime/JSLock.h	2017-03-28 20:08:49 UTC (rev 214489)
@@ -20,7 +20,6 @@
 
 #pragma once
 
-#include "PlatformThread.h"
 #include <mutex>
 #include <wtf/Assertions.h>
 #include <wtf/Lock.h>
@@ -93,13 +92,13 @@
 
     VM* vm() { return m_vm; }
 
-    std::optional<PlatformThread> ownerThread() const
+    std::optional<ThreadIdentifier> ownerThread() const
     {
         if (m_hasOwnerThread)
             return m_ownerThread;
-        return { };
+        return std::nullopt;
     }
-    bool currentThreadIsHoldingLock() { return m_hasOwnerThread && m_ownerThread == currentPlatformThread(); }
+    bool currentThreadIsHoldingLock() { return m_hasOwnerThread && m_ownerThread == currentThread(); }
 
     void willDestroyVM(VM*);
 
@@ -136,7 +135,7 @@
     // different thread, and an optional is vulnerable to races.
     // See https://bugs.webkit.org/show_bug.cgi?id=169042#c6
     bool m_hasOwnerThread { false };
-    PlatformThread m_ownerThread;
+    ThreadIdentifier m_ownerThread;
     intptr_t m_lockCount;
     unsigned m_lockDropDepth;
     bool m_shouldReleaseHeapAccess;

Modified: trunk/Source/_javascript_Core/runtime/PlatformThread.h (214488 => 214489)


--- trunk/Source/_javascript_Core/runtime/PlatformThread.h	2017-03-28 20:02:10 UTC (rev 214488)
+++ trunk/Source/_javascript_Core/runtime/PlatformThread.h	2017-03-28 20:08:49 UTC (rev 214489)
@@ -60,19 +60,4 @@
 #endif
 }
 
-#if OS(DARWIN)
-inline bool platformThreadSignal(PlatformThread platformThread, int signalNumber)
-{
-    pthread_t pthreadID = pthread_from_mach_thread_np(platformThread);
-    int errNo = pthread_kill(pthreadID, signalNumber);
-    return !errNo; // A 0 errNo means success.
-}
-#elif USE(PTHREADS)
-inline bool platformThreadSignal(PlatformThread pthreadID, int signalNumber)
-{
-    int errNo = pthread_kill(pthreadID, signalNumber);
-    return !errNo; // A 0 errNo means success.
-}
-#endif
-
 } // namespace JSC

Modified: trunk/Source/_javascript_Core/runtime/VM.h (214488 => 214489)


--- trunk/Source/_javascript_Core/runtime/VM.h	2017-03-28 20:02:10 UTC (rev 214488)
+++ trunk/Source/_javascript_Core/runtime/VM.h	2017-03-28 20:08:49 UTC (rev 214489)
@@ -673,7 +673,7 @@
     template<typename Func>
     void logEvent(CodeBlock*, const char* summary, const Func& func);
 
-    std::optional<PlatformThread> ownerThread() const { return m_apiLock->ownerThread(); }
+    std::optional<ThreadIdentifier> ownerThread() const { return m_apiLock->ownerThread(); }
 
     VMTraps& traps() { return m_traps; }
 

Modified: trunk/Source/_javascript_Core/runtime/VMTraps.cpp (214488 => 214489)


--- trunk/Source/_javascript_Core/runtime/VMTraps.cpp	2017-03-28 20:02:10 UTC (rev 214488)
+++ trunk/Source/_javascript_Core/runtime/VMTraps.cpp	2017-03-28 20:08:49 UTC (rev 214489)
@@ -455,7 +455,7 @@
             VM& vm = *m_vm;
             auto optionalOwnerThread = vm.ownerThread();
             if (optionalOwnerThread) {
-                platformThreadSignal(optionalOwnerThread.value(), SIGUSR1);
+                signalThread(optionalOwnerThread.value(), SIGUSR1);
                 break;
             }
 

Modified: trunk/Source/WTF/ChangeLog (214488 => 214489)


--- trunk/Source/WTF/ChangeLog	2017-03-28 20:02:10 UTC (rev 214488)
+++ trunk/Source/WTF/ChangeLog	2017-03-28 20:08:49 UTC (rev 214489)
@@ -1,3 +1,14 @@
+2017-03-25  Yusuke Suzuki  <utatane....@gmail.com>
+
+        [JSC] Move platformThreadSignal to WTF
+        https://bugs.webkit.org/show_bug.cgi?id=170097
+
+        Reviewed by Mark Lam.
+
+        * wtf/Threading.h:
+        * wtf/ThreadingPthreads.cpp:
+        (WTF::signalThread):
+
 2017-03-26  Filip Pizlo  <fpi...@apple.com>
 
         B3::fixSSA should do liveness pruning

Modified: trunk/Source/WTF/wtf/Threading.h (214488 => 214489)


--- trunk/Source/WTF/wtf/Threading.h	2017-03-28 20:02:10 UTC (rev 214488)
+++ trunk/Source/WTF/wtf/Threading.h	2017-03-28 20:08:49 UTC (rev 214489)
@@ -79,6 +79,10 @@
 
 const char* normalizeThreadName(const char* threadName);
 
+#if USE(PTHREADS)
+bool signalThread(ThreadIdentifier, int signalNumber);
+#endif
+
 #if HAVE(QOS_CLASSES)
 WTF_EXPORT_PRIVATE void setGlobalMaxQOSClass(qos_class_t);
 WTF_EXPORT_PRIVATE qos_class_t adjustedQOSClass(qos_class_t);
@@ -93,6 +97,10 @@
 using WTF::detachThread;
 using WTF::waitForThreadCompletion;
 
+#if USE(PTHREADS)
+using WTF::signalThread;
+#endif
+
 #if HAVE(QOS_CLASSES)
 using WTF::setGlobalMaxQOSClass;
 using WTF::adjustedQOSClass;

Modified: trunk/Source/WTF/wtf/ThreadingPthreads.cpp (214488 => 214489)


--- trunk/Source/WTF/wtf/ThreadingPthreads.cpp	2017-03-28 20:02:10 UTC (rev 214488)
+++ trunk/Source/WTF/wtf/ThreadingPthreads.cpp	2017-03-28 20:08:49 UTC (rev 214489)
@@ -59,6 +59,10 @@
 #include <sys/prctl.h>
 #endif
 
+#if !OS(DARWIN)
+#include <signal.h>
+#endif
+
 namespace WTF {
 
 class PthreadState {
@@ -307,6 +311,19 @@
     return id;
 }
 
+bool signalThread(ThreadIdentifier threadID, int signalNumber)
+{
+    pthread_t pthreadHandle;
+    ASSERT(threadID);
+    {
+        MutexLocker locker(threadMapMutex());
+        pthreadHandle = pthreadHandleForIdentifierWithLockAlreadyHeld(threadID);
+        ASSERT(pthreadHandle);
+    }
+    int errNo = pthread_kill(pthreadHandle, signalNumber);
+    return !errNo; // A 0 errNo means success.
+}
+
 Mutex::Mutex()
 {
     pthread_mutexattr_t attr;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to