-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Fixed layout classes should still have resilient vtables [5.0; ABI] #20888
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
Fixed layout classes should still have resilient vtables [5.0; ABI] #20888
Conversation
We want to be able to define classes with a fixed storage layout, but a resilient (opaque) vtable. If the class is also generic, we still have to load field offsets from the metadata if they are dependent. So put the field offsets after the generic arguments and before the vtable. This is an ABI break for @_fixed_layout classes, which are defined by the stdlib.
…t-metadata from resilient-storage We want @_fixed_layout classes to have non-resilient storage, but still have resilient metadata.
@swift-ci Please test |
Build failed |
Build failed |
The test failure was a bad cherry-pick. Let's try again |
Build failed |
@swift-ci Please test |
Build failed |
Build failed |
d879b2a
to
34e998b
Compare
Another test typo... should've tested locally |
@swift-ci Please test |
Build failed |
Build failed |
@_fixed_layout classes have resilient vtables now, so we can add and re-order methods. Removing overrides is not legal though because they are subject to devirtualization.
The result type mismatch comes up when we're calling a covariant override of a class method resiliently as well.
34e998b
to
9b3758e
Compare
@swift-ci Please test |
1 similar comment
@swift-ci Please test |
Build failed |
Build failed |
Build failed |
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.
Approved and merging now.
To achieve this, re-organize the metadata so that the field offset vector comes immediately after the generic parameter area, instead of after the vtable. This means the vtable can change resiliently.
Note that for non-generic
@_fixed_layout
classes without resiliently-sized fields, field offsets are constant and will be inlined directly, but we need the more general access pattern to work if the@_fixed_layout
class has generic layout.Also, use method dispatch thunks to call vtable methods instead of accessing the vtable directly, as with resilient classes.
Since the metadata size is not known at compile time, we use the most general metadata instantiation strategy now.