Skip to content

Add experimental feature to defer Sendable checking to SILGen #66874

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 16 commits into from

Conversation

JTurcotti
Copy link
Contributor

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.

jturcotti added 15 commits June 20, 2023 20:01
…s, and possibly defer their production. Does not build yet due to failing static asserts.
…s to enable AST allocation and trivial deallocation.
… and controlflow in ActorIsolationChecker::walkToExprPre
…dableDiagnostic instances - causing insertion of spurious SendNonSendableExpr's
…r, and produce its diagnostics during SILGen
…xperimental-feature DeferredSendableChecking
@JTurcotti
Copy link
Contributor Author

@swift-ci please smoke test

2 similar comments
@JTurcotti
Copy link
Contributor Author

@swift-ci please smoke test

@JTurcotti
Copy link
Contributor Author

@swift-ci please smoke test

@JTurcotti
Copy link
Contributor Author

superseded by #66929

1 similar comment
@JTurcotti
Copy link
Contributor Author

superseded by #66929

@JTurcotti JTurcotti closed this Jun 26, 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