Bug 1322560 - const-ify gc::Statistics API
☠☠ backed out by f40f9adb88a6 ☠ ☠
authorSteve Fink <sfink@mozilla.com>
Mon, 24 Apr 2017 12:01:10 -0700
changeset 355582 86277c75f5f7c5320214b5b99d2ca70af027693c
parent 355581 3ed8f64c76a504e57970468cc6c959d6e3e382c6
child 355583 4dee851a0d45655260ace1c01eb4dd9e9905942f
push id89703
push usersfink@mozilla.com
push dateFri, 28 Apr 2017 18:04:28 +0000
treeherdermozilla-inbound@2cd1662bcc5b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1322560
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1322560 - const-ify gc::Statistics API
js/src/gc/Statistics.cpp
js/src/gc/Statistics.h
--- a/js/src/gc/Statistics.cpp
+++ b/js/src/gc/Statistics.cpp
@@ -308,17 +308,17 @@ Statistics::gcDuration(TimeDuration* tot
         if (slice->duration() > *maxPause)
             *maxPause = slice->duration();
     }
     if (*maxPause > maxPauseInInterval)
         maxPauseInInterval = *maxPause;
 }
 
 void
-Statistics::sccDurations(TimeDuration* total, TimeDuration* maxPause)
+Statistics::sccDurations(TimeDuration* total, TimeDuration* maxPause) const
 {
     *total = *maxPause = 0;
     for (size_t i = 0; i < sccTimes.length(); i++) {
         *total += sccTimes[i];
         *maxPause = Max(*maxPause, sccTimes[i]);
     }
 }
 
@@ -486,17 +486,17 @@ Statistics::formatCompactSlicePhaseTimes
                     return UniqueChars(nullptr);
             }
         }
     }
     return Join(fragments, ", ");
 }
 
 UniqueChars
-Statistics::formatDetailedMessage()
+Statistics::formatDetailedMessage() const
 {
     FragmentVector fragments;
 
     if (!fragments.append(formatDetailedDescription()))
         return UniqueChars(nullptr);
 
     if (slices.length() > 1) {
         for (unsigned i = 0; i < slices.length(); i++) {
@@ -510,17 +510,17 @@ Statistics::formatDetailedMessage()
         return UniqueChars(nullptr);
     if (!fragments.append(formatDetailedPhaseTimes(phaseTimes)))
         return UniqueChars(nullptr);
 
     return Join(fragments);
 }
 
 UniqueChars
-Statistics::formatDetailedDescription()
+Statistics::formatDetailedDescription() const
 {
     const double bytesPerMiB = 1024 * 1024;
 
     TimeDuration sccTotal, sccLongest;
     sccDurations(&sccTotal, &sccLongest);
 
     const double mmu20 = computeMMU(TimeDuration::FromMilliseconds(20));
     const double mmu50 = computeMMU(TimeDuration::FromMilliseconds(50));
@@ -556,17 +556,17 @@ Statistics::formatDetailedDescription()
                    double(preBytes) / bytesPerMiB,
                    counts[STAT_NEW_CHUNK] - counts[STAT_DESTROY_CHUNK],
                    counts[STAT_NEW_CHUNK] + counts[STAT_DESTROY_CHUNK],
                    double(ArenaSize * counts[STAT_ARENA_RELOCATED]) / bytesPerMiB);
     return DuplicateString(buffer);
 }
 
 UniqueChars
-Statistics::formatDetailedSliceDescription(unsigned i, const SliceData& slice)
+Statistics::formatDetailedSliceDescription(unsigned i, const SliceData& slice) const
 {
     char budgetDescription[200];
     slice.budget.describe(budgetDescription, sizeof(budgetDescription) - 1);
 
     const char* format =
 "\
   ---- Slice %u ----\n\
     Reason: %s\n\
@@ -581,17 +581,17 @@ Statistics::formatDetailedSliceDescripti
                    slice.wasReset() ? ExplainAbortReason(slice.resetReason) : "",
                    gc::StateName(slice.initialState), gc::StateName(slice.finalState),
                    uint64_t(slice.endFaults - slice.startFaults),
                    t(slice.duration()), budgetDescription, t(slice.start - slices[0].start));
     return DuplicateString(buffer);
 }
 
 UniqueChars
-Statistics::formatDetailedPhaseTimes(const PhaseTimeTable& phaseTimes)
+Statistics::formatDetailedPhaseTimes(const PhaseTimeTable& phaseTimes) const
 {
     static const char* LevelToIndent[] = { "", "  ", "    ", "      " };
     static const TimeDuration MaxUnaccountedChildTime = TimeDuration::FromMicroseconds(50);
 
     FragmentVector fragments;
     char buffer[128];
     for (AllPhaseIterator iter; !iter.done(); iter.advance()) {
         Phase phase;
@@ -616,34 +616,34 @@ Statistics::formatDetailedPhaseTimes(con
                     return UniqueChars(nullptr);
             }
         }
     }
     return Join(fragments);
 }
 
 UniqueChars
-Statistics::formatDetailedTotals()
+Statistics::formatDetailedTotals() const
 {
     TimeDuration total, longest;
     gcDuration(&total, &longest);
 
     const char* format =
 "\
   ---- Totals ----\n\
     Total Time: %.3fms\n\
     Max Pause: %.3fms\n\
 ";
     char buffer[1024];
     SprintfLiteral(buffer, format, t(total), t(longest));
     return DuplicateString(buffer);
 }
 
 UniqueChars
-Statistics::formatJsonMessage(uint64_t timestamp)
+Statistics::formatJsonMessage(uint64_t timestamp) const
 {
     MOZ_ASSERT(!aborted);
 
     FragmentVector fragments;
 
     if (!fragments.append(DuplicateString("{")) ||
         !fragments.append(formatJsonDescription(timestamp)) ||
         !fragments.append(DuplicateString("\"slices\":[")))
@@ -679,17 +679,17 @@ Statistics::formatJsonMessage(uint64_t t
 // %llu.%03llu.
 static lldiv_t
 SplitDurationMS(TimeDuration d)
 {
     return lldiv(static_cast<int64_t>(d.ToMicroseconds()), 1000);
 }
 
 UniqueChars
-Statistics::formatJsonDescription(uint64_t timestamp)
+Statistics::formatJsonDescription(uint64_t timestamp) const
 {
     TimeDuration total, longest;
     gcDuration(&total, &longest);
     lldiv_t totalParts = SplitDurationMS(total);
     lldiv_t longestParts = SplitDurationMS(longest);
 
     TimeDuration sccTotal, sccLongest;
     sccDurations(&sccTotal, &sccLongest);
@@ -733,17 +733,17 @@ Statistics::formatJsonDescription(uint64
                    ExplainAbortReason(nonincrementalReason_),
                    unsigned(preBytes / 1024 / 1024),
                    counts[STAT_NEW_CHUNK],
                    counts[STAT_DESTROY_CHUNK]);
     return DuplicateString(buffer);
 }
 
 UniqueChars
-Statistics::formatJsonSliceDescription(unsigned i, const SliceData& slice)
+Statistics::formatJsonSliceDescription(unsigned i, const SliceData& slice) const
 {
     TimeDuration duration = slice.duration();
     lldiv_t durationParts = SplitDurationMS(duration);
     TimeDuration when = slice.start - slices[0].start;
     lldiv_t whenParts = SplitDurationMS(when);
     char budgetDescription[200];
     slice.budget.describe(budgetDescription, sizeof(budgetDescription) - 1);
     int64_t pageFaults = slice.endFaults - slice.startFaults;
@@ -786,17 +786,17 @@ FilterJsonKey(const char*const buffer)
         else if (isupper(*c))
             *c = tolower(*c);
         ++c;
     }
     return UniqueChars(mut);
 }
 
 UniqueChars
-Statistics::formatJsonPhaseTimes(const PhaseTimeTable& phaseTimes)
+Statistics::formatJsonPhaseTimes(const PhaseTimeTable& phaseTimes) const
 {
     FragmentVector fragments;
     char buffer[128];
     for (AllPhaseIterator iter; !iter.done(); iter.advance()) {
         Phase phase;
         size_t dagSlot;
         iter.get(&phase, &dagSlot);
 
--- a/js/src/gc/Statistics.h
+++ b/js/src/gc/Statistics.h
@@ -269,18 +269,18 @@ struct Statistics
     void beginNurseryCollection(JS::gcreason::Reason reason);
     void endNurseryCollection(JS::gcreason::Reason reason);
 
     TimeStamp beginSCC();
     void endSCC(unsigned scc, TimeStamp start);
 
     UniqueChars formatCompactSliceMessage() const;
     UniqueChars formatCompactSummaryMessage() const;
-    UniqueChars formatJsonMessage(uint64_t timestamp);
-    UniqueChars formatDetailedMessage();
+    UniqueChars formatJsonMessage(uint64_t timestamp) const;
+    UniqueChars formatDetailedMessage() const;
 
     JS::GCSliceCallback setSliceCallback(JS::GCSliceCallback callback);
     JS::GCNurseryCollectionCallback setNurseryCollectionCallback(
         JS::GCNurseryCollectionCallback callback);
 
     TimeDuration clearMaxGCPauseAccumulator();
     TimeDuration getMaxGCPauseSinceClear();
 
@@ -416,29 +416,29 @@ FOR_EACH_GC_PROFILE_TIME(DEFINE_TIME_KEY
     uint64_t sliceCount_;
 
     void beginGC(JSGCInvocationKind kind);
     void endGC();
 
     void recordPhaseEnd(Phase phase);
 
     void gcDuration(TimeDuration* total, TimeDuration* maxPause) const;
-    void sccDurations(TimeDuration* total, TimeDuration* maxPause);
+    void sccDurations(TimeDuration* total, TimeDuration* maxPause) const;
     void printStats();
 
     UniqueChars formatCompactSlicePhaseTimes(const PhaseTimeTable& phaseTimes) const;
 
-    UniqueChars formatDetailedDescription();
-    UniqueChars formatDetailedSliceDescription(unsigned i, const SliceData& slice);
-    UniqueChars formatDetailedPhaseTimes(const PhaseTimeTable& phaseTimes);
-    UniqueChars formatDetailedTotals();
+    UniqueChars formatDetailedDescription() const;
+    UniqueChars formatDetailedSliceDescription(unsigned i, const SliceData& slice) const;
+    UniqueChars formatDetailedPhaseTimes(const PhaseTimeTable& phaseTimes) const;
+    UniqueChars formatDetailedTotals() const;
 
-    UniqueChars formatJsonDescription(uint64_t timestamp);
-    UniqueChars formatJsonSliceDescription(unsigned i, const SliceData& slice);
-    UniqueChars formatJsonPhaseTimes(const PhaseTimeTable& phaseTimes);
+    UniqueChars formatJsonDescription(uint64_t timestamp) const;
+    UniqueChars formatJsonSliceDescription(unsigned i, const SliceData& slice) const;
+    UniqueChars formatJsonPhaseTimes(const PhaseTimeTable& phaseTimes) const;
 
     double computeMMU(TimeDuration resolution) const;
 
     void printSliceProfile();
     static void printProfileTimes(const ProfileDurations& times);
 };
 
 struct MOZ_RAII AutoGCSlice