diff --git a/js/xpconnect/src/XPCJSRuntime.cpp b/js/xpconnect/src/XPCJSRuntime.cpp index 99666aebb20..f880c7317c1 100644 --- a/js/xpconnect/src/XPCJSRuntime.cpp +++ b/js/xpconnect/src/XPCJSRuntime.cpp @@ -680,21 +680,6 @@ xpc_UnmarkSkippableJSHolders() } } -template static void -DoDeferredRelease(nsTArray& array) -{ - while (1) { - uint32_t count = array.Length(); - if (!count) { - array.Compact(); - break; - } - T wrapper = array[count-1]; - array.RemoveElementAt(count-1); - NS_RELEASE(wrapper); - } -} - /* static */ void XPCJSRuntime::GCSliceCallback(JSRuntime* rt, JS::GCProgress progress, @@ -747,10 +732,6 @@ XPCJSRuntime::FinalizeCallback(JSFreeOp* fop, MOZ_ASSERT(self->mDoingFinalization, "bad state"); self->mDoingFinalization = false; - // Release all the members whose JSObjects are now known - // to be dead. - DoDeferredRelease(self->mWrappedJSToReleaseArray); - // Sweep scopes needing cleanup XPCWrappedNativeScope::KillDyingScopes(); @@ -945,7 +926,6 @@ XPCJSRuntime::WeakPointerZoneGroupCallback(JSRuntime* rt, void* data) // about to be finalized and update any pointers to moved GC things. XPCJSRuntime* self = static_cast(data); - MOZ_ASSERT(self->WrappedJSToReleaseArray().IsEmpty()); self->mWrappedJSMap->UpdateWeakPointersAfterGC(self); XPCWrappedNativeScope::UpdateWeakPointersAfterGC(self); @@ -3336,7 +3316,6 @@ XPCJSRuntime::XPCJSRuntime(nsXPConnect* aXPConnect) mDyingWrappedNativeProtoMap(XPCWrappedNativeProtoMap::newMap(XPC_DYING_NATIVE_PROTO_MAP_LENGTH)), mDetachedWrappedNativeProtoMap(XPCWrappedNativeProtoMap::newMap(XPC_DETACHED_NATIVE_PROTO_MAP_LENGTH)), mGCIsRunning(false), - mWrappedJSToReleaseArray(), mNativesToReleaseArray(), mDoingFinalization(false), mVariantRoots(nullptr), @@ -3675,10 +3654,6 @@ XPCJSRuntime::DebugDump(int16_t depth) XPC_LOG_INDENT(); XPC_LOG_ALWAYS(("mJSRuntime @ %x", Runtime())); - XPC_LOG_ALWAYS(("mWrappedJSToReleaseArray @ %x with %d wrappers(s)", - &mWrappedJSToReleaseArray, - mWrappedJSToReleaseArray.Length())); - int cxCount = 0; JSContext* iter = nullptr; while (JS_ContextIterator(Runtime(), &iter)) diff --git a/js/xpconnect/src/XPCMaps.cpp b/js/xpconnect/src/XPCMaps.cpp index 0437c056cb3..297e9776ce7 100644 --- a/js/xpconnect/src/XPCMaps.cpp +++ b/js/xpconnect/src/XPCMaps.cpp @@ -88,14 +88,9 @@ void JSObject2WrappedJSMap::UpdateWeakPointersAfterGC(XPCJSRuntime* runtime) { // Check all wrappers and update their JSObject pointer if it has been - // moved, or if it is about to be finalized queue the wrapper for - // destruction by adding it to an array held by the runtime. - // Note that we do not want to be changing the refcount of these wrappers. - // We add them to the array now and Release the array members later to avoid - // the posibility of doing any JS GCThing allocations during the gc cycle. - - nsTArray& dying = runtime->WrappedJSToReleaseArray(); + // moved. Release any wrappers whose weakly held JSObject has died. + nsTArray> dying; for (Map::Enum e(mTable); !e.empty(); e.popFront()) { nsXPCWrappedJS* wrapper = e.front().value(); MOZ_ASSERT(wrapper, "found a null JS wrapper!"); @@ -117,7 +112,7 @@ JSObject2WrappedJSMap::UpdateWeakPointersAfterGC(XPCJSRuntime* runtime) if (wrapper->IsSubjectToFinalization()) { wrapper->UpdateObjectPointerAfterGC(); if (!wrapper->GetJSObjectPreserveColor()) - dying.AppendElement(wrapper); + dying.AppendElement(dont_AddRef(wrapper)); } wrapper = wrapper->GetNextWrapper(); } diff --git a/js/xpconnect/src/xpcprivate.h b/js/xpconnect/src/xpcprivate.h index fc0c384e4bb..8ddef8749b5 100644 --- a/js/xpconnect/src/xpcprivate.h +++ b/js/xpconnect/src/xpcprivate.h @@ -612,8 +612,6 @@ public: PRTime GetWatchdogTimestamp(WatchdogTimestampCategory aCategory); - nsTArray& WrappedJSToReleaseArray() { return mWrappedJSToReleaseArray; } - private: XPCJSRuntime() = delete; explicit XPCJSRuntime(nsXPConnect* aXPConnect); @@ -639,7 +637,6 @@ private: XPCWrappedNativeProtoMap* mDyingWrappedNativeProtoMap; XPCWrappedNativeProtoMap* mDetachedWrappedNativeProtoMap; bool mGCIsRunning; - nsTArray mWrappedJSToReleaseArray; nsTArray mNativesToReleaseArray; bool mDoingFinalization; XPCRootSetElem* mVariantRoots;