-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[WIP] [Mangling] Mangle more standard substitutions #17290
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
[WIP] [Mangling] Mangle more standard substitutions #17290
Conversation
@eeckstein With the new substitution mangling scheme, is |
It seems useful to me to reserve some expansion capacity—for example, S_XY could mean "standard substitution of length 2, value XY". Even without that there's still a few letters left. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this is silly of me but I'd prefer if the letters lined up with the protocols as much as possible too, like they do for many of the structs.
STANDARD_TYPE(Protocol, B, BinaryFloatingPoint)
STANDARD_TYPE(Protocol, C, Character) // not actually a protocol??
STANDARD_TYPE(Protocol, E, Encodable)
STANDARD_TYPE(Protocol, e, Decodable) // to go with Encodable; Set becomes 'h', to go with Hashable
STANDARD_TYPE(Protocol, F, FloatingPoint)
STANDARD_TYPE(Protocol, G, RandomNumberGenerator)
// 'g' is open
STANDARD_TYPE(Protocol, H, Hashable)
// 'h' for Set, to go with Hashable
// 'J' is open
STANDARD_TYPE(Protocol, j, Numeric) // a stretch, comes from i-j-k as indexes
STANDARD_TYPE(Protocol, K, BidirectionalCollection) // "kollection", plus pairing with RAC
STANDARD_TYPE(Protocol, k, RandomAccessCollection) // "kollection", plus pairing with BC
STANDARD_TYPE(Protocol, L, Comparable) // "less than"
STANDARD_TYPE(Protocol, l, Collection) // co'l'lection, plus right before MC
STANDARD_TYPE(Protocol, M, MutableCollection)
STANDARD_TYPE(Protocol, m, RangeReplaceableCollection) // pairing with MC
// 'o' is open
STANDARD_TYPE(Protocol, Q, Equatable) // e'q'uatable
STANDARD_TYPE(Protocol, T, Sequence) // pairing with IteratorProtocol
STANDARD_TYPE(Protocol, t, IteratorProtocol) // i't'erator
STANDARD_TYPE(Protocol, U, UnsignedInteger)
STANDARD_TYPE(Protocol, X, RangeExpression) // e'x'pression
STANDARD_TYPE(Protocol, x, Strideable) // pairing with RangeExpression
STANDARD_TYPE(Protocol, Y, RawRepresentable) // arbitrary
STANDARD_TYPE(Protocol, y, StringProtocol) // arbitrary
STANDARD_TYPE(Protocol, Z, BinaryInteger) // Z, from math
STANDARD_TYPE(Protocol, z, SignedInteger) // Z, from math
STANDARD_TYPE(Protocol, j, Equatable) | ||
STANDARD_TYPE(Protocol, K, Comparable) | ||
STANDARD_TYPE(Protocol, k, Hashable) | ||
STANDARD_TYPE(Protocol, L, Character) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a struct, isn't it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yikes! It is a struct, thank you.
Did you look at what impact this has on binary sizes on a corpus like the compatibility suite? The effect on standard library binary size may not be representative due to the fact that these types are all defined there, but the standard library's size is somewhat less important in the future for Apple platforms when it's in the shared cache. |
I did not look at binary sizes across the compatibility suite. I'm going to call "perfect is the enemy of the good" on this optimization problem and focus on getting it merged. Y'all didn't comment on the (de-/re-/)mangler code changes ;) |
Sigh, I'm taking @jrose-apple 's attempt at lining up letters with names, though. Updates coming. |
Note that |
@DougGregor Sorry, I didn't mean to raise the issue saying you should redo your work or try to adapt the set of substitutions based on some statistical model or anything like that, only that I think the size savings there would be a more interesting and compelling message than the size impact on the stdlib alone. |
Okay, okay, I'll admit I'm not sure why some of those manglings are disallowing the standard substitutions, and comments as to why would be nice. |
In that case I suggest 'g' for "grapheme cluster" for Character. |
type ::= type 'Sg' // optional type, shortcut for: type 'ySqG' |
99b1a28
to
6b8c802
Compare
…I guess that makes it 'J', and the alphabet is filled after all! |
…ypes. Since the mangling scheme and set of standard library types is effectively fixed now, introduce known mangling substitutions for a number of new standard library types, filling out the S[A-Za-z] space. Reduces standard library binary size by ~195k.
Protocol name mangling didn’t always go through a path that allowed the use of standard substitutions. Enable standard substitutions for protocol name manglings where they make sense. Removes ~277k from the standard library binary size.
6b8c802
to
a66df57
Compare
@swift-ci please test |
@swift-ci please test source compatibility |
@swift-ci please test |
@swift-ci please test source compatibility |
lgtm |
Introduce more standard substitutions to the mangling scheme, to better compress manglings that involve common standard library types.
Implements rdar://problem/40468532.
Note: This shaves ~472k off the size of the unstripped standard library binary.