Commit Graph

273 Commits

Author SHA1 Message Date
Mykola Pokhylets
62dbc6c966 Fixed some tests. Using extract_executor SIL instruction instead of custom code. 2024-07-11 13:09:06 +02:00
Tim Kientzle
4470ed71ac Update executor test
The test previously checked for a message that is no longer
emitted.  Drop it.
2024-07-09 13:31:49 -07:00
Konrad `ktoso` Malawski
168bc7b454 [Concurrency] Fix how we obtain DA-as-A conformance for cross module
Resolves rdar://127206143
2024-05-28 13:37:21 +09:00
Pavel Yaskevich
e6b445b8d1 [SE-0428] NFC: Rename _DistributedProtocol macro into Resolvable
The proposal was [accepted with modifications](https://forums.swift.org/t/accepted-with-modifications-se-0428-resolve-distributedactor-protocols/71366)

The decision was made to change the spelling of the attached macro
in the proposal from @DistributedProtocol to `@Resolvable`
(or `@Distributed.Resolvable` if disambiguation is needed).
2024-04-22 14:18:11 -07:00
Konrad `ktoso` Malawski
efd8cbf978 [Distributed] Add more tests for implicit Codable on distributed actors 2024-04-17 11:53:05 +09:00
Konrad `ktoso` Malawski
460a030860 [Distributed] Avoid infinite recursion in distributed thunk on protocol extensions (#73032) 2024-04-15 03:43:49 -07:00
Meghana Gupta
afb65c2cdd Disable some distributed actor tests on arm64e 2024-04-09 11:00:12 -07:00
Konrad `ktoso` Malawski
7cd9063ba5 [Distributed] Diagnose missing import also for funcs in extensions
Resolves rdar://125813581
2024-04-09 17:08:27 +09:00
Konrad `ktoso` Malawski
86f5441294 [SerialExecutor] SerialExecutor.checkIsolated() to check its own tracking for isolation checks (#71172) 2024-03-29 07:06:34 +09:00
Konrad `ktoso` Malawski
6132386371 [Distributed] Complete handling of protocol calls and witnesses using adjusted mangling scheme (#72416) 2024-03-23 23:54:23 +09:00
Konrad `ktoso` Malawski
27702fa115 [Distributed][Macro] Handle more cases in distributed protocol macro (#72177) 2024-03-12 02:12:31 -07:00
Konrad `ktoso` Malawski
143d8f9801 [Distributed] Handle distributed thunk requirements/witnesses (#72151)
Co-authored-by: Pavel Yaskevich <pyaskevich@apple.com>
2024-03-11 02:07:22 -07:00
Konrad `ktoso` Malawski
b7ff16baf7 [Distributed] Only synthesize Codable for DA where the ID is Codable (#72081) 2024-03-07 22:40:00 -08:00
Pavel Yaskevich
e3dbcd01af [Tests] Distributed: XFAIL protocol requirement accessor test on Windows 2024-03-05 13:31:53 -08:00
Pavel Yaskevich
a4c0d84f7e [Tests] Distributed: Remove workaround for lack of requirement accessors 2024-03-04 15:59:57 -08:00
Konrad `ktoso` Malawski
c56a1e8be7 [Distributed] Handle mangling thunks in extensions with generic AS and $Stubs (#71914) 2024-02-29 04:22:00 -08:00
John McCall
83850efba0 Fix a test to use SwiftStdlib 6.0 instead of 5.11. 2024-02-23 02:58:03 -05:00
Pavel Yaskevich
f9ec3b1d7e Merge pull request #71796 from xedin/make-dist-new-requirements-conditionally-available
[Distributed] Make new protocol requirements conditionally available
2024-02-22 15:18:52 -08:00
Konrad `ktoso` Malawski
1d44e2e8e0 [Distributed] Undo new record and mangling scheme for dist.p.witnesses (#71801) 2024-02-22 23:02:29 +09:00
Pavel Yaskevich
2bd1825a1f [stdlib] Distributed: Mark all new protocol requirements as available starting from stdlib 5.11 2024-02-21 13:29:47 -08:00
Pavel Yaskevich
738ac14489 [IRGen] Distributed: Dispatch decodeNextArgument via witness thunk if concrete decoder is not available
Since distributed actors can now be generic over actor system
it's no longer guaranteed for concrete decoder to be present,
we need to handle that case specifically during accessor emission.
2024-02-21 13:29:47 -08:00
Pavel Yaskevich
c0dc88878c Revert "[IRGen] Distributed: Always invoke decodeNextArgument through witness thunk"
This reverts commit 4d4c80b8ec.
2024-02-21 13:29:47 -08:00
Konrad `ktoso` Malawski
e9c7f3c382 [Distributed] Target identifiers for protocol calls (#70928) 2024-02-16 07:19:20 -08:00
Pavel Yaskevich
4d4c80b8ec [IRGen] Distributed: Always invoke decodeNextArgument through witness thunk
`decodeNextArgument` is now a requirement, so thunks should be
always calling that instead of trying to dispatch directly.
2024-02-12 14:26:30 -08:00
Hamish Knight
5d0ad81932 [test] Remove unnecessary --color flags
This is now the default.
2024-02-09 16:47:03 +00:00
Konrad `ktoso` Malawski
1d73afb296 [Distributed] Handle DA declared inside a generic type (#71492) 2024-02-08 21:32:34 -08:00
John McCall
dd90ae7416 Rename SIL's @isolated attribute to @sil_isolated.
We want to use @isolated in ordinary Swift, and while we could probably
make it coexist with this SIL use, doing so would be really inconvenient.
2024-02-03 01:51:36 -05:00
Konrad `ktoso` Malawski
bd19d937f0 [TaskExecutor] Remove underscore from new APIs (#71145) 2024-01-30 06:27:54 +09:00
Konrad `ktoso` Malawski
dfdbe457bf [Distributed] Support complex generic distributed actors in thunk gen (#70842) 2024-01-28 01:26:52 -08:00
Allan Shortlidge
fdc7ebddbc Tests: Make distributed_actor_custom_executor_availability.swift use an explicit deployment target.
Split distributed_actor_custom_executor_availability.swift into two tests, one
that only runs on existing platforms that support back deployment to Swift 5.7
aligned runtimes, and another test that is not restricted by platform that
tests behavior when deploying to a Swift 5.9 aligned runtime or later.
2024-01-24 22:21:51 -08:00
Doug Gregor
5c83cae0df Merge pull request #71105 from DougGregor/silgen-hack-distributed-actor-as-actor
[SILGen] Ensure that we emit the distributed-actor-as-actor conformance
2024-01-23 22:36:17 -08:00
Doug Gregor
07c6b78540 [SILGen] Ensure that we emit the distributed-actor-as-actor conformance
The distributed-actor-as-actor conformance is synthesized by the
frontend, so make sure that when we access the API that exposes it
(asLocalActor), we be sure to mark the conformance as "used".

This is a very specific workaround for general problem with
compiler-synthesized conformances. SIL deserialization can bring in a
reference to a conformance late in the SIL pipeline, after the point at
which SILGen can create the conformance. We should be able to address
this systemically to remove the hack.
2024-01-23 19:32:47 -08:00
Michael Gottesman
6f3d45219a [ast] Represent a parameter's isolation at the SIL level.
I did this by adding flag on SILParamInfo.

rdar://121387872
2024-01-23 15:20:22 -08:00
Doug Gregor
97ea19d191 Introduce a builtin and API for getting the local actor from a distributed one
When an actual instance of a distributed actor is on the local node, it is
has the capabilities of `Actor`. This isn't expressible directly in the type
system, because not all `DistributedActor`s are `Actor`s, nor is the
opposite true.

Instead, provide an API `DistributedActor.asLocalActor` that can only
be executed when the distributed actor is known to be local (because
this API is not itself `distributed`), and produces an existential
`any Actor` referencing that actor. The resulting existential value
carries with it a special witness table that adapts any type
conforming to the DistributedActor protocol into a type that conforms
to the Actor protocol. It is "as if" one had written something like this:

    extension DistributedActor: Actor { }

which, of course, is not permitted in the language. Nonetheless, we
lovingly craft such a witness table:

* The "type" being extended is represented as an extension context,
rather than as a type context. This hasn't been done before, all Swift
runtimes support it uniformly.

* A special witness is provided in the Distributed library to implement
the `Actor.unownedExecutor` operation. This witness back-deploys to the
Swift version were distributed actors were introduced (5.7). On Swift
5.9 runtimes (and newer), it will use
`DistributedActor.unownedExecutor` to support custom executors.

* The conformance of `Self: DistributedActor` is represented as a
conditional requirement, which gets satisfied by the witness table
that makes the type a `DistributedActor`. This makes the special
witness work.

* The witness table is *not* visible via any of the normal runtime
lookup tables, because doing so would allow any
`DistributedActor`-conforming type to conform to `Actor`, which would
break the safety model.

* The witness table is emitted on demand in any client that needs it.
In back-deployment configurations, there may be several witness tables
for the same concrete distributed actor conforming to `Actor`.
However, this duplication can only be observed under fairly extreme
circumstances (where one is opening the returned existential and
instantiating generic types with the distributed actor type as an
`Actor`, then performing dynamic type equivalence checks), and will
not be present with a new Swift runtime.

All of these tricks together mean that we need no runtime changes, and
`asLocalActor` back-deploys as far as distributed actors, allowing it's
use in `#isolation` and the async for...in loop.
2024-01-22 17:27:31 -08:00
Konrad `ktoso` Malawski
9eb84a4ecb [Distributed] add test for remoteCall on dist property (#71052) 2024-01-21 23:42:52 -08:00
Konrad `ktoso` Malawski
1dec00a420 [TaskExecutors] Task initializer and withTaskExecutor parameter changes (#70783) 2024-01-20 11:03:26 +09:00
Konrad `ktoso` Malawski
13a42f4bce [Distributed] Allow isolated any DistributedActor (#70906) 2024-01-14 21:16:00 -08:00
Konrad `ktoso` Malawski
396ecdf5ed [Distributed] Destroy decoded parameters after executeDistributedTarget (#70806) 2024-01-11 11:56:14 +09:00
Mike Ash
99f4bad86f Merge pull request #70377 from mikeash/distributed-actor-remotecall-argument-labels-disable-use-os-stdlib
[Test] Mark distributed_actor_remoteCall_argument_labels.swift unsupported for use_os_stdlib.
2023-12-13 20:23:26 -05:00
Konrad `ktoso` Malawski
828f589be4 Initial Task Executor implementation Task(on:), addTask(on:) etc. (#68793)
Co-authored-by: John McCall <rjmccall@gmail.com>
2023-12-12 17:14:24 +09:00
Mike Ash
9eac772c21 [Test] Mark distributed_actor_remoteCall_argument_labels.swift unsupported for use_os_stdlib. 2023-12-11 12:41:53 -05:00
Konrad `ktoso` Malawski
aa4b0d0ae3 Merge pull request #69823 from ktoso/wip-remoteCall_argument_old_os_tests
[Distributed] Resolve test issue on old OSes in remoteCall labels
2023-11-14 11:41:11 +09:00
Konrad `ktoso` Malawski
708f23a836 [Distributed] Resolve test issue on old OSes in remoteCall labels 2023-11-14 07:21:31 +09:00
Allan Shortlidge
941ac3c097 Distributed: Enabled availability checking in Distributed tests.
Various distributed actors test cases were testing behavior that ultimately
depends on availability checking but then disabled availability checking on the
command line when building. This will break with future planned changes to
availability checking infrastructure.
2023-11-08 20:56:04 -08:00
Konrad `ktoso` Malawski
faf287015f [Distributed] Allow overloads with different types; mangling can handle it 2023-11-02 12:36:40 +09:00
Konrad `ktoso` Malawski
370fa50132 Merge pull request #69093 from ktoso/wip-distributed-effective-label 2023-10-25 10:40:17 +09:00
Konrad `ktoso` Malawski
0a65445765 [Distributed] Correct handling super-class implemented ad-hoc requirements 2023-10-20 10:30:51 +09:00
Konrad `ktoso` Malawski
1d150c811c [Distributed] Fix effectiveLabel implemementation to expected semantics 2023-10-11 00:19:34 +09:00
Konrad `ktoso` Malawski
037df0130f [Distributed] PoC using a property wrapper on distributed func param for validation 2023-06-30 11:28:27 +09:00
Konrad `ktoso` Malawski
cd3e243ff8 [Distributed] Ensure decoded classes get refcounted down to 0 from decoding 2023-05-19 23:29:49 +02:00