Move relevant index into the ehooks_t itself.
It's always passed into the ehooks; keeping it colocated lets us avoid passing the arena everywhere.
This commit is contained in:
parent
c792f3e4ab
commit
57fe99d4be
@ -3,7 +3,7 @@
|
||||
|
||||
static inline unsigned
|
||||
base_ind_get(const base_t *base) {
|
||||
return base->ind;
|
||||
return ehooks_ind_get(&base->ehooks);
|
||||
}
|
||||
|
||||
static inline bool
|
||||
|
@ -20,9 +20,6 @@ struct base_block_s {
|
||||
};
|
||||
|
||||
struct base_s {
|
||||
/* Associated arena's index within the arenas array. */
|
||||
unsigned ind;
|
||||
|
||||
/*
|
||||
* User-configurable extent hook functions.
|
||||
*/
|
||||
|
@ -20,6 +20,12 @@ extern const extent_hooks_t ehooks_default_extent_hooks;
|
||||
|
||||
typedef struct ehooks_s ehooks_t;
|
||||
struct ehooks_s {
|
||||
/*
|
||||
* The user-visible id that goes with the ehooks (i.e. that of the base
|
||||
* they're a part of, the associated arena's index within the arenas
|
||||
* array).
|
||||
*/
|
||||
unsigned ind;
|
||||
/* Logically an extent_hooks_t *. */
|
||||
atomic_p_t ptr;
|
||||
};
|
||||
@ -80,7 +86,12 @@ ehooks_post_reentrancy(tsdn_t *tsdn) {
|
||||
}
|
||||
|
||||
/* Beginning of the public API. */
|
||||
void ehooks_init(ehooks_t *ehooks, extent_hooks_t *extent_hooks);
|
||||
void ehooks_init(ehooks_t *ehooks, extent_hooks_t *extent_hooks, unsigned ind);
|
||||
|
||||
static inline unsigned
|
||||
ehooks_ind_get(const ehooks_t *ehooks) {
|
||||
return ehooks->ind;
|
||||
}
|
||||
|
||||
static inline void
|
||||
ehooks_set_extent_hooks_ptr(ehooks_t *ehooks, extent_hooks_t *extent_hooks) {
|
||||
|
@ -346,7 +346,7 @@ base_new(tsdn_t *tsdn, unsigned ind, extent_hooks_t *extent_hooks) {
|
||||
* memory, and then initialize the ehooks within the base_t.
|
||||
*/
|
||||
ehooks_t fake_ehooks;
|
||||
ehooks_init(&fake_ehooks, extent_hooks);
|
||||
ehooks_init(&fake_ehooks, extent_hooks, ind);
|
||||
|
||||
base_block_t *block = base_block_alloc(tsdn, NULL, &fake_ehooks, ind,
|
||||
&pind_last, &extent_sn_next, sizeof(base_t), QUANTUM);
|
||||
@ -359,8 +359,7 @@ base_new(tsdn_t *tsdn, unsigned ind, extent_hooks_t *extent_hooks) {
|
||||
size_t base_size = ALIGNMENT_CEILING(sizeof(base_t), base_alignment);
|
||||
base_t *base = (base_t *)base_extent_bump_alloc_helper(&block->edata,
|
||||
&gap_size, base_size, base_alignment);
|
||||
base->ind = ind;
|
||||
ehooks_init(&base->ehooks, extent_hooks);
|
||||
ehooks_init(&base->ehooks, extent_hooks, ind);
|
||||
if (malloc_mutex_init(&base->mtx, "base", WITNESS_RANK_BASE,
|
||||
malloc_mutex_rank_exclusive)) {
|
||||
base_unmap(tsdn, &fake_ehooks, ind, block, block->size);
|
||||
@ -411,7 +410,7 @@ extent_hooks_t *
|
||||
base_extent_hooks_set(base_t *base, extent_hooks_t *extent_hooks) {
|
||||
extent_hooks_t *old_extent_hooks =
|
||||
ehooks_get_extent_hooks_ptr(&base->ehooks);
|
||||
ehooks_init(&base->ehooks, extent_hooks);
|
||||
ehooks_init(&base->ehooks, extent_hooks, ehooks_ind_get(&base->ehooks));
|
||||
return old_extent_hooks;
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,9 @@
|
||||
#include "jemalloc/internal/ehooks.h"
|
||||
#include "jemalloc/internal/extent_mmap.h"
|
||||
|
||||
void ehooks_init(ehooks_t *ehooks, extent_hooks_t *extent_hooks) {
|
||||
void
|
||||
ehooks_init(ehooks_t *ehooks, extent_hooks_t *extent_hooks, unsigned ind) {
|
||||
ehooks->ind = ind;
|
||||
ehooks_set_extent_hooks_ptr(ehooks, extent_hooks);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user