mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-16 06:45:42 +00:00
Bug 700668 - Don't enumerate all compartments for every traversal of a XPCWrappedNative. r=mrbkap.
This commit is contained in:
parent
b6eb396961
commit
d424202e66
@ -138,13 +138,15 @@ NS_CYCLE_COLLECTION_CLASSNAME(XPCWrappedNative)::Traverse(void *p,
|
||||
cb.NoteScriptChild(nsIProgrammingLanguage::JAVASCRIPT, obj);
|
||||
}
|
||||
|
||||
XPCJSRuntime *rt = tmp->GetRuntime();
|
||||
TraverseExpandoObjectClosure closure = {
|
||||
rt->GetXPConnect()->GetCycleCollectionContext()->GetJSContext(),
|
||||
tmp,
|
||||
cb
|
||||
};
|
||||
rt->GetCompartmentMap().EnumerateRead(TraverseExpandoObjects, &closure);
|
||||
if (tmp->MightHaveExpandoObject()) {
|
||||
XPCJSRuntime *rt = tmp->GetRuntime();
|
||||
TraverseExpandoObjectClosure closure = {
|
||||
rt->GetXPConnect()->GetCycleCollectionContext()->GetJSContext(),
|
||||
tmp,
|
||||
cb
|
||||
};
|
||||
rt->GetCompartmentMap().EnumerateRead(TraverseExpandoObjects, &closure);
|
||||
}
|
||||
|
||||
// XPCWrappedNative keeps its native object alive.
|
||||
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mIdentity");
|
||||
|
@ -277,9 +277,9 @@ class PtrAndPrincipalHashKey : public PLDHashEntryHdr
|
||||
return aKey->mSavedHash;
|
||||
}
|
||||
|
||||
nsISupports* GetPtr()
|
||||
{
|
||||
return mPtr;
|
||||
nsISupports* GetPtr()
|
||||
{
|
||||
return mPtr;
|
||||
}
|
||||
|
||||
enum { ALLOW_MEMMOVE = true };
|
||||
@ -2744,6 +2744,8 @@ public:
|
||||
void SetNeedsSOW() { mWrapperWord |= NEEDS_SOW; }
|
||||
JSBool NeedsCOW() { return !!(mWrapperWord & NEEDS_COW); }
|
||||
void SetNeedsCOW() { mWrapperWord |= NEEDS_COW; }
|
||||
JSBool MightHaveExpandoObject() { return !!(mWrapperWord & MIGHT_HAVE_EXPANDO); }
|
||||
void SetHasExpandoObject() { mWrapperWord |= MIGHT_HAVE_EXPANDO; }
|
||||
|
||||
JSObject* GetWrapperPreserveColor() const
|
||||
{return (JSObject*)(mWrapperWord & (size_t)~(size_t)FLAG_MASK);}
|
||||
@ -2760,11 +2762,7 @@ public:
|
||||
}
|
||||
void SetWrapper(JSObject *obj)
|
||||
{
|
||||
PRWord needsSOW = NeedsSOW() ? NEEDS_SOW : 0;
|
||||
PRWord needsCOW = NeedsCOW() ? NEEDS_COW : 0;
|
||||
mWrapperWord = PRWord(obj) |
|
||||
needsSOW |
|
||||
needsCOW;
|
||||
mWrapperWord = PRWord(obj) | (mWrapperWord & FLAG_MASK);
|
||||
}
|
||||
|
||||
void NoteTearoffs(nsCycleCollectionTraversalCallback& cb);
|
||||
@ -2803,10 +2801,8 @@ private:
|
||||
enum {
|
||||
NEEDS_SOW = JS_BIT(0),
|
||||
NEEDS_COW = JS_BIT(1),
|
||||
|
||||
LAST_FLAG = NEEDS_COW,
|
||||
|
||||
FLAG_MASK = 0x7
|
||||
MIGHT_HAVE_EXPANDO = JS_BIT(2),
|
||||
FLAG_MASK = JS_BITMASK(3)
|
||||
};
|
||||
|
||||
private:
|
||||
@ -4379,7 +4375,7 @@ xpc_GetJSPrivate(JSObject *obj)
|
||||
// and used.
|
||||
nsresult
|
||||
xpc_CreateSandboxObject(JSContext * cx, jsval * vp, nsISupports *prinOrSop,
|
||||
JSObject *proto, bool preferXray, const nsACString &sandboxName,
|
||||
JSObject *proto, bool preferXray, const nsACString &sandboxName,
|
||||
nsISupports *identityPtr = nsnull);
|
||||
// Helper for evaluating scripts in a sandbox object created with
|
||||
// xpc_CreateSandboxObject(). The caller is responsible of ensuring
|
||||
@ -4467,6 +4463,7 @@ struct CompartmentPrivate
|
||||
return false;
|
||||
}
|
||||
}
|
||||
wn->SetHasExpandoObject();
|
||||
return expandoMap->Put(wn, expando);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user