Commit Graph

21434 Commits

Author SHA1 Message Date
Daniil Kovalev
a5c727125e Fix compilation errors appearing due to missing <cstdint> include (#81233)
This patch resolves the issue by adding missing `<cstdint>` includes.
For SmallVector.h, such a change was already introduced in LLVM repository:
7e44305041

<!--
If this pull request is targeting a release branch, please fill out the
following form:

https://github.com/swiftlang/.github/blob/main/PULL_REQUEST_TEMPLATE/release.md?plain=1

Otherwise, replace this comment with a description of your changes and
rationale. Provide links to external references/discussions if
appropriate.
If this pull request resolves any GitHub issues, link them like so:

  Resolves <link to issue>, resolves <link to another issue>.

For more information about linking a pull request to an issue, see:

https://docs.github.com/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue
-->

<!--
Before merging this pull request, you must run the Swift continuous
integration tests.
For information about triggering CI builds via @swift-ci, see:

https://github.com/apple/swift/blob/main/docs/ContinuousIntegration.md#swift-ci

Thank you for your contribution to Swift!
-->
2025-05-08 17:43:29 -07:00
Henrik G. Olsson
59d7d3160f [Swiftify] Emit @availability when expansions contain Span (#81320)
This prevents errors when compiling for older targets using a newer
compiler.

rdar://150740330
2025-05-08 16:13:24 -07:00
Alejandro Alonso
d26bde798e Start building the runtime demangle tree for extended existentials 2025-05-07 13:56:25 -07:00
Ben Troller
3123cb0407 Merge pull request #81311 from btroller/clean-up-obj-interop-templating-in-remote-mirror
[RemoteMirror] Clean up templating used by Remote Mirror's SwiftReflectionContext to handle ObjC interop being enabled/disabled in the target.
2025-05-07 12:34:11 -07:00
Nate Cook
e68069f891 [stdlib] Allow a default for optional interpolations (#80547)
This adds an `appendInterpolation` overload to
`DefaultStringInterpolation` that includes a parameter for providing a
default string when the value to interpolate is `nil`. This allows this
kind of usage:

```swift
let age: Int? = nil
print("Your age is \(age, default: "timeless")")
// Prints "Your age is timeless"
```

The change includes an additional fixit when optional values are
interpolated, with a suggestion to use this `default:` parameter.
2025-05-07 12:47:02 -05:00
Alastair Houghton
921d6d8d2c Merge pull request #81332 from al45tair/eng/PR-148899609
[Concurrency] Don't pass negative times to the Dispatch code.
2025-05-07 09:46:26 +01:00
Guillaume Lessard
d8c3942198 Merge pull request #81224 from glessard/override-lifetime-publicly
[stdlib] make `_overrideLifetime()` functions public
2025-05-06 19:56:11 -07:00
Guillaume Lessard
bc22bcd820 [stdlib] remove TODOs
These TODOs aren’t particularly actionable. What we really want is a way to define `_overrideLifetime()` in a not-unsafe way, and that will probably be a `Builtin` operation.
2025-05-06 15:19:32 -07:00
Eric Miotto
dd9adeb0bf Merge pull request #81241 from edymtt/edymtt/add-builtin-float-dep-for-libraries-depending-on-darwin
CMake: add explicit dependency to _Builtin_float to targets...
2025-05-06 09:09:09 -07:00
Michael Gottesman
b34e2d72fb Merge pull request #81306 from gottesmm/pr-b6ba1a771d90007a5ee6da3e4dc657bfef32b320
[swift-settings] Now that we aren't using it immediately, remove it from tree.
2025-05-06 08:21:23 -07:00
Alastair Houghton
69c965e15c [Concurrency] Don't pass negative times to the Dispatch code.
Dispatch uses unsigned times, and cannot cope with times before its
clock started.  As such, passing negative times from Swift through to
the C++ code results in large unsigned values, which then causes us to
wait forever.  This is undesirable.

rdar://148899609
2025-05-06 15:56:07 +01:00
Slava Pestov
cc8639b523 Merge pull request #81301 from slavapestov/remote-mirrors-cleanups
RemoteInspection: Two small cleanups
2025-05-06 07:43:47 -04:00
Ben Troller
943c0a034a Clean up templating related to whether ObjC interop is enabled for a Remote Mirror context 2025-05-05 15:29:23 -07:00
Doug Gregor
d7c77130e7 Merge pull request #81293 from DougGregor/revert-hashable-asyncstream-inlining
Revert hashable asyncstream inlining
2025-05-05 15:14:34 -07:00
Michael Gottesman
9d59dbed17 [swift-settings] Now that we aren't using it immediately, remove it from tree.
We can always get it back from the git history.

rdar://150695113
2025-05-05 13:39:03 -07:00
Slava Pestov
c205c802f6 RemoteInspection: Remove 'DidSubstitute' form of TypeRef::subst() 2025-05-05 14:59:45 -04:00
Slava Pestov
31947d0617 RemoteInspection: Fix latent bug in TypeRefIsConcrete::visitOpaqueArchetypeTypeRef() 2025-05-05 14:59:45 -04:00
Doug Gregor
f358c1e6b7 Revert "[Concurrency] Hashable funcs should be inlinable for AsyncStream"
This reverts commit 06bb7183f4.
2025-05-05 10:43:11 -07:00
Eric Miotto
8c7e8550aa CMake: add explicit dependency to _Builtin_float to targets...
... that would import that as a result of importing Darwin from the SDK.

Amend my previous change to Differentiation and Distributed in this
sense.

Addresses rdar://150400049
2025-05-05 10:39:14 -07:00
Doug Gregor
f04e916dff Fix issue with older compilers not handling MutableSpan code
The use of SendableCompletionHandlers here is completely incidental,
because it happened to be introduced at roughly the same time as the
bits we needed for MutableSpan. Fixes rdar://148072153.
2025-05-05 10:12:06 -07:00
Philippe Hausler
c4088252d0 [Concurrency] An implementation of system epochs for continuous and suspending clocks (#80409)
This implements
[SE-0473](https://github.com/swiftlang/swift-evolution/blob/main/proposals/0473-clock-epochs.md)
2025-05-05 08:45:24 -07:00
Evan Wilde
91a0692bd1 Merge pull request #81227 from etcwilde/ewilde/FreeBSDPlatformExecutor
Add platform executor module for FreeBSD
2025-05-04 13:07:32 -07:00
Alastair Houghton
3b89d6d137 Merge pull request #81195 from al45tair/eng/PR-150290165
[Concurrency] Fix copy-paste error.
2025-05-04 18:33:50 +01:00
Henrik G. Olsson
bd233ea26e [Swiftify] Don't use count from Span inside withUnsafeBufferPointer call (#81267) 2025-05-04 01:52:05 -07:00
Doug Gregor
c249357f16 Merge pull request #81249 from DougGregor/observation-nonisolated-conformances
[Observation] Create nonisolated conformances to Observable
2025-05-02 12:56:27 -07:00
Karoy Lorentey
74efc7d354 Merge pull request #80859 from lorentey/is_same_metatype_condfail
[stdlib] Allow metatype comparisons to work with outdated compilers
2025-05-02 00:06:18 -07:00
Doug Gregor
3a01fc18b4 Make the _Concurrency library depend on _Builtin_float 2025-05-01 22:01:38 -07:00
Philippe Hausler
3f157ab712 [Observation] Use independent locking since the runtime functions reference a symbol that is not emitted (#81185)
The runtime functions for locking end up referencing a symbol that is
not publicly emitted. This leads to broken linux builds.
Since that interface is not public and does not offer a stable mechanism
and Synchronization cannot be used (due to it being a higher deployment
target) instead it has to revert to implementing locking from scratch
for all platforms.

This is mostly replicated from the swift-async-algorithms package and
should be usable enough to accomplish the goals of this module.

Resolves rdar://150060874
2025-05-01 17:30:50 -07:00
Mike Ash
2838208c06 Merge pull request #81234 from mikeash/useless-comment-begone
[Concurrency] Remove useless comment about assert in AsyncTask::complete().
2025-05-01 16:02:45 -04:00
Stephen Canon
ab2b28cc4b Add static .nanoseconds(_: Double) to Duration (#81210)
SE-0329 defines the following static factory methods:
```
public static func seconds<T: BinaryInteger>(_ seconds: T) -> Duration
public static func seconds(_ seconds: Double) -> Duration
public static func milliseconds<T: BinaryInteger>(_ milliseconds: T) -> Duration
public static func milliseconds(_ milliseconds: Double) -> Duration
public static func microseconds<T: BinaryInteger>(_ microseconds: T) -> Duration
public static func microseconds(_ microseconds: Double) -> Duration
public static func nanoseconds<T: BinaryInteger>(_ value: T) -> Duration
```
For no good reason, the obvious additional method:
```
public static func nanoseconds(_ nanoseconds: Double) -> Duration
```
was omitted. After talking this through with the LSG, we have decided
that this is simply a bug, and we will add this method without formal
evolution review.
2025-05-01 15:50:17 -04:00
Mike Ash
a1dbdd59d1 [Concurrency] Remove useless comment about assert in AsyncTask::complete().
This comment is really about an assert that's no longer present, so it should just go away.
2025-05-01 11:22:39 -04:00
Meghana Gupta
3cad5c5924 Merge pull request #81043 from meg-gupta/fixcow
Insert end_cow_mutation_addr for lifetime dependent values dependent on mutable addresses
2025-05-01 07:26:28 -07:00
Alastair Houghton
23a181730f Merge pull request #81200 from al45tair/eng/PR-150310927
[Concurrency] Fix issue with using Dispatch queues as executors.
2025-05-01 11:56:43 +01:00
Konrad `ktoso` Malawski
62c6159027 Merge pull request #81229 from ktoso/wip-escalation-handler-priority-auth
[Concurrency] Fix ptr auth for task priority escalation handler
2025-05-01 19:53:54 +09:00
Konrad 'ktoso' Malawski
8fccafd2fa [Concurrency] Fix ptr auth for task priority escalation handler
We missed to sign the handler. Along the way the signature of it
changed, so adjust for that.

How to get the number:

```
func PROPER(bar: (TaskPriority, TaskPriority) -> Void) {
    let p = TaskPriority.default
    bar(p, p)
}
```

```
-> % swiftc -target arm64e-apple-macos13 example.swift -S -o - | swift demangle | grep -a3 autda
	stur	x8, [x29, #-64]
	mov	x17, x8
	movk	x17, #11839, lsl #48 <<<<<<<<<
	autda	x16, x17
	ldr	x8, [x16, #64]
	lsr	x8, x8, #0
	add	x8, x8, #15
```

Resolves rdar://150378890
2025-05-01 12:07:35 +09:00
Mike Ash
158b1c56aa Merge pull request #81205 from mikeash/fix-statusRecordLock
[Concurrency] Fix alreadyLocked in withStatusRecordLock.
2025-04-30 21:20:16 -04:00
Evan Wilde
4a41e50730 Add platform executor module for FreeBSD
Effectively the same as Linux and OpenBSD. If Dispatch is disabled, this
will fail because the dispatch executor isn't defined.
2025-04-30 17:08:53 -07:00
Guillaume Lessard
e0cfb31fcd [stdlib] make _overrideLifetime functions public
These are discussed in the lifetime annotations pitch: https://github.com/swiftlang/swift-evolution/pull/2750

Addresses rdar://150400414
2025-04-30 15:54:41 -07:00
Meghana Gupta
ceb3264e40 Disable runtime cow verification for mutableSpan property 2025-04-30 13:38:51 -07:00
Mike Ash
325b66ab20 [Concurrency] Fix alreadyLocked in withStatusRecordLock.
If the preloaded status is locked, then we need to reload it in order to distinguish between the current thread holding the lock and another thread holding the lock. Without this, if another thread holds the lock, then we won't set the is-locked bit. We'll still actually hold the lock, but other threads may perform operations locklessly if the bit is not set, which can cause a crash. By reloading status in that case, we ensure that the bit is always set correctly.

This manifested as crashes in task cancellation but could cause other task-related issues as well.

Also remove an assert of !isStatusRecordLocked() in AsyncTask::complete(). We allow other threads to access tasks and take the lock for things like cancellation, so the lock may legitimately be held at that point.

rdar://150327908
2025-04-30 13:53:31 -04:00
Alejandro Alonso
aad8513040 Merge pull request #81169 from Azoy/wrap-in-feature
[stdlib] Wrap InlineArray inlinable code in new feature
2025-04-30 09:45:26 -07:00
Alastair Houghton
e843a24a99 [Concurrency] Fix issue with using Dispatch queues as executors.
We were failing to switch executors to Dispatch queues, where those
were being used as executors, which caused a variety of unusual
symptoms.

rdar://150310927
2025-04-30 14:18:42 +01:00
Alastair Houghton
0a5fa056e7 [Concurrency] Fix copy-paste error.
The `__builtin_add_overflow` should have been adding to `leeway`, not to
`deadline`.

rdar://150290165
2025-04-30 10:14:22 +01:00
Konrad `ktoso` Malawski
0083f09cf4 Merge pull request #81134 from ktoso/wip-adjust-isIsolatingCurrentContext-impl 2025-04-30 06:43:20 +09:00
Eric Miotto
ea74546e15 Merge pull request #81141 from edymtt/edymtt/add-builtin-float-dep-to-distributed-and-synchronization
Add `_Builtin_float` dependency to `Distributed` and `Synchronization`
2025-04-29 12:32:23 -07:00
Alejandro Alonso
865aed0c38 Wrap InlineArray inlinable code in new feature 2025-04-29 10:02:15 -07:00
Konrad 'ktoso' Malawski
6872707574 [embedded][Concurrency] Further refine C-api boundary for isIsolating... 2025-04-29 22:29:26 +09:00
Konrad 'ktoso' Malawski
ea16df04ac [Concurrency] adjust how we fail creating an IsIsolatingCurrentContextDecision 2025-04-29 20:08:56 +09:00
Konrad 'ktoso' Malawski
e1dc854f8f [Concurrency] Change isIsolatingCurrent... to return Bool?
This changes the isIsolatingCurrentContext function to return `Bool?`
and removes all the witness table trickery we did previously to detect
if it was implemented or not. This comes at a cost of trying to invoke
it always, before `checkIsolated`, but it makes for an simpler
implementation and more checkable even by third party Swift code which
may want to ask this question.

Along with the `withSerialExecutor` function, this now enables us to
check the isolation at runtime when we have an `any Actor` e.g. from
`#isolation`.

Updates SE-0471 according to
https://forums.swift.org/t/se-0471-improved-custom-serialexecutor-isolation-checking-for-concurrency-runtime/78834/
review discussions
2025-04-29 20:08:55 +09:00
Mike Ash
22c34dd254 Merge pull request #81041 from mikeash/unowned-destroyed-error-message
[Runtime] Change the unowned reference fatal error to "was already destroyed."
2025-04-28 19:49:06 -04:00