AutomaticThread should have a way to provide a thread name
authorkeith_miller@apple.com <keith_miller@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 13 Jun 2018 19:07:22 +0000 (19:07 +0000)
committerkeith_miller@apple.com <keith_miller@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 13 Jun 2018 19:07:22 +0000 (19:07 +0000)
https://bugs.webkit.org/show_bug.cgi?id=186604

Reviewed by Filip Pizlo.

Source/JavaScriptCore:

Add names for JSC's automatic threads.

* dfg/DFGWorklist.cpp:
* heap/Heap.cpp:
* jit/JITWorklist.cpp:
* runtime/VMTraps.cpp:
* wasm/WasmWorklist.cpp:

Source/WTF:

AutomaticThread now has a virtual method to get a name, which can be
overridden to provide a custom name to the thread.

* wtf/AutomaticThread.cpp:
(WTF::AutomaticThread::start):
* wtf/AutomaticThread.h:
* wtf/WorkerPool.cpp:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@232801 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/dfg/DFGWorklist.cpp
Source/JavaScriptCore/heap/Heap.cpp
Source/JavaScriptCore/jit/JITWorklist.cpp
Source/JavaScriptCore/runtime/VMTraps.cpp
Source/JavaScriptCore/wasm/WasmWorklist.cpp
Source/WTF/ChangeLog
Source/WTF/wtf/AutomaticThread.cpp
Source/WTF/wtf/AutomaticThread.h
Source/WTF/wtf/WorkerPool.cpp

index 0c61c95..206fcc3 100644 (file)
@@ -1,3 +1,18 @@
+2018-06-13  Keith Miller  <keith_miller@apple.com>
+
+        AutomaticThread should have a way to provide a thread name
+        https://bugs.webkit.org/show_bug.cgi?id=186604
+
+        Reviewed by Filip Pizlo.
+
+        Add names for JSC's automatic threads.
+
+        * dfg/DFGWorklist.cpp:
+        * heap/Heap.cpp:
+        * jit/JITWorklist.cpp:
+        * runtime/VMTraps.cpp:
+        * wasm/WasmWorklist.cpp:
+
 2018-06-13  Saam Barati  <sbarati@apple.com>
 
         CFGSimplificationPhase should de-dupe jettisonedBlocks
index 685f042..5bc88c4 100644 (file)
@@ -46,7 +46,12 @@ public:
         , m_relativePriority(relativePriority)
     {
     }
-    
+
+    const char* name() const override
+    {
+        return m_worklist.m_threadName.data();
+    }
+
 protected:
     PollResult poll(const AbstractLocker& locker) override
     {
@@ -160,7 +165,7 @@ protected:
         m_compilationScope = nullptr;
         m_plan = nullptr;
     }
-    
+
 private:
     Worklist& m_worklist;
     ThreadData& m_data;
index 63d8001..88e12db 100644 (file)
@@ -238,6 +238,11 @@ public:
         , m_heap(heap)
     {
     }
+
+    const char* name() const override
+    {
+        return "JSC Heap Collector Thread";
+    }
     
 protected:
     PollResult poll(const AbstractLocker& locker) override
index f534910..0b32e1f 100644 (file)
@@ -105,6 +105,11 @@ public:
     {
         m_worklist.m_numAvailableThreads++;
     }
+
+    const char* name() const override
+    {
+        return "JIT Worklist Helper Thread";
+    }
     
 protected:
     PollResult poll(const AbstractLocker&) override
index e6e848f..6c14c0a 100644 (file)
@@ -220,6 +220,11 @@ public:
         });
     }
 
+    const char* name() const override
+    {
+        return "JSC VMTraps Signal Sender Thread";
+    }
+
     VMTraps& traps() { return m_vm.traps(); }
 
 protected:
index 2fe132c..6b32533 100644 (file)
@@ -117,6 +117,11 @@ protected:
         return complete(holdLock(*worklist.m_lock));
     }
 
+    const char* name() const override
+    {
+        return "Wasm Worklist Helper Thread";
+    }
+
 public:
     Condition synchronize;
     Worklist& worklist;
index c2c83cf..4f1c316 100644 (file)
@@ -1,3 +1,18 @@
+2018-06-13  Keith Miller  <keith_miller@apple.com>
+
+        AutomaticThread should have a way to provide a thread name
+        https://bugs.webkit.org/show_bug.cgi?id=186604
+
+        Reviewed by Filip Pizlo.
+
+        AutomaticThread now has a virtual method to get a name, which can be
+        overridden to provide a custom name to the thread.
+
+        * wtf/AutomaticThread.cpp:
+        (WTF::AutomaticThread::start):
+        * wtf/AutomaticThread.h:
+        * wtf/WorkerPool.cpp:
+
 2018-06-11  Saam Barati  <sbarati@apple.com>
 
         The NaturalLoops algorithm only works when the list of blocks in a loop is de-duplicated
index a59c5d1..f1156ac 100644 (file)
@@ -163,7 +163,7 @@ void AutomaticThread::start(const AbstractLocker&)
     m_hasUnderlyingThread = true;
     
     Thread::create(
-        "WTF::AutomaticThread",
+        name(),
         [=] () {
             if (verbose)
                 dataLog(RawPointer(this), ": Running automatic thread!\n");
index 0054524..387fd8f 100644 (file)
@@ -125,7 +125,9 @@ public:
     bool notify(const AbstractLocker&);
 
     void join();
-    
+
+    virtual const char* name() const { return "WTF::AutomaticThread"; }
+
 protected:
     // This logically creates the thread, but in reality the thread won't be created until someone
     // calls AutomaticThreadCondition::notifyOne() or notifyAll().
index b879076..3ccb7a2 100644 (file)
@@ -73,6 +73,11 @@ public:
         return m_pool.shouldSleep(locker);
     }
 
+    const char* name() const override
+    {
+        return "Worker Pool";
+    }
+
 private:
     WorkerPool& m_pool;
     Function<void()> m_task;