зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1434965 - Don't store a JSContext pointer in UniqueStacks; pass it manually to the functions that need it. r=njn
This resolves the bug where we attempted to find information about JitReturnAddr entries which were collected with a new JSContext by asking an old JSContext. MozReview-Commit-ID: FQrnAuwwzHU --HG-- extra : rebase_source : d0a0c7077199dc177123bb54951f4f7238c5eaf6
This commit is contained in:
Родитель
655bb7136b
Коммит
01745f4e91
|
@ -309,8 +309,7 @@ uint32_t UniqueStacks::FrameKey::Hash() const
|
|||
return hash;
|
||||
}
|
||||
|
||||
UniqueStacks::UniqueStacks(JSContext* aContext)
|
||||
: mContext(aContext)
|
||||
UniqueStacks::UniqueStacks()
|
||||
{
|
||||
mFrameTableWriter.StartBareList();
|
||||
mStackTableWriter.StartBareList();
|
||||
|
@ -331,19 +330,19 @@ uint32_t UniqueStacks::GetOrAddStackIndex(const StackKey& aStack)
|
|||
}
|
||||
|
||||
MOZ_MUST_USE nsTArray<UniqueStacks::FrameKey>
|
||||
UniqueStacks::GetOrAddJITFrameKeysForAddress(void* aJITAddress)
|
||||
UniqueStacks::GetOrAddJITFrameKeysForAddress(JSContext* aContext,
|
||||
void* aJITAddress)
|
||||
{
|
||||
nsTArray<FrameKey>& frameKeys =
|
||||
*mAddressToJITFrameKeysMap.LookupOrAdd(aJITAddress);
|
||||
|
||||
if (frameKeys.IsEmpty()) {
|
||||
MOZ_RELEASE_ASSERT(mContext);
|
||||
for (JS::ProfiledFrameHandle handle : JS::GetProfiledFrames(mContext,
|
||||
for (JS::ProfiledFrameHandle handle : JS::GetProfiledFrames(aContext,
|
||||
aJITAddress)) {
|
||||
// JIT frames with the same canonical address should be treated as the
|
||||
// same frame, so set the frame key's address to the canonical address.
|
||||
FrameKey frameKey(handle.canonicalAddress(), frameKeys.Length());
|
||||
MaybeAddJITFrameIndex(frameKey, handle);
|
||||
MaybeAddJITFrameIndex(aContext, frameKey, handle);
|
||||
frameKeys.AppendElement(frameKey);
|
||||
}
|
||||
MOZ_ASSERT(frameKeys.Length() > 0);
|
||||
|
@ -354,7 +353,8 @@ UniqueStacks::GetOrAddJITFrameKeysForAddress(void* aJITAddress)
|
|||
}
|
||||
|
||||
void
|
||||
UniqueStacks::MaybeAddJITFrameIndex(const FrameKey& aFrame,
|
||||
UniqueStacks::MaybeAddJITFrameIndex(JSContext* aContext,
|
||||
const FrameKey& aFrame,
|
||||
const JS::ProfiledFrameHandle& aJITFrame)
|
||||
{
|
||||
uint32_t index;
|
||||
|
@ -365,7 +365,7 @@ UniqueStacks::MaybeAddJITFrameIndex(const FrameKey& aFrame,
|
|||
|
||||
index = mFrameToIndexMap.Count();
|
||||
mFrameToIndexMap.Put(aFrame, index);
|
||||
StreamJITFrame(aJITFrame);
|
||||
StreamJITFrame(aContext, aJITFrame);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
|
@ -525,7 +525,8 @@ StreamJITFrameOptimizations(SpliceableJSONWriter& aWriter,
|
|||
}
|
||||
|
||||
void
|
||||
UniqueStacks::StreamJITFrame(const JS::ProfiledFrameHandle& aJITFrame)
|
||||
UniqueStacks::StreamJITFrame(JSContext* aContext,
|
||||
const JS::ProfiledFrameHandle& aJITFrame)
|
||||
{
|
||||
enum Schema : uint32_t {
|
||||
LOCATION = 0,
|
||||
|
@ -550,7 +551,7 @@ UniqueStacks::StreamJITFrame(const JS::ProfiledFrameHandle& aJITFrame)
|
|||
if (aJITFrame.hasTrackedOptimizations()) {
|
||||
writer.FreeFormElement(OPTIMIZATIONS,
|
||||
[&](SpliceableJSONWriter& aWriter, UniqueJSONStrings& aUniqueStrings) {
|
||||
StreamJITFrameOptimizations(aWriter, aUniqueStrings, mContext,
|
||||
StreamJITFrameOptimizations(aWriter, aUniqueStrings, aContext,
|
||||
aJITFrame);
|
||||
});
|
||||
}
|
||||
|
@ -873,10 +874,13 @@ ProfileBuffer::StreamSamplesToJSON(SpliceableJSONWriter& aWriter, int aThreadId,
|
|||
} 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.
|
||||
void* pc = e.Get().u.mPtr;
|
||||
nsTArray<UniqueStacks::FrameKey> frameKeys =
|
||||
aUniqueStacks.GetOrAddJITFrameKeysForAddress(pc);
|
||||
aUniqueStacks.GetOrAddJITFrameKeysForAddress(aContext, pc);
|
||||
for (const UniqueStacks::FrameKey& frameKey : frameKeys) {
|
||||
stack = aUniqueStacks.AppendFrame(stack, frameKey);
|
||||
}
|
||||
|
|
|
@ -218,7 +218,7 @@ public:
|
|||
uint32_t mHash;
|
||||
};
|
||||
|
||||
explicit UniqueStacks(JSContext* aContext);
|
||||
explicit UniqueStacks();
|
||||
|
||||
// Return a StackKey for aFrame as the stack's root frame (no prefix).
|
||||
MOZ_MUST_USE StackKey BeginStack(const FrameKey& aFrame);
|
||||
|
@ -228,7 +228,7 @@ public:
|
|||
const FrameKey& aFrame);
|
||||
|
||||
MOZ_MUST_USE nsTArray<FrameKey>
|
||||
GetOrAddJITFrameKeysForAddress(void* aJITAddress);
|
||||
GetOrAddJITFrameKeysForAddress(JSContext* aContext, void* aJITAddress);
|
||||
|
||||
MOZ_MUST_USE uint32_t GetOrAddFrameIndex(const FrameKey& aFrame);
|
||||
MOZ_MUST_USE uint32_t GetOrAddStackIndex(const StackKey& aStack);
|
||||
|
@ -239,19 +239,19 @@ public:
|
|||
private:
|
||||
// Make sure that there exists a frame index for aFrame, and if there isn't
|
||||
// one already, create one and call StreamJITFrame for the frame.
|
||||
void MaybeAddJITFrameIndex(const FrameKey& aFrame,
|
||||
void MaybeAddJITFrameIndex(JSContext* aContext,
|
||||
const FrameKey& aFrame,
|
||||
const JS::ProfiledFrameHandle& aJITFrame);
|
||||
|
||||
void StreamNonJITFrame(const FrameKey& aFrame);
|
||||
void StreamJITFrame(const JS::ProfiledFrameHandle& aJITFrame);
|
||||
void StreamJITFrame(JSContext* aContext,
|
||||
const JS::ProfiledFrameHandle& aJITFrame);
|
||||
void StreamStack(const StackKey& aStack);
|
||||
|
||||
public:
|
||||
UniqueJSONStrings mUniqueStrings;
|
||||
|
||||
private:
|
||||
JSContext* mContext;
|
||||
|
||||
// To avoid incurring JitcodeGlobalTable lookup costs for every JIT frame,
|
||||
// we cache the frame keys of frames keyed by JIT code address. All FrameKeys
|
||||
// in mAddressToJITFrameKeysMap are guaranteed to be in mFrameToIndexMap.
|
||||
|
|
|
@ -81,7 +81,7 @@ ThreadInfo::StreamJSON(const ProfileBuffer& aBuffer,
|
|||
|
||||
UniquePtr<UniqueStacks> uniqueStacks = partialProfile
|
||||
? Move(partialProfile->mUniqueStacks)
|
||||
: MakeUnique<UniqueStacks>(mContext);
|
||||
: MakeUnique<UniqueStacks>();
|
||||
|
||||
UniquePtr<char[]> partialSamplesJSON;
|
||||
UniquePtr<char[]> partialMarkersJSON;
|
||||
|
@ -247,7 +247,7 @@ ThreadInfo::FlushSamplesAndMarkers(const TimeStamp& aProcessStartTime,
|
|||
// mapping is stable across JS shutdown.
|
||||
UniquePtr<UniqueStacks> uniqueStacks = mPartialProfile
|
||||
? Move(mPartialProfile->mUniqueStacks)
|
||||
: MakeUnique<UniqueStacks>(mContext);
|
||||
: MakeUnique<UniqueStacks>();
|
||||
|
||||
UniquePtr<char[]> samplesJSON;
|
||||
UniquePtr<char[]> markersJSON;
|
||||
|
|
Загрузка…
Ссылка в новой задаче