Skip to content

Commit 09da198

Browse files
committed
Add ExternalTypeInfoProvider the the key of the ReflectionContext TypeInfo cache
This change is analogous to the TypeInfo cache in TypeLowering, which does the exact same thing. In LLDB the ExternalTypeInfoProvider may gain new information throughout the life of a process, and more importantly, it may return context-dependent results. rdar://122432501
1 parent 8621508 commit 09da198

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

include/swift/RemoteInspection/ReflectionContext.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,10 @@ class ReflectionContext
122122
using super::readMetadata;
123123
using super::readObjCClassName;
124124
using super::readResolvedPointerValue;
125-
llvm::DenseMap<typename super::StoredPointer, const RecordTypeInfo *> Cache;
125+
llvm::DenseMap<std::pair<typename super::StoredPointer,
126+
remote::TypeInfoProvider::IdType>,
127+
const RecordTypeInfo *>
128+
Cache;
126129

127130
/// All buffers we need to keep around long term. This will automatically free them
128131
/// when this object is destroyed.
@@ -892,7 +895,8 @@ class ReflectionContext
892895
getMetadataTypeInfo(StoredPointer MetadataAddress,
893896
remote::TypeInfoProvider *ExternalTypeInfo) {
894897
// See if we cached the layout already
895-
auto found = Cache.find(MetadataAddress);
898+
auto ExternalTypeInfoId = ExternalTypeInfo ? ExternalTypeInfo->getId() : 0;
899+
auto found = Cache.find({MetadataAddress, ExternalTypeInfoId});
896900
if (found != Cache.end())
897901
return found->second;
898902

@@ -922,7 +926,7 @@ class ReflectionContext
922926
}
923927

924928
// Cache the result for future lookups
925-
Cache[MetadataAddress] = TI;
929+
Cache[{MetadataAddress, ExternalTypeInfoId}] = TI;
926930
return TI;
927931
}
928932

0 commit comments

Comments
 (0)