Bug 1319971: Re-work some static_asserts to get VS2017 compiling. r=luke, a=IanN CLOSED TREE DONTBUILD SEAMONKEY_2_49_ESR_RELBRANCH
authorDavid Major <dmajor@mozilla.com>
Thu, 09 Mar 2017 15:13:08 +1300
branchSEAMONKEY_2_49_ESR_RELBRANCH
changeset 357480 3d860232518da33642c50490510d6569b4057ce8
parent 357479 2a08e3bf9014fdfcd14fb973579ea3bc284408b4
child 357481 76d781cfe6ea057c5042c6ed959cecec8ee59fe1
push id7834
push userfrgrahl@gmx.net
push dateSun, 13 Jan 2019 12:17:02 +0000
treeherdermozilla-esr52@6e4ad8a8f2e8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersluke, IanN
bugs1319971
milestone52.9.1
Bug 1319971: Re-work some static_asserts to get VS2017 compiling. r=luke, a=IanN CLOSED TREE DONTBUILD mozilla-esr52 SEAMONKEY_2_49_ESR_RELBRANCH VS2017 doesn't consider functions like Foo::offsetOfBar() to be constexpr, so it refuses to allow them in static_asserts.
js/src/ds/OrderedHashTable.h
js/src/jit/CodeGenerator.cpp
--- a/js/src/ds/OrderedHashTable.h
+++ b/js/src/ds/OrderedHashTable.h
@@ -528,16 +528,18 @@ class OrderedHashTable
 
     static size_t offsetOfDataLength() {
         return offsetof(OrderedHashTable, dataLength);
     }
     static size_t offsetOfData() {
         return offsetof(OrderedHashTable, data);
     }
     static constexpr size_t offsetOfDataElement() {
+        static_assert(offsetof(Data, element) == 0,
+                      "RangeFront and RangePopFront depend on offsetof(Data, element) being 0");
         return offsetof(Data, element);
     }
     static constexpr size_t sizeofData() {
         return sizeof(Data);
     }
 
   private:
     /* Logarithm base 2 of the number of buckets in the hash table initially. */
--- a/js/src/jit/CodeGenerator.cpp
+++ b/js/src/jit/CodeGenerator.cpp
@@ -6233,31 +6233,31 @@ RangeFront(MacroAssembler&, Register, Re
 
 template <>
 void
 RangeFront<ValueMap>(MacroAssembler& masm, Register range, Register i, Register front)
 {
     masm.loadPtr(Address(range, ValueMap::Range::offsetOfHashTable()), front);
     masm.loadPtr(Address(front, ValueMap::offsetOfImplData()), front);
 
-    static_assert(ValueMap::offsetOfImplDataElement() == 0, "offsetof(Data, element) is 0");
+    MOZ_ASSERT(ValueMap::offsetOfImplDataElement() == 0, "offsetof(Data, element) is 0");
     static_assert(ValueMap::sizeofImplData() == 24, "sizeof(Data) is 24");
     masm.mulBy3(i, i);
     masm.lshiftPtr(Imm32(3), i);
     masm.addPtr(i, front);
 }
 
 template <>
 void
 RangeFront<ValueSet>(MacroAssembler& masm, Register range, Register i, Register front)
 {
     masm.loadPtr(Address(range, ValueSet::Range::offsetOfHashTable()), front);
     masm.loadPtr(Address(front, ValueSet::offsetOfImplData()), front);
 
-    static_assert(ValueSet::offsetOfImplDataElement() == 0, "offsetof(Data, element) is 0");
+    MOZ_ASSERT(ValueSet::offsetOfImplDataElement() == 0, "offsetof(Data, element) is 0");
     static_assert(ValueSet::sizeofImplData() == 16, "sizeof(Data) is 16");
     masm.lshiftPtr(Imm32(4), i);
     masm.addPtr(i, front);
 }
 
 template <class OrderedHashTable>
 static void
 RangePopFront(MacroAssembler& masm, Register range, Register front, Register dataLength,
@@ -6271,17 +6271,17 @@ RangePopFront(MacroAssembler& masm, Regi
     masm.add32(Imm32(1), i);
 
     Label done, seek;
     masm.bind(&seek);
     masm.branch32(Assembler::AboveOrEqual, i, dataLength, &done);
 
     // We can add sizeof(Data) to |front| to select the next element, because
     // |front| and |range.ht.data[i]| point to the same location.
-    static_assert(OrderedHashTable::offsetOfImplDataElement() == 0, "offsetof(Data, element) is 0");
+    MOZ_ASSERT(OrderedHashTable::offsetOfImplDataElement() == 0, "offsetof(Data, element) is 0");
     masm.addPtr(Imm32(OrderedHashTable::sizeofImplData()), front);
 
     masm.branchTestMagic(Assembler::NotEqual, Address(front, OrderedHashTable::offsetOfEntryKey()),
                          JS_HASH_KEY_EMPTY, &done);
 
     masm.add32(Imm32(1), i);
     masm.jump(&seek);