Bug 1358320 - Make TimeStamp::ProcessCreation()'s outparam optional. r=gsvelto.

TimeStamp::ProcessCreations()'s aIsInconsistent outparam is ignored by the
majority of its caller. This patch makes it optional. Notably, this makes
ProcessCreation() easier to use in a constructor's initializer list.
This commit is contained in:
Nicholas Nethercote 2017-04-26 14:55:54 +10:00
parent 867b4336cd
commit bc1d6a21a2
22 changed files with 36 additions and 51 deletions

View File

@ -1436,8 +1436,7 @@ WriteHeapGraph(JSContext* cx,
static unsigned long
msSinceProcessCreation(const TimeStamp& now)
{
bool ignored;
auto duration = now - TimeStamp::ProcessCreation(ignored);
auto duration = now - TimeStamp::ProcessCreation();
return (unsigned long) duration.ToMilliseconds();
}

View File

@ -3024,9 +3024,7 @@ nsDocShell::PopProfileTimelineMarkers(
nsresult
nsDocShell::Now(DOMHighResTimeStamp* aWhen)
{
bool ignore;
*aWhen =
(TimeStamp::Now() - TimeStamp::ProcessCreation(ignore)).ToMilliseconds();
*aWhen = (TimeStamp::Now() - TimeStamp::ProcessCreation()).ToMilliseconds();
return NS_OK;
}

View File

@ -65,8 +65,7 @@ AbstractTimelineMarker::SetCurrentTime()
void
AbstractTimelineMarker::SetCustomTime(const TimeStamp& aTime)
{
bool isInconsistent = false;
mTime = (aTime - TimeStamp::ProcessCreation(isInconsistent)).ToMilliseconds();
mTime = (aTime - TimeStamp::ProcessCreation()).ToMilliseconds();
}
void

View File

@ -100,8 +100,7 @@ nsImageLoadingContent::nsImageLoadingContent()
mLoadingEnabled = false;
}
bool isInconsistent;
mMostRecentRequestChange = TimeStamp::ProcessCreation(isInconsistent);
mMostRecentRequestChange = TimeStamp::ProcessCreation();
}
void

View File

@ -254,8 +254,7 @@ CrashStatsLogForwarder::UpdateStringsVector(const std::string& aString)
MOZ_ASSERT(index >= 0 && index < (int32_t)mMaxCapacity);
MOZ_ASSERT(index <= mIndex && index <= (int32_t)mBuffer.size());
bool ignored;
double tStamp = (TimeStamp::NowLoRes()-TimeStamp::ProcessCreation(ignored)).ToSecondsSigDigits();
double tStamp = (TimeStamp::NowLoRes() - TimeStamp::ProcessCreation()).ToSecondsSigDigits();
// Checking for index >= mBuffer.size(), rather than index == mBuffer.size()
// just out of paranoia, but we know index <= mBuffer.size().

View File

@ -258,8 +258,7 @@ Logger::VariantToString(const VARIANT& aVariant, nsACString& aOut, LONG aIndex)
Logger::GetElapsedTime()
{
TimeStamp ts = TimeStamp::Now();
bool inconsistent;
TimeDuration duration = ts - TimeStamp::ProcessCreation(inconsistent);
TimeDuration duration = ts - TimeStamp::ProcessCreation();
return duration.ToMicroseconds();
}

View File

@ -30,8 +30,7 @@ static double
MillisecondsSinceStartup()
{
auto now = mozilla::TimeStamp::Now();
bool ignored;
return (now - mozilla::TimeStamp::ProcessCreation(ignored)).ToMilliseconds();
return (now - mozilla::TimeStamp::ProcessCreation()).ToMilliseconds();
}
enum PromiseHandler {

View File

@ -4319,9 +4319,8 @@ static bool
TimeSinceCreation(JSContext* cx, unsigned argc, Value* vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
bool ignore;
double when = (mozilla::TimeStamp::Now()
- mozilla::TimeStamp::ProcessCreation(ignore)).ToMilliseconds();
double when = (mozilla::TimeStamp::Now() -
mozilla::TimeStamp::ProcessCreation()).ToMilliseconds();
args.rval().setNumber(when);
return true;
}

View File

@ -747,8 +747,7 @@ Statistics::formatJsonSliceDescription(unsigned i, const SliceData& slice)
char budgetDescription[200];
slice.budget.describe(budgetDescription, sizeof(budgetDescription) - 1);
int64_t pageFaults = slice.endFaults - slice.startFaults;
bool ignore;
TimeStamp originTime = TimeStamp::ProcessCreation(ignore);
TimeStamp originTime = TimeStamp::ProcessCreation();
const char* format =
"\"slice\":%d,"
@ -1029,9 +1028,8 @@ Statistics::printStats()
} else {
UniqueChars msg = formatDetailedMessage();
if (msg) {
bool ignoredInconsistency;
double secSinceStart =
(slices[0].start - TimeStamp::ProcessCreation(ignoredInconsistency)).ToSeconds();
(slices[0].start - TimeStamp::ProcessCreation()).ToSeconds();
fprintf(fp, "GC(T+%.3fs) %s\n", secSinceStart, msg.get());
}
}

View File

@ -11796,8 +11796,7 @@ GarbageCollectionEvent::toJSObject(JSContext* cx) const
if (!slicesArray)
return nullptr;
bool ignored; // Ignore inconsistencies in process creation timestamp.
TimeStamp originTime = TimeStamp::ProcessCreation(ignored);
TimeStamp originTime = TimeStamp::ProcessCreation();
size_t idx = 0;
for (auto range = collections.all(); !range.empty(); range.popFront()) {

View File

@ -206,8 +206,8 @@ DebuggerMemory::drainAllocationsLog(JSContext* cx, unsigned argc, Value* vp)
if (!DefineProperty(cx, obj, cx->names().frame, frame))
return false;
bool ignore;
double when = (entry.when - mozilla::TimeStamp::ProcessCreation(ignore)).ToMilliseconds();
double when = (entry.when -
mozilla::TimeStamp::ProcessCreation()).ToMilliseconds();
RootedValue timestampValue(cx, NumberValue(when));
if (!DefineProperty(cx, obj, cx->names().timestamp, timestampValue))
return false;

View File

@ -88,8 +88,7 @@ JS::detail::InitWithFailureDiagnostic(bool isDebugBuild)
// and crashes if that fails, i.e. because we're out of memory. To prevent
// that from happening at some later time, get it out of the way during
// startup.
bool ignored;
mozilla::TimeStamp::ProcessCreation(ignored);
mozilla::TimeStamp::ProcessCreation();
#ifdef DEBUG
CheckMessageParameterCounts();

View File

@ -3356,8 +3356,7 @@ nsXPCComponents_Utils::AllowCPOWsInAddon(const nsACString& addonIdStr,
NS_IMETHODIMP
nsXPCComponents_Utils::Now(double* aRetval)
{
bool isInconsistent = false;
TimeStamp start = TimeStamp::ProcessCreation(isInconsistent);
TimeStamp start = TimeStamp::ProcessCreation();
*aRetval = (TimeStamp::Now() - start).ToMilliseconds();
return NS_OK;
}

View File

@ -47,9 +47,11 @@ struct TimeStampInitialization
static TimeStampInitialization sInitOnce;
MFBT_API TimeStamp
TimeStamp::ProcessCreation(bool& aIsInconsistent)
TimeStamp::ProcessCreation(bool* aIsInconsistent)
{
aIsInconsistent = false;
if (aIsInconsistent) {
*aIsInconsistent = false;
}
if (sInitOnce.mProcessCreation.IsNull()) {
char* mozAppRestart = getenv("MOZ_APP_RESTART");
@ -72,7 +74,9 @@ TimeStamp::ProcessCreation(bool& aIsInconsistent)
/* If the process creation timestamp was inconsistent replace it with
* the first one instead and notify that a telemetry error was
* detected. */
aIsInconsistent = true;
if (aIsInconsistent) {
*aIsInconsistent = true;
}
ts = sInitOnce.mFirstTimeStamp;
}
}

View File

@ -474,12 +474,12 @@ public:
* the @a aIsInconsistent parameter will be set to true, the returned
* timestamp however will still be valid though inaccurate.
*
* @param aIsInconsistent Set to true if an inconsistency was detected in the
* process creation time
* @param aIsInconsistent If non-null, set to true if an inconsistency was
* detected in the process creation time
* @returns A timestamp representing the time when the process was created,
* this timestamp is always valid even when errors are reported
*/
static MFBT_API TimeStamp ProcessCreation(bool& aIsInconsistent);
static MFBT_API TimeStamp ProcessCreation(bool* aIsInconsistent = nullptr);
/**
* Records a process restart. After this call ProcessCreation() will return

View File

@ -758,7 +758,7 @@ nsAppStartup::GetStartupInfo(JSContext* aCx, JS::MutableHandle<JS::Value> aRetva
if (procTime.IsNull()) {
bool error = false;
procTime = TimeStamp::ProcessCreation(error);
procTime = TimeStamp::ProcessCreation(&error);
if (error) {
Telemetry::Accumulate(Telemetry::STARTUP_MEASUREMENT_ERRORS,

View File

@ -83,7 +83,7 @@ MsSinceProcessStart(double* aResult)
{
bool error;
*aResult = (TimeStamp::NowLoRes() -
TimeStamp::ProcessCreation(error)).ToMilliseconds();
TimeStamp::ProcessCreation(&error)).ToMilliseconds();
if (error) {
return NS_ERROR_NOT_AVAILABLE;
}

View File

@ -588,8 +588,7 @@ TelemetryEvent::RecordChildEvents(GeckoProcessType aProcessType,
// Timestamps from child processes are absolute. We fix them up here to be
// relative to the main process start time.
// This allows us to put events from all processes on the same timeline.
bool inconsistent = false;
double relativeTimestamp = (e.timestamp - TimeStamp::ProcessCreation(inconsistent)).ToMilliseconds();
double relativeTimestamp = (e.timestamp - TimeStamp::ProcessCreation()).ToMilliseconds();
::RecordEvent(locker, aProcessType, relativeTimestamp, e.category, e.method, e.object, e.value, e.extra);
}

View File

@ -1041,9 +1041,8 @@ bool MinidumpCallback(
WriteString(lastCrashFile, crashTimeString);
}
bool ignored = false;
double uptimeTS = (TimeStamp::NowLoRes()-
TimeStamp::ProcessCreation(ignored)).ToSecondsSigDigits();
double uptimeTS = (TimeStamp::NowLoRes() -
TimeStamp::ProcessCreation()).ToSecondsSigDigits();
char uptimeTSString[64];
SimpleNoCLibDtoA(uptimeTS, uptimeTSString, sizeof(uptimeTSString));
@ -3215,9 +3214,8 @@ WriteExtraData(nsIFile* extraFile,
nsDependentCString("CrashTime"),
nsDependentCString(crashTimeString));
bool ignored = false;
double uptimeTS = (TimeStamp::NowLoRes()-
TimeStamp::ProcessCreation(ignored)).ToSecondsSigDigits();
double uptimeTS = (TimeStamp::NowLoRes() -
TimeStamp::ProcessCreation()).ToSecondsSigDigits();
char uptimeTSString[64];
SimpleNoCLibDtoA(uptimeTS, uptimeTSString, sizeof(uptimeTSString));

View File

@ -95,8 +95,7 @@ MemoryProfiler::InitOnce()
ClearOnShutdown(&sJSContextProfilerMap);
ClearOnShutdown(&sNativeProfiler);
std::srand(PR_Now());
bool ignored;
sStartTime = TimeStamp::ProcessCreation(ignored);
sStartTime = TimeStamp::ProcessCreation();
initialized = true;
}
}

View File

@ -1978,8 +1978,7 @@ profiler_init(void* aStackTop)
// indicates that the profiler has initialized successfully.
gPS = new PS();
bool ignore;
gPS->SetProcessStartTime(lock, mozilla::TimeStamp::ProcessCreation(ignore));
gPS->SetProcessStartTime(lock, mozilla::TimeStamp::ProcessCreation());
locked_register_thread(lock, kMainThreadName, aStackTop);

View File

@ -183,7 +183,7 @@ GetChromeHangReport(Telemetry::ProcessedStack& aStack,
// Record Firefox uptime (in minutes) at the time of the hang
bool error;
TimeStamp processCreation = TimeStamp::ProcessCreation(error);
TimeStamp processCreation = TimeStamp::ProcessCreation(&error);
if (!error) {
TimeDuration td = TimeStamp::Now() - processCreation;
aFirefoxUptime = (static_cast<int32_t>(td.ToSeconds()) - (gTimeout * 2)) / 60;