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.

--HG--
extra : rebase_source : 8045f30e9c609dd7d922c77d85ac017638df6961
This commit is contained in:
Mike Hommey 2017-09-15 10:28:33 +09:00
parent 9741c8e076
commit f3bff41d59

View File

@ -14,51 +14,52 @@
#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);
}