Title: [91906] trunk/Source/_javascript_Core
Revision
91906
Author
dslo...@google.com
Date
2011-07-27 22:16:23 -0700 (Wed, 27 Jul 2011)

Log Message

[chromium] Turn on WTF_MULTIPLE_THREADS.
https://bugs.webkit.org/show_bug.cgi?id=61017
The patch turns on WTF_MULTIPLE_THREADS in chromium and
pushes some relevant initializations from JSC::initializeThreading
to WTF::initializeThreading.

Reviewed by David Levin.

* runtime/InitializeThreading.cpp:
(JSC::initializeThreadingOnce):
* wtf/FastMalloc.cpp:
(WTF::isForbidden):
(WTF::fastMallocForbid):
(WTF::fastMallocAllow):
* wtf/Platform.h:
* wtf/ThreadingPthreads.cpp:
(WTF::initializeThreading):
* wtf/ThreadingWin.cpp:
(WTF::initializeThreading):
* wtf/gtk/ThreadingGtk.cpp:
(WTF::initializeThreading):
* wtf/qt/ThreadingQt.cpp:
(WTF::initializeThreading):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (91905 => 91906)


--- trunk/Source/_javascript_Core/ChangeLog	2011-07-28 05:11:46 UTC (rev 91905)
+++ trunk/Source/_javascript_Core/ChangeLog	2011-07-28 05:16:23 UTC (rev 91906)
@@ -1,3 +1,29 @@
+2011-07-27  Dmitry Lomov  <dslo...@google.com>
+
+        [chromium] Turn on WTF_MULTIPLE_THREADS.
+        https://bugs.webkit.org/show_bug.cgi?id=61017
+        The patch turns on WTF_MULTIPLE_THREADS in chromium and 
+        pushes some relevant initializations from JSC::initializeThreading
+        to WTF::initializeThreading.
+
+        Reviewed by David Levin.
+
+        * runtime/InitializeThreading.cpp:
+        (JSC::initializeThreadingOnce):
+        * wtf/FastMalloc.cpp:
+        (WTF::isForbidden):
+        (WTF::fastMallocForbid):
+        (WTF::fastMallocAllow):
+        * wtf/Platform.h:
+        * wtf/ThreadingPthreads.cpp:
+        (WTF::initializeThreading):
+        * wtf/ThreadingWin.cpp:
+        (WTF::initializeThreading):
+        * wtf/gtk/ThreadingGtk.cpp:
+        (WTF::initializeThreading):
+        * wtf/qt/ThreadingQt.cpp:
+        (WTF::initializeThreading):
+
 2011-07-27  Mark Hahnenberg  <mhahnenb...@apple.com>
 
         Remove operator new from JSCell

Modified: trunk/Source/_javascript_Core/runtime/InitializeThreading.cpp (91905 => 91906)


--- trunk/Source/_javascript_Core/runtime/InitializeThreading.cpp	2011-07-28 05:11:46 UTC (rev 91905)
+++ trunk/Source/_javascript_Core/runtime/InitializeThreading.cpp	2011-07-28 05:16:23 UTC (rev 91906)
@@ -36,7 +36,6 @@
 #include "UString.h"
 #include <wtf/DateMath.h>
 #include <wtf/Threading.h>
-#include <wtf/WTFThreadData.h>
 
 using namespace WTF;
 
@@ -48,16 +47,9 @@
 
 static void initializeThreadingOnce()
 {
-    // StringImpl::empty() does not construct its static string in a threadsafe fashion,
-    // so ensure it has been initialized from here.
-    StringImpl::empty();
-
     WTF::initializeThreading();
-    wtfThreadData();
     JSGlobalData::storeVPtrs();
 #if ENABLE(JSC_MULTIPLE_THREADS)
-    s_dtoaP5Mutex = new Mutex;
-    initializeDates();
     RegisterFile::initializeThreading();
 #endif
 }

Modified: trunk/Source/_javascript_Core/wtf/FastMalloc.cpp (91905 => 91906)


--- trunk/Source/_javascript_Core/wtf/FastMalloc.cpp	2011-07-28 05:11:46 UTC (rev 91905)
+++ trunk/Source/_javascript_Core/wtf/FastMalloc.cpp	2011-07-28 05:16:23 UTC (rev 91906)
@@ -80,7 +80,11 @@
 #include "Assertions.h"
 #include <limits>
 #if ENABLE(WTF_MULTIPLE_THREADS)
+#if OS(WINDOWS) && PLATFORM(CHROMIUM)
+#include <windows.h>
+#else
 #include <pthread.h>
+#endif // OS(WINDOWS)
 #endif
 #include <wtf/StdLibExtras.h>
 
@@ -103,6 +107,38 @@
 namespace WTF {
 
 #if ENABLE(WTF_MULTIPLE_THREADS)
+#if OS(WINDOWS) && PLATFORM(CHROMIUM)
+
+static DWORD isForibiddenTlsIndex = TLS_OUT_OF_INDEXES;
+static const LPVOID kTlsAllowValue = reinterpret_cast<LPVOID>(0); // Must be zero.
+static const LPVOID kTlsForbiddenValue = reinterpret_cast<LPVOID>(1);
+
+#if !ASSERT_DISABLED
+static bool isForbidden()
+{
+    // By default, fastMalloc is allowed so we don't allocate the
+    // tls index unless we're asked to make it forbidden. If TlsSetValue
+    // has not been called on a thread, the value returned by TlsGetValue is 0.
+    return (isForibiddenTlsIndex != TLS_OUT_OF_INDEXES) && (TlsGetValue(isForibiddenTlsIndex) == kTlsForbiddenValue);
+}
+#endif
+
+void fastMallocForbid()
+{
+    if (isForibiddenTlsIndex == TLS_OUT_OF_INDEXES)
+        isForibiddenTlsIndex = TlsAlloc(); // a little racey, but close enough for debug only
+    TlsSetValue(isForibiddenTlsIndex, kTlsForbiddenValue);
+}
+
+void fastMallocAllow()
+{
+    if (isForibiddenTlsIndex == TLS_OUT_OF_INDEXES)
+        return;
+    TlsSetValue(isForibiddenTlsIndex, kTlsAllowValue);
+}
+
+#else // !OS(WINDOWS) || !PLATFORM(CHROMIUM)
+
 static pthread_key_t isForbiddenKey;
 static pthread_once_t isForbiddenKeyOnce = PTHREAD_ONCE_INIT;
 static void initializeIsForbiddenKey()
@@ -129,7 +165,7 @@
     pthread_once(&isForbiddenKeyOnce, initializeIsForbiddenKey);
     pthread_setspecific(isForbiddenKey, 0);
 }
-
+#endif // OS(WINDOWS) && PLATFORM(CHROMIUM)
 #else
 
 static bool staticIsForbidden;

Modified: trunk/Source/_javascript_Core/wtf/Platform.h (91905 => 91906)


--- trunk/Source/_javascript_Core/wtf/Platform.h	2011-07-28 05:11:46 UTC (rev 91905)
+++ trunk/Source/_javascript_Core/wtf/Platform.h	2011-07-28 05:16:23 UTC (rev 91906)
@@ -582,7 +582,7 @@
 #define ENABLE_JSC_MULTIPLE_THREADS 1
 #endif
 
-#if ENABLE(JSC_MULTIPLE_THREADS)
+#if ENABLE(JSC_MULTIPLE_THREADS) || PLATFORM(CHROMIUM)
 #define ENABLE_WTF_MULTIPLE_THREADS 1
 #endif
 

Modified: trunk/Source/_javascript_Core/wtf/ThreadingPthreads.cpp (91905 => 91906)


--- trunk/Source/_javascript_Core/wtf/ThreadingPthreads.cpp	2011-07-28 05:11:46 UTC (rev 91905)
+++ trunk/Source/_javascript_Core/wtf/ThreadingPthreads.cpp	2011-07-28 05:16:23 UTC (rev 91906)
@@ -33,6 +33,8 @@
 #if USE(PTHREADS)
 
 #include "CurrentTime.h"
+#include "DateMath.h"
+#include "dtoa.h"
 #include "HashMap.h"
 #include "MainThread.h"
 #include "RandomNumberSeed.h"
@@ -40,6 +42,7 @@
 #include "ThreadIdentifierDataPthreads.h"
 #include "ThreadSpecific.h"
 #include "UnusedParam.h"
+#include <wtf/WTFThreadData.h>
 #include <errno.h>
 
 #if !COMPILER(MSVC)
@@ -78,9 +81,17 @@
     if (atomicallyInitializedStaticMutex)
         return;
 
+    // StringImpl::empty() does not construct its static string in a threadsafe fashion,
+    // so ensure it has been initialized from here.
+    StringImpl::empty();
     atomicallyInitializedStaticMutex = new Mutex;
     threadMapMutex();
     initializeRandomNumberGenerator();
+    wtfThreadData();
+#if ENABLE(WTF_MULTIPLE_THREADS)
+    s_dtoaP5Mutex = new Mutex;
+    initializeDates();
+#endif
 }
 
 void lockAtomicallyInitializedStaticMutex()

Modified: trunk/Source/_javascript_Core/wtf/ThreadingWin.cpp (91905 => 91906)


--- trunk/Source/_javascript_Core/wtf/ThreadingWin.cpp	2011-07-28 05:11:46 UTC (rev 91905)
+++ trunk/Source/_javascript_Core/wtf/ThreadingWin.cpp	2011-07-28 05:16:23 UTC (rev 91906)
@@ -85,6 +85,8 @@
 
 #include "config.h"
 #include "Threading.h"
+#include "DateMath.h"
+#include "dtoa.h"
 
 #include "MainThread.h"
 #include "ThreadFunctionInvocation.h"
@@ -95,6 +97,7 @@
 #include <wtf/OwnPtr.h>
 #include <wtf/PassOwnPtr.h>
 #include <wtf/RandomNumberSeed.h>
+#include <wtf/WTFThreadData.h>
 
 #if !USE(PTHREADS) && OS(WINDOWS)
 #include "ThreadSpecific.h"
@@ -160,9 +163,18 @@
     if (atomicallyInitializedStaticMutex)
         return;
 
+    // StringImpl::empty() does not construct its static string in a threadsafe fashion,
+    // so ensure it has been initialized from here.
+    StringImpl::empty();
     atomicallyInitializedStaticMutex = new Mutex;
     threadMapMutex();
     initializeRandomNumberGenerator();
+    wtfThreadData();
+#if ENABLE(WTF_MULTIPLE_THREADS)
+    s_dtoaP5Mutex = new Mutex;
+    initializeDates();
+#endif
+
 }
 
 static HashMap<DWORD, HANDLE>& threadMap()

Modified: trunk/Source/_javascript_Core/wtf/gtk/ThreadingGtk.cpp (91905 => 91906)


--- trunk/Source/_javascript_Core/wtf/gtk/ThreadingGtk.cpp	2011-07-28 05:11:46 UTC (rev 91905)
+++ trunk/Source/_javascript_Core/wtf/gtk/ThreadingGtk.cpp	2011-07-28 05:16:23 UTC (rev 91906)
@@ -33,10 +33,13 @@
 #if !USE(PTHREADS)
 
 #include "CurrentTime.h"
+#include "DateMap.h"
+#include "dtoa.h"
 #include "HashMap.h"
 #include "MainThread.h"
 #include "RandomNumberSeed.h"
 #include <wtf/StdLibExtras.h>
+#include <wtf/WTFThreadData.h>
 
 #include <glib.h>
 #include <limits.h>
@@ -60,9 +63,17 @@
     ASSERT(g_thread_supported());
 
     if (!atomicallyInitializedStaticMutex) {
+        // StringImpl::empty() does not construct its static string in a threadsafe fashion,
+        // so ensure it has been initialized from here.
+        StringImpl::empty();
         atomicallyInitializedStaticMutex = new Mutex;
         threadMapMutex();
         initializeRandomNumberGenerator();
+        wtfThreadData();
+#if ENABLE(WTF_MULTIPLE_THREADS)
+        s_dtoaP5Mutex = new Mutex;
+        initializeDates();
+#endif
     }
 }
 

Modified: trunk/Source/_javascript_Core/wtf/qt/ThreadingQt.cpp (91905 => 91906)


--- trunk/Source/_javascript_Core/wtf/qt/ThreadingQt.cpp	2011-07-28 05:11:46 UTC (rev 91905)
+++ trunk/Source/_javascript_Core/wtf/qt/ThreadingQt.cpp	2011-07-28 05:16:23 UTC (rev 91906)
@@ -31,10 +31,13 @@
 
 #if !ENABLE(SINGLE_THREADED)
 
+#include "DateMath.h"
+#include "dtoa.h"
 #include "CurrentTime.h"
 #include "HashMap.h"
 #include "MainThread.h"
 #include "RandomNumberSeed.h"
+#include <wtf/WTFThreadData.h>
 
 #include <QCoreApplication>
 #include <QMutex>
@@ -141,9 +144,18 @@
 void initializeThreading()
 {
     if (!atomicallyInitializedStaticMutex) {
+        // StringImpl::empty() does not construct its static string in a threadsafe fashion,
+        // so ensure it has been initialized from here.
+        StringImpl::empty();
         atomicallyInitializedStaticMutex = new Mutex;
         threadMapMutex();
         initializeRandomNumberGenerator();
+        wtfThreadData();
+#if ENABLE(WTF_MULTIPLE_THREADS)
+        s_dtoaP5Mutex = new Mutex;
+        initializeDates();
+#endif
+
     }
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to