Skip to content

[IRGen] Reorder generic struct metadata so that field offsets follow … #14232

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 1 commit into from
Jan 29, 2018

Conversation

xedin
Copy link
Contributor

@xedin xedin commented Jan 29, 2018

…generic parameters

Right now, field offsets come before generic arguments in instances
of a struct's metadata. It would be more resilient to put the generic
arguments first, since they're always used by compiler-generated code,
and cannot change resiliently, unlike fields.

Resolves: rdar://problem/36560486

@xedin xedin requested a review from jckarter January 29, 2018 06:29
@xedin
Copy link
Contributor Author

xedin commented Jan 29, 2018

@swift-ci please test

@xedin
Copy link
Contributor Author

xedin commented Jan 29, 2018

@jckarter please take a look, I'm going to try and move from pointer size to uint32_t for field offsets separately.

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - cfa8b82387a87ddf3ad3ffbd515464cc396b5d67

…generic parameters

Right now, field offsets come before generic arguments in instances
of a struct's metadata. It would be more resilient to put the generic
arguments first, since they're always used by compiler-generated code,
and cannot change resiliently, unlike fields.

Resolves: rdar://problem/36560486
@xedin
Copy link
Contributor Author

xedin commented Jan 29, 2018

@swift-ci please test

@swiftlang swiftlang deleted a comment from swift-ci Jan 29, 2018
@swiftlang swiftlang deleted a comment from swift-ci Jan 29, 2018
Copy link
Contributor

@jckarter jckarter 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! Changing the field offsets to 32-bit as a separate patch makes sense to me.

@xedin
Copy link
Contributor Author

xedin commented Jan 29, 2018

@swift-ci please test source compatibility

@xedin
Copy link
Contributor Author

xedin commented Jan 29, 2018

Source compatibility failed with known certificate problems, merging.

@xedin xedin merged commit 9ac1dc8 into swiftlang:master Jan 29, 2018
@slavapestov
Copy link
Contributor

@xedin Can you also add a test to validation-test/Evolution to test this case? Look at the existing tests to see how they work. The setup should be:

  • Library file defines a generic resilient struct with a protocol-constrained parameter
  • Before: a generic resilient struct has N fields
  • After: a generic resilient struct has N+1 fields
  • The test program itself defines an extension that uses type metadata for the generic parameter in some way, perhaps calling a static protocol requirement on the type

This test should fail before your change, because the offset at which the generic arguments are stored will change, causing failures in the after/before and before/after combinations.

Also can you verify that for enums, the generic arguments are always at a fixed offset? Some enum metadata has a field for the payload size, and I don't remember if this comes before or after the generic arguments.

@xedin
Copy link
Contributor Author

xedin commented Jan 30, 2018

@slavapestov Will do!

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.

4 participants