Skip to content

[ClangImporter] Avoid calling into ObjCSelector lookup #31937

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
May 22, 2020

Conversation

hamishknight
Copy link
Contributor

The ClangImporter currently calls into ObjCSelector's lookupDirect in a couple of places, stashing the selector in a DenseMap to try and avoid re-entrancy problems.

However this will become a problem once ObjCSelector's lookupDirect is both requestified and starts pulling in members from the main module, so migrate the ClangImporter off calling it.

Fortunately most of its uses only care about decls with associated Clang nodes. For those cases, we can use the existing member table, making sure to populate it with any method we import.

In one case, the ClangImporter needs to check to see if there's a deserialized Swift method with a matching selector. Instead of calling through to lookupDirect, let's just query the Swift module loaders directly.

The ClangImporter currently calls into
`ObjCSelector`'s `lookupDirect` in a couple of
places, stashing the selector in a DenseMap to try
and avoid re-entrancy problems.

However this will become a problem once
`ObjCSelector`'s `lookupDirect` is both
requestified and starts pulling in members from
the main module, so migrate the ClangImporter off
calling it.

Fortunately most of its uses only care about decls
with associated Clang nodes. For those cases, we
can use the existing member table, making sure to
populate it with any method we import.

In one case, the ClangImporter needs to check to
see if there's a deserialized Swift method with a
matching selector. Instead of calling through to
`lookupDirect`, let's just query the Swift module
loaders directly.
@hamishknight
Copy link
Contributor Author

@swift-ci please test

@hamishknight
Copy link
Contributor Author

@swift-ci please test source compatibility

@hamishknight hamishknight requested a review from CodaFi May 21, 2020 16:23
Copy link
Contributor

@CodaFi CodaFi left a comment

Choose a reason for hiding this comment

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

Great to see ClangImporter lose more re-entrant lookupDirect calls.

@hamishknight
Copy link
Contributor Author

@swift-ci please smoke test

@hamishknight hamishknight merged commit 30e14ee into swiftlang:master May 22, 2020
@hamishknight hamishknight deleted the an-introspective-lookup branch May 22, 2020 20:35
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