Backout changeset 9e38c5518605, fc59bd8d49ba, d0ba1abde985, and acf91f25f228 (bugs 796119, 796279, and 797106) because of broken reftests on 64-bit platforms
authorEhsan Akhgari <ehsan@mozilla.com>
Tue, 02 Oct 2012 23:16:36 -0400
changeset 109104 402e2cf6602db00c2b1ccb0e1e062986f80a4804
parent 109089 acf91f25f22849bc97ad5b8126315f17df146691
child 109105 c43aeb9b844478c69d66d9795ca5341cb72277e7
push id82
push usershu@rfrn.org
push dateFri, 05 Oct 2012 13:20:22 +0000
bugs796119, 796279, 797106
milestone18.0a1
backs out9e38c551860548f77d289ac26baf1e0ee2ac0330
Backout changeset 9e38c5518605, fc59bd8d49ba, d0ba1abde985, and acf91f25f228 (bugs 796119, 796279, and 797106) because of broken reftests on 64-bit platforms
content/base/src/nsTextFragment.cpp
content/base/src/nsTextFragmentImpl.h
content/base/src/nsTextFragmentSSE2.cpp
layout/style/nsCSSProps.cpp
xpcom/base/nsStackWalk.h
xpcom/build/BinaryPath.h
xpcom/build/nsXULAppAPI.h
xpcom/ds/nsCRT.h
xpcom/ds/nsHashtable.h
xpcom/ds/nsStringEnumerator.cpp
xpcom/glue/nsDebug.h
xpcom/glue/nsQuickSort.cpp
xpcom/glue/nsQuickSort.h
xpcom/glue/nsTArray.h
xpcom/glue/nsTHashtable.h
xpcom/glue/pldhash.h
xpcom/io/nsLocalFileOS2.cpp
xpcom/io/nsLocalFileWin.cpp
xpcom/reflect/xptcall/public/xptcall.h
xpcom/reflect/xptinfo/public/xptinfo.h
xpcom/string/public/nsAlgorithm.h
xpcom/string/public/nsString.h
--- a/content/base/src/nsTextFragment.cpp
+++ b/content/base/src/nsTextFragment.cpp
@@ -12,17 +12,16 @@
 #include "nsTextFragment.h"
 #include "nsCRT.h"
 #include "nsReadableUtils.h"
 #include "nsMemory.h"
 #include "nsBidiUtils.h"
 #include "nsUnicharUtils.h"
 #include "nsUTF8Utils.h"
 #include "mozilla/SSE.h"
-#include "nsTextFragmentImpl.h"
 
 #define TEXTFRAG_WHITE_AFTER_NEWLINE 50
 #define TEXTFRAG_MAX_NEWLINES 7
 
 // Static buffer used for common fragments
 static char* sSpaceSharedString[TEXTFRAG_MAX_NEWLINES + 1];
 static char* sTabSharedString[TEXTFRAG_MAX_NEWLINES + 1];
 static char sSingleCharSharedString[256];
@@ -113,20 +112,28 @@ nsTextFragment::operator=(const nsTextFr
   }
 
   return *this;
 }
 
 static inline int32_t
 FirstNon8BitUnvectorized(const PRUnichar *str, const PRUnichar *end)
 {
-  typedef Non8BitParameters<sizeof(size_t)> p;
-  const size_t mask = p::mask;
-  const uint32_t alignMask = p::alignMask;
-  const uint32_t numUnicharsPerWord = p::numUnicharsPerWord;
+#if PR_BYTES_PER_WORD == 4
+  const size_t mask = 0xff00ff00;
+  const uint32_t alignMask = 0x3;
+  const uint32_t numUnicharsPerWord = 2;
+#elif PR_BYTES_PER_WORD == 8
+  const size_t mask = 0xff00ff00ff00ff00;
+  const uint32_t alignMask = 0x7;
+  const uint32_t numUnicharsPerWord = 4;
+#else
+#error Unknown platform!
+#endif
+
   const int32_t len = end - str;
   int32_t i = 0;
 
   // Align ourselves to a word boundary.
   int32_t alignLen =
     NS_MIN(len, int32_t(((-NS_PTR_TO_INT32(str)) & alignMask) / sizeof(PRUnichar)));
   for (; i < alignLen; i++) {
     if (str[i] > 255)
deleted file mode 100644
--- a/content/base/src/nsTextFragmentImpl.h
+++ /dev/null
@@ -1,24 +0,0 @@
-/* -*- 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/. */
-
-#ifndef nsTextFragmentImpl_h__
-#define nsTextFragmentImpl_h__
-
-#include "mozilla/StandardInteger.h"
-
-template<size_t size> struct Non8BitParameters;
-template<> struct Non8BitParameters<4> {
-  static const size_t mask = 0xff00ff00;
-  static const uint32_t alignMask = 0x3;
-  static const uint32_t numUnicharsPerWord = 2;
-};
-
-template<> struct Non8BitParameters<8> {
-  static const size_t mask = 0xff00ff00ff00ff0;
-  static const uint32_t alignMask = 0x7;
-  static const uint32_t numUnicharsPerWord = 4;
-};
-
-#endif
--- a/content/base/src/nsTextFragmentSSE2.cpp
+++ b/content/base/src/nsTextFragmentSSE2.cpp
@@ -3,35 +3,42 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // This file should only be compiled if you're on x86 or x86_64.  Additionally,
 // you'll need to compile this file with -msse2 if you're using gcc.
 
 #include <emmintrin.h>
 #include "nscore.h"
 #include "nsAlgorithm.h"
-#include "nsTextFragmentImpl.h"
 
 namespace mozilla {
 namespace SSE2 {
 
 static inline bool
 is_zero (__m128i x)
 {
   return
     _mm_movemask_epi8(_mm_cmpeq_epi8(x, _mm_setzero_si128())) == 0xffff;
 }
 
 int32_t
 FirstNon8Bit(const PRUnichar *str, const PRUnichar *end)
 {
   const uint32_t numUnicharsPerVector = 8;
-  typedef Non8BitParameters<sizeof(size_t)> p;
-  const size_t mask = p::mask;
-  const uint32_t numUnicharsPerWord = p::numUnicharsPerWord;
+
+#if PR_BYTES_PER_WORD == 4
+  const size_t mask = 0xff00ff00;
+  const uint32_t numUnicharsPerWord = 2;
+#elif PR_BYTES_PER_WORD == 8
+  const size_t mask = 0xff00ff00ff00ff00;
+  const uint32_t numUnicharsPerWord = 4;
+#else
+#error Unknown platform!
+#endif
+
   const int32_t len = end - str;
   int32_t i = 0;
 
   // Align ourselves to a 16-byte boundary, as required by _mm_load_si128
   // (i.e. MOVDQA).
   int32_t alignLen =
     NS_MIN(len, int32_t(((-NS_PTR_TO_INT32(str)) & 0xf) / sizeof(PRUnichar)));
   for (; i < alignLen; i++) {
--- a/layout/style/nsCSSProps.cpp
+++ b/layout/style/nsCSSProps.cpp
@@ -80,55 +80,49 @@ enum {
 #define CSS_PROP_ALIAS(aliasname_, propid_, aliasmethod_, pref_)              \
   eCSSAliasCountBefore_##aliasmethod_,
 #include "nsCSSPropAliasList.h"
 #undef CSS_PROP_ALIAS
 
   eCSSAliasCount
 };
 
-// Use a macro in the definitions below to ensure compile-time constants
-// in all the necessary places.
-#define CSS_MAX(x, y) ((x) > (y) ? (x) : (y))
-
 enum {
   // We want the largest sizeof(#aliasname_).  To find that, we use the
   // auto-incrementing behavior of C++ enums (a value without an
   // initializer is one larger than the previous value, or 0 at the
   // start of the enum), and for each alias we define two values:
   //   eMaxCSSAliasNameSizeBefore_##aliasmethod_ is the largest
   //     sizeof(#aliasname_) before that alias.  The first one is
   //     conveniently zero.
   //   eMaxCSSAliasNameSizeWith_##aliasmethod_ is **one less than** the
   //     largest sizeof(#aliasname_) before or including that alias.
 #define CSS_PROP_ALIAS(aliasname_, propid_, aliasmethod_, pref_)              \
   eMaxCSSAliasNameSizeBefore_##aliasmethod_,                                  \
   eMaxCSSAliasNameSizeWith_##aliasmethod_ =                                   \
-    CSS_MAX(sizeof(#aliasname_), eMaxCSSAliasNameSizeBefore_##aliasmethod_) - 1,
+    PR_MAX(sizeof(#aliasname_), eMaxCSSAliasNameSizeBefore_##aliasmethod_) - 1,
 #include "nsCSSPropAliasList.h"
 #undef CSS_PROP_ALIAS
 
   eMaxCSSAliasNameSize
 };
 
 struct CSSPropertyAlias {
-  const char name[CSS_MAX(eMaxCSSAliasNameSize, 1)];
+  const char name[PR_MAX(eMaxCSSAliasNameSize, 1)];
   const nsCSSProperty id;
   bool enabled;
 };
 
-static CSSPropertyAlias gAliases[CSS_MAX(eCSSAliasCount, 1)] = {
+static CSSPropertyAlias gAliases[PR_MAX(eCSSAliasCount, 1)] = {
 #define CSS_PROP_ALIAS(aliasname_, propid_, aliasmethod_, pref_)  \
   { #aliasname_, eCSSProperty_##propid_, true },
 #include "nsCSSPropAliasList.h"
 #undef CSS_PROP_ALIAS
 };
 
-#undef CSS_MAX
-
 void
 nsCSSProps::AddRefTable(void)
 {
   if (0 == gTableRefCount++) {
     NS_ABORT_IF_FALSE(!gPropertyTable, "pre existing array!");
     NS_ABORT_IF_FALSE(!gFontDescTable, "pre existing array!");
 
     gPropertyTable = new nsStaticCaseInsensitiveNameTable();
--- a/xpcom/base/nsStackWalk.h
+++ b/xpcom/base/nsStackWalk.h
@@ -7,16 +7,17 @@
 
 #ifndef nsStackWalk_h_
 #define nsStackWalk_h_
 
 /* WARNING: This file is intended to be included from C or C++ files. */
 
 #include "nscore.h"
 #include <mozilla/StandardInteger.h>
+#include "prtypes.h"
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
 // aSP will be the best approximation possible of what the stack pointer will be
 // pointing to when the execution returns to executing that at that PC.
 // If no approximation can be made it will be NULL.
--- a/xpcom/build/BinaryPath.h
+++ b/xpcom/build/BinaryPath.h
@@ -1,16 +1,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_BinaryPath_h
 #define mozilla_BinaryPath_h
 
 #include "nsXPCOMPrivate.h" // for MAXPATHLEN
+#include "prtypes.h"
 #ifdef XP_WIN
 #include <windows.h>
 #elif defined(XP_MACOSX)
 #include <CoreFoundation/CoreFoundation.h>
 #elif defined(XP_UNIX)
 #include <sys/stat.h>
 #include <string.h>
 #endif
--- a/xpcom/build/nsXULAppAPI.h
+++ b/xpcom/build/nsXULAppAPI.h
@@ -1,16 +1,17 @@
 /* -*- 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/. */
 
 #ifndef _nsXULAppAPI_h__
 #define _nsXULAppAPI_h__
 
+#include "prtypes.h"
 #include "nsID.h"
 #include "xrecore.h"
 #include "nsXPCOM.h"
 #include "nsISupports.h"
 #include "prlog.h"
 #include "nsXREAppData.h"
 
 #include "mozilla/Assertions.h"
--- a/xpcom/ds/nsCRT.h
+++ b/xpcom/ds/nsCRT.h
@@ -5,16 +5,17 @@
 #ifndef nsCRT_h___
 #define nsCRT_h___
 
 #include <stdlib.h>
 #include <string.h>
 #include <ctype.h>
 #include "plstr.h"
 #include "nscore.h"
+#include "prtypes.h"
 #include "nsCppSharedAllocator.h"
 #include "nsCRTGlue.h"
 
 #if defined(XP_WIN) || defined(XP_OS2)
 #  define NS_LINEBREAK           "\015\012"
 #  define NS_LINEBREAK_LEN       2
 #else
 #  ifdef XP_UNIX
--- a/xpcom/ds/nsHashtable.h
+++ b/xpcom/ds/nsHashtable.h
@@ -16,16 +16,17 @@
 
 /**
  * nsHashtable is OBSOLETE. Use nsTHashtable or a derivative instead.
  */
 
 #ifndef nsHashtable_h__
 #define nsHashtable_h__
 
+#include "prtypes.h"
 #include "pldhash.h"
 #include "prlock.h"
 #include "nscore.h"
 #include "nsString.h"
 #include "nsISupportsBase.h"
 #include "nsTraceRefcnt.h"
 
 class nsIObjectInputStream;
--- a/xpcom/ds/nsStringEnumerator.cpp
+++ b/xpcom/ds/nsStringEnumerator.cpp
@@ -1,15 +1,16 @@
 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
 /* 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 "nsStringEnumerator.h"
+#include "prtypes.h"
 #include "nsCRT.h"
 #include "nsString.h"
 #include "nsReadableUtils.h"
 #include "nsISimpleEnumerator.h"
 #include "nsSupportsPrimitives.h"
 #include "mozilla/Attributes.h"
 
 //
--- a/xpcom/glue/nsDebug.h
+++ b/xpcom/glue/nsDebug.h
@@ -16,16 +16,18 @@
 
 #include "nsXPCOM.h"
 #include "mozilla/Assertions.h"
 
 #ifdef DEBUG
 #include "prprf.h"
 #endif
 
+#include "prtypes.h"
+
 #ifdef DEBUG
 
 /**
  * Abort the execution of the program if the expression evaluates to
  * false.
  *
  * There is no status value returned from the macro.
  *
--- a/xpcom/glue/nsQuickSort.cpp
+++ b/xpcom/glue/nsQuickSort.cpp
@@ -29,16 +29,17 @@
  * SUCH DAMAGE.
  */
 
 /* We need this because Solaris' version of qsort is broken and
  * causes array bounds reads.
  */
 
 #include <stdlib.h>
+#include "prtypes.h"
 #include "nsAlgorithm.h"
 #include "nsQuickSort.h"
 
 extern "C" {
 
 #if !defined(DEBUG) && (defined(__cplusplus) || defined(__gcc))
 # ifndef INLINE
 #  define INLINE inline
--- a/xpcom/glue/nsQuickSort.h
+++ b/xpcom/glue/nsQuickSort.h
@@ -6,16 +6,17 @@
 
 /* We need this because Solaris' version of qsort is broken and
  * causes array bounds reads.
  */
 
 #ifndef nsQuickSort_h___
 #define nsQuickSort_h___
 
+#include "prtypes.h"
 #include "nscore.h"
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
 /**
  * Parameters:
--- a/xpcom/glue/nsTArray.h
+++ b/xpcom/glue/nsTArray.h
@@ -7,16 +7,17 @@
 #ifndef nsTArray_h__
 #define nsTArray_h__
 
 #include "mozilla/Assertions.h"
 #include "mozilla/Util.h"
 
 #include <string.h>
 
+#include "prtypes.h"
 #include "nsAlgorithm.h"
 #include "nscore.h"
 #include "nsQuickSort.h"
 #include "nsDebug.h"
 #include "nsTraceRefcnt.h"
 #include NEW_H
 
 //
@@ -1343,19 +1344,17 @@ private:
   }
 
   // Declare mAutoBuf aligned to the maximum of the header's alignment and
   // elem_type's alignment.  We need to use a union rather than
   // MOZ_ALIGNED_DECL because GCC is picky about what goes into
   // __attribute__((aligned(foo))).
   union {
     char mAutoBuf[sizeof(nsTArrayHeader) + N * sizeof(elem_type)];
-    // Do the max operation inline to ensure that it is a compile-time constant.
-    mozilla::AlignedElem<(MOZ_ALIGNOF(Header) > MOZ_ALIGNOF(elem_type))
-                         ? MOZ_ALIGNOF(Header) : MOZ_ALIGNOF(elem_type)> mAlign;
+    mozilla::AlignedElem<PR_MAX(MOZ_ALIGNOF(Header), MOZ_ALIGNOF(elem_type))> mAlign;
   };
 };
 
 template<class E, uint32_t N, class Alloc=nsTArrayDefaultAllocator>
 class nsAutoTArray : public nsAutoArrayBase<nsTArray<E, Alloc>, N>
 {
   typedef nsAutoArrayBase<nsTArray<E, Alloc>, N> Base;
 
--- a/xpcom/glue/nsTHashtable.h
+++ b/xpcom/glue/nsTHashtable.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 nsTHashtable_h__
 #define nsTHashtable_h__
 
 #include "nscore.h"
+#include "prtypes.h"
 #include "pldhash.h"
 #include "nsDebug.h"
 #include NEW_H
 #include "mozilla/fallible.h"
 
 // helper function for nsTHashtable::Clear()
 NS_COM_GLUE PLDHashOperator
 PL_DHashStubEnumRemove(PLDHashTable    *table,
--- a/xpcom/glue/pldhash.h
+++ b/xpcom/glue/pldhash.h
@@ -26,17 +26,17 @@ extern "C" {
 #endif
 
 #ifdef DEBUG_XXXbrendan
 #define PL_DHASHMETER 1
 #endif
 
 /* Table size limit, do not equal or exceed (see min&maxAlphaFrac, below). */
 #undef PL_DHASH_SIZE_LIMIT
-#define PL_DHASH_SIZE_LIMIT     ((uint32_t)1 << 24)
+#define PL_DHASH_SIZE_LIMIT     PR_BIT(24)
 
 /* Minimum table size, or gross entry count (net is at most .75 loaded). */
 #ifndef PL_DHASH_MIN_SIZE
 #define PL_DHASH_MIN_SIZE 16
 #elif (PL_DHASH_MIN_SIZE & (PL_DHASH_MIN_SIZE - 1)) != 0
 #error "PL_DHASH_MIN_SIZE must be a power of two!"
 #endif
 
@@ -197,18 +197,17 @@ struct PLDHashTable {
 #endif
 };
 
 /*
  * Size in entries (gross, not net of free and removed sentinels) for table.
  * We store hashShift rather than sizeLog2 to optimize the collision-free case
  * in SearchTable.
  */
-#define PL_DHASH_TABLE_SIZE(table) \
-    ((uint32_t)1 << (PL_DHASH_BITS - (table)->hashShift))
+#define PL_DHASH_TABLE_SIZE(table)  PR_BIT(PL_DHASH_BITS - (table)->hashShift)
 
 /*
  * Table space at entryStore is allocated and freed using these callbacks.
  * The allocator should return null on error only (not if called with nbytes
  * equal to 0; but note that pldhash.c code will never call with 0 nbytes).
  */
 typedef void *
 (* PLDHashAllocTable)(PLDHashTable *table, uint32_t nbytes);
--- a/xpcom/io/nsLocalFileOS2.cpp
+++ b/xpcom/io/nsLocalFileOS2.cpp
@@ -10,16 +10,17 @@
 #include "nsMemory.h"
 
 #include "nsLocalFile.h"
 #include "nsNativeCharsetUtils.h"
 
 #include "nsISimpleEnumerator.h"
 #include "nsIDirectoryEnumerator.h"
 #include "nsIComponentManager.h"
+#include "prtypes.h"
 #include "prio.h"
 
 #include "nsReadableUtils.h"
 #include "nsISupportsPrimitives.h"
 #include "nsIMutableArray.h"
 #include "nsTraceRefcntImpl.h"
 
 using namespace mozilla;
--- a/xpcom/io/nsLocalFileWin.cpp
+++ b/xpcom/io/nsLocalFileWin.cpp
@@ -10,16 +10,17 @@
 #include "nsMemory.h"
 
 #include "nsLocalFile.h"
 #include "nsIDirectoryEnumerator.h"
 #include "nsNativeCharsetUtils.h"
 
 #include "nsISimpleEnumerator.h"
 #include "nsIComponentManager.h"
+#include "prtypes.h"
 #include "prio.h"
 #include "private/pprio.h"  // To get PR_ImportFile
 #include "prprf.h"
 #include "prmem.h"
 #include "nsHashKeys.h"
 
 #include "nsXPIDLString.h"
 #include "nsReadableUtils.h"
--- a/xpcom/reflect/xptcall/public/xptcall.h
+++ b/xpcom/reflect/xptcall/public/xptcall.h
@@ -9,16 +9,17 @@
 #define xptcall_h___
 
 #ifdef MOZILLA_INTERNAL_API
 # define NS_GetXPTCallStub     NS_GetXPTCallStub_P
 # define NS_DestroyXPTCallStub NS_DestroyXPTCallStub_P
 # define NS_InvokeByIndex      NS_InvokeByIndex_P
 #endif
 
+#include "prtypes.h"
 #include "nscore.h"
 #include "nsISupports.h"
 #include "xpt_struct.h"
 #include "xptinfo.h"
 #include "jsapi.h"
 
 struct nsXPTCMiniVariant
 {
--- a/xpcom/reflect/xptinfo/public/xptinfo.h
+++ b/xpcom/reflect/xptinfo/public/xptinfo.h
@@ -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/. */
 
 /* XPTI_PUBLIC_API and XPTI_GetInterfaceInfoManager declarations. */
 
 #ifndef xptiinfo_h___
 #define xptiinfo_h___
 
+#include "prtypes.h"
 #include "nscore.h"
 #include "xpt_struct.h"
 
 class nsIInterfaceInfoManager;
 
 // Flyweight wrapper classes for xpt_struct.h structs. 
 // Everything here is dependent upon - and sensitive to changes in -
 // xpcom/typelib/xpt/public/xpt_struct.h!
--- a/xpcom/string/public/nsAlgorithm.h
+++ b/xpcom/string/public/nsAlgorithm.h
@@ -6,16 +6,21 @@
 #ifndef nsAlgorithm_h___
 #define nsAlgorithm_h___
 
 #ifndef nsCharTraits_h___
 #include "nsCharTraits.h"
   // for |nsCharSourceTraits|, |nsCharSinkTraits|
 #endif
 
+#ifndef prtypes_h___
+#include "prtypes.h"
+  // for |uint32_t|...
+#endif
+
 #ifndef nsDebug_h___
 #include "nsDebug.h"
   // for NS_ASSERTION
 #endif
 
 
 template <class T>
 inline
--- a/xpcom/string/public/nsString.h
+++ b/xpcom/string/public/nsString.h
@@ -16,19 +16,16 @@
 #ifndef nsDependentSubstring_h___
 #include "nsDependentSubstring.h"
 #endif
 
 #ifndef nsReadableUtils_h___
 #include "nsReadableUtils.h"
 #endif
 
-// For PRUnichar
-#include "prtypes.h"
-
 #include NEW_H
 
   // enable support for the obsolete string API if not explicitly disabled
 #ifndef MOZ_STRING_WITH_OBSOLETE_API
 #define MOZ_STRING_WITH_OBSOLETE_API 1
 #endif
 
 #if MOZ_STRING_WITH_OBSOLETE_API