mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 19:04:45 +00:00
Back out 090ebbb90a7f (bug 873914) for Android build bustage
CLOSED TREE
This commit is contained in:
parent
a8c66f4e83
commit
0549f69793
@ -95,8 +95,7 @@ static inline void profiler_shutdown() {};
|
||||
// best to sample at this interval. The profiler visualization
|
||||
// should represent the actual sampling accuracy.
|
||||
static inline void profiler_start(int aProfileEntries, int aInterval,
|
||||
const char** aFeatures, uint32_t aFeatureCount,
|
||||
const char** aThreadNameFilters, uint32_t aFilterCount) {}
|
||||
const char** aFeatures, uint32_t aFeatureCount) {}
|
||||
|
||||
// Stop the profiler and discard the profile. Call 'profiler_save' before this
|
||||
// to retrieve the profile.
|
||||
|
@ -21,9 +21,8 @@ inline void* mozilla_sampler_call_enter(const char *aInfo, void *aFrameAddress =
|
||||
inline void mozilla_sampler_call_exit(void* handle);
|
||||
inline void mozilla_sampler_add_marker(const char *aInfo);
|
||||
|
||||
void mozilla_sampler_start(int aEntries, int aInterval,
|
||||
const char** aFeatures, uint32_t aFeatureCount,
|
||||
const char** aThreadNameFilters, uint32_t aFilterCount);
|
||||
void mozilla_sampler_start(int aEntries, int aInterval, const char** aFeatures,
|
||||
uint32_t aFeatureCount);
|
||||
|
||||
void mozilla_sampler_stop();
|
||||
|
||||
|
@ -65,10 +65,9 @@ void profiler_shutdown()
|
||||
|
||||
static inline
|
||||
void profiler_start(int aProfileEntries, int aInterval,
|
||||
const char** aFeatures, uint32_t aFeatureCount,
|
||||
const char** aThreadNameFilters, uint32_t aFilterCount)
|
||||
const char** aFeatures, uint32_t aFeatureCount)
|
||||
{
|
||||
mozilla_sampler_start(aProfileEntries, aInterval, aFeatures, aFeatureCount, aThreadNameFilters, aFilterCount);
|
||||
mozilla_sampler_start(aProfileEntries, aInterval, aFeatures, aFeatureCount);
|
||||
}
|
||||
|
||||
static inline
|
||||
|
@ -16,22 +16,6 @@ hasFeature(const char** aFeatures, uint32_t aFeatureCount, const char* aFeature)
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool
|
||||
threadSelected(ThreadInfo* aInfo, char** aThreadNameFilters, uint32_t aFeatureCount) {
|
||||
if (aFeatureCount == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < aFeatureCount; ++i) {
|
||||
const char* filterPrefix = aThreadNameFilters[i];
|
||||
if (strncmp(aInfo->Name(), filterPrefix, strlen(filterPrefix)) == 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
extern TimeStamp sLastTracerEvent;
|
||||
extern int sFrameNumber;
|
||||
extern int sLastFrameNumber;
|
||||
@ -43,13 +27,11 @@ class BreakpadSampler;
|
||||
class TableTicker: public Sampler {
|
||||
public:
|
||||
TableTicker(int aInterval, int aEntrySize,
|
||||
const char** aFeatures, uint32_t aFeatureCount,
|
||||
const char** aThreadNameFilters, uint32_t aFilterCount)
|
||||
const char** aFeatures, uint32_t aFeatureCount)
|
||||
: Sampler(aInterval, true, aEntrySize)
|
||||
, mPrimaryThreadProfile(nullptr)
|
||||
, mSaveRequested(false)
|
||||
, mUnwinderThread(false)
|
||||
, mFilterCount(aFilterCount)
|
||||
{
|
||||
mUseStackWalk = hasFeature(aFeatures, aFeatureCount, "stackwalk");
|
||||
|
||||
@ -63,12 +45,6 @@ class TableTicker: public Sampler {
|
||||
mPrivacyMode = hasFeature(aFeatures, aFeatureCount, "privacy");
|
||||
mAddMainThreadIO = hasFeature(aFeatures, aFeatureCount, "mainthreadio");
|
||||
|
||||
// Deep copy aThreadNameFilters
|
||||
mThreadNameFilters = new char*[aFilterCount];
|
||||
for (uint32_t i = 0; i < aFilterCount; ++i) {
|
||||
mThreadNameFilters[i] = strdup(aThreadNameFilters[i]);
|
||||
}
|
||||
|
||||
sStartTime = TimeStamp::Now();
|
||||
|
||||
{
|
||||
@ -78,7 +54,18 @@ class TableTicker: public Sampler {
|
||||
for (uint32_t i = 0; i < sRegisteredThreads->size(); i++) {
|
||||
ThreadInfo* info = sRegisteredThreads->at(i);
|
||||
|
||||
RegisterThread(info);
|
||||
if (!info->IsMainThread() && !mProfileThreads)
|
||||
continue;
|
||||
|
||||
ThreadProfile* profile = new ThreadProfile(info->Name(),
|
||||
aEntrySize,
|
||||
info->Stack(),
|
||||
info->ThreadId(),
|
||||
info->GetPlatformData(),
|
||||
info->IsMainThread());
|
||||
profile->addTag(ProfileEntry('m', "Start"));
|
||||
|
||||
info->SetProfile(profile);
|
||||
}
|
||||
|
||||
SetActiveSampler(this);
|
||||
@ -106,26 +93,6 @@ class TableTicker: public Sampler {
|
||||
}
|
||||
}
|
||||
|
||||
void RegisterThread(ThreadInfo* aInfo) {
|
||||
if (!aInfo->IsMainThread() && !mProfileThreads) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!threadSelected(aInfo, mThreadNameFilters, mFilterCount)) {
|
||||
return;
|
||||
}
|
||||
|
||||
ThreadProfile* profile = new ThreadProfile(aInfo->Name(),
|
||||
EntrySize(),
|
||||
aInfo->Stack(),
|
||||
aInfo->ThreadId(),
|
||||
aInfo->GetPlatformData(),
|
||||
aInfo->IsMainThread());
|
||||
profile->addTag(ProfileEntry('m', "Start"));
|
||||
|
||||
aInfo->SetProfile(profile);
|
||||
}
|
||||
|
||||
// Called within a signal. This function must be reentrant
|
||||
virtual void Tick(TickSample* sample);
|
||||
|
||||
@ -187,11 +154,6 @@ protected:
|
||||
bool mProfileThreads;
|
||||
bool mUnwinderThread;
|
||||
bool mProfileJava;
|
||||
|
||||
// Keep the thread filter to check against new thread that
|
||||
// are started while profiling
|
||||
char** mThreadNameFilters;
|
||||
uint32_t mFilterCount;
|
||||
bool mPrivacyMode;
|
||||
bool mAddMainThreadIO;
|
||||
};
|
||||
|
@ -5,14 +5,12 @@
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
[scriptable, uuid(eb77a9b0-285f-472c-93b0-04db5e9e3e7e)]
|
||||
[scriptable, uuid(c94651cf-082f-45e2-9481-33a1a700b46a)]
|
||||
interface nsIProfiler : nsISupports
|
||||
{
|
||||
void StartProfiler(in uint32_t aEntries, in uint32_t aInterval,
|
||||
[array, size_is(aFeatureCount)] in string aFeatures,
|
||||
in uint32_t aFeatureCount,
|
||||
[array, size_is(aFilterCount), optional] in string aThreadNameFilters,
|
||||
[optional] in uint32_t aFilterCount);
|
||||
in uint32_t aFeatureCount);
|
||||
void StopProfiler();
|
||||
void AddMarker(in string aMarker);
|
||||
string GetProfile();
|
||||
|
@ -71,16 +71,13 @@ nsProfiler::Observe(nsISupports *aSubject,
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsProfiler::StartProfiler(uint32_t aEntries, uint32_t aInterval,
|
||||
const char** aFeatures, uint32_t aFeatureCount,
|
||||
const char** aThreadNameFilters, uint32_t aFilterCount)
|
||||
const char** aFeatures, uint32_t aFeatureCount)
|
||||
{
|
||||
if (mLockedForPrivateBrowsing) {
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
profiler_start(aEntries, aInterval,
|
||||
aFeatures, aFeatureCount,
|
||||
aThreadNameFilters, aFilterCount);
|
||||
profiler_start(aEntries, aInterval, aFeatures, aFeatureCount);
|
||||
#ifdef MOZ_INSTRUMENT_EVENT_LOOP
|
||||
bool printToConsole = false;
|
||||
mozilla::InitEventTracing(printToConsole);
|
||||
|
@ -371,8 +371,20 @@ bool Sampler::RegisterCurrentThread(const char* aName,
|
||||
ThreadInfo* info = new ThreadInfo(aName, gettid(),
|
||||
aIsMainThread, aPseudoStack);
|
||||
|
||||
if (sActiveSampler) {
|
||||
sActiveSampler->RegisterThread(info);
|
||||
bool profileThread = sActiveSampler &&
|
||||
(aIsMainThread || sActiveSampler->ProfileThreads());
|
||||
|
||||
if (profileThread) {
|
||||
// We need to create the ThreadProfile now
|
||||
info->SetProfile(new ThreadProfile(info->Name(),
|
||||
sActiveSampler->EntrySize(),
|
||||
info->Stack(),
|
||||
info->ThreadId(),
|
||||
info->GetPlatformData(),
|
||||
aIsMainThread));
|
||||
if (sActiveSampler->ProfileJS()) {
|
||||
info->Profile()->GetPseudoStack()->enableJSSampling();
|
||||
}
|
||||
}
|
||||
|
||||
sRegisteredThreads->push_back(info);
|
||||
@ -408,8 +420,7 @@ const int SIGSTART = SIGUSR1;
|
||||
|
||||
static void StartSignalHandler(int signal, siginfo_t* info, void* context) {
|
||||
profiler_start(PROFILE_DEFAULT_ENTRY, PROFILE_DEFAULT_INTERVAL,
|
||||
PROFILE_DEFAULT_FEATURES, PROFILE_DEFAULT_FEATURE_COUNT,
|
||||
NULL, 0);
|
||||
PROFILE_DEFAULT_FEATURES, PROFILE_DEFAULT_FEATURE_COUNT);
|
||||
}
|
||||
|
||||
void OS::RegisterStartHandler()
|
||||
|
@ -353,8 +353,20 @@ bool Sampler::RegisterCurrentThread(const char* aName,
|
||||
ThreadInfo* info = new ThreadInfo(aName, gettid(),
|
||||
aIsMainThread, aPseudoStack);
|
||||
|
||||
if (sActiveSampler) {
|
||||
sActiveSampler->RegisterThread(info);
|
||||
bool profileThread = sActiveSampler &&
|
||||
(aIsMainThread || sActiveSampler->ProfileThreads());
|
||||
|
||||
if (profileThread) {
|
||||
// We need to create the ThreadProfile now
|
||||
info->SetProfile(new ThreadProfile(info->Name(),
|
||||
sActiveSampler->EntrySize(),
|
||||
info->Stack(),
|
||||
info->ThreadId(),
|
||||
info->GetPlatformData(),
|
||||
aIsMainThread));
|
||||
if (sActiveSampler->ProfileJS()) {
|
||||
info->Profile()->GetPseudoStack()->enableJSSampling();
|
||||
}
|
||||
}
|
||||
|
||||
sRegisteredThreads->push_back(info);
|
||||
|
@ -274,8 +274,20 @@ bool Sampler::RegisterCurrentThread(const char* aName,
|
||||
ThreadInfo* info = new ThreadInfo(aName, GetCurrentThreadId(),
|
||||
aIsMainThread, aPseudoStack);
|
||||
|
||||
if (sActiveSampler) {
|
||||
sActiveSampler->RegisterThread(info);
|
||||
bool profileThread = sActiveSampler &&
|
||||
(aIsMainThread || sActiveSampler->ProfileThreads());
|
||||
|
||||
if (profileThread) {
|
||||
// We need to create the ThreadProfile now
|
||||
info->SetProfile(new ThreadProfile(info->Name(),
|
||||
sActiveSampler->EntrySize(),
|
||||
info->Stack(),
|
||||
GetCurrentThreadId(),
|
||||
info->GetPlatformData(),
|
||||
aIsMainThread));
|
||||
if (sActiveSampler->ProfileJS()) {
|
||||
info->Profile()->GetPseudoStack()->enableJSSampling();
|
||||
}
|
||||
}
|
||||
|
||||
sRegisteredThreads->push_back(info);
|
||||
|
@ -303,9 +303,7 @@ void mozilla_sampler_init(void* stackTop)
|
||||
#endif
|
||||
};
|
||||
profiler_start(PROFILE_DEFAULT_ENTRY, PROFILE_DEFAULT_INTERVAL,
|
||||
features, sizeof(features)/sizeof(const char*),
|
||||
// TODO Add env variable to select threads
|
||||
NULL, 0);
|
||||
features, sizeof(features)/sizeof(const char*));
|
||||
LOG("END mozilla_sampler_init");
|
||||
}
|
||||
|
||||
@ -416,9 +414,7 @@ const char** mozilla_sampler_get_features()
|
||||
|
||||
// Values are only honored on the first start
|
||||
void mozilla_sampler_start(int aProfileEntries, int aInterval,
|
||||
const char** aFeatures, uint32_t aFeatureCount,
|
||||
const char** aThreadNameFilters, uint32_t aFilterCount)
|
||||
|
||||
const char** aFeatures, uint32_t aFeatureCount)
|
||||
{
|
||||
if (!stack_key_initialized)
|
||||
profiler_init(NULL);
|
||||
@ -434,8 +430,7 @@ void mozilla_sampler_start(int aProfileEntries, int aInterval,
|
||||
TableTicker* t;
|
||||
t = new TableTicker(aInterval ? aInterval : PROFILE_DEFAULT_INTERVAL,
|
||||
aProfileEntries ? aProfileEntries : PROFILE_DEFAULT_ENTRY,
|
||||
aFeatures, aFeatureCount,
|
||||
aThreadNameFilters, aFilterCount);
|
||||
aFeatures, aFeatureCount);
|
||||
if (t->HasUnwinderThread()) {
|
||||
// Create the unwinder thread. ATM there is only one.
|
||||
uwt__init();
|
||||
|
Loading…
Reference in New Issue
Block a user