Add branch hints to free_fastpath.
Explicityly mark the non-slab case unlikely. Previously there were jumps in the common case.
This commit is contained in:
parent
a787d2f5b3
commit
7160617107
@ -2647,8 +2647,6 @@ bool free_fastpath(void *ptr, size_t size, bool size_hint) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
tcache_t *tcache = tsd_tcachep_get(tsd);
|
|
||||||
|
|
||||||
alloc_ctx_t alloc_ctx;
|
alloc_ctx_t alloc_ctx;
|
||||||
/*
|
/*
|
||||||
* If !config_cache_oblivious, we can check PAGE alignment to
|
* If !config_cache_oblivious, we can check PAGE alignment to
|
||||||
@ -2658,27 +2656,29 @@ bool free_fastpath(void *ptr, size_t size, bool size_hint) {
|
|||||||
*/
|
*/
|
||||||
if (!size_hint || config_cache_oblivious) {
|
if (!size_hint || config_cache_oblivious) {
|
||||||
rtree_ctx_t *rtree_ctx = tsd_rtree_ctx(tsd);
|
rtree_ctx_t *rtree_ctx = tsd_rtree_ctx(tsd);
|
||||||
bool res = rtree_szind_slab_read_fast(tsd_tsdn(tsd), &extents_rtree,
|
bool res = rtree_szind_slab_read_fast(tsd_tsdn(tsd),
|
||||||
rtree_ctx, (uintptr_t)ptr,
|
&extents_rtree, rtree_ctx, (uintptr_t)ptr, &alloc_ctx.szind,
|
||||||
&alloc_ctx.szind, &alloc_ctx.slab);
|
&alloc_ctx.slab);
|
||||||
|
|
||||||
/* Note: profiled objects will have alloc_ctx.slab set */
|
/* Note: profiled objects will have alloc_ctx.slab set */
|
||||||
if (!res || !alloc_ctx.slab) {
|
if (unlikely(!res || !alloc_ctx.slab)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
assert(alloc_ctx.szind != SC_NSIZES);
|
assert(alloc_ctx.szind != SC_NSIZES);
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
* Check for both sizes that are too large, and for sampled objects.
|
* Check for both sizes that are too large, and for sampled
|
||||||
* Sampled objects are always page-aligned. The sampled object check
|
* objects. Sampled objects are always page-aligned. The
|
||||||
* will also check for null ptr.
|
* sampled object check will also check for null ptr.
|
||||||
*/
|
*/
|
||||||
if (size > SC_LOOKUP_MAXCLASS || (((uintptr_t)ptr & PAGE_MASK) == 0)) {
|
if (unlikely(size > SC_LOOKUP_MAXCLASS ||
|
||||||
|
(((uintptr_t)ptr & PAGE_MASK) == 0))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
alloc_ctx.szind = sz_size2index_lookup(size);
|
alloc_ctx.szind = sz_size2index_lookup(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tcache_t *tcache = tsd_tcachep_get(tsd);
|
||||||
if (unlikely(ticker_trytick(&tcache->gc_ticker))) {
|
if (unlikely(ticker_trytick(&tcache->gc_ticker))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -3532,7 +3532,7 @@ je_sdallocx(void *ptr, size_t size, int flags) {
|
|||||||
LOG("core.sdallocx.entry", "ptr: %p, size: %zu, flags: %d", ptr,
|
LOG("core.sdallocx.entry", "ptr: %p, size: %zu, flags: %d", ptr,
|
||||||
size, flags);
|
size, flags);
|
||||||
|
|
||||||
if (flags !=0 || !free_fastpath(ptr, size, true)) {
|
if (flags != 0 || !free_fastpath(ptr, size, true)) {
|
||||||
sdallocx_default(ptr, size, flags);
|
sdallocx_default(ptr, size, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user