Skip to content

Commit

Permalink
Bug 798158 - Part 1: Use a pointer-sized type to store refcounts inte…
Browse files Browse the repository at this point in the history
…rnally; r=bsmedberg
  • Loading branch information
ehsan committed Mar 27, 2014
1 parent 3bd7955 commit 98b8925
Show file tree
Hide file tree
Showing 103 changed files with 250 additions and 238 deletions.
4 changes: 2 additions & 2 deletions accessible/src/base/NotificationController.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ class NotificationController : public EventQueue,
NotificationController(DocAccessible* aDocument, nsIPresShell* aPresShell);
virtual ~NotificationController();

NS_IMETHOD_(nsrefcnt) AddRef(void);
NS_IMETHOD_(nsrefcnt) Release(void);
NS_IMETHOD_(MozExternalRefCountType) AddRef(void);
NS_IMETHOD_(MozExternalRefCountType) Release(void);

NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS(NotificationController)

Expand Down
4 changes: 2 additions & 2 deletions caps/include/nsPrincipal.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ class nsBasePrincipal : public nsJSPrincipals
virtual ~nsBasePrincipal();

public:
NS_IMETHOD_(nsrefcnt) AddRef(void);
NS_IMETHOD_(nsrefcnt) Release(void);
NS_IMETHOD_(MozExternalRefCountType) AddRef(void);
NS_IMETHOD_(MozExternalRefCountType) Release(void);
NS_IMETHOD GetCsp(nsIContentSecurityPolicy** aCsp);
NS_IMETHOD SetCsp(nsIContentSecurityPolicy* aCsp);
public:
Expand Down
4 changes: 2 additions & 2 deletions caps/src/nsNullPrincipal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ NS_IMPL_CI_INTERFACE_GETTER2(nsNullPrincipal,
nsIPrincipal,
nsISerializable)

NS_IMETHODIMP_(nsrefcnt)
NS_IMETHODIMP_(MozExternalRefCountType)
nsNullPrincipal::AddRef()
{
NS_PRECONDITION(int32_t(refcount) >= 0, "illegal refcnt");
Expand All @@ -44,7 +44,7 @@ nsNullPrincipal::AddRef()
return count;
}

NS_IMETHODIMP_(nsrefcnt)
NS_IMETHODIMP_(MozExternalRefCountType)
nsNullPrincipal::Release()
{
NS_PRECONDITION(0 != refcount, "dup release");
Expand Down
4 changes: 2 additions & 2 deletions caps/src/nsPrincipal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ static bool URIIsImmutable(nsIURI* aURI)
// Static member variables
const char nsBasePrincipal::sInvalid[] = "Invalid";

NS_IMETHODIMP_(nsrefcnt)
NS_IMETHODIMP_(MozExternalRefCountType)
nsBasePrincipal::AddRef()
{
NS_PRECONDITION(int32_t(refcount) >= 0, "illegal refcnt");
Expand All @@ -56,7 +56,7 @@ nsBasePrincipal::AddRef()
return count;
}

NS_IMETHODIMP_(nsrefcnt)
NS_IMETHODIMP_(MozExternalRefCountType)
nsBasePrincipal::Release()
{
NS_PRECONDITION(0 != refcount, "dup release");
Expand Down
4 changes: 2 additions & 2 deletions caps/src/nsSystemPrincipal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ NS_IMPL_CI_INTERFACE_GETTER2(nsSystemPrincipal,
nsIPrincipal,
nsISerializable)

NS_IMETHODIMP_(nsrefcnt)
NS_IMETHODIMP_(MozExternalRefCountType)
nsSystemPrincipal::AddRef()
{
NS_PRECONDITION(int32_t(refcount) >= 0, "illegal refcnt");
Expand All @@ -38,7 +38,7 @@ nsSystemPrincipal::AddRef()
return count;
}

NS_IMETHODIMP_(nsrefcnt)
NS_IMETHODIMP_(MozExternalRefCountType)
nsSystemPrincipal::Release()
{
NS_PRECONDITION(0 != refcount, "dup release");
Expand Down
3 changes: 2 additions & 1 deletion content/base/src/Comment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "nsCOMPtr.h"
#include "mozilla/dom/Comment.h"
#include "mozilla/dom/CommentBinding.h"
#include "mozilla/IntegerPrintfMacros.h"

using namespace mozilla;
using namespace dom;
Expand Down Expand Up @@ -49,7 +50,7 @@ Comment::List(FILE* out, int32_t aIndent) const
int32_t indx;
for (indx = aIndent; --indx >= 0; ) fputs(" ", out);

fprintf(out, "Comment@%p refcount=%d<!--", (void*)this, mRefCnt.get());
fprintf(out, "Comment@%p refcount=%" PRIuPTR "<!--", (void*)this, mRefCnt.get());

nsAutoString tmp;
ToCString(tmp, 0, mText.GetLength());
Expand Down
3 changes: 2 additions & 1 deletion content/base/src/DocumentFragment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "mozilla/dom/DocumentFragmentBinding.h"
#include "nsPIDOMWindow.h"
#include "nsIDocument.h"
#include "mozilla/IntegerPrintfMacros.h"

namespace mozilla {
namespace dom {
Expand Down Expand Up @@ -72,7 +73,7 @@ DocumentFragment::List(FILE* out, int32_t aIndent) const
fprintf(out, "DocumentFragment@%p", (void *)this);

fprintf(out, " flags=[%08x]", static_cast<unsigned int>(GetFlags()));
fprintf(out, " refcount=%d<", mRefCnt.get());
fprintf(out, " refcount=%" PRIuPTR "<", mRefCnt.get());

nsIContent* child = GetFirstChild();
if (child) {
Expand Down
3 changes: 2 additions & 1 deletion content/base/src/Element.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@
#include "nsITextControlElement.h"
#include "nsISupportsImpl.h"
#include "mozilla/dom/DocumentFragment.h"
#include "mozilla/IntegerPrintfMacros.h"

using namespace mozilla;
using namespace mozilla::dom;
Expand Down Expand Up @@ -2199,7 +2200,7 @@ Element::List(FILE* out, int32_t aIndent,
fprintf(out, " ranges:%d", ranges ? ranges->Count() : 0);
}
fprintf(out, " primaryframe=%p", static_cast<void*>(GetPrimaryFrame()));
fprintf(out, " refcount=%d<", mRefCnt.get());
fprintf(out, " refcount=%" PRIuPTR "<", mRefCnt.get());

nsIContent* child = GetFirstChild();
if (child) {
Expand Down
2 changes: 1 addition & 1 deletion content/base/src/nsDocument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1783,7 +1783,7 @@ NS_INTERFACE_MAP_END


NS_IMPL_CYCLE_COLLECTING_ADDREF(nsDocument)
NS_IMETHODIMP_(nsrefcnt)
NS_IMETHODIMP_(MozExternalRefCountType)
nsDocument::Release()
{
NS_PRECONDITION(0 != mRefCnt, "dup release");
Expand Down
3 changes: 2 additions & 1 deletion content/base/src/nsTextNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "nsIDocument.h"
#include "nsThreadUtils.h"
#include "nsStubMutationObserver.h"
#include "mozilla/IntegerPrintfMacros.h"
#ifdef DEBUG
#include "nsRange.h"
#endif
Expand Down Expand Up @@ -169,7 +170,7 @@ nsTextNode::List(FILE* out, int32_t aIndent) const
fprintf(out, " ranges:%d", ranges ? ranges->Count() : 0);
}
fprintf(out, " primaryframe=%p", static_cast<void*>(GetPrimaryFrame()));
fprintf(out, " refcount=%d<", mRefCnt.get());
fprintf(out, " refcount=%" PRIuPTR "<", mRefCnt.get());

nsAutoString tmp;
ToCString(tmp, 0, mText.GetLength());
Expand Down
4 changes: 2 additions & 2 deletions content/media/SharedThreadPool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ SharedThreadPool::Get(const nsCString& aName, uint32_t aThreadLimit)
return instance.forget();
}

NS_IMETHODIMP_(nsrefcnt) SharedThreadPool::AddRef(void)
NS_IMETHODIMP_(MozExternalRefCountType) SharedThreadPool::AddRef(void)
{
MOZ_ASSERT(sMonitor);
ReentrantMonitorAutoEnter mon(*sMonitor);
Expand All @@ -128,7 +128,7 @@ NS_IMETHODIMP_(nsrefcnt) SharedThreadPool::AddRef(void)
return count;
}

NS_IMETHODIMP_(nsrefcnt) SharedThreadPool::Release(void)
NS_IMETHODIMP_(MozExternalRefCountType) SharedThreadPool::Release(void)
{
MOZ_ASSERT(sMonitor);
bool dispatchShutdownEvent;
Expand Down
6 changes: 3 additions & 3 deletions content/media/SharedThreadPool.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ class SharedThreadPool : public nsIThreadPool
// are implemented using locking, so it's not recommended that you use them
// in a tight loop.
NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr);
NS_IMETHOD_(nsrefcnt) AddRef(void);
NS_IMETHOD_(nsrefcnt) Release(void);
NS_IMETHOD_(MozExternalRefCountType) AddRef(void);
NS_IMETHOD_(MozExternalRefCountType) Release(void);

// Forward behaviour to wrapped thread pool implementation.
NS_FORWARD_SAFE_NSITHREADPOOL(mPool);
Expand Down Expand Up @@ -87,4 +87,4 @@ class SharedThreadPool : public nsIThreadPool

} // namespace mozilla

#endif // SharedThreadPool_h_
#endif // SharedThreadPool_h_
2 changes: 1 addition & 1 deletion content/media/webaudio/AudioNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END

NS_IMPL_ADDREF_INHERITED(AudioNode, nsDOMEventTargetHelper)

NS_IMETHODIMP_(nsrefcnt)
NS_IMETHODIMP_(MozExternalRefCountType)
AudioNode::Release()
{
if (mRefCnt.get() == 1) {
Expand Down
2 changes: 1 addition & 1 deletion content/media/webaudio/AudioParam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ NS_IMPL_CYCLE_COLLECTION_TRACE_WRAPPERCACHE(AudioParam)

NS_IMPL_CYCLE_COLLECTING_NATIVE_ADDREF(AudioParam)

NS_IMETHODIMP_(nsrefcnt)
NS_IMETHODIMP_(MozExternalRefCountType)
AudioParam::Release()
{
if (mRefCnt.get() == 1) {
Expand Down
4 changes: 2 additions & 2 deletions content/media/webaudio/AudioParam.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ class AudioParam MOZ_FINAL : public nsWrapperCache,
float aDefaultValue);
virtual ~AudioParam();

NS_IMETHOD_(nsrefcnt) AddRef(void);
NS_IMETHOD_(nsrefcnt) Release(void);
NS_IMETHOD_(MozExternalRefCountType) AddRef(void);
NS_IMETHOD_(MozExternalRefCountType) Release(void);
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(AudioParam)

AudioContext* GetParentObject() const
Expand Down
3 changes: 2 additions & 1 deletion content/xml/content/src/CDATASection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include "mozilla/dom/CDATASection.h"
#include "mozilla/dom/CDATASectionBinding.h"
#include "mozilla/IntegerPrintfMacros.h"

namespace mozilla {
namespace dom {
Expand Down Expand Up @@ -48,7 +49,7 @@ CDATASection::List(FILE* out, int32_t aIndent) const
int32_t index;
for (index = aIndent; --index >= 0; ) fputs(" ", out);

fprintf(out, "CDATASection refcount=%d<", mRefCnt.get());
fprintf(out, "CDATASection refcount=%" PRIuPTR "<", mRefCnt.get());

nsAutoString tmp;
ToCString(tmp, 0, mText.GetLength());
Expand Down
3 changes: 2 additions & 1 deletion content/xml/content/src/ProcessingInstruction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "mozilla/dom/ProcessingInstruction.h"
#include "mozilla/dom/ProcessingInstructionBinding.h"
#include "mozilla/dom/XMLStylesheetProcessingInstruction.h"
#include "mozilla/IntegerPrintfMacros.h"
#include "nsContentUtils.h"

already_AddRefed<mozilla::dom::ProcessingInstruction>
Expand Down Expand Up @@ -111,7 +112,7 @@ ProcessingInstruction::List(FILE* out, int32_t aIndent) const
int32_t index;
for (index = aIndent; --index >= 0; ) fputs(" ", out);

fprintf(out, "Processing instruction refcount=%d<", mRefCnt.get());
fprintf(out, "Processing instruction refcount=%" PRIuPTR "<", mRefCnt.get());

nsAutoString tmp;
ToCString(tmp, 0, mText.GetLength());
Expand Down
4 changes: 2 additions & 2 deletions content/xul/templates/src/nsXMLBinding.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ class nsXMLBindingSet MOZ_FINAL

public:

NS_METHOD_(nsrefcnt) AddRef();
NS_METHOD_(nsrefcnt) Release();
NS_METHOD_(MozExternalRefCountType) AddRef();
NS_METHOD_(MozExternalRefCountType) Release();
NS_DECL_OWNINGTHREAD
NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS(nsXMLBindingSet)

Expand Down
4 changes: 2 additions & 2 deletions dom/asmjscache/AsmJSCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1726,10 +1726,10 @@ GetBuildId(JS::BuildIdCharVector* aBuildID)
class Client : public quota::Client
{
public:
NS_IMETHOD_(nsrefcnt)
NS_IMETHOD_(MozExternalRefCountType)
AddRef() MOZ_OVERRIDE;

NS_IMETHOD_(nsrefcnt)
NS_IMETHOD_(MozExternalRefCountType)
Release() MOZ_OVERRIDE;

virtual Type
Expand Down
4 changes: 2 additions & 2 deletions dom/devicestorage/DeviceStorageRequestParent.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ class DeviceStorageRequestParent : public PDeviceStorageRequestParent
public:
DeviceStorageRequestParent(const DeviceStorageParams& aParams);

NS_IMETHOD_(nsrefcnt) AddRef();
NS_IMETHOD_(nsrefcnt) Release();
NS_IMETHOD_(MozExternalRefCountType) AddRef();
NS_IMETHOD_(MozExternalRefCountType) Release();

bool EnsureRequiredPermissions(mozilla::dom::ContentParent* aParent);
void Dispatch();
Expand Down
4 changes: 2 additions & 2 deletions dom/file/FileHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ class LockedFile;
class FileHelperListener
{
public:
NS_IMETHOD_(nsrefcnt)
NS_IMETHOD_(MozExternalRefCountType)
AddRef() = 0;

NS_IMETHOD_(nsrefcnt)
NS_IMETHOD_(MozExternalRefCountType)
Release() = 0;

virtual void
Expand Down
4 changes: 2 additions & 2 deletions dom/file/FileService.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ class FileService MOZ_FINAL : public nsIObserver
friend class FileService;

public:
NS_IMETHOD_(nsrefcnt)
NS_IMETHOD_(MozExternalRefCountType)
AddRef() MOZ_OVERRIDE;

NS_IMETHOD_(nsrefcnt)
NS_IMETHOD_(MozExternalRefCountType)
Release() MOZ_OVERRIDE;

inline nsresult
Expand Down
4 changes: 2 additions & 2 deletions dom/indexedDB/AsyncConnectionHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -630,14 +630,14 @@ AsyncConnectionHelper::ConvertToArrayAndCleanup(
return rv;
}

NS_IMETHODIMP_(nsrefcnt)
NS_IMETHODIMP_(MozExternalRefCountType)
StackBasedEventTarget::AddRef()
{
NS_NOTREACHED("Don't call me!");
return 2;
}

NS_IMETHODIMP_(nsrefcnt)
NS_IMETHODIMP_(MozExternalRefCountType)
StackBasedEventTarget::Release()
{
NS_NOTREACHED("Don't call me!");
Expand Down
4 changes: 2 additions & 2 deletions dom/indexedDB/Client.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ class Client : public mozilla::dom::quota::Client
typedef mozilla::dom::quota::UsageInfo UsageInfo;

public:
NS_IMETHOD_(nsrefcnt)
NS_IMETHOD_(MozExternalRefCountType)
AddRef() MOZ_OVERRIDE;

NS_IMETHOD_(nsrefcnt)
NS_IMETHOD_(MozExternalRefCountType)
Release() MOZ_OVERRIDE;

virtual Type
Expand Down
4 changes: 2 additions & 2 deletions dom/indexedDB/IDBTransaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,12 @@ class StartTransactionRunnable : public nsIRunnable
};

// Could really use those NS_REFCOUNTING_HAHA_YEAH_RIGHT macros here.
NS_IMETHODIMP_(nsrefcnt) StartTransactionRunnable::AddRef()
NS_IMETHODIMP_(MozExternalRefCountType) StartTransactionRunnable::AddRef()
{
return 2;
}

NS_IMETHODIMP_(nsrefcnt) StartTransactionRunnable::Release()
NS_IMETHODIMP_(MozExternalRefCountType) StartTransactionRunnable::Release()
{
return 1;
}
Expand Down
4 changes: 2 additions & 2 deletions dom/indexedDB/IDBTransaction.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ class UpdateRefcountFunction;
class IDBTransactionListener
{
public:
NS_IMETHOD_(nsrefcnt) AddRef() = 0;
NS_IMETHOD_(nsrefcnt) Release() = 0;
NS_IMETHOD_(MozExternalRefCountType) AddRef() = 0;
NS_IMETHOD_(MozExternalRefCountType) Release() = 0;

// Called just before dispatching the final events on the transaction.
virtual nsresult NotifyTransactionPreComplete(IDBTransaction* aTransaction) = 0;
Expand Down
2 changes: 1 addition & 1 deletion dom/network/src/TCPServerSocketChild.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ TCPServerSocketChildBase::~TCPServerSocketChildBase()
{
}

NS_IMETHODIMP_(nsrefcnt) TCPServerSocketChild::Release(void)
NS_IMETHODIMP_(MozExternalRefCountType) TCPServerSocketChild::Release(void)
{
nsrefcnt refcnt = TCPServerSocketChildBase::Release();
if (refcnt == 1 && mIPCOpen) {
Expand Down
2 changes: 1 addition & 1 deletion dom/network/src/TCPServerSocketChild.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class TCPServerSocketChild : public mozilla::net::PTCPServerSocketChild
{
public:
NS_DECL_NSITCPSERVERSOCKETCHILD
NS_IMETHOD_(nsrefcnt) Release() MOZ_OVERRIDE;
NS_IMETHOD_(MozExternalRefCountType) Release() MOZ_OVERRIDE;

TCPServerSocketChild();
~TCPServerSocketChild();
Expand Down
2 changes: 1 addition & 1 deletion dom/network/src/TCPSocketChild.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ TCPSocketChildBase::~TCPSocketChildBase()
{
}

NS_IMETHODIMP_(nsrefcnt) TCPSocketChild::Release(void)
NS_IMETHODIMP_(MozExternalRefCountType) TCPSocketChild::Release(void)
{
nsrefcnt refcnt = TCPSocketChildBase::Release();
if (refcnt == 1 && mIPCOpen) {
Expand Down
Loading

0 comments on commit 98b8925

Please sign in to comment.