@@ -584,6 +584,8 @@ struct ASTContext::Implementation {
584
584
}
585
585
586
586
size_t getTotalMemory () const ;
587
+
588
+ void dump (llvm::raw_ostream &out) const ;
587
589
};
588
590
589
591
llvm::DenseMap<ModuleDecl*, ModuleType*> ModuleTypes;
@@ -672,6 +674,8 @@ struct ASTContext::Implementation {
672
674
BuiltinTupleType *TheTupleType = nullptr ;
673
675
674
676
std::array<ProtocolDecl *, NumInvertibleProtocols> InvertibleProtocolDecls = {};
677
+
678
+ void dump (llvm::raw_ostream &out) const ;
675
679
};
676
680
677
681
ASTContext::Implementation::Implementation ()
@@ -803,9 +807,59 @@ ASTContext::ASTContext(
803
807
}
804
808
}
805
809
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
+
806
857
ASTContext::~ASTContext () {
807
- if (LangOpts.AnalyzeRequestEvaluator )
858
+ if (LangOpts.AnalyzeRequestEvaluator ) {
808
859
evaluator.dump (llvm::dbgs ());
860
+ getImpl ().dump (llvm::dbgs ());
861
+ }
862
+
809
863
getImpl ().~Implementation ();
810
864
}
811
865
@@ -3064,6 +3118,56 @@ size_t ASTContext::Implementation::Arena::getTotalMemory() const {
3064
3118
// BuiltinConformances ?
3065
3119
}
3066
3120
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
+
3067
3171
void AbstractFunctionDecl::setForeignErrorConvention (
3068
3172
const ForeignErrorConvention &conv) {
3069
3173
assert (hasThrows () && " setting error convention on non-throwing decl" );
0 commit comments