Diff
Modified: trunk/LayoutTests/ChangeLog (199728 => 199729)
--- trunk/LayoutTests/ChangeLog 2016-04-19 15:48:00 UTC (rev 199728)
+++ trunk/LayoutTests/ChangeLog 2016-04-19 16:29:54 UTC (rev 199729)
@@ -1,3 +1,17 @@
+2016-04-19 Commit Queue <[email protected]>
+
+ Unreviewed, rolling out r199726.
+ https://bugs.webkit.org/show_bug.cgi?id=156748
+
+ WebKit tests crash on Windows 32 (Requested by msaboff on
+ #webkit).
+
+ Reverted changeset:
+
+ "iTunes crashing _javascript_Core.dll"
+ https://bugs.webkit.org/show_bug.cgi?id=156647
+ http://trac.webkit.org/changeset/199726
+
2016-04-19 Sergio Villar Senin <[email protected]>
[css-grid] Use the margin box for non-auto minimum sizes
Modified: trunk/LayoutTests/platform/win/TestExpectations (199728 => 199729)
--- trunk/LayoutTests/platform/win/TestExpectations 2016-04-19 15:48:00 UTC (rev 199728)
+++ trunk/LayoutTests/platform/win/TestExpectations 2016-04-19 16:29:54 UTC (rev 199729)
@@ -437,10 +437,6 @@
storage/storagequota-request-quota.html [ Skip ]
fast/workers/worker-storagequota-query-usage.html [ Skip ]
-# The number of workers in this test exceeds the number of
-# ThreadSpecificValues we have on Windows.
-fast/workers/dedicated-worker-lifecycle.html [ Skip ]
-
# Tests that require ENABLE(DOWNLOAD_ATTRIBUTE).
fast/dom/HTMLAnchorElement/anchor-nodownload.html [ Skip ]
fast/dom/HTMLAnchorElement/anchor-download.html [ Skip ]
Modified: trunk/Source/_javascript_Core/ChangeLog (199728 => 199729)
--- trunk/Source/_javascript_Core/ChangeLog 2016-04-19 15:48:00 UTC (rev 199728)
+++ trunk/Source/_javascript_Core/ChangeLog 2016-04-19 16:29:54 UTC (rev 199729)
@@ -1,3 +1,17 @@
+2016-04-19 Commit Queue <[email protected]>
+
+ Unreviewed, rolling out r199726.
+ https://bugs.webkit.org/show_bug.cgi?id=156748
+
+ WebKit tests crash on Windows 32 (Requested by msaboff on
+ #webkit).
+
+ Reverted changeset:
+
+ "iTunes crashing _javascript_Core.dll"
+ https://bugs.webkit.org/show_bug.cgi?id=156647
+ http://trac.webkit.org/changeset/199726
+
2016-04-19 Michael Saboff <[email protected]>
iTunes crashing _javascript_Core.dll
Modified: trunk/Source/_javascript_Core/heap/MachineStackMarker.cpp (199728 => 199729)
--- trunk/Source/_javascript_Core/heap/MachineStackMarker.cpp 2016-04-19 15:48:00 UTC (rev 199728)
+++ trunk/Source/_javascript_Core/heap/MachineStackMarker.cpp 2016-04-19 16:29:54 UTC (rev 199729)
@@ -192,12 +192,14 @@
MachineThreads::MachineThreads(Heap* heap)
: m_registeredThreads(0)
, m_threadSpecificForMachineThreads(0)
+ , m_threadSpecificForThread(0)
#if !ASSERT_DISABLED
, m_heap(heap)
#endif
{
UNUSED_PARAM(heap);
threadSpecificKeyCreate(&m_threadSpecificForMachineThreads, removeThread);
+ threadSpecificKeyCreate(&m_threadSpecificForThread, nullptr);
activeMachineThreadsManager().add(this);
}
@@ -205,6 +207,7 @@
{
activeMachineThreadsManager().remove(this);
threadSpecificKeyDelete(m_threadSpecificForMachineThreads);
+ threadSpecificKeyDelete(m_threadSpecificForThread);
LockHolder registeredThreadsLock(m_registeredThreadsMutex);
for (Thread* t = m_registeredThreads; t;) {
@@ -231,6 +234,18 @@
#endif
}
+#ifndef NDEBUG
+static bool isThreadInList(Thread* listHead, Thread* target)
+{
+ for (Thread* thread = listHead; thread; thread = thread->next) {
+ if (thread == target)
+ return true;
+ }
+
+ return false;
+}
+#endif
+
void MachineThreads::addCurrentThread()
{
ASSERT(!m_heap->vm()->hasExclusiveThread() || m_heap->vm()->exclusiveThread() == std::this_thread::get_id());
@@ -239,12 +254,15 @@
#ifndef NDEBUG
LockHolder lock(m_registeredThreadsMutex);
ASSERT(threadSpecificGet(m_threadSpecificForMachineThreads) == this);
+ ASSERT(threadSpecificGet(m_threadSpecificForThread));
+ ASSERT(isThreadInList(m_registeredThreads, static_cast<Thread*>(threadSpecificGet(m_threadSpecificForThread))));
#endif
return;
}
Thread* thread = Thread::createForCurrentThread();
threadSpecificSet(m_threadSpecificForMachineThreads, this);
+ threadSpecificSet(m_threadSpecificForThread, thread);
LockHolder lock(m_registeredThreadsMutex);
@@ -254,15 +272,14 @@
Thread* MachineThreads::machineThreadForCurrentThread()
{
+ Thread* result = static_cast<Thread*>(threadSpecificGet(m_threadSpecificForThread));
+ RELEASE_ASSERT(result);
+#ifndef NDEBUG
LockHolder lock(m_registeredThreadsMutex);
- PlatformThread platformThread = getCurrentPlatformThread();
- for (Thread* thread = m_registeredThreads; thread; thread = thread->next) {
- if (*thread == platformThread)
- return thread;
- }
+ ASSERT(isThreadInList(m_registeredThreads, result));
+#endif
- RELEASE_ASSERT_NOT_REACHED();
- return nullptr;
+ return result;
}
void MachineThreads::removeThread(void* p)
Modified: trunk/Source/_javascript_Core/heap/MachineStackMarker.h (199728 => 199729)
--- trunk/Source/_javascript_Core/heap/MachineStackMarker.h 2016-04-19 15:48:00 UTC (rev 199728)
+++ trunk/Source/_javascript_Core/heap/MachineStackMarker.h 2016-04-19 16:29:54 UTC (rev 199729)
@@ -159,6 +159,7 @@
Lock m_registeredThreadsMutex;
Thread* m_registeredThreads;
WTF::ThreadSpecificKey m_threadSpecificForMachineThreads;
+ WTF::ThreadSpecificKey m_threadSpecificForThread;
#if !ASSERT_DISABLED
Heap* m_heap;
#endif
Modified: trunk/Source/WTF/ChangeLog (199728 => 199729)
--- trunk/Source/WTF/ChangeLog 2016-04-19 15:48:00 UTC (rev 199728)
+++ trunk/Source/WTF/ChangeLog 2016-04-19 16:29:54 UTC (rev 199729)
@@ -1,3 +1,17 @@
+2016-04-19 Commit Queue <[email protected]>
+
+ Unreviewed, rolling out r199726.
+ https://bugs.webkit.org/show_bug.cgi?id=156748
+
+ WebKit tests crash on Windows 32 (Requested by msaboff on
+ #webkit).
+
+ Reverted changeset:
+
+ "iTunes crashing _javascript_Core.dll"
+ https://bugs.webkit.org/show_bug.cgi?id=156647
+ http://trac.webkit.org/changeset/199726
+
2016-04-19 Michael Saboff <[email protected]>
iTunes crashing _javascript_Core.dll
Modified: trunk/Source/WTF/wtf/ThreadSpecific.h (199728 => 199729)
--- trunk/Source/WTF/wtf/ThreadSpecific.h 2016-04-19 15:48:00 UTC (rev 199728)
+++ trunk/Source/WTF/wtf/ThreadSpecific.h 2016-04-19 16:29:54 UTC (rev 199729)
@@ -94,6 +94,9 @@
T* value;
ThreadSpecific<T>* owner;
+#if OS(WINDOWS)
+ void (*destructor)(void*);
+#endif
};
#if USE(PTHREADS)
@@ -155,64 +158,47 @@
#elif OS(WINDOWS)
-// The maximum number of FLS keys that can be created. For simplification, we assume that:
+// The maximum number of TLS keys that can be created. For simplification, we assume that:
// 1) Once the instance of ThreadSpecific<> is created, it will not be destructed until the program dies.
// 2) We do not need to hold many instances of ThreadSpecific<> data. This fixed number should be far enough.
-const int kMaxFlsKeySize = 128;
+const int kMaxTlsKeySize = 256;
-WTF_EXPORT_PRIVATE long& flsKeyCount();
-WTF_EXPORT_PRIVATE DWORD* flsKeys();
+WTF_EXPORT_PRIVATE long& tlsKeyCount();
+WTF_EXPORT_PRIVATE DWORD* tlsKeys();
-typedef DWORD ThreadSpecificKey;
+class PlatformThreadSpecificKey;
+typedef PlatformThreadSpecificKey* ThreadSpecificKey;
-inline void threadSpecificKeyCreate(ThreadSpecificKey* key, void (*destructor)(void *))
-{
- DWORD flsKey = FlsAlloc(reinterpret_cast<PFLS_CALLBACK_FUNCTION>(destructor));
- if (flsKey == FLS_OUT_OF_INDEXES)
- CRASH();
+WTF_EXPORT_PRIVATE void threadSpecificKeyCreate(ThreadSpecificKey*, void (*)(void *));
+WTF_EXPORT_PRIVATE void threadSpecificKeyDelete(ThreadSpecificKey);
+WTF_EXPORT_PRIVATE void threadSpecificSet(ThreadSpecificKey, void*);
+WTF_EXPORT_PRIVATE void* threadSpecificGet(ThreadSpecificKey);
- *key = flsKey;
-}
-
-inline void threadSpecificKeyDelete(ThreadSpecificKey key)
-{
- FlsFree(key);
-}
-
-inline void threadSpecificSet(ThreadSpecificKey key, void* data)
-{
- FlsSetValue(key, data);
-}
-
-inline void* threadSpecificGet(ThreadSpecificKey key)
-{
- return FlsGetValue(key);
-}
-
template<typename T>
inline ThreadSpecific<T>::ThreadSpecific()
: m_index(-1)
{
- DWORD flsKey = FlsAlloc(reinterpret_cast<PFLS_CALLBACK_FUNCTION>(destroy));
- if (flsKey == FLS_OUT_OF_INDEXES)
+ DWORD tlsKey = TlsAlloc();
+ if (tlsKey == TLS_OUT_OF_INDEXES)
CRASH();
- m_index = InterlockedIncrement(&flsKeyCount()) - 1;
- if (m_index >= kMaxFlsKeySize)
+ m_index = InterlockedIncrement(&tlsKeyCount()) - 1;
+ if (m_index >= kMaxTlsKeySize)
CRASH();
- flsKeys()[m_index] = flsKey;
+ tlsKeys()[m_index] = tlsKey;
}
template<typename T>
inline ThreadSpecific<T>::~ThreadSpecific()
{
- FlsFree(flsKeys()[m_index]);
+ // Does not invoke destructor functions. They will be called from ThreadSpecificThreadExit when the thread is detached.
+ TlsFree(tlsKeys()[m_index]);
}
template<typename T>
inline T* ThreadSpecific<T>::get()
{
- Data* data = ""
+ Data* data = ""
return data ? data->value : 0;
}
@@ -221,7 +207,8 @@
{
ASSERT(!get());
Data* data = "" Data(ptr, this);
- FlsSetValue(flsKeys()[m_index], data);
+ data->destructor = &ThreadSpecific<T>::destroy;
+ TlsSetValue(tlsKeys()[m_index], data);
}
#else
@@ -245,7 +232,7 @@
#if USE(PTHREADS)
pthread_setspecific(data->owner->m_key, 0);
#elif OS(WINDOWS)
- FlsSetValue(flsKeys()[data->owner->m_index], 0);
+ TlsSetValue(tlsKeys()[data->owner->m_index], 0);
#else
#error ThreadSpecific is not implemented for this platform.
#endif
Modified: trunk/Source/WTF/wtf/ThreadSpecificWin.cpp (199728 => 199729)
--- trunk/Source/WTF/wtf/ThreadSpecificWin.cpp 2016-04-19 15:48:00 UTC (rev 199728)
+++ trunk/Source/WTF/wtf/ThreadSpecificWin.cpp 2016-04-19 16:29:54 UTC (rev 199729)
@@ -24,22 +24,117 @@
#if OS(WINDOWS)
+#include "StdLibExtras.h"
+#include "ThreadingPrimitives.h"
+#include <wtf/DoublyLinkedList.h>
+
#if !USE(PTHREADS)
namespace WTF {
-long& flsKeyCount()
+static DoublyLinkedList<PlatformThreadSpecificKey>& destructorsList()
{
+ static DoublyLinkedList<PlatformThreadSpecificKey> staticList;
+ return staticList;
+}
+
+static Mutex& destructorsMutex()
+{
+ static Mutex staticMutex;
+ return staticMutex;
+}
+
+class PlatformThreadSpecificKey : public DoublyLinkedListNode<PlatformThreadSpecificKey> {
+public:
+ friend class DoublyLinkedListNode<PlatformThreadSpecificKey>;
+
+ PlatformThreadSpecificKey(void (*destructor)(void *))
+ : m_destructor(destructor)
+ {
+ m_tlsKey = TlsAlloc();
+ if (m_tlsKey == TLS_OUT_OF_INDEXES)
+ CRASH();
+ }
+
+ ~PlatformThreadSpecificKey()
+ {
+ TlsFree(m_tlsKey);
+ }
+
+ void setValue(void* data) { TlsSetValue(m_tlsKey, data); }
+ void* value() { return TlsGetValue(m_tlsKey); }
+
+ void callDestructor()
+ {
+ if (void* data = ""
+ m_destructor(data);
+ }
+
+private:
+ void (*m_destructor)(void *);
+ DWORD m_tlsKey;
+ PlatformThreadSpecificKey* m_prev;
+ PlatformThreadSpecificKey* m_next;
+};
+
+long& tlsKeyCount()
+{
static long count;
return count;
}
-DWORD* flsKeys()
+DWORD* tlsKeys()
{
- static DWORD keys[kMaxFlsKeySize];
+ static DWORD keys[kMaxTlsKeySize];
return keys;
}
+void threadSpecificKeyCreate(ThreadSpecificKey* key, void (*destructor)(void *))
+{
+ // Use the original malloc() instead of fastMalloc() to use this function in FastMalloc code.
+ *key = static_cast<PlatformThreadSpecificKey*>(::malloc(sizeof(PlatformThreadSpecificKey)));
+ new (*key) PlatformThreadSpecificKey(destructor);
+
+ MutexLocker locker(destructorsMutex());
+ destructorsList().push(*key);
+}
+
+void threadSpecificKeyDelete(ThreadSpecificKey key)
+{
+ MutexLocker locker(destructorsMutex());
+ destructorsList().remove(key);
+ key->~PlatformThreadSpecificKey();
+ ::free(key);
+}
+
+void threadSpecificSet(ThreadSpecificKey key, void* data)
+{
+ key->setValue(data);
+}
+
+void* threadSpecificGet(ThreadSpecificKey key)
+{
+ return key->value();
+}
+
+void ThreadSpecificThreadExit()
+{
+ for (long i = 0; i < tlsKeyCount(); i++) {
+ // The layout of ThreadSpecific<T>::Data does not depend on T. So we are safe to do the static cast to ThreadSpecific<int> in order to access its data member.
+ ThreadSpecific<int>::Data* data = ""
+ if (data)
+ data->destructor(data);
+ }
+
+ MutexLocker locker(destructorsMutex());
+ PlatformThreadSpecificKey* key = destructorsList().head();
+ while (key) {
+ PlatformThreadSpecificKey* nextKey = key->next();
+ key->callDestructor();
+ key = nextKey;
+ }
+}
+
} // namespace WTF
#endif // !USE(PTHREADS)
Modified: trunk/Source/WTF/wtf/ThreadingWin.cpp (199728 => 199729)
--- trunk/Source/WTF/wtf/ThreadingWin.cpp 2016-04-19 15:48:00 UTC (rev 199728)
+++ trunk/Source/WTF/wtf/ThreadingWin.cpp 2016-04-19 16:29:54 UTC (rev 199729)
@@ -102,6 +102,10 @@
#include <wtf/RandomNumberSeed.h>
#include <wtf/WTFThreadData.h>
+#if !USE(PTHREADS) && OS(WINDOWS)
+#include "ThreadSpecific.h"
+#endif
+
#if HAVE(ERRNO_H)
#include <errno.h>
#endif
@@ -195,6 +199,11 @@
std::unique_ptr<ThreadFunctionInvocation> invocation(static_cast<ThreadFunctionInvocation*>(param));
invocation->function(invocation->data);
+#if !USE(PTHREADS) && OS(WINDOWS)
+ // Do the TLS cleanup.
+ ThreadSpecificThreadExit();
+#endif
+
return 0;
}