Bug 1400096 - Don't define the operator new/delete functions as mangled in mozmem_wrap.cpp. r?njn
Now that this is a C++ file, and that the function names are not
mangled, we can just use the actual C++ names.
We do however need to replace MOZ_MEMORY_API, which implies extern "C",
with MFBT_API.
Also use the correct type for the size given to operator new. It
happened to work before because the generated code would just jump to
malloc without touching any register, but on aarch64, unsigned int was
the wrong type.
--- a/memory/build/mozmemory_wrap.cpp
+++ b/memory/build/mozmemory_wrap.cpp
@@ -9,61 +9,62 @@
/* 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
-/* operator new(unsigned int) */
-MOZ_MEMORY_API void*
-_Znwj(unsigned int size)
+#include <new>
+
+MFBT_API void*
+operator new(size_t size)
{
return malloc_impl(size);
}
-/* operator new[](unsigned int) */
-MOZ_MEMORY_API void*
-_Znaj(unsigned int size)
+
+MFBT_API void*
+operator new[](size_t size)
{
return malloc_impl(size);
}
-/* operator delete(void*) */
-MOZ_MEMORY_API void
-_ZdlPv(void* ptr)
+
+MFBT_API void
+operator delete(void* ptr)
{
free_impl(ptr);
}
-/* operator delete[](void*) */
-MOZ_MEMORY_API void
-_ZdaPv(void* ptr)
+
+MFBT_API void
+operator delete[](void* ptr)
{
free_impl(ptr);
}
-/*operator new(unsigned int, std::nothrow_t const&)*/
-MOZ_MEMORY_API void*
-_ZnwjRKSt9nothrow_t(unsigned int size)
+
+MFBT_API void*
+operator new(size_t size, std::nothrow_t const&)
{
return malloc_impl(size);
}
-/*operator new[](unsigned int, std::nothrow_t const&)*/
-MOZ_MEMORY_API void*
-_ZnajRKSt9nothrow_t(unsigned int size)
+
+MFBT_API void*
+operator new[](size_t size, std::nothrow_t const&)
{
return malloc_impl(size);
}
-/* operator delete(void*, std::nothrow_t const&) */
-MOZ_MEMORY_API void
-_ZdlPvRKSt9nothrow_t(void* ptr)
+
+MFBT_API void
+operator delete(void* ptr, std::nothrow_t const&)
{
free_impl(ptr);
}
-/* operator delete[](void*, std::nothrow_t const&) */
-MOZ_MEMORY_API void
-_ZdaPvRKSt9nothrow_t(void* ptr)
+
+MFBT_API void
+operator delete[](void* ptr, std::nothrow_t const&)
{
free_impl(ptr);
}
#endif
/* strndup and strdup may be defined as macros in string.h, which would
* clash with the definitions below. */
#undef strndup