Skip to content

runtime: conditionally generate relative protocol witness tables entry points #63412

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

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion include/swift/Runtime/Metadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -354,11 +354,13 @@ swift_getWitnessTable(const ProtocolConformanceDescriptor *conformance,
const Metadata *type,
const void * const *instantiationArgs);

#if SWIFT_STDLIB_USE_RELATIVE_PROTOCOL_WITNESS_TABLES
SWIFT_RUNTIME_EXPORT
const RelativeWitnessTable *
swift_getWitnessTableRelative(const ProtocolConformanceDescriptor *conformance,
const Metadata *type,
const void * const *instantiationArgs);
#endif

/// Retrieve an associated type witness from the given witness table.
///
Expand All @@ -375,14 +377,15 @@ MetadataResponse swift_getAssociatedTypeWitness(
const Metadata *conformingType,
const ProtocolRequirement *reqBase,
const ProtocolRequirement *assocType);
#if SWIFT_STDLIB_USE_RELATIVE_PROTOCOL_WITNESS_TABLES
SWIFT_RUNTIME_EXPORT SWIFT_CC(swift)
MetadataResponse swift_getAssociatedTypeWitnessRelative(
MetadataRequest request,
RelativeWitnessTable *wtable,
const Metadata *conformingType,
const ProtocolRequirement *reqBase,
const ProtocolRequirement *assocType);

#endif
/// Retrieve an associated conformance witness table from the given witness
/// table.
///
Expand All @@ -401,13 +404,15 @@ const WitnessTable *swift_getAssociatedConformanceWitness(
const ProtocolRequirement *reqBase,
const ProtocolRequirement *assocConformance);

#if SWIFT_STDLIB_USE_RELATIVE_PROTOCOL_WITNESS_TABLES
SWIFT_RUNTIME_EXPORT SWIFT_CC(swift)
const RelativeWitnessTable *swift_getAssociatedConformanceWitnessRelative(
RelativeWitnessTable *wtable,
const Metadata *conformingType,
const Metadata *assocType,
const ProtocolRequirement *reqBase,
const ProtocolRequirement *assocConformance);
#endif

/// Determine whether two protocol conformance descriptors describe the same
/// conformance of a type to a protocol.
Expand Down
6 changes: 6 additions & 0 deletions stdlib/public/runtime/Metadata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5368,6 +5368,7 @@ swift::swift_getWitnessTable(const ProtocolConformanceDescriptor *conformance,
return uniqueForeignWitnessTableRef(result.second);
}

#if SWIFT_STDLIB_USE_RELATIVE_PROTOCOL_WITNESS_TABLES
namespace {

/// A cache-entry type suitable for use with LockingConcurrentMap.
Expand Down Expand Up @@ -5644,6 +5645,7 @@ swift::swift_getWitnessTableRelative(const ProtocolConformanceDescriptor *confor
return reinterpret_cast<RelativeWitnessTable*>(((uintptr_t)table) |
(uintptr_t)0x1);
}
#endif

/// Find the name of the associated type with the given descriptor.
static StringRef findAssociatedTypeName(const ProtocolDescriptor *protocol,
Expand Down Expand Up @@ -5858,6 +5860,7 @@ RelativeWitnessTable *swift::lookThroughOptionalConditionalWitnessTable(
return table;
}

#if SWIFT_STDLIB_USE_RELATIVE_PROTOCOL_WITNESS_TABLES
SWIFT_CC(swift)
static MetadataResponse
swift_getAssociatedTypeWitnessRelativeSlowImpl(
Expand Down Expand Up @@ -5954,6 +5957,7 @@ swift::swift_getAssociatedTypeWitnessRelative(MetadataRequest request,
conformingType, reqBase,
assocType);
}
#endif

using AssociatedConformanceWitness = std::atomic<void *>;

Expand Down Expand Up @@ -6098,6 +6102,7 @@ const WitnessTable *swift::swift_getAssociatedConformanceWitness(
assocConformance);
}

#if SWIFT_STDLIB_USE_RELATIVE_PROTOCOL_WITNESS_TABLES
SWIFT_CC(swift)
static const RelativeWitnessTable *swift_getAssociatedConformanceWitnessRelativeSlowImpl(
RelativeWitnessTable *wtable,
Expand Down Expand Up @@ -6186,6 +6191,7 @@ const RelativeWitnessTable *swift::swift_getAssociatedConformanceWitnessRelative
assocType, reqBase,
assocConformance);
}
#endif

bool swift::swift_compareProtocolConformanceDescriptors(
const ProtocolConformanceDescriptor *lhs,
Expand Down