Break prof_accum into multiple compilation units.
Break prof_accum into multiple compilation units, in order to thwart compiler optimizations such as inlining and tail call optimization that would alter backtraces.
This commit is contained in:
@@ -1,9 +1,4 @@
|
||||
#include "test/jemalloc_test.h"
|
||||
|
||||
#define NTHREADS 4
|
||||
#define NALLOCS_PER_THREAD 50
|
||||
#define DUMP_INTERVAL 1
|
||||
#define BT_COUNT_CHECK_INTERVAL 5
|
||||
#include "prof_accum.h"
|
||||
|
||||
#ifdef JEMALLOC_PROF
|
||||
const char *malloc_conf =
|
||||
@@ -21,37 +16,6 @@ prof_dump_open_intercept(bool propagate_err, const char *filename)
|
||||
return (fd);
|
||||
}
|
||||
|
||||
#define alloc_n_proto(n) \
|
||||
JEMALLOC_NOINLINE static void *alloc_##n(unsigned bits);
|
||||
|
||||
#define alloc_n_gen(n) \
|
||||
JEMALLOC_NOINLINE static void * \
|
||||
alloc_##n(unsigned bits) \
|
||||
{ \
|
||||
void *p; \
|
||||
\
|
||||
if (bits == 0) \
|
||||
p = mallocx(1, 0); \
|
||||
else { \
|
||||
switch (bits & 0x1U) { \
|
||||
case 0: \
|
||||
p = alloc_0(bits >> 1); \
|
||||
break; \
|
||||
case 1: \
|
||||
p = alloc_1(bits >> 1); \
|
||||
break; \
|
||||
default: not_reached(); \
|
||||
} \
|
||||
} \
|
||||
/* Intentionally sabotage tail call optimization. */ \
|
||||
assert_ptr_not_null(p, "Unexpected mallocx() failure"); \
|
||||
return (p); \
|
||||
}
|
||||
alloc_n_proto(0)
|
||||
alloc_n_proto(1)
|
||||
alloc_n_gen(0)
|
||||
alloc_n_gen(1)
|
||||
|
||||
static void *
|
||||
alloc_from_permuted_backtrace(unsigned thd_ind, unsigned iteration)
|
||||
{
|
||||
|
29
test/unit/prof_accum.h
Normal file
29
test/unit/prof_accum.h
Normal file
@@ -0,0 +1,29 @@
|
||||
#include "test/jemalloc_test.h"
|
||||
|
||||
#define NTHREADS 4
|
||||
#define NALLOCS_PER_THREAD 50
|
||||
#define DUMP_INTERVAL 1
|
||||
#define BT_COUNT_CHECK_INTERVAL 5
|
||||
|
||||
#define alloc_n_proto(n) \
|
||||
void *alloc_##n(unsigned bits);
|
||||
alloc_n_proto(0)
|
||||
alloc_n_proto(1)
|
||||
|
||||
#define alloc_n_gen(n) \
|
||||
void * \
|
||||
alloc_##n(unsigned bits) \
|
||||
{ \
|
||||
\
|
||||
if (bits == 0) { \
|
||||
void *p = mallocx(1, 0); \
|
||||
assert_ptr_not_null(p, "Unexpected mallocx() failure"); \
|
||||
return (p); \
|
||||
} else { \
|
||||
switch (bits & 0x1U) { \
|
||||
case 0: return (alloc_0(bits >> 1)); \
|
||||
case 1: return (alloc_1(bits >> 1)); \
|
||||
default: not_reached(); \
|
||||
} \
|
||||
} \
|
||||
}
|
3
test/unit/prof_accum_a.c
Normal file
3
test/unit/prof_accum_a.c
Normal file
@@ -0,0 +1,3 @@
|
||||
#include "prof_accum.h"
|
||||
|
||||
alloc_n_gen(0)
|
3
test/unit/prof_accum_b.c
Normal file
3
test/unit/prof_accum_b.c
Normal file
@@ -0,0 +1,3 @@
|
||||
#include "prof_accum.h"
|
||||
|
||||
alloc_n_gen(1)
|
Reference in New Issue
Block a user