diff --git a/js/xpconnect/src/XPCJSRuntime.cpp b/js/xpconnect/src/XPCJSRuntime.cpp index 4320fe5eb71..53d40658bd2 100644 --- a/js/xpconnect/src/XPCJSRuntime.cpp +++ b/js/xpconnect/src/XPCJSRuntime.cpp @@ -111,9 +111,6 @@ bool xpc::ExtraWarningsForSystemJS() { return sExtraWarningsForSystemJS; } bool xpc::ExtraWarningsForSystemJS() { return false; } #endif -static void * const UNMARK_ONLY = nullptr; -static void * const UNMARK_AND_SWEEP = (void*)1; - // *Some* NativeSets are referenced from mClassInfo2NativeSetMap. // *All* NativeSets are referenced from mNativeSetMap. // So, in mClassInfo2NativeSetMap we just clear references to the unmarked. @@ -811,7 +808,7 @@ XPCJSRuntime::FinalizeCallback(JSFreeOp* fop, // kept separate, we could sweep only the ones belonging to // compartments being collected. Currently, though, NativeInterfaces // are shared between compartments. This ought to be fixed. - void* sweepArg = isCompartmentGC ? UNMARK_ONLY : UNMARK_AND_SWEEP; + bool doSweep = !isCompartmentGC; // We don't want to sweep the JSClasses at shutdown time. // At this point there may be JSObjects using them that have @@ -822,13 +819,10 @@ XPCJSRuntime::FinalizeCallback(JSFreeOp* fop, XPCNativeScriptableShared* shared = entry->key; if (shared->IsMarked()) { shared->Unmark(); - continue; + } else if (doSweep) { + delete shared; + i.Remove(); } - if (sweepArg == UNMARK_ONLY) - continue; - - delete shared; - i.Remove(); } } @@ -845,13 +839,10 @@ XPCJSRuntime::FinalizeCallback(JSFreeOp* fop, XPCNativeSet* set = entry->key_value; if (set->IsMarked()) { set->Unmark(); - continue; + } else if (doSweep) { + XPCNativeSet::DestroyInstance(set); + i.Remove(); } - if (sweepArg == UNMARK_ONLY) - continue; - - XPCNativeSet::DestroyInstance(set); - i.Remove(); } for (auto i = self->mIID2NativeInterfaceMap->RemovingIter(); !i.Done(); i.Next()) { @@ -859,13 +850,10 @@ XPCJSRuntime::FinalizeCallback(JSFreeOp* fop, XPCNativeInterface* iface = entry->value; if (iface->IsMarked()) { iface->Unmark(); - continue; + } else if (doSweep) { + XPCNativeInterface::DestroyInstance(iface); + i.Remove(); } - if (sweepArg == UNMARK_ONLY) - continue; - - XPCNativeInterface::DestroyInstance(iface); - i.Remove(); } #ifdef DEBUG