mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-07-08 23:07:20 +03:00
Add opt.experimental_infallible_new.
This allows a guarantee that operator new never throws. Fix the .gitignore rules to include test/integration/cpp while we're here.
This commit is contained in:
parent
0689448b1e
commit
4452a4812f
14 changed files with 134 additions and 3 deletions
|
|
@ -141,6 +141,7 @@ void (*junk_free_callback)(void *ptr, size_t size) = &default_junk_free;
|
|||
|
||||
bool opt_utrace = false;
|
||||
bool opt_xmalloc = false;
|
||||
bool opt_experimental_infallible_new = false;
|
||||
bool opt_zero = false;
|
||||
unsigned opt_narenas = 0;
|
||||
fxp_t opt_narenas_ratio = FXP_INIT_INT(4);
|
||||
|
|
@ -1307,6 +1308,12 @@ malloc_conf_init_helper(sc_data_t *sc_data, unsigned bin_shard_sizes[SC_NBINS],
|
|||
if (config_xmalloc) {
|
||||
CONF_HANDLE_BOOL(opt_xmalloc, "xmalloc")
|
||||
}
|
||||
if (config_enable_cxx) {
|
||||
CONF_HANDLE_BOOL(
|
||||
opt_experimental_infallible_new,
|
||||
"experimental_infallible_new")
|
||||
}
|
||||
|
||||
CONF_HANDLE_BOOL(opt_tcache, "tcache")
|
||||
CONF_HANDLE_SIZE_T(opt_tcache_max, "tcache_max",
|
||||
0, TCACHE_MAXCLASS_LIMIT, CONF_DONT_CHECK_MIN,
|
||||
|
|
|
|||
|
|
@ -56,6 +56,12 @@ void operator delete[](void* ptr, std::size_t size, std::align_val_t al) noexcep
|
|||
JEMALLOC_NOINLINE
|
||||
static void *
|
||||
handleOOM(std::size_t size, bool nothrow) {
|
||||
if (opt_experimental_infallible_new) {
|
||||
safety_check_fail("<jemalloc>: Allocation failed and "
|
||||
"opt.experimental_infallible_new is true. Aborting.\n");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void *ptr = nullptr;
|
||||
|
||||
while (ptr == nullptr) {
|
||||
|
|
@ -93,7 +99,6 @@ fallback_impl(std::size_t size) noexcept(IsNoExcept) {
|
|||
if (likely(ptr != nullptr)) {
|
||||
return ptr;
|
||||
}
|
||||
|
||||
return handleOOM(size, IsNoExcept);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1501,6 +1501,7 @@ stats_general_print(emitter_t *emitter) {
|
|||
OPT_WRITE_BOOL("zero")
|
||||
OPT_WRITE_BOOL("utrace")
|
||||
OPT_WRITE_BOOL("xmalloc")
|
||||
OPT_WRITE_BOOL("experimental_infallible_new")
|
||||
OPT_WRITE_BOOL("tcache")
|
||||
OPT_WRITE_SIZE_T("tcache_max")
|
||||
OPT_WRITE_UNSIGNED("tcache_nslots_small_min")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue