Skip to content

[Swift-ObjC-Interop] Speculative cyclic lookup fix #66195

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 1 commit into from
Jun 6, 2023

Conversation

NuriAmari
Copy link
Contributor

@NuriAmari NuriAmari commented May 28, 2023

Explanation:

In certain scenarios (ie. mixed modules), we must be able to associate an ObjC forward declaration with a corresponding @objc exposed native Swift declaration. There is no existing look up table to facilitate lookups of Swift declaration via @objc name.

Prior to 61606, the behavior used getTopLevelDeclsWhereAttributesMatch to fetch all Swift declarations with a matching @objc name. In an attempt to make this faster, I created lookupTopLevelDeclsByObjCName which does the same, but finds all declarations that have any @objc name and puts them into a cache. This lookup deserializes too many declarations.

This patch reverts to the old lookup method, which due to a narrowed predicate, does far less deserialization.

Issue:

Deserialization was taking too long on some framework @slavapestov can provide more detail.

Risk:

This is a partial revert, and the existing lookup behavior was used in Swift5.8 and before, so should be low risk. Since the other changes are gated behind a flag, without the flag on, this patch is likely equivalent to reverting 61606 in its entirety.

Testing:

CI

The lookup to resolve an ObjC forward declaration
to its potential native Swift definition within
a mixed module is becoming cyclic somehow.

The old uncached lookup still works, so it seems
this is an issue with cache invalidation somehow.
Until the route of the issue, use the old uncached
lookup method.
@NuriAmari
Copy link
Contributor Author

@swift-ci Please test

@NuriAmari NuriAmari marked this pull request as ready for review May 30, 2023 16:12
@NuriAmari NuriAmari requested a review from a team as a code owner May 30, 2023 16:12
@NuriAmari NuriAmari requested a review from hyp May 30, 2023 16:13
@NuriAmari NuriAmari requested a review from slavapestov May 30, 2023 22:42
@NuriAmari
Copy link
Contributor Author

@swift-ci Please Test Source Compatibility

@DougGregor
Copy link
Member

Thank you!

@DougGregor DougGregor merged commit e49fccf into swiftlang:release/5.9 Jun 6, 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.

3 participants