Emap: Move in alloc_ctx lookup functionality.

This commit is contained in:
David Goldblatt
2020-02-05 18:58:19 -08:00
committed by David Goldblatt
parent 65a54d7714
commit f7d9c6c42d
4 changed files with 44 additions and 37 deletions

View File

@@ -197,10 +197,4 @@ struct arena_tdata_s {
ticker_t decay_ticker;
};
/* Used to pass rtree lookup context down the path. */
struct alloc_ctx_s {
szind_t szind;
bool slab;
};
#endif /* JEMALLOC_INTERNAL_ARENA_STRUCTS_B_H */

View File

@@ -12,7 +12,6 @@
typedef struct arena_decay_s arena_decay_t;
typedef struct arena_s arena_t;
typedef struct arena_tdata_s arena_tdata_t;
typedef struct alloc_ctx_s alloc_ctx_t;
typedef enum {
percpu_arena_mode_names_base = 0, /* Used for options processing. */

View File

@@ -11,6 +11,13 @@ struct emap_s {
mutex_pool_t mtx_pool;
};
/* Used to pass rtree lookup context down the path. */
typedef struct alloc_ctx_t alloc_ctx_t;
struct alloc_ctx_t {
szind_t szind;
bool slab;
};
extern emap_t emap_global;
bool emap_init(emap_t *emap);
@@ -127,4 +134,15 @@ emap_lookup(tsdn_t *tsdn, emap_t *emap, const void *ptr) {
true);
}
/* Fills in alloc_ctx with the info in the map. */
JEMALLOC_ALWAYS_INLINE void
emap_alloc_info_lookup(tsdn_t *tsdn, emap_t *emap, void *ptr,
alloc_ctx_t *alloc_ctx) {
rtree_ctx_t rtree_ctx_fallback;
rtree_ctx_t *rtree_ctx = tsdn_rtree_ctx(tsdn, &rtree_ctx_fallback);
rtree_szind_slab_read(tsdn, &emap->rtree, rtree_ctx, (uintptr_t)ptr,
true, &alloc_ctx->szind, &alloc_ctx->slab);
}
#endif /* JEMALLOC_INTERNAL_EMAP_H */