Skip to content

Commit dd2f3b4

Browse files
[stdlib] More inalienable auditing (swiftlang#18925)
* Removing FIXME from methods also marked always/never * Unavailable/deprecated things don't need inlining * Trivial implementations * Enum namespaces * Unsafe performance of opaque/raw pointer * Dump doesn't need to be fast * Error paths shouldn't require inlining * Consistency with surrounding code * Lazy performance needs specialization
1 parent 249b55b commit dd2f3b4

21 files changed

+122
-140
lines changed

stdlib/public/core/Array.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ extension Array: RandomAccessCollection, MutableCollection {
353353
/// // Prints "[30, 40, 50]"
354354
///
355355
/// If the array is empty, `endIndex` is equal to `startIndex`.
356-
@inlinable // FIXME(sil-serialize-all)
356+
@inlinable
357357
public var endIndex: Int {
358358
@inlinable
359359
get {

stdlib/public/core/ArraySlice.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ extension ArraySlice: RandomAccessCollection, MutableCollection {
179179
/// // Prints "[30, 40, 50]"
180180
///
181181
/// If the array is empty, `endIndex` is equal to `startIndex`.
182-
@inlinable // FIXME(sil-serialize-all)
182+
@inlinable
183183
public var endIndex: Int {
184184
return _buffer.endIndex
185185
}

stdlib/public/core/Assert.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public func precondition(
122122
/// where `assertionFailure(_:file:line:)` is called.
123123
/// - line: The line number to print along with `message`. The default is the
124124
/// line number where `assertionFailure(_:file:line:)` is called.
125-
@inlinable // FIXME(sil-serialize-all)
125+
@inlinable
126126
@inline(__always)
127127
public func assertionFailure(
128128
_ message: @autoclosure () -> String = String(),

stdlib/public/core/AssertCommon.swift

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ func _fatalErrorFlags() -> UInt32 {
7575
///
7676
/// This function should not be inlined because it is cold and inlining just
7777
/// bloats code.
78-
@usableFromInline // FIXME(sil-serialize-all)
78+
@usableFromInline
7979
@inline(never)
8080
internal func _assertionFailure(
8181
_ prefix: StaticString, _ message: StaticString,
@@ -105,7 +105,7 @@ internal func _assertionFailure(
105105
///
106106
/// This function should not be inlined because it is cold and inlining just
107107
/// bloats code.
108-
@usableFromInline // FIXME(sil-serialize-all)
108+
@usableFromInline
109109
@inline(never)
110110
internal func _assertionFailure(
111111
_ prefix: StaticString, _ message: String,
@@ -135,7 +135,7 @@ internal func _assertionFailure(
135135
///
136136
/// This function should not be inlined because it is cold and inlining just
137137
/// bloats code.
138-
@usableFromInline // FIXME(sil-serialize-all)
138+
@usableFromInline
139139
@inline(never)
140140
internal func _assertionFailure(
141141
_ prefix: StaticString, _ message: String,
@@ -160,7 +160,7 @@ internal func _assertionFailure(
160160
///
161161
/// This function should not be inlined because it is cold and it inlining just
162162
/// bloats code.
163-
@usableFromInline // FIXME(sil-serialize-all)
163+
@usableFromInline
164164
@inline(never)
165165
@_semantics("arc.programtermination_point")
166166
internal func _fatalErrorMessage(
@@ -246,7 +246,6 @@ func _unimplementedInitializer(className: StaticString,
246246
Builtin.int_trap()
247247
}
248248

249-
// FIXME(ABI)#21 (Type Checker): rename to something descriptive.
250249
@inlinable // FIXME(sil-serialize-all)
251250
public // COMPILER_INTRINSIC
252251
func _undefined<T>(

stdlib/public/core/Builtin.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import SwiftShims
1818
// This function is the implementation of the `_roundUp` overload set. It is
1919
// marked `@inline(__always)` to make primary `_roundUp` entry points seem
2020
// cheap enough for the inliner.
21-
@inlinable // FIXME(sil-serialize-all)
21+
@inlinable
2222
@inline(__always)
2323
internal func _roundUpImpl(_ offset: UInt, toAlignment alignment: Int) -> UInt {
2424
_sanityCheck(alignment > 0)
@@ -31,12 +31,12 @@ internal func _roundUpImpl(_ offset: UInt, toAlignment alignment: Int) -> UInt {
3131
return x & ~(UInt(bitPattern: alignment) &- 1)
3232
}
3333

34-
@inlinable // FIXME(sil-serialize-all)
34+
@inlinable
3535
internal func _roundUp(_ offset: UInt, toAlignment alignment: Int) -> UInt {
3636
return _roundUpImpl(offset, toAlignment: alignment)
3737
}
3838

39-
@inlinable // FIXME(sil-serialize-all)
39+
@inlinable
4040
internal func _roundUp(_ offset: Int, toAlignment alignment: Int) -> Int {
4141
_sanityCheck(offset >= 0)
4242
return Int(_roundUpImpl(UInt(bitPattern: offset), toAlignment: alignment))

stdlib/public/core/CTypes.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ public struct OpaquePointer {
160160
}
161161

162162
extension OpaquePointer: Equatable {
163-
@inlinable // FIXME(sil-serialize-all)
163+
@inlinable // unsafe-performance
164164
public static func == (lhs: OpaquePointer, rhs: OpaquePointer) -> Bool {
165165
return Bool(Builtin.cmp_eq_RawPointer(lhs._rawValue, rhs._rawValue))
166166
}
@@ -193,7 +193,7 @@ extension Int {
193193
///
194194
/// - Parameter pointer: The pointer to use as the source for the new
195195
/// integer.
196-
@inlinable // FIXME(sil-serialize-all)
196+
@inlinable // unsafe-performance
197197
public init(bitPattern pointer: OpaquePointer?) {
198198
self.init(bitPattern: UnsafeRawPointer(pointer))
199199
}
@@ -207,7 +207,7 @@ extension UInt {
207207
///
208208
/// - Parameter pointer: The pointer to use as the source for the new
209209
/// integer.
210-
@inlinable // FIXME(sil-serialize-all)
210+
@inlinable // unsafe-performance
211211
public init(bitPattern pointer: OpaquePointer?) {
212212
self.init(bitPattern: UnsafeRawPointer(pointer))
213213
}
@@ -216,10 +216,10 @@ extension UInt {
216216
/// A wrapper around a C `va_list` pointer.
217217
@_fixed_layout
218218
public struct CVaListPointer {
219-
@usableFromInline // FIXME(sil-serialize-all)
219+
@usableFromInline // unsafe-performance
220220
internal var value: UnsafeMutableRawPointer
221221

222-
@inlinable // FIXME(sil-serialize-all)
222+
@inlinable // unsafe-performance
223223
public // @testable
224224
init(_fromUnsafeMutablePointer from: UnsafeMutableRawPointer) {
225225
value = from

stdlib/public/core/CollectionOfOne.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ extension CollectionOfOne: RandomAccessCollection, MutableCollection {
7979
/// The position of the first element.
8080
///
8181
/// In a `CollectionOfOne` instance, `startIndex` is always `0`.
82-
@inlinable // FIXME(sil-serialize-all)
82+
@inlinable // trivial-implementation
8383
public var startIndex: Index {
8484
return 0
8585
}

stdlib/public/core/CommandLine.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import SwiftShims
1414

1515
/// Command-line arguments for the current process.
16-
@_frozen // FIXME(sil-serialize-all)
16+
@_frozen // namespace
1717
public enum CommandLine {
1818
/// The backing static variable for argument count may come either from the
1919
/// entry point or it may need to be computed e.g. if we're in the REPL.
@@ -31,15 +31,13 @@ public enum CommandLine {
3131
= _swift_stdlib_getUnsafeArgvArgc(&_argc)
3232

3333
/// Access to the raw argc value from C.
34-
@inlinable // FIXME(sil-serialize-all)
3534
public static var argc: Int32 {
3635
_ = CommandLine.unsafeArgv // Force evaluation of argv.
3736
return _argc
3837
}
3938

4039
/// Access to the raw argv value from C. Accessing the argument vector
4140
/// through this pointer is unsafe.
42-
@inlinable // FIXME(sil-serialize-all)
4341
public static var unsafeArgv:
4442
UnsafeMutablePointer<UnsafeMutablePointer<Int8>?> {
4543
return _unsafeArgv

stdlib/public/core/ContiguousArray.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ extension ContiguousArray: RandomAccessCollection, MutableCollection {
8585
/// // Prints "[30, 40, 50]"
8686
///
8787
/// If the array is empty, `endIndex` is equal to `startIndex`.
88-
@inlinable // FIXME(sil-serialize-all)
8988
public var endIndex: Int {
9089
@inlinable
9190
get {

stdlib/public/core/Dump.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
/// - maxItems: The maximum number of elements for which to write the full
2626
/// contents. The default is `Int.max`.
2727
/// - Returns: The instance passed as `value`.
28-
@inlinable // FIXME(sil-serialize-all)
2928
@discardableResult
3029
@_semantics("optimize.sil.specialize.generic.never")
3130
public func dump<T, TargetStream : TextOutputStream>(
@@ -64,7 +63,6 @@ public func dump<T, TargetStream : TextOutputStream>(
6463
/// - maxItems: The maximum number of elements for which to write the full
6564
/// contents. The default is `Int.max`.
6665
/// - Returns: The instance passed as `value`.
67-
@inlinable // FIXME(sil-serialize-all)
6866
@discardableResult
6967
@_semantics("optimize.sil.specialize.generic.never")
7068
public func dump<T>(
@@ -85,7 +83,6 @@ public func dump<T>(
8583
}
8684

8785
/// Dump an object's contents. User code should use dump().
88-
@inlinable // FIXME(sil-serialize-all)
8986
@_semantics("optimize.sil.specialize.generic.never")
9087
internal func _dump_unlocked<TargetStream : TextOutputStream>(
9188
_ value: Any,
@@ -185,7 +182,6 @@ internal func _dump_unlocked<TargetStream : TextOutputStream>(
185182

186183
/// Dump information about an object's superclass, given a mirror reflecting
187184
/// that superclass.
188-
@inlinable // FIXME(sil-serialize-all)
189185
@_semantics("optimize.sil.specialize.generic.never")
190186
internal func _dumpSuperclass_unlocked<TargetStream : TextOutputStream>(
191187
mirror: Mirror,

0 commit comments

Comments
 (0)