Skip to content

Commit 02401d4

Browse files
committed
Remove some workarounds
1 parent 581376e commit 02401d4

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
@@ -3665,16 +3665,7 @@ internal struct InstantiateKeyPathBuffer: KeyPathPatternVisitor {
36653665
self.patternArgs = patternArgs
36663666
self.base = root
36673667

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

36803671
// Track the triviality of the resulting object data.
@@ -3980,14 +3971,7 @@ internal struct InstantiateKeyPathBuffer: KeyPathPatternVisitor {
39803971
pushDest(metadata)
39813972
base = metadata
39823973

3983-
// FIXME: This will not work on arm64e.
3984-
let metadataPtr = unsafeBitCast(metadata, to: UnsafeRawPointer.self)
3985-
let vwtPtr = metadataPtr.load(
3986-
fromByteOffset: 0 &- MemoryLayout<Int>.size,
3987-
as: UnsafeRawPointer.self
3988-
)
3989-
let size = vwtPtr.load(fromByteOffset: 0x40, as: Int.self)
3990-
//let size = _openExistential(metadata, do: _getTypeSize(_:))
3974+
let size = _openExistential(metadata, do: _getTypeSize(_:))
39913975

39923976
maxSize = Swift.max(maxSize, size)
39933977
}

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)
@@ -295,7 +294,7 @@ public func _withUnprotectedUnsafeTemporaryAllocation<R: ~Copyable>(
295294
alignment: alignment
296295
) { pointer in
297296
let buffer = UnsafeMutableRawBufferPointer(
298-
_uncheckedStart: .init(pointer),
297+
start: .init(pointer),
299298
count: byteCount
300299
)
301300
return try body(buffer)
@@ -375,7 +374,7 @@ public func _withUnprotectedUnsafeTemporaryAllocation<
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: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -117,20 +117,6 @@ public struct Unsafe${Mutable}RawBufferPointer {
117117
_debugPrecondition(count == 0 || start != nil,
118118
"${Self} has a nil start and nonzero count")
119119

120-
self.init(_uncheckedStart: start, count: count)
121-
}
122-
123-
@_alwaysEmitIntoClient
124-
internal init(
125-
_uncheckedStart start: Unsafe${Mutable}RawPointer?,
126-
count: Int
127-
) {
128-
_internalInvariant(count >= 0, "${Self} with negative count")
129-
_internalInvariant(
130-
count == 0 || start != nil,
131-
"${Self} has a nil start and nonzero count"
132-
)
133-
134120
_position = start
135121
_end = start.map { $0 + _assumeNonNegative(count) }
136122
}
@@ -1397,10 +1383,7 @@ public func _withUnprotectedUnsafeBytes<
13971383
#else
13981384
let addr = UnsafeRawPointer(Builtin.addressOfBorrow(value))
13991385
#endif
1400-
let buffer = UnsafeRawBufferPointer(
1401-
_uncheckedStart: addr,
1402-
count: MemoryLayout<T>.size
1403-
)
1386+
let buffer = UnsafeRawBufferPointer(start: addr, count: MemoryLayout<T>.size)
14041387
return try body(buffer)
14051388
}
14061389

0 commit comments

Comments
 (0)