mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-19 15:51:33 +00:00
Backed out changeset 79af4e3b4d71 (bug 1347274)
This commit is contained in:
parent
41c89444e7
commit
928e14c9f8
@ -111,9 +111,6 @@ typedef const PSAutoLock& PSLockRef;
|
||||
#define PS_GET(type_, name_) \
|
||||
static type_ name_(PSLockRef) { return sInstance->m##name_; } \
|
||||
|
||||
#define PS_GET_LOCKLESS(type_, name_) \
|
||||
static type_ name_() { return sInstance->m##name_; } \
|
||||
|
||||
#define PS_GET_AND_SET(type_, name_) \
|
||||
PS_GET(type_, name_) \
|
||||
static void Set##name_(PSLockRef, type_ a##name_) \
|
||||
@ -124,19 +121,15 @@ typedef const PSAutoLock& PSLockRef;
|
||||
// anything useful when this class is not instantiated, so we release-assert
|
||||
// its non-nullness in all such operations.
|
||||
//
|
||||
// Accesses to CorePS are guarded by gPSMutex. Getters and setters take a
|
||||
// Accesses to CorePS are guarded by gPSMutex. Every getter and setter takes a
|
||||
// PSAutoLock reference as an argument as proof that the gPSMutex is currently
|
||||
// locked. This makes it clear when gPSMutex is locked and helps avoid
|
||||
// accidental unlocked accesses to global state. There are ways to circumvent
|
||||
// this mechanism, but please don't do so without *very* good reason and a
|
||||
// detailed explanation.
|
||||
//
|
||||
// The exceptions to this rule:
|
||||
//
|
||||
// - mProcessStartTime, because it's immutable;
|
||||
//
|
||||
// - each thread's RacyThreadInfo object is accessible without locking via
|
||||
// TLSInfo::RacyThreadInfo().
|
||||
// The exception to this rule is each thread's RacyThreadInfo object, which is
|
||||
// accessible without locking via TLSInfo::RacyThreadInfo().
|
||||
//
|
||||
class CorePS
|
||||
{
|
||||
@ -210,8 +203,7 @@ public:
|
||||
#endif
|
||||
}
|
||||
|
||||
// No PSLockRef is needed for this field because it's immutable.
|
||||
PS_GET_LOCKLESS(TimeStamp, ProcessStartTime)
|
||||
PS_GET(TimeStamp, ProcessStartTime)
|
||||
|
||||
PS_GET(ThreadVector&, LiveThreads)
|
||||
PS_GET(ThreadVector&, DeadThreads)
|
||||
@ -473,7 +465,6 @@ ActivePS* ActivePS::sInstance = nullptr;
|
||||
uint32_t ActivePS::sNextGeneration = 0;
|
||||
|
||||
#undef PS_GET
|
||||
#undef PS_GET_LOCKLESS
|
||||
#undef PS_GET_AND_SET
|
||||
|
||||
// The mutex that guards accesses to CorePS and ActivePS.
|
||||
@ -1284,7 +1275,7 @@ Tick(PSLockRef aLock, ProfileBuffer* aBuffer, const TickSample& aSample)
|
||||
aBuffer->addTagThreadId(aSample.mThreadId, aSample.mLastSample);
|
||||
|
||||
mozilla::TimeDuration delta =
|
||||
aSample.mTimeStamp - CorePS::ProcessStartTime();
|
||||
aSample.mTimeStamp - CorePS::ProcessStartTime(aLock);
|
||||
aBuffer->addTag(ProfileBufferEntry::Time(delta.ToMilliseconds()));
|
||||
|
||||
#if defined(HAVE_NATIVE_UNWIND)
|
||||
@ -1394,7 +1385,7 @@ StreamTaskTracer(PSLockRef aLock, SpliceableJSONWriter& aWriter)
|
||||
aWriter.StartArrayProperty("data");
|
||||
{
|
||||
UniquePtr<nsTArray<nsCString>> data =
|
||||
mozilla::tasktracer::GetLoggedData(CorePS::ProcessStartTime());
|
||||
mozilla::tasktracer::GetLoggedData(CorePS::ProcessStartTime(aLock));
|
||||
for (uint32_t i = 0; i < data->Length(); ++i) {
|
||||
aWriter.StringElement((data->ElementAt(i)).get());
|
||||
}
|
||||
@ -1447,7 +1438,7 @@ StreamMetaJSCustomObject(PSLockRef aLock, SpliceableJSONWriter& aWriter)
|
||||
// January 1, 1970 GMT. This grotty code computes (Now - (Now -
|
||||
// ProcessStartTime)) to convert CorePS::ProcessStartTime() into that form.
|
||||
mozilla::TimeDuration delta =
|
||||
mozilla::TimeStamp::Now() - CorePS::ProcessStartTime();
|
||||
mozilla::TimeStamp::Now() - CorePS::ProcessStartTime(aLock);
|
||||
aWriter.DoubleProperty(
|
||||
"startTime", static_cast<double>(PR_Now()/1000.0 - delta.ToMilliseconds()));
|
||||
|
||||
@ -1594,7 +1585,7 @@ locked_profiler_stream_json_for_this_process(PSLockRef aLock,
|
||||
continue;
|
||||
}
|
||||
info->StreamJSON(ActivePS::Buffer(aLock), aWriter,
|
||||
CorePS::ProcessStartTime(), aSinceTime);
|
||||
CorePS::ProcessStartTime(aLock), aSinceTime);
|
||||
}
|
||||
|
||||
const CorePS::ThreadVector& deadThreads = CorePS::DeadThreads(aLock);
|
||||
@ -1602,7 +1593,7 @@ locked_profiler_stream_json_for_this_process(PSLockRef aLock,
|
||||
ThreadInfo* info = deadThreads.at(i);
|
||||
MOZ_ASSERT(info->IsBeingProfiled());
|
||||
info->StreamJSON(ActivePS::Buffer(aLock), aWriter,
|
||||
CorePS::ProcessStartTime(), aSinceTime);
|
||||
CorePS::ProcessStartTime(aLock), aSinceTime);
|
||||
}
|
||||
|
||||
#if defined(GP_OS_android)
|
||||
@ -1817,7 +1808,7 @@ SamplerThread::Run()
|
||||
if (info->RacyInfo()->CanDuplicateLastSampleDueToSleep()) {
|
||||
bool dup_ok =
|
||||
ActivePS::Buffer(lock)->DuplicateLastSample(
|
||||
info->ThreadId(), CorePS::ProcessStartTime(),
|
||||
info->ThreadId(), CorePS::ProcessStartTime(lock),
|
||||
info->LastSample());
|
||||
if (dup_ok) {
|
||||
continue;
|
||||
@ -2743,8 +2734,10 @@ profiler_time()
|
||||
|
||||
MOZ_RELEASE_ASSERT(CorePS::Exists());
|
||||
|
||||
PSAutoLock lock(gPSMutex);
|
||||
|
||||
mozilla::TimeDuration delta =
|
||||
mozilla::TimeStamp::Now() - CorePS::ProcessStartTime();
|
||||
mozilla::TimeStamp::Now() - CorePS::ProcessStartTime(lock);
|
||||
return delta.ToMilliseconds();
|
||||
}
|
||||
|
||||
@ -2877,7 +2870,7 @@ locked_profiler_add_marker(PSLockRef aLock, const char* aMarkerName,
|
||||
mozilla::TimeStamp origin = (payload && !payload->GetStartTime().IsNull())
|
||||
? payload->GetStartTime()
|
||||
: mozilla::TimeStamp::Now();
|
||||
mozilla::TimeDuration delta = origin - CorePS::ProcessStartTime();
|
||||
mozilla::TimeDuration delta = origin - CorePS::ProcessStartTime(aLock);
|
||||
racyInfo->AddPendingMarker(aMarkerName, payload.release(),
|
||||
delta.ToMilliseconds());
|
||||
}
|
||||
@ -2992,7 +2985,7 @@ profiler_clear_js_context()
|
||||
// Flush this thread's ThreadInfo, if it is being profiled.
|
||||
if (info->IsBeingProfiled()) {
|
||||
info->FlushSamplesAndMarkers(ActivePS::Buffer(lock),
|
||||
CorePS::ProcessStartTime());
|
||||
CorePS::ProcessStartTime(lock));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user