mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
bug 559263 - make jemalloc work with android, follow up patch r=ted
This commit is contained in:
parent
18d49dc041
commit
4859e2ab1d
14
configure.in
14
configure.in
@ -7171,6 +7171,8 @@ if test "$MOZ_MEMORY"; then
|
||||
*-android*)
|
||||
AC_DEFINE(MOZ_MEMORY_LINUX)
|
||||
AC_DEFINE(MOZ_MEMORY_ANDROID)
|
||||
_WRAP_MALLOC=1
|
||||
export WRAP_MALLOC_LIB="-L$_objdir/dist/lib -lmozalloc"
|
||||
;;
|
||||
*)
|
||||
AC_MSG_ERROR([--enable-jemalloc not supported on ${target}])
|
||||
@ -7200,7 +7202,7 @@ MOZ_ARG_ENABLE_BOOL(wrap-malloc,
|
||||
|
||||
if test -n "$_WRAP_MALLOC"; then
|
||||
if test "$GNU_CC"; then
|
||||
WRAP_MALLOC_CFLAGS="${LDFLAGS} -Wl,--wrap -Wl,malloc -Wl,--wrap -Wl,calloc -Wl,--wrap -Wl,valloc -Wl,--wrap -Wl,free -Wl,--wrap -Wl,realloc -Wl,--wrap -Wl,memalign -Wl,--wrap -Wl,__builtin_new -Wl,--wrap -Wl,__builtin_vec_new -Wl,--wrap -Wl,__builtin_delete -Wl,--wrap -Wl,__builtin_vec_delete -Wl,--wrap -Wl,PR_Free -Wl,--wrap -Wl,PR_Malloc -Wl,--wrap -Wl,PR_Calloc -Wl,--wrap -Wl,PR_Realloc -Wl,--wrap -Wl,strdup -Wl,--wrap -Wl,strndup"
|
||||
WRAP_MALLOC_CFLAGS="${LDFLAGS} -Wl,--wrap -Wl,malloc -Wl,--wrap -Wl,calloc -Wl,--wrap -Wl,valloc -Wl,--wrap -Wl,free -Wl,--wrap -Wl,realloc -Wl,--wrap -Wl,memalign -Wl,--wrap -Wl,__builtin_new -Wl,--wrap -Wl,__builtin_vec_new -Wl,--wrap -Wl,__builtin_delete -Wl,--wrap -Wl,__builtin_vec_delete -Wl,--wrap -Wl,PR_Free -Wl,--wrap -Wl,PR_Malloc -Wl,--wrap -Wl,PR_Calloc -Wl,--wrap -Wl,PR_Realloc -Wl,--wrap -Wl,strdup -Wl,--wrap -Wl,strndup -Wl,--wrap -Wl,posix_memalign"
|
||||
MKSHLIB='$(CXX) $(DSO_LDOPTS) $(WRAP_MALLOC_CFLAGS) $(WRAP_MALLOC_LIB) -o $@'
|
||||
fi
|
||||
fi
|
||||
@ -9007,6 +9009,13 @@ unset CONFIG_FILES
|
||||
# No need to run subconfigures when building with LIBXUL_SDK_DIR
|
||||
if test "$COMPILE_ENVIRONMENT" -a -z "$LIBXUL_SDK_DIR"; then
|
||||
|
||||
if test -n "$MOZ_THUMB2"; then
|
||||
_SUBDIR_CONFIG_ARGS="$_SUBDIR_CONFIG_ARGS --enable-thumb2"
|
||||
fi
|
||||
if test -n "$_WRAP_MALLOC"; then
|
||||
_SUBDIR_CONFIG_ARGS="$_SUBDIR_CONFIG_ARGS --enable-wrap-malloc"
|
||||
fi
|
||||
|
||||
if test -z "$MOZ_NATIVE_NSPR"; then
|
||||
ac_configure_args="$_SUBDIR_CONFIG_ARGS --with-dist-prefix=$MOZ_BUILD_ROOT/dist --with-mozilla"
|
||||
if test -z "$MOZ_DEBUG"; then
|
||||
@ -9024,9 +9033,6 @@ if test -z "$MOZ_NATIVE_NSPR"; then
|
||||
if test -n "$USE_ARM_KUSER"; then
|
||||
ac_configure_args="$ac_configure_args --with-arm-kuser"
|
||||
fi
|
||||
if test -n "$MOZ_THUMB2"; then
|
||||
ac_configure_args="$ac_configure_args --enable-thumb2"
|
||||
fi
|
||||
AC_OUTPUT_SUBDIRS(nsprpub)
|
||||
ac_configure_args="$_SUBDIR_CONFIG_ARGS"
|
||||
fi
|
||||
|
@ -4368,7 +4368,7 @@ MOZ_ARG_ENABLE_BOOL(wrap-malloc,
|
||||
|
||||
if test -n "$_WRAP_MALLOC"; then
|
||||
if test "$GNU_CC"; then
|
||||
WRAP_MALLOC_CFLAGS="${LDFLAGS} -Wl,--wrap -Wl,malloc -Wl,--wrap -Wl,calloc -Wl,--wrap -Wl,valloc -Wl,--wrap -Wl,free -Wl,--wrap -Wl,realloc -Wl,--wrap -Wl,memalign -Wl,--wrap -Wl,__builtin_new -Wl,--wrap -Wl,__builtin_vec_new -Wl,--wrap -Wl,__builtin_delete -Wl,--wrap -Wl,__builtin_vec_delete -Wl,--wrap -Wl,PR_Free -Wl,--wrap -Wl,PR_Malloc -Wl,--wrap -Wl,PR_Calloc -Wl,--wrap -Wl,PR_Realloc -Wl,--wrap -Wl,strdup -Wl,--wrap -Wl,strndup"
|
||||
WRAP_MALLOC_CFLAGS="${LDFLAGS} -Wl,--wrap -Wl,malloc -Wl,--wrap -Wl,calloc -Wl,--wrap -Wl,valloc -Wl,--wrap -Wl,free -Wl,--wrap -Wl,realloc -Wl,--wrap -Wl,memalign -Wl,--wrap -Wl,__builtin_new -Wl,--wrap -Wl,__builtin_vec_new -Wl,--wrap -Wl,__builtin_delete -Wl,--wrap -Wl,__builtin_vec_delete -Wl,--wrap -Wl,PR_Free -Wl,--wrap -Wl,PR_Malloc -Wl,--wrap -Wl,PR_Calloc -Wl,--wrap -Wl,PR_Realloc -Wl,--wrap -Wl,strdup -Wl,--wrap -Wl,strndup -Wl,--wrap -Wl,posix_memalign"
|
||||
MKSHLIB='$(CXX) $(DSO_LDOPTS) $(WRAP_MALLOC_CFLAGS) $(WRAP_MALLOC_LIB) -o $@'
|
||||
fi
|
||||
fi
|
||||
|
@ -5770,6 +5770,8 @@ inline void sys_free(void* ptr) {return free(ptr);}
|
||||
#define calloc(a, b) je_calloc(a, b)
|
||||
#define realloc(a, b) je_realloc(a, b)
|
||||
#define free(a) je_free(a)
|
||||
#define posix_memalign(a, b, c) je_posix_memalign(a, b, c)
|
||||
|
||||
char *je_strndup(const char *src, size_t len) {
|
||||
char* dst = (char*)je_malloc(len + 1);
|
||||
if(dst)
|
||||
|
@ -59,8 +59,8 @@ ifneq (,$(findstring mozalloc,$(WRAP_MALLOC_LIB)))
|
||||
EXTRA_DSO_LDOPTS += $(DIST)/lib/libjemalloc.a
|
||||
WRAP_MALLOC_LIB=
|
||||
WRAP_MALLOC_CFLAGS=
|
||||
DEFINES += -DWRAP_MALLOC
|
||||
CSRCS = wraps.c
|
||||
DEFINES += -DWRAP_MALLOC_WITH_JEMALLOC
|
||||
CSRCS = ld_malloc_wrappers.c
|
||||
ifeq (,$(filter-out Linux,$(OS_TARGET)))
|
||||
EXTRA_DSO_LDOPTS += -lpthread
|
||||
endif
|
||||
|
140
memory/mozalloc/ld_malloc_wrappers.c
Normal file
140
memory/mozalloc/ld_malloc_wrappers.c
Normal file
@ -0,0 +1,140 @@
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Mozilla Foundation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Brad Lassey <blassey@mozilla.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include <stddef.h> // for size_t
|
||||
#include <stdlib.h> // for malloc, free
|
||||
#include "mozalloc.h"
|
||||
#include <malloc.h>
|
||||
|
||||
#ifdef __malloc_hook
|
||||
static void* moz_malloc_hook(size_t size, const void *caller)
|
||||
{
|
||||
return moz_malloc(size);
|
||||
}
|
||||
|
||||
static void* moz_realloc_hook(void *ptr, size_t size, const void *caller)
|
||||
{
|
||||
return moz_realloc(ptr, size);
|
||||
}
|
||||
|
||||
static void moz_free_hook(void *ptr, const void *caller)
|
||||
{
|
||||
moz_free(ptr);
|
||||
}
|
||||
|
||||
static void* moz_memalign_hook(size_t align, size_t size, const void *caller)
|
||||
{
|
||||
return moz_memalign(align, size);
|
||||
}
|
||||
|
||||
static void
|
||||
moz_malloc_init_hook (void)
|
||||
{
|
||||
__malloc_hook = moz_malloc_hook;
|
||||
__realloc_hook = moz_realloc_hook;
|
||||
__free_hook = moz_free_hook;
|
||||
__memalign_hook = moz_memalign_hook;
|
||||
}
|
||||
|
||||
/* Override initializing hook from the C library. */
|
||||
void (*__malloc_initialize_hook) (void) = moz_malloc_init_hook;
|
||||
#endif
|
||||
|
||||
inline void __wrap_free(void* ptr)
|
||||
{
|
||||
moz_free(ptr);
|
||||
}
|
||||
|
||||
inline void* __wrap_malloc(size_t size)
|
||||
{
|
||||
return moz_malloc(size);
|
||||
}
|
||||
|
||||
inline void* __wrap_realloc(void* ptr, size_t size)
|
||||
{
|
||||
return moz_realloc(ptr, size);
|
||||
}
|
||||
|
||||
inline void* __wrap_calloc(size_t num, size_t size)
|
||||
{
|
||||
return moz_calloc(num, size);
|
||||
}
|
||||
|
||||
inline void* __wrap_valloc(size_t size)
|
||||
{
|
||||
return moz_valloc(size);
|
||||
}
|
||||
|
||||
inline void* __wrap_memalign(size_t align, size_t size)
|
||||
{
|
||||
return moz_memalign(align, size);
|
||||
}
|
||||
|
||||
inline char* __wrap_strdup(char* str)
|
||||
{
|
||||
return moz_strdup(str);
|
||||
}
|
||||
|
||||
inline char* __wrap_strndup(const char* str, size_t size) {
|
||||
return moz_strndup(str, size);
|
||||
}
|
||||
|
||||
|
||||
inline void __wrap_PR_Free(void* ptr)
|
||||
{
|
||||
moz_free(ptr);
|
||||
}
|
||||
|
||||
inline void* __wrap_PR_Malloc(size_t size)
|
||||
{
|
||||
return moz_malloc(size);
|
||||
}
|
||||
|
||||
inline void* __wrap_PR_Realloc(void* ptr, size_t size)
|
||||
{
|
||||
return moz_realloc(ptr, size);
|
||||
}
|
||||
|
||||
inline void* __wrap_PR_Calloc(size_t num, size_t size)
|
||||
{
|
||||
return moz_calloc(num, size);
|
||||
}
|
||||
|
||||
inline int __wrap_posix_memalign(void **memptr, size_t alignment, size_t size)
|
||||
{
|
||||
return moz_posix_memalign(memptr, alignment, size);
|
||||
}
|
@ -74,7 +74,7 @@
|
||||
#define UNLIKELY(x) (x)
|
||||
#endif
|
||||
|
||||
#if defined(MOZ_MEMORY_ANDROID) || defined(WRAP_MALLOC)
|
||||
#if defined(MOZ_MEMORY_ANDROID) || defined(WRAP_MALLOC_WITH_JEMALLOC)
|
||||
#include "jemalloc.h"
|
||||
#define malloc(a) je_malloc(a)
|
||||
#define valloc(a) je_valloc(a)
|
||||
@ -83,6 +83,7 @@
|
||||
#define free(a) je_free(a)
|
||||
#define strdup(a) je_strdup(a)
|
||||
#define strndup(a, b) je_strndup(a, b)
|
||||
#define posix_memalign(a, b, c) je_posix_memalign(a, b, c)
|
||||
#endif
|
||||
|
||||
void
|
||||
|
@ -1,102 +0,0 @@
|
||||
#include <stddef.h> // for size_t
|
||||
#include <stdlib.h> // for malloc, free
|
||||
#include "mozalloc.h"
|
||||
#ifdef MOZ_MEMORY_ANDROID
|
||||
#include <android/log.h>
|
||||
#define LOG(args...) __android_log_print(ANDROID_LOG_INFO, "wrap", args)
|
||||
#endif
|
||||
#include <malloc.h>
|
||||
|
||||
#ifdef __malloc_hook
|
||||
static void* moz_malloc_hook(size_t size, const void *caller)
|
||||
{
|
||||
return moz_malloc(size);
|
||||
}
|
||||
|
||||
static void* moz_realloc_hook(void *ptr, size_t size, const void *caller)
|
||||
{
|
||||
return moz_realloc(ptr, size);
|
||||
}
|
||||
|
||||
static void moz_free_hook(void *ptr, const void *caller)
|
||||
{
|
||||
moz_free(ptr);
|
||||
}
|
||||
|
||||
static void* moz_memalign_hook(size_t align, size_t size, const void *caller)
|
||||
{
|
||||
return moz_memalign(align, size);
|
||||
}
|
||||
|
||||
static void
|
||||
moz_malloc_init_hook (void)
|
||||
{
|
||||
__malloc_hook = moz_malloc_hook;
|
||||
__realloc_hook = moz_realloc_hook;
|
||||
__free_hook = moz_free_hook;
|
||||
__memalign_hook = moz_memalign_hook;
|
||||
}
|
||||
|
||||
/* Override initializing hook from the C library. */
|
||||
void (*__malloc_initialize_hook) (void) = moz_malloc_init_hook;
|
||||
#endif
|
||||
|
||||
inline void __wrap_free(void* ptr)
|
||||
{
|
||||
moz_free(ptr);
|
||||
}
|
||||
|
||||
inline void* __wrap_malloc(size_t size)
|
||||
{
|
||||
return moz_malloc(size);
|
||||
}
|
||||
|
||||
inline void* __wrap_realloc(void* ptr, size_t size)
|
||||
{
|
||||
return moz_realloc(ptr, size);
|
||||
}
|
||||
|
||||
inline void* __wrap_calloc(size_t num, size_t size)
|
||||
{
|
||||
return moz_calloc(num, size);
|
||||
}
|
||||
|
||||
inline void* __wrap_valloc(size_t size)
|
||||
{
|
||||
return moz_valloc(size);
|
||||
}
|
||||
|
||||
inline void* __wrap_memalign(size_t align, size_t size)
|
||||
{
|
||||
return moz_memalign(align, size);
|
||||
}
|
||||
|
||||
inline char* __wrap_strdup(char* str)
|
||||
{
|
||||
return moz_strdup(str);
|
||||
}
|
||||
|
||||
inline char* __wrap_strndup(const char* str, size_t size) {
|
||||
return moz_strndup(str, size);
|
||||
}
|
||||
|
||||
|
||||
inline void __wrap_PR_Free(void* ptr)
|
||||
{
|
||||
moz_free(ptr);
|
||||
}
|
||||
|
||||
inline void* __wrap_PR_Malloc(size_t size)
|
||||
{
|
||||
return moz_malloc(size);
|
||||
}
|
||||
|
||||
inline void* __wrap_PR_Realloc(void* ptr, size_t size)
|
||||
{
|
||||
return moz_realloc(ptr, size);
|
||||
}
|
||||
|
||||
inline void* __wrap_PR_Calloc(size_t num, size_t size)
|
||||
{
|
||||
return moz_calloc(num, size);
|
||||
}
|
Loading…
Reference in New Issue
Block a user