48
48
#define SHARED_CACHE_LOG (fmt, ...) (void )0
49
49
#endif
50
50
51
+ // Enable dyld shared cache acceleration only when it's available and we have
52
+ // ObjC interop.
53
+ #if DYLD_FIND_PROTOCOL_CONFORMANCE_DEFINED && SWIFT_OBJC_INTEROP
54
+ #define USE_DYLD_SHARED_CACHE_CONFORMANCE_TABLES 1
55
+ #endif
56
+
51
57
using namespace swift ;
52
58
53
59
#ifndef NDEBUG
@@ -272,7 +278,7 @@ struct ConformanceState {
272
278
ConcurrentReadableArray<ConformanceSection> SectionsToScan;
273
279
bool scanSectionsBackwards;
274
280
275
- #if DYLD_FIND_PROTOCOL_CONFORMANCE_DEFINED
281
+ #if USE_DYLD_SHARED_CACHE_CONFORMANCE_TABLES
276
282
uintptr_t dyldSharedCacheStart;
277
283
uintptr_t dyldSharedCacheEnd;
278
284
bool hasOverriddenImage;
@@ -291,7 +297,7 @@ struct ConformanceState {
291
297
scanSectionsBackwards =
292
298
runtime::bincompat::workaroundProtocolConformanceReverseIteration ();
293
299
294
- #if DYLD_FIND_PROTOCOL_CONFORMANCE_DEFINED
300
+ #if USE_DYLD_SHARED_CACHE_CONFORMANCE_TABLES
295
301
if (_dyld_swift_optimizations_version () ==
296
302
DYLD_EXPECTED_SWIFT_OPTIMIZATIONS_VERSION) {
297
303
size_t length;
@@ -390,7 +396,7 @@ void swift::addImageProtocolConformanceBlockCallbackUnsafe(
390
396
// Conformance cache should always be sufficiently initialized by this point.
391
397
auto &C = Conformances.unsafeGetAlreadyInitialized ();
392
398
393
- #if DYLD_FIND_PROTOCOL_CONFORMANCE_DEFINED
399
+ #if USE_DYLD_SHARED_CACHE_CONFORMANCE_TABLES
394
400
// If any image in the shared cache is overridden, we need to scan all
395
401
// conformance sections in the shared cache. The pre-built table does NOT work
396
402
// if the protocol, type, or descriptor are in overridden images. Example:
@@ -563,7 +569,7 @@ static void validateSharedCacheResults(
563
569
const ProtocolDescriptor *protocol,
564
570
const WitnessTable *dyldCachedWitnessTable,
565
571
const ProtocolConformanceDescriptor *dyldCachedConformanceDescriptor) {
566
- #if DYLD_FIND_PROTOCOL_CONFORMANCE_DEFINED
572
+ #if USE_DYLD_SHARED_CACHE_CONFORMANCE_TABLES
567
573
if (!C.validateSharedCacheResults )
568
574
return ;
569
575
@@ -625,7 +631,7 @@ static std::tuple<const WitnessTable *, const ProtocolConformanceDescriptor *,
625
631
bool >
626
632
findSharedCacheConformance (ConformanceState &C, const Metadata *type,
627
633
const ProtocolDescriptor *protocol) {
628
- #if DYLD_FIND_PROTOCOL_CONFORMANCE_DEFINED
634
+ #if USE_DYLD_SHARED_CACHE_CONFORMANCE_TABLES
629
635
const ContextDescriptor *description;
630
636
llvm::StringRef foreignTypeIdentity;
631
637
std::tie (description, foreignTypeIdentity) = getContextDescriptor (type);
0 commit comments