Skip to content

Conversation

@slavapestov
Copy link
Contributor

No description provided.

Previously we would recursively get the abstract layout for the fully
generic class type for every superclass. But really we only need to do
that for fields of the class itself, not any superclass fields, since
we throw out the superclass field information anyway.
We cannot use field offset globals if *any* field of a generic class
with Objective-C ancestry is dependent.

This is because the Swift runtime first performs layout starting
from a static instance start offset, and then asks the Objective-C
runtime to slide the offsets based on the dynamic superclass size.

So if the class has a field of generic type, the alignment of that
type can change the offsets of fields *before* it as well as after.

So we cannot assuem that any fields in such a class have the same
offset across instantiations at all.

The previous fix captured the intent of the above, but it only
kicked in if the immediate superclass of the class was imported
from Objective-C. But really we need to do this for any class with
Objective-C ancestry.

While fixing this, re-organize the code in ClassLayoutBuilder a
little bit to untangle the stored property iteration from the
interesting FieldAccess adjustments that take place after.
@slavapestov
Copy link
Contributor Author

@swift-ci Please test

@slavapestov
Copy link
Contributor Author

@swift-ci Please test source compatibility

@slavapestov
Copy link
Contributor Author

@aschwaighofer You implemented the original fix for https://bugs.swift.org/browse/SR-4687; do you mind taking a look at my changes extending it to classes with any Objective-C ancestry, not just an immediate superclass?

The other cleanups should hopefully be straightforward, they're in support of some class resilience work I'm doing right now.

Copy link
Contributor

@aschwaighofer aschwaighofer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@slavapestov slavapestov merged commit 3788138 into swiftlang:master Aug 7, 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.

2 participants