@@ -584,6 +584,8 @@ struct ASTContext::Implementation {
584584 }
585585
586586 size_t getTotalMemory () const ;
587+
588+ void dump (llvm::raw_ostream &out) const ;
587589 };
588590
589591 llvm::DenseMap<ModuleDecl*, ModuleType*> ModuleTypes;
@@ -672,6 +674,8 @@ struct ASTContext::Implementation {
672674 BuiltinTupleType *TheTupleType = nullptr ;
673675
674676 std::array<ProtocolDecl *, NumInvertibleProtocols> InvertibleProtocolDecls = {};
677+
678+ void dump (llvm::raw_ostream &out) const ;
675679};
676680
677681ASTContext::Implementation::Implementation ()
@@ -803,9 +807,59 @@ ASTContext::ASTContext(
803807 }
804808}
805809
810+ void ASTContext::Implementation::dump (llvm::raw_ostream &os) const {
811+ os << " -------------------------------------------------\n " ;
812+ os << " Arena\t 0\t " << Allocator.getBytesAllocated () << " \n " ;
813+ Permanent.dump (os);
814+
815+ #define SIZE (Name ) os << #Name << " \t " << Name.size() << " \t 0\n "
816+ #define SIZE_AND_BYTES (Name ) os << #Name << " \t " \
817+ << Name.size () << " \t " \
818+ << llvm::capacity_in_bytes (Name) << " \n "
819+
820+ SIZE (LoadedModules);
821+ SIZE (IdentifierTable);
822+ SIZE (Cleanups);
823+ SIZE_AND_BYTES (ModuleLoaders);
824+ SIZE_AND_BYTES (ExternalSourceLocs);
825+ SIZE_AND_BYTES (ForeignErrorConventions);
826+ SIZE_AND_BYTES (ForeignAsyncConventions);
827+ SIZE_AND_BYTES (AssociativityCache);
828+ SIZE_AND_BYTES (DelayedConformanceDiags);
829+ SIZE_AND_BYTES (LazyContexts);
830+ SIZE_AND_BYTES (ExistentialSignatures);
831+ SIZE_AND_BYTES (ElementSignatures);
832+ SIZE_AND_BYTES (Overrides);
833+ SIZE_AND_BYTES (DefaultWitnesses);
834+ SIZE_AND_BYTES (DefaultTypeWitnesses);
835+ SIZE_AND_BYTES (DefaultAssociatedConformanceWitnesses);
836+ SIZE_AND_BYTES (DefaultTypeRequestCaches);
837+ SIZE_AND_BYTES (PropertyWrapperBackingVarTypes);
838+ SIZE_AND_BYTES (OriginalWrappedProperties);
839+ SIZE_AND_BYTES (BuiltinInitWitness);
840+ SIZE_AND_BYTES (OriginalBodySourceRanges);
841+ SIZE_AND_BYTES (NextMacroDiscriminator);
842+ SIZE_AND_BYTES (NextDiscriminator);
843+ SIZE_AND_BYTES (ModuleTypes);
844+ SIZE_AND_BYTES (GenericParamTypes);
845+ SIZE_AND_BYTES (SILBlockStorageTypes);
846+ SIZE_AND_BYTES (SILMoveOnlyWrappedTypes);
847+ SIZE_AND_BYTES (IntegerTypes);
848+ SIZE_AND_BYTES (OpenedExistentialEnvironments);
849+ SIZE_AND_BYTES (OpenedElementEnvironments);
850+ SIZE_AND_BYTES (ForeignRepresentableCache);
851+ SIZE (SearchPathsSet);
852+
853+ #undef SIZE
854+ #undef SIZE_AND_BYTES
855+ }
856+
806857ASTContext::~ASTContext () {
807- if (LangOpts.AnalyzeRequestEvaluator )
858+ if (LangOpts.AnalyzeRequestEvaluator ) {
808859 evaluator.dump (llvm::dbgs ());
860+ getImpl ().dump (llvm::dbgs ());
861+ }
862+
809863 getImpl ().~Implementation ();
810864}
811865
@@ -3064,6 +3118,56 @@ size_t ASTContext::Implementation::Arena::getTotalMemory() const {
30643118 // BuiltinConformances ?
30653119}
30663120
3121+ void ASTContext::Implementation::Arena::dump (llvm::raw_ostream &os) const {
3122+ #define SIZE (Name ) os << #Name << " \t " << Name.size() << " \t 0\n "
3123+ #define SIZE_AND_BYTES (Name ) os << #Name << " \t " \
3124+ << Name.size () << " \t " \
3125+ << llvm::capacity_in_bytes (Name) << " \n "
3126+
3127+ SIZE_AND_BYTES (ErrorTypesWithOriginal);
3128+ SIZE (TypeAliasTypes);
3129+ SIZE (TupleTypes);
3130+ SIZE (PackTypes);
3131+ SIZE (PackExpansionTypes);
3132+ SIZE (PackElementTypes);
3133+ SIZE_AND_BYTES (MetatypeTypes);
3134+ SIZE_AND_BYTES (ExistentialMetatypeTypes);
3135+ SIZE_AND_BYTES (ArraySliceTypes);
3136+ SIZE_AND_BYTES (VariadicSequenceTypes);
3137+ SIZE_AND_BYTES (DictionaryTypes);
3138+ SIZE_AND_BYTES (OptionalTypes);
3139+ SIZE_AND_BYTES (ParenTypes);
3140+ SIZE_AND_BYTES (ReferenceStorageTypes);
3141+ SIZE_AND_BYTES (LValueTypes);
3142+ SIZE_AND_BYTES (InOutTypes);
3143+ SIZE_AND_BYTES (DependentMemberTypes);
3144+ SIZE (ErrorUnionTypes);
3145+ SIZE_AND_BYTES (PlaceholderTypes);
3146+ SIZE_AND_BYTES (DynamicSelfTypes);
3147+ SIZE_AND_BYTES (EnumTypes);
3148+ SIZE_AND_BYTES (StructTypes);
3149+ SIZE_AND_BYTES (ClassTypes);
3150+ SIZE_AND_BYTES (ProtocolTypes);
3151+ SIZE_AND_BYTES (ExistentialTypes);
3152+ SIZE (UnboundGenericTypes);
3153+ SIZE (BoundGenericTypes);
3154+ SIZE (ProtocolCompositionTypes);
3155+ SIZE (ParameterizedProtocolTypes);
3156+ SIZE (LayoutConstraints);
3157+ SIZE_AND_BYTES (OpaqueArchetypeEnvironments);
3158+ SIZE (FunctionTypes);
3159+ SIZE (NormalConformances);
3160+ SIZE (SelfConformances);
3161+ SIZE (SpecializedConformances);
3162+ SIZE (InheritedConformances);
3163+ SIZE_AND_BYTES (BuiltinConformances);
3164+ SIZE (PackConformances);
3165+ SIZE (SubstitutionMaps);
3166+
3167+ #undef SIZE
3168+ #undef SIZE_AND_BYTES
3169+ }
3170+
30673171void AbstractFunctionDecl::setForeignErrorConvention (
30683172 const ForeignErrorConvention &conv) {
30693173 assert (hasThrows () && " setting error convention on non-throwing decl" );
@@ -5192,21 +5296,11 @@ void SubstitutionMap::Storage::Profile(
51925296 id.AddPointer (genericSig.getPointer ());
51935297 if (!genericSig) return ;
51945298
5195- // Profile those replacement types that corresponding to canonical generic
5196- // parameters within the generic signature.
5197- id.AddInteger (replacementTypes.size ());
5198-
5199- unsigned i = 0 ;
5200- genericSig->forEachParam ([&](GenericTypeParamType *gp, bool canonical) {
5201- if (canonical)
5202- id.AddPointer (replacementTypes[i].getPointer ());
5203- else
5204- id.AddPointer (nullptr );
5205- ++i;
5206- });
5299+ // Replacement types.
5300+ for (auto replacementType : replacementTypes)
5301+ id.AddPointer (replacementType.getPointer ());
52075302
52085303 // Conformances.
5209- id.AddInteger (conformances.size ());
52105304 for (auto conformance : conformances)
52115305 id.AddPointer (conformance.getOpaqueValue ());
52125306}
0 commit comments