Skip to content
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

[SR-3726] Define layout algorithm for tuples #46311

Closed
ematejska mannequin opened this issue Jan 25, 2017 · 5 comments
Closed

[SR-3726] Define layout algorithm for tuples #46311

ematejska mannequin opened this issue Jan 25, 2017 · 5 comments
Labels
affects ABI Flag: Affects ABI task

Comments

@ematejska
Copy link
Mannequin

ematejska mannequin commented Jan 25, 2017

Previous ID SR-3726
Radar rdar://problem/34141063
Original Reporter @ematejska
Type Task
Status Resolved
Resolution Won't Do
Additional Detail from JIRA
Votes 0
Component/s
Labels Task, AffectsABI
Assignee None
Priority Medium

md5: 49f72855cd0ebf30564d52987c7d03f6

Issue Description:

Ahead of ABI stability, consider if tuple elements are bit-packed to save space.

Updated

This issue should track the overall data layout for tuples. Here is the relevant text from the ABI manifesto:

Tuples are similar to anonymous structs, but they differ in that they exhibit structural subtyping: a tuple of type e.g. (Bool, Bool) can be passed anywhere expecting generic types (T, U). But, the type (T, U) exists at a higher abstraction level than (Bool, Bool). Due to this, tuples may face more expensive reabstraction costs if their layout is aggressively packed. Reabstracting such a tuple would involve splitting and promoting each element into their own addresses.

This may be an argument for a simple, declaration-order, non bit-packed layout algorithm for tuples. Tuples are often used for small local values and rarely persisted across ABI boundaries in a way that aggressive packing is performance-critical. This would also be more consistent with how fixed-size C arrays are presented in Swift, which are imported as tuples.

We should investigate whether to aggressively bit-pack tuple elements similarly to structs, paying the reabstraction costs, or if the benefits are not worth the costs [SR-3726].

Tuples should be binary compatible between labeled and unlabeled tuples of the same type and structure.

@bob-wilson
Copy link

@swift-ci create

@bob-wilson
Copy link

SR-3725 is about structs; this one is about tuples.

@belkadan
Copy link
Contributor

We've previously promised that homogeneous tuples of C types will have C layout, so we can't bitpack (Bool, Bool, Bool). @rjmccall has been inclined to extend that to just make tuples use C layout all the time, but I don't know if we've formally promised that yet.

@rjmccall
Copy link
Member

The layout of tuples is formally promised.

@bob-wilson
Copy link

OK, so we can't bit pack tuples and do not plan any other changes for tuple layout in Swift 5. The only thing left is to document the layout algorithm and we can track that in SR-3730

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects ABI Flag: Affects ABI task
Projects
None yet
Development

No branches or pull requests

3 participants