Backed out 2 changesets (bug 1559379) for SM build bustages on a CLOSED TREE
authorAndreea Pavel <apavel@mozilla.com>
Fri, 28 Jun 2019 01:03:23 +0300
changeset 543275 a72f0a08f652ab309328230659c97660e13cfd27
parent 543274 40bcaacdcf614e325f0538754a99b4c99411d26f
child 543276 aaa160599ef488a6854c34a566b92abf5c2353c4
child 543490 ed8177bac14e50fabf3a8a080b0508f40eb1d009
push id2131
push userffxbld-merge
push dateMon, 26 Aug 2019 18:30:20 +0000
treeherdermozilla-release@b19ffb3ca153 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1559379
milestone69.0a1
backs out0defd54899e27b9bb378871bac282b0e3b46f4a5
ee4f23ea853083f8387320b5b723b2bc89df5aca
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
Backed out 2 changesets (bug 1559379) for SM build bustages on a CLOSED TREE Backed out changeset 0defd54899e2 (bug 1559379) Backed out changeset ee4f23ea8530 (bug 1559379)
memory/build/mozmemory_wrap.cpp
memory/build/mozmemory_wrap.h
memory/mozalloc/cxxalloc.cpp
memory/mozalloc/cxxalloc.h
memory/mozalloc/moz.build
memory/mozalloc/mozalloc.h
--- a/memory/build/mozmemory_wrap.cpp
+++ b/memory/build/mozmemory_wrap.cpp
@@ -10,16 +10,45 @@
 
 // Declare malloc implementation functions with the right return and
 // argument types.
 #define MALLOC_DECL(name, return_type, ...) \
   MOZ_MEMORY_API return_type name##_impl(__VA_ARGS__);
 #define MALLOC_FUNCS MALLOC_FUNCS_MALLOC
 #include "malloc_decls.h"
 
+#ifdef MOZ_WRAP_NEW_DELETE
+#  include <new>
+
+MFBT_API void* operator new(size_t size) { return malloc_impl(size); }
+
+MFBT_API void* operator new[](size_t size) { return malloc_impl(size); }
+
+MFBT_API void operator delete(void* ptr) noexcept(true) { free_impl(ptr); }
+
+MFBT_API void operator delete[](void* ptr) noexcept(true) { free_impl(ptr); }
+
+MFBT_API void* operator new(size_t size, std::nothrow_t const&) {
+  return malloc_impl(size);
+}
+
+MFBT_API void* operator new[](size_t size, std::nothrow_t const&) {
+  return malloc_impl(size);
+}
+
+MFBT_API void operator delete(void* ptr, std::nothrow_t const&)noexcept(true) {
+  free_impl(ptr);
+}
+
+MFBT_API void operator delete[](void* ptr,
+                                std::nothrow_t const&) noexcept(true) {
+  free_impl(ptr);
+}
+#endif
+
 // strndup and strdup may be defined as macros in string.h, which would
 // clash with the definitions below.
 #undef strndup
 #undef strdup
 
 MOZ_MEMORY_API char* strndup_impl(const char* src, size_t len) {
   char* dst = (char*)malloc_impl(len + 1);
   if (dst) {
--- a/memory/build/mozmemory_wrap.h
+++ b/memory/build/mozmemory_wrap.h
@@ -55,21 +55,23 @@
 //
 // - On MacOSX, the system libc has a zone allocator, which allows us to
 //   hook custom malloc implementation functions without exporting them.
 //   However, since we want things in Firefox to skip the system zone
 //   allocator, the malloc implementation functions are all exported
 //   unprefixed, as well as duplication functions.
 //   Jemalloc-specific functions are also left unprefixed.
 //
-// - On Android all functions are left unprefixed.
+// - On Android all functions are left unprefixed. Additionally,
+//   C++ allocation functions (operator new/delete) are also exported and
+//   unprefixed.
 //
 // - On other systems (mostly Linux), all functions are left unprefixed.
 //
-// On all platforms, C++ allocation functions are also exported.
+// Only Android adds C++ allocation functions.
 //
 // Proper exporting of the various functions is done with the MOZ_MEMORY_API
 // and MOZ_JEMALLOC_API macros. MOZ_MEMORY_API is meant to be used for malloc
 // implementation and duplication functions, while MOZ_JEMALLOC_API is
 // dedicated to jemalloc specific functions.
 //
 //
 // All these functions are meant to be called with no prefix from Gecko code.
@@ -104,16 +106,19 @@
 #endif
 
 #ifdef MOZ_MEMORY_IMPL
 #  define MOZ_JEMALLOC_API MOZ_EXTERN_C MFBT_API
 #  if defined(XP_WIN)
 #    define mozmem_malloc_impl(a) je_##a
 #  else
 #    define MOZ_MEMORY_API MOZ_EXTERN_C MFBT_API
+#    if defined(MOZ_WIDGET_ANDROID)
+#      define MOZ_WRAP_NEW_DELETE
+#    endif
 #  endif
 #endif
 #ifdef XP_WIN
 #  define mozmem_dup_impl(a) wrap_##a
 #endif
 
 #if !defined(MOZ_MEMORY_IMPL)
 #  define MOZ_MEMORY_API MOZ_EXTERN_C MFBT_API
deleted file mode 100644
--- a/memory/mozalloc/cxxalloc.cpp
+++ /dev/null
@@ -1,26 +0,0 @@
-/* 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/. */
-
-#define MOZ_MEMORY_IMPL
-#include "mozmemory_wrap.h"
-#define MALLOC_FUNCS MALLOC_FUNCS_MALLOC
-// See mozmemory_wrap.h for more details. Files that are part of libmozglue,
-// need to use _impl suffixes, which is becoming cumbersome. We'll have to use
-// something like a malloc.h wrapper and allow the use of the functions without
-// a _impl suffix. In the meanwhile, this is enough to get by for C++ code.
-#define MALLOC_DECL(name, return_type, ...) \
-  MOZ_MEMORY_API return_type name##_impl(__VA_ARGS__);
-#include "malloc_decls.h"
-
-#include "mozilla/Attributes.h"
-
-extern "C" MFBT_API void* moz_xmalloc(size_t size) MOZ_ALLOCATOR;
-
-namespace std {
-struct nothrow_t;
-}
-
-#define MOZALLOC_EXPORT_NEW MFBT_API
-
-#include "mozilla/cxxalloc.h"
deleted file mode 100644
--- a/memory/mozalloc/cxxalloc.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/* 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_cxxalloc_h
-#define mozilla_cxxalloc_h
-
-/*
- * We implement the default operators new/delete as part of
- * libmozalloc, replacing their definitions in libstdc++.  The
- * operator new* definitions in libmozalloc will never return a NULL
- * pointer.
- *
- * Each operator new immediately below returns a pointer to memory
- * that can be delete'd by any of
- *
- *   (1) the matching infallible operator delete immediately below
- *   (2) the matching system |operator delete(void*, std::nothrow)|
- *   (3) the matching system |operator delete(void*) noexcept(false)|
- *
- * NB: these are declared |noexcept(false)|, though they will never
- * throw that exception.  This declaration is consistent with the rule
- * that |::operator new() noexcept(false)| will never return NULL.
- *
- * NB: mozilla::fallible can be used instead of std::nothrow.
- */
-
-#ifndef MOZALLOC_EXPORT_NEW
-#  define MOZALLOC_EXPORT_NEW MFBT_API
-#endif
-
-MOZALLOC_EXPORT_NEW void* operator new(size_t size) noexcept(false) {
-  return moz_xmalloc(size);
-}
-
-MOZALLOC_EXPORT_NEW void* operator new(size_t size,
-                                       const std::nothrow_t&) noexcept(true) {
-  return malloc_impl(size);
-}
-
-MOZALLOC_EXPORT_NEW void* operator new[](size_t size) noexcept(false) {
-  return moz_xmalloc(size);
-}
-
-MOZALLOC_EXPORT_NEW void* operator new[](size_t size,
-                                         const std::nothrow_t&) noexcept(true) {
-  return malloc_impl(size);
-}
-
-MOZALLOC_EXPORT_NEW void operator delete(void* ptr) noexcept(true) {
-  return free_impl(ptr);
-}
-
-MOZALLOC_EXPORT_NEW void operator delete(void* ptr,
-                                         const std::nothrow_t&)noexcept(true) {
-  return free_impl(ptr);
-}
-
-MOZALLOC_EXPORT_NEW void operator delete[](void* ptr) noexcept(true) {
-  return free_impl(ptr);
-}
-
-MOZALLOC_EXPORT_NEW void operator delete[](
-    void* ptr, const std::nothrow_t&) noexcept(true) {
-  return free_impl(ptr);
-}
-
-#if defined(XP_WIN)
-// We provide the global sized delete overloads unconditionally because the
-// MSVC runtime headers do, despite compiling with /Zc:sizedDealloc-
-MOZALLOC_EXPORT_NEW void operator delete(void* ptr,
-                                         size_t /*size*/) noexcept(true) {
-  return free_impl(ptr);
-}
-
-MOZALLOC_EXPORT_NEW void operator delete[](void* ptr,
-                                           size_t /*size*/) noexcept(true) {
-  return free_impl(ptr);
-}
-#endif
-
-#endif /* mozilla_cxxalloc_h */
--- a/memory/mozalloc/moz.build
+++ b/memory/mozalloc/moz.build
@@ -1,17 +1,16 @@
 # -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=python:
 # 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/.
 NoVisibilityFlags()
 
 EXPORTS.mozilla += [
-    'cxxalloc.h',
     'mozalloc.h',
     'mozalloc_abort.h',
     'mozalloc_oom.h',
 ]
 
 if CONFIG['WRAP_STL_INCLUDES']:
     if CONFIG['CC_TYPE'] in ('clang', 'gcc'):
         EXPORTS.mozilla += ['throw_gcc.h']
@@ -31,21 +30,16 @@ UNIFIED_SOURCES += [
     'mozalloc.cpp',
     'mozalloc_oom.cpp',
 ]
 
 SOURCES += [
     'mozalloc_abort.cpp',
 ]
 
-if CONFIG['MOZ_MEMORY']:
-    SOURCES += [
-        'cxxalloc.cpp',
-    ]
-
 if CONFIG['CPU_ARCH'] == 'arm' and CONFIG['CC_TYPE'] == 'clang':
     SOURCES['mozalloc_abort.cpp'].flags += ['-Wno-infinite-recursion']
 
 FINAL_LIBRARY = 'mozglue'
 
 # The strndup declaration in string.h is in an ifdef __USE_GNU section
 DEFINES['_GNU_SOURCE'] = True
 
--- a/memory/mozalloc/mozalloc.h
+++ b/memory/mozalloc/mozalloc.h
@@ -98,26 +98,105 @@ MFBT_API size_t moz_malloc_size_of(const
  * pointers into the middle of a live allocation.
  */
 MFBT_API size_t moz_malloc_enclosing_size_of(const void* ptr);
 
 MOZ_END_EXTERN_C
 
 #ifdef __cplusplus
 
+/*
+ * We implement the default operators new/delete as part of
+ * libmozalloc, replacing their definitions in libstdc++.  The
+ * operator new* definitions in libmozalloc will never return a NULL
+ * pointer.
+ *
+ * Each operator new immediately below returns a pointer to memory
+ * that can be delete'd by any of
+ *
+ *   (1) the matching infallible operator delete immediately below
+ *   (2) the matching system |operator delete(void*, std::nothrow)|
+ *   (3) the matching system |operator delete(void*) noexcept(false)|
+ *
+ * NB: these are declared |noexcept(false)|, though they will never
+ * throw that exception.  This declaration is consistent with the rule
+ * that |::operator new() noexcept(false)| will never return NULL.
+ *
+ * NB: mozilla::fallible can be used instead of std::nothrow.
+ */
+
 /* NB: This is defined just to silence vacuous warnings about symbol
  * visibility on OS X/gcc. These symbols are force-inline and not
  * exported. */
 #  if defined(XP_MACOSX)
-#    define MOZALLOC_EXPORT_NEW MFBT_API MOZ_ALWAYS_INLINE_EVEN_DEBUG
+#    define MOZALLOC_EXPORT_NEW MFBT_API
 #  else
-#    define MOZALLOC_EXPORT_NEW MOZ_ALWAYS_INLINE_EVEN_DEBUG
+#    define MOZALLOC_EXPORT_NEW
 #  endif
 
-#  include "mozilla/cxxalloc.h"
+MOZALLOC_EXPORT_NEW
+#  if defined(__GNUC__) && !defined(__clang__) && defined(__SANITIZE_ADDRESS__)
+/* gcc's asan somehow doesn't like always_inline on this function. */
+__attribute__((gnu_inline)) inline
+#  else
+MOZ_ALWAYS_INLINE_EVEN_DEBUG
+#  endif
+    void*
+    operator new(size_t size) noexcept(false) {
+  return moz_xmalloc(size);
+}
+
+MOZALLOC_EXPORT_NEW MOZ_ALWAYS_INLINE_EVEN_DEBUG void* operator new(
+    size_t size, const std::nothrow_t&) noexcept(true) {
+  return malloc_impl(size);
+}
+
+MOZALLOC_EXPORT_NEW MOZ_ALWAYS_INLINE_EVEN_DEBUG void* operator new[](
+    size_t size) noexcept(false) {
+  return moz_xmalloc(size);
+}
+
+MOZALLOC_EXPORT_NEW MOZ_ALWAYS_INLINE_EVEN_DEBUG void* operator new[](
+    size_t size, const std::nothrow_t&) noexcept(true) {
+  return malloc_impl(size);
+}
+
+MOZALLOC_EXPORT_NEW MOZ_ALWAYS_INLINE_EVEN_DEBUG void operator delete(
+    void* ptr) noexcept(true) {
+  return free_impl(ptr);
+}
+
+MOZALLOC_EXPORT_NEW MOZ_ALWAYS_INLINE_EVEN_DEBUG void operator delete(
+    void* ptr, const std::nothrow_t&)noexcept(true) {
+  return free_impl(ptr);
+}
+
+MOZALLOC_EXPORT_NEW MOZ_ALWAYS_INLINE_EVEN_DEBUG void operator delete[](
+    void* ptr) noexcept(true) {
+  return free_impl(ptr);
+}
+
+MOZALLOC_EXPORT_NEW MOZ_ALWAYS_INLINE_EVEN_DEBUG void operator delete[](
+    void* ptr, const std::nothrow_t&) noexcept(true) {
+  return free_impl(ptr);
+}
+
+#  if defined(XP_WIN)
+// We provide the global sized delete overloads unconditionally because the
+// MSVC runtime headers do, despite compiling with /Zc:sizedDealloc-
+MOZALLOC_EXPORT_NEW MOZ_ALWAYS_INLINE_EVEN_DEBUG void operator delete(
+    void* ptr, size_t /*size*/) noexcept(true) {
+  return free_impl(ptr);
+}
+
+MOZALLOC_EXPORT_NEW MOZ_ALWAYS_INLINE_EVEN_DEBUG void operator delete[](
+    void* ptr, size_t /*size*/) noexcept(true) {
+  return free_impl(ptr);
+}
+#  endif
 
 /*
  * This policy is identical to MallocAllocPolicy, except it uses
  * moz_xmalloc/moz_xcalloc/moz_xrealloc instead of
  * malloc/calloc/realloc.
  */
 class InfallibleAllocPolicy {
  public: