Skip to content

Commit 293da8f

Browse files
[stdlib] YAIAPR (#18956)
* Scrap Comparable conformance for _SwiftNSOperatingSystemVersion * Lazy performance needs specialization * Uninline dump/stdout * Bool consistency * fixup CollectionOld * Uninline printing functions
1 parent e4388af commit 293da8f

File tree

8 files changed

+74
-203
lines changed

8 files changed

+74
-203
lines changed

stdlib/public/core/Availability.swift

+4-53
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,11 @@ public func _stdlib_isOSVersionAtLeast(
2929
// that this function was called by a compiler optimization pass. If it is
3030
// replaced that pass needs to be updated.
3131
let runningVersion = _swift_stdlib_operatingSystemVersion()
32-
let queryVersion = _SwiftNSOperatingSystemVersion(
33-
majorVersion: Int(major),
34-
minorVersion: Int(minor),
35-
patchVersion: Int(patch)
36-
)
37-
38-
let result = runningVersion >= queryVersion
3932

33+
let result =
34+
(runningVersion.majorVersion,runningVersion.minorVersion,runningVersion.patchVersion)
35+
>= (Int(major),Int(minor),Int(patch))
36+
4037
return result._value
4138
#else
4239
// FIXME: As yet, there is no obvious versioning standard for platforms other
@@ -45,49 +42,3 @@ public func _stdlib_isOSVersionAtLeast(
4542
return false._value
4643
#endif
4744
}
48-
49-
extension _SwiftNSOperatingSystemVersion : Comparable {
50-
51-
@inlinable // FIXME(sil-serialize-all)
52-
public static func == (
53-
lhs: _SwiftNSOperatingSystemVersion,
54-
rhs: _SwiftNSOperatingSystemVersion
55-
) -> Bool {
56-
return lhs.majorVersion == rhs.majorVersion &&
57-
lhs.minorVersion == rhs.minorVersion &&
58-
lhs.patchVersion == rhs.patchVersion
59-
}
60-
61-
/// Lexicographic comparison of version components.
62-
@inlinable // FIXME(sil-serialize-all)
63-
public static func < (
64-
lhs: _SwiftNSOperatingSystemVersion,
65-
rhs: _SwiftNSOperatingSystemVersion
66-
) -> Bool {
67-
guard lhs.majorVersion == rhs.majorVersion else {
68-
return lhs.majorVersion < rhs.majorVersion
69-
}
70-
71-
guard lhs.minorVersion == rhs.minorVersion else {
72-
return lhs.minorVersion < rhs.minorVersion
73-
}
74-
75-
return lhs.patchVersion < rhs.patchVersion
76-
}
77-
78-
@inlinable // FIXME(sil-serialize-all)
79-
public static func >= (
80-
lhs: _SwiftNSOperatingSystemVersion,
81-
rhs: _SwiftNSOperatingSystemVersion
82-
) -> Bool {
83-
guard lhs.majorVersion == rhs.majorVersion else {
84-
return lhs.majorVersion >= rhs.majorVersion
85-
}
86-
87-
guard lhs.minorVersion == rhs.minorVersion else {
88-
return lhs.minorVersion >= rhs.minorVersion
89-
}
90-
91-
return lhs.patchVersion >= rhs.patchVersion
92-
}
93-
}

stdlib/public/core/Bool.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public struct Bool {
8181
/// Creates an instance equal to the given Boolean value.
8282
///
8383
/// - Parameter value: The Boolean value to copy.
84-
@inlinable // FIXME(sil-serialize-all)
84+
@inlinable
8585
public init(_ value: Bool) {
8686
self = value
8787
}
@@ -176,7 +176,7 @@ extension Bool {
176176

177177
extension Bool : CustomStringConvertible {
178178
/// A textual representation of the Boolean value.
179-
@inlinable // FIXME(sil-serialize-all)
179+
@inlinable
180180
public var description: String {
181181
return self ? "true" : "false"
182182
}
@@ -213,7 +213,7 @@ extension Bool : LosslessStringConvertible {
213213
/// `"false"`, the result is `nil`. This initializer is case sensitive.
214214
///
215215
/// - Parameter description: A string representation of the Boolean value.
216-
@inlinable // FIXME(sil-serialize-all)
216+
@inlinable
217217
public init?(_ description: String) {
218218
if description == "true" {
219219
self = true

stdlib/public/core/Join.swift

+14-14
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
/// A sequence that presents the elements of a base sequence of sequences
1414
/// concatenated using a given separator.
15-
@_fixed_layout // FIXME(sil-serialize-all)
15+
@_fixed_layout // lazy-performance
1616
public struct JoinedSequence<Base : Sequence> where Base.Element : Sequence {
1717

1818
public typealias Element = Base.Element.Element
@@ -37,33 +37,33 @@ public struct JoinedSequence<Base : Sequence> where Base.Element : Sequence {
3737
extension JoinedSequence {
3838
/// An iterator that presents the elements of the sequences traversed
3939
/// by a base iterator, concatenated using a given separator.
40-
@_fixed_layout // FIXME(sil-serialize-all)
40+
@_fixed_layout // lazy-performance
4141
public struct Iterator {
42-
@usableFromInline // FIXME(sil-serialize-all)
42+
@usableFromInline // lazy-performance
4343
internal var _base: Base.Iterator
44-
@usableFromInline // FIXME(sil-serialize-all)
44+
@usableFromInline // lazy-performance
4545
internal var _inner: Base.Element.Iterator?
46-
@usableFromInline // FIXME(sil-serialize-all)
46+
@usableFromInline // lazy-performance
4747
internal var _separatorData: ContiguousArray<Element>
48-
@usableFromInline // FIXME(sil-serialize-all)
48+
@usableFromInline // lazy-performance
4949
internal var _separator: ContiguousArray<Element>.Iterator?
5050

51-
@_frozen // FIXME(sil-serialize-all)
52-
@usableFromInline // FIXME(sil-serialize-all)
51+
@_frozen // lazy-performance
52+
@usableFromInline // lazy-performance
5353
internal enum JoinIteratorState {
5454
case start
5555
case generatingElements
5656
case generatingSeparator
5757
case end
5858
}
59-
@usableFromInline // FIXME(sil-serialize-all)
59+
@usableFromInline // lazy-performance
6060
internal var _state: JoinIteratorState = .start
6161

6262
/// Creates a sequence that presents the elements of `base` sequences
6363
/// concatenated using `separator`.
6464
///
6565
/// - Complexity: O(`separator.count`).
66-
@inlinable // FIXME(sil-serialize-all)
66+
@inlinable // lazy-performance
6767
public init<Separator: Sequence>(base: Base.Iterator, separator: Separator)
6868
where Separator.Element == Element {
6969
self._base = base
@@ -79,7 +79,7 @@ extension JoinedSequence.Iterator: IteratorProtocol {
7979
/// exists.
8080
///
8181
/// Once `nil` has been returned, all subsequent calls return `nil`.
82-
@inlinable // FIXME(sil-serialize-all)
82+
@inlinable // lazy-performance
8383
public mutating func next() -> Element? {
8484
while true {
8585
switch _state {
@@ -125,12 +125,12 @@ extension JoinedSequence: Sequence {
125125
/// Return an iterator over the elements of this sequence.
126126
///
127127
/// - Complexity: O(1).
128-
@inlinable // FIXME(sil-serialize-all)
128+
@inlinable // lazy-performance
129129
public func makeIterator() -> Iterator {
130130
return Iterator(base: _base.makeIterator(), separator: _separator)
131131
}
132132

133-
@inlinable // FIXME(sil-serialize-all)
133+
@inlinable // lazy-performance
134134
public func _copyToContiguousArray() -> ContiguousArray<Element> {
135135
var result = ContiguousArray<Element>()
136136
let separatorSize: Int = numericCast(_separator.count)
@@ -183,7 +183,7 @@ extension Sequence where Element : Sequence {
183183
/// - Parameter separator: A sequence to insert between each of this
184184
/// sequence's elements.
185185
/// - Returns: The joined sequence of elements.
186-
@inlinable // FIXME(sil-serialize-all)
186+
@inlinable // lazy-performance
187187
public func joined<Separator : Sequence>(
188188
separator: Separator
189189
) -> JoinedSequence<Self>

stdlib/public/core/MigrationSupport.swift

+11
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,17 @@ extension String { // RangeReplaceableCollection
466466
}
467467
}
468468

469+
@available(*, unavailable, renamed: "TextOutputStream")
470+
public typealias OutputStreamType = TextOutputStream
471+
472+
extension TextOutputStreamable {
473+
@available(*, unavailable, renamed: "write(to:)")
474+
public func writeTo<Target : TextOutputStream>(_ target: inout Target) {
475+
Builtin.unreachable()
476+
}
477+
}
478+
479+
469480
extension String.UnicodeScalarView : _CustomPlaygroundQuickLookable {
470481
@available(*, deprecated/*, obsoleted: 5.0*/, message: "UnicodeScalarView.customPlaygroundQuickLook will be removed in Swift 5.0")
471482
public var customPlaygroundQuickLook: _PlaygroundQuickLook {

stdlib/public/core/OutputStream.swift

+1-25
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,6 @@ internal func _adHocPrint_unlocked<T, TargetStream : TextOutputStream>(
374374
}
375375

376376
@usableFromInline
377-
@inline(never)
378377
@_semantics("optimize.sil.specialize.generic.never")
379378
internal func _print_unlocked<T, TargetStream : TextOutputStream>(
380379
_ value: T, _ target: inout TargetStream
@@ -415,7 +414,7 @@ internal func _print_unlocked<T, TargetStream : TextOutputStream>(
415414
///
416415
/// This function is forbidden from being inlined because when building the
417416
/// standard library inlining makes us drop the special semantics.
418-
@inline(never) @_effects(readonly)
417+
@_effects(readonly)
419418
@usableFromInline
420419
internal func _toStringReadOnlyStreamable<
421420
T : TextOutputStreamable
@@ -533,23 +532,17 @@ internal func _dumpPrint_unlocked<T, TargetStream : TextOutputStream>(
533532
// OutputStreams
534533
//===----------------------------------------------------------------------===//
535534

536-
@_fixed_layout // FIXME(sil-serialize-all)
537-
@usableFromInline // FIXME(sil-serialize-all)
538535
internal struct _Stdout : TextOutputStream {
539-
@inlinable // FIXME(sil-serialize-all)
540536
internal init() {}
541537

542-
@inlinable // FIXME(sil-serialize-all)
543538
internal mutating func _lock() {
544539
_swift_stdlib_flockfile_stdout()
545540
}
546541

547-
@inlinable // FIXME(sil-serialize-all)
548542
internal mutating func _unlock() {
549543
_swift_stdlib_funlockfile_stdout()
550544
}
551545

552-
@inlinable // FIXME(sil-serialize-all)
553546
internal mutating func write(_ string: String) {
554547
if string.isEmpty { return }
555548

@@ -614,42 +607,25 @@ extension Unicode.Scalar : TextOutputStreamable {
614607
/// A hook for playgrounds to print through.
615608
public var _playgroundPrintHook : ((String) -> Void)? = nil
616609

617-
@_fixed_layout // FIXME(sil-serialize-all)
618-
@usableFromInline // FIXME(sil-serialize-all)
619610
internal struct _TeeStream<
620611
L : TextOutputStream,
621612
R : TextOutputStream
622613
> : TextOutputStream {
623614

624-
@inlinable // FIXME(sil-serialize-all)
625615
internal init(left: L, right: R) {
626616
self.left = left
627617
self.right = right
628618
}
629619

630-
@usableFromInline // FIXME(sil-serialize-all)
631620
internal var left: L
632-
@usableFromInline // FIXME(sil-serialize-all)
633621
internal var right: R
634622

635623
/// Append the given `string` to this stream.
636-
@inlinable // FIXME(sil-serialize-all)
637624
internal mutating func write(_ string: String) {
638625
left.write(string); right.write(string)
639626
}
640627

641-
@inlinable // FIXME(sil-serialize-all)
642628
internal mutating func _lock() { left._lock(); right._lock() }
643-
@inlinable // FIXME(sil-serialize-all)
644629
internal mutating func _unlock() { right._unlock(); left._unlock() }
645630
}
646631

647-
@available(*, unavailable, renamed: "TextOutputStream")
648-
public typealias OutputStreamType = TextOutputStream
649-
650-
extension TextOutputStreamable {
651-
@available(*, unavailable, renamed: "write(to:)")
652-
public func writeTo<Target : TextOutputStream>(_ target: inout Target) {
653-
Builtin.unreachable()
654-
}
655-
}

stdlib/public/core/Print.swift

+7-21
Original file line numberDiff line numberDiff line change
@@ -49,22 +49,19 @@
4949
/// space (`" "`).
5050
/// - terminator: The string to print after all items have been printed. The
5151
/// default is a newline (`"\n"`).
52-
@inline(never)
5352
public func print(
5453
_ items: Any...,
5554
separator: String = " ",
5655
terminator: String = "\n"
5756
) {
5857
if let hook = _playgroundPrintHook {
5958
var output = _TeeStream(left: "", right: _Stdout())
60-
_print(
61-
items, separator: separator, terminator: terminator, to: &output)
59+
_print(items, separator: separator, terminator: terminator, to: &output)
6260
hook(output.left)
6361
}
6462
else {
6563
var output = _Stdout()
66-
_print(
67-
items, separator: separator, terminator: terminator, to: &output)
64+
_print(items, separator: separator, terminator: terminator, to: &output)
6865
}
6966
}
7067

@@ -108,21 +105,19 @@ public func print(
108105
/// space (`" "`).
109106
/// - terminator: The string to print after all items have been printed. The
110107
/// default is a newline (`"\n"`).
111-
@inline(never)
112108
public func debugPrint(
113109
_ items: Any...,
114110
separator: String = " ",
115-
terminator: String = "\n") {
111+
terminator: String = "\n"
112+
) {
116113
if let hook = _playgroundPrintHook {
117114
var output = _TeeStream(left: "", right: _Stdout())
118-
_debugPrint(
119-
items, separator: separator, terminator: terminator, to: &output)
115+
_debugPrint(items, separator: separator, terminator: terminator, to: &output)
120116
hook(output.left)
121117
}
122118
else {
123119
var output = _Stdout()
124-
_debugPrint(
125-
items, separator: separator, terminator: terminator, to: &output)
120+
_debugPrint(items, separator: separator, terminator: terminator, to: &output)
126121
}
127122
}
128123

@@ -163,8 +158,6 @@ public func debugPrint(
163158
/// default is a newline (`"\n"`).
164159
/// - output: An output stream to receive the text representation of each
165160
/// item.
166-
@inlinable // FIXME(sil-serialize-all)
167-
@inline(__always)
168161
public func print<Target : TextOutputStream>(
169162
_ items: Any...,
170163
separator: String = " ",
@@ -212,20 +205,15 @@ public func print<Target : TextOutputStream>(
212205
/// default is a newline (`"\n"`).
213206
/// - output: An output stream to receive the text representation of each
214207
/// item.
215-
@inlinable // FIXME(sil-serialize-all)
216-
@inline(__always)
217208
public func debugPrint<Target : TextOutputStream>(
218209
_ items: Any...,
219210
separator: String = " ",
220211
terminator: String = "\n",
221212
to output: inout Target
222213
) {
223-
_debugPrint(
224-
items, separator: separator, terminator: terminator, to: &output)
214+
_debugPrint(items, separator: separator, terminator: terminator, to: &output)
225215
}
226216

227-
@usableFromInline
228-
@inline(never)
229217
internal func _print<Target : TextOutputStream>(
230218
_ items: [Any],
231219
separator: String = " ",
@@ -243,8 +231,6 @@ internal func _print<Target : TextOutputStream>(
243231
output.write(terminator)
244232
}
245233

246-
@usableFromInline
247-
@inline(never)
248234
internal func _debugPrint<Target : TextOutputStream>(
249235
_ items: [Any],
250236
separator: String = " ",

0 commit comments

Comments
 (0)