Deleted Added
full compact
chunk_dss.c (286866) chunk_dss.c (288090)
1#define JEMALLOC_CHUNK_DSS_C_
2#include "jemalloc/internal/jemalloc_internal.h"
3/******************************************************************************/
4/* Data. */
5
6const char *dss_prec_names[] = {
7 "disabled",
8 "primary",

--- 55 unchanged lines hidden (view full) ---

64 malloc_mutex_unlock(&dss_mtx);
65 return (false);
66}
67
68void *
69chunk_alloc_dss(arena_t *arena, void *new_addr, size_t size, size_t alignment,
70 bool *zero, bool *commit)
71{
1#define JEMALLOC_CHUNK_DSS_C_
2#include "jemalloc/internal/jemalloc_internal.h"
3/******************************************************************************/
4/* Data. */
5
6const char *dss_prec_names[] = {
7 "disabled",
8 "primary",

--- 55 unchanged lines hidden (view full) ---

64 malloc_mutex_unlock(&dss_mtx);
65 return (false);
66}
67
68void *
69chunk_alloc_dss(arena_t *arena, void *new_addr, size_t size, size_t alignment,
70 bool *zero, bool *commit)
71{
72 void *ret;
73
74 cassert(have_dss);
75 assert(size > 0 && (size & chunksize_mask) == 0);
76 assert(alignment > 0 && (alignment & chunksize_mask) == 0);
77
78 /*
79 * sbrk() uses a signed increment argument, so take care not to
80 * interpret a huge allocation request as a negative increment.
81 */
82 if ((intptr_t)size < 0)
83 return (NULL);
84
85 malloc_mutex_lock(&dss_mtx);
86 if (dss_prev != (void *)-1) {
72 cassert(have_dss);
73 assert(size > 0 && (size & chunksize_mask) == 0);
74 assert(alignment > 0 && (alignment & chunksize_mask) == 0);
75
76 /*
77 * sbrk() uses a signed increment argument, so take care not to
78 * interpret a huge allocation request as a negative increment.
79 */
80 if ((intptr_t)size < 0)
81 return (NULL);
82
83 malloc_mutex_lock(&dss_mtx);
84 if (dss_prev != (void *)-1) {
87 size_t gap_size, cpad_size;
88 void *cpad, *dss_next;
89 intptr_t incr;
90
91 /*
92 * The loop is necessary to recover from races with other
93 * threads that are using the DSS for something other than
94 * malloc.
95 */
96 do {
85
86 /*
87 * The loop is necessary to recover from races with other
88 * threads that are using the DSS for something other than
89 * malloc.
90 */
91 do {
92 void *ret, *cpad, *dss_next;
93 size_t gap_size, cpad_size;
94 intptr_t incr;
97 /* Avoid an unnecessary system call. */
98 if (new_addr != NULL && dss_max != new_addr)
99 break;
100
101 /* Get the current end of the DSS. */
102 dss_max = chunk_dss_sbrk(0);
103
104 /* Make sure the earlier condition still holds. */

--- 112 unchanged lines hidden ---
95 /* Avoid an unnecessary system call. */
96 if (new_addr != NULL && dss_max != new_addr)
97 break;
98
99 /* Get the current end of the DSS. */
100 dss_max = chunk_dss_sbrk(0);
101
102 /* Make sure the earlier condition still holds. */

--- 112 unchanged lines hidden ---