Bug 1044205 - Invoke XPCWrappedNativeScope::TraceSelf from TraceXPCGlobal. r=billm

This commit is contained in:
Bobby Holley 2014-07-29 08:48:32 -07:00
parent 22790b10a5
commit bba4516624
4 changed files with 13 additions and 14 deletions

View File

@ -2504,15 +2504,7 @@ ConvertExceptionToPromise(JSContext* cx,
void void
CreateGlobalOptions<nsGlobalWindow>::TraceGlobal(JSTracer* aTrc, JSObject* aObj) CreateGlobalOptions<nsGlobalWindow>::TraceGlobal(JSTracer* aTrc, JSObject* aObj)
{ {
mozilla::dom::TraceProtoAndIfaceCache(aTrc, aObj); xpc::TraceXPCGlobal(aTrc, aObj);
// We might be called from a GC during the creation of a global, before we've
// been able to set up the compartment private or the XPCWrappedNativeScope,
// so we need to null-check those.
xpc::CompartmentPrivate* compartmentPrivate = xpc::CompartmentPrivate::Get(aObj);
if (compartmentPrivate && compartmentPrivate->scope) {
compartmentPrivate->scope->TraceSelf(aTrc);
}
} }
/* static */ /* static */

View File

@ -298,10 +298,17 @@ static inline T UnexpectedFailure(T rv)
} }
void void
TraceXPCGlobal(JSTracer *trc, JSObject *obj) xpc::TraceXPCGlobal(JSTracer *trc, JSObject *obj)
{ {
if (js::GetObjectClass(obj)->flags & JSCLASS_DOM_GLOBAL) if (js::GetObjectClass(obj)->flags & JSCLASS_DOM_GLOBAL)
mozilla::dom::TraceProtoAndIfaceCache(trc, obj); mozilla::dom::TraceProtoAndIfaceCache(trc, obj);
// We might be called from a GC during the creation of a global, before we've
// been able to set up the compartment private or the XPCWrappedNativeScope,
// so we need to null-check those.
xpc::CompartmentPrivate* compartmentPrivate = xpc::CompartmentPrivate::Get(obj);
if (compartmentPrivate && compartmentPrivate->scope)
compartmentPrivate->scope->TraceSelf(trc);
} }
namespace xpc { namespace xpc {

View File

@ -1987,9 +1987,6 @@ private:
void *xpc_GetJSPrivate(JSObject *obj); void *xpc_GetJSPrivate(JSObject *obj);
void
TraceXPCGlobal(JSTracer *trc, JSObject *obj);
/***************************************************************************/ /***************************************************************************/
// XPCWrappedNative the wrapper around one instance of a native xpcom object // XPCWrappedNative the wrapper around one instance of a native xpcom object
// to be used from JavaScript. // to be used from JavaScript.
@ -2180,7 +2177,7 @@ public:
GetScope()->TraceSelf(trc); GetScope()->TraceSelf(trc);
if (mFlatJSObject && JS_IsGlobalObject(mFlatJSObject)) if (mFlatJSObject && JS_IsGlobalObject(mFlatJSObject))
{ {
TraceXPCGlobal(trc, mFlatJSObject); xpc::TraceXPCGlobal(trc, mFlatJSObject);
} }
} }

View File

@ -139,6 +139,9 @@ IsXrayWrapper(JSObject *obj);
JSObject * JSObject *
XrayAwareCalleeGlobal(JSObject *fun); XrayAwareCalleeGlobal(JSObject *fun);
void
TraceXPCGlobal(JSTracer *trc, JSObject *obj);
} /* namespace xpc */ } /* namespace xpc */
namespace JS { namespace JS {