зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1337189 (part 20) - Move Start() and Stop() out of Sampler. r=mstange.
The patch also renames them as PlatformStart() and PlatformStop() to make it clearer they are platform-specific.
This commit is contained in:
Родитель
d091075635
Коммит
7976b574cf
|
@ -186,7 +186,7 @@ Sampler::~Sampler()
|
|||
MOZ_COUNT_DTOR(Sampler);
|
||||
|
||||
if (gIsActive)
|
||||
Stop();
|
||||
PlatformStop();
|
||||
|
||||
// Destroy ThreadInfo for all threads
|
||||
{
|
||||
|
|
|
@ -90,7 +90,7 @@ static pthread_t gSignalSenderThread;
|
|||
|
||||
#if defined(USE_LUL_STACKWALK)
|
||||
// A singleton instance of the library. It is initialised at first
|
||||
// use. Currently only the main thread can call Sampler::Start, so
|
||||
// use. Currently only the main thread can call PlatformStart(), so
|
||||
// there is no need for a mechanism to ensure that it is only
|
||||
// created once in a multi-thread-use situation.
|
||||
lul::LUL* sLUL = nullptr;
|
||||
|
@ -358,7 +358,9 @@ static void* SignalSender(void* arg) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
void Sampler::Start() {
|
||||
static void
|
||||
PlatformStart()
|
||||
{
|
||||
MOZ_RELEASE_ASSERT(NS_IsMainThread());
|
||||
|
||||
LOG("Sampler started");
|
||||
|
@ -366,7 +368,7 @@ void Sampler::Start() {
|
|||
#if defined(USE_EHABI_STACKWALK)
|
||||
mozilla::EHABIStackWalkInit();
|
||||
#elif defined(USE_LUL_STACKWALK)
|
||||
// NOTE: this isn't thread-safe. But we expect Sampler::Start to be
|
||||
// NOTE: this isn't thread-safe. But we expect PlatformStart() to be
|
||||
// called only from the main thread, so this is OK in general.
|
||||
if (!sLUL) {
|
||||
sLUL_initialization_routine();
|
||||
|
@ -417,8 +419,9 @@ void Sampler::Start() {
|
|||
LOG("Profiler thread started");
|
||||
}
|
||||
|
||||
|
||||
void Sampler::Stop() {
|
||||
static void
|
||||
PlatformStop()
|
||||
{
|
||||
MOZ_RELEASE_ASSERT(NS_IsMainThread());
|
||||
|
||||
MOZ_ASSERT(gIsActive);
|
||||
|
|
|
@ -266,13 +266,17 @@ private:
|
|||
|
||||
SamplerThread* SamplerThread::mInstance = NULL;
|
||||
|
||||
void Sampler::Start() {
|
||||
static void
|
||||
PlatformStart()
|
||||
{
|
||||
MOZ_ASSERT(!gIsActive);
|
||||
gIsActive = true;
|
||||
SamplerThread::AddActiveSampler();
|
||||
}
|
||||
|
||||
void Sampler::Stop() {
|
||||
static void
|
||||
PlatformStop()
|
||||
{
|
||||
MOZ_ASSERT(gIsActive);
|
||||
gIsActive = false;
|
||||
SamplerThread::RemoveActiveSampler();
|
||||
|
|
|
@ -301,13 +301,17 @@ private:
|
|||
|
||||
SamplerThread* SamplerThread::mInstance = NULL;
|
||||
|
||||
void Sampler::Start() {
|
||||
static void
|
||||
PlatformStart()
|
||||
{
|
||||
MOZ_ASSERT(!gIsActive);
|
||||
gIsActive = true;
|
||||
SamplerThread::StartSampler();
|
||||
}
|
||||
|
||||
void Sampler::Stop() {
|
||||
static void
|
||||
PlatformStop()
|
||||
{
|
||||
MOZ_ASSERT(gIsActive);
|
||||
gIsActive = false;
|
||||
SamplerThread::StopSampler();
|
||||
|
|
|
@ -1211,7 +1211,7 @@ profiler_init(void* stackTop)
|
|||
// at this point. That would match the lifetime implied by destruction of it
|
||||
// in profiler_shutdown() just below. However, that gives a big delay on
|
||||
// startup, even if no profiling is actually to be done. So, instead, sLUL is
|
||||
// created on demand at the first call to Sampler::Start.
|
||||
// created on demand at the first call to PlatformStart().
|
||||
|
||||
PseudoStack* stack = new PseudoStack();
|
||||
tlsPseudoStack.set(stack);
|
||||
|
@ -1532,6 +1532,10 @@ hasFeature(const char** aFeatures, uint32_t aFeatureCount, const char* aFeature)
|
|||
return false;
|
||||
}
|
||||
|
||||
// Platform-specific start/stop actions.
|
||||
static void PlatformStart();
|
||||
static void PlatformStop();
|
||||
|
||||
// Values are only honored on the first start
|
||||
void
|
||||
profiler_start(int aProfileEntries, double aInterval,
|
||||
|
@ -1606,8 +1610,8 @@ profiler_start(int aProfileEntries, double aInterval,
|
|||
gUseStackWalk = hasFeature(aFeatures, aFeatureCount, "stackwalk");
|
||||
|
||||
MOZ_ASSERT(!gIsActive && !gIsPaused);
|
||||
gSampler->Start();
|
||||
MOZ_ASSERT(gIsActive && !gIsPaused); // Start() sets gIsActive.
|
||||
PlatformStart();
|
||||
MOZ_ASSERT(gIsActive && !gIsPaused); // PlatformStart() sets gIsActive.
|
||||
|
||||
if (gProfileJS || privacyMode) {
|
||||
mozilla::StaticMutexAutoLock lock(sRegisteredThreadsMutex);
|
||||
|
@ -1697,8 +1701,8 @@ profiler_stop()
|
|||
}
|
||||
gFeatures.clear();
|
||||
|
||||
gSampler->Stop();
|
||||
MOZ_ASSERT(!gIsActive && !gIsPaused); // Stop() clears these.
|
||||
PlatformStop();
|
||||
MOZ_ASSERT(!gIsActive && !gIsPaused); // PlatformStop() clears these.
|
||||
|
||||
gProfileJava = false;
|
||||
gProfileJS = false;
|
||||
|
|
|
@ -211,10 +211,6 @@ public:
|
|||
Sampler();
|
||||
~Sampler();
|
||||
|
||||
// Start and stop sampler.
|
||||
void Start();
|
||||
void Stop();
|
||||
|
||||
// We can't new/delete the type safely without defining it
|
||||
// (-Wdelete-incomplete). Use these to hide the details from
|
||||
// clients.
|
||||
|
|
Загрузка…
Ссылка в новой задаче