Bug 1400096 - Don't define the operator new/delete functions as mangled in mozmem_wrap.cpp. r?njn draft
authorMike Hommey <mh+mozilla@glandium.org>
Fri, 15 Sep 2017 10:28:33 +0900
changeset 665219 f746c849eb390916ba004df9d5ce702c9532fc2b
parent 665218 d6874c3d967744d1a2c71638b71bdca08dd3cf93
child 731698 397bf1d1a94201d4aaff57f0928da721bd57d5d9
push id79976
push userbmo:mh+mozilla@glandium.org
push dateFri, 15 Sep 2017 05:26:57 +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