remove malloc_init() off the fastpath
This commit is contained in:
parent
997d86acc6
commit
325e3305fc
@ -47,7 +47,6 @@ tsd_get_allocates(void) {
|
||||
/* Get/set. */
|
||||
JEMALLOC_ALWAYS_INLINE tsd_t *
|
||||
tsd_get(bool init) {
|
||||
assert(tsd_booted);
|
||||
return &tsd_tls;
|
||||
}
|
||||
JEMALLOC_ALWAYS_INLINE void
|
||||
|
@ -40,7 +40,6 @@ tsd_get_allocates(void) {
|
||||
/* Get/set. */
|
||||
JEMALLOC_ALWAYS_INLINE tsd_t *
|
||||
tsd_get(bool init) {
|
||||
assert(tsd_booted);
|
||||
return &tsd_tls;
|
||||
}
|
||||
|
||||
|
@ -2110,9 +2110,8 @@ label_invalid_alignment:
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
/* Returns the errno-style error code of the allocation. */
|
||||
JEMALLOC_ALWAYS_INLINE int
|
||||
imalloc(static_opts_t *sopts, dynamic_opts_t *dopts) {
|
||||
JEMALLOC_ALWAYS_INLINE bool
|
||||
imalloc_init_check(static_opts_t *sopts, dynamic_opts_t *dopts) {
|
||||
if (unlikely(!malloc_initialized()) && unlikely(malloc_init())) {
|
||||
if (config_xmalloc && unlikely(opt_xmalloc)) {
|
||||
malloc_write(sopts->oom_string);
|
||||
@ -2122,6 +2121,16 @@ imalloc(static_opts_t *sopts, dynamic_opts_t *dopts) {
|
||||
set_errno(ENOMEM);
|
||||
*dopts->result = NULL;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Returns the errno-style error code of the allocation. */
|
||||
JEMALLOC_ALWAYS_INLINE int
|
||||
imalloc(static_opts_t *sopts, dynamic_opts_t *dopts) {
|
||||
if (tsd_get_allocates() && !imalloc_init_check(sopts, dopts)) {
|
||||
return ENOMEM;
|
||||
}
|
||||
|
||||
@ -2134,6 +2143,10 @@ imalloc(static_opts_t *sopts, dynamic_opts_t *dopts) {
|
||||
sopts->slow = false;
|
||||
return imalloc_body(sopts, dopts, tsd);
|
||||
} else {
|
||||
if (!tsd_get_allocates() && !imalloc_init_check(sopts, dopts)) {
|
||||
return ENOMEM;
|
||||
}
|
||||
|
||||
sopts->slow = true;
|
||||
return imalloc_body(sopts, dopts, tsd);
|
||||
}
|
||||
|
12
src/tsd.c
12
src/tsd.c
@ -280,11 +280,13 @@ tsd_fetch_slow(tsd_t *tsd, bool minimal) {
|
||||
tsd_slow_update(tsd);
|
||||
} else if (tsd_state_get(tsd) == tsd_state_uninitialized) {
|
||||
if (!minimal) {
|
||||
tsd_state_set(tsd, tsd_state_nominal);
|
||||
tsd_slow_update(tsd);
|
||||
/* Trigger cleanup handler registration. */
|
||||
tsd_set(tsd);
|
||||
tsd_data_init(tsd);
|
||||
if (tsd_booted) {
|
||||
tsd_state_set(tsd, tsd_state_nominal);
|
||||
tsd_slow_update(tsd);
|
||||
/* Trigger cleanup handler registration. */
|
||||
tsd_set(tsd);
|
||||
tsd_data_init(tsd);
|
||||
}
|
||||
} else {
|
||||
tsd_state_set(tsd, tsd_state_minimal_initialized);
|
||||
tsd_set(tsd);
|
||||
|
Loading…
Reference in New Issue
Block a user