Commit Graph

722 Commits

Author SHA1 Message Date
Alastair Houghton
61cab14821 [Concurrency] Mark custom executors entry points as SPI.
Marking these as `@_spi(ExperimentalCustomExecutors)` for now, to match
what we're doing for 6.3.

rdar://168508495
2026-01-27 09:48:01 +00:00
Daniel Rodríguez Troitiño
67836a82d6 Runtime: Mark demangling test as requiring the runtime_module (#86604)
Otherwise the test will try to execute in configurations that do not
build the runtime module, and will fail to pass.
2026-01-18 20:35:24 -08:00
Owen Voorhees
4f0b627d6d Revert "[Concurrency] Adopt typed throws in Task creation APIs (#84802)"
This reverts commit dc2d6fb4af.
2026-01-15 13:10:36 -08:00
Konrad `ktoso` Malawski
40dabefdb4 Reapply: Runtime: expose demangle() in Runtime module (#84788) (#86510) 2026-01-14 21:44:28 +09:00
Konrad `ktoso` Malawski
dc2d6fb4af [Concurrency] Adopt typed throws in Task creation APIs (#84802) 2026-01-13 20:21:20 +09:00
eeckstein
4766678f3f Revert "Runtime: expose demangle() in Runtime module (#84788)"
This reverts commit ab69fc0d2c.
2026-01-12 10:26:14 +01:00
Konrad `ktoso` Malawski
ab69fc0d2c Runtime: expose demangle() in Runtime module (#84788)
We should expose the demangle functionality; It's been widely used by
calling into internal _swift_demangle and instead we should offer a real
API. It's also already used in the Runtime module already when forming
backtraces.

[Previous
discussions](https://forums.swift.org/t/demangle-function/25416/15)
happened between 2019 and 2024, and just never materialized in a
complete implementation and proposal.

Right now, even more tools are in need of this API, as we are building
continious profiling solutions etc, so it is a good time to revisit this
topic.

This PR is roughly based off @Azoy's

https://github.com/swiftlang/swift/pull/25314/files#diff-fd379a721cc9a1c9ef6486eae713e945da842b42170d4d069029a57334371eba
from 2019, however it brings it over to the new Runtime module which is
a great place to put this functionality - even Backtrace had to recently
reinvent calling the demangling infra in this module.

Pending SE review, [proposal
here](https://github.com/swiftlang/swift-evolution/pull/2989).

cc @azoy @al45tair

---------

Co-authored-by: Alastair Houghton <alastair@alastairs-place.net>
2026-01-09 09:46:19 -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
Alastair Houghton
748ba05161 [Concurrency][Tests] Bump availability in a couple of tests.
Since we've bumped availability elsewhere, we need to bump these
tests also.
2025-11-18 12:08:46 +00: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
Ramon Asuncion
1e4835b179 [Test][Concurrency] Apply %env- subtituion to environment varibles in RUN lines 2025-09-30 05:51:13 -07:00
Ramon Asuncion
35aae9303b [Test][Concurrency] Make test environment compatible with LLVM Lit's internal shell
Convert `VAR=value cmd` to `env VAR=value cmd` in Concurrency tests for compatibility with LLVM Lit’s internal shell.

Partially address #84407
2025-09-29 07:48:49 -07:00
Alastair Houghton
687e09da65 Merge pull request #82456 from al45tair/concurrency-updates
[Concurrency] Updates after second SE pitch.
2025-08-27 11:40:07 +01:00
Allan Shortlidge
6918a63efb Tests: Mark Concurrency/Runtime/reasync.swift unsupported for back deployment.
Every other test in this directory has `UNSUPPORTED: back_deployment_runtime`
but this one did not, for some reason.

Resolves rdar://159025986.
2025-08-26 15:37:24 -07:00
Alastair Houghton
53ceb0d153 [Tests][Concurrency] Fix macOS build.
There was still some canonicalization in one of the tests, plus we needed
to update the ABI tests.
2025-08-26 09:38:14 +01:00
Alastair Houghton
c866fa074a [Tests][Concurrency] Remove clock canonicalization from test.
We've removed this code, so the test was failing.
2025-08-26 09:38:13 +01:00
Alastair Houghton
6cc4a4d823 [SILGen][Concurrency] Improve DefaultExecutorFactory lookup.
Rather than just looking at top level in the module, start by searching
the type marked as `@main`.  This means that a library that provides a
protocol or superclass that the `@main` type can conform to can specify
an executor in a reasonable manner.
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
Michael Gottesman
373ff5b747 Merge pull request #83857 from gottesmm/pr-12c1043388c039692620e595297d355620fcedf3
[concurrency] Make all runtime tests also run with nonisolated(nonsending) by default enabled.
2025-08-25 14:43:55 -07:00
Michael Gottesman
61ae730f00 [concurrency] Make all runtime tests also run with nonisolated(nonsending) by default enabled.
Just adding more code coverage.
2025-08-21 12:54:00 -07:00
Eric Miotto
d6df83d8fa Restrict a few tests to run against the just built runtime
Addresses rdar://158442561
2025-08-20 14:50:47 -07:00
Alastair Houghton
e99e80d569 [Test][Concurrency] Add libdispatch to the requirements for the test.
The test uses Dispatch, mainly for convenience, but that means it
won't run everywhere.

rdar://156701386
2025-07-30 13:41:04 +01:00
Alastair Houghton
a55008066d [Concurrency] Further improve performance.
Remove some reference counting traffic by using `Unowned*Executor`s.

Also, add a test to make sure we stay on the fast path.

rdar://156701386
2025-07-30 13:41:04 +01:00
Pavel Yaskevich
95d4ef5756 [Concurrency] Remove deprecated Task.startSynchronously API
This is the original spelling which was not accepted. We kept
it for a bit to give adopters time to switch but it's time to
remove it now.
2025-07-25 13:15:02 -07:00
Max Desiatov
67c4be0ac2 Update tests for wasi -> wasip1 triple change
Fixes a regression introduced with https://github.com/swiftlang/swift/pull/83167
2025-07-23 10:10:47 +01:00
Konrad 'ktoso' Malawski
34c48f70df [test] startImmediately was missing explicit plugins path 2025-07-22 17:35:54 +09:00
Yuta Saito
c0b4727fc0 [Concurrency] Unskip isolated-conformance runtime test on WebAssembly 2025-07-16 06:28:04 +00:00
Konrad `ktoso` Malawski
1e2047c6c3 CI: Temporarily disable taskExecutor test with Task.immediate
rdar://155596073 Task executors execution may not always hop as expected

I'm investigating a fix here as we speak, but disabling the specific piece of the test while we work on it.
2025-07-14 19:35:46 +09:00
Konrad 'ktoso' Malawski
664be9bd1e [Concurrency] Add missing Task.immediateDetached, which drops task locals 2025-07-10 14:57:44 +09:00
Konrad 'ktoso' Malawski
358c3e9dcf [Concurrency] a few missing overloads for immediate tasks 2025-07-10 12:40:41 +09:00
Pavel Yaskevich
8c4f7e97c8 Revert "[Concurrency] Remove deprecated Task.startSynchronously API" 2025-07-08 13:54:23 -07:00
Konrad `ktoso` Malawski
c6f223f57a Merge pull request #82793 from ktoso/wip-correct-isolated-handling-with-caller-isolation 2025-07-08 12:01:54 +09:00
Pavel Yaskevich
e108524d98 [Concurrency] Remove deprecated Task.startSynchronously API
This is the original spelling which was not accepted. We kept
it for a bit to give adopters time to switch but it's time to
remove it now.
2025-07-07 00:31:19 -07:00
Konrad 'ktoso' Malawski
b0d2ca9be6 [Concurrency] Fix nonisolated(nonsending) interaction with #isolation 2025-07-04 10:20:08 +09:00
Ryan Mansfield
ef934e0f4e Merge pull request #76316 from rjmansfield/reenable-async-sequence-test 2025-06-27 02:26:46 -07:00
(null)
aaf283258b Merge branch 'main' into mchiu/freebsd 2025-06-17 15:41:57 -04:00
(null)
d6811260a9 Merge commit '665515c781999a81094bbe4f8302a7cb1a6a6b39' into mchiu/freebsd 2025-06-17 15:12:23 -04:00
Alastair Houghton
a5b14d747f [Tests][Concurrency] Turn off async_taskgroup test for back-deployment.
We don't want to run this test when back-deploying.

rdar://151975988
2025-06-12 18:30:42 +01:00
Konrad 'ktoso' Malawski
3aa28b4de9 [Concurrency] Correct memory effect attributes of task_create
Without this, llvm would sometimes wrongly assume there's no indirect
accesses and the optimizations can lead to a runtime crash, by
optimizing away initializing options properly.

Resolves rdar://152548190
2025-06-11 22:03:52 +09:00
Mike Ash
224dc12063 [Test] Reduce stack usage in async_taskgroup_discarding_neverConsumingTasks.swift.
With optimizations disabled, the InlineArray initializer uses 512kB of stack space. This can overflow the stack depending on exactly how things are set up. Reduce stack usage by manually allocating memory for the array and initializing it as a pointer to Int.

rdar://152420308
2025-06-04 15:05:51 -04:00
Michael Chiu
7bbafc599d Merge branch 'main' into mchiu/freebsd 2025-06-02 13:33:18 -04:00
Mike Ash
5be22fa7cc [Concurrency] Fix races/overflows in TaskGroup implementation.
statusCompletePendingReadyWaiting(), offer(), and poll() did a one-off compare_exchange_strong which could fail if the group was concurrently cancelled. Put these into loops so that they are retried when needed.

DiscardingTaskGroup creation passed the group result type as the task result type. waitAll() would then use the group result type when collecting task results. Since the task result type is always Void in this case, this would overflow the result buffer if the group result type was larger. This often works as it writes into the free space of the task allocator, but can crash if it happens to be at the end of a page or the group result type is particularly large.

rdar://151663730
2025-05-28 20:58:33 -04:00
michael-yuji
8738e722bd Merge branch 'main' into mchiu/freebsd 2025-05-28 14:44:11 -07:00
Alastair Houghton
3305e89ff9 Merge pull request #81639 from swiftlang/revert-81472-eng/PR-151147606
Revert "[Concurrency] Add underscore prefixes for not yet official API."
2025-05-22 15:36:52 +01:00
michael-yuji
9a948a9c3b Merge branch 'main' into mchiu/freebsd 2025-05-21 16:29:16 -07:00
Alastair Houghton
28732f4a8b Revert "[Concurrency] Add underscore prefixes for not yet official API." 2025-05-20 15:44:26 +01:00
Pavel Yaskevich
c3c1b4fca0 [stdlib] Adopt @_inheritActorContext(always) on Task.immediate
This change aligns implementation with the current SE-0472 proposal.
2025-05-16 14:27:46 -07:00
Slava Pestov
2eceb299c9 Merge pull request #81516 from slavapestov/fix-pack-task-dealloc
IRGen: Fix out-of-order task_dealloc with parameter pack metadata
2025-05-15 17:02:08 -04:00
Slava Pestov
b2e2b02a71 IRGen: Fix out-of-order task_dealloc with parameter pack metadata
We deallocate an instruction's packs at points where no further
control flow path uses the value. In the case of an alloc_stack,
this will be right after the dealloc_stack. Thus, if alloc_stack
allocates some packs to build type metadata for a tuple type
that contains a pack, and then proceeds to allocate a value
large enough to hold the tuple, we will free the second allocation
first, before we free the pack, as expected.

However, after stack allocating the value, alloc_stack does
some further work to emit debug info. This could result in
emission of additional metadata packs.

Split up the debug info emission into two parts; the first we do
before we perform the stack allocation, the rest we do after.

- Fixes https://github.com/swiftlang/swift/issues/67702.
- Fixes rdar://problem/141363236.
2025-05-15 12:22:21 -04:00
Alastair Houghton
c0ccdffeb7 [Concurrency] Add underscore prefixes for not yet official API.
Custom main and global executors work hasn't passed Swift Evolution yet,
so we need to avoid leaking it as API until it does.

To that end, underscore all the things.

rdar://151147606
2025-05-14 11:57:06 +01:00