diff --git a/xpcom/base/CycleCollectedJSRuntime.cpp b/xpcom/base/CycleCollectedJSRuntime.cpp index f8e72480bf8f..3e9fe026b572 100644 --- a/xpcom/base/CycleCollectedJSRuntime.cpp +++ b/xpcom/base/CycleCollectedJSRuntime.cpp @@ -1181,25 +1181,26 @@ static inline void CheckHolderIsSingleZone( aParticipant->Trace(aHolder, tracer, nullptr); } -#endif - static inline bool ShouldCheckSingleZoneHolders() { -#if defined(DEBUG) +# ifdef DEBUG return true; -#elif defined(NIGHTLY_BUILD) || defined(MOZ_DEV_EDITION) +# else // Don't check every time to avoid performance impact. return rand() % 256 == 0; -#else - return false; # endif } +#endif + void CycleCollectedJSRuntime::TraceNativeGrayRoots(JSTracer* aTracer) { // NB: This is here just to preserve the existing XPConnect order. I doubt it // would hurt to do this after the JS holders. TraceAdditionalNativeGrayRoots(aTracer); +#ifdef CHECK_SINGLE_ZONE_JS_HOLDERS bool checkSingleZoneHolders = ShouldCheckSingleZoneHolders(); +#endif + mJSHolders.ForEach([aTracer, checkSingleZoneHolders]( void* holder, nsScriptObjectTracer* tracer) { #ifdef CHECK_SINGLE_ZONE_JS_HOLDERS