Skip to content

Add experimental feature to defer Sendable checking to SILGen #66929

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

Closed
wants to merge 5 commits into from

Conversation

JTurcotti
Copy link
Contributor

@JTurcotti JTurcotti commented Jun 26, 2023

Currently Sendable diagnostics such as non-sendable type 'NonSendable' passed in call to actor-isolated instance method 'actorTakesNS' cannot cross actor boundary are all produced during type checking. We want to add a SIL pass that uses flow-sensitive ownership analysis to determine that some of these diagnostic sites are actually safe (i.e. cannot yield data races), so the production of such diagnostics must be deferred to a SIL pass.

This PR is an incremental step towards accomplishing that goal. Instead of being directly produced during type checking, a large class of sendable diagnostics (see the added test files in swift/test/Concurrency/DeferredSendableChecking for a characterization) are wrapped into closures that can be called later to produce the diagnostics. Those closures are wrapped in DeferredSendableDiagnostics - a class containing utilities for handling creation and accumulation that respects existing control flows - which are then placed in SendNonSendableExpr AST nodes that are inserted at appropriate sites in the AST.

SILGen responds to encountering these SendNonSendableExpr nodes by recursing to their subexpression, but calling their contained closure to emit the appropriate diagnostics before doing so.

swift/test/Concurrency/DeferredSendableChecking contains two identical test files, except that one is run with -typecheck and the other is run with emit-silgen. The former produces no diagnostics, the latter produces all diagnostics.

This behavior is guarded behind the -enable-experimental-feature DeferredSendableChecking flag.

This PR supersedes #66874.

@JTurcotti
Copy link
Contributor Author

@swift-ci please smoke test

@JTurcotti JTurcotti changed the title [Draft] Defer vector diagnostics Add experimental feature to defer Sendable checking to SILGen Jun 26, 2023
jturcotti added 5 commits June 26, 2023 13:24
…s, and possibly defer their production. Does not build yet due to failing static asserts; store pointers to DeferredSendableDiagnostics in SendNonSendableExpr's to enable AST allocation and trivial deallocation.
…bleDiagnostics instead of eagerly emitting them

add documentation
…r, and produce its diagnostics during SILGen
…xperimental-feature DeferredSendableChecking
…tead of nesting diagnostic closures inside each other
@JTurcotti JTurcotti force-pushed the defer-vector-diagnostics branch from e5e8952 to 6d06ee2 Compare June 26, 2023 20:27
@JTurcotti
Copy link
Contributor Author

@swift-ci please smoke test

@JTurcotti
Copy link
Contributor Author

Superseded by #66994, which defers a subset of the diagnostics deferred here.

@JTurcotti JTurcotti closed this Jun 28, 2023
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.

1 participant