Skip to content

Conversation

slavapestov
Copy link
Contributor

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.

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.
@slavapestov slavapestov requested a review from a team as a code owner November 29, 2018 22:41
@slavapestov slavapestov changed the title Fixed layout classes should still have resilient vtables Fixed layout classes should still have resilient vtables [5.0; ABI] Nov 29, 2018
@slavapestov
Copy link
Contributor Author

@swift-ci Please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 2c9b62df029cbbff2125486db4d50d5b8325b9d1

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 2c9b62df029cbbff2125486db4d50d5b8325b9d1

@slavapestov
Copy link
Contributor Author

The test failure was a bad cherry-pick. Let's try again

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 2c9b62df029cbbff2125486db4d50d5b8325b9d1

@slavapestov
Copy link
Contributor Author

@swift-ci Please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 2c9b62df029cbbff2125486db4d50d5b8325b9d1

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - d879b2ac02091ecfcd874eaa3a2be73111664b5c

@slavapestov slavapestov force-pushed the fixed-layout-classes-5.0 branch from d879b2a to 34e998b Compare November 30, 2018 01:38
@slavapestov
Copy link
Contributor Author

Another test typo... should've tested locally

@slavapestov
Copy link
Contributor Author

@swift-ci Please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - d879b2ac02091ecfcd874eaa3a2be73111664b5c

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - d879b2ac02091ecfcd874eaa3a2be73111664b5c

@_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.
@slavapestov slavapestov force-pushed the fixed-layout-classes-5.0 branch from 34e998b to 9b3758e Compare November 30, 2018 04:23
@slavapestov
Copy link
Contributor Author

@swift-ci Please test

1 similar comment
@slavapestov
Copy link
Contributor Author

@swift-ci Please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 34e998baaf994b317f818ee575651dcb89364c07

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 34e998baaf994b317f818ee575651dcb89364c07

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 34e998baaf994b317f818ee575651dcb89364c07

Copy link
Contributor

@AnnaZaks AnnaZaks left a 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.

@AnnaZaks AnnaZaks merged commit 4f54131 into swiftlang:swift-5.0-branch Nov 30, 2018
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