Bug 770535, part 3 - Fold mMainThreadWrappedNativeProtoMap into mWrappedNativeProtoMap. r=bholley

With the removal of locks, these two maps are identical.
This commit is contained in:
Andrew McCreight 2013-11-24 11:03:29 -08:00
parent 22a229f621
commit 98a1da209e
3 changed files with 3 additions and 33 deletions

View File

@ -134,8 +134,7 @@ XPCWrappedNativeProto::JSProtoObjectFinalized(js::FreeOp *fop, JSObject *obj)
MOZ_ASSERT(obj == mJSProtoObject, "huh?");
// Only remove this proto from the map if it is the one in the map.
ClassInfo2WrappedNativeProtoMap* map =
GetScope()->GetWrappedNativeProtoMap(ClassIsMainThreadOnly());
ClassInfo2WrappedNativeProtoMap* map = GetScope()->GetWrappedNativeProtoMap();
if (map->Find(mClassInfo) == this)
map->Remove(mClassInfo);
@ -176,8 +175,7 @@ XPCWrappedNativeProto::GetNewOrUsed(XPCWrappedNativeScope* scope,
if (NS_FAILED(classInfo->GetFlags(&ciFlags)))
ciFlags = 0;
bool mainThreadOnly = !!(ciFlags & nsIClassInfo::MAIN_THREAD_ONLY);
map = scope->GetWrappedNativeProtoMap(mainThreadOnly);
map = scope->GetWrappedNativeProtoMap();
proto = map->Find(classInfo);
if (proto)
return proto;

View File

@ -68,7 +68,6 @@ XPCWrappedNativeScope::XPCWrappedNativeScope(JSContext *cx,
JS::HandleObject aGlobal)
: mWrappedNativeMap(Native2WrappedNativeMap::newMap(XPC_NATIVE_MAP_SIZE)),
mWrappedNativeProtoMap(ClassInfo2WrappedNativeProtoMap::newMap(XPC_NATIVE_PROTO_MAP_SIZE)),
mMainThreadWrappedNativeProtoMap(ClassInfo2WrappedNativeProtoMap::newMap(XPC_NATIVE_PROTO_MAP_SIZE)),
mComponents(nullptr),
mNext(nullptr),
mGlobalJSObject(aGlobal),
@ -258,11 +257,6 @@ XPCWrappedNativeScope::~XPCWrappedNativeScope()
delete mWrappedNativeProtoMap;
}
if (mMainThreadWrappedNativeProtoMap) {
MOZ_ASSERT(0 == mMainThreadWrappedNativeProtoMap->Count(), "scope has non-empty map");
delete mMainThreadWrappedNativeProtoMap;
}
if (mContext)
mContext->RemoveScope(this);
@ -411,7 +405,6 @@ XPCWrappedNativeScope::MarkAllWrappedNativesAndProtos()
for (XPCWrappedNativeScope* cur = gScopes; cur; cur = cur->mNext) {
cur->mWrappedNativeMap->Enumerate(WrappedNativeMarker, nullptr);
cur->mWrappedNativeProtoMap->Enumerate(WrappedNativeProtoMarker, nullptr);
cur->mMainThreadWrappedNativeProtoMap->Enumerate(WrappedNativeProtoMarker, nullptr);
}
}
@ -439,7 +432,6 @@ XPCWrappedNativeScope::ASSERT_NoInterfaceSetsAreMarked()
for (XPCWrappedNativeScope* cur = gScopes; cur; cur = cur->mNext) {
cur->mWrappedNativeMap->Enumerate(ASSERT_WrappedNativeSetNotMarked, nullptr);
cur->mWrappedNativeProtoMap->Enumerate(ASSERT_WrappedNativeProtoSetNotMarked, nullptr);
cur->mMainThreadWrappedNativeProtoMap->Enumerate(ASSERT_WrappedNativeProtoSetNotMarked, nullptr);
}
}
#endif
@ -542,8 +534,6 @@ XPCWrappedNativeScope::SystemIsBeingShutDown()
// proto pointers in the proto map.
cur->mWrappedNativeProtoMap->
Enumerate(WrappedNativeProtoShutdownEnumerator, &data);
cur->mMainThreadWrappedNativeProtoMap->
Enumerate(WrappedNativeProtoShutdownEnumerator, &data);
cur->mWrappedNativeMap->
Enumerate(WrappedNativeShutdownEnumerator, &data);
}
@ -571,7 +561,6 @@ XPCWrappedNativeScope::ClearAllWrappedNativeSecurityPolicies()
{
for (XPCWrappedNativeScope* cur = gScopes; cur; cur = cur->mNext) {
cur->mWrappedNativeProtoMap->Enumerate(WNProtoSecPolicyClearer, nullptr);
cur->mMainThreadWrappedNativeProtoMap->Enumerate(WNProtoSecPolicyClearer, nullptr);
}
return NS_OK;
@ -596,8 +585,6 @@ XPCWrappedNativeScope::RemoveWrappedNativeProtos()
{
mWrappedNativeProtoMap->Enumerate(WNProtoRemover,
GetRuntime()->GetDetachedWrappedNativeProtoMap());
mMainThreadWrappedNativeProtoMap->Enumerate(WNProtoRemover,
GetRuntime()->GetDetachedWrappedNativeProtoMap());
}
/***************************************************************************/
@ -672,16 +659,6 @@ XPCWrappedNativeScope::DebugDump(int16_t depth)
mWrappedNativeProtoMap->Enumerate(WrappedNativeProtoMapDumpEnumerator, &depth);
XPC_LOG_OUTDENT();
}
XPC_LOG_ALWAYS(("mMainThreadWrappedNativeProtoMap @ %x with %d protos(s)", \
mMainThreadWrappedNativeProtoMap, \
mMainThreadWrappedNativeProtoMap ? mMainThreadWrappedNativeProtoMap->Count() : 0));
// iterate contexts...
if (depth && mMainThreadWrappedNativeProtoMap && mMainThreadWrappedNativeProtoMap->Count()) {
XPC_LOG_INDENT();
mMainThreadWrappedNativeProtoMap->Enumerate(WrappedNativeProtoMapDumpEnumerator, &depth);
XPC_LOG_OUTDENT();
}
XPC_LOG_OUTDENT();
#endif
}
@ -703,7 +680,6 @@ XPCWrappedNativeScope::SizeOfIncludingThis(MallocSizeOf mallocSizeOf)
n += mallocSizeOf(this);
n += mWrappedNativeMap->SizeOfIncludingThis(mallocSizeOf);
n += mWrappedNativeProtoMap->SizeOfIncludingThis(mallocSizeOf);
n += mMainThreadWrappedNativeProtoMap->SizeOfIncludingThis(mallocSizeOf);
// There are other XPCWrappedNativeScope members that could be measured;
// the above ones have been seen by DMD to be worth measuring. More stuff

View File

@ -1075,10 +1075,7 @@ public:
GetWrappedNativeMap() const {return mWrappedNativeMap;}
ClassInfo2WrappedNativeProtoMap*
GetWrappedNativeProtoMap(bool aMainThreadOnly) const
{return aMainThreadOnly ?
mMainThreadWrappedNativeProtoMap :
mWrappedNativeProtoMap;}
GetWrappedNativeProtoMap() const {return mWrappedNativeProtoMap;}
nsXPCComponents*
GetComponents() const {return mComponents;}
@ -1208,7 +1205,6 @@ private:
XPCJSRuntime* mRuntime;
Native2WrappedNativeMap* mWrappedNativeMap;
ClassInfo2WrappedNativeProtoMap* mWrappedNativeProtoMap;
ClassInfo2WrappedNativeProtoMap* mMainThreadWrappedNativeProtoMap;
nsRefPtr<nsXPCComponents> mComponents;
XPCWrappedNativeScope* mNext;
// The JS global object for this scope. If non-null, this will be the