Bug 1429904 - Add another constructor to FrameKey which initializes mLine and mCategory, and use it in one place. r?njn draft
authorMarkus Stange <mstange@themasta.com>
Tue, 27 Feb 2018 23:10:06 -0500
changeset 762101 5ab6d98acb6a6624c841839de838c3bc470e8631
parent 762100 b366941fbef50c430114f3cf9f41008027f6761b
child 762102 bf93be38d9f6caaa414df5c517ae223bcf131ef5
push id101088
push userbmo:mstange@themasta.com
push dateThu, 01 Mar 2018 20:52:26 +0000
reviewersnjn
bugs1429904
milestone60.0a1
Bug 1429904 - Add another constructor to FrameKey which initializes mLine and mCategory, and use it in one place. r?njn MozReview-Commit-ID: 1LliQMGjfjx
tools/profiler/core/ProfileBufferEntry.cpp
tools/profiler/core/ProfileBufferEntry.h
--- a/tools/profiler/core/ProfileBufferEntry.cpp
+++ b/tools/profiler/core/ProfileBufferEntry.cpp
@@ -863,29 +863,30 @@ ProfileBuffer::StreamSamplesToJSON(Splic
             }
             e.Next();
           } else {
             break;
           }
         }
         strbuf[kMaxFrameKeyLength - 1] = '\0';
 
-        UniqueStacks::FrameKey frameKey(strbuf.get());
-
+        Maybe<unsigned> line;
         if (e.Has() && e.Get().IsLineNumber()) {
-          frameKey.mLine = Some(unsigned(e.Get().u.mInt));
+          line = Some(unsigned(e.Get().u.mInt));
           e.Next();
         }
 
+        Maybe<unsigned> category;
         if (e.Has() && e.Get().IsCategory()) {
-          frameKey.mCategory = Some(unsigned(e.Get().u.mInt));
+          category = Some(unsigned(e.Get().u.mInt));
           e.Next();
         }
 
-        stack = aUniqueStacks.AppendFrame(stack, frameKey);
+        stack = aUniqueStacks.AppendFrame(
+          stack, UniqueStacks::FrameKey(strbuf.get(), line, category));
 
       } else if (e.Get().IsJitReturnAddr()) {
         numFrames++;
 
         // We can only process JitReturnAddr entries if we have a JSContext.
         MOZ_RELEASE_ASSERT(aContext);
 
         // A JIT frame may expand to multiple frames due to inlining.
--- a/tools/profiler/core/ProfileBufferEntry.h
+++ b/tools/profiler/core/ProfileBufferEntry.h
@@ -178,16 +178,24 @@ public:
     mozilla::Maybe<JITAddress> mJITAddress;
     mozilla::Maybe<uint32_t> mJITDepth;
 
     explicit FrameKey(const char* aLocation)
      : mLocation(aLocation)
     {
     }
 
+    FrameKey(const char* aLocation, const mozilla::Maybe<unsigned>& aLine,
+             const mozilla::Maybe<unsigned>& aCategory)
+     : mLocation(aLocation)
+     , mLine(aLine)
+     , mCategory(aCategory)
+    {
+    }
+
     FrameKey(const JITAddress& aJITAddress, uint32_t aJITDepth)
      : mJITAddress(mozilla::Some(aJITAddress))
      , mJITDepth(mozilla::Some(aJITDepth))
     {
     }
 
     FrameKey(const FrameKey& aToCopy) = default;