-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[ClangImporter] Make conformance loading lazier. #10707
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
[ClangImporter] Make conformance loading lazier. #10707
Conversation
@swift-ci Please test |
@DougGregor: after discussing this with @ematejska we decided the story with a flag didn't make enough sense—either we're comfortable with this for 4.0 or we're not. I'm personally a lot happier than I thought I would be because the lazy mechanism is already there; if I had had to add that for the first time I'd be a lot more apprehensive. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was smaller than I expected, which is great. Thank you, LGTM.
Failing a number of internal tests. Stay tuned. |
Previously, the importer queued up conformances to complete once it was done importing the current batch of declarations. However, if there was a serialized Swift module that extended an imported type to add a conformance in exactly the wrong way, the importer could end up asking for that conformance later---even before the reference to the imported type was resolved. This led to a crash in the deserializer "while reading conformance for type X". Instead of this "pending actions" queue, we can just use the mechanisms already in place for lazily loading conformances. That way they'll get filled out on demand, which is better all around anyway. This does mean putting the requirement signature into the "lazy" part of the conformance, though. This does as a side effect mean that /all/ of the witnesses for the imported conformance may be opaque---that is, they will never be devirtualized to a particular implementation. However, they previously would have referred to methods implemented in Objective-C anyway, which are always dispatched with objc_msgSend. So this should have no practical effect. rdar://problem/32346184
3cd0f13
to
4c18bda
Compare
It looks like those are configuration issues on our end, not related to this pull request. Previous full-testing passed. @swift-ci Please smoke test |
The previous commit needed this for the importer, so we might as well take advantage of it in deserialization as well. No expected change in behavior.
4c18bda
to
897effe
Compare
*sigh* Left in some conflict markers. @swift-ci Please smoke test |
@DougGregor, do you think we should take the serialization change for 4.0 as well, or just the importer work? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
…wrong PR? |
Previously, the importer queued up conformances to complete once it was done importing the current batch of declarations. However, if there was a serialized Swift module that extended an imported type to add a conformance in exactly the wrong way, the importer could end up asking for that conformance later—even before the reference to the imported type was resolved. This led to a crash in the deserializer "while reading conformance for type X".
Instead of this "pending actions" queue, we can just use the mechanisms already in place for lazily loading conformances. That way they'll get filled out on demand, which is better all around anyway. This does mean putting the requirement signature into the "lazy" part of the conformance, though.
This does as a side effect mean that all of the witnesses for the imported conformance may be opaque—that is, they will never be devirtualized to a particular implementation. However, they previously would have referred to methods implemented in Objective-C anyway, which are always dispatched with objc_msgSend. So this should have no practical effect.
There's also a second commit that makes deserialization of Swift conformances a little lazier as well, now that we have that ability. This isn't critical to this fix and we could easily leave it for later.
rdar://problem/32346184