inline void ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback, mozilla::WebGLFramebuffer::Attachment& aField, const char* aName, uint32_t aFlags = 0) { CycleCollectionNoteEdgeName(aCallback, aName, aFlags); aCallback.NoteXPCOMChild(aField.mTexturePtr); aCallback.NoteXPCOMChild(aField.mRenderbufferPtr); }
void nsXBLPrototypeBinding::Traverse(nsCycleCollectionTraversalCallback &cb) const { NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "proto mBinding"); cb.NoteXPCOMChild(mBinding); if (mResources) { NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "proto mResources mLoader"); cb.NoteXPCOMChild(mResources->mLoader); } ImplCycleCollectionTraverse(cb, mInterfaceTable, "proto mInterfaceTable"); }
void nsSelectionState::DoTraverse(nsCycleCollectionTraversalCallback &cb) { for (uint32_t i = 0, iEnd = mArray.Length(); i < iEnd; ++i) { nsRangeStore* item = mArray[i]; NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "selection state mArray[i].startNode"); cb.NoteXPCOMChild(item->startNode); NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "selection state mArray[i].endNode"); cb.NoteXPCOMChild(item->endNode); } }
void EffectSet::Traverse(nsCycleCollectionTraversalCallback& aCallback) { for (auto iter = mEffects.Iter(); !iter.Done(); iter.Next()) { CycleCollectionNoteChild(aCallback, iter.Get()->GetKey(), "EffectSet::mEffects[]", aCallback.Flags()); } }
static void SuspectDOMExpandos(JSObject *obj, nsCycleCollectionTraversalCallback &cb) { const dom::DOMClass* clasp = dom::GetDOMClass(obj); MOZ_ASSERT(clasp && clasp->mDOMObjectIsISupports); nsISupports* native = dom::UnwrapDOMObject<nsISupports>(obj); cb.NoteXPCOMRoot(native); }
void nsXBLPrototypeResources::Traverse(nsCycleCollectionTraversalCallback &cb) { NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "proto mResources mLoader"); cb.NoteXPCOMChild(mLoader); CycleCollectionNoteChild(cb, mRuleProcessor.get(), "mRuleProcessor"); ImplCycleCollectionTraverse(cb, mStyleSheetList, "mStyleSheetList"); }
static void TraverseElements(nsCycleCollectionTraversalCallback& cb, const nsTArray<T>& array, const char* name) { for (uint32_t i = 0, length = array.Length(); i < length; ++i) { NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, name); AudioNode* node = array[i].get(); cb.NoteXPCOMChild(node); } }
static NS_METHOD TraverseImpl(JSContextParticipant *that, void *n, nsCycleCollectionTraversalCallback &cb) { JSContext *cx = static_cast<JSContext*>(n); // JSContexts do not have an internal refcount and always have a single // owner (e.g., nsJSContext). Thus, the default refcount is 1. However, // in the (abnormal) case of synchronous cycle-collection, the context // may be actively executing code in which case we want to treat it as // rooted by adding an extra refcount. unsigned refCount = js::ContextHasOutstandingRequests(cx) ? 2 : 1; cb.DescribeRefCountedNode(refCount, "JSContext"); if (JSObject *global = js::GetDefaultGlobalForContext(cx)) { NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "[global object]"); cb.NoteJSChild(global); } return NS_OK; }
void CycleCollectionNoteEdgeNameImpl(nsCycleCollectionTraversalCallback& aCallback, const char* aName, uint32_t aFlags) { nsAutoCString arrayEdgeName(aName); if (aFlags & CycleCollectionEdgeNameArrayFlag) { arrayEdgeName.AppendLiteral("[i]"); } aCallback.NoteNextEdgeName(arrayEdgeName.get()); }
void nsTransactionStack::DoTraverse(nsCycleCollectionTraversalCallback &cb) { for (PRInt32 i = 0, qcount = mQue.GetSize(); i < qcount; ++i) { nsTransactionItem *item = static_cast<nsTransactionItem*>(mQue.ObjectAt(i)); if (item) { NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "transaction stack mQue[i]"); cb.NoteNativeChild(item, &NS_CYCLE_COLLECTION_NAME(nsTransactionItem)); } } }
void nsTransactionStack::DoTraverse(nsCycleCollectionTraversalCallback &cb) { int32_t size = GetSize(); for (int32_t i = 0; i < size; ++i) { nsTransactionItem* item = static_cast<nsTransactionItem*>(nsDeque::ObjectAt(i)); if (item) { NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "transaction stack mDeque[i]"); cb.NoteNativeChild(item, NS_CYCLE_COLLECTION_PARTICIPANT(nsTransactionItem)); } } }
void XPCJSRuntime::AddXPConnectRoots(JSContext* cx, nsCycleCollectionTraversalCallback &cb) { // For all JS objects that are held by native objects but aren't held // through rooting or locking, we need to add all the native objects that // hold them so that the JS objects are colored correctly in the cycle // collector. This includes JSContexts that don't have outstanding requests, // because their global object wasn't marked by the JS GC. All other JS // roots were marked by the JS GC and will be colored correctly in the cycle // collector. JSContext *iter = nsnull, *acx; while((acx = JS_ContextIterator(GetJSRuntime(), &iter))) { #ifndef DEBUG_CC // Only skip JSContexts with outstanding requests if DEBUG_CC is not // defined, else we do want to know about all JSContexts to get better // graphs and explanations. if(nsXPConnect::GetXPConnect()->GetRequestDepth(acx) != 0) continue; #endif cb.NoteRoot(nsIProgrammingLanguage::CPLUSPLUS, acx, nsXPConnect::JSContextParticipant()); } XPCWrappedNativeScope::SuspectAllWrappers(this, cx, cb); for(XPCRootSetElem *e = mVariantRoots; e ; e = e->GetNextRoot()) cb.NoteXPCOMRoot(static_cast<XPCTraceableVariant*>(e)); for(XPCRootSetElem *e = mWrappedJSRoots; e ; e = e->GetNextRoot()) { nsIXPConnectWrappedJS *wrappedJS = static_cast<nsXPCWrappedJS*>(e); cb.NoteXPCOMRoot(wrappedJS); } if(mJSHolders.ops) JS_DHashTableEnumerate(&mJSHolders, NoteJSHolder, &cb); }
void nsHostObjectProtocolHandler::Traverse(const nsACString& aUri, nsCycleCollectionTraversalCallback& aCallback) { if (!gDataTable) { return; } DataInfo* res; gDataTable->Get(aUri, &res); if (!res) { return; } NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(aCallback, "HostObjectProtocolHandler DataInfo.mBlobImpl"); aCallback.NoteXPCOMChild(res->mBlobImpl); NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(aCallback, "HostObjectProtocolHandler DataInfo.mMediaSource"); aCallback.NoteXPCOMChild(res->mMediaSource); NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(aCallback, "HostObjectProtocolHandler DataInfo.mMediaStream"); aCallback.NoteXPCOMChild(res->mMediaStream); }
void CustomElementData::Traverse(nsCycleCollectionTraversalCallback& aCb) const { for (uint32_t i = 0; i < mReactionQueue.Length(); i++) { if (mReactionQueue[i]) { mReactionQueue[i]->Traverse(aCb); } } if (mCustomElementDefinition) { NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(aCb, "mCustomElementDefinition"); aCb.NoteNativeChild(mCustomElementDefinition, NS_CYCLE_COLLECTION_PARTICIPANT(CustomElementDefinition)); } }
NS_CYCLE_COLLECTION_CLASSNAME(nsXPCWrappedJS)::Traverse (void *p, nsCycleCollectionTraversalCallback &cb) { nsISupports *s = static_cast<nsISupports*>(p); NS_ASSERTION(CheckForRightISupports(s), "not the nsISupports pointer we expect"); nsXPCWrappedJS *tmp = Downcast(s); nsrefcnt refcnt = tmp->mRefCnt.get(); if (cb.WantDebugInfo()) { char name[72]; if (tmp->GetClass()) JS_snprintf(name, sizeof(name), "nsXPCWrappedJS (%s)", tmp->GetClass()->GetInterfaceName()); else JS_snprintf(name, sizeof(name), "nsXPCWrappedJS"); cb.DescribeNode(RefCounted, refcnt, sizeof(nsXPCWrappedJS), name); } else { cb.DescribeNode(RefCounted, refcnt, sizeof(nsXPCWrappedJS), "nsXPCWrappedJS"); } // nsXPCWrappedJS keeps its own refcount artificially at or above 1, see the // comment above nsXPCWrappedJS::AddRef. cb.NoteXPCOMChild(s); if(refcnt > 1) // nsXPCWrappedJS roots its mJSObj when its refcount is > 1, see // the comment above nsXPCWrappedJS::AddRef. cb.NoteScriptChild(nsIProgrammingLanguage::JAVASCRIPT, tmp->GetJSObject()); nsXPCWrappedJS* root = tmp->GetRootWrapper(); if(root == tmp) // The root wrapper keeps the aggregated native object alive. cb.NoteXPCOMChild(tmp->GetAggregatedNativeObject()); else // Non-root wrappers keep their root alive. cb.NoteXPCOMChild(static_cast<nsIXPConnectWrappedJS*>(root)); return NS_OK; }
NS_CYCLE_COLLECTION_CLASSNAME(nsXPCWrappedJS)::Traverse (void *p, nsCycleCollectionTraversalCallback &cb) { nsISupports *s = static_cast<nsISupports*>(p); NS_ASSERTION(CheckForRightISupports(s), "not the nsISupports pointer we expect"); nsXPCWrappedJS *tmp = Downcast(s); nsrefcnt refcnt = tmp->mRefCnt.get(); if (cb.WantDebugInfo()) { char name[72]; if (tmp->GetClass()) JS_snprintf(name, sizeof(name), "nsXPCWrappedJS (%s)", tmp->GetClass()->GetInterfaceName()); else JS_snprintf(name, sizeof(name), "nsXPCWrappedJS"); cb.DescribeRefCountedNode(refcnt, name); } else { NS_IMPL_CYCLE_COLLECTION_DESCRIBE(nsXPCWrappedJS, refcnt) } // nsXPCWrappedJS keeps its own refcount artificially at or above 1, see the // comment above nsXPCWrappedJS::AddRef. NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "self"); cb.NoteXPCOMChild(s); if (refcnt > 1) { // nsXPCWrappedJS roots its mJSObj when its refcount is > 1, see // the comment above nsXPCWrappedJS::AddRef. NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mJSObj"); cb.NoteJSChild(tmp->GetJSObjectPreserveColor()); } nsXPCWrappedJS* root = tmp->GetRootWrapper(); if (root == tmp) { // The root wrapper keeps the aggregated native object alive. NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "aggregated native"); cb.NoteXPCOMChild(tmp->GetAggregatedNativeObject()); } else { // Non-root wrappers keep their root alive. NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "root"); cb.NoteXPCOMChild(static_cast<nsIXPConnectWrappedJS*>(root)); } return NS_OK; }
NS_CYCLE_COLLECTION_CLASSNAME(nsXPCWrappedJS)::Traverse (void *p, nsCycleCollectionTraversalCallback &cb) { nsISupports *s = static_cast<nsISupports*>(p); MOZ_ASSERT(CheckForRightISupports(s), "not the nsISupports pointer we expect"); nsXPCWrappedJS *tmp = Downcast(s); nsrefcnt refcnt = tmp->mRefCnt.get(); if (cb.WantDebugInfo()) { char name[72]; if (tmp->GetClass()) JS_snprintf(name, sizeof(name), "nsXPCWrappedJS (%s)", tmp->GetClass()->GetInterfaceName()); else JS_snprintf(name, sizeof(name), "nsXPCWrappedJS"); cb.DescribeRefCountedNode(refcnt, name); } else { NS_IMPL_CYCLE_COLLECTION_DESCRIBE(nsXPCWrappedJS, refcnt) } // A wrapper that is subject to finalization will only die when its JS object dies. if (tmp->IsSubjectToFinalization()) return NS_OK; // Don't let the extra reference for nsSupportsWeakReference keep a wrapper that is // not subject to finalization alive. NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "self"); cb.NoteXPCOMChild(s); if (tmp->IsValid()) { MOZ_ASSERT(refcnt > 1); NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mJSObj"); cb.NoteJSChild(tmp->GetJSObjectPreserveColor()); } if (tmp->IsRootWrapper()) { NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "aggregated native"); cb.NoteXPCOMChild(tmp->GetAggregatedNativeObject()); } else { NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "root"); cb.NoteXPCOMChild(ToSupports(tmp->GetRootWrapper())); } return NS_OK; }
inline void ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback, nsListenerStruct& aField, const char* aName, unsigned aFlags) { if (MOZ_UNLIKELY(aCallback.WantDebugInfo())) { nsAutoCString name; name.AppendASCII(aName); if (aField.mTypeAtom) { name.AppendASCII(" event="); name.Append(nsAtomCString(aField.mTypeAtom)); name.AppendASCII(" listenerType="); name.AppendInt(aField.mListenerType); name.AppendASCII(" "); } CycleCollectionNoteChild(aCallback, aField.mListener.GetISupports(), name.get(), aFlags); } else { CycleCollectionNoteChild(aCallback, aField.mListener.GetISupports(), aName, aFlags); } }
void nsXBLPrototypeResources::Traverse(nsCycleCollectionTraversalCallback &cb) const { NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "proto mResources mLoader"); cb.NoteXPCOMChild(mLoader); }