Skip to content

[region-isolation] Only make partial_apply actor derived if we capture an isolated parameter... not just any actor. #72004

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 8 commits into from
Mar 3, 2024

Conversation

gottesmm
Copy link
Contributor

@gottesmm gottesmm commented Mar 1, 2024

Before I couldn't do this since, @sil_isolated was not represented on partial_applies. In the first commit in this commit series, I added support to the frontend so that we now emit partial_applies with sil_isolated parameters.

In the second commit, I use this information to restrict when the partial_apply is considered to be "actor derived" to if the partial_apply parameter is @sil_isolated.

rdar://123881277

@gottesmm gottesmm requested a review from ktoso as a code owner March 1, 2024 05:58
@gottesmm
Copy link
Contributor Author

gottesmm commented Mar 1, 2024

@swift-ci smoke test

Copy link
Contributor

@rjmccall rjmccall left a comment

Choose a reason for hiding this comment

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

Other than the two questionable assertions, this looks good.

gottesmm added 2 commits March 1, 2024 11:54
…ated parameter in the closure's function signature.

This ensures that when region isolation is enabled, we can begin properly
modeling when a closure should not be allowed to be isolated. In the next
commit, I am going to loosen this and we should be able to pass in actors
outside of methods without the closure being afflicted with "actor
derived-ness".
…e an isolated parameter... not just any actor.

Before I couldn't do this since, @sil_isolated was not represented on
partial_applies. Since in the previous commit, I added support to the compiler
to represent this, I can now limit this query so now one can pass an actor
instance outside of its method to a nonisolated non-Sendable partial apply.
Since it is Sendable, it is always safe to do this since we are passing the
actor.

rdar://123881277
@gottesmm
Copy link
Contributor Author

gottesmm commented Mar 1, 2024

Problem was that in CaptureInfo we were determining if a value was isLocalCapture by calling CapturedValue::getDecl(). This doesn't work for dynamic self metadata which is never an isolation parameter (it is a metatype) and doesn't have a decl. I am preparing a small addition to this PR with a patch that fixes that issue by adding a new isLocalCapture to CapturedValue that does the correct thing.

Specifically, CaptureInfo previously as a pattern in CaptureInfo.cpp would
attempt to ascertain if a CapturedValue was a local capture by checking the
CapturedValue's decl. Unfortunately, when we have captured dynamic self
metadata, we do not even have a getDecl() and should return false.

I fixed this by adding a new API to CaptureValue that checks if it has a decl
before checking if the decl is a local capture. This avoids this problem.
…re that we actually process it via an assert.

A little paranoia never hurts.
@gottesmm
Copy link
Contributor Author

gottesmm commented Mar 1, 2024

@swift-ci smoke test

@gottesmm gottesmm force-pushed the main-rdar123881277 branch from a76eb10 to 77e2cd3 Compare March 1, 2024 20:58
@gottesmm
Copy link
Contributor Author

gottesmm commented Mar 1, 2024

@swift-ci smoke test

@gottesmm gottesmm enabled auto-merge March 1, 2024 21:15
@gottesmm
Copy link
Contributor Author

gottesmm commented Mar 1, 2024

@swift-ci smoke test

@gottesmm
Copy link
Contributor Author

gottesmm commented Mar 2, 2024

@swift-ci smoke test

@gottesmm
Copy link
Contributor Author

gottesmm commented Mar 2, 2024

@swift-ci smoke test macOS platform

@gottesmm gottesmm merged commit c24889c into swiftlang:main Mar 3, 2024
@gottesmm gottesmm deleted the main-rdar123881277 branch March 3, 2024 07:39
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