Bug 1429904 - Make FrameKey members const. r?njn
MozReview-Commit-ID: Hls5ecronv0
--- 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
@@ -165,55 +165,43 @@ public:
bool operator==(const JITAddress& aRhs) const
{
return mAddress == aRhs.mAddress && mStreamingGen == aRhs.mStreamingGen;
}
bool operator!=(const JITAddress& aRhs) const { return !(*this == aRhs); }
};
struct FrameKey {
- // This cannot be a std::string, as it is not memmove compatible, which
- // is used by nsHashTable
- nsCString mLocation;
- mozilla::Maybe<unsigned> mLine;
- mozilla::Maybe<unsigned> mCategory;
- mozilla::Maybe<JITAddress> mJITAddress;
- mozilla::Maybe<uint32_t> mJITDepth;
+ const nsCString mLocation;
+ const mozilla::Maybe<unsigned> mLine;
+ const mozilla::Maybe<unsigned> mCategory;
+ const mozilla::Maybe<JITAddress> mJITAddress;
+ const mozilla::Maybe<uint32_t> mJITDepth;
explicit FrameKey(const char* aLocation)
- : mLocation(aLocation)
- {
- mHash = Hash();
- }
+ : mLocation(aLocation)
+ {}
- FrameKey(const FrameKey& aToCopy)
- : mLocation(aToCopy.mLocation)
- , mLine(aToCopy.mLine)
- , mCategory(aToCopy.mCategory)
- , mJITAddress(aToCopy.mJITAddress)
- , mJITDepth(aToCopy.mJITDepth)
- {
- mHash = Hash();
- }
+ 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))
- {
- mHash = Hash();
- }
+ {}
+
+ FrameKey(const FrameKey& aOther) = default;
uint32_t Hash() const;
bool operator==(const FrameKey& aOther) const;
- bool operator<(const FrameKey& aOther) const {
- return mHash < aOther.mHash;
- }
-
- private:
- uint32_t mHash;
+ bool operator!=(const FrameKey& aOther) const { return !(*this == aOther); }
};
struct StackKey {
mozilla::Maybe<uint32_t> mPrefixStackIndex;
uint32_t mFrameIndex;
explicit StackKey(uint32_t aFrame)
: mFrameIndex(aFrame)