mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[ABI] Optimize out the witness table pattern for resilient conformances.
Resilient conformances now put all witnesses into the resilient witness table, so optimize away the witness table pattern for such cases. Teach the runtime to fill in the protocol conformance descriptor, because that’s the only bit of real information that would be in the pattern. This is a minor optimization enabled by rdar://problem/46282080.
This commit is contained in:
@@ -4069,12 +4069,18 @@ WitnessTableCacheEntry::allocate(
|
||||
// Advance the address point; the private storage area is accessed via
|
||||
// negative offsets.
|
||||
auto table = fullTable + privateSizeInWords;
|
||||
auto pattern = reinterpret_cast<void * const *>(
|
||||
&*conformance->getWitnessTablePattern());
|
||||
|
||||
// Fill in the provided part of the requirements from the pattern.
|
||||
for (size_t i = 0, e = numPatternWitnesses; i < e; ++i) {
|
||||
table[i] = pattern[i];
|
||||
if (auto pattern =
|
||||
reinterpret_cast<void * const *>(
|
||||
&*conformance->getWitnessTablePattern())) {
|
||||
// Fill in the provided part of the requirements from the pattern.
|
||||
for (size_t i = 0, e = numPatternWitnesses; i < e; ++i) {
|
||||
table[i] = pattern[i];
|
||||
}
|
||||
} else {
|
||||
// Put the conformance descriptor in place. Instantiation will fill in the
|
||||
// rest.
|
||||
assert(numPatternWitnesses == 0);
|
||||
table[0] = (void *)conformance;
|
||||
}
|
||||
|
||||
// Copy any instantiation arguments that correspond to conditional
|
||||
|
||||
Reference in New Issue
Block a user