@@ -161,7 +161,6 @@ internal func _withUnsafeTemporaryAllocation<T, R>(
161
161
#endif
162
162
}
163
163
164
- #if $BuiltinUnprotectedStackAlloc
165
164
@_alwaysEmitIntoClient @_transparent
166
165
internal func _withUnprotectedUnsafeTemporaryAllocation< T, R> (
167
166
of type: T . Type ,
@@ -181,11 +180,19 @@ internal func _withUnprotectedUnsafeTemporaryAllocation<T, R>(
181
180
// notice and complain.)
182
181
let result : R
183
182
183
+ #if $BuiltinUnprotectedStackAlloc
184
184
let stackAddress = Builtin . unprotectedStackAlloc (
185
185
capacity. _builtinWordValue,
186
186
MemoryLayout < T > . stride. _builtinWordValue,
187
187
alignment. _builtinWordValue
188
188
)
189
+ #else
190
+ let stackAddress = Builtin . stackAlloc (
191
+ capacity. _builtinWordValue,
192
+ MemoryLayout < T > . stride. _builtinWordValue,
193
+ alignment. _builtinWordValue
194
+ )
195
+ #endif
189
196
190
197
// The multiple calls to Builtin.stackDealloc() are because defer { } produces
191
198
// a child function at the SIL layer and that conflicts with the verifier's
@@ -200,7 +207,6 @@ internal func _withUnprotectedUnsafeTemporaryAllocation<T, R>(
200
207
throw error
201
208
}
202
209
}
203
- #endif
204
210
205
211
@_alwaysEmitIntoClient @_transparent
206
212
internal func _fallBackToHeapAllocation< R> (
@@ -281,20 +287,16 @@ public func _withUnprotectedUnsafeTemporaryAllocation<R>(
281
287
alignment: Int ,
282
288
_ body: ( UnsafeMutableRawBufferPointer ) throws -> R
283
289
) rethrows -> R {
284
- return try _withUnsafeTemporaryAllocation (
290
+ return try _withUnprotectedUnsafeTemporaryAllocation (
285
291
of: Int8 . self,
286
292
capacity: byteCount,
287
293
alignment: alignment
288
294
) { pointer in
289
- #if $BuiltinUnprotectedStackAlloc
290
295
let buffer = UnsafeMutableRawBufferPointer (
291
296
start: . init( pointer) ,
292
297
count: byteCount
293
298
)
294
299
return try body ( buffer)
295
- #else
296
- return try withUnsafeTemporaryAllocation ( byteCount: byteCount, alignment: alignment, body)
297
- #endif
298
300
}
299
301
}
300
302
@@ -365,15 +367,11 @@ public func _withUnprotectedUnsafeTemporaryAllocation<T, R>(
365
367
capacity: capacity,
366
368
alignment: MemoryLayout< T> . alignment
367
369
) { pointer in
368
- #if $BuiltinUnprotectedStackAlloc
369
370
Builtin . bindMemory ( pointer, capacity. _builtinWordValue, type)
370
371
let buffer = UnsafeMutableBufferPointer < T > (
371
372
start: . init( pointer) ,
372
373
count: capacity
373
374
)
374
375
return try body ( buffer)
375
- #else
376
- return try withUnsafeTemporaryAllocation ( of: type, capacity: capacity, body)
377
- #endif
378
376
}
379
377
}
0 commit comments