diff --git a/tools/profiler/core/Sampler.cpp b/tools/profiler/core/Sampler.cpp index 181c4aa1f929..df952941df59 100644 --- a/tools/profiler/core/Sampler.cpp +++ b/tools/profiler/core/Sampler.cpp @@ -204,7 +204,6 @@ Sampler::Sampler(double aInterval, int aEntrySize, : interval_(aInterval) , paused_(false) , active_(false) - , entrySize_(aEntrySize) , mBuffer(new ProfileBuffer(aEntrySize)) { MOZ_COUNT_CTOR(Sampler); @@ -1262,7 +1261,7 @@ Sampler::GetBufferInfo(uint32_t *aCurrentPosition, uint32_t *aTotalSize, uint32_t *aGeneration) { *aCurrentPosition = mBuffer->mWritePos; - *aTotalSize = mBuffer->mEntrySize; + *aTotalSize = gEntrySize; *aGeneration = mBuffer->mGeneration; } diff --git a/tools/profiler/core/platform.cpp b/tools/profiler/core/platform.cpp index 0355cbd6d82f..059bd9da86d9 100644 --- a/tools/profiler/core/platform.cpp +++ b/tools/profiler/core/platform.cpp @@ -87,6 +87,9 @@ static mozilla::StaticMutex gThreadNameFiltersMutex; // All accesses to gFeatures are on the main thread, so no locking is needed. static Vector gFeatures; +// All accesses to gEntrySize are on the main thread, so no locking is needed. +static int gEntrySize = 0; + // We need to track whether we've been initialized otherwise // we end up using tlsStack without initializing it. // Because tlsStack is totally opaque to us we can't reuse @@ -677,7 +680,7 @@ profiler_get_start_params(int* aEntrySize, return; } - *aEntrySize = gSampler->EntrySize(); + *aEntrySize = gEntrySize; *aInterval = gSampler->interval(); { @@ -852,9 +855,9 @@ profiler_start(int aProfileEntries, double aInterval, gFeatures[i] = aFeatures[i]; } + gEntrySize = aProfileEntries ? aProfileEntries : PROFILE_DEFAULT_ENTRY; gSampler = - new Sampler(aInterval ? aInterval : PROFILE_DEFAULT_INTERVAL, - aProfileEntries ? aProfileEntries : PROFILE_DEFAULT_ENTRY, + new Sampler(aInterval ? aInterval : PROFILE_DEFAULT_INTERVAL, gEntrySize, aFeatures, aFeatureCount, aFilterCount); gGatherer = new mozilla::ProfileGatherer(gSampler); @@ -954,6 +957,7 @@ profiler_stop() gSampler->Stop(); delete gSampler; gSampler = nullptr; + gEntrySize = 0; // Cancel any in-flight async profile gatherering requests. gGatherer->Cancel(); diff --git a/tools/profiler/core/platform.h b/tools/profiler/core/platform.h index 181e2bf43dc8..4c4b1bc0b796 100644 --- a/tools/profiler/core/platform.h +++ b/tools/profiler/core/platform.h @@ -272,8 +272,6 @@ public: bool IsPaused() const { return paused_; } void SetPaused(bool value) { NoBarrier_Store(&paused_, value); } - int EntrySize() { return entrySize_; } - // We can't new/delete the type safely without defining it // (-Wdelete-incomplete). Use these to hide the details from // clients. @@ -344,7 +342,6 @@ private: const double interval_; Atomic32 paused_; Atomic32 active_; - const int entrySize_; // Refactor me! #if defined(SPS_OS_linux) || defined(SPS_OS_android)