Skip to content

Commit 1ca08c1

Browse files
committed
Remove some workarounds
1 parent f9773c3 commit 1ca08c1

File tree

3 files changed

+6
-40
lines changed

3 files changed

+6
-40
lines changed

stdlib/public/core/KeyPath.swift

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3661,16 +3661,7 @@ internal struct InstantiateKeyPathBuffer: KeyPathPatternVisitor {
36613661
self.patternArgs = patternArgs
36623662
self.base = root
36633663

3664-
// FIXME: This will not work on arm64e.
3665-
let metadataPtr = unsafeBitCast(root, to: UnsafeRawPointer.self)
3666-
let vwtPtr = metadataPtr.load(
3667-
fromByteOffset: 0 &- MemoryLayout<Int>.size,
3668-
as: UnsafeRawPointer.self
3669-
)
3670-
self.maxSize = vwtPtr.load(fromByteOffset: 0x40, as: Int.self)
3671-
3672-
// FIXME: The following doesn't work as it crashes the compiler in IRGen.
3673-
//self.maxSize = _openExistential(root, do: _getTypeSize(_:))
3664+
self.maxSize = _openExistential(root, do: _getTypeSize(_:))
36743665
}
36753666

36763667
// Track the triviality of the resulting object data.
@@ -3976,14 +3967,7 @@ internal struct InstantiateKeyPathBuffer: KeyPathPatternVisitor {
39763967
pushDest(metadata)
39773968
base = metadata
39783969

3979-
// FIXME: This will not work on arm64e.
3980-
let metadataPtr = unsafeBitCast(metadata, to: UnsafeRawPointer.self)
3981-
let vwtPtr = metadataPtr.load(
3982-
fromByteOffset: 0 &- MemoryLayout<Int>.size,
3983-
as: UnsafeRawPointer.self
3984-
)
3985-
let size = vwtPtr.load(fromByteOffset: 0x40, as: Int.self)
3986-
//let size = _openExistential(metadata, do: _getTypeSize(_:))
3970+
let size = _openExistential(metadata, do: _getTypeSize(_:))
39873971

39883972
maxSize = Swift.max(maxSize, size)
39893973
}

stdlib/public/core/TemporaryAllocation.swift

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

184183
guard _isStackAllocationSafe(byteCount: byteCount, alignment: alignment) else {
185184
return try _fallBackToHeapAllocation(byteCount: byteCount, alignment: alignment, body)
@@ -303,7 +302,7 @@ public func _withUnprotectedUnsafeTemporaryAllocation<R: ~Copyable>(
303302
alignment: alignment
304303
) { pointer in
305304
let buffer = UnsafeMutableRawBufferPointer(
306-
_uncheckedStart: .init(pointer),
305+
start: .init(pointer),
307306
count: byteCount
308307
)
309308
return try body(buffer)
@@ -383,7 +382,7 @@ public func _withUnprotectedUnsafeTemporaryAllocation<
383382
) { pointer in
384383
Builtin.bindMemory(pointer, capacity._builtinWordValue, type)
385384
let buffer = UnsafeMutableBufferPointer<T>(
386-
_uncheckedStart: .init(pointer),
385+
start: .init(pointer),
387386
count: capacity
388387
)
389388
return try body(buffer)

stdlib/public/core/UnsafeRawBufferPointer.swift.gyb

Lines changed: 1 addition & 18 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
}
@@ -1408,10 +1394,7 @@ public func _withUnprotectedUnsafeBytes<
14081394
#else
14091395
let addr = UnsafeRawPointer(Builtin.addressOfBorrow(value))
14101396
#endif
1411-
let buffer = UnsafeRawBufferPointer(
1412-
_uncheckedStart: addr,
1413-
count: MemoryLayout<T>.size
1414-
)
1397+
let buffer = UnsafeRawBufferPointer(start: addr, count: MemoryLayout<T>.size)
14151398
return try body(buffer)
14161399
}
14171400

0 commit comments

Comments
 (0)