зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1339327 (part 4) - Rename some globals in the profiler. r=mstange.
The 'g' prefix is for global variables. The 's' prefix is for static class members.
This commit is contained in:
Родитель
27345fed25
Коммит
74eeaa5980
|
@ -775,7 +775,7 @@ void ProfileBuffer::DuplicateLastSample(int aThreadId)
|
|||
return;
|
||||
case ProfileEntry::Kind::Time:
|
||||
// Copy with new time
|
||||
addTag(ProfileEntry::Time((mozilla::TimeStamp::Now() - sStartTime).ToMilliseconds()));
|
||||
addTag(ProfileEntry::Time((mozilla::TimeStamp::Now() - gStartTime).ToMilliseconds()));
|
||||
break;
|
||||
case ProfileEntry::Kind::Marker:
|
||||
// Don't copy markers
|
||||
|
|
|
@ -95,16 +95,16 @@ static pthread_t gSignalSenderThread;
|
|||
// 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;
|
||||
lul::LUL* gLUL = nullptr;
|
||||
|
||||
// This is the sLUL initialization routine.
|
||||
static void sLUL_initialization_routine(void)
|
||||
// This is the gLUL initialization routine.
|
||||
static void gLUL_initialization_routine(void)
|
||||
{
|
||||
MOZ_ASSERT(!sLUL);
|
||||
MOZ_ASSERT(!gLUL);
|
||||
MOZ_ASSERT(gettid() == getpid()); /* "this is the main thread" */
|
||||
sLUL = new lul::LUL(logging_sink_for_LUL);
|
||||
gLUL = new lul::LUL(logging_sink_for_LUL);
|
||||
// Read all the unwind info currently available.
|
||||
read_procmaps(sLUL);
|
||||
read_procmaps(gLUL);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -151,8 +151,8 @@ static void* setup_atfork() {
|
|||
}
|
||||
#endif /* !defined(ANDROID) */
|
||||
|
||||
static mozilla::Atomic<ThreadInfo*> sCurrentThreadInfo;
|
||||
static sem_t sSignalHandlingDone;
|
||||
static mozilla::Atomic<ThreadInfo*> gCurrentThreadInfo;
|
||||
static sem_t gSignalHandlingDone;
|
||||
|
||||
static void SetSampleContext(TickSample* sample, void* context)
|
||||
{
|
||||
|
@ -202,7 +202,7 @@ void ProfilerSignalHandler(int signal, siginfo_t* info, void* context) {
|
|||
|
||||
// XXX: this is an off-main-thread(?) use of gSampler
|
||||
if (!gSampler) {
|
||||
sem_post(&sSignalHandlingDone);
|
||||
sem_post(&gSignalHandlingDone);
|
||||
errno = savedErrno;
|
||||
return;
|
||||
}
|
||||
|
@ -213,15 +213,15 @@ void ProfilerSignalHandler(int signal, siginfo_t* info, void* context) {
|
|||
|
||||
// Extract the current pc and sp.
|
||||
SetSampleContext(sample, context);
|
||||
sample->threadInfo = sCurrentThreadInfo;
|
||||
sample->threadInfo = gCurrentThreadInfo;
|
||||
sample->timestamp = mozilla::TimeStamp::Now();
|
||||
sample->rssMemory = sample->threadInfo->mRssMemory;
|
||||
sample->ussMemory = sample->threadInfo->mUssMemory;
|
||||
|
||||
Tick(sample);
|
||||
|
||||
sCurrentThreadInfo = NULL;
|
||||
sem_post(&sSignalHandlingDone);
|
||||
gCurrentThreadInfo = NULL;
|
||||
sem_post(&gSignalHandlingDone);
|
||||
errno = savedErrno;
|
||||
}
|
||||
|
||||
|
@ -285,11 +285,11 @@ static void* SignalSender(void* arg) {
|
|||
gBuffer->deleteExpiredStoredMarkers();
|
||||
|
||||
if (!gIsPaused) {
|
||||
StaticMutexAutoLock lock(sRegisteredThreadsMutex);
|
||||
StaticMutexAutoLock lock(gRegisteredThreadsMutex);
|
||||
|
||||
bool isFirstProfiledThread = true;
|
||||
for (uint32_t i = 0; i < sRegisteredThreads->size(); i++) {
|
||||
ThreadInfo* info = (*sRegisteredThreads)[i];
|
||||
for (uint32_t i = 0; i < gRegisteredThreads->size(); i++) {
|
||||
ThreadInfo* info = (*gRegisteredThreads)[i];
|
||||
|
||||
// This will be null if we're not interested in profiling this thread.
|
||||
if (!info->hasProfile() || info->IsPendingDelete()) {
|
||||
|
@ -303,9 +303,9 @@ static void* SignalSender(void* arg) {
|
|||
|
||||
info->UpdateThreadResponsiveness();
|
||||
|
||||
// We use sCurrentThreadInfo to pass the ThreadInfo for the
|
||||
// We use gCurrentThreadInfo to pass the ThreadInfo for the
|
||||
// thread we're profiling to the signal handler.
|
||||
sCurrentThreadInfo = info;
|
||||
gCurrentThreadInfo = info;
|
||||
|
||||
int threadId = info->ThreadId();
|
||||
MOZ_ASSERT(threadId != my_tid);
|
||||
|
@ -313,7 +313,7 @@ static void* SignalSender(void* arg) {
|
|||
// Profile from the signal sender for information which is not signal
|
||||
// safe, and will have low variation between the emission of the signal
|
||||
// and the signal handler catch.
|
||||
ProfilerSignalThread(sCurrentThreadInfo, isFirstProfiledThread);
|
||||
ProfilerSignalThread(gCurrentThreadInfo, isFirstProfiledThread);
|
||||
|
||||
// Profile from the signal handler for information which is signal safe
|
||||
// and needs to be precise too, such as the stack of the interrupted
|
||||
|
@ -328,7 +328,7 @@ static void* SignalSender(void* arg) {
|
|||
}
|
||||
|
||||
// Wait for the signal handler to run before moving on to the next one
|
||||
sem_wait(&sSignalHandlingDone);
|
||||
sem_wait(&gSignalHandlingDone);
|
||||
isFirstProfiledThread = false;
|
||||
|
||||
// The LUL unwind object accumulates frame statistics.
|
||||
|
@ -338,7 +338,7 @@ static void* SignalSender(void* arg) {
|
|||
// the unwinder threads, which is why it is done here.
|
||||
if ((++nSignalsSent & 0xF) == 0) {
|
||||
# if defined(USE_LUL_STACKWALK)
|
||||
sLUL->MaybeShowStats();
|
||||
gLUL->MaybeShowStats();
|
||||
# endif
|
||||
}
|
||||
}
|
||||
|
@ -369,14 +369,14 @@ PlatformStart()
|
|||
#elif defined(USE_LUL_STACKWALK)
|
||||
// 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();
|
||||
if (!gLUL) {
|
||||
gLUL_initialization_routine();
|
||||
}
|
||||
#endif
|
||||
|
||||
// Initialize signal handler communication
|
||||
sCurrentThreadInfo = nullptr;
|
||||
if (sem_init(&sSignalHandlingDone, /* pshared: */ 0, /* value: */ 0) != 0) {
|
||||
gCurrentThreadInfo = nullptr;
|
||||
if (sem_init(&gSignalHandlingDone, /* pshared: */ 0, /* value: */ 0) != 0) {
|
||||
LOG("Error initializing semaphore");
|
||||
return;
|
||||
}
|
||||
|
@ -398,12 +398,12 @@ PlatformStart()
|
|||
// Switch into unwind mode. After this point, we can't add or
|
||||
// remove any unwind info to/from this LUL instance. The only thing
|
||||
// we can do with it is Unwind() calls.
|
||||
sLUL->EnableUnwinding();
|
||||
gLUL->EnableUnwinding();
|
||||
|
||||
// Has a test been requested?
|
||||
if (PR_GetEnv("MOZ_PROFILER_LUL_TEST")) {
|
||||
int nTests = 0, nTestsPassed = 0;
|
||||
RunLulUnitTests(&nTests, &nTestsPassed, sLUL);
|
||||
RunLulUnitTests(&nTests, &nTestsPassed, gLUL);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -159,11 +159,11 @@ public:
|
|||
gBuffer->deleteExpiredStoredMarkers();
|
||||
|
||||
if (!gIsPaused) {
|
||||
StaticMutexAutoLock lock(sRegisteredThreadsMutex);
|
||||
StaticMutexAutoLock lock(gRegisteredThreadsMutex);
|
||||
|
||||
bool isFirstProfiledThread = true;
|
||||
for (uint32_t i = 0; i < sRegisteredThreads->size(); i++) {
|
||||
ThreadInfo* info = (*sRegisteredThreads)[i];
|
||||
for (uint32_t i = 0; i < gRegisteredThreads->size(); i++) {
|
||||
ThreadInfo* info = (*gRegisteredThreads)[i];
|
||||
|
||||
// This will be null if we're not interested in profiling this thread.
|
||||
if (!info->hasProfile() || info->IsPendingDelete()) {
|
||||
|
|
|
@ -161,11 +161,11 @@ class SamplerThread
|
|||
gBuffer->deleteExpiredStoredMarkers();
|
||||
|
||||
if (!gIsPaused) {
|
||||
mozilla::StaticMutexAutoLock lock(sRegisteredThreadsMutex);
|
||||
mozilla::StaticMutexAutoLock lock(gRegisteredThreadsMutex);
|
||||
|
||||
bool isFirstProfiledThread = true;
|
||||
for (uint32_t i = 0; i < sRegisteredThreads->size(); i++) {
|
||||
ThreadInfo* info = (*sRegisteredThreads)[i];
|
||||
for (uint32_t i = 0; i < gRegisteredThreads->size(); i++) {
|
||||
ThreadInfo* info = (*gRegisteredThreads)[i];
|
||||
|
||||
// This will be null if we're not interested in profiling this thread.
|
||||
if (!info->hasProfile() || info->IsPendingDelete()) {
|
||||
|
|
|
@ -103,8 +103,8 @@ MOZ_THREAD_LOCAL(PseudoStack *) tlsPseudoStack;
|
|||
|
||||
static Sampler* gSampler;
|
||||
|
||||
static std::vector<ThreadInfo*>* sRegisteredThreads = nullptr;
|
||||
static mozilla::StaticMutex sRegisteredThreadsMutex;
|
||||
static std::vector<ThreadInfo*>* gRegisteredThreads = nullptr;
|
||||
static mozilla::StaticMutex gRegisteredThreadsMutex;
|
||||
|
||||
// All accesses to gGatherer are on the main thread, so no locking is needed.
|
||||
static StaticRefPtr<mozilla::ProfileGatherer> gGatherer;
|
||||
|
@ -146,16 +146,16 @@ bool stack_key_initialized;
|
|||
// XXX: This is set by profiler_init() and profiler_start() on the main thread.
|
||||
// It is read off the main thread, e.g. by Tick(). It might require more
|
||||
// inter-thread synchronization than it currently has.
|
||||
mozilla::TimeStamp sStartTime;
|
||||
mozilla::TimeStamp gStartTime;
|
||||
|
||||
// XXX: These are accessed by multiple threads and might require more
|
||||
// inter-thread synchronization than they currently have.
|
||||
static int gFrameNumber = 0;
|
||||
static int gLastFrameNumber = 0;
|
||||
|
||||
int sInitCount = 0; // Each init must have a matched shutdown.
|
||||
static int gInitCount = 0; // Each init must have a matched shutdown.
|
||||
|
||||
static bool sIsProfiling = false; // is raced on
|
||||
static bool gIsProfiling = false; // is raced on
|
||||
|
||||
// All accesses to these are on the main thread, so no locking is needed.
|
||||
static bool gProfileJava = false;
|
||||
|
@ -186,16 +186,16 @@ const char* PROFILER_FEATURES = "MOZ_PROFILING_FEATURES";
|
|||
* to know are associated with different events */
|
||||
|
||||
// Values harvested from env vars, that control the profiler.
|
||||
static int sUnwindInterval; /* in milliseconds */
|
||||
static int sUnwindStackScan; /* max # of dubious frames allowed */
|
||||
static int sProfileEntries; /* how many entries do we store? */
|
||||
static int gUnwindInterval; /* in milliseconds */
|
||||
static int gUnwindStackScan; /* max # of dubious frames allowed */
|
||||
static int gProfileEntries; /* how many entries do we store? */
|
||||
|
||||
static mozilla::StaticAutoPtr<mozilla::ProfilerIOInterposeObserver>
|
||||
sInterposeObserver;
|
||||
gInterposeObserver;
|
||||
|
||||
// The name that identifies the gecko thread for calls to
|
||||
// profiler_register_thread.
|
||||
static const char * gGeckoThreadName = "GeckoMain";
|
||||
static const char* gGeckoThreadName = "GeckoMain";
|
||||
|
||||
static bool
|
||||
CanNotifyObservers()
|
||||
|
@ -754,7 +754,7 @@ DoNativeBacktrace(ThreadInfo& aInfo, TickSample* aSample)
|
|||
size_t framesAvail = mozilla::ArrayLength(framePCs);
|
||||
size_t framesUsed = 0;
|
||||
size_t scannedFramesAcquired = 0;
|
||||
sLUL->Unwind(&framePCs[0], &frameSPs[0],
|
||||
gLUL->Unwind(&framePCs[0], &frameSPs[0],
|
||||
&framesUsed, &scannedFramesAcquired,
|
||||
framesAvail, scannedFramesAllowed,
|
||||
&startRegs, &stackImg );
|
||||
|
@ -772,9 +772,9 @@ DoNativeBacktrace(ThreadInfo& aInfo, TickSample* aSample)
|
|||
|
||||
// Update stats in the LUL stats object. Unfortunately this requires
|
||||
// three global memory operations.
|
||||
sLUL->mStats.mContext += 1;
|
||||
sLUL->mStats.mCFI += framesUsed - 1 - scannedFramesAcquired;
|
||||
sLUL->mStats.mScanned += scannedFramesAcquired;
|
||||
gLUL->mStats.mContext += 1;
|
||||
gLUL->mStats.mCFI += framesUsed - 1 - scannedFramesAcquired;
|
||||
gLUL->mStats.mScanned += scannedFramesAcquired;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -801,7 +801,7 @@ Tick(TickSample* aSample)
|
|||
|
||||
currThreadInfo.addTag(ProfileEntry::ThreadId(currThreadInfo.ThreadId()));
|
||||
|
||||
mozilla::TimeDuration delta = aSample->timestamp - sStartTime;
|
||||
mozilla::TimeDuration delta = aSample->timestamp - gStartTime;
|
||||
currThreadInfo.addTag(ProfileEntry::Time(delta.ToMilliseconds()));
|
||||
|
||||
PseudoStack* stack = currThreadInfo.Stack();
|
||||
|
@ -950,7 +950,7 @@ StreamTaskTracer(SpliceableJSONWriter& aWriter)
|
|||
aWriter.StartArrayProperty("data");
|
||||
{
|
||||
UniquePtr<nsTArray<nsCString>> data =
|
||||
mozilla::tasktracer::GetLoggedData(sStartTime);
|
||||
mozilla::tasktracer::GetLoggedData(gStartTime);
|
||||
for (uint32_t i = 0; i < data->Length(); ++i) {
|
||||
aWriter.StringElement((data->ElementAt(i)).get());
|
||||
}
|
||||
|
@ -959,11 +959,11 @@ StreamTaskTracer(SpliceableJSONWriter& aWriter)
|
|||
|
||||
aWriter.StartArrayProperty("threads");
|
||||
{
|
||||
StaticMutexAutoLock lock(sRegisteredThreadsMutex);
|
||||
StaticMutexAutoLock lock(gRegisteredThreadsMutex);
|
||||
|
||||
for (size_t i = 0; i < sRegisteredThreads->size(); i++) {
|
||||
for (size_t i = 0; i < gRegisteredThreads->size(); i++) {
|
||||
// Thread meta data
|
||||
ThreadInfo* info = sRegisteredThreads->at(i);
|
||||
ThreadInfo* info = gRegisteredThreads->at(i);
|
||||
aWriter.StartObjectElement();
|
||||
{
|
||||
if (XRE_GetProcessType() == GeckoProcessType_Plugin) {
|
||||
|
@ -1004,7 +1004,7 @@ StreamMetaJSCustomObject(SpliceableJSONWriter& aWriter)
|
|||
bool asyncStacks = Preferences::GetBool("javascript.options.asyncstack");
|
||||
aWriter.IntProperty("asyncstack", asyncStacks);
|
||||
|
||||
mozilla::TimeDuration delta = mozilla::TimeStamp::Now() - sStartTime;
|
||||
mozilla::TimeDuration delta = mozilla::TimeStamp::Now() - gStartTime;
|
||||
aWriter.DoubleProperty(
|
||||
"startTime", static_cast<double>(PR_Now()/1000.0 - delta.ToMilliseconds()));
|
||||
|
||||
|
@ -1162,11 +1162,11 @@ StreamJSON(SpliceableJSONWriter& aWriter, double aSinceTime)
|
|||
gIsPaused = true;
|
||||
|
||||
{
|
||||
StaticMutexAutoLock lock(sRegisteredThreadsMutex);
|
||||
StaticMutexAutoLock lock(gRegisteredThreadsMutex);
|
||||
|
||||
for (size_t i = 0; i < sRegisteredThreads->size(); i++) {
|
||||
for (size_t i = 0; i < gRegisteredThreads->size(); i++) {
|
||||
// Thread not being profiled, skip it
|
||||
ThreadInfo* info = sRegisteredThreads->at(i);
|
||||
ThreadInfo* info = gRegisteredThreads->at(i);
|
||||
if (!info->hasProfile()) {
|
||||
continue;
|
||||
}
|
||||
|
@ -1323,7 +1323,7 @@ bool set_profiler_interval(const char* interval) {
|
|||
errno = 0;
|
||||
long int n = strtol(interval, (char**)nullptr, 10);
|
||||
if (errno == 0 && n >= 1 && n <= 1000) {
|
||||
sUnwindInterval = n;
|
||||
gUnwindInterval = n;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -1337,7 +1337,7 @@ bool set_profiler_entries(const char* entries) {
|
|||
errno = 0;
|
||||
long int n = strtol(entries, (char**)nullptr, 10);
|
||||
if (errno == 0 && n > 0) {
|
||||
sProfileEntries = n;
|
||||
gProfileEntries = n;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -1351,7 +1351,7 @@ bool set_profiler_scan(const char* scanCount) {
|
|||
errno = 0;
|
||||
long int n = strtol(scanCount, (char**)nullptr, 10);
|
||||
if (errno == 0 && n >= 0 && n <= 100) {
|
||||
sUnwindStackScan = n;
|
||||
gUnwindStackScan = n;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -1369,12 +1369,12 @@ bool is_native_unwinding_avail() {
|
|||
}
|
||||
|
||||
// Read env vars at startup, so as to set:
|
||||
// sUnwindInterval, sProfileEntries, sUnwindStackScan.
|
||||
// gUnwindInterval, gProfileEntries, gUnwindStackScan.
|
||||
void read_profiler_env_vars()
|
||||
{
|
||||
/* Set defaults */
|
||||
sUnwindInterval = 0; /* We'll have to look elsewhere */
|
||||
sProfileEntries = 0;
|
||||
gUnwindInterval = 0; /* We'll have to look elsewhere */
|
||||
gProfileEntries = 0;
|
||||
|
||||
const char* interval = getenv(PROFILER_INTERVAL);
|
||||
const char* entries = getenv(PROFILER_ENTRIES);
|
||||
|
@ -1396,11 +1396,11 @@ void read_profiler_env_vars()
|
|||
} else {
|
||||
LOG( "Profiler:");
|
||||
LOGF("Profiler: Sampling interval = %d ms (zero means \"platform default\")",
|
||||
(int)sUnwindInterval);
|
||||
(int)gUnwindInterval);
|
||||
LOGF("Profiler: Entry store size = %d (zero means \"platform default\")",
|
||||
(int)sProfileEntries);
|
||||
(int)gProfileEntries);
|
||||
LOGF("Profiler: UnwindStackScan = %d (max dubious frames per unwind).",
|
||||
(int)sUnwindStackScan);
|
||||
(int)gUnwindStackScan);
|
||||
LOG( "Profiler:");
|
||||
}
|
||||
}
|
||||
|
@ -1433,17 +1433,17 @@ void profiler_usage() {
|
|||
LOG( "Profiler: ");
|
||||
|
||||
/* Re-set defaults */
|
||||
sUnwindInterval = 0; /* We'll have to look elsewhere */
|
||||
sProfileEntries = 0;
|
||||
sUnwindStackScan = 0;
|
||||
gUnwindInterval = 0; /* We'll have to look elsewhere */
|
||||
gProfileEntries = 0;
|
||||
gUnwindStackScan = 0;
|
||||
|
||||
LOG( "Profiler:");
|
||||
LOGF("Profiler: Sampling interval = %d ms (zero means \"platform default\")",
|
||||
(int)sUnwindInterval);
|
||||
(int)gUnwindInterval);
|
||||
LOGF("Profiler: Entry store size = %d (zero means \"platform default\")",
|
||||
(int)sProfileEntries);
|
||||
(int)gProfileEntries);
|
||||
LOGF("Profiler: UnwindStackScan = %d (max dubious frames per unwind).",
|
||||
(int)sUnwindStackScan);
|
||||
(int)gUnwindStackScan);
|
||||
LOG( "Profiler:");
|
||||
|
||||
return;
|
||||
|
@ -1518,10 +1518,10 @@ GeckoProfilerReporter::CollectReports(nsIHandleReportCallback* aHandleReport,
|
|||
|
||||
size_t n = 0;
|
||||
{
|
||||
StaticMutexAutoLock lock(sRegisteredThreadsMutex);
|
||||
StaticMutexAutoLock lock(gRegisteredThreadsMutex);
|
||||
|
||||
for (uint32_t i = 0; i < sRegisteredThreads->size(); i++) {
|
||||
ThreadInfo* info = sRegisteredThreads->at(i);
|
||||
for (uint32_t i = 0; i < gRegisteredThreads->size(); i++) {
|
||||
ThreadInfo* info = gRegisteredThreads->at(i);
|
||||
|
||||
n += info->SizeOfIncludingThis(GeckoProfilerMallocSizeOf);
|
||||
}
|
||||
|
@ -1538,7 +1538,7 @@ GeckoProfilerReporter::CollectReports(nsIHandleReportCallback* aHandleReport,
|
|||
}
|
||||
|
||||
#if defined(USE_LUL_STACKWALK)
|
||||
n = sLUL ? sLUL->SizeOfIncludingThis(GeckoProfilerMallocSizeOf) : 0;
|
||||
n = gLUL ? gLUL->SizeOfIncludingThis(GeckoProfilerMallocSizeOf) : 0;
|
||||
MOZ_COLLECT_REPORT(
|
||||
"explicit/profiler/lul", KIND_HEAP, UNITS_BYTES, n,
|
||||
"Memory used by LUL, a stack unwinder used by the Gecko Profiler.");
|
||||
|
@ -1592,16 +1592,16 @@ static void
|
|||
RegisterCurrentThread(const char* aName, PseudoStack* aPseudoStack,
|
||||
bool aIsMainThread, void* stackTop)
|
||||
{
|
||||
StaticMutexAutoLock lock(sRegisteredThreadsMutex);
|
||||
StaticMutexAutoLock lock(gRegisteredThreadsMutex);
|
||||
|
||||
if (!sRegisteredThreads) {
|
||||
if (!gRegisteredThreads) {
|
||||
return;
|
||||
}
|
||||
|
||||
Thread::tid_t id = Thread::GetCurrentId();
|
||||
|
||||
for (uint32_t i = 0; i < sRegisteredThreads->size(); i++) {
|
||||
ThreadInfo* info = sRegisteredThreads->at(i);
|
||||
for (uint32_t i = 0; i < gRegisteredThreads->size(); i++) {
|
||||
ThreadInfo* info = gRegisteredThreads->at(i);
|
||||
if (info->ThreadId() == id && !info->IsPendingDelete()) {
|
||||
// Thread already registered. This means the first unregister will be
|
||||
// too early.
|
||||
|
@ -1615,7 +1615,7 @@ RegisterCurrentThread(const char* aName, PseudoStack* aPseudoStack,
|
|||
|
||||
MaybeSetProfile(info);
|
||||
|
||||
sRegisteredThreads->push_back(info);
|
||||
gRegisteredThreads->push_back(info);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1623,7 +1623,7 @@ profiler_init(void* stackTop)
|
|||
{
|
||||
MOZ_RELEASE_ASSERT(NS_IsMainThread());
|
||||
|
||||
sInitCount++;
|
||||
gInitCount++;
|
||||
|
||||
if (stack_key_initialized)
|
||||
return;
|
||||
|
@ -1638,20 +1638,20 @@ profiler_init(void* stackTop)
|
|||
return;
|
||||
}
|
||||
bool ignore;
|
||||
sStartTime = mozilla::TimeStamp::ProcessCreation(ignore);
|
||||
gStartTime = mozilla::TimeStamp::ProcessCreation(ignore);
|
||||
|
||||
stack_key_initialized = true;
|
||||
|
||||
{
|
||||
StaticMutexAutoLock lock(sRegisteredThreadsMutex);
|
||||
StaticMutexAutoLock lock(gRegisteredThreadsMutex);
|
||||
|
||||
sRegisteredThreads = new std::vector<ThreadInfo*>();
|
||||
gRegisteredThreads = new std::vector<ThreadInfo*>();
|
||||
}
|
||||
|
||||
// (Linux-only) We could create the sLUL object and read unwind info into it
|
||||
// (Linux-only) We could create the gLUL object and read unwind info into it
|
||||
// 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
|
||||
// startup, even if no profiling is actually to be done. So, instead, gLUL is
|
||||
// created on demand at the first call to PlatformStart().
|
||||
|
||||
PseudoStack* stack = new PseudoStack();
|
||||
|
@ -1709,9 +1709,9 @@ profiler_shutdown()
|
|||
{
|
||||
MOZ_RELEASE_ASSERT(NS_IsMainThread());
|
||||
|
||||
sInitCount--;
|
||||
gInitCount--;
|
||||
|
||||
if (sInitCount > 0)
|
||||
if (gInitCount > 0)
|
||||
return;
|
||||
|
||||
// Save the profile on shutdown if requested.
|
||||
|
@ -1727,28 +1727,28 @@ profiler_shutdown()
|
|||
set_stderr_callback(nullptr);
|
||||
|
||||
{
|
||||
StaticMutexAutoLock lock(sRegisteredThreadsMutex);
|
||||
StaticMutexAutoLock lock(gRegisteredThreadsMutex);
|
||||
|
||||
while (sRegisteredThreads->size() > 0) {
|
||||
delete sRegisteredThreads->back();
|
||||
sRegisteredThreads->pop_back();
|
||||
while (gRegisteredThreads->size() > 0) {
|
||||
delete gRegisteredThreads->back();
|
||||
gRegisteredThreads->pop_back();
|
||||
}
|
||||
|
||||
// UnregisterThread can be called after shutdown in XPCShell. Thus we need
|
||||
// to point to null to ignore such a call after shutdown.
|
||||
delete sRegisteredThreads;
|
||||
sRegisteredThreads = nullptr;
|
||||
delete gRegisteredThreads;
|
||||
gRegisteredThreads = nullptr;
|
||||
}
|
||||
|
||||
#if defined(USE_LUL_STACKWALK)
|
||||
// Delete the sLUL object, if it actually got created.
|
||||
if (sLUL) {
|
||||
delete sLUL;
|
||||
sLUL = nullptr;
|
||||
// Delete the gLUL object, if it actually got created.
|
||||
if (gLUL) {
|
||||
delete gLUL;
|
||||
gLUL = nullptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
// We just destroyed all the ThreadInfos in sRegisteredThreads, so it is safe
|
||||
// We just destroyed all the ThreadInfos in gRegisteredThreads, so it is safe
|
||||
// the delete the PseudoStack.
|
||||
delete tlsPseudoStack.get();
|
||||
tlsPseudoStack.set(nullptr);
|
||||
|
@ -1987,12 +1987,12 @@ profiler_start(int aProfileEntries, double aInterval,
|
|||
|
||||
/* If the sampling interval was set using env vars, use that
|
||||
in preference to anything else. */
|
||||
if (sUnwindInterval > 0)
|
||||
aInterval = sUnwindInterval;
|
||||
if (gUnwindInterval > 0)
|
||||
aInterval = gUnwindInterval;
|
||||
|
||||
/* If the entry count was set using env vars, use that, too: */
|
||||
if (sProfileEntries > 0)
|
||||
aProfileEntries = sProfileEntries;
|
||||
if (gProfileEntries > 0)
|
||||
aProfileEntries = gProfileEntries;
|
||||
|
||||
// Reset the current state if the profiler is running
|
||||
profiler_stop();
|
||||
|
@ -2020,14 +2020,14 @@ profiler_start(int aProfileEntries, double aInterval,
|
|||
gSampler = new Sampler();
|
||||
|
||||
bool ignore;
|
||||
sStartTime = mozilla::TimeStamp::ProcessCreation(ignore);
|
||||
gStartTime = mozilla::TimeStamp::ProcessCreation(ignore);
|
||||
|
||||
{
|
||||
StaticMutexAutoLock lock(sRegisteredThreadsMutex);
|
||||
StaticMutexAutoLock lock(gRegisteredThreadsMutex);
|
||||
|
||||
// Set up profiling for each registered thread, if appropriate
|
||||
for (uint32_t i = 0; i < sRegisteredThreads->size(); i++) {
|
||||
ThreadInfo* info = sRegisteredThreads->at(i);
|
||||
for (uint32_t i = 0; i < gRegisteredThreads->size(); i++) {
|
||||
ThreadInfo* info = gRegisteredThreads->at(i);
|
||||
|
||||
MaybeSetProfile(info);
|
||||
}
|
||||
|
@ -2070,10 +2070,10 @@ profiler_start(int aProfileEntries, double aInterval,
|
|||
MOZ_ASSERT(gIsActive && !gIsPaused); // PlatformStart() sets gIsActive.
|
||||
|
||||
if (gProfileJS || privacyMode) {
|
||||
mozilla::StaticMutexAutoLock lock(sRegisteredThreadsMutex);
|
||||
mozilla::StaticMutexAutoLock lock(gRegisteredThreadsMutex);
|
||||
|
||||
for (uint32_t i = 0; i < sRegisteredThreads->size(); i++) {
|
||||
ThreadInfo* info = (*sRegisteredThreads)[i];
|
||||
for (uint32_t i = 0; i < gRegisteredThreads->size(); i++) {
|
||||
ThreadInfo* info = (*gRegisteredThreads)[i];
|
||||
if (info->IsPendingDelete() || !info->hasProfile()) {
|
||||
continue;
|
||||
}
|
||||
|
@ -2099,15 +2099,15 @@ profiler_start(int aProfileEntries, double aInterval,
|
|||
#endif
|
||||
|
||||
if (mainThreadIO) {
|
||||
if (!sInterposeObserver) {
|
||||
if (!gInterposeObserver) {
|
||||
// Lazily create IO interposer observer
|
||||
sInterposeObserver = new mozilla::ProfilerIOInterposeObserver();
|
||||
gInterposeObserver = new mozilla::ProfilerIOInterposeObserver();
|
||||
}
|
||||
mozilla::IOInterposer::Register(mozilla::IOInterposeObserver::OpAll,
|
||||
sInterposeObserver);
|
||||
gInterposeObserver);
|
||||
}
|
||||
|
||||
sIsProfiling = true;
|
||||
gIsProfiling = true;
|
||||
|
||||
if (CanNotifyObservers()) {
|
||||
nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
|
||||
|
@ -2178,17 +2178,17 @@ profiler_stop()
|
|||
|
||||
// Destroy ThreadInfo for all threads
|
||||
{
|
||||
StaticMutexAutoLock lock(sRegisteredThreadsMutex);
|
||||
StaticMutexAutoLock lock(gRegisteredThreadsMutex);
|
||||
|
||||
for (uint32_t i = 0; i < sRegisteredThreads->size(); i++) {
|
||||
ThreadInfo* info = sRegisteredThreads->at(i);
|
||||
for (uint32_t i = 0; i < gRegisteredThreads->size(); i++) {
|
||||
ThreadInfo* info = gRegisteredThreads->at(i);
|
||||
// We've stopped profiling. We no longer need to retain
|
||||
// information for an old thread.
|
||||
if (info->IsPendingDelete()) {
|
||||
// The stack was nulled when SetPendingDelete() was called.
|
||||
MOZ_ASSERT(!info->Stack());
|
||||
delete info;
|
||||
sRegisteredThreads->erase(sRegisteredThreads->begin() + i);
|
||||
gRegisteredThreads->erase(gRegisteredThreads->begin() + i);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
|
@ -2217,10 +2217,10 @@ profiler_stop()
|
|||
}
|
||||
|
||||
mozilla::IOInterposer::Unregister(mozilla::IOInterposeObserver::OpAll,
|
||||
sInterposeObserver);
|
||||
sInterposeObserver = nullptr;
|
||||
gInterposeObserver);
|
||||
gInterposeObserver = nullptr;
|
||||
|
||||
sIsProfiling = false;
|
||||
gIsProfiling = false;
|
||||
|
||||
if (CanNotifyObservers()) {
|
||||
nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
|
||||
|
@ -2284,7 +2284,7 @@ profiler_feature_active(const char* aName)
|
|||
{
|
||||
// This function runs both on and off the main thread.
|
||||
|
||||
if (!sIsProfiling) {
|
||||
if (!gIsProfiling) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -2312,7 +2312,7 @@ profiler_is_active()
|
|||
{
|
||||
// This function runs both on and off the main thread.
|
||||
|
||||
return sIsProfiling;
|
||||
return gIsProfiling;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -2349,7 +2349,7 @@ profiler_register_thread(const char* aName, void* aGuessStackTop)
|
|||
{
|
||||
// This function runs both on and off the main thread.
|
||||
|
||||
if (sInitCount == 0) {
|
||||
if (gInitCount == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2375,20 +2375,20 @@ profiler_unregister_thread()
|
|||
{
|
||||
// This function runs both on and off the main thread.
|
||||
|
||||
// Don't check sInitCount count here -- we may be unregistering the
|
||||
// Don't check gInitCount count here -- we may be unregistering the
|
||||
// thread after the sampler was shut down.
|
||||
if (!stack_key_initialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
{
|
||||
StaticMutexAutoLock lock(sRegisteredThreadsMutex);
|
||||
StaticMutexAutoLock lock(gRegisteredThreadsMutex);
|
||||
|
||||
if (sRegisteredThreads) {
|
||||
if (gRegisteredThreads) {
|
||||
Thread::tid_t id = Thread::GetCurrentId();
|
||||
|
||||
for (uint32_t i = 0; i < sRegisteredThreads->size(); i++) {
|
||||
ThreadInfo* info = sRegisteredThreads->at(i);
|
||||
for (uint32_t i = 0; i < gRegisteredThreads->size(); i++) {
|
||||
ThreadInfo* info = gRegisteredThreads->at(i);
|
||||
if (info->ThreadId() == id && !info->IsPendingDelete()) {
|
||||
if (profiler_is_active()) {
|
||||
// We still want to show the results of this thread if you
|
||||
|
@ -2397,7 +2397,7 @@ profiler_unregister_thread()
|
|||
info->SetPendingDelete();
|
||||
} else {
|
||||
delete info;
|
||||
sRegisteredThreads->erase(sRegisteredThreads->begin() + i);
|
||||
gRegisteredThreads->erase(gRegisteredThreads->begin() + i);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -2417,7 +2417,7 @@ profiler_sleep_start()
|
|||
{
|
||||
// This function runs both on and off the main thread.
|
||||
|
||||
if (sInitCount == 0) {
|
||||
if (gInitCount == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2433,7 +2433,7 @@ profiler_sleep_end()
|
|||
{
|
||||
// This function runs both on and off the main thread.
|
||||
|
||||
if (sInitCount == 0) {
|
||||
if (gInitCount == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2451,7 +2451,7 @@ profiler_is_sleeping()
|
|||
// (and this assertion) could be removed without too much difficulty.
|
||||
MOZ_RELEASE_ASSERT(NS_IsMainThread());
|
||||
|
||||
if (sInitCount == 0) {
|
||||
if (gInitCount == 0) {
|
||||
return false;
|
||||
}
|
||||
PseudoStack *stack = tlsPseudoStack.get();
|
||||
|
@ -2479,7 +2479,7 @@ profiler_time(const mozilla::TimeStamp& aTime)
|
|||
{
|
||||
MOZ_RELEASE_ASSERT(NS_IsMainThread());
|
||||
|
||||
mozilla::TimeDuration delta = aTime - sStartTime;
|
||||
mozilla::TimeDuration delta = aTime - gStartTime;
|
||||
return delta.ToMilliseconds();
|
||||
}
|
||||
|
||||
|
@ -2653,7 +2653,7 @@ profiler_add_marker(const char *aMarker, ProfilerMarkerPayload *aPayload)
|
|||
|
||||
mozilla::TimeStamp origin = (aPayload && !aPayload->GetStartTime().IsNull()) ?
|
||||
aPayload->GetStartTime() : mozilla::TimeStamp::Now();
|
||||
mozilla::TimeDuration delta = origin - sStartTime;
|
||||
mozilla::TimeDuration delta = origin - gStartTime;
|
||||
stack->addMarker(aMarker, payload.release(), delta.ToMilliseconds());
|
||||
}
|
||||
|
||||
|
@ -2671,11 +2671,11 @@ void PseudoStack::flushSamplerOnJSShutdown()
|
|||
gIsPaused = true;
|
||||
|
||||
{
|
||||
StaticMutexAutoLock lock(sRegisteredThreadsMutex);
|
||||
StaticMutexAutoLock lock(gRegisteredThreadsMutex);
|
||||
|
||||
for (size_t i = 0; i < sRegisteredThreads->size(); i++) {
|
||||
for (size_t i = 0; i < gRegisteredThreads->size(); i++) {
|
||||
// Thread not being profiled, skip it.
|
||||
ThreadInfo* info = sRegisteredThreads->at(i);
|
||||
ThreadInfo* info = gRegisteredThreads->at(i);
|
||||
if (!info->hasProfile() || info->IsPendingDelete()) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -106,7 +106,7 @@ bool profiler_verbose();
|
|||
#define ENABLE_LEAF_DATA
|
||||
#endif
|
||||
|
||||
extern mozilla::TimeStamp sStartTime;
|
||||
extern mozilla::TimeStamp gStartTime;
|
||||
|
||||
typedef uint8_t* Address;
|
||||
|
||||
|
|
|
@ -19,6 +19,6 @@ void
|
|||
logging_sink_for_LUL(const char* str);
|
||||
|
||||
// A singleton instance of the library.
|
||||
extern lul::LUL* sLUL;
|
||||
extern lul::LUL* gLUL;
|
||||
|
||||
#endif /* ndef MOZ_PLATFORM_LINUX_LUL_H */
|
||||
|
|
Загрузка…
Ссылка в новой задаче