Bug 904110 - Move alignment features out of Util.h into a new header; r=Waldo
authorMs2ger <ms2ger@gmail.com>
Wed, 14 Aug 2013 09:00:52 +0200
changeset 150479 ce2910a5da0094d7683e337e6cb466bee00ca34d
parent 150478 7904d4264954c0ce8ae5f62c91b62815324ba649
child 150480 4aa0ac960f13bf8e8966cfce9d3a4153dde7d05f
push idunknown
push userunknown
push dateunknown
reviewersWaldo
bugs904110
milestone26.0a1
Bug 904110 - Move alignment features out of Util.h into a new header; r=Waldo
content/canvas/src/CanvasRenderingContext2D.cpp
dom/bindings/BindingUtils.h
gfx/thebes/gfxContext.cpp
gfx/thebes/gfxPattern.h
image/src/ClippedImage.h
ipc/chromium/src/base/pickle.cc
js/public/HashTable.h
js/src/jit/BaselineFrameInfo.h
js/src/jit/RegisterSets.h
js/src/jit/shared/CodeGenerator-shared.h
js/src/vm/TypedArrayObject.cpp
js/xpconnect/src/xpcprivate.h
mfbt/Alignment.h
mfbt/Util.h
mfbt/Vector.h
mfbt/exported_headers.mk
mozglue/build/BionicGlue.cpp
netwerk/base/src/nsMediaFragmentURIParser.h
netwerk/wifi/nsWifiAccessPoint.h
tools/profiler/JSCustomObjectBuilder.cpp
xpcom/glue/nsIClassInfoImpl.h
xpcom/glue/nsTArray.h
--- a/content/canvas/src/CanvasRenderingContext2D.cpp
+++ b/content/canvas/src/CanvasRenderingContext2D.cpp
@@ -68,16 +68,17 @@
 #include "nsStyleUtil.h"
 #include "CanvasImageCache.h"
 
 #include <algorithm>
 
 #include "jsapi.h"
 #include "jsfriendapi.h"
 
+#include "mozilla/Alignment.h"
 #include "mozilla/Assertions.h"
 #include "mozilla/CheckedInt.h"
 #include "mozilla/dom/ContentParent.h"
 #include "mozilla/dom/ImageData.h"
 #include "mozilla/dom/PBrowserParent.h"
 #include "mozilla/dom/TypedArray.h"
 #include "mozilla/gfx/2D.h"
 #include "mozilla/gfx/PathHelpers.h"
--- a/dom/bindings/BindingUtils.h
+++ b/dom/bindings/BindingUtils.h
@@ -6,25 +6,27 @@
 
 #ifndef mozilla_dom_BindingUtils_h__
 #define mozilla_dom_BindingUtils_h__
 
 #include <algorithm>
 
 #include "jsfriendapi.h"
 #include "jswrapper.h"
+#include "mozilla/Alignment.h"
 #include "mozilla/dom/BindingDeclarations.h"
 #include "mozilla/dom/CallbackObject.h"
 #include "mozilla/dom/DOMJSClass.h"
 #include "mozilla/dom/DOMJSProxyHandler.h"
 #include "mozilla/dom/NonRefcountedDOMObject.h"
 #include "mozilla/dom/Nullable.h"
 #include "mozilla/dom/workers/Workers.h"
 #include "mozilla/ErrorResult.h"
 #include "mozilla/Likely.h"
+#include "mozilla/Util.h"
 #include "nsCycleCollector.h"
 #include "nsIXPConnect.h"
 #include "nsTraceRefcnt.h"
 #include "qsObjectHelper.h"
 #include "xpcpublic.h"
 
 #include "nsWrapperCacheInlines.h"
 
--- a/gfx/thebes/gfxContext.cpp
+++ b/gfx/thebes/gfxContext.cpp
@@ -3,16 +3,17 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifdef _MSC_VER
 #define _USE_MATH_DEFINES
 #endif
 #include <math.h>
 
+#include "mozilla/Alignment.h"
 #include "mozilla/Constants.h"
 
 #include "cairo.h"
 
 #include "gfxContext.h"
 
 #include "gfxColor.h"
 #include "gfxMatrix.h"
--- a/gfx/thebes/gfxPattern.h
+++ b/gfx/thebes/gfxPattern.h
@@ -7,18 +7,18 @@
 #define GFX_PATTERN_H
 
 #include "gfxTypes.h"
 
 #include "gfxColor.h"
 #include "gfxMatrix.h"
 #include "nsISupportsImpl.h"
 #include "nsAutoPtr.h"
+#include "mozilla/Alignment.h"
 #include "mozilla/gfx/2D.h"
-#include "mozilla/Util.h"
 
 class gfxContext;
 class gfxASurface;
 typedef struct _cairo_pattern cairo_pattern_t;
 
 
 class gfxPattern {
     NS_INLINE_DECL_REFCOUNTING(gfxPattern)
--- a/image/src/ClippedImage.h
+++ b/image/src/ClippedImage.h
@@ -2,16 +2,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef MOZILLA_IMAGELIB_CLIPPEDIMAGE_H_
 #define MOZILLA_IMAGELIB_CLIPPEDIMAGE_H_
 
 #include "ImageWrapper.h"
+#include "mozilla/Util.h" // for Maybe
 
 namespace mozilla {
 namespace image {
 
 class ClippedImageCachedSurface;
 class DrawSingleTileCallback;
 
 /**
--- a/ipc/chromium/src/base/pickle.cc
+++ b/ipc/chromium/src/base/pickle.cc
@@ -1,17 +1,17 @@
 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
 #include "base/pickle.h"
 
+#include "mozilla/Alignment.h"
 #include "mozilla/Endian.h"
 #include "mozilla/TypeTraits.h"
-#include "mozilla/Util.h"
 
 #include <stdlib.h>
 
 #include <limits>
 #include <string>
 #include <algorithm>
 
 //------------------------------------------------------------------------------
--- a/js/public/HashTable.h
+++ b/js/public/HashTable.h
@@ -2,27 +2,27 @@
  * vim: set ts=8 sts=4 et sw=4 tw=99:
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef js_HashTable_h
 #define js_HashTable_h
 
+#include "mozilla/Alignment.h"
 #include "mozilla/Assertions.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/Casting.h"
 #include "mozilla/DebugOnly.h"
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/Move.h"
 #include "mozilla/PodOperations.h"
 #include "mozilla/ReentrancyGuard.h"
 #include "mozilla/TemplateLib.h"
 #include "mozilla/TypeTraits.h"
-#include "mozilla/Util.h"
 
 #include "js/Utility.h"
 
 namespace js {
 
 class TempAllocPolicy;
 template <class> struct DefaultHasher;
 template <class, class> class HashMapEntry;
--- a/js/src/jit/BaselineFrameInfo.h
+++ b/js/src/jit/BaselineFrameInfo.h
@@ -4,16 +4,18 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef jit_BaselineFrameInfo_h
 #define jit_BaselineFrameInfo_h
 
 #ifdef JS_ION
 
+#include "mozilla/Alignment.h"
+
 #include "jit/BaselineFrame.h"
 #include "jit/BaselineJIT.h"
 #include "jit/BaselineRegisters.h"
 #include "jit/BytecodeAnalysis.h"
 #include "jit/FixedList.h"
 #include "jit/IonMacroAssembler.h"
 
 namespace js {
--- a/js/src/jit/RegisterSets.h
+++ b/js/src/jit/RegisterSets.h
@@ -2,16 +2,17 @@
  * vim: set ts=8 sts=4 et sw=4 tw=99:
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef jit_RegisterSets_h
 #define jit_RegisterSets_h
 
+#include "mozilla/Alignment.h"
 #include "mozilla/MathAlgorithms.h"
 
 #include "jit/IonAllocPolicy.h"
 #include "jit/Registers.h"
 
 namespace js {
 namespace ion {
 
--- a/js/src/jit/shared/CodeGenerator-shared.h
+++ b/js/src/jit/shared/CodeGenerator-shared.h
@@ -2,16 +2,19 @@
  * vim: set ts=8 sts=4 et sw=4 tw=99:
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef jit_shared_CodeGenerator_shared_h
 #define jit_shared_CodeGenerator_shared_h
 
+#include "mozilla/Alignment.h"
+#include "mozilla/Util.h"
+
 #include "jit/IonCaches.h"
 #include "jit/IonFrames.h"
 #include "jit/IonMacroAssembler.h"
 #include "jit/LIR.h"
 #include "jit/MIR.h"
 #include "jit/MIRGraph.h"
 #include "jit/Safepoints.h"
 #include "jit/SnapshotWriter.h"
--- a/js/src/vm/TypedArrayObject.cpp
+++ b/js/src/vm/TypedArrayObject.cpp
@@ -1,16 +1,17 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  * vim: set ts=8 sts=4 et sw=4 tw=99:
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "vm/TypedArrayObject.h"
 
+#include "mozilla/Alignment.h"
 #include "mozilla/FloatingPoint.h"
 #include "mozilla/PodOperations.h"
 
 #include <string.h>
 #ifndef XP_WIN
 # include <sys/mman.h>
 #endif
 
--- a/js/xpconnect/src/xpcprivate.h
+++ b/js/xpconnect/src/xpcprivate.h
@@ -70,19 +70,24 @@
  * given scriptable info.
  */
 
 /* All the XPConnect private declarations - only include locally. */
 
 #ifndef xpcprivate_h___
 #define xpcprivate_h___
 
+#include "mozilla/Alignment.h"
 #include "mozilla/Assertions.h"
 #include "mozilla/Attributes.h"
+#include "mozilla/CycleCollectedJSRuntime.h"
+#include "mozilla/GuardObjects.h"
 #include "mozilla/MemoryReporting.h"
+#include "mozilla/Mutex.h"
+#include "mozilla/ReentrantMonitor.h"
 #include "mozilla/Util.h"
 
 #include <math.h>
 #include <stdarg.h>
 #include <stdint.h>
 #include <stdlib.h>
 #include <string.h>
 
@@ -95,17 +100,16 @@
 #include "jsfriendapi.h"
 #include "js/HeapAPI.h"
 #include "jswrapper.h"
 #include "nscore.h"
 #include "nsXPCOM.h"
 #include "nsAutoPtr.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsCycleCollectorUtils.h"
-#include "mozilla/CycleCollectedJSRuntime.h"
 #include "nsDebug.h"
 #include "nsISupports.h"
 #include "nsIServiceManager.h"
 #include "nsIClassInfoImpl.h"
 #include "nsIComponentManager.h"
 #include "nsIComponentRegistrar.h"
 #include "nsISupportsPrimitives.h"
 #include "nsMemory.h"
@@ -127,19 +131,16 @@
 #include "prclist.h"
 #include "prcvar.h"
 #include "nsString.h"
 #include "nsReadableUtils.h"
 #include "nsXPIDLString.h"
 #include "nsAutoJSValHolder.h"
 
 #include "js/HashTable.h"
-#include "mozilla/GuardObjects.h"
-#include "mozilla/ReentrantMonitor.h"
-#include "mozilla/Mutex.h"
 
 #include "nsThreadUtils.h"
 #include "nsIJSEngineTelemetryStats.h"
 
 #include "nsIConsoleService.h"
 #include "nsIScriptError.h"
 #include "nsIExceptionService.h"
 
new file mode 100644
--- /dev/null
+++ b/mfbt/Alignment.h
@@ -0,0 +1,137 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/* Functionality related to memory alignment. */
+
+#ifndef mozilla_Alignment_h
+#define mozilla_Alignment_h
+
+#include <stddef.h>
+#include <stdint.h>
+
+namespace mozilla {
+
+/*
+ * This class, and the corresponding macro MOZ_ALIGNOF, figures out how many
+ * bytes of alignment a given type needs.
+ */
+template<typename T>
+class AlignmentFinder
+{
+    struct Aligner
+    {
+        char c;
+        T t;
+    };
+
+  public:
+    static const size_t alignment = sizeof(Aligner) - sizeof(T);
+};
+
+#define MOZ_ALIGNOF(T) mozilla::AlignmentFinder<T>::alignment
+
+/*
+ * Declare the MOZ_ALIGNED_DECL macro for declaring aligned types.
+ *
+ * For instance,
+ *
+ *   MOZ_ALIGNED_DECL(char arr[2], 8);
+ *
+ * will declare a two-character array |arr| aligned to 8 bytes.
+ */
+
+#if defined(__GNUC__)
+#  define MOZ_ALIGNED_DECL(_type, _align) \
+     _type __attribute__((aligned(_align)))
+#elif defined(_MSC_VER)
+#  define MOZ_ALIGNED_DECL(_type, _align) \
+     __declspec(align(_align)) _type
+#else
+#  warning "We don't know how to align variables on this compiler."
+#  define MOZ_ALIGNED_DECL(_type, _align) _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-bit alignment.
+ */
+template<size_t Align>
+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);
+};
+
+template<>
+struct AlignedElem<2>
+{
+    MOZ_ALIGNED_DECL(uint8_t elem, 2);
+};
+
+template<>
+struct AlignedElem<4>
+{
+    MOZ_ALIGNED_DECL(uint8_t elem, 4);
+};
+
+template<>
+struct AlignedElem<8>
+{
+    MOZ_ALIGNED_DECL(uint8_t elem, 8);
+};
+
+template<>
+struct AlignedElem<16>
+{
+    MOZ_ALIGNED_DECL(uint8_t elem, 16);
+};
+
+/*
+ * This utility pales in comparison to Boost's aligned_storage. The utility
+ * simply assumes that uint64_t is enough alignment for anyone. This may need
+ * to be extended one day...
+ *
+ * As an important side effect, pulling the storage into this template is
+ * enough obfuscation to confuse gcc's strict-aliasing analysis into not giving
+ * false negatives when we cast from the char buffer to whatever type we've
+ * constructed using the bytes.
+ */
+template<size_t Nbytes>
+struct AlignedStorage
+{
+    union U {
+      char bytes[Nbytes];
+      uint64_t _;
+    } u;
+
+    const void* addr() const { return u.bytes; }
+    void* addr() { return u.bytes; }
+};
+
+template<typename T>
+struct AlignedStorage2
+{
+    union U {
+      char bytes[sizeof(T)];
+      uint64_t _;
+    } u;
+
+    const T* addr() const { return reinterpret_cast<const T*>(u.bytes); }
+    T* addr() { return static_cast<T*>(static_cast<void*>(u.bytes)); }
+};
+
+} /* namespace mozilla */
+
+#endif /* mozilla_Alignment_h */
--- a/mfbt/Util.h
+++ b/mfbt/Util.h
@@ -13,135 +13,19 @@
 #define mozilla_Util_h
 
 #include "mozilla/Assertions.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/Types.h"
 
 #ifdef __cplusplus
 
-namespace mozilla {
-
-/*
- * This class, and the corresponding macro MOZ_ALIGNOF, figure out how many 
- * bytes of alignment a given type needs.
- */
-template<class T>
-class AlignmentFinder
-{
-    struct Aligner
-    {
-        char c;
-        T t;
-    };
-
-  public:
-    static const size_t alignment = sizeof(Aligner) - sizeof(T);
-};
-
-#define MOZ_ALIGNOF(T) mozilla::AlignmentFinder<T>::alignment
-
-/*
- * Declare the MOZ_ALIGNED_DECL macro for declaring aligned types.
- *
- * For instance,
- *
- *   MOZ_ALIGNED_DECL(char arr[2], 8);
- *
- * will declare a two-character array |arr| aligned to 8 bytes.
- */
-
-#if defined(__GNUC__)
-#  define MOZ_ALIGNED_DECL(_type, _align) \
-     _type __attribute__((aligned(_align)))
-#elif defined(_MSC_VER)
-#  define MOZ_ALIGNED_DECL(_type, _align) \
-     __declspec(align(_align)) _type
-#else
-#  warning "We don't know how to align variables on this compiler."
-#  define MOZ_ALIGNED_DECL(_type, _align) _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-bit alignment.
- */
-template<size_t align>
-struct AlignedElem;
-
-/*
- * We have to specialize this template because GCC doesn't like __attribute__((aligned(foo))) where
- * foo is a template parameter.
- */
+#include "mozilla/Alignment.h"
 
-template<>
-struct AlignedElem<1>
-{
-    MOZ_ALIGNED_DECL(uint8_t elem, 1);
-};
-
-template<>
-struct AlignedElem<2>
-{
-    MOZ_ALIGNED_DECL(uint8_t elem, 2);
-};
-
-template<>
-struct AlignedElem<4>
-{
-    MOZ_ALIGNED_DECL(uint8_t elem, 4);
-};
-
-template<>
-struct AlignedElem<8>
-{
-    MOZ_ALIGNED_DECL(uint8_t elem, 8);
-};
-
-template<>
-struct AlignedElem<16>
-{
-    MOZ_ALIGNED_DECL(uint8_t elem, 16);
-};
-
-/*
- * This utility pales in comparison to Boost's aligned_storage. The utility
- * simply assumes that uint64_t is enough alignment for anyone. This may need
- * to be extended one day...
- *
- * As an important side effect, pulling the storage into this template is
- * enough obfuscation to confuse gcc's strict-aliasing analysis into not giving
- * false negatives when we cast from the char buffer to whatever type we've
- * constructed using the bytes.
- */
-template<size_t nbytes>
-struct AlignedStorage
-{
-    union U {
-      char bytes[nbytes];
-      uint64_t _;
-    } u;
-
-    const void* addr() const { return u.bytes; }
-    void* addr() { return u.bytes; }
-};
-
-template<class T>
-struct AlignedStorage2
-{
-    union U {
-      char bytes[sizeof(T)];
-      uint64_t _;
-    } u;
-
-    const T* addr() const { return reinterpret_cast<const T*>(u.bytes); }
-    T* addr() { return static_cast<T*>(static_cast<void*>(u.bytes)); }
-};
+namespace mozilla {
 
 /*
  * Small utility for lazily constructing objects without using dynamic storage.
  * When a Maybe<T> is constructed, it is |empty()|, i.e., no value of T has
  * been constructed and no T destructor will be called when the Maybe<T> is
  * destroyed. Upon calling |construct|, a T object will be constructed with the
  * given arguments and that object will be destroyed when the owning Maybe<T>
  * is destroyed.
--- a/mfbt/Vector.h
+++ b/mfbt/Vector.h
@@ -4,27 +4,28 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /* A type/length-parametrized vector class. */
 
 #ifndef mozilla_Vector_h
 #define mozilla_Vector_h
 
+#include "mozilla/Alignment.h"
 #include "mozilla/AllocPolicy.h"
 #include "mozilla/Assertions.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/MathAlgorithms.h"
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/Move.h"
 #include "mozilla/NullPtr.h"
 #include "mozilla/ReentrancyGuard.h"
 #include "mozilla/TemplateLib.h"
 #include "mozilla/TypeTraits.h"
-#include "mozilla/Util.h"
+#include "mozilla/Util.h" // for PointerRangeSize
 
 #include <new> // for placement new
 
 /* Silence dire "bugs in previous versions of MSVC have been fixed" warnings */
 #ifdef _MSC_VER
 #pragma warning(push)
 #pragma warning(disable:4345)
 #endif
--- a/mfbt/exported_headers.mk
+++ b/mfbt/exported_headers.mk
@@ -4,16 +4,17 @@
 
 # This file defines the headers exported by mfbt.  It is included by mfbt
 # itself and by the JS engine, which, when built standalone, must install
 # mfbt's exported headers itself.
 
 EXPORTS_NAMESPACES += mozilla
 
 EXPORTS_mozilla += \
+  Alignment.h \
   AllocPolicy.h \
   Array.h \
   Assertions.h \
   Atomics.h \
   Attributes.h \
   BloomFilter.h \
   Casting.h \
   Char16.h \
--- a/mozglue/build/BionicGlue.cpp
+++ b/mozglue/build/BionicGlue.cpp
@@ -4,17 +4,18 @@
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include <pthread.h>
 #include <string.h>
 #include <stdlib.h>
 #include <time.h>
 #include <unistd.h>
 #include <android/log.h>
-#include <mozilla/Util.h>
+
+#include "mozilla/Alignment.h"
 
 #include <vector>
 
 #define NS_EXPORT __attribute__ ((visibility("default")))
 
 #if ANDROID_VERSION < 17 || defined(MOZ_WIDGET_ANDROID)
 /* Android doesn't have pthread_atfork(), so we need to use our own. */
 struct AtForkFuncs {
--- a/netwerk/base/src/nsMediaFragmentURIParser.h
+++ b/netwerk/base/src/nsMediaFragmentURIParser.h
@@ -1,16 +1,17 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim:set ts=2 sw=2 sts=2 et cindent: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 #if !defined(nsMediaFragmentURIParser_h__)
 #define nsMediaFragmentURIParser_h__
 
+#include "mozilla/Util.h" // Maybe
 #include "nsIURI.h"
 #include "nsString.h"
 #include "nsRect.h"
 
 // Class to handle parsing of a W3C media fragment URI as per
 // spec at: http://www.w3.org/TR/media-frags/
 // Only the temporaral URI portion of the spec is implemented.
 // To use:
--- a/netwerk/wifi/nsWifiAccessPoint.h
+++ b/netwerk/wifi/nsWifiAccessPoint.h
@@ -3,16 +3,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsWifiMonitor.h"
 #include "nsIWifiAccessPoint.h"
 
 #include "nsString.h"
 #include "nsCOMArray.h"
 #include "mozilla/Attributes.h"
+#include "mozilla/Util.h" // ArrayLength
 
 #ifndef __nsWifiAccessPoint__
 #define __nsWifiAccessPoint__
 
 class nsWifiAccessPoint MOZ_FINAL : public nsIWifiAccessPoint
 {
 public:
   NS_DECL_THREADSAFE_ISUPPORTS
--- a/tools/profiler/JSCustomObjectBuilder.cpp
+++ b/tools/profiler/JSCustomObjectBuilder.cpp
@@ -1,15 +1,16 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "JSCustomObjectBuilder.h"
 
+#include "mozilla/Util.h" // for ArrayLength
 #include "nsDataHashtable.h"
 #include "nsStringGlue.h"
 #include "nsTArray.h"
 #include "nsUTF8Utils.h"
 
 #if _MSC_VER
  #define snprintf _snprintf
 #endif
--- a/xpcom/glue/nsIClassInfoImpl.h
+++ b/xpcom/glue/nsIClassInfoImpl.h
@@ -1,18 +1,18 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef nsIClassInfoImpl_h__
 #define nsIClassInfoImpl_h__
 
+#include "mozilla/Alignment.h"
 #include "nsIClassInfo.h"
 #include "nsISupportsImpl.h"
-#include "mozilla/Util.h"
 
 #include <new>
 
 /**
  * This header file provides macros which help you make your class implement
  * nsIClassInfo.  Implementing nsIClassInfo is particularly helpful if you have
  * a C++ class which implements multiple interfaces and which you access from
  * JavaScript.  If that class implements nsIClassInfo, the JavaScript code
--- a/xpcom/glue/nsTArray.h
+++ b/xpcom/glue/nsTArray.h
@@ -3,20 +3,20 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef nsTArray_h__
 #define nsTArray_h__
 
 #include "nsTArrayForwardDeclare.h"
+#include "mozilla/Alignment.h"
 #include "mozilla/Assertions.h"
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/TypeTraits.h"
-#include "mozilla/Util.h"
 
 #include <string.h>
 
 #include "nsCycleCollectionNoteChild.h"
 #include "nsAlgorithm.h"
 #include "nscore.h"
 #include "nsQuickSort.h"
 #include "nsDebug.h"