diff --git a/js/public/MemoryMetrics.h b/js/public/MemoryMetrics.h index 44d70e8fa4f8..3204177b30f2 100644 --- a/js/public/MemoryMetrics.h +++ b/js/public/MemoryMetrics.h @@ -11,7 +11,6 @@ // at your own risk. #include "mozilla/MemoryReporting.h" -#include "mozilla/PodOperations.h" #include "mozilla/TypeTraits.h" #include @@ -74,15 +73,7 @@ struct ServoSizes Ignore }; - ServoSizes() - : gcHeapUsed(0) - , gcHeapUnused(0) - , gcHeapAdmin(0) - , gcHeapDecommitted(0) - , mallocHeap(0) - , nonHeap(0) - { - } + ServoSizes() = default; void add(Kind kind, size_t n) { switch (kind) { @@ -97,12 +88,12 @@ struct ServoSizes } } - size_t gcHeapUsed; - size_t gcHeapUnused; - size_t gcHeapAdmin; - size_t gcHeapDecommitted; - size_t mallocHeap; - size_t nonHeap; + size_t gcHeapUsed = 0; + size_t gcHeapUnused = 0; + size_t gcHeapAdmin = 0; + size_t gcHeapDecommitted = 0; + size_t mallocHeap = 0; + size_t nonHeap = 0; }; } // namespace JS diff --git a/js/src/builtin/RegExp.cpp b/js/src/builtin/RegExp.cpp index 85264e61578d..cc0386014358 100644 --- a/js/src/builtin/RegExp.cpp +++ b/js/src/builtin/RegExp.cpp @@ -1178,11 +1178,11 @@ using CapturesVector = GCVector; struct JSSubString { - JSLinearString* base; - size_t offset; - size_t length; + JSLinearString* base = nullptr; + size_t offset = 0; + size_t length = 0; - JSSubString() { mozilla::PodZero(this); } + JSSubString() = default; void initEmpty(JSLinearString* base) { this->base = base; diff --git a/js/src/gc/GCInternals.h b/js/src/gc/GCInternals.h index 25c985659936..cf6bbf502450 100644 --- a/js/src/gc/GCInternals.h +++ b/js/src/gc/GCInternals.h @@ -13,7 +13,6 @@ #include "mozilla/ArrayUtils.h" #include "mozilla/Maybe.h" -#include "mozilla/PodOperations.h" #include "gc/RelocationOverlay.h" #include "gc/Zone.h" @@ -158,9 +157,9 @@ struct TenureCountCache static const size_t EntryShift = 4; static const size_t EntryCount = 1 << EntryShift; - TenureCount entries[EntryCount]; + TenureCount entries[EntryCount] = {}; // zeroes - TenureCountCache() { mozilla::PodZero(this); } + TenureCountCache() = default; HashNumber hash(ObjectGroup* group) { #if JS_BITS_PER_WORD == 32 diff --git a/js/src/gc/Statistics.h b/js/src/gc/Statistics.h index 9db8427ff790..3364e190051f 100644 --- a/js/src/gc/Statistics.h +++ b/js/src/gc/Statistics.h @@ -11,7 +11,6 @@ #include "mozilla/Atomics.h" #include "mozilla/EnumeratedArray.h" #include "mozilla/IntegerRange.h" -#include "mozilla/PodOperations.h" #include "mozilla/TimeStamp.h" #include "jspubtd.h" @@ -50,33 +49,31 @@ enum Stat { struct ZoneGCStats { /* Number of zones collected in this GC. */ - int collectedZoneCount; + int collectedZoneCount = 0; /* Number of zones that could have been collected in this GC. */ - int collectableZoneCount; + int collectableZoneCount = 0; /* Total number of zones in the Runtime at the start of this GC. */ - int zoneCount; + int zoneCount = 0; /* Number of zones swept in this GC. */ - int sweptZoneCount; + int sweptZoneCount = 0; /* Total number of compartments in all zones collected. */ - int collectedCompartmentCount; + int collectedCompartmentCount = 0; /* Total number of compartments in the Runtime at the start of this GC. */ - int compartmentCount; + int compartmentCount = 0; /* Total number of compartments swept by this GC. */ - int sweptCompartmentCount; + int sweptCompartmentCount = 0; bool isFullCollection() const { return collectedZoneCount == collectableZoneCount; } - ZoneGCStats() { - mozilla::PodZero(this); - } + ZoneGCStats() = default; }; #define FOR_EACH_GC_PROFILE_TIME(_) \ diff --git a/js/src/jit/IonCode.h b/js/src/jit/IonCode.h index 7b2c849ad49e..99b9e9689945 100644 --- a/js/src/jit/IonCode.h +++ b/js/src/jit/IonCode.h @@ -9,7 +9,6 @@ #include "mozilla/Atomics.h" #include "mozilla/MemoryReporting.h" -#include "mozilla/PodOperations.h" #include "jstypes.h" @@ -677,17 +676,14 @@ struct IonScriptCounts { private: // Any previous invalidated compilation(s) for the script. - IonScriptCounts* previous_; + IonScriptCounts* previous_ = nullptr; // Information about basic blocks in this script. - size_t numBlocks_; - IonBlockCounts* blocks_; + size_t numBlocks_ = 0; + IonBlockCounts* blocks_ = nullptr; public: - - IonScriptCounts() { - mozilla::PodZero(this); - } + IonScriptCounts() = default; ~IonScriptCounts() { for (size_t i = 0; i < numBlocks_; i++) diff --git a/js/src/jit/shared/Assembler-shared.h b/js/src/jit/shared/Assembler-shared.h index 0cab84131e15..9a0c4e226934 100644 --- a/js/src/jit/shared/Assembler-shared.h +++ b/js/src/jit/shared/Assembler-shared.h @@ -8,7 +8,6 @@ #define jit_shared_Assembler_shared_h #include "mozilla/CheckedInt.h" -#include "mozilla/PodOperations.h" #include @@ -597,10 +596,10 @@ typedef Vector CodeLabelVector; class CodeOffsetJump { - size_t offset_; + size_t offset_ = 0; #ifdef JS_SMALL_BRANCH - size_t jumpTableIndex_; + size_t jumpTableIndex_ = 0; #endif public: @@ -616,9 +615,7 @@ class CodeOffsetJump explicit CodeOffsetJump(size_t offset) : offset_(offset) {} #endif - CodeOffsetJump() { - mozilla::PodZero(this); - } + CodeOffsetJump() = default; size_t offset() const { return offset_; diff --git a/js/src/vm/Caches.h b/js/src/vm/Caches.h index f0674f07d122..da840e01c3a2 100644 --- a/js/src/vm/Caches.h +++ b/js/src/vm/Caches.h @@ -7,6 +7,8 @@ #ifndef vm_Caches_h #define vm_Caches_h +#include + #include "jsmath.h" #include "frontend/SourceNotes.h" @@ -142,14 +144,20 @@ class NewObjectCache char templateObject[MAX_OBJ_SIZE]; }; - Entry entries[41]; // TODO: reconsider size + using EntryArray = Entry[41]; // TODO: reconsider size; + EntryArray entries; public: - typedef int EntryIndex; + using EntryIndex = int; - NewObjectCache() { mozilla::PodZero(this); } - void purge() { mozilla::PodZero(this); } + NewObjectCache() + : entries{} // zeroes out the array + {} + + void purge() { + new (&entries) EntryArray{}; // zeroes out the array + } /* Remove any cached items keyed on moved objects. */ void clearNurseryObjects(JSRuntime* rt); diff --git a/js/src/vm/Runtime.h b/js/src/vm/Runtime.h index 9d9deb5c51b0..3c6e85a08b5f 100644 --- a/js/src/vm/Runtime.h +++ b/js/src/vm/Runtime.h @@ -14,11 +14,11 @@ #include "mozilla/Maybe.h" #include "mozilla/MaybeOneOf.h" #include "mozilla/MemoryReporting.h" -#include "mozilla/PodOperations.h" #include "mozilla/Scoped.h" #include "mozilla/ThreadLocal.h" #include "mozilla/Vector.h" +#include #include #include "builtin/AtomicsObject.h" @@ -1093,20 +1093,21 @@ class MOZ_RAII AutoUnlockGC static MOZ_ALWAYS_INLINE void MakeRangeGCSafe(Value* vec, size_t len) { - mozilla::PodZero(vec, len); + // Don't PodZero here because JS::Value is non-trivial. + for (size_t i = 0; i < len; i++) + vec[i].setDouble(+0.0); } static MOZ_ALWAYS_INLINE void MakeRangeGCSafe(Value* beg, Value* end) { - mozilla::PodZero(beg, end - beg); + MakeRangeGCSafe(beg, end - beg); } static MOZ_ALWAYS_INLINE void MakeRangeGCSafe(jsid* beg, jsid* end) { - for (jsid* id = beg; id != end; ++id) - *id = INT_TO_JSID(0); + std::fill(beg, end, INT_TO_JSID(0)); } static MOZ_ALWAYS_INLINE void @@ -1118,13 +1119,13 @@ MakeRangeGCSafe(jsid* vec, size_t len) static MOZ_ALWAYS_INLINE void MakeRangeGCSafe(Shape** beg, Shape** end) { - mozilla::PodZero(beg, end - beg); + std::fill(beg, end, nullptr); } static MOZ_ALWAYS_INLINE void MakeRangeGCSafe(Shape** vec, size_t len) { - mozilla::PodZero(vec, len); + MakeRangeGCSafe(vec, vec + len); } static MOZ_ALWAYS_INLINE void diff --git a/js/src/vm/StringType.h b/js/src/vm/StringType.h index 10ced03c4169..0615f30d2e66 100644 --- a/js/src/vm/StringType.h +++ b/js/src/vm/StringType.h @@ -8,7 +8,6 @@ #define vm_StringType_h #include "mozilla/MemoryReporting.h" -#include "mozilla/PodOperations.h" #include "mozilla/Range.h" #include "mozilla/TextUtils.h" @@ -1280,19 +1279,17 @@ class StaticStrings static const size_t SMALL_CHAR_LIMIT = 128U; static const size_t NUM_SMALL_CHARS = 64U; - JSAtom* length2StaticTable[NUM_SMALL_CHARS * NUM_SMALL_CHARS]; + JSAtom* length2StaticTable[NUM_SMALL_CHARS * NUM_SMALL_CHARS] = {}; // zeroes public: /* We keep these public for the JITs. */ static const size_t UNIT_STATIC_LIMIT = 256U; - JSAtom* unitStaticTable[UNIT_STATIC_LIMIT]; + JSAtom* unitStaticTable[UNIT_STATIC_LIMIT] = {}; // zeroes static const size_t INT_STATIC_LIMIT = 256U; - JSAtom* intStaticTable[INT_STATIC_LIMIT]; + JSAtom* intStaticTable[INT_STATIC_LIMIT] = {}; // zeroes - StaticStrings() { - mozilla::PodZero(this); - } + StaticStrings() = default; bool init(JSContext* cx); void trace(JSTracer* trc); diff --git a/js/src/vm/TypeInference.h b/js/src/vm/TypeInference.h index 417c55c4160b..6dab7afadc06 100644 --- a/js/src/vm/TypeInference.h +++ b/js/src/vm/TypeInference.h @@ -957,12 +957,10 @@ class PreliminaryObjectArray private: // All objects with the type which have been allocated. The pointers in // this array are weak. - JSObject* objects[COUNT]; + JSObject* objects[COUNT] = {}; // zeroes public: - PreliminaryObjectArray() { - mozilla::PodZero(this); - } + PreliminaryObjectArray() = default; void registerNewObject(PlainObject* res); void unregisterObject(PlainObject* obj); @@ -1056,11 +1054,11 @@ class TypeNewScript private: // Scripted function which this information was computed for. - HeapPtr function_; + HeapPtr function_ = {}; // Any preliminary objects with the type. The analyses are not performed // until this array is cleared. - PreliminaryObjectArray* preliminaryObjects; + PreliminaryObjectArray* preliminaryObjects = nullptr; // After the new script properties analyses have been performed, a template // object to use for newly constructed objects. The shape of this object @@ -1068,7 +1066,7 @@ class TypeNewScript // allocation kind to use. This is null if the new objects have an unboxed // layout, in which case the UnboxedLayout provides the initial structure // of the object. - HeapPtr templateObject_; + HeapPtr templateObject_ = {}; // Order in which definite properties become initialized. We need this in // case the definite properties are invalidated (such as by adding a setter @@ -1078,21 +1076,21 @@ class TypeNewScript // shape. Property assignments in inner frames are preceded by a series of // SETPROP_FRAME entries specifying the stack down to the frame containing // the write. - Initializer* initializerList; + Initializer* initializerList = nullptr; // If there are additional properties found by the acquired properties // analysis which were not found by the definite properties analysis, this // shape contains all such additional properties (plus the definite // properties). When an object of this group acquires this shape, it is // fully initialized and its group can be changed to initializedGroup. - HeapPtr initializedShape_; + HeapPtr initializedShape_ = {}; // Group with definite properties set for all properties found by // both the definite and acquired properties analyses. - HeapPtr initializedGroup_; + HeapPtr initializedGroup_ = {}; public: - TypeNewScript() { mozilla::PodZero(this); } + TypeNewScript() = default; ~TypeNewScript() { js_delete(preliminaryObjects); js_free(initializerList); diff --git a/js/src/wasm/WasmModule.h b/js/src/wasm/WasmModule.h index 5b8fdca8e541..761a76181330 100644 --- a/js/src/wasm/WasmModule.h +++ b/js/src/wasm/WasmModule.h @@ -43,11 +43,11 @@ struct CompileArgs; struct LinkDataTierCacheablePod { - uint32_t outOfBoundsOffset; - uint32_t unalignedAccessOffset; - uint32_t trapOffset; + uint32_t outOfBoundsOffset = 0; + uint32_t unalignedAccessOffset = 0; + uint32_t trapOffset = 0; - LinkDataTierCacheablePod() { mozilla::PodZero(this); } + LinkDataTierCacheablePod() = default; }; struct LinkDataTier : LinkDataTierCacheablePod