Commit Graph

216 Commits

Author SHA1 Message Date
Pavel Yaskevich
f5ed53d918 Revert "[stdlib] Distributed: Remove invokeOnReturn requirement and its synthesis"
This reverts commit 961aa30d46.
2024-02-20 20:33:02 -08:00
Konrad `ktoso` Malawski
551b07ba80 [Distributed] Fix _executeDistributedTarget ABI (#71725) 2024-02-19 21:23:11 -08:00
Mishal Shah
af112c1591 Update the Swift version to 6.0 from 5.11 2024-02-19 17:47:16 -08:00
Konrad `ktoso` Malawski
e9c7f3c382 [Distributed] Target identifiers for protocol calls (#70928) 2024-02-16 07:19:20 -08:00
Konrad `ktoso` Malawski
827e6a5708 [Distributed] Add DistributedProtocol macro (#71090) 2024-02-16 07:27:34 +09:00
Pavel Yaskevich
a2caaa3d03 [Distributed] Promote SerializationRequirement as a primary associated type for encoder/decoder/result 2024-02-12 14:26:30 -08:00
Pavel Yaskevich
961aa30d46 [stdlib] Distributed: Remove invokeOnReturn requirement and its synthesis
This is no longer necessary because `onReturn` is a protocol
requirement now.
2024-02-12 14:26:30 -08:00
Pavel Yaskevich
6c7000ae0b [Sema/IRGen] Extend ad-hoc requirement handling to DistributedTargetInvocationResultHandler.onReturn 2024-02-12 14:26:30 -08:00
Pavel Yaskevich
4d45701046 [Sema/IRGen] Extend ad-hoc requirement handling to DistributedTargetInvocationDecoder.decodeNextArgument 2024-02-12 14:26:30 -08:00
Pavel Yaskevich
4f32111bf8 [Sema/IRGen] Extend ad-hoc requirement handling to DistributedTargetInvocationEncoder.record{Argument, ReturnType} 2024-02-12 14:26:30 -08:00
Pavel Yaskevich
e59727aa3d [stdlib] Distributed: Promote remoteCall{Void} into protocol requirements 2024-02-12 13:30:59 -08:00
Konrad `ktoso` Malawski
68eab70a18 [Distributed] whenLocal adoption of typed throws (#71439) 2024-02-10 10:16:36 +09:00
Konrad `ktoso` Malawski
dfdbe457bf [Distributed] Support complex generic distributed actors in thunk gen (#70842) 2024-01-28 01:26:52 -08:00
Holly Borla
f7326618ae [Concurrency] Model actor isolation to an arbitrary actor instance using
a VarDecl or Expr.

This generalization exposed a bug where distributed actor isolation checking
was skipped in some cases, including for the isolated call in `whenLocal`.
The `whenLocal` implementation violated distributed actor isolation because
despite the `__isLocal` dynamic check, the `self` value passed to the `body`
function argument is still not statically local. To workaround this, I
applied the `_local` modifier explicitly to `self` before the call, which
also necessitated allowing `_local` to be written explicitly in the Distributed
library.
2024-01-24 16:11:09 -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
70b1c0e43c [Concurrency] Major cleanup of assert/precondition/assume isolated docs (#70800)
Co-authored-by: Alex Martini <amartini@apple.com>
2024-01-10 23:48:32 -08: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
Konrad `ktoso` Malawski
370fa50132 Merge pull request #69093 from ktoso/wip-distributed-effective-label 2023-10-25 10:40:17 +09:00
Ian Anderson
4dbc58723a [CMake] [Darwin] Don't add the Darwin overlay as a dependency if the overlays aren't being built
Allow for the overlays to not be built in Darwin by respecting SWIFT_BUILD_SDK_OVERLAY.
2023-10-17 11:03:57 -07:00
Konrad `ktoso` Malawski
1d150c811c [Distributed] Fix effectiveLabel implemementation to expected semantics 2023-10-11 00:19:34 +09:00
Max Desiatov
21a2b78801 stdlib/benchmark: add canImport(Musl) where needed (#67120)
This allows compiling stdlib and benchmarks when targeting musl instead of Glibc.
2023-07-05 19:55:08 +01:00
Konrad `ktoso` Malawski
da6f08a24e [Concurrency] Adopt stable keyword consuming instead of __owned
add test for warnings emitted when missing consuming attribute

use -emit-sil in mock SDK tests for better coverage
2023-05-11 15:18:54 +02:00
Kavon Farvardin
103bd043cd Revert "Revert "Prevent noncopyable metatypes from being converted to Any""
This reverts commit 1a3b42cd63.
2023-05-04 11:38:00 -07:00
Hamish Knight
1a3b42cd63 Revert "Prevent noncopyable metatypes from being converted to Any" 2023-05-04 12:10:10 +01:00
Kavon Farvardin
4710fc675b Prevent noncopyable metatypes from being converted to Any
These metatypes are a gateway to more incorrect
uses of these noncopyable values because we don't
yet have the corresponding runtime support yet.
The other use cases of using metatypes of
noncopyable types in generics is not high enough to
warrant people using them yet.

resolves rdar://106452518
2023-05-03 10:23:11 -07:00
Konrad `ktoso` Malawski
e19ccb2228 [Executors] Avoid using Job typealias and use the ExecutorJob explicitly 2023-04-14 18:44:17 +09: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
b8780c9d9e [Executors] Move assert/assume APIs onto actors; assumeIsolated() (#64812) 2023-04-04 07:44:43 +09:00
Konrad `ktoso` Malawski
edb66df377 [Executors] Clean up how we unwrap the local executor of distributed custom actor (#64719) 2023-03-30 06:22:48 +09:00
Konrad `ktoso` Malawski
0586c14b60 [Concurrency] SerialExecutor.isSameExclusiveExecutionContext (#64604) 2023-03-28 15:56:28 +09:00
Konrad `ktoso` Malawski
345c221f56 [Concurrency] Distributed actor's unownedExecutor should be optional (#64499) 2023-03-22 08:40:41 +09: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
48c6f59186 [Distributed] LocalDAS cannot gain constraint on resolve method (#63321) 2023-02-01 13:56:48 +09:00
Konrad `ktoso` Malawski
a2879246ad [Distributed] LocalDAS cannot gain this constraint, even though the DAS protocol has it (#62572) 2022-12-15 07:00:45 +09:00
Max Desiatov
ffc6152f68 [Distributed] fix deprecation warning in LocalTesting (#61415) 2022-10-24 20:19:41 +09:00
swift-ci
5d90a69dfb Merge pull request #61542 from ktoso/wip-more-docs-on-decoder-da
[Distributed] More docs on the InvocationDecoder itself
2022-10-12 16:31:35 -07:00
Konrad `ktoso` Malawski
e1527ff9b6 Update stdlib/public/Distributed/DistributedActorSystem.swift
Co-authored-by: Kavon Farvardin <kfarvardin@apple.com>
2022-10-13 06:14:32 +09:00
Konrad `ktoso` Malawski
20e1834627 [Distributed] More docs on the InvocationDecoder itself 2022-10-11 23:00:24 +09:00
Yuta Saito
2f9fb0a426 [Distributed] Fix signature mismatch in NotFoundError constructor 2022-10-06 16:15:25 +00:00
Konrad `ktoso` Malawski
7d214054b6 [Distributed] More docs for ad-hoc requirements (#60916) 2022-09-16 09:38:29 +09:00
swift-ci
a851866920 Merge pull request #60296 from apple/wip-distributed-docs
[Distributed] More API documentation
2022-08-18 04:29:48 -07:00
Konrad `ktoso` Malawski
49ae51c37c small cleanups 2022-08-18 18:07:28 +09:00
Konrad `ktoso` Malawski
968a64eb8b Apply suggestions from code review
Co-authored-by: Yim Lee <yim_lee@apple.com>
2022-08-18 17:04:11 +09:00
Konrad `ktoso` Malawski
1f840d75cc actor system docs 2022-08-17 22:07:41 +09:00
Konrad `ktoso` Malawski
25e17930cc [Distributed] more specific errorCodes for dist failures; hide the make error func 2022-08-10 10:39:12 +09:00
Konrad `ktoso` Malawski
2418aeb375 [Distributed] documentation 2022-07-29 12:32:49 +09:00
Konrad `ktoso` Malawski
96462980fe improve error reporting 2022-07-29 10:44:38 +09:00
Konrad `ktoso` Malawski
cf37dd8860 make error func can be internal 2022-07-29 09:51:53 +09:00