Skip to content

Add runtime functions to compute tuple layouts from element layouts #18342

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

Conversation

rjmccall
Copy link
Contributor

Previously, when a tuple type had non-fixed layout, we would compute a layout by building the metadata for that tuple type and then extracting the layout from the VWT. This can be quite expensive because it involves constructing the exact metadata for types like arrays and functions despite those types being fixed-layout across all instantiations. It also tends to cause unnecessary recursive-type issues, especially with enums where tuples are currently used to model cases with mutliple payloads. Since we just need a layout, computing it directly from element layouts instead of constructing metadata for the formal type lets us take advantage of all the other fast paths for layout construction, e.g. for fixed types and single-field aggregates.

This is a good improvement overall, but it also serves to alleviate some of the problems of rdar://40810002 / SR-7876 in a way that might be suitable for integration to 4.2.

@rjmccall rjmccall changed the title Add runtime functions to compute tuple layouts from element layouts. Add runtime functions to compute tuple layouts from element layouts Jul 29, 2018
@rjmccall
Copy link
Contributor Author

@swift-ci Please test.

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 192774fbd0b9492b0553d72489a7f153932274ea

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 192774fbd0b9492b0553d72489a7f153932274ea

Previously, when a tuple type had non-fixed layout, we would compute
a layout by building the metadata for that tuple type and then
extracting the layout from the VWT.  This can be quite expensive
because it involves constructing the exact metadata for types like
arrays and functions despite those types being fixed-layout across
all instantiations.  It also tends to cause unnecessary recursive-type
issues, especially with enums where tuples are currently used to model
cases with mutliple payloads.  Since we just need a layout, computing
it directly from element layouts instead of constructing metadata for
the formal type lets us take advantage of all the other fast paths for
layout construction, e.g. for fixed types and single-field aggregates.

This is a good improvement overall, but it also serves to alleviate
some of the problems of rdar://40810002 / SR-7876 in a way that
might be suitable for integration to 4.2.
@rjmccall rjmccall force-pushed the tuple-layout-from-element-layouts branch from 192774f to 436a8b2 Compare July 29, 2018 22:28
@rjmccall
Copy link
Contributor Author

@swift-ci Please test.

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 192774fbd0b9492b0553d72489a7f153932274ea

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 192774fbd0b9492b0553d72489a7f153932274ea

@rjmccall rjmccall merged commit 23781df into swiftlang:master Jul 30, 2018
@rjmccall rjmccall deleted the tuple-layout-from-element-layouts branch July 30, 2018 01:36
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