mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1148069 - Set SyncProfiles' buffers to an invalid generation. (r=djvj)
This commit is contained in:
parent
1a9b3e7acc
commit
dc37949a92
@ -101,18 +101,18 @@ void* ProfileEntry::get_tagPtr() {
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// BEGIN ProfileBuffer
|
||||
|
||||
ProfileBuffer::ProfileBuffer(int aEntrySize)
|
||||
ProfileBuffer::ProfileBuffer(int aEntrySize, uint32_t aGeneration)
|
||||
: mEntries(MakeUnique<ProfileEntry[]>(aEntrySize))
|
||||
, mWritePos(0)
|
||||
, mReadPos(0)
|
||||
, mEntrySize(aEntrySize)
|
||||
, mGeneration(0)
|
||||
, mGeneration(aGeneration)
|
||||
{
|
||||
}
|
||||
|
||||
ProfileBuffer::~ProfileBuffer()
|
||||
{
|
||||
mGeneration = INT_MAX;
|
||||
mGeneration = UINT32_MAX;
|
||||
deleteExpiredStoredMarkers();
|
||||
}
|
||||
|
||||
@ -121,6 +121,11 @@ void ProfileBuffer::addTag(const ProfileEntry& aTag)
|
||||
{
|
||||
mEntries[mWritePos++] = aTag;
|
||||
if (mWritePos == mEntrySize) {
|
||||
// Wrapping around may result in things referenced in the buffer (e.g.,
|
||||
// JIT code addresses and markers) being incorrectly collected. 2 is
|
||||
// subtracted to assert that we do not leak stored markers in
|
||||
// ~ProfileBuffer.
|
||||
MOZ_ASSERT(mGeneration != UINT32_MAX - 2);
|
||||
mGeneration++;
|
||||
mWritePos = 0;
|
||||
}
|
||||
|
@ -98,7 +98,7 @@ class ProfileBuffer {
|
||||
public:
|
||||
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(ProfileBuffer)
|
||||
|
||||
explicit ProfileBuffer(int aEntrySize);
|
||||
explicit ProfileBuffer(int aEntrySize, uint32_t aGeneration = 0);
|
||||
|
||||
void addTag(const ProfileEntry& aTag);
|
||||
void IterateTagsForThread(IterateTagsCallback aCallback, int aThreadId);
|
||||
@ -131,7 +131,7 @@ public:
|
||||
int mEntrySize;
|
||||
|
||||
// How many times mWritePos has wrapped around.
|
||||
int mGeneration;
|
||||
uint32_t mGeneration;
|
||||
|
||||
// Markers that marker entries in the buffer might refer to.
|
||||
ProfilerMarkerLinkedList mStoredMarkers;
|
||||
@ -178,7 +178,6 @@ public:
|
||||
}
|
||||
|
||||
uint32_t bufferGeneration() const {
|
||||
MOZ_ASSERT(mBuffer->mGeneration >= 0);
|
||||
return mBuffer->mGeneration;
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include "UnwinderThread2.h"
|
||||
|
||||
SyncProfile::SyncProfile(ThreadInfo* aInfo, int aEntrySize)
|
||||
: ThreadProfile(aInfo, new ProfileBuffer(aEntrySize))
|
||||
: ThreadProfile(aInfo, new ProfileBuffer(aEntrySize, /* aGeneration = */ UINT32_MAX))
|
||||
, mOwnerState(REFERENCED)
|
||||
, mUtb(nullptr)
|
||||
{
|
||||
|
@ -635,14 +635,13 @@ void mergeStacksIntoProfile(ThreadProfile& aProfile, TickSample* aSample, Native
|
||||
nativeIndex--;
|
||||
}
|
||||
|
||||
MOZ_ASSERT(aProfile.bufferGeneration() >= startBufferGen);
|
||||
uint32_t lapCount = aProfile.bufferGeneration() - startBufferGen;
|
||||
|
||||
// Update the JS runtime with the current profile sample buffer generation.
|
||||
//
|
||||
// Do not do this for synchronous sampling, which create their own
|
||||
// ProfileBuffers.
|
||||
if (!aSample->isSamplingCurrentThread && pseudoStack->mRuntime) {
|
||||
MOZ_ASSERT(aProfile.bufferGeneration() >= startBufferGen);
|
||||
uint32_t lapCount = aProfile.bufferGeneration() - startBufferGen;
|
||||
JS::UpdateJSRuntimeProfilerSampleBufferGen(pseudoStack->mRuntime,
|
||||
aProfile.bufferGeneration(),
|
||||
lapCount);
|
||||
|
Loading…
Reference in New Issue
Block a user