File tree Expand file tree Collapse file tree 3 files changed +9
-7
lines changed Expand file tree Collapse file tree 3 files changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -273,8 +273,8 @@ internal struct _ContiguousArrayBuffer<Element>: _ArrayBufferProtocol {
273
273
_ContiguousArrayStorage< Element> . self ,
274
274
realMinimumCapacity. _builtinWordValue, Element . self)
275
275
276
- let storageAddr = UnsafeMutableRawPointer ( Builtin . bridgeToRawPointer ( _storage) )
277
- if let allocSize = _mallocSizeIfHeap ( ofAllocation : storageAddr ) {
276
+ if let allocSize = _mallocSizeIfHeap ( of : _storage) {
277
+ let storageAddr = UnsafeMutableRawPointer ( Builtin . bridgeToRawPointer ( _storage ) )
278
278
let endAddr = storageAddr + allocSize
279
279
let realCapacity = endAddr. assumingMemoryBound ( to: Element . self) - firstElementAddress
280
280
_initStorageHeader (
Original file line number Diff line number Diff line change @@ -45,9 +45,11 @@ internal func _mallocSize(ofAllocation ptr: UnsafeRawPointer) -> Int? {
45
45
return _swift_stdlib_has_malloc_size ( ) ? _swift_stdlib_malloc_size ( ptr) : nil
46
46
}
47
47
48
- @inline ( __always) @inlinable @_effects ( readonly)
49
- internal func _mallocSizeIfHeap( ofAllocation ptr: UnsafeRawPointer ) -> Int ? {
50
- if Builtin . isOnStack ( ptr) { return nil }
51
- return _mallocSize ( ofAllocation: ptr)
48
+ @_transparent @inlinable @_effects ( readonly)
49
+ internal func _mallocSizeIfHeap( of object: AnyObject ) -> Int ? {
50
+ if Bool ( Builtin . isOnStack ( _nativeObject ( fromNative: object) ) ) { return nil }
51
+ return _mallocSize (
52
+ ofAllocation: UnsafeRawPointer ( Builtin . bridgeToRawPointer ( object) )
53
+ )
52
54
}
53
55
Original file line number Diff line number Diff line change @@ -206,7 +206,7 @@ fileprivate func _allocate<T: AnyObject>(
206
206
let totalTailBytes = total - numHeaderBytes
207
207
208
208
let object = tailAllocator ( totalTailBytes)
209
- if let allocSize = _mallocSizeIfHeap ( ofAllocation:
209
+ if let allocSize = _mallocSize ( ofAllocation:
210
210
UnsafeRawPointer ( Builtin . bridgeToRawPointer ( object) ) ) {
211
211
_internalInvariant ( allocSize % MemoryLayout< Int> . stride == 0 )
212
212
You can’t perform that action at this time.
0 commit comments