Cache-bin: Make flush modifications internal
I.e. the tcache code just calls a cache-bin function to finish flush (and move pointers around, etc.). It doesn't directly access the cache-bin's owned memory any more.
This commit is contained in:
parent
ff6acc6ed5
commit
44529da852
@ -267,7 +267,7 @@ cache_bin_init_ptr_array_for_fill(cache_bin_t *bin, cache_bin_info_t *info,
|
||||
*/
|
||||
static inline void
|
||||
cache_bin_finish_fill(cache_bin_t *bin, cache_bin_info_t *info,
|
||||
cache_bin_ptr_array_t *arr, szind_t nfilled) {
|
||||
cache_bin_ptr_array_t *arr, cache_bin_sz_t nfilled) {
|
||||
assert(cache_bin_ncached_get(bin, info) == 0);
|
||||
if (nfilled < arr->n) {
|
||||
void **empty_position = cache_bin_empty_position_get(bin, info);
|
||||
@ -285,6 +285,10 @@ cache_bin_init_ptr_array_for_flush(cache_bin_t *bin, cache_bin_info_t *info,
|
||||
|| *arr->ptr != NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* These accessors are used by the flush pathways -- they reverse ordinary flush
|
||||
* ordering.
|
||||
*/
|
||||
JEMALLOC_ALWAYS_INLINE void *
|
||||
cache_bin_ptr_array_get(cache_bin_ptr_array_t *arr, cache_bin_sz_t n) {
|
||||
return *(arr->ptr - n);
|
||||
@ -295,4 +299,16 @@ cache_bin_ptr_array_set(cache_bin_ptr_array_t *arr, cache_bin_sz_t n, void *p) {
|
||||
*(arr->ptr - n) = p;
|
||||
}
|
||||
|
||||
static inline void
|
||||
cache_bin_finish_flush(cache_bin_t *bin, cache_bin_info_t *info,
|
||||
cache_bin_ptr_array_t *arr, cache_bin_sz_t nflushed) {
|
||||
unsigned rem = cache_bin_ncached_get(bin, info) - nflushed;
|
||||
memmove(bin->cur_ptr.ptr + nflushed, bin->cur_ptr.ptr,
|
||||
rem * sizeof(void *));
|
||||
cache_bin_ncached_set(bin, info, rem);
|
||||
if (bin->cur_ptr.lowbits > bin->low_water_position) {
|
||||
bin->low_water_position = bin->cur_ptr.lowbits;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* JEMALLOC_INTERNAL_CACHE_BIN_H */
|
||||
|
@ -346,12 +346,8 @@ tcache_bin_flush_impl(tsd_t *tsd, tcache_t *tcache, cache_bin_t *tbin,
|
||||
}
|
||||
}
|
||||
|
||||
memmove(tbin->cur_ptr.ptr + (ncached - rem), tbin->cur_ptr.ptr, rem *
|
||||
sizeof(void *));
|
||||
cache_bin_ncached_set(tbin, &tcache_bin_info[binind], rem);
|
||||
if (tbin->cur_ptr.lowbits > tbin->low_water_position) {
|
||||
tbin->low_water_position = tbin->cur_ptr.lowbits;
|
||||
}
|
||||
cache_bin_finish_flush(tbin, &tcache_bin_info[binind], &ptrs,
|
||||
ncached - rem);
|
||||
}
|
||||
|
||||
void
|
||||
|
Loading…
Reference in New Issue
Block a user