summaryrefslogtreecommitdiff
path: root/deps/jemalloc/test/integration/chunk.c
diff options
context:
space:
mode:
Diffstat (limited to 'deps/jemalloc/test/integration/chunk.c')
-rw-r--r--deps/jemalloc/test/integration/chunk.c98
1 files changed, 40 insertions, 58 deletions
diff --git a/deps/jemalloc/test/integration/chunk.c b/deps/jemalloc/test/integration/chunk.c
index 94cf0025a..af1c9a53e 100644
--- a/deps/jemalloc/test/integration/chunk.c
+++ b/deps/jemalloc/test/integration/chunk.c
@@ -121,10 +121,6 @@ TEST_BEGIN(test_chunk)
{
void *p;
size_t old_size, new_size, large0, large1, huge0, huge1, huge2, sz;
- unsigned arena_ind;
- int flags;
- size_t hooks_mib[3], purge_mib[3];
- size_t hooks_miblen, purge_miblen;
chunk_hooks_t new_hooks = {
chunk_alloc,
chunk_dalloc,
@@ -136,21 +132,11 @@ TEST_BEGIN(test_chunk)
};
bool xallocx_success_a, xallocx_success_b, xallocx_success_c;
- sz = sizeof(unsigned);
- assert_d_eq(mallctl("arenas.extend", (void *)&arena_ind, &sz, NULL, 0),
- 0, "Unexpected mallctl() failure");
- flags = MALLOCX_ARENA(arena_ind) | MALLOCX_TCACHE_NONE;
-
/* Install custom chunk hooks. */
- hooks_miblen = sizeof(hooks_mib)/sizeof(size_t);
- assert_d_eq(mallctlnametomib("arena.0.chunk_hooks", hooks_mib,
- &hooks_miblen), 0, "Unexpected mallctlnametomib() failure");
- hooks_mib[1] = (size_t)arena_ind;
old_size = sizeof(chunk_hooks_t);
new_size = sizeof(chunk_hooks_t);
- assert_d_eq(mallctlbymib(hooks_mib, hooks_miblen, (void *)&old_hooks,
- &old_size, (void *)&new_hooks, new_size), 0,
- "Unexpected chunk_hooks error");
+ assert_d_eq(mallctl("arena.0.chunk_hooks", &old_hooks, &old_size,
+ &new_hooks, new_size), 0, "Unexpected chunk_hooks error");
orig_hooks = old_hooks;
assert_ptr_ne(old_hooks.alloc, chunk_alloc, "Unexpected alloc error");
assert_ptr_ne(old_hooks.dalloc, chunk_dalloc,
@@ -165,63 +151,59 @@ TEST_BEGIN(test_chunk)
/* Get large size classes. */
sz = sizeof(size_t);
- assert_d_eq(mallctl("arenas.lrun.0.size", (void *)&large0, &sz, NULL,
- 0), 0, "Unexpected arenas.lrun.0.size failure");
- assert_d_eq(mallctl("arenas.lrun.1.size", (void *)&large1, &sz, NULL,
- 0), 0, "Unexpected arenas.lrun.1.size failure");
+ assert_d_eq(mallctl("arenas.lrun.0.size", &large0, &sz, NULL, 0), 0,
+ "Unexpected arenas.lrun.0.size failure");
+ assert_d_eq(mallctl("arenas.lrun.1.size", &large1, &sz, NULL, 0), 0,
+ "Unexpected arenas.lrun.1.size failure");
/* Get huge size classes. */
- assert_d_eq(mallctl("arenas.hchunk.0.size", (void *)&huge0, &sz, NULL,
- 0), 0, "Unexpected arenas.hchunk.0.size failure");
- assert_d_eq(mallctl("arenas.hchunk.1.size", (void *)&huge1, &sz, NULL,
- 0), 0, "Unexpected arenas.hchunk.1.size failure");
- assert_d_eq(mallctl("arenas.hchunk.2.size", (void *)&huge2, &sz, NULL,
- 0), 0, "Unexpected arenas.hchunk.2.size failure");
+ assert_d_eq(mallctl("arenas.hchunk.0.size", &huge0, &sz, NULL, 0), 0,
+ "Unexpected arenas.hchunk.0.size failure");
+ assert_d_eq(mallctl("arenas.hchunk.1.size", &huge1, &sz, NULL, 0), 0,
+ "Unexpected arenas.hchunk.1.size failure");
+ assert_d_eq(mallctl("arenas.hchunk.2.size", &huge2, &sz, NULL, 0), 0,
+ "Unexpected arenas.hchunk.2.size failure");
/* Test dalloc/decommit/purge cascade. */
- purge_miblen = sizeof(purge_mib)/sizeof(size_t);
- assert_d_eq(mallctlnametomib("arena.0.purge", purge_mib, &purge_miblen),
- 0, "Unexpected mallctlnametomib() failure");
- purge_mib[1] = (size_t)arena_ind;
do_dalloc = false;
do_decommit = false;
- p = mallocx(huge0 * 2, flags);
+ p = mallocx(huge0 * 2, 0);
assert_ptr_not_null(p, "Unexpected mallocx() error");
did_dalloc = false;
did_decommit = false;
did_purge = false;
did_split = false;
- xallocx_success_a = (xallocx(p, huge0, 0, flags) == huge0);
- assert_d_eq(mallctlbymib(purge_mib, purge_miblen, NULL, NULL, NULL, 0),
- 0, "Unexpected arena.%u.purge error", arena_ind);
+ xallocx_success_a = (xallocx(p, huge0, 0, 0) == huge0);
+ assert_d_eq(mallctl("arena.0.purge", NULL, NULL, NULL, 0), 0,
+ "Unexpected arena.0.purge error");
if (xallocx_success_a) {
assert_true(did_dalloc, "Expected dalloc");
assert_false(did_decommit, "Unexpected decommit");
assert_true(did_purge, "Expected purge");
}
assert_true(did_split, "Expected split");
- dallocx(p, flags);
+ dallocx(p, 0);
do_dalloc = true;
/* Test decommit/commit and observe split/merge. */
do_dalloc = false;
do_decommit = true;
- p = mallocx(huge0 * 2, flags);
+ p = mallocx(huge0 * 2, 0);
assert_ptr_not_null(p, "Unexpected mallocx() error");
did_decommit = false;
did_commit = false;
did_split = false;
did_merge = false;
- xallocx_success_b = (xallocx(p, huge0, 0, flags) == huge0);
- assert_d_eq(mallctlbymib(purge_mib, purge_miblen, NULL, NULL, NULL, 0),
- 0, "Unexpected arena.%u.purge error", arena_ind);
+ xallocx_success_b = (xallocx(p, huge0, 0, 0) == huge0);
+ assert_d_eq(mallctl("arena.0.purge", NULL, NULL, NULL, 0), 0,
+ "Unexpected arena.0.purge error");
if (xallocx_success_b)
assert_true(did_split, "Expected split");
- xallocx_success_c = (xallocx(p, huge0 * 2, 0, flags) == huge0 * 2);
+ xallocx_success_c = (xallocx(p, huge0 * 2, 0, 0) == huge0 * 2);
assert_b_eq(did_decommit, did_commit, "Expected decommit/commit match");
if (xallocx_success_b && xallocx_success_c)
assert_true(did_merge, "Expected merge");
- dallocx(p, flags);
+ dallocx(p, 0);
do_dalloc = true;
do_decommit = false;
@@ -232,43 +214,43 @@ TEST_BEGIN(test_chunk)
* successful xallocx() from size=huge2 to size=huge1 is
* guaranteed to leave trailing purgeable memory.
*/
- p = mallocx(huge2, flags);
+ p = mallocx(huge2, 0);
assert_ptr_not_null(p, "Unexpected mallocx() error");
did_purge = false;
- assert_zu_eq(xallocx(p, huge1, 0, flags), huge1,
+ assert_zu_eq(xallocx(p, huge1, 0, 0), huge1,
"Unexpected xallocx() failure");
assert_true(did_purge, "Expected purge");
- dallocx(p, flags);
+ dallocx(p, 0);
}
/* Test decommit for large allocations. */
do_decommit = true;
- p = mallocx(large1, flags);
+ p = mallocx(large1, 0);
assert_ptr_not_null(p, "Unexpected mallocx() error");
- assert_d_eq(mallctlbymib(purge_mib, purge_miblen, NULL, NULL, NULL, 0),
- 0, "Unexpected arena.%u.purge error", arena_ind);
+ assert_d_eq(mallctl("arena.0.purge", NULL, NULL, NULL, 0), 0,
+ "Unexpected arena.0.purge error");
did_decommit = false;
- assert_zu_eq(xallocx(p, large0, 0, flags), large0,
+ assert_zu_eq(xallocx(p, large0, 0, 0), large0,
"Unexpected xallocx() failure");
- assert_d_eq(mallctlbymib(purge_mib, purge_miblen, NULL, NULL, NULL, 0),
- 0, "Unexpected arena.%u.purge error", arena_ind);
+ assert_d_eq(mallctl("arena.0.purge", NULL, NULL, NULL, 0), 0,
+ "Unexpected arena.0.purge error");
did_commit = false;
- assert_zu_eq(xallocx(p, large1, 0, flags), large1,
+ assert_zu_eq(xallocx(p, large1, 0, 0), large1,
"Unexpected xallocx() failure");
assert_b_eq(did_decommit, did_commit, "Expected decommit/commit match");
- dallocx(p, flags);
+ dallocx(p, 0);
do_decommit = false;
/* Make sure non-huge allocation succeeds. */
- p = mallocx(42, flags);
+ p = mallocx(42, 0);
assert_ptr_not_null(p, "Unexpected mallocx() error");
- dallocx(p, flags);
+ dallocx(p, 0);
/* Restore chunk hooks. */
- assert_d_eq(mallctlbymib(hooks_mib, hooks_miblen, NULL, NULL,
- (void *)&old_hooks, new_size), 0, "Unexpected chunk_hooks error");
- assert_d_eq(mallctlbymib(hooks_mib, hooks_miblen, (void *)&old_hooks,
- &old_size, NULL, 0), 0, "Unexpected chunk_hooks error");
+ assert_d_eq(mallctl("arena.0.chunk_hooks", NULL, NULL, &old_hooks,
+ new_size), 0, "Unexpected chunk_hooks error");
+ assert_d_eq(mallctl("arena.0.chunk_hooks", &old_hooks, &old_size,
+ NULL, 0), 0, "Unexpected chunk_hooks error");
assert_ptr_eq(old_hooks.alloc, orig_hooks.alloc,
"Unexpected alloc error");
assert_ptr_eq(old_hooks.dalloc, orig_hooks.dalloc,