Skip to content

[WIP] Protocol conformance decoder #39246

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

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

al45tair
Copy link
Contributor

@al45tair al45tair commented Sep 10, 2021

Add support for protocol conformance demangling.

rdar://46280860

@al45tair al45tair marked this pull request as draft September 10, 2021 14:11
@slavapestov
Copy link
Contributor

Cool!

jckarter and others added 8 commits September 28, 2021 15:08
This was much easier to understand with an example to look at.  Add
the example to the documentation to help future readers.
This is to match the decodeMangledType function that already exists.
For protocol conformance demangling, we will need to be able to fetch a
ProtocolConformanceDescriptor given a protocol and a type that might conform
to that protocol.  Add a function to do that, as well as a cache for that
function's results.

rdar://46280860
MetadataReader should expose the builder's protocol conformance related types,
and should provide a method to demangle a mangled protocol conformance.

rdar://46280860
Complete the DecodedMetadataBuilder implementation of protocol conformance
demangling.

rdar://46280860
Added:

  * Demangle node types for the various symbolic manglings.
  * SymbolicReferenceKind values for the symbolic manglings.
  * A method on the demangler to demangle a conformance.
  * Support for printing the new node types.
  * Remangler support for the new node types.
  * Code to the runtime to deal with the symbolic references.
  * A private _getAssocWitnessTableFromMangledName() function to use
    from Metadata.cpp.

Use the demangler from swift_getAssociatedConformanceWitnessSlowImpl(),
rather than the existing hack.

Also rebased on current swift/main.

rdar://46280860
@al45tair al45tair force-pushed the protocol-conformance-decoder branch from e3a6bef to 29bc118 Compare September 28, 2021 16:24
…able

swift_unreachable() needs to be a macro, otherwise the message isn't
expanded by the assert() call, and the line number mentioned in the assert()
is the one in the header file, making it rather less useful in figuring
out what went wrong.
The new demangleConformance() method needs to allow the accessor nodes that
are generated by the temporary mangling used in older code.

rdar://46280860
Rather than generating accessor functions, use the new support for demangling.
This also required some changes to the keypath code in the Swift standard
library, which was relying on the symbolic accessor mangling to support witness
tables.

rdar://46280860
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.

3 participants