Skip to content

Lazy-Load @_dynamicReplacement #28453

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

Conversation

CodaFi
Copy link
Contributor

@CodaFi CodaFi commented Nov 23, 2019

Cherry-pick #28434 so we get rid of a class of cycles through deserialization.

To support lazy resolution of the cross-referenced function in a serialized @_dynamicReplacement(for: ...) attribute, add a utility to the LazyMemberLoader and plumb it through.  This is a more general utility than the current resolver, which relies on the type checker to strip the attribute off of VarDecls and fan it back out onto accessors, which means serialization has only ever seen AbstractFunctionDecls.
Remove a dead overload and add an overload for lazy member loading
Add DynamicallyReplacedDeclRequest to ValueDecl and plumb the request through to TypeCheckAttr where it replaces TypeChecker::findReplacedDynamicFunction.
Use the new dynamically replaced request to power this predicates.
Complete the refactoring by splitting the semantic callers for the original decl of a dynamically replaced declaration.

There's also a change to the way this attribute is validated and placed.  The old model visited the attribute on any functions and variable declarations it encountered in the primary.  Once there, it would strip the attribute off of variables and attach the corresponding attribute to each parsed accessor, then perform some additional ObjC-related validation.

The new approach instead leaves the attribute alone.  The request exists specifically to perform the lookups and type matching required to find replaced decls, and the attribute visitor no longer needs to worry about revisiting decls it has just grafted attributes onto.  This also means that a bunch of parts of IRGen and SILGen that needed to fan out to the accessors to ask for the @_dynamicReplacement attribute to undo the work the type checker had done can just look at the storage itself.  Further, syntactic requests for the attribute will now consistently succeed, where before they would fail dependending on whether or not the type checker had run - which was generally not an issue by the time we hit SIL.
We've changed *what* is serialized by changing the way
@_dynamicReplacement is type checked, but not *how* it's
serialized.  Bump the format so there aren't strange incompatibilities
because of this.
@CodaFi
Copy link
Contributor Author

CodaFi commented Nov 23, 2019

@swift-ci please smoke test and merge

@swift-ci swift-ci merged commit 855671a into swiftlang:swift-incremental-dependency-tracking Nov 23, 2019
@CodaFi CodaFi deleted the clap-yo-hands branch November 23, 2019 15:40
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