Skip to content

Commit b829465

Browse files
committed
Build fix + temporarily disable for String
1 parent 6135f45 commit b829465

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

stdlib/public/core/ContiguousArrayBuffer.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,8 @@ internal struct _ContiguousArrayBuffer<Element>: _ArrayBufferProtocol {
273273
_ContiguousArrayStorage<Element>.self,
274274
realMinimumCapacity._builtinWordValue, Element.self)
275275

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))
278278
let endAddr = storageAddr + allocSize
279279
let realCapacity = endAddr.assumingMemoryBound(to: Element.self) - firstElementAddress
280280
_initStorageHeader(

stdlib/public/core/Shims.swift

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,11 @@ internal func _mallocSize(ofAllocation ptr: UnsafeRawPointer) -> Int? {
4545
return _swift_stdlib_has_malloc_size() ? _swift_stdlib_malloc_size(ptr) : nil
4646
}
4747

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+
)
5254
}
5355

stdlib/public/core/StringStorage.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ fileprivate func _allocate<T: AnyObject>(
206206
let totalTailBytes = total - numHeaderBytes
207207

208208
let object = tailAllocator(totalTailBytes)
209-
if let allocSize = _mallocSizeIfHeap(ofAllocation:
209+
if let allocSize = _mallocSize(ofAllocation:
210210
UnsafeRawPointer(Builtin.bridgeToRawPointer(object))) {
211211
_internalInvariant(allocSize % MemoryLayout<Int>.stride == 0)
212212

0 commit comments

Comments
 (0)