Skip to content

Commit de93c3e

Browse files
committed
[Runtime] Skip shared cache protocol conformance queries we know won't succeed.
The shared cache tables can only point to things within the shared cache, so if the protocol, ObjC class, or type descriptor are outside the shared cache, we know that the lookup will fail and we can skip it. rdar://90427793
1 parent 6a08f14 commit de93c3e

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

stdlib/public/runtime/ProtocolConformance.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -802,6 +802,19 @@ static _dyld_protocol_conformance_result getDyldSharedCacheConformance(
802802
ConformanceState &C, const ProtocolDescriptor *protocol,
803803
const ClassMetadata *objcClassMetadata,
804804
const ContextDescriptor *description, llvm::StringRef foreignTypeIdentity) {
805+
// Protocols, classes, and descriptions that aren't in the shared cache will
806+
// never be found in the shared cache conformances. Foreign types are
807+
// non-unique so those can still be found in the shared cache regardless of
808+
// where the we got the identity.
809+
if (!C.inSharedCache(protocol) ||
810+
(objcClassMetadata && !C.inSharedCache(objcClassMetadata)) ||
811+
(description && !C.inSharedCache(description))) {
812+
DYLD_CONFORMANCES_LOG("Skipping shared cache lookup, protocol %p, class "
813+
"%p, or description %p is not in shared cache.",
814+
protocol, objcClassMetadata, description);
815+
return {_dyld_protocol_conformance_result_kind_not_found, nullptr};
816+
}
817+
805818
if (!foreignTypeIdentity.empty()) {
806819
DYLD_CONFORMANCES_LOG(
807820
"_dyld_find_foreign_type_protocol_conformance(%p, %.*s, %zu)", protocol,

0 commit comments

Comments
 (0)