Skip to content

Commit 7b7b2e9

Browse files
committed
[stdlib] Remove SipHash from ABI names
1 parent d80c46b commit 7b7b2e9

File tree

3 files changed

+59
-66
lines changed

3 files changed

+59
-66
lines changed

stdlib/public/core/Hasher.swift

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,6 @@
1616

1717
import SwiftShims
1818

19-
extension _SipHash13Core {
20-
@inlinable
21-
@inline(__always)
22-
internal init() {
23-
self.init(rawSeed: Hasher._executionSeed)
24-
}
25-
26-
@inlinable
27-
@inline(__always)
28-
internal init(seed: Int) {
29-
let executionSeed = Hasher._executionSeed
30-
// Prevent sign-extending the supplied seed; this makes testing slightly
31-
// easier.
32-
let seed = UInt(bitPattern: seed)
33-
self.init(rawSeed: (
34-
executionSeed.0 ^ UInt64(truncatingIfNeeded: seed),
35-
executionSeed.1))
36-
}
37-
}
38-
3919
/// The universal hash function used by `Set` and `Dictionary`.
4020
///
4121
/// `Hasher` can be used to map an arbitrary sequence of bytes to an integer
@@ -61,9 +41,6 @@ extension _SipHash13Core {
6141
/// versions of the standard library.
6242
@_fixed_layout
6343
public struct Hasher {
64-
@usableFromInline
65-
internal typealias _Core = _SipHash13Core
66-
6744
internal var _tail: _TailBuffer
6845

6946
internal var _core: _Core

stdlib/public/core/SipHash.swift

Lines changed: 56 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -19,28 +19,32 @@
1919
/// * Daniel J. Bernstein <[email protected]>
2020
//===----------------------------------------------------------------------===//
2121

22-
@_fixed_layout
23-
@usableFromInline
24-
internal struct _SipHashState {
25-
// "somepseudorandomlygeneratedbytes"
26-
fileprivate var v0: UInt64 = 0x736f6d6570736575
27-
fileprivate var v1: UInt64 = 0x646f72616e646f6d
28-
fileprivate var v2: UInt64 = 0x6c7967656e657261
29-
fileprivate var v3: UInt64 = 0x7465646279746573
30-
// These fields are reserved for future use.
31-
fileprivate var p0: UInt64 = 0
32-
fileprivate var p1: UInt64 = 0
33-
fileprivate var p2: UInt64 = 0
34-
fileprivate var p3: UInt64 = 0
22+
extension Hasher {
23+
@_fixed_layout
24+
@usableFromInline
25+
internal struct _State {
26+
// "somepseudorandomlygeneratedbytes"
27+
fileprivate var v0: UInt64 = 0x736f6d6570736575
28+
fileprivate var v1: UInt64 = 0x646f72616e646f6d
29+
fileprivate var v2: UInt64 = 0x6c7967656e657261
30+
fileprivate var v3: UInt64 = 0x7465646279746573
31+
// The fields below are reserved for future use. They aren't currently used.
32+
fileprivate var v4: UInt64 = 0
33+
fileprivate var v5: UInt64 = 0
34+
fileprivate var v6: UInt64 = 0
35+
fileprivate var v7: UInt64 = 0
3536

36-
@inline(__always)
37-
fileprivate init(rawSeed: (UInt64, UInt64)) {
38-
v3 ^= rawSeed.1
39-
v2 ^= rawSeed.0
40-
v1 ^= rawSeed.1
41-
v0 ^= rawSeed.0
37+
@inline(__always)
38+
fileprivate init(rawSeed: (UInt64, UInt64)) {
39+
v3 ^= rawSeed.1
40+
v2 ^= rawSeed.0
41+
v1 ^= rawSeed.1
42+
v0 ^= rawSeed.0
43+
}
4244
}
45+
}
4346

47+
extension Hasher._State {
4448
@inline(__always)
4549
fileprivate
4650
static func _rotateLeft(_ x: UInt64, by amount: UInt64) -> UInt64 {
@@ -50,19 +54,19 @@ internal struct _SipHashState {
5054
@inline(__always)
5155
fileprivate mutating func _round() {
5256
v0 = v0 &+ v1
53-
v1 = _SipHashState._rotateLeft(v1, by: 13)
57+
v1 = Hasher._State._rotateLeft(v1, by: 13)
5458
v1 ^= v0
55-
v0 = _SipHashState._rotateLeft(v0, by: 32)
59+
v0 = Hasher._State._rotateLeft(v0, by: 32)
5660
v2 = v2 &+ v3
57-
v3 = _SipHashState._rotateLeft(v3, by: 16)
61+
v3 = Hasher._State._rotateLeft(v3, by: 16)
5862
v3 ^= v2
5963
v0 = v0 &+ v3
60-
v3 = _SipHashState._rotateLeft(v3, by: 21)
64+
v3 = Hasher._State._rotateLeft(v3, by: 21)
6165
v3 ^= v0
6266
v2 = v2 &+ v1
63-
v1 = _SipHashState._rotateLeft(v1, by: 17)
67+
v1 = Hasher._State._rotateLeft(v1, by: 17)
6468
v1 ^= v2
65-
v2 = _SipHashState._rotateLeft(v2, by: 32)
69+
v2 = Hasher._State._rotateLeft(v2, by: 32)
6670
}
6771

6872
@inline(__always)
@@ -71,27 +75,42 @@ internal struct _SipHashState {
7175
}
7276
}
7377

74-
@usableFromInline
75-
@_fixed_layout
76-
internal struct _SipHash13Core {
77-
private var _state: _SipHashState
78-
78+
extension Hasher {
7979
@usableFromInline
80-
@_effects(releasenone)
81-
internal init(rawSeed: (UInt64, UInt64)) {
82-
_state = _SipHashState(rawSeed: rawSeed)
80+
@_fixed_layout
81+
internal struct _Core {
82+
private var _state: Hasher._State
83+
84+
@inline(__always)
85+
internal init(rawSeed: (UInt64, UInt64)) {
86+
_state = Hasher._State(rawSeed: rawSeed)
87+
}
88+
}
89+
}
90+
91+
extension Hasher._Core {
92+
@inline(__always)
93+
internal init() {
94+
self.init(rawSeed: Hasher._executionSeed)
95+
}
96+
97+
@inline(__always)
98+
internal init(seed: Int) {
99+
let executionSeed = Hasher._executionSeed
100+
// Prevent sign-extending the supplied seed; this makes testing slightly
101+
// easier.
102+
let seed = UInt(bitPattern: seed)
103+
self.init(rawSeed: (
104+
executionSeed.0 ^ UInt64(truncatingIfNeeded: seed),
105+
executionSeed.1))
83106
}
84107

85-
@usableFromInline
86-
@_effects(releasenone)
87108
internal mutating func compress(_ m: UInt64) {
88109
_state.v3 ^= m
89110
_state._round()
90111
_state.v0 ^= m
91112
}
92113

93-
@usableFromInline
94-
@_effects(releasenone)
95114
internal mutating func finalize(tailAndByteCount: UInt64) -> UInt64 {
96115
compress(tailAndByteCount)
97116
_state.v2 ^= 0xff

test/api-digester/Outputs/stability-stdlib-abi.swift.expected

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ Struct _ConcreteHashableBox has been removed
3030
Struct _HasherTailBuffer has been removed
3131
Struct _HeapBufferHeader has been removed
3232
Struct _SipHash13 has been removed
33+
Struct _SipHash13Core has been removed
3334
Struct _SipHash24 has been removed
35+
Struct _SipHashState has been removed
3436
Subscript ManagedBufferPointer.subscript(_:) has been removed
3537
Var ManagedBufferPointer.baseAddress has been removed
3638
Var ManagedBufferPointer.storage has been removed
@@ -51,7 +53,7 @@ Var __SwiftDeferredNSArray._heapBufferBridgedPtr has been removed
5153
/* Renamed Decls */
5254

5355
/* Type Changes */
54-
Var Hasher._core has declared type change from _BufferingHasher<_SipHash13Core> to _SipHash13Core
56+
Var Hasher._core has declared type change from _BufferingHasher<_SipHash13Core> to Hasher._Core
5557
Struct _BridgeableMetatype is now without @_fixed_layout
5658
Func __ContiguousArrayStorageBase._getNonVerbatimBridgingBuffer() is added to a non-resilient type
5759
Var Hasher._core in a non-resilient type changes position from 0 to 1
@@ -60,11 +62,6 @@ Var _CocoaDictionary.Index._offset is added to a non-resilient type
6062
Var _CocoaDictionary.Index._storage in a non-resilient type changes position from 1 to 0
6163
Var _CocoaSet.Index._offset is added to a non-resilient type
6264
Var _CocoaSet.Index._storage in a non-resilient type changes position from 1 to 0
63-
Var _SipHashState.p0 is added to a non-resilient type
64-
Var _SipHashState.p1 is added to a non-resilient type
65-
Var _SipHashState.p2 is added to a non-resilient type
66-
Var _SipHashState.p3 is added to a non-resilient type
67-
Struct _SipHash13Core has removed conformance to _HasherCore
6865

6966
/* Decl Attribute changes */
7067

0 commit comments

Comments
 (0)