Commit Graph

15953 Commits

Author SHA1 Message Date
swift-ci
6c829e02a8 Merge pull request #41719 from apple/natecook1000-patch-3
Fix error in MutableCollection.shuffle() docs
2022-03-07 22:12:42 -08:00
Nate Cook
544d10f2cb Fix error in MutableCollection.shuffle() docs 2022-03-07 22:17:58 -06:00
Saleem Abdulrasool
0bc375d97c Revert "visualc: clean up the module definition"
This reverts commit c194d1cf24.
2022-03-07 18:25:25 -08:00
Allan Shortlidge
58fe2e1a05 Merge pull request #41682 from tshortli/fix-warnings
NFC: Fix a number of warnings emitted when building swift-frontend
2022-03-07 15:11:36 -08:00
Robert Widmann
7cd3541c62 Merge pull request #41656 from MillerTechnologyPeru/feature/ppc32
[stdlib] Added PowerPC 32-bit support
2022-03-07 15:08:26 -08:00
Robert Widmann
7d9d79879c Merge pull request #41686 from MillerTechnologyPeru/feature/armv5-trunk
[stdlib] Added Armv5 support
2022-03-07 12:34:32 -08:00
Allan Shortlidge
a8ff646b6e NFC: Fix unintialized variable warnings and C++20 extension warnings in concurrency related code. 2022-03-07 11:59:08 -08:00
Saleem Abdulrasool
9be5586688 Merge pull request #41705 from compnerd/arm64-long
core: map UnsignedLong to UInt32
2022-03-07 11:47:19 -08:00
Saleem Abdulrasool
c194d1cf24 visualc: clean up the module definition
Clean up the submodules in visualc to not export all imported modules.
The one special case is `vcruntime` which re-exports `SAL` due to a
dependency in the headers.  The import of `visualc` however will
re-export all submodules to keep the current behaviour.  This is
required to get the ARM64 SDK building on newer MSVC toolsets.
2022-03-07 10:59:00 -08:00
Alex Martini
6491da8b62 Merge pull request #41339 from amartini51/BidirectionalCollection_88709422
Add missing word & slightly clarify.
2022-03-07 10:52:53 -08:00
Egor Zhdan
2ddadc27fb Merge pull request #41704 from apple/egorzhdan/no-concurrency-fix
[OSLog] Conditionally remove the dependency on `_Concurrency`
2022-03-07 09:36:41 -08:00
Saleem Abdulrasool
20ade9b602 core: map UnsignedLong to UInt32
Windows ARM64 is a LLP64 platform, which means that `unsigned long` is a
32-bit value.  This was already mapped properly for x86_64, but somehow
had missed ARM64.  This repairs that which is required for building the
standard library.
2022-03-07 08:11:42 -08:00
Egor Zhdan
18ec9b3c3f [OSLog] Conditionally remove the dependency on _Concurrency
rdar://89902675
2022-03-07 14:32:47 +00:00
Egor Zhdan
ea002eca0d Merge pull request #41644 from apple/egorzhdan/no-concurrency
[OSLog] Remove the dependency on `_Concurrency`
2022-03-07 04:19:39 -08:00
Saleem Abdulrasool
8e0cc413c2 Concurrency: clean up a log message (NFC)
This simply cleans up the logged message when debug tracing is enabled.
2022-03-06 10:17:47 -08:00
Alsey Coleman Miller
b85e673a78 [stdlib] Added Armv5 support 2022-03-06 00:56:32 -05:00
Guillaume Lessard
f4d56d3734 Merge pull request #41679 from amartini51/trailing_double_tab
Remove trailing double tabs
2022-03-05 13:16:24 -07:00
Jonathan Grynspan
597d7097e8 Merge pull request #41621 from grynspan/jgrynspan/copy-metadata-sections
Add exported symbol on non-Apple platforms to enumerate MetadataSection structures at runtime.
2022-03-05 13:54:22 -05:00
Hamish Knight
a2cfbda850 Revert "Cleaning up _runAsyncMain a bit" 2022-03-05 13:14:36 +00:00
Evan Wilde
1ab41bf955 Merge pull request #40661 from etcwilde/ewilde/concurrency/cleanup-run-async-main
Cleaning up _runAsyncMain a bit
2022-03-04 21:25:18 -08:00
Philippe Hausler
b0f0cb257d Audit and correct AsyncSequence Sendability (#41253)
* Audit and correct AsyncSequence Sendability

* Annotate availability on Sendable conformances for AsyncSequences

* Fix typo of Sendable.Iterator

* Correct tests to use sendable builders

* Add @preconcurrency annotations and fixup one remaining missing @Sendable case

* Move preconcurrency to correct syntactical position

* Use unchecked Sendable conditional conformance instead of marking all internals as preconcurrency and sendable

* Use unchecked Sendable conditional conformance instead of marking all internals as preconcurrency and sendable for dropWhile

* claim ABI changes for marking of @preconcurrency as expected
2022-03-04 21:21:32 -08:00
Jonathan Grynspan
845182252c Add exported symbol on non-Apple platforms to enumerate MetadataSection structures at runtime. 2022-03-04 23:44:10 -05:00
Allan Shortlidge
1be8913c9b NFC: Fix a number of warnings emitted when building swift-frontend. 2022-03-04 16:15:33 -08:00
Alsey Coleman Miller
0ab3eec987 Added PowerPC 32-bit support 2022-03-03 22:21:33 -05:00
Guillaume Lessard
bc3a9d287f Merge pull request #41392 from amartini51/UnsafeMutableRawBufferPointer_storeBytes_88982081
Add missing parameter in doc comment.
2022-03-03 13:14:20 -07:00
Artem Chikin
612ef087d4 Merge pull request #41637 from artemcm/StaticMirrorAssociatedTypes
[Static Mirror] Refactor gathering of associated types from a binary and add SwiftStaticMirror entry-point for it.
2022-03-03 11:58:09 -08:00
Egor Zhdan
1326f821a0 [OSLog] Remove the dependency on _Concurrency
_Concurrency is not used in the module, and having it as a dependency causes a ninja error when trying to build stdlib without `-D SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY=YES`:

```
ninja: error: 'stdlib/private/OSLog/swift_Concurrency-swiftmodule-macosx-arm64', needed by 'stdlib/private/OSLog/OSX/arm64/OSLogTestHelper.o', missing and no known rule to make it
```
2022-03-03 13:34:23 +00:00
Slava Pestov
06dabe91ec Merge pull request #41630 from slavapestov/rqm-abstract-signatures-fixes
RequirementMachine: Fix test failures with -requirement-machine-abstract-signatures=verify
2022-03-02 22:13:45 -05:00
Artem Chikin
62e07dc339 [Static Mirror] Refactor gathering of associated types from a binary and add SwiftStaticMirror entry-point for it. 2022-03-02 16:28:12 -08:00
Slava Pestov
f53756aebb stdlib: Build with -requirement-machine-abstract-signatures=verify 2022-03-02 17:42:40 -05:00
Mike Ash
d61fee3884 [Runtime] Check the weak-linked _dyld_has_preoptimized_swift_protocol_conformances for NULL before calling it.
rdar://89522018
2022-03-02 14:24:12 -05:00
Chris Adamson
87d0885088 AsyncStream: Explicit code-block fence around doc code snippet. (#41407)
* Explicit code-block fence around doc code snippet.

* Doc snippet: remove unnecessary indentation.

Co-authored-by: Chris Adamson <cadamson@apple.com>
2022-03-02 09:06:26 -05:00
Karoy Lorentey
1da581642c Merge pull request #41599 from lorentey/string-unicodescalarview-index-validation
[stdlib] String.UnicodeScalarView: Fix some index validation issues
2022-03-01 16:27:34 -08:00
Karoy Lorentey
20c293ee18 Merge pull request #41598 from lorentey/string-index-validation
[stdlib] String.index(before:): Fix index validation issues
2022-03-01 16:27:03 -08:00
Alex Martini
17d3b01b48 Remove trailing double tabs. 2022-03-01 14:46:40 -08:00
Guillaume Lessard
577015f5be Merge pull request #39639 from glessard/se-pointer-convenience
SE-0334: Pointer API Usability Improvements
2022-03-01 13:24:25 -07:00
Karoy Lorentey
6f9edc8be8 [stdlib] String.UnicodeScalarView: Fix some index validation issues
`String.UnicodeScalarView` currently lacks proper index validation in its `index(after:)` and `index(before:)` methods, leading to out-of-bounds memory accesses when index navigation methods in this view are given invalid indices.

(Also see https://github.com/apple/swift/pull/41598 and https://github.com/apple/swift/pull/41417)

rdar://89498541
2022-02-28 19:49:22 -08:00
Karoy Lorentey
5b364c4e2b [stdlib] String.index(before:): Fix index validation issues
`String.index(before:)` (and methods that rely on it, such as `Substring.index(before:)`, `.distance(from:to:)` etc.) does not currently verify that the given index falls before the `endIndex` before aligning it to a scalar boundary. This allows an out-of-bounds memory access when the provided index points to a position beyond the end of `self`’s storage.

Additionally, the `i > startIndex` check needs to be done after scalar alignment, not before, as alignment can round the index down to `startIndex`.

rdar://89497074&89495373
2022-02-28 17:26:52 -08:00
Guillaume Lessard
ee08dc9951 Merge pull request #41586 from stephentyrone/order-of-operations-is-hard
|| has higher precedence than the ternary operator
2022-02-28 16:33:46 -07:00
Karoy Lorentey
57af818823 Merge pull request #41548 from lorentey/simplify-failEarlyRangeCheck
[stdlib] Collection: simplify default _failEarlyRangeCheck implementations
2022-02-28 14:52:31 -08:00
Karoy Lorentey
d2673ed342 Merge pull request #41572 from lorentey/stop-mentioning-IndexDistance
[stdlib] Mark String.IndexDistance as deprecated and stop mentioning it in method signatures
2022-02-28 14:50:58 -08:00
Stephen Canon
b520063e53 || has higher precedence than the ternary operator, so this check didn't work. 2022-02-28 15:33:27 -05:00
Karoy Lorentey
626582ce5f [stdlib] Mark String.IndexDistance as deprecated and stop mentioning it in method signatures
`IndexDistance` is an artifact of ancient history — it used to be an associated type of Collection in the Swift 3 era. The Collection requirement got replaced with a deprecated typealias of Int in Swift 4, the same release that re-introduced the Collection conformance for String.

However, the typealias declaration for String.IndexDistance has fallen through the cracks. It was accidentally left un-deprecated and it’s still actively mentioned in String API declarations to this day. (These usages leak into the API docs, which can be a source of unnecessary confusion.)

Let’s put an end to this and add the missing deprecation attribute, replacing `IndexDistance` usages with `Int`.

While we’re here, also bring `String.index(_:offsetBy:)` and `String.index(_:offsetBy:limitedBy:)` in sync with their declarations in Collection by renaming the second argument from `n` to `distance`.

(These method declaration changes do get emitted into .swiftinterface files, but they aren’t breaking any client code — the argument names are only relevant to the docs (and the method implementation). They do not affect callers of these functions.)
2022-02-25 17:32:04 -08:00
Karoy Lorentey
5293bde558 [stdlib] Collection: simplify default _failEarlyRangeCheck implementations
Currently, the default implementations of the various `_failEarlyRangeCheck` forms contain several _precondition invocations, like this:

```
@inlinable
  public func _failEarlyRangeCheck(_ index: Index, bounds: Range<Index>) {
    _precondition(
      bounds.lowerBound <= index,
      "Out of bounds: index < startIndex")
    _precondition(
      index < bounds.upperBound,
      "Out of bounds: index >= endIndex")
  }
```

Each such precondition call generates a separate trap instruction, which seems like a waste — theoretically it would be helpful to know which condition was violated, but in practice, that information tends not to be surfaced anyway. Combining these will lead to a minuscule code size improvement.

(The separate messages do surface these in debug builds, but only if these generic defaults actually execute, which isn’t often. These are not public entry points, so concrete collection types tend ignore these and roll their own custom index validation instead. From what I’ve seen, custom code tends to combine the upper/lower checks into a single precondition check. These underscored requirements tend to be only called by the standard `Slice`; and it seems reasonable for that to follow suit.)

More interestingly, the range-in-range version of `_failEarlyRangeCheck` performs two times as many checks than are necessary:

```
  @inlinable
  public func _failEarlyRangeCheck(_ range: Range<Index>, bounds: Range<Index>) {
    _precondition(
      bounds.lowerBound <= range.lowerBound,
      "Out of bounds: range begins before startIndex")
    _precondition(
      range.lowerBound <= bounds.upperBound,
      "Out of bounds: range ends after endIndex")
    _precondition(
      bounds.lowerBound <= range.upperBound,
      "Out of bounds: range ends before bounds.lowerBound")
    _precondition(
      range.upperBound <= bounds.upperBound,
      "Out of bounds: range begins after bounds.upperBound")
  }
```

It is safe to assume that `range.lowerBound <= range.upperBound`, so it’s enough to test that `bounds.lowerBound <= range.lowerBound && range.upperBound <= bounds.upperBound` — we don’t need to check each combination separately.
2022-02-25 17:06:08 -08:00
John McCall
aca744b211 Remove the Flags field from AsyncContext.
Generated code has never actually initialized this field, so we
might as well remove it.  Doing so mostly doesn't impact the ABI
since we don't store anything for arguments or results in the
context as part of the normal call sequence.  We do need to adjust
some of the hard-coded contexts, however, such as continuation
contexts and the statically-sized context for special runtime
async functions.
2022-02-25 16:57:49 -05:00
Guillaume Lessard
758cdaebb0 Merge branch 'main' into se-pointer-convenience 2022-02-25 13:52:45 -07:00
Guillaume Lessard
bb05e851af [stdlib] restrict pointer arithmetic to UInt 2022-02-25 13:35:20 -07:00
Guillaume Lessard
d80a50bda0 [stdlib] comparisons for heterogeneous pointer types 2022-02-25 13:34:23 -07:00
Guillaume Lessard
5c10c67a01 [stdlib] pointer(to property:) for UP and UMP 2022-02-25 13:34:23 -07:00
Guillaume Lessard
b3f96e8cea [stdlib] alignedUp(for:) and siblings for URP and UMRP 2022-02-25 13:34:23 -07:00