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)
This commit is contained in:
Andreea Pavel 2019-06-28 01:03:23 +03:00
parent 796eb812c0
commit f145bcfd98
6 changed files with 118 additions and 119 deletions

View File

@ -15,6 +15,35 @@
#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

View File

@ -60,11 +60,13 @@
// 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
@ -109,6 +111,9 @@
# 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

View File

@ -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"

View File

@ -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 */

View File

@ -6,7 +6,6 @@
NoVisibilityFlags()
EXPORTS.mozilla += [
'cxxalloc.h',
'mozalloc.h',
'mozalloc_abort.h',
'mozalloc_oom.h',
@ -36,11 +35,6 @@ 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']

View File

@ -103,16 +103,95 @@ 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