Commit Graph

580 Commits

Author SHA1 Message Date
Konrad `ktoso` Malawski
b77685efe0 [Distributed] Remove diagnostic emitting from macro, rely on compiler
The macro cannot diagnose some situations, or rather, would diagnose too
aggressively, because it cannot inspect the type declarations of all
invokved types, and therefore we're unable to reliably report errors
only when necessary.

Originally I thought we don't want to emit macro code that "may fail to
compile" but we don't really have a choice.

This patch removes a manual diagnostic, and enables more correct code to
properly use @Resolvable protocols.
2024-05-15 16:12:50 +09:00
Konrad `ktoso` Malawski
552815e75e [Distributed] remove not used Input file from tests 2024-05-15 10:27:08 +09:00
Michael Gottesman
fe2dc11cb9 [region-isolation] When computing isolation for isolated parameters, use getAnyActor instead of getNominalOrBoundGenericNominal().
This ensures that we can properly compute isolation for generic types that
conform to AnyActor.

I found this by playing with test cases from the previous commit. We would not
find an actor type for the actor instance isolation and would fall back along an
incorrect path.

rdar://128021548
2024-05-13 13:43:51 -07:00
Michael Gottesman
50c2d678f2 [region-isolation] When inferring isolation for an argument, handle non-self isolated parameters as well as self parameters that are actor isolated.
As part of this I went through how we handled inference and rather than using a
grab-bag getActorIsolation that was confusing to use, I created split APIs for
specific use cases (actor instance, global actor, just an apply expr crossing)
that makes it clearer inside the SILIsolationInfo::get* APIs what we are
actually trying to model. I found a few issues as a result and fixed most of
them if they were small. I also fixed one bigger one around computed property
initializers in the next commit. There is a larger change I didn't fix around allowing function
ref/partial_apply with isolated self parameters have a delayed flow sensitive
actor isolation... this will be fixed in a subsequent commit.

This also fixes a bunch of cases where we were printing actor-isolated instead
of 'self' isolated.

rdar://127295657
2024-05-10 15:33:44 -07:00
Michael Gottesman
6a53e9a3f4 Merge pull request #73446 from gottesmm/rdar127580781
[region-isolation] Some diagnostic tweaks
2024-05-05 22:21:36 -07:00
Michael Gottesman
f02172a323 [region-isolation] Change terminology to use the term 'risk' instead of could. 2024-05-05 18:01:05 -07:00
Michael Gottesman
0b761109e2 [region-isolation] If we can infer the callee's name, use that instead of just saying 'callee'.
I also wordsmithed the error message to use the term 'risk' instead of less
negative terms.
2024-05-05 18:01:05 -07:00
Michael Gottesman
699692bd39 [region-isolation] Change diagnostics from using the term transferring -> sending.
rdar://127580781
2024-05-05 18:00:54 -07:00
Alastair Houghton
3c029ebd3f [IRGen] Use llvm.used on ELF instead of llvm.compiler.used.
We changed to `llvm.compiler.used` because of the behaviour of `gold`,
which refuses to coalesce sections that have different `SHF_GNU_RETAIN`
flags, which causes problems with metadata.

Originally I thought we were going to have to generate two sections
with distinct names and have the runtime look for both of them, but
it turns out that the runtime only wants to see sections that have
`SHF_GNU_RETAIN` in any case.  It's really the reflection code that
is interested in being able to see non-retained sections.  The upshot
is that we don't need to use `llvm.compiler.used`; it's just fine if
we have duplicate sections, as long as the reflection code looks for
them when it's inspecting an ELF image.

This also means we no longer need to pass `-z nostart-stop-gc` to the
linker if we're using `lld`.

rdar://123504095
2024-04-29 10:48:22 +01: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
2467c2fa22 Merge pull request #73049 from ktoso/wip-codable-dont-addl-always-implicitly 2024-04-18 15:21:10 +09:00
Konrad `ktoso` Malawski
5df0f053d9 [Distributed][Macro] Improve diagnostics, handle edge cases, properties, assoc types (#73046) 2024-04-18 12:38:02 +09:00
Michael Gottesman
bfa910dcb1 Merge pull request #72959 from gottesmm/tns-upstream-2
[region-isolation] Do not look through begin_borrow or move_value if they are marked as a var_decl.
2024-04-17 17:42:19 -07:00
Michael Gottesman
fa20e52ab6 [region-isolation] Add some tests around initializers and distributed actors. 2024-04-17 13:07:40 -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
Konrad `ktoso` Malawski
54229549b3 [Distributed] Offer fixit for import Distributed when it is required (#72948) 2024-04-12 18:05:32 -07:00
Alex Hoppen
5ec11045d5 Merge pull request #72876 from ahoppen/no-space-before-open-paren
[SwiftSyntax] Test adjustments because no space is inserted between `#available` and `(` by SwiftSyntax anymore
2024-04-10 13:09:12 -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
Alex Hoppen
ba0bae2810 [SwiftSyntax] Test adjustments because no space is inserted between #available and ( by SwiftSyntax anymore
Companion of https://github.com/apple/swift-syntax/pull/2592
2024-04-05 10:33:29 -07: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
Doug Gregor
14fc015d51 Ensure that we map the capture isolation into context
Failing to map the type of an isolation capture into context
caused assertions in type lowering. Fixes the build of the
swift-distributed-actors package.
2024-03-25 17:13:33 -07: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
John McCall
590643ce5e Make @isolated(any) imply @Sendable. No avoidance mechanism for now. 2024-03-15 00:40:54 -04:00
Alexis Laferrière
4209844dfd Tests: disable Distributed/distributed_actor_to_actor.swift on arm64e 2024-03-13 10:22:03 -07: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
Slava Pestov
5afdb987e2 Merge pull request #72146 from slavapestov/ncgenerics-fixes-9
Non-copyable generics fixes, part 9
2024-03-07 22:14:33 -05:00
Slava Pestov
af8c8f1671 Sema: Remove non-experimental associated type inference 2024-03-07 17:30:17 -05:00
Slava Pestov
41df661160 AST: Use a builtin conformance for unconditional Copyable/Escapable
This generalizes what we were already doing for classes.
2024-03-07 15:07:47 -05:00
Pavel Yaskevich
7b7716cda9 [AST/Sema] Distributed: Introduced unified way to retrieve serialization requirements for actors 2024-03-06 13:51:14 -08:00
Konrad `ktoso` Malawski
746521b31c Merge branch 'main' into distributed-protocol-requirement-accessors 2024-03-06 12:52:41 +09: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
John McCall
43b9b28797 Fix a pair of bugs with @isolated(any) closure erasure.
First, and I really should've checked this, but global actors do not
require `shared` to return `Self`; adjust the logic to propagate the
right formal type to the erasure logic.

Second, handle attempts to erase the isolation of something isolated to
a distributed actor using the magic Actor conformance that Doug added.
This only works when the actor is local, but it shouldn't be difficult to
enforce that we only attempt to erase isolation what that's true --- we
need to prevent partial application of distributed actors, and we need to
disallow explicit isolated captures of distributed actors when we're not
currently isolated to it.  Otherwise, it's not possible to get an
@isolated(any) function value with an isolation that isn't the current
function's isolation, which means it always has to be local.

Fixed rdar://123734019
2024-03-04 04:15:21 -05:00
Holly Borla
9ba481ad53 [Diagnostics] Clarify the wording of error_in_future_swift_version. 2024-03-01 12:05:51 -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
Holly Borla
bb6de776d9 Merge pull request #71893 from hborla/downgrade-distributed-actor-isolation-error
[Concurrency] Downgrade newly diagnosed distributed actor isolation violation as a warning until Swift 6.
2024-02-26 17:19:10 -08:00
Holly Borla
479ee384b8 [Concurrency] Downgrade newly diagnosed actor isolation violation
as a warning until swift 6.

In compiler versions <=5.10, the compiler did not diagnose cases
where a non-isolated distributed actor value was passed to a VarDecl
with a function type type that has an isolated distributed actor
parameter, e.g. `(isolated DA) -> Void`. Stage in the error as a
warning until Swift 6.
2024-02-26 12:31:06 -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
Mishal Shah
cb96ec2893 Merge remote-tracking branch 'origin/main' into bump-swift-version-to-6 2024-02-22 09:44:44 -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
Mishal Shah
6c306e3d43 Update the SwiftStdlib version to 6.0 and fix Frontend/crash.swift test 2024-02-21 15:20:24 -08: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
Pavel Yaskevich
65d164a9c3 Revert "[SIL] Distributed: Remove logic related to ad-hoc requirements from SILFunction"
This reverts commit 1909b12370.
2024-02-21 13:29:47 -08:00