Skip to content

Commit f197c13

Browse files
committed
Runtime: Remove old 'default requirements at the end' mechanism
1 parent 2f0440e commit f197c13

File tree

1 file changed

+17
-24
lines changed

1 file changed

+17
-24
lines changed

stdlib/public/runtime/Metadata.cpp

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3169,22 +3169,26 @@ static GenericWitnessTableCache &getCache(GenericWitnessTable *gen) {
31693169
/// If there's no initializer, no private storage, and all requirements
31703170
/// are present, we don't have to instantiate anything; just return the
31713171
/// witness table template.
3172-
///
3173-
/// Most of the time IRGen should be able to determine this statically;
3174-
/// the one case is with resilient conformances, where the resilient
3175-
/// protocol has not yet changed in a way that's incompatible with the
3176-
/// conformance.
31773172
static bool doesNotRequireInstantiation(GenericWitnessTable *genericTable) {
3178-
if (genericTable->Instantiator.isNull() &&
3179-
genericTable->ResilientWitnesses.isNull() &&
3180-
genericTable->WitnessTablePrivateSizeInWords == 0 &&
3181-
genericTable->WitnessTableSizeInWords ==
3182-
(genericTable->Protocol->NumRequirements +
3183-
WitnessTableFirstRequirementOffset)) {
3184-
return true;
3173+
// If we have resilient witnesses, we require instantiation.
3174+
if (!genericTable->ResilientWitnesses.isNull()) {
3175+
return false;
31853176
}
31863177

3187-
return false;
3178+
// If we don't have resilient witnesses, the template must provide
3179+
// everything.
3180+
assert (genericTable->WitnessTableSizeInWords ==
3181+
(genericTable->Protocol->NumRequirements +
3182+
WitnessTableFirstRequirementOffset));
3183+
3184+
// If we have an instantiation function or private data, we require
3185+
// instantiation.
3186+
if (!genericTable->Instantiator.isNull() ||
3187+
genericTable->WitnessTablePrivateSizeInWords > 0) {
3188+
return false;
3189+
}
3190+
3191+
return true;
31883192
}
31893193

31903194
/// Initialize witness table entries from order independent resilient
@@ -3260,7 +3264,6 @@ WitnessTableCacheEntry::allocate(GenericWitnessTable *genericTable,
32603264
// negative offsets.
32613265
auto table = fullTable + privateSizeInWords;
32623266
auto pattern = reinterpret_cast<void * const *>(&*genericTable->Pattern);
3263-
auto requirements = protocol->Requirements.get();
32643267

32653268
// Fill in the provided part of the requirements from the pattern.
32663269
for (size_t i = 0, e = numPatternWitnesses; i < e; ++i) {
@@ -3270,16 +3273,6 @@ WitnessTableCacheEntry::allocate(GenericWitnessTable *genericTable,
32703273
// Fill in any default requirements.
32713274
if (genericTable->ResilientWitnesses)
32723275
initializeResilientWitnessTable(genericTable, table);
3273-
else {
3274-
for (size_t i = numPatternWitnesses, e = numRequirements; i < e; ++i) {
3275-
size_t requirementIndex = i - WitnessTableFirstRequirementOffset;
3276-
void *defaultImpl =
3277-
requirements[requirementIndex].DefaultImplementation.get();
3278-
assert(defaultImpl &&
3279-
"no default implementation for missing requirement");
3280-
table[i] = defaultImpl;
3281-
}
3282-
}
32833276

32843277
auto castTable = reinterpret_cast<WitnessTable*>(table);
32853278

0 commit comments

Comments
 (0)