Support for jemalloc to replace dlmalloc.

To use jemalloc, add MALLOC_IMPL = jemalloc in a board config file
and you get the new version automatically.

Update the pthread_create_key tests since jemalloc uses a few keys.
Add a new test to verify memalign works as expected.

Bug: 981363

Change-Id: I16eb152b291a95bd2499e90492fc6b4bd7053836
This commit is contained in:
Christopher Ferris
2014-05-08 11:14:03 -07:00
parent afb89c2a01
commit 72bbd42357
13 changed files with 206 additions and 80 deletions

View File

@@ -498,6 +498,16 @@ ifeq ($(strip $(DEBUG_BIONIC_LIBC)),true)
libc_common_cflags += -DDEBUG
endif
ifeq ($(MALLOC_IMPL),jemalloc)
libc_common_cflags += -DUSE_JEMALLOC
libc_malloc_src := bionic/jemalloc.cpp
else
libc_common_cflags += -DUSE_DLMALLOC
libc_malloc_src := bionic/dlmalloc.cpp
endif
# To customize dlmalloc's alignment, set BOARD_MALLOC_ALIGNMENT in
# the appropriate BoardConfig.mk file.
#
@@ -526,6 +536,10 @@ libc_common_c_includes := \
$(LOCAL_PATH)/stdlib \
$(LOCAL_PATH)/stdio \
ifeq ($(MALLOC_IMPL),jemalloc)
libc_common_c_includes += external/jemalloc/include
endif
# ========================================================
# Add in the arch-specific flags.
# Must be called with $(eval).
@@ -812,6 +826,11 @@ LOCAL_WHOLE_STATIC_LIBRARIES := \
libc_syscalls \
libc_tzcode \
ifeq ($(MALLOC_IMPL),jemalloc)
LOCAL_WHOLE_STATIC_LIBRARIES += \
libjemalloc
endif
LOCAL_SYSTEM_SHARED_LIBRARIES :=
# TODO: split out the asflags.
@@ -866,7 +885,7 @@ include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
$(libc_arch_static_src_files) \
$(libc_static_common_src_files) \
bionic/dlmalloc.c \
$(libc_malloc_src) \
bionic/malloc_debug_common.cpp \
bionic/libc_init_static.cpp \
@@ -896,11 +915,10 @@ LOCAL_CFLAGS := $(libc_common_cflags) -Werror
LOCAL_CONLYFLAGS := $(libc_common_conlyflags)
LOCAL_CPPFLAGS := $(libc_common_cppflags)
LOCAL_C_INCLUDES := $(libc_common_c_includes)
LOCAL_SRC_FILES := \
$(libc_arch_dynamic_src_files) \
$(libc_static_common_src_files) \
bionic/dlmalloc.c \
$(libc_malloc_src) \
bionic/malloc_debug_common.cpp \
bionic/debug_mapinfo.cpp \
bionic/debug_stacktrace.cpp \