Commit Graph

1719 Commits

Author SHA1 Message Date
Michael Gottesman
e186e5e5d0 Merge pull request #85972 from gottesmm/pr-9663abc1697da1382a8514e6877a6c3ce3f439b9
[concurrency] Hide Concurrency StackNesting builtins behind a feature flag
2025-12-11 21:16:37 -08:00
Michael Gottesman
7b9281fcb8 [concurrency] Hide Concurrency StackNesting builtins behind a feature flag.
rdar://166244033
2025-12-10 16:02:18 -08:00
Kyle Robson
f8f107f857 <rdar://165142180> fix immediate Task docs (#85626)
Co-authored-by: Kyle Robson <kyledr@apple.com>
2025-12-10 09:51:19 +09:00
Evan Wilde
1c3541e926 Build: Remove concurrency tracing option
Stripping out the logic behind enabling concurrency tracing
independently of the rest of the standard library tracing. It's not
clear that there is a use-case where we want one without the other.
2025-12-03 14:03:40 -08:00
Evan Wilde
c1efd8f9d2 Concurrency: Use SWIFT_STDLIB_TRACING
Switching the concurrency runtime to use the common SWIFT_STDLIB_TRACING
to control whether the concurrency runtime enables tracing. The old
process required passing bot the `SWIFT_STDLIB_TRACING` and
`SWIFT_STDLIB_CONCURRENCY_TRACING` macro to the concurrency build or it
would fail to build.

It's not clear that there are any environments where it is desirable
for swiftCore to have tracing enabled and not have swift_Concurrency
tracing enabled or vice versa. Replacing the concurrency-specific macro
with a single common macro. If it is desirable, we can teach the build
system to avoid passing `SWIFT_STDLIB_TRACING` to a specific target if
an option is not set.

rdar://165777240
2025-12-03 14:02:40 -08:00
Tim Kientzle
f607cd9d0c Fix two other unsafe markers 2025-12-02 10:45:25 -08:00
Alastair Houghton
354b461f7f Merge pull request #85312 from al45tair/concurrency-6.3-not-6.2
[Concurrency] Change all of the StdlibDeploymentTarget 6.2s to 6.3.
2025-12-02 10:51:09 +00:00
Bryce Wilson
b30f63530a [Concurrency] Set thread base priority when running escalated Tasks (#84895) 2025-11-20 09:58:08 +09:00
AZero13
5c6f34163b Fix copy-paste error of calculation of suspending time in Clock.cpp (#85545)
We should be assigning the value to suspension, not continuous!
2025-11-17 22:11:35 -08:00
Alastair Houghton
629d708577 [Concurrency] Add more availability tests.
Some additional availability tests required.
2025-11-11 17:59:29 +00:00
Alastair Houghton
844130fb8c [Concurrency] Fix isIsolatingCurrentContext.
`isIsolatingCurrentContext` _should_ be in 6.2, not 6.3.
2025-11-11 16:38:55 +00:00
Mike Ash
f149a8bce4 Merge pull request #85259 from mikeash/task-allocator-disable-option
[Concurrency] Add environment variable for disabling async stack slab allocator.
2025-11-08 07:53:56 -05:00
Mike Ash
a62f08e050 [Concurrency] Add environment variable for disabling async stack slab allocator.
Add SWIFT_DEBUG_ENABLE_TASK_SLAB_ALLOCATOR, which is on by default. When turned off, async stack allocations call through to malloc/free. This allows memory debugging tools to be used on async stack allocations.
2025-11-07 22:48:41 -05:00
Mike Ash
05f98b2e99 Merge pull request #85341 from mikeash/fix-complex-equality-executor-bitcast
[Concurrency] Fix asSerialExecutor() for complex equality.
2025-11-07 22:45:09 -05:00
Mike Ash
8fbf0e07f3 [Concurrency] Fix asSerialExecutor() for complex equality.
Complex equality is encoded in the low bit of the witness table pointer. We need to mask off the low bits when bitcasting to an `any SerialExecutor`.

rdar://164005854
2025-11-06 13:20:56 -05:00
Michael Gottesman
48b253d111 [concurrency] Use the new builtins. 2025-11-05 20:44:50 -08:00
John McCall
13937fdb4e Merge pull request #84528 from rjmccall/async-let-runtime-realism
Model async let begin/finish as builtins in SIL
2025-11-05 10:24:46 -08:00
Alastair Houghton
34dfbf7bbd [Concurrency] Tweak some things after the availability change.
We need to fix some call sites to make this work.
2025-11-05 09:29:27 +00:00
Alastair Houghton
d81da3a5f0 [Concurrency] Change all of the StdlibDeploymentTarget 6.2s to 6.3.
These were right when they were written, but they are now causing
trouble.  Move them to 6.3.
2025-11-04 18:00:45 +00:00
Alex Martini
903e9c4d7c Refer to checked APIs in CheckedContinuation overview 2025-11-03 14:53:30 -08:00
John McCall
3cfda35b7c Remove the unused swift_asyncLet_{start,end,wait,wait_throwing} runtime
functions.

These were introduced in an early draft implementation of async let, but
never used by a released compiler. They are not used as symbols by any
app binaries. There's no reason to keep carrying them.

While I'm at it, dramatically improve the documentation of the remaining
async let API functions.
2025-11-03 13:45:18 -08:00
Mike Ash
29245e4ef2 [Concurrency] Fix MarkerItem::create to use malloc when there's no task.
Item::destroy will call free when there's no task, so the allocation needs to match, lest we free something that wasn't malloced and crash.

rdar://162589711
2025-10-29 18:17:33 -04:00
Alex Martini
2ee9b16a8b Merge pull request #85126 from amartini51/task_cancellation_162979796
Document withTaskCancellationHandler parameters and at-most-once semantics

Fixes: rdar://162979796
2025-10-27 09:35:52 -07:00
Allan Shortlidge
539b49b477 Concurrency: Suppress -Wnontrivial-memcall warning in Actor.cpp.
NFC.
2025-10-24 19:47:15 -07:00
Alex Martini
09bbcdd22a Include at-most-once
Co-authored-by: Konrad Malawski <ktoso@apple.com>
2025-10-24 14:43:21 -07:00
Alex Martini
a3994ecfd4 Document parameters and at-most-once semantics 2025-10-24 14:11:29 -07:00
Guillaume Lessard
92b54e6434 [concurrency] fix availability of new executor symbols 2025-10-16 21:29:51 -07:00
Guillaume Lessard
b661ff8288 [concurrency] fix availability of new Clock symbols 2025-10-16 19:16:19 -07:00
Stephen Canon
dc04d4f0d4 Revert "[stdlib] Make PlatformExecutorFactory and ExecutorFactory deploy to 6.3 instead of 6.2." 2025-10-15 16:59:32 -04:00
Eric Miotto
e798e9c3cc CMake: allow to specify a SDK when building a triple for Embedded Swift (#84817)
To achieve this, add a new cache variable
`SWIFT_EMBEDDED_STDLIB_SDKS_FOR_TARGET_TRIPLES` to be set like in the
following examples.
    
```
-DSWIFT_EMBEDDED_STDLIB_SDKS_FOR_TARGET_TRIPLES=aarch64-vendor-os@/usr/local/aarch64-vendor-os-sdk;aaarch-vendor-anotheros@/opt/aarch64-vendor-anotheros-sdk
```
    
We chose to use another setting instead of e.g. folding this into
`SWIFT_EMBEDDED_STDLIB_EXTRA_TARGET_TRIPLES` so it is clear this is opt
in and it does not regress existing configurations that set the SDK
directly (like it's the case for the WASM stdlib).

Addresses rdar://162368529
2025-10-15 06:37:54 -07:00
Michael Gottesman
6f5a0c5b5a [stdlib] Make PlatformExecutorFactory and ExecutorFactory deploy to 6.3 instead of 6.2.
This code is public on main, but not on 6.2, so if one compiles a binary for 6.2
on main and then attempts to use a stdlib from a 6.2 aligned macOS, one gets an
ABI error since the type isn't there. Just mark these types as being available
in 6.3 so that way this is future proofed and allows for main binaries to run
against a 6.2 aligned macOS stdlib.
2025-10-13 09:35:46 -07:00
Slava Pestov
0cfb11b1f5 Merge pull request #84690 from valeriyvan/minor-typos
Fix some typos in doc comments
2025-10-05 15:10:59 -04:00
Valeriy Van
c53d71bb2a Fix typos 2025-10-04 12:53:44 +02:00
Alex Martini
3ad3421e01 Break up long sentence; fix punctuation
Fixes: rdar://115730302
2025-09-23 16:27:51 -07:00
Mike Ash
0116da253e [Concurrency] Emit async task running/waitingOn metadata inline into CPUTrace.
This allows tracking async code execution throughout a task's lifetime.

rdar://137230240
2025-09-10 11:32:10 -04:00
Eric Miotto
c9345a38c4 [Concurrency] Add availability to one of the ExecutorJob extensions
Without this, we may fail building Concurrency when enforcing strict
availability.

Addresses rdar://159473855
2025-08-29 15:09:46 -07:00
Eric Miotto
173c5ff2a4 [Concurrency] Change availability for a TaskPriority extension
We need the `init?(JobPriority)` constructor to be
`StdlibDeploymentTarget 5.9`
so the compiler will not complain when we reference it
 from `ExecutorJob.createTrampoline` when building the standard library
without strict availability.

Addresses rdar://159397287
2025-08-28 15:34:10 -07:00
Alastair Houghton
d6224d16d9 [Concurrency] Fix minimal stdlib build again.
Some mentions of `ExecutorJob` were not guarded by the required
`SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY` condition.
2025-08-26 09:38:14 +01:00
Alastair Houghton
ff8d2fa80c [Concurrency] Support continuous waits in CooperativeExecutor.
This fixes some WASM tests.
2025-08-26 09:38:14 +01:00
Alastair Houghton
bd27a14ea0 [Concurrency] Fix cooperative executor to return only after all jobs run.
We were terminating after the first set of jobs; if one of them scheduled
another job, and there were no timers running, we would terminate,
which was wrong.
2025-08-26 09:38:13 +01:00
Alastair Houghton
d0b3d14c68 [Concurrency] Don't expose Dispatch or CF executors directly.
Also add `final` to the `CooperativeExecutor` declaration.
2025-08-26 09:38:13 +01:00
Alastair Houghton
250458f9f6 [Concurrency] Add a couple of comments.
Add some documentation comments to the Dispatch and CF executors,
and update the comments for the allocation and private data APIs.
2025-08-26 09:38:13 +01:00
Alastair Houghton
0fbd382e9c [Concurrency] Fix CooperativeExecutor to not loop forever.
If a job enqueues another job on the executor, we might never leave
the inner `while` loop in the `run()` method.  Fix this by taking
the contents of the run queue and only running those jobs in the
queue at the time we enter the inner loop.
2025-08-26 09:38:13 +01:00
Alastair Houghton
871a062002 [Concurrency] Remove canonicalization code.
I don't think we actually need this.  If you have a non-canonical
(i.e. derived) clock, you can just implement `enqueue` and/or `run`
and call those methods on the clock you're wrapping.
2025-08-26 09:38:13 +01:00
Alastair Houghton
7af5b8d8fd [Concurrency] Add implementations of run and enqueue for built-in clocks.
The built-in clocks should have implementations of `run` and `enqueue`,
to allow derived clocks to call those implementations.
2025-08-26 09:38:13 +01:00
Alastair Houghton
6046286b58 [Concurrency] Updates after second SE pitch.
We no longer attempt to convert timestamps from the passed-in `Clock`
in order to allow any clock to work with any executor.  Instead,
executors that do not recognise a clock should call the `enqueue`
function on that `Clock`, which lets the `Clock` itself decide how
to proceed.

Additionally, rename `SchedulableExecutor` to `SchedulingExecutor`.
2025-08-26 09:38:11 +01:00
Gábor Horváth
35b5c817b2 Merge pull request #83520 from Xazax-hun/check-safety-function-types 2025-08-08 06:39:39 +01:00
Gabor Horvath
402ad33463 [StrictMemorySafety] Check the safety of return types of calls
Previously, we skipped checking the return type of a function for safety
as we expected to warn at the use of the returned value:

  let x = returnsUnsafe()
  usesUnsafe(x) // warn here

Unfortunately, this resulted in missing some unsafe constructs that can
introduce memory safety issues when the use of the return value had a
different shape resulting in false negatives for cases like:

  return returnsUnsafe()

or

  usesUnsafe(returnsUnsafe())

This PR changes the analysis to always take return types of function
calls into account.

rdar://157237301
2025-08-05 12:16:44 +01:00
Alastair Houghton
94058e5e68 [Concurrency] Fix availability problem with UnownedTaskExecutor.
a550080 added a call to the new initializer, but that call
came from a function annotated with `StdlibDeploymentTarget 6.2`,
rather than `SwiftStdlib 6.2`, while the initializer was set to
`SwiftStdlib 6.2`.  This will fail in some build configurations
(specifically where the target being built for is older than that
implied by `SwiftStdlib 6.2`).

rdar://157217460
2025-08-04 14:30:20 +01:00
Max Desiatov
78c85945f6 Actor.cpp: Fix unused variables for non-embedded path 2025-07-31 21:16:40 +01:00