Bug 865583 - Use thread-safe ref-counting in the linker. r=nfroyd

This commit is contained in:
Mike Hommey 2013-05-18 09:53:18 +02:00
parent 6334a79a0e
commit 5b640b3daa
2 changed files with 9 additions and 8 deletions

View File

@ -70,9 +70,9 @@ class LibHandle;
namespace mozilla { namespace mozilla {
namespace detail { namespace detail {
template <> inline void RefCounted<LibHandle, NonAtomicRefCount>::Release(); template <> inline void RefCounted<LibHandle, AtomicRefCount>::Release();
template <> inline RefCounted<LibHandle, NonAtomicRefCount>::~RefCounted() template <> inline RefCounted<LibHandle, AtomicRefCount>::~RefCounted()
{ {
MOZ_ASSERT(refCnt == 0x7fffdead); MOZ_ASSERT(refCnt == 0x7fffdead);
} }
@ -87,7 +87,7 @@ class Mappable;
* Abstract class for loaded libraries. Libraries may be loaded through the * Abstract class for loaded libraries. Libraries may be loaded through the
* system linker or this linker, both cases will be derived from this class. * system linker or this linker, both cases will be derived from this class.
*/ */
class LibHandle: public mozilla::RefCounted<LibHandle> class LibHandle: public mozilla::AtomicRefCounted<LibHandle>
{ {
public: public:
/** /**
@ -138,7 +138,7 @@ public:
void AddDirectRef() void AddDirectRef()
{ {
++directRefCnt; ++directRefCnt;
mozilla::RefCounted<LibHandle>::AddRef(); mozilla::AtomicRefCounted<LibHandle>::AddRef();
} }
/** /**
@ -149,10 +149,11 @@ public:
{ {
bool ret = false; bool ret = false;
if (directRefCnt) { if (directRefCnt) {
MOZ_ASSERT(directRefCnt <= mozilla::RefCounted<LibHandle>::refCount()); MOZ_ASSERT(directRefCnt <=
mozilla::AtomicRefCounted<LibHandle>::refCount());
if (--directRefCnt) if (--directRefCnt)
ret = true; ret = true;
mozilla::RefCounted<LibHandle>::Release(); mozilla::AtomicRefCounted<LibHandle>::Release();
} }
return ret; return ret;
} }
@ -217,7 +218,7 @@ private:
namespace mozilla { namespace mozilla {
namespace detail { namespace detail {
template <> inline void RefCounted<LibHandle, NonAtomicRefCount>::Release() { template <> inline void RefCounted<LibHandle, AtomicRefCount>::Release() {
#ifdef DEBUG #ifdef DEBUG
if (refCnt > 0x7fff0000) if (refCnt > 0x7fff0000)
MOZ_ASSERT(refCnt > 0x7fffdead); MOZ_ASSERT(refCnt > 0x7fffdead);

View File

@ -26,7 +26,7 @@ class ZipCollection;
* libraries from Zip archives, there is no interest in making this code * libraries from Zip archives, there is no interest in making this code
* safe, since the libraries could contain malicious code anyways. * safe, since the libraries could contain malicious code anyways.
*/ */
class Zip: public mozilla::RefCounted<Zip> class Zip: public mozilla::AtomicRefCounted<Zip>
{ {
public: public:
/** /**