зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset 46f6705f9c0c (bug 1533240) for xpcshell failures at /test/test_dmd.js on a CLOSED TREE.
This commit is contained in:
Родитель
08a7dd5352
Коммит
0f47ac1ab9
|
@ -41,7 +41,6 @@
|
|||
#include "mozilla/MemoryReporting.h"
|
||||
#include "mozilla/PodOperations.h"
|
||||
#include "mozilla/StackWalk.h"
|
||||
#include "mozilla/ThreadLocal.h"
|
||||
|
||||
// CodeAddressService is defined entirely in the header, so this does not make
|
||||
// DMD depend on XPCOM's object file.
|
||||
|
@ -436,9 +435,32 @@ class AutoUnlockState {
|
|||
};
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Per-thread blocking of intercepts
|
||||
// Thread-local storage and blocking of intercepts
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#ifdef XP_WIN
|
||||
|
||||
# define DMD_TLS_INDEX_TYPE DWORD
|
||||
# define DMD_CREATE_TLS_INDEX(i_) \
|
||||
do { \
|
||||
(i_) = TlsAlloc(); \
|
||||
} while (0)
|
||||
# define DMD_DESTROY_TLS_INDEX(i_) TlsFree((i_))
|
||||
# define DMD_GET_TLS_DATA(i_) TlsGetValue((i_))
|
||||
# define DMD_SET_TLS_DATA(i_, v_) TlsSetValue((i_), (v_))
|
||||
|
||||
#else
|
||||
|
||||
# define DMD_TLS_INDEX_TYPE pthread_key_t
|
||||
# define DMD_CREATE_TLS_INDEX(i_) pthread_key_create(&(i_), nullptr)
|
||||
# define DMD_DESTROY_TLS_INDEX(i_) pthread_key_delete((i_))
|
||||
# define DMD_GET_TLS_DATA(i_) pthread_getspecific((i_))
|
||||
# define DMD_SET_TLS_DATA(i_, v_) pthread_setspecific((i_), (v_))
|
||||
|
||||
#endif
|
||||
|
||||
static DMD_TLS_INDEX_TYPE gTlsIndex;
|
||||
|
||||
class Thread {
|
||||
// Required for allocation via InfallibleAllocPolicy::new_.
|
||||
friend class InfallibleAllocPolicy;
|
||||
|
@ -453,26 +475,8 @@ class Thread {
|
|||
|
||||
DISALLOW_COPY_AND_ASSIGN(Thread);
|
||||
|
||||
static MOZ_THREAD_LOCAL(Thread*) tlsThread;
|
||||
|
||||
public:
|
||||
static void Init() {
|
||||
if (!tlsThread.init()) {
|
||||
MOZ_CRASH();
|
||||
}
|
||||
}
|
||||
|
||||
static Thread* Fetch() {
|
||||
Thread* t = tlsThread.get();
|
||||
if (MOZ_UNLIKELY(!t)) {
|
||||
// This memory is never freed, even if the thread dies. It's a leak, but
|
||||
// only a tiny one.
|
||||
t = InfallibleAllocPolicy::new_<Thread>();
|
||||
tlsThread.set(t);
|
||||
}
|
||||
|
||||
return t;
|
||||
}
|
||||
static Thread* Fetch();
|
||||
|
||||
bool BlockIntercepts() {
|
||||
MOZ_ASSERT(!mBlockIntercepts);
|
||||
|
@ -487,7 +491,19 @@ class Thread {
|
|||
bool InterceptsAreBlocked() const { return mBlockIntercepts; }
|
||||
};
|
||||
|
||||
MOZ_THREAD_LOCAL(Thread*) Thread::tlsThread;
|
||||
/* static */
|
||||
Thread* Thread::Fetch() {
|
||||
Thread* t = static_cast<Thread*>(DMD_GET_TLS_DATA(gTlsIndex));
|
||||
|
||||
if (MOZ_UNLIKELY(!t)) {
|
||||
// This memory is never freed, even if the thread dies. It's a leak, but
|
||||
// only a tiny one.
|
||||
t = InfallibleAllocPolicy::new_<Thread>();
|
||||
DMD_SET_TLS_DATA(gTlsIndex, t);
|
||||
}
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
// An object of this class must be created (on the stack) before running any
|
||||
// code that might allocate.
|
||||
|
@ -1394,7 +1410,7 @@ static bool Init(malloc_table_t* aMallocTable) {
|
|||
sizeof(FastBernoulliTrial));
|
||||
ResetBernoulli();
|
||||
|
||||
Thread::Init();
|
||||
DMD_CREATE_TLS_INDEX(gTlsIndex);
|
||||
|
||||
{
|
||||
AutoLockState lock;
|
||||
|
|
Загрузка…
Ссылка в новой задаче