Bug 1407822 - Remove BumpChunk::magic_ value when the assertion are removed. r=jandem
authorNicolas B. Pierron <nicolas.b.pierron@mozilla.com>
Fri, 13 Oct 2017 13:44:01 +0000
changeset 386145 eab45e291bc0a1e52f257665a1e3716b3f32c735
parent 386144 7e76eb11f03423e98ad3f4676d25de0e4dd508d3
child 386146 807ccf63a12ff40db6c24565d0716f2306c21ca7
push id32676
push userarchaeopteryx@coole-files.de
push dateFri, 13 Oct 2017 21:38:18 +0000
treeherdermozilla-central@a31334a65a1c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjandem
bugs1407822
milestone58.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 1407822 - Remove BumpChunk::magic_ value when the assertion are removed. r=jandem
js/src/ds/LifoAlloc.h
--- a/js/src/ds/LifoAlloc.h
+++ b/js/src/ds/LifoAlloc.h
@@ -211,37 +211,42 @@ AlignPtr(uint8_t* orig) {
 // This structure is only move-able, but not copyable.
 class BumpChunk : public SingleLinkedListElement<BumpChunk>
 {
   private:
     // Pointer to the last byte allocated in this chunk.
     uint8_t* bump_;
     // Pointer to the last byte available in this chunk.
     const uint8_t* capacity_;
+
+#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
     // Magic number used to check against poisoned values.
     const uintptr_t magic_;
+    static constexpr uintptr_t magicNumber =
+        sizeof(uintptr_t) == 4 ? uintptr_t(0x4c69666f) : uintptr_t(0x4c69666f42756d70);
+#endif
 
     // Byte used for poisoning unused memory after releasing memory.
     static constexpr int undefinedChunkMemory = 0xcd;
-    static constexpr uintptr_t magicNumber =
-        sizeof(uintptr_t) == 4 ? uintptr_t(0x4c69666f) : uintptr_t(0x4c69666f42756d70);
 
     void assertInvariants() {
         MOZ_DIAGNOSTIC_ASSERT(magic_ == magicNumber);
         MOZ_ASSERT(begin() <= end());
         MOZ_ASSERT(end() <= capacity_);
     }
 
     BumpChunk& operator=(const BumpChunk&) = delete;
     BumpChunk(const BumpChunk&) = delete;
 
     explicit BumpChunk(uintptr_t capacity)
       : bump_(begin()),
-        capacity_(base() + capacity),
-        magic_(magicNumber)
+        capacity_(base() + capacity)
+#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
+      , magic_(magicNumber)
+#endif
     {
         // We cannot bake this value inside the BumpChunk class, because
         // sizeof(BumpChunk) can only be computed after the closing brace of the
         // BumpChunk class, or within one of its methods. As a work-around, the
         // reservedSpace value is baked in, and we check that it indeed matches
         // with the space taken by the data of the BumpChunk class, and the
         // alignment of a pointer.
         MOZ_ASSERT(BumpChunk::reservedSpace == AlignBytes(sizeof(BumpChunk), LIFO_ALLOC_ALIGN),