Commit Graph

197 Commits

Author SHA1 Message Date
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
Yuta Saito
5f94468416 [Test] Disable part of distributed tests on singlethreaded global executor 2023-04-29 10:58:04 +00:00
Konrad `ktoso` Malawski
80b93863a9 [Concurrency] Rename Job to ExecutorJob, ease transition with typealias (#65006) 2023-04-11 14:52:10 +09:00
Konrad `ktoso` Malawski
b666fc672e [Executors] Remote distributed actors get "crash on enqueue" default executor (#64969) 2023-04-10 19:12:03 +09:00
Konrad `ktoso` Malawski
854b889781 Fix test using assume APIs, which landed concurrently to API renames 2023-04-04 13:16:52 +09:00
Konrad `ktoso` Malawski
10b49bcb85 [Executors] Ensure we treat DA older than 5.9 always as DefaultActor (#64800) 2023-04-04 11:04:53 +09:00
Konrad `ktoso` Malawski
b8780c9d9e [Executors] Move assert/assume APIs onto actors; assumeIsolated() (#64812) 2023-04-04 07:44:43 +09:00
Konrad `ktoso` Malawski
345c221f56 [Concurrency] Distributed actor's unownedExecutor should be optional (#64499) 2023-03-22 08:40:41 +09:00
Saleem Abdulrasool
06725cca3d IRGen: correct field counting for distributed actors (#64439) 2023-03-17 13:31:19 +09:00
Allan Shortlidge
b2a1e16a80 Disable distributed_actor_assume_executor.swift because it is failing on Windows. 2023-03-16 13:17:07 -07:00
Konrad `ktoso` Malawski
5d2a311dda [Executors] assumeOnLocalDistributedActorExecutor (isolated Act) -> 2023-03-16 13:23:47 +09:00
Konrad `ktoso` Malawski
41f99fc2ae [Executors][Distributed] custom executors for distributed actor (#64237)
* [Executors][Distributed] custom executors for distributed actor

* harden ordering guarantees of synthesised fields

* the issue was that a non-default actor must implement the is remote check differently

* NonDefaultDistributedActor to complete support and remote flag handling

* invoke nonDefaultDistributedActorInitialize when necessary in SILGen

* refactor inline assertion into method

* cleanup

* [Executors][Distributed] Update module version for NonDefaultDistributedActor

* Minor docs cleanup

* we solved those fixme's

* add mangling test for non-def-dist-actor
2023-03-15 23:42:55 +09:00
Konrad `ktoso` Malawski
ae23892276 Merge branch 'main' into wip-prevent-async-overloads-dist 2022-09-20 20:31:04 +09:00
Duo Wang
21154d56f7 fix missing test codesign 2022-08-04 10:36:13 -07:00
Mishal Shah
a436f98fff Merge pull request #60286 from wd-doylle/fix/test_codesign
[test] fix missing codesign in test files
2022-08-01 13:14:53 -07:00
Konrad `ktoso` Malawski
96462980fe improve error reporting 2022-07-29 10:44:38 +09:00
Konrad `ktoso` Malawski
fbc829fbbd [Distributed] Don't hang, but throw when target accessor not found 2022-07-29 09:33:38 +09:00
Duo Wang
72e0ac2819 [tests] fix missing codesign in test files 2022-07-28 13:59:44 -07:00
Pavel Yaskevich
ae0c942089 [Distributed] NFC: Re-enable two test-cases that used to fail on arm64e 2022-07-21 14:33:06 -07:00
Konrad `ktoso` Malawski
027c4a69c9 [Distributed] Prevent remote distributed actor from running deinit body 2022-07-14 17:56:03 +09:00
Konrad `ktoso` Malawski
db64d5a961 [Distributed] Disable test while we investigate arm64e issue 2022-07-07 12:58:12 +09:00
Konrad `ktoso` Malawski
6b8642cdf2 [Distributed] Prevent overloading on async in distributed methods, for wire compat 2022-07-05 18:49:42 +09:00
Konrad `ktoso` Malawski
728c007fb9 [Distributed] Implement witnesses for sync or non-throw dist reqs
[Distributed] generic and inner test; without one edge case

[Distributed] fix distributed_thunk test; unsure about those extra hops, could remove later

[Distributed] Remove type pretending in getSILFunctionType; it is not needed

It seems our constant replacement in the earlier phases is enough, and
we don't need this trick at all.

[Distributed] Use thunk when calling cross-actor on DA protocols
2022-07-04 19:02:11 +09:00
Konrad `ktoso` Malawski
ef525424f6 Merge pull request #59700 from xedin/distributed-computed-properties-via-accessor-thunk
[Distributed] Implement distributed computed properties via special accessor
2022-06-30 16:04:36 +09:00
Pavel Yaskevich
84fa2322d3 [Distributed] Synthesize 'distributed thunk' accessor for distributed computed properties 2022-06-29 14:49:10 -07:00
Konrad `ktoso` Malawski
febfef97d4 [Distributed] Skeleton implementation of distributed computed properties 2022-06-29 14:49:04 -07:00
Konrad `ktoso` Malawski
22b20afce6 [Distributed] make witness be the distributed thunk 2022-06-27 17:08:55 +09:00