Bug 937157, part 8 - Remove XPC_TRACK_SCOPE_STATS. r=bholley
authorAndrew McCreight <continuation@gmail.com>
Sun, 17 Nov 2013 14:47:00 -0800
changeset 155456 3f46c9ffdc9a848fd7302185f8cc3bcdff0729fb
parent 155455 0bbf398ade29a2c22c4b656b7b6e556a2ee79047
child 155457 53edeffc65c2dff946e62667960513675bb59a06
push id270
push userpvanderbeken@mozilla.com
push dateThu, 06 Mar 2014 09:24:21 +0000
reviewersbholley
bugs937157
milestone28.0a1
Bug 937157, part 8 - Remove XPC_TRACK_SCOPE_STATS. r=bholley
js/xpconnect/src/XPCWrappedNativeScope.cpp
js/xpconnect/src/xpcprivate.h
--- a/js/xpconnect/src/XPCWrappedNativeScope.cpp
+++ b/js/xpconnect/src/XPCWrappedNativeScope.cpp
@@ -15,77 +15,16 @@
 #include "mozilla/dom/BindingUtils.h"
 
 using namespace mozilla;
 using namespace xpc;
 using namespace JS;
 
 /***************************************************************************/
 
-#ifdef XPC_TRACK_SCOPE_STATS
-static int DEBUG_TotalScopeCount;
-static int DEBUG_TotalLiveScopeCount;
-static int DEBUG_TotalMaxScopeCount;
-static int DEBUG_TotalScopeTraversalCount;
-static bool    DEBUG_DumpedStats;
-#endif
-
-#ifdef DEBUG
-static void DEBUG_TrackNewScope(XPCWrappedNativeScope* scope)
-{
-#ifdef XPC_TRACK_SCOPE_STATS
-    DEBUG_TotalScopeCount++;
-    DEBUG_TotalLiveScopeCount++;
-    if (DEBUG_TotalMaxScopeCount < DEBUG_TotalLiveScopeCount)
-        DEBUG_TotalMaxScopeCount = DEBUG_TotalLiveScopeCount;
-#endif
-}
-
-static void DEBUG_TrackDeleteScope(XPCWrappedNativeScope* scope)
-{
-#ifdef XPC_TRACK_SCOPE_STATS
-    DEBUG_TotalLiveScopeCount--;
-#endif
-}
-
-static void DEBUG_TrackScopeTraversal()
-{
-#ifdef XPC_TRACK_SCOPE_STATS
-    DEBUG_TotalScopeTraversalCount++;
-#endif
-}
-
-static void DEBUG_TrackScopeShutdown()
-{
-#ifdef XPC_TRACK_SCOPE_STATS
-    if (!DEBUG_DumpedStats) {
-        DEBUG_DumpedStats = true;
-        printf("%d XPCWrappedNativeScope(s) were constructed.\n",
-               DEBUG_TotalScopeCount);
-
-        printf("%d XPCWrappedNativeScopes(s) max alive at one time.\n",
-               DEBUG_TotalMaxScopeCount);
-
-        printf("%d XPCWrappedNativeScope(s) alive now.\n" ,
-               DEBUG_TotalLiveScopeCount);
-
-        printf("%d traversals of Scope list.\n",
-               DEBUG_TotalScopeTraversalCount);
-    }
-#endif
-}
-#else
-#define DEBUG_TrackNewScope(scope) ((void)0)
-#define DEBUG_TrackDeleteScope(scope) ((void)0)
-#define DEBUG_TrackScopeTraversal() ((void)0)
-#define DEBUG_TrackScopeShutdown() ((void)0)
-#endif
-
-/***************************************************************************/
-
 XPCWrappedNativeScope* XPCWrappedNativeScope::gScopes = nullptr;
 XPCWrappedNativeScope* XPCWrappedNativeScope::gDyingScopes = nullptr;
 
 // static
 XPCWrappedNativeScope*
 XPCWrappedNativeScope::GetNewOrUsed(JSContext *cx, JS::HandleObject aGlobal)
 {
     XPCWrappedNativeScope* scope = GetObjectScope(aGlobal);
@@ -151,17 +90,16 @@ XPCWrappedNativeScope::XPCWrappedNativeS
         mNext = gScopes;
         gScopes = this;
 
         // Grab the XPCContext associated with our context.
         mContext = XPCContext::GetXPCContext(cx);
         mContext->AddScope(this);
     }
 
-    DEBUG_TrackNewScope(this);
     MOZ_COUNT_CTOR(XPCWrappedNativeScope);
 
     // Attach ourselves to the compartment private.
     CompartmentPrivate *priv = EnsureCompartmentPrivate(aGlobal);
     priv->scope = this;
 
     // Determine whether we would allow an XBL scope in this situation.
     // In addition to being pref-controlled, we also disable XBL scopes for
@@ -305,17 +243,16 @@ bool UseXBLScope(JSCompartment *c)
   return scope && scope->UseXBLScope();
 }
 
 } /* namespace xpc */
 
 XPCWrappedNativeScope::~XPCWrappedNativeScope()
 {
     MOZ_COUNT_DTOR(XPCWrappedNativeScope);
-    DEBUG_TrackDeleteScope(this);
 
     // We can do additional cleanup assertions here...
 
     if (mWrappedNativeMap) {
         MOZ_ASSERT(0 == mWrappedNativeMap->Count(), "scope has non-empty map");
         delete mWrappedNativeMap;
     }
 
@@ -490,18 +427,16 @@ WrappedNativeProtoMarker(PLDHashTable *t
 void
 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);
     }
-
-    DEBUG_TrackScopeTraversal();
 }
 
 #ifdef DEBUG
 static PLDHashOperator
 ASSERT_WrappedNativeSetNotMarked(PLDHashTable *table, PLDHashEntryHdr *hdr,
                                  uint32_t number, void *arg)
 {
     ((Native2WrappedNativeMap::Entry*)hdr)->value->ASSERT_SetsNotMarked();
@@ -537,18 +472,16 @@ WrappedNativeTearoffSweeper(PLDHashTable
 }
 
 // static
 void
 XPCWrappedNativeScope::SweepAllWrappedNativeTearOffs()
 {
     for (XPCWrappedNativeScope* cur = gScopes; cur; cur = cur->mNext)
         cur->mWrappedNativeMap->Enumerate(WrappedNativeTearoffSweeper, nullptr);
-
-    DEBUG_TrackScopeTraversal();
 }
 
 // static
 void
 XPCWrappedNativeScope::KillDyingScopes()
 {
     // always called inside the lock!
     XPCWrappedNativeScope* cur = gDyingScopes;
@@ -593,19 +526,16 @@ WrappedNativeProtoShutdownEnumerator(PLD
     data->protoCount++;
     return PL_DHASH_REMOVE;
 }
 
 //static
 void
 XPCWrappedNativeScope::SystemIsBeingShutDown()
 {
-    DEBUG_TrackScopeTraversal();
-    DEBUG_TrackScopeShutdown();
-
     int liveScopeCount = 0;
 
     ShutdownData data;
 
     XPCWrappedNativeScope* cur;
 
     // First move all the scopes to the dying list.
 
@@ -674,18 +604,16 @@ XPCWrappedNativeScope::ClearAllWrappedNa
     // Hold the lock throughout.
     XPCAutoLock lock(XPCJSRuntime::Get()->GetMapLock());
 
     for (XPCWrappedNativeScope* cur = gScopes; cur; cur = cur->mNext) {
         cur->mWrappedNativeProtoMap->Enumerate(WNProtoSecPolicyClearer, nullptr);
         cur->mMainThreadWrappedNativeProtoMap->Enumerate(WNProtoSecPolicyClearer, nullptr);
     }
 
-    DEBUG_TrackScopeTraversal();
-
     return NS_OK;
 }
 
 static PLDHashOperator
 WNProtoRemover(PLDHashTable *table, PLDHashEntryHdr *hdr,
                uint32_t number, void *arg)
 {
     XPCWrappedNativeProtoMap* detachedMap = (XPCWrappedNativeProtoMap*)arg;
--- a/js/xpconnect/src/xpcprivate.h
+++ b/js/xpconnect/src/xpcprivate.h
@@ -176,17 +176,16 @@
 /***************************************************************************/
 // Compile time switches for instrumentation and stuff....
 
 // Note that one would not normally turn *any* of these on in a non-DEBUG build.
 
 #if defined(DEBUG_xpc_hacker)
 #define XPC_DUMP_AT_SHUTDOWN
 #define XPC_TRACK_WRAPPER_STATS
-#define XPC_TRACK_SCOPE_STATS
 #endif
 
 /***************************************************************************/
 // default initial sizes for maps (hashtables)
 
 #define XPC_CONTEXT_MAP_SIZE                16
 #define XPC_JS_MAP_SIZE                     64
 #define XPC_JS_CLASS_MAP_SIZE               64