Bug 1325771 - mfbt: Reorder parameters for MOZ_ALIGNED_DECL r=jwalden
☠☠ backed out by c593e06b6cf4 ☠ ☠
authorJohn Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Wed, 03 Jun 2020 16:51:08 +0000
changeset 597815 d69ac62c063fd9a31b7033c960fa67528f780159
parent 597814 24e6299e112dac7dc5891a1d61abc3e4dbbbb689
child 597816 b3e0fb410a1c1bf1881887f049da04a5e473e067
push id13310
push userffxbld-merge
push dateMon, 29 Jun 2020 14:50:06 +0000
treeherdermozilla-beta@15a59a0afa5c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjwalden
bugs1325771
milestone79.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 1325771 - mfbt: Reorder parameters for MOZ_ALIGNED_DECL r=jwalden Currently, MOZ_ALIGNED_DECL uses the order (_type, _align) for its parameters. However, this order makes the code less readable when _type is a larger object like a struct because the value for _align would be at the end of the struct definition. By swapping the order of _type and _align, the alignment value will always be next to the type name, regardless how far the definition of _type extends. Depends on D77287 Differential Revision: https://phabricator.services.mozilla.com/D77288
js/src/jsapi-tests/testAtomicOperations.cpp
js/src/wasm/WasmTypes.h
mfbt/Alignment.h
--- a/js/src/jsapi-tests/testAtomicOperations.cpp
+++ b/js/src/jsapi-tests/testAtomicOperations.cpp
@@ -80,18 +80,18 @@ END_TEST(testAtomicFence)
 
 // These tests for the atomic load and store primitives ascertain that the
 // primitives are defined and that they load and store the values they should,
 // but not that the primitives are actually atomic wrt to the memory subsystem.
 
 // Memory for testing atomics.  This must be aligned to the natural alignment of
 // the type we're testing; for now, use 8-byte alignment for all.
 
-MOZ_ALIGNED_DECL(static uint8_t atomicMem[8], 8);
-MOZ_ALIGNED_DECL(static uint8_t atomicMem2[8], 8);
+MOZ_ALIGNED_DECL(8, static uint8_t atomicMem[8]);
+MOZ_ALIGNED_DECL(8, static uint8_t atomicMem2[8]);
 
 // T is the primitive type we're testing, and A and B are references to constant
 // bindings holding values of that type.
 //
 // No bytes of A and B should be 0 or FF.  A+B and A-B must not overflow.
 
 #define ATOMIC_TESTS(T, A, B)                                           \
   T* q = (T*)hidePointerValue((void*)atomicMem);                        \
--- a/js/src/wasm/WasmTypes.h
+++ b/js/src/wasm/WasmTypes.h
@@ -2869,17 +2869,17 @@ struct TlsData {
 
   // When compiling with tiering, the jumpTable has one entry for each
   // baseline-compiled function.
   void** jumpTable;
 
   // The globalArea must be the last field.  Globals for the module start here
   // and are inline in this structure.  16-byte alignment is required for SIMD
   // data.
-  MOZ_ALIGNED_DECL(char globalArea, 16);
+  MOZ_ALIGNED_DECL(16, char globalArea);
 };
 
 static const size_t TlsDataAlign = 16;  // = Simd128DataSize
 static_assert(offsetof(TlsData, globalArea) % TlsDataAlign == 0, "aligned");
 
 struct TlsDataDeleter {
   void operator()(TlsData* tlsData) { js_free(tlsData->allocatedBase); }
 };
--- a/mfbt/Alignment.h
+++ b/mfbt/Alignment.h
@@ -57,28 +57,28 @@ struct AlignasHelper {
  */
 #define MOZ_ALIGNAS_IN_STRUCT(T) alignas(mozilla::detail::AlignasHelper<T>)
 
 /*
  * Declare the MOZ_ALIGNED_DECL macro for declaring aligned types.
  *
  * For instance,
  *
- *   MOZ_ALIGNED_DECL(char arr[2], 8);
+ *   MOZ_ALIGNED_DECL(8, char arr[2]);
  *
  * will declare a two-character array |arr| aligned to 8 bytes.
  */
 
 #if defined(__GNUC__)
-#  define MOZ_ALIGNED_DECL(_type, _align) _type __attribute__((aligned(_align)))
+#  define MOZ_ALIGNED_DECL(_align, _type) _type __attribute__((aligned(_align)))
 #elif defined(_MSC_VER)
-#  define MOZ_ALIGNED_DECL(_type, _align) __declspec(align(_align)) _type
+#  define MOZ_ALIGNED_DECL(_align, _type) __declspec(align(_align)) _type
 #else
 #  warning "We don't know how to align variables on this compiler."
-#  define MOZ_ALIGNED_DECL(_type, _align) _type
+#  define MOZ_ALIGNED_DECL(_align, _type) _type
 #endif
 
 /*
  * AlignedElem<N> is a structure whose alignment is guaranteed to be at least N
  * bytes.
  *
  * We support 1, 2, 4, 8, and 16-byte alignment.
  */
@@ -87,37 +87,37 @@ struct AlignedElem;
 
 /*
  * We have to specialize this template because GCC doesn't like
  * __attribute__((aligned(foo))) where foo is a template parameter.
  */
 
 template <>
 struct AlignedElem<1> {
-  MOZ_ALIGNED_DECL(uint8_t elem, 1);
+  MOZ_ALIGNED_DECL(1, uint8_t elem);
 };
 
 template <>
 struct AlignedElem<2> {
-  MOZ_ALIGNED_DECL(uint8_t elem, 2);
+  MOZ_ALIGNED_DECL(2, uint8_t elem);
 };
 
 template <>
 struct AlignedElem<4> {
-  MOZ_ALIGNED_DECL(uint8_t elem, 4);
+  MOZ_ALIGNED_DECL(4, uint8_t elem);
 };
 
 template <>
 struct AlignedElem<8> {
-  MOZ_ALIGNED_DECL(uint8_t elem, 8);
+  MOZ_ALIGNED_DECL(8, uint8_t elem);
 };
 
 template <>
 struct AlignedElem<16> {
-  MOZ_ALIGNED_DECL(uint8_t elem, 16);
+  MOZ_ALIGNED_DECL(16, uint8_t elem);
 };
 
 template <typename T>
 struct MOZ_INHERIT_TYPE_ANNOTATIONS_FROM_TEMPLATE_ARGS AlignedStorage2 {
   union U {
     char mBytes[sizeof(T)];
     uint64_t mDummy;
   } u;