@@ -575,12 +575,6 @@ struct ASTContext::Implementation {
575
575
// / The set of function types.
576
576
llvm::FoldingSet<FunctionType> FunctionTypes;
577
577
578
- // / The set of normal protocol conformances.
579
- llvm::FoldingSet<NormalProtocolConformance> NormalConformances;
580
-
581
- // The set of self protocol conformances.
582
- llvm::DenseMap<ProtocolDecl*, SelfProtocolConformance*> SelfConformances;
583
-
584
578
// / The set of specialized protocol conformances.
585
579
llvm::FoldingSet<SpecializedProtocolConformance> SpecializedConformances;
586
580
@@ -597,9 +591,6 @@ struct ASTContext::Implementation {
597
591
// / The set of substitution maps (uniqued by their storage).
598
592
llvm::FoldingSet<SubstitutionMap::Storage> SubstitutionMaps;
599
593
600
- // / The set of unique AvailabilityContexts (uniqued by their storage).
601
- llvm::FoldingSet<AvailabilityContext::Storage> AvailabilityContexts;
602
-
603
594
~Arena () {
604
595
for (auto &conformance : SpecializedConformances)
605
596
conformance.~SpecializedProtocolConformance ();
@@ -613,11 +604,6 @@ struct ASTContext::Implementation {
613
604
#if SWIFT_COMPILER_IS_MSVC
614
605
#pragma warning (default: 4189)
615
606
#endif
616
-
617
- // Call the normal conformance destructors last since they could be
618
- // referenced by the other conformance types.
619
- for (auto &conformance : NormalConformances)
620
- conformance.~NormalProtocolConformance ();
621
607
}
622
608
623
609
size_t getTotalMemory () const ;
@@ -645,6 +631,11 @@ struct ASTContext::Implementation {
645
631
AutoDiffDerivativeFunctionIdentifiers;
646
632
647
633
llvm::FoldingSet<GenericSignatureImpl> GenericSignatures;
634
+ llvm::FoldingSet<NormalProtocolConformance> NormalConformances;
635
+ llvm::DenseMap<ProtocolDecl*, SelfProtocolConformance*> SelfConformances;
636
+
637
+ // / The set of unique AvailabilityContexts (uniqued by their storage).
638
+ llvm::FoldingSet<AvailabilityContext::Storage> AvailabilityContexts;
648
639
649
640
// / A cache of information about whether particular nominal types
650
641
// / are representable in a foreign language.
@@ -720,6 +711,9 @@ ASTContext::Implementation::Implementation()
720
711
: IdentifierTable(Allocator),
721
712
IntrinsicScratchContext(new llvm::LLVMContext()) {}
722
713
ASTContext::Implementation::~Implementation () {
714
+ for (auto &conformance : NormalConformances)
715
+ conformance.~NormalProtocolConformance ();
716
+
723
717
for (auto &cleanup : Cleanups)
724
718
cleanup ();
725
719
}
@@ -889,6 +883,9 @@ void ASTContext::Implementation::dump(llvm::raw_ostream &os) const {
889
883
SIZE_AND_BYTES (SILMoveOnlyWrappedTypes);
890
884
SIZE_AND_BYTES (BuiltinIntegerTypes);
891
885
SIZE_AND_BYTES (OpenedElementEnvironments);
886
+ SIZE (NormalConformances);
887
+ SIZE (SelfConformances);
888
+ SIZE (AvailabilityContexts);
892
889
SIZE_AND_BYTES (ForeignRepresentableCache);
893
890
SIZE (SearchPathsSet);
894
891
@@ -2912,15 +2909,14 @@ ASTContext::getNormalConformance(Type conformingType,
2912
2909
2913
2910
// Did we already record the normal conformance?
2914
2911
void *insertPos;
2915
- auto &normalConformances =
2916
- getImpl ().getArena (AllocationArena::Permanent).NormalConformances ;
2912
+ auto &normalConformances = getImpl ().NormalConformances ;
2917
2913
if (auto result = normalConformances.FindNodeOrInsertPos (id, insertPos))
2918
2914
return result;
2919
2915
2920
2916
// Build a new normal protocol conformance.
2921
- auto result = new (*this , AllocationArena::Permanent)
2922
- NormalProtocolConformance ( conformingType, protocol, loc, dc, state,
2923
- options, preconcurrencyLoc);
2917
+ auto result = new (*this ) NormalProtocolConformance (
2918
+ conformingType, protocol, loc, dc, state,
2919
+ options, preconcurrencyLoc);
2924
2920
normalConformances.InsertNode (result, insertPos);
2925
2921
2926
2922
return result;
@@ -2929,12 +2925,11 @@ ASTContext::getNormalConformance(Type conformingType,
2929
2925
// / Produce a self-conformance for the given protocol.
2930
2926
SelfProtocolConformance *
2931
2927
ASTContext::getSelfConformance (ProtocolDecl *protocol) {
2932
- auto &selfConformances =
2933
- getImpl ().getArena (AllocationArena::Permanent).SelfConformances ;
2928
+ auto &selfConformances = getImpl ().SelfConformances ;
2934
2929
auto &entry = selfConformances[protocol];
2935
2930
if (!entry) {
2936
- entry = new (*this , AllocationArena::Permanent)
2937
- SelfProtocolConformance ( protocol->getDeclaredExistentialType ());
2931
+ entry = new (*this ) SelfProtocolConformance (
2932
+ protocol->getDeclaredExistentialType ());
2938
2933
}
2939
2934
return entry;
2940
2935
}
@@ -3274,6 +3269,9 @@ size_t ASTContext::getTotalMemory() const {
3274
3269
// getImpl().GenericSignatures ?
3275
3270
// getImpl().CompoundNames ?
3276
3271
// getImpl().IntegerTypes ?
3272
+ // getImpl().NormalConformances ?
3273
+ // getImpl().SelfConformances ?
3274
+ // getImpl().AvailabilityContexts
3277
3275
getImpl ().Permanent .getTotalMemory ();
3278
3276
3279
3277
Size += getSolverMemory ();
@@ -3315,7 +3313,6 @@ size_t ASTContext::Implementation::Arena::getTotalMemory() const {
3315
3313
// FunctionTypes ?
3316
3314
// UnboundGenericTypes ?
3317
3315
// BoundGenericTypes ?
3318
- // NormalConformances ?
3319
3316
// SpecializedConformances ?
3320
3317
// InheritedConformances ?
3321
3318
// BuiltinConformances ?
@@ -3360,14 +3357,11 @@ void ASTContext::Implementation::Arena::dump(llvm::raw_ostream &os) const {
3360
3357
SIZE_AND_BYTES (OpaqueArchetypeEnvironments);
3361
3358
SIZE_AND_BYTES (OpenedExistentialEnvironments);
3362
3359
SIZE (FunctionTypes);
3363
- SIZE (NormalConformances);
3364
- SIZE (SelfConformances);
3365
3360
SIZE (SpecializedConformances);
3366
3361
SIZE (InheritedConformances);
3367
3362
SIZE_AND_BYTES (BuiltinConformances);
3368
3363
SIZE (PackConformances);
3369
3364
SIZE (SubstitutionMaps);
3370
- SIZE (AvailabilityContexts);
3371
3365
3372
3366
#undef SIZE
3373
3367
#undef SIZE_AND_BYTES
@@ -5720,8 +5714,7 @@ const AvailabilityContext::Storage *AvailabilityContext::Storage::get(
5720
5714
AvailabilityContext::Storage::Profile (id, platformRange, isDeprecated,
5721
5715
domainInfos);
5722
5716
5723
- auto &foldingSet =
5724
- ctx.getImpl ().getArena (AllocationArena::Permanent).AvailabilityContexts ;
5717
+ auto &foldingSet = ctx.getImpl ().AvailabilityContexts ;
5725
5718
void *insertPos;
5726
5719
auto *existing = foldingSet.FindNodeOrInsertPos (id, insertPos);
5727
5720
if (existing)
0 commit comments