Bug 1400096 - Don't define the operator new/delete functions as mangled in mozmem_wrap.cpp. r=njn
authorMike Hommey <mh+mozilla@glandium.org>
Fri, 15 Sep 2017 10:28:33 +0900
changeset 665562 738de4c495b950a459772024a74ba9bc32d0c68f
parent 665561 09aa9fae62808374cf8d78e01a8e7ac8c428b3d2
child 665563 7f7d9a165b2fd988d4c8153352e0301dc9f364c5
push id80115
push userbmo:eoger@fastmail.com
push dateFri, 15 Sep 2017 18:29:01 +0000
reviewersnjn
bugs1400096
milestone57.0a1
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.
memory/build/mozmemory_wrap.cpp
--- 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