зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1340928 (part 5) - Pass the interval to PlatformStart(). r=mstange.
This avoids the need for platform-linux-android.cpp to read gInterval off the main thread in an awkward spot. It also makes platform-linux-android.cpp more like platform-{win32,macos}.cpp. --HG-- extra : rebase_source : c1c76a382d6373f9fd2e3f89a1e1f8fef9072257
This commit is contained in:
Родитель
598cac65d4
Коммит
8c6f56c330
|
@ -145,6 +145,8 @@ static void* setup_atfork() {
|
|||
}
|
||||
#endif /* !defined(GP_OS_android) */
|
||||
|
||||
static int gIntervalMicro;
|
||||
|
||||
// Global variables through which data is sent from SigprofSender() to
|
||||
// SigprofHandler(). gSignalHandlingDone provides inter-thread synchronization.
|
||||
static ThreadInfo* gCurrentThreadInfo;
|
||||
|
@ -342,11 +344,8 @@ SigprofSender(void* aArg)
|
|||
#endif
|
||||
}
|
||||
|
||||
// This off-main-thread use of gInterval is safe due to implicit
|
||||
// synchronization -- this function cannot run at the same time as
|
||||
// profiler_{start,stop}(), where gInterval is set.
|
||||
TimeStamp targetSleepEndTime =
|
||||
sampleStart + TimeDuration::FromMicroseconds(gInterval * 1000);
|
||||
sampleStart + TimeDuration::FromMicroseconds(gIntervalMicro);
|
||||
TimeStamp beforeSleep = TimeStamp::Now();
|
||||
TimeDuration targetSleepDuration = targetSleepEndTime - beforeSleep;
|
||||
double sleepTime = std::max(0.0, (targetSleepDuration - lastSleepOverhead).ToMicroseconds());
|
||||
|
@ -358,7 +357,7 @@ SigprofSender(void* aArg)
|
|||
}
|
||||
|
||||
static void
|
||||
PlatformStart()
|
||||
PlatformStart(double aInterval)
|
||||
{
|
||||
MOZ_RELEASE_ASSERT(NS_IsMainThread());
|
||||
|
||||
|
@ -372,6 +371,11 @@ PlatformStart()
|
|||
}
|
||||
#endif
|
||||
|
||||
gIntervalMicro = floor(aInterval * 1000 + 0.5);
|
||||
if (gIntervalMicro <= 0) {
|
||||
gIntervalMicro = 1;
|
||||
}
|
||||
|
||||
// Initialize signal handler communication
|
||||
gCurrentThreadInfo = nullptr;
|
||||
gRssMemory = 0;
|
||||
|
@ -426,6 +430,8 @@ PlatformStop()
|
|||
MOZ_ASSERT(gIsActive);
|
||||
gIsActive = false;
|
||||
|
||||
gIntervalMicro = 0;
|
||||
|
||||
// Wait for signal sender termination (it will exit after setting
|
||||
// active_ to false).
|
||||
if (gHasSigprofSenderLaunched) {
|
||||
|
|
|
@ -80,8 +80,8 @@ PlatformDataDestructor::operator()(PlatformData* aData)
|
|||
class SamplerThread
|
||||
{
|
||||
public:
|
||||
explicit SamplerThread(double interval)
|
||||
: mIntervalMicro(floor(interval * 1000 + 0.5))
|
||||
explicit SamplerThread(double aInterval)
|
||||
: mIntervalMicro(floor(aInterval * 1000 + 0.5))
|
||||
{
|
||||
if (mIntervalMicro <= 0) {
|
||||
mIntervalMicro = 1;
|
||||
|
@ -120,12 +120,12 @@ public:
|
|||
pthread_join(mThread, NULL);
|
||||
}
|
||||
|
||||
static void StartSampler() {
|
||||
static void StartSampler(double aInterval) {
|
||||
MOZ_RELEASE_ASSERT(NS_IsMainThread());
|
||||
MOZ_RELEASE_ASSERT(!mInstance);
|
||||
|
||||
if (mInstance == NULL) {
|
||||
mInstance = new SamplerThread(gInterval);
|
||||
mInstance = new SamplerThread(aInterval);
|
||||
mInstance->Start();
|
||||
}
|
||||
}
|
||||
|
@ -261,13 +261,13 @@ PlatformInit()
|
|||
}
|
||||
|
||||
static void
|
||||
PlatformStart()
|
||||
PlatformStart(double aInterval)
|
||||
{
|
||||
MOZ_RELEASE_ASSERT(NS_IsMainThread());
|
||||
|
||||
MOZ_ASSERT(!gIsActive);
|
||||
gIsActive = true;
|
||||
SamplerThread::StartSampler();
|
||||
SamplerThread::StartSampler(aInterval);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -87,11 +87,10 @@ static const HANDLE kNoThread = INVALID_HANDLE_VALUE;
|
|||
class SamplerThread
|
||||
{
|
||||
public:
|
||||
explicit SamplerThread(double interval)
|
||||
explicit SamplerThread(double aInterval)
|
||||
: mThread(kNoThread)
|
||||
, mInterval(interval)
|
||||
, mInterval(floor(aInterval + 0.5))
|
||||
{
|
||||
mInterval = floor(interval + 0.5);
|
||||
if (mInterval <= 0) {
|
||||
mInterval = 1;
|
||||
}
|
||||
|
@ -129,11 +128,11 @@ class SamplerThread
|
|||
}
|
||||
}
|
||||
|
||||
static void StartSampler() {
|
||||
static void StartSampler(double aInterval) {
|
||||
MOZ_RELEASE_ASSERT(NS_IsMainThread());
|
||||
MOZ_RELEASE_ASSERT(!mInstance);
|
||||
|
||||
mInstance = new SamplerThread(gInterval);
|
||||
mInstance = new SamplerThread(aInterval);
|
||||
mInstance->Start();
|
||||
}
|
||||
|
||||
|
@ -273,13 +272,13 @@ PlatformInit()
|
|||
}
|
||||
|
||||
static void
|
||||
PlatformStart()
|
||||
PlatformStart(double aInterval)
|
||||
{
|
||||
MOZ_RELEASE_ASSERT(NS_IsMainThread());
|
||||
|
||||
MOZ_ASSERT(!gIsActive);
|
||||
gIsActive = true;
|
||||
SamplerThread::StartSampler();
|
||||
SamplerThread::StartSampler(aInterval);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -122,11 +122,7 @@ static Vector<std::string> gFeatures;
|
|||
// All accesses to gEntrySize are on the main thread, so no locking is needed.
|
||||
static int gEntrySize = 0;
|
||||
|
||||
// This variable is set on the main thread in profiler_{start,stop}(), and
|
||||
// mostly read on the main thread. There is one read off the main thread in
|
||||
// SigprofSender() in platform-linux.cc which is safe because there is implicit
|
||||
// synchronization between that function and the set points in
|
||||
// profiler_{start,stop}().
|
||||
// All accesses to gInterval are on the main thread, so no locking is needed.
|
||||
static double gInterval = 0;
|
||||
|
||||
// XXX: These two variables are used extensively both on and off the main
|
||||
|
@ -1591,7 +1587,7 @@ RegisterCurrentThread(const char* aName, PseudoStack* aPseudoStack,
|
|||
|
||||
// Platform-specific init/start/stop actions.
|
||||
static void PlatformInit();
|
||||
static void PlatformStart();
|
||||
static void PlatformStart(double aInterval);
|
||||
static void PlatformStop();
|
||||
|
||||
void
|
||||
|
@ -2032,7 +2028,7 @@ profiler_start(int aProfileEntries, double aInterval,
|
|||
gGatherer = new mozilla::ProfileGatherer();
|
||||
|
||||
MOZ_ASSERT(!gIsActive && !gIsPaused);
|
||||
PlatformStart();
|
||||
PlatformStart(gInterval);
|
||||
MOZ_ASSERT(gIsActive && !gIsPaused); // PlatformStart() sets gIsActive.
|
||||
|
||||
if (gProfileJS || privacyMode) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче