Skip to content

Commit f2a9649

Browse files
lorenteymilseman
authored andcommitted
[StringGuts] Support for 32-bit platforms
Add 32-bit support to the new StringGuts.
1 parent 5cf9fd7 commit f2a9649

21 files changed

+527
-179
lines changed

stdlib/public/SDK/Foundation/NSString.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ public class NSSimpleCString {}
2323
public class NSConstantString {}
2424

2525
// Called by the SwiftObject implementation.
26-
public func _convertStringToNSString(_ string: String) -> NSString {
27-
return string._bridgeToObjectiveC()
26+
public func _getDescription<T>(_ x: T) -> NSString {
27+
return String(reflecting: x)._bridgeToObjectiveC()
2828
}
2929

3030
extension NSString : ExpressibleByStringLiteral {

stdlib/public/core/Arrays.swift.gyb

+2-1
Original file line numberDiff line numberDiff line change
@@ -1232,7 +1232,8 @@ extension ${Self} : RangeReplaceableCollection, ArrayProtocol {
12321232
/// element. Otherwise, `nil`.
12331233
@_inlineable
12341234
public var _baseAddressIfContiguous: UnsafeMutablePointer<Element>? {
1235-
return _buffer.firstElementAddressIfContiguous
1235+
@inline(__always) // FIXME(TODO: JIRA): Hack around test failure
1236+
get { return _buffer.firstElementAddressIfContiguous }
12361237
}
12371238

12381239
%if Self != 'Array': # // Array does not necessarily have contiguous storage

stdlib/public/core/ReflectionLegacy.swift

-10
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,6 @@ public protocol _Mirror {
6666
var disposition: _MirrorDisposition { get }
6767
}
6868

69-
/// An entry point that can be called from C++ code to get the summary string
70-
/// for an arbitrary object. The memory pointed to by "out" is initialized with
71-
/// the summary string.
72-
@_inlineable // FIXME(sil-serialize-all)
73-
@_silgen_name("swift_getSummary")
74-
public // COMPILER_INTRINSIC
75-
func _getSummary<T>(_ out: UnsafeMutablePointer<String>, x: T) {
76-
out.initialize(to: String(reflecting: x))
77-
}
78-
7969
/// Produce a mirror for any value. The runtime produces a mirror that
8070
/// structurally reflects values of any type.
8171
@_inlineable // FIXME(sil-serialize-all)

stdlib/public/core/StringComparable.swift

+13-26
Original file line numberDiff line numberDiff line change
@@ -80,33 +80,25 @@ extension _StringGuts {
8080
@effects(readonly)
8181
public
8282
static func _compareDeterministicUnicodeCollation(
83-
_leftUnsafeStringGutsBitPattern leftBits: (UInt, UInt),
84-
_rightUnsafeStringGutsBitPattern rightBits: (UInt, UInt)
83+
_leftUnsafeStringGutsBitPattern leftBits: _RawBitPattern,
84+
_rightUnsafeStringGutsBitPattern rightBits: _RawBitPattern
8585
) -> Int {
86-
let left = _StringGuts(
87-
object: _StringObject(rawBits: leftBits.0),
88-
otherBits: leftBits.1)
89-
let right = _StringGuts(
90-
object: _StringObject(rawBits: rightBits.0),
91-
otherBits: rightBits.1)
86+
let left = _StringGuts(rawBits: leftBits)
87+
let right = _StringGuts(rawBits: rightBits)
9288
return _compareDeterministicUnicodeCollation(
9389
left, 0..<left.count, to: right, 0..<right.count)
9490
}
9591
@inline(never)
9692
@effects(readonly)
9793
public
9894
static func _compareDeterministicUnicodeCollation(
99-
_leftUnsafeStringGutsBitPattern leftBits: (UInt, UInt),
95+
_leftUnsafeStringGutsBitPattern leftBits: _RawBitPattern,
10096
_ leftRange: Range<Int>,
101-
_rightUnsafeStringGutsBitPattern rightBits: (UInt, UInt),
97+
_rightUnsafeStringGutsBitPattern rightBits: _RawBitPattern,
10298
_ rightRange: Range<Int>
10399
) -> Int {
104-
let left = _StringGuts(
105-
object: _StringObject(rawBits: leftBits.0),
106-
otherBits: leftBits.1)
107-
let right = _StringGuts(
108-
object: _StringObject(rawBits: rightBits.0),
109-
otherBits: rightBits.1)
100+
let left = _StringGuts(rawBits: leftBits)
101+
let right = _StringGuts(rawBits: rightBits)
110102
return _compareDeterministicUnicodeCollation(
111103
left, leftRange, to: right, rightRange)
112104
}
@@ -165,8 +157,7 @@ extension _StringGuts {
165157
@inline(__always)
166158
@_inlineable
167159
public func _bitwiseEqualTo(_ other: _StringGuts) -> Bool {
168-
return self._object.rawBits == other._object.rawBits
169-
&& self._otherBits == other._otherBits
160+
return self.rawBits == other.rawBits
170161
}
171162

172163
@_inlineable
@@ -232,11 +223,9 @@ extension _StringGuts {
232223
return result
233224
}
234225
#endif
235-
let leftBits = (left._object.rawBits, left._otherBits)
236-
let rightBits = (right._object.rawBits, right._otherBits)
237226
return _compareDeterministicUnicodeCollation(
238-
_leftUnsafeStringGutsBitPattern: leftBits, leftRange,
239-
_rightUnsafeStringGutsBitPattern: rightBits, rightRange)
227+
_leftUnsafeStringGutsBitPattern: left.rawBits, leftRange,
228+
_rightUnsafeStringGutsBitPattern: right.rawBits, rightRange)
240229
}
241230

242231
@_inlineable
@@ -259,11 +248,9 @@ extension _StringGuts {
259248
return result
260249
}
261250
#endif
262-
let leftBits = (left._object.rawBits, left._otherBits)
263-
let rightBits = (right._object.rawBits, right._otherBits)
264251
return _compareDeterministicUnicodeCollation(
265-
_leftUnsafeStringGutsBitPattern: leftBits,
266-
_rightUnsafeStringGutsBitPattern: rightBits)
252+
_leftUnsafeStringGutsBitPattern: left.rawBits,
253+
_rightUnsafeStringGutsBitPattern: right.rawBits)
267254
}
268255
}
269256

0 commit comments

Comments
 (0)