WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Enables WTF_MULTIPLE_THREADS in chromium port
61017.patch (text/plain), 8.09 KB, created by
Dmitry Lomov
on 2011-07-27 14:44:01 PDT
(
hide
)
Description:
Enables WTF_MULTIPLE_THREADS in chromium port
Filename:
MIME Type:
Creator:
Dmitry Lomov
Created:
2011-07-27 14:44:01 PDT
Size:
8.09 KB
patch
obsolete
>diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog >index 6b3a9cb..bbcf68a 100644 >--- a/Source/JavaScriptCore/ChangeLog >+++ b/Source/JavaScriptCore/ChangeLog >@@ -1,3 +1,27 @@ >+2011-07-27 Dmitry Lomov <dslomov@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. >+ >+ * 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 Shinya Kawanaka <shinyak@google.com> > > Added an interface to take IsWhiteSpaceFunctionPtr. >diff --git a/Source/JavaScriptCore/runtime/InitializeThreading.cpp b/Source/JavaScriptCore/runtime/InitializeThreading.cpp >index 27611b7..912727c 100644 >--- a/Source/JavaScriptCore/runtime/InitializeThreading.cpp >+++ b/Source/JavaScriptCore/runtime/InitializeThreading.cpp >@@ -56,7 +56,6 @@ static void initializeThreadingOnce() > wtfThreadData(); > JSGlobalData::storeVPtrs(); > #if ENABLE(JSC_MULTIPLE_THREADS) >- s_dtoaP5Mutex = new Mutex; > initializeDates(); > RegisterFile::initializeThreading(); > #endif >diff --git a/Source/JavaScriptCore/wtf/FastMalloc.cpp b/Source/JavaScriptCore/wtf/FastMalloc.cpp >index 9c7a65a..6a1584b 100644 >--- a/Source/JavaScriptCore/wtf/FastMalloc.cpp >+++ b/Source/JavaScriptCore/wtf/FastMalloc.cpp >@@ -71,7 +71,7 @@ > // > // 9/28/2003 (new page-level allocator replaces ptmalloc2): > // * malloc/free of small objects goes from ~300 ns to ~50 ns. >-// * allocation of a reasonably complicated struct >+// * allocation of a reasonably complicated sfEtruct > // goes from about 1100 ns to about 300 ns. > > #include "config.h" >@@ -80,7 +80,11 @@ > #include "Assertions.h" > #include <limits> > #if ENABLE(WTF_MULTIPLE_THREADS) >+#if OS(WINDOWS) >+#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) >+ >+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) >+ > static pthread_key_t isForbiddenKey; > static pthread_once_t isForbiddenKeyOnce = PTHREAD_ONCE_INIT; > static void initializeIsForbiddenKey() >@@ -129,7 +165,7 @@ void fastMallocAllow() > pthread_once(&isForbiddenKeyOnce, initializeIsForbiddenKey); > pthread_setspecific(isForbiddenKey, 0); > } >- >+#endif // OS(WINDOWS) > #else > > static bool staticIsForbidden; >diff --git a/Source/JavaScriptCore/wtf/Platform.h b/Source/JavaScriptCore/wtf/Platform.h >index 2b56e0a..cf16921 100644 >--- a/Source/JavaScriptCore/wtf/Platform.h >+++ b/Source/JavaScriptCore/wtf/Platform.h >@@ -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 > >diff --git a/Source/JavaScriptCore/wtf/ThreadingPthreads.cpp b/Source/JavaScriptCore/wtf/ThreadingPthreads.cpp >index 916aa36..a802f17 100644 >--- a/Source/JavaScriptCore/wtf/ThreadingPthreads.cpp >+++ b/Source/JavaScriptCore/wtf/ThreadingPthreads.cpp >@@ -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" >@@ -78,9 +80,16 @@ void initializeThreading() > 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(); >+#if ENABLE(WTF_MULTIPLE_THREADS) >+ s_dtoaP5Mutex = new Mutex; >+ initializeDates(); >+#endif > } > > void lockAtomicallyInitializedStaticMutex() >diff --git a/Source/JavaScriptCore/wtf/ThreadingWin.cpp b/Source/JavaScriptCore/wtf/ThreadingWin.cpp >index c452205..6e8ae78 100644 >--- a/Source/JavaScriptCore/wtf/ThreadingWin.cpp >+++ b/Source/JavaScriptCore/wtf/ThreadingWin.cpp >@@ -85,6 +85,8 @@ > > #include "config.h" > #include "Threading.h" >+#include "DateMath.h" >+#include "dtoa.h" > > #include "MainThread.h" > #include "ThreadFunctionInvocation.h" >@@ -160,9 +162,17 @@ void initializeThreading() > 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(); >+#if ENABLE(WTF_MULTIPLE_THREADS) >+ s_dtoaP5Mutex = new Mutex; >+ initializeDates(); >+#endif >+ > } > > static HashMap<DWORD, HANDLE>& threadMap() >diff --git a/Source/JavaScriptCore/wtf/gtk/ThreadingGtk.cpp b/Source/JavaScriptCore/wtf/gtk/ThreadingGtk.cpp >index 863ee81..872cdfa 100644 >--- a/Source/JavaScriptCore/wtf/gtk/ThreadingGtk.cpp >+++ b/Source/JavaScriptCore/wtf/gtk/ThreadingGtk.cpp >@@ -33,6 +33,8 @@ > #if !USE(PTHREADS) > > #include "CurrentTime.h" >+#include "DateMap.h" >+#include "dtoa.h" > #include "HashMap.h" > #include "MainThread.h" > #include "RandomNumberSeed.h" >@@ -60,9 +62,16 @@ void initializeThreading() > 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(); >+#if ENABLE(WTF_MULTIPLE_THREADS) >+ s_dtoaP5Mutex = new Mutex; >+ initializeDates(); >+#endif > } > } > >diff --git a/Source/JavaScriptCore/wtf/qt/ThreadingQt.cpp b/Source/JavaScriptCore/wtf/qt/ThreadingQt.cpp >index 8041dea..e4c926b 100644 >--- a/Source/JavaScriptCore/wtf/qt/ThreadingQt.cpp >+++ b/Source/JavaScriptCore/wtf/qt/ThreadingQt.cpp >@@ -31,6 +31,8 @@ > > #if !ENABLE(SINGLE_THREADED) > >+#include "DateMath.h" >+#include "dtoa.h" > #include "CurrentTime.h" > #include "HashMap.h" > #include "MainThread.h" >@@ -141,9 +143,17 @@ static QThread* threadForIdentifier(ThreadIdentifier id) > 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(); >+#if ENABLE(WTF_MULTIPLE_THREADS) >+ s_dtoaP5Mutex = new Mutex; >+ initializeDates(); >+#endif >+ > } > } >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
levin
:
review-
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 61017
:
101776
|
102186
|
102204
|
102205