-
Notifications
You must be signed in to change notification settings - Fork 10.5k
NCGenerics: New Inverse Mangling 3DS XL #71878
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
Conversation
@swift-ci smoke test |
preset=ncgenerics,smoketest=macosx |
17cb5cd
to
0af627b
Compare
@swift-ci test |
0af627b
to
a91fea5
Compare
@swift-ci test |
31146b7
to
9521098
Compare
@swift-ci smoke test |
1 similar comment
@swift-ci smoke test |
d94cb78
to
a981a53
Compare
@@ -925,13 +1012,19 @@ now codified into the ABI; the index 0 is therefore reserved. | |||
|
|||
generic-param-pack-marker ::= 'Rv' GENERIC_PARAM-INDEX // generic parameter pack marker | |||
|
|||
INVERTIBLE-KIND ::= 'c' // Copyable | |||
INVERTIBLE-KIND ::= 'e' // Escapable |
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.
I don't think we should bake the invertible protocols we know about into the mangling scheme. Rather, I think we should mangle an "inverted conformance requirement" and add standard substitutions for Copyable and Escapable to keep it smaller.
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.
I considered that approach and would support it. I just went with this current approach as it was simple to sketch out.
GENERIC-PARAM-COUNT ::= 'z' // zero parameters | ||
GENERIC-PARAM-COUNT ::= INDEX // N+1 parameters | ||
|
||
requirement ::= protocol 'R' GENERIC-PARAM-INDEX // protocol requirement | ||
requirement ::= protocol assoc-type-name 'Rp' GENERIC-PARAM-INDEX // protocol requirement on associated type | ||
requirement ::= protocol assoc-type-list 'RP' GENERIC-PARAM-INDEX // protocol requirement on associated type at depth | ||
requirement ::= protocol substitution 'RQ' // protocol requirement with substitution | ||
#if SWIFT_RUNTIME_VERSION >= 6.0 | ||
requirement ::= 'Ri' INVERTIBLE-KIND GENERIC-PARAM-INDEX // inverse requirement |
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.
We'll also need a version that works with associated types, I presume?
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.
Yes I believe we'll need them.
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.
@slavapestov seems to think we won’t need them
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.
Currently the only place in the language where you can state T: ~Copyable
with T
a dependent member type is inside of a protocol, eg
protocol P {
associatedtype A: ~Copyable
}
I was thinking that for symbol mangling, we don't ever need this because the requirement signature is not mangled as part of any symbol. However, now that I think about it I do believe we mangle the requirement signature in the protocol's context descriptor. So perhaps we need a mangling here after all.
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.
Yes, we do mangle the requirement signature as part of the protocol's context descriptor.
a981a53
to
a07d9eb
Compare
@swift-ci smoke test |
a07d9eb
to
0d19444
Compare
@swift-ci smoke test |
@swift-ci test |
preset=ncgenerics,smoketest=macosx |
0d19444
to
3f03eef
Compare
@swift-ci test |
preset=ncgenerics,smoketest=macosx |
|
3f03eef
to
184ec68
Compare
@swift-ci smoke test |
@swift-ci test platform linux |
@swift-ci Please test Linux platform |
184ec68
to
6ee6527
Compare
@swift-ci smoke test |
preset=ncgenerics,smoketest=macosx |
After implementing mangling for inverses, issues have been revealed.
6ee6527
to
2a1cf37
Compare
@swift-ci smoke test |
@swift-ci smoke test linux |
Initial implementation of mangling for inverse requirements for NoncopyableGenerics. There are some known issues:
(1) Protocols with
~Copyable
have bogus default witness tables. Entries for a default implementation of a method requirement gives this:In general, protocols aren't well tested or fully covered by this PR. As discussion below reveals, we may need an updated mangling scheme to handle associated types.
(2) a number of tests now regress when NoncopyableGenerics is enabled in the compiler:
These have been marked
XFAIL: noncopyable_generics
since they're most likely issues that have been uncovered now that we're mangling inverses.(3) type aliases were left basically as a TODO. I think since they can appear in an extension, and have their own generic signature, we need to be careful about how we mangle them. I have no tests for them yet either.