Bug 1300830 - Remove XPCJSRuntime::mDetachedWrappedNativeProtoMap. r=mrbkap
Nothing is ever added to this hash table.
MozReview-Commit-ID: 7gmlBZKNPOc
--- a/js/xpconnect/src/XPCJSContext.cpp
+++ b/js/xpconnect/src/XPCJSContext.cpp
@@ -785,21 +785,16 @@ XPCJSContext::FinalizeCallback(JSFreeOp*
self->mGCIsRunning = true;
// We use this occasion to mark and sweep NativeInterfaces,
// NativeSets, and the WrappedNativeJSClasses...
// Do the marking...
XPCWrappedNativeScope::MarkAllWrappedNativesAndProtos();
- for (auto i = self->mDetachedWrappedNativeProtoMap->Iter(); !i.Done(); i.Next()) {
- auto entry = static_cast<XPCWrappedNativeProtoMap::Entry*>(i.Get());
- static_cast<const XPCWrappedNativeProto*>(entry->key)->Mark();
- }
-
// Mark the sets used in the call contexts. There is a small
// chance that a wrapper's set will change *while* a call is
// happening which uses that wrapper's old interfface set. So,
// we need to do this marking to avoid collecting those sets
// that might no longer be otherwise reachable from the wrappers
// or the wrapperprotos.
// Skip this part if XPConnect is shutting down. We get into
@@ -1490,25 +1485,16 @@ CompartmentPrivate::SizeOfIncludingThis(
size_t n = mallocSizeOf(this);
n += mWrappedJSMap->SizeOfIncludingThis(mallocSizeOf);
n += mWrappedJSMap->SizeOfWrappedJS(mallocSizeOf);
return n;
}
/***************************************************************************/
-void XPCJSContext::SystemIsBeingShutDown()
-{
- for (auto i = mDetachedWrappedNativeProtoMap->Iter(); !i.Done(); i.Next()) {
- auto entry = static_cast<XPCWrappedNativeProtoMap::Entry*>(i.Get());
- auto proto = const_cast<XPCWrappedNativeProto*>(static_cast<const XPCWrappedNativeProto*>(entry->key));
- proto->SystemIsBeingShutDown();
- }
-}
-
#define JS_OPTIONS_DOT_STR "javascript.options."
static void
ReloadPrefsCallback(const char* pref, void* data)
{
XPCJSContext* xpccx = reinterpret_cast<XPCJSContext*>(data);
JSContext* cx = xpccx->Context();
@@ -1639,19 +1625,16 @@ XPCJSContext::~XPCJSContext()
mThisTranslatorMap = nullptr;
delete mNativeScriptableSharedMap;
mNativeScriptableSharedMap = nullptr;
delete mDyingWrappedNativeProtoMap;
mDyingWrappedNativeProtoMap = nullptr;
- delete mDetachedWrappedNativeProtoMap;
- mDetachedWrappedNativeProtoMap = nullptr;
-
#ifdef MOZ_ENABLE_PROFILER_SPS
// Tell the profiler that the context is gone
if (PseudoStack* stack = mozilla_get_pseudo_stack())
stack->sampleContext(nullptr);
#endif
Preferences::UnregisterCallback(ReloadPrefsCallback, JS_OPTIONS_DOT_STR, this);
}
@@ -3313,17 +3296,16 @@ XPCJSContext::XPCJSContext()
mWrappedJSMap(JSObject2WrappedJSMap::newMap(XPC_JS_MAP_LENGTH)),
mWrappedJSClassMap(IID2WrappedJSClassMap::newMap(XPC_JS_CLASS_MAP_LENGTH)),
mIID2NativeInterfaceMap(IID2NativeInterfaceMap::newMap(XPC_NATIVE_INTERFACE_MAP_LENGTH)),
mClassInfo2NativeSetMap(ClassInfo2NativeSetMap::newMap(XPC_NATIVE_SET_MAP_LENGTH)),
mNativeSetMap(NativeSetMap::newMap(XPC_NATIVE_SET_MAP_LENGTH)),
mThisTranslatorMap(IID2ThisTranslatorMap::newMap(XPC_THIS_TRANSLATOR_MAP_LENGTH)),
mNativeScriptableSharedMap(XPCNativeScriptableSharedMap::newMap(XPC_NATIVE_JSCLASS_MAP_LENGTH)),
mDyingWrappedNativeProtoMap(XPCWrappedNativeProtoMap::newMap(XPC_DYING_NATIVE_PROTO_MAP_LENGTH)),
- mDetachedWrappedNativeProtoMap(XPCWrappedNativeProtoMap::newMap(XPC_DETACHED_NATIVE_PROTO_MAP_LENGTH)),
mGCIsRunning(false),
mNativesToReleaseArray(),
mDoingFinalization(false),
mVariantRoots(nullptr),
mWrappedJSRoots(nullptr),
mObjectHolderRoots(nullptr),
mWatchdogManager(new WatchdogManager(this)),
mAsyncSnowWhiteFreer(new AsyncFreeSnowWhite()),
--- a/js/xpconnect/src/XPCWrappedNativeProto.cpp
+++ b/js/xpconnect/src/XPCWrappedNativeProto.cpp
@@ -117,17 +117,16 @@ XPCWrappedNativeProto::JSProtoObjectFina
{
MOZ_ASSERT(obj == mJSProtoObject, "huh?");
// Only remove this proto from the map if it is the one in the map.
ClassInfo2WrappedNativeProtoMap* map = GetScope()->GetWrappedNativeProtoMap();
if (map->Find(mClassInfo) == this)
map->Remove(mClassInfo);
- GetContext()->GetDetachedWrappedNativeProtoMap()->Remove(this);
GetContext()->GetDyingWrappedNativeProtoMap()->Add(this);
mJSProtoObject.finalize(js::CastToJSFreeOp(fop)->runtime());
}
void
XPCWrappedNativeProto::JSProtoObjectMoved(JSObject* obj, const JSObject* old)
{
--- a/js/xpconnect/src/nsXPConnect.cpp
+++ b/js/xpconnect/src/nsXPConnect.cpp
@@ -78,17 +78,16 @@ nsXPConnect::~nsXPConnect()
// we unrooted above), and once after forcing a bunch of shutdown in
// XPConnect, to clean the stuff we forcibly disconnected. The forced
// shutdown code defaults to leaking in a number of situations, so we can't
// get by with only the second GC. :-(
mContext->GarbageCollect(JS::gcreason::XPCONNECT_SHUTDOWN);
mShuttingDown = true;
XPCWrappedNativeScope::SystemIsBeingShutDown();
- mContext->SystemIsBeingShutDown();
// The above causes us to clean up a bunch of XPConnect data structures,
// after which point we need to GC to clean everything up. We need to do
// this before deleting the XPCJSContext, because doing so destroys the
// maps that our finalize callback depends on.
mContext->GarbageCollect(JS::gcreason::XPCONNECT_SHUTDOWN);
NS_RELEASE(gSystemPrincipal);
--- a/js/xpconnect/src/xpcprivate.h
+++ b/js/xpconnect/src/xpcprivate.h
@@ -173,17 +173,16 @@
// default initial sizes for maps (hashtables)
#define XPC_JS_MAP_LENGTH 32
#define XPC_JS_CLASS_MAP_LENGTH 32
#define XPC_NATIVE_MAP_LENGTH 8
#define XPC_NATIVE_PROTO_MAP_LENGTH 8
#define XPC_DYING_NATIVE_PROTO_MAP_LENGTH 8
-#define XPC_DETACHED_NATIVE_PROTO_MAP_LENGTH 16
#define XPC_NATIVE_INTERFACE_MAP_LENGTH 32
#define XPC_NATIVE_SET_MAP_LENGTH 32
#define XPC_NATIVE_JSCLASS_MAP_LENGTH 16
#define XPC_THIS_TRANSLATOR_MAP_LENGTH 4
#define XPC_WRAPPER_MAP_LENGTH 8
/***************************************************************************/
// data declarations...
@@ -450,19 +449,16 @@ public:
{return mThisTranslatorMap;}
XPCNativeScriptableSharedMap* GetNativeScriptableSharedMap() const
{return mNativeScriptableSharedMap;}
XPCWrappedNativeProtoMap* GetDyingWrappedNativeProtoMap() const
{return mDyingWrappedNativeProtoMap;}
- XPCWrappedNativeProtoMap* GetDetachedWrappedNativeProtoMap() const
- {return mDetachedWrappedNativeProtoMap;}
-
bool JSContextInitialized(JSContext* cx);
virtual bool
DescribeCustomObjects(JSObject* aObject, const js::Class* aClasp,
char (&aName)[72]) const override;
virtual bool
NoteCustomGCThingXPCOMChildren(const js::Class* aClasp, JSObject* aObj,
nsCycleCollectionTraversalCallback& aCb) const override;
@@ -560,18 +556,16 @@ public:
static void WeakPointerCompartmentCallback(JSContext* cx, JSCompartment* comp, void* data);
inline void AddVariantRoot(XPCTraceableVariant* variant);
inline void AddWrappedJSRoot(nsXPCWrappedJS* wrappedJS);
inline void AddObjectHolderRoot(XPCJSObjectHolder* holder);
void DebugDump(int16_t depth);
- void SystemIsBeingShutDown();
-
bool GCIsRunning() const {return mGCIsRunning;}
~XPCJSContext();
ShortLivedStringBuffer<nsString> mScratchStrings;
ShortLivedStringBuffer<nsCString> mScratchCStrings;
void AddGCCallback(xpcGCCallback cb);
@@ -614,17 +608,16 @@ private:
JSObject2WrappedJSMap* mWrappedJSMap;
IID2WrappedJSClassMap* mWrappedJSClassMap;
IID2NativeInterfaceMap* mIID2NativeInterfaceMap;
ClassInfo2NativeSetMap* mClassInfo2NativeSetMap;
NativeSetMap* mNativeSetMap;
IID2ThisTranslatorMap* mThisTranslatorMap;
XPCNativeScriptableSharedMap* mNativeScriptableSharedMap;
XPCWrappedNativeProtoMap* mDyingWrappedNativeProtoMap;
- XPCWrappedNativeProtoMap* mDetachedWrappedNativeProtoMap;
bool mGCIsRunning;
nsTArray<nsISupports*> mNativesToReleaseArray;
bool mDoingFinalization;
XPCRootSetElem* mVariantRoots;
XPCRootSetElem* mWrappedJSRoots;
XPCRootSetElem* mObjectHolderRoots;
nsTArray<xpcGCCallback> extraGCCallbacks;
RefPtr<WatchdogManager> mWatchdogManager;