Bug 1507379 - Rename gcstats::Stat to gcstats::Count r=jonco
authorPaul Bone <pbone@mozilla.com>
Fri, 16 Nov 2018 13:38:21 +1100
changeset 447125 46cc3fa6e65e0e08e015344966741e5a0ff92df7
parent 447124 3c7a3fc19c85ebca0be908143148c388f9d36f04
child 447126 5ab6d3eabd825a4cc8be82ae63a7816968ac16ff
push id109987
push userpbone@mozilla.com
push dateTue, 20 Nov 2018 02:30:01 +0000
treeherdermozilla-inbound@5ab6d3eabd82 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjonco
bugs1507379
milestone65.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 1507379 - Rename gcstats::Stat to gcstats::Count r=jonco I want to add a new type of value to Statisticx, which is similar to Stat but not the same. This change renames the existing type to Count (since it's used for counters) and the new one shall be Stat.
js/src/gc/Allocator.cpp
js/src/gc/GC.cpp
js/src/gc/Statistics.cpp
js/src/gc/Statistics.h
js/src/gc/StoreBuffer.cpp
--- a/js/src/gc/Allocator.cpp
+++ b/js/src/gc/Allocator.cpp
@@ -762,17 +762,17 @@ BackgroundAllocTask::run()
 
 /* static */ Chunk*
 Chunk::allocate(JSRuntime* rt)
 {
     Chunk* chunk = static_cast<Chunk*>(MapAlignedPages(ChunkSize, ChunkSize));
     if (!chunk) {
         return nullptr;
     }
-    rt->gc.stats().count(gcstats::STAT_NEW_CHUNK);
+    rt->gc.stats().count(gcstats::COUNT_NEW_CHUNK);
     return chunk;
 }
 
 void
 Chunk::init(JSRuntime* rt)
 {
     /* The chunk may still have some regions marked as no-access. */
     MOZ_MAKE_MEM_UNDEFINED(this, ChunkSize);
--- a/js/src/gc/GC.cpp
+++ b/js/src/gc/GC.cpp
@@ -841,17 +841,17 @@ GCRuntime::freeEmptyChunks(const AutoLoc
     FreeChunkPool(emptyChunks(lock));
 }
 
 inline void
 GCRuntime::prepareToFreeChunk(ChunkInfo& info)
 {
     MOZ_ASSERT(numArenasFreeCommitted >= info.numArenasFreeCommitted);
     numArenasFreeCommitted -= info.numArenasFreeCommitted;
-    stats().count(gcstats::STAT_DESTROY_CHUNK);
+    stats().count(gcstats::COUNT_DESTROY_CHUNK);
 #ifdef DEBUG
     /*
      * Let FreeChunkPool detect a missing prepareToFreeChunk call before it
      * frees chunk.
      */
     info.numArenasFreeCommitted = 0;
 #endif
 }
@@ -2495,17 +2495,17 @@ ArenaList::relocateArenas(Arena* toReloc
     check();
 
     while (Arena* arena = toRelocate) {
         toRelocate = arena->next;
         RelocateArena(arena, sliceBudget);
         // Prepend to list of relocated arenas
         arena->next = relocated;
         relocated = arena;
-        stats.count(gcstats::STAT_ARENA_RELOCATED);
+        stats.count(gcstats::COUNT_ARENA_RELOCATED);
     }
 
     check();
 
     return relocated;
 }
 
 // Skip compacting zones unless we can free a certain proportion of their GC
--- a/js/src/gc/Statistics.cpp
+++ b/js/src/gc/Statistics.cpp
@@ -352,28 +352,28 @@ Statistics::formatCompactSummaryMessage(
 
     SprintfLiteral(buffer,
                    "Zones: %d of %d (-%d); Compartments: %d of %d (-%d); HeapSize: %.3f MiB; " \
                    "HeapChange (abs): %+d (%d); ",
                    zoneStats.collectedZoneCount, zoneStats.zoneCount, zoneStats.sweptZoneCount,
                    zoneStats.collectedCompartmentCount, zoneStats.compartmentCount,
                    zoneStats.sweptCompartmentCount,
                    double(preBytes) / bytesPerMiB,
-                   counts[STAT_NEW_CHUNK] - counts[STAT_DESTROY_CHUNK],
-                   counts[STAT_NEW_CHUNK] + counts[STAT_DESTROY_CHUNK]);
+                   counts[COUNT_NEW_CHUNK] - counts[COUNT_DESTROY_CHUNK],
+                   counts[COUNT_NEW_CHUNK] + counts[COUNT_DESTROY_CHUNK]);
     if (!fragments.append(DuplicateString(buffer))) {
         return UniqueChars(nullptr);
     }
 
-    MOZ_ASSERT_IF(counts[STAT_ARENA_RELOCATED], gckind == GC_SHRINK);
+    MOZ_ASSERT_IF(counts[COUNT_ARENA_RELOCATED], gckind == GC_SHRINK);
     if (gckind == GC_SHRINK) {
         SprintfLiteral(buffer,
                        "Kind: %s; Relocated: %.3f MiB; ",
                        ExplainInvocationKind(gckind),
-                       double(ArenaSize * counts[STAT_ARENA_RELOCATED]) / bytesPerMiB);
+                       double(ArenaSize * counts[COUNT_ARENA_RELOCATED]) / bytesPerMiB);
         if (!fragments.append(DuplicateString(buffer))) {
             return UniqueChars(nullptr);
         }
     }
 
     return Join(fragments);
 }
 
@@ -477,24 +477,24 @@ Statistics::formatDetailedDescription() 
         buffer, format,
         ExplainInvocationKind(gckind),
         ExplainReason(slices_[0].reason),
         nonincremental() ? "no - " : "yes",
         nonincremental() ? ExplainAbortReason(nonincrementalReason_) : "",
         zoneStats.collectedZoneCount, zoneStats.zoneCount, zoneStats.sweptZoneCount,
         zoneStats.collectedCompartmentCount, zoneStats.compartmentCount,
         zoneStats.sweptCompartmentCount,
-        getCount(STAT_MINOR_GC),
-        getCount(STAT_STOREBUFFER_OVERFLOW),
+        getCount(COUNT_MINOR_GC),
+        getCount(COUNT_STOREBUFFER_OVERFLOW),
         mmu20 * 100., mmu50 * 100.,
         t(sccTotal), t(sccLongest),
         double(preBytes) / bytesPerMiB,
-        getCount(STAT_NEW_CHUNK) - getCount(STAT_DESTROY_CHUNK),
-        getCount(STAT_NEW_CHUNK) + getCount(STAT_DESTROY_CHUNK),
-        double(ArenaSize * getCount(STAT_ARENA_RELOCATED)) / bytesPerMiB,
+        getCount(COUNT_NEW_CHUNK) - getCount(COUNT_DESTROY_CHUNK),
+        getCount(COUNT_NEW_CHUNK) + getCount(COUNT_DESTROY_CHUNK),
+        double(ArenaSize * getCount(COUNT_ARENA_RELOCATED)) / bytesPerMiB,
         thresholdBuffer);
 
     return DuplicateString(buffer);
 }
 
 UniqueChars
 Statistics::formatDetailedSliceDescription(unsigned i, const SliceData& slice) const
 {
@@ -699,18 +699,18 @@ Statistics::formatJsonDescription(uint64
     json.property("max_pause", longest, JSONPrinter::MILLISECONDS); // #3
     json.property("total_time", total, JSONPrinter::MILLISECONDS); // #4
     // We might be able to omit reason if perf.html was able to retrive it
     // from the first slice.  But it doesn't do this yet.
     json.property("reason", ExplainReason(slices_[0].reason)); // #5
     json.property("zones_collected", zoneStats.collectedZoneCount); // #6
     json.property("total_zones", zoneStats.zoneCount); // #7
     json.property("total_compartments", zoneStats.compartmentCount); // #8
-    json.property("minor_gcs", getCount(STAT_MINOR_GC)); // #9
-    uint32_t storebufferOverflows = getCount(STAT_STOREBUFFER_OVERFLOW);
+    json.property("minor_gcs", getCount(COUNT_MINOR_GC)); // #9
+    uint32_t storebufferOverflows = getCount(COUNT_STOREBUFFER_OVERFLOW);
     if (storebufferOverflows) {
         json.property("store_buffer_overflows", storebufferOverflows); // #10
     }
     json.property("slices", slices_.length()); // #11
 
     const double mmu20 = computeMMU(TimeDuration::FromMilliseconds(20));
     const double mmu50 = computeMMU(TimeDuration::FromMilliseconds(50));
     json.property("mmu_20ms", int(mmu20 * 100)); // #12
@@ -720,21 +720,21 @@ Statistics::formatJsonDescription(uint64
     sccDurations(&sccTotal, &sccLongest);
     json.property("scc_sweep_total", sccTotal, JSONPrinter::MILLISECONDS); // #14
     json.property("scc_sweep_max_pause", sccLongest, JSONPrinter::MILLISECONDS); // #15
 
     if (nonincrementalReason_ != AbortReason::None) {
         json.property("nonincremental_reason", ExplainAbortReason(nonincrementalReason_)); // #16
     }
     json.property("allocated_bytes", preBytes); // #17
-    uint32_t addedChunks = getCount(STAT_NEW_CHUNK);
+    uint32_t addedChunks = getCount(COUNT_NEW_CHUNK);
     if (addedChunks) {
         json.property("added_chunks", addedChunks); // #18
     }
-    uint32_t removedChunks = getCount(STAT_DESTROY_CHUNK);
+    uint32_t removedChunks = getCount(COUNT_DESTROY_CHUNK);
     if (removedChunks) {
         json.property("removed_chunks", removedChunks); // #19
     }
     json.property("major_gc_number", startingMajorGCNumber); // #20
     json.property("minor_gc_number", startingMinorGCNumber); // #21
     json.property("slice_number", startingSliceNumber); // #22
 }
 
@@ -1072,17 +1072,17 @@ Statistics::endGC()
     const double mmu50 = computeMMU(TimeDuration::FromMilliseconds(50));
     runtime->addTelemetry(JS_TELEMETRY_GC_MMU_50, mmu50 * 100);
     thresholdTriggered = false;
 }
 
 void
 Statistics::beginNurseryCollection(JS::gcreason::Reason reason)
 {
-    count(STAT_MINOR_GC);
+    count(COUNT_MINOR_GC);
     startingMinorGCNumber = runtime->gc.minorGCCount();
     if (nurseryCollectionCallback) {
         (*nurseryCollectionCallback)(runtime->mainContextFromOwnThread(),
                                      JS::GCNurseryProgress::GC_NURSERY_COLLECTION_START,
                                      reason);
     }
 }
 
--- a/js/src/gc/Statistics.h
+++ b/js/src/gc/Statistics.h
@@ -26,29 +26,29 @@
 namespace js {
 namespace gcstats {
 
 // Phase data is generated by a script. If you need to add phases, edit
 // js/src/gc/GenerateStatsPhases.py
 
 #include "gc/StatsPhasesGenerated.h"
 
-enum Stat {
-    STAT_NEW_CHUNK,
-    STAT_DESTROY_CHUNK,
-    STAT_MINOR_GC,
+enum Count {
+    COUNT_NEW_CHUNK,
+    COUNT_DESTROY_CHUNK,
+    COUNT_MINOR_GC,
 
     // Number of times a 'put' into a storebuffer overflowed, triggering a
     // compaction
-    STAT_STOREBUFFER_OVERFLOW,
+    COUNT_STOREBUFFER_OVERFLOW,
 
     // Number of arenas relocated by compacting GC.
-    STAT_ARENA_RELOCATED,
+    COUNT_ARENA_RELOCATED,
 
-    STAT_LIMIT
+    COUNT_LIMIT
 };
 
 struct ZoneGCStats
 {
     /* Number of zones collected in this GC. */
     int collectedZoneCount = 0;
 
     /* Number of zones that could have been collected in this GC. */
@@ -174,21 +174,21 @@ struct Statistics
     bool nonincremental() const {
         return nonincrementalReason_ != gc::AbortReason::None;
     }
 
     const char* nonincrementalReason() const {
         return ExplainAbortReason(nonincrementalReason_);
     }
 
-    void count(Stat s) {
+    void count(Count s) {
         counts[s]++;
     }
 
-    uint32_t getCount(Stat s) const {
+    uint32_t getCount(Count s) const {
         return uint32_t(counts[s]);
     }
 
     void recordTrigger(double amount, double threshold) {
         triggerAmount = amount;
         triggerThreshold = threshold;
         thresholdTriggered = true;
     }
@@ -327,18 +327,18 @@ struct Statistics
     TimeStamp timedGCStart;
     TimeDuration timedGCTime;
 
     /* Total time in a given phase for this GC. */
     PhaseTimeTable phaseTimes;
     PhaseTimeTable parallelTimes;
 
     /* Number of events of this type for this GC. */
-    EnumeratedArray<Stat,
-                    STAT_LIMIT,
+    EnumeratedArray<Count,
+                    COUNT_LIMIT,
                     mozilla::Atomic<uint32_t, mozilla::ReleaseAcquire,
                                     mozilla::recordreplay::Behavior::DontPreserve>> counts;
 
     /*
      * These events cannot be kept in the above array, we need to take their
      * address.
      */
     struct {
--- a/js/src/gc/StoreBuffer.cpp
+++ b/js/src/gc/StoreBuffer.cpp
@@ -93,17 +93,17 @@ StoreBuffer::clear()
     bufferGeneric.clear();
 }
 
 void
 StoreBuffer::setAboutToOverflow(JS::gcreason::Reason reason)
 {
     if (!aboutToOverflow_) {
         aboutToOverflow_ = true;
-        runtime_->gc.stats().count(gcstats::STAT_STOREBUFFER_OVERFLOW);
+        runtime_->gc.stats().count(gcstats::COUNT_STOREBUFFER_OVERFLOW);
     }
     nursery_.requestMinorGC(reason);
 }
 
 void
 StoreBuffer::addSizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf, JS::GCSizes
 *sizes)
 {