зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1184400, part 1 - Make XPCJSRuntime::SuspectWrappedNative into a method on XPCWrappedNative. r=bholley
This commit is contained in:
Родитель
f3d75a224c
Коммит
e7070f39fe
|
@ -571,24 +571,6 @@ void XPCJSRuntime::TraceAdditionalNativeGrayRoots(JSTracer* trc)
|
||||||
static_cast<nsXPCWrappedJS*>(e)->TraceJS(trc);
|
static_cast<nsXPCWrappedJS*>(e)->TraceJS(trc);
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
|
||||||
void
|
|
||||||
XPCJSRuntime::SuspectWrappedNative(XPCWrappedNative* wrapper,
|
|
||||||
nsCycleCollectionNoteRootCallback& cb)
|
|
||||||
{
|
|
||||||
if (!wrapper->IsValid() || wrapper->IsWrapperExpired())
|
|
||||||
return;
|
|
||||||
|
|
||||||
MOZ_ASSERT(NS_IsMainThread(),
|
|
||||||
"Suspecting wrapped natives from non-main thread");
|
|
||||||
|
|
||||||
// Only record objects that might be part of a cycle as roots, unless
|
|
||||||
// the callback wants all traces (a debug feature).
|
|
||||||
JSObject* obj = wrapper->GetFlatJSObjectPreserveColor();
|
|
||||||
if (JS::ObjectIsMarkedGray(obj) || cb.WantAllTraces())
|
|
||||||
cb.NoteJSRoot(obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
XPCJSRuntime::TraverseAdditionalNativeRoots(nsCycleCollectionNoteRootCallback& cb)
|
XPCJSRuntime::TraverseAdditionalNativeRoots(nsCycleCollectionNoteRootCallback& cb)
|
||||||
{
|
{
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include "XrayWrapper.h"
|
#include "XrayWrapper.h"
|
||||||
|
|
||||||
#include "nsContentUtils.h"
|
#include "nsContentUtils.h"
|
||||||
|
#include "nsCycleCollectionNoteRootCallback.h"
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "mozilla/DeferredFinalize.h"
|
#include "mozilla/DeferredFinalize.h"
|
||||||
|
@ -93,6 +94,22 @@ NS_CYCLE_COLLECTION_CLASSNAME(XPCWrappedNative)::Traverse
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
XPCWrappedNative::Suspect(nsCycleCollectionNoteRootCallback& cb)
|
||||||
|
{
|
||||||
|
if (!IsValid() || IsWrapperExpired())
|
||||||
|
return;
|
||||||
|
|
||||||
|
MOZ_ASSERT(NS_IsMainThread(),
|
||||||
|
"Suspecting wrapped natives from non-main thread");
|
||||||
|
|
||||||
|
// Only record objects that might be part of a cycle as roots, unless
|
||||||
|
// the callback wants all traces (a debug feature).
|
||||||
|
JSObject* obj = GetFlatJSObjectPreserveColor();
|
||||||
|
if (JS::ObjectIsMarkedGray(obj) || cb.WantAllTraces())
|
||||||
|
cb.NoteJSRoot(obj);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
XPCWrappedNative::NoteTearoffs(nsCycleCollectionTraversalCallback& cb)
|
XPCWrappedNative::NoteTearoffs(nsCycleCollectionTraversalCallback& cb)
|
||||||
{
|
{
|
||||||
|
|
|
@ -500,7 +500,7 @@ XPCWrappedNativeScope::SuspectAllWrappers(XPCJSRuntime* rt,
|
||||||
auto entry = static_cast<Native2WrappedNativeMap::Entry*>(i.Get());
|
auto entry = static_cast<Native2WrappedNativeMap::Entry*>(i.Get());
|
||||||
XPCWrappedNative* wrapper = entry->value;
|
XPCWrappedNative* wrapper = entry->value;
|
||||||
if (wrapper->HasExternalReference())
|
if (wrapper->HasExternalReference())
|
||||||
XPCJSRuntime::SuspectWrappedNative(wrapper, cb);
|
wrapper->Suspect(cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cur->mDOMExpandoSet) {
|
if (cur->mDOMExpandoSet) {
|
||||||
|
|
|
@ -580,9 +580,6 @@ public:
|
||||||
inline void AddWrappedJSRoot(nsXPCWrappedJS* wrappedJS);
|
inline void AddWrappedJSRoot(nsXPCWrappedJS* wrappedJS);
|
||||||
inline void AddObjectHolderRoot(XPCJSObjectHolder* holder);
|
inline void AddObjectHolderRoot(XPCJSObjectHolder* holder);
|
||||||
|
|
||||||
static void SuspectWrappedNative(XPCWrappedNative* wrapper,
|
|
||||||
nsCycleCollectionNoteRootCallback& cb);
|
|
||||||
|
|
||||||
void DebugDump(int16_t depth);
|
void DebugDump(int16_t depth);
|
||||||
|
|
||||||
void SystemIsBeingShutDown();
|
void SystemIsBeingShutDown();
|
||||||
|
@ -2247,6 +2244,7 @@ public:
|
||||||
|
|
||||||
bool HasExternalReference() const {return mRefCnt > 1;}
|
bool HasExternalReference() const {return mRefCnt > 1;}
|
||||||
|
|
||||||
|
void Suspect(nsCycleCollectionNoteRootCallback& cb);
|
||||||
void NoteTearoffs(nsCycleCollectionTraversalCallback& cb);
|
void NoteTearoffs(nsCycleCollectionTraversalCallback& cb);
|
||||||
|
|
||||||
// Make ctor and dtor protected (rather than private) to placate nsCOMPtr.
|
// Make ctor and dtor protected (rather than private) to placate nsCOMPtr.
|
||||||
|
|
Загрузка…
Ссылка в новой задаче