Bug 1433007 - (part 6) Rename lazyCapacity() to committed() and remove sizeOfHeapCommitted() r=sfink
authorPaul Bone <pbone@mozilla.com>
Fri, 15 Feb 2019 04:30:41 +0000
changeset 459497 6cec6714210566cd5a156c40b1759a3c46d9d69f
parent 459496 cd3427c916a4d424e46f999089db29f3825fbec9
child 459498 1bcbf6ebcd453f3ea6eaa944145704766aee8b49
push id111964
push usercsabou@mozilla.com
push dateFri, 15 Feb 2019 18:54:44 +0000
treeherdermozilla-inbound@db3c4f905082 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssfink
bugs1433007
milestone67.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 1433007 - (part 6) Rename lazyCapacity() to committed() and remove sizeOfHeapCommitted() r=sfink spaceToEnd() now works when the nursery is disabled. Differential Revision: https://phabricator.services.mozilla.com/D19459
js/src/gc/Nursery.cpp
js/src/gc/Nursery.h
js/src/vm/Runtime.cpp
--- a/js/src/gc/Nursery.cpp
+++ b/js/src/gc/Nursery.cpp
@@ -608,18 +608,18 @@ void js::Nursery::renderProfileJSON(JSON
   json.property("strings_tenured",
                 stats().getStat(gcstats::STAT_STRINGS_TENURED));
   json.property("bytes_used", previousGC.nurseryUsedBytes);
   json.property("cur_capacity", previousGC.nurseryCapacity);
   const size_t newCapacity = capacity();
   if (newCapacity != previousGC.nurseryCapacity) {
     json.property("new_capacity", newCapacity);
   }
-  if (previousGC.nurseryLazyCapacity != previousGC.nurseryCapacity) {
-    json.property("lazy_capacity", previousGC.nurseryLazyCapacity);
+  if (previousGC.nurseryCommitted != previousGC.nurseryCapacity) {
+    json.property("lazy_capacity", previousGC.nurseryCommitted);
   }
   if (!timeInChunkAlloc_.IsZero()) {
     json.property("chunk_alloc_us", timeInChunkAlloc_, json.MICROSECONDS);
   }
 
   // These counters only contain consistent data if the profiler is enabled,
   // and then there's no guarentee.
   if (runtime()->geckoProfiler().enabled()) {
@@ -750,17 +750,17 @@ void js::Nursery::collect(JS::GCReason r
 
   TenureCountCache tenureCounts;
   previousGC.reason = JS::GCReason::NO_REASON;
   if (!isEmpty()) {
     doCollection(reason, tenureCounts);
   } else {
     previousGC.nurseryUsedBytes = 0;
     previousGC.nurseryCapacity = capacity();
-    previousGC.nurseryLazyCapacity = lazyCapacity();
+    previousGC.nurseryCommitted = committed();
     previousGC.tenuredBytes = 0;
     previousGC.tenuredCells = 0;
   }
 
   // Resize the nursery.
   maybeResizeNursery(reason);
 
   // If we are promoting the nursery, or exhausted the store buffer with
@@ -842,17 +842,17 @@ void js::Nursery::collect(JS::GCReason r
   rt->gc.incMinorGcNumber();
 
   TimeDuration totalTime = profileDurations_[ProfileKey::Total];
   rt->addTelemetry(JS_TELEMETRY_GC_MINOR_US, totalTime.ToMicroseconds());
   rt->addTelemetry(JS_TELEMETRY_GC_MINOR_REASON, uint32_t(reason));
   if (totalTime.ToMilliseconds() > 1.0) {
     rt->addTelemetry(JS_TELEMETRY_GC_MINOR_REASON_LONG, uint32_t(reason));
   }
-  rt->addTelemetry(JS_TELEMETRY_GC_NURSERY_BYTES, sizeOfHeapCommitted());
+  rt->addTelemetry(JS_TELEMETRY_GC_NURSERY_BYTES, committed());
   rt->addTelemetry(JS_TELEMETRY_GC_PRETENURE_COUNT, pretenureCount);
   rt->addTelemetry(JS_TELEMETRY_GC_NURSERY_PROMOTION_RATE, promotionRate * 100);
 
   stats().endNurseryCollection(reason);
   gcTracer.traceMinorGCEnd();
   timeInChunkAlloc_ = mozilla::TimeDuration();
 
   if (enableProfiling_ && totalTime >= profileThreshold_) {
@@ -979,17 +979,17 @@ void js::Nursery::doCollection(JS::GCRea
   if (rt->hasZealMode(ZealMode::CheckHashTablesOnMinorGC)) {
     CheckHashTablesAfterMovingGC(rt);
   }
 #endif
   endProfile(ProfileKey::CheckHashTables);
 
   previousGC.reason = reason;
   previousGC.nurseryCapacity = initialNurseryCapacity;
-  previousGC.nurseryLazyCapacity = spaceToEnd(allocatedChunkCount());
+  previousGC.nurseryCommitted = spaceToEnd(allocatedChunkCount());
   previousGC.nurseryUsedBytes = initialNurseryUsedBytes;
   previousGC.tenuredBytes = mover.tenuredSize;
   previousGC.tenuredCells = mover.tenuredCells;
 }
 
 bool js::Nursery::registerMallocedBuffer(void* buffer) {
   MOZ_ASSERT(buffer);
   return mallocedBuffers.putNew(buffer);
@@ -1041,16 +1041,20 @@ void js::Nursery::clear() {
     setCurrentChunk(0);
   }
 
   /* Set current start position for isEmpty checks. */
   setStartPosition();
 }
 
 size_t js::Nursery::spaceToEnd(unsigned chunkCount) const {
+  if (chunkCount == 0) {
+    return 0;
+  }
+
   unsigned lastChunk = chunkCount - 1;
 
   MOZ_ASSERT(lastChunk >= currentStartChunk_);
   MOZ_ASSERT(currentStartPosition_ - chunk(currentStartChunk_).start() <=
              NurseryChunkUsableSize);
 
   size_t bytes;
 
--- a/js/src/gc/Nursery.h
+++ b/js/src/gc/Nursery.h
@@ -327,19 +327,16 @@ class Nursery {
   MOZ_MUST_USE bool addedUniqueIdToCell(gc::Cell* cell) {
     MOZ_ASSERT(IsInsideNursery(cell));
     MOZ_ASSERT(isEnabled());
     return cellsWithUid_.append(cell);
   }
 
   MOZ_MUST_USE bool queueDictionaryModeObjectToSweep(NativeObject* obj);
 
-  size_t sizeOfHeapCommitted() const {
-    return allocatedChunkCount() * gc::ChunkSize;
-  }
   size_t sizeOfMallocedBuffers(mozilla::MallocSizeOf mallocSizeOf) const {
     size_t total = 0;
     for (BufferSet::Range r = mallocedBuffers.all(); !r.empty(); r.popFront()) {
       total += mallocSizeOf(r.front());
     }
     total += mallocedBuffers.shallowSizeOfExcludingThis(mallocSizeOf);
     return total;
   }
@@ -350,17 +347,17 @@ class Nursery {
   // limit respectively.
   size_t spaceToEnd(unsigned chunkCount) const;
 
   size_t capacity() const {
     MOZ_ASSERT(capacity_ >= SubChunkLimit || capacity_ == 0);
     MOZ_ASSERT(capacity_ <= chunkCountLimit() * NurseryChunkUsableSize);
     return capacity_;
   }
-  size_t lazyCapacity() const { return spaceToEnd(allocatedChunkCount()); }
+  size_t committed() const { return spaceToEnd(allocatedChunkCount()); }
 
   // Used and free space, not counting chunk trailers.
   //
   // usedSpace() + freeSpace() == capacity()
   //
   MOZ_ALWAYS_INLINE size_t usedSpace() const {
     return capacity() - freeSpace();
   }
@@ -500,17 +497,17 @@ class Nursery {
 
   ProfileTimes startTimes_;
   ProfileDurations profileDurations_;
   ProfileDurations totalDurations_;
 
   struct {
     JS::GCReason reason = JS::GCReason::NO_REASON;
     size_t nurseryCapacity = 0;
-    size_t nurseryLazyCapacity = 0;
+    size_t nurseryCommitted = 0;
     size_t nurseryUsedBytes = 0;
     size_t tenuredBytes = 0;
     size_t tenuredCells = 0;
   } previousGC;
 
   /*
    * Calculate the promotion rate of the most recent minor GC.
    * The valid_for_tenuring parameter is used to return whether this
--- a/js/src/vm/Runtime.cpp
+++ b/js/src/vm/Runtime.cpp
@@ -354,17 +354,17 @@ void JSRuntime::addSizeOfIncludingThis(m
   if (cx->traceLogger) {
     rtSizes->tracelogger += cx->traceLogger->sizeOfIncludingThis(mallocSizeOf);
   }
 #endif
 
   rtSizes->uncompressedSourceCache +=
       caches().uncompressedSourceCache.sizeOfExcludingThis(mallocSizeOf);
 
-  rtSizes->gc.nurseryCommitted += gc.nursery().sizeOfHeapCommitted();
+  rtSizes->gc.nurseryCommitted += gc.nursery().committed();
   rtSizes->gc.nurseryMallocedBuffers +=
       gc.nursery().sizeOfMallocedBuffers(mallocSizeOf);
   gc.storeBuffer().addSizeOfExcludingThis(mallocSizeOf, &rtSizes->gc);
 
   if (sharedImmutableStrings_) {
     rtSizes->sharedImmutableStringsCache +=
         sharedImmutableStrings_->sizeOfExcludingThis(mallocSizeOf);
   }