зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1429904 - Use a Variant to split the FrameKey members into two groups. r=njn
This makes it clear which combinations of fields are possible. MozReview-Commit-ID: C3PriO7nWsJ --HG-- extra : rebase_source : 68df01f11121b09b2f2762581dc28184262abfb8
This commit is contained in:
Родитель
f4f1500202
Коммит
15b53ded07
|
@ -261,15 +261,6 @@ UniqueJSONStrings::GetOrAddIndex(const char* aStr)
|
|||
return index;
|
||||
}
|
||||
|
||||
bool UniqueStacks::FrameKey::operator==(const FrameKey& aOther) const
|
||||
{
|
||||
return mLocation == aOther.mLocation &&
|
||||
mLine == aOther.mLine &&
|
||||
mCategory == aOther.mCategory &&
|
||||
mJITAddress == aOther.mJITAddress &&
|
||||
mJITDepth == aOther.mJITDepth;
|
||||
}
|
||||
|
||||
UniqueStacks::StackKey
|
||||
UniqueStacks::BeginStack(const FrameKey& aFrame)
|
||||
{
|
||||
|
@ -291,23 +282,40 @@ UniqueStacks::JITAddress::Hash() const
|
|||
return hash;
|
||||
}
|
||||
|
||||
uint32_t UniqueStacks::FrameKey::Hash() const
|
||||
bool
|
||||
UniqueStacks::FrameKey::NormalFrameData::operator==(const NormalFrameData& aOther) const
|
||||
{
|
||||
return mLocation == aOther.mLocation &&
|
||||
mLine == aOther.mLine &&
|
||||
mCategory == aOther.mCategory;
|
||||
}
|
||||
|
||||
bool
|
||||
UniqueStacks::FrameKey::JITFrameData::operator==(const JITFrameData& aOther) const
|
||||
{
|
||||
return mAddress == aOther.mAddress &&
|
||||
mDepth == aOther.mDepth;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
UniqueStacks::FrameKey::Hash() const
|
||||
{
|
||||
uint32_t hash = 0;
|
||||
if (!mLocation.IsEmpty()) {
|
||||
hash = HashString(mLocation.get());
|
||||
}
|
||||
if (mLine.isSome()) {
|
||||
hash = AddToHash(hash, *mLine);
|
||||
}
|
||||
if (mCategory.isSome()) {
|
||||
hash = AddToHash(hash, *mCategory);
|
||||
}
|
||||
if (mJITAddress.isSome()) {
|
||||
hash = AddToHash(hash, mJITAddress->Hash());
|
||||
if (mJITDepth.isSome()) {
|
||||
hash = AddToHash(hash, *mJITDepth);
|
||||
if (mData.is<NormalFrameData>()) {
|
||||
const NormalFrameData& data = mData.as<NormalFrameData>();
|
||||
if (!data.mLocation.IsEmpty()) {
|
||||
hash = AddToHash(hash, HashString(data.mLocation.get()));
|
||||
}
|
||||
if (data.mLine.isSome()) {
|
||||
hash = AddToHash(hash, *data.mLine);
|
||||
}
|
||||
if (data.mCategory.isSome()) {
|
||||
hash = AddToHash(hash, *data.mCategory);
|
||||
}
|
||||
} else {
|
||||
const JITFrameData& data = mData.as<JITFrameData>();
|
||||
hash = AddToHash(hash, data.mAddress.Hash());
|
||||
hash = AddToHash(hash, data.mDepth);
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
|
@ -417,6 +425,8 @@ void UniqueStacks::StreamStack(const StackKey& aStack)
|
|||
void
|
||||
UniqueStacks::StreamNonJITFrame(const FrameKey& aFrame)
|
||||
{
|
||||
using NormalFrameData = FrameKey::NormalFrameData;
|
||||
|
||||
enum Schema : uint32_t {
|
||||
LOCATION = 0,
|
||||
IMPLEMENTATION = 1,
|
||||
|
@ -427,12 +437,13 @@ UniqueStacks::StreamNonJITFrame(const FrameKey& aFrame)
|
|||
|
||||
AutoArraySchemaWriter writer(mFrameTableWriter, mUniqueStrings);
|
||||
|
||||
writer.StringElement(LOCATION, aFrame.mLocation.get());
|
||||
if (aFrame.mLine.isSome()) {
|
||||
writer.IntElement(LINE, *aFrame.mLine);
|
||||
const NormalFrameData& data = aFrame.mData.as<NormalFrameData>();
|
||||
writer.StringElement(LOCATION, data.mLocation.get());
|
||||
if (data.mLine.isSome()) {
|
||||
writer.IntElement(LINE, *data.mLine);
|
||||
}
|
||||
if (aFrame.mCategory.isSome()) {
|
||||
writer.IntElement(CATEGORY, *aFrame.mCategory);
|
||||
if (data.mCategory.isSome()) {
|
||||
writer.IntElement(CATEGORY, *data.mCategory);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "mozilla/HashFunctions.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
#include "nsClassHashtable.h"
|
||||
#include "mozilla/Variant.h"
|
||||
|
||||
class ProfilerMarker;
|
||||
|
||||
|
@ -170,35 +171,42 @@ public:
|
|||
};
|
||||
|
||||
struct FrameKey {
|
||||
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)
|
||||
: mData(NormalFrameData{
|
||||
nsCString(aLocation), mozilla::Nothing(), mozilla::Nothing() })
|
||||
{
|
||||
}
|
||||
|
||||
FrameKey(const char* aLocation, const mozilla::Maybe<unsigned>& aLine,
|
||||
const mozilla::Maybe<unsigned>& aCategory)
|
||||
: mLocation(aLocation)
|
||||
, mLine(aLine)
|
||||
, mCategory(aCategory)
|
||||
: mData(NormalFrameData{ nsCString(aLocation), aLine, aCategory })
|
||||
{
|
||||
}
|
||||
|
||||
FrameKey(const JITAddress& aJITAddress, uint32_t aJITDepth)
|
||||
: mJITAddress(mozilla::Some(aJITAddress))
|
||||
, mJITDepth(mozilla::Some(aJITDepth))
|
||||
: mData(JITFrameData{ aJITAddress, aJITDepth })
|
||||
{
|
||||
}
|
||||
|
||||
FrameKey(const FrameKey& aToCopy) = default;
|
||||
|
||||
uint32_t Hash() const;
|
||||
bool operator==(const FrameKey& aOther) const;
|
||||
bool operator==(const FrameKey& aOther) const { return mData == aOther.mData; }
|
||||
|
||||
struct NormalFrameData {
|
||||
bool operator==(const NormalFrameData& aOther) const;
|
||||
|
||||
nsCString mLocation;
|
||||
mozilla::Maybe<unsigned> mLine;
|
||||
mozilla::Maybe<unsigned> mCategory;
|
||||
};
|
||||
struct JITFrameData {
|
||||
bool operator==(const JITFrameData& aOther) const;
|
||||
|
||||
JITAddress mAddress;
|
||||
uint32_t mDepth;
|
||||
};
|
||||
mozilla::Variant<NormalFrameData, JITFrameData> mData;
|
||||
};
|
||||
|
||||
struct StackKey {
|
||||
|
|
Загрузка…
Ссылка в новой задаче