Skip to content

Lift the decision of whether a method needs a vtable slot up to AST. #9309

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 4 commits into from
May 5, 2017

Conversation

jrose-apple
Copy link
Contributor

This lets us serialize that decision, which means we can conceivably change the decision in later versions of the compiler without breaking existing code. More immediately, it's groundwork that will eventually allow us to drop decls from the AST without affecting vtable layout.

First half of <rdar://problem/31878396> Deserialization: Dropping members from a class affects the layout of its vtable

@jrose-apple jrose-apple requested a review from slavapestov May 5, 2017 00:40
@jrose-apple
Copy link
Contributor Author

Note: In the long-term, we'd probably prefer to just consider SIL vtables the canonical layout for a vtable. But we don't think SIL serialization is in a good enough state to use for arbitrary code in Swift 4.

This allows fuzzy matching of top-level optionals in types, using the
same logic we use to fuzzy-match potential overrides.
The previous logic accidentally propagated the "is parameter" flag
into any number of nested tuples. Fix this by differentiating between
"input of a function type" and "member of a tuple that's the input of
a function type".
It's doing essentially the same walk, just with different rules at
each step. This is also something we want accessible at the AST level
(see subsequent commits).
This lets us serialize that decision, which means we can conceivably
/change/ the decision in later versions of the compiler without
breaking existing code. More immediately, it's groundwork that will
eventually allow us to drop decls from the AST without affecting
vtable layout.

This isn't actually a great answer; what we really want is for SIL
vtables to be serialized consistently and treated as the point of
truth. But that would be more change than we're comfortable taking in
the Swift 4 timeframe.

First part of rdar://problem/31878396.
@jrose-apple
Copy link
Contributor Author

@swift-ci Please test

@swift-ci
Copy link
Contributor

swift-ci commented May 5, 2017

Build failed
Jenkins build - Swift Test OS X Platform
Git Commit - a3ad67a819446612784bc7ca5d6ddbde82872dc4
Test requested by - @jrose-apple

@swift-ci
Copy link
Contributor

swift-ci commented May 5, 2017

Build failed
Jenkins build - Swift Test Linux Platform
Git Commit - a3ad67a819446612784bc7ca5d6ddbde82872dc4
Test requested by - @jrose-apple

@slavapestov
Copy link
Contributor

Thanks!

Even once we serialized SIL vtable a we still need to do something about classes in multi-file modules. Lifting this up to the AST makes sense to me regardless, since it's in terms of AST types.

@jrose-apple
Copy link
Contributor Author

I'm not sure how this helps the cross-file case. It seems like you still have to do the same amount of work in both cases?

@slavapestov
Copy link
Contributor

Right, I just meant that we can't always rely on the SIL vtable even in the future when SIL serialization always works

@jrose-apple jrose-apple merged commit 6de9b1e into swiftlang:master May 5, 2017
@jrose-apple jrose-apple deleted the ast-vtables branch May 5, 2017 03:12
jrose-apple added a commit to jrose-apple/swift that referenced this pull request May 11, 2017
Lift the decision of whether a method needs a vtable slot up to AST.
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