Bug 716067 - UnmarkGray more often (r=bent)

This commit is contained in:
Bill McCloskey 2012-02-10 18:32:13 -08:00
Родитель 686923a64b
Коммит 5578343c66
6 изменённых файлов: 26 добавлений и 11 удалений

Просмотреть файл

@ -582,11 +582,19 @@ inline void XPCNativeSet::ASSERT_NotMarked()
/***************************************************************************/
inline
JSObject* XPCWrappedNativeTearOff::GetJSObject() const
JSObject* XPCWrappedNativeTearOff::GetJSObjectPreserveColor() const
{
return mJSObject;
}
inline
JSObject* XPCWrappedNativeTearOff::GetJSObject()
{
JSObject *obj = GetJSObjectPreserveColor();
xpc_UnmarkGrayObject(obj);
return obj;
}
inline
void XPCWrappedNativeTearOff::SetJSObject(JSObject* JSObj)
{
@ -596,7 +604,7 @@ void XPCWrappedNativeTearOff::SetJSObject(JSObject* JSObj)
inline
XPCWrappedNativeTearOff::~XPCWrappedNativeTearOff()
{
NS_ASSERTION(!(GetInterface()||GetNative()||GetJSObject()), "tearoff not empty in dtor");
NS_ASSERTION(!(GetInterface()||GetNative()||GetJSObjectPreserveColor()), "tearoff not empty in dtor");
}
/***************************************************************************/
@ -621,7 +629,7 @@ XPCWrappedNative::SweepTearOffs()
// If this tearoff does not have a live dedicated JSObject,
// then let's recycle it.
if (!to->GetJSObject()) {
if (!to->GetJSObjectPreserveColor()) {
nsISupports* obj = to->GetNative();
if (obj) {
obj->Release();

Просмотреть файл

@ -171,7 +171,7 @@ XPCWrappedNative::NoteTearoffs(nsCycleCollectionTraversalCallback& cb)
for (chunk = &mFirstChunk; chunk; chunk = chunk->mNextChunk) {
XPCWrappedNativeTearOff* to = chunk->mTearOffs;
for (int i = XPC_WRAPPED_NATIVE_TEAROFFS_PER_CHUNK-1; i >= 0; i--, to++) {
JSObject* jso = to->GetJSObject();
JSObject* jso = to->GetJSObjectPreserveColor();
if (!jso) {
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "tearoff's mNative");
cb.NoteXPCOMChild(to->GetNative());
@ -1259,7 +1259,7 @@ XPCWrappedNative::FlatJSObjectFinalized()
for (chunk = &mFirstChunk; chunk; chunk = chunk->mNextChunk) {
XPCWrappedNativeTearOff* to = chunk->mTearOffs;
for (int i = XPC_WRAPPED_NATIVE_TEAROFFS_PER_CHUNK-1; i >= 0; i--, to++) {
JSObject* jso = to->GetJSObject();
JSObject* jso = to->GetJSObjectPreserveColor();
if (jso) {
NS_ASSERTION(JS_IsAboutToBeFinalized(jso), "bad!");
JS_SetPrivate(jso, nsnull);
@ -1363,8 +1363,8 @@ XPCWrappedNative::SystemIsBeingShutDown()
for (chunk = &mFirstChunk; chunk; chunk = chunk->mNextChunk) {
XPCWrappedNativeTearOff* to = chunk->mTearOffs;
for (int i = XPC_WRAPPED_NATIVE_TEAROFFS_PER_CHUNK-1; i >= 0; i--, to++) {
if (to->GetJSObject()) {
JS_SetPrivate(to->GetJSObject(), nsnull);
if (JSObject *jso = to->GetJSObjectPreserveColor()) {
JS_SetPrivate(jso, nsnull);
to->SetJSObject(nsnull);
}
// We leak the tearoff mNative
@ -1777,7 +1777,7 @@ XPCWrappedNative::FindTearOff(XPCCallContext& ccx,
to < end;
to++) {
if (to->GetInterface() == aInterface) {
if (needJSObject && !to->GetJSObject()) {
if (needJSObject && !to->GetJSObjectPreserveColor()) {
AutoMarkingWrappedNativeTearOffPtr tearoff(ccx, to);
JSBool ok = InitTearOffJSObject(ccx, to);
// During shutdown, we don't sweep tearoffs. So make sure

Просмотреть файл

@ -327,6 +327,8 @@ XPCWrappedNativeScope::GetPrototypeNoHelper(XPCCallContext& ccx)
NS_ASSERTION(mPrototypeNoHelper,
"Failed to create prototype for wrappers w/o a helper");
} else {
xpc_UnmarkGrayObject(mPrototypeNoHelper);
}
return mPrototypeNoHelper;

Просмотреть файл

@ -491,8 +491,10 @@ ListBase<LC>::getPrototype(JSContext *cx, XPCWrappedNativeScope *scope)
JSObject *interfacePrototype;
if (cache.IsInitialized()) {
if (cache.Get(sInterfaceClass.name, &interfacePrototype))
if (cache.Get(sInterfaceClass.name, &interfacePrototype)) {
xpc_UnmarkGrayObject(interfacePrototype);
return interfacePrototype;
}
} else if (!cache.Init()) {
return NULL;
}

Просмотреть файл

@ -2382,7 +2382,8 @@ public:
XPCNativeInterface* GetInterface() const {return mInterface;}
nsISupports* GetNative() const {return mNative;}
JSObject* GetJSObject() const;
JSObject* GetJSObject();
JSObject* GetJSObjectPreserveColor() const;
void SetInterface(XPCNativeInterface* Interface) {mInterface = Interface;}
void SetNative(nsISupports* Native) {mNative = Native;}
void SetJSObject(JSObject* JSObj);

Просмотреть файл

@ -103,8 +103,10 @@ WrapperFactory::WaiveXray(JSContext *cx, JSObject *obj)
CompartmentPrivate *priv =
(CompartmentPrivate *)JS_GetCompartmentPrivate(cx, js::GetObjectCompartment(obj));
JSObject *wobj = nsnull;
if (priv && priv->waiverWrapperMap)
if (priv && priv->waiverWrapperMap) {
wobj = priv->waiverWrapperMap->Find(obj);
xpc_UnmarkGrayObject(wobj);
}
// No wrapper yet, make one.
if (!wobj) {