Skip to content

Handle all isolation checking for function calls in one place #66928

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 27, 2023

Conversation

DougGregor
Copy link
Member

Isolation checking for calls had two separate implementation places:
one that looked at the declaration being called (for member
declarations) and one that worked on the actual call expression. Unify
on the latter implementation, which is more general and has access to
the specific call arguments. Improve diagnostics here somewher so we
don't regress in that area.

This refactoring shouldn't change the actual semantics, but it makes
upcoming semantic changes easier.

Isolation checking for calls had two separate implementation places:
one that looked at the declaration being called (for member
declarations) and one that worked on the actual call expression. Unify
on the latter implementation, which is more general and has access to
the specific call arguments. Improve diagnostics here somewher so we
don't regress in that area.

This refactoring shouldn't change the actual semantics, but it makes
upcoming semantic changes easier.
The move to perform all call checking that can cross concurrency
domains into one place dropped the specific logic for distributed
actor calls. Introduce that logic, cleaning it up to consistently use
the "known to be local" semantics needed for distributed actors.
…te path

Remove the "old" path that diagnosed actor isolation and sendability
issues with some calls. It is now unused.
@DougGregor DougGregor force-pushed the unify-call-isolation-checking branch from e9f3ec7 to 11dd80a Compare June 26, 2023 20:40
@DougGregor
Copy link
Member Author

@swift-ci please smoke test

@@ -2646,6 +2596,8 @@ namespace {
}
}

// FIXME: Subscript?
Copy link
Contributor

@ktoso ktoso Jun 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't support distributed subscripts; unsure if we need handling here after the changes?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at the line below I think we just handle it via fallthrough into the general case:

// This is either non-distributed variable, subscript, or something else.
       ctx.Diags.diagnose(declLoc,
                          diag::distributed_actor_isolated_non_self_reference,

so nothing to do here for the fixme?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't change anything with respect to distributed subscripts, but wanted to note that this is where we'd deal with them if/when we do

@DougGregor DougGregor merged commit 6d58bce into swiftlang:main Jun 27, 2023
@DougGregor DougGregor deleted the unify-call-isolation-checking branch June 27, 2023 01:21
}

func f() {} // expected-note {{distributed actor-isolated instance method 'f()' declared here}}
func f() {} // expected-note {{calls to instance method 'f()' from outside of its actor context are implicitly asynchronous}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah this message is good, the "more general" isolation rules just apply here 👍

@@ -2434,41 +2415,6 @@ namespace {
return ReferencedActor(var, isPotentiallyIsolated, ReferencedActor::NonIsolatedParameter);
}

VarDecl *findReferencedBaseSelf(Expr *expr) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh sweet to get rid of this entire func, thanks!

break;
}

// If we're calling an async function that's nonisolated, and we're in
// an isolated context, then we're exiting the actor context.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 that's not something we were diagnosing before right? Nice.

Copy link
Contributor

@ktoso ktoso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAICS this looks good!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants