Skip to content

Commit dd154f6

Browse files
committed
[Runtime] Rename swift_instantiateWitnessTable() -> swift_getWitnessTable()
This runtime function doesn’t always perform instantiation; it’s how we get a witness table given a conformance, type, and set of instantiation arguments. Name it accordingly.
1 parent b5bc06e commit dd154f6

File tree

7 files changed

+20
-26
lines changed

7 files changed

+20
-26
lines changed

include/swift/Runtime/Metadata.h

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -385,18 +385,13 @@ SWIFT_RUNTIME_EXPORT SWIFT_CC(swift)
385385
MetadataResponse swift_checkMetadataState(MetadataRequest request,
386386
const Metadata *type);
387387

388-
/// Instantiate a resilient or generic protocol witness table.
388+
/// Retrieve a witness table based on a given conformance.
389389
///
390390
/// \param conformance - The protocol conformance descriptor, which
391-
/// contains the generic witness table record. It may either have fields
392-
/// that require runtime initialization, or be missing requirements at the
393-
/// end for which default witnesses are available.
391+
/// contains any information required to form the witness table.
394392
///
395393
/// \param type - The conforming type, used to form a uniquing key
396-
/// for the conformance. If the witness table is not dependent on
397-
/// the substituted type of the conformance, this can be set to
398-
/// nullptr, in which case there will only be one instantiated
399-
/// witness table per witness table template.
394+
/// for the conformance.
400395
///
401396
/// \param instantiationArgs - An opaque pointer that's forwarded to
402397
/// the instantiation function, used for conditional conformances.
@@ -406,9 +401,9 @@ MetadataResponse swift_checkMetadataState(MetadataRequest request,
406401
/// conformances.
407402
SWIFT_RUNTIME_EXPORT
408403
const WitnessTable *
409-
swift_instantiateWitnessTable(const ProtocolConformanceDescriptor *conformance,
410-
const Metadata *type,
411-
const void * const *instantiationArgs);
404+
swift_getWitnessTable(const ProtocolConformanceDescriptor *conformance,
405+
const Metadata *type,
406+
const void * const *instantiationArgs);
412407

413408
/// Retrieve an associated type witness from the given witness table.
414409
///

include/swift/Runtime/RuntimeFunctions.def

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -625,10 +625,10 @@ FUNCTION(CheckMetadataState, swift_checkMetadataState, SwiftCC,
625625
ATTRS(NoUnwind, ReadOnly))
626626

627627
// const ProtocolWitnessTable *
628-
// swift_instantiateWitnessTable(const ProtocolConformanceDescriptor *conf,
629-
// const Metadata *type,
630-
// const void * const *instantiationArgs);
631-
FUNCTION(InstantiateWitnessTable, swift_instantiateWitnessTable, C_CC,
628+
// swift_getWitnessTable(const ProtocolConformanceDescriptor *conf,
629+
// const Metadata *type,
630+
// const void * const *instantiationArgs);
631+
FUNCTION(GetWitnessTable, swift_getWitnessTable, C_CC,
632632
RETURNS(WitnessTablePtrTy),
633633
ARGS(ProtocolConformanceDescriptorPtrTy,
634634
TypeMetadataPtrTy,

lib/IRGen/GenProto.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1074,7 +1074,7 @@ static llvm::Value *emitWitnessTableAccessorCall(
10741074
auto conditionalTables =
10751075
emitConditionalConformancesBuffer(IGF, conformance);
10761076

1077-
auto call = IGF.Builder.CreateCall(IGF.IGM.getInstantiateWitnessTableFn(),
1077+
auto call = IGF.Builder.CreateCall(IGF.IGM.getGetWitnessTableFn(),
10781078
{conformanceDescriptor, *srcMetadataCache,
10791079
conditionalTables});
10801080

stdlib/public/runtime/ErrorObject.mm

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -250,17 +250,17 @@ static ErrorBridgingInfo getErrorBridgingInfo() {
250250
assert(conformance &&
251251
"Foundation overlay not loaded, or 'CFError : Error' conformance "
252252
"not available");
253-
return swift_instantiateWitnessTable(conformance,
254-
conformance->getCanonicalTypeMetadata(),
255-
nullptr);
253+
return swift_getWitnessTable(conformance,
254+
conformance->getCanonicalTypeMetadata(),
255+
nullptr);
256256
}
257257

258258
static const HashableWitnessTable *getNSErrorConformanceToHashable() {
259259
auto conformance = getErrorBridgingInfo().NSObjectHashableConformance;
260260
assert(conformance &&
261261
"ObjectiveC overlay not loaded, or 'NSObject : Hashable' conformance "
262262
"not available");
263-
return (const HashableWitnessTable *)swift_instantiateWitnessTable(
263+
return (const HashableWitnessTable *)swift_getWitnessTable(
264264
conformance,
265265
conformance->getCanonicalTypeMetadata(),
266266
nullptr);

stdlib/public/runtime/Metadata.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3962,10 +3962,9 @@ WitnessTableCacheEntry::allocate(
39623962
}
39633963

39643964
const WitnessTable *
3965-
swift::swift_instantiateWitnessTable(
3966-
const ProtocolConformanceDescriptor *conformance,
3967-
const Metadata *type,
3968-
const void * const *instantiationArgs) {
3965+
swift::swift_getWitnessTable(const ProtocolConformanceDescriptor *conformance,
3966+
const Metadata *type,
3967+
const void * const *instantiationArgs) {
39693968
/// Local function to unique a foreign witness table, if needed.
39703969
auto uniqueForeignWitnessTableRef =
39713970
[conformance, type](const WitnessTable *candidate)

stdlib/public/runtime/ProtocolConformance.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ ProtocolConformanceDescriptor::getWitnessTable(const Metadata *type) const {
167167
if (failed) return nullptr;
168168
}
169169

170-
return swift_instantiateWitnessTable(this, type, conditionalArgs.data());
170+
return swift_getWitnessTable(this, type, conditionalArgs.data());
171171
}
172172

173173
namespace {

validation-test/stdlib/MicroStdlib/Inputs/RuntimeStubs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ void swift_allocateGenericValueMetadata(void) {}
1414
void swift_initEnumMetadataSinglePayload(void) {}
1515
void swift_retain(){}
1616
void swift_allocBox(){}
17-
void swift_instantiateWitnessTable(void) {}
17+
void swift_getWitnessTable(void) {}

0 commit comments

Comments
 (0)