Skip to content

Commit 3b0a35d

Browse files
committed
Remove some workarounds
1 parent b6125a3 commit 3b0a35d

File tree

3 files changed

+7
-46
lines changed

3 files changed

+7
-46
lines changed

stdlib/public/core/KeyPath.swift

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3604,16 +3604,7 @@ internal struct InstantiateKeyPathBuffer: KeyPathPatternVisitor {
36043604
self.patternArgs = patternArgs
36053605
self.base = root
36063606

3607-
// FIXME: This will not work on arm64e.
3608-
let metadataPtr = unsafeBitCast(root, to: UnsafeRawPointer.self)
3609-
let vwtPtr = metadataPtr.load(
3610-
fromByteOffset: 0 &- MemoryLayout<Int>.size,
3611-
as: UnsafeRawPointer.self
3612-
)
3613-
self.maxSize = vwtPtr.load(fromByteOffset: 0x40, as: Int.self)
3614-
3615-
// FIXME: The following doesn't work as it crashes the compiler in IRGen.
3616-
//self.maxSize = _openExistential(root, do: _getTypeSize(_:))
3607+
self.maxSize = _openExistential(root, do: _getTypeSize(_:))
36173608
}
36183609

36193610
// Track the triviality of the resulting object data.
@@ -3919,14 +3910,7 @@ internal struct InstantiateKeyPathBuffer: KeyPathPatternVisitor {
39193910
pushDest(metadata)
39203911
base = metadata
39213912

3922-
// FIXME: This will not work on arm64e.
3923-
let metadataPtr = unsafeBitCast(metadata, to: UnsafeRawPointer.self)
3924-
let vwtPtr = metadataPtr.load(
3925-
fromByteOffset: 0 &- MemoryLayout<Int>.size,
3926-
as: UnsafeRawPointer.self
3927-
)
3928-
let size = vwtPtr.load(fromByteOffset: 0x40, as: Int.self)
3929-
//let size = _openExistential(metadata, do: _getTypeSize(_:))
3913+
let size = _openExistential(metadata, do: _getTypeSize(_:))
39303914

39313915
maxSize = Swift.max(maxSize, size)
39323916
}

stdlib/public/core/TemporaryAllocation.swift

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,7 @@ internal func _withUnprotectedUnsafeTemporaryAllocation<T, R>(
174174
_ body: (Builtin.RawPointer) throws -> R
175175
) rethrows -> R {
176176
// How many bytes do we need to allocate?
177-
//let byteCount = _byteCountForTemporaryAllocation(of: type, capacity: capacity)
178-
let byteCount = MemoryLayout<T>.stride &* capacity
177+
let byteCount = _byteCountForTemporaryAllocation(of: type, capacity: capacity)
179178

180179
guard _isStackAllocationSafe(byteCount: byteCount, alignment: alignment) else {
181180
return try _fallBackToHeapAllocation(byteCount: byteCount, alignment: alignment, body)
@@ -299,7 +298,7 @@ public func _withUnprotectedUnsafeTemporaryAllocation<R>(
299298
alignment: alignment
300299
) { pointer in
301300
let buffer = UnsafeMutableRawBufferPointer(
302-
_uncheckedStart: .init(pointer),
301+
start: .init(pointer),
303302
count: byteCount
304303
)
305304
return try body(buffer)
@@ -375,7 +374,7 @@ public func _withUnprotectedUnsafeTemporaryAllocation<T, R>(
375374
) { pointer in
376375
Builtin.bindMemory(pointer, capacity._builtinWordValue, type)
377376
let buffer = UnsafeMutableBufferPointer<T>(
378-
_uncheckedStart: .init(pointer),
377+
start: .init(pointer),
379378
count: capacity
380379
)
381380
return try body(buffer)

stdlib/public/core/UnsafeRawBufferPointer.swift.gyb

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -116,20 +116,6 @@ public struct Unsafe${Mutable}RawBufferPointer {
116116
_debugPrecondition(count == 0 || start != nil,
117117
"${Self} has a nil start and nonzero count")
118118

119-
self.init(_uncheckedStart: start, count: count)
120-
}
121-
122-
@_alwaysEmitIntoClient
123-
internal init(
124-
_uncheckedStart start: Unsafe${Mutable}RawPointer?,
125-
count: Int
126-
) {
127-
_internalInvariant(count >= 0, "${Self} with negative count")
128-
_internalInvariant(
129-
count == 0 || start != nil,
130-
"${Self} has a nil start and nonzero count"
131-
)
132-
133119
_position = start
134120
_end = start.map { $0 + _assumeNonNegative(count) }
135121
}
@@ -1279,12 +1265,7 @@ public func _withUnprotectedUnsafeBytes<T, Result>(
12791265
) rethrows -> Result
12801266
{
12811267
return try _withUnprotectedUnsafePointer(to: &value) {
1282-
try body(
1283-
UnsafeRawBufferPointer(
1284-
_uncheckedStart: $0,
1285-
count: MemoryLayout<T>.size
1286-
)
1287-
)
1268+
try body(UnsafeRawBufferPointer(start: $0, count: MemoryLayout<T>.size))
12881269
}
12891270
}
12901271

@@ -1332,10 +1313,7 @@ public func _withUnprotectedUnsafeBytes<T, Result>(
13321313
#else
13331314
let addr = UnsafeRawPointer(Builtin.addressOfBorrow(value))
13341315
#endif
1335-
let buffer = UnsafeRawBufferPointer(
1336-
_uncheckedStart: addr,
1337-
count: MemoryLayout<T>.size
1338-
)
1316+
let buffer = UnsafeRawBufferPointer(start: addr, count: MemoryLayout<T>.size)
13391317
return try body(buffer)
13401318
}
13411319

0 commit comments

Comments
 (0)