Title: [231404] trunk/Source/WTF
Revision
231404
Author
[email protected]
Date
2018-05-06 22:24:59 -0700 (Sun, 06 May 2018)

Log Message

[WTF] Embed default atomic string table in Thread
https://bugs.webkit.org/show_bug.cgi?id=185349

Reviewed by Darin Adler.

Do not need to allocate AtomicStringTable separate from Thread
since the table's lifetime is completely the same as Thread.

This patch just embeds it as a data member of Thread.

* wtf/Threading.cpp:
(WTF::Thread::initializeInThread):
(WTF::Thread::didExit):
* wtf/Threading.h:
* wtf/text/AtomicStringTable.cpp:
(WTF::AtomicStringTable::create): Deleted.
(WTF::AtomicStringTable::destroy): Deleted.
* wtf/text/AtomicStringTable.h:

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (231403 => 231404)


--- trunk/Source/WTF/ChangeLog	2018-05-07 02:46:40 UTC (rev 231403)
+++ trunk/Source/WTF/ChangeLog	2018-05-07 05:24:59 UTC (rev 231404)
@@ -1,5 +1,26 @@
 2018-05-06  Yusuke Suzuki  <[email protected]>
 
+        [WTF] Embed default atomic string table in Thread
+        https://bugs.webkit.org/show_bug.cgi?id=185349
+
+        Reviewed by Darin Adler.
+
+        Do not need to allocate AtomicStringTable separate from Thread
+        since the table's lifetime is completely the same as Thread.
+
+        This patch just embeds it as a data member of Thread.
+
+        * wtf/Threading.cpp:
+        (WTF::Thread::initializeInThread):
+        (WTF::Thread::didExit):
+        * wtf/Threading.h:
+        * wtf/text/AtomicStringTable.cpp:
+        (WTF::AtomicStringTable::create): Deleted.
+        (WTF::AtomicStringTable::destroy): Deleted.
+        * wtf/text/AtomicStringTable.h:
+
+2018-05-06  Yusuke Suzuki  <[email protected]>
+
         [WTF] Use static initializers for WTF::Mutex and WTF::ThreadCondition
         https://bugs.webkit.org/show_bug.cgi?id=185361
 

Modified: trunk/Source/WTF/wtf/Threading.cpp (231403 => 231404)


--- trunk/Source/WTF/wtf/Threading.cpp	2018-05-07 02:46:40 UTC (rev 231403)
+++ trunk/Source/WTF/wtf/Threading.cpp	2018-05-07 05:24:59 UTC (rev 231404)
@@ -98,8 +98,15 @@
     if (m_stack.isEmpty())
         m_stack = StackBounds::currentThreadStackBounds();
     m_savedLastStackTop = stack().origin();
-    AtomicStringTable::create(*this);
-    m_currentAtomicStringTable = m_defaultAtomicStringTable;
+
+    m_currentAtomicStringTable = &m_defaultAtomicStringTable;
+#if USE(WEB_THREAD)
+    // On iOS, one AtomicStringTable is shared between the main UI thread and the WebThread.
+    if (isWebThread() || isUIThread()) {
+        static NeverDestroyed<AtomicStringTable> sharedStringTable;
+        m_currentAtomicStringTable = &sharedStringTable.get();
+    }
+#endif
 }
 
 void Thread::entryPoint(NewThreadContext* newThreadContext)
@@ -196,8 +203,6 @@
         }
     }
 
-    AtomicStringTable::destroy(m_defaultAtomicStringTable);
-
     // We would like to say "thread is exited" after unregistering threads from thread groups.
     // So we need to separate m_isShuttingDown from m_didExit.
     auto locker = holdLock(m_mutex);

Modified: trunk/Source/WTF/wtf/Threading.h (231403 => 231404)


--- trunk/Source/WTF/wtf/Threading.h	2018-05-07 02:46:40 UTC (rev 231403)
+++ trunk/Source/WTF/wtf/Threading.h	2018-05-07 05:24:59 UTC (rev 231404)
@@ -46,6 +46,7 @@
 #include <wtf/ThreadSpecific.h>
 #include <wtf/Vector.h>
 #include <wtf/WordLock.h>
+#include <wtf/text/AtomicStringTable.h>
 
 #if USE(PTHREADS) && !OS(DARWIN)
 #include <signal.h>
@@ -54,7 +55,6 @@
 namespace WTF {
 
 class AbstractLocker;
-class AtomicStringTable;
 class ThreadMessageData;
 
 enum class ThreadGroupAddResult;
@@ -77,7 +77,6 @@
 class Thread : public ThreadSafeRefCounted<Thread> {
 public:
     friend class ThreadGroup;
-    friend class AtomicStringTable;
     friend WTF_EXPORT_PRIVATE void initializeThreading();
 #if OS(WINDOWS)
     friend WTF_EXPORT_PRIVATE int waitForThreadCompletion(ThreadIdentifier);
@@ -290,7 +289,7 @@
 #endif
 
     AtomicStringTable* m_currentAtomicStringTable { nullptr };
-    AtomicStringTable* m_defaultAtomicStringTable { nullptr };
+    AtomicStringTable m_defaultAtomicStringTable;
 
 #if ENABLE(STACK_STATS)
     StackStats::PerThreadStats m_stackStats;

Modified: trunk/Source/WTF/wtf/text/AtomicStringTable.cpp (231403 => 231404)


--- trunk/Source/WTF/wtf/text/AtomicStringTable.cpp	2018-05-07 02:46:40 UTC (rev 231403)
+++ trunk/Source/WTF/wtf/text/AtomicStringTable.cpp	2018-05-07 05:24:59 UTC (rev 231404)
@@ -29,20 +29,6 @@
 
 namespace WTF {
 
-void AtomicStringTable::create(Thread& thread)
-{
-#if USE(WEB_THREAD)
-    // On iOS, one AtomicStringTable is shared between the main UI thread and the WebThread.
-    static AtomicStringTable* sharedStringTable = new AtomicStringTable;
-
-    if (isWebThread() || isUIThread()) {
-        thread.m_defaultAtomicStringTable = sharedStringTable;
-        return;
-    }
-#endif // USE(WEB_THREAD)
-    thread.m_defaultAtomicStringTable = new AtomicStringTable;
-}
-
 AtomicStringTable::~AtomicStringTable()
 {
     for (auto* string : m_table)
@@ -49,15 +35,4 @@
         string->setIsAtomic(false);
 }
 
-void AtomicStringTable::destroy(AtomicStringTable* table)
-{
-#if USE(WEB_THREAD)
-    // We do the following so that destruction of default atomic string table happens only
-    // once - on the main UI thread.
-    if (isWebThread())
-        return;
-#endif // USE(WEB_THREAD)
-    delete table;
 }
-
-}

Modified: trunk/Source/WTF/wtf/text/AtomicStringTable.h (231403 => 231404)


--- trunk/Source/WTF/wtf/text/AtomicStringTable.h	2018-05-07 02:46:40 UTC (rev 231403)
+++ trunk/Source/WTF/wtf/text/AtomicStringTable.h	2018-05-07 05:24:59 UTC (rev 231404)
@@ -29,7 +29,6 @@
 namespace WTF {
 
 class StringImpl;
-class Thread;
 
 class AtomicStringTable {
     WTF_MAKE_FAST_ALLOCATED;
@@ -36,8 +35,6 @@
 public:
     WTF_EXPORT_PRIVATE ~AtomicStringTable();
 
-    static void create(Thread&);
-    static void destroy(AtomicStringTable*);
     HashSet<StringImpl*>& table() { return m_table; }
 
 private:
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to