Bug 1429904 - Add another constructor to FrameKey which initializes mLine and mCategory, and use it in one place. r?njn
MozReview-Commit-ID: 1LliQMGjfjx
--- 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;