forked from mirrors/gecko-dev
Bug 1328916 - Remove ProfilerSaveSignalHandler and transitively reachable code. r=mstange.
--HG-- extra : rebase_source : c4b95dcf205d4df81e22d4b08947d55ab4fac8ca
This commit is contained in:
parent
d427770671
commit
62b845c331
6 changed files with 30 additions and 141 deletions
|
|
@ -9,7 +9,7 @@
|
|||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include "GeckoProfiler.h"
|
||||
#include "SaveProfileTask.h"
|
||||
#include "nsIProfileSaveEvent.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "prenv.h"
|
||||
#include "prtime.h"
|
||||
|
|
@ -97,6 +97,35 @@ using namespace mozilla;
|
|||
#endif
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
// BEGIN ProfileSaveEvent
|
||||
|
||||
class ProfileSaveEvent final : public nsIProfileSaveEvent {
|
||||
public:
|
||||
typedef void (*AddSubProfileFunc)(const char* aProfile, void* aClosure);
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
ProfileSaveEvent(AddSubProfileFunc aFunc, void* aClosure)
|
||||
: mFunc(aFunc)
|
||||
, mClosure(aClosure)
|
||||
{}
|
||||
|
||||
NS_IMETHOD AddSubProfile(const char* aProfile) override {
|
||||
mFunc(aProfile, mClosure);
|
||||
return NS_OK;
|
||||
}
|
||||
private:
|
||||
~ProfileSaveEvent() {}
|
||||
|
||||
AddSubProfileFunc mFunc;
|
||||
void* mClosure;
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS(ProfileSaveEvent, nsIProfileSaveEvent)
|
||||
|
||||
// END ProfileSaveEvent
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
// BEGIN SaveProfileTask et al
|
||||
|
||||
|
|
@ -176,7 +205,6 @@ Sampler::Sampler(double aInterval, int aEntrySize,
|
|||
, active_(false)
|
||||
, entrySize_(aEntrySize)
|
||||
, mBuffer(new ProfileBuffer(aEntrySize))
|
||||
, mSaveRequested(false)
|
||||
{
|
||||
MOZ_COUNT_CTOR(Sampler);
|
||||
|
||||
|
|
@ -376,19 +404,6 @@ Sampler::UnregisterCurrentThread()
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
Sampler::HandleSaveRequest()
|
||||
{
|
||||
if (!mSaveRequested)
|
||||
return;
|
||||
mSaveRequested = false;
|
||||
|
||||
// TODO: Use use the ipc/chromium Tasks here to support processes
|
||||
// without XPCOM.
|
||||
nsCOMPtr<nsIRunnable> runnable = new SaveProfileTask();
|
||||
NS_DispatchToMainThread(runnable);
|
||||
}
|
||||
|
||||
void
|
||||
Sampler::DeleteExpiredMarkers()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -92,8 +92,6 @@
|
|||
#include <string.h>
|
||||
#include <list>
|
||||
|
||||
#define SIGNAL_SAVE_PROFILE SIGUSR2
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
#if defined(USE_LUL_STACKWALK)
|
||||
|
|
@ -179,11 +177,6 @@ Sampler *SamplerRegistry::sampler = NULL;
|
|||
static mozilla::Atomic<ThreadInfo*> sCurrentThreadInfo;
|
||||
static sem_t sSignalHandlingDone;
|
||||
|
||||
static void ProfilerSaveSignalHandler(int signal, siginfo_t* info, void* context) {
|
||||
// XXX: this is an off-main-thread(?) use of gSampler
|
||||
gSampler->RequestSave();
|
||||
}
|
||||
|
||||
static void SetSampleContext(TickSample* sample, void* context)
|
||||
{
|
||||
// Extracting the sample from the context is extremely machine dependent.
|
||||
|
|
@ -313,7 +306,6 @@ static void* SignalSender(void* arg) {
|
|||
TimeStamp sampleStart = TimeStamp::Now();
|
||||
while (SamplerRegistry::sampler->IsActive()) {
|
||||
|
||||
SamplerRegistry::sampler->HandleSaveRequest();
|
||||
SamplerRegistry::sampler->DeleteExpiredMarkers();
|
||||
|
||||
if (!SamplerRegistry::sampler->IsPaused()) {
|
||||
|
|
@ -422,16 +414,6 @@ void Sampler::Start() {
|
|||
LOG("Error installing signal");
|
||||
return;
|
||||
}
|
||||
|
||||
// Request save profile signals
|
||||
struct sigaction sa2;
|
||||
sa2.sa_sigaction = ProfilerSaveSignalHandler;
|
||||
sigemptyset(&sa2.sa_mask);
|
||||
sa2.sa_flags = SA_RESTART | SA_SIGINFO;
|
||||
if (sigaction(SIGNAL_SAVE_PROFILE, &sa2, &old_sigsave_signal_handler_) != 0) {
|
||||
LOG("Error installing start signal");
|
||||
return;
|
||||
}
|
||||
LOG("Signal installed");
|
||||
signal_handler_installed_ = true;
|
||||
|
||||
|
|
@ -474,7 +456,6 @@ void Sampler::Stop() {
|
|||
|
||||
// Restore old signal handler
|
||||
if (signal_handler_installed_) {
|
||||
sigaction(SIGNAL_SAVE_PROFILE, &old_sigsave_signal_handler_, 0);
|
||||
sigaction(SIGPROF, &old_sigprof_signal_handler_, 0);
|
||||
signal_handler_installed_ = false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -262,12 +262,6 @@ public:
|
|||
// Immediately captures the calling thread's call stack and returns it.
|
||||
SyncProfile* GetBacktrace();
|
||||
|
||||
// Request a save from a signal handler. This function must be re-entrant.
|
||||
void RequestSave() { mSaveRequested = true; }
|
||||
|
||||
// Process any outstanding request outside a signal handler.
|
||||
void HandleSaveRequest();
|
||||
|
||||
// Delete markers which are no longer part of the profile due to buffer
|
||||
// wraparound.
|
||||
void DeleteExpiredMarkers();
|
||||
|
|
@ -388,7 +382,6 @@ private:
|
|||
#endif
|
||||
|
||||
RefPtr<ProfileBuffer> mBuffer;
|
||||
bool mSaveRequested;
|
||||
bool mAddLeafAddresses;
|
||||
bool mUseStackWalk;
|
||||
bool mProfileJS;
|
||||
|
|
|
|||
|
|
@ -1,45 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "SaveProfileTask.h"
|
||||
#include "GeckoProfiler.h"
|
||||
|
||||
nsresult
|
||||
SaveProfileTask::Run() {
|
||||
// Get file path
|
||||
#if defined(SPS_PLAT_arm_android) && !defined(MOZ_WIDGET_GONK)
|
||||
nsCString tmpPath;
|
||||
tmpPath.AppendPrintf("/sdcard/profile_%i_%i.txt", XRE_GetProcessType(), getpid());
|
||||
#else
|
||||
nsCOMPtr<nsIFile> tmpFile;
|
||||
nsAutoCString tmpPath;
|
||||
if (NS_FAILED(NS_GetSpecialDirectory(NS_OS_TEMP_DIR, getter_AddRefs(tmpFile)))) {
|
||||
LOG("Failed to find temporary directory.");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
tmpPath.AppendPrintf("profile_%i_%i.txt", XRE_GetProcessType(), getpid());
|
||||
|
||||
nsresult rv = tmpFile->AppendNative(tmpPath);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
rv = tmpFile->GetNativePath(tmpPath);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
#endif
|
||||
|
||||
profiler_save_profile_to_file(tmpPath.get());
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS(ProfileSaveEvent, nsIProfileSaveEvent)
|
||||
|
||||
nsresult
|
||||
ProfileSaveEvent::AddSubProfile(const char* aProfile) {
|
||||
mFunc(aProfile, mClosure);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
@ -1,54 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef PROFILER_SAVETASK_H_
|
||||
#define PROFILER_SAVETASK_H_
|
||||
|
||||
#include "platform.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsIXULRuntime.h"
|
||||
#include "nsDirectoryServiceUtils.h"
|
||||
#include "nsDirectoryServiceDefs.h"
|
||||
#include "nsXULAppAPI.h"
|
||||
#include "nsIProfileSaveEvent.h"
|
||||
|
||||
#ifdef XP_WIN
|
||||
#include <windows.h>
|
||||
#define getpid GetCurrentProcessId
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
/**
|
||||
* This is an event used to save the profile on the main thread
|
||||
* to be sure that it is not being modified while saving.
|
||||
*/
|
||||
class SaveProfileTask : public mozilla::Runnable {
|
||||
public:
|
||||
SaveProfileTask() {}
|
||||
|
||||
NS_IMETHOD Run();
|
||||
};
|
||||
|
||||
class ProfileSaveEvent final : public nsIProfileSaveEvent {
|
||||
public:
|
||||
typedef void (*AddSubProfileFunc)(const char* aProfile, void* aClosure);
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
ProfileSaveEvent(AddSubProfileFunc aFunc, void* aClosure)
|
||||
: mFunc(aFunc)
|
||||
, mClosure(aClosure)
|
||||
{}
|
||||
|
||||
NS_IMETHOD AddSubProfile(const char* aProfile) override;
|
||||
private:
|
||||
~ProfileSaveEvent() {}
|
||||
|
||||
AddSubProfileFunc mFunc;
|
||||
void* mClosure;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -37,7 +37,6 @@ if CONFIG['MOZ_GECKO_PROFILER']:
|
|||
'gecko/nsProfilerFactory.cpp',
|
||||
'gecko/nsProfilerStartParams.cpp',
|
||||
'gecko/ProfilerIOInterposeObserver.cpp',
|
||||
'gecko/SaveProfileTask.cpp',
|
||||
'gecko/ThreadResponsiveness.cpp',
|
||||
]
|
||||
if CONFIG['OS_TARGET'] == 'Darwin':
|
||||
|
|
|
|||
Loading…
Reference in a new issue