mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 976247 - Remove a useless static keyword from mozilla::detail::DEAD; r=froydnj
--HG-- extra : rebase_source : e73444ec000f1e867651d39cf2aa6beaf88bf4f3
This commit is contained in:
parent
d2d53aec7b
commit
32a9de133d
@ -14,6 +14,9 @@
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/RefCountType.h"
|
||||
#include "mozilla/TypeTraits.h"
|
||||
#if defined(MOZILLA_INTERNAL_API)
|
||||
#include "nsTraceRefcnt.h"
|
||||
#endif
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
@ -53,6 +56,28 @@ namespace detail {
|
||||
static const MozRefCountType DEAD = 0xffffdead;
|
||||
#endif
|
||||
|
||||
// When building code that gets compiled into Gecko, try to use the
|
||||
// trace-refcount leak logging facilities.
|
||||
#if defined(MOZILLA_INTERNAL_API) && (defined(DEBUG) || defined(FORCE_BUILD_REFCNT_LOGGING))
|
||||
class RefCountLogger
|
||||
{
|
||||
public:
|
||||
static void logAddRef(const void* aPointer, MozRefCountType aRefCount,
|
||||
const char* aTypeName, uint32_t aInstanceSize)
|
||||
{
|
||||
MOZ_ASSERT(aRefCount != DEAD);
|
||||
NS_LogAddRef(const_cast<void*>(aPointer), aRefCount, aTypeName, aInstanceSize);
|
||||
}
|
||||
|
||||
static void logRelease(const void* aPointer, MozRefCountType aRefCount,
|
||||
const char* aTypeName)
|
||||
{
|
||||
MOZ_ASSERT(aRefCount != DEAD);
|
||||
NS_LogRelease(const_cast<void*>(aPointer), aRefCount, aTypeName);
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
// This is used WeakPtr.h as well as this file.
|
||||
enum RefCountAtomicity
|
||||
{
|
||||
@ -76,11 +101,20 @@ class RefCounted
|
||||
void AddRef() const {
|
||||
MOZ_ASSERT(int32_t(refCnt) >= 0);
|
||||
++refCnt;
|
||||
#if defined(MOZILLA_INTERNAL_API) && (defined(DEBUG) || defined(FORCE_BUILD_REFCNT_LOGGING))
|
||||
detail::RefCountLogger::logAddRef(static_cast<const T*>(this), refCnt,
|
||||
static_cast<const T*>(this)->typeName(), sizeof(T));
|
||||
#endif
|
||||
}
|
||||
|
||||
void Release() const {
|
||||
MOZ_ASSERT(int32_t(refCnt) > 0);
|
||||
if (0 == --refCnt) {
|
||||
--refCnt;
|
||||
#if defined(MOZILLA_INTERNAL_API) && (defined(DEBUG) || defined(FORCE_BUILD_REFCNT_LOGGING))
|
||||
detail::RefCountLogger::logRelease(static_cast<const T*>(this), refCnt,
|
||||
static_cast<const T*>(this)->typeName());
|
||||
#endif
|
||||
if (0 == refCnt) {
|
||||
#ifdef DEBUG
|
||||
refCnt = detail::DEAD;
|
||||
#endif
|
||||
|
@ -64,11 +64,14 @@
|
||||
#ifndef mozilla_WeakPtr_h
|
||||
#define mozilla_WeakPtr_h
|
||||
|
||||
#include "mozilla/ArrayUtils.h"
|
||||
#include "mozilla/Assertions.h"
|
||||
#include "mozilla/NullPtr.h"
|
||||
#include "mozilla/RefPtr.h"
|
||||
#include "mozilla/TypeTraits.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
template <typename T, class WeakReference> class WeakPtrBase;
|
||||
@ -86,6 +89,20 @@ class WeakReference : public ::mozilla::RefCounted<WeakReference<T> >
|
||||
return ptr;
|
||||
}
|
||||
|
||||
const char* typeName() const {
|
||||
static char nameBuffer[1024];
|
||||
const char* innerType = ptr->typeName();
|
||||
// We could do fancier length checks at runtime, but innerType is
|
||||
// controlled by us so we can ensure that this never causes a buffer
|
||||
// overflow by this assertion.
|
||||
MOZ_ASSERT(strlen(innerType) + sizeof("WeakReference<>") < ArrayLength(nameBuffer),
|
||||
"Exceedingly large type name");
|
||||
sprintf(nameBuffer, "WeakReference<%s>", innerType);
|
||||
// This is usually not OK, but here we are returning a pointer to a static
|
||||
// buffer which will immediately be used by the caller.
|
||||
return nameBuffer;
|
||||
}
|
||||
|
||||
private:
|
||||
friend class WeakPtrBase<T, WeakReference<T> >;
|
||||
friend class SupportsWeakPtrBase<T, WeakReference<T> >;
|
||||
|
@ -124,6 +124,13 @@ struct nsTraceRefcntStats {
|
||||
double mRefsOutstandingSquared;
|
||||
double mObjsOutstandingTotal;
|
||||
double mObjsOutstandingSquared;
|
||||
void dump(FILE* out) {
|
||||
fprintf(out, "mAddRefs: %" PRIu64 ", ", mAddRefs);
|
||||
fprintf(out, "mReleases: %" PRIu64 ", ", mReleases);
|
||||
fprintf(out, "mCreates: %" PRIu64 ", ", mCreates);
|
||||
fprintf(out, "mDestroys: %" PRIu64 ", ", mDestroys);
|
||||
fprintf(out, "\n");
|
||||
}
|
||||
};
|
||||
|
||||
// I hope to turn this on for everybody once we hit it a little less.
|
||||
@ -368,6 +375,7 @@ public:
|
||||
stats->mCreates != 0 ||
|
||||
meanObjs != 0 ||
|
||||
stddevObjs != 0) {
|
||||
stats->dump(out);
|
||||
fprintf(out, "%4d %-40.40s %8d %8" PRIu64 " %8" PRIu64 " %8" PRIu64 " (%8.2f +/- %8.2f) %8" PRIu64 " %8" PRIu64 " (%8.2f +/- %8.2f)\n",
|
||||
i+1, mClassName,
|
||||
(int32_t)mClassSize,
|
||||
|
Loading…
Reference in New Issue
Block a user