@@ -60,13 +60,6 @@ static constexpr size_t MALLOC_ALIGN_MASK = alignof(std::max_align_t) - 1;
60
60
static_assert (_swift_MinAllocationAlignment > MALLOC_ALIGN_MASK,
61
61
" Swift's default alignment must exceed platform malloc mask." );
62
62
63
- #if defined(__APPLE__) && SWIFT_STDLIB_HAS_DARWIN_LIBMALLOC
64
- static inline malloc_zone_t *DEFAULT_ZONE () {
65
- static malloc_zone_t *z = SWIFT_LAZY_CONSTANT (malloc_default_zone ());
66
- return z;
67
- }
68
- #endif
69
-
70
63
// When alignMask == ~(size_t(0)), allocation uses the "default"
71
64
// _swift_MinAllocationAlignment. This is different than calling swift_slowAlloc
72
65
// with `alignMask == _swift_MinAllocationAlignment - 1` because it forces
@@ -91,11 +84,7 @@ void *swift::swift_slowAlloc(size_t size, size_t alignMask) {
91
84
void *p;
92
85
// This check also forces "default" alignment to use AlignedAlloc.
93
86
if (alignMask <= MALLOC_ALIGN_MASK) {
94
- #if defined(__APPLE__) && SWIFT_STDLIB_HAS_DARWIN_LIBMALLOC
95
- p = malloc_zone_malloc (DEFAULT_ZONE (), size);
96
- #else
97
87
p = malloc (size);
98
- #endif
99
88
} else {
100
89
size_t alignment = computeAlignment (alignMask);
101
90
p = AlignedAlloc (size, alignment);
@@ -111,10 +100,10 @@ void *swift::swift_slowAllocTyped(size_t size, size_t alignMask,
111
100
void *p;
112
101
// This check also forces "default" alignment to use malloc_memalign().
113
102
if (alignMask <= MALLOC_ALIGN_MASK) {
114
- p = malloc_type_zone_malloc ( DEFAULT_ZONE (), size, typeId);
103
+ p = malloc_type_malloc ( size, typeId);
115
104
} else {
116
105
size_t alignment = computeAlignment (alignMask);
117
- p = malloc_type_zone_memalign ( DEFAULT_ZONE (), alignment, size, typeId);
106
+ p = malloc_type_aligned_alloc ( alignment, size, typeId);
118
107
}
119
108
if (!p) swift::crash (" Could not allocate memory." );
120
109
return p;
@@ -141,11 +130,7 @@ void *swift::swift_slowAllocTyped(size_t size, size_t alignMask,
141
130
// consistent with allocation with the same alignment.
142
131
static void swift_slowDeallocImpl (void *ptr, size_t alignMask) {
143
132
if (alignMask <= MALLOC_ALIGN_MASK) {
144
- #if defined(__APPLE__) && SWIFT_STDLIB_HAS_DARWIN_LIBMALLOC
145
- malloc_zone_free (DEFAULT_ZONE (), ptr);
146
- #else
147
133
free (ptr);
148
- #endif
149
134
} else {
150
135
AlignedFree (ptr);
151
136
}
0 commit comments