[ABI] Rework protocol descriptor metadata.

Reimplement protocol descriptors for Swift protocols as a kind of
context descriptor, dropping the Objective-C protocol compatibility
layout. The new protocol descriptors have several advantages over the
current implementation:

* They drop all of the unused fields required for layout-compatibility
  with Objective-C protocols.
* They encode the full requirement signature of the protocol. This
  maintains more information about the protocol itself, including
  (e.g.) correctly encoding superclass requirements.
* They fit within the general scheme of context descriptors, rather than
  being their own thing, which allows us to share more code with
  nominal type descriptors.
* They only use relative pointers, so they’re smaller and can be placed
  in read-only memory

 Implements rdar://problem/38815359.
This commit is contained in:
Doug Gregor
2018-07-23 17:01:13 -07:00
parent c56879da73
commit a54a6d8d7f
21 changed files with 528 additions and 550 deletions

View File

@@ -32,22 +32,9 @@ using namespace swift;
#ifndef NDEBUG
template <> void ProtocolDescriptor::dump() const {
unsigned NumInheritedProtocols =
InheritedProtocols ? InheritedProtocols->NumProtocols : 0;
printf("TargetProtocolDescriptor.\n"
"Name: \"%s\".\n"
"ObjC Isa: %p.\n",
Name, _ObjC_Isa);
Flags.dump();
printf("Has Inherited Protocols: %s.\n",
(NumInheritedProtocols ? "true" : "false"));
if (NumInheritedProtocols) {
printf("Inherited Protocol List:\n");
for (unsigned i = 0, e = NumInheritedProtocols; i != e; ++i) {
printf("%s\n", (*InheritedProtocols)[i]->Name);
}
}
"Name: \"%s\".\n",
Name.get());
}
void ProtocolDescriptorFlags::dump() const {