Bug 898916 - Properly align statically allocated classinfo objects. r=bsmedberg
authorMike Hommey <mh+mozilla@glandium.org>
Tue, 30 Jul 2013 08:57:28 +0900
changeset 152762 7506c6ee2e8b25f5893dc23e1b392ec5828ba545
parent 152761 f92a6dcf7361edd3ef7ea7d18c82cf2140bc81cc
child 152763 09fa1683d16a33f08562545002245bf45527b219
push id2859
push userakeybl@mozilla.com
push dateMon, 16 Sep 2013 19:14:59 +0000
treeherdermozilla-beta@87d3c51cd2bf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbsmedberg
bugs898916
milestone25.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 898916 - Properly align statically allocated classinfo objects. r=bsmedberg
xpcom/glue/nsIClassInfoImpl.h
--- a/xpcom/glue/nsIClassInfoImpl.h
+++ b/xpcom/glue/nsIClassInfoImpl.h
@@ -2,16 +2,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/. */
 
 #ifndef nsIClassInfoImpl_h__
 #define nsIClassInfoImpl_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
@@ -114,23 +115,23 @@ private:
 #define NS_IMPL_CLASSINFO(_class, _getlanguagehelper, _flags, _cid)     \
   NS_DECL_CI_INTERFACE_GETTER(_class)                                   \
   static const GenericClassInfo::ClassInfoData k##_class##ClassInfoData = { \
     NS_CI_INTERFACE_GETTER_NAME(_class),                                \
     _getlanguagehelper,                                                 \
     _flags | nsIClassInfo::SINGLETON_CLASSINFO,                         \
     _cid,                                                               \
   };                                                                    \
-  static char k##_class##ClassInfoDataPlace[sizeof(GenericClassInfo)];  \
+  mozilla::AlignedStorage2<GenericClassInfo> k##_class##ClassInfoDataPlace;   \
   nsIClassInfo* NS_CLASSINFO_NAME(_class) = NULL;
 
 #define NS_IMPL_QUERY_CLASSINFO(_class)                                       \
   if ( aIID.Equals(NS_GET_IID(nsIClassInfo)) ) {                              \
     if (!NS_CLASSINFO_NAME(_class))                                           \
-      NS_CLASSINFO_NAME(_class) = new (k##_class##ClassInfoDataPlace)         \
+      NS_CLASSINFO_NAME(_class) = new (k##_class##ClassInfoDataPlace.addr())  \
         GenericClassInfo(&k##_class##ClassInfoData);                          \
     foundInterface = NS_CLASSINFO_NAME(_class);                               \
   } else
 
 #define NS_CLASSINFO_HELPER_BEGIN(_class, _c)                                 \
 NS_IMETHODIMP                                                                 \
 NS_CI_INTERFACE_GETTER_NAME(_class)(uint32_t *count, nsIID ***array)          \
 {                                                                             \