Bug 1496699 - Use size_t for memory sizes r=sfink
authorPaul Bone <pbone@mozilla.com>
Thu, 04 Oct 2018 19:13:49 +1000
changeset 499099 2398cc611aba734f6de7000d3429f40efb0517eb
parent 499098 5aee88f016b05ac1a2239f46db3207af42f45199
child 499100 6dd61044e50ab89772a49adc1c8f020d1d32d1ec
push id1864
push userffxbld-merge
push dateMon, 03 Dec 2018 15:51:40 +0000
treeherdermozilla-release@f040763d99ad [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssfink
bugs1496699
milestone64.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 1496699 - Use size_t for memory sizes r=sfink Some of these values were uint64_t which would not have made sense on 32bit systems.
js/src/gc/GC.cpp
js/src/gc/Scheduling.h
js/src/jit-test/tests/gc/gcparam.js
--- a/js/src/gc/GC.cpp
+++ b/js/src/gc/GC.cpp
@@ -307,20 +307,20 @@ namespace TuningDefaults {
 
     /* JSGC_DYNAMIC_HEAP_GROWTH */
     static const bool DynamicHeapGrowthEnabled = false;
 
     /* JSGC_HIGH_FREQUENCY_TIME_LIMIT */
     static const auto HighFrequencyThreshold = 1; // in seconds
 
     /* JSGC_HIGH_FREQUENCY_LOW_LIMIT */
-    static const uint64_t HighFrequencyLowLimitBytes = 100 * 1024 * 1024;
+    static const size_t HighFrequencyLowLimitBytes = 100 * 1024 * 1024;
 
     /* JSGC_HIGH_FREQUENCY_HIGH_LIMIT */
-    static const uint64_t HighFrequencyHighLimitBytes = 500 * 1024 * 1024;
+    static const size_t HighFrequencyHighLimitBytes = 500 * 1024 * 1024;
 
     /* JSGC_HIGH_FREQUENCY_HEAP_GROWTH_MAX */
     static const float HighFrequencyHeapGrowthMax = 3.0f;
 
     /* JSGC_HIGH_FREQUENCY_HEAP_GROWTH_MIN */
     static const float HighFrequencyHeapGrowthMin = 1.5f;
 
     /* JSGC_LOW_FREQUENCY_HEAP_GROWTH */
@@ -1338,17 +1338,17 @@ js::gc::DumpArenaInfo()
 }
 
 #endif // JS_GC_ZEAL
 
 /*
  * Lifetime in number of major GCs for type sets attached to scripts containing
  * observed types.
  */
-static const uint64_t JIT_SCRIPT_RELEASE_TYPES_PERIOD = 20;
+static const unsigned JIT_SCRIPT_RELEASE_TYPES_PERIOD = 20;
 
 bool
 GCRuntime::init(uint32_t maxbytes, uint32_t maxNurseryBytes)
 {
     MOZ_ASSERT(SystemPageSize());
 
     {
         AutoLockGCBgAlloc lock(rt);
@@ -1495,25 +1495,25 @@ GCSchedulingTunables::setParameter(JSGCP
         break;
       case JSGC_MAX_NURSERY_BYTES:
         gcMaxNurseryBytes_ = value;
         break;
       case JSGC_HIGH_FREQUENCY_TIME_LIMIT:
         highFrequencyThreshold_ = TimeDuration::FromMilliseconds(value);
         break;
       case JSGC_HIGH_FREQUENCY_LOW_LIMIT: {
-        uint64_t newLimit = (uint64_t)value * 1024 * 1024;
-        if (newLimit == UINT64_MAX) {
+        CheckedInt<size_t> newLimit = CheckedInt<size_t>(value) * 1024 * 1024;
+        if (!newLimit.isValid()) {
             return false;
         }
-        setHighFrequencyLowLimit(newLimit);
+        setHighFrequencyLowLimit(newLimit.value());
         break;
       }
       case JSGC_HIGH_FREQUENCY_HIGH_LIMIT: {
-        uint64_t newLimit = (uint64_t)value * 1024 * 1024;
+        size_t newLimit = (size_t)value * 1024 * 1024;
         if (newLimit == 0) {
             return false;
         }
         setHighFrequencyHighLimit(newLimit);
         break;
       }
       case JSGC_HIGH_FREQUENCY_HEAP_GROWTH_MAX: {
         float newGrowth = value / 100.0f;
@@ -1585,27 +1585,27 @@ GCSchedulingTunables::setParameter(JSGCP
 
 void
 GCSchedulingTunables::setMaxMallocBytes(size_t value)
 {
     maxMallocBytes_ = std::min(value, TuningDefaults::MallocThresholdLimit);
 }
 
 void
-GCSchedulingTunables::setHighFrequencyLowLimit(uint64_t newLimit)
+GCSchedulingTunables::setHighFrequencyLowLimit(size_t newLimit)
 {
     highFrequencyLowLimitBytes_ = newLimit;
     if (highFrequencyLowLimitBytes_ >= highFrequencyHighLimitBytes_) {
         highFrequencyHighLimitBytes_ = highFrequencyLowLimitBytes_ + 1;
     }
     MOZ_ASSERT(highFrequencyHighLimitBytes_ > highFrequencyLowLimitBytes_);
 }
 
 void
-GCSchedulingTunables::setHighFrequencyHighLimit(uint64_t newLimit)
+GCSchedulingTunables::setHighFrequencyHighLimit(size_t newLimit)
 {
     highFrequencyHighLimitBytes_ = newLimit;
     if (highFrequencyHighLimitBytes_ <= highFrequencyLowLimitBytes_) {
         highFrequencyLowLimitBytes_ = highFrequencyHighLimitBytes_ - 1;
     }
     MOZ_ASSERT(highFrequencyHighLimitBytes_ > highFrequencyLowLimitBytes_);
 }
 
--- a/js/src/gc/Scheduling.h
+++ b/js/src/gc/Scheduling.h
@@ -397,18 +397,18 @@ class GCSchedulingTunables
      * JSGC_HIGH_FREQUENCY_LOW_LIMIT
      * JSGC_HIGH_FREQUENCY_HIGH_LIMIT
      * JSGC_HIGH_FREQUENCY_HEAP_GROWTH_MAX
      * JSGC_HIGH_FREQUENCY_HEAP_GROWTH_MIN
      *
      * When in the |highFrequencyGC| mode, these parameterize the per-zone
      * "HeapGrowthFactor" computation.
      */
-    MainThreadData<uint64_t> highFrequencyLowLimitBytes_;
-    MainThreadData<uint64_t> highFrequencyHighLimitBytes_;
+    MainThreadData<size_t> highFrequencyLowLimitBytes_;
+    MainThreadData<size_t> highFrequencyHighLimitBytes_;
     MainThreadData<float> highFrequencyHeapGrowthMax_;
     MainThreadData<float> highFrequencyHeapGrowthMin_;
 
     /*
      * JSGC_LOW_FREQUENCY_HEAP_GROWTH
      *
      * When not in |highFrequencyGC| mode, this is the global (stored per-zone)
      * "HeapGrowthFactor".
@@ -446,36 +446,36 @@ class GCSchedulingTunables
     size_t maxMallocBytes() const { return maxMallocBytes_; }
     size_t gcMaxNurseryBytes() const { return gcMaxNurseryBytes_; }
     size_t gcZoneAllocThresholdBase() const { return gcZoneAllocThresholdBase_; }
     double allocThresholdFactor() const { return allocThresholdFactor_; }
     double allocThresholdFactorAvoidInterrupt() const { return allocThresholdFactorAvoidInterrupt_; }
     size_t zoneAllocDelayBytes() const { return zoneAllocDelayBytes_; }
     bool isDynamicHeapGrowthEnabled() const { return dynamicHeapGrowthEnabled_; }
     const mozilla::TimeDuration &highFrequencyThreshold() const { return highFrequencyThreshold_; }
-    uint64_t highFrequencyLowLimitBytes() const { return highFrequencyLowLimitBytes_; }
-    uint64_t highFrequencyHighLimitBytes() const { return highFrequencyHighLimitBytes_; }
+    size_t highFrequencyLowLimitBytes() const { return highFrequencyLowLimitBytes_; }
+    size_t highFrequencyHighLimitBytes() const { return highFrequencyHighLimitBytes_; }
     double highFrequencyHeapGrowthMax() const { return highFrequencyHeapGrowthMax_; }
     double highFrequencyHeapGrowthMin() const { return highFrequencyHeapGrowthMin_; }
     double lowFrequencyHeapGrowth() const { return lowFrequencyHeapGrowth_; }
     bool isDynamicMarkSliceEnabled() const { return dynamicMarkSliceEnabled_; }
     unsigned minEmptyChunkCount(const AutoLockGC&) const { return minEmptyChunkCount_; }
     unsigned maxEmptyChunkCount() const { return maxEmptyChunkCount_; }
     uint32_t nurseryFreeThresholdForIdleCollection() const {
         return nurseryFreeThresholdForIdleCollection_;
     }
 
     MOZ_MUST_USE bool setParameter(JSGCParamKey key, uint32_t value, const AutoLockGC& lock);
     void resetParameter(JSGCParamKey key, const AutoLockGC& lock);
 
     void setMaxMallocBytes(size_t value);
 
 private:
-    void setHighFrequencyLowLimit(uint64_t value);
-    void setHighFrequencyHighLimit(uint64_t value);
+    void setHighFrequencyLowLimit(size_t value);
+    void setHighFrequencyHighLimit(size_t value);
     void setHighFrequencyHeapGrowthMin(float value);
     void setHighFrequencyHeapGrowthMax(float value);
     void setLowFrequencyHeapGrowth(float value);
     void setMinEmptyChunkCount(uint32_t value);
     void setMaxEmptyChunkCount(uint32_t value);
 };
 
 class GCSchedulingState
--- a/js/src/jit-test/tests/gc/gcparam.js
+++ b/js/src/jit-test/tests/gc/gcparam.js
@@ -9,17 +9,17 @@ function testChangeParam(key) {
     let value = prev - 1;
     gcparam(key, value);
     assertEq(gcparam(key), value);
     gcparam(key, prev);
 }
 
 function testLargeParamValue(key) {
     let prev = gcparam(key);
-    const value = 1000000;
+    const value = 1024;
     gcparam(key, value);
     assertEq(gcparam(key), value);
     gcparam(key, prev);
 }
 
 testGetParam("gcBytes");
 testGetParam("gcNumber");
 testGetParam("unusedChunks");