Backed out changeset d9ce5cdb4e5a (bug 1351963) for hopefully fix the dt leaks
authorCarsten "Tomcat" Book <cbook@mozilla.com>
Mon, 03 Apr 2017 08:19:22 +0200
changeset 350916 66146205625406fd7eabd6b03c8b4c7ec464c3a1
parent 350915 abd1a8acd193a5263bd77b437c7c27c6fe27b7d1
child 350917 aaa0cd3bd620daf6be29c72625f6e63fd0bc1d46
child 351003 48c4cf6ed1275179fc44324437d59997cb999d7e
push id39980
push usercbook@mozilla.com
push dateMon, 03 Apr 2017 10:33:25 +0000
treeherderautoland@69713a85b57b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1351963
milestone55.0a1
backs outd9ce5cdb4e5a59daac066a2bd59abbf48388795e
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
Backed out changeset d9ce5cdb4e5a (bug 1351963) for hopefully fix the dt leaks
tools/profiler/core/ProfileBufferEntry.cpp
tools/profiler/core/ProfilerBacktrace.cpp
tools/profiler/core/ProfilerBacktrace.h
tools/profiler/core/ThreadInfo.cpp
tools/profiler/core/ThreadInfo.h
--- a/tools/profiler/core/ProfileBufferEntry.cpp
+++ b/tools/profiler/core/ProfileBufferEntry.cpp
@@ -688,17 +688,16 @@ void ProfileBuffer::StreamSamplesToJSON(
               }
               stack.AppendFrame(frameKey);
             } else if (frame.isJitReturnAddr()) {
               // A JIT frame may expand to multiple frames due to inlining.
               void* pc = frame.mTagPtr;
               unsigned depth = aUniqueStacks.LookupJITFrameDepth(pc);
               if (depth == 0) {
                 StreamJSFramesOp framesOp(pc, stack);
-                MOZ_RELEASE_ASSERT(aContext);
                 JS::ForEachProfiledFrame(aContext, pc, framesOp);
                 aUniqueStacks.AddJITFrameDepth(pc, framesOp.depth());
               } else {
                 for (unsigned i = 0; i < depth; i++) {
                   UniqueStacks::OnStackFrameKey inlineFrameKey(pc, i);
                   stack.AppendFrame(inlineFrameKey);
                 }
               }
--- a/tools/profiler/core/ProfilerBacktrace.cpp
+++ b/tools/profiler/core/ProfilerBacktrace.cpp
@@ -25,19 +25,11 @@ ProfilerBacktrace::~ProfilerBacktrace()
   delete mThreadInfo;
 }
 
 void
 ProfilerBacktrace::StreamJSON(SpliceableJSONWriter& aWriter,
                               const TimeStamp& aStartTime,
                               UniqueStacks& aUniqueStacks)
 {
-  // This call to StreamSamplesAndMarkers() can safely pass in a non-null
-  // JSContext. That's because StreamSamplesAndMarkers() only accesses the
-  // JSContext when streaming JitReturnAddress entries, and such entries
-  // never appear in synchronous samples.
-  StreamSamplesAndMarkers(mThreadInfo->Name(), mThreadInfo->ThreadId(),
-                          mBuffer, aWriter, aStartTime,
-                          /* aSinceTime */ 0, /* aContext */ nullptr,
-                          /* aSavedStreamedSamples */ nullptr,
-                          /* aSavedStreamedMarkers */ nullptr,
-                          aUniqueStacks);
+  mThreadInfo->StreamSamplesAndMarkers(mBuffer, aWriter, aStartTime,
+                                       /* aSinceTime */ 0, aUniqueStacks);
 }
--- a/tools/profiler/core/ProfilerBacktrace.h
+++ b/tools/profiler/core/ProfilerBacktrace.h
@@ -7,17 +7,16 @@
 #ifndef __PROFILER_BACKTRACE_H
 #define __PROFILER_BACKTRACE_H
 
 class ProfileBuffer;
 class SpliceableJSONWriter;
 class ThreadInfo;
 class UniqueStacks;
 
-// ProfilerBacktrace encapsulates a synchronous sample.
 class ProfilerBacktrace
 {
 public:
   explicit ProfilerBacktrace(ProfileBuffer* aBuffer, ThreadInfo* aThreadInfo);
   ~ProfilerBacktrace();
 
   // ProfilerBacktraces' stacks are deduplicated in the context of the
   // profile that contains the backtrace as a marker payload.
--- a/tools/profiler/core/ThreadInfo.cpp
+++ b/tools/profiler/core/ThreadInfo.cpp
@@ -67,22 +67,18 @@ ThreadInfo::StreamJSON(ProfileBuffer* aB
 {
   // mUniqueStacks may already be emplaced from FlushSamplesAndMarkers.
   if (!mUniqueStacks.isSome()) {
     mUniqueStacks.emplace(mPseudoStack->mContext);
   }
 
   aWriter.Start(SpliceableJSONWriter::SingleLineStyle);
   {
-    StreamSamplesAndMarkers(Name(), ThreadId(), aBuffer, aWriter, aStartTime,
-                            aSinceTime, mPseudoStack->mContext,
-                            mSavedStreamedSamples.get(),
-                            mSavedStreamedMarkers.get(), *mUniqueStacks);
-    mSavedStreamedSamples.reset();
-    mSavedStreamedMarkers.reset();
+    StreamSamplesAndMarkers(aBuffer, aWriter, aStartTime, aSinceTime,
+                            *mUniqueStacks);
 
     aWriter.StartObjectProperty("stackTable");
     {
       {
         JSONSchemaWriter schema(aWriter);
         schema.WriteField("prefix");
         schema.WriteField("frame");
       }
@@ -121,78 +117,75 @@ ThreadInfo::StreamJSON(ProfileBuffer* aB
     aWriter.EndArray();
   }
   aWriter.End();
 
   mUniqueStacks.reset();
 }
 
 void
-StreamSamplesAndMarkers(const char* aName,
-                        int aThreadId,
-                        ProfileBuffer* aBuffer,
-                        SpliceableJSONWriter& aWriter,
-                        const TimeStamp& aStartTime,
-                        double aSinceTime,
-                        JSContext* aContext,
-                        char* aSavedStreamedSamples,
-                        char* aSavedStreamedMarkers,
-                        UniqueStacks& aUniqueStacks)
+ThreadInfo::StreamSamplesAndMarkers(ProfileBuffer* aBuffer,
+                                    SpliceableJSONWriter& aWriter,
+                                    const TimeStamp& aStartTime,
+                                    double aSinceTime,
+                                    UniqueStacks& aUniqueStacks)
 {
   aWriter.StringProperty("processType",
                          XRE_ChildProcessTypeToString(XRE_GetProcessType()));
 
-  aWriter.StringProperty("name", aName);
-  aWriter.IntProperty("tid", static_cast<int64_t>(aThreadId));
+  aWriter.StringProperty("name", Name());
+  aWriter.IntProperty("tid", static_cast<int64_t>(mThreadId));
   aWriter.IntProperty("pid", static_cast<int64_t>(getpid()));
 
   aWriter.StartObjectProperty("samples");
   {
     {
       JSONSchemaWriter schema(aWriter);
       schema.WriteField("stack");
       schema.WriteField("time");
       schema.WriteField("responsiveness");
       schema.WriteField("rss");
       schema.WriteField("uss");
       schema.WriteField("frameNumber");
     }
 
     aWriter.StartArrayProperty("data");
     {
-      if (aSavedStreamedSamples) {
+      if (mSavedStreamedSamples) {
         // We would only have saved streamed samples during shutdown
         // streaming, which cares about dumping the entire buffer, and thus
         // should have passed in 0 for aSinceTime.
         MOZ_ASSERT(aSinceTime == 0);
-        aWriter.Splice(aSavedStreamedSamples);
+        aWriter.Splice(mSavedStreamedSamples.get());
+        mSavedStreamedSamples.reset();
       }
-      aBuffer->StreamSamplesToJSON(aWriter, aThreadId, aSinceTime, aContext,
-                                   aUniqueStacks);
+      aBuffer->StreamSamplesToJSON(aWriter, mThreadId, aSinceTime,
+                                   mPseudoStack->mContext, aUniqueStacks);
     }
     aWriter.EndArray();
   }
   aWriter.EndObject();
 
   aWriter.StartObjectProperty("markers");
   {
     {
       JSONSchemaWriter schema(aWriter);
       schema.WriteField("name");
       schema.WriteField("time");
       schema.WriteField("data");
     }
 
     aWriter.StartArrayProperty("data");
     {
-      if (aSavedStreamedMarkers) {
+      if (mSavedStreamedMarkers) {
         MOZ_ASSERT(aSinceTime == 0);
-        aWriter.Splice(aSavedStreamedMarkers);
+        aWriter.Splice(mSavedStreamedMarkers.get());
+        mSavedStreamedMarkers.reset();
       }
-      aBuffer->StreamMarkersToJSON(aWriter, aThreadId, aStartTime, aSinceTime,
+      aBuffer->StreamMarkersToJSON(aWriter, mThreadId, aStartTime, aSinceTime,
                                    aUniqueStacks);
     }
     aWriter.EndArray();
   }
   aWriter.EndObject();
 }
 
 void
--- a/tools/profiler/core/ThreadInfo.h
+++ b/tools/profiler/core/ThreadInfo.h
@@ -76,16 +76,22 @@ public:
                               const mozilla::TimeStamp& aStartTime);
 
   ThreadResponsiveness* GetThreadResponsiveness() { return &mRespInfo; }
 
   void UpdateThreadResponsiveness() {
     mRespInfo.Update(mIsMainThread, mThread);
   }
 
+  void StreamSamplesAndMarkers(ProfileBuffer* aBuffer,
+                               SpliceableJSONWriter& aWriter,
+                               const mozilla::TimeStamp& aStartTime,
+                               double aSinceTime,
+                               UniqueStacks& aUniqueStacks);
+
 private:
   bool mHasProfile;
 
   // JS frames in the buffer may require a live JSRuntime to stream (e.g.,
   // stringifying JIT frames). In the case of JSRuntime destruction,
   // FlushSamplesAndMarkers should be called to save them. These are spliced
   // into the final stream.
   mozilla::UniquePtr<char[]> mSavedStreamedSamples;
@@ -96,20 +102,9 @@ private:
 
   // When sampling, this holds the generation number and offset in the
   // ProfileBuffer of the most recent sample for this thread.
   // mLastSample.mThreadId duplicates mThreadId in this structure, which
   // simplifies some uses of mLastSample.
   ProfileBuffer::LastSample mLastSample;
 };
 
-void
-StreamSamplesAndMarkers(const char* aName, int aThreadId,
-                        ProfileBuffer* aBuffer,
-                        SpliceableJSONWriter& aWriter,
-                        const mozilla::TimeStamp& aStartTime,
-                        double aSinceTime,
-                        JSContext* aContext,
-                        char* aSavedStreamedSamples,
-                        char* aSavedStreamedMarkers,
-                        UniqueStacks& aUniqueStacks);
-
 #endif