Bug 976372 - Remove support for compilers which lack support for dynamic_cast<void*>; r=dbaron
☠☠ backed out by 22d6c5982c53 ☠ ☠
authorEhsan Akhgari <ehsan@mozilla.com>
Mon, 24 Feb 2014 21:06:06 -0500
changeset 170662 8d8165293e9b34761a1517f7904488742d47dcd8
parent 170661 f74c9326b89c94440109bbcfc99330695b6576d5
child 170663 f0ce508ce329e4988b6b281f50966e20ff85318c
push id270
push userpvanderbeken@mozilla.com
push dateThu, 06 Mar 2014 09:24:21 +0000
reviewersdbaron
bugs976372
milestone30.0a1
Bug 976372 - Remove support for compilers which lack support for dynamic_cast<void*>; r=dbaron
configure.in
js/src/configure.in
xpcom/base/nsTraceRefcntImpl.cpp
xpcom/xpcom-config.h.in
--- a/configure.in
+++ b/configure.in
@@ -3184,40 +3184,16 @@ AC_CACHE_CHECK(whether the C++ \"using\"
                                };,
                                X x; Y y; y.jo(x);,
                                ac_cv_cpp_ambiguity_resolving_using=yes,
                                ac_cv_cpp_ambiguity_resolving_using=no)])
 if test "$ac_cv_cpp_ambiguity_resolving_using" = yes ; then
    AC_DEFINE(HAVE_CPP_AMBIGUITY_RESOLVING_USING)
 fi
 
-dnl See if a dynamic_cast to void* gives the most derived object.
-AC_CACHE_CHECK(for C++ dynamic_cast to void*,
-               ac_cv_cpp_dynamic_cast_void_ptr,
-               [AC_TRY_RUN([class X { int i; public: virtual ~X() { } };
-                            class Y { int j; public: virtual ~Y() { } };
-                            class Z : public X, public Y { int k; };
-
-                            int main() {
-                                 Z mdo;
-                                 X *subx = (X*)&mdo;
-                                 Y *suby = (Y*)&mdo;
-                                 return !((((void*)&mdo != (void*)subx) &&
-                                           ((void*)&mdo == dynamic_cast<void*>(subx))) ||
-                                          (((void*)&mdo != (void*)suby) &&
-                                           ((void*)&mdo == dynamic_cast<void*>(suby))));
-                            }],
-                           ac_cv_cpp_dynamic_cast_void_ptr=yes,
-                           ac_cv_cpp_dynamic_cast_void_ptr=no,
-                           ac_cv_cpp_dynamic_cast_void_ptr=no)])
-if test "$ac_cv_cpp_dynamic_cast_void_ptr" = yes ; then
-   AC_DEFINE(HAVE_CPP_DYNAMIC_CAST_TO_VOID_PTR)
-fi
-
-
 dnl note that this one is reversed - if the test fails, then
 dnl we require implementations of unused virtual methods. Which
 dnl really blows because it means we'll have useless vtable
 dnl bloat.
 AC_CACHE_CHECK(whether C++ requires implementation of unused virtual methods,
                ac_cv_cpp_unused_required,
                [AC_TRY_LINK(class X {private: virtual void never_called();};,
                                X x;,
@@ -8737,17 +8713,16 @@ AC_SUBST(ac_configure_args)
 
 dnl Spit out some output
 dnl ========================================================
 
 dnl The following defines are used by xpcom
 _NON_GLOBAL_ACDEFINES="$_NON_GLOBAL_ACDEFINES
 CPP_THROW_NEW
 HAVE_CPP_AMBIGUITY_RESOLVING_USING
-HAVE_CPP_DYNAMIC_CAST_TO_VOID_PTR
 HAVE_CPP_PARTIAL_SPECIALIZATION
 HAVE_CPP_TROUBLE_COMPARING_TO_ZERO
 NEED_CPP_UNUSED_IMPLEMENTATIONS
 HAVE_GETPAGESIZE
 HAVE_ICONV
 HAVE_ICONV_WITH_CONST_INPUT
 HAVE_MBRTOWC
 HAVE_WCRTOMB
--- a/js/src/configure.in
+++ b/js/src/configure.in
@@ -2583,40 +2583,16 @@ AC_CACHE_CHECK(whether the C++ \"using\"
                                };,
                                X x; Y y; y.jo(x);,
                                ac_cv_cpp_ambiguity_resolving_using=yes,
                                ac_cv_cpp_ambiguity_resolving_using=no)])
 if test "$ac_cv_cpp_ambiguity_resolving_using" = yes ; then
    AC_DEFINE(HAVE_CPP_AMBIGUITY_RESOLVING_USING)
 fi
 
-dnl See if a dynamic_cast to void* gives the most derived object.
-AC_CACHE_CHECK(for C++ dynamic_cast to void*,
-               ac_cv_cpp_dynamic_cast_void_ptr,
-               [AC_TRY_RUN([class X { int i; public: virtual ~X() { } };
-                            class Y { int j; public: virtual ~Y() { } };
-                            class Z : public X, public Y { int k; };
-
-                            int main() {
-                                 Z mdo;
-                                 X *subx = (X*)&mdo;
-                                 Y *suby = (Y*)&mdo;
-                                 return !((((void*)&mdo != (void*)subx) &&
-                                           ((void*)&mdo == dynamic_cast<void*>(subx))) ||
-                                          (((void*)&mdo != (void*)suby) &&
-                                           ((void*)&mdo == dynamic_cast<void*>(suby))));
-                            }],
-                           ac_cv_cpp_dynamic_cast_void_ptr=yes,
-                           ac_cv_cpp_dynamic_cast_void_ptr=no,
-                           ac_cv_cpp_dynamic_cast_void_ptr=no)])
-if test "$ac_cv_cpp_dynamic_cast_void_ptr" = yes ; then
-   AC_DEFINE(HAVE_CPP_DYNAMIC_CAST_TO_VOID_PTR)
-fi
-
-
 dnl note that this one is reversed - if the test fails, then
 dnl we require implementations of unused virtual methods. Which
 dnl really blows because it means we'll have useless vtable
 dnl bloat.
 AC_CACHE_CHECK(whether C++ requires implementation of unused virtual methods,
                ac_cv_cpp_unused_required,
                [AC_TRY_LINK(class X {private: virtual void never_called();};,
                                X x;,
--- a/xpcom/base/nsTraceRefcntImpl.cpp
+++ b/xpcom/base/nsTraceRefcntImpl.cpp
@@ -450,30 +450,22 @@ GetBloatEntry(const char* aTypeName, uin
     }
   }
   return entry;
 }
 
 static int DumpSerialNumbers(PLHashEntry* aHashEntry, int aIndex, void* aClosure)
 {
   serialNumberRecord* record = reinterpret_cast<serialNumberRecord *>(aHashEntry->value);
-#ifdef HAVE_CPP_DYNAMIC_CAST_TO_VOID_PTR
   fprintf((FILE*) aClosure, "%" PRIdPTR
                             " @%p (%d references; %d from COMPtrs)\n",
                             record->serialNumber,
                             NS_INT32_TO_PTR(aHashEntry->key),
                             record->refCount,
                             record->COMPtrCount);
-#else
-  fprintf((FILE*) aClosure, "%" PRIdPTR
-                            " @%p (%d references)\n",
-                            record->serialNumber,
-                            NS_INT32_TO_PTR(aHashEntry->key),
-                            record->refCount);
-#endif
   return HT_ENUMERATE_NEXT;
 }
 
 
 template <>
 class nsDefaultComparator <BloatEntry*, BloatEntry*> {
   public:
     bool Equals(BloatEntry* const& aA, BloatEntry* const& aB) const {
@@ -593,17 +585,17 @@ static int32_t* GetRefCount(void* aPtr)
   PLHashEntry** hep = PL_HashTableRawLookup(gSerialNumbers, PLHashNumber(NS_PTR_TO_INT32(aPtr)), aPtr);
   if (hep && *hep) {
     return &((reinterpret_cast<serialNumberRecord*>((*hep)->value))->refCount);
   } else {
     return nullptr;
   }
 }
 
-#if defined(NS_IMPL_REFCNT_LOGGING) && defined(HAVE_CPP_DYNAMIC_CAST_TO_VOID_PTR)
+#if defined(NS_IMPL_REFCNT_LOGGING)
 static int32_t* GetCOMPtrCount(void* aPtr)
 {
   PLHashEntry** hep = PL_HashTableRawLookup(gSerialNumbers, PLHashNumber(NS_PTR_TO_INT32(aPtr)), aPtr);
   if (hep && *hep) {
     return &((reinterpret_cast<serialNumberRecord*>((*hep)->value))->COMPtrCount);
   } else {
     return nullptr;
   }
@@ -728,30 +720,23 @@ static void InitTraceLog(void)
       gLogToLeaky = false;
       fprintf(stdout, "### ERROR: XPCOM_MEM_LEAKY_LOG defined, but can't locate __log_addref and __log_release symbols\n");
       fflush(stdout);
     }
   }
 
   const char* classes = getenv("XPCOM_MEM_LOG_CLASSES");
 
-#ifdef HAVE_CPP_DYNAMIC_CAST_TO_VOID_PTR
   if (classes) {
     (void)InitLog("XPCOM_MEM_COMPTR_LOG", "nsCOMPtr", &gCOMPtrLog);
   } else {
     if (getenv("XPCOM_MEM_COMPTR_LOG")) {
       fprintf(stdout, "### XPCOM_MEM_COMPTR_LOG defined -- but XPCOM_MEM_LOG_CLASSES is not defined\n");
     }
   }
-#else
-  const char* comptr_log = getenv("XPCOM_MEM_COMPTR_LOG");
-  if (comptr_log) {
-    fprintf(stdout, "### XPCOM_MEM_COMPTR_LOG defined -- but it will not work without dynamic_cast\n");
-  }
-#endif
 
   if (classes) {
     // if XPCOM_MEM_LOG_CLASSES was set to some value, the value is interpreted
     // as a list of class names to track
     gTypesToLog = PL_NewHashTable(256,
                                   PL_HashString,
                                   PL_CompareStrings,
                                   PL_CompareValues,
@@ -1168,17 +1153,17 @@ NS_LogDtor(void* aPtr, const char* aType
   }
 #endif
 }
 
 
 EXPORT_XPCOM_API(void)
 NS_LogCOMPtrAddRef(void* aCOMPtr, nsISupports* aObject)
 {
-#if defined(NS_IMPL_REFCNT_LOGGING) && defined(HAVE_CPP_DYNAMIC_CAST_TO_VOID_PTR)
+#if defined(NS_IMPL_REFCNT_LOGGING)
   // Get the most-derived object.
   void *object = dynamic_cast<void *>(aObject);
 
   // This is a very indirect way of finding out what the class is
   // of the object being logged.  If we're logging a specific type,
   // then
   if (!gTypesToLog || !gSerialNumbers) {
     return;
@@ -1209,17 +1194,17 @@ NS_LogCOMPtrAddRef(void* aCOMPtr, nsISup
   }
 #endif
 }
 
 
 EXPORT_XPCOM_API(void)
 NS_LogCOMPtrRelease(void* aCOMPtr, nsISupports* aObject)
 {
-#if defined(NS_IMPL_REFCNT_LOGGING) && defined(HAVE_CPP_DYNAMIC_CAST_TO_VOID_PTR)
+#if defined(NS_IMPL_REFCNT_LOGGING)
   // Get the most-derived object.
   void *object = dynamic_cast<void *>(aObject);
 
   // This is a very indirect way of finding out what the class is
   // of the object being logged.  If we're logging a specific type,
   // then
   if (!gTypesToLog || !gSerialNumbers) {
     return;
--- a/xpcom/xpcom-config.h.in
+++ b/xpcom/xpcom-config.h.in
@@ -10,19 +10,16 @@
 /* Define this to throw() if the compiler complains about 
  * constructors returning NULL
  */
 #undef CPP_THROW_NEW
 
 /* Define if the c++ compiler can resolve ambiguity with |using| */
 #undef HAVE_CPP_AMBIGUITY_RESOLVING_USING
 
-/* Define if a dyanmic_cast to void* gives the most derived object */
-#undef HAVE_CPP_DYNAMIC_CAST_TO_VOID_PTR
-
 /* Define if the c++ compiler has trouble comparing a constant
  * reference to a templatized class to zero
  */
 #undef HAVE_CPP_TROUBLE_COMPARING_TO_ZERO
 
 /* Define if the c++ compiler requires implementations of 
  * unused virtual methods
  */