Bug 1351963 (part 3) - Remove ThreadInfo from ProfilerBacktrace. r=mstange.
☠☠ backed out by abd1a8acd193 ☠ ☠
authorNicholas Nethercote <nnethercote@mozilla.com>
Fri, 31 Mar 2017 09:41:42 +1100
changeset 350912 016c13131fffb242bdb06a33b4946a96c175a603
parent 350911 d9ce5cdb4e5a59daac066a2bd59abbf48388795e
child 350913 6d89751bf9dfe7a40c6f7a6e2647ac078eef1042
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)
reviewersmstange
bugs1351963
milestone55.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 1351963 (part 3) - Remove ThreadInfo from ProfilerBacktrace. r=mstange. At this point the only things in the ThreadInfo it uses are the thread name and id, which are easy to store instead. This gets a step closer to avoiding the use of ThreadInfo in profiler_get_backtrace().
tools/profiler/core/ProfilerBacktrace.cpp
tools/profiler/core/ProfilerBacktrace.h
tools/profiler/core/platform.cpp
--- a/tools/profiler/core/ProfilerBacktrace.cpp
+++ b/tools/profiler/core/ProfilerBacktrace.cpp
@@ -4,40 +4,39 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "ProfilerBacktrace.h"
 
 #include "ProfileJSONWriter.h"
 #include "ThreadInfo.h"
 
-ProfilerBacktrace::ProfilerBacktrace(ProfileBuffer* aBuffer,
-                                     ThreadInfo* aThreadInfo)
-  : mBuffer(aBuffer)
-  , mThreadInfo(aThreadInfo)
+ProfilerBacktrace::ProfilerBacktrace(const char* aName, int aThreadId,
+                                     ProfileBuffer* aBuffer)
+  : mName(strdup(aName))
+  , mThreadId(aThreadId)
+  , mBuffer(aBuffer)
 {
   MOZ_COUNT_CTOR(ProfilerBacktrace);
-  MOZ_ASSERT(aThreadInfo && aThreadInfo->HasProfile());
 }
 
 ProfilerBacktrace::~ProfilerBacktrace()
 {
   MOZ_COUNT_DTOR(ProfilerBacktrace);
   delete mBuffer;
-  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(),
+  StreamSamplesAndMarkers(mName.get(), mThreadId,
                           mBuffer, aWriter, aStartTime,
                           /* aSinceTime */ 0, /* aContext */ nullptr,
                           /* aSavedStreamedSamples */ nullptr,
                           /* aSavedStreamedMarkers */ nullptr,
                           aUniqueStacks);
 }
--- a/tools/profiler/core/ProfilerBacktrace.h
+++ b/tools/profiler/core/ProfilerBacktrace.h
@@ -2,40 +2,43 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef __PROFILER_BACKTRACE_H
 #define __PROFILER_BACKTRACE_H
 
+#include "mozilla/UniquePtrExtensions.h"
+
 class ProfileBuffer;
 class SpliceableJSONWriter;
 class ThreadInfo;
 class UniqueStacks;
 
 // ProfilerBacktrace encapsulates a synchronous sample.
 class ProfilerBacktrace
 {
 public:
-  explicit ProfilerBacktrace(ProfileBuffer* aBuffer, ThreadInfo* aThreadInfo);
+  ProfilerBacktrace(const char* aName, int aThreadId, ProfileBuffer* aBuffer);
   ~ProfilerBacktrace();
 
   // ProfilerBacktraces' stacks are deduplicated in the context of the
   // profile that contains the backtrace as a marker payload.
   //
   // That is, markers that contain backtraces should not need their own stack,
   // frame, and string tables. They should instead reuse their parent
   // profile's tables.
   void StreamJSON(SpliceableJSONWriter& aWriter,
                   const mozilla::TimeStamp& aStartTime,
                   UniqueStacks& aUniqueStacks);
 
 private:
   ProfilerBacktrace(const ProfilerBacktrace&);
   ProfilerBacktrace& operator=(const ProfilerBacktrace&);
 
+  mozilla::UniqueFreePtr<char> mName;
+  int mThreadId;
   ProfileBuffer* mBuffer;
-  ThreadInfo* mThreadInfo;
 };
 
 #endif // __PROFILER_BACKTRACE_H
 
--- a/tools/profiler/core/platform.cpp
+++ b/tools/profiler/core/platform.cpp
@@ -2934,17 +2934,18 @@ profiler_get_backtrace()
   sample.PopulateContext(nullptr);
 #else
 # error "unknown platform"
 #endif
 #endif
 
   Tick(lock, buffer, &sample);
 
-  return UniqueProfilerBacktrace(new ProfilerBacktrace(buffer, threadInfo));
+  return UniqueProfilerBacktrace(
+    new ProfilerBacktrace("SyncProfile", tid, buffer));
 }
 
 void
 ProfilerBacktraceDestructor::operator()(ProfilerBacktrace* aBacktrace)
 {
   delete aBacktrace;
 }