mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-04-14 22:51:50 +03:00
Add LOGs when entrying and exiting free and sdallocx.
This commit is contained in:
parent
05160258df
commit
b1792c80d2
3 changed files with 61 additions and 15 deletions
|
|
@ -278,8 +278,6 @@ fastpath_success_finish(tsd_t *tsd, uint64_t allocated_after,
|
|||
if (config_stats) {
|
||||
bin->tstats.nrequests++;
|
||||
}
|
||||
|
||||
LOG("core.malloc.exit", "result: %p", ret);
|
||||
}
|
||||
|
||||
JEMALLOC_ALWAYS_INLINE bool
|
||||
|
|
@ -306,7 +304,6 @@ malloc_initialized(void) {
|
|||
*/
|
||||
JEMALLOC_ALWAYS_INLINE void *
|
||||
imalloc_fastpath(size_t size, void *(fallback_alloc)(size_t)) {
|
||||
LOG("core.malloc.entry", "size: %zu", size);
|
||||
if (tsd_get_allocates() && unlikely(!malloc_initialized())) {
|
||||
return fallback_alloc(size);
|
||||
}
|
||||
|
|
@ -578,14 +575,9 @@ bool free_fastpath(void *ptr, size_t size, bool size_hint) {
|
|||
|
||||
JEMALLOC_ALWAYS_INLINE void JEMALLOC_NOTHROW
|
||||
je_sdallocx_noflags(void *ptr, size_t size) {
|
||||
LOG("core.sdallocx.entry", "ptr: %p, size: %zu, flags: 0", ptr,
|
||||
size);
|
||||
|
||||
if (!free_fastpath(ptr, size, true)) {
|
||||
sdallocx_default(ptr, size, 0);
|
||||
}
|
||||
|
||||
LOG("core.sdallocx.exit", "");
|
||||
}
|
||||
|
||||
JEMALLOC_ALWAYS_INLINE void JEMALLOC_NOTHROW
|
||||
|
|
|
|||
|
|
@ -2730,8 +2730,6 @@ malloc_default(size_t size) {
|
|||
hook_invoke_alloc(hook_alloc_malloc, ret, (uintptr_t)ret, args);
|
||||
}
|
||||
|
||||
LOG("core.malloc.exit", "result: %p", ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -2744,7 +2742,12 @@ JEMALLOC_EXPORT JEMALLOC_ALLOCATOR JEMALLOC_RESTRICT_RETURN
|
|||
void JEMALLOC_NOTHROW *
|
||||
JEMALLOC_ATTR(malloc) JEMALLOC_ALLOC_SIZE(1)
|
||||
je_malloc(size_t size) {
|
||||
return imalloc_fastpath(size, &malloc_default);
|
||||
LOG("core.malloc.entry", "size: %zu", size);
|
||||
|
||||
void * ret = imalloc_fastpath(size, &malloc_default);
|
||||
|
||||
LOG("core.malloc.exit", "result: %p", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
JEMALLOC_EXPORT int JEMALLOC_NOTHROW
|
||||
|
|
@ -2835,7 +2838,7 @@ je_calloc(size_t num, size_t size) {
|
|||
static_opts_t sopts;
|
||||
dynamic_opts_t dopts;
|
||||
|
||||
LOG("core.calloc.entry", "num: %zu, size: %zu\n", num, size);
|
||||
LOG("core.calloc.entry", "num: %zu, size: %zu", num, size);
|
||||
|
||||
static_opts_init(&sopts);
|
||||
dynamic_opts_init(&dopts);
|
||||
|
|
@ -3014,7 +3017,11 @@ je_free(void *ptr) {
|
|||
|
||||
JEMALLOC_EXPORT void JEMALLOC_NOTHROW
|
||||
je_free_sized(void *ptr, size_t size) {
|
||||
return je_sdallocx_noflags(ptr, size);
|
||||
LOG("core.free_sized.entry", "ptr: %p, size: %zu", ptr, size);
|
||||
|
||||
je_sdallocx_noflags(ptr, size);
|
||||
|
||||
LOG("core.free_sized.exit", "");
|
||||
}
|
||||
|
||||
JEMALLOC_EXPORT void JEMALLOC_NOTHROW
|
||||
|
|
|
|||
|
|
@ -112,7 +112,12 @@ template <bool IsNoExcept>
|
|||
JEMALLOC_ALWAYS_INLINE
|
||||
void *
|
||||
newImpl(std::size_t size) noexcept(IsNoExcept) {
|
||||
return imalloc_fastpath(size, &fallbackNewImpl<IsNoExcept>);
|
||||
LOG("core.operator_new.entry", "size: %zu", size);
|
||||
|
||||
void * ret = imalloc_fastpath(size, &fallbackNewImpl<IsNoExcept>);
|
||||
|
||||
LOG("core.operator_new.exit", "result: %p", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void *
|
||||
|
|
@ -173,21 +178,37 @@ operator new[](std::size_t size, std::align_val_t alignment, const std::nothrow_
|
|||
|
||||
void
|
||||
operator delete(void *ptr) noexcept {
|
||||
LOG("core.operator_delete.entry", "ptr: %p", ptr);
|
||||
|
||||
je_free_impl(ptr);
|
||||
|
||||
LOG("core.operator_delete.exit", "");
|
||||
}
|
||||
|
||||
void
|
||||
operator delete[](void *ptr) noexcept {
|
||||
LOG("core.operator_delete.entry", "ptr: %p", ptr);
|
||||
|
||||
je_free_impl(ptr);
|
||||
|
||||
LOG("core.operator_delete.exit", "");
|
||||
}
|
||||
|
||||
void
|
||||
operator delete(void *ptr, const std::nothrow_t &) noexcept {
|
||||
LOG("core.operator_delete.entry", "ptr: %p", ptr);
|
||||
|
||||
je_free_impl(ptr);
|
||||
|
||||
LOG("core.operator_delete.exit", "");
|
||||
}
|
||||
|
||||
void operator delete[](void *ptr, const std::nothrow_t &) noexcept {
|
||||
LOG("core.operator_delete.entry", "ptr: %p", ptr);
|
||||
|
||||
je_free_impl(ptr);
|
||||
|
||||
LOG("core.operator_delete.exit", "");
|
||||
}
|
||||
|
||||
#if __cpp_sized_deallocation >= 201309
|
||||
|
|
@ -198,7 +219,11 @@ sizedDeleteImpl(void* ptr, std::size_t size) noexcept {
|
|||
if (unlikely(ptr == nullptr)) {
|
||||
return;
|
||||
}
|
||||
LOG("core.operator_delete.entry", "ptr: %p, size: %zu", ptr, size);
|
||||
|
||||
je_sdallocx_noflags(ptr, size);
|
||||
|
||||
LOG("core.operator_delete.exit", "");
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -217,34 +242,56 @@ operator delete[](void *ptr, std::size_t size) noexcept {
|
|||
|
||||
JEMALLOC_ALWAYS_INLINE
|
||||
void
|
||||
alignedSizedDeleteImpl(void* ptr, std::size_t size, std::align_val_t alignment) noexcept {
|
||||
alignedSizedDeleteImpl(void* ptr, std::size_t size, std::align_val_t alignment)
|
||||
noexcept {
|
||||
if (config_debug) {
|
||||
assert(((size_t)alignment & ((size_t)alignment - 1)) == 0);
|
||||
}
|
||||
if (unlikely(ptr == nullptr)) {
|
||||
return;
|
||||
}
|
||||
LOG("core.operator_delete.entry", "ptr: %p, size: %zu, alignment: %zu",
|
||||
ptr, size, alignment);
|
||||
|
||||
je_sdallocx_impl(ptr, size, MALLOCX_ALIGN(alignment));
|
||||
|
||||
LOG("core.operator_delete.exit", "");
|
||||
}
|
||||
|
||||
void
|
||||
operator delete(void* ptr, std::align_val_t) noexcept {
|
||||
LOG("core.operator_delete.entry", "ptr: %p", ptr);
|
||||
|
||||
je_free_impl(ptr);
|
||||
|
||||
LOG("core.operator_delete.exit", "");
|
||||
}
|
||||
|
||||
void
|
||||
operator delete[](void* ptr, std::align_val_t) noexcept {
|
||||
LOG("core.operator_delete.entry", "ptr: %p", ptr);
|
||||
|
||||
je_free_impl(ptr);
|
||||
|
||||
LOG("core.operator_delete.exit", "");
|
||||
}
|
||||
|
||||
void
|
||||
operator delete(void* ptr, std::align_val_t, const std::nothrow_t&) noexcept {
|
||||
LOG("core.operator_delete.entry", "ptr: %p", ptr);
|
||||
|
||||
je_free_impl(ptr);
|
||||
|
||||
LOG("core.operator_delete.exit", "");
|
||||
}
|
||||
|
||||
void
|
||||
operator delete[](void* ptr, std::align_val_t, const std::nothrow_t&) noexcept {
|
||||
LOG("core.operator_delete.entry", "ptr: %p", ptr);
|
||||
|
||||
je_free_impl(ptr);
|
||||
|
||||
LOG("core.operator_delete.exit", "");
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue