Bug 1577658 - UniqueStacks constructor can accept a ProfilerCodeAddressService - r=canaltinova

When it's constructed, UniqueStacks can now take a ProfilerCodeAddressService pointer, instead of having to add it separately.
It will be even more useful in a later patch, when constructing it as a struct member in one shot.

Differential Revision: https://phabricator.services.mozilla.com/D128434
This commit is contained in:
Gerald Squelart 2021-10-21 05:47:21 +00:00
parent 302a5711fa
commit 153c2bb05e
3 changed files with 8 additions and 4 deletions

View File

@ -288,8 +288,11 @@ bool UniqueStacks::FrameKey::JITFrameData::operator==(
// ranges. The JIT frame info contains JSON which refers to strings from the
// JIT frame info's string table, so our string table needs to have the same
// strings at the same indices.
UniqueStacks::UniqueStacks(JITFrameInfo&& aJITFrameInfo)
UniqueStacks::UniqueStacks(
JITFrameInfo&& aJITFrameInfo,
ProfilerCodeAddressService* aCodeAddressService /* = nullptr */)
: mUniqueStrings(std::move(aJITFrameInfo.mUniqueStrings)),
mCodeAddressService(aCodeAddressService),
mJITInfoRanges(std::move(aJITFrameInfo.mRanges)) {
mFrameTableWriter.StartBareList();
mStackTableWriter.StartBareList();

View File

@ -311,7 +311,9 @@ class UniqueStacks {
}
};
explicit UniqueStacks(JITFrameInfo&& aJITFrameInfo);
explicit UniqueStacks(
JITFrameInfo&& aJITFrameInfo,
ProfilerCodeAddressService* aCodeAddressService = nullptr);
// Return a StackKey for aFrame as the stack's root frame (no prefix).
[[nodiscard]] StackKey BeginStack(const FrameKey& aFrame);

View File

@ -53,8 +53,7 @@ void ProfiledThreadData::StreamJSON(
mThreadInfo.ThreadId(), aCx, jitFrameInfo);
}
UniqueStacks uniqueStacks(std::move(jitFrameInfo));
uniqueStacks.mCodeAddressService = aService;
UniqueStacks uniqueStacks(std::move(jitFrameInfo), aService);
MOZ_ASSERT(uniqueStacks.mUniqueStrings);
aWriter.SetUniqueStrings(*uniqueStacks.mUniqueStrings);