diff --git a/mozilla/js/src/xpconnect/src/xpcprivate.h b/mozilla/js/src/xpconnect/src/xpcprivate.h index 9a02811a814..7540da77be2 100644 --- a/mozilla/js/src/xpconnect/src/xpcprivate.h +++ b/mozilla/js/src/xpconnect/src/xpcprivate.h @@ -78,6 +78,7 @@ #include "jsinterp.h" #include "jscntxt.h" #include "jsdbgapi.h" +#include "jsgc.h" #include "xptinfo.h" #include "xpcforwards.h" #include "xpclog.h" @@ -2172,6 +2173,9 @@ private: nsXPCWrappedJS* mRoot; nsXPCWrappedJS* mNext; nsISupports* mOuter; // only set in root +#ifdef GC_MARK_DEBUG + char *mGCRootName; +#endif }; /***************************************************************************/ diff --git a/mozilla/js/src/xpconnect/src/xpcwrappedjs.cpp b/mozilla/js/src/xpconnect/src/xpcwrappedjs.cpp index a9e100f2b09..0576ec850c7 100644 --- a/mozilla/js/src/xpconnect/src/xpcwrappedjs.cpp +++ b/mozilla/js/src/xpconnect/src/xpcwrappedjs.cpp @@ -127,8 +127,16 @@ nsXPCWrappedJS::AddRef(void) if(2 == cnt && IsValid()) { XPCCallContext ccx(NATIVE_CALLER); - if(ccx.IsValid()) + if(ccx.IsValid()) { +#ifdef GC_MARK_DEBUG + mGCRootName = JS_smprintf("nsXPCWrappedJS::mJSObj[%s,0x%p,0x%p]", + GetClass()->GetInterfaceName(), + this, mJSObj); + JS_AddNamedRoot(ccx.GetJSContext(), &mJSObj, mGCRootName); +#else JS_AddNamedRoot(ccx.GetJSContext(), &mJSObj, "nsXPCWrappedJS::mJSObj"); +#endif + } } return cnt; @@ -159,8 +167,13 @@ do_decrement: if(IsValid()) { XPCJSRuntime* rt = mClass->GetRuntime(); - if(rt) + if(rt) { JS_RemoveRootRT(rt->GetJSRuntime(), &mJSObj); +#ifdef GC_MARK_DEBUG + JS_smprintf_free(mGCRootName); + mGCRootName = nsnull; +#endif + } } // If we are not the root wrapper or if we are not being used from a @@ -309,6 +322,9 @@ nsXPCWrappedJS::nsXPCWrappedJS(XPCCallContext& ccx, mRoot(root ? root : this), mNext(nsnull), mOuter(root ? nsnull : aOuter) +#ifdef GC_MARK_DEBUG + , mGCRootName(nsnull) +#endif { #ifdef DEBUG_stats_jband static int count = 0;