Commit Graph

59 Commits

Author SHA1 Message Date
Slava Pestov
e8c0e33ab6 AST: Fix actor isolation checking for lazy property initializers
The initializer DeclContext is not a ValueDecl; instead, fish out the
associated VarDecl using other means.

Also while I'm here, fix actor isolation checking in the case where
'self' is explicitly captured in a capture list as well.

Fixes <rdar://problem/72727986>.
2021-01-06 18:39:57 -05:00
Erik Eckstein
c5bbe516c7 [concurrency] SILGen: emit hop_to_executor instructions
Emit hop_to_executor instruction in the prolog of actor-isolated async functions and after all async calls in such functions.

rdar://problem/70299168
2020-11-04 09:57:40 +01:00
Kavon Farvardin
34d22105b8 implemented parsing and typechecking for @actorIndependent(unsafe)
[broken] first impl of @actorIndependent in the type checker.

[broken] fixed mistake in my parsing code wrt invalid source range

[broken] found another spot where ActorIndependent needs custom handling

[broken] incomplete set of @actorIndependent(unsafe) tests

updates to ActorIndependentUnsafe

[fixed] add FIXME plus simple handling of IndependentUnsafe context

finished @actorIndependent(unsafe) regression tests

added wip serialization / deserialization test

focus test to just one actor class

round-trip serialize/deserialize test for @actorIndependent

serialize -> deserialize -> serialize -> compare to original

most of doug's comments

addressed robert's comments

fix printing bug; add module printing to regression test

[nfc] update comment for ActorIsolation::IndependentUnsafe
2020-10-19 15:20:24 -07:00
Doug Gregor
18fd4be17a [Concurrency] Check actor isolation consistency for overrides & subclasses.
Both overriding declarations and subclasses must have the actor
isolation as their overridden declarations or superclasses,
respectively. Enforce this, ensuring that we're also doing the
appropriate substitutions.
2020-10-13 21:41:59 -07:00
Doug Gregor
2f7ff6aa39 [Concurrency] Allow ActorIsolation in diagnostic messages.
ActorIsolation is rendered as a descriptive phrase before an entity,
e.g, "actor-independent" or "global actor 'UIActor'-isolated" when
used in diagnostics.
2020-10-13 21:41:03 -07:00
Doug Gregor
f089ba9464 [Concurrency] Propagation of actor constraints.
Implement propagation rules for global actor constraints, which can come from:

* Enclosing extension or type
* Superclass of a class
* Overridden declaration
* Requirement witnessed by a declaration
* Storage declaration for an accessor
2020-10-13 15:17:13 -07:00
Doug Gregor
c6f4be2392 [Concurrency] Eliminate "privileged" forms of ActorIsolation.
The "privileged" cases for actor instance and global actor isolation
covered the case where the entity itself is within the particular
actor but can be freely used from outside the actor, e.g., because it
is asynchronous or an asynchronous handler. This is the wrong modeling
for the problem, because it's only the first part of that---what the
isolation of the particular entity is---that is needed for most
clients. There will be a different abstraction for that.
2020-10-09 15:44:54 -07:00
Doug Gregor
77584928da [Concurrency] Implement global actor isolation rules.
Extend the actor isolation checking rules to account for global
actors. For example, a function annotated with a given global actor
can invoke synchronous methods from the same global actor, but not
from a different global actor or a particular actor instance.
Similarly, a method of an (instance) actor that is annotated with a
global actor attribute is not part of the (instance) actor and,
therefore, cannot operate on its actor-isolated state.
2020-10-09 15:20:01 -07:00
Doug Gregor
2762405390 [Concurrency] Introduce @actorIndependent attribute.
Introduce a new attribute `@actorIndependent` that specifies that a
given declaration is considered to be independent of any actor.
Actor-independent declarations do not have access to actor-isolated
state, even when they are declared as instance members of the actor.

On the other hand, actor-independent declarations can be used to
conform to (synchronous) requirements in protocols.
2020-09-18 22:56:17 -07:00