mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-05-01 09:37:50 +03:00
Integrate auto tcache into TSD.
The embedded tcache is initialized upon tsd initialization. The avail arrays for the tbins will be allocated / deallocated accordingly during init / cleanup. With this change, the pointer to the auto tcache will always be available, as long as we have access to the TSD. tcache_available() (called in tcache_get()) is provided to check if we should use tcache.
This commit is contained in:
parent
eeabdd2466
commit
fde3e20cc0
16 changed files with 300 additions and 178 deletions
|
|
@ -275,7 +275,7 @@ static bool malloc_init_hard(void);
|
|||
* Begin miscellaneous support functions.
|
||||
*/
|
||||
|
||||
JEMALLOC_ALWAYS_INLINE_C bool
|
||||
bool
|
||||
malloc_initialized(void) {
|
||||
return (malloc_init_state == malloc_init_initialized);
|
||||
}
|
||||
|
|
@ -1536,7 +1536,7 @@ imalloc_no_sample(static_opts_t *sopts, dynamic_opts_t *dopts, tsd_t *tsd,
|
|||
|
||||
/* Fill in the tcache. */
|
||||
if (dopts->tcache_ind == TCACHE_IND_AUTOMATIC) {
|
||||
tcache = tcache_get(tsd, true);
|
||||
tcache = tcache_get(tsd);
|
||||
} else if (dopts->tcache_ind == TCACHE_IND_NONE) {
|
||||
tcache = NULL;
|
||||
} else {
|
||||
|
|
@ -2056,7 +2056,7 @@ je_realloc(void *ptr, size_t size) {
|
|||
/* realloc(ptr, 0) is equivalent to free(ptr). */
|
||||
UTRACE(ptr, 0, 0);
|
||||
tsd = tsd_fetch();
|
||||
ifree(tsd, ptr, tcache_get(tsd, false), true);
|
||||
ifree(tsd, ptr, tcache_get(tsd), true);
|
||||
return NULL;
|
||||
}
|
||||
size = 1;
|
||||
|
|
@ -2113,9 +2113,9 @@ je_free(void *ptr) {
|
|||
tsd_t *tsd = tsd_fetch();
|
||||
witness_assert_lockless(tsd_tsdn(tsd));
|
||||
if (likely(!malloc_slow)) {
|
||||
ifree(tsd, ptr, tcache_get(tsd, false), false);
|
||||
ifree(tsd, ptr, tcache_get(tsd), false);
|
||||
} else {
|
||||
ifree(tsd, ptr, tcache_get(tsd, false), true);
|
||||
ifree(tsd, ptr, tcache_get(tsd), true);
|
||||
}
|
||||
witness_assert_lockless(tsd_tsdn(tsd));
|
||||
}
|
||||
|
|
@ -2393,7 +2393,7 @@ je_rallocx(void *ptr, size_t size, int flags) {
|
|||
tcache = tcaches_get(tsd, MALLOCX_TCACHE_GET(flags));
|
||||
}
|
||||
} else {
|
||||
tcache = tcache_get(tsd, true);
|
||||
tcache = tcache_get(tsd);
|
||||
}
|
||||
|
||||
old_usize = isalloc(tsd_tsdn(tsd), ptr);
|
||||
|
|
@ -2605,7 +2605,7 @@ je_dallocx(void *ptr, int flags) {
|
|||
tcache = tcaches_get(tsd, MALLOCX_TCACHE_GET(flags));
|
||||
}
|
||||
} else {
|
||||
tcache = tcache_get(tsd, false);
|
||||
tcache = tcache_get(tsd);
|
||||
}
|
||||
|
||||
UTRACE(ptr, 0, 0);
|
||||
|
|
@ -2652,7 +2652,7 @@ je_sdallocx(void *ptr, size_t size, int flags) {
|
|||
tcache = tcaches_get(tsd, MALLOCX_TCACHE_GET(flags));
|
||||
}
|
||||
} else {
|
||||
tcache = tcache_get(tsd, false);
|
||||
tcache = tcache_get(tsd);
|
||||
}
|
||||
|
||||
UTRACE(ptr, 0, 0);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue