forked from mirrors/gecko-dev
Bug 1843477, remove main thread only CC macros, r=mccr8
Differential Revision: https://phabricator.services.mozilla.com/D187146
This commit is contained in:
parent
310f2406b1
commit
b632508d71
8 changed files with 44 additions and 156 deletions
|
|
@ -2434,9 +2434,8 @@ NS_INTERFACE_TABLE_HEAD(Document)
|
|||
NS_INTERFACE_TABLE_TO_MAP_SEGUE_CYCLE_COLLECTION(Document)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
NS_IMPL_MAIN_THREAD_ONLY_CYCLE_COLLECTING_ADDREF(Document)
|
||||
NS_IMPL_MAIN_THREAD_ONLY_CYCLE_COLLECTING_RELEASE_WITH_LAST_RELEASE(
|
||||
Document, LastRelease())
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(Document)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE_WITH_LAST_RELEASE(Document, LastRelease())
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_BEGIN(Document)
|
||||
if (Element::CanSkip(tmp, aRemovingAllowed)) {
|
||||
|
|
|
|||
|
|
@ -147,12 +147,13 @@ NS_INTERFACE_MAP_BEGIN(nsIContent)
|
|||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
NS_IMPL_MAIN_THREAD_ONLY_CYCLE_COLLECTING_ADDREF(nsIContent)
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsIContent)
|
||||
|
||||
NS_IMPL_DOMARENA_DESTROY(nsIContent)
|
||||
|
||||
NS_IMPL_MAIN_THREAD_ONLY_CYCLE_COLLECTING_RELEASE_WITH_LAST_RELEASE_AND_DESTROY(
|
||||
nsIContent, LastRelease(), Destroy())
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE_WITH_LAST_RELEASE_AND_DESTROY(nsIContent,
|
||||
LastRelease(),
|
||||
Destroy())
|
||||
|
||||
nsIContent* nsIContent::FindFirstNonChromeOnlyAccessContent() const {
|
||||
// This handles also nested native anonymous content.
|
||||
|
|
|
|||
|
|
@ -804,9 +804,8 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(Selection)
|
|||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
NS_IMPL_MAIN_THREAD_ONLY_CYCLE_COLLECTING_ADDREF(Selection)
|
||||
NS_IMPL_MAIN_THREAD_ONLY_CYCLE_COLLECTING_RELEASE_WITH_LAST_RELEASE(
|
||||
Selection, Disconnect())
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(Selection)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE_WITH_LAST_RELEASE(Selection, Disconnect())
|
||||
|
||||
const RangeBoundary& Selection::AnchorRef() const {
|
||||
if (!mAnchorFocusRange) {
|
||||
|
|
|
|||
|
|
@ -46,8 +46,8 @@ template void StaticRange::DoSetRange(const RawRangeBoundary& aStartBoundary,
|
|||
|
||||
nsTArray<RefPtr<StaticRange>>* StaticRange::sCachedRanges = nullptr;
|
||||
|
||||
NS_IMPL_MAIN_THREAD_ONLY_CYCLE_COLLECTING_ADDREF(StaticRange)
|
||||
NS_IMPL_MAIN_THREAD_ONLY_CYCLE_COLLECTING_RELEASE_WITH_INTERRUPTABLE_LAST_RELEASE(
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(StaticRange)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE_WITH_INTERRUPTABLE_LAST_RELEASE(
|
||||
StaticRange, DoSetRange(RawRangeBoundary(), RawRangeBoundary(), nullptr),
|
||||
AbstractRange::MaybeCacheToReuse(*this))
|
||||
|
||||
|
|
|
|||
|
|
@ -204,8 +204,8 @@ already_AddRefed<nsRange> nsRange::Create(
|
|||
* nsISupports
|
||||
******************************************************/
|
||||
|
||||
NS_IMPL_MAIN_THREAD_ONLY_CYCLE_COLLECTING_ADDREF(nsRange)
|
||||
NS_IMPL_MAIN_THREAD_ONLY_CYCLE_COLLECTING_RELEASE_WITH_INTERRUPTABLE_LAST_RELEASE(
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsRange)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE_WITH_INTERRUPTABLE_LAST_RELEASE(
|
||||
nsRange, DoSetRange(RawRangeBoundary(), RawRangeBoundary(), nullptr),
|
||||
MaybeInterruptLastRelease())
|
||||
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ struct RangeItem final {
|
|||
return EditorDOMPointType(mEndContainer, mEndOffset);
|
||||
}
|
||||
|
||||
NS_INLINE_DECL_MAIN_THREAD_ONLY_CYCLE_COLLECTING_NATIVE_REFCOUNTING(RangeItem)
|
||||
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(RangeItem)
|
||||
NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS(RangeItem)
|
||||
|
||||
nsCOMPtr<nsINode> mStartContainer;
|
||||
|
|
|
|||
|
|
@ -390,9 +390,9 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsComputedDOMStyle)
|
|||
NS_INTERFACE_MAP_ENTRY(nsIMutationObserver)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsDOMCSSDeclaration)
|
||||
|
||||
NS_IMPL_MAIN_THREAD_ONLY_CYCLE_COLLECTING_ADDREF(nsComputedDOMStyle)
|
||||
NS_IMPL_MAIN_THREAD_ONLY_CYCLE_COLLECTING_RELEASE_WITH_LAST_RELEASE(
|
||||
nsComputedDOMStyle, ClearComputedStyle())
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsComputedDOMStyle)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE_WITH_LAST_RELEASE(nsComputedDOMStyle,
|
||||
ClearComputedStyle())
|
||||
|
||||
void nsComputedDOMStyle::GetPropertyValue(const nsCSSPropertyID aPropID,
|
||||
nsACString& aValue) {
|
||||
|
|
|
|||
|
|
@ -228,12 +228,10 @@ class nsCycleCollectingAutoRefCnt {
|
|||
nsCycleCollectingAutoRefCnt(const nsCycleCollectingAutoRefCnt&) = delete;
|
||||
void operator=(const nsCycleCollectingAutoRefCnt&) = delete;
|
||||
|
||||
template <Suspect suspect = NS_CycleCollectorSuspect3>
|
||||
MOZ_ALWAYS_INLINE uintptr_t incr(nsISupports* aOwner) {
|
||||
return incr<suspect>(aOwner, nullptr);
|
||||
return incr(aOwner, nullptr);
|
||||
}
|
||||
|
||||
template <Suspect suspect = NS_CycleCollectorSuspect3>
|
||||
MOZ_ALWAYS_INLINE uintptr_t incr(void* aOwner,
|
||||
nsCycleCollectionParticipant* aCp) {
|
||||
mRefCntAndFlags += NS_REFCOUNT_CHANGE;
|
||||
|
|
@ -244,7 +242,7 @@ class nsCycleCollectingAutoRefCnt {
|
|||
mRefCntAndFlags |= NS_IN_PURPLE_BUFFER;
|
||||
// Refcount isn't zero, so Suspect won't delete anything.
|
||||
MOZ_ASSERT(get() > 0);
|
||||
suspect(aOwner, aCp, this, nullptr);
|
||||
NS_CycleCollectorSuspect3(aOwner, aCp, this, nullptr);
|
||||
}
|
||||
return NS_REFCOUNT_VALUE(mRefCntAndFlags);
|
||||
}
|
||||
|
|
@ -255,13 +253,11 @@ class nsCycleCollectingAutoRefCnt {
|
|||
mRefCntAndFlags = NS_REFCOUNT_CHANGE | NS_IN_PURPLE_BUFFER;
|
||||
}
|
||||
|
||||
template <Suspect suspect = NS_CycleCollectorSuspect3>
|
||||
MOZ_ALWAYS_INLINE uintptr_t decr(nsISupports* aOwner,
|
||||
bool* aShouldDelete = nullptr) {
|
||||
return decr<suspect>(aOwner, nullptr, aShouldDelete);
|
||||
return decr(aOwner, nullptr, aShouldDelete);
|
||||
}
|
||||
|
||||
template <Suspect suspect = NS_CycleCollectorSuspect3>
|
||||
MOZ_ALWAYS_INLINE uintptr_t decr(void* aOwner,
|
||||
nsCycleCollectionParticipant* aCp,
|
||||
bool* aShouldDelete = nullptr) {
|
||||
|
|
@ -271,7 +267,7 @@ class nsCycleCollectingAutoRefCnt {
|
|||
mRefCntAndFlags |= (NS_IN_PURPLE_BUFFER | NS_IS_PURPLE);
|
||||
uintptr_t retval = NS_REFCOUNT_VALUE(mRefCntAndFlags);
|
||||
// Suspect may delete 'aOwner' and 'this'!
|
||||
suspect(aOwner, aCp, this, aShouldDelete);
|
||||
NS_CycleCollectorSuspect3(aOwner, aCp, this, aShouldDelete);
|
||||
return retval;
|
||||
}
|
||||
mRefCntAndFlags -= NS_REFCOUNT_CHANGE;
|
||||
|
|
@ -498,16 +494,6 @@ class InterfaceNeedsThreadSafeRefCnt : public std::false_type {};
|
|||
NS_LOG_ADDREF(this, count, #_class, sizeof(*this)); \
|
||||
return count;
|
||||
|
||||
#define NS_IMPL_CC_MAIN_THREAD_ONLY_NATIVE_ADDREF_BODY(_class) \
|
||||
MOZ_ASSERT_TYPE_OK_FOR_REFCOUNTING(_class) \
|
||||
MOZ_ASSERT(int32_t(mRefCnt) >= 0, "illegal refcnt"); \
|
||||
NS_ASSERT_OWNINGTHREAD(_class); \
|
||||
nsrefcnt count = mRefCnt.incr<NS_CycleCollectorSuspectUsingNursery>( \
|
||||
static_cast<void*>(this), \
|
||||
_class::NS_CYCLE_COLLECTION_INNERCLASS::GetParticipant()); \
|
||||
NS_LOG_ADDREF(this, count, #_class, sizeof(*this)); \
|
||||
return count;
|
||||
|
||||
#define NS_IMPL_CC_NATIVE_RELEASE_BODY(_class) \
|
||||
MOZ_ASSERT(int32_t(mRefCnt) > 0, "dup release"); \
|
||||
NS_ASSERT_OWNINGTHREAD(_class); \
|
||||
|
|
@ -517,15 +503,6 @@ class InterfaceNeedsThreadSafeRefCnt : public std::false_type {};
|
|||
NS_LOG_RELEASE(this, count, #_class); \
|
||||
return count;
|
||||
|
||||
#define NS_IMPL_CC_MAIN_THREAD_ONLY_NATIVE_RELEASE_BODY(_class) \
|
||||
MOZ_ASSERT(int32_t(mRefCnt) > 0, "dup release"); \
|
||||
NS_ASSERT_OWNINGTHREAD(_class); \
|
||||
nsrefcnt count = mRefCnt.decr<NS_CycleCollectorSuspectUsingNursery>( \
|
||||
static_cast<void*>(this), \
|
||||
_class::NS_CYCLE_COLLECTION_INNERCLASS::GetParticipant()); \
|
||||
NS_LOG_RELEASE(this, count, #_class); \
|
||||
return count;
|
||||
|
||||
#define NS_IMPL_CYCLE_COLLECTING_NATIVE_ADDREF(_class) \
|
||||
NS_METHOD_(MozExternalRefCountType) _class::AddRef(void) { \
|
||||
NS_IMPL_CC_NATIVE_ADDREF_BODY(_class) \
|
||||
|
|
@ -586,21 +563,6 @@ class InterfaceNeedsThreadSafeRefCnt : public std::false_type {};
|
|||
NS_DECL_OWNINGTHREAD \
|
||||
public:
|
||||
|
||||
#define NS_INLINE_DECL_MAIN_THREAD_ONLY_CYCLE_COLLECTING_NATIVE_REFCOUNTING( \
|
||||
_class) \
|
||||
public: \
|
||||
NS_METHOD_(MozExternalRefCountType) \
|
||||
AddRef(void){NS_IMPL_CC_MAIN_THREAD_ONLY_NATIVE_ADDREF_BODY( \
|
||||
_class)} NS_METHOD_(MozExternalRefCountType) Release(void) { \
|
||||
NS_IMPL_CC_MAIN_THREAD_ONLY_NATIVE_RELEASE_BODY(_class) \
|
||||
} \
|
||||
using HasThreadSafeRefCnt = std::false_type; \
|
||||
\
|
||||
protected: \
|
||||
nsCycleCollectingAutoRefCnt mRefCnt; \
|
||||
NS_DECL_OWNINGTHREAD \
|
||||
public:
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
|
|
@ -956,17 +918,6 @@ void ProxyDeleteVoid(const char* aRunnableName,
|
|||
return count; \
|
||||
}
|
||||
|
||||
#define NS_IMPL_MAIN_THREAD_ONLY_CYCLE_COLLECTING_ADDREF(_class) \
|
||||
NS_IMETHODIMP_(MozExternalRefCountType) _class::AddRef(void) { \
|
||||
MOZ_ASSERT_TYPE_OK_FOR_REFCOUNTING(_class) \
|
||||
MOZ_ASSERT(int32_t(mRefCnt) >= 0, "illegal refcnt"); \
|
||||
NS_ASSERT_OWNINGTHREAD(_class); \
|
||||
nsISupports* base = NS_CYCLE_COLLECTION_CLASSNAME(_class)::Upcast(this); \
|
||||
nsrefcnt count = mRefCnt.incr<NS_CycleCollectorSuspectUsingNursery>(base); \
|
||||
NS_LOG_ADDREF(this, count, #_class, sizeof(*this)); \
|
||||
return count; \
|
||||
}
|
||||
|
||||
#define NS_IMPL_CYCLE_COLLECTING_RELEASE_WITH_DESTROY(_class, _destroy) \
|
||||
NS_IMETHODIMP_(MozExternalRefCountType) _class::Release(void) { \
|
||||
MOZ_ASSERT(int32_t(mRefCnt) > 0, "dup release"); \
|
||||
|
|
@ -1028,42 +979,6 @@ void ProxyDeleteVoid(const char* aRunnableName,
|
|||
} \
|
||||
NS_IMETHODIMP_(void) _class::DeleteCycleCollectable(void) { _destroy; }
|
||||
|
||||
#define NS_IMPL_MAIN_THREAD_ONLY_CYCLE_COLLECTING_RELEASE(_class) \
|
||||
NS_IMETHODIMP_(MozExternalRefCountType) _class::Release(void) { \
|
||||
MOZ_ASSERT(int32_t(mRefCnt) > 0, "dup release"); \
|
||||
NS_ASSERT_OWNINGTHREAD(_class); \
|
||||
nsISupports* base = NS_CYCLE_COLLECTION_CLASSNAME(_class)::Upcast(this); \
|
||||
nsrefcnt count = mRefCnt.decr<NS_CycleCollectorSuspectUsingNursery>(base); \
|
||||
NS_LOG_RELEASE(this, count, #_class); \
|
||||
return count; \
|
||||
} \
|
||||
NS_IMETHODIMP_(void) _class::DeleteCycleCollectable(void) { delete this; }
|
||||
|
||||
// _LAST_RELEASE can be useful when certain resources should be released
|
||||
// as soon as we know the object will be deleted.
|
||||
#define NS_IMPL_MAIN_THREAD_ONLY_CYCLE_COLLECTING_RELEASE_WITH_LAST_RELEASE( \
|
||||
_class, _last) \
|
||||
NS_IMETHODIMP_(MozExternalRefCountType) _class::Release(void) { \
|
||||
MOZ_ASSERT(int32_t(mRefCnt) > 0, "dup release"); \
|
||||
NS_ASSERT_OWNINGTHREAD(_class); \
|
||||
bool shouldDelete = false; \
|
||||
nsISupports* base = NS_CYCLE_COLLECTION_CLASSNAME(_class)::Upcast(this); \
|
||||
nsrefcnt count = mRefCnt.decr<NS_CycleCollectorSuspectUsingNursery>( \
|
||||
base, &shouldDelete); \
|
||||
NS_LOG_RELEASE(this, count, #_class); \
|
||||
if (count == 0) { \
|
||||
mRefCnt.incr<NS_CycleCollectorSuspectUsingNursery>(base); \
|
||||
_last; \
|
||||
mRefCnt.decr<NS_CycleCollectorSuspectUsingNursery>(base); \
|
||||
if (shouldDelete) { \
|
||||
mRefCnt.stabilizeForDeletion(); \
|
||||
DeleteCycleCollectable(); \
|
||||
} \
|
||||
} \
|
||||
return count; \
|
||||
} \
|
||||
NS_IMETHODIMP_(void) _class::DeleteCycleCollectable(void) { delete this; }
|
||||
|
||||
// _WITH_INTERRUPTABLE_LAST_RELEASE can be useful when certain resources
|
||||
// should be released as soon as we know the object will be deleted and the
|
||||
// instance may be cached for reuse.
|
||||
|
|
@ -1073,58 +988,32 @@ void ProxyDeleteVoid(const char* aRunnableName,
|
|||
// during _last is performed.)
|
||||
// Therefore, when _maybeInterrupt returns true, the instance has to be grabbed
|
||||
// by nsCOMPtr or RefPtr.
|
||||
#define NS_IMPL_MAIN_THREAD_ONLY_CYCLE_COLLECTING_RELEASE_WITH_INTERRUPTABLE_LAST_RELEASE( \
|
||||
_class, _last, _maybeInterrupt) \
|
||||
NS_IMETHODIMP_(MozExternalRefCountType) _class::Release(void) { \
|
||||
MOZ_ASSERT(int32_t(mRefCnt) > 0, "dup release"); \
|
||||
NS_ASSERT_OWNINGTHREAD(_class); \
|
||||
bool shouldDelete = false; \
|
||||
nsISupports* base = NS_CYCLE_COLLECTION_CLASSNAME(_class)::Upcast(this); \
|
||||
nsrefcnt count = mRefCnt.decr<NS_CycleCollectorSuspectUsingNursery>( \
|
||||
base, &shouldDelete); \
|
||||
NS_LOG_RELEASE(this, count, #_class); \
|
||||
if (count == 0) { \
|
||||
mRefCnt.incr<NS_CycleCollectorSuspectUsingNursery>(base); \
|
||||
_last; \
|
||||
mRefCnt.decr<NS_CycleCollectorSuspectUsingNursery>(base); \
|
||||
if (_maybeInterrupt) { \
|
||||
MOZ_ASSERT(mRefCnt.get() > 0); \
|
||||
return mRefCnt.get(); \
|
||||
} \
|
||||
if (shouldDelete) { \
|
||||
mRefCnt.stabilizeForDeletion(); \
|
||||
DeleteCycleCollectable(); \
|
||||
} \
|
||||
} \
|
||||
return count; \
|
||||
} \
|
||||
#define NS_IMPL_CYCLE_COLLECTING_RELEASE_WITH_INTERRUPTABLE_LAST_RELEASE( \
|
||||
_class, _last, _maybeInterrupt) \
|
||||
NS_IMETHODIMP_(MozExternalRefCountType) _class::Release(void) { \
|
||||
MOZ_ASSERT(int32_t(mRefCnt) > 0, "dup release"); \
|
||||
NS_ASSERT_OWNINGTHREAD(_class); \
|
||||
bool shouldDelete = false; \
|
||||
nsISupports* base = NS_CYCLE_COLLECTION_CLASSNAME(_class)::Upcast(this); \
|
||||
nsrefcnt count = mRefCnt.decr(base, &shouldDelete); \
|
||||
NS_LOG_RELEASE(this, count, #_class); \
|
||||
if (count == 0) { \
|
||||
mRefCnt.incr(base); \
|
||||
_last; \
|
||||
mRefCnt.decr(base); \
|
||||
if (_maybeInterrupt) { \
|
||||
MOZ_ASSERT(mRefCnt.get() > 0); \
|
||||
return mRefCnt.get(); \
|
||||
} \
|
||||
if (shouldDelete) { \
|
||||
mRefCnt.stabilizeForDeletion(); \
|
||||
DeleteCycleCollectable(); \
|
||||
} \
|
||||
} \
|
||||
return count; \
|
||||
} \
|
||||
NS_IMETHODIMP_(void) _class::DeleteCycleCollectable(void) { delete this; }
|
||||
|
||||
// _LAST_RELEASE can be useful when certain resources should be released
|
||||
// as soon as we know the object will be deleted.
|
||||
#define NS_IMPL_MAIN_THREAD_ONLY_CYCLE_COLLECTING_RELEASE_WITH_LAST_RELEASE_AND_DESTROY( \
|
||||
_class, _last, _destroy) \
|
||||
NS_IMETHODIMP_(MozExternalRefCountType) _class::Release(void) { \
|
||||
MOZ_ASSERT(int32_t(mRefCnt) > 0, "dup release"); \
|
||||
NS_ASSERT_OWNINGTHREAD(_class); \
|
||||
bool shouldDelete = false; \
|
||||
nsISupports* base = NS_CYCLE_COLLECTION_CLASSNAME(_class)::Upcast(this); \
|
||||
nsrefcnt count = mRefCnt.decr<NS_CycleCollectorSuspectUsingNursery>( \
|
||||
base, &shouldDelete); \
|
||||
NS_LOG_RELEASE(this, count, #_class); \
|
||||
if (count == 0) { \
|
||||
mRefCnt.incr<NS_CycleCollectorSuspectUsingNursery>(base); \
|
||||
_last; \
|
||||
mRefCnt.decr<NS_CycleCollectorSuspectUsingNursery>(base); \
|
||||
if (shouldDelete) { \
|
||||
mRefCnt.stabilizeForDeletion(); \
|
||||
DeleteCycleCollectable(); \
|
||||
} \
|
||||
} \
|
||||
return count; \
|
||||
} \
|
||||
NS_IMETHODIMP_(void) _class::DeleteCycleCollectable(void) { _destroy; }
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace mozilla::detail {
|
||||
|
|
|
|||
Loading…
Reference in a new issue