Skip to content

Commit

Permalink
Merge branch 'release/1.2'
Browse files Browse the repository at this point in the history
# Conflicts:
#	.swiftci/5_10_ubuntu2204
#	.swiftci/5_7_ubuntu2204
#	.swiftci/5_8_ubuntu2204
#	.swiftci/5_9_ubuntu2204
#	.swiftci/nightly_6_0_macos
#	.swiftci/nightly_6_0_ubuntu2204
#	.swiftci/nightly_main_macos
#	.swiftci/nightly_main_ubuntu2204
  • Loading branch information
lorentey committed Feb 7, 2025
2 parents 78b544f + 973459e commit 1934a59
Show file tree
Hide file tree
Showing 82 changed files with 264 additions and 2,146 deletions.
9 changes: 9 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ project(SwiftCollections

list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/modules)

if(NOT SWIFT_SYSTEM_NAME)
if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
set(SWIFT_SYSTEM_NAME macosx)
else()
set(SWIFT_SYSTEM_NAME "$<LOWER_CASE:${CMAKE_SYSTEM_NAME}>")
endif()
endif()

set(CMAKE_Swift_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/swift)
set(CMAKE_Swift_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY MultiThreadedDLL)

Expand All @@ -38,6 +46,7 @@ if(COLLECTIONS_FOUNDATION_TOOLCHAIN_MODULE)
endif()

include(CTest)
include(GNUInstallDirs)
include(SwiftSupport)

add_subdirectory(Sources)
Expand Down
6 changes: 1 addition & 5 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.7
// swift-tools-version:5.9
//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift Collections open source project
Expand Down Expand Up @@ -188,17 +188,13 @@ let targets: [CustomTarget] = [
name: "InternalCollectionsUtilities",
exclude: [
"CMakeLists.txt",
"Compatibility/UnsafeMutableBufferPointer+SE-0370.swift.gyb",
"Compatibility/UnsafeMutablePointer+SE-0370.swift.gyb",
"Compatibility/UnsafeRawPointer extensions.swift.gyb",
"Debugging.swift.gyb",
"Descriptions.swift.gyb",
"IntegerTricks/FixedWidthInteger+roundUpToPowerOfTwo.swift.gyb",
"IntegerTricks/Integer rank.swift.gyb",
"IntegerTricks/UInt+first and last set bit.swift.gyb",
"IntegerTricks/UInt+reversed.swift.gyb",
"RandomAccessCollection+Offsets.swift.gyb",
"Specialize.swift.gyb",
"UnsafeBitSet/_UnsafeBitSet+Index.swift.gyb",
"UnsafeBitSet/_UnsafeBitSet+_Word.swift.gyb",
"UnsafeBitSet/_UnsafeBitSet.swift.gyb",
Expand Down
41 changes: 28 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,11 @@ The Swift Collections package is source stable. The version numbers follow [Sema

[semver]: https://semver.org

The public API of version 1.1 of the `swift-collections` package consists of non-underscored declarations that are marked `public` in the `Collections`, `BitCollections`, `DequeModule`, `HeapModule`, `OrderedCollections` and `HashTreeCollections` modules.
### Public API

Interfaces that aren't part of the public API may continue to change in any release, including patch releases.
If you have a use case that requires using underscored APIs, please [submit a Feature Request][enhancement] describing it! We'd like the public interface to be as useful as possible -- although preferably without compromising safety or limiting future evolution.
The public API of version 1.2 of the `swift-collections` package consists of non-underscored declarations that are marked `public` in the `Collections`, `BitCollections`, `DequeModule`, `HeapModule`, `OrderedCollections` and `HashTreeCollections` modules.

Interfaces that aren't part of the public API may continue to change in any release, including patch releases.

By "underscored declarations" we mean declarations that have a leading underscore anywhere in their fully qualified name. For instance, here are some names that wouldn't be considered part of the public API, even if they were technically marked public:

Expand All @@ -65,18 +66,25 @@ By "underscored declarations" we mean declarations that have a leading underscor
- `_FooModule.Bar` (underscored module)
- `FooModule.Bar.init(_value:)` (underscored initializer)

Note that contents of the `Tests`, `Utils` and `Benchmarks` subdirectories aren't public API. We don't make any source compatibility promises about them -- they may change at whim, and code may be removed in any new release. Do not rely on anything about them.
If you have a use case that requires using underscored (or otherwise non-public) APIs, please [submit a Feature Request][enhancement] describing it! We'd like the public interface to be as useful as possible -- although preferably without compromising safety or limiting future evolution.

This source compatibility promise only applies to swift-collection when built as a Swift package. (The repository also contains unstable configurations for building swift-collections using CMake and Xcode. These configurations are provided for internal Swift project use only -- such as for building the (private) swift-collections binaries that ship within Swift toolchains.)

Note that the files in the `Tests`, `Utils`, `Documentation`, `Xcode`, `cmake` and `Benchmarks` subdirectories may change at whim; they may be added, modified or removed in any new release. Do not rely on anything about them.

Future minor versions of the package may update these rules as needed.

### Minimum Required Swift Toolchain Version

We'd like this package to quickly embrace Swift language and toolchain improvements that are relevant to its mandate. Accordingly, from time to time, new versions of this package require clients to upgrade to a more recent Swift toolchain release. (This allows the package to make use of new language/stdlib features, build on compiler bug fixes, and adopt new package manager functionality as soon as they are available.) Patch (i.e., bugfix) releases will not increase the required toolchain version, but any minor (i.e., new feature) release may do so.

The following table maps existing package releases to their minimum required Swift toolchain release:
The following table maps package releases to their minimum required Swift toolchain release:

| Package version | Swift version | Xcode release |
| ----------------------- | --------------- | ------------- |
| swift-collections 1.0.x | >= Swift 5.3.2 | >= Xcode 12.4 |
| swift-collections 1.1.x | >= Swift 5.7.2 | >= Xcode 14.2 |
| swift-collections 1.2.x | >= Swift 5.9.0 | >= Xcode 15.0 |

(Note: the package has no minimum deployment target, so while it does require clients to use a recent Swift toolchain to build it, the code itself is able to run on any OS release that supports running Swift code.)

Expand All @@ -86,7 +94,7 @@ The following table maps existing package releases to their minimum required Swi
To use this package in a SwiftPM project, you need to set it up as a package dependency:

```swift
// swift-tools-version:5.9
// swift-tools-version:6.0
import PackageDescription

let package = Package(
Expand Down Expand Up @@ -120,17 +128,19 @@ If you find something that looks like a bug, please open a [Bug Report][bugrepor

We maintain separate branches for each minor version of the package:

| Package version | Branch |
| ----------------------- | ----------- |
| swift-collections 1.0.x | release/1.0 |
| swift-collections 1.1.x | release/1.1 |
| swift-collections 1.2.x | main |
| Package version | Branch | Status |
| ----------------------- | ----------- | -------- |
| swift-collections 1.0.x | release/1.0 | Critical bugfixes only |
| swift-collections 1.1.x | release/1.1 | Critical bugfixes only |
| swift-collections 1.2.x | release/1.2 | Open for feature development (next feature release) |
| swift-collections 1.3.x | main | Open for feature development (unscheduled landing area) |
| n.a. | future | Experimental prototyping |

Changes must land on the branch corresponding to the earliest release that they will need to ship on. They are periodically propagated to subsequent branches, in the following direction:

`release/1.0``release/1.1``main`
`release/1.0``release/1.1``release/1.2``main`

For example, anything landing on `release/1.0` will eventually appear on `release/1.1` and then `main` too; there is no need to file standalone PRs for each release line. (Change propagation currently requires manual work -- it is performed by project maintainers.)
For example, anything landing on `release/1.1` will eventually appear on `release/1.2` and then `main` too; there is no need to file standalone PRs for each release line. (Change propagation currently requires manual work -- it is performed by project maintainers.)

### Working on the package

Expand Down Expand Up @@ -160,6 +170,10 @@ By submitting a pull request, you represent that you have the right to license y

#### Proposing the addition of a new data structure

**Note:** As of 2024, we are fully preoccupied with refactoring our existing data structures to support noncopyable and/or nonescapable element types; this includes designing new container protocols around them. I don't expect we'll have capacity to work on any major new data structure implementations until this effort is complete.

<!--
We intend this package to collect generally useful data structures -- the ones that ought to be within easy reach of every Swift engineer's basic toolbox. The implementations we ship need to be of the highest technical quality, polished to the same shine as anything that gets included in the Swift Standard Library. (The only real differences are that this package isn't under the formal Swift Evolution process, and its code isn't ABI stable.)
Accordingly, adding a new data structure to this package is not an easy or quick process, and not all useful data structures are going to be a good fit.
Expand All @@ -174,6 +188,7 @@ Participate in the review discussion, and adapt code accordingly. Sometimes we m
Historically, PRs adding a new data structure have typically been merged to a new feature branch rather than directly to a release branch or `main`, and there was an extended amount of time between the initial merge and the tag that shipped the new feature. Nobody likes to wait, but getting a new data structure implementation from a state that was ready to merge to a state that's ready to ship is actually quite difficult work, and it takes maintainer time and effort that needs to be scheduled in advance. The closer an implementation is to the coding conventions and performance baseline of the Standard Library, the shorter this wait is likely to become, and the fewer changes there will be between merging and shipping.
-->

### Code of Conduct

Expand Down
2 changes: 2 additions & 0 deletions Sources/BitCollections/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@ target_sources(${module_name} PRIVATE
"BitArray/BitArray+Descriptions.swift"
"BitArray/BitArray+Equatable.swift"
"BitArray/BitArray+ExpressibleByArrayLiteral.swift"
"BitArray/BitArray+ExpressibleByStringLiteral.swift"
"BitArray/BitArray+Extras.swift"
"BitArray/BitArray+Fill.swift"
"BitArray/BitArray+Hashable.swift"
"BitArray/BitArray+Initializers.swift"
"BitArray/BitArray+Invariants.swift"
"BitArray/BitArray+LosslessStringConvertible.swift"
"BitArray/BitArray+RandomBits.swift"
"BitArray/BitArray+RangeReplaceableCollection.swift"
"BitArray/BitArray+Testing.swift"
Expand Down
5 changes: 2 additions & 3 deletions Sources/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,12 @@ if(COLLECTIONS_SINGLE_MODULE)
LIBRARY DESTINATION lib/swift_static/${swift_os}
RUNTIME DESTINATION bin)
endif()
get_swift_host_arch(swift_arch)
install(FILES $<TARGET_PROPERTY:${COLLECTIONS_MODULE_NAME},Swift_MODULE_DIRECTORY>/${COLLECTIONS_MODULE_NAME}.swiftdoc
DESTINATION lib/${swift}/${swift_os}/${COLLECTIONS_MODULE_NAME}.swiftmodule
RENAME ${swift_arch}.swiftdoc)
RENAME ${Swift_MODULE_TRIPLE}.swiftdoc)
install(FILES $<TARGET_PROPERTY:${COLLECTIONS_MODULE_NAME},Swift_MODULE_DIRECTORY>/${COLLECTIONS_MODULE_NAME}.swiftmodule
DESTINATION lib/${swift}/${swift_os}/${COLLECTIONS_MODULE_NAME}.swiftmodule
RENAME ${swift_arch}.swiftmodule)
RENAME ${Swift_MODULE_TRIPLE}.swiftmodule)
else()
_install_target(${COLLECTIONS_MODULE_NAME})
endif()
Expand Down
1 change: 0 additions & 1 deletion Sources/DequeModule/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ target_sources(${module_name} PRIVATE
"Deque+ExpressibleByArrayLiteral.swift"
"Deque+Extras.swift"
"Deque+Hashable.swift"
"Deque+Sendable.swift"
"Deque+Testing.swift"
"Deque._Storage.swift"
"Deque._UnsafeHandle.swift"
Expand Down
2 changes: 1 addition & 1 deletion Sources/DequeModule/Deque+Collection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ extension Deque: Sequence {
}
}

extension Deque.Iterator: Sendable where Element: Sendable {}
extension Deque.Iterator: @unchecked Sendable where Element: Sendable {}

extension Deque: RandomAccessCollection {
public typealias Index = Int
Expand Down
12 changes: 0 additions & 12 deletions Sources/DequeModule/Deque+Sendable.swift

This file was deleted.

2 changes: 2 additions & 0 deletions Sources/DequeModule/Deque.swift
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,5 @@ public struct Deque<Element> {
self._storage = _Storage(minimumCapacity: minimumCapacity)
}
}

extension Deque: @unchecked Sendable where Element: Sendable {}
23 changes: 17 additions & 6 deletions Sources/DequeModule/_DequeBuffer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,22 @@ extension _DequeBuffer: CustomStringConvertible {
}
}

#if compiler(>=5.10)
/// The type-punned empty singleton storage instance.
@usableFromInline
internal let _emptyDequeStorage = _DequeBuffer<Void>.create(
minimumCapacity: 0,
makingHeaderWith: { _ in
_DequeBufferHeader(capacity: 0, count: 0, startSlot: .init(at: 0))
})

nonisolated(unsafe) internal let _emptyDequeStorage
= _DequeBuffer<Void>.create(
minimumCapacity: 0,
makingHeaderWith: { _ in
_DequeBufferHeader(capacity: 0, count: 0, startSlot: .init(at: 0))
})
#else
/// The type-punned empty singleton storage instance.
@usableFromInline
internal let _emptyDequeStorage
= _DequeBuffer<Void>.create(
minimumCapacity: 0,
makingHeaderWith: { _ in
_DequeBufferHeader(capacity: 0, count: 0, startSlot: .init(at: 0))
})
#endif
15 changes: 15 additions & 0 deletions Sources/HashTreeCollections/HashNode/_HashNode+Storage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import InternalCollectionsUtilities
@usableFromInline
internal typealias _RawHashStorage = ManagedBuffer<_HashNodeHeader, _RawHashNode>

#if compiler(>=5.10)
/// Type-punned storage for the singleton root node used in empty hash trees
/// (of all `Key` and `Value` types).
///
Expand All @@ -26,9 +27,23 @@ internal typealias _RawHashStorage = ManagedBuffer<_HashNodeHeader, _RawHashNode
/// `_HashNode.Storage` subclass is to allow storage instances to properly
/// clean up after themselves in their `deinit` method.)
@usableFromInline
nonisolated(unsafe)
internal let _emptySingleton: _RawHashStorage = _RawHashStorage.create(
minimumCapacity: 0,
makingHeaderWith: { _ in _HashNodeHeader(byteCapacity: 0) })
#else
/// Type-punned storage for the singleton root node used in empty hash trees
/// (of all `Key` and `Value` types).
///
/// `_HashNode` is carefully defined to use a `_RawHashStorage` reference as its
/// storage variable, so that this can work. (The only reason we need the
/// `_HashNode.Storage` subclass is to allow storage instances to properly
/// clean up after themselves in their `deinit` method.)
@usableFromInline
internal let _emptySingleton: _RawHashStorage = _RawHashStorage.create(
minimumCapacity: 0,
makingHeaderWith: { _ in _HashNodeHeader(byteCapacity: 0) })
#endif

extension _HashNode {
/// Instances of this class hold (tail-allocated) storage for individual
Expand Down
12 changes: 8 additions & 4 deletions Sources/HashTreeCollections/HashNode/_HashStack.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
@usableFromInline
@frozen
internal struct _HashStack<Element> {
#if arch(x86_64) || arch(arm64)
#if _pointerBitWidth(_64)
@inlinable
@inline(__always)
internal static var capacity: Int { 13 }
Expand All @@ -27,7 +27,7 @@ internal struct _HashStack<Element> {
Element, Element, Element, Element,
Element
)
#else
#elseif _pointerBitWidth(_32)
@inlinable
@inline(__always)
internal static var capacity: Int { 7 }
Expand All @@ -38,6 +38,8 @@ internal struct _HashStack<Element> {
Element, Element, Element, Element,
Element, Element, Element
)
#else
#error("Unexpected pointer bit width")
#endif

@usableFromInline
Expand All @@ -46,18 +48,20 @@ internal struct _HashStack<Element> {
@inlinable
internal init(filledWith value: Element) {
assert(Self.capacity == _HashLevel.limit)
#if arch(x86_64) || arch(arm64)
#if _pointerBitWidth(_64)
_contents = (
value, value, value, value,
value, value, value, value,
value, value, value, value,
value
)
#else
#elseif _pointerBitWidth(_32)
_contents = (
value, value, value, value,
value, value, value
)
#else
#error("Unexpected pointer bit width")
#endif
self._count = 0
}
Expand Down
4 changes: 0 additions & 4 deletions Sources/InternalCollectionsUtilities/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,8 @@ target_sources(${module_name} PRIVATE
"autogenerated/Debugging.swift"
"autogenerated/Descriptions.swift"
"autogenerated/RandomAccessCollection+Offsets.swift"
"autogenerated/Specialize.swift"
"autogenerated/UnsafeBufferPointer+Extras.swift"
"autogenerated/UnsafeMutableBufferPointer+Extras.swift"
"Compatibility/autogenerated/UnsafeMutableBufferPointer+SE-0370.swift"
"Compatibility/autogenerated/UnsafeMutablePointer+SE-0370.swift"
"Compatibility/autogenerated/UnsafeRawPointer extensions.swift"
"IntegerTricks/autogenerated/FixedWidthInteger+roundUpToPowerOfTwo.swift"
"IntegerTricks/autogenerated/Integer rank.swift"
"IntegerTricks/autogenerated/UInt+first and last set bit.swift"
Expand Down
Loading

0 comments on commit 1934a59

Please sign in to comment.