jemalloc cpp new/delete bindings

Adds cpp bindings for jemalloc, along with necessary autoconf settings.
This is mostly to add sized deallocation support, which can't be added
from C directly.  Sized deallocation is ~10% microbench improvement.

* Import ax_cxx_compile_stdcxx.m4 from the autoconf repo, seems like the
  easiest way to get c++14 detection.
* Adds various other changes, like CXXFLAGS, to configure.ac.
* Adds new rules to Makefile.in for src/jemalloc-cpp.cpp, and a basic
  unittest.
* Both new and delete are overridden, to ensure jemalloc is used for
  both.
* TODO future enhancement of avoiding extra PLT thunks for new and
  delete - sdallocx and malloc are publicly exported jemalloc symbols,
  using an alias would link them directly.  Unfortunately, was having
  trouble getting it to play nice with jemalloc's namespace support.

Testing:
Tested gcc 4.8, gcc 5, gcc 5.2, clang 4.0.  Only gcc >= 5 has sized
deallocation support, verified that the rest build correctly.

Tested mac osx and Centos.

Tested --with-jemalloc-prefix and --without-export.

This resolves #202.
This commit is contained in:
Dave Watson
2016-10-23 15:56:30 -07:00
committed by Jason Evans
parent d4c5aceb7c
commit 2319152d9f
13 changed files with 905 additions and 25 deletions

View File

@@ -1,3 +1,7 @@
#ifdef __cplusplus
extern "C" {
#endif
#include <limits.h>
#ifndef SIZE_T_MAX
# define SIZE_T_MAX SIZE_MAX
@@ -47,7 +51,8 @@
* expose the minimum necessary internal utility code (to avoid re-implementing
* essentially identical code within the test infrastructure).
*/
#elif defined(JEMALLOC_INTEGRATION_TEST)
#elif defined(JEMALLOC_INTEGRATION_TEST) || \
defined(JEMALLOC_INTEGRATION_CPP_TEST)
# define JEMALLOC_MANGLE
# include "jemalloc/jemalloc@install_suffix@.h"
# include "jemalloc/internal/jemalloc_internal_defs.h"
@@ -161,3 +166,7 @@ static const bool config_debug =
if (!(e)) \
not_implemented(); \
} while (0)
#ifdef __cplusplus
}
#endif

View File

@@ -8,8 +8,8 @@
char message[ASSERT_BUFSIZE]; \
malloc_snprintf(prefix, sizeof(prefix), \
"%s:%s:%d: Failed assertion: " \
"(%s) "#cmp" (%s) --> " \
"%"pri" "#neg_cmp" %"pri": ", \
"(%s) " #cmp " (%s) --> " \
"%" pri " " #neg_cmp " %" pri ": ", \
__func__, __FILE__, __LINE__, \
#a, #b, a_, b_); \
malloc_snprintf(message, sizeof(message), __VA_ARGS__); \