Bug 1049051 - Part 4: Make PrintCycle internal
☠☠ backed out by 4d90a2cce157 ☠ ☠
authorEric Rahm <erahm@mozilla.com>
Mon, 11 Aug 2014 10:30:08 -0700
changeset 198872 06dd873bb3e9b6b1e667239f8d1c1ad5897b700d
parent 198871 96b54c1771b6a8e9b510123eafa23b933b47b981
child 198873 4a283d42050cea79367a4ff32b9931112655c063
push id47519
push usererahm@mozilla.com
push dateMon, 11 Aug 2014 17:44:26 +0000
treeherdermozilla-inbound@4a283d42050c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1049051
milestone34.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1049051 - Part 4: Make PrintCycle internal
xpcom/glue/BlockingResourceBase.cpp
xpcom/glue/BlockingResourceBase.h
--- a/xpcom/glue/BlockingResourceBase.cpp
+++ b/xpcom/glue/BlockingResourceBase.cpp
@@ -32,16 +32,62 @@ const char* const BlockingResourceBase::
 };
 
 #ifdef DEBUG
 
 PRCallOnceType BlockingResourceBase::sCallOnce;
 unsigned BlockingResourceBase::sResourceAcqnChainFrontTPI = (unsigned)-1;
 BlockingResourceBase::DDT* BlockingResourceBase::sDeadlockDetector;
 
+
+/**
+ * PrintCycle
+ * Append to |aOut| detailed information about the circular
+ * dependency in |aCycle|.  Returns true if it *appears* that this
+ * cycle may represent an imminent deadlock, but this is merely a
+ * heuristic; the value returned may be a false positive or false
+ * negative.
+ *
+ * *NOT* thread safe.  Calls |Print()|.
+ *
+ * FIXME bug 456272 hack alert: because we can't write call
+ * contexts into strings, all info is written to stderr, but only
+ * some info is written into |aOut|
+ */
+bool
+PrintCycle(const BlockingResourceBase::DDT::ResourceAcquisitionArray* aCycle, nsACString& aOut)
+{
+  NS_ASSERTION(aCycle->Length() > 1, "need > 1 element for cycle!");
+
+  bool maybeImminent = true;
+
+  fputs("=== Cyclical dependency starts at\n", stderr);
+  aOut += "Cyclical dependency starts at\n";
+
+  const BlockingResourceBase::DDT::ResourceAcquisitionArray::elem_type res = aCycle->ElementAt(0);
+  maybeImminent &= res->Print(aOut);
+
+  BlockingResourceBase::DDT::ResourceAcquisitionArray::index_type i;
+  BlockingResourceBase::DDT::ResourceAcquisitionArray::size_type len = aCycle->Length();
+  const BlockingResourceBase::DDT::ResourceAcquisitionArray::elem_type* it = 1 + aCycle->Elements();
+  for (i = 1; i < len - 1; ++i, ++it) {
+    fputs("\n--- Next dependency:\n", stderr);
+    aOut += "\nNext dependency:\n";
+
+    maybeImminent &= (*it)->Print(aOut);
+  }
+
+  fputs("\n=== Cycle completed at\n", stderr);
+  aOut += "Cycle completed at\n";
+  (*it)->Print(aOut);
+
+  return maybeImminent;
+}
+
+
 bool
 BlockingResourceBase::Print(nsACString& aOut) const
 {
   fprintf(stderr, "--- %s : %s",
           kResourceTypeName[mType], mName);
   aOut += BlockingResourceBase::kResourceTypeName[mType];
   aOut += " : ";
   aOut += mName;
@@ -177,48 +223,16 @@ BlockingResourceBase::Release()
       curr->mChainPrev = prev->mChainPrev;
     }
   }
 
   mAcquired = false;
 }
 
 
-bool
-BlockingResourceBase::PrintCycle(const DDT::ResourceAcquisitionArray* aCycle,
-                                 nsACString& aOut)
-{
-  NS_ASSERTION(aCycle->Length() > 1, "need > 1 element for cycle!");
-
-  bool maybeImminent = true;
-
-  fputs("=== Cyclical dependency starts at\n", stderr);
-  aOut += "Cyclical dependency starts at\n";
-
-  const DDT::ResourceAcquisitionArray::elem_type res = aCycle->ElementAt(0);
-  maybeImminent &= res->Print(aOut);
-
-  DDT::ResourceAcquisitionArray::index_type i;
-  DDT::ResourceAcquisitionArray::size_type len = aCycle->Length();
-  const DDT::ResourceAcquisitionArray::elem_type* it = 1 + aCycle->Elements();
-  for (i = 1; i < len - 1; ++i, ++it) {
-    fputs("\n--- Next dependency:\n", stderr);
-    aOut += "\nNext dependency:\n";
-
-    maybeImminent &= (*it)->Print(aOut);
-  }
-
-  fputs("\n=== Cycle completed at\n", stderr);
-  aOut += "Cycle completed at\n";
-  (*it)->Print(aOut);
-
-  return maybeImminent;
-}
-
-
 //
 // Debug implementation of (OffTheBooks)Mutex
 void
 OffTheBooksMutex::Lock()
 {
   CheckAcquire();
   PR_Lock(mLock);
   Acquire();       // protected by mLock
--- a/xpcom/glue/BlockingResourceBase.h
+++ b/xpcom/glue/BlockingResourceBase.h
@@ -83,17 +83,16 @@ public:
   {
     // NB: |mName| is not reported as it's expected to be a static string.
     //     If we switch to a nsString it should be added to the tally.
     //     |mChainPrev| is not reported because its memory is not owned.
     size_t n = aMallocSizeOf(this);
     return n;
   }
 
-private:
   // ``DDT'' = ``Deadlock Detector Type''
   typedef DeadlockDetector<BlockingResourceBase> DDT;
 
 protected:
   /**
    * BlockingResourceBase
    * Initialize this blocking resource.  Also hooks the resource into
    * instrumentation code.
@@ -129,33 +128,16 @@ protected:
    * it is confusing to release resources in a different order than they
    * are acquired.  This generates a warning.
    *
    * *NOT* thread safe.  Requires ownership of underlying resource.
    **/
   void Release();             //NS_NEEDS_RESOURCE(this)
 
   /**
-   * PrintCycle
-   * Append to |aOut| detailed information about the circular
-   * dependency in |aCycle|.  Returns true if it *appears* that this
-   * cycle may represent an imminent deadlock, but this is merely a
-   * heuristic; the value returned may be a false positive or false
-   * negative.
-   *
-   * *NOT* thread safe.  Calls |Print()|.
-   *
-   * FIXME bug 456272 hack alert: because we can't write call
-   * contexts into strings, all info is written to stderr, but only
-   * some info is written into |aOut|
-   */
-  static bool PrintCycle(const DDT::ResourceAcquisitionArray* aCycle,
-                         nsACString& aOut);
-
-  /**
    * ResourceChainFront
    *
    * Thread safe.
    *
    * @return the front of the resource acquisition chain, i.e., the last
    *         resource acquired.
    */
   static BlockingResourceBase* ResourceChainFront()