mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-07-22 04:03:11 +00:00
Replace experimental_infallible_new with compile-time flag
The runtime option aborted on every OOM, breaking new(std::nothrow) semantics. Replace with configure-time --enable-cxx-infallible-new (default off): when on, throwing new aborts (size logged) and nothrow returns null; when off, standard new_handler + bad_alloc / null behavior is preserved. Under LTO the on-path lets the compiler prove operator new is no-throw.
This commit is contained in:
@@ -468,6 +468,13 @@
|
||||
/* Are C++ exceptions enabled? */
|
||||
#undef JEMALLOC_HAVE_CXX_EXCEPTIONS
|
||||
|
||||
/*
|
||||
* If defined, throwing operator new aborts on OOM (with size logged) instead
|
||||
* of throwing std::bad_alloc. Nothrow new still returns null. With LTO this
|
||||
* lets the compiler prove operator new is no-throw and elide exception cleanup.
|
||||
*/
|
||||
#undef JEMALLOC_INFALLIBLE_NEW
|
||||
|
||||
/* Performs additional size checks when defined. */
|
||||
#undef JEMALLOC_OPT_SIZE_CHECKS
|
||||
|
||||
|
||||
@@ -30,7 +30,6 @@ extern void (*JET_MUTABLE junk_alloc_callback)(void *ptr, size_t size);
|
||||
extern void (*JET_MUTABLE invalid_conf_abort)(void);
|
||||
extern bool opt_utrace;
|
||||
extern bool opt_xmalloc;
|
||||
extern bool opt_experimental_infallible_new;
|
||||
extern bool opt_experimental_tcache_gc;
|
||||
extern bool opt_zero;
|
||||
extern unsigned opt_narenas;
|
||||
|
||||
@@ -238,6 +238,18 @@ static const bool config_enable_cxx =
|
||||
#endif
|
||||
;
|
||||
|
||||
/*
|
||||
* Whether the throwing operator new aborts on OOM instead of throwing
|
||||
* std::bad_alloc (--enable-cxx-infallible-new).
|
||||
*/
|
||||
static const bool config_infallible_new =
|
||||
#ifdef JEMALLOC_INFALLIBLE_NEW
|
||||
true
|
||||
#else
|
||||
false
|
||||
#endif
|
||||
;
|
||||
|
||||
#if defined(_WIN32) || defined(__APPLE__) || defined(JEMALLOC_HAVE_SCHED_GETCPU)
|
||||
/* Currently percpu_arena depends on sched_getcpu. */
|
||||
#define JEMALLOC_PERCPU_ARENA
|
||||
|
||||
Reference in New Issue
Block a user